CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

FWGeometryTableManager Class Reference

#include <Fireworks/Core/interface/FWGeometryTableManager.h>

Inheritance diagram for FWGeometryTableManager:
FWGeometryTableManagerBase FWTableManagerBase

List of all members.

Classes

struct  Match

Public Types

enum  ECol {
  kNameColumn, kColorColumn, kVisSelfColumn, kVisChildColumn,
  kMaterialColumn, kNumColumn
}
enum  GeometryBits { kMatches = BIT(5), kChildMatches = BIT(6), kFilterCached = BIT(7) }
typedef Volumes_t::iterator Volumes_i
typedef boost::unordered_map
< TGeoVolume *, Match
Volumes_t

Public Member Functions

void assertNodeFilterCache (NodeInfo &data)
virtual FWTableCellRendererBasecellRenderer (int iSortedRowNumber, int iCol) const
void checkChildMatches (TGeoVolume *v, std::vector< TGeoVolume * > &)
void checkHierarchy ()
 FWGeometryTableManager (FWGeometryTableView *)
bool getVisibility (const NodeInfo &nodeInfo) const
bool getVisibilityChld (const NodeInfo &nodeInfo) const
void importChildren (int parent_idx)
void loadGeometry (TGeoNode *iGeoTopNode, TObjArray *iVolumes)
virtual int numberOfColumns () const
 Number of columns in the table.
void printMaterials ()
virtual void recalculateVisibility ()
void recalculateVisibilityNodeRec (int)
void recalculateVisibilityVolumeRec (int)
void setDaughtersSelfVisibility (int i, bool v)
void setVisibility (NodeInfo &nodeInfo, bool)
void setVisibilityChld (NodeInfo &nodeInfo, bool)
void updateFilter ()
virtual ~FWGeometryTableManager ()

Protected Member Functions

virtual const char * cellName (const NodeInfo &data) const
virtual bool nodeIsParent (const NodeInfo &) const

Private Member Functions

 FWGeometryTableManager (const FWGeometryTableManager &)
const FWGeometryTableManageroperator= (const FWGeometryTableManager &)

Private Attributes

FWGeometryTableViewm_browser
bool m_filterOff
Volumes_t m_volumes

Detailed Description

Description: [one line class summary]

Usage: <usage>

Definition at line 32 of file FWGeometryTableManager.h.


Member Typedef Documentation

typedef Volumes_t::iterator FWGeometryTableManager::Volumes_i

Definition at line 55 of file FWGeometryTableManager.h.

typedef boost::unordered_map<TGeoVolume*, Match> FWGeometryTableManager::Volumes_t

Definition at line 54 of file FWGeometryTableManager.h.


Member Enumeration Documentation

Enumerator:
kNameColumn 
kColorColumn 
kVisSelfColumn 
kVisChildColumn 
kMaterialColumn 
kNumColumn 

Definition at line 35 of file FWGeometryTableManager.h.

Enumerator:
kMatches 
kChildMatches 
kFilterCached 

Definition at line 37 of file FWGeometryTableManager.h.

   {
      kMatches         =  BIT(5),
      kChildMatches    =  BIT(6),
      kFilterCached    =  BIT(7)
   };

Constructor & Destructor Documentation

FWGeometryTableManager::FWGeometryTableManager ( FWGeometryTableView v)

Definition at line 24 of file FWGeometryTableManager.cc.

FWGeometryTableManager::~FWGeometryTableManager ( ) [virtual]

Definition at line 32 of file FWGeometryTableManager.cc.

{
}
FWGeometryTableManager::FWGeometryTableManager ( const FWGeometryTableManager ) [private]

Member Function Documentation

void FWGeometryTableManager::assertNodeFilterCache ( NodeInfo data)

Definition at line 392 of file FWGeometryTableManager.cc.

References kChildMatches, FWGeometryTableManagerBase::kExpanded, kFilterCached, kMatches, FWGeometryTableManagerBase::NodeInfo::m_node, m_volumes, FWGeometryTableManagerBase::NodeInfo::setBit(), FWGeometryTableManagerBase::NodeInfo::setBitVal(), setVisibility(), setVisibilityChld(), and FWGeometryTableManagerBase::NodeInfo::testBit().

