CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/Fireworks/Core/src/FWEveDetectorGeo.cc

Go to the documentation of this file.
00001 #include "Fireworks/Core/src/FWEveDetectorGeo.h"
00002 #include "Fireworks/Core/src/FWGeometryTableView.h"
00003 #include "Fireworks/Core/src/FWGeometryTableManager.h"
00004 #include "Fireworks/Core/interface/FWGeometryTableViewManager.h"
00005 #include "Fireworks/Core/interface/fwLog.h"
00006 #include "Fireworks/Core/src/FWPopupMenu.cc"
00007 
00008 #include "TGeoMatrix.h"
00009 
00010 //==============================================================================
00011 //==============================================================================
00012 //==============================================================================
00013 FWEveDetectorGeo::FWEveDetectorGeo(FWGeometryTableView* v):
00014    m_browser(v), m_maxLevel(0), m_filterOff(0)
00015 {
00016 } 
00017 
00018 FWGeometryTableManagerBase* FWEveDetectorGeo::tableManager()
00019 {
00020    return m_browser->getTableManager();
00021 }
00022 //______________________________________________________________________________
00023 
00024 void FWEveDetectorGeo::Paint(Option_t* opt)
00025 {
00026    FWGeoTopNode::Paint();
00027 
00028    //   printf("PAINPAINTPAINTPAINTPAINTPAINTPAINTPAINTPAINTPAINTT  %d/%d \n",  m_browser->getTopNodeIdx(),  (int)m_browser->getTableManager()->refEntries().size());
00029    if (m_browser->getTableManager()->refEntries().empty()) return; 
00030 
00031    TEveGeoManagerHolder gmgr( FWGeometryTableViewManager::getGeoMangeur());
00032 
00033    m_maxLevel = m_browser->getVisLevel() + m_browser->getTableManager()->getLevelOffset();
00034    m_filterOff = m_browser->getFilter().empty();
00035 
00036    Int_t topIdx = m_browser->getTopNodeIdx();
00037    FWGeometryTableManagerBase::Entries_i sit = m_browser->getTableManager()->refEntries().begin(); 
00038 
00039    TGeoHMatrix mtx;
00040    if (topIdx >= 0)
00041    {
00042       std::advance(sit, topIdx);
00043       m_browser->getTableManager()->getNodeMatrix(*sit, mtx);
00044 
00045       if (sit->testBit(FWGeometryTableManagerBase::kVisNodeSelf) && ((FWGeometryTableManager*)tableManager())->getVisibility(*sit))
00046          paintShape(*sit,  topIdx,mtx, m_browser->getVolumeMode() );
00047    }
00048 
00049    if ( ((FWGeometryTableManager*)tableManager())->getVisibilityChld(*sit))
00050       paintChildNodesRecurse( sit, topIdx, mtx);
00051 }
00052 
00053 
00054 // ______________________________________________________________________
00055 void FWEveDetectorGeo::paintChildNodesRecurse (FWGeometryTableManagerBase::Entries_i pIt, Int_t cnt, const TGeoHMatrix& parentMtx)
00056 { 
00057    TGeoNode* parentNode =  pIt->m_node;
00058    int nD = parentNode->GetNdaughters();
00059 
00060    int dOff=0;
00061 
00062    pIt++;
00063    int pcnt = cnt+1;
00064 
00065    FWGeometryTableManagerBase::Entries_i it;
00066    for (int n = 0; n != nD; ++n)
00067    {
00068       it =  pIt;
00069       std::advance(it,n + dOff);
00070       cnt = pcnt + n+dOff;
00071 
00072       TGeoHMatrix nm = parentMtx;
00073       nm.Multiply(it->m_node->GetMatrix());
00074 
00075   
00076       if (m_filterOff)
00077       {
00078          if ( ((FWGeometryTableManager*)tableManager())->getVisibility(*it))
00079             paintShape(*it, cnt , nm, m_browser->getVolumeMode() );
00080 
00081          if  ( ((FWGeometryTableManager*)tableManager())->getVisibilityChld(*it) && ( it->m_level < m_maxLevel  || it->testBit(FWGeometryTableManagerBase::kExpanded) )) {
00082             paintChildNodesRecurse(it,cnt , nm);
00083          }
00084 
00085       }
00086       else
00087       {
00088          if ( ((FWGeometryTableManager*)tableManager())->getVisibility(*it))
00089             paintShape(*it,cnt , nm, m_browser->getVolumeMode()  );
00090 
00091          if ( ((FWGeometryTableManager*)tableManager())->getVisibilityChld(*it) && ( it->m_level < m_maxLevel || m_browser->getIgnoreVisLevelWhenFilter() ))
00092          {
00093             paintChildNodesRecurse(it,cnt , nm);
00094          }
00095       }
00096 
00097 
00098       FWGeometryTableManagerBase::getNNodesTotal(parentNode->GetDaughter(n), dOff);  
00099    }
00100 }
00101 
00102 //______________________________________________________________________________
00103 
00104 TString  FWEveDetectorGeo::GetHighlightTooltip()
00105 {
00106    std::set<TGLPhysicalShape*>::iterator it = fHted.begin();
00107    int idx = tableIdx(*it);
00108    if (idx > 0)
00109    {
00110       FWGeometryTableManagerBase::NodeInfo& data = m_browser->getTableManager()->refEntries().at(idx);
00111       return data.name();
00112    }
00113    return "error";
00114 }
00115 
00116 
00117 
00118 //______________________________________________________________________________
00119 
00120 void FWEveDetectorGeo::popupMenu(int x, int y)
00121 {  
00122    if (getFirstSelectedTableIndex() < 0)
00123    {
00124       if (fSted.empty()) fwLog(fwlog::kInfo) << "No menu -- no node/entry selected \n";
00125       return;
00126    }
00127    
00128    FWPopupMenu* nodePopup = new FWPopupMenu();
00129    nodePopup->AddEntry("Set As Top Node", kGeoSetTopNode);
00130    nodePopup->AddEntry("Set As Top Node And Camera Center", kGeoSetTopNodeCam);
00131    nodePopup->AddSeparator();
00132    nodePopup->AddEntry("Rnr Off For All Children", kGeoVisOff);
00133    nodePopup->AddEntry("Rnr On For All Children", kGeoVisOn);
00134    nodePopup->AddSeparator();
00135    nodePopup->AddEntry("Set Camera Center", kGeoCamera);
00136    nodePopup->AddSeparator();
00137    //   nodePopup->AddEntry("InspectMaterial", kGeoInspectMaterial); crashes !!!
00138    nodePopup->AddEntry("InspectShape", kGeoInspectShape);
00139 
00140    nodePopup->PlaceMenu(x, y,true,true);
00141    nodePopup->Connect("Activated(Int_t)",
00142                       "FWGeometryTableView",
00143                        m_browser,
00144                       "chosenItem(Int_t)");
00145 }