Modify defaults for otho-camera (disable rotations).
[u/mrichter/AliRoot.git] / EVE / Reve / Viewer.cxx
CommitLineData
32e219c2 1// $Header$
2
3#include "Viewer.h"
4#include "Scene.h"
5#include "SceneInfo.h"
6
7#include <Reve/ReveManager.h>
8
9#include <TGLSAViewer.h>
10#include <TGLScenePad.h>
11
44865ff0 12#include <TGLOrthoCamera.h> // For fixing defaults in root 5.17.4
13
32e219c2 14using namespace Reve;
15
16//______________________________________________________________________
17// Reve::Viewer
18//
19
20ClassImp(Viewer)
21
22Viewer::Viewer(const Text_t* n, const Text_t* t) :
23 RenderElementList(n, t),
24 fGLViewer (0)
25{
26 SetChildClass(SceneInfo::Class());
27}
28
29Viewer::~Viewer()
30{}
31
32/**************************************************************************/
33
34void Viewer::SetGLViewer(TGLViewer* s)
35{
36 delete fGLViewer;
37 fGLViewer = s;
38
39 fGLViewer->SetSmartRefresh(kTRUE);
40 // fGLViewer->SetResetCamerasOnUpdate(kFALSE);
41 fGLViewer->SetResetCameraOnDoubleClick(kFALSE);
44865ff0 42
43 // Temporary fix for wrong defaults in root 5.17.04
44 fGLViewer->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
45 ((TGLOrthoCamera&)(fGLViewer->CurrentCamera())).SetEnableRotate(kTRUE);
46 fGLViewer->SetCurrentCamera(TGLViewer::kCameraOrthoXOZ);
47 ((TGLOrthoCamera&)(fGLViewer->CurrentCamera())).SetEnableRotate(kTRUE);
48 fGLViewer->SetCurrentCamera(TGLViewer::kCameraOrthoZOY);
49 ((TGLOrthoCamera&)(fGLViewer->CurrentCamera())).SetEnableRotate(kTRUE);
50 fGLViewer->SetCurrentCamera(TGLViewer::kCameraPerspXOZ);
32e219c2 51}
52
53void Viewer::SpawnGLViewer(const TGWindow* parent, TGedEditor* ged)
54{
55 TGLSAViewer* v = new TGLSAViewer(parent, 0, ged);
56 v->ToggleEditObject();
57 SetGLViewer(v);
58}
59
60/**************************************************************************/
61
62void Viewer::AddScene(Scene* scene)
63{
64 static const Exc_t eH("Viewer::AddScene ");
65
66 TGLSceneInfo* glsi = fGLViewer->AddScene(scene->GetGLScene());
67 if (glsi != 0) {
68 SceneInfo* si = new SceneInfo(this, scene, glsi);
69 gReve->AddRenderElement(si, this);
70 } else {
71 throw(eH + "scene already in the viewer.");
72 }
73}
74
75void Viewer::RemoveElementLocal(RenderElement* el)
76{
77 fGLViewer->RemoveScene(((SceneInfo*)el)->GetGLScene());
78}
79
80void Viewer::RemoveElementsLocal()
81{
82 fGLViewer->RemoveAllScenes();
83}
84
85TObject* Viewer::GetEditorObject() const
86{
87 return fGLViewer;
88}
89
90Bool_t Viewer::HandleElementPaste(RenderElement* el)
91{
92 static const Exc_t eH("Viewer::HandleElementPaste ");
93
94 Scene* scene = dynamic_cast<Scene*>(el);
95 if (scene != 0) {
96 AddScene(scene);
97 return kTRUE;
98 } else {
99 Warning(eH.Data(), "class Viewer only accepts Scene paste argument.");
100 return kFALSE;
101 }
102}
103
104/**************************************************************************/
105/**************************************************************************/
106/**************************************************************************/
107
108//______________________________________________________________________
109// Reve::ViewerList
110//
111
112ClassImp(ViewerList)
113
114ViewerList::ViewerList(const Text_t* n, const Text_t* t) :
115 RenderElementList(n, t)
116{
117 SetChildClass(Viewer::Class());
118}
119
120ViewerList::~ViewerList()
121{}
122
123/**************************************************************************/
124
125void ViewerList::RepaintChangedViewers(Bool_t resetCameras, Bool_t dropLogicals)
126{
127 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
128 {
129 TGLViewer* glv = ((Viewer*)*i)->GetGLViewer();
130 if (glv->IsChanged())
131 {
132 // printf(" Viewer '%s' changed ... reqesting draw.\n", (*i)->GetObject()->GetName());
133
134 if (resetCameras) glv->PostSceneBuildSetup(kTRUE);
135 if (dropLogicals) glv->SetSmartRefresh(kFALSE);
136
137 glv->RequestDraw(TGLRnrCtx::kLODHigh);
138
139 if (dropLogicals) glv->SetSmartRefresh(kTRUE);
140 }
141 }
142}
143
144void ViewerList::RepaintAllViewers(Bool_t resetCameras, Bool_t dropLogicals)
145{
146 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
147 {
148 TGLViewer* glv = ((Viewer*)*i)->GetGLViewer();
149
150 // printf(" Viewer '%s' sending redraw reqest.\n", (*i)->GetObject()->GetName());
151
152 if (resetCameras) glv->PostSceneBuildSetup(kTRUE);
153 if (dropLogicals) glv->SetSmartRefresh(kFALSE);
154
155 glv->RequestDraw(TGLRnrCtx::kLODHigh);
156
157 if (dropLogicals) glv->SetSmartRefresh(kTRUE);
158 }
159}
160
161/**************************************************************************/
162
163void ViewerList::SceneDestructing(Scene* scene)
164{
165 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
166 {
167 Viewer* viewer = (Viewer*) *i;
168 List_i j = viewer->BeginChildren();
169 while (j != viewer->EndChildren())
170 {
171 SceneInfo* sinfo = (SceneInfo*) *j;
172 ++j;
173 if (sinfo->GetScene() == scene)
174 gReve->RemoveRenderElement(sinfo, viewer);
175 }
176 }
177}