Logo ROOT   6.14/05
Reference Guide
boxset.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_eve
3 /// Demonstrates usage of TEveBoxSet class.
4 ///
5 /// \image html eve_boxset.png
6 /// \macro_code
7 ///
8 /// \author Matevz Tadel
9 
10 TEveBoxSet* boxset(Float_t x=0, Float_t y=0, Float_t z=0,
11  Int_t num=100, Bool_t registerSet=kTRUE)
12 {
14 
15  TRandom r(0);
16 
17  TEveRGBAPalette* pal = new TEveRGBAPalette(0, 130);
18 
19  TEveFrameBox* frm = new TEveFrameBox();
20  frm->SetAABoxCenterHalfSize(0, 0, 0, 12, 12, 12);
21  frm->SetFrameColor(kCyan);
22  frm->SetBackColorRGBA(120,120,120,20);
23  frm->SetDrawBack(kTRUE);
24 
25  TEveBoxSet* q = new TEveBoxSet("BoxSet");
26  q->SetPalette(pal);
27  q->SetFrame(frm);
29  for (Int_t i=0; i<num; ++i) {
30  q->AddBox(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10),
31  r.Uniform(0.2, 1), r.Uniform(0.2, 1), r.Uniform(0.2, 1));
32  q->DigitValue(r.Uniform(0, 130));
33  }
34  q->RefitPlex();
35 
36  TEveTrans& t = q->RefMainTrans();
37  t.SetPos(x, y, z);
38 
39  // Uncomment these two lines to get internal highlight / selection.
40  // q->SetPickable(1);
41  // q->SetAlwaysSecSelect(1);
42 
43  if (registerSet)
44  {
45  gEve->AddElement(q);
47  }
48 
49  return q;
50 }
51 
52 TEveBoxSet* boxset_colisval(Float_t x=0, Float_t y=0, Float_t z=0,
53  Int_t num=100, Bool_t registerSet=kTRUE)
54 {
56 
57  TRandom r(0);
58 
59  TEveBoxSet* q = new TEveBoxSet("BoxSet");
61  for (Int_t i=0; i<num; ++i) {
62  q->AddBox(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10),
63  r.Uniform(0.2, 1), r.Uniform(0.2, 1), r.Uniform(0.2, 1));
64  q->DigitColor(r.Uniform(20, 255), r.Uniform(20, 255),
65  r.Uniform(20, 255), r.Uniform(20, 255));
66  }
67  q->RefitPlex();
68 
69  TEveTrans& t = q->RefMainTrans();
70  t.SetPos(x, y, z);
71 
72  if (registerSet)
73  {
74  gEve->AddElement(q);
76  }
77 
78  return q;
79 }
80 
81 TEveBoxSet* boxset_single_color(Float_t x=0, Float_t y=0, Float_t z=0,
82  Int_t num=100, Bool_t registerSet=kTRUE)
83 {
85 
86  TRandom r(0);
87 
88  TEveBoxSet* q = new TEveBoxSet("BoxSet");
89  q->UseSingleColor();
90  q->SetMainColor(kCyan-2);
91  q->SetMainTransparency(50);
93  for (Int_t i=0; i<num; ++i) {
94  q->AddBox(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10),
95  r.Uniform(0.2, 1), r.Uniform(0.2, 1), r.Uniform(0.2, 1));
96  }
97  q->RefitPlex();
98 
99  TEveTrans& t = q->RefMainTrans();
100  t.SetPos(x, y, z);
101 
102  if (registerSet)
103  {
104  gEve->AddElement(q);
105  gEve->Redraw3D(kTRUE);
106  }
107 
108  return q;
109 }
110 
111 TEveBoxSet* boxset_freebox(Int_t num=100, Bool_t registerSet=kTRUE)
112 {
114 
115  TRandom r(0);
116 
117  TEveRGBAPalette* pal = new TEveRGBAPalette(0, 130);
118 
119  TEveBoxSet* q = new TEveBoxSet("BoxSet");
120  q->SetPalette(pal);
122 
123 #define RND_BOX(x) (Float_t)r.Uniform(-(x), (x))
124 
125  Float_t verts[24];
126  for (Int_t i=0; i<num; ++i) {
127  Float_t x = RND_BOX(10);
128  Float_t y = RND_BOX(10);
129  Float_t z = RND_BOX(10);
130  Float_t a = r.Uniform(0.2, 0.5);
131  Float_t d = 0.05;
132  Float_t verts[24] = {
133  x - a + RND_BOX(d), y - a + RND_BOX(d), z - a + RND_BOX(d),
134  x - a + RND_BOX(d), y + a + RND_BOX(d), z - a + RND_BOX(d),
135  x + a + RND_BOX(d), y + a + RND_BOX(d), z - a + RND_BOX(d),
136  x + a + RND_BOX(d), y - a + RND_BOX(d), z - a + RND_BOX(d),
137  x - a + RND_BOX(d), y - a + RND_BOX(d), z + a + RND_BOX(d),
138  x - a + RND_BOX(d), y + a + RND_BOX(d), z + a + RND_BOX(d),
139  x + a + RND_BOX(d), y + a + RND_BOX(d), z + a + RND_BOX(d),
140  x + a + RND_BOX(d), y - a + RND_BOX(d), z + a + RND_BOX(d) };
141  q->AddBox(verts);
142  q->DigitValue(r.Uniform(0, 130));
143  }
144  q->RefitPlex();
145 
146 #undef RND_BOX
147 
148  // Uncomment these two lines to get internal highlight / selection.
149  // q->SetPickable(1);
150  // q->SetAlwaysSecSelect(1);
151 
152  if (registerSet)
153  {
154  gEve->AddElement(q);
155  gEve->Redraw3D(kTRUE);
156  }
157 
158  return q;
159 }
TEveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Definition: TEveTrans.h:26
A generic, speed-optimised mapping from value to RGBA color supporting different wrapping and range t...
float Float_t
Definition: RtypesCore.h:53
Collection of 3D primitives (fixed-size boxes, boxes of different sizes, or arbitrary sexto-epipeds...
Definition: TEveBoxSet.h:21
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Description of a 2D or 3D frame that can be used to visually group a set of objects.
Definition: TEveFrameBox.h:18
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Definition: TEveManager.h:168
void AddElement(TEveElement *element, TEveElement *parent=0)
Add an element.
void SetDrawBack(Bool_t f)
Definition: TEveFrameBox.h:86
void SetFrameColor(Color_t ci)
Set color of the frame.
Double_t x[n]
Definition: legend1.C:17
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
void DigitColor(Color_t ci)
Set color for the last digit added.
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
void UseSingleColor()
Instruct digit-set to use single color for its digits.
void SetFrame(TEveFrameBox *b)
Set TEveFrameBox pointer.
ROOT::R::TRInterface & r
Definition: Object.C:4
auto * a
Definition: textangle.C:12
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
virtual void SetMainTransparency(Char_t t)
Set main-transparency.
const Bool_t kFALSE
Definition: RtypesCore.h:88
#define d(i)
Definition: RSha256.hxx:102
void SetPos(Double_t x, Double_t y, Double_t z)
Set position (base-vec 4).
Definition: TEveTrans.cxx:507
void Reset(EBoxType_e boxType, Bool_t valIsCol, Int_t chunkSize)
Reset the data containers to zero size.
Definition: TEveBoxSet.cxx:87
void SetPalette(TEveRGBAPalette *p)
Set TEveRGBAPalette pointer.
void RefitPlex()
Instruct underlying memory allocator to regroup itself into a contiguous memory chunk.
Double_t y[n]
Definition: legend1.C:17
Definition: Rtypes.h:59
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
virtual TEveTrans & RefMainTrans()
Return reference to main transformation.
virtual void SetMainColor(Color_t color)
Override from TEveElement, forward to Frame.
void SetAABoxCenterHalfSize(Float_t x, Float_t y, Float_t z, Float_t dx, Float_t dy, Float_t dz)
Setup for axis-aligned box with center at x, y, z and given half-sizes in x (dx), y (dy) and z (dz)...
float * q
Definition: THbookFile.cxx:87
void DigitValue(Int_t value)
Set signal value for the last digit added.
const Bool_t kTRUE
Definition: RtypesCore.h:87
void AddBox(const Float_t *verts)
Create a new box from a set of 8 vertices.
Definition: TEveBoxSet.cxx:112
void SetBackColorRGBA(UChar_t r, UChar_t g, UChar_t b, UChar_t a=255)
Set color of the background polygon.