Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:27:10

0001 #include "Fireworks/Core/src/FWEveDetectorGeo.h"
0002 #include "Fireworks/Core/src/FWGeometryTableView.h"
0003 #include "Fireworks/Core/src/FWGeometryTableManager.h"
0004 #include "Fireworks/Core/interface/FWGeometryTableViewManager.h"
0005 #include "Fireworks/Core/interface/fwLog.h"
0006 #include "Fireworks/Core/src/FWPopupMenu.cc"
0007 
0008 #include "TGeoMatrix.h"
0009 
0010 //==============================================================================
0011 //==============================================================================
0012 //==============================================================================
0013 FWEveDetectorGeo::FWEveDetectorGeo(FWGeometryTableView* v) : m_browser(v), m_maxLevel(0), m_filterOff(false) {}
0014 
0015 FWGeometryTableManagerBase* FWEveDetectorGeo::tableManager() { return m_browser->getTableManager(); }
0016 
0017 FWGeometryTableViewBase* FWEveDetectorGeo::browser() { return m_browser; }
0018 //______________________________________________________________________________
0019 
0020 void FWEveDetectorGeo::Paint(Option_t* opt) {
0021   FWGeoTopNode::Paint();
0022 
0023   // printf("PAINPAINTPAINTPAINTPAINTPAINTPAINTPAINTPAINTPAINTT  %d/%d \n",  m_browser->getTopNodeIdx(),  (int)m_browser->getTableManager()->refEntries().size());
0024   if (m_browser->getTableManager()->refEntries().empty())
0025     return;
0026 
0027   TEveGeoManagerHolder gmgr(FWGeometryTableViewManager::getGeoMangeur());
0028 
0029   m_maxLevel = m_browser->getVisLevel() + m_browser->getTableManager()->getLevelOffset();
0030 
0031   m_filterOff = m_browser->getFilter().empty();
0032 
0033   Int_t topIdx = m_browser->getTopNodeIdx();
0034   FWGeometryTableManagerBase::Entries_i sit = m_browser->getTableManager()->refEntries().begin();
0035 
0036   TGeoHMatrix mtx;
0037   if (topIdx >= 0) {
0038     std::advance(sit, topIdx);
0039     m_browser->getTableManager()->getNodeMatrix(*sit, mtx);
0040   }
0041 
0042   bool drawsChildren = false;
0043 
0044   if (((FWGeometryTableManager*)tableManager())->getVisibilityChld(*sit))
0045     drawsChildren = paintChildNodesRecurse(sit, topIdx, mtx);
0046 
0047   if (sit->testBit(FWGeometryTableManagerBase::kVisNodeSelf) &&
0048       ((FWGeometryTableManager*)tableManager())->getVisibility(*sit))
0049     paintShape(topIdx, mtx, m_browser->getVolumeMode(), drawsChildren);
0050 
0051   fflush(stdout);
0052 }
0053 
0054 // ______________________________________________________________________
0055 bool FWEveDetectorGeo::paintChildNodesRecurse(FWGeometryTableManagerBase::Entries_i pIt,
0056                                               Int_t cnt,
0057                                               const TGeoHMatrix& parentMtx) {
0058   TGeoNode* parentNode = pIt->m_node;
0059   int nD = parentNode->GetNdaughters();
0060 
0061   int dOff = 0;
0062 
0063   pIt++;
0064   int pcnt = cnt + 1;
0065 
0066   bool drawsChildNodes = false;
0067 
0068   FWGeometryTableManagerBase::Entries_i it;
0069   for (int n = 0; n != nD; ++n) {
0070     it = pIt;
0071     std::advance(it, n + dOff);
0072     cnt = pcnt + n + dOff;
0073 
0074     TGeoHMatrix nm = parentMtx;
0075     nm.Multiply(it->m_node->GetMatrix());
0076 
0077     bool drawsChildNodesSecondGen = false;
0078     if (m_filterOff || m_browser->isSelectedByRegion()) {
0079       if (((FWGeometryTableManager*)tableManager())->getVisibilityChld(*it) && (it->m_level < m_maxLevel)) {
0080         drawsChildNodesSecondGen = paintChildNodesRecurse(it, cnt, nm);
0081       }
0082 
0083       if (((FWGeometryTableManager*)tableManager())->getVisibility(*it)) {
0084         paintShape(cnt, nm, m_browser->getVolumeMode(), drawsChildNodesSecondGen);
0085         drawsChildNodes = true;
0086       }
0087 
0088     } else {
0089       if (((FWGeometryTableManager*)tableManager())->getVisibilityChld(*it) &&
0090           (it->m_level < m_maxLevel || m_browser->getIgnoreVisLevelWhenFilter())) {
0091         drawsChildNodesSecondGen = paintChildNodesRecurse(it, cnt, nm);
0092       }
0093 
0094       ((FWGeometryTableManager*)tableManager())->assertNodeFilterCache(*it);
0095       if (((FWGeometryTableManager*)tableManager())->getVisibility(*it)) {
0096         paintShape(cnt, nm, m_browser->getVolumeMode(), drawsChildNodesSecondGen);
0097         drawsChildNodes = true;
0098       }
0099     }
0100 
0101     drawsChildNodes |= drawsChildNodesSecondGen;
0102     FWGeometryTableManagerBase::getNNodesTotal(parentNode->GetDaughter(n), dOff);
0103   }
0104 
0105   return drawsChildNodes;
0106 }
0107 
0108 //______________________________________________________________________________
0109 
0110 TString FWEveDetectorGeo::GetHighlightTooltip() {
0111   std::set<TGLPhysicalShape*>::iterator it = fHted.begin();
0112   int idx = tableIdx(*it);
0113   if (idx > 0) {
0114     FWGeometryTableManagerBase::NodeInfo& data = m_browser->getTableManager()->refEntries().at(idx);
0115     return data.name();
0116   }
0117   return "error";
0118 }
0119 
0120 //_____________________________________________________________________________
0121 
0122 void FWEveDetectorGeo::popupMenu(int x, int y, TGLViewer* v) {
0123   FWPopupMenu* nodePopup = FWGeoTopNode::setPopupMenu(x, y, v, false);
0124 
0125   if (nodePopup)
0126     nodePopup->Connect("Activated(Int_t)", "FWGeometryTableView", m_browser, "chosenItem(Int_t)");
0127 }