ROOT logo
// @(#)root/gviz3d:$Id: TStructViewerGUI.h 30023 2009-09-02 17:57:16Z 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_TStructViewerGUI
#define ROOT_TStructViewerGUI

#include <TGFrame.h>
#include <TGLEmbeddedViewer.h>
#include <TGToolTip.h>
#include <TGLabel.h>
#include <TGNumberEntry.h>
#include <TGeoVolume.h>
#include <TExMap.h>

class TGeoMedium;
class TStructViewer;
class TGeoVolume;
class TStructNode;
class TCanvas;
class TGCheckButton;
class TGTextButton;
class TGRadioButton;
class TStructNodeEditor;
class TStructNodeProperty;
class TGLPhysicalShape;
class TString;
class TGTextEntry;

class TStructViewerGUI : public TGMainFrame {

private:
   TStructViewer       *fParent;                // Pointer to Viewer GUI
   TGeoVolume          *fTopVolume;             // Main volume containing all others volumes
   TStructNode         *fNodePtr;               // Root node which represents the main pointer
   UInt_t               fMaxSlices;             // Maximum number of slices used to build a collection node
   UInt_t               fMouseX;                // Position of ToolTip on x-axis
   UInt_t               fMouseY;                // Position of ToolTip on y-axis
   TStructNode         *fSelectedObject;        // Pointer to actual selected object on scene
   TList                fUndoList;              // List with nodes pointers which were top nodes
   TList                fRedoList;              // List with nodes pointers which were top nodes
   TList                fVisibleObjects;        // List with pointer to nodes which are visible
   Float_t              fMaxRatio;              // Maximum ratio used to scale objetcs
   TList               *fColors;                // Pointer to the list with color properties
   static TGeoMedium   *fgMedium;               // Material and medium
   TExMap               fVolumes;               // Map with pointers to Volumes associated with nodes
   static UInt_t        fgCounter;              // Volume counter

   // layout
   TCanvas             *fCanvas;                // Canvas used to store and paint objects
   TGLEmbeddedViewer   *fGLViewer;              // GLViewer in frame
   TGToolTip           *fToolTip;               // ToolTip is showed when user mouse is over the object
   TGCheckButton       *fShowLinksCheckButton;  // Enable/Disable lines between nodes
   TGLabel             *fNodeNameLabel;         // Label with name of node
   TGLabel             *fNodeTypelabel;         // Label with classname
   TGLabel             *fMembersCountLabel;     // Label with number of members in node
   TGLabel             *fAllMembersCountLabel;  // Label with daugthers members
   TGLabel             *fSizeLabel;             // Label with size of node
   TGLabel             *fTotalSizeLabel;        // Label with size of node and daughters nodes
   TGLabel             *fLevelLabel;            // Label with level where the node is placed
   TGTextButton        *fUndoButton;            // Button which can restore last top node
   TGTextButton        *fRedoButton;            // Button which can repeat last node change
   TGRadioButton       *fScaleBySizeButton;     // Sets sorting method to size
   TGRadioButton       *fScaleByMembersButton;  // Sets sorting method to members
   TGTextEntry         *fPointerTextEntry;      // Sets address of pointer
   TGTextEntry         *fPointerTypeTextEntry;  // Sets type of pointer
   TStructNodeEditor   *fEditor;                // Frame with a node editor
   TGNumberEntry       *fBoxHeightEntry;        // Height of boxes
   TGCheckButton       *fAutoRefesh;            // Automatic redraw the scene
   TGNumberEntry       *fLevelDistanceEntry;    // Distance between levels
   
private:
   void           CalculatePosistion(TStructNode* parent);
   void           CheckMaxObjects(TStructNode* parent);
   void           Divide(TList* list, Float_t x1, Float_t x2, Float_t y1, Float_t y2);
   void           DrawNode(TStructNode* node);
   void           DrawLink(TStructNode* parent);
   void           DrawVolumes(TStructNode* visObj);
   TStructNodeProperty* FindNodeProperty(TStructNode* node);
   void           Scale(TStructNode* parent);
   void           UnCheckMaxObjects();
   void           UpdateLabels( TStructNode* node );

public:
   TStructViewerGUI(TStructViewer* parent, TStructNode* nodePtr, TList* colors, const TGWindow *p = NULL, 
      UInt_t w = 800, UInt_t h = 600);
   ~TStructViewerGUI();
   
   void           AutoRefreshButtonSlot(Bool_t on);
   void           BoxHeightValueSetSlot(Long_t h);
   void           CloseWindow();
   void           ColorSelectedSlot(Pixel_t pixel);
   void           DoubleClickedSlot();
   void           Draw(Option_t* option = "");
   TCanvas       *GetCanvas();
   Int_t          GetColor(TStructNode* node);
   TStructNodeProperty* GetDefaultColor();
   Bool_t         GetLinksVisibility() const;
   TStructNode   *GetNodePtr() const;
   void           GLWidgetProcessedEventSlot(Event_t* event);
   void           LevelDistValueSetSlot(Long_t dist);
   void           MouseOverSlot(TGLPhysicalShape* shape);
   void           RedoButtonSlot();
   void           ResetButtonSlot();
   void           ScaleByChangedSlot();
   void           SetLinksVisibility(Bool_t val);
   void           SetNodePtr(TStructNode* val);
   void           SetPointerButtonSlot();
   void           ShowLinksToggled(Bool_t on);
   void           UndoButtonSlot();
   void           Update(Bool_t resetCamera = false);
   void           UpdateButtonSlot();
   
   ClassDef(TStructViewerGUI, 1); // A GUI fo 3D struct viewer 
};

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