// @(#)root/gviz3d:$Id$
// 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.             *
*************************************************************************/

#include "TStructViewerGUI.h"
#include <TRandom.h>
#include "TStructViewer.h"
#include "TStructNodeEditor.h"
#include "TStructNodeProperty.h"
#include "TStructNode.h"
#include <TCanvas.h>
#include <RQ_OBJECT.h>
#include <TGLLogicalShape.h>
#include <TGLPhysicalShape.h>
#include <TGLWidget.h>
#include <TGButtonGroup.h>
#include <TGSplitter.h>
#include <TList.h>
#include <TClass.h>
#include <TDataMember.h>
#include <TExMap.h>
#include <TPolyLine3D.h>
#include <TObjArray.h>
#include <TColor.h>
#include <TGTab.h>
#include <TGeoManager.h>
#include <TGeoMatrix.h>
#include <TMath.h>
#include <TROOT.h>
#include <TApplication.h>

ClassImp(TStructViewerGUI);

//________________________________________________________________________
//////////////////////////////////////////////////////////////////////////
//
// TStructViewerGUI is main window of TStructViewer. It provides graphical
// interface. In the window we can find panel with tabs and frame with
// GLViewer. Tab "Info" serves information about node and is used to naviagate
// backward and forward. Second tab "Options" is used to set few options
// such as links visibility, scaling method or setting a pointer.
// Last tab "Editor" is tab when the TStructNodeEditor is placed.
//
//////////////////////////////////////////////////////////////////////////

TGeoMedium* TStructViewerGUI::fgMedium = NULL;
UInt_t      TStructViewerGUI::fgCounter = 0;

//________________________________________________________________________
TStructViewerGUI::TStructViewerGUI(TStructViewer* parent, TStructNode* nodePtr, TList* colors, const TGWindow *p,UInt_t w,UInt_t h)
   : TGMainFrame(p, w, h, kHorizontalFrame)
{
   // Constructs window with "w" as width, "h" as height and given parent "p". Argument "parent" is a pointer to TStructViewer which contains this GUI.
   // This constructor build window with all controls, build map with colors, init OpenGL Viewer and create TGeoVolumes.

   fParent = parent;
   fNodePtr = nodePtr;

   fMaxSlices = 10;
   fMouseX = 0;
   fMouseY = 0;
   fSelectedObject = NULL;
   fMaxRatio = 0;
   fColors = colors;

   if (!gGeoManager) new TGeoManager("tmp","tmp");
   if (!fgMedium) {
      fgMedium = new TGeoMedium("MED",1,new TGeoMaterial("Mat", 26.98,13,2.7));
   }

   SetCleanup(kDeepCleanup);
   //////////////////////////////////////////////////////////////////////////
   // layout
   //////////////////////////////////////////////////////////////////////////
   TGVerticalFrame* leftFrame = new TGVerticalFrame(this, 200, 200, kFixedWidth);
   this->AddFrame(leftFrame, new TGLayoutHints(kFixedWidth, 1, 1, 1, 1));
   TGTab* tabs = new TGTab(leftFrame);
   TGLayoutHints* expandX = new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 5,5,5,5);
   //////////////////////////////////////////////////////////////////////////
   // INFO
   //////////////////////////////////////////////////////////////////////////
   TGCompositeFrame* infoFrame = tabs->AddTab("Info");
   TGGroupFrame* fInfoMenu = new TGGroupFrame(infoFrame, "Info");
   fNodeNameLabel = new TGLabel(fInfoMenu, "Name:");
   fInfoMenu->AddFrame(fNodeNameLabel, expandX);
   fNodeTypelabel = new TGLabel(fInfoMenu, "Type:");
   fInfoMenu->AddFrame(fNodeTypelabel, expandX);
   fMembersCountLabel = new TGLabel(fInfoMenu, "Members:");
   fInfoMenu->AddFrame(fMembersCountLabel, expandX);
   fAllMembersCountLabel = new TGLabel(fInfoMenu, "All members:");
   fInfoMenu->AddFrame(fAllMembersCountLabel, expandX);
   fLevelLabel = new TGLabel(fInfoMenu, "Level:");
   fInfoMenu->AddFrame(fLevelLabel, expandX);
   fSizeLabel = new TGLabel(fInfoMenu, "Size:");
   fInfoMenu->AddFrame(fSizeLabel, expandX);
   fTotalSizeLabel = new TGLabel(fInfoMenu, "Total size:");
   fInfoMenu->AddFrame(fTotalSizeLabel, expandX);
   infoFrame->AddFrame(fInfoMenu, expandX);

   //////////////////////////////////////////////////////////////////////////
   // OPTIONS
   //////////////////////////////////////////////////////////////////////////
   TGCompositeFrame* options = tabs->AddTab("Options");

   fShowLinksCheckButton = new TGCheckButton(options, "Show links");
   fShowLinksCheckButton->Connect("Toggled(Bool_t)", "TStructViewerGUI", this, "ShowLinksToggled(Bool_t)");
   options->AddFrame(fShowLinksCheckButton);
   fShowLinksCheckButton->SetOn();

   TGVButtonGroup* scaleByGroup = new TGVButtonGroup(options, "Scale by");
   fScaleBySizeButton = new TGRadioButton(scaleByGroup, "Size");
   fScaleBySizeButton->Connect("Clicked()", "TStructViewerGUI", this, "ScaleByChangedSlot()");
   fScaleBySizeButton->SetOn();
   fScaleByMembersButton = new TGRadioButton(scaleByGroup, "Members count");
   fScaleByMembersButton->Connect("Clicked()", "TStructViewerGUI", this, "ScaleByChangedSlot()");
   options->AddFrame(scaleByGroup, expandX);

   TGHorizontalFrame* defaultColorFrame = new TGHorizontalFrame(options);
   options->AddFrame(defaultColorFrame, expandX);
   TGLabel* defColorlabel = new TGLabel(defaultColorFrame, "Default color");
   defaultColorFrame->AddFrame(defColorlabel, expandX);
   TGColorSelect* defColorSelect = new TGColorSelect(defaultColorFrame, GetDefaultColor()->GetPixel());
   defColorSelect->Connect("ColorSelected(Pixel_t)", "TStructViewerGUI", this, "ColorSelectedSlot(Pixel_t)");
   defaultColorFrame->AddFrame(defColorSelect);

   TGHorizontalFrame* boxHeightFrame = new TGHorizontalFrame(options);
   options->AddFrame(boxHeightFrame, expandX);
   TGLabel* boxHeightLabel = new TGLabel(boxHeightFrame, "Box height:");
   boxHeightFrame->AddFrame(boxHeightLabel, expandX);
   fBoxHeightEntry = new TGNumberEntry(boxHeightFrame, 0.1);
   fBoxHeightEntry->SetLimits(TGNumberEntry::kNELLimitMin, 0.01);
   fBoxHeightEntry->Connect("ValueSet(Long_t)", "TStructViewerGUI", this, "BoxHeightValueSetSlot(Long_t)");
   boxHeightFrame->AddFrame(fBoxHeightEntry);

   TGHorizontalFrame* levelDistanceFrame = new TGHorizontalFrame(options);
   options->AddFrame(levelDistanceFrame, expandX);
   TGLabel* lvlDistLabel = new TGLabel(levelDistanceFrame, "Distance between levels");
   levelDistanceFrame->AddFrame(lvlDistLabel, expandX);
   fLevelDistanceEntry = new TGNumberEntry(levelDistanceFrame, 1.1);
   fLevelDistanceEntry->SetLimits(TGNumberEntry::kNELLimitMin, 0.01);
   fLevelDistanceEntry->Connect("ValueSet(Long_t)", "TStructViewerGUI", this, "LevelDistValueSetSlot(Long_t)");
   levelDistanceFrame->AddFrame(fLevelDistanceEntry);

   fAutoRefesh = new TGCheckButton(options, "Auto refresh");
   fAutoRefesh->SetOn();
   fAutoRefesh->Connect("Toggled(Bool_t)", "TStructViewerGUI", this, "AutoRefreshButtonSlot(Bool_t)");
   options->AddFrame(fAutoRefesh, expandX);

   TGLabel* pointerLabel = new TGLabel(options, "Pointer:");
   options->AddFrame(pointerLabel, expandX);
   fPointerTextEntry = new TGTextEntry(options, "0x0000000");
   options->AddFrame(fPointerTextEntry, expandX);
   TGLabel* fPointerTypeLabel = new TGLabel(options, "Pointer Type:");
   options->AddFrame(fPointerTypeLabel, expandX);
   fPointerTypeTextEntry = new TGTextEntry(options, "TObject");
   options->AddFrame(fPointerTypeTextEntry, expandX);
   TGTextButton* setPointerButton = new TGTextButton(options, "Set pointer");
   setPointerButton->Connect("Clicked()", "TStructViewerGUI", this, "SetPointerButtonSlot()");
   options->AddFrame(setPointerButton, expandX);

   //////////////////////////////////////////////////////////////////////////
   // EDITOR
   //////////////////////////////////////////////////////////////////////////
   TGCompositeFrame* editTab = tabs->AddTab("Editor");
   fEditor = new TStructNodeEditor(fColors, editTab);
   fEditor->Connect("Update(Bool_t)", "TStructViewerGUI", this, "Update(Bool_t)");
   editTab->AddFrame(fEditor, expandX);

   leftFrame->AddFrame(tabs, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 1,1,1,1));

   TGVSplitter* splitter = new TGVSplitter(this);
   splitter->SetFrame(leftFrame, true);
   this->AddFrame(splitter, new TGLayoutHints(kLHintsLeft | kLHintsExpandY));

   //////////////////////////////////////////////////////////////////////////
   // NAVIGATE
   //////////////////////////////////////////////////////////////////////////
   fUndoButton = new TGTextButton(leftFrame, "Undo");
   fUndoButton->Connect("Clicked()", "TStructViewerGUI", this, "UndoButtonSlot()");
   fUndoButton->SetEnabled(false);
   leftFrame->AddFrame(fUndoButton, expandX);

   fRedoButton = new TGTextButton(leftFrame, "Redo");
   fRedoButton->Connect("Clicked()", "TStructViewerGUI", this, "RedoButtonSlot()");
   fRedoButton->SetEnabled(false);
   leftFrame->AddFrame(fRedoButton, expandX);

   TGTextButton* resetCameraButton = new TGTextButton(leftFrame, "Reset camera");
   leftFrame->AddFrame(resetCameraButton, expandX);
   resetCameraButton->Connect("Clicked()", "TStructViewerGUI", this, "ResetButtonSlot()");

   TGTextButton* updateButton = new TGTextButton(leftFrame, "Update");
   updateButton->Connect("Clicked()", "TStructViewerGUI", this, "UpdateButtonSlot()");
   leftFrame->AddFrame(updateButton, expandX);

   TGTextButton* quitButton = new TGTextButton(leftFrame, "Quit");
   leftFrame->AddFrame(quitButton, expandX);
   quitButton->Connect("Clicked()", "TApplication", gApplication, "Terminate()");

   fTopVolume = gGeoManager->MakeBox("TOPVolume", fgMedium,100, 100, 100);
   gGeoManager->SetTopVolume(fTopVolume);
   gGeoManager->SetNsegments(40);

   fCanvas = new TCanvas("", "", 0, 0);
   // drawing after creating canvas to avoid drawing in default canvas
   fGLViewer = new TGLEmbeddedViewer(this, fCanvas);
   AddFrame(fGLViewer->GetFrame(), new TGLayoutHints(kLHintsExpandX| kLHintsExpandY, 10,10,10,10));
   fGLViewer->PadPaint(fCanvas);
   fGLViewer->Connect("MouseOver(TGLPhysicalShape*)", "TStructViewerGUI", this, "MouseOverSlot(TGLPhysicalShape*)");
   fGLViewer->GetGLWidget()->Connect("ProcessedEvent(Event_t*)", "TStructViewerGUI", this, "GLWidgetProcessedEventSlot(Event_t*))");
   fGLViewer->Connect("DoubleClicked()", "TStructViewerGUI", this, "DoubleClickedSlot()");
   fGLViewer->SetCurrentCamera(TGLViewer::kCameraPerspXOY);
   Update();
   fGLViewer->SetResetCamerasOnUpdate(false);

   SetWindowName("Struct Viewer");
   MapSubwindows();
   this->SetWMSizeHints(w, h, 2000, 2000, 0, 0);
   Resize(GetDefaultSize());
   MapWindow();

   fToolTip = new TGToolTip(0, 0, "ToolTip", 500);
}

