CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/Fireworks/Core/src/FWEveViewManager.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Core
00004 // Class  :     FWEveViewManager
00005 // 
00006 // Implementation:
00007 //     [Notes on implementation]
00008 //
00009 // Original Author:  Chris Jones, Alja Mrak-Tadel
00010 //         Created:  Thu Mar 18 14:11:32 CET 2010
00011 // $Id: FWEveViewManager.cc,v 1.45 2011/03/14 17:57:29 amraktad Exp $
00012 //
00013 
00014 // system include files
00015 
00016 // user include files
00017 #include "TEveManager.h"
00018 #include "TEveSelection.h"
00019 #include "TEveScene.h"
00020 #include "TEveViewer.h"
00021 #include "TEveCalo.h"
00022 #include "TGLViewer.h"
00023 
00024 #include "Fireworks/Core/interface/FWEveViewManager.h"
00025 #include "Fireworks/Core/interface/FWSelectionManager.h"
00026 #include "Fireworks/Core/interface/FWColorManager.h"
00027 #include "Fireworks/Core/interface/Context.h"
00028 #include "Fireworks/Core/interface/FWInteractionList.h"
00029 #include "Fireworks/Core/interface/CmsShowCommon.h"
00030 #include "Fireworks/Core/interface/fwLog.h"
00031 
00032 // PB
00033 #include "Fireworks/Core/interface/FWEDProductRepresentationChecker.h"
00034 #include "Fireworks/Core/interface/FWSimpleRepresentationChecker.h"
00035 #include "Fireworks/Core/interface/FWTypeToRepresentations.h"
00036 #include "Fireworks/Core/interface/FWEventItem.h"
00037 #include "Fireworks/Core/interface/FWProxyBuilderFactory.h"
00038 
00039 // viewes
00040 #include "Fireworks/Core/interface/FWGUIManager.h"
00041 #include "Fireworks/Core/interface/FWISpyView.h"
00042 #include "Fireworks/Core/interface/FW3DView.h"
00043 #include "Fireworks/Core/interface/FWGlimpseView.h"
00044 #include "Fireworks/Core/interface/FWEveLegoView.h"
00045 #include "Fireworks/Core/interface/FWHFView.h"
00046 #include "Fireworks/Core/interface/FWRPZView.h"
00047 
00048 #include <boost/bind.hpp>
00049 
00050 class FWViewContext;
00051 
00052 // sentry class block TEveSelection signals when call TEveSelection::Remove/AddElement and
00053 // when process its callbacks
00054 class EveSelectionSentry {
00055 public:
00056    EveSelectionSentry()
00057    {
00058       m_blocked = gEve->GetSelection()->BlockSignals(true);
00059    }
00060    ~EveSelectionSentry()
00061    {
00062      gEve->GetSelection()->BlockSignals(m_blocked);
00063    }
00064 private:
00065    bool m_blocked;
00066 };
00067 
00068 //
00069 //
00070 // constants, enums and typedefs
00071 //
00072 //
00073 // constructors and destructor
00074 //
00075 FWEveViewManager::FWEveViewManager(FWGUIManager* iGUIMgr) :
00076    FWViewManagerBase()
00077 {
00078      
00079    // builders
00080    std::set<std::string> builders;
00081    
00082    std::vector<edmplugin::PluginInfo> available = FWProxyBuilderFactory::get()->available();
00083    std::transform(available.begin(),
00084                   available.end(),
00085                   std::inserter(builders,builders.begin()),
00086                   boost::bind(&edmplugin::PluginInfo::name_,_1));
00087    
00088    if(edmplugin::PluginManager::get()->categoryToInfos().end()!=edmplugin::PluginManager::get()->categoryToInfos().find(FWProxyBuilderFactory::get()->category())) {
00089       available = edmplugin::PluginManager::get()->categoryToInfos().find(FWProxyBuilderFactory::get()->category())->second;
00090       std::transform(available.begin(),
00091                      available.end(),
00092                      std::inserter(builders,builders.begin()),
00093                      boost::bind(&edmplugin::PluginInfo::name_,_1));
00094    }
00095    
00096    
00097    for(std::set<std::string>::iterator it = builders.begin(), itEnd=builders.end();
00098        it!=itEnd;
00099        ++it) {
00100       std::string::size_type first = it->find_first_of('@')+1;
00101       std::string purpose = it->substr(first,it->find_last_of('@')-first);
00102       
00103       first = it->find_last_of('@')+1;
00104       std::string view_str =  it->substr(first,it->find_last_of('#')-first);
00105       int viewTypes = atoi(view_str.c_str());
00106       std::string fullName = *it;
00107       m_typeToBuilder[purpose].push_back(BuilderInfo(*it, viewTypes));
00108    }
00109    
00110    
00111    m_views.resize(FWViewType::kTypeSize); 
00112    
00113    
00114    // view construction called via GUI mng
00115    FWGUIManager::ViewBuildFunctor f =  boost::bind(&FWEveViewManager::buildView, this, _1, _2);
00116    for (int i = 0; i < FWViewType::kTypeSize; i++)
00117    {
00118       if ( i == FWViewType::kTable || i == FWViewType::kTableHLT || i == FWViewType::kTableL1)
00119          continue;
00120       iGUIMgr->registerViewBuilder(FWViewType::idToName(i), f);
00121    }
00122    
00123    // signal
00124    gEve->GetHighlight()->SetPickToSelect(TEveSelection::kPS_Master);
00125    TEveSelection* eveSelection = gEve->GetSelection();
00126    eveSelection->SetPickToSelect(TEveSelection::kPS_Master);  
00127    eveSelection->Connect("SelectionAdded(TEveElement*)","FWEveViewManager",this,"selectionAdded(TEveElement*)");
00128    eveSelection->Connect("SelectionRepeated(TEveElement*)","FWEveViewManager",this,"selectionAdded(TEveElement*)");
00129    eveSelection->Connect("SelectionRemoved(TEveElement*)","FWEveViewManager",this,"selectionRemoved(TEveElement*)");
00130    eveSelection->Connect("SelectionCleared()","FWEveViewManager",this,"selectionCleared()");
00131 
00132    gEve->GetHighlight()->Connect("SelectionAdded(TEveElement*)","FWEveViewManager",this,"highlightAdded(TEveElement*)");
00133    gEve->GetHighlight()->Connect("SelectionRepeated(TEveElement*)","FWEveViewManager",this,"highlightAdded(TEveElement*)");
00134 }
00135 
00136 FWEveViewManager::~FWEveViewManager()
00137 {
00138 }
00139 
00140 //
00141 // member functions
00142 //
00143 
00144 //______________________________________________________________________________
00145 
00151 void
00152 addElements(const FWEventItem *item, FWEveView *view, 
00153             int viewType, TEveElementList* product)
00154 {
00155    if (FWViewType::isProjected(viewType))
00156    {
00157       FWRPZView* rpzView = dynamic_cast<FWRPZView*>(view);
00158       assert(rpzView);
00159       rpzView->importElements(product, item->layer(), rpzView->eventScene());
00160    }
00161    else
00162    {
00163       view->eventScene()->AddElement(product);
00164    }
00165 }
00166 
00180 void
00181 FWEveViewManager::newItem(const FWEventItem* iItem)
00182 {
00183    TypeToBuilder::iterator itFind = m_typeToBuilder.find(iItem->purpose());
00184    
00185    if (itFind == m_typeToBuilder.end())
00186       return;
00187 
00188    std::vector<BuilderInfo>& blist = itFind->second;
00189 
00190    for (size_t bii = 0, bie = blist.size(); bii != bie; ++bii)
00191    {
00192       // 1.
00193       BuilderInfo &info = blist[bii];
00194       std::string builderName = info.m_name;
00195       int builderViewBit =  info.m_viewBit;
00196       
00197       FWProxyBuilderBase* builder = 0;
00198       try
00199       {
00200          builder = FWProxyBuilderFactory::get()->create(builderName);
00201 
00202       }
00203       catch (std::exception& exc)
00204       {
00205          fwLog(fwlog::kWarning) << "FWEveViewManager::newItem ignoring the following exception (probably edmplugincache mismatch):"
00206                                 << std::endl << exc.what();
00207       }
00208       if (!builder)
00209          continue;
00210 
00211       // 2.
00212       // printf("FWEveViewManager::makeProxyBuilderFor NEW builder %s \n", builderName.c_str());
00213       
00214       boost::shared_ptr<FWProxyBuilderBase> pB(builder);
00215       builder->setItem(iItem);
00216       iItem->changed_.connect(boost::bind(&FWEveViewManager::modelChanges,this,_1));
00217       iItem->goingToBeDestroyed_.connect(boost::bind(&FWEveViewManager::removeItem,this,_1));
00218       iItem->itemChanged_.connect(boost::bind(&FWEveViewManager::itemChanged,this,_1));
00219 
00220       // 3.
00221       // This calud be opaque to the user. I would pass a reference to the m_interactionLists to
00222       // FWProxyBuilderBase::setInteractionList and handle different case differently.
00223       if (builder->willHandleInteraction() == false)
00224       {
00225          typedef std::map<const FWEventItem*, FWInteractionList*>::iterator Iterator;
00226          std::pair<Iterator, bool> t = m_interactionLists.insert(std::make_pair(iItem,
00227                                                                                 (FWInteractionList*)0));
00228 
00229          if (t.second == true)
00230             t.first->second = new FWInteractionList(iItem);
00231          //  printf(">>> builder %s add list %p \n", iItem->name().c_str(), il); fflush(stdout);
00232          builder->setInteractionList(t.first->second, iItem->purpose());
00233       }
00234       
00235       builder->setHaveWindow(haveViewForBit(builderViewBit));
00236       
00237       // 4.
00238       for (size_t viewType = 0; viewType < FWViewType::kTypeSize; ++viewType)
00239       {
00240          if (((1 << viewType) & builderViewBit) == 0)
00241             continue;
00242          
00243          FWViewType::EType type = (FWViewType::EType) viewType;
00244          
00245          // printf("%s builder %s supportsd view %s \n",  iItem->name().c_str(), builderName.c_str(), FWViewType::idToName(viewType).c_str());
00246          if (builder->havePerViewProduct((FWViewType::EType) viewType))
00247          { 
00248             for (size_t i = 0, e = m_views[viewType].size(); i != e; ++i)
00249             {
00250                FWEveView *view = m_views[viewType][i].get();
00251                TEveElementList* product = builder->createProduct(type, 
00252                                                                  view->viewContext());
00253                addElements(iItem, view, viewType, product);
00254             }
00255          }
00256          else 
00257          {
00258             TEveElementList* product = builder->createProduct(type, 0);
00259          
00260             for (size_t i = 0, e = m_views[viewType].size(); i != e; ++i)
00261                addElements(iItem, m_views[viewType][i].get(), viewType, product);
00262          }
00263       }
00264       
00265       m_builders[builderViewBit].push_back(pB);
00266    } // loop views
00267 }
00268 
00269 //______________________________________________________________________________
00270 FWViewBase*
00271 FWEveViewManager::buildView(TEveWindowSlot* iParent, const std::string& viewName)
00272 {
00273    FWViewType::EType type = FWViewType::kTypeSize;
00274    for (int i = 0; i < FWViewType::kTypeSize; ++i)
00275    {
00276       if (viewName == FWViewType::idToName(i))
00277       {
00278          type = FWViewType::EType(i);
00279          break;
00280       }
00281    }
00282 
00283    boost::shared_ptr<FWEveView> view;
00284    switch(type)
00285    {
00286       case FWViewType::k3D:
00287          view.reset(new FW3DView(iParent, type));
00288          break;
00289       case FWViewType::kISpy:
00290          view.reset(new FWISpyView(iParent, type));
00291          break;
00292       case FWViewType::kRhoPhi:
00293       case FWViewType::kRhoZ:
00294       case FWViewType::kRhoPhiPF:
00295          view.reset(new FWRPZView(iParent, type));
00296          break;
00297       case FWViewType::kLego:
00298       case FWViewType::kLegoPFECAL:
00299          view.reset(new FWEveLegoView(iParent, type));
00300          break;
00301       case FWViewType::kLegoHF:
00302          view.reset(new FWHFView(iParent, type));
00303          break;
00304       case FWViewType::kGlimpse:
00305          view.reset(new FWGlimpseView(iParent, type));
00306          break;
00307       default:
00308          break;
00309    }
00310 
00311    m_views[type].push_back(boost::shared_ptr<FWEveView> (view));
00312    return finishViewCreate(m_views[type].back());
00313 }
00314 
00315 FWEveView*
00316 FWEveViewManager::finishViewCreate(boost::shared_ptr<FWEveView> view)
00317 {
00318    // printf("new view %s added \n", view->typeName().c_str());
00319    gEve->DisableRedraw();
00320 
00321    // set geometry and calo data
00322    view->setContext(context()); 
00323 
00324    FWColorManager::setColorSetViewer(view->viewerGL(),  context().colorManager()->background());
00325 
00326    // set proxies have a window falg
00327    int viewerBit = 1 << view->typeId();   
00328    if (m_views[view->typeId()].size() == 1)
00329    {
00330       for ( std::map<int, BuilderVec>::iterator i = m_builders.begin(); i!=  m_builders.end(); ++i)
00331       {
00332          int builderViewBit = i->first;
00333          BuilderVec& bv =  i->second;
00334          if (viewerBit == (builderViewBit & viewerBit))
00335          {
00336             for(BuilderVec_it bIt = bv.begin(); bIt != bv.end(); ++bIt)
00337             {
00338                (*bIt)->setHaveWindow(true);
00339             }
00340          }
00341       }
00342    }
00343     
00344    FWRPZView* rpzView = dynamic_cast<FWRPZView*>(view.get());
00345    for ( std::map<int, BuilderVec>::iterator i = m_builders.begin(); i!=  m_builders.end(); ++i)
00346    {
00347       int builderViewBit = i->first;
00348       BuilderVec& bv =  i->second;
00349       if (viewerBit == (builderViewBit & viewerBit))
00350       { 
00351          for(BuilderVec_it bIt = bv.begin(); bIt != bv.end(); ++bIt)
00352          {
00353             // it is ok to call create even for shared productsm since
00354             // builder map key garanties that
00355             TEveElementList* product = (*bIt)->createProduct(view->typeId(), view->viewContext());
00356 
00357             if ((*bIt)->havePerViewProduct((FWViewType::EType)view->typeId()))
00358             {
00359                // view owned
00360                (*bIt)->build();
00361                if (rpzView)
00362                {
00363                   rpzView->importElements(product, (*bIt)->item()->layer(), rpzView->ownedProducts());
00364                }
00365                else
00366                {
00367                   view->ownedProducts()->AddElement(product);
00368                }
00369             }
00370             else
00371             {
00372                // shared
00373                if (rpzView)
00374                {
00375                   rpzView->importElements(product, (*bIt)->item()->layer(), rpzView->eventScene());
00376                }
00377                else
00378                {
00379                   view->eventScene()->AddElement(product);
00380                }
00381                  
00382             }
00383          }
00384       }
00385    }
00386 
00387    view->beingDestroyed_.connect(boost::bind(&FWEveViewManager::beingDestroyed,this,_1));
00388 
00389    view->setupEnergyScale(); // notify PB for energy scale
00390 
00391    gEve->EnableRedraw();
00392    view->viewerGL()->UpdateScene();
00393    gEve->Redraw3D();   
00394 
00395    return view.get();
00396 }
00397 
00398 void
00399 FWEveViewManager::beingDestroyed(const FWViewBase* vb)
00400 {
00401    FWEveView* view = (FWEveView*) vb;
00402    int typeId = view->typeId();
00403   
00404    int viewerBit = 1 << typeId;
00405    int nviews = m_views[typeId].size(); 
00406    for ( std::map<int, BuilderVec>::iterator i = m_builders.begin(); i!= m_builders.end(); ++i)
00407    {
00408       int builderBit = i->first;
00409       if (viewerBit == (builderBit & viewerBit)) // check only in case if connected
00410       {
00411          BuilderVec& bv =  i->second;
00412 
00413          // remove view-owned product
00414          if (viewerBit == (builderBit & viewerBit))
00415          {
00416             for(BuilderVec_it bIt = bv.begin(); bIt != bv.end(); ++bIt)
00417                (*bIt)->removePerViewProduct(view->typeId(), view->viewContext());
00418          }
00419 
00420          // and setup proxy builders have-a-window flag
00421          if (nviews == 1)
00422          {
00423             if (!haveViewForBit(builderBit))
00424             {
00425                if (viewerBit == (builderBit & viewerBit))
00426                {
00427                   for(BuilderVec_it bIt = bv.begin(); bIt != bv.end(); ++bIt)
00428                      (*bIt)->setHaveWindow(false);
00429                }
00430             }
00431          }
00432       }
00433    }
00434   
00435 
00436    for(EveViewVec_it i= m_views[typeId].begin(); i != m_views[typeId].end(); ++i) {
00437       if(i->get() == vb) {
00438          m_views[typeId].erase(i);
00439          break;
00440       }
00441    }
00442 }
00443 
00444 //______________________________________________________________________________
00445 
00446 void
00447 FWEveViewManager::modelChangesComing()
00448 {
00449    gEve->DisableRedraw();
00450 }
00451 
00452 void
00453 FWEveViewManager::modelChangesDone()
00454 {
00455    gEve->EnableRedraw();
00456 }
00457 
00459 void
00460 FWEveViewManager::modelChanges(const FWModelIds& iIds)
00461 {
00462    FWModelId id = *(iIds.begin());
00463    const FWEventItem* item = id.item();
00464 
00465    // in standard case new elements can be build in case of change of visibility
00466    // and in non-standard case (e.g. calo towers) PB's modelChages handles all changes
00467    bool itemHaveWindow = false;
00468    for (std::map<int, BuilderVec>::iterator i = m_builders.begin(); 
00469         i != m_builders.end(); ++i)
00470    {
00471       for (size_t bi = 0, be = i->second.size(); bi != be; ++bi)
00472       {
00473          FWProxyBuilderBase *builder = i->second[bi].get();
00474          if (builder->getHaveWindow() && builder->item() == item)
00475          {
00476             builder->modelChanges(iIds);
00477             itemHaveWindow = true;
00478          }
00479       }
00480    }
00481 
00482    if (!itemHaveWindow)
00483       return;
00484 
00485    EveSelectionSentry();
00486 
00487    std::map<const FWEventItem*, FWInteractionList*>::iterator it = m_interactionLists.find(item);
00488    if (it != m_interactionLists.end())
00489    {
00490       if (!it->second->empty())
00491          it->second->modelChanges(iIds);
00492    }
00493 }
00494 
00500 void
00501 FWEveViewManager::itemChanged(const FWEventItem* item)
00502 {
00503    if (!item)
00504       return;
00505 
00506    bool itemHaveWindow = false;
00507 
00508    for (std::map<int, BuilderVec>::iterator i = m_builders.begin(); 
00509         i != m_builders.end(); ++i)
00510    {
00511       for(size_t bi = 0, be = i->second.size(); bi != be; ++bi)
00512       {
00513          FWProxyBuilderBase *builder = i->second[bi].get();
00514          
00515          if (builder->item() != item)
00516             continue;
00517 
00518          builder->itemChanged(item);
00519          itemHaveWindow |= builder->getHaveWindow();
00520       }
00521    }
00522    
00523    if (!itemHaveWindow)
00524       return;
00525 
00526    std::map<const FWEventItem*, FWInteractionList*>::iterator it = m_interactionLists.find(item);
00527    if (it != m_interactionLists.end())
00528    {
00529       if (!it->second->empty())
00530          it->second->itemChanged();
00531    }
00532 }
00533 
00536 void
00537 FWEveViewManager::removeItem(const FWEventItem* item)
00538 {
00539    EveSelectionSentry();
00540 
00541    std::map<const FWEventItem*, FWInteractionList*>::iterator it =  m_interactionLists.find(item);
00542    if (it != m_interactionLists.end())
00543    {
00544       delete it->second;
00545       m_interactionLists.erase(it);
00546    }
00547   
00548    for (std::map<int, BuilderVec>::iterator i = m_builders.begin();
00549         i != m_builders.end(); ++i)
00550    {
00551       BuilderVec_it bIt = i->second.begin();
00552       while( bIt != i->second.end() )
00553       {
00554          if ((*bIt)->item() == item)
00555          { 
00556             // TODO caching of proxy builders
00557             (*bIt)->itemBeingDestroyed(item);
00558             bIt = i->second.erase(bIt);
00559          }
00560          else
00561          {
00562             ++bIt;
00563          }
00564       }
00565    }
00566 }
00567 
00568 void
00569 FWEveViewManager::setContext(const fireworks::Context* x)
00570 {
00571    FWViewManagerBase::setContext(x);
00572    x->commonPrefs()->getEnergyScale()->parameterChanged_.connect(boost::bind(&FWEveViewManager::globalEnergyScaleChanged,this));
00573 
00574 }
00575 
00576 void
00577 FWEveViewManager::globalEnergyScaleChanged()
00578 {
00579    for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
00580    {
00581       for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i) 
00582       {
00583          if ((*i)->isEnergyScaleGlobal())
00584          {
00585             (*i)->setupEnergyScale();
00586          }
00587       }
00588 
00589    }
00590 }
00591 
00592 void
00593 FWEveViewManager::colorsChanged()
00594 {
00595    for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
00596    {
00597       for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i) 
00598          (*i)->setBackgroundColor(colorManager().background());
00599    }
00600 }
00601 
00602 //______________________________________________________________________________
00603 void
00604 FWEveViewManager::eventBegin()
00605 {
00606    gEve->DisableRedraw();
00607 
00608    context().resetMaxEtAndEnergy();
00609 
00610    for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
00611    {
00612       for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)   
00613          (*i)->eventBegin();
00614    }
00615 }
00616 
00617 void
00618 FWEveViewManager::eventEnd()
00619 {
00620    for (int t = 0 ; t < FWViewType::kTypeSize; ++t)
00621    {
00622       for(EveViewVec_it i = m_views[t].begin(); i != m_views[t].end(); ++i)   
00623          (*i)->eventEnd();
00624    }
00625    gEve->EnableRedraw();
00626 }
00627 
00628 //______________________________________________________________________________
00629 
00632 FWFromEveSelectorBase *getSelector(TEveElement *iElement)
00633 {
00634    if (!iElement)
00635       return 0;
00636 
00637    //std::cout <<"  non null"<<std::endl;
00638    void* userData = iElement->GetUserData();
00639    //std::cout <<"  user data "<<userData<<std::endl;
00640    if (!userData)
00641       return 0;
00642 
00643    //std::cout <<"    have userData"<<std::endl;
00644    //std::cout <<"      calo"<<std::endl;
00645    EveSelectionSentry();
00646    return reinterpret_cast<FWFromEveSelectorBase*> (userData);   
00647 }
00648 
00649 void
00650 FWEveViewManager::selectionAdded(TEveElement* iElement)
00651 {
00652    FWFromEveSelectorBase* selector = getSelector(iElement);
00653    if (selector)
00654       selector->doSelect();
00655 }
00656 
00657 void
00658 FWEveViewManager::selectionRemoved(TEveElement* iElement)
00659 {
00660    FWFromEveSelectorBase* selector = getSelector(iElement);
00661    if (selector)
00662       selector->doUnselect();
00663 }
00664 
00665 void
00666 FWEveViewManager::selectionCleared()
00667 {
00668    context().selectionManager()->clearSelection();
00669 }
00670 
00671 
00672 //
00673 // const member functions
00674 //
00675 
00676 FWTypeToRepresentations
00677 FWEveViewManager::supportedTypesAndRepresentations() const
00678 {
00679    // needed for add collection GUI
00680    FWTypeToRepresentations returnValue;
00681    const std::string kSimple("simple#");
00682    for(TypeToBuilder::const_iterator it = m_typeToBuilder.begin(), itEnd = m_typeToBuilder.end();
00683        it != itEnd;
00684        ++it) 
00685    {
00686       std::vector<BuilderInfo> blist = it->second;
00687       for (size_t bii = 0, bie = blist.size(); bii != bie; ++bii)
00688       {
00689          BuilderInfo &info = blist[bii];
00690          std::string name = info.m_name;
00691          unsigned int bitPackedViews = info.m_viewBit;
00692          bool representsSubPart = (name.substr(name.find_first_of('@')-1, 1)=="!");
00693      
00694          if(name.substr(0,kSimple.size()) == kSimple)
00695          {
00696             name = name.substr(kSimple.size(), name.find_first_of('@')-kSimple.size()-1);
00697             returnValue.add(boost::shared_ptr<FWRepresentationCheckerBase>(new FWSimpleRepresentationChecker(name, it->first,bitPackedViews,representsSubPart)) );
00698          }
00699          else
00700          {
00701             name = name.substr(0, name.find_first_of('@')-1);
00702             returnValue.add(boost::shared_ptr<FWRepresentationCheckerBase>(new FWEDProductRepresentationChecker(name, it->first,bitPackedViews,representsSubPart)) );
00703          }
00704       }
00705    }
00706    return returnValue;
00707 }
00708 
00709 
00711 bool
00712 FWEveViewManager::haveViewForBit(int bit) const
00713 {
00714    for (int t = 0; t < FWViewType::kTypeSize; ++t)
00715    {
00716       if ((bit & (1 << t)) && m_views[t].size())
00717          return true;
00718    }
00719    // printf("have %d view for bit %d \n", haveView, bit);
00720    return false;
00721 }
00722 
00723 
00724 /*
00725 AMT: temporary workaround for using TEveCaloDataHist instead of
00726 TEveCaloDataVec. 
00727 
00728  */
00729 
00730 #include "TH2F.h"
00731 #include "TAxis.h"
00732 #include "TEveCaloData.h"
00733 
00734 void
00735 FWEveViewManager::highlightAdded(TEveElement* iElement)
00736 {
00737 
00738    bool blocked = gEve->GetHighlight()->BlockSignals(true);
00739 
00740 
00741    if (iElement == context().getCaloData())
00742    {
00743       TEveCaloData::vCellId_t& hlist =  context().getCaloData()->GetCellsHighlighted();
00744       std::set<TEveCaloData::CellId_t> hset;
00745 
00746       int etaBin, phiBin, w, newPhiBin, tower;
00747       TH2F* hist =  context().getCaloData()->GetHist(0);
00748       TAxis* etaAxis = hist->GetXaxis();
00749       int nBinsX = etaAxis->GetNbins() + 2;
00750 
00751       for (TEveCaloData::vCellId_i i = hlist.begin(); i != hlist.end(); ++i)
00752       {
00753          hist->GetBinXYZ((*i).fTower, etaBin, phiBin, w);
00754          if (TMath::Abs(etaAxis->GetBinCenter(etaBin)) > 4.71475)
00755          {
00756             newPhiBin = ((phiBin + 1) / 4) * 4 - 1;
00757             if (newPhiBin <= 0) newPhiBin = 71;
00758                
00759             tower = etaBin + newPhiBin*nBinsX;
00760             hset.insert(TEveCaloData::CellId_t( tower, (*i).fSlice, (*i).fFraction));
00761             tower += nBinsX;
00762             hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
00763             tower += nBinsX;
00764 
00765             if (newPhiBin == 71)
00766                tower = etaBin + 1*nBinsX;
00767 
00768             hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
00769             tower += nBinsX;
00770             hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
00771          }
00772          else if (TMath::Abs(etaAxis->GetBinCenter(etaBin)) > 1.747650)
00773          {  
00774             newPhiBin =  ((phiBin + 1)/2)*2 - 1;
00775             tower = etaBin + newPhiBin*nBinsX;
00776             hset.insert(TEveCaloData::CellId_t( tower, (*i).fSlice, (*i).fFraction));
00777             tower += nBinsX;
00778             hset.insert(TEveCaloData::CellId_t(tower, (*i).fSlice, (*i).fFraction));
00779          }
00780          else
00781          {
00782             hset.insert(*i);
00783          }
00784       }
00785  
00786       // edit calo data list
00787       hlist.clear();
00788       for(std::set<TEveCaloData::CellId_t>::iterator it = hset.begin(); it != hset.end(); ++it)
00789       {
00790          hlist.push_back(*it);
00791       }    
00792       context().getCaloData()->CellSelectionChanged();
00793 
00794    }
00795 
00796    gEve->GetHighlight()->BlockSignals(blocked);
00797 }