]>
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 | { |
91 | QT_Undef, | |
92 | QT_FreeQuad, | |
93 | QT_AxisAligned, | |
94 | QT_AxisAlignedFixedDim, | |
95 | QT_AxisAlignedFixedZ, | |
96 | QT_AxisAlignedFixedY, | |
97 | QT_AxisAlignedFixedDimZ, | |
98 | QT_AxisAlignedFixedDimY, | |
99 | // line modes (needed for uniform handling of silicon-strip digits) | |
100 | QT_LineFixedZ, | |
101 | QT_LineFixedY | |
102 | }; | |
103 | ||
104 | enum RenderMode_e { RM_AsIs, RM_Line, RM_Fill }; | |
3aa97c5d | 105 | |
106 | protected: | |
8be1b0cc | 107 | struct QuadBase |
108 | { | |
109 | Int_t fValue; | |
110 | // Here could have additional integer (like time, second threshold). | |
111 | ||
112 | QuadBase(Int_t v=0) : fValue(v) {} | |
3aa97c5d | 113 | }; |
114 | ||
8be1b0cc | 115 | struct FreeQuad : public QuadBase |
116 | { | |
3aa97c5d | 117 | Float_t fVertices[12]; |
118 | }; | |
119 | ||
8be1b0cc | 120 | struct AAFixDimZQuad : public QuadBase |
121 | { | |
3aa97c5d | 122 | Float_t fX, fY; |
123 | }; | |
124 | ||
8be1b0cc | 125 | struct AAFixDimQuad : public AAFixDimZQuad |
126 | { | |
3aa97c5d | 127 | Float_t fZ; |
128 | }; | |
129 | ||
8be1b0cc | 130 | struct AAFixZQuad : public AAFixDimZQuad |
131 | { | |
3aa97c5d | 132 | Float_t fW, fH; |
133 | }; | |
134 | ||
8be1b0cc | 135 | struct AAQuad : public AAFixDimQuad |
136 | { | |
3aa97c5d | 137 | Float_t fW, fH; |
138 | }; | |
139 | ||
8be1b0cc | 140 | struct LineFixedZ : public AAFixDimZQuad |
141 | { | |
142 | Float_t fDx, fDy; | |
143 | }; | |
144 | ||
3aa97c5d | 145 | protected: |
146 | QuadType_e fQuadType; | |
8be1b0cc | 147 | Bool_t fValueIsColor; |
148 | Int_t fDefaultValue; | |
149 | VoidCPlex fPlex; | |
150 | QuadBase* fLastQuad; //! | |
3aa97c5d | 151 | |
3aa97c5d | 152 | Float_t fDefWidth; |
153 | Float_t fDefHeight; | |
8be1b0cc | 154 | Float_t fDefCoord; |
3aa97c5d | 155 | |
8be1b0cc | 156 | FrameBox* fFrame; |
157 | RGBAPalette* fPalette; | |
158 | RenderMode_e fRenderMode; | |
3aa97c5d | 159 | ZTrans fHMTrans; |
160 | ||
8be1b0cc | 161 | static Int_t SizeofAtom(QuadType_e qt); |
162 | QuadBase* NewQuad(); | |
163 | ||
3aa97c5d | 164 | public: |
165 | QuadSet(const Text_t* n="QuadSet", const Text_t* t=""); | |
8be1b0cc | 166 | QuadSet(QuadType_e quadType, Bool_t valIsCol, Int_t chunkSize, |
167 | const Text_t* n="QuadSet", const Text_t* t=""); | |
168 | virtual ~QuadSet(); | |
169 | ||
170 | virtual Bool_t CanEditMainColor() { return kTRUE; } | |
171 | ||
172 | void Reset(QuadType_e quadType, Bool_t valIsCol, Int_t chunkSize); | |
173 | void RefitPlex(); | |
174 | ||
175 | void ScanMinMaxValues(Int_t& min, Int_t& max); | |
176 | ||
177 | Float_t GetDefWidth() const { return fDefWidth; } | |
178 | Float_t GetDefHeight() const { return fDefHeight; } | |
179 | Float_t GetDefCoord() const { return fDefCoord; } | |
180 | ||
181 | void SetDefWidth(Float_t v) { fDefWidth = v ; } | |
182 | void SetDefHeight(Float_t v) { fDefHeight = v ; } | |
183 | void SetDefCoord(Float_t v) { fDefCoord = v ; } | |
184 | ||
185 | // -------------------------------- | |
186 | ||
187 | FrameBox* GetFrame() const { return fFrame; } | |
188 | void SetFrame(FrameBox* b); | |
189 | ||
190 | RGBAPalette* GetPalette() const { return fPalette; } | |
191 | void SetPalette(RGBAPalette* p); | |
192 | ||
193 | RenderMode_e GetRenderMode() const { return fRenderMode; } | |
194 | void SetRenderMode(RenderMode_e rm) { fRenderMode = rm; } | |
3aa97c5d | 195 | |
196 | ZTrans& RefHMTrans() { return fHMTrans; } | |
197 | void SetTransMatrix(Double_t* carr) { fHMTrans.SetFrom(carr); } | |
198 | void SetTransMatrix(const TGeoMatrix& mat) { fHMTrans.SetFrom(mat); } | |
199 | ||
8be1b0cc | 200 | // -------------------------------- |
201 | ||
202 | void AddQuad(Float_t* verts); | |
203 | void AddQuad(Float_t x, Float_t y); | |
204 | void AddQuad(Float_t x, Float_t y, Float_t z); | |
205 | void AddQuad(Float_t x, Float_t y, Float_t w, Float_t h); | |
206 | void AddQuad(Float_t x, Float_t y, Float_t z, Float_t w, Float_t h); | |
207 | ||
208 | void QuadValue(Int_t value); | |
209 | void QuadColor(Color_t ci); | |
210 | void QuadColor(UChar_t r, UChar_t g, UChar_t b, UChar_t a=255); | |
211 | ||
212 | // -------------------------------- | |
213 | ||
214 | // void Test(Int_t nquads); | |
5a5a1232 | 215 | |
216 | virtual void ComputeBBox(); | |
217 | ||
8be1b0cc | 218 | virtual void Paint(Option_t* option=""); |
5a5a1232 | 219 | |
220 | ClassDef(QuadSet, 1); | |
221 | }; | |
222 | ||
223 | } // namespace Reve | |
224 | ||
225 | #endif |