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>
16 #include <ROOT/REveSceneInfo.hxx>
17 #include <ROOT/REveManager.hxx>
18 #include <ROOT/REveSelection.hxx>
19 
20 using namespace ROOT::Experimental;
21 namespace REX = ROOT::Experimental;
22 
23 /** \class REveViewer
24 \ingroup REve
25 Eve representation of a GL view. In a gist, it's a camera + a list of scenes.
26 
27 */
28 
29 ////////////////////////////////////////////////////////////////////////////////
30 /// Constructor.
31 
32 REveViewer::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 
47 void 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
99 List of Viewers providing common operations on REveViewer collections.
100 */
101 
102 ////////////////////////////////////////////////////////////////////////////////
103 
104 REveViewerList::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 
212 void 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 
231 void 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 
316  HandleTooltip();
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 
338  HandleTooltip();
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 
360  HandleTooltip();
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 
372 void 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 
389 void 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 
406 void 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 }
c
#define c(i)
Definition: RSha256.hxx:119
n
const Int_t n
Definition: legend1.C:16
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
ROOT::Experimental::REveViewer::REveViewer
REveViewer(const REveViewer &)=delete
ROOT::Experimental::REveViewer::Redraw
void Redraw(Bool_t resetCameras=kFALSE)
Redraw viewer immediately.
Definition: REveViewer.cxx:47
ROOT::Experimental::REveElement::IsPickable
Bool_t IsPickable() const
Definition: REveElement.hxx:328
ROOT::Experimental::REveElement::fChildren
List_t fChildren
Definition: REveElement.hxx:111
ROOT::Experimental::REveViewer::RemoveElementsLocal
void RemoveElementsLocal() override
Remove all children, forwarded to GLViewer.
Definition: REveViewer.cxx:89
ROOT::Experimental::REveViewerList::OnUnClicked
void OnUnClicked(TObject *obj, UInt_t button, UInt_t state)
Slot for global TGLViewer::UnClicked().
Definition: REveViewer.cxx:406
ROOT::Experimental::REveViewerList::SwitchColorSet
void SwitchColorSet()
Switch background color.
Definition: REveViewer.cxx:425
ROOT::Experimental::REveViewerList::RemoveElementLocal
void RemoveElementLocal(REveElement *el) override
Decompoundofy el, call base-class version.
Definition: REveViewer.cxx:138
ROOT::Experimental::REveSceneInfo::GetScene
REveScene * GetScene() const
Definition: REveSceneInfo.hxx:57
ROOT::Experimental::REveViewerList::RepaintAllViewers
void RepaintAllViewers(Bool_t resetCameras, Bool_t dropLogicals)
Repaint all viewers.
Definition: REveViewer.cxx:231
ROOT::Experimental::REveViewerList::OnClicked
void OnClicked(TObject *obj, UInt_t button, UInt_t state)
Slot for global TGLViewer::Clicked().
Definition: REveViewer.cxx:372
ROOT::Experimental::REveViewerList::REveViewerList
REveViewerList(const REveViewerList &)=delete
ROOT::Experimental::REveViewerList::AddElement
void AddElement(REveElement *el) override
Call base-class implementation.
Definition: REveViewer.cxx:130
ROOT::Experimental::REveViewerList::DeleteAnnotations
void DeleteAnnotations()
Delete annotations from all viewers.
Definition: REveViewer.cxx:248
ROOT::Experimental::REveViewerList::Connect
virtual void Connect()
Connect to TGLViewer class-signals.
Definition: REveViewer.cxx:164
TEveManager::GetSelection
TEveSelection * GetSelection() const
Definition: TEveManager.h:129
ROOT::Experimental::REveViewerList::RepaintChangedViewers
void RepaintChangedViewers(Bool_t resetCameras, Bool_t dropLogicals)
Repaint viewers that are tagged as changed.
Definition: REveViewer.cxx:212
ROOT::Experimental::REveElement
Definition: REveElement.hxx:79
gEve
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
b
#define b(i)
Definition: RSha256.hxx:118
bool
ROOT::Experimental::REveViewerList::OnMouseOver
void OnMouseOver(TObject *obj, UInt_t state)
Slot for global TGLViewer::MouseOver() signal.
Definition: REveViewer.cxx:306
ROOT::Experimental::REveUtil::SetColorBrightness
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:205
ROOT::Experimental::REveViewerList::OnUnMouseOver
void OnUnMouseOver(TObject *obj, UInt_t state)
Slot for global TGLViewer::UnMouseOver().
Definition: REveViewer.cxx:350
ROOT::Experimental::REveViewerList::fUseLightColorSet
Bool_t fUseLightColorSet
Definition: REveViewer.hxx:74
ROOT::Experimental::REveScene
Definition: REveScene.hxx:45
REveScene.hxx
ROOT::Experimental::REveException
REveException Exception-type thrown by Eve classes.
Definition: REveTypes.hxx:40
ROOT::Experimental::REveViewerList::~REveViewerList
virtual ~REveViewerList()
Destructor.
Definition: REveViewer.cxx:120
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TEveSelection::UserUnPickedElement
virtual void UserUnPickedElement(TEveElement *el)
Called when secondary selection becomes empty.
Definition: TEveSelection.cxx:383
REveSelection.hxx
ROOT::Experimental::REveViewerList::Disconnect
virtual void Disconnect()
Disconnect from TGLViewer class-signals.
Definition: REveViewer.cxx:188
ROOT::Experimental::REveViewerList::OnReClicked
void OnReClicked(TObject *obj, UInt_t button, UInt_t state)
Slot for global TGLViewer::ReClicked().
Definition: REveViewer.cxx:389
TEveSelection::UserRePickedElement
virtual void UserRePickedElement(TEveElement *el)
Called when secondary selection becomes empty.
Definition: TEveSelection.cxx:370
ROOT::Experimental::REveViewerList::SetColorBrightness
void SetColorBrightness(Float_t b)
Set color brightness.
Definition: REveViewer.cxx:417
ROOT::Experimental::REveElement::RemoveElementLocal
virtual void RemoveElementLocal(REveElement *el)
Perform additional local removal of el.
Definition: REveElement.cxx:908
ROOT::Experimental::REveElement::RefChildren
List_t & RefChildren()
Definition: REveElement.hxx:201
TEveSelection::UserPickedElement
virtual void UserPickedElement(TEveElement *el, Bool_t multi=kFALSE)
Called when user picks/clicks on an element.
Definition: TEveSelection.cxx:344
unsigned int
ROOT::Experimental::REveViewerList::HandleTooltip
void HandleTooltip()
Show / hide tooltip for various MouseOver events.
Definition: REveViewer.cxx:275
kKeyControlMask
const Mask_t kKeyControlMask
Definition: GuiTypes.h:196
REveManager.hxx
ROOT::Experimental::REveElement::RemoveElement
virtual void RemoveElement(REveElement *el)
Remove el from the list of children.
Definition: REveElement.cxx:875
ROOT::Experimental::REveElement::AddElement
virtual void AddElement(REveElement *el)
Add el to the list of children.
Definition: REveElement.cxx:842
ROOT::Experimental::REveViewer::RemoveElementLocal
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
REveUtil.hxx
ROOT::Experimental::REveViewerList::OnReMouseOver
void OnReMouseOver(TObject *obj, UInt_t state)
Slot for global TGLViewer::ReMouseOver().
Definition: REveViewer.cxx:328
TObject
Definition: TObject.h:37
ROOT::Experimental::REveViewer::AddScene
virtual void AddScene(REveScene *scene)
Add 'scene' to the list of scenes.
Definition: REveViewer.cxx:56
ROOT::Experimental::REveElement::RemoveElementsLocal
virtual void RemoveElementsLocal()
Perform additional local removal of all elements.
Definition: REveElement.cxx:952
REveSceneInfo.hxx
ROOT::Experimental::REveViewerList::SceneDestructing
void SceneDestructing(REveScene *scene)
Callback done from a REveScene destructor allowing proper removal of the scene from affected viewers.
Definition: REveViewer.cxx:260
ROOT::Experimental::REveViewerList::fShowTooltip
Bool_t fShowTooltip
Definition: REveViewer.hxx:71
ROOT::Experimental
Definition: RDirectory.hxx:36
ROOT::Experimental::REveSceneInfo
REveSceneInfo Scene in a viewer.
Definition: REveSceneInfo.hxx:40
Float_t
REveViewer.hxx
ROOT::Experimental::REveElement::SetChildClass
void SetChildClass(TClass *c)
Definition: REveElement.hxx:199
ROOT::Experimental::REveViewer::~REveViewer
virtual ~REveViewer()
Destructor.
Definition: REveViewer.cxx:41
ROOT::Experimental::REveViewerList::RemoveElementsLocal
void RemoveElementsLocal() override
Decompoundofy children, call base-class version.
Definition: REveViewer.cxx:149