Referenced by recalculateVisibility(), recalculateVisibilityNodeRec(), and recalculateVisibilityVolumeRec().

{
   if (!data.testBit(kFilterCached))
   {
      bool matches = m_volumes[data.m_node->GetVolume()].m_matches;
      data.setBitVal(kMatches, matches);
      setVisibility(data, matches);

      bool childMatches = m_volumes[data.m_node->GetVolume()].m_childMatches;
      data.setBitVal(kChildMatches, childMatches);
      data.setBitVal(kExpanded, childMatches);
      setVisibilityChld(data, childMatches);

      data.setBit(kFilterCached);
      //  printf("%s matches [%d] childMatches [%d] ................ %d %d \n", data.name(), data.testBit(kMatches), data.testBit(kChildMatches), matches , childMatches);
   }
}
const char * FWGeometryTableManager::cellName ( const NodeInfo data) const [protected, virtual]

Reimplemented from FWGeometryTableManagerBase.

Definition at line 36 of file FWGeometryTableManager.cc.

References FWGeometryTableView::getVolumeMode(), m_browser, and FWGeometryTableManagerBase::NodeInfo::m_node.

Referenced by cellRenderer().

{
   if (m_browser->getVolumeMode())
      return Form("%s [%d]", data.m_node->GetVolume()->GetName(), data.m_node->GetNdaughters());
   else    
      return Form("%s [%d]", data.m_node->GetName(), data.m_node->GetNdaughters()); 
}
FWTableCellRendererBase * FWGeometryTableManager::cellRenderer ( int  iSortedRowNumber,
int  iCol 
) const [virtual]

Returns the particular renderer used to handle the requested cell. Arguments: iSortedRowNumber: the row number from the present sort (i.e. the cell number of the view) iCol: the column number of the cell. The returned value must be used immediately and not held onto since the same Renderer can be used for subsequent calls

Implements FWTableManagerBase.

Definition at line 46 of file FWGeometryTableManager.cc.

References cellName(), AlCaHLTBitMon_QueryRunRegistry::data, getVisibility(), getVisibilityChld(), FWTextTreeCellRenderer::iconWidth(), kColorColumn, FWGeometryTableManagerBase::kExpanded, FWGeometryTableManagerBase::kHighlighted, kMatches, kMaterialColumn, kNameColumn, FWGeometryTableManagerBase::kSelected, kVisChildColumn, kVisSelfColumn, testEve_cfg::level, FWGeometryTableManagerBase::NodeInfo::m_color, FWGeometryTableManagerBase::m_colorBoxRenderer, FWGeometryTableManagerBase::m_entries, FWGeometryTableManagerBase::m_highlightContext, FWGeometryTableManagerBase::NodeInfo::m_level, FWGeometryTableManagerBase::m_levelOffset, FWGeometryTableManagerBase::NodeInfo::m_node, FWGeometryTableManagerBase::m_renderer, FWGeometryTableManagerBase::m_row_to_index, nodeIsParent(), FWTextTableCellRenderer::setData(), FWGeometryTableManagerBase::ColorBoxRenderer::setData(), FWTextTreeCellRenderer::setIndentation(), FWTextTreeCellRenderer::setIsOpen(), FWTextTreeCellRenderer::setIsParent(), and FWGeometryTableManagerBase::NodeInfo::testBit().

