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
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//
108{
109 fAxesType = (EAxesType)at;
110 if (fAxesType != kAxesNone) {
111 std::string rf_dir = gSystem->ExpandPathName("${ROOTSYS}/fonts/");
112 REX::REveText::AssertSdfFont("LiberationSerif-Regular", rf_dir + "LiberationSerif-Regular.ttf");
113 }
115}
116
117////////////////////////////////////////////////////////////////////////////////
118//
120{
123}
124
125////////////////////////////////////////////////////////////////////////////////
126/// Stream Camera Info.
127/// Virtual from REveElement.
128int REveViewer::WriteCoreJson(nlohmann::json &j, Int_t rnr_offset)
129{
130 std::string ct;
131 switch (fCameraType)
132 {
133 case kCameraPerspXOZ: ct = "PerspXOZ"; break;
134 case kCameraOrthoXOY: ct = "OrthoXOY"; break;
135 }
136 j["CameraType"] = ct;
137 j["Mandatory"] = fMandatory;
138 j["AxesType"] = fAxesType;
139 j["BlackBg"] = fBlackBackground;
140
141 j["UT_PostStream"] = "UT_EveViewerUpdate";
142
143 return REveElement::WriteCoreJson(j, rnr_offset);
144}
145
146////////////////////////////////////////////////////////////////////////////////
147/// Function called from MIR when user closes one of the viewer window.
148// Client id stored in thread local data
150{
152}
153////////////////////////////////////////////////////////////////////////////////
154/// Function called from MIR when user wants to stream unsubscribed view.
155// Client id stored in thread local data
157{
158 gEve->ConnectEveViewer(this);
159}
160
161////////////////////////////////////////////////////////////////////////////////
162///
163// Set Flag if this viewer is presented on connect
165{
166 fMandatory = x;
167 for (auto &c : RefChildren()) {
168 REveSceneInfo *sinfo = dynamic_cast<REveSceneInfo *>(c);
170 }
171}
172
173////////////////////////////////////////////////////////////////////////////////
174
175REveViewerList::REveViewerList(const std::string &n, const std::string &t) :
176 REveElement (n, t),
177 fShowTooltip (kTRUE),
178
179 fBrightness(0),
180 fUseLightColorSet(kFALSE)
181{
182 // Constructor.
183
184 SetChildClass(TClass::GetClass<REveViewer>());
185 Connect();
186}
187
188////////////////////////////////////////////////////////////////////////////////
189/// Destructor.
190
192{
193 Disconnect();
194}
195
196////////////////////////////////////////////////////////////////////////////////
197/// Call base-class implementation.
198/// If compound is open and compound of the new element is not set,
199/// the el's compound is set to this.
200
202{
204}
205
206////////////////////////////////////////////////////////////////////////////////
207/// Decompoundofy el, call base-class version.
208
210{
211 // This was needed as viewer was in EveWindowManager hierarchy, too.
212 // el->DecParentIgnoreCnt();
213
215}
216
217////////////////////////////////////////////////////////////////////////////////
218/// Decompoundofy children, call base-class version.
219
221{
222 // This was needed as viewer was in EveWindowManager hierarchy, too.
223 // el->DecParentIgnoreCnt();
224 // for (auto &c: fChildren)
225 // {
226 // c->DecParentIgnoreCnt();
227 // }
228
230}
231
232////////////////////////////////////////////////////////////////////////////////
233/// Connect to TGLViewer class-signals.
234
236{
237 // TQObject::Connect("TGLViewer", "MouseOver(TObject*,UInt_t)",
238 // "REveViewerList", this, "OnMouseOver(TObject*,UInt_t)");
239
240 // TQObject::Connect("TGLViewer", "ReMouseOver(TObject*,UInt_t)",
241 // "REveViewerList", this, "OnReMouseOver(TObject*,UInt_t)");
242
243 // TQObject::Connect("TGLViewer", "UnMouseOver(TObject*,UInt_t)",
244 // "REveViewerList", this, "OnUnMouseOver(TObject*,UInt_t)");
245
246 // TQObject::Connect("TGLViewer", "Clicked(TObject*,UInt_t,UInt_t)",
247 // "REveViewerList", this, "OnClicked(TObject*,UInt_t,UInt_t)");
248
249 // TQObject::Connect("TGLViewer", "ReClicked(TObject*,UInt_t,UInt_t)",
250 // "REveViewerList", this, "OnReClicked(TObject*,UInt_t,UInt_t)");
251
252 // TQObject::Connect("TGLViewer", "UnClicked(TObject*,UInt_t,UInt_t)",
253 // "REveViewerList", this, "OnUnClicked(TObject*,UInt_t,UInt_t)");
254}
255
256////////////////////////////////////////////////////////////////////////////////
257/// Disconnect from TGLViewer class-signals.
258
260{
261 // TQObject::Disconnect("TGLViewer", "MouseOver(TObject*,UInt_t)",
262 // this, "OnMouseOver(TObject*,UInt_t)");
263
264 // TQObject::Disconnect("TGLViewer", "ReMouseOver(TObject*,UInt_t)",
265 // this, "OnReMouseOver(TObject*,UInt_t)");
266
267 // TQObject::Disconnect("TGLViewer", "UnMouseOver(TObject*,UInt_t)",
268 // this, "OnUnMouseOver(TObject*,UInt_t)");
269
270 // TQObject::Disconnect("TGLViewer", "Clicked(TObject*,UInt_t,UInt_t)",
271 // this, "OnClicked(TObject*,UInt_t,UInt_t)");
272
273 // TQObject::Disconnect("TGLViewer", "ReClicked(TObject*,UInt_t,UInt_t)",
274 // this, "OnReClicked(TObject*,UInt_t,UInt_t)");
275
276 // TQObject::Disconnect("TGLViewer", "UnClicked(TObject*,UInt_t,UInt_t)",
277 // this, "OnUnClicked(TObject*,UInt_t,UInt_t)");
278}
279
280////////////////////////////////////////////////////////////////////////////////
281/// Repaint viewers that are tagged as changed.
282
283void REveViewerList::RepaintChangedViewers(Bool_t /*resetCameras*/, Bool_t /*dropLogicals*/)
284{
285 //for (auto &c: fChildren) {
286 // TGLViewer* glv = ((REveViewer*)c)->GetGLViewer();
287 // if (glv->IsChanged())
288 // {
289 // if (resetCameras) glv->PostSceneBuildSetup(kTRUE);
290 // if (dropLogicals) glv->SetSmartRefresh(kFALSE);
291
292 // glv->RequestDraw(TGLRnrCtx::kLODHigh);
293
294 // if (dropLogicals) glv->SetSmartRefresh(kTRUE);
295 // }
296 //}
297}
298
299////////////////////////////////////////////////////////////////////////////////
300/// Repaint all viewers.
301
302void REveViewerList::RepaintAllViewers(Bool_t /*resetCameras*/, Bool_t /*dropLogicals*/)
303{
304 // for (auto &c: fChildren) {
305 // TGLViewer* glv = ((REveViewer *)c)->GetGLViewer();
306
307 // if (resetCameras) glv->PostSceneBuildSetup(kTRUE);
308 // if (dropLogicals) glv->SetSmartRefresh(kFALSE);
309
310 // glv->RequestDraw(TGLRnrCtx::kLODHigh);
311
312 // if (dropLogicals) glv->SetSmartRefresh(kTRUE);
313 // }
314}
315
316////////////////////////////////////////////////////////////////////////////////
317/// Delete annotations from all viewers.
318
320{
321 // for (auto &c: fChildren) {
322 // TGLViewer* glv = ((REveViewer *)c)->GetGLViewer();
323 // glv->DeleteOverlayAnnotations();
324 // }
325}
326
327////////////////////////////////////////////////////////////////////////////////
328/// Callback done from a REveScene destructor allowing proper
329/// removal of the scene from affected viewers.
330
332{
333 for (auto &viewer: fChildren) {
334 for (auto &j: viewer->RefChildren()) {
335 REveSceneInfo* sinfo = (REveSceneInfo *) j;
336 if (sinfo->GetScene() == scene)
337 viewer->RemoveElement(sinfo);
338 }
339 }
340}
341
342////////////////////////////////////////////////////////////////////////////////
343/// Show / hide tooltip for various MouseOver events.
344/// Must be called from slots where sender is TGLEventHandler.
345
347{
348 if (fShowTooltip)
349 {
350 // TGLViewer *glw = dynamic_cast<TGLViewer*>((TQObject*) gTQSender);
351 // TGLEventHandler *glh = (TGLEventHandler*) glw->GetEventHandler();
352 // if (REX::gEve->GetHighlight()->NumChildren() == 1)
353 // {
354 // TString title(REX::gEve->GetHighlight()->FirstChild()->GetHighlightTooltip());
355 // if ( ! title.IsNull())
356 // glh->TriggerTooltip(title);
357 // }
358 // else
359 // {
360 // glh->RemoveTooltip();
361 // }
362 }
363}
364
365////////////////////////////////////////////////////////////////////////////////
366/// Set color brightness.
367
369{
371}
372
373////////////////////////////////////////////////////////////////////////////////
374/// Switch background color.
375
377{
379 // To implement something along the lines of:
380 // BeginChanges on EveWorld; // Here or in the calling function
381 // for (auto &c: fChildren) {
382 // REveViewer* v = (REveViewer *)c;
383 // if ( fUseLightColorSet)
384 // c->UseLightColorSet();
385 // else
386 // c->UseDarkColorSet();
387 // }
388 // EndChanges on EveWorld;
389}
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
R__EXTERN TSystem * gSystem
Definition TSystem.h:561
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:43
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.
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1274
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
R__EXTERN REveManager * gEve