CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/Fireworks/Core/src/FWEveOverlap.cc

Go to the documentation of this file.
00001 #include "Fireworks/Core/src/FWEveOverlap.h"
00002 #include "TGeoOverlap.h"
00003 #include "Fireworks/Core/src/FWOverlapTableView.h"
00004 #include "Fireworks/Core/src/FWOverlapTableManager.h"
00005 #include "Fireworks/Core/interface/FWGeometryTableViewManager.h"
00006 #include "Fireworks/Core/interface/fwLog.h"
00007 #include "Fireworks/Core/src/FWPopupMenu.cc"
00008 //==============================================================================
00009 //==============================================================================
00010 //==============================================================================
00011 FWEveOverlap::FWEveOverlap(FWOverlapTableView* v):
00012    m_browser(v)
00013 {
00014 } 
00015 FWGeometryTableManagerBase* FWEveOverlap::tableManager()
00016 {
00017    return m_browser->getTableManager();
00018 }
00019 
00020 FWGeometryTableViewBase* FWEveOverlap::browser()
00021 {
00022    return m_browser;
00023 }
00024 //______________________________________________________________________________
00025 
00026 void FWEveOverlap::Paint(Option_t*)
00027 {
00028    
00029    if (m_browser->getTableManager()->refEntries().empty()) return; 
00030    
00031    FWGeoTopNode::Paint();
00032    
00033    TEveGeoManagerHolder gmgr( FWGeometryTableViewManager::getGeoMangeur());
00034    
00035    
00036    int topNodeIdx =  m_browser->getTopNodeIdx();
00037    
00038    FWGeometryTableManagerBase::Entries_i sit = m_browser->getTableManager()->refEntries().begin();
00039    std::advance(sit,topNodeIdx );
00040    TGeoHMatrix mtx;
00041    m_browser->getTableManager()->getNodeMatrix(*sit, mtx);
00042    
00043    bool  drawsChildren = false;
00044    
00045    if ( (*sit).testBit(FWGeometryTableManagerBase::kVisNodeChld))
00046       drawsChildren = paintChildNodesRecurse( sit, topNodeIdx, mtx);
00047    
00048    if (sit->testBit(FWGeometryTableManagerBase::kVisNodeSelf))
00049       paintShape(topNodeIdx,mtx, false,  drawsChildren);
00050 }
00051 
00052 
00053 // ______________________________________________________________________
00054 bool FWEveOverlap::paintChildNodesRecurse (FWGeometryTableManagerBase::Entries_i pIt, Int_t cnt, const TGeoHMatrix& parentMtx)
00055 {
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    bool  drawsChildren = false;
00066    
00067    FWGeometryTableManagerBase::Entries_i it;
00068    for (int n = 0; n != nD; ++n)
00069    {
00070       it =  pIt;
00071       std::advance(it,n + dOff);
00072       cnt = pcnt + n+dOff;
00073       
00074       TGeoHMatrix nm = parentMtx;
00075       nm.Multiply(it->m_node->GetMatrix());
00076       
00077       bool  drawsChildrenSecondGen = false;
00078       if ( it->testBit(FWGeometryTableManagerBase::kVisNodeChld) && it->testBit(FWOverlapTableManager::kOverlapChild))
00079          drawsChildrenSecondGen = paintChildNodesRecurse(it,cnt , nm);
00080       
00081       if (it->testBit(FWGeometryTableManagerBase::kVisNodeSelf))
00082       {
00083          if (it->testBit(FWOverlapTableManager::kOverlap))
00084          {
00085             int nno;it->m_node->GetOverlaps(nno);
00086             if ( (m_browser->m_rnrOverlap.value() && ((nno & BIT(1)) == BIT(1)) ) 
00087                 || (m_browser->m_rnrExtrusion.value() && ((nno & BIT(2)) == BIT(2)) ))
00088             {
00089                paintShape(cnt , nm, false, drawsChildrenSecondGen);
00090                drawsChildren = true;
00091             }
00092             
00093          }
00094          else
00095          {
00096             paintShape(cnt , nm, false, drawsChildrenSecondGen);
00097             drawsChildren = true;
00098          }
00099       }
00100       
00101       drawsChildren |= drawsChildrenSecondGen;
00102       FWGeometryTableManagerBase::getNNodesTotal(parentNode->GetDaughter(n), dOff);  
00103    }
00104    return drawsChildren;
00105 }
00106 
00107 
00108 //______________________________________________________________________________
00109 
00110 TString  FWEveOverlap::GetHighlightTooltip()
00111 {
00112    //   printf("highlight tooltio \n");
00113    std::set<TGLPhysicalShape*>::iterator it = fHted.begin();
00114    int idx = tableIdx(*it);
00115    if ( idx < 0) 
00116    {
00117       return Form("TopNode ");
00118    }
00119    FWGeometryTableManagerBase::NodeInfo& data = m_browser->getTableManager()->refEntries().at(idx);
00120    
00121    TString name = data.name();
00122    if (data.testBit(FWOverlapTableManager::kOverlap)) {
00123       
00124       ((FWOverlapTableManager*)m_browser->getTableManager())->getOverlapTitles(idx, name);
00125       return name; 
00126    }
00127    
00128    return data.name();
00129 }
00130 
00131 
00132 //_____________________________________________________________________________
00133 
00134 void FWEveOverlap::popupMenu(int x, int y, TGLViewer* v)
00135 {
00136    FWPopupMenu* nodePopup = setPopupMenu(x, y,v, true);
00137    
00138    if (nodePopup)  nodePopup->Connect("Activated(Int_t)",
00139                                       "FWOverlapTableView",
00140                                       m_browser,
00141                                       "chosenItem(Int_t)");
00142 }