{
   FWTextTreeCellRenderer* renderer = &m_renderer;
   if (m_row_to_index.empty()) return renderer;


   int unsortedRow =  m_row_to_index[iSortedRowNumber];
   if (unsortedRow < 0) printf("!!!!!!!!!!!!!!!! error %d %d \n",unsortedRow,  iSortedRowNumber);


   const NodeInfo& data = m_entries[unsortedRow];
   TGeoNode& gn = *data.m_node;
   bool isSelected = data.testBit(kHighlighted) ||  data.testBit(kSelected);
   // printf("cell render %s \n", data.name());
   if (data.testBit(kSelected))
   {
      m_highlightContext->SetBackground(0xc86464);
   }
   else if (data.testBit(kHighlighted) )
   {
      m_highlightContext->SetBackground(0x6464c8);
   }
   else if (iCol == kMaterialColumn && data.testBit(kMatches) )
   {
         m_highlightContext->SetBackground(0xdddddd);
   }


   if (iCol == kNameColumn)
   {
      renderer->setData(cellName(data), isSelected); 


      renderer->setIsParent(nodeIsParent(data));

      renderer->setIsOpen( data.testBit(FWGeometryTableManagerBase::kExpanded));

      int level = data.m_level - m_levelOffset;
      if (nodeIsParent(data))
         renderer->setIndentation(20*level);
      else
         renderer->setIndentation(20*level + FWTextTreeCellRenderer::iconWidth());

      return renderer;
   }
   else
   {
      // printf("title %s \n",data.m_node->GetTitle() );
      renderer->setIsParent(false);
      renderer->setIndentation(0);
      if (iCol == kColorColumn)
      {
         // m_colorBoxRenderer.setData(data.m_node->GetVolume()->GetLineColor(), isSelected);
         m_colorBoxRenderer.setData(data.m_color, isSelected);
         return  &m_colorBoxRenderer;
      }
      else if (iCol == kVisSelfColumn )
      {
         renderer->setData(getVisibility(data)  ? "On" : "-",  isSelected );
         return renderer;
      }
      else if (iCol == kVisChildColumn )
      {
         renderer->setData( getVisibilityChld(data) ? "On" : "-",  isSelected);
         return renderer;
      }
      else if (iCol == kMaterialColumn )
      { 
         renderer->setData( gn.GetVolume()->GetMaterial()->GetName(),  isSelected);
         return renderer;
      }
      else
      {  renderer->setData("ERROR", false);
         return renderer;
      }

   }
}
void FWGeometryTableManager::checkChildMatches ( TGeoVolume *  v,
std::vector< TGeoVolume * > &  pstack 
)

Definition at line 175 of file FWGeometryTableManager.cc.

References i, FWGeometryTableManager::Match::m_childMatches, and m_volumes.

Referenced by updateFilter().

{
   if (m_volumes[vol].m_matches)
   {
      for (std::vector<TGeoVolume*>::iterator i = pstack.begin(); i!= pstack.end(); ++i)
      {
         Match& pm =  m_volumes[*i];
         pm.m_childMatches = true; 
      }
   }

   pstack.push_back(vol);

   int nD =  vol->GetNdaughters();//TMath::Min(m_browser->getMaxDaughters(), vol->GetNdaughters());
   for (int i = 0; i!=nD; ++i)
      checkChildMatches(vol->GetNode(i)->GetVolume(), pstack);
   
   pstack.pop_back();
}
void FWGeometryTableManager::checkHierarchy ( )

Definition at line 151 of file FWGeometryTableManager.cc.

References alignCSCRings::e, i, FWGeometryTableManagerBase::m_entries, mergeVDriftHistosByStation::name, and convertSQLiteXML::ok.

{
   // Used for debug: in a NodeInfo entry look TGeoNode children from parent index and check
   // if child is found.
   
   for ( size_t i = 0,  e = m_entries.size(); i != e; ++i )
   {
      if ( m_entries[i].m_level > 0)
      {
         TGeoNode* pn = m_entries[m_entries[i].m_parent].m_node;
         bool ok = false;
         for (int d = 0; d < pn->GetNdaughters(); ++d )
         {
            if (m_entries[i].m_node ==  pn->GetDaughter(d))
            {
               ok = true;
               break;
            }
         }
         if (!ok) printf("!!!!!! node %s has false parent %s \n", m_entries[i].name(), pn->GetName());
      }   
   }
}
bool FWGeometryTableManager::getVisibility ( const NodeInfo nodeInfo) const
bool FWGeometryTableManager::getVisibilityChld ( const NodeInfo nodeInfo) const
void FWGeometryTableManager::importChildren ( int  parent_idx)