//________________________________________________________________________
TStructViewerGUI::~TStructViewerGUI()
{
   // Destructor

   delete fCanvas;
}

//________________________________________________________________________
void TStructViewerGUI::AutoRefreshButtonSlot(Bool_t on)
{
   // Activated when user chage condition

   if (on) {
      Update();
   }
}

//________________________________________________________________________
void TStructViewerGUI::BoxHeightValueSetSlot(Long_t /* h */)
{
   // Emmited when user changes height of boxes

   if(fAutoRefesh->IsOn()) {
      Update();
   }
}

//________________________________________________________________________
void TStructViewerGUI::CalculatePosistion(TStructNode* parent)
{
   // Recursive method to calculating nodes posistion in 3D space

   // choose scaling method
   if (fScaleBySizeButton->GetState() == kButtonDown) {
      TStructNode::SetScaleBy(kSize);
   } else if (fScaleByMembersButton->GetState() == kButtonDown) {
      TStructNode::SetScaleBy(kMembers);
   }
   Float_t ratio = (Float_t)((parent->GetLevel()+1.0) / parent->GetLevel());

   // changing the angle between parent object and daughters
   // if center of parent is 0 that is real piramid
   parent->SetWidth(1);
   parent->SetHeight(1);
   parent->SetX(-parent->GetWidth()/2);
   parent->SetY(-parent->GetHeight()/2);

   fMaxRatio = parent->GetVolumeRatio();

   // sorting list of members by size or number of members
   parent->GetMembers()->Sort(kSortDescending);
   Divide(parent->GetMembers(), (parent->GetX()) *ratio, (parent->GetX() + parent->GetWidth())* ratio, (parent->GetY())* ratio, (parent->GetY() + parent->GetHeight())*ratio);

   // sclale all the objects
   Scale(parent);
}

//________________________________________________________________________
void TStructViewerGUI::CheckMaxObjects(TStructNode* parent)
{
   // Check if all of nodes can be displayed on scene. Hides redendant nodes.

   UInt_t object = 0;

   TList queue;
   queue.Add(parent);
   TStructNode* node;

   while ((node = (TStructNode*) queue.First() )) {
      object++;

      if (object > fNodePtr->GetMaxObjects() || node->GetLevel() - fNodePtr->GetLevel() >= fNodePtr->GetMaxLevel()) {
         break;
      }

      node->SetVisible(true);

      queue.AddAll(node->GetMembers());
      queue.RemoveFirst();

      fVisibleObjects.Add(node);
   }

   TIter it(&fVisibleObjects);
   TStructNode* member;
   while ((node = (TStructNode*) it() )) {
      if(node->GetLevel() - fNodePtr->GetLevel() == fNodePtr->GetMaxLevel()-1 && node->GetMembersCount() > 0) {
         node->SetCollapsed(true);
         continue;
      }

      TIter memIt(node->GetMembers());
      while ((member = (TStructNode*) memIt() )) {
         if(member->IsVisible() == false) {
            node->SetCollapsed(true);
            break;
         }
      }
   }
}

//________________________________________________________________________
void TStructViewerGUI::CloseWindow()
{
   // Delete window

   DeleteWindow();
}

//________________________________________________________________________
void TStructViewerGUI::ColorSelectedSlot(Pixel_t pixel)
{
   // Slot for default color selsect.
   // Sets default colot to "pixel"

   TStructNodeProperty* prop = GetDefaultColor();
   if(prop) {
      prop->SetColor(pixel);
      Update();
   }
}

//________________________________________________________________________
void TStructViewerGUI::Divide(TList* list, Float_t x1, Float_t x2, Float_t y1, Float_t y2)
{
   // Divides rectangle where the outlining box is placed.

   if (list->GetSize() > 1) { // spliting node into two lists
      ULong_t sum1 = 0, sum = 0;

      TStructNode* node;
      TList list1, list2;
      TIter it(list);

      while((node = (TStructNode*) it() )) {
         sum += node->GetVolume();
      }
      it.Reset();
      while((node = (TStructNode*) it() )) {
         if(sum1 >= sum/2.0) {
            list2.Add(node);
         } else {
            sum1 += node->GetVolume();
            list1.Add(node);
         }
      }

      if (!sum) return;
      Float_t ratio = (float)sum1/sum;

      Float_t width = x2 - x1;
      Float_t height = y2 - y1;
      if (width < height) { // vertical split
         Float_t split = y1 + ratio * height;
         Divide(&list1, x1, x2, y1, split);
         Divide(&list2, x1, x2, split, y2);
      } else { // horizontal
         Float_t split = x1 + ratio * width;
         Divide(&list1, x1, split, y1, y2);
         Divide(&list2, split, x2, y1, y2);
      }
   } else if (list->GetSize() == 1) { // divide place to node
      TStructNode* node = (TStructNode*)(list->First());

      node->SetWidth(x2 - x1);
      node->SetHeight(y2 - y1);
      node->SetX(x1);
      node->SetY(y1);

      if (node->GetVolumeRatio() > fMaxRatio) {
         fMaxRatio = node->GetVolumeRatio();
      }

      Float_t ratio = (Float_t)((node->GetLevel()+1.0)/node->GetLevel());
      node->GetMembers()->Sort(kSortDescending);
      Divide(node->GetMembers(), x1*ratio, x2*ratio, y1*ratio, y2*ratio);
   }
}

