Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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;
32 class TStructNodeProperty;
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);
86  TStructNodeProperty* FindNodeProperty(TStructNode* node);
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);
94  ~TStructViewerGUI();
95 
96  void AutoRefreshButtonSlot(Bool_t on);
97  void BoxHeightValueSetSlot(Long_t h);
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);
104  TStructNodeProperty* GetDefaultColor();
105  Bool_t GetLinksVisibility() const;
106  TStructNode *GetNodePtr() const;
107  void GLWidgetProcessedEventSlot(Event_t* event);
108  void LevelDistValueSetSlot(Long_t dist);
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