Definition at line 126 of file FWGeometryTableManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::data, FWGeometryTableView::getAutoExpand(), FWGeometryTableManagerBase::getNNodesTotal(), FWGeometryTableManagerBase::kExpanded, m_browser, FWGeometryTableManagerBase::NodeInfo::m_color, FWGeometryTableManagerBase::m_entries, FWGeometryTableManagerBase::NodeInfo::m_level, FWGeometryTableManagerBase::NodeInfo::m_node, FWGeometryTableManagerBase::NodeInfo::m_parent, n, dbtoconf::parent, and FWGeometryTableManagerBase::NodeInfo::setBit().

Referenced by loadGeometry().

{
   NodeInfo& parent        = m_entries[parent_idx];
   TGeoNode* parentGeoNode = parent.m_node; 
   int       parentLevel   = parent.m_level; 
   
   int nV = parentGeoNode->GetNdaughters();
   int dOff = 0; 
   for (int n = 0; n != nV; ++n)
   {         
      NodeInfo& data = m_entries[parent_idx + n + 1 + dOff];    
      data.m_node =   parentGeoNode->GetDaughter(n);
      data.m_level =  parentLevel + 1;
      data.m_parent = parent_idx;
      data.m_color =  data.m_node->GetVolume()->GetLineColor();
      if (data.m_level <=  m_browser->getAutoExpand()) data.setBit(kExpanded);
      
 
      importChildren(parent_idx + n + 1 + dOff);         
      getNNodesTotal(parentGeoNode->GetDaughter(n), dOff);            
   }  
}
void FWGeometryTableManager::loadGeometry ( TGeoNode *  iGeoTopNode,
TObjArray *  iVolumes 
)

Reimplemented from FWGeometryTableManagerBase.

Definition at line 230 of file FWGeometryTableManager.cc.

References FWGeometryTableView::drawTopNode(), FWGeometryTableView::getAutoExpand(), FWGeometryTableManagerBase::getNNodesTotal(), importChildren(), FWGeometryTableManagerBase::kExpanded, FWGeometryTableManagerBase::kVisNodeSelf, m_browser, FWGeometryTableManagerBase::m_entries, m_filterOff, FWGeometryTableManagerBase::NodeInfo::m_level, FWGeometryTableManagerBase::m_levelOffset, FWGeometryTableManagerBase::NodeInfo::m_node, FWGeometryTableManagerBase::NodeInfo::m_parent, FWGeometryTableManagerBase::m_row_to_index, m_volumes, MultipleCompare::Match(), FWGeometryTableManagerBase::NodeInfo::setBitVal(), updateFilter(), and v.

Referenced by FWGeometryTableView::FWGeometryTableView().

{
#ifdef PERFTOOL_GEO_TABLE  
   ProfilerStart("loadGeo");
#endif
   
   // Prepare data for cell render.
   
   // clear entries
   m_entries.clear();
   m_row_to_index.clear();
   m_volumes.clear();
   m_levelOffset = 0;

   // set volume table for filters
   boost::unordered_map<TGeoVolume*, Match>  pipi(iVolumes->GetSize());
   m_volumes.swap(pipi);
   TIter next( iVolumes);
   TGeoVolume* v;
   while ((v = (TGeoVolume*) next()) != 0)
      m_volumes.insert(std::make_pair(v, Match()));

   if (!m_filterOff)
      updateFilter();  

   // add top node to init
 
   int nTotal = 0;
   NodeInfo topNodeInfo;
   topNodeInfo.m_node   = iGeoTopNode;
   topNodeInfo.m_level  = 0;
   topNodeInfo.m_parent = -1;
   topNodeInfo.setBitVal(kExpanded, m_browser->getAutoExpand());
   topNodeInfo.setBitVal(kVisNodeSelf, m_browser->drawTopNode());

   getNNodesTotal(topNodeInfo.m_node , nTotal);
   m_entries.resize(nTotal+1);
   m_entries[0] = topNodeInfo;

   importChildren(0);

   // checkHierarchy();
   
#ifdef PERFTOOL_GEO_TABLE  
   ProfilerStop();
#endif
}
bool FWGeometryTableManager::nodeIsParent ( const NodeInfo data) const [protected, virtual]

