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
25
26////////////////////////////////////////////////////////////////////////////////
27/// Default constructor.
28
30 fN (0),
31 fItems (nullptr),
32 fMinZ (0),
33 fMaxZ (0),
34 fPos (0)
35{
36}
37
38////////////////////////////////////////////////////////////////////////////////
39/// Constructor from raw GL-select record.
40
42 fN (data[0]),
43 fItems (nullptr),
44 fMinZ ((Float_t)data[1] / (Float_t)0x7fffffff),
45 fMaxZ ((Float_t)data[2] / (Float_t)0x7fffffff),
46 fPos (0)
47{
48 CopyItems(&data[3]);
49}
50
51////////////////////////////////////////////////////////////////////////////////
52/// Copy constructor.
53
55 fN (rec.fN),
56 fItems (nullptr),
57 fMinZ (rec.fMinZ),
58 fMaxZ (rec.fMaxZ),
59 fPos (rec.fPos)
60{
61 CopyItems(rec.fItems);
62}
63
64////////////////////////////////////////////////////////////////////////////////
65/// Destructor.
66
71
72////////////////////////////////////////////////////////////////////////////////
73/// Copy operator.
74
76{
77 if (this != &rec)
78 {
79 fN = rec.fN;
80 fMinZ = rec.fMinZ;
81 fMaxZ = rec.fMaxZ;
82 fPos = rec.fPos;
83 CopyItems(rec.fItems);
84 }
85 return *this;
86}
87
88////////////////////////////////////////////////////////////////////////////////
89/// Copy data from names. fN must already be set.
90
92{
93 delete [] fItems;
94 if (fN > 0) {
95 fItems = new UInt_t[fN];
96 memcpy(fItems, items, fN*sizeof(UInt_t));
97 } else {
98 fItems = nullptr;
99 }
100}
101
102////////////////////////////////////////////////////////////////////////////////
103/// Setup the record from raw buffer.
104
106{
107 fN = data[0];
108 fMinZ = (Float_t)data[1] / (Float_t)0x7fffffff;
109 fMaxZ = (Float_t)data[2] / (Float_t)0x7fffffff;
110 CopyItems(&data[3]);
111}
112
113////////////////////////////////////////////////////////////////////////////////
114/// Setup the record from raw buffer.
115
117{
118 fN = data[0];
119 fMinZ = (Float_t)data[1] / (Float_t)0x7fffffff;
120 fMaxZ = (Float_t)data[2] / (Float_t)0x7fffffff;
121 fPos = 0;
122 CopyItems(&data[3]);
123}
124
125////////////////////////////////////////////////////////////////////////////////
126/// Reinitialise all data to null values.
127
129{
130 delete [] fItems;
131 fN = 0;
132 fItems = nullptr;
133 fMinZ = 0;
134 fMaxZ = 0;
135 fPos = 0;
136}
137
138
139/** \class TGLSelectRecord
140\ingroup opengl
141Standard selection record including information about containing
142scene and details ob out selected object (TGLPhysicalShape*,
143TObject* or simply a void* for foreign scenes).
144*/
145
147
148////////////////////////////////////////////////////////////////////////////////
149/// Default constructor.
150
154 fSceneInfo (nullptr),
155 fPhysShape (nullptr),
156 fLogShape (nullptr),
157 fObject (nullptr),
158 fSpecific (nullptr),
162{
163}
164
165////////////////////////////////////////////////////////////////////////////////
166/// Constructor from raw GL-select record.
167
171 fSceneInfo (nullptr),
172 fPhysShape (nullptr),
173 fLogShape (nullptr),
174 fObject (nullptr),
175 fSpecific (nullptr),
179{
180}
181
182////////////////////////////////////////////////////////////////////////////////
183/// Copy constructor.
184
198
199////////////////////////////////////////////////////////////////////////////////
200/// Destructor.
201
205
206////////////////////////////////////////////////////////////////////////////////
207/// Copy operator.
208
210{
211 if (this != &rec)
212 {
214 fTransparent = rec.fTransparent;
215 fSceneInfo = rec.fSceneInfo;
216 fPhysShape = rec.fPhysShape;
217 fLogShape = rec.fLogShape;
218 fObject = rec.fObject;
219 fSpecific = rec.fSpecific;
220 fMultiple = rec.fMultiple;
221 fHighlight = rec.fHighlight;
222 fSecSelRes = rec.fSecSelRes;
223 }
224 return *this;
225}
226
227////////////////////////////////////////////////////////////////////////////////
228/// Setup the record from raw buffer.
229/// Non-core members are reset.
230
232{
235 fSceneInfo = nullptr;
236 fPhysShape = nullptr;
237 fLogShape = nullptr;
238 fObject = nullptr;
239 fSpecific = nullptr;
243}
244
245////////////////////////////////////////////////////////////////////////////////
246/// Reinitialise all data to null values.
247
249{
252 fSceneInfo = nullptr;
253 fPhysShape = nullptr;
254 fLogShape = nullptr;
255 fObject = nullptr;
256 fSpecific = nullptr;
260}
261
262////////////////////////////////////////////////////////////////////////////////
263/// Print contents of the select record to stdout.
264
266{
267 printf("SelectRecord N=%d, miZ=%.4f, maxZ=%.4f\n"
268 " sceneinfo=%p, pshp=%p, transp=%d, mult=%d, hilite=%d\n"
269 " tobj=%p (name='%s'), spec=%p\n",
270 fN, fMinZ, fMaxZ,
272 fObject, fObject ? fObject->GetName() : "",
273 fSpecific);
274}
275
276////////////////////////////////////////////////////////////////////////////////
277/// Check if the records imply the same selection result, that is,
278/// their secondary members are all equal.
279
281 const TGLSelectRecord& r2)
282{
283 return r1.fSceneInfo == r2.fSceneInfo && r1.fPhysShape == r2.fPhysShape &&
284 r1.fObject == r2.fObject && r1.fSpecific == r2.fSpecific;
285}
286
287
288/** \class TGLOvlSelectRecord
289\ingroup opengl
290Selection record for overlay objects.
291*/
292
294
295////////////////////////////////////////////////////////////////////////////////
296/// Default constructor.
297
303
304////////////////////////////////////////////////////////////////////////////////
305/// Constructor from raw GL-select record.
306
312
313////////////////////////////////////////////////////////////////////////////////
314/// Copy constructor.
315
321
322////////////////////////////////////////////////////////////////////////////////
323/// Destructor.
324
328
329////////////////////////////////////////////////////////////////////////////////
330/// Copy operator.
331
333{
334 if (this != &rec)
335 {
337 fOvlElement = rec.fOvlElement;
338 }
339 return *this;
340}
341
342////////////////////////////////////////////////////////////////////////////////
343/// Setup the record from raw buffer.
344/// Non-core members are reset.
345
351
352////////////////////////////////////////////////////////////////////////////////
353/// Reinitialise all data to null values.
354
360
bool Bool_t
Definition RtypesCore.h:63
unsigned int UInt_t
Definition RtypesCore.h:46
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
#define ClassImp(name)
Definition Rtypes.h:377
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Selection record for overlay objects.
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.
Base class for select records.
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.
Standard selection record including information about containing scene and details ob out selected ob...
~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.