ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  gStyle->SetPalette(1, 0);
17 
18  TEveRGBAPalette* pal = new TEveRGBAPalette(0, 130);
19 
20  TEveFrameBox* frm = new TEveFrameBox();
21  frm->SetAABoxCenterHalfSize(0, 0, 0, 12, 12, 12);
22  frm->SetFrameColor(kCyan);
23  frm->SetBackColorRGBA(120,120,120,20);
24  frm->SetDrawBack(kTRUE);
25 
26  TEveBoxSet* q = new TEveBoxSet("BoxSet");
27  q->SetPalette(pal);
28  q->SetFrame(frm);
30  for (Int_t i=0; i<num; ++i) {
31  q->AddBox(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10),
32  r.Uniform(0.2, 1), r.Uniform(0.2, 1), r.Uniform(0.2, 1));
33  q->DigitValue(r.Uniform(0, 130));
34  }
35  q->RefitPlex();
36 
37  TEveTrans& t = q->RefMainTrans();
38  t.SetPos(x, y, z);
39 
40  // Uncomment these two lines to get internal highlight / selection.
41  // q->SetPickable(1);
42  // q->SetAlwaysSecSelect(1);
43 
44  if (registerSet)
45  {
46  gEve->AddElement(q);
48  }
49 
50  return q;
51 }
52 
53 TEveBoxSet* boxset_colisval(Float_t x=0, Float_t y=0, Float_t z=0,
54  Int_t num=100, Bool_t registerSet=kTRUE)
55 {
57 
58  TRandom r(0);
59 
60  TEveBoxSet* q = new TEveBoxSet("BoxSet");
62  for (Int_t i=0; i<num; ++i) {
63  q->AddBox(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10),
64  r.Uniform(0.2, 1), r.Uniform(0.2, 1), r.Uniform(0.2, 1));
65  q->DigitColor(r.Uniform(20, 255), r.Uniform(20, 255),
66  r.Uniform(20, 255), r.Uniform(20, 255));
67  }
68  q->RefitPlex();
69 
70  TEveTrans& t = q->RefMainTrans();
71  t.SetPos(x, y, z);
72 
73  if (registerSet)
74  {
75  gEve->AddElement(q);
77  }
78 
79  return q;
80 }
81 
82 TEveBoxSet* boxset_single_color(Float_t x=0, Float_t y=0, Float_t z=0,
83  Int_t num=100, Bool_t registerSet=kTRUE)
84 {
86 
87  TRandom r(0);
88 
89  TEveBoxSet* q = new TEveBoxSet("BoxSet");
90  q->UseSingleColor();
91  q->SetMainColor(kCyan-2);
92  q->SetMainTransparency(50);
94  for (Int_t i=0; i<num; ++i) {
95  q->AddBox(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10),
96  r.Uniform(0.2, 1), r.Uniform(0.2, 1), r.Uniform(0.2, 1));
97  }
98  q->RefitPlex();
99 
100  TEveTrans& t = q->RefMainTrans();
101  t.SetPos(x, y, z);
102 
103  if (registerSet)
104  {
105  gEve->AddElement(q);
106  gEve->Redraw3D(kTRUE);
107  }
108 
109  return q;
110 }
111 
112 TEveBoxSet* boxset_freebox(Int_t num=100, Bool_t registerSet=kTRUE)
113 {
115 
116  TRandom r(0);
117  gStyle->SetPalette(1, 0);
118 
119  TEveRGBAPalette* pal = new TEveRGBAPalette(0, 130);
120 
121  TEveBoxSet* q = new TEveBoxSet("BoxSet");
122  q->SetPalette(pal);
124 
125 #define RND_BOX(x) (Float_t)r.Uniform(-(x), (x))
126 
127  Float_t verts[24];
128  for (Int_t i=0; i<num; ++i) {
129  Float_t x = RND_BOX(10);
130  Float_t y = RND_BOX(10);
131  Float_t z = RND_BOX(10);
132  Float_t a = r.Uniform(0.2, 0.5);
133  Float_t d = 0.05;
134  Float_t verts[24] = {
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  x + a + RND_BOX(d), y + a + RND_BOX(d), z + a + RND_BOX(d),
142  x + a + RND_BOX(d), y - a + RND_BOX(d), z + a + RND_BOX(d) };
143  q->AddBox(verts);
144  q->DigitValue(r.Uniform(0, 130));
145  }
146  q->RefitPlex();
147 
148 #undef RND_BOX
149 
150  // Uncomment these two lines to get internal highlight / selection.
151  // q->SetPickable(1);
152  // q->SetAlwaysSecSelect(1);
153 
154  if (registerSet)
155  {
156  gEve->AddElement(q);
157  gEve->Redraw3D(kTRUE);
158  }
159 
160  return q;
161 }
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
R__EXTERN TStyle * gStyle
Definition: TStyle.h:423
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
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.
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:29
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
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
virtual void SetMainTransparency(Char_t t)
Set main-transparency.
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.
Definition: Rtypes.h:61
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)...
const Bool_t kTRUE
Definition: Rtypes.h:91
float * q
Definition: THbookFile.cxx:87
void DigitValue(Int_t value)
Set signal value for the last digit added.
void SetPalette(Int_t ncolors=kBird, Int_t *colors=0, Float_t alpha=1.)
See TColor::SetPalette.
Definition: TStyle.cxx:1445
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.