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
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/// Stream Camera Info.
104/// Virtual from REveElement.
105int REveViewer::WriteCoreJson(nlohmann::json &j, Int_t rnr_offset)
106{
107 std::string ct;
108 switch (fCameraType)
109 {
110 case kCameraPerspXOZ: ct = "PerspXOZ"; break;
111 case kCameraOrthoXOY: ct = "OrthoXOY"; break;
112 }
113 j["CameraType"] = ct;
114 return REveElement::WriteCoreJson(j, rnr_offset);
115}
116
117////////////////////////////////////////////////////////////////////////////////
118
119REveViewerList::REveViewerList(const std::string &n, const std::string &t) :
120 REveElement (n, t),
121 fShowTooltip (kTRUE),
122
123 fBrightness(0),
124 fUseLightColorSet(kFALSE)
125{
126 // Constructor.
127
128 SetChildClass(TClass::GetClass<REveViewer>());
129 Connect();
130}
131
132////////////////////////////////////////////////////////////////////////////////
133/// Destructor.
134
136{
137 Disconnect();
138}
139
140////////////////////////////////////////////////////////////////////////////////
141/// Call base-class implementation.
142/// If compound is open and compound of the new element is not set,
143/// the el's compound is set to this.
144
146{
148}
149
150////////////////////////////////////////////////////////////////////////////////
151/// Decompoundofy el, call base-class version.
152
154{
155 // This was needed as viewer was in EveWindowManager hierarchy, too.
156 // el->DecParentIgnoreCnt();
157
159}
160
161////////////////////////////////////////////////////////////////////////////////
162/// Decompoundofy children, call base-class version.
163
165{
166 // This was needed as viewer was in EveWindowManager hierarchy, too.
167 // el->DecParentIgnoreCnt();
168 // for (auto &c: fChildren)
169 // {
170 // c->DecParentIgnoreCnt();
171 // }
172
174}
175
176////////////////////////////////////////////////////////////////////////////////
177/// Connect to TGLViewer class-signals.
178
180{
181 // TQObject::Connect("TGLViewer", "MouseOver(TObject*,UInt_t)",
182 // "REveViewerList", this, "OnMouseOver(TObject*,UInt_t)");
183
184 // TQObject::Connect("TGLViewer", "ReMouseOver(TObject*,UInt_t)",
185 // "REveViewerList", this, "OnReMouseOver(TObject*,UInt_t)");
186
187 // TQObject::Connect("TGLViewer", "UnMouseOver(TObject*,UInt_t)",
188 // "REveViewerList", this, "OnUnMouseOver(TObject*,UInt_t)");
189
190 // TQObject::Connect("TGLViewer", "Clicked(TObject*,UInt_t,UInt_t)",
191 // "REveViewerList", this, "OnClicked(TObject*,UInt_t,UInt_t)");
192
193 // TQObject::Connect("TGLViewer", "ReClicked(TObject*,UInt_t,UInt_t)",
194 // "REveViewerList", this, "OnReClicked(TObject*,UInt_t,UInt_t)");
195
196 // TQObject::Connect("TGLViewer", "UnClicked(TObject*,UInt_t,UInt_t)",
197 // "REveViewerList", this, "OnUnClicked(TObject*,UInt_t,UInt_t)");
198}
199
200////////////////////////////////////////////////////////////////////////////////
201/// Disconnect from TGLViewer class-signals.
202
204{
205 // TQObject::Disconnect("TGLViewer", "MouseOver(TObject*,UInt_t)",
206 // this, "OnMouseOver(TObject*,UInt_t)");
207
208 // TQObject::Disconnect("TGLViewer", "ReMouseOver(TObject*,UInt_t)",
209 // this, "OnReMouseOver(TObject*,UInt_t)");
210
211 // TQObject::Disconnect("TGLViewer", "UnMouseOver(TObject*,UInt_t)",
212 // this, "OnUnMouseOver(TObject*,UInt_t)");
213
214 // TQObject::Disconnect("TGLViewer", "Clicked(TObject*,UInt_t,UInt_t)",
215 // this, "OnClicked(TObject*,UInt_t,UInt_t)");
216
217 // TQObject::Disconnect("TGLViewer", "ReClicked(TObject*,UInt_t,UInt_t)",
218 // this, "OnReClicked(TObject*,UInt_t,UInt_t)");
219
220 // TQObject::Disconnect("TGLViewer", "UnClicked(TObject*,UInt_t,UInt_t)",
221 // this, "OnUnClicked(TObject*,UInt_t,UInt_t)");
222}
223
224////////////////////////////////////////////////////////////////////////////////
225/// Repaint viewers that are tagged as changed.
226
227void REveViewerList::RepaintChangedViewers(Bool_t /*resetCameras*/, Bool_t /*dropLogicals*/)
228{
229 //for (auto &c: fChildren) {
230 // TGLViewer* glv = ((REveViewer*)c)->GetGLViewer();
231 // if (glv->IsChanged())
232 // {
233 // if (resetCameras) glv->PostSceneBuildSetup(kTRUE);
234 // if (dropLogicals) glv->SetSmartRefresh(kFALSE);
235
236 // glv->RequestDraw(TGLRnrCtx::kLODHigh);
237
238 // if (dropLogicals) glv->SetSmartRefresh(kTRUE);
239 // }
240 //}
241}
242
243////////////////////////////////////////////////////////////////////////////////
244/// Repaint all viewers.
245
246void REveViewerList::RepaintAllViewers(Bool_t /*resetCameras*/, Bool_t /*dropLogicals*/)
247{
248 // for (auto &c: fChildren) {
249 // TGLViewer* glv = ((REveViewer *)c)->GetGLViewer();
250
251 // if (resetCameras) glv->PostSceneBuildSetup(kTRUE);
252 // if (dropLogicals) glv->SetSmartRefresh(kFALSE);
253
254 // glv->RequestDraw(TGLRnrCtx::kLODHigh);
255
256 // if (dropLogicals) glv->SetSmartRefresh(kTRUE);
257 // }
258}
259
260////////////////////////////////////////////////////////////////////////////////
261/// Delete annotations from all viewers.
262
264{
265 // for (auto &c: fChildren) {
266 // TGLViewer* glv = ((REveViewer *)c)->GetGLViewer();
267 // glv->DeleteOverlayAnnotations();
268 // }
269}
270
271////////////////////////////////////////////////////////////////////////////////
272/// Callback done from a REveScene destructor allowing proper
273/// removal of the scene from affected viewers.
274
276{
277 for (auto &viewer: fChildren) {
278 for (auto &j: viewer->RefChildren()) {
279 REveSceneInfo* sinfo = (REveSceneInfo *) j;
280 if (sinfo->GetScene() == scene)
281 viewer->RemoveElement(sinfo);
282 }
283 }
284}
285
286////////////////////////////////////////////////////////////////////////////////
287/// Show / hide tooltip for various MouseOver events.
288/// Must be called from slots where sender is TGLEventHandler.
289
291{
292 if (fShowTooltip)
293 {
294 // TGLViewer *glw = dynamic_cast<TGLViewer*>((TQObject*) gTQSender);
295 // TGLEventHandler *glh = (TGLEventHandler*) glw->GetEventHandler();
296 // if (REX::gEve->GetHighlight()->NumChildren() == 1)
297 // {
298 // TString title(REX::gEve->GetHighlight()->FirstChild()->GetHighlightTooltip());
299 // if ( ! title.IsNull())
300 // glh->TriggerTooltip(title);
301 // }
302 // else
303 // {
304 // glh->RemoveTooltip();
305 // }
306 }
307}
308
309////////////////////////////////////////////////////////////////////////////////
310/// Slot for global TGLViewer::MouseOver() signal.
311///
312/// The attempt is made to determine the REveElement being
313/// represented by the physical shape and global highlight is updated
314/// accordingly.
315///
316/// If REveElement::IsPickable() returns false, the element is not
317/// highlighted.
318///
319/// Highlight is always in single-selection mode.
320
322{
323 // REveElement *el = dynamic_cast<REveElement*>(obj);
324 // if (el && !el->IsPickable())
325 // el = nullptr;
326
327 // void *qsender = gTQSender;
328 // REX::gEve->GetHighlight()->UserPickedElement(el, kFALSE);
329 // gTQSender = qsender;
330
332}
333
334////////////////////////////////////////////////////////////////////////////////
335/// Slot for global TGLViewer::ReMouseOver().
336///
337/// The obj is dyn-casted to the REveElement and global selection is
338/// updated accordingly.
339///
340/// If REveElement::IsPickable() returns false, the element is not
341/// selected.
342
344{
345 REveElement* el = dynamic_cast<REveElement*>(obj);
346 if (el && !el->IsPickable())
347 el = 0;
348
349 // void *qsender = gTQSender;
350 // REX::gEve->GetHighlight()->UserRePickedElement(el);
351 // gTQSender = qsender;
352
354}
355
356////////////////////////////////////////////////////////////////////////////////
357/// Slot for global TGLViewer::UnMouseOver().
358///
359/// The obj is dyn-casted to the REveElement and global selection is
360/// updated accordingly.
361///
362/// If REveElement::IsPickable() returns false, the element is not
363/// selected.
364
366{
367 REveElement* el = dynamic_cast<REveElement*>(obj);
368 if (el && !el->IsPickable())
369 el = 0;
370
371 // void *qsender = gTQSender;
372 // REX::gEve->GetHighlight()->UserUnPickedElement(el);
373 // gTQSender = qsender;
374
376}
377
378////////////////////////////////////////////////////////////////////////////////
379/// Slot for global TGLViewer::Clicked().
380///
381/// The obj is dyn-casted to the REveElement and global selection is
382/// updated accordingly.
383///
384/// If REveElement::IsPickable() returns false, the element is not
385/// selected.
386
387void REveViewerList::OnClicked(TObject *obj, UInt_t /*button*/, UInt_t state)
388{
389 REveElement* el = dynamic_cast<REveElement*>(obj);
390 if (el && !el->IsPickable())
391 el = 0;
393}
394
395////////////////////////////////////////////////////////////////////////////////
396/// Slot for global TGLViewer::ReClicked().
397///
398/// The obj is dyn-casted to the REveElement and global selection is
399/// updated accordingly.
400///
401/// If REveElement::IsPickable() returns false, the element is not
402/// selected.
403
404void REveViewerList::OnReClicked(TObject *obj, UInt_t /*button*/, UInt_t /*state*/)
405{
406 REveElement* el = dynamic_cast<REveElement*>(obj);
407 if (el && !el->IsPickable())
408 el = 0;
410}
411
412////////////////////////////////////////////////////////////////////////////////
413/// Slot for global TGLViewer::UnClicked().
414///
415/// The obj is dyn-casted to the REveElement and global selection is
416/// updated accordingly.
417///
418/// If REveElement::IsPickable() returns false, the element is not
419/// selected.
420
421void REveViewerList::OnUnClicked(TObject *obj, UInt_t /*button*/, UInt_t /*state*/)
422{
423 REveElement* el = dynamic_cast<REveElement*>(obj);
424 if (el && !el->IsPickable())
425 el = 0;
427}
428
429////////////////////////////////////////////////////////////////////////////////
430/// Set color brightness.
431
433{
435}
436
437////////////////////////////////////////////////////////////////////////////////
438/// Switch background color.
439
441{
443 // for (auto &c: fChildren) {
444 // TGLViewer* glv = ((REveViewer *)c)->GetGLViewer();
445 // if ( fUseLightColorSet)
446 // glv->UseLightColorSet();
447 // else
448 // glv->UseDarkColorSet();
449
450 // glv->RequestDraw(TGLRnrCtx::kLODHigh);
451 // }
452}
const Mask_t kKeyControlMask
Definition: GuiTypes.h:197
#define b(i)
Definition: RSha256.hxx:100
#define c(i)
Definition: RSha256.hxx:101
int Int_t
Definition: RtypesCore.h:45
unsigned int UInt_t
Definition: RtypesCore.h:46
const Bool_t kFALSE
Definition: RtypesCore.h:101
bool Bool_t
Definition: RtypesCore.h:63
float Float_t
Definition: RtypesCore.h:57
const Bool_t kTRUE
Definition: RtypesCore.h:100
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
virtual void RemoveElementsLocal()
Perform additional local removal of all elements.
virtual Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset)
Write core json.
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:41
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:206
void RemoveElementsLocal() override
Decompoundofy children, call base-class version.
Definition: REveViewer.cxx:164
void OnUnClicked(TObject *obj, UInt_t button, UInt_t state)
Slot for global TGLViewer::UnClicked().
Definition: REveViewer.cxx:421
void AddElement(REveElement *el) override
Call base-class implementation.
Definition: REveViewer.cxx:145
void OnReClicked(TObject *obj, UInt_t button, UInt_t state)
Slot for global TGLViewer::ReClicked().
Definition: REveViewer.cxx:404
void OnClicked(TObject *obj, UInt_t button, UInt_t state)
Slot for global TGLViewer::Clicked().
Definition: REveViewer.cxx:387
void HandleTooltip()
Show / hide tooltip for various MouseOver events.
Definition: REveViewer.cxx:290
void SceneDestructing(REveScene *scene)
Callback done from a REveScene destructor allowing proper removal of the scene from affected viewers.
Definition: REveViewer.cxx:275
void OnMouseOver(TObject *obj, UInt_t state)
Slot for global TGLViewer::MouseOver() signal.
Definition: REveViewer.cxx:321
void SetColorBrightness(Float_t b)
Set color brightness.
Definition: REveViewer.cxx:432
void RepaintAllViewers(Bool_t resetCameras, Bool_t dropLogicals)
Repaint all viewers.
Definition: REveViewer.cxx:246
void OnUnMouseOver(TObject *obj, UInt_t state)
Slot for global TGLViewer::UnMouseOver().
Definition: REveViewer.cxx:365
virtual void Disconnect()
Disconnect from TGLViewer class-signals.
Definition: REveViewer.cxx:203
void RepaintChangedViewers(Bool_t resetCameras, Bool_t dropLogicals)
Repaint viewers that are tagged as changed.
Definition: REveViewer.cxx:227
void OnReMouseOver(TObject *obj, UInt_t state)
Slot for global TGLViewer::ReMouseOver().
Definition: REveViewer.cxx:343
virtual ~REveViewerList()
Destructor.
Definition: REveViewer.cxx:135
void SwitchColorSet()
Switch background color.
Definition: REveViewer.cxx:440
REveViewerList(const REveViewerList &)=delete
virtual void Connect()
Connect to TGLViewer class-signals.
Definition: REveViewer.cxx:179
void DeleteAnnotations()
Delete annotations from all viewers.
Definition: REveViewer.cxx:263
void RemoveElementLocal(REveElement *el) override
Decompoundofy el, call base-class version.
Definition: REveViewer.cxx:153
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:78
void RemoveElementsLocal() override
Remove all children, forwarded to GLViewer.
Definition: REveViewer.cxx:89
virtual ~REveViewer()
Destructor.
Definition: REveViewer.cxx:41
REveViewer(const REveViewer &)=delete
Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override
Stream Camera Info.
Definition: REveViewer.cxx:105
void Redraw(Bool_t resetCameras=kFALSE)
Redraw viewer immediately.
Definition: REveViewer.cxx:47
virtual void AddScene(REveScene *scene)
Add 'scene' to the list of scenes.
Definition: REveViewer.cxx:56
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