CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/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 FWGeometryTableViewBase* FWEveDetectorGeo::browser()
00024 {
00025    return m_browser;
00026 }
00027 //______________________________________________________________________________
00028 
00029 void FWEveDetectorGeo::Paint(Option_t* opt)
00030 {
00031    FWGeoTopNode::Paint();
00032 
00033    // printf("PAINPAINTPAINTPAINTPAINTPAINTPAINTPAINTPAINTPAINTT  %d/%d \n",  m_browser->getTopNodeIdx(),  (int)m_browser->getTableManager()->refEntries().size());
00034    if (m_browser->getTableManager()->refEntries().empty()) return; 
00035 
00036    TEveGeoManagerHolder gmgr( FWGeometryTableViewManager::getGeoMangeur());
00037 
00038    m_maxLevel = m_browser->getVisLevel() + m_browser->getTableManager()->getLevelOffset();
00039 
00040    m_filterOff = m_browser->getFilter().empty();
00041 
00042    Int_t topIdx = m_browser->getTopNodeIdx();
00043    FWGeometryTableManagerBase::Entries_i sit = m_browser->getTableManager()->refEntries().begin(); 
00044 
00045    TGeoHMatrix mtx;
00046    if (topIdx >= 0)
00047    {
00048       std::advance(sit, topIdx);
00049       m_browser->getTableManager()->getNodeMatrix(*sit, mtx);
00050    }
00051 
00052    bool drawsChildren = 0;
00053    
00054    if ( ((FWGeometryTableManager*)tableManager())->getVisibilityChld(*sit))
00055       drawsChildren = paintChildNodesRecurse( sit, topIdx, mtx);
00056    
00057    if (sit->testBit(FWGeometryTableManagerBase::kVisNodeSelf) && ((FWGeometryTableManager*)tableManager())->getVisibility(*sit))
00058       paintShape( topIdx,mtx, m_browser->getVolumeMode(), drawsChildren );
00059    
00060    
00061    fflush(stdout);
00062 }
00063 
00064 
00065 // ______________________________________________________________________
00066 bool FWEveDetectorGeo::paintChildNodesRecurse (FWGeometryTableManagerBase::Entries_i pIt, Int_t cnt, const TGeoHMatrix& parentMtx)
00067 { 
00068    TGeoNode* parentNode =  pIt->m_node;
00069    int nD = parentNode->GetNdaughters();
00070 
00071    int dOff=0;
00072 
00073    pIt++;
00074    int pcnt = cnt+1;
00075    
00076    bool drawsChildNodes = 0;
00077 
00078    FWGeometryTableManagerBase::Entries_i it;
00079    for (int n = 0; n != nD; ++n)
00080    {
00081       it =  pIt;
00082       std::advance(it,n + dOff);
00083       cnt = pcnt + n+dOff;
00084 
00085       TGeoHMatrix nm = parentMtx;
00086       nm.Multiply(it->m_node->GetMatrix());
00087 
00088       bool drawsChildNodesSecondGen = false;
00089       if (m_filterOff || m_browser->isSelectedByRegion())
00090       {
00091          if  ( ((FWGeometryTableManager*)tableManager())->getVisibilityChld(*it) && ( it->m_level < m_maxLevel)) {
00092            drawsChildNodesSecondGen = paintChildNodesRecurse(it,cnt , nm);
00093          }
00094          
00095          if ( ((FWGeometryTableManager*)tableManager())->getVisibility(*it))
00096          {
00097             paintShape(cnt , nm, m_browser->getVolumeMode(),  drawsChildNodesSecondGen );
00098             drawsChildNodes = true;
00099          }
00100 
00101       }
00102       else
00103       {
00104          if ( ((FWGeometryTableManager*)tableManager())->getVisibilityChld(*it) && ( it->m_level < m_maxLevel || m_browser->getIgnoreVisLevelWhenFilter() ))
00105          {
00106             drawsChildNodesSecondGen = paintChildNodesRecurse(it,cnt , nm);
00107          }
00108          
00109          ((FWGeometryTableManager*)tableManager())->assertNodeFilterCache(*it);
00110          if ( ((FWGeometryTableManager*)tableManager())->getVisibility(*it))
00111          {
00112             paintShape(cnt , nm, m_browser->getVolumeMode(), drawsChildNodesSecondGen );
00113             drawsChildNodes = true;
00114          }
00115       }
00116 
00117       drawsChildNodes |= drawsChildNodesSecondGen;
00118       FWGeometryTableManagerBase::getNNodesTotal(parentNode->GetDaughter(n), dOff);  
00119    }
00120    
00121    return  drawsChildNodes;
00122 }
00123 
00124 //______________________________________________________________________________
00125 
00126 TString  FWEveDetectorGeo::GetHighlightTooltip()
00127 {
00128    std::set<TGLPhysicalShape*>::iterator it = fHted.begin();
00129    int idx = tableIdx(*it);
00130    if (idx > 0)
00131    {
00132       FWGeometryTableManagerBase::NodeInfo& data = m_browser->getTableManager()->refEntries().at(idx);
00133       return data.name();
00134    }
00135    return "error";
00136 }
00137 
00138 //_____________________________________________________________________________
00139 
00140 void FWEveDetectorGeo::popupMenu(int x, int y, TGLViewer* v)
00141 {
00142    FWPopupMenu* nodePopup = FWGeoTopNode::setPopupMenu(x, y, v, false);
00143    
00144  if (nodePopup)  nodePopup->Connect("Activated(Int_t)",
00145                       "FWGeometryTableView",
00146                       m_browser,
00147                       "chosenItem(Int_t)");
00148 }