//________________________________________________________________________
void TStructViewerGUI::DoubleClickedSlot()
{
   // Activated when user double click on objects on 3D scene. Sets clicked node to top node
   // and updates scene with camers reset.

   if (fSelectedObject) {
      if(fSelectedObject == fNodePtr) {
         return;
      }

      fUndoList.Add(fNodePtr);
      fNodePtr = fSelectedObject;
      fUndoButton->SetEnabled(true);

      Update(kTRUE);
   }
}
//________________________________________________________________________
void TStructViewerGUI::Draw(Option_t* /*option*/)
{
   // Check limits and draws nodes and links

   fVolumes.Clear();
   CheckMaxObjects(fNodePtr);

   CalculatePosistion(fNodePtr);
   DrawVolumes(fNodePtr);

   if(fShowLinksCheckButton->GetState() == kButtonDown) {
      DrawLink(fNodePtr);
   }

   UnCheckMaxObjects();
}

//________________________________________________________________________
void TStructViewerGUI::DrawLink(TStructNode* parent)
{
   // Recursive method to draw links
   if(parent->GetLevel() - fNodePtr->GetLevel() >= fNodePtr->GetMaxLevel()) {
      return;
   }

   if(parent->IsCollapsed()) {
      return;
   }

   TIter it(parent->GetMembers());
   TStructNode* node;
   while((node = (TStructNode*) it())) {
      TPolyLine3D *l = new TPolyLine3D(2);
      l->SetPoint(0 ,node->GetCenter(), node->GetMiddle(), -(node->GetLevel() * fLevelDistanceEntry->GetNumber()));
      l->SetPoint(1 ,parent->GetCenter(), parent->GetMiddle(), -(parent->GetLevel() * fLevelDistanceEntry->GetNumber()));

      l->SetLineColor(GetColor(node));
      l->SetLineWidth(1);
      l->Draw();

      if(!node->IsCollapsed()) {
         DrawLink(node);
      }
   }
}

//________________________________________________________________________
void TStructViewerGUI::DrawNode(TStructNode* node)
{
   // Creates and draws TGeoVolume from given "node"

   TGeoVolume* vol;

   /*if(node->IsCollapsed())
   {
   //float r = (node->GetWidth() < node->GetHeight() ? 0.5 * node->GetWidth() : 0.5 * node->GetHeight());
   //vol = gGeoManager->MakeTorus(node->GetName(),TStructNode::GetMedium(), 0.75*r, 0, r/4);

   vol = gGeoManager->MakeBox(TString(node->GetName()) + "up",TStructNode::GetMedium(), 0.45*node->GetWidth(), 0.45*node->GetHeight(), (node->GetWidth() < node->GetHeight() ? 0.45 * node->GetWidth() : 0.45 * node->GetHeight()));
   Double_t max = TMath::Max(0.22 * node->GetWidth(), 0.22 * node->GetHeight());
   TGeoVolume* subvol = gGeoManager->MakeTrd2(node->GetName(), TStructNode::GetMedium(), 0, 0.45 * node->GetWidth(), 0, 0.45 * node->GetHeight(), max);
   subvol->SetLineColor(GetColor(node));
   subvol->SetNumber((Int_t)node);
   TGeoTranslation* subtrans = new TGeoTranslation("subtranslation", 0, 0, -max);
   vol->AddNodeOverlap(subvol, 1, subtrans);

   subvol = gGeoManager->MakeTrd2(TString(node->GetName()) + "down", TStructNode::GetMedium(), 0.45 * node->GetWidth(), 0, 0.45 * node->GetHeight(), 0, max);
   subvol->SetLineColor(GetColor(node));
   subvol->SetNumber((Int_t)node);
   subtrans = new TGeoTranslation("subtranslation", 0, 0, max);
   vol->AddNodeOverlap(subvol, 1, subtrans);
   }
   else*/ if(node->GetNodeType() == kCollection) {
      vol = gGeoManager->MakeBox(Form("%s_%d", node->GetName(), fgCounter++), fgMedium, 0.45*node->GetWidth(), 0.45*node->GetHeight(), fBoxHeightEntry->GetNumber());
      // subboxes
      Float_t slices = (Float_t)(node->GetMembersCount());
      if (slices > fMaxSlices) {
         slices = (Float_t)fMaxSlices;
      }

      for (Float_t i = -(slices-1)/2; i < slices/2; i++) {
         TGeoVolume* sub = gGeoManager->MakeBox(Form("%s_%d", node->GetName(), fgCounter++), fgMedium,0.45*node->GetWidth() * 0.7 / slices, 0.45*node->GetHeight(), fBoxHeightEntry->GetNumber());
         sub->SetLineColor(GetColor(node));
         fVolumes.Add((Long_t)sub, (Long_t)node);
         TGeoTranslation* subtrans = new TGeoTranslation("subtranslation", i * node->GetWidth() / slices, 0, 0);
         vol->AddNodeOverlap(sub, 1, subtrans);
      }
   } else {
      vol = gGeoManager->MakeBox(Form("%s_%d", node->GetName(), fgCounter++), fgMedium, 0.45*node->GetWidth(), 0.45*node->GetHeight(), fBoxHeightEntry->GetNumber());
   }

   vol->SetLineColor(GetColor(node));
   vol->SetLineWidth(1);

   TGeoTranslation* trans = new TGeoTranslation("translation", node->GetCenter(), node->GetMiddle(), -(node->GetLevel() * fLevelDistanceEntry->GetNumber()));
   fVolumes.Add((Long_t)vol, (Long_t)node);

   fTopVolume->AddNode(vol,1, trans);
}

//________________________________________________________________________
void TStructViewerGUI::DrawVolumes(TStructNode* parent)
{
   // Recursive method to draw GeoVolumes

   if(parent->GetLevel() - fNodePtr->GetLevel() >= fNodePtr->GetMaxLevel()) {
      return;
   }

   DrawNode(parent);

   if(parent->IsCollapsed()) {
      return;
   }

   TIter nextVis(parent->GetMembers());
   TStructNode* node;
   while((node = (TStructNode*)nextVis())) {
      DrawVolumes(node);
   }
}

//________________________________________________________________________
TStructNodeProperty* TStructViewerGUI::FindNodeProperty(TStructNode* node)
{
   // Returns pointer to property associated with node "node". If property is not found
   // then it returns default property

   TIter it(fColors);
   TStructNodeProperty* prop;
   while ((prop = (TStructNodeProperty*) it() )) {
      TString propName(prop->GetName());
      if (propName.EndsWith("+")) {

         if (TClass* cl = TClass::GetClass(node->GetTypeName())) {
            propName.Remove(propName.Length()-1, 1);
            if (cl->InheritsFrom(propName.Data())) {
               return prop;
            }
         }
      } else {
         if (propName == TString(node->GetTypeName())) {
            return prop;
         }
      }
   }

   return (TStructNodeProperty*)fColors->Last();
}

//________________________________________________________________________`
TCanvas* TStructViewerGUI::GetCanvas()
{
   // Returns canvas used to keep TGeoVolumes

   return fCanvas;
}
//________________________________________________________________________
Int_t TStructViewerGUI::GetColor(TStructNode* node)
{
   // Returns color form fColors for given "node"

   TStructNodeProperty* prop = FindNodeProperty(node);
   if (prop) {
      return prop->GetColor().GetNumber();
   }

   return 2;
}

//________________________________________________________________________
TStructNodeProperty* TStructViewerGUI::GetDefaultColor()
{
   // Return default color for nodes

   return ((TStructNodeProperty*)(fColors->Last()));
}

//________________________________________________________________________
Bool_t TStructViewerGUI::GetLinksVisibility() const
{
   // Returns true if links are visible, otherwise return false.

   if (fShowLinksCheckButton->GetState() == kButtonDown) {
      return true;
   } else {
      return false;
   }
}

//________________________________________________________________________
TStructNode* TStructViewerGUI::GetNodePtr() const
{
   // Returns top node pointer

   return fNodePtr;
}

//________________________________________________________________________
void TStructViewerGUI::GLWidgetProcessedEventSlot(Event_t* event)
{
   // Handle events. Sets fMouseX and fMouseY when user move a mouse over viewer and hides ToolTip

   switch (event->fType) {
      case kMotionNotify:
         fMouseX = event->fXRoot + 15;
         fMouseY = event->fYRoot + 15;
         break;

      case kButtonPress:
         fToolTip->Hide();
         if (fSelectedObject) {
            UpdateLabels(fSelectedObject);
            fEditor->SetModel(fSelectedObject);
         }
         break;

      default:
         break;
   }
}

//________________________________________________________________________
void TStructViewerGUI::LevelDistValueSetSlot(Long_t /* dist */)
{
   // Emmited when user changes distance between levels

   if(fAutoRefesh->IsOn()) {
      Update(kTRUE);
   }
}

