]>
Commit | Line | Data |
---|---|---|
a8b53f69 | 1 | // $Header$ |
2 | ||
5a5a1232 | 3 | #ifndef REVE_QuadSet_H |
4 | #define REVE_QuadSet_H | |
5 | ||
6 | #include <Gtypes.h> | |
7 | #include <TNamed.h> | |
5ac9ed05 | 8 | #include <TQObject.h> |
5a5a1232 | 9 | #include <TAtt3D.h> |
10 | #include <TAttBBox.h> | |
11 | ||
3aa97c5d | 12 | #include <Reve/Reve.h> |
8be1b0cc | 13 | #include <Reve/RenderElement.h> |
14 | #include <Reve/FrameBox.h> | |
15 | #include <Reve/RGBAPalette.h> | |
16 | #include <Reve/Plex.h> | |
17 | #include <Reve/ZTrans.h> | |
3aa97c5d | 18 | |
5a5a1232 | 19 | #include <vector> |
20 | ||
21 | class TRandom; | |
22 | ||
23 | namespace Reve { | |
24 | ||
25 | struct Quad | |
26 | { | |
27 | Float_t vertices[12]; | |
28 | Int_t color; | |
29 | ||
30 | void ColorFromIdx(Color_t ci); | |
31 | ||
265ecb21 | 32 | Quad(Color_t col = 1) : color(0) |
5a5a1232 | 33 | { ColorFromIdx(col); } |
34 | ||
265ecb21 | 35 | Quad(Color_t col, Float_t* p) : color(0) |
5a5a1232 | 36 | { ColorFromIdx(col); memcpy(vertices, p, 12*sizeof(Float_t)); } |
37 | ||
38 | Quad(TRandom& rnd, Float_t origin, Float_t size); | |
39 | ||
265ecb21 | 40 | Quad(const Quad& org) : color(0) { memcpy(this, &org, sizeof(Quad)); } |
5a5a1232 | 41 | |
a8b53f69 | 42 | virtual ~Quad() {} |
43 | ||
5a5a1232 | 44 | ClassDef(Quad, 1); |
45 | }; | |
46 | ||
3aa97c5d | 47 | class OldQuadSet : public TNamed, public TAtt3D, public TAttBBox |
5a5a1232 | 48 | { |
3aa97c5d | 49 | friend class OldQuadSetGL; |
5a5a1232 | 50 | |
5a5a1232 | 51 | protected: |
52 | std::vector<Quad> fQuads; | |
53 | Double_t fMatrix[16]; | |
54 | Bool_t fTrans; | |
55 | ||
56 | public: | |
3aa97c5d | 57 | OldQuadSet(const Text_t* n="QuadSet", const Text_t* t=""); |
58 | virtual ~OldQuadSet() {} | |
5a5a1232 | 59 | |
60 | Bool_t GetTrans() const { return fTrans; } | |
61 | void SetTrans(Bool_t t) { fTrans = t; } | |
62 | ||
3aa97c5d | 63 | std::vector<Reve::Quad>& Quads() { return fQuads; } |
64 | ||
65 | void Test(Int_t nquads); | |
66 | ||
67 | virtual void ComputeBBox(); | |
68 | ||
69 | virtual void Paint(Option_t* option = ""); | |
70 | ||
71 | ClassDef(OldQuadSet, 1); | |
72 | }; | |
73 | ||
74 | /**************************************************************************/ | |
c4f03896 | 75 | // To become new implementation of QuadSet ... somewhat finished. |
3aa97c5d | 76 | /**************************************************************************/ |
77 | ||
78 | class QuadSet : public RenderElement, | |
5ac9ed05 | 79 | public TNamed, public TQObject, |
3aa97c5d | 80 | public TAtt3D, |
81 | public TAttBBox | |
82 | { | |
c4f03896 | 83 | friend class QuadSetEditor; |
3aa97c5d | 84 | friend class QuadSetGL; |
85 | ||
3c67f72c | 86 | QuadSet(const QuadSet&); // Not implemented |
87 | QuadSet& operator=(const QuadSet&); // Not implemented | |
88 | ||
3aa97c5d | 89 | public: |
90 | enum QuadType_e | |
8be1b0cc | 91 | { |
20358789 | 92 | QT_Undef, // unknown-ignored |
93 | QT_FreeQuad, // arbitrary quad: specify 4*(x,y,z) quad corners | |
94 | QT_RectangleXY, // rectangle in x-y plane: specify x, y, z, w, h | |
253a61b0 | 95 | QT_RectangleXZ, // rectangle in x-z plane: specify x, y, z, w, h |
96 | QT_RectangleYZ, // rectangle in y-z plane: specify x, y, z, w, h | |
20358789 | 97 | QT_RectangleXYFixedDim, // rectangle in x-y plane: specify x, y, z; w, h taken from fDefWidth/Height |
98 | QT_RectangleXYFixedZ, // rectangle in x-y plane: specify x, y, w, h; z taken from fDefCoord | |
99 | QT_RectangleXZFixedY, // rectangle in x-z plane: specify x, z, w, h; y taken from fDefCoord | |
253a61b0 | 100 | QT_RectangleYZFixedX, // rectangle in y-z plane: specify y, z, w, h; x taken from fDefWidth/Height/Coord |
20358789 | 101 | QT_RectangleXYFixedDimZ, // rectangle in x-y plane: specify x, y; w, h, z taken from fDefWidth/Height/Coord |
102 | QT_RectangleXZFixedDimY, // rectangle in x-z plane: specify x, z; w, h, y taken from fDefWidth/Height/Coord | |
253a61b0 | 103 | QT_RectangleYZFixedDimX, // rectangle in y-z plane: specify y, z; w, h, x taken from fDefWidth/Height/Coord |
96c51586 | 104 | QT_Rectangle_End, |
8be1b0cc | 105 | // line modes (needed for uniform handling of silicon-strip digits) |
96c51586 | 106 | QT_LineXYFixedZ, // line in x-y plane: specify x, y, w(dx), h(dy); z taken from fDefCoord |
107 | QT_LineXZFixedY, // line in x-z plane: specify x, z, w(dx), h(dz); y taken from fDefCoord | |
108 | QT_Line_End, | |
109 | // hexagon modes | |
110 | QT_HexagonXY, // horizontal hexagon: specify x, y, z, r | |
111 | QT_HexagonYX, // vertical hexagon: specify x, y, z, r | |
112 | QT_Hexagon_End | |
20358789 | 113 | // circle modes: |
114 | // QT_CircleXY, // specify r, z | |
115 | // QT_CircleXYFixedZ, // specify r | |
116 | // QT_CircleXYFixedR, // specify z | |
8be1b0cc | 117 | }; |
118 | ||
119 | enum RenderMode_e { RM_AsIs, RM_Line, RM_Fill }; | |
3aa97c5d | 120 | |
121 | protected: | |
8be1b0cc | 122 | struct QuadBase |
123 | { | |
124 | Int_t fValue; | |
bcb20c3e | 125 | TRef fId; |
126 | ||
8be1b0cc | 127 | // Here could have additional integer (like time, second threshold). |
128 | ||
f36b73bd | 129 | QuadBase(Int_t v=0) : fValue(v), fId() {} |
3aa97c5d | 130 | }; |
131 | ||
20358789 | 132 | struct QFreeQuad : public QuadBase { Float_t fVertices[12]; }; |
3aa97c5d | 133 | |
253a61b0 | 134 | struct QOrigin : public QuadBase { Float_t fA, fB; }; |
3aa97c5d | 135 | |
20358789 | 136 | struct QRectFixDimC : public QOrigin { }; |
3aa97c5d | 137 | |
253a61b0 | 138 | struct QRectFixDim : public QRectFixDimC { Float_t fC; }; |
3aa97c5d | 139 | |
20358789 | 140 | struct QRectFixC : public QRectFixDimC { Float_t fW, fH; }; |
3aa97c5d | 141 | |
20358789 | 142 | struct QRect : public QRectFixDim { Float_t fW, fH; }; |
143 | ||
144 | struct QLineFixC : public QOrigin { Float_t fDx, fDy; }; | |
8be1b0cc | 145 | |
253a61b0 | 146 | struct QHex : public QOrigin { Float_t fC, fR; }; |
96c51586 | 147 | |
3aa97c5d | 148 | protected: |
149 | QuadType_e fQuadType; | |
8be1b0cc | 150 | Int_t fDefaultValue; |
bcb20c3e | 151 | Bool_t fValueIsColor; |
152 | Bool_t fOwnIds; //Flag specifying if id-objects are owned by the QuadSet | |
8be1b0cc | 153 | VoidCPlex fPlex; |
154 | QuadBase* fLastQuad; //! | |
3aa97c5d | 155 | |
253a61b0 | 156 | Float_t fDefWidth; // Breadth assigned to first coordinate (A) |
157 | Float_t fDefHeight; // Breadth assigned to second coordinate (B) | |
158 | Float_t fDefCoord; // Default value for third coordinate (C) | |
3aa97c5d | 159 | |
8be1b0cc | 160 | FrameBox* fFrame; |
161 | RGBAPalette* fPalette; | |
162 | RenderMode_e fRenderMode; | |
20358789 | 163 | Bool_t fDisableLigting; |
5ac9ed05 | 164 | Bool_t fEmitSignals; |
48fd623d | 165 | Bool_t fHistoButtons; |
3aa97c5d | 166 | ZTrans fHMTrans; |
167 | ||
8be1b0cc | 168 | static Int_t SizeofAtom(QuadType_e qt); |
169 | QuadBase* NewQuad(); | |
170 | ||
bcb20c3e | 171 | void ReleaseIds(); |
172 | ||
3aa97c5d | 173 | public: |
174 | QuadSet(const Text_t* n="QuadSet", const Text_t* t=""); | |
8be1b0cc | 175 | QuadSet(QuadType_e quadType, Bool_t valIsCol, Int_t chunkSize, |
176 | const Text_t* n="QuadSet", const Text_t* t=""); | |
177 | virtual ~QuadSet(); | |
178 | ||
179 | virtual Bool_t CanEditMainColor() { return kTRUE; } | |
5ac9ed05 | 180 | virtual void SetMainColor(Color_t color); |
8be1b0cc | 181 | |
182 | void Reset(QuadType_e quadType, Bool_t valIsCol, Int_t chunkSize); | |
183 | void RefitPlex(); | |
184 | ||
185 | void ScanMinMaxValues(Int_t& min, Int_t& max); | |
186 | ||
187 | Float_t GetDefWidth() const { return fDefWidth; } | |
188 | Float_t GetDefHeight() const { return fDefHeight; } | |
189 | Float_t GetDefCoord() const { return fDefCoord; } | |
190 | ||
191 | void SetDefWidth(Float_t v) { fDefWidth = v ; } | |
192 | void SetDefHeight(Float_t v) { fDefHeight = v ; } | |
193 | void SetDefCoord(Float_t v) { fDefCoord = v ; } | |
194 | ||
195 | // -------------------------------- | |
196 | ||
197 | FrameBox* GetFrame() const { return fFrame; } | |
198 | void SetFrame(FrameBox* b); | |
9bbf03ba | 199 | |
200 | Bool_t GetValueIsColor() const { return fValueIsColor; } | |
8be1b0cc | 201 | |
202 | RGBAPalette* GetPalette() const { return fPalette; } | |
203 | void SetPalette(RGBAPalette* p); | |
20358789 | 204 | RGBAPalette* AssertPalette(); |
8be1b0cc | 205 | |
206 | RenderMode_e GetRenderMode() const { return fRenderMode; } | |
207 | void SetRenderMode(RenderMode_e rm) { fRenderMode = rm; } | |
3aa97c5d | 208 | |
5ac9ed05 | 209 | Bool_t GetEmitSignals() const { return fEmitSignals; } |
210 | void SetEmitSignals(Bool_t f) { fEmitSignals = f; } | |
211 | ||
48fd623d | 212 | Bool_t GetHistoButtons() const { return fHistoButtons; } |
213 | void SetHistoButtons(Bool_t f) { fHistoButtons = f; } | |
214 | ||
3aa97c5d | 215 | ZTrans& RefHMTrans() { return fHMTrans; } |
216 | void SetTransMatrix(Double_t* carr) { fHMTrans.SetFrom(carr); } | |
217 | void SetTransMatrix(const TGeoMatrix& mat) { fHMTrans.SetFrom(mat); } | |
218 | ||
8be1b0cc | 219 | // -------------------------------- |
220 | ||
221 | void AddQuad(Float_t* verts); | |
20358789 | 222 | |
253a61b0 | 223 | void AddQuad(Float_t a, Float_t b); |
224 | void AddQuad(Float_t a, Float_t b, Float_t c); | |
225 | void AddQuad(Float_t a, Float_t b, Float_t w, Float_t h); | |
226 | void AddQuad(Float_t a, Float_t b, Float_t c, Float_t w, Float_t h); | |
8be1b0cc | 227 | |
253a61b0 | 228 | void AddLine(Float_t a, Float_t b, Float_t w, Float_t h); |
20358789 | 229 | |
253a61b0 | 230 | void AddHexagon(Float_t a, Float_t b, Float_t z, Float_t r); |
96c51586 | 231 | |
8be1b0cc | 232 | void QuadValue(Int_t value); |
233 | void QuadColor(Color_t ci); | |
234 | void QuadColor(UChar_t r, UChar_t g, UChar_t b, UChar_t a=255); | |
235 | ||
bcb20c3e | 236 | void QuadId(TObject* id); |
237 | Bool_t GetOwnIds() const { return fOwnIds; } | |
238 | void SetOwnIds(Bool_t o) { fOwnIds = o; } | |
239 | ||
240 | QuadBase* GetQuad(Int_t n) { return (QuadBase*) fPlex.Atom(n); } | |
241 | TObject* GetId(Int_t n) { return GetQuad(n)->fId.GetObject(); } | |
242 | ||
243 | virtual void QuadSelected(Int_t idx); | |
244 | ||
5ac9ed05 | 245 | virtual void CtrlClicked(QuadSet* qs, Int_t idx); // *SIGNAL* |
246 | ||
8be1b0cc | 247 | // -------------------------------- |
248 | ||
249 | // void Test(Int_t nquads); | |
5a5a1232 | 250 | |
251 | virtual void ComputeBBox(); | |
252 | ||
8be1b0cc | 253 | virtual void Paint(Option_t* option=""); |
5a5a1232 | 254 | |
ca462fa9 | 255 | VoidCPlex* GetPlex() { return &fPlex; } |
256 | ||
5a5a1232 | 257 | ClassDef(QuadSet, 1); |
258 | }; | |
259 | ||
260 | } // namespace Reve | |
261 | ||
262 | #endif |