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
35
36////////////////////////////////////////////////////////////////////////////////
37/// Constructor.
38
39TEveQuadSet::TEveQuadSet(const char* n, const char* t) :
40 TEveDigitSet (n, t),
41
42 fQuadType (kQT_Undef),
43 fDefWidth (1),
44 fDefHeight (1),
45 fDefCoord (0)
46{
47}
48
49////////////////////////////////////////////////////////////////////////////////
50/// Constructor.
51
53 const char* n, const char* t) :
54 TEveDigitSet (n, t),
55
56 fQuadType (kQT_Undef),
57 fDefWidth (1),
58 fDefHeight (1),
59 fDefCoord (0)
60{
62}
63
64////////////////////////////////////////////////////////////////////////////////
65/// Return size of given atom type.
66
68{
69 static const TEveException eH("TEveQuadSet::SizeofAtom ");
70
71 switch (qt) {
72 case kQT_Undef: return 0;
73 case kQT_FreeQuad: return sizeof(QFreeQuad_t);
74 case kQT_RectangleXY:
75 case kQT_RectangleXZ:
76 case kQT_RectangleYZ: return sizeof(QRect_t);
77 case kQT_RectangleXYFixedDim: return sizeof(QRectFixDim_t);
80 case kQT_RectangleYZFixedX: return sizeof(QRectFixC_t);
83 case kQT_RectangleYZFixedDimX: return sizeof(QRectFixDimC_t);
85 case kQT_LineXYFixedZ: return sizeof(QLineFixC_t);
86 case kQT_HexagonXY:
87 case kQT_HexagonYX: return sizeof(QHex_t);
88 default: throw(eH + "unexpected atom type.");
89 }
90 return 0;
91}
92
93////////////////////////////////////////////////////////////////////////////////
94/// Clear the quad-set and reset the basic parameters.
95
106
107////////////////////////////////////////////////////////////////////////////////
108/// Add a quad specified with 4 vertices.
109
111{
112 static const TEveException eH("TEveQuadSet::AddQuad ");
113
114 if (fQuadType != kQT_FreeQuad)
115 throw(eH + "expect free quad-type.");
116
118 if (verts != nullptr)
119 memcpy(fq->fVertices, verts, sizeof(fq->fVertices));
120}
121
122////////////////////////////////////////////////////////////////////////////////
123/// Add a quad with a and b coordinates. Defaults are applied for
124/// c coordinate and sizes.
125
130
131////////////////////////////////////////////////////////////////////////////////
132/// Add a quad with a, b and c coordinates. Defaults are applied
133/// for sizes.
134
139
140////////////////////////////////////////////////////////////////////////////////
141/// Add a quad with a and b coordinates and sizes. Default is applied
142/// for c coordinate.
143
148
149////////////////////////////////////////////////////////////////////////////////
150/// Add a quad with a, b and c coordinates and sizes.
151
153{
154 static const TEveException eH("TEveQuadSet::AddAAQuad ");
155
156 QOrigin_t& fq = * (QOrigin_t*) NewDigit();
157 fq.fA = a; fq.fB = b;
158 switch (fQuadType)
159 {
160 case kQT_RectangleXY:
161 case kQT_RectangleXZ:
162 case kQT_RectangleYZ:
163 {
164 QRect_t& q = (QRect_t&) fq;
165 q.fC = c; q.fW = w; q.fH = h;
166 break;
167 }
168
170 {
172 q.fC = c;
173 break;
174 }
175
179 {
181 q.fW = w; q.fH = h;
182 break;
183 }
184
188 {
189 break;
190 }
191
192 default:
193 throw(eH + "expect axis-aligned quad-type.");
194 }
195}
196
197////////////////////////////////////////////////////////////////////////////////
198/// Add a line with starting coordinates and displacements.
199
201{
202 static const TEveException eH("TEveQuadSet::AddLine ");
203
204 QOrigin_t& fq = * (QOrigin_t*) NewDigit();
205 fq.fA = a; fq.fB = b;
206 switch (fQuadType)
207 {
208 case kQT_LineXZFixedY:
209 case kQT_LineXYFixedZ: {
211 q.fDx = w; q.fDy = h;
212 break;
213 }
214 default:
215 throw(eH + "expect line quad-type.");
216 }
217}
218
219////////////////////////////////////////////////////////////////////////////////
220/// Add a hexagon with given center (a,b,c) and radius.
221
223{
224 static const TEveException eH("TEveQuadSet::AddHexagon ");
225
226 QOrigin_t& fq = * (QOrigin_t*) NewDigit();
227 fq.fA = a; fq.fB = b;
228 switch (fQuadType)
229 {
230 case kQT_HexagonXY:
231 case kQT_HexagonYX: {
232 QHex_t& q = (QHex_t&) fq;
233 q.fC = c; q.fR = r;
234 break;
235 }
236 default:
237 throw eH + "expects hexagon quad-type.";
238 }
239}
240
241////////////////////////////////////////////////////////////////////////////////
242/// Fill bounding-box information. Virtual from TAttBBox.
243/// If member 'TEveFrameBox* fFrame' is set, frame's corners are
244/// used as bbox.
245
247{
248 static const TEveException eH("TEveQuadSet::ComputeBBox ");
249
250 if (fFrame != nullptr)
251 {
252 BBoxInit();
253 Int_t n = fFrame->GetFrameSize() / 3;
255 for (int i=0; i<n; ++i, bbps+=3)
257 }
258 else
259 {
260 if(fPlex.Size() == 0) {
261 BBoxZero();
262 return;
263 }
264
265 BBoxInit();
268 {
269 fBBox[4] = fDefCoord;
270 fBBox[5] = fDefCoord;
271 }
272 else if (fQuadType == kQT_RectangleXZFixedY ||
274 {
275 fBBox[2] = fDefCoord;
276 fBBox[3] = fDefCoord;
277 }
278 else if (fQuadType == kQT_RectangleYZFixedX ||
280 {
281 fBBox[0] = fDefCoord;
282 fBBox[1] = fDefCoord;
283 }
284
286
287 switch (fQuadType)
288 {
289
290 case kQT_FreeQuad:
291 {
292 while (qi.next()) {
293 const Float_t* p = ((QFreeQuad_t*) qi())->fVertices;
294 BBoxCheckPoint(p); p += 3;
295 BBoxCheckPoint(p); p += 3;
296 BBoxCheckPoint(p); p += 3;
298 }
299 break;
300 }
301
302 case kQT_RectangleXY:
303 {
304 while (qi.next()) {
305 QRect_t& q = * (QRect_t*) qi();
306 if(q.fA < fBBox[0]) fBBox[0] = q.fA;
307 if(q.fA + q.fW > fBBox[1]) fBBox[1] = q.fA + q.fW;
308 if(q.fB < fBBox[2]) fBBox[2] = q.fB;
309 if(q.fB + q.fH > fBBox[3]) fBBox[3] = q.fB + q.fH;
310 if(q.fC < fBBox[4]) fBBox[4] = q.fC;
311 if(q.fC > fBBox[5]) fBBox[5] = q.fC;
312 }
313 break;
314 }
315
316 case kQT_RectangleXZ:
317 {
318 while (qi.next()) {
319 QRect_t& q = * (QRect_t*) qi();
320 if(q.fA < fBBox[0]) fBBox[0] = q.fA;
321 if(q.fA + q.fW > fBBox[1]) fBBox[1] = q.fA + q.fW;
322 if(q.fB < fBBox[4]) fBBox[4] = q.fB;
323 if(q.fB + q.fH > fBBox[5]) fBBox[5] = q.fB + q.fH;
324 if(q.fC < fBBox[2]) fBBox[2] = q.fC;
325 if(q.fC > fBBox[3]) fBBox[3] = q.fC;
326 }
327 break;
328 }
329
330 case kQT_RectangleYZ:
331 {
332 while (qi.next()) {
333 QRect_t& q = * (QRect_t*) qi();
334 if(q.fA < fBBox[2]) fBBox[2] = q.fA;
335 if(q.fA + q.fW > fBBox[3]) fBBox[3] = q.fA + q.fW;
336 if(q.fB < fBBox[4]) fBBox[4] = q.fB;
337 if(q.fB + q.fH > fBBox[5]) fBBox[5] = q.fB + q.fH;
338 if(q.fC < fBBox[0]) fBBox[0] = q.fC;
339 if(q.fC > fBBox[1]) fBBox[1] = q.fC;
340 }
341 break;
342 }
343
345 {
346 const Float_t& w = fDefWidth;
347 const Float_t& h = fDefHeight;
348 while (qi.next()) {
350 if(q.fA < fBBox[0]) fBBox[0] = q.fA;
351 if(q.fA + w > fBBox[1]) fBBox[1] = q.fA + w;
352 if(q.fB < fBBox[2]) fBBox[2] = q.fB;
353 if(q.fB + h > fBBox[3]) fBBox[3] = q.fB + h;
354 if(q.fC < fBBox[4]) fBBox[4] = q.fC;
355 if(q.fC > fBBox[5]) fBBox[5] = q.fC;
356 }
357 break;
358 }
359
361 {
362 while (qi.next()) {
363 QRectFixC_t& q = * (QRectFixC_t*) qi();
364 if(q.fA < fBBox[0]) fBBox[0] = q.fA;
365 if(q.fA + q.fW > fBBox[1]) fBBox[1] = q.fA + q.fW;
366 if(q.fB < fBBox[2]) fBBox[2] = q.fB;
367 if(q.fB + q.fH > fBBox[3]) fBBox[3] = q.fB + q.fH;
368 }
369 break;
370 }
371
373 {
374 while (qi.next()) {
375 QRectFixC_t& q = * (QRectFixC_t*) qi();
376 if(q.fA < fBBox[0]) fBBox[0] = q.fA;
377 if(q.fA + q.fW > fBBox[1]) fBBox[1] = q.fA + q.fW;
378 if(q.fB < fBBox[4]) fBBox[4] = q.fB;
379 if(q.fB + q.fH > fBBox[5]) fBBox[5] = q.fB + q.fH;
380 }
381 break;
382 }
383
385 {
386 while (qi.next()) {
387 QRectFixC_t& q = * (QRectFixC_t*) qi();
388 if(q.fA < fBBox[2]) fBBox[2] = q.fA;
389 if(q.fA + q.fW > fBBox[3]) fBBox[3] = q.fA + q.fW;
390 if(q.fB < fBBox[4]) fBBox[4] = q.fB;
391 if(q.fB + q.fH > fBBox[5]) fBBox[5] = q.fB + q.fH;
392 }
393 break;
394 }
395
397 {
398 const Float_t& w = fDefWidth;
399 const Float_t& h = fDefHeight;
400 while (qi.next()) {
402 if(q.fA < fBBox[0]) fBBox[0] = q.fA;
403 if(q.fA + w > fBBox[1]) fBBox[1] = q.fA + w;
404 if(q.fB < fBBox[2]) fBBox[2] = q.fB;
405 if(q.fB + h > fBBox[3]) fBBox[3] = q.fB + h;
406 }
407 break;
408 }
409
411 {
412 const Float_t& w = fDefWidth;
413 const Float_t& h = fDefHeight;
414 while (qi.next()) {
416 if(q.fA < fBBox[0]) fBBox[0] = q.fA;
417 if(q.fA + w > fBBox[1]) fBBox[1] = q.fA + w;
418 if(q.fB < fBBox[4]) fBBox[4] = q.fB;
419 if(q.fB + h > fBBox[5]) fBBox[5] = q.fB + h;
420 }
421 break;
422 }
423
425 {
426 const Float_t& w = fDefWidth;
427 const Float_t& h = fDefHeight;
428 while (qi.next()) {
430 if(q.fA < fBBox[2]) fBBox[2] = q.fA;
431 if(q.fA + w > fBBox[3]) fBBox[3] = q.fA + w;
432 if(q.fB < fBBox[4]) fBBox[4] = q.fB;
433 if(q.fB + h > fBBox[5]) fBBox[5] = q.fB + h;
434 }
435 break;
436 }
437
438 // TEveLine modes
439
440 case kQT_LineXYFixedZ:
441 {
442 while (qi.next()) {
443 QLineFixC_t& q = * (QLineFixC_t*) qi();
444 BBoxCheckPoint(q.fA, q.fB, fDefCoord);
445 BBoxCheckPoint(q.fA + q.fDx, q.fB + q.fDy, fDefCoord);
446 }
447 break;
448 }
449
450 case kQT_LineXZFixedY:
451 {
452 while (qi.next()) {
453 QLineFixC_t& q = * (QLineFixC_t*) qi();
454 BBoxCheckPoint(q.fA, fDefCoord, q.fB);
455 BBoxCheckPoint(q.fA + q.fDx, fDefCoord, q.fB + q.fDy);
456 }
457 break;
458 }
459
460 // Hexagon modes
461
462 // Ignore 'slight' difference, assume square box for both cases.
463 case kQT_HexagonXY:
464 case kQT_HexagonYX:
465 {
466 while (qi.next()) {
467 QHex_t& q = * (QHex_t*) qi();
468 BBoxCheckPoint(q.fA-q.fR, q.fB-q.fR, q.fC);
469 BBoxCheckPoint(q.fA+q.fR, q.fB+q.fR, q.fC);
470 }
471 break;
472 }
473
474 default:
475 {
476 throw(eH + "unsupported quad-type.");
477 }
478
479 } // end switch quad-type
480 } // end if frame ... else ...
481}
#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:120
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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:41
void BBoxInit(Float_t infinity=1e6)
Dynamic Float_t[6] X(min,max), Y(min,max), Z(min,max)
Definition TAttBBox.cxx:28
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
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
void ComputeBBox() override
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