CMS 3D CMS Logo

FWGeometryTableManagerBase.h
Go to the documentation of this file.
1 #ifndef Fireworks_Core_FWGeometryTableManagerBase_h
2 #define Fireworks_Core_FWGeometryTableManagerBase_h
3 // -*- C++ -*-
4 //
5 // Package: Core
6 // Class : FWGeometryTableManagerBase
7 //
16 //
17 // Original Author: Alja Mrak-Tadel, Matevz Tadel
18 // Created: Thu Jan 27 14:50:40 CET 2011
19 //
20 
21 #include <sigc++/sigc++.h>
22 
24 
29 
30 #include "TGeoNode.h"
31 
33 class TGeoNode;
34 class TEvePointSet;
35 
37 {
39 
40 public:
41  // enum ESelectionState { kNone, kSelected, kHighlighted, kFiltered };
42 
43  enum Bits
44  {
45  kExpanded = BIT(0),
46 
47  kVisNodeSelf = BIT(1),
48  kVisNodeChld = BIT(2),
49 
50  kHighlighted = BIT(3),
51  kSelected = BIT(4)
52  };
53 
54  struct NodeInfo
55  {
56  NodeInfo():m_node(0), m_parent(-1), m_color(0), m_level(-1),
58 
59  NodeInfo(TGeoNode* n, Int_t p, Color_t col, Char_t l, UChar_t f = kVisNodeSelf|kVisNodeChld ):m_node(n), m_parent(p), m_color(col), m_level(l),
60  m_flags(f) {}
61 
62  TGeoNode* m_node;
63  Int_t m_parent;
64  Color_t m_color;
65  UChar_t m_level;
66  UChar_t m_flags;
67  UChar_t m_transparency;
68 
69 
70  const char* name() const;
71  // const char* nameIndent() const;
72 
73  void setBit(UChar_t f) { m_flags |= f;}
74  void resetBit(UChar_t f) { m_flags &= ~f; }
75  void setBitVal(UChar_t f, bool x) { x ? setBit(f) : resetBit(f);}
76 
77  bool testBit(UChar_t f) const { return (m_flags & f) == f; }
78  bool testBitAny(UChar_t f) const { return (m_flags & f) != 0; }
79 
80  void switchBit(UChar_t f) { testBit(f) ? resetBit(f) : setBit(f); }
81 
83  m_color = x.m_color; m_transparency = x.m_transparency;
84  if (m_node->GetVolume()) {
85  m_node->GetVolume()->SetLineColor(x.m_color);
86  m_node->GetVolume()->SetTransparency(x.m_transparency);
87  }
88  }
89  };
90 
91 
92  typedef std::vector<NodeInfo> Entries_v;
93  typedef Entries_v::iterator Entries_i;
94 
96 
97  //private:
98  // AMT: this could be a common base class with FWCollectionSummaryModelCellRenderer ..
100  {
101  public:
103  virtual ~ColorBoxRenderer();
104 
105  virtual UInt_t width() const { return m_width; }
106  virtual UInt_t height() const { return m_height; }
107  void setData(Color_t c, bool);
108  virtual void draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight);
109 
110  UInt_t m_width;
111  UInt_t m_height;
112  Pixel_t m_color;
115  };
116 
117 protected:
118  virtual bool nodeIsParent(const NodeInfo&) const { return false; }
119  // virtual ESelectionState nodeSelectionState(int idx) const;
120 
121 public:
123  virtual ~FWGeometryTableManagerBase();
124  // virtual std::string& cellName(const NodeInfo& ) const { return &std::string("ddd");}
125  virtual const char* cellName(const NodeInfo& ) const { return 0;}
126 
127  // virtual functions of FWTableManagerBase
128 
129  virtual int unsortedRowNumber(int unsorted) const;
130  virtual int numberOfRows() const;
131  virtual std::vector<std::string> getTitles() 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  bool nodeImported(int idx) const;
145  // geo stuff
146 
148 
149  Entries_v& refEntries() {return m_entries;}
150  NodeInfo& refEntry(int i) {return m_entries[i];}
151 
152  void loadGeometry( TGeoNode* , TObjArray*);
153 
154  void setBackgroundToWhite(bool);
155  void getNodePath(int, std::string&) const;
156 
157  int getLevelOffset() const { return m_levelOffset; }
158  void setLevelOffset(int x) { m_levelOffset =x; }
159 
160  void setDaughtersSelfVisibility(bool);
161 
162  void getNodeMatrix(const NodeInfo& nodeInfo, TGeoHMatrix& mat) const;
163 
164 
165  virtual void setVisibility(NodeInfo&, bool );
166  virtual void setVisibilityChld(NodeInfo&, bool);
167  virtual void setDaughtersSelfVisibility(int selectedIdx, bool v);
168 
169  virtual bool getVisibilityChld(const NodeInfo& nodeInfo) const;
170  virtual bool getVisibility (const NodeInfo& nodeInfo) const;
171 
172  virtual void applyColorTranspToDaughters(int selectedIdx, bool recurse);
173 
174  bool isNodeRendered(int idx, int top_node_idx) const;
175 
176  static void getNNodesTotal(TGeoNode* geoNode, int& off);
177 
178  void showEditor(int);
179  void cancelEditor(bool);
180  void setCellValueEditor(TGTextEntry *editor);
182  // protected:
184  const FWGeometryTableManagerBase& operator=(const FWGeometryTableManagerBase&); // stop default
185 
186 
187  bool firstColumnClicked(int row, int xPos);
188  // void changeSelection(int iRow, int iColumn);
189 
190  void redrawTable(bool setExpand = false);
191 
192  virtual void recalculateVisibility() = 0;
193 
194 
195  virtual bool cellDataIsSortable() const { return false ; }
196  // ---------- member data --------------------------------
197 
198 
199  // table stuff
200  mutable TGGC* m_highlightContext;
203 
204  std::vector<int> m_row_to_index;
205 
206  Entries_v m_entries;
207 
209 
210  TGTextEntry* m_editor;
212 };
213 
214 
215 
216 inline void FWGeometryTableManagerBase::getNNodesTotal(TGeoNode* geoNode, int& off)
217 {
218  int nD = geoNode->GetNdaughters();
219  off += nD;
220  for (int i = 0; i < nD; ++i )
221  {
222  getNNodesTotal(geoNode->GetDaughter(i), off);
223  }
224 }
225 
226 #endif
bool isNodeRendered(int idx, int top_node_idx) const
virtual std::vector< std::string > getTitles() const
returns the title names for each column
bool firstColumnClicked(int row, int xPos)
virtual bool nodeIsParent(const NodeInfo &) const
virtual bool getVisibility(const NodeInfo &nodeInfo) const
virtual const char * cellName(const NodeInfo &) const
virtual void recalculateVisibility()=0
virtual bool getVisibilityChld(const NodeInfo &nodeInfo) const
void getNodePath(int, std::string &) const
void getNodeMatrix(const NodeInfo &nodeInfo, TGeoHMatrix &mat) const
virtual void applyColorTranspToDaughters(int selectedIdx, bool recurse)
virtual void setVisibilityChld(NodeInfo &, bool)
bool nodeImported(int idx) const
def draw(name, histos, styles=_defaultStyles, legendLabels=[], kwargs)
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;...
const FWGeometryTableManagerBase & operator=(const FWGeometryTableManagerBase &)
virtual const std::string title() const
double f[11][100]
void loadGeometry(TGeoNode *, TObjArray *)
void setDaughtersSelfVisibility(bool)
virtual void setVisibility(NodeInfo &, bool)
static void getNNodesTotal(TGeoNode *geoNode, int &off)
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...
NodeInfo(TGeoNode *n, Int_t p, Color_t col, Char_t l, UChar_t f=kVisNodeSelf|kVisNodeChld)
void setCellValueEditor(TGTextEntry *editor)
col
Definition: cuy.py:1008
virtual UInt_t height() const
returns the minimum height of the cell to which the renderer is representing
virtual UInt_t width() const
returns the minimum width of the cell to which the renderer is representing
virtual bool cellDataIsSortable() const
void redrawTable(bool setExpand=false)
virtual int numberOfRows() const
Number of rows in the table.