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#include <ROOT/REveText.hxx>
20
21#include <nlohmann/json.hpp>
22#include "TROOT.h"
23
24using namespace ROOT::Experimental;
25namespace REX = ROOT::Experimental;
26
27/** \class REveViewer
28\ingroup REve
29Eve representation of a GL view. In a gist, it's a camera + a list of scenes.
30
31*/
32
33////////////////////////////////////////////////////////////////////////////////
34/// Constructor.
35
36REveViewer::REveViewer(const std::string& n, const std::string& t) :
37 REveElement(n, t)
38{
39 // SetChildClass(TClass::GetClass<REveSceneInfo>());
40}
41
42////////////////////////////////////////////////////////////////////////////////
43/// Destructor.
44
47
48////////////////////////////////////////////////////////////////////////////////
49/// Redraw viewer immediately.
50
51void REveViewer::Redraw(Bool_t /*resetCameras*/)
52{
53 // if (resetCameras) fGLViewer->PostSceneBuildSetup(kTRUE);
54 // fGLViewer->RequestDraw(TGLRnrCtx::kLODHigh);
55}
56
57////////////////////////////////////////////////////////////////////////////////
58/// Add 'scene' to the list of scenes.
59
61{
62 static const REveException eh("REveViewer::AddScene ");
63
64 for (auto &c: RefChildren()) {
65 auto sinfo = dynamic_cast<REveSceneInfo*>(c);
66
67 if (sinfo && sinfo->GetScene() == scene)
68 {
69 throw eh + "scene already in the viewer.";
70 }
71 }
72
73 auto si = new REveSceneInfo(this, scene);
75}
76
77////////////////////////////////////////////////////////////////////////////////
78/// Remove element 'el' from the list of children and also remove
79/// appropriate GLScene from GLViewer's list of scenes.
80/// Virtual from REveElement.
81
83{
84 // fGLViewer->RemoveScene(((REveSceneInfo*)el)->GetGLScene());
85
86 // XXXXX Notify clients !!! Or will this be automatic?
87}
88
89////////////////////////////////////////////////////////////////////////////////
90/// Remove all children, forwarded to GLViewer.
91/// Virtual from REveElement.
92
94{
95 // fGLViewer->RemoveAllScenes();
96
97 // XXXXX Notify clients !!! Or will this be automatic?
98}
99
100
101/** \class REveViewerList
102\ingroup REve
103List of Viewers providing common operations on REveViewer collections.
104*/
105
106////////////////////////////////////////////////////////////////////////////////
107//
109{
110 fAxesType = (EAxesType)at;
111 if (fAxesType != kAxesNone) {
112 std::string fn = "LiberationSerif-Regular";
113 std::string rf_dir = std::string(TROOT::GetDataDir().Data()) + "/fonts/";
114 REX::REveText::AssertSdfFont(fn, rf_dir + fn + ".ttf");
115 }
117}
118
119////////////////////////////////////////////////////////////////////////////////
120//
126
127////////////////////////////////////////////////////////////////////////////////
128/// Stream Camera Info.
129/// Virtual from REveElement.
131{
132 std::string ct;
133 switch (fCameraType)
134 {
135 case kCameraPerspXOZ: ct = "PerspXOZ"; break;
136 case kCameraOrthoXOY: ct = "OrthoXOY"; break;
137 }
138 j["CameraType"] = ct;
139 j["Mandatory"] = fMandatory;
140 j["AxesType"] = fAxesType;
141 j["BlackBg"] = fBlackBackground;
142
143 j["UT_PostStream"] = "UT_EveViewerUpdate";
144
146}
147
148////////////////////////////////////////////////////////////////////////////////
149/// Function called from MIR when user closes one of the viewer window.
150// Client id stored in thread local data
155////////////////////////////////////////////////////////////////////////////////
156/// Function called from MIR when user wants to stream unsubscribed view.
157// Client id stored in thread local data
162
163////////////////////////////////////////////////////////////////////////////////
164///
165// Set Flag if this viewer is presented on connect
167{
168 fMandatory = x;
169 for (auto &c : RefChildren()) {
170 REveSceneInfo *sinfo = dynamic_cast<REveSceneInfo *>(c);
171 sinfo->GetScene()->GetScene()->SetMandatory(fMandatory);
172 }
173}
174
175////////////////////////////////////////////////////////////////////////////////
176
177REveViewerList::REveViewerList(const std::string &n, const std::string &t) :
178 REveElement (n, t),
179 fShowTooltip (kTRUE),
180
181 fBrightness(0),
182 fUseLightColorSet(kFALSE)
183{
184 // Constructor.
185
186 SetChildClass(TClass::GetClass<REveViewer>());
187 Connect();
188}
189
190////////////////////////////////////////////////////////////////////////////////
191/// Destructor.
192
197
198////////////////////////////////////////////////////////////////////////////////
199/// Call base-class implementation.
200/// If compound is open and compound of the new element is not set,
201/// the el's compound is set to this.
202
207
208////////////////////////////////////////////////////////////////////////////////
209/// Decompoundofy el, call base-class version.
210
212{
213 // This was needed as viewer was in EveWindowManager hierarchy, too.
214 // el->DecParentIgnoreCnt();
215
217}
218
219////////////////////////////////////////////////////////////////////////////////
220/// Decompoundofy children, call base-class version.
221
223{
224 // This was needed as viewer was in EveWindowManager hierarchy, too.
225 // el->DecParentIgnoreCnt();
226 // for (auto &c: fChildren)
227 // {
228 // c->DecParentIgnoreCnt();
229 // }
230
232}
233
234////////////////////////////////////////////////////////////////////////////////
235/// Connect to TGLViewer class-signals.
236
238{
239 // TQObject::Connect("TGLViewer", "MouseOver(TObject*,UInt_t)",
240 // "REveViewerList", this, "OnMouseOver(TObject*,UInt_t)");
241
242 // TQObject::Connect("TGLViewer", "ReMouseOver(TObject*,UInt_t)",
243 // "REveViewerList", this, "OnReMouseOver(TObject*,UInt_t)");
244
245 // TQObject::Connect("TGLViewer", "UnMouseOver(TObject*,UInt_t)",
246 // "REveViewerList", this, "OnUnMouseOver(TObject*,UInt_t)");
247
248 // TQObject::Connect("TGLViewer", "Clicked(TObject*,UInt_t,UInt_t)",
249 // "REveViewerList", this, "OnClicked(TObject*,UInt_t,UInt_t)");
250
251 // TQObject::Connect("TGLViewer", "ReClicked(TObject*,UInt_t,UInt_t)",
252 // "REveViewerList", this, "OnReClicked(TObject*,UInt_t,UInt_t)");
253
254 // TQObject::Connect("TGLViewer", "UnClicked(TObject*,UInt_t,UInt_t)",
255 // "REveViewerList", this, "OnUnClicked(TObject*,UInt_t,UInt_t)");
256}
257
258////////////////////////////////////////////////////////////////////////////////
259/// Disconnect from TGLViewer class-signals.
260
262{
263 // TQObject::Disconnect("TGLViewer", "MouseOver(TObject*,UInt_t)",
264 // this, "OnMouseOver(TObject*,UInt_t)");
265
266 // TQObject::Disconnect("TGLViewer", "ReMouseOver(TObject*,UInt_t)",
267 // this, "OnReMouseOver(TObject*,UInt_t)");
268
269 // TQObject::Disconnect("TGLViewer", "UnMouseOver(TObject*,UInt_t)",
270 // this, "OnUnMouseOver(TObject*,UInt_t)");
271
272 // TQObject::Disconnect("TGLViewer", "Clicked(TObject*,UInt_t,UInt_t)",
273 // this, "OnClicked(TObject*,UInt_t,UInt_t)");
274
275 // TQObject::Disconnect("TGLViewer", "ReClicked(TObject*,UInt_t,UInt_t)",
276 // this, "OnReClicked(TObject*,UInt_t,UInt_t)");
277
278 // TQObject::Disconnect("TGLViewer", "UnClicked(TObject*,UInt_t,UInt_t)",
279 // this, "OnUnClicked(TObject*,UInt_t,UInt_t)");
280}
281
282////////////////////////////////////////////////////////////////////////////////
283/// Repaint viewers that are tagged as changed.
284
285void REveViewerList::RepaintChangedViewers(Bool_t /*resetCameras*/, Bool_t /*dropLogicals*/)
286{
287 //for (auto &c: fChildren) {
288 // TGLViewer* glv = ((REveViewer*)c)->GetGLViewer();
289 // if (glv->IsChanged())
290 // {
291 // if (resetCameras) glv->PostSceneBuildSetup(kTRUE);
292 // if (dropLogicals) glv->SetSmartRefresh(kFALSE);
293
294 // glv->RequestDraw(TGLRnrCtx::kLODHigh);
295
296 // if (dropLogicals) glv->SetSmartRefresh(kTRUE);
297 // }
298 //}
299}
300
301////////////////////////////////////////////////////////////////////////////////
302/// Repaint all viewers.
303
304void REveViewerList::RepaintAllViewers(Bool_t /*resetCameras*/, Bool_t /*dropLogicals*/)
305{
306 // for (auto &c: fChildren) {
307 // TGLViewer* glv = ((REveViewer *)c)->GetGLViewer();
308
309 // if (resetCameras) glv->PostSceneBuildSetup(kTRUE);
310 // if (dropLogicals) glv->SetSmartRefresh(kFALSE);
311
312 // glv->RequestDraw(TGLRnrCtx::kLODHigh);
313
314 // if (dropLogicals) glv->SetSmartRefresh(kTRUE);
315 // }
316}
317
318////////////////////////////////////////////////////////////////////////////////
319/// Delete annotations from all viewers.
320
322{
323 // for (auto &c: fChildren) {
324 // TGLViewer* glv = ((REveViewer *)c)->GetGLViewer();
325 // glv->DeleteOverlayAnnotations();
326 // }
327}
328
329////////////////////////////////////////////////////////////////////////////////
330/// Callback done from a REveScene destructor allowing proper
331/// removal of the scene from affected viewers.
332
334{
335 for (auto &viewer: fChildren) {
336 for (auto &j: viewer->RefChildren()) {
338 if (sinfo->GetScene() == scene)
339 viewer->RemoveElement(sinfo);
340 }
341 }
342}
343
344////////////////////////////////////////////////////////////////////////////////
345/// Show / hide tooltip for various MouseOver events.
346/// Must be called from slots where sender is TGLEventHandler.
347
349{
350 if (fShowTooltip)
351 {
352 // TGLViewer *glw = dynamic_cast<TGLViewer*>((TQObject*) gTQSender);
353 // TGLEventHandler *glh = (TGLEventHandler*) glw->GetEventHandler();
354 // if (REX::gEve->GetHighlight()->NumChildren() == 1)
355 // {
356 // TString title(REX::gEve->GetHighlight()->FirstChild()->GetHighlightTooltip());
357 // if ( ! title.IsNull())
358 // glh->TriggerTooltip(title);
359 // }
360 // else
361 // {
362 // glh->RemoveTooltip();
363 // }
364 }
365}
366
367////////////////////////////////////////////////////////////////////////////////
368/// Set color brightness.
369
374
375////////////////////////////////////////////////////////////////////////////////
376/// Switch background color.
377
379{
381 // To implement something along the lines of:
382 // BeginChanges on EveWorld; // Here or in the calling function
383 // for (auto &c: fChildren) {
384 // REveViewer* v = (REveViewer *)c;
385 // if ( fUseLightColorSet)
386 // c->UseLightColorSet();
387 // else
388 // c->UseDarkColorSet();
389 // }
390 // EndChanges on EveWorld;
391}
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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.
REveException Exception-type thrown by Eve classes.
Definition REveTypes.hxx:42
void DisconnectEveViewer(REveViewer *)
void ConnectEveViewer(REveViewer *)
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:226
void RemoveElementsLocal() override
Decompoundofy children, call base-class version.
void AddElement(REveElement *el) override
Call base-class implementation.
~REveViewerList() override
Destructor.
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 SetColorBrightness(Float_t b)
Set color brightness.
void RepaintAllViewers(Bool_t resetCameras, Bool_t dropLogicals)
Repaint all viewers.
virtual void Disconnect()
Disconnect from TGLViewer class-signals.
void RepaintChangedViewers(Bool_t resetCameras, Bool_t dropLogicals)
Repaint viewers that are tagged as changed.
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 DisconnectClient()
Function called from MIR when user closes one of the viewer window.
void ConnectClient()
Function called from MIR when user wants to stream unsubscribed view.
~REveViewer() override
Destructor.
void RemoveElementsLocal() override
Remove all children, forwarded to GLViewer.
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.
static const TString & GetDataDir()
Get the data directory in the installation. Static utility function.
Definition TROOT.cxx:3063
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
R__EXTERN REveManager * gEve