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
16
17//________________________________________________________________________
18//////////////////////////////////////////////////////////////////////////
19//
20// TStructNode - class which represent a node. Node has all information
21// about some pointer. It keeps information such as name of object, type,
22// size of pointers class, size of node and daughter nodes, number of child
23// nodes. It is also used to store information needed to draw TGeoVolume.
24// It is for example x, y and z coordinates.
25// Condition fVisible tells us that node is visible and should be drawn.
26// fCollapsed tells us that we can see daughter nodes.
27//
28//////////////////////////////////////////////////////////////////////////
29
31
32////////////////////////////////////////////////////////////////////////////////
33/// Constructs node with name "name" of class "typeName" and given parent "parent" which represents pointer "pointer".
34/// Size of node is set to "size" and type is set to "type"
35
37{
38 fName = name;
39 fTypeName = typeName;
41 fMembers = new TList();
43 fLevel = 1;
44 fX = fY = fWidth = fHeight = 0;
45 fParent = parent;
46 if (parent) {
47 fLevel = parent->GetLevel()+1;
48 parent->fMembers->Add(this);
49 }
50
52 fPointer = pointer;
53 fCollapsed = false;
54 fVisible = false;
55 fMaxLevel = 3;
56 fMaxObjects = 100;
57}
58
59////////////////////////////////////////////////////////////////////////////////
60/// Destructs list of nodes
61
66
67////////////////////////////////////////////////////////////////////////////////
68/// Overrided method. Compare to objects of TStructNode class.
69
71{
72 TStructNode* node = (TStructNode*)obj;
73
74 if (GetVolume() < node->GetVolume()) {
75 return -1;
76 }
77 if(GetVolume() > node->GetVolume()) {
78 return 1;
79 }
80
81 if (this > node) {
82 return 1;
83 }
84 if (this < node) {
85 return -1;
86 }
87
88 return 0;
89}
90
91////////////////////////////////////////////////////////////////////////////////
92/// Returns number of all members in node
93
98
99////////////////////////////////////////////////////////////////////////////////
100/// Returns center of outlining box on x-axis
101
103{
104 return (fX + fWidth /2);
105}
106
107////////////////////////////////////////////////////////////////////////////////
108/// Returns height of outlining box
109
111{
112 return fHeight;
113}
114
115////////////////////////////////////////////////////////////////////////////////
116/// Returns actual level of node
117
119{
120 return fLevel;
121}
122
123////////////////////////////////////////////////////////////////////////////////
124/// Returns name of object
125
126const char* TStructNode::GetName() const
127{
128 return fName.Data();
129}
130
131////////////////////////////////////////////////////////////////////////////////
132/// Returns type of node
133
135{
136 return fNodeType;
137}
138
139////////////////////////////////////////////////////////////////////////////////
140/// Returns maximum number of leves displayed when the node is top node on scene
141
143{
144 return fMaxLevel;
145}
146
147////////////////////////////////////////////////////////////////////////////////
148/// Returns maximum number of objects displayed when the node is top node on scene
149
151{
152 return fMaxObjects;
153}
154
155////////////////////////////////////////////////////////////////////////////////
156/// Returns list with pointers to daughter nodes.
157
159{
160 return fMembers;
161}
162
163////////////////////////////////////////////////////////////////////////////////
164/// Returns numbers of members of node
165
170
171////////////////////////////////////////////////////////////////////////////////
172/// Returns center of outlining box on y-axis
173
175{
176 return (fY + fHeight/2);
177}
178
179////////////////////////////////////////////////////////////////////////////////
180/// Returns pointer to parent node
181
183{
184 return fParent;
185}
186
187////////////////////////////////////////////////////////////////////////////////
188/// Returns main pointer
189
191{
192 return fPointer;
193}
194
195////////////////////////////////////////////////////////////////////////////////
196/// Returns relative numbers of members. If node is collapsed, then method returns number of all members,
197/// it's node and its daughters, otherwise it returns number of members of node
198
200{
201 if (fCollapsed) {
202 return fAllMembersCount;
203 }
204 return fMembersCount;
205}
206
207////////////////////////////////////////////////////////////////////////////////
208/// Returns relative size of node. If node is collapsed, then function returns size of node and dauthers,
209/// otherwise returns size of node only.
210
212{
213 if (fCollapsed) {
214 return fTotalSize;
215 }
216 return fSize;
217}
218
219////////////////////////////////////////////////////////////////////////////////
220/// Returns size or number of members. If ScaleBy is set to kMembers and node is collapsed, then it
221/// returns all number of members. If node isn't collapsed it returns number of members.
222/// If Scaleby is set to kSize and node is collapsed, then it returns total size of node and daughters,
223/// else it returns size of node, otherwise it returns 0.
224
226{
227 if (fgScalBy == kMembers) {
228 if (fCollapsed) {
229 return GetAllMembersCount();
230 } else {
231 return GetMembersCount();
232 }
233 } else if (fgScalBy == kSize) {
234 if (fCollapsed) {
235 return GetTotalSize();
236 } else {
237 return GetSize();
238 }
239 } else {
240 return 0;
241 }
242}
243
244////////////////////////////////////////////////////////////////////////////////
245/// Returns ratio - relative volume to area taken by utlining box.
246
251
252////////////////////////////////////////////////////////////////////////////////
253/// Returns size of node
254
256{
257 return fSize;
258}
259
260////////////////////////////////////////////////////////////////////////////////
261/// Returns total size of allocated memory in bytes
262
264{
265 return fTotalSize;
266}
267
268////////////////////////////////////////////////////////////////////////////////
269/// Returns name of class
270
272{
273 return fTypeName;
274}
275
276////////////////////////////////////////////////////////////////////////////////
277/// Returns size or number of members. If ScaleBy is set to kMembers it returns all number of members.
278/// If Scaleby is set to kSize then it returns total size of node and daughters, otherwise it returns 0.
279
281{
282 if (fgScalBy == kMembers) {
283 return GetAllMembersCount();
284 } else if (fgScalBy == kSize) {
285 return GetTotalSize();
286 } else {
287 return 0;
288 }
289
290}
291
292////////////////////////////////////////////////////////////////////////////////
293/// Returns ratio - volme of node to area taken by outlining box
294
299
300////////////////////////////////////////////////////////////////////////////////
301/// Returns width of outlining box
302
304{
305 return fWidth;
306}
307
308////////////////////////////////////////////////////////////////////////////////
309/// Returns X coordinate
310
312{
313 return fX;
314}
315
316////////////////////////////////////////////////////////////////////////////////
317/// Returns Y coordinate
318
320{
321 return fY;
322}
323
324////////////////////////////////////////////////////////////////////////////////
325/// Returns true if node is colllapsed
326
328{
329 return fCollapsed;
330}
331
332////////////////////////////////////////////////////////////////////////////////
333/// Returns true, because we have overrided method Compare
334
336{
337 return kTRUE;
338}
339
340////////////////////////////////////////////////////////////////////////////////
341/// Returns true if node is visible
342
344{
345 return fVisible;
346}
347
348////////////////////////////////////////////////////////////////////////////////
349/// Sets numbers of all members to "number"
350
352{
353 fAllMembersCount = number;
354}
355
356////////////////////////////////////////////////////////////////////////////////
357/// Sets collapsing of node to "collapse"
358
363
364////////////////////////////////////////////////////////////////////////////////
365/// Sets width of outlining box to "w"
366
368{
369 fHeight = val;
370}
371
372////////////////////////////////////////////////////////////////////////////////
373/// Sets maximum number of leves displayed when the node is top node on scene
374
376{
377 fMaxLevel = level;
378}
379
380////////////////////////////////////////////////////////////////////////////////
381/// Sets maximum number of objects displayed when the node is top node on scene
382
384{
385 fMaxObjects = max;
386}
387
388////////////////////////////////////////////////////////////////////////////////
389/// Sets list of dauther nodes to "list"
390
392{
393 fMembers = list;
394}
395
396////////////////////////////////////////////////////////////////////////////////
397/// Sets number of members to "number"
398
400{
401 fMembersCount = number;
402}
403
404////////////////////////////////////////////////////////////////////////////////
405/// Sets type of node to "type"
406
411
412////////////////////////////////////////////////////////////////////////////////
413/// Sets main pointer to "pointer"
414
415void TStructNode::SetPointer(void* pointer)
416{
417 fPointer = pointer;
418}
419
420////////////////////////////////////////////////////////////////////////////////
421/// Sets scaling by to "type"
422
427
428////////////////////////////////////////////////////////////////////////////////
429/// Sets size of node to "size"
430
435
436////////////////////////////////////////////////////////////////////////////////
437/// Sets total size of allocated memory in bytes to value "size"
438
443
444////////////////////////////////////////////////////////////////////////////////
445/// Sets visibility of node to "visible"
446
447void TStructNode::SetVisible(bool visible)
448{
449 fVisible = visible;
450}
451
452////////////////////////////////////////////////////////////////////////////////
453/// Sets width of outlining box to "w"
454
456{
457 fWidth = w;
458}
459
460////////////////////////////////////////////////////////////////////////////////
461/// Sets X coordinate to "x"
462
464{
465 fX = x;
466}
467
468////////////////////////////////////////////////////////////////////////////////
469/// Sets Y coordinate to "y"
470
472{
473 fY = y;
474}
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:69
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Definition TGX11.cxx:110
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:38
void Add(TObject *obj) override
Definition TList.h:81
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:138
const char * Data() const
Definition TString.h:384
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.
ULong_t fTotalSize
Definition TStructNode.h:41
const char * GetName() const override
Returns name of object.
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.
Int_t Compare(const TObject *obj) const override
Overrided method. Compare to objects of TStructNode class.
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.
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".
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
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
Bool_t IsSortable() const override
Returns true, because we have overrided method Compare.
TStructNode * fParent
Definition TStructNode.h:42
~TStructNode() override
Destructs list of nodes.
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.
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17