Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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