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