File indexing completed on 2024-04-06 12:11:31
0001 #ifndef Fireworks_Core_FWGeometryTableManagerBase_h
0002 #define Fireworks_Core_FWGeometryTableManagerBase_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include <sigc++/sigc++.h>
0022
0023 #include "Fireworks/Core/interface/FWGeometryTableViewBase.h"
0024
0025 #include "Fireworks/TableWidget/interface/FWTableManagerBase.h"
0026 #include "Fireworks/TableWidget/interface/FWTextTreeCellRenderer.h"
0027 #include "Fireworks/TableWidget/interface/FWTextTableCellRenderer.h"
0028 #include "Fireworks/TableWidget/interface/FWTableCellRendererBase.h"
0029
0030 #include "TGeoNode.h"
0031
0032 class FWTableCellRendererBase;
0033 class TGeoNode;
0034 class TEvePointSet;
0035
0036 class FWGeometryTableManagerBase : public FWTableManagerBase {
0037 friend class FWGeometryTableViewBase;
0038
0039 public:
0040
0041
0042 enum Bits {
0043 kExpanded = BIT(0),
0044
0045 kVisNodeSelf = BIT(1),
0046 kVisNodeChld = BIT(2),
0047
0048 kHighlighted = BIT(3),
0049 kSelected = BIT(4)
0050 };
0051
0052 struct NodeInfo {
0053 NodeInfo() : m_node(nullptr), m_parent(-1), m_color(0), m_level(-1), m_flags(kVisNodeSelf | kVisNodeChld) {}
0054
0055 NodeInfo(TGeoNode* n, Int_t p, Color_t col, Char_t l, UChar_t f = kVisNodeSelf | kVisNodeChld)
0056 : m_node(n), m_parent(p), m_color(col), m_level(l), m_flags(f) {}
0057
0058 TGeoNode* m_node;
0059 Int_t m_parent;
0060 Color_t m_color;
0061 UChar_t m_level;
0062 UChar_t m_flags;
0063 UChar_t m_transparency;
0064
0065 const char* name() const;
0066
0067
0068 void setBit(UChar_t f) { m_flags |= f; }
0069 void resetBit(UChar_t f) { m_flags &= ~f; }
0070 void setBitVal(UChar_t f, bool x) { x ? setBit(f) : resetBit(f); }
0071
0072 bool testBit(UChar_t f) const { return (m_flags & f) == f; }
0073 bool testBitAny(UChar_t f) const { return (m_flags & f) != 0; }
0074
0075 void switchBit(UChar_t f) { testBit(f) ? resetBit(f) : setBit(f); }
0076
0077 void copyColorTransparency(const NodeInfo& x) {
0078 m_color = x.m_color;
0079 m_transparency = x.m_transparency;
0080 if (m_node->GetVolume()) {
0081 m_node->GetVolume()->SetLineColor(x.m_color);
0082 m_node->GetVolume()->SetTransparency(x.m_transparency);
0083 }
0084 }
0085 };
0086
0087 typedef std::vector<NodeInfo> Entries_v;
0088 typedef Entries_v::iterator Entries_i;
0089
0090 int m_highlightIdx;
0091
0092
0093
0094 class ColorBoxRenderer : public FWTableCellRendererBase {
0095 public:
0096 ColorBoxRenderer();
0097 ~ColorBoxRenderer() override;
0098
0099 UInt_t width() const override { return m_width; }
0100 UInt_t height() const override { return m_height; }
0101 void setData(Color_t c, bool);
0102 void draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight) override;
0103
0104 UInt_t m_width;
0105 UInt_t m_height;
0106 Pixel_t m_color;
0107 bool m_isSelected;
0108 TGGC* m_colorContext;
0109 };
0110
0111 protected:
0112 virtual bool nodeIsParent(const NodeInfo&) const { return false; }
0113
0114
0115 public:
0116 FWGeometryTableManagerBase();
0117 ~FWGeometryTableManagerBase() override;
0118
0119 virtual const char* cellName(const NodeInfo&) const { return nullptr; }
0120
0121
0122
0123 int unsortedRowNumber(int unsorted) const override;
0124 int numberOfRows() const override;
0125 std::vector<std::string> getTitles() const override;
0126
0127 virtual const std::string title() const;
0128
0129
0130
0131
0132
0133 std::vector<int> rowToIndex() { return m_row_to_index; }
0134
0135
0136 void implSort(int, bool) override {}
0137
0138 bool nodeImported(int idx) const;
0139
0140
0141 NodeInfo* getSelected();
0142
0143 Entries_v& refEntries() { return m_entries; }
0144 NodeInfo& refEntry(int i) { return m_entries[i]; }
0145
0146 void loadGeometry(TGeoNode*, TObjArray*);
0147
0148 void setBackgroundToWhite(bool);
0149 void getNodePath(int, std::string&) const;
0150
0151 int getLevelOffset() const { return m_levelOffset; }
0152 void setLevelOffset(int x) { m_levelOffset = x; }
0153
0154 void setDaughtersSelfVisibility(bool);
0155
0156 void getNodeMatrix(const NodeInfo& nodeInfo, TGeoHMatrix& mat) const;
0157
0158 virtual void setVisibility(NodeInfo&, bool);
0159 virtual void setVisibilityChld(NodeInfo&, bool);
0160 virtual void setDaughtersSelfVisibility(int selectedIdx, bool v);
0161
0162 virtual bool getVisibilityChld(const NodeInfo& nodeInfo) const;
0163 virtual bool getVisibility(const NodeInfo& nodeInfo) const;
0164
0165 virtual void applyColorTranspToDaughters(int selectedIdx, bool recurse);
0166
0167 bool isNodeRendered(int idx, int top_node_idx) const;
0168
0169 static void getNNodesTotal(TGeoNode* geoNode, int& off);
0170
0171 void showEditor(int);
0172 void cancelEditor(bool);
0173 void setCellValueEditor(TGTextEntry* editor);
0174 void applyTransparencyFromEditor();
0175
0176 FWGeometryTableManagerBase(const FWGeometryTableManagerBase&);
0177 const FWGeometryTableManagerBase& operator=(const FWGeometryTableManagerBase&);
0178
0179 bool firstColumnClicked(int row, int xPos);
0180
0181
0182 void redrawTable(bool setExpand = false);
0183
0184 virtual void recalculateVisibility() = 0;
0185
0186 bool cellDataIsSortable() const override { return false; }
0187
0188
0189
0190 mutable TGGC* m_highlightContext;
0191 mutable FWTextTreeCellRenderer m_renderer;
0192 mutable ColorBoxRenderer m_colorBoxRenderer;
0193
0194 std::vector<int> m_row_to_index;
0195
0196 Entries_v m_entries;
0197
0198 int m_levelOffset;
0199
0200 TGTextEntry* m_editor;
0201 int m_editTransparencyIdx;
0202 };
0203
0204 inline void FWGeometryTableManagerBase::getNNodesTotal(TGeoNode* geoNode, int& off) {
0205 int nD = geoNode->GetNdaughters();
0206 off += nD;
0207 for (int i = 0; i < nD; ++i) {
0208 getNNodesTotal(geoNode->GetDaughter(i), off);
0209 }
0210 }
0211
0212 #endif