//________________________________________________________________________
void TStructViewerGUI::MouseOverSlot(TGLPhysicalShape* shape)
{
   // MouseOver slot. Activated when user out mouse over object on scene.
   // Sets ToolTip and updates labels

   fToolTip->Hide();
   fSelectedObject = NULL;
   if (shape && shape->GetLogical()) {
      fSelectedObject =  (TStructNode*)(shape->GetLogical()->ID());
      if (fSelectedObject) {
         if (fSelectedObject->IsA()->InheritsFrom(TPolyLine3D::Class())) {
            fSelectedObject = NULL;
            return;
         }
         Long_t shapeID  = (Long_t)(shape->GetLogical()->ID());
         Long_t volValue = (Long_t)fVolumes.GetValue(shapeID);
         fSelectedObject = (TStructNode*)volValue;

         fToolTip->SetText(TString(fSelectedObject->GetName()) + "\n" + fSelectedObject->GetTypeName());
         fToolTip->SetPosition(fMouseX, fMouseY);
         fToolTip->Reset();
         UpdateLabels(fSelectedObject);
      }
   }
}

//________________________________________________________________________
void TStructViewerGUI::RedoButtonSlot()
{
   // Activated when user click Redo button. Repeat last Undo action.

   fUndoList.Add(fNodePtr);
   fUndoButton->SetEnabled(true);
   fNodePtr = (TStructNode*) fRedoList.Last();
   fRedoList.RemoveLast();
   if (!fRedoList.First()) {
      fRedoButton->SetEnabled(false);
   }
   Update(kTRUE);
   UpdateLabels(fNodePtr);
}

//________________________________________________________________________
void TStructViewerGUI::ResetButtonSlot()
{
   // Resets camera

   fGLViewer->UpdateScene();
   fGLViewer->ResetCurrentCamera();
}

//________________________________________________________________________
void TStructViewerGUI::Scale(TStructNode* parent)
{
   // Recursive method to scaling all modes on scene. We have to scale nodes to get real ratio between nodes.
   // Uses fMaxRatio.

   // newRatio = sqrt(ratio/maxratio)
   Float_t newRatio = (Float_t)(TMath::Sqrt(parent->GetRelativeVolumeRatio()/fMaxRatio));
   // set left top conner in the center
   parent->SetX(parent->GetX() + parent->GetWidth()/2);
   parent->SetY(parent->GetY() + parent->GetHeight()/2);
   // set new size
   Float_t min = (Float_t)TMath::Min(parent->GetWidth(), parent->GetHeight());
   parent->SetWidth(parent->GetWidth() * newRatio);
   parent->SetHeight(parent->GetHeight() * newRatio);
   // fit the ratio -> height to width
   Float_t sqrt = (Float_t)(TMath::Sqrt(parent->GetWidth() * parent->GetHeight()));
   // it's a square
   if (min > sqrt) {
      parent->SetWidth(sqrt);
      parent->SetHeight(sqrt);
   } else { // it's rectangle
      if (parent->GetHeight() > parent->GetWidth()) {
         parent->SetWidth(min);
         parent->SetHeight(sqrt * sqrt / min);
      } else {
         parent->SetWidth(sqrt * sqrt / min);
         parent->SetHeight(min);
      }
   }
   // move left top corner
   parent->SetX(parent->GetX() - parent->GetWidth()/2);
   parent->SetY(parent->GetY() - parent->GetHeight()/2);

   // scale others nodes
   TStructNode* node;
   TIter it(parent->GetMembers());
   while ((node = (TStructNode*) it() )) {
      Scale(node);
   }
}

//________________________________________________________________________
void TStructViewerGUI::SetNodePtr(TStructNode* val)
{
   // Sets top node pointer and updates view

   fNodePtr = val;
   Update(kTRUE);
}

//________________________________________________________________________
void TStructViewerGUI::SetLinksVisibility(Bool_t visible)
{
   // Sets links visibility to "visible"

   if (visible) {
      fShowLinksCheckButton->SetState(kButtonDown);
   } else {
      fShowLinksCheckButton->SetState(kButtonUp);
   }
}

//________________________________________________________________________
void TStructViewerGUI::SetPointerButtonSlot()
{
   // Sets pointer given in fPointerTestEntry to the main pointer

   void* obj = (void*)gROOT->ProcessLine(fPointerTextEntry->GetText());
   fParent->SetPointer(obj, fPointerTypeTextEntry->GetText());
}

//________________________________________________________________________
void TStructViewerGUI::ShowLinksToggled(Bool_t /*on*/)
{
   // Changes links visibility and refresh view.

   if (fAutoRefesh->IsOn()) {
      Update();
   }
}

//________________________________________________________________________
void TStructViewerGUI::UnCheckMaxObjects()
{
   // Shows hidden nodes

   TStructNode* node;
   TIter it(&fVisibleObjects);

   while ((node = (TStructNode*) it() )) {
      node->SetCollapsed(false);
      node->SetVisible(false);
   }

   fVisibleObjects.Clear();
}

//________________________________________________________________________
void TStructViewerGUI::Update(Bool_t resetCamera)
{
   // Updates view. Clear all the nodes, call draw function and update scene. Doesn't reset camera.

   if (!fNodePtr) {
      return;
   }

   fCanvas->GetListOfPrimitives()->Clear();
   fTopVolume->ClearNodes();
   Draw();
   fCanvas->GetListOfPrimitives()->Add(fTopVolume);
   fGLViewer->UpdateScene();

   if(resetCamera) {
      fGLViewer->ResetCurrentCamera();
   }
}

//________________________________________________________________________
void TStructViewerGUI::UpdateButtonSlot()
{
   // Update button slot. Updates scene

   Update();
}

//________________________________________________________________________
void TStructViewerGUI::UpdateLabels(TStructNode* node)
{
   // Refresh information in labels when user put mouse over object

   fNodeNameLabel->SetText(node->GetName());
   fNodeTypelabel->SetText(node->GetTypeName());

   TString name = "Members: ";
   name += node->GetMembersCount();
   fMembersCountLabel->SetText(name);
   name = "All members: ";
   name += node->GetAllMembersCount();
   fAllMembersCountLabel->SetText(name);
   name = "Level: ";
   name += node->GetLevel();
   fLevelLabel->SetText(name);
   name = "Size: ";
   name += node->GetSize();
   fSizeLabel->SetText(name);
   name = "Total size: ";
   name += node->GetTotalSize();
   fTotalSizeLabel->SetText(name);
}

//________________________________________________________________________
void TStructViewerGUI::UndoButtonSlot()
{
   // UndoButton Slot. Activated when user press Undo button. Restore last top node pointer.

   fRedoList.Add(fNodePtr);
   fRedoButton->SetEnabled(true);
   fNodePtr = (TStructNode*) fUndoList.Last();
   fUndoList.RemoveLast();
   if (!fUndoList.First()) {
      fUndoButton->SetEnabled(false);
   }
   Update(kTRUE);
   UpdateLabels(fNodePtr);
}

