CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWGeometryTableManager.h
Go to the documentation of this file.
1 #ifndef Fireworks_Core_FWGeometryTableManager_h
2 #define Fireworks_Core_FWGeometryTableManager_h
3 // -*- C++ -*-
4 //
5 // Package: Core
6 // Class : FWGeometryTableManager
7 //
16 //
17 // Original Author: Alja Mrak-Tadel, Matevz Tadel
18 // Created: Thu Jan 27 14:50:40 CET 2011
19 // $Id: FWGeometryTableManager.h,v 1.30 2011/07/20 22:11:49 amraktad Exp $
20 //
21 
22 #include <sigc++/sigc++.h>
23 #include <boost/tr1/unordered_map.hpp>
24 
26 
31 
32 #include "TGeoNode.h"
33 #include "TGeoVolume.h"
34 
36 // class FWGeometryTableView;
37 //class TGeoManager;
38 class TGeoNode;
39 
41 {
42  friend class FWGeometryTableView;
43 
44 public:
45  enum ECol { kName, kColor, kVisSelf, kVisChild, kMaterial, kPosX, kPosY, kPosZ /*, kDiagonal*/, kNumCol };
46 
47  enum Bits
48  {
49  kExpanded = BIT(0),
50  kMatches = BIT(1),
51  kChildMatches = BIT(2),
52  kFilterCached = BIT(3),
53 
54  kVisNode = BIT(4),
55  kVisNodeChld = BIT(5)
56  // kVisVol = BIT(6),
57  // kVisVolChld = BIT(7),
58 
59  };
60 
61  struct NodeInfo
62  {
63  NodeInfo():m_node(0), m_parent(-1), m_color(0), m_level(-1),
65  {}
66 
67  TGeoNode* m_node;
68  Int_t m_parent;
69  Color_t m_color;
72 
73  const char* name() const;
74  const char* nameIndent() const;
75 
76  void setBit(UChar_t f) { m_flags |= f;}
77  void resetBit(UChar_t f) { m_flags &= ~f; }
78  void setBitVal(UChar_t f, bool x) { x ? setBit(f) : resetBit(f);}
79 
80  bool testBit(UChar_t f) const { return (m_flags & f) == f; }
81  bool testBitAny(UChar_t f) const { return (m_flags & f) != 0; }
82 
83  void switchBit(UChar_t f) { testBit(f) ? resetBit(f) : setBit(f); }
84  };
85 
86  struct Match
87  {
88  bool m_matches;
91 
92  bool accepted() { return m_matches || m_childMatches; }
93  };
94 
95  typedef std::vector<NodeInfo> Entries_v;
96  typedef Entries_v::iterator Entries_i;
97 
98  typedef boost::unordered_map<TGeoVolume*, Match> Volumes_t;
99  typedef Volumes_t::iterator Volumes_i;
100 
101 private:
102  // AMT: this could be a common base class with FWCollectionSummaryModelCellRenderer ..
104  {
105  public:
107  virtual ~ColorBoxRenderer();
108 
109  virtual UInt_t width() const { return m_width; }
110  virtual UInt_t height() const { return m_height; }
111  void setData(Color_t c, bool);
112  virtual void draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight);
113 
116  Pixel_t m_color;
119  };
120 
121 public:
123  virtual ~FWGeometryTableManager();
124 
125  // virtual functions of FWTableManagerBase
126 
127  virtual int unsortedRowNumber(int unsorted) const;
128  virtual int numberOfRows() const;
129  virtual int numberOfColumns() const;
130  virtual std::vector<std::string> getTitles() const;
131  virtual FWTableCellRendererBase* cellRenderer(int iSortedRowNumber, int iCol) const;
132 
133  virtual const std::string title() const;
134 
135  int selectedRow() const;
136  int selectedColumn() const;
137  virtual bool rowIsSelected(int row) const;
138 
139  std::vector<int> rowToIndex() { return m_row_to_index; }
140 
141  void setSelection(int row, int column, int mask);
142  virtual void implSort(int, bool) {}
143 
144  void printChildren(int) const;
145  bool nodeImported(int idx) const;
146  // geo stuff
149 
150  void loadGeometry( TGeoNode* , TObjArray*);
151  void setBackgroundToWhite(bool);
152  void getNodePath(int, std::string&) const;
153 
154  int getLevelOffset() const { return m_levelOffset; }
155 
156  void assertNodeFilterCache(NodeInfo& data);
157 
158  void setDaughtersSelfVisibility(bool);
159 
160  void getNodeMatrix(const NodeInfo& nodeInfo, TGeoHMatrix& mat) const;
161 
162  void setVisibility(NodeInfo& nodeInfo, bool );
163  void setVisibilityChld(NodeInfo& nodeInfo, bool);
164 
165  bool getVisibilityChld(const NodeInfo& nodeInfo) const;
166  bool getVisibility (const NodeInfo& nodeInfo) const;
167 
168  static void getNNodesTotal(TGeoNode* geoNode, int& off);
169 
170 private:
171  FWGeometryTableManager(const FWGeometryTableManager&); // stop default
172  const FWGeometryTableManager& operator=(const FWGeometryTableManager&); // stop default
173 
174 
175  void firstColumnClicked(int row);
176 
177  // table mng
178  void changeSelection(int iRow, int iColumn);
179  void redrawTable();
180 
181  void recalculateVisibility();
184 
185  // geo
186  void checkChildMatches(TGeoVolume* v, std::vector<TGeoVolume*>&);
187  void importChildren(int parent_idx);
188  void checkHierarchy();
189 
190 
191  // signal callbacks
192  void updateFilter();
193  void checkExpandLevel();
194  void topGeoNodeChanged(int);
195  void printMaterials();
196 
197  // const std::string& getStatusMessage() const { return m_statusMessage; }
198  // ---------- member data --------------------------------
199 
200 
201  // table stuff
204 
205  std::vector<int> m_row_to_index;
209 
210  // geo stuff
212 
215 
216  bool m_filterOff; //cached
217  int m_numVolumesMatched; //cached
218 
221  // int m_geoTopNodeIdx;
222 
223  // std::string m_statusMessage;
224 };
225 
226 
227 
228 inline void FWGeometryTableManager::getNNodesTotal(TGeoNode* geoNode, int& off)
229 {
230  int nD = geoNode->GetNdaughters();
231  off += nD;
232  for (int i = 0; i < nD; ++i )
233  {
234  getNNodesTotal(geoNode->GetDaughter(i), off);
235  }
236 }
237 
238 #endif
void setVisibility(NodeInfo &nodeInfo, bool)
FWGeometryTableView * m_browser
void loadGeometry(TGeoNode *, TObjArray *)
int i
Definition: DBlmapReader.cc:9
virtual int unsortedRowNumber(int unsorted) const
when passed the index to the sorted order of the rows it returns the original row number from the und...
virtual std::vector< std::string > getTitles() const
returns the title names for each column
bool getVisibilityChld(const NodeInfo &nodeInfo) const
virtual FWTableCellRendererBase * cellRenderer(int iSortedRowNumber, int iCol) const
virtual void implSort(int, bool)
Called by &#39;sort&#39; method to actually handle the sorting of the rows. Arguments are the same as &#39;sort&#39;...
FWGeometryTableManager(FWGeometryTableView *)
virtual UInt_t width() const
returns the minimum width of the cell to which the renderer is representing
std::vector< NodeInfo > Entries_v
FWTextTreeCellRenderer m_renderer
void setVisibilityChld(NodeInfo &nodeInfo, bool)
void getNodePath(int, std::string &) const
const FWGeometryTableManager & operator=(const FWGeometryTableManager &)
virtual bool rowIsSelected(int row) const
std::vector< int > rowToIndex()
ColorBoxRenderer m_colorBoxRenderer
unsigned char UChar_t
Definition: FUTypes.h:14
std::vector< int > m_row_to_index
virtual const std::string title() const
virtual UInt_t height() const
returns the minimum height of the cell to which the renderer is representing
bool getVisibility(const NodeInfo &nodeInfo) const
double f[11][100]
virtual void draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight)
void assertNodeFilterCache(NodeInfo &data)
unsigned int UInt_t
Definition: FUTypes.h:12
void setSelection(int row, int column, int mask)
bool nodeImported(int idx) const
void getNodeMatrix(const NodeInfo &nodeInfo, TGeoHMatrix &mat) const
static void getNNodesTotal(TGeoNode *geoNode, int &off)
Entries_v::iterator Entries_i
void checkChildMatches(TGeoVolume *v, std::vector< TGeoVolume * > &)
virtual int numberOfColumns() const
Number of columns in the table.
Volumes_t::iterator Volumes_i
Definition: DDAxes.h:10
boost::unordered_map< TGeoVolume *, Match > Volumes_t
void importChildren(int parent_idx)
virtual int numberOfRows() const
Number of rows in the table.
mathSSE::Vec4< T > v
void changeSelection(int iRow, int iColumn)