Logo ROOT   6.14/05
Reference Guide
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 <string.h>
16 
17 /** \class TGLSelectRecordBase
18 \ingroup opengl TGLSelectRecordBase
19 Base class for select records.
20 Supports initialization from a raw GL record (UInt_t*) and
21 copies the name-data into internal array.
22 */
23 
25 
26 ////////////////////////////////////////////////////////////////////////////////
27 /// Default constructor.
28 
30  fN (0),
31  fItems (0),
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 (0),
44  fMinZ ((Float_t)data[1] / 0x7fffffff),
45  fMaxZ ((Float_t)data[2] / 0x7fffffff),
46  fPos (0)
47 {
48  CopyItems(&data[3]);
49 }
50 
51 ////////////////////////////////////////////////////////////////////////////////
52 /// Copy constructor.
53 
55  fN (rec.fN),
56  fItems (0),
57  fMinZ (rec.fMinZ),
58  fMaxZ (rec.fMaxZ),
59  fPos (rec.fPos)
60 {
61  CopyItems(rec.fItems);
62 }
63 
64 ////////////////////////////////////////////////////////////////////////////////
65 /// Destructor.
66 
68 {
69  delete [] fItems;
70 }
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 = 0;
99  }
100 }
101 
102 ////////////////////////////////////////////////////////////////////////////////
103 /// Setup the record from raw buffer.
104 
106 {
107  fN = data[0];
108  fMinZ = (Float_t)data[1] / 0x7fffffff;
109  fMaxZ = (Float_t)data[2] / 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] / 0x7fffffff;
120  fMaxZ = (Float_t)data[2] / 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 = 0;
133  fMinZ = 0;
134  fMaxZ = 0;
135  fPos = 0;
136 }
137 
138 
139 /** \class TGLSelectRecord
140 \ingroup opengl
141 Standard selection record including information about containing
142 scene and details ob out selected object (TGLPhysicalShape*,
143 TObject* or simply a void* for foreign scenes).
144 */
145 
147 
148 ////////////////////////////////////////////////////////////////////////////////
149 /// Default constructor.
150 
153  fTransparent (kFALSE),
154  fSceneInfo (0),
155  fPhysShape (0),
156  fLogShape (0),
157  fObject (0),
158  fSpecific (0),
159  fMultiple (kFALSE),
160  fHighlight (kFALSE),
161  fSecSelRes (kNone)
162 {
163 }
164 
165 ////////////////////////////////////////////////////////////////////////////////
166 /// Constructor from raw GL-select record.
167 
169  TGLSelectRecordBase(data),
171  fSceneInfo (0),
172  fPhysShape (0),
173  fLogShape (0),
174  fObject (0),
175  fSpecific (0),
176  fMultiple (kFALSE),
177  fHighlight (kFALSE),
178  fSecSelRes (kNone)
179 {
180 }
181 
182 ////////////////////////////////////////////////////////////////////////////////
183 /// Copy constructor.
184 
186  TGLSelectRecordBase(rec),
188  fSceneInfo (rec.fSceneInfo),
189  fPhysShape (rec.fPhysShape),
190  fLogShape (rec.fLogShape),
191  fObject (rec.fObject),
192  fSpecific (rec.fSpecific),
193  fMultiple (rec.fMultiple),
194  fHighlight (rec.fHighlight),
195  fSecSelRes (kNone)
196 {
197 }
198 
199 ////////////////////////////////////////////////////////////////////////////////
200 /// Destructor.
201 
203 {
204 }
205 
206 ////////////////////////////////////////////////////////////////////////////////
207 /// Copy operator.
208 
210 {
211  if (this != &rec)
212  {
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 = 0;
236  fPhysShape = 0;
237  fLogShape = 0;
238  fObject = 0;
239  fSpecific = 0;
240  fMultiple = kFALSE;
241  fHighlight = kFALSE;
242  fSecSelRes = kNone;
243 }
244 
245 ////////////////////////////////////////////////////////////////////////////////
246 /// Reinitialise all data to null values.
247 
249 {
252  fSceneInfo = 0;
253  fPhysShape = 0;
254  fLogShape = 0;
255  fObject = 0;
256  fSpecific = 0;
257  fMultiple = kFALSE;
258  fHighlight = kFALSE;
259  fSecSelRes = kNone;
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
290 Selection record for overlay objects.
291 */
292 
294 
295 ////////////////////////////////////////////////////////////////////////////////
296 /// Default constructor.
297 
300  fOvlElement (0)
301 {
302 }
303 
304 ////////////////////////////////////////////////////////////////////////////////
305 /// Constructor from raw GL-select record.
306 
308  TGLSelectRecordBase(data),
309  fOvlElement (0)
310 {
311 }
312 
313 ////////////////////////////////////////////////////////////////////////////////
314 /// Copy constructor.
315 
317  TGLSelectRecordBase(rec),
319 {
320 }
321 
322 ////////////////////////////////////////////////////////////////////////////////
323 /// Destructor.
324 
326 {
327 }
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 
347 {
349  fOvlElement = 0;
350 }
351 
352 ////////////////////////////////////////////////////////////////////////////////
353 /// Reinitialise all data to null values.
354 
356 {
358  fOvlElement = 0;
359 }
360 
float Float_t
Definition: RtypesCore.h:53
virtual void Reset()
Reinitialise all data to null values.
virtual ~TGLOvlSelectRecord()
Destructor.
bool Bool_t
Definition: RtypesCore.h:59
void SetRawOnly(UInt_t *data)
Setup the record from raw buffer.
TGLOvlSelectRecord()
Default constructor.
TGLSelectRecord()
Default constructor.
Base class for select records.
virtual void Set(UInt_t *data)
Setup the record from raw buffer.
virtual void Reset()
Reinitialise all data to null values.
virtual void Reset()
Reinitialise all data to null values.
virtual void Set(UInt_t *data)
Setup the record from raw buffer.
virtual ~TGLSelectRecordBase()
Destructor.
TGLOverlayElement * fOvlElement
Standard selection record including information about containing scene and details ob out selected ob...
unsigned int UInt_t
Definition: RtypesCore.h:42
const Handle_t kNone
Definition: GuiTypes.h:87
const Bool_t kFALSE
Definition: RtypesCore.h:88
void Print()
Print contents of the select record to stdout.
#define ClassImp(name)
Definition: Rtypes.h:359
TGLSelectRecordBase & operator=(const TGLSelectRecordBase &rec)
Copy operator.
TGLOvlSelectRecord & operator=(const TGLOvlSelectRecord &rec)
Copy operator.
ESecSelResult fSecSelRes
TGLLogicalShape * fLogShape
void CopyItems(UInt_t *items)
Copy data from names. fN must already be set.
TGLPhysicalShape * fPhysShape
virtual ~TGLSelectRecord()
Destructor.
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...
Selection record for overlay objects.
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:357
TGLSelectRecord & operator=(const TGLSelectRecord &rec)
Copy operator.
TGLSceneInfo * fSceneInfo
virtual void Set(UInt_t *data)
Setup the record from raw buffer.
TGLSelectRecordBase()
Default constructor.