forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TEveFrameBox.cxx
207 lines (173 loc) · 6.65 KB
/
TEveFrameBox.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
// @(#)root/eve:$Id$
// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
/*************************************************************************
* Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#include "TEveFrameBox.h"
#include "TColor.h"
/** \class TEveFrameBox
\ingroup TEve
Description of a 2D or 3D frame that can be used to visually group
a set of objects.
*/
ClassImp(TEveFrameBox);
////////////////////////////////////////////////////////////////////////////////
TEveFrameBox::TEveFrameBox() :
fFrameType (kFT_None),
fFrameSize (0),
fFramePoints (0),
fFrameWidth (1),
fFrameColor (1),
fBackColor (0),
fFrameFill (kFALSE),
fDrawBack (kFALSE)
{
// Default constructor.
fFrameRGBA[0] = fFrameRGBA[1] = fFrameRGBA[2] = 0; fFrameRGBA[3] = 255;
fBackRGBA [0] = fBackRGBA [1] = fBackRGBA [2] = 255; fBackRGBA [3] = 255;
}
////////////////////////////////////////////////////////////////////////////////
/// Destructor.
TEveFrameBox::~TEveFrameBox()
{
delete [] fFramePoints;
}
////////////////////////////////////////////////////////////////////////////////
/// Setup for axis-aligned rectangle with one corner at x, y, z and
/// given sizes in x (dx) and y (dy).
void TEveFrameBox::SetAAQuadXY(Float_t x, Float_t y, Float_t z,
Float_t dx, Float_t dy)
{
fFrameType = kFT_Quad;
fFrameSize = 12;
delete [] fFramePoints;
fFramePoints = new Float_t [fFrameSize];
Float_t* p = fFramePoints;
p[0] = x; p[1] = y; p[2] = z; p += 3;
p[0] = x+dx; p[1] = y; p[2] = z; p += 3;
p[0] = x+dx; p[1] = y+dy; p[2] = z; p += 3;
p[0] = x ; p[1] = y+dy; p[2] = z; p += 3;
}
////////////////////////////////////////////////////////////////////////////////
/// Setup for axis-aligned rectangle with one corner at x, y, z and
/// given sizes in x (dx) and z (dz).
void TEveFrameBox::SetAAQuadXZ(Float_t x, Float_t y, Float_t z,
Float_t dx, Float_t dz)
{
fFrameType = kFT_Quad;
fFrameSize = 12;
delete [] fFramePoints;
fFramePoints = new Float_t [fFrameSize];
Float_t* p = fFramePoints;
p[0] = x; p[1] = y; p[2] = z; p += 3;
p[0] = x+dx; p[1] = y; p[2] = z; p += 3;
p[0] = x+dx; p[1] = y; p[2] = z+dz; p += 3;
p[0] = x ; p[1] = y; p[2] = z+dz; p += 3;
}
////////////////////////////////////////////////////////////////////////////////
/// Setup frame with explicitly given corner coordinates.
/// Arguments:
/// - pointArr - array containing the 3D points
/// - nPoint - number of points, size of array divided by 3
void TEveFrameBox::SetQuadByPoints(const Float_t* pointArr, Int_t nPoints)
{
fFrameType = kFT_Quad;
fFrameSize = 3*nPoints;
delete [] fFramePoints;
fFramePoints = new Float_t [fFrameSize];
memcpy(fFramePoints, pointArr, fFrameSize*sizeof(Float_t));
}
////////////////////////////////////////////////////////////////////////////////
/// Setup for axis-aligned box with one corner at x, y, z and
/// given sizes in x (dx), y (dy) and z (dz).
void TEveFrameBox::SetAABox(Float_t x, Float_t y, Float_t z,
Float_t dx, Float_t dy, Float_t dz)
{
fFrameType = kFT_Box;
fFrameSize = 24;
delete [] fFramePoints;
fFramePoints = new Float_t [fFrameSize];
Float_t* p = fFramePoints;
//bottom
p[0] = x; p[1] = y + dy; p[2] = z; p += 3;
p[0] = x + dx; p[1] = y + dy; p[2] = z; p += 3;
p[0] = x + dx; p[1] = y; p[2] = z; p += 3;
p[0] = x; p[1] = y; p[2] = z; p += 3;
//top
p[0] = x; p[1] = y + dy; p[2] = z + dz; p += 3;
p[0] = x + dx; p[1] = y + dy; p[2] = z + dz; p += 3;
p[0] = x + dx; p[1] = y; p[2] = z + dz; p += 3;
p[0] = x; p[1] = y; p[2] = z + dz;
}
////////////////////////////////////////////////////////////////////////////////
/// Setup for axis-aligned box with center at x, y, z and given
/// half-sizes in x (dx), y (dy) and z (dz).
void TEveFrameBox::SetAABoxCenterHalfSize(Float_t x, Float_t y, Float_t z,
Float_t dx, Float_t dy, Float_t dz)
{
fFrameType = kFT_Box;
fFrameSize = 24;
delete [] fFramePoints;
fFramePoints = new Float_t [fFrameSize];
Float_t* p = fFramePoints;
//bottom
p[0] = x - dx; p[1] = y + dy; p[2] = z - dz; p += 3;
p[0] = x + dx; p[1] = y + dy; p[2] = z - dz; p += 3;
p[0] = x + dx; p[1] = y - dy; p[2] = z - dz; p += 3;
p[0] = x - dx; p[1] = y - dy; p[2] = z - dz; p += 3;
//top
p[0] = x - dx; p[1] = y + dy; p[2] = z + dz; p += 3;
p[0] = x + dx; p[1] = y + dy; p[2] = z + dz; p += 3;
p[0] = x + dx; p[1] = y - dy; p[2] = z + dz; p += 3;
p[0] = x - dx; p[1] = y - dy; p[2] = z + dz;
}
////////////////////////////////////////////////////////////////////////////////
/// Set color of the frame.
void TEveFrameBox::SetFrameColor(Color_t ci)
{
fFrameColor = ci;
TEveUtil::ColorFromIdx(ci, fFrameRGBA, kTRUE);
}
////////////////////////////////////////////////////////////////////////////////
/// Set color of the frame.
void TEveFrameBox::SetFrameColorPixel(Pixel_t pix)
{
SetFrameColor(Color_t(TColor::GetColor(pix)));
}
////////////////////////////////////////////////////////////////////////////////
/// Set color of the frame.
void TEveFrameBox::SetFrameColorRGBA(UChar_t r, UChar_t g, UChar_t b, UChar_t a)
{
fFrameColor = Color_t(TColor::GetColor(r, g, b));
fFrameRGBA[0] = r;
fFrameRGBA[1] = g;
fFrameRGBA[2] = b;
fFrameRGBA[3] = a;
}
////////////////////////////////////////////////////////////////////////////////
/// Set color of the background polygon.
void TEveFrameBox::SetBackColor(Color_t ci)
{
fBackColor = ci;
TEveUtil::ColorFromIdx(ci, fBackRGBA, kTRUE);
}
////////////////////////////////////////////////////////////////////////////////
/// Set color of the background polygon.
void TEveFrameBox::SetBackColorPixel(Pixel_t pix)
{
SetBackColor(Color_t(TColor::GetColor(pix)));
}
////////////////////////////////////////////////////////////////////////////////
/// Set color of the background polygon.
void TEveFrameBox::SetBackColorRGBA(UChar_t r, UChar_t g, UChar_t b, UChar_t a)
{
fBackColor = Color_t(TColor::GetColor(r, g, b));
fBackRGBA[0] = r;
fBackRGBA[1] = g;
fBackRGBA[2] = b;
fBackRGBA[3] = a;
}