Reimplemented from FWGeometryTableManagerBase.

Definition at line 481 of file FWGeometryTableManager.cc.

References kChildMatches, m_filterOff, FWGeometryTableManagerBase::NodeInfo::m_node, and FWGeometryTableManagerBase::NodeInfo::testBit().

Referenced by cellRenderer().

{
   return   (data.m_node->GetNdaughters() != 0) && (m_filterOff || data.testBit(kChildMatches) );
}
virtual int FWGeometryTableManager::numberOfColumns ( ) const [inline, virtual]

Number of columns in the table.

Implements FWTableManagerBase.

Definition at line 82 of file FWGeometryTableManager.h.

References kNumColumn.

{ return kNumColumn; }
const FWGeometryTableManager& FWGeometryTableManager::operator= ( const FWGeometryTableManager ) [private]
void FWGeometryTableManager::printMaterials ( )

Definition at line 281 of file FWGeometryTableManager.cc.

References dtNoiseDBValidation_cfg::cerr.

{
   std::cerr << "not implemented \n";
}
void FWGeometryTableManager::recalculateVisibility ( ) [virtual]
void FWGeometryTableManager::recalculateVisibilityNodeRec ( int  pIdx)

Definition at line 365 of file FWGeometryTableManager.cc.

References assertNodeFilterCache(), AlCaHLTBitMon_QueryRunRegistry::data, FWGeometryTableManagerBase::getNNodesTotal(), UserOptions_cff::idx, kChildMatches, FWGeometryTableManagerBase::kExpanded, kMatches, FWGeometryTableManagerBase::m_entries, m_filterOff, FWGeometryTableManagerBase::m_row_to_index, n, FWGeometryTableManagerBase::NodeInfo::testBit(), and FWGeometryTableManagerBase::NodeInfo::testBitAny().

Referenced by recalculateVisibility().

{
   TGeoNode* parentNode = m_entries[pIdx].m_node;
   int nD = parentNode->GetNdaughters();
   int dOff=0;
   for (int n = 0; n != nD; ++n)
   {
      int idx = pIdx + 1 + n + dOff;
      NodeInfo& data = m_entries[idx];

      if (m_filterOff)
      {
         m_row_to_index.push_back(idx);
         if (data.testBit(kExpanded)) recalculateVisibilityNodeRec(idx);
      }
      else
      {
         assertNodeFilterCache(data);
         if (data.testBitAny(kMatches | kChildMatches)) m_row_to_index.push_back(idx); 
         if (data.testBit(kChildMatches) && data.testBit(kExpanded) ) recalculateVisibilityNodeRec(idx);
      }

      FWGeometryTableManagerBase::getNNodesTotal(parentNode->GetDaughter(n), dOff);
   }
} 
void FWGeometryTableManager::recalculateVisibilityVolumeRec ( int  pIdx)

Definition at line 314 of file FWGeometryTableManager.cc.

References assertNodeFilterCache(), AlCaHLTBitMon_QueryRunRegistry::data, FWGeometryTableManagerBase::getNNodesTotal(), UserOptions_cff::idx, kChildMatches, FWGeometryTableManagerBase::kExpanded, kMatches, FWGeometryTableManagerBase::m_entries, m_filterOff, FWGeometryTableManagerBase::NodeInfo::m_node, FWGeometryTableManagerBase::m_row_to_index, n, FWGeometryTableManagerBase::NodeInfo::testBit(), FWGeometryTableManagerBase::NodeInfo::testBitAny(), and makeLayoutFileForGui::toAdd.

Referenced by recalculateVisibility().

