Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
REveViewer.cxx
Go to the documentation of this file.
1// @(#)root/eve7:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2019, 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#include <ROOT/REveViewer.hxx>
13
14#include <ROOT/REveUtil.hxx>
15#include <ROOT/REveScene.hxx>
17#include <ROOT/REveManager.hxx>
19
20using namespace ROOT::Experimental;
21namespace REX = ROOT::Experimental;
22
23/** \class REveViewer
24\ingroup REve
25Eve representation of a GL view. In a gist, it's a camera + a list of scenes.
26
27*/
28
29////////////////////////////////////////////////////////////////////////////////
30/// Constructor.
31
32REveViewer::REveViewer(const std::string& n, const std::string& t) :
33 REveElement(n, t)
34{
35 // SetChildClass(TClass::GetClass<REveSceneInfo>());
36}
37
38////////////////////////////////////////////////////////////////////////////////
39/// Destructor.
40
42{}
43
44////////////////////////////////////////////////////////////////////////////////
45/// Redraw viewer immediately.
46
47void REveViewer::Redraw(Bool_t /*resetCameras*/)
48{
49 // if (resetCameras) fGLViewer->PostSceneBuildSetup(kTRUE);
50 // fGLViewer->RequestDraw(TGLRnrCtx::kLODHigh);
51}
52
53////////////////////////////////////////////////////////////////////////////////
54/// Add 'scene' to the list of scenes.
55
57{
58 static const REveException eh("REveViewer::AddScene ");
59
60 for (auto &c: RefChildren()) {
61 auto sinfo = dynamic_cast<REveSceneInfo*>(c);
62
63 if (sinfo && sinfo->GetScene() == scene)
64 {
65 throw eh + "scene already in the viewer.";
66 }
67 }
68
69 auto si = new REveSceneInfo(this, scene);
70 AddElement(si);
71}
72
73////////////////////////////////////////////////////////////////////////////////
74/// Remove element 'el' from the list of children and also remove
75/// appropriate GLScene from GLViewer's list of scenes.
76/// Virtual from REveElement.
77
79{
80 // fGLViewer->RemoveScene(((REveSceneInfo*)el)->GetGLScene());
81
82 // XXXXX Notify clients !!! Or will this be automatic?
83}
84
85////////////////////////////////////////////////////////////////////////////////
86/// Remove all children, forwarded to GLViewer.
87/// Virtual from REveElement.
88
90{
91 // fGLViewer->RemoveAllScenes();
92
93 // XXXXX Notify clients !!! Or will this be automatic?
94}
95
96
97/** \class REveViewerList
98\ingroup REve
99List of Viewers providing common operations on REveViewer collections.
100*/
101
102////////////////////////////////////////////////////////////////////////////////
103
104REveViewerList::REveViewerList(const std::string &n, const std::string &t) :
105 REveElement (n, t),
106 fShowTooltip (kTRUE),
107
108 fBrightness(0),
109 fUseLightColorSet(kFALSE)
110{
111 // Constructor.
112
113 SetChildClass(TClass::GetClass<REveViewer>());
114 Connect();
115}
116
117////////////////////////////////////////////////////////////////////////////////
118/// Destructor.
119
121{
122 Disconnect();
123}
124
125////////////////////////////////////////////////////////////////////////////////
126/// Call base-class implementation.
127/// If compound is open and compound of the new element is not set,
128/// the el's compound is set to this.
129
131{
133}
134
135////////////////////////////////////////////////////////////////////////////////
136/// Decompoundofy el, call base-class version.
137
139{
140 // This was needed as viewer was in EveWindowManager hierarchy, too.
141 // el->DecParentIgnoreCnt();
142
144}
145
146////////////////////////////////////////////////////////////////////////////////
147/// Decompoundofy children, call base-class version.
148
150{
151 // This was needed as viewer was in EveWindowManager hierarchy, too.
152 // el->DecParentIgnoreCnt();
153 // for (auto &c: fChildren)
154 // {
155 // c->DecParentIgnoreCnt();
156 // }
157
159}
160
161////////////////////////////////////////////////////////////////////////////////
162/// Connect to TGLViewer class-signals.
163
165{
166 // TQObject::Connect("TGLViewer", "MouseOver(TObject*,UInt_t)",
167 // "REveViewerList", this, "OnMouseOver(TObject*,UInt_t)");
168
169 // TQObject::Connect("TGLViewer", "ReMouseOver(TObject*,UInt_t)",
170 // "REveViewerList", this, "OnReMouseOver(TObject*,UInt_t)");
171
172 // TQObject::Connect("TGLViewer", "UnMouseOver(TObject*,UInt_t)",
173 // "REveViewerList", this, "OnUnMouseOver(TObject*,UInt_t)");
174
175 // TQObject::Connect("TGLViewer", "Clicked(TObject*,UInt_t,UInt_t)",
176 // "REveViewerList", this, "OnClicked(TObject*,UInt_t,UInt_t)");
177
178 // TQObject::Connect("TGLViewer", "ReClicked(TObject*,UInt_t,UInt_t)",
179 // "REveViewerList", this, "OnReClicked(TObject*,UInt_t,UInt_t)");
180
181 // TQObject::Connect("TGLViewer", "UnClicked(TObject*,UInt_t,UInt_t)",
182 // "REveViewerList", this, "OnUnClicked(TObject*,UInt_t,UInt_t)");
183}
184
185////////////////////////////////////////////////////////////////////////////////
186/// Disconnect from TGLViewer class-signals.
187
189{
190 // TQObject::Disconnect("TGLViewer", "MouseOver(TObject*,UInt_t)",
191 // this, "OnMouseOver(TObject*,UInt_t)");
192
193 // TQObject::Disconnect("TGLViewer", "ReMouseOver(TObject*,UInt_t)",
194 // this, "OnReMouseOver(TObject*,UInt_t)");
195
196 // TQObject::Disconnect("TGLViewer", "UnMouseOver(TObject*,UInt_t)",
197 // this, "OnUnMouseOver(TObject*,UInt_t)");
198
199 // TQObject::Disconnect("TGLViewer", "Clicked(TObject*,UInt_t,UInt_t)",
200 // this, "OnClicked(TObject*,UInt_t,UInt_t)");
201
202 // TQObject::Disconnect("TGLViewer", "ReClicked(TObject*,UInt_t,UInt_t)",
203 // this, "OnReClicked(TObject*,UInt_t,UInt_t)");
204
205 // TQObject::Disconnect("TGLViewer", "UnClicked(TObject*,UInt_t,UInt_t)",
206 // this, "OnUnClicked(TObject*,UInt_t,UInt_t)");
207}
208
209////////////////////////////////////////////////////////////////////////////////
210/// Repaint viewers that are tagged as changed.
211
212void REveViewerList::RepaintChangedViewers(Bool_t /*resetCameras*/, Bool_t /*dropLogicals*/)
213{
214 //for (auto &c: fChildren) {
215 // TGLViewer* glv = ((REveViewer*)c)->GetGLViewer();
216 // if (glv->IsChanged())
217 // {
218 // if (resetCameras) glv->PostSceneBuildSetup(kTRUE);
219 // if (dropLogicals) glv->SetSmartRefresh(kFALSE);
220
221 // glv->RequestDraw(TGLRnrCtx::kLODHigh);
222
223 // if (dropLogicals) glv->SetSmartRefresh(kTRUE);
224 // }
225 //}
226}
227
228////////////////////////////////////////////////////////////////////////////////
229/// Repaint all viewers.
230
231void REveViewerList::RepaintAllViewers(Bool_t /*resetCameras*/, Bool_t /*dropLogicals*/)
232{
233 // for (auto &c: fChildren) {
234 // TGLViewer* glv = ((REveViewer *)c)->GetGLViewer();
235
236 // if (resetCameras) glv->PostSceneBuildSetup(kTRUE);
237 // if (dropLogicals) glv->SetSmartRefresh(kFALSE);
238
239 // glv->RequestDraw(TGLRnrCtx::kLODHigh);
240
241 // if (dropLogicals) glv->SetSmartRefresh(kTRUE);
242 // }
243}
244
245////////////////////////////////////////////////////////////////////////////////
246/// Delete annotations from all viewers.
247
249{
250 // for (auto &c: fChildren) {
251 // TGLViewer* glv = ((REveViewer *)c)->GetGLViewer();
252 // glv->DeleteOverlayAnnotations();
253 // }
254}
255
256////////////////////////////////////////////////////////////////////////////////
257/// Callback done from a REveScene destructor allowing proper
258/// removal of the scene from affected viewers.
259
261{
262 for (auto &viewer: fChildren) {
263 for (auto &j: viewer->RefChildren()) {
264 REveSceneInfo* sinfo = (REveSceneInfo *) j;
265 if (sinfo->GetScene() == scene)
266 viewer->RemoveElement(sinfo);
267 }
268 }
269}
270
271////////////////////////////////////////////////////////////////////////////////
272/// Show / hide tooltip for various MouseOver events.
273/// Must be called from slots where sender is TGLEventHandler.
274
276{
277 if (fShowTooltip)
278 {
279 // TGLViewer *glw = dynamic_cast<TGLViewer*>((TQObject*) gTQSender);
280 // TGLEventHandler *glh = (TGLEventHandler*) glw->GetEventHandler();
281 // if (REX::gEve->GetHighlight()->NumChildren() == 1)
282 // {
283 // TString title(REX::gEve->GetHighlight()->FirstChild()->GetHighlightTooltip());
284 // if ( ! title.IsNull())
285 // glh->TriggerTooltip(title);
286 // }
287 // else
288 // {
289 // glh->RemoveTooltip();
290 // }
291 }
292}
293
294////////////////////////////////////////////////////////////////////////////////
295/// Slot for global TGLViewer::MouseOver() signal.
296///
297/// The attempt is made to determine the REveElement being
298/// represented by the physical shape and global highlight is updated
299/// accordingly.
300///
301/// If REveElement::IsPickable() returns false, the element is not
302/// highlighted.
303///
304/// Highlight is always in single-selection mode.
305
307{
308 // REveElement *el = dynamic_cast<REveElement*>(obj);
309 // if (el && !el->IsPickable())
310 // el = nullptr;
311
312 // void *qsender = gTQSender;
313 // REX::gEve->GetHighlight()->UserPickedElement(el, kFALSE);
314 // gTQSender = qsender;
315
317}
318
319////////////////////////////////////////////////////////////////////////////////
320/// Slot for global TGLViewer::ReMouseOver().
321///
322/// The obj is dyn-casted to the REveElement and global selection is
323/// updated accordingly.
324///
325/// If REveElement::IsPickable() returns false, the element is not
326/// selected.
327
329{
330 REveElement* el = dynamic_cast<REveElement*>(obj);
331 if (el && !el->IsPickable())
332 el = 0;
333
334 // void *qsender = gTQSender;
335 // REX::gEve->GetHighlight()->UserRePickedElement(el);
336 // gTQSender = qsender;
337
339}
340
341////////////////////////////////////////////////////////////////////////////////
342/// Slot for global TGLViewer::UnMouseOver().
343///
344/// The obj is dyn-casted to the REveElement and global selection is
345/// updated accordingly.
346///
347/// If REveElement::IsPickable() returns false, the element is not
348/// selected.
349
351{
352 REveElement* el = dynamic_cast<REveElement*>(obj);
353 if (el && !el->IsPickable())
354 el = 0;
355
356 // void *qsender = gTQSender;
357 // REX::gEve->GetHighlight()->UserUnPickedElement(el);
358 // gTQSender = qsender;
359
361}
362
363////////////////////////////////////////////////////////////////////////////////
364/// Slot for global TGLViewer::Clicked().
365///
366/// The obj is dyn-casted to the REveElement and global selection is
367/// updated accordingly.
368///
369/// If REveElement::IsPickable() returns false, the element is not
370/// selected.
371
372void REveViewerList::OnClicked(TObject *obj, UInt_t /*button*/, UInt_t state)
373{
374 REveElement* el = dynamic_cast<REveElement*>(obj);
375 if (el && !el->IsPickable())
376 el = 0;
378}
379
380////////////////////////////////////////////////////////////////////////////////
381/// Slot for global TGLViewer::ReClicked().
382///
383/// The obj is dyn-casted to the REveElement and global selection is
384/// updated accordingly.
385///
386/// If REveElement::IsPickable() returns false, the element is not
387/// selected.
388
389void REveViewerList::OnReClicked(TObject *obj, UInt_t /*button*/, UInt_t /*state*/)
390{
391 REveElement* el = dynamic_cast<REveElement*>(obj);
392 if (el && !el->IsPickable())
393 el = 0;
395}
396
397////////////////////////////////////////////////////////////////////////////////
398/// Slot for global TGLViewer::UnClicked().
399///
400/// The obj is dyn-casted to the REveElement and global selection is
401/// updated accordingly.
402///
403/// If REveElement::IsPickable() returns false, the element is not
404/// selected.
405
406void REveViewerList::OnUnClicked(TObject *obj, UInt_t /*button*/, UInt_t /*state*/)
407{
408 REveElement* el = dynamic_cast<REveElement*>(obj);
409 if (el && !el->IsPickable())
410 el = 0;
412}
413
414////////////////////////////////////////////////////////////////////////////////
415/// Set color brightness.
416
418{
420}
421
422////////////////////////////////////////////////////////////////////////////////
423/// Switch background color.
424
426{
428 // for (auto &c: fChildren) {
429 // TGLViewer* glv = ((REveViewer *)c)->GetGLViewer();
430 // if ( fUseLightColorSet)
431 // glv->UseLightColorSet();
432 // else
433 // glv->UseDarkColorSet();
434
435 // glv->RequestDraw(TGLRnrCtx::kLODHigh);
436 // }
437}
const Mask_t kKeyControlMask
Definition GuiTypes.h:197
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
const Bool_t kFALSE
Definition RtypesCore.h:92
const Bool_t kTRUE
Definition RtypesCore.h:91
virtual void RemoveElementsLocal()
Perform additional local removal of all elements.
virtual void AddElement(REveElement *el)
Add el to the list of children.
virtual void RemoveElementLocal(REveElement *el)
Perform additional local removal of el.
virtual void RemoveElement(REveElement *el)
Remove el from the list of children.
REveException Exception-type thrown by Eve classes.
Definition REveTypes.hxx:40
REveSelection * GetSelection() const
REveSceneInfo Scene in a viewer.
virtual void UserRePickedElement(REveElement *el)
Called when element selection is repeated.
virtual void UserPickedElement(REveElement *el, Bool_t multi=kFALSE)
Called when user picks/clicks on an element.
virtual void UserUnPickedElement(REveElement *el)
Called when an element is unselected.
static void SetColorBrightness(Float_t value, Bool_t full_redraw=kFALSE)
Tweak all ROOT colors to become brighter (if value > 0) or darker (value < 0).
Definition REveUtil.cxx:210
void RemoveElementsLocal() override
Decompoundofy children, call base-class version.
void OnUnClicked(TObject *obj, UInt_t button, UInt_t state)
Slot for global TGLViewer::UnClicked().
void AddElement(REveElement *el) override
Call base-class implementation.
void OnReClicked(TObject *obj, UInt_t button, UInt_t state)
Slot for global TGLViewer::ReClicked().
void OnClicked(TObject *obj, UInt_t button, UInt_t state)
Slot for global TGLViewer::Clicked().
void HandleTooltip()
Show / hide tooltip for various MouseOver events.
void SceneDestructing(REveScene *scene)
Callback done from a REveScene destructor allowing proper removal of the scene from affected viewers.
void OnMouseOver(TObject *obj, UInt_t state)
Slot for global TGLViewer::MouseOver() signal.
void SetColorBrightness(Float_t b)
Set color brightness.
void RepaintAllViewers(Bool_t resetCameras, Bool_t dropLogicals)
Repaint all viewers.
void OnUnMouseOver(TObject *obj, UInt_t state)
Slot for global TGLViewer::UnMouseOver().
virtual void Disconnect()
Disconnect from TGLViewer class-signals.
void RepaintChangedViewers(Bool_t resetCameras, Bool_t dropLogicals)
Repaint viewers that are tagged as changed.
void OnReMouseOver(TObject *obj, UInt_t state)
Slot for global TGLViewer::ReMouseOver().
virtual ~REveViewerList()
Destructor.
void SwitchColorSet()
Switch background color.
REveViewerList(const REveViewerList &)=delete
virtual void Connect()
Connect to TGLViewer class-signals.
void DeleteAnnotations()
Delete annotations from all viewers.
void RemoveElementLocal(REveElement *el) override
Decompoundofy el, call base-class version.
void RemoveElementLocal(REveElement *el) override
Remove element 'el' from the list of children and also remove appropriate GLScene from GLViewer's lis...
void RemoveElementsLocal() override
Remove all children, forwarded to GLViewer.
virtual ~REveViewer()
Destructor.
void Redraw(Bool_t resetCameras=kFALSE)
Redraw viewer immediately.
virtual void AddScene(REveScene *scene)
Add 'scene' to the list of scenes.
Mother of all ROOT objects.
Definition TObject.h:37
const Int_t n
Definition legend1.C:16
R__EXTERN REveManager * gEve