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 
38 
39 public:
40  // enum ESelectionState { kNone, kSelected, kHighlighted, kFiltered };
41 
42  enum Bits {
43  kExpanded = BIT(0),
44 
45  kVisNodeSelf = BIT(1),
46  kVisNodeChld = BIT(2),
47 
48  kHighlighted = BIT(3),
49  kSelected = BIT(4)
50  };
51 
52  struct NodeInfo {
54 
55  NodeInfo(TGeoNode* n, Int_t p, Color_t col, Char_t l, UChar_t f = kVisNodeSelf | kVisNodeChld)
56  : m_node(n), m_parent(p), m_color(col), m_level(l), m_flags(f) {}
57 
58  TGeoNode* m_node;
59  Int_t m_parent;
60  Color_t m_color;
61  UChar_t m_level;
62  UChar_t m_flags;
63  UChar_t m_transparency;
64 
65  const char* name() const;
66  // const char* nameIndent() const;
67 
68  void setBit(UChar_t f) { m_flags |= f; }
69  void resetBit(UChar_t f) { m_flags &= ~f; }
70  void setBitVal(UChar_t f, bool x) { x ? setBit(f) : resetBit(f); }
71 
72  bool testBit(UChar_t f) const { return (m_flags & f) == f; }
73  bool testBitAny(UChar_t f) const { return (m_flags & f) != 0; }
74 
75  void switchBit(UChar_t f) { testBit(f) ? resetBit(f) : setBit(f); }
76 
78  m_color = x.m_color;
79  m_transparency = x.m_transparency;
80  if (m_node->GetVolume()) {
81  m_node->GetVolume()->SetLineColor(x.m_color);
82  m_node->GetVolume()->SetTransparency(x.m_transparency);
83  }
84  }
85  };
86 
87  typedef std::vector<NodeInfo> Entries_v;
88  typedef Entries_v::iterator Entries_i;
89 
91 
92  //private:
93  // AMT: this could be a common base class with FWCollectionSummaryModelCellRenderer ..
95  public:
97  ~ColorBoxRenderer() override;
98 
99  UInt_t width() const override { return m_width; }
100  UInt_t height() const override { return m_height; }
101  void setData(Color_t c, bool);
102  void draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight) override;
103 
104  UInt_t m_width;
105  UInt_t m_height;
106  Pixel_t m_color;
109  };
110 
111 protected:
112  virtual bool nodeIsParent(const NodeInfo&) const { return false; }
113  // virtual ESelectionState nodeSelectionState(int idx) const;
114 
115 public:
117  ~FWGeometryTableManagerBase() override;
118  // virtual std::string& cellName(const NodeInfo& ) const { return &std::string("ddd");}
119  virtual const char* cellName(const NodeInfo&) const { return nullptr; }
120 
121  // virtual functions of FWTableManagerBase
122 
123  int unsortedRowNumber(int unsorted) const override;
124  int numberOfRows() const override;
125  std::vector<std::string> getTitles() const override;
126 
127  virtual const std::string title() const;
128 
129  //int selectedRow() const;
130  //int selectedColumn() const;
131  //virtual bool rowIsSelected(int row) const;
132 
133  std::vector<int> rowToIndex() { return m_row_to_index; }
134 
135  // void setSelection(int row, int column, int mask);
136  void implSort(int, bool) override {}
137 
138  bool nodeImported(int idx) const;
139  // geo stuff
140 
141  NodeInfo* getSelected();
142 
144  NodeInfo& refEntry(int i) { return m_entries[i]; }
145 
146  void loadGeometry(TGeoNode*, TObjArray*);
147 
148  void setBackgroundToWhite(bool);
149  void getNodePath(int, std::string&) const;
150 
151  int getLevelOffset() const { return m_levelOffset; }
152  void setLevelOffset(int x) { m_levelOffset = x; }
153 
154  void setDaughtersSelfVisibility(bool);
155 
156  void getNodeMatrix(const NodeInfo& nodeInfo, TGeoHMatrix& mat) const;
157 
158  virtual void setVisibility(NodeInfo&, bool);
159  virtual void setVisibilityChld(NodeInfo&, bool);
160  virtual void setDaughtersSelfVisibility(int selectedIdx, bool v);
161 
162  virtual bool getVisibilityChld(const NodeInfo& nodeInfo) const;
163  virtual bool getVisibility(const NodeInfo& nodeInfo) const;
164 
165  virtual void applyColorTranspToDaughters(int selectedIdx, bool recurse);
166 
167  bool isNodeRendered(int idx, int top_node_idx) const;
168 
169  static void getNNodesTotal(TGeoNode* geoNode, int& off);
170 
171  void showEditor(int);
172  void cancelEditor(bool);
173  void setCellValueEditor(TGTextEntry* editor);
175  // protected:
177  const FWGeometryTableManagerBase& operator=(const FWGeometryTableManagerBase&); // stop default
178 
179  bool firstColumnClicked(int row, int xPos);
180  // void changeSelection(int iRow, int iColumn);
181 
182  void redrawTable(bool setExpand = false);
183 
184  virtual void recalculateVisibility() = 0;
185 
186  bool cellDataIsSortable() const override { return false; }
187  // ---------- member data --------------------------------
188 
189  // table stuff
190  mutable TGGC* m_highlightContext;
193 
194  std::vector<int> m_row_to_index;
195 
197 
199 
200  TGTextEntry* m_editor;
202 };
203 
204 inline void FWGeometryTableManagerBase::getNNodesTotal(TGeoNode* geoNode, int& off) {
205  int nD = geoNode->GetNdaughters();
206  off += nD;
207  for (int i = 0; i < nD; ++i) {
208  getNNodesTotal(geoNode->GetDaughter(i), off);
209  }
210 }
211 
212 #endif
bool firstColumnClicked(int row, int xPos)
bool cellDataIsSortable() const override
int unsortedRowNumber(int unsorted) const override
when passed the index to the sorted order of the rows it returns the original row number from the und...
virtual void recalculateVisibility()=0
virtual void applyColorTranspToDaughters(int selectedIdx, bool recurse)
virtual void setVisibilityChld(NodeInfo &, bool)
virtual const std::string title() const
UInt_t height() const override
returns the minimum height of the cell to which the renderer is representing
void getNodePath(int, std::string &) const
UInt_t width() const override
returns the minimum width of the cell to which the renderer is representing
const FWGeometryTableManagerBase & operator=(const FWGeometryTableManagerBase &)
double f[11][100]
virtual bool nodeIsParent(const NodeInfo &) const
void loadGeometry(TGeoNode *, TObjArray *)
bool isNodeRendered(int idx, int top_node_idx) const
void implSort(int, bool) override
Called by &#39;sort&#39; method to actually handle the sorting of the rows. Arguments are the same as &#39;sort&#39;...
void setDaughtersSelfVisibility(bool)
virtual void setVisibility(NodeInfo &, bool)
static void getNNodesTotal(TGeoNode *geoNode, int &off)
void draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight) override
NodeInfo(TGeoNode *n, Int_t p, Color_t col, Char_t l, UChar_t f=kVisNodeSelf|kVisNodeChld)
int numberOfRows() const override
Number of rows in the table.
virtual const char * cellName(const NodeInfo &) const
void setCellValueEditor(TGTextEntry *editor)
virtual bool getVisibilityChld(const NodeInfo &nodeInfo) const
bool nodeImported(int idx) const
virtual bool getVisibility(const NodeInfo &nodeInfo) const
void getNodeMatrix(const NodeInfo &nodeInfo, TGeoHMatrix &mat) const
col
Definition: cuy.py:1009
void redrawTable(bool setExpand=false)
std::vector< std::string > getTitles() const override
returns the title names for each column