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