Logo ROOT   6.10/09
Reference Guide
TStructViewerGUI.h
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 #ifndef ROOT_TStructViewerGUI
13 #define ROOT_TStructViewerGUI
14 
15 #include <TGFrame.h>
16 #include <TGLEmbeddedViewer.h>
17 #include <TGToolTip.h>
18 #include <TGLabel.h>
19 #include <TGNumberEntry.h>
20 #include <TGeoVolume.h>
21 #include <TExMap.h>
22 
23 class TGeoMedium;
24 class TStructViewer;
25 class TGeoVolume;
26 class TStructNode;
27 class TCanvas;
28 class TGCheckButton;
29 class TGTextButton;
30 class TGRadioButton;
31 class TStructNodeEditor;
33 class TGLPhysicalShape;
34 class TString;
35 class TGTextEntry;
36 
37 class TStructViewerGUI : public TGMainFrame {
38 
39 private:
40  TStructViewer *fParent; // Pointer to Viewer GUI
41  TGeoVolume *fTopVolume; // Main volume containing all others volumes
42  TStructNode *fNodePtr; // Root node which represents the main pointer
43  UInt_t fMaxSlices; // Maximum number of slices used to build a collection node
44  UInt_t fMouseX; // Position of ToolTip on x-axis
45  UInt_t fMouseY; // Position of ToolTip on y-axis
46  TStructNode *fSelectedObject; // Pointer to actual selected object on scene
47  TList fUndoList; // List with nodes pointers which were top nodes
48  TList fRedoList; // List with nodes pointers which were top nodes
49  TList fVisibleObjects; // List with pointer to nodes which are visible
50  Float_t fMaxRatio; // Maximum ratio used to scale objetcs
51  TList *fColors; // Pointer to the list with color properties
52  static TGeoMedium *fgMedium; // Material and medium
53  TExMap fVolumes; // Map with pointers to Volumes associated with nodes
54  static UInt_t fgCounter; // Volume counter
55 
56  // layout
57  TCanvas *fCanvas; // Canvas used to store and paint objects
58  TGLEmbeddedViewer *fGLViewer; // GLViewer in frame
59  TGToolTip *fToolTip; // ToolTip is showed when user mouse is over the object
60  TGCheckButton *fShowLinksCheckButton; // Enable/Disable lines between nodes
61  TGLabel *fNodeNameLabel; // Label with name of node
62  TGLabel *fNodeTypelabel; // Label with classname
63  TGLabel *fMembersCountLabel; // Label with number of members in node
64  TGLabel *fAllMembersCountLabel; // Label with daugthers members
65  TGLabel *fSizeLabel; // Label with size of node
66  TGLabel *fTotalSizeLabel; // Label with size of node and daughters nodes
67  TGLabel *fLevelLabel; // Label with level where the node is placed
68  TGTextButton *fUndoButton; // Button which can restore last top node
69  TGTextButton *fRedoButton; // Button which can repeat last node change
70  TGRadioButton *fScaleBySizeButton; // Sets sorting method to size
71  TGRadioButton *fScaleByMembersButton; // Sets sorting method to members
72  TGTextEntry *fPointerTextEntry; // Sets address of pointer
73  TGTextEntry *fPointerTypeTextEntry; // Sets type of pointer
74  TStructNodeEditor *fEditor; // Frame with a node editor
75  TGNumberEntry *fBoxHeightEntry; // Height of boxes
76  TGCheckButton *fAutoRefesh; // Automatic redraw the scene
77  TGNumberEntry *fLevelDistanceEntry; // Distance between levels
78 
79 private:
80  void CalculatePosistion(TStructNode* parent);
81  void CheckMaxObjects(TStructNode* parent);
82  void Divide(TList* list, Float_t x1, Float_t x2, Float_t y1, Float_t y2);
83  void DrawNode(TStructNode* node);
84  void DrawLink(TStructNode* parent);
85  void DrawVolumes(TStructNode* visObj);
87  void Scale(TStructNode* parent);
88  void UnCheckMaxObjects();
89  void UpdateLabels( TStructNode* node );
90 
91 public:
92  TStructViewerGUI(TStructViewer* parent, TStructNode* nodePtr, TList* colors, const TGWindow *p = NULL,
93  UInt_t w = 800, UInt_t h = 600);
95 
98  void CloseWindow();
99  void ColorSelectedSlot(Pixel_t pixel);
100  void DoubleClickedSlot();
101  void Draw(Option_t* option = "");
102  TCanvas *GetCanvas();
103  Int_t GetColor(TStructNode* node);
105  Bool_t GetLinksVisibility() const;
106  TStructNode *GetNodePtr() const;
107  void GLWidgetProcessedEventSlot(Event_t* event);
109  void MouseOverSlot(TGLPhysicalShape* shape);
110  void RedoButtonSlot();
111  void ResetButtonSlot();
112  void ScaleByChangedSlot();
113  void SetLinksVisibility(Bool_t val);
114  void SetNodePtr(TStructNode* val);
115  void SetPointerButtonSlot();
116  void ShowLinksToggled(Bool_t on);
117  void UndoButtonSlot();
118  void Update(Bool_t resetCamera = false);
119  void UpdateButtonSlot();
120 
121  ClassDef(TStructViewerGUI, 0); // A GUI fo 3D struct viewer
122 };
123 
124 #endif
double dist(Rotation3D const &r1, Rotation3D const &r2)
Definition: 3DDistances.cxx:48
void SetNodePtr(TStructNode *val)
Sets top node pointer and updates view.
TGTextEntry * fPointerTypeTextEntry
void CalculatePosistion(TStructNode *parent)
Recursive method to calculating nodes posistion in 3D space.
void Update(Bool_t resetCamera=false)
Updates view. Clear all the nodes, call draw function and update scene. Doesn&#39;t reset camera...
void SetLinksVisibility(Bool_t val)
Sets links visibility to "visible".
void ScaleByChangedSlot()
Activated when user press radio button.
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
TGNumberEntry * fBoxHeightEntry
TH1 * h
Definition: legend2.C:5
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition: TGeoVolume.h:48
TGToolTip * fToolTip
Basic string class.
Definition: TString.h:129
TStructNodeProperty * FindNodeProperty(TStructNode *node)
Returns pointer to property associated with node "node".
void ColorSelectedSlot(Pixel_t pixel)
Slot for default color selsect.
TGRadioButton * fScaleByMembersButton
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TGLabel * fNodeTypelabel
#define NULL
Definition: RtypesCore.h:88
void ShowLinksToggled(Bool_t on)
Changes links visibility and refresh view.
Minimal GL-viewer that can be embedded in a standard ROOT frames.
Concrete physical shape - a GL drawable.
Bool_t GetLinksVisibility() const
Returns true if links are visible, otherwise return false.
~TStructViewerGUI()
Destructor.
TGLabel * fMembersCountLabel
void UpdateLabels(TStructNode *node)
Refresh information in labels when user put mouse over object.
static const double x2[5]
TGTextButton * fUndoButton
#define ClassDef(name, id)
Definition: Rtypes.h:297
ULong_t Pixel_t
Definition: GuiTypes.h:39
void Divide(TList *list, Float_t x1, Float_t x2, Float_t y1, Float_t y2)
Divides rectangle where the outlining box is placed.
void CloseWindow()
Delete window.
TStructNodeEditor * fEditor
void Scale(TStructNode *parent)
Recursive method to scaling all modes on scene.
void UpdateButtonSlot()
Update button slot. Updates scene.
static TGeoMedium * fgMedium
void DrawLink(TStructNode *parent)
Recursive method to draw links.
A doubly linked list.
Definition: TList.h:43
static UInt_t fgCounter
TGCheckButton * fAutoRefesh
void GLWidgetProcessedEventSlot(Event_t *event)
Handle events. Sets fMouseX and fMouseY when user move a mouse over viewer and hides ToolTip...
TStructNodeProperty * GetDefaultColor()
Return default color for nodes.
void DrawNode(TStructNode *node)
Creates and draws TGeoVolume from given "node".
void UnCheckMaxObjects()
Shows hidden nodes.
TStructViewer * fParent
unsigned int UInt_t
Definition: RtypesCore.h:42
TGLabel * fNodeNameLabel
TGTextButton * fRedoButton
TGLabel * fAllMembersCountLabel
TGLEmbeddedViewer * fGLViewer
TGeoVolume * fTopVolume
long Long_t
Definition: RtypesCore.h:50
Color * colors
Definition: X3DBuffer.c:19
The Canvas class.
Definition: TCanvas.h:31
TGRadioButton * fScaleBySizeButton
void Draw(Option_t *option="")
Check limits and draws nodes and links.
static const double x1[5]
TStructNode * GetNodePtr() const
Returns top node pointer.
void RedoButtonSlot()
Activated when user click Redo button. Repeat last Undo action.
void DrawVolumes(TStructNode *visObj)
Recursive method to draw GeoVolumes.
TGNumberEntry * fLevelDistanceEntry
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition: TGeoMedium.h:23
TGTextEntry * fPointerTextEntry
void AutoRefreshButtonSlot(Bool_t on)
Activated when user chage condition.
void BoxHeightValueSetSlot(Long_t h)
Emmited when user changes height of boxes.
void CheckMaxObjects(TStructNode *parent)
Check if all of nodes can be displayed on scene. Hides redendant nodes.
TStructNode * fSelectedObject
TStructViewerGUI(TStructViewer *parent, TStructNode *nodePtr, TList *colors, const TGWindow *p=NULL, UInt_t w=800, UInt_t h=600)
Constructs window with "w" as width, "h" as height and given parent "p".
TStructNode * fNodePtr
Int_t GetColor(TStructNode *node)
Returns color form fColors for given "node".
void ResetButtonSlot()
Resets camera.
TGLabel * fTotalSizeLabel
TGCheckButton * fShowLinksCheckButton
void SetPointerButtonSlot()
Sets pointer given in fPointerTestEntry to the main pointer.
void DoubleClickedSlot()
Activated when user double click on objects on 3D scene.
void LevelDistValueSetSlot(Long_t dist)
Emmited when user changes distance between levels.
void MouseOverSlot(TGLPhysicalShape *shape)
MouseOver slot.
void UndoButtonSlot()
UndoButton Slot. Activated when user press Undo button. Restore last top node pointer.
This class stores a (key,value) pair using an external hash.
Definition: TExMap.h:33