//________________________________________________________________________
void TStructViewerGUI::ScaleByChangedSlot()
{
   // Activated when user press radio button

    if (fAutoRefesh->IsOn()) {
       Update();
    }
}
 TStructViewerGUI.cxx:1
 TStructViewerGUI.cxx:2
 TStructViewerGUI.cxx:3
 TStructViewerGUI.cxx:4
 TStructViewerGUI.cxx:5
 TStructViewerGUI.cxx:6
 TStructViewerGUI.cxx:7
 TStructViewerGUI.cxx:8
 TStructViewerGUI.cxx:9
 TStructViewerGUI.cxx:10
 TStructViewerGUI.cxx:11
 TStructViewerGUI.cxx:12
 TStructViewerGUI.cxx:13
 TStructViewerGUI.cxx:14
 TStructViewerGUI.cxx:15
 TStructViewerGUI.cxx:16
 TStructViewerGUI.cxx:17
 TStructViewerGUI.cxx:18
 TStructViewerGUI.cxx:19
 TStructViewerGUI.cxx:20
 TStructViewerGUI.cxx:21
 TStructViewerGUI.cxx:22
 TStructViewerGUI.cxx:23
 TStructViewerGUI.cxx:24
 TStructViewerGUI.cxx:25
 TStructViewerGUI.cxx:26
 TStructViewerGUI.cxx:27
 TStructViewerGUI.cxx:28
 TStructViewerGUI.cxx:29
 TStructViewerGUI.cxx:30
 TStructViewerGUI.cxx:31
 TStructViewerGUI.cxx:32
 TStructViewerGUI.cxx:33
 TStructViewerGUI.cxx:34
 TStructViewerGUI.cxx:35
 TStructViewerGUI.cxx:36
 TStructViewerGUI.cxx:37
 TStructViewerGUI.cxx:38
 TStructViewerGUI.cxx:39
 TStructViewerGUI.cxx:40
 TStructViewerGUI.cxx:41
 TStructViewerGUI.cxx:42
 TStructViewerGUI.cxx:43
 TStructViewerGUI.cxx:44
 TStructViewerGUI.cxx:45
 TStructViewerGUI.cxx:46
 TStructViewerGUI.cxx:47
 TStructViewerGUI.cxx:48
 TStructViewerGUI.cxx:49
 TStructViewerGUI.cxx:50
 TStructViewerGUI.cxx:51
 TStructViewerGUI.cxx:52
 TStructViewerGUI.cxx:53
 TStructViewerGUI.cxx:54
 TStructViewerGUI.cxx:55
 TStructViewerGUI.cxx:56
 TStructViewerGUI.cxx:57
 TStructViewerGUI.cxx:58
 TStructViewerGUI.cxx:59
 TStructViewerGUI.cxx:60
 TStructViewerGUI.cxx:61
 TStructViewerGUI.cxx:62
 TStructViewerGUI.cxx:63
 TStructViewerGUI.cxx:64
 TStructViewerGUI.cxx:65
 TStructViewerGUI.cxx:66
 TStructViewerGUI.cxx:67
 TStructViewerGUI.cxx:68
 TStructViewerGUI.cxx:69
 TStructViewerGUI.cxx:70
 TStructViewerGUI.cxx:71
 TStructViewerGUI.cxx:72
 TStructViewerGUI.cxx:73
 TStructViewerGUI.cxx:74
 TStructViewerGUI.cxx:75
 TStructViewerGUI.cxx:76
 TStructViewerGUI.cxx:77
 TStructViewerGUI.cxx:78
 TStructViewerGUI.cxx:79
 TStructViewerGUI.cxx:80
 TStructViewerGUI.cxx:81
 TStructViewerGUI.cxx:82
 TStructViewerGUI.cxx:83
 TStructViewerGUI.cxx:84
 TStructViewerGUI.cxx:85
 TStructViewerGUI.cxx:86
 TStructViewerGUI.cxx:87
 TStructViewerGUI.cxx:88
 TStructViewerGUI.cxx:89
 TStructViewerGUI.cxx:90
 TStructViewerGUI.cxx:91
 TStructViewerGUI.cxx:92
 TStructViewerGUI.cxx:93
 TStructViewerGUI.cxx:94
 TStructViewerGUI.cxx:95
 TStructViewerGUI.cxx:96
 TStructViewerGUI.cxx:97
 TStructViewerGUI.cxx:98
 TStructViewerGUI.cxx:99
 TStructViewerGUI.cxx:100
 TStructViewerGUI.cxx:101
 TStructViewerGUI.cxx:102
 TStructViewerGUI.cxx:103
 TStructViewerGUI.cxx:104
 TStructViewerGUI.cxx:105
 TStructViewerGUI.cxx:106
 TStructViewerGUI.cxx:107
 TStructViewerGUI.cxx:108
 TStructViewerGUI.cxx:109
 TStructViewerGUI.cxx:110
 TStructViewerGUI.cxx:111
 TStructViewerGUI.cxx:112
 TStructViewerGUI.cxx:113
 TStructViewerGUI.cxx:114
 TStructViewerGUI.cxx:115
 TStructViewerGUI.cxx:116
 TStructViewerGUI.cxx:117
 TStructViewerGUI.cxx:118
 TStructViewerGUI.cxx:119
 TStructViewerGUI.cxx:120
 TStructViewerGUI.cxx:121
 TStructViewerGUI.cxx:122
 TStructViewerGUI.cxx:123
 TStructViewerGUI.cxx:124
 TStructViewerGUI.cxx:125
 TStructViewerGUI.cxx:126
 TStructViewerGUI.cxx:127
 TStructViewerGUI.cxx:128
 TStructViewerGUI.cxx:129
 TStructViewerGUI.cxx:130
 TStructViewerGUI.cxx:131
 TStructViewerGUI.cxx:132
 TStructViewerGUI.cxx:133
 TStructViewerGUI.cxx:134
 TStructViewerGUI.cxx:135
 TStructViewerGUI.cxx:136
 TStructViewerGUI.cxx:137
 TStructViewerGUI.cxx:138
 TStructViewerGUI.cxx:139
 TStructViewerGUI.cxx:140
 TStructViewerGUI.cxx:141
 TStructViewerGUI.cxx:142
 TStructViewerGUI.cxx:143
 TStructViewerGUI.cxx:144
 TStructViewerGUI.cxx:145
 TStructViewerGUI.cxx:146
 TStructViewerGUI.cxx:147
 TStructViewerGUI.cxx:148
 TStructViewerGUI.cxx:149
 TStructViewerGUI.cxx:150
 TStructViewerGUI.cxx:151
 TStructViewerGUI.cxx:152
 TStructViewerGUI.cxx:153
 TStructViewerGUI.cxx:154
 TStructViewerGUI.cxx:155
 TStructViewerGUI.cxx:156
 TStructViewerGUI.cxx:157
 TStructViewerGUI.cxx:158
 TStructViewerGUI.cxx:159
 TStructViewerGUI.cxx:160
 TStructViewerGUI.cxx:161
 TStructViewerGUI.cxx:162
 TStructViewerGUI.cxx:163
 TStructViewerGUI.cxx:164
 TStructViewerGUI.cxx:165
 TStructViewerGUI.cxx:166
 TStructViewerGUI.cxx:167
 TStructViewerGUI.cxx:168
 TStructViewerGUI.cxx:169
 TStructViewerGUI.cxx:170
 TStructViewerGUI.cxx:171
 TStructViewerGUI.cxx:172
 TStructViewerGUI.cxx:173
 TStructViewerGUI.cxx:174
 TStructViewerGUI.cxx:175
 TStructViewerGUI.cxx:176
 TStructViewerGUI.cxx:177
 TStructViewerGUI.cxx:178
 TStructViewerGUI.cxx:179
 TStructViewerGUI.cxx:180
 TStructViewerGUI.cxx:181
 TStructViewerGUI.cxx:182
 TStructViewerGUI.cxx:183
 TStructViewerGUI.cxx:184
 TStructViewerGUI.cxx:185
 TStructViewerGUI.cxx:186
 TStructViewerGUI.cxx:187
 TStructViewerGUI.cxx:188
 TStructViewerGUI.cxx:189
 TStructViewerGUI.cxx:190
 TStructViewerGUI.cxx:191
 TStructViewerGUI.cxx:192
 TStructViewerGUI.cxx:193
 TStructViewerGUI.cxx:194
 TStructViewerGUI.cxx:195
 TStructViewerGUI.cxx:196
 TStructViewerGUI.cxx:197
 TStructViewerGUI.cxx:198
 TStructViewerGUI.cxx:199
 TStructViewerGUI.cxx:200
 TStructViewerGUI.cxx:201
 TStructViewerGUI.cxx:202
 TStructViewerGUI.cxx:203
 TStructViewerGUI.cxx:204
 TStructViewerGUI.cxx:205
 TStructViewerGUI.cxx:206
 TStructViewerGUI.cxx:207
 TStructViewerGUI.cxx:208
 TStructViewerGUI.cxx:209
 TStructViewerGUI.cxx:210
 TStructViewerGUI.cxx:211
 TStructViewerGUI.cxx:212
 TStructViewerGUI.cxx:213
 TStructViewerGUI.cxx:214
 TStructViewerGUI.cxx:215
 TStructViewerGUI.cxx:216
 TStructViewerGUI.cxx:217
 TStructViewerGUI.cxx:218
 TStructViewerGUI.cxx:219
 TStructViewerGUI.cxx:220
 TStructViewerGUI.cxx:221
 TStructViewerGUI.cxx:222
 TStructViewerGUI.cxx:223
 TStructViewerGUI.cxx:224
 TStructViewerGUI.cxx:225
 TStructViewerGUI.cxx:226
 TStructViewerGUI.cxx:227
 TStructViewerGUI.cxx:228
 TStructViewerGUI.cxx:229
 TStructViewerGUI.cxx:230
 TStructViewerGUI.cxx:231
 TStructViewerGUI.cxx:232
 TStructViewerGUI.cxx:233
 TStructViewerGUI.cxx:234
 TStructViewerGUI.cxx:235
 TStructViewerGUI.cxx:236
 TStructViewerGUI.cxx:237
 TStructViewerGUI.cxx:238
 TStructViewerGUI.cxx:239
 TStructViewerGUI.cxx:240
 TStructViewerGUI.cxx:241
 TStructViewerGUI.cxx:242
 TStructViewerGUI.cxx:243
 TStructViewerGUI.cxx:244
 TStructViewerGUI.cxx:245
 TStructViewerGUI.cxx:246
 TStructViewerGUI.cxx:247
 TStructViewerGUI.cxx:248
 TStructViewerGUI.cxx:249
 TStructViewerGUI.cxx:250
 TStructViewerGUI.cxx:251
 TStructViewerGUI.cxx:252
 TStructViewerGUI.cxx:253
 TStructViewerGUI.cxx:254
 TStructViewerGUI.cxx:255
 TStructViewerGUI.cxx:256
 TStructViewerGUI.cxx:257
 TStructViewerGUI.cxx:258
 TStructViewerGUI.cxx:259
 TStructViewerGUI.cxx:260
 TStructViewerGUI.cxx:261
 TStructViewerGUI.cxx:262
 TStructViewerGUI.cxx:263
 TStructViewerGUI.cxx:264
 TStructViewerGUI.cxx:265
 TStructViewerGUI.cxx:266
 TStructViewerGUI.cxx:267
 TStructViewerGUI.cxx:268
 TStructViewerGUI.cxx:269
 TStructViewerGUI.cxx:270
 TStructViewerGUI.cxx:271
 TStructViewerGUI.cxx:272
 TStructViewerGUI.cxx:273
 TStructViewerGUI.cxx:274
 TStructViewerGUI.cxx:275
 TStructViewerGUI.cxx:276
 TStructViewerGUI.cxx:277
 TStructViewerGUI.cxx:278
 TStructViewerGUI.cxx:279
 TStructViewerGUI.cxx:280
 TStructViewerGUI.cxx:281
 TStructViewerGUI.cxx:282
 TStructViewerGUI.cxx:283
 TStructViewerGUI.cxx:284
 TStructViewerGUI.cxx:285
 TStructViewerGUI.cxx:286
 TStructViewerGUI.cxx:287
 TStructViewerGUI.cxx:288
 TStructViewerGUI.cxx:289
 TStructViewerGUI.cxx:290
 TStructViewerGUI.cxx:291
 TStructViewerGUI.cxx:292
 TStructViewerGUI.cxx:293
 TStructViewerGUI.cxx:294
 TStructViewerGUI.cxx:295
 TStructViewerGUI.cxx:296
 TStructViewerGUI.cxx:297
 TStructViewerGUI.cxx:298
 TStructViewerGUI.cxx:299
 TStructViewerGUI.cxx:300
 TStructViewerGUI.cxx:301
 TStructViewerGUI.cxx:302
 TStructViewerGUI.cxx:303
 TStructViewerGUI.cxx:304
 TStructViewerGUI.cxx:305
 TStructViewerGUI.cxx:306
 TStructViewerGUI.cxx:307
 TStructViewerGUI.cxx:308
 TStructViewerGUI.cxx:309
 TStructViewerGUI.cxx:310
 TStructViewerGUI.cxx:311
 TStructViewerGUI.cxx:312
 TStructViewerGUI.cxx:313
 TStructViewerGUI.cxx:314
 TStructViewerGUI.cxx:315
 TStructViewerGUI.cxx:316
 TStructViewerGUI.cxx:317
 TStructViewerGUI.cxx:318
 TStructViewerGUI.cxx:319
 TStructViewerGUI.cxx:320
 TStructViewerGUI.cxx:321
 TStructViewerGUI.cxx:322
 TStructViewerGUI.cxx:323
 TStructViewerGUI.cxx:324
 TStructViewerGUI.cxx:325
 TStructViewerGUI.cxx:326
 TStructViewerGUI.cxx:327
 TStructViewerGUI.cxx:328
 TStructViewerGUI.cxx:329
 TStructViewerGUI.cxx:330
 TStructViewerGUI.cxx:331
 TStructViewerGUI.cxx:332
 TStructViewerGUI.cxx:333
 TStructViewerGUI.cxx:334
 TStructViewerGUI.cxx:335
 TStructViewerGUI.cxx:336
 TStructViewerGUI.cxx:337
 TStructViewerGUI.cxx:338
 TStructViewerGUI.cxx:339
 TStructViewerGUI.cxx:340
 TStructViewerGUI.cxx:341
 TStructViewerGUI.cxx:342
 TStructViewerGUI.cxx:343
 TStructViewerGUI.cxx:344
 TStructViewerGUI.cxx:345
 TStructViewerGUI.cxx:346
 TStructViewerGUI.cxx:347
 TStructViewerGUI.cxx:348
 TStructViewerGUI.cxx:349
 TStructViewerGUI.cxx:350
 TStructViewerGUI.cxx:351
 TStructViewerGUI.cxx:352
 TStructViewerGUI.cxx:353
 TStructViewerGUI.cxx:354
 TStructViewerGUI.cxx:355
 TStructViewerGUI.cxx:356
 TStructViewerGUI.cxx:357
 TStructViewerGUI.cxx:358
 TStructViewerGUI.cxx:359
 TStructViewerGUI.cxx:360
 TStructViewerGUI.cxx:361
 TStructViewerGUI.cxx:362
 TStructViewerGUI.cxx:363
 TStructViewerGUI.cxx:364
 TStructViewerGUI.cxx:365
 TStructViewerGUI.cxx:366
 TStructViewerGUI.cxx:367
 TStructViewerGUI.cxx:368
 TStructViewerGUI.cxx:369
 TStructViewerGUI.cxx:370
 TStructViewerGUI.cxx:371
 TStructViewerGUI.cxx:372
 TStructViewerGUI.cxx:373
 TStructViewerGUI.cxx:374
 TStructViewerGUI.cxx:375
 TStructViewerGUI.cxx:376
 TStructViewerGUI.cxx:377
 TStructViewerGUI.cxx:378
 TStructViewerGUI.cxx:379
 TStructViewerGUI.cxx:380
 TStructViewerGUI.cxx:381
 TStructViewerGUI.cxx:382
 TStructViewerGUI.cxx:383
 TStructViewerGUI.cxx:384
 TStructViewerGUI.cxx:385
 TStructViewerGUI.cxx:386
 TStructViewerGUI.cxx:387
 TStructViewerGUI.cxx:388
 TStructViewerGUI.cxx:389
 TStructViewerGUI.cxx:390
 TStructViewerGUI.cxx:391
 TStructViewerGUI.cxx:392
 TStructViewerGUI.cxx:393
 TStructViewerGUI.cxx:394
 TStructViewerGUI.cxx:395
 TStructViewerGUI.cxx:396
 TStructViewerGUI.cxx:397
 TStructViewerGUI.cxx:398
 TStructViewerGUI.cxx:399
 TStructViewerGUI.cxx:400
 TStructViewerGUI.cxx:401
 TStructViewerGUI.cxx:402
 TStructViewerGUI.cxx:403
 TStructViewerGUI.cxx:404
 TStructViewerGUI.cxx:405
 TStructViewerGUI.cxx:406
 TStructViewerGUI.cxx:407
 TStructViewerGUI.cxx:408
 TStructViewerGUI.cxx:409
 TStructViewerGUI.cxx:410
 TStructViewerGUI.cxx:411
 TStructViewerGUI.cxx:412
 TStructViewerGUI.cxx:413
 TStructViewerGUI.cxx:414
 TStructViewerGUI.cxx:415
 TStructViewerGUI.cxx:416
 TStructViewerGUI.cxx:417
 TStructViewerGUI.cxx:418
 TStructViewerGUI.cxx:419
 TStructViewerGUI.cxx:420
 TStructViewerGUI.cxx:421
 TStructViewerGUI.cxx:422
 TStructViewerGUI.cxx:423
 TStructViewerGUI.cxx:424
 TStructViewerGUI.cxx:425
 TStructViewerGUI.cxx:426
 TStructViewerGUI.cxx:427
 TStructViewerGUI.cxx:428
 TStructViewerGUI.cxx:429
 TStructViewerGUI.cxx:430
 TStructViewerGUI.cxx:431
 TStructViewerGUI.cxx:432
 TStructViewerGUI.cxx:433
 TStructViewerGUI.cxx:434
 TStructViewerGUI.cxx:435
 TStructViewerGUI.cxx:436
 TStructViewerGUI.cxx:437
 TStructViewerGUI.cxx:438
 TStructViewerGUI.cxx:439
 TStructViewerGUI.cxx:440
 TStructViewerGUI.cxx:441
 TStructViewerGUI.cxx:442
 TStructViewerGUI.cxx:443
 TStructViewerGUI.cxx:444
 TStructViewerGUI.cxx:445
 TStructViewerGUI.cxx:446
 TStructViewerGUI.cxx:447
 TStructViewerGUI.cxx:448
 TStructViewerGUI.cxx:449
 TStructViewerGUI.cxx:450
 TStructViewerGUI.cxx:451
 TStructViewerGUI.cxx:452
 TStructViewerGUI.cxx:453
 TStructViewerGUI.cxx:454
 TStructViewerGUI.cxx:455
 TStructViewerGUI.cxx:456
 TStructViewerGUI.cxx:457
 TStructViewerGUI.cxx:458
 TStructViewerGUI.cxx:459
 TStructViewerGUI.cxx:460
 TStructViewerGUI.cxx:461
 TStructViewerGUI.cxx:462
 TStructViewerGUI.cxx:463
 TStructViewerGUI.cxx:464
 TStructViewerGUI.cxx:465
 TStructViewerGUI.cxx:466
 TStructViewerGUI.cxx:467
 TStructViewerGUI.cxx:468
 TStructViewerGUI.cxx:469
 TStructViewerGUI.cxx:470
 TStructViewerGUI.cxx:471
 TStructViewerGUI.cxx:472
 TStructViewerGUI.cxx:473
 TStructViewerGUI.cxx:474
 TStructViewerGUI.cxx:475
 TStructViewerGUI.cxx:476
 TStructViewerGUI.cxx:477
 TStructViewerGUI.cxx:478
 TStructViewerGUI.cxx:479
 TStructViewerGUI.cxx:480
 TStructViewerGUI.cxx:481
 TStructViewerGUI.cxx:482
 TStructViewerGUI.cxx:483
 TStructViewerGUI.cxx:484
 TStructViewerGUI.cxx:485
 TStructViewerGUI.cxx:486
 TStructViewerGUI.cxx:487
 TStructViewerGUI.cxx:488
 TStructViewerGUI.cxx:489
 TStructViewerGUI.cxx:490
 TStructViewerGUI.cxx:491
 TStructViewerGUI.cxx:492
 TStructViewerGUI.cxx:493
 TStructViewerGUI.cxx:494
 TStructViewerGUI.cxx:495
 TStructViewerGUI.cxx:496
 TStructViewerGUI.cxx:497
 TStructViewerGUI.cxx:498
 TStructViewerGUI.cxx:499
 TStructViewerGUI.cxx:500
 TStructViewerGUI.cxx:501
 TStructViewerGUI.cxx:502
 TStructViewerGUI.cxx:503
 TStructViewerGUI.cxx:504
 TStructViewerGUI.cxx:505
 TStructViewerGUI.cxx:506
 TStructViewerGUI.cxx:507
 TStructViewerGUI.cxx:508
 TStructViewerGUI.cxx:509
 TStructViewerGUI.cxx:510
 TStructViewerGUI.cxx:511
 TStructViewerGUI.cxx:512
 TStructViewerGUI.cxx:513
 TStructViewerGUI.cxx:514
 TStructViewerGUI.cxx:515
 TStructViewerGUI.cxx:516
 TStructViewerGUI.cxx:517
 TStructViewerGUI.cxx:518
 TStructViewerGUI.cxx:519
 TStructViewerGUI.cxx:520
 TStructViewerGUI.cxx:521
 TStructViewerGUI.cxx:522
 TStructViewerGUI.cxx:523
 TStructViewerGUI.cxx:524
 TStructViewerGUI.cxx:525
 TStructViewerGUI.cxx:526
 TStructViewerGUI.cxx:527
 TStructViewerGUI.cxx:528
 TStructViewerGUI.cxx:529
 TStructViewerGUI.cxx:530
 TStructViewerGUI.cxx:531
 TStructViewerGUI.cxx:532
 TStructViewerGUI.cxx:533
 TStructViewerGUI.cxx:534
 TStructViewerGUI.cxx:535
 TStructViewerGUI.cxx:536
 TStructViewerGUI.cxx:537
 TStructViewerGUI.cxx:538
 TStructViewerGUI.cxx:539
 TStructViewerGUI.cxx:540
 TStructViewerGUI.cxx:541
 TStructViewerGUI.cxx:542
 TStructViewerGUI.cxx:543
 TStructViewerGUI.cxx:544
 TStructViewerGUI.cxx:545
 TStructViewerGUI.cxx:546
 TStructViewerGUI.cxx:547
 TStructViewerGUI.cxx:548
 TStructViewerGUI.cxx:549
 TStructViewerGUI.cxx:550
 TStructViewerGUI.cxx:551
 TStructViewerGUI.cxx:552
 TStructViewerGUI.cxx:553
 TStructViewerGUI.cxx:554
 TStructViewerGUI.cxx:555
 TStructViewerGUI.cxx:556
 TStructViewerGUI.cxx:557
 TStructViewerGUI.cxx:558
 TStructViewerGUI.cxx:559
 TStructViewerGUI.cxx:560
 TStructViewerGUI.cxx:561
 TStructViewerGUI.cxx:562
 TStructViewerGUI.cxx:563
 TStructViewerGUI.cxx:564
 TStructViewerGUI.cxx:565
 TStructViewerGUI.cxx:566
 TStructViewerGUI.cxx:567
 TStructViewerGUI.cxx:568
 TStructViewerGUI.cxx:569
 TStructViewerGUI.cxx:570
 TStructViewerGUI.cxx:571
 TStructViewerGUI.cxx:572
 TStructViewerGUI.cxx:573
 TStructViewerGUI.cxx:574
 TStructViewerGUI.cxx:575
 TStructViewerGUI.cxx:576
 TStructViewerGUI.cxx:577
 TStructViewerGUI.cxx:578
 TStructViewerGUI.cxx:579
 TStructViewerGUI.cxx:580
 TStructViewerGUI.cxx:581
 TStructViewerGUI.cxx:582
 TStructViewerGUI.cxx:583
 TStructViewerGUI.cxx:584
 TStructViewerGUI.cxx:585
 TStructViewerGUI.cxx:586
 TStructViewerGUI.cxx:587
 TStructViewerGUI.cxx:588
 TStructViewerGUI.cxx:589
 TStructViewerGUI.cxx:590
 TStructViewerGUI.cxx:591
 TStructViewerGUI.cxx:592
 TStructViewerGUI.cxx:593
 TStructViewerGUI.cxx:594
 TStructViewerGUI.cxx:595
 TStructViewerGUI.cxx:596
 TStructViewerGUI.cxx:597
 TStructViewerGUI.cxx:598
 TStructViewerGUI.cxx:599
 TStructViewerGUI.cxx:600
 TStructViewerGUI.cxx:601
 TStructViewerGUI.cxx:602
 TStructViewerGUI.cxx:603
 TStructViewerGUI.cxx:604
 TStructViewerGUI.cxx:605
 TStructViewerGUI.cxx:606
 TStructViewerGUI.cxx:607
 TStructViewerGUI.cxx:608
 TStructViewerGUI.cxx:609
 TStructViewerGUI.cxx:610
 TStructViewerGUI.cxx:611
 TStructViewerGUI.cxx:612
 TStructViewerGUI.cxx:613
 TStructViewerGUI.cxx:614
 TStructViewerGUI.cxx:615
 TStructViewerGUI.cxx:616
 TStructViewerGUI.cxx:617
 TStructViewerGUI.cxx:618
 TStructViewerGUI.cxx:619
 TStructViewerGUI.cxx:620
 TStructViewerGUI.cxx:621
 TStructViewerGUI.cxx:622
 TStructViewerGUI.cxx:623
 TStructViewerGUI.cxx:624
 TStructViewerGUI.cxx:625
 TStructViewerGUI.cxx:626
 TStructViewerGUI.cxx:627
 TStructViewerGUI.cxx:628
 TStructViewerGUI.cxx:629
 TStructViewerGUI.cxx:630
 TStructViewerGUI.cxx:631
 TStructViewerGUI.cxx:632
 TStructViewerGUI.cxx:633
 TStructViewerGUI.cxx:634
 TStructViewerGUI.cxx:635
 TStructViewerGUI.cxx:636
 TStructViewerGUI.cxx:637
 TStructViewerGUI.cxx:638
 TStructViewerGUI.cxx:639
 TStructViewerGUI.cxx:640
 TStructViewerGUI.cxx:641
 TStructViewerGUI.cxx:642
 TStructViewerGUI.cxx:643
 TStructViewerGUI.cxx:644
 TStructViewerGUI.cxx:645
 TStructViewerGUI.cxx:646
 TStructViewerGUI.cxx:647
 TStructViewerGUI.cxx:648
 TStructViewerGUI.cxx:649
 TStructViewerGUI.cxx:650
 TStructViewerGUI.cxx:651
 TStructViewerGUI.cxx:652
 TStructViewerGUI.cxx:653
 TStructViewerGUI.cxx:654
 TStructViewerGUI.cxx:655
 TStructViewerGUI.cxx:656
 TStructViewerGUI.cxx:657
 TStructViewerGUI.cxx:658
 TStructViewerGUI.cxx:659
 TStructViewerGUI.cxx:660
 TStructViewerGUI.cxx:661
 TStructViewerGUI.cxx:662
 TStructViewerGUI.cxx:663
 TStructViewerGUI.cxx:664
 TStructViewerGUI.cxx:665
 TStructViewerGUI.cxx:666
 TStructViewerGUI.cxx:667
 TStructViewerGUI.cxx:668
 TStructViewerGUI.cxx:669
 TStructViewerGUI.cxx:670
 TStructViewerGUI.cxx:671
 TStructViewerGUI.cxx:672
 TStructViewerGUI.cxx:673
 TStructViewerGUI.cxx:674
 TStructViewerGUI.cxx:675
 TStructViewerGUI.cxx:676
 TStructViewerGUI.cxx:677
 TStructViewerGUI.cxx:678
 TStructViewerGUI.cxx:679
 TStructViewerGUI.cxx:680
 TStructViewerGUI.cxx:681
 TStructViewerGUI.cxx:682
 TStructViewerGUI.cxx:683
 TStructViewerGUI.cxx:684
 TStructViewerGUI.cxx:685
 TStructViewerGUI.cxx:686
 TStructViewerGUI.cxx:687
 TStructViewerGUI.cxx:688
 TStructViewerGUI.cxx:689
 TStructViewerGUI.cxx:690
 TStructViewerGUI.cxx:691
 TStructViewerGUI.cxx:692
 TStructViewerGUI.cxx:693
 TStructViewerGUI.cxx:694
 TStructViewerGUI.cxx:695
 TStructViewerGUI.cxx:696
 TStructViewerGUI.cxx:697
 TStructViewerGUI.cxx:698
 TStructViewerGUI.cxx:699
 TStructViewerGUI.cxx:700
 TStructViewerGUI.cxx:701
 TStructViewerGUI.cxx:702
 TStructViewerGUI.cxx:703
 TStructViewerGUI.cxx:704
 TStructViewerGUI.cxx:705
 TStructViewerGUI.cxx:706
 TStructViewerGUI.cxx:707
 TStructViewerGUI.cxx:708
 TStructViewerGUI.cxx:709
 TStructViewerGUI.cxx:710
 TStructViewerGUI.cxx:711
 TStructViewerGUI.cxx:712
 TStructViewerGUI.cxx:713
 TStructViewerGUI.cxx:714
 TStructViewerGUI.cxx:715
 TStructViewerGUI.cxx:716
 TStructViewerGUI.cxx:717
 TStructViewerGUI.cxx:718
 TStructViewerGUI.cxx:719
 TStructViewerGUI.cxx:720
 TStructViewerGUI.cxx:721
 TStructViewerGUI.cxx:722
 TStructViewerGUI.cxx:723
 TStructViewerGUI.cxx:724
 TStructViewerGUI.cxx:725
 TStructViewerGUI.cxx:726
 TStructViewerGUI.cxx:727
 TStructViewerGUI.cxx:728
 TStructViewerGUI.cxx:729
 TStructViewerGUI.cxx:730
 TStructViewerGUI.cxx:731
 TStructViewerGUI.cxx:732
 TStructViewerGUI.cxx:733
 TStructViewerGUI.cxx:734
 TStructViewerGUI.cxx:735
 TStructViewerGUI.cxx:736
 TStructViewerGUI.cxx:737
 TStructViewerGUI.cxx:738
 TStructViewerGUI.cxx:739
 TStructViewerGUI.cxx:740
 TStructViewerGUI.cxx:741
 TStructViewerGUI.cxx:742
 TStructViewerGUI.cxx:743
 TStructViewerGUI.cxx:744
 TStructViewerGUI.cxx:745
 TStructViewerGUI.cxx:746
 TStructViewerGUI.cxx:747
 TStructViewerGUI.cxx:748
 TStructViewerGUI.cxx:749
 TStructViewerGUI.cxx:750
 TStructViewerGUI.cxx:751
 TStructViewerGUI.cxx:752
 TStructViewerGUI.cxx:753
 TStructViewerGUI.cxx:754
 TStructViewerGUI.cxx:755
 TStructViewerGUI.cxx:756
 TStructViewerGUI.cxx:757
 TStructViewerGUI.cxx:758
 TStructViewerGUI.cxx:759
 TStructViewerGUI.cxx:760
 TStructViewerGUI.cxx:761
 TStructViewerGUI.cxx:762
 TStructViewerGUI.cxx:763
 TStructViewerGUI.cxx:764
 TStructViewerGUI.cxx:765
 TStructViewerGUI.cxx:766
 TStructViewerGUI.cxx:767
 TStructViewerGUI.cxx:768
 TStructViewerGUI.cxx:769
 TStructViewerGUI.cxx:770
 TStructViewerGUI.cxx:771
 TStructViewerGUI.cxx:772
 TStructViewerGUI.cxx:773
 TStructViewerGUI.cxx:774
 TStructViewerGUI.cxx:775
 TStructViewerGUI.cxx:776
 TStructViewerGUI.cxx:777
 TStructViewerGUI.cxx:778
 TStructViewerGUI.cxx:779
 TStructViewerGUI.cxx:780
 TStructViewerGUI.cxx:781
 TStructViewerGUI.cxx:782
 TStructViewerGUI.cxx:783
 TStructViewerGUI.cxx:784
 TStructViewerGUI.cxx:785
 TStructViewerGUI.cxx:786
 TStructViewerGUI.cxx:787
 TStructViewerGUI.cxx:788
 TStructViewerGUI.cxx:789
 TStructViewerGUI.cxx:790
 TStructViewerGUI.cxx:791
 TStructViewerGUI.cxx:792
 TStructViewerGUI.cxx:793
 TStructViewerGUI.cxx:794
 TStructViewerGUI.cxx:795
 TStructViewerGUI.cxx:796
 TStructViewerGUI.cxx:797
 TStructViewerGUI.cxx:798
 TStructViewerGUI.cxx:799
 TStructViewerGUI.cxx:800
 TStructViewerGUI.cxx:801
 TStructViewerGUI.cxx:802
 TStructViewerGUI.cxx:803
 TStructViewerGUI.cxx:804
 TStructViewerGUI.cxx:805
 TStructViewerGUI.cxx:806
 TStructViewerGUI.cxx:807
 TStructViewerGUI.cxx:808
 TStructViewerGUI.cxx:809
 TStructViewerGUI.cxx:810
 TStructViewerGUI.cxx:811
 TStructViewerGUI.cxx:812
 TStructViewerGUI.cxx:813
 TStructViewerGUI.cxx:814
 TStructViewerGUI.cxx:815
 TStructViewerGUI.cxx:816
 TStructViewerGUI.cxx:817
 TStructViewerGUI.cxx:818
 TStructViewerGUI.cxx:819
 TStructViewerGUI.cxx:820
 TStructViewerGUI.cxx:821
 TStructViewerGUI.cxx:822
 TStructViewerGUI.cxx:823
 TStructViewerGUI.cxx:824
 TStructViewerGUI.cxx:825
 TStructViewerGUI.cxx:826
 TStructViewerGUI.cxx:827
 TStructViewerGUI.cxx:828
 TStructViewerGUI.cxx:829
 TStructViewerGUI.cxx:830
 TStructViewerGUI.cxx:831
 TStructViewerGUI.cxx:832
 TStructViewerGUI.cxx:833
 TStructViewerGUI.cxx:834
 TStructViewerGUI.cxx:835
 TStructViewerGUI.cxx:836
 TStructViewerGUI.cxx:837
 TStructViewerGUI.cxx:838
 TStructViewerGUI.cxx:839
 TStructViewerGUI.cxx:840
 TStructViewerGUI.cxx:841
 TStructViewerGUI.cxx:842
 TStructViewerGUI.cxx:843
 TStructViewerGUI.cxx:844
 TStructViewerGUI.cxx:845
 TStructViewerGUI.cxx:846
 TStructViewerGUI.cxx:847
 TStructViewerGUI.cxx:848
 TStructViewerGUI.cxx:849
 TStructViewerGUI.cxx:850
 TStructViewerGUI.cxx:851
 TStructViewerGUI.cxx:852
 TStructViewerGUI.cxx:853
 TStructViewerGUI.cxx:854
 TStructViewerGUI.cxx:855
 TStructViewerGUI.cxx:856
 TStructViewerGUI.cxx:857
 TStructViewerGUI.cxx:858
 TStructViewerGUI.cxx:859
 TStructViewerGUI.cxx:860
 TStructViewerGUI.cxx:861
 TStructViewerGUI.cxx:862
 TStructViewerGUI.cxx:863
 TStructViewerGUI.cxx:864
 TStructViewerGUI.cxx:865
 TStructViewerGUI.cxx:866
 TStructViewerGUI.cxx:867
 TStructViewerGUI.cxx:868
 TStructViewerGUI.cxx:869
 TStructViewerGUI.cxx:870
 TStructViewerGUI.cxx:871
 TStructViewerGUI.cxx:872
 TStructViewerGUI.cxx:873
 TStructViewerGUI.cxx:874
 TStructViewerGUI.cxx:875
 TStructViewerGUI.cxx:876
 TStructViewerGUI.cxx:877
 TStructViewerGUI.cxx:878
 TStructViewerGUI.cxx:879
 TStructViewerGUI.cxx:880
 TStructViewerGUI.cxx:881
 TStructViewerGUI.cxx:882
 TStructViewerGUI.cxx:883
 TStructViewerGUI.cxx:884
 TStructViewerGUI.cxx:885
 TStructViewerGUI.cxx:886
 TStructViewerGUI.cxx:887
 TStructViewerGUI.cxx:888
 TStructViewerGUI.cxx:889
 TStructViewerGUI.cxx:890