ROOT logo
// @(#)root/eve:$Id$
// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007

/*************************************************************************
 * Copyright (C) 1995-2007, 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_TEveManager
#define ROOT_TEveManager

#include "TEveElement.h"

#include "TSysEvtHandler.h"
#include "TTimer.h"
#include "TVirtualPad.h"

class TMap;
class TExMap;
class TMacro;
class TFolder;
class TCanvas;
class TGeoManager;

class TGTab;
class TGStatusBar;
class TGListTree;
class TGListTreeItem;
class TGStatusBar;
class TGWindow;

class TGLViewer;

class TEveSelection;
class TEveGListTreeEditorFrame;
class TEveBrowser;
class TEveGedEditor;

class TEveViewer; class TEveViewerList;
class TEveScene;  class TEveSceneList;

class TEveEventManager;
class TEveWindowManager;


class TEveManager
{
   TEveManager(const TEveManager&);            // Not implemented
   TEveManager& operator=(const TEveManager&); // Not implemented

public:
   class TRedrawDisabler
   {
   private:
      TRedrawDisabler(const TRedrawDisabler&);            // Not implemented
      TRedrawDisabler& operator=(const TRedrawDisabler&); // Not implemented

      TEveManager* fMgr;
   public:
      TRedrawDisabler(TEveManager* m) : fMgr(m)
      { if (fMgr) fMgr->DisableRedraw(); }
      virtual ~TRedrawDisabler()
      { if (fMgr) fMgr->EnableRedraw(); }

      ClassDef(TRedrawDisabler, 0); // Exception-safe EVE redraw-disabler.
   };

   class TExceptionHandler : public TStdExceptionHandler
   {
   public:
      TExceptionHandler() : TStdExceptionHandler() { Add(); }
      virtual ~TExceptionHandler()                 { Remove(); }

      virtual EStatus  Handle(std::exception& exc);

      ClassDef(TExceptionHandler, 0); // Exception handler for Eve exceptions.
   };

protected:
   TExceptionHandler        *fExcHandler;

   TMap                     *fVizDB;
   Bool_t                    fVizDBReplace;
   Bool_t                    fVizDBUpdate;

   TMap                     *fGeometries;
   TMap                     *fGeometryAliases;

   TEveBrowser              *fBrowser;
   TEveGListTreeEditorFrame *fLTEFrame;

   TFolder                  *fMacroFolder;

   TEveWindowManager        *fWindowManager;
   TEveViewerList           *fViewers;
   TEveSceneList            *fScenes;

   TEveScene                *fGlobalScene;
   TEveScene                *fEventScene;
   TEveEventManager         *fCurrentEvent;

   Int_t                     fRedrawDisabled;
   Bool_t                    fFullRedraw;
   Bool_t                    fResetCameras;
   Bool_t                    fDropLogicals;
   Bool_t                    fKeepEmptyCont;
   Bool_t                    fTimerActive;
   TTimer                    fRedrawTimer;

   // Fine grained scene updates.
   TExMap                   *fStampedElements;

   // Selection / hihglight elements
   TEveSelection            *fSelection;
   TEveSelection            *fHighlight;

   TEveElementList          *fOrphanage;
   Bool_t                    fUseOrphanage;

public:
   TEveManager(UInt_t w, UInt_t h, Bool_t map_window=kTRUE, Option_t* opt="FI");
   virtual ~TEveManager();

   TExceptionHandler* GetExcHandler() const { return fExcHandler; }

   TEveSelection*     GetSelection() const { return fSelection; }
   TEveSelection*     GetHighlight() const { return fHighlight; }

   TEveElementList*   GetOrphanage()    const { return fOrphanage;    }
   Bool_t             GetUseOrphanage() const { return fUseOrphanage; }
   void               SetUseOrphanage(Bool_t o) { fUseOrphanage = o;  }
   void               ClearOrphanage();

   TEveBrowser*      GetBrowser()   const { return fBrowser;   }
   TEveGListTreeEditorFrame* GetLTEFrame()  const { return fLTEFrame;  }
   TEveGedEditor*    GetEditor()    const;
   TGStatusBar*      GetStatusBar() const;

   TEveWindowManager* GetWindowManager() const { return fWindowManager; }

   TEveSceneList*    GetScenes()   const { return fScenes;  }
   TEveViewerList*   GetViewers()  const { return fViewers; }

   TEveScene*        GetGlobalScene()  const { return fGlobalScene; }
   TEveScene*        GetEventScene()   const { return fEventScene; }
   TEveEventManager* GetCurrentEvent() const { return fCurrentEvent; }

   void SetCurrentEvent(TEveEventManager* mgr) { fCurrentEvent = mgr; }

   TCanvas*     AddCanvasTab(const char* name);
   TGWindow*    GetMainWindow() const;
   TEveViewer*  GetDefaultViewer() const;
   TGLViewer*   GetDefaultGLViewer() const;
   TEveViewer*  SpawnNewViewer(const char* name, const char* title="", Bool_t embed=kTRUE);
   TEveScene*   SpawnNewScene(const char* name, const char* title="");

   TFolder*     GetMacroFolder() const { return fMacroFolder; }
   TMacro*      GetMacro(const char* name) const;

   void EditElement(TEveElement* element);

   void DisableRedraw() { ++fRedrawDisabled; }
   void EnableRedraw()  { --fRedrawDisabled; if (fRedrawDisabled <= 0) Redraw3D(); }

   void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
   {
      if (fRedrawDisabled <= 0 && !fTimerActive) RegisterRedraw3D();
      if (resetCameras) fResetCameras = kTRUE;
      if (dropLogicals) fDropLogicals = kTRUE;
   }
   void RegisterRedraw3D();
   void DoRedraw3D();
   void FullRedraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE);

   Bool_t GetKeepEmptyCont() const   { return fKeepEmptyCont; }
   void   SetKeepEmptyCont(Bool_t k) { fKeepEmptyCont = k; }

   void ElementChanged(TEveElement* element, Bool_t update_scenes=kTRUE, Bool_t redraw=kFALSE);
   void ScenesChanged(TEveElement::List_t& scenes);

   // Fine grained updates via stamping.
   void ElementStamped(TEveElement* element);

   // These are more like TEveManager stuff.
   TGListTree*     GetListTree() const;
   TGListTreeItem* AddToListTree(TEveElement* re, Bool_t open, TGListTree* lt=0);
   void            RemoveFromListTree(TEveElement* element, TGListTree* lt, TGListTreeItem* lti);

   TGListTreeItem* AddEvent(TEveEventManager* event);

   void AddElement(TEveElement* element, TEveElement* parent=0);
   void AddGlobalElement(TEveElement* element, TEveElement* parent=0);

   void RemoveElement(TEveElement* element, TEveElement* parent);
   void PreDeleteElement(TEveElement* element);

   void   ElementSelect(TEveElement* element);
   Bool_t ElementPaste(TEveElement* element);

   // VizDB - Visualization-parameter data-base.
   Bool_t       InsertVizDBEntry(const TString& tag, TEveElement* model,
                                 Bool_t replace, Bool_t update);
   Bool_t       InsertVizDBEntry(const TString& tag, TEveElement* model);
   TEveElement* FindVizDBEntry  (const TString& tag);

   void         LoadVizDB(const TString& filename, Bool_t replace, Bool_t update);
   void         LoadVizDB(const TString& filename);
   void         SaveVizDB(const TString& filename);

   Bool_t GetVizDBReplace()   const { return fVizDBReplace; }
   Bool_t GetVizDBUpdate ()   const { return fVizDBUpdate;  }
   void   SetVizDBReplace(Bool_t r) { fVizDBReplace = r; }
   void   SetVizDBUpdate (Bool_t u) { fVizDBUpdate  = u; }


   // Geometry management.
   TGeoManager* GetGeometry(const TString& filename);
   TGeoManager* GetGeometryByAlias(const TString& alias);
   TGeoManager* GetDefaultGeometry();
   void         RegisterGeometryAlias(const TString& alias, const TString& filename);

   void SetStatusLine(const char* text);
   void ClearROOTClassSaved();

   void CloseEveWindow();

   static TEveManager* Create(Bool_t map_window=kTRUE, Option_t* opt="FIV");
   static void         Terminate();

   ClassDef(TEveManager, 0); // Eve application manager.
};

R__EXTERN TEveManager* gEve;

#endif
 TEveManager.h:1
 TEveManager.h:2
 TEveManager.h:3
 TEveManager.h:4
 TEveManager.h:5
 TEveManager.h:6
 TEveManager.h:7
 TEveManager.h:8
 TEveManager.h:9
 TEveManager.h:10
 TEveManager.h:11
 TEveManager.h:12
 TEveManager.h:13
 TEveManager.h:14
 TEveManager.h:15
 TEveManager.h:16
 TEveManager.h:17
 TEveManager.h:18
 TEveManager.h:19
 TEveManager.h:20
 TEveManager.h:21
 TEveManager.h:22
 TEveManager.h:23
 TEveManager.h:24
 TEveManager.h:25
 TEveManager.h:26
 TEveManager.h:27
 TEveManager.h:28
 TEveManager.h:29
 TEveManager.h:30
 TEveManager.h:31
 TEveManager.h:32
 TEveManager.h:33
 TEveManager.h:34
 TEveManager.h:35
 TEveManager.h:36
 TEveManager.h:37
 TEveManager.h:38
 TEveManager.h:39
 TEveManager.h:40
 TEveManager.h:41
 TEveManager.h:42
 TEveManager.h:43
 TEveManager.h:44
 TEveManager.h:45
 TEveManager.h:46
 TEveManager.h:47
 TEveManager.h:48
 TEveManager.h:49
 TEveManager.h:50
 TEveManager.h:51
 TEveManager.h:52
 TEveManager.h:53
 TEveManager.h:54
 TEveManager.h:55
 TEveManager.h:56
 TEveManager.h:57
 TEveManager.h:58
 TEveManager.h:59
 TEveManager.h:60
 TEveManager.h:61
 TEveManager.h:62
 TEveManager.h:63
 TEveManager.h:64
 TEveManager.h:65
 TEveManager.h:66
 TEveManager.h:67
 TEveManager.h:68
 TEveManager.h:69
 TEveManager.h:70
 TEveManager.h:71
 TEveManager.h:72
 TEveManager.h:73
 TEveManager.h:74
 TEveManager.h:75
 TEveManager.h:76
 TEveManager.h:77
 TEveManager.h:78
 TEveManager.h:79
 TEveManager.h:80
 TEveManager.h:81
 TEveManager.h:82
 TEveManager.h:83
 TEveManager.h:84
 TEveManager.h:85
 TEveManager.h:86
 TEveManager.h:87
 TEveManager.h:88
 TEveManager.h:89
 TEveManager.h:90
 TEveManager.h:91
 TEveManager.h:92
 TEveManager.h:93
 TEveManager.h:94
 TEveManager.h:95
 TEveManager.h:96
 TEveManager.h:97
 TEveManager.h:98
 TEveManager.h:99
 TEveManager.h:100
 TEveManager.h:101
 TEveManager.h:102
 TEveManager.h:103
 TEveManager.h:104
 TEveManager.h:105
 TEveManager.h:106
 TEveManager.h:107
 TEveManager.h:108
 TEveManager.h:109
 TEveManager.h:110
 TEveManager.h:111
 TEveManager.h:112
 TEveManager.h:113
 TEveManager.h:114
 TEveManager.h:115
 TEveManager.h:116
 TEveManager.h:117
 TEveManager.h:118
 TEveManager.h:119
 TEveManager.h:120
 TEveManager.h:121
 TEveManager.h:122
 TEveManager.h:123
 TEveManager.h:124
 TEveManager.h:125
 TEveManager.h:126
 TEveManager.h:127
 TEveManager.h:128
 TEveManager.h:129
 TEveManager.h:130
 TEveManager.h:131
 TEveManager.h:132
 TEveManager.h:133
 TEveManager.h:134
 TEveManager.h:135
 TEveManager.h:136
 TEveManager.h:137
 TEveManager.h:138
 TEveManager.h:139
 TEveManager.h:140
 TEveManager.h:141
 TEveManager.h:142
 TEveManager.h:143
 TEveManager.h:144
 TEveManager.h:145
 TEveManager.h:146
 TEveManager.h:147
 TEveManager.h:148
 TEveManager.h:149
 TEveManager.h:150
 TEveManager.h:151
 TEveManager.h:152
 TEveManager.h:153
 TEveManager.h:154
 TEveManager.h:155
 TEveManager.h:156
 TEveManager.h:157
 TEveManager.h:158
 TEveManager.h:159
 TEveManager.h:160
 TEveManager.h:161
 TEveManager.h:162
 TEveManager.h:163
 TEveManager.h:164
 TEveManager.h:165
 TEveManager.h:166
 TEveManager.h:167
 TEveManager.h:168
 TEveManager.h:169
 TEveManager.h:170
 TEveManager.h:171
 TEveManager.h:172
 TEveManager.h:173
 TEveManager.h:174
 TEveManager.h:175
 TEveManager.h:176
 TEveManager.h:177
 TEveManager.h:178
 TEveManager.h:179
 TEveManager.h:180
 TEveManager.h:181
 TEveManager.h:182
 TEveManager.h:183
 TEveManager.h:184
 TEveManager.h:185
 TEveManager.h:186
 TEveManager.h:187
 TEveManager.h:188
 TEveManager.h:189
 TEveManager.h:190
 TEveManager.h:191
 TEveManager.h:192
 TEveManager.h:193
 TEveManager.h:194
 TEveManager.h:195
 TEveManager.h:196
 TEveManager.h:197
 TEveManager.h:198
 TEveManager.h:199
 TEveManager.h:200
 TEveManager.h:201
 TEveManager.h:202
 TEveManager.h:203
 TEveManager.h:204
 TEveManager.h:205
 TEveManager.h:206
 TEveManager.h:207
 TEveManager.h:208
 TEveManager.h:209
 TEveManager.h:210
 TEveManager.h:211
 TEveManager.h:212
 TEveManager.h:213
 TEveManager.h:214
 TEveManager.h:215
 TEveManager.h:216
 TEveManager.h:217
 TEveManager.h:218
 TEveManager.h:219
 TEveManager.h:220
 TEveManager.h:221
 TEveManager.h:222
 TEveManager.h:223
 TEveManager.h:224
 TEveManager.h:225
 TEveManager.h:226
 TEveManager.h:227
 TEveManager.h:228
 TEveManager.h:229
 TEveManager.h:230
 TEveManager.h:231
 TEveManager.h:232
 TEveManager.h:233
 TEveManager.h:234
 TEveManager.h:235
 TEveManager.h:236
 TEveManager.h:237
 TEveManager.h:238