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