Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TStructNode.cxx
Go to the documentation of this file.
1// @(#)root/gviz3d:$Id$
2// Author: Tomasz Sosnicki 18/09/09
3
4/************************************************************************
5* Copyright (C) 1995-2009, 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 "TStructNode.h"
13#include <TList.h>
14#include <TGeoManager.h>
15
17
18//________________________________________________________________________
19//////////////////////////////////////////////////////////////////////////
20//
21// TStructNode - class which represent a node. Node has all information
22// about some pointer. It keeps information such as name of object, type,
23// size of pointers class, size of node and daughter nodes, number of child
24// nodes. It is also used to store information needed to draw TGeoVolume.
25// It is for example x, y and z coordinates.
26// Condition fVisible tells us that node is visible and should be drawn.
27// fCollapsed tells us that we can see daughter nodes.
28//
29//////////////////////////////////////////////////////////////////////////
30
32
33////////////////////////////////////////////////////////////////////////////////
34/// Constructs node with name "name" of class "typeName" and given parent "parent" which represents pointer "pointer".
35/// Size of node is set to "size" and type is set to "type"
36
38{
39 fName = name;
40 fTypeName = typeName;
41 fTotalSize = fSize = size;
42 fMembers = new TList();
44 fLevel = 1;
45 fX = fY = fWidth = fHeight = 0;
46 fParent = parent;
47 if (parent) {
48 fLevel = parent->GetLevel()+1;
49 parent->fMembers->Add(this);
50 }
51
53 fPointer = pointer;
54 fCollapsed = false;
55 fVisible = false;
56 fMaxLevel = 3;
57 fMaxObjects = 100;
58}
59
60////////////////////////////////////////////////////////////////////////////////
61/// Destructs list of nodes
62
64{
65 delete fMembers;
66}
67
68////////////////////////////////////////////////////////////////////////////////
69/// Overrided method. Compare to objects of TStructNode class.
70
72{
73 TStructNode* node = (TStructNode*)obj;
74
75 if (GetVolume() < node->GetVolume()) {
76 return -1;
77 }
78 if(GetVolume() > node->GetVolume()) {
79 return 1;
80 }
81
82 if (this > node) {
83 return 1;
84 }
85 if (this < node) {
86 return -1;
87 }
88
89 return 0;
90}
91
92////////////////////////////////////////////////////////////////////////////////
93/// Returns number of all members in node
94
96{
97 return fAllMembersCount;
98}
99
100////////////////////////////////////////////////////////////////////////////////
101/// Returns center of outlining box on x-axis
102
104{
105 return (fX + fWidth /2);
106}
107
108////////////////////////////////////////////////////////////////////////////////
109/// Returns height of outlining box
110
112{
113 return fHeight;
114}
115
116////////////////////////////////////////////////////////////////////////////////
117/// Returns actual level of node
118
120{
121 return fLevel;
122}
123
124////////////////////////////////////////////////////////////////////////////////
125/// Returns name of object
126
127const char* TStructNode::GetName() const
128{
129 return fName.Data();
130}
131
132////////////////////////////////////////////////////////////////////////////////
133/// Returns type of node
134
136{
137 return fNodeType;
138}
139
140////////////////////////////////////////////////////////////////////////////////
141/// Returns maximum number of leves displayed when the node is top node on scene
142
144{
145 return fMaxLevel;
146}
147
148////////////////////////////////////////////////////////////////////////////////
149/// Returns maximum number of objects displayed when the node is top node on scene
150
152{
153 return fMaxObjects;
154}
155
156////////////////////////////////////////////////////////////////////////////////
157/// Returns list with pointers to daughter nodes.
158
160{
161 return fMembers;
162}
163
164////////////////////////////////////////////////////////////////////////////////
165/// Returns numbers of members of node
166
168{
169 return fMembersCount;
170}
171
172////////////////////////////////////////////////////////////////////////////////
173/// Returns center of outlining box on y-axis
174
176{
177 return (fY + fHeight/2);
178}
179
180////////////////////////////////////////////////////////////////////////////////
181/// Returns pointer to parent node
182
184{
185 return fParent;
186}
187
188////////////////////////////////////////////////////////////////////////////////
189/// Returns main pointer
190
192{
193 return fPointer;
194}
195
196////////////////////////////////////////////////////////////////////////////////
197/// Returns relative numbers of members. If node is collapsed, then method returns number of all members,
198/// it's node and its daughters, otherwise it returns number of members of node
199
201{
202 if (fCollapsed) {
203 return fAllMembersCount;
204 }
205 return fMembersCount;
206}
207
208////////////////////////////////////////////////////////////////////////////////
209/// Returns relative size of node. If node is collapsed, then function returns size of node and dauthers,
210/// otherwise returns size of node only.
211
213{
214 if (fCollapsed) {
215 return fTotalSize;
216 }
217 return fSize;
218}
219
220////////////////////////////////////////////////////////////////////////////////
221/// Returns size or number of members. If ScaleBy is set to kMembers and node is collapsed, then it
222/// returns all number of members. If node isn't collapsed it returns number of members.
223/// If Scaleby is set to kSize and node is collapsed, then it returns total size of node and daughters,
224/// else it returns size of node, otherwise it returns 0.
225
227{
228 if (fgScalBy == kMembers) {
229 if (fCollapsed) {
230 return GetAllMembersCount();
231 } else {
232 return GetMembersCount();
233 }
234 } else if (fgScalBy == kSize) {
235 if (fCollapsed) {
236 return GetTotalSize();
237 } else {
238 return GetSize();
239 }
240 } else {
241 return 0;
242 }
243}
244
245////////////////////////////////////////////////////////////////////////////////
246/// Returns ratio - relative volume to area taken by utlining box.
247
249{
250 return ((Float_t)(GetRelativeVolume())/(fWidth*fHeight));
251}
252
253////////////////////////////////////////////////////////////////////////////////
254/// Returns size of node
255
257{
258 return fSize;
259}
260
261////////////////////////////////////////////////////////////////////////////////
262/// Returns total size of allocated memory in bytes
263
265{
266 return fTotalSize;
267}
268
269////////////////////////////////////////////////////////////////////////////////
270/// Returns name of class
271
273{
274 return fTypeName;
275}
276
277////////////////////////////////////////////////////////////////////////////////
278/// Returns size or number of members. If ScaleBy is set to kMembers it returns all number of members.
279/// If Scaleby is set to kSize then it returns total size of node and daughters, otherwise it returns 0.
280
282{
283 if (fgScalBy == kMembers) {
284 return GetAllMembersCount();
285 } else if (fgScalBy == kSize) {
286 return GetTotalSize();
287 } else {
288 return 0;
289 }
290
291}
292
293////////////////////////////////////////////////////////////////////////////////
294/// Returns ratio - volme of node to area taken by outlining box
295
297{
298 return ((Float_t)(GetVolume())/(fWidth*fHeight));
299}
300
301////////////////////////////////////////////////////////////////////////////////
302/// Returns width of outlining box
303
305{
306 return fWidth;
307}
308
309////////////////////////////////////////////////////////////////////////////////
310/// Returns X coordinate
311
313{
314 return fX;
315}
316
317////////////////////////////////////////////////////////////////////////////////
318/// Returns Y coordinate
319
321{
322 return fY;
323}
324
325////////////////////////////////////////////////////////////////////////////////
326/// Returns true if node is colllapsed
327
329{
330 return fCollapsed;
331}
332
333////////////////////////////////////////////////////////////////////////////////
334/// Returns true, because we have overrided method Compare
335
337{
338 return kTRUE;
339}
340
341////////////////////////////////////////////////////////////////////////////////
342/// Returns true if node is visible
343
345{
346 return fVisible;
347}
348
349////////////////////////////////////////////////////////////////////////////////
350/// Sets numbers of all members to "number"
351
353{
354 fAllMembersCount = number;
355}
356
357////////////////////////////////////////////////////////////////////////////////
358/// Sets collapsing of node to "collapse"
359
361{
362 fCollapsed = collapse;
363}
364
365////////////////////////////////////////////////////////////////////////////////
366/// Sets width of outlining box to "w"
367
369{
370 fHeight = val;
371}
372
373////////////////////////////////////////////////////////////////////////////////
374/// Sets maximum number of leves displayed when the node is top node on scene
375
377{
378 fMaxLevel = level;
379}
380
381////////////////////////////////////////////////////////////////////////////////
382/// Sets maximum number of objects displayed when the node is top node on scene
383
385{
386 fMaxObjects = max;
387}
388
389////////////////////////////////////////////////////////////////////////////////
390/// Sets list of dauther nodes to "list"
391
393{
394 fMembers = list;
395}
396
397////////////////////////////////////////////////////////////////////////////////
398/// Sets number of members to "number"
399
401{
402 fMembersCount = number;
403}
404
405////////////////////////////////////////////////////////////////////////////////
406/// Sets type of node to "type"
407
409{
410 fNodeType = type;
411}
412
413////////////////////////////////////////////////////////////////////////////////
414/// Sets main pointer to "pointer"
415
416void TStructNode::SetPointer(void* pointer)
417{
418 fPointer = pointer;
419}
420
421////////////////////////////////////////////////////////////////////////////////
422/// Sets scaling by to "type"
423
425{
426 fgScalBy = type;
427}
428
429////////////////////////////////////////////////////////////////////////////////
430/// Sets size of node to "size"
431
433{
434 fSize = size;
435}
436
437////////////////////////////////////////////////////////////////////////////////
438/// Sets total size of allocated memory in bytes to value "size"
439
441{
442 fTotalSize = size;
443}
444
445////////////////////////////////////////////////////////////////////////////////
446/// Sets visibility of node to "visible"
447
448void TStructNode::SetVisible(bool visible)
449{
450 fVisible = visible;
451}
452
453////////////////////////////////////////////////////////////////////////////////
454/// Sets width of outlining box to "w"
455
457{
458 fWidth = w;
459}
460
461////////////////////////////////////////////////////////////////////////////////
462/// Sets X coordinate to "x"
463
465{
466 fX = x;
467}
468
469////////////////////////////////////////////////////////////////////////////////
470/// Sets Y coordinate to "y"
471
473{
474 fY = y;
475}
unsigned long ULong_t
Definition RtypesCore.h:55
float Float_t
Definition RtypesCore.h:57
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassImp(name)
Definition Rtypes.h:364
char name[80]
Definition TGX11.cxx:110
int type
Definition TGX11.cxx:121
EScalingType
Definition TStructNode.h:25
@ kSize
Definition TStructNode.h:26
@ kMembers
Definition TStructNode.h:27
ENodeType
Definition TStructNode.h:18
A doubly linked list.
Definition TList.h:44
virtual void Add(TObject *obj)
Definition TList.h:87
Mother of all ROOT objects.
Definition TObject.h:37
Basic string class.
Definition TString.h:136
const char * Data() const
Definition TString.h:369
TStructNode(TString name, TString typeName, void *pointer, TStructNode *parent, ULong_t size, ENodeType type)
Constructs node with name "name" of class "typeName" and given parent "parent" which represents point...
void SetNodeType(ENodeType type)
Sets type of node to "type".
UInt_t GetMaxLevel() const
Returns maximum number of leves displayed when the node is top node on scene.
virtual Bool_t IsSortable() const
Returns true, because we have overrided method Compare.
ULong_t fTotalSize
Definition TStructNode.h:41
ULong_t GetAllMembersCount() const
Returns number of all members in node.
void SetY(Float_t y)
Sets Y coordinate to "y".
ULong_t GetSize() const
Returns size of node.
void SetPointer(void *pointer)
Sets main pointer to "pointer".
Float_t fHeight
Definition TStructNode.h:53
TString GetTypeName() const
Returns name of class.
void SetX(Float_t x)
Sets X coordinate to "x".
TString fName
Definition TStructNode.h:38
UInt_t fMaxLevel
Definition TStructNode.h:55
TStructNode * GetParent() const
Returns pointer to parent node.
void SetWidth(Float_t w)
Sets width of outlining box to "w".
void SetCollapsed(Bool_t collapsed)
Sets collapsing of node to "collapse".
void SetMaxLevel(UInt_t level)
Sets maximum number of leves displayed when the node is top node on scene.
ULong_t fSize
Definition TStructNode.h:40
ULong_t fMembersCount
Definition TStructNode.h:44
ULong_t GetMembersCount() const
Returns numbers of members of node.
Bool_t fCollapsed
Definition TStructNode.h:47
bool IsVisible() const
Returns true if node is visible.
virtual Int_t Compare(const TObject *obj) const
Overrided method. Compare to objects of TStructNode class.
void SetMembersCount(ULong_t count)
Sets number of members to "number".
void SetSize(ULong_t size)
Sets size of node to "size".
void SetMembers(TList *list)
Sets list of dauther nodes to "list".
ULong_t GetRelativeSize() const
Returns relative size of node.
Float_t GetCenter() const
Returns center of outlining box on x-axis.
ULong_t GetVolume() const
Returns size or number of members.
Bool_t fVisible
Definition TStructNode.h:48
void * GetPointer() const
Returns main pointer.
void SetTotalSize(ULong_t size)
Sets total size of allocated memory in bytes to value "size".
UInt_t fLevel
Definition TStructNode.h:43
TString fTypeName
Definition TStructNode.h:39
void SetAllMembersCount(ULong_t count)
Sets numbers of all members to "number".
~TStructNode()
Destructs list of nodes.
Float_t GetY() const
Returns Y coordinate.
ULong_t GetRelativeVolume() const
Returns size or number of members.
void SetVisible(bool visible)
Sets visibility of node to "visible".
TList * GetMembers() const
Returns list with pointers to daughter nodes.
void SetMaxObjects(UInt_t max)
Sets maximum number of objects displayed when the node is top node on scene.
ULong_t GetRelativeMembersCount() const
Returns relative numbers of members.
Float_t fY
Definition TStructNode.h:51
Float_t GetWidth() const
Returns width of outlining box.
ULong_t fAllMembersCount
Definition TStructNode.h:45
Float_t GetVolumeRatio()
Returns ratio - volme of node to area taken by outlining box.
static void SetScaleBy(EScalingType type)
Sets scaling by to "type".
Float_t GetX() const
Returns X coordinate.
UInt_t fMaxObjects
Definition TStructNode.h:56
const char * GetName() const
Returns name of object.
ENodeType fNodeType
Definition TStructNode.h:54
Float_t GetRelativeVolumeRatio()
Returns ratio - relative volume to area taken by utlining box.
TList * fMembers
Definition TStructNode.h:49
Float_t GetMiddle() const
Returns center of outlining box on y-axis.
ENodeType GetNodeType() const
Returns type of node.
void SetHeight(Float_t h)
Sets width of outlining box to "w".
Float_t GetHeight() const
Returns height of outlining box.
UInt_t GetMaxObjects() const
Returns maximum number of objects displayed when the node is top node on scene.
static EScalingType fgScalBy
Definition TStructNode.h:37
TStructNode * fParent
Definition TStructNode.h:42
UInt_t GetLevel() const
Returns actual level of node.
Float_t fWidth
Definition TStructNode.h:52
void * fPointer
Definition TStructNode.h:46
ULong_t GetTotalSize() const
Returns total size of allocated memory in bytes.
Float_t fX
Definition TStructNode.h:50
Bool_t IsCollapsed() const
Returns true if node is colllapsed.
struct void * fTypeName
Definition cppyy.h:9
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17