ROOT logo
// @(#)root/gviz3d:$Id: TStructNode.h 29985 2009-08-31 16:05:21Z brun $
// Author: Tomasz Sosnicki   18/09/09

/************************************************************************
* Copyright (C) 1995-2009, Rene Brun and Fons Rademakers.               *
* All rights reserved.                                                  *
*                                                                       *
* For the licensing terms see $ROOTSYS/LICENSE.                         *
* For the list of contributors see $ROOTSYS/README/CREDITS.             *
*************************************************************************/

#ifndef ROOT_TStructNode
#define ROOT_TStructNode

#include <TObject.h>
#include <TString.h>

enum ENodeType {
   kUnknown = 1,  // Unknown type
   kClass,        // Class or structure
   kCollection,   // TCollection (e.g. TList, TExMap, TMap etc.)
   kBasic,        // Basic type (e.g. char, float, double)
   kSTLCollection // STL collection
};
enum EScalingType {
   kSize,         // Objects are proportional to allocated memory
   kMembers       // Objects are proportional to number of members
};

//________________________________________________________________________
//
// Logical node with informatioon about class

class TStructNode : public TObject {

private:
   static EScalingType  fgScalBy;
   TString              fName;            // Name of node
   TString              fTypeName;        // Name of type
   ULong_t              fSize;            // Memory allocated by class without pointers and list elements
   ULong_t              fTotalSize;       // Total allocated memory
   TStructNode         *fParent;          // Pointer to parent node, NULL if not exist
   UInt_t               fLevel;           // Level number
   ULong_t              fMembersCount;    // Number of members in class
   ULong_t              fAllMembersCount; // Number of all members (class and its daughters)
   void*                fPointer;         // Pointer to data (address of variable)
   Bool_t               fCollapsed;       // Condition - true if node is collapsed (we don't see dauthers)
   Bool_t               fVisible;         // Condition - true if node is visible
   TList*               fMembers;         // List of daughter nodes
   Float_t              fX;               // X coordinate in 3D space
   Float_t              fY;               // Y coordinate in 3D space
   Float_t              fWidth;           // Width of outlining box
   Float_t              fHeight;          // Height of outlining box
   ENodeType            fNodeType;        // Type of node
   UInt_t               fMaxLevel;        // Number of levels displayed when the node is top node on scene
   UInt_t               fMaxObjects;      // Number of objects displayed when the node is top node on scene

public:
   TStructNode(TString name, TString typeName, void* pointer, TStructNode* parent, ULong_t size, ENodeType type);
   ~TStructNode();
   
   virtual Int_t  Compare(const TObject* obj) const;
   ULong_t        GetAllMembersCount() const;
   Float_t        GetCenter() const;
   Float_t        GetHeight() const;
   UInt_t         GetLevel() const;
   UInt_t         GetMaxLevel() const;
   UInt_t         GetMaxObjects() const;
   TList*         GetMembers() const;
   ULong_t        GetMembersCount() const;
   Float_t        GetMiddle() const;
   const char*    GetName() const;
   ENodeType      GetNodeType() const;
   TStructNode   *GetParent() const;
   void*          GetPointer() const;
   ULong_t        GetRelativeMembersCount() const;
   ULong_t        GetRelativeSize() const;
   ULong_t        GetRelativeVolume() const;
   Float_t        GetRelativeVolumeRatio();
   ULong_t        GetSize() const;
   ULong_t        GetTotalSize() const;
   TString        GetTypeName() const;
   ULong_t        GetVolume() const;
   Float_t        GetVolumeRatio();
   Float_t        GetWidth() const;
   Float_t        GetX() const;
   Float_t        GetY() const;
   Bool_t         IsCollapsed() const;
   virtual Bool_t IsSortable() const;
   bool           IsVisible() const;
   void           SetAllMembersCount(ULong_t count);
   void           SetCollapsed(Bool_t collapsed);
   void           SetHeight(Float_t h);
   void           SetMaxLevel(UInt_t level);
   void           SetMaxObjects(UInt_t max);
   void           SetMembers(TList* list);
   void           SetMembersCount(ULong_t count);
   void           SetNodeType(ENodeType type);
   void           SetPointer(void* pointer);
   static void    SetScaleBy(EScalingType type);
   void           SetSize(ULong_t size);
   void           SetTotalSize(ULong_t size);
   void           SetVisible(bool visible);
   void           SetWidth(Float_t w);
   void           SetX(Float_t x);
   void           SetY(Float_t y);

   ClassDef(TStructNode,0); // Node with information about class
};

#endif
 TStructNode.h:1
 TStructNode.h:2
 TStructNode.h:3
 TStructNode.h:4
 TStructNode.h:5
 TStructNode.h:6
 TStructNode.h:7
 TStructNode.h:8
 TStructNode.h:9
 TStructNode.h:10
 TStructNode.h:11
 TStructNode.h:12
 TStructNode.h:13
 TStructNode.h:14
 TStructNode.h:15
 TStructNode.h:16
 TStructNode.h:17
 TStructNode.h:18
 TStructNode.h:19
 TStructNode.h:20
 TStructNode.h:21
 TStructNode.h:22
 TStructNode.h:23
 TStructNode.h:24
 TStructNode.h:25
 TStructNode.h:26
 TStructNode.h:27
 TStructNode.h:28
 TStructNode.h:29
 TStructNode.h:30
 TStructNode.h:31
 TStructNode.h:32
 TStructNode.h:33
 TStructNode.h:34
 TStructNode.h:35
 TStructNode.h:36
 TStructNode.h:37
 TStructNode.h:38
 TStructNode.h:39
 TStructNode.h:40
 TStructNode.h:41
 TStructNode.h:42
 TStructNode.h:43
 TStructNode.h:44
 TStructNode.h:45
 TStructNode.h:46
 TStructNode.h:47
 TStructNode.h:48
 TStructNode.h:49
 TStructNode.h:50
 TStructNode.h:51
 TStructNode.h:52
 TStructNode.h:53
 TStructNode.h:54
 TStructNode.h:55
 TStructNode.h:56
 TStructNode.h:57
 TStructNode.h:58
 TStructNode.h:59
 TStructNode.h:60
 TStructNode.h:61
 TStructNode.h:62
 TStructNode.h:63
 TStructNode.h:64
 TStructNode.h:65
 TStructNode.h:66
 TStructNode.h:67
 TStructNode.h:68
 TStructNode.h:69
 TStructNode.h:70
 TStructNode.h:71
 TStructNode.h:72
 TStructNode.h:73
 TStructNode.h:74
 TStructNode.h:75
 TStructNode.h:76
 TStructNode.h:77
 TStructNode.h:78
 TStructNode.h:79
 TStructNode.h:80
 TStructNode.h:81
 TStructNode.h:82
 TStructNode.h:83
 TStructNode.h:84
 TStructNode.h:85
 TStructNode.h:86
 TStructNode.h:87
 TStructNode.h:88
 TStructNode.h:89
 TStructNode.h:90
 TStructNode.h:91
 TStructNode.h:92
 TStructNode.h:93
 TStructNode.h:94
 TStructNode.h:95
 TStructNode.h:96
 TStructNode.h:97
 TStructNode.h:98
 TStructNode.h:99
 TStructNode.h:100
 TStructNode.h:101
 TStructNode.h:102
 TStructNode.h:103
 TStructNode.h:104
 TStructNode.h:105
 TStructNode.h:106
 TStructNode.h:107
 TStructNode.h:108
 TStructNode.h:109
 TStructNode.h:110
 TStructNode.h:111