Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TEveQuadSet.cxx
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TEveQuadSet.h"
13
14#include "TEveManager.h"
15
16#include "TBuffer3D.h"
17#include "TBuffer3DTypes.h"
18#include "TVirtualViewer3D.h"
19
20/** \class TEveQuadSet
21\ingroup TEve
22Supports various internal formats that result in rendering of a
23set of planar (lines, rectangles, hexagons with shared normal) objects.
24
25Names of internal structures and their variables use A, B and C as
26names for coordinate value-holders. Typical assignment is A->X,
27B->Y, C->Z but each render mode can override this convention and
28impose y or x as a fixed (third or C) coordinate. Alphabetic order
29is obeyed in this correspondence.
30
31For quad modes the deltas are expected to be positive.
32For line modes negative deltas are ok.
33*/
34
36
37////////////////////////////////////////////////////////////////////////////////
38/// Constructor.
39
40TEveQuadSet::TEveQuadSet(const char* n, const char* t) :
41 TEveDigitSet (n, t),
42
43 fQuadType (kQT_Undef),
44 fDefWidth (1),
45 fDefHeight (1),
46 fDefCoord (0)
47{
48}
49
50////////////////////////////////////////////////////////////////////////////////
51/// Constructor.
52
53TEveQuadSet::TEveQuadSet(EQuadType_e quadType, Bool_t valIsCol, Int_t chunkSize,
54 const char* n, const char* t) :
55 TEveDigitSet (n, t),
56
57 fQuadType (kQT_Undef),
58 fDefWidth (1),
59 fDefHeight (1),
60 fDefCoord (0)
61{
62 Reset(quadType, valIsCol, chunkSize);
63}
64
65////////////////////////////////////////////////////////////////////////////////
66/// Return size of given atom type.
67
69{
70 static const TEveException eH("TEveQuadSet::SizeofAtom ");
71
72 switch (qt) {
73 case kQT_Undef: return 0;
74 case kQT_FreeQuad: return sizeof(QFreeQuad_t);
75 case kQT_RectangleXY:
76 case kQT_RectangleXZ:
77 case kQT_RectangleYZ: return sizeof(QRect_t);
78 case kQT_RectangleXYFixedDim: return sizeof(QRectFixDim_t);
81 case kQT_RectangleYZFixedX: return sizeof(QRectFixC_t);
84 case kQT_RectangleYZFixedDimX: return sizeof(QRectFixDimC_t);
86 case kQT_LineXYFixedZ: return sizeof(QLineFixC_t);
87 case kQT_HexagonXY:
88 case kQT_HexagonYX: return sizeof(QHex_t);
89 default: throw(eH + "unexpected atom type.");
90 }
91 return 0;
92}
93
94////////////////////////////////////////////////////////////////////////////////
95/// Clear the quad-set and reset the basic parameters.
96
98 Int_t chunkSize)
99{
100 fQuadType = quadType;
101 fValueIsColor = valIsCol;
102 fDefaultValue = valIsCol ? 0 : kMinInt;
103 if (fOwnIds)
104 ReleaseIds();
105 fPlex.Reset(SizeofAtom(fQuadType), chunkSize);
106}
107
108////////////////////////////////////////////////////////////////////////////////
109/// Add a quad specified with 4 vertices.
110
112{
113 static const TEveException eH("TEveQuadSet::AddQuad ");
114
115 if (fQuadType != kQT_FreeQuad)
116 throw(eH + "expect free quad-type.");
117
119 if (verts != 0)
120 memcpy(fq->fVertices, verts, sizeof(fq->fVertices));
121}
122
123////////////////////////////////////////////////////////////////////////////////
124/// Add a quad with a and b coordinates. Defaults are applied for
125/// c coordinate and sizes.
126
128{
130}
131
132////////////////////////////////////////////////////////////////////////////////
133/// Add a quad with a, b and c coordinates. Defaults are applied
134/// for sizes.
135
137{
139}
140
141////////////////////////////////////////////////////////////////////////////////
142/// Add a quad with a and b coordinates and sizes. Default is applied
143/// for c coordinate.
144
146{
147 AddQuad(a, b, fDefCoord, w, h);
148}
149
150////////////////////////////////////////////////////////////////////////////////
151/// Add a quad with a, b and c coordinates and sizes.
152
154{
155 static const TEveException eH("TEveQuadSet::AddAAQuad ");
156
157 QOrigin_t& fq = * (QOrigin_t*) NewDigit();
158 fq.fA = a; fq.fB = b;
159 switch (fQuadType)
160 {
161 case kQT_RectangleXY:
162 case kQT_RectangleXZ:
163 case kQT_RectangleYZ:
164 {
165 QRect_t& q = (QRect_t&) fq;
166 q.fC = c; q.fW = w; q.fH = h;
167 break;
168 }
169
171 {
173 q.fC = c;
174 break;
175 }
176
180 {
181 QRectFixC_t& q = (QRectFixC_t&) fq;
182 q.fW = w; q.fH = h;
183 break;
184 }
185
189 {
190 break;
191 }
192
193 default:
194 throw(eH + "expect axis-aligned quad-type.");
195 }
196}
197
198////////////////////////////////////////////////////////////////////////////////
199/// Add a line with starting coordinates and displacements.
200
202{
203 static const TEveException eH("TEveQuadSet::AddLine ");
204
205 QOrigin_t& fq = * (QOrigin_t*) NewDigit();
206 fq.fA = a; fq.fB = b;
207 switch (fQuadType)
208 {
209 case kQT_LineXZFixedY:
210 case kQT_LineXYFixedZ: {
211 QLineFixC_t& q = (QLineFixC_t&) fq;
212 q.fDx = w; q.fDy = h;
213 break;
214 }
215 default:
216 throw(eH + "expect line quad-type.");
217 }
218}
219
220////////////////////////////////////////////////////////////////////////////////
221/// Add a hexagon with given center (a,b,c) and radius.
222
224{
225 static const TEveException eH("TEveQuadSet::AddHexagon ");
226
227 QOrigin_t& fq = * (QOrigin_t*) NewDigit();
228 fq.fA = a; fq.fB = b;
229 switch (fQuadType)
230 {
231 case kQT_HexagonXY:
232 case kQT_HexagonYX: {
233 QHex_t& q = (QHex_t&) fq;
234 q.fC = c; q.fR = r;
235 break;
236 }
237 default:
238 throw eH + "expects hexagon quad-type.";
239 }
240}
241
242////////////////////////////////////////////////////////////////////////////////
243/// Fill bounding-box information. Virtual from TAttBBox.
244/// If member 'TEveFrameBox* fFrame' is set, frame's corners are
245/// used as bbox.
246
248{
249 static const TEveException eH("TEveQuadSet::ComputeBBox ");
250
251 if (fFrame != 0)
252 {
253 BBoxInit();
254 Int_t n = fFrame->GetFrameSize() / 3;
255 Float_t *bbps = fFrame->GetFramePoints();
256 for (int i=0; i<n; ++i, bbps+=3)
257 BBoxCheckPoint(bbps);
258 }
259 else
260 {
261 if(fPlex.Size() == 0) {
262 BBoxZero();
263 return;
264 }
265
266 BBoxInit();
269 {
270 fBBox[4] = fDefCoord;
271 fBBox[5] = fDefCoord;
272 }
273 else if (fQuadType == kQT_RectangleXZFixedY ||
275 {
276 fBBox[2] = fDefCoord;
277 fBBox[3] = fDefCoord;
278 }
279 else if (fQuadType == kQT_RectangleYZFixedX ||
281 {
282 fBBox[0] = fDefCoord;
283 fBBox[1] = fDefCoord;
284 }
285
287
288 switch (fQuadType)
289 {
290
291 case kQT_FreeQuad:
292 {
293 while (qi.next()) {
294 const Float_t* p = ((QFreeQuad_t*) qi())->fVertices;
295 BBoxCheckPoint(p); p += 3;
296 BBoxCheckPoint(p); p += 3;
297 BBoxCheckPoint(p); p += 3;
299 }
300 break;
301 }
302
303 case kQT_RectangleXY:
304 {
305 while (qi.next()) {
306 QRect_t& q = * (QRect_t*) qi();
307 if(q.fA < fBBox[0]) fBBox[0] = q.fA;
308 if(q.fA + q.fW > fBBox[1]) fBBox[1] = q.fA + q.fW;
309 if(q.fB < fBBox[2]) fBBox[2] = q.fB;
310 if(q.fB + q.fH > fBBox[3]) fBBox[3] = q.fB + q.fH;
311 if(q.fC < fBBox[4]) fBBox[4] = q.fC;
312 if(q.fC > fBBox[5]) fBBox[5] = q.fC;
313 }
314 break;
315 }
316
317 case kQT_RectangleXZ:
318 {
319 while (qi.next()) {
320 QRect_t& q = * (QRect_t*) qi();
321 if(q.fA < fBBox[0]) fBBox[0] = q.fA;
322 if(q.fA + q.fW > fBBox[1]) fBBox[1] = q.fA + q.fW;
323 if(q.fB < fBBox[4]) fBBox[4] = q.fB;
324 if(q.fB + q.fH > fBBox[5]) fBBox[5] = q.fB + q.fH;
325 if(q.fC < fBBox[2]) fBBox[2] = q.fC;
326 if(q.fC > fBBox[3]) fBBox[3] = q.fC;
327 }
328 break;
329 }
330
331 case kQT_RectangleYZ:
332 {
333 while (qi.next()) {
334 QRect_t& q = * (QRect_t*) qi();
335 if(q.fA < fBBox[2]) fBBox[2] = q.fA;
336 if(q.fA + q.fW > fBBox[3]) fBBox[3] = q.fA + q.fW;
337 if(q.fB < fBBox[4]) fBBox[4] = q.fB;
338 if(q.fB + q.fH > fBBox[5]) fBBox[5] = q.fB + q.fH;
339 if(q.fC < fBBox[0]) fBBox[0] = q.fC;
340 if(q.fC > fBBox[1]) fBBox[1] = q.fC;
341 }
342 break;
343 }
344
346 {
347 const Float_t& w = fDefWidth;
348 const Float_t& h = fDefHeight;
349 while (qi.next()) {
350 QRectFixDim_t& q = * (QRectFixDim_t*) qi();
351 if(q.fA < fBBox[0]) fBBox[0] = q.fA;
352 if(q.fA + w > fBBox[1]) fBBox[1] = q.fA + w;
353 if(q.fB < fBBox[2]) fBBox[2] = q.fB;
354 if(q.fB + h > fBBox[3]) fBBox[3] = q.fB + h;
355 if(q.fC < fBBox[4]) fBBox[4] = q.fC;
356 if(q.fC > fBBox[5]) fBBox[5] = q.fC;
357 }
358 break;
359 }
360
362 {
363 while (qi.next()) {
364 QRectFixC_t& q = * (QRectFixC_t*) qi();
365 if(q.fA < fBBox[0]) fBBox[0] = q.fA;
366 if(q.fA + q.fW > fBBox[1]) fBBox[1] = q.fA + q.fW;
367 if(q.fB < fBBox[2]) fBBox[2] = q.fB;
368 if(q.fB + q.fH > fBBox[3]) fBBox[3] = q.fB + q.fH;
369 }
370 break;
371 }
372
374 {
375 while (qi.next()) {
376 QRectFixC_t& q = * (QRectFixC_t*) qi();
377 if(q.fA < fBBox[0]) fBBox[0] = q.fA;
378 if(q.fA + q.fW > fBBox[1]) fBBox[1] = q.fA + q.fW;
379 if(q.fB < fBBox[4]) fBBox[4] = q.fB;
380 if(q.fB + q.fH > fBBox[5]) fBBox[5] = q.fB + q.fH;
381 }
382 break;
383 }
384
386 {
387 while (qi.next()) {
388 QRectFixC_t& q = * (QRectFixC_t*) qi();
389 if(q.fA < fBBox[2]) fBBox[2] = q.fA;
390 if(q.fA + q.fW > fBBox[3]) fBBox[3] = q.fA + q.fW;
391 if(q.fB < fBBox[4]) fBBox[4] = q.fB;
392 if(q.fB + q.fH > fBBox[5]) fBBox[5] = q.fB + q.fH;
393 }
394 break;
395 }
396
398 {
399 const Float_t& w = fDefWidth;
400 const Float_t& h = fDefHeight;
401 while (qi.next()) {
402 QRectFixDimC_t& q = * (QRectFixDimC_t*) qi();
403 if(q.fA < fBBox[0]) fBBox[0] = q.fA;
404 if(q.fA + w > fBBox[1]) fBBox[1] = q.fA + w;
405 if(q.fB < fBBox[2]) fBBox[2] = q.fB;
406 if(q.fB + h > fBBox[3]) fBBox[3] = q.fB + h;
407 }
408 break;
409 }
410
412 {
413 const Float_t& w = fDefWidth;
414 const Float_t& h = fDefHeight;
415 while (qi.next()) {
416 QRectFixDimC_t& q = * (QRectFixDimC_t*) qi();
417 if(q.fA < fBBox[0]) fBBox[0] = q.fA;
418 if(q.fA + w > fBBox[1]) fBBox[1] = q.fA + w;
419 if(q.fB < fBBox[4]) fBBox[4] = q.fB;
420 if(q.fB + h > fBBox[5]) fBBox[5] = q.fB + h;
421 }
422 break;
423 }
424
426 {
427 const Float_t& w = fDefWidth;
428 const Float_t& h = fDefHeight;
429 while (qi.next()) {
430 QRectFixDimC_t& q = * (QRectFixDimC_t*) qi();
431 if(q.fA < fBBox[2]) fBBox[2] = q.fA;
432 if(q.fA + w > fBBox[3]) fBBox[3] = q.fA + w;
433 if(q.fB < fBBox[4]) fBBox[4] = q.fB;
434 if(q.fB + h > fBBox[5]) fBBox[5] = q.fB + h;
435 }
436 break;
437 }
438
439 // TEveLine modes
440
441 case kQT_LineXYFixedZ:
442 {
443 while (qi.next()) {
444 QLineFixC_t& q = * (QLineFixC_t*) qi();
445 BBoxCheckPoint(q.fA, q.fB, fDefCoord);
446 BBoxCheckPoint(q.fA + q.fDx, q.fB + q.fDy, fDefCoord);
447 }
448 break;
449 }
450
451 case kQT_LineXZFixedY:
452 {
453 while (qi.next()) {
454 QLineFixC_t& q = * (QLineFixC_t*) qi();
455 BBoxCheckPoint(q.fA, fDefCoord, q.fB);
456 BBoxCheckPoint(q.fA + q.fDx, fDefCoord, q.fB + q.fDy);
457 }
458 break;
459 }
460
461 // Hexagon modes
462
463 // Ignore 'slight' difference, assume square box for both cases.
464 case kQT_HexagonXY:
465 case kQT_HexagonYX:
466 {
467 while (qi.next()) {
468 QHex_t& q = * (QHex_t*) qi();
469 BBoxCheckPoint(q.fA-q.fR, q.fB-q.fR, q.fC);
470 BBoxCheckPoint(q.fA+q.fR, q.fB+q.fR, q.fC);
471 }
472 break;
473 }
474
475 default:
476 {
477 throw(eH + "unsupported quad-type.");
478 }
479
480 } // end switch quad-type
481 } // end if frame ... else ...
482}
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
constexpr Int_t kMinInt
Definition RtypesCore.h:113
float Float_t
Definition RtypesCore.h:57
#define ClassImp(name)
Definition Rtypes.h:377
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
float * q
void BBoxCheckPoint(Float_t x, Float_t y, Float_t z)
Definition TAttBBox.h:69
void BBoxZero(Float_t epsilon=0, Float_t x=0, Float_t y=0, Float_t z=0)
Create cube of volume (2*epsilon)^3 at (x,y,z).
Definition TAttBBox.cxx:42
void BBoxInit(Float_t infinity=1e6)
Dynamic Float_t[6] X(min,max), Y(min,max), Z(min,max)
Definition TAttBBox.cxx:29
Float_t * fBBox
Definition TAttBBox.h:20
void Reset(Int_t atom_size, Int_t chunk_size)
Empty the container and reset it with given atom and chunk sizes.
Int_t Size() const
Base-class for storage of digit collections; provides transformation matrix (TEveTrans),...
Int_t fDefaultValue
void ReleaseIds()
Protected method.
TEveChunkManager fPlex
DigitBase_t * NewDigit()
Function providing highlight tooltips when always-sec-select is active.
TEveFrameBox * fFrame
Bool_t fValueIsColor
Exception class thrown by TEve classes and macros.
Definition TEveUtil.h:102
Int_t GetFrameSize() const
Float_t * GetFramePoints() const
Supports various internal formats that result in rendering of a set of planar (lines,...
Definition TEveQuadSet.h:20
Float_t fDefHeight
Definition TEveQuadSet.h:75
void AddQuad(Float_t verts[12])
Add a quad specified with 4 vertices.
@ kQT_RectangleYZFixedX
Definition TEveQuadSet.h:36
@ kQT_RectangleXZFixedDimY
Definition TEveQuadSet.h:38
@ kQT_RectangleXYFixedDim
Definition TEveQuadSet.h:33
@ kQT_RectangleXYFixedZ
Definition TEveQuadSet.h:34
@ kQT_RectangleXYFixedDimZ
Definition TEveQuadSet.h:37
@ kQT_RectangleYZFixedDimX
Definition TEveQuadSet.h:39
@ kQT_RectangleXZFixedY
Definition TEveQuadSet.h:35
virtual void ComputeBBox()
Fill bounding-box information.
Float_t fDefWidth
Definition TEveQuadSet.h:74
TEveQuadSet(const TEveQuadSet &)
static Int_t SizeofAtom(EQuadType_e qt)
Return size of given atom type.
Float_t fDefCoord
Definition TEveQuadSet.h:76
EQuadType_e fQuadType
Definition TEveQuadSet.h:72
void Reset(EQuadType_e quadType, Bool_t valIsCol, Int_t chunkSize)
Clear the quad-set and reset the basic parameters.
void AddLine(Float_t a, Float_t b, Float_t w, Float_t h)
Add a line with starting coordinates and displacements.
void AddHexagon(Float_t a, Float_t b, Float_t z, Float_t r)
Add a hexagon with given center (a,b,c) and radius.
const Int_t n
Definition legend1.C:16
Bool_t next()
Go to next atom.