Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TGLSelectRecord.cxx
Go to the documentation of this file.
1// @(#)root/gl:$Id$
2// Author: Matevz Tadel, Jun 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2004, 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 "TGLSelectRecord.h"
13#include <TObject.h>
14
15#include <cstring>
16
17/** \class TGLSelectRecordBase
18\ingroup opengl
19Base class for select records.
20Supports initialization from a raw GL record (UInt_t*) and
21copies the name-data into internal array.
22*/
23
24
25////////////////////////////////////////////////////////////////////////////////
26/// Default constructor.
27
29 fN (0),
30 fItems (nullptr),
31 fMinZ (0),
32 fMaxZ (0),
33 fPos (0)
34{
35}
36
37////////////////////////////////////////////////////////////////////////////////
38/// Constructor from raw GL-select record.
39
41 fN (data[0]),
42 fItems (nullptr),
43 fMinZ ((Float_t)data[1] / (Float_t)0x7fffffff),
44 fMaxZ ((Float_t)data[2] / (Float_t)0x7fffffff),
45 fPos (0)
46{
47 CopyItems(&data[3]);
48}
49
50////////////////////////////////////////////////////////////////////////////////
51/// Copy constructor.
52
54 fN (rec.fN),
55 fItems (nullptr),
56 fMinZ (rec.fMinZ),
57 fMaxZ (rec.fMaxZ),
58 fPos (rec.fPos)
59{
60 CopyItems(rec.fItems);
61}
62
63////////////////////////////////////////////////////////////////////////////////
64/// Destructor.
65
70
71////////////////////////////////////////////////////////////////////////////////
72/// Copy operator.
73
75{
76 if (this != &rec)
77 {
78 fN = rec.fN;
79 fMinZ = rec.fMinZ;
80 fMaxZ = rec.fMaxZ;
81 fPos = rec.fPos;
82 CopyItems(rec.fItems);
83 }
84 return *this;
85}
86
87////////////////////////////////////////////////////////////////////////////////
88/// Copy data from names. fN must already be set.
89
91{
92 delete [] fItems;
93 if (fN > 0) {
94 fItems = new UInt_t[fN];
95 memcpy(fItems, items, fN*sizeof(UInt_t));
96 } else {
97 fItems = nullptr;
98 }
99}
100
101////////////////////////////////////////////////////////////////////////////////
102/// Setup the record from raw buffer.
103
105{
106 fN = data[0];
107 fMinZ = (Float_t)data[1] / (Float_t)0x7fffffff;
108 fMaxZ = (Float_t)data[2] / (Float_t)0x7fffffff;
109 CopyItems(&data[3]);
110}
111
112////////////////////////////////////////////////////////////////////////////////
113/// Setup the record from raw buffer.
114
116{
117 fN = data[0];
118 fMinZ = (Float_t)data[1] / (Float_t)0x7fffffff;
119 fMaxZ = (Float_t)data[2] / (Float_t)0x7fffffff;
120 fPos = 0;
121 CopyItems(&data[3]);
122}
123
124////////////////////////////////////////////////////////////////////////////////
125/// Reinitialise all data to null values.
126
128{
129 delete [] fItems;
130 fN = 0;
131 fItems = nullptr;
132 fMinZ = 0;
133 fMaxZ = 0;
134 fPos = 0;
135}
136
137
138/** \class TGLSelectRecord
139\ingroup opengl
140Standard selection record including information about containing
141scene and details ob out selected object (TGLPhysicalShape*,
142TObject* or simply a void* for foreign scenes).
143*/
144
145
146////////////////////////////////////////////////////////////////////////////////
147/// Default constructor.
148
152 fSceneInfo (nullptr),
153 fPhysShape (nullptr),
154 fLogShape (nullptr),
155 fObject (nullptr),
156 fSpecific (nullptr),
160{
161}
162
163////////////////////////////////////////////////////////////////////////////////
164/// Constructor from raw GL-select record.
165
169 fSceneInfo (nullptr),
170 fPhysShape (nullptr),
171 fLogShape (nullptr),
172 fObject (nullptr),
173 fSpecific (nullptr),
177{
178}
179
180////////////////////////////////////////////////////////////////////////////////
181/// Copy constructor.
182
196
197////////////////////////////////////////////////////////////////////////////////
198/// Destructor.
199
203
204////////////////////////////////////////////////////////////////////////////////
205/// Copy operator.
206
208{
209 if (this != &rec)
210 {
215 fLogShape = rec.fLogShape;
216 fObject = rec.fObject;
217 fSpecific = rec.fSpecific;
218 fMultiple = rec.fMultiple;
221 }
222 return *this;
223}
224
225////////////////////////////////////////////////////////////////////////////////
226/// Setup the record from raw buffer.
227/// Non-core members are reset.
228
230{
233 fSceneInfo = nullptr;
234 fPhysShape = nullptr;
235 fLogShape = nullptr;
236 fObject = nullptr;
237 fSpecific = nullptr;
241}
242
243////////////////////////////////////////////////////////////////////////////////
244/// Reinitialise all data to null values.
245
247{
250 fSceneInfo = nullptr;
251 fPhysShape = nullptr;
252 fLogShape = nullptr;
253 fObject = nullptr;
254 fSpecific = nullptr;
258}
259
260////////////////////////////////////////////////////////////////////////////////
261/// Print contents of the select record to stdout.
262
264{
265 printf("SelectRecord N=%d, miZ=%.4f, maxZ=%.4f\n"
266 " sceneinfo=%p, pshp=%p, transp=%d, mult=%d, hilite=%d\n"
267 " tobj=%p (name='%s'), spec=%p\n",
268 fN, fMinZ, fMaxZ,
270 fObject, fObject ? fObject->GetName() : "",
271 fSpecific);
272}
273
274////////////////////////////////////////////////////////////////////////////////
275/// Check if the records imply the same selection result, that is,
276/// their secondary members are all equal.
277
279 const TGLSelectRecord& r2)
280{
281 return r1.fSceneInfo == r2.fSceneInfo && r1.fPhysShape == r2.fPhysShape &&
282 r1.fObject == r2.fObject && r1.fSpecific == r2.fSpecific;
283}
284
285
286/** \class TGLOvlSelectRecord
287\ingroup opengl
288Selection record for overlay objects.
289*/
290
291
292////////////////////////////////////////////////////////////////////////////////
293/// Default constructor.
294
300
301////////////////////////////////////////////////////////////////////////////////
302/// Constructor from raw GL-select record.
303
309
310////////////////////////////////////////////////////////////////////////////////
311/// Copy constructor.
312
318
319////////////////////////////////////////////////////////////////////////////////
320/// Destructor.
321
325
326////////////////////////////////////////////////////////////////////////////////
327/// Copy operator.
328
330{
331 if (this != &rec)
332 {
335 }
336 return *this;
337}
338
339////////////////////////////////////////////////////////////////////////////////
340/// Setup the record from raw buffer.
341/// Non-core members are reset.
342
344{
346 fOvlElement = nullptr;
347}
348
349////////////////////////////////////////////////////////////////////////////////
350/// Reinitialise all data to null values.
351
357
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
float Float_t
Float 4 bytes (float).
Definition RtypesCore.h:71
void Reset() override
Reinitialise all data to null values.
TGLOverlayElement * fOvlElement
~TGLOvlSelectRecord() override
Destructor.
TGLOvlSelectRecord()
Default constructor.
TGLOvlSelectRecord & operator=(const TGLOvlSelectRecord &rec)
Copy operator.
void Set(UInt_t *data) override
Setup the record from raw buffer.
TGLSelectRecordBase & operator=(const TGLSelectRecordBase &rec)
Copy operator.
void SetRawOnly(UInt_t *data)
Setup the record from raw buffer.
void CopyItems(UInt_t *items)
Copy data from names. fN must already be set.
virtual void Set(UInt_t *data)
Setup the record from raw buffer.
virtual ~TGLSelectRecordBase()
Destructor.
TGLSelectRecordBase()
Default constructor.
virtual void Reset()
Reinitialise all data to null values.
~TGLSelectRecord() override
Destructor.
TGLSelectRecord()
Default constructor.
static Bool_t AreSameSelectionWise(const TGLSelectRecord &r1, const TGLSelectRecord &r2)
Check if the records imply the same selection result, that is, their secondary members are all equal.
TGLSelectRecord & operator=(const TGLSelectRecord &rec)
Copy operator.
void Reset() override
Reinitialise all data to null values.
ESecSelResult fSecSelRes
TGLSceneInfo * fSceneInfo
TGLLogicalShape * fLogShape
TGLPhysicalShape * fPhysShape
void Print()
Print contents of the select record to stdout.
void Set(UInt_t *data) override
Setup the record from raw buffer.