Go to the documentation of this file.00001 #ifndef Fireworks_Core_FWGeometryTableManagerBase_h
00002 #define Fireworks_Core_FWGeometryTableManagerBase_h
00003
00004
00005
00006
00007
00016
00017
00018
00019
00020
00021
00022 #include <sigc++/sigc++.h>
00023
00024 #include "Fireworks/Core/interface/FWGeometryTableViewBase.h"
00025
00026 #include "Fireworks/TableWidget/interface/FWTableManagerBase.h"
00027 #include "Fireworks/TableWidget/interface/FWTextTreeCellRenderer.h"
00028 #include "Fireworks/TableWidget/interface/FWTextTableCellRenderer.h"
00029 #include "Fireworks/TableWidget/interface/FWTableCellRendererBase.h"
00030
00031 #include "TGeoNode.h"
00032
00033 class FWTableCellRendererBase;
00034 class TGeoNode;
00035 class TEvePointSet;
00036
00037 class FWGeometryTableManagerBase : public FWTableManagerBase
00038 {
00039 friend class FWGeometryTableViewBase;
00040
00041 public:
00042
00043
00044 enum Bits
00045 {
00046 kExpanded = BIT(0),
00047
00048 kVisNodeSelf = BIT(1),
00049 kVisNodeChld = BIT(2),
00050
00051 kHighlighted = BIT(3),
00052 kSelected = BIT(4)
00053 };
00054
00055 struct NodeInfo
00056 {
00057 NodeInfo():m_node(0), m_parent(-1), m_color(0), m_level(-1),
00058 m_flags(kVisNodeSelf|kVisNodeChld) {}
00059
00060 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),
00061 m_flags(f) {}
00062
00063 TGeoNode* m_node;
00064 Int_t m_parent;
00065 Color_t m_color;
00066 UChar_t m_level;
00067 UChar_t m_flags;
00068
00069 const char* name() const;
00070
00071
00072 void setBit(UChar_t f) { m_flags |= f;}
00073 void resetBit(UChar_t f) { m_flags &= ~f; }
00074 void setBitVal(UChar_t f, bool x) { x ? setBit(f) : resetBit(f);}
00075
00076 bool testBit(UChar_t f) const { return (m_flags & f) == f; }
00077 bool testBitAny(UChar_t f) const { return (m_flags & f) != 0; }
00078
00079 void switchBit(UChar_t f) { testBit(f) ? resetBit(f) : setBit(f); }
00080 };
00081
00082
00083 typedef std::vector<NodeInfo> Entries_v;
00084 typedef Entries_v::iterator Entries_i;
00085
00086 int m_highlightIdx;
00087
00088
00089
00090 class ColorBoxRenderer : public FWTableCellRendererBase
00091 {
00092 public:
00093 ColorBoxRenderer();
00094 virtual ~ColorBoxRenderer();
00095
00096 virtual UInt_t width() const { return m_width; }
00097 virtual UInt_t height() const { return m_height; }
00098 void setData(Color_t c, bool);
00099 virtual void draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight);
00100
00101 UInt_t m_width;
00102 UInt_t m_height;
00103 Pixel_t m_color;
00104 bool m_isSelected;
00105 TGGC* m_colorContext;
00106 };
00107
00108 protected:
00109 virtual bool nodeIsParent(const NodeInfo&) const { return false; }
00110
00111
00112 public:
00113 FWGeometryTableManagerBase();
00114 virtual ~FWGeometryTableManagerBase();
00115
00116 virtual const char* cellName(const NodeInfo& ) const { return 0;}
00117
00118
00119
00120 virtual int unsortedRowNumber(int unsorted) const;
00121 virtual int numberOfRows() const;
00122 virtual std::vector<std::string> getTitles() const;
00123
00124 virtual const std::string title() const;
00125
00126
00127
00128
00129
00130 std::vector<int> rowToIndex() { return m_row_to_index; }
00131
00132
00133 virtual void implSort(int, bool) {}
00134
00135 bool nodeImported(int idx) const;
00136
00137
00138 NodeInfo* getSelected();
00139
00140 Entries_v& refEntries() {return m_entries;}
00141 NodeInfo& refEntry(int i) {return m_entries[i];}
00142
00143 void loadGeometry( TGeoNode* , TObjArray*);
00144
00145 void setBackgroundToWhite(bool);
00146 void getNodePath(int, std::string&) const;
00147
00148 int getLevelOffset() const { return m_levelOffset; }
00149 void setLevelOffset(int x) { m_levelOffset =x; }
00150
00151 void setDaughtersSelfVisibility(bool);
00152
00153 void getNodeMatrix(const NodeInfo& nodeInfo, TGeoHMatrix& mat) const;
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163 static void getNNodesTotal(TGeoNode* geoNode, int& off);
00164
00165
00166
00167 FWGeometryTableManagerBase(const FWGeometryTableManagerBase&);
00168 const FWGeometryTableManagerBase& operator=(const FWGeometryTableManagerBase&);
00169
00170
00171 bool firstColumnClicked(int row, int xPos);
00172
00173
00174 void redrawTable(bool setExpand = false);
00175
00176 virtual void recalculateVisibility() = 0;
00177
00178
00179 virtual bool cellDataIsSortable() const { return false ; }
00180
00181
00182
00183
00184 mutable TGGC* m_highlightContext;
00185 mutable FWTextTreeCellRenderer m_renderer;
00186 mutable ColorBoxRenderer m_colorBoxRenderer;
00187
00188 std::vector<int> m_row_to_index;
00189
00190 Entries_v m_entries;
00191
00192
00193 int m_levelOffset;
00194 };
00195
00196
00197
00198 inline void FWGeometryTableManagerBase::getNNodesTotal(TGeoNode* geoNode, int& off)
00199 {
00200 int nD = geoNode->GetNdaughters();
00201 off += nD;
00202 for (int i = 0; i < nD; ++i )
00203 {
00204 getNNodesTotal(geoNode->GetDaughter(i), off);
00205 }
00206 }
00207
00208 #endif