{
   TGeoNode* parentNode = m_entries[pIdx].m_node;
   int nD = parentNode->GetNdaughters();
   int dOff=0;

   // printf("----------- parent %s\n", parentNode->GetName() );

   std::vector<int> vi; 
   vi.reserve(nD);


   for (int n = 0; n != nD; ++n)
   {
      int idx = pIdx + 1 + n + dOff;
      NodeInfo& data = m_entries[idx];

      bool toAdd = true;
      for (std::vector<int>::iterator u = vi.begin(); u != vi.end(); ++u )
      {
         TGeoVolume* neighbourVolume =  parentNode->GetDaughter(*u)->GetVolume();
         if (neighbourVolume == data.m_node->GetVolume())
         {
            toAdd = false;
            // printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
            break;
         }
      }

      if (toAdd)
      {
         vi.push_back(n);
         if (m_filterOff)
         {
            //    std::cout << data.nameIndent() << std::endl;
            m_row_to_index.push_back(idx);
            if (data.testBit(kExpanded)) recalculateVisibilityVolumeRec(idx);
         }
         else
         {
            assertNodeFilterCache(data);
            if (data.testBitAny(kMatches | kChildMatches)) m_row_to_index.push_back(idx); 
            if (data.testBit(kChildMatches) && data.testBit(kExpanded)) recalculateVisibilityVolumeRec(idx);
         }
      }
      FWGeometryTableManagerBase::getNNodesTotal(parentNode->GetDaughter(n), dOff);
   }
}
void FWGeometryTableManager::setDaughtersSelfVisibility ( int  i,
bool  v 
)

Definition at line 444 of file FWGeometryTableManager.cc.

References AlCaHLTBitMon_QueryRunRegistry::data, FWGeometryTableManagerBase::getNNodesTotal(), UserOptions_cff::idx, FWGeometryTableManagerBase::m_entries, n, setVisibility(), and setVisibilityChld().

Referenced by FWGeometryTableView::chosenItem().

{
   int dOff = 0;
   TGeoNode* parentNode = m_entries[selectedIdx].m_node;
   int nD = parentNode->GetNdaughters();
   for (int n = 0; n != nD; ++n)
   {
      int idx = selectedIdx + 1 + n + dOff;
      NodeInfo& data = m_entries[idx];

      setVisibility(data, v);
      setVisibilityChld(data, v);

      FWGeometryTableManager::getNNodesTotal(parentNode->GetDaughter(n), dOff);
   }
}
void FWGeometryTableManager::setVisibility ( NodeInfo nodeInfo,
bool  x 
)
void FWGeometryTableManager::setVisibilityChld ( NodeInfo nodeInfo,
bool  x 
)
void FWGeometryTableManager::updateFilter ( )

Definition at line 197 of file FWGeometryTableManager.cc.

References checkChildMatches(), FWGeometryTableView::getFilter(), FWGeometryTableViewBase::getTopNodeIdx(), i, kFilterCached, m_browser, FWGeometryTableManagerBase::m_entries, m_filterOff, m_volumes, and siStripFEDMonitor_P5_cff::Max.

Referenced by loadGeometry(), and FWGeometryTableView::updateFilter().

{
   std::string filterExp =  m_browser->getFilter();
   m_filterOff =  filterExp.empty();
   //   printf("update filter %s  OFF %d volumes size %d\n",filterExp.c_str(),  m_filterOff , (int)m_volumes.size());

   if (m_filterOff || m_entries.empty()) return;
   
   // update volume-match entries
   //   m_numVolumesMatched = 0;
   for (Volumes_i i = m_volumes.begin(); i!= m_volumes.end(); ++i) 
   {
      if (strcasestr(i->first->GetMaterial()->GetName(), filterExp.c_str()) > 0) {
         i->second.m_matches = true;
         //    m_numVolumesMatched++;
      }
      else {
         i->second.m_matches = false;
      }
      i->second.m_childMatches = false;
   }  

   std::vector<TGeoVolume*> pstack;
   checkChildMatches(m_entries[TMath::Max(0,m_browser->getTopNodeIdx())].m_node->GetVolume(), pstack);
 

   for (Entries_i ni = m_entries.begin(); ni != m_entries.end(); ++ni)
      ni->resetBit(kFilterCached);

}

Member Data Documentation