Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
REveElement.cxx
Go to the documentation of this file.
1// @(#)root/eve7:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007, 2018
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/REveElement.hxx>
13#include <ROOT/REveUtil.hxx>
14#include <ROOT/REveScene.hxx>
15#include <ROOT/REveCompound.hxx>
16#include <ROOT/REveTrans.hxx>
17#include <ROOT/REveManager.hxx>
22
23#include "TGeoMatrix.h"
24
25#include "TClass.h"
26#include "TPRegexp.h"
27#include "TROOT.h"
28#include "TBase64.h"
29#include "TColor.h"
30#include "TVirtualX.h"
31
32#include <cassert>
33#include <algorithm>
34#include <limits>
35#include <mutex>
36#include <set>
37
38#include <nlohmann/json.hpp>
39
40using namespace ROOT::Experimental;
41namespace REX = ROOT::Experimental;
42
43/** \class REveElement
44\ingroup REve
45Base class for REveUtil visualization elements, providing hierarchy
46management, rendering control and list-tree item management.
47
48Class of acceptable children can be limited by setting the
49fChildClass member.
50*/
51
52////////////////////////////////////////////////////////////////////////////////
53/// Default constructor.
54
55REveElement::REveElement(const std::string& name, const std::string& title) :
56 fName (name),
57 fTitle (title)
58{
59}
60
61////////////////////////////////////////////////////////////////////////////////
62/// Copy constructor. Does shallow copy.
63/// For deep-cloning and children-cloning, see:
64/// ~~~ {.cpp}
65/// REveElement* CloneElementRecurse(Int_t level)
66/// void CloneChildrenRecurse(REveElement* dest, Int_t level)
67/// ~~~
68/// 'void* UserData' is NOT copied.
69/// If the element is projectable, its projections are NOT copied.
70///
71/// Not implemented for most sub-classes, let us know.
72/// Note that sub-classes of REveProjected are NOT and will NOT be copyable.
73
75 fName (e.fName),
76 fTitle (e.fTitle),
77 fChildClass (e.fChildClass),
78 fVizTag (e.fVizTag),
79 fDestroyOnZeroRefCnt (e.fDestroyOnZeroRefCnt),
80 fRnrSelf (e.fRnrSelf),
81 fRnrChildren (e.fRnrChildren),
82 fCanEditMainColor (e.fCanEditMainColor),
83 fCanEditMainTransparency(e.fCanEditMainTransparency),
84 fCanEditMainTrans (e.fCanEditMainTrans),
85 fMainTransparency (e.fMainTransparency),
86 fPickable (e.fPickable),
87 fCSCBits (e.fCSCBits)
88{
89 SetVizModel(e.fVizModel);
90 // FIXME: from Sergey: one have to use other way to referencing main color
91 if (e.fMainColorPtr)
92 fMainColorPtr = (Color_t*)((const char*) this + ((const char*) e.fMainColorPtr - (const char*) &e));
93 if (e.fMainTrans)
94 fMainTrans = std::make_unique<REveTrans>(*e.fMainTrans.get());
95}
96
97////////////////////////////////////////////////////////////////////////////////
98/// Destructor. Do not call this method directly, either call Destroy() or
99/// Annihilate(). See also DestroyElements() and AnnihilateElements() if you
100/// need to delete all children of an element.
101
103{
105 {
108
109 if (fMother) {
111 fMother->fChildren.remove(this);
112 }
113
114 if (fScene) {
116 }
117
118 for (auto &au : fAunts)
119 {
120 au->RemoveNieceInternal(this);
121 }
122 }
123}
124
125// MIR execution variables and helper functions
126
127thread_local REveElement *REveElement::stlMirAlpha = nullptr;
128thread_local int REveElement::stlMirError = 0;
129thread_local std::string REveElement::stlMirErrorString;
130
132 stlMirAlpha = nullptr;
133 stlMirError = 0;
134 stlMirErrorString.clear();
135}
136
140
141void REveElement::SetMirError(int error, std::string_view err_str) {
142 stlMirError = error;
143 if ( ! err_str.empty()) {
144 AppendMirErrorString(err_str);
145 }
146}
147
148void REveElement::AppendMirErrorString(std::string_view err_str) {
149 if (stlMirErrorString.empty()) {
150 stlMirErrorString = err_str;
151 } else {
152 std::string s;
153 s.reserve(stlMirErrorString.size() + err_str.size() + 4);
154 s = err_str;
155 s += " :: ";
157 stlMirErrorString.swap(s);
158 }
159}
160
161// Element IDs etc
162
167
169{
170 return fScene ? fScene->GetElementId() : 0;
171}
172
174{
175 assert(fElementId == 0);
176
178 for (auto &c : fChildren)
179 c->assign_element_id_recurisvely();
180}
181
182std::string REveElement::GetHighlightTooltip(const std::set<int>& iSet) const
183{
184 std::string res = fTitle;
185 if (res.empty())
186 res = fName;
187
188 if (!iSet.empty())
189 res = TString::Format("%s idx=%d", res.c_str(), *iSet.begin());
190
191 return res;
192}
193
195{
196 assert(fScene == nullptr);
197
198 fScene = s;
199
200 // XXX MT -- Why do we have fDestructing here? Can this really happen?
201 // If yes, shouldn't we block it in AddElement() already?
203 {
205 }
206 for (auto &c : fChildren)
207 c->assign_scene_recursively(s);
208}
209
210////////////////////////////////////////////////////////////////////////////////
211/// Called before the element is deleted, thus offering the last chance
212/// to detach from acquired resources and from the framework itself.
213/// Here the request is just passed to REveManager.
214/// If you override it, make sure to call base-class version.
215
217{
218 if (fElementId != 0)
219 {
221 }
222}
223
224////////////////////////////////////////////////////////////////////////////////
225/// Clone the element via copy constructor.
226/// Should be implemented for all classes that require cloning support.
227
229{
230 return new REveElement(*this);
231}
232
233////////////////////////////////////////////////////////////////////////////////
234/// Clone elements and recurse 'level' deep over children.
235/// - If level == 0, only the element itself is cloned (default).
236/// - If level == -1, all the hierarchy is cloned.
237
239{
241 if (level--)
242 {
243 CloneChildrenRecurse(el, level);
244 }
245 return el;
246}
247
248////////////////////////////////////////////////////////////////////////////////
249/// Clone children and attach them to the dest element.
250/// If level == 0, only the direct descendants are cloned (default).
251/// If level == -1, all the hierarchy is cloned.
252
254{
255 for (auto &c: fChildren)
256 dest->AddElement(c->CloneElementRecurse(level));
257}
258
259
260//==============================================================================
261
262////////////////////////////////////////////////////////////////////////////////
263/// Set name of an element.
264
265void REveElement::SetName(const std::string& name)
266{
267 fName = name;
269}
270
271////////////////////////////////////////////////////////////////////////////////
272/// Set title of an element.
273
274void REveElement::SetTitle(const std::string& title)
275{
276 fTitle = title;
278}
279
280////////////////////////////////////////////////////////////////////////////////
281/// Set name and title of an element.
282/// Here we attempt to cast the assigned object into TNamed and call
283/// SetNameTitle() there.
284/// If you override this call NameTitleChanged() from there.
285
286void REveElement::SetNameTitle(const std::string& name, const std::string& title)
287{
288 fName = name;
289 fTitle = title;
291}
292
293////////////////////////////////////////////////////////////////////////////////
294/// Virtual function called when a name or title of the element has
295/// been changed. Stamps kCBCoreJson, which streams both to the client.
296/// If you override this, call also the version of your direct base-class.
297
302
303////////////////////////////////////////////////////////////////////////////////
304/// Set visualization-parameter model element.
305/// Calling of this function from outside of EVE should in principle
306/// be avoided as it can lead to dis-synchronization of viz-tag and
307/// viz-model.
308
310{
311 fVizModel = model;
312}
313
314////////////////////////////////////////////////////////////////////////////////
315/// Find model element in VizDB that corresponds to previously
316/// assigned fVizTag and set fVizModel accordingly.
317/// If the tag is not found in VizDB, the old model-element is kept
318/// and false is returned.
319
321{
323 if (model)
324 {
325 SetVizModel(model);
326 return kTRUE;
327 }
328 else
329 {
330 return kFALSE;
331 }
332}
333
334////////////////////////////////////////////////////////////////////////////////
335/// Set the VizTag, find model-element from the VizDB and copy
336/// visualization-parameters from it. If the model is not found and
337/// fallback_tag is non-null, search for it is attempted as well.
338/// For example: ApplyVizTag("TPC Clusters", "Clusters");
339///
340/// If the model-element can not be found a warning is printed and
341/// false is returned.
342
343Bool_t REveElement::ApplyVizTag(const TString& tag, const TString& fallback_tag)
344{
345 REveElement* model;
346
347 if ((model = REX::gEve->FindVizDBEntry(tag)) != nullptr)
348 {
349 SetVizTag(tag);
350 }
351 else if ( ! fallback_tag.IsNull() && (model = REX::gEve->FindVizDBEntry(fallback_tag)) != nullptr)
352 {
353 SetVizTag(fallback_tag);
354 }
355
356 if (model)
357 {
358 SetVizModel(model);
360 return true;
361 }
362 Warning("REveElement::ApplyVizTag", "entry for tag '%s' not found in VizDB.", tag.Data());
363 return false;
364}
365
366////////////////////////////////////////////////////////////////////////////////
367/// Propagate visualization parameters to dependent elements.
368///
369/// MainColor is propagated independently in SetMainColor().
370/// In this case, as fMainColor is a pointer to Color_t, it should
371/// be set in TProperClass::CopyVizParams().
372///
373/// Render state is not propagated. Maybe it should be, at least optionally.
374
376{
377 REveProjectable* pable = dynamic_cast<REveProjectable*>(this);
378 if (pable && pable->HasProjecteds())
379 {
380 pable->PropagateVizParams();
381 }
382}
383
384////////////////////////////////////////////////////////////////////////////////
385/// Propagate visualization parameters from element el (defaulting
386/// to this) to all children.
387///
388/// The primary use of this is for model-elements from
389/// visualization-parameter database.
390
392{
393 if (!el) el = this;
394
395 for (auto &c : fChildren)
396 {
397 c->CopyVizParams(el);
398 }
399}
400
401////////////////////////////////////////////////////////////////////////////////
402/// Copy visualization parameters from element el.
403/// This method needs to be overriden by any class that introduces
404/// new parameters.
405
415
416////////////////////////////////////////////////////////////////////////////////
417/// Copy visualization parameters from the model-element fVizModel.
418/// A warning is printed if the model-element fVizModel is not set.
419
421{
422 if (fVizModel)
423 {
425 }
426 else
427 {
428 Warning("REveElement::CopyVizParamsFromDB", "VizModel has not been set.");
429 }
430}
431
432////////////////////////////////////////////////////////////////////////////////
433/// Save visualization parameters for this element with given tag.
434///
435/// This function creates the instantiation code, calls virtual
436/// WriteVizParams() and, at the end, writes out the code for
437/// registration of the model into the VizDB.
438
439void REveElement::SaveVizParams(std::ostream& out, const TString& tag, const TString& var)
440{
441 static const REveException eh("REveElement::GetObject ");
442
443 TString t = " ";
444 TString cls(IsA()->GetName());
445
446 out << "\n";
447
448 TString intro = " TAG='" + tag + "', CLASS='" + cls + "'";
449 out << " //" << intro << "\n";
450 out << " //" << TString('-', intro.Length()) << "\n";
451 out << t << cls << "* " << var <<" = new " << cls << ";\n";
452
453 WriteVizParams(out, var);
454
455 out << t << "REX::gEve->InsertVizDBEntry(\"" << tag << "\", "<< var <<");\n";
456}
457
458////////////////////////////////////////////////////////////////////////////////
459/// Write-out visual parameters for this object.
460/// This is a virtual function and all sub-classes are required to
461/// first call the base-element version.
462/// The name of the element pointer is 'x%03d', due to historical CINT limitations.
463/// Three spaces should be used for indentation, same as in
464/// SavePrimitive() methods.
465
466void REveElement::WriteVizParams(std::ostream& out, const TString& var)
467{
468 TString t = " " + var + "->";
469
470 out << t << "SetElementName(\"" << fName << "\");\n";
471 out << t << "SetElementTitle(\"" << fTitle << "\");\n";
472 out << t << "SetEditMainColor(" << fCanEditMainColor << ");\n";
473 out << t << "SetEditMainTransparency(" << fCanEditMainTransparency << ");\n";
474 out << t << "SetMainTransparency(" << fMainTransparency << ");\n";
475}
476
477////////////////////////////////////////////////////////////////////////////////
478/// Set visual parameters for this object for given tag.
479
480void REveElement::VizDB_Apply(const std::string& tag)
481{
482 if (ApplyVizTag(tag))
483 {
485 }
486}
487
488////////////////////////////////////////////////////////////////////////////////
489/// Reset visual parameters for this object from VizDB.
490/// The model object must be already set.
491
500
501////////////////////////////////////////////////////////////////////////////////
502/// Copy visual parameters from this element to viz-db model.
503/// If update is set, all clients of the model will be updated to
504/// the new value.
505/// A warning is printed if the model-element fVizModel is not set.
506
508{
509 if (fVizModel)
510 {
512 if (update)
513 {
514 // XXX Back references from vizdb templates have been removed in Eve7.
515 // XXX We could traverse all scenes and elementes and reset those that
516 // XXX have a matching fVizModel. Or something.
517 Error("VizDB_UpdateModel", "update from vizdb -> elements not implemented.");
518 // fVizModel->PropagateVizParamsToElements(fVizModel);
519 }
520 }
521 else
522 {
523 Warning("VizDB_UpdateModel", "VizModel has not been set.");
524 }
525}
526
527////////////////////////////////////////////////////////////////////////////////
528/// Create a replica of element and insert it into VizDB with given tag.
529/// If replace is true an existing element with the same tag will be replaced.
530/// If update is true, existing client of tag will be updated.
531
532void REveElement::VizDB_Insert(const std::string& tag, Bool_t replace, Bool_t update)
533{
534 static const REveException eh("REveElement::GetObject ");
535
536 TClass* cls = IsA();
537 REveElement* el = reinterpret_cast<REveElement*>(cls->New());
538 if (!el) {
539 Error("VizDB_Insert", "Creation of replica failed.");
540 return;
541 }
542 el->CopyVizParams(this);
543 REX::gEve->InsertVizDBEntry(tag, el, replace, update);
544}
545
546////////////////////////////////////////////////////////////////////////////////
547/// Add el into the list aunts.
548///
549/// Adding aunt is subordinate to adding a niece.
550/// This is an internal function.
551
553{
554 assert(au != nullptr);
555
556 fAunts.emplace_back(au);
557}
558
559////////////////////////////////////////////////////////////////////////////////
560/// Remove el from the list of aunts.
561/// Removing aunt is subordinate to removing a niece.
562/// This is an internal function.
563
565{
566 assert(au != nullptr);
567
568 fAunts.remove(au);
569}
570
571/******************************************************************************/
572
573////////////////////////////////////////////////////////////////////////////////
574/// Check external references to this and eventually auto-destruct
575/// the render-element.
576
577void REveElement::CheckReferenceCount(const std::string& from)
578{
579 if (fDestructing != kNone)
580 return;
581
582 if (fMother == nullptr && fDestroyOnZeroRefCnt && fDenyDestroy <= 0)
583 {
584 if (gDebug > 0)
585 Info("REveElement::CheckReferenceCount", "(called from %s) auto-destructing '%s' on zero reference count.",
586 from.c_str(), GetCName());
587
589 delete this;
590 }
591}
592
593////////////////////////////////////////////////////////////////////////////////
594/// Return class for this element
595/// Return REveElement class in case dicitonary is not exisiting
596////////////////////////////////////////////////////////////////////////////////
597
599{
600 TClass* res = TClass::GetClass(typeid(*this), kTRUE, kTRUE);
601 if (!res) {
602 R__LOG_WARNING(REveLog()) << "REveElement::IsA() no dictionary found for " << typeid(*this).name();
603 res = TClass::GetClass("ROOT::Experimental::REveElement");
604 }
605 return res;
606}
607
608////////////////////////////////////////////////////////////////////////////////
609/// Export render-element to Cling with variable name var_name.
610
611void REveElement::ExportToInterpreter(const char *var_name)
612{
613 const char* cname = IsA()->GetName();
614 gROOT->ProcessLine(TString::Format("%s* %s = (%s*)0x%zx;", cname, var_name, cname, (size_t)this));
615}
616
617////////////////////////////////////////////////////////////////////////////////
618/// Set render state of this element, i.e. if it will be published
619/// on next scene update pass.
620/// Returns true if the state has changed.
621
623{
624 if (SingleRnrState())
625 {
626 return SetRnrState(rnr);
627 }
628
629 if (rnr != fRnrSelf)
630 {
631 fRnrSelf = rnr;
634
635 return kTRUE;
636 }
637 return kFALSE;
638}
639
640////////////////////////////////////////////////////////////////////////////////
641/// Set render state of this element's children, i.e. if they will
642/// be published on next scene update pass.
643/// Returns true if the state has changed.
644
646{
647 if (SingleRnrState())
648 {
649 return SetRnrState(rnr);
650 }
651
652 if (rnr != fRnrChildren)
653 {
654 fRnrChildren = rnr;
657 return kTRUE;
658 }
659 return kFALSE;
660}
661
662////////////////////////////////////////////////////////////////////////////////
663/// Set state for rendering of this element and its children.
664/// Returns true if the state has changed.
665
667{
668 if (SingleRnrState())
669 {
670 return SetRnrState(rnr_self);
671 }
672
673 if (fRnrSelf != rnr_self || fRnrChildren != rnr_children)
674 {
675 fRnrSelf = rnr_self;
676 fRnrChildren = rnr_children;
679 return kTRUE;
680 }
681 return kFALSE;
682}
683
684////////////////////////////////////////////////////////////////////////////////
685/// Set render state of this element and of its children to the same
686/// value.
687/// Returns true if the state has changed.
688
690{
691 if (fRnrSelf != rnr || fRnrChildren != rnr)
692 {
693 fRnrSelf = fRnrChildren = rnr;
696 return kTRUE;
697 }
698 return kFALSE;
699}
700
701////////////////////////////////////////////////////////////////////////////////
702/// Propagate render state to the projected replicas of this element.
703/// Maybe this should be optional on REX::gEve/element level.
704
706{
707 REveProjectable *pable = dynamic_cast<REveProjectable*>(this);
708 if (pable && pable->HasProjecteds())
709 {
711 }
712}
713
714////////////////////////////////////////////////////////////////////////////////
715/// Set up element to use built-in main color and set flags allowing editing
716/// of main color and transparency.
717
718void REveElement::SetupDefaultColorAndTransparency(Color_t col, Bool_t can_edit_color, Bool_t can_edit_transparency)
719{
721 fDefaultColor = col;
722 fCanEditMainColor = can_edit_color;
723 fCanEditMainTransparency = can_edit_transparency;
724}
725
726////////////////////////////////////////////////////////////////////////////////
727/// Set main color of the element.
728
730{
731 Color_t old_color = GetMainColor();
732
733 if (fMainColorPtr)
734 {
735 *fMainColorPtr = color;
737 }
738
739 PropagateMainColorToProjecteds(color, old_color);
740}
741
742////////////////////////////////////////////////////////////////////////////////
743/// Convert pixel to Color_t and call SetMainColor().
744
749
750////////////////////////////////////////////////////////////////////////////////
751/// Convert RGB values to Color_t and call SetMainColor.
752
757
758////////////////////////////////////////////////////////////////////////////////
759/// Convert RGB values to Color_t and call SetMainColor.
760
765
766////////////////////////////////////////////////////////////////////////////////
767/// Propagate color to projected elements.
768
770{
771 REveProjectable* pable = dynamic_cast<REveProjectable*>(this);
772 if (pable && pable->HasProjecteds())
773 {
774 pable->PropagateMainColor(color, old_color);
775 }
776}
777
778////////////////////////////////////////////////////////////////////////////////
779/// Set main-transparency.
780/// Transparency is clamped to [0, 100].
781
783{
784 Char_t old_t = GetMainTransparency();
785
786 if (t > 100) t = 100;
789
791}
792
793////////////////////////////////////////////////////////////////////////////////
794/// Set main-transparency via float alpha variable.
795/// Value of alpha is clamped t0 [0, 1].
796
798{
799 if (alpha < 0) alpha = 0;
800 if (alpha > 1) alpha = 1;
801 SetMainTransparency((Char_t) (100.0f*(1.0f - alpha)));
802}
803
804////////////////////////////////////////////////////////////////////////////////
805/// Propagate transparency to projected elements.
806
808{
809 REveProjectable* pable = dynamic_cast<REveProjectable*>(this);
810 if (pable && pable->HasProjecteds())
811 {
812 pable->PropagateMainTransparency(t, old_t);
813 }
814}
815
816////////////////////////////////////////////////////////////////////////////////
817/// Return pointer to main transformation. If 'create' flag is set (default)
818/// it is created if not yet existing.
819
821{
822 if (!fMainTrans && create)
824
825 return fMainTrans.get();
826}
827
828////////////////////////////////////////////////////////////////////////////////
829/// Return reference to main transformation. It is created if not yet
830/// existing.
831
833{
834 if (!fMainTrans)
836
837 return *fMainTrans.get();
838}
839
840////////////////////////////////////////////////////////////////////////////////
841/// Initialize the main transformation to identity matrix, without motion.
842/// If can_edit is true (default), the user will be able to edit the
843/// transformation parameters via GUI.
844
846{
847 if (fMainTrans) {
848 fMainTrans->UnitTrans();
849 fMainTrans->ClearMotion();
850 } else {
851 fMainTrans = std::make_unique<REveTrans>();
852 }
853 fCanEditMainTrans = can_edit;
854 StampTrans();
855}
856
857////////////////////////////////////////////////////////////////////////////////
858/// Destroy the main transformation matrix, it will always be taken
859/// as identity. Editing of transformation parameters is disabled.
860/// The motion goes with it.
861
863{
864 fMainTrans.reset(nullptr);
866 StampTrans();
867}
868
869////////////////////////////////////////////////////////////////////////////////
870/// Set transformation matrix from column-major array.
871
873{
874 RefMainTrans().SetFrom(carr);
875 StampTrans();
876}
877
878////////////////////////////////////////////////////////////////////////////////
879/// Set transformation matrix from TGeo's matrix.
880
882{
883 RefMainTrans().SetFrom(mat);
884 StampTrans();
885}
886
887////////////////////////////////////////////////////////////////////////////////
888/// Compose into `t` the matrices of this element and of its mothers up to,
889/// not including, its REveScene: the frame the client draws the element in.
890/// Returns the number of matrices; `t` is set only when it is non-zero.
891
893{
894 Int_t n = 0;
895 for (const REveElement *el = this; el && !dynamic_cast<const REveScene *>(el); el = el->fMother) {
896 if (const REveTrans *m = el->fMainTrans.get()) {
897 if (n++ == 0)
898 t = *m;
899 else
900 t.MultLeft(*m);
901 }
902 }
903 return n;
904}
905
906////////////////////////////////////////////////////////////////////////////////
907/// Check if el can be added to this element.
908///
909/// Here we make sure the new child is not equal to this and, if fChildClass
910/// is set, that it is inherited from it.
911
913{
914 if (el == this)
915 return kFALSE;
916 if (fChildClass && ! el->IsA()->InheritsFrom(fChildClass))
917 return kFALSE;
918 return kTRUE;
919}
920
921////////////////////////////////////////////////////////////////////////////////
922/// Add el to the list of children.
923
925{
926 static const REveException eh("REveElement::AddElement ");
927
928 if (!el) throw eh + "called with nullptr argument.";
929 if ( ! AcceptElement(el)) throw eh + Form("parent '%s' rejects '%s'.", GetCName(), el->GetCName());
930 if (el->fElementId) throw eh + "element already has an id.";
931 // if (el->fScene) throw eh + "element already has a Scene.";
932 if (el->fMother) throw eh + "element already has a Mother.";
933
934 // XXX Implement reparent --> MoveElement() ????
935 // Actually, better to do new = old.Clone(), RemoveElement(old), AddElement(new);
936 // Or do magick with Inc/DecDenyDestroy().
937 // PITA with existing children !!!! Need to re-scene them.
938
940 if (fScene && ! el->fScene) el->assign_scene_recursively(fScene);
941
942 el->fMother = this;
943
944 fChildren.emplace_back(el);
945
946 // XXXX This should be element added. Also, should be different for
947 // "full (re)construction". Scenes should manage that and have
948 // state like: none - constructing - clearing - nominal - updating.
949 // I recon this means an element should have a ptr to its scene.
950 //
951 // ElementChanged();
952}
953
954////////////////////////////////////////////////////////////////////////////////
955/// Remove el from the list of children.
956
958{
959 static const REveException eh("REveElement::RemoveElement ");
960
961 if (!el) throw eh + "called with nullptr argument.";
962 if (el->fMother != this) throw eh + "this element is not mother of el.";
963
965
967 el->fMother = nullptr;
968 el->fScene = nullptr;
969
971
972 fChildren.remove(el);
973
974 // XXXX This should be ElementRemoved(). Also, think about recursion, deletion etc.
975 // Also, this seems to be done above, in the call to fScene.
976 //
977 // ElementChanged();
978}
979
980////////////////////////////////////////////////////////////////////////////////
981/// Perform additional local removal of el.
982/// Called from RemoveElement() which does whole untangling.
983/// Put into special function as framework-related handling of
984/// element removal should really be common to all classes and
985/// clearing of local structures happens in between removal
986/// of list-tree-items and final removal.
987/// If you override this, you should also override
988/// RemoveElementsLocal().
989
993
994////////////////////////////////////////////////////////////////////////////////
995/// Remove all elements. This assumes removing of all elements can
996/// be done more efficiently then looping over them and removing one
997/// by one. This protected function performs the removal on the
998/// level of REveElement.
999
1001{
1003
1004 for (auto &c : fChildren)
1005 {
1006 c->fScene->SceneElementRemoved(c->fElementId);
1007 c->fMother = nullptr;
1008 c->fScene = nullptr;
1009
1010 c->CheckReferenceCount();
1011 }
1012
1013 fChildren.clear();
1014}
1015
1016////////////////////////////////////////////////////////////////////////////////
1017/// Remove all elements. This assumes removing of all elements can
1018/// be done more efficiently then looping over them and removing
1019/// them one by one.
1020
1022{
1023 if (HasChildren())
1024 {
1026 // ElementChanged();
1027 }
1028}
1029
1030////////////////////////////////////////////////////////////////////////////////
1031/// Perform additional local removal of all elements.
1032/// See comment to RemoveElementLocal(REveElement*).
1033
1037
1038////////////////////////////////////////////////////////////////////////////////
1039/// If this is a projectable, loop over all projected replicas and
1040/// add the projected image of child 'el' there. This is supposed to
1041/// be called after you add a child to a projectable after it has
1042/// already been projected.
1043/// You might also want to call RecheckImpliedSelections() on this
1044/// element or 'el'.
1045///
1046/// If 'same_depth' flag is true, the same depth as for parent object
1047/// is used in every projection. Otherwise current depth of each
1048/// relevant projection-manager is used.
1049
1051{
1052 REveProjectable* pable = dynamic_cast<REveProjectable*>(this);
1053 if (pable && HasChild(el))
1054 {
1055 for (auto &pp: pable->RefProjecteds())
1056 {
1057 auto pmgr = pp->GetManager();
1058 Float_t cd = pmgr->GetCurrentDepth();
1059 if (same_depth) pmgr->SetCurrentDepth(pp->GetDepth());
1060
1061 pmgr->SubImportElements(el, pp->GetProjectedAsElement());
1062
1063 if (same_depth) pmgr->SetCurrentDepth(cd);
1064 }
1065 }
1066}
1067
1068////////////////////////////////////////////////////////////////////////////////
1069/// If this is a projectable, loop over all projected replicas and
1070/// add the projected image of all children there. This is supposed
1071/// to be called after you destroy all children and then add new
1072/// ones after this element has already been projected.
1073/// You might also want to call RecheckImpliedSelections() on this
1074/// element.
1075///
1076/// If 'same_depth' flag is true, the same depth as for the
1077/// projected element is used in every projection. Otherwise current
1078/// depth of each relevant projection-manager is used.
1079
1081{
1082 REveProjectable* pable = dynamic_cast<REveProjectable*>(this);
1083 if (pable)
1084 {
1085 for (auto &pp: pable->RefProjecteds())
1086 {
1087 REveProjectionManager *pmgr = pp->GetManager();
1088 Float_t cd = pmgr->GetCurrentDepth();
1089 if (same_depth) pmgr->SetCurrentDepth(pp->GetDepth());
1090
1091 pmgr->SubImportChildren(this, pp->GetProjectedAsElement());
1092
1093 if (same_depth) pmgr->SetCurrentDepth(cd);
1094 }
1095 }
1096}
1097
1098////////////////////////////////////////////////////////////////////////////////
1099/// Check if element el is a child of this element.
1100
1102{
1103 return (std::find(fChildren.begin(), fChildren.end(), el) != fChildren.end());
1104}
1105
1106////////////////////////////////////////////////////////////////////////////////
1107/// Find the first child with given name. If cls is specified (non
1108/// 0), it is also checked.
1109///
1110/// Returns nullptr if not found.
1111
1113{
1114 for (auto &c: fChildren)
1115 {
1116 if (name.CompareTo(c->GetCName()) == 0)
1117 {
1118 if (!cls || c->IsA()->InheritsFrom(cls))
1119 return c;
1120 }
1121 }
1122 return nullptr;
1123}
1124
1125////////////////////////////////////////////////////////////////////////////////
1126/// Find the first child whose name matches regexp. If cls is
1127/// specified (non 0), it is also checked.
1128///
1129/// Returns nullptr if not found.
1130
1132{
1133 for (auto &c: fChildren)
1134 {
1135 if (regexp.MatchB(c->GetName()))
1136 {
1137 if (!cls || c->IsA()->InheritsFrom(cls))
1138 return c;
1139 }
1140 }
1141 return nullptr;
1142}
1143
1144////////////////////////////////////////////////////////////////////////////////
1145/// Find all children with given name and append them to matches
1146/// list. If class is specified (non 0), it is also checked.
1147///
1148/// Returns number of elements added to the list.
1149
1151 const TString& name, const TClass* cls)
1152{
1153 Int_t count = 0;
1154 for (auto &c: fChildren)
1155 {
1156 if (name.CompareTo(c->GetCName()) == 0)
1157 {
1158 if (!cls || c->IsA()->InheritsFrom(cls))
1159 {
1160 matches.push_back(c);
1161 ++count;
1162 }
1163 }
1164 }
1165 return count;
1166}
1167
1168////////////////////////////////////////////////////////////////////////////////
1169/// Find all children whose name matches regexp and append them to
1170/// matches list.
1171///
1172/// Returns number of elements added to the list.
1173
1175 TPRegexp &regexp, const TClass *cls)
1176{
1177 Int_t count = 0;
1178 for (auto &c : fChildren)
1179 {
1180 if (regexp.MatchB(c->GetCName()))
1181 {
1182 if (!cls || c->IsA()->InheritsFrom(cls))
1183 {
1184 matches.push_back(c);
1185 ++count;
1186 }
1187 }
1188 }
1189 return count;
1190}
1191
1192////////////////////////////////////////////////////////////////////////////////
1193/// Returns the first child element or 0 if the list is empty.
1194
1196{
1197 return HasChildren() ? fChildren.front() : nullptr;
1198}
1199
1200////////////////////////////////////////////////////////////////////////////////
1201/// Returns the last child element or 0 if the list is empty.
1202
1204{
1205 return HasChildren() ? fChildren.back() : nullptr;
1206}
1207
1208////////////////////////////////////////////////////////////////////////////////
1209/// Enable rendering of children and their list contents.
1210/// Arguments control how to set self/child rendering.
1211
1213{
1214 for (auto &c: fChildren)
1215 c->SetRnrSelfChildren(rnr_self, rnr_children);
1216}
1217
1218////////////////////////////////////////////////////////////////////////////////
1219/// Disable rendering of children and their list contents.
1220/// Arguments control how to set self/child rendering.
1221///
1222/// Same as above function, but default arguments are different. This
1223/// is convenient for calls via context menu.
1224
1226{
1227 for (auto &c: fChildren)
1228 c->SetRnrSelfChildren(rnr_self, rnr_children);
1229}
1230
1231////////////////////////////////////////////////////////////////////////////////
1232/// Protected member function called from REveElement::Annihilate().
1233
1235{
1236 // projected were already destroyed in REveElement::Anihilate(), now only clear its list
1237 REveProjectable* pable = dynamic_cast<REveProjectable*>(this);
1238 if (pable && pable->HasProjecteds())
1239 pable->ClearProjectedList();
1240
1241 // same as REveElement::RemoveElementsInternal(), except parents are ignored
1243 for (auto &c : fChildren)
1244 c->AnnihilateRecursively();
1245
1246 fChildren.clear();
1247
1250
1251 delete this;
1252}
1253
1254////////////////////////////////////////////////////////////////////////////////
1255/// Optimized destruction without check of reference-count.
1256/// Parents are not notified about child destruction.
1257/// The method should only be used when an element does not have
1258/// more than one parent -- otherwise an exception is thrown.
1259
1261{
1262 static const REveException eh("REveElement::Annihilate ");
1263
1265
1266 // recursive annihilation of projecteds
1267 REveProjectable* pable = dynamic_cast<REveProjectable*>(this);
1268 if (pable && pable->HasProjecteds())
1269 {
1270 pable->AnnihilateProjecteds();
1271 }
1272
1273 // detach from the parent
1274 if (fMother)
1275 {
1276 fMother->RemoveElement(this);
1277 }
1278
1279 // XXXX wont the above already start off the destruction cascade ?????
1280
1282
1283 // XXXX ????? Annihilate flag ???? Is it different than regular remove ????
1284}
1285
1286////////////////////////////////////////////////////////////////////////////////
1287/// Annihilate elements.
1288
1290{
1291 while (!fChildren.empty())
1292 {
1293 auto c = fChildren.front();
1294 c->Annihilate();
1295 }
1296}
1297
1298////////////////////////////////////////////////////////////////////////////////
1299/// Destroy this element. Throws an exception if deny-destroy is in force.
1300/// This method should be called instead of a destructor.
1301/// Note that an exception will be thrown if the element has been
1302/// protected against destruction with IncDenyDestroy().
1303
1305{
1306 static const REveException eh("REveElement::Destroy ");
1307
1308 if (fDenyDestroy > 0)
1309 throw eh + TString::Format("element '%s' (%s*) %p is protected against destruction.",
1310 GetCName(), IsA()->GetName(), this);
1311
1313 delete this;
1314}
1315
1316////////////////////////////////////////////////////////////////////////////////
1317/// Destroy this element. Prints a warning if deny-destroy is in force.
1318
1320{
1321 try
1322 {
1323 Destroy();
1324 }
1325 catch (REveException &exc)
1326 {
1327 ::Warning("REveElement::DestroyOrWarn", "Error while destroy element %p : %s", this, exc.what());
1328 }
1329}
1330
1331////////////////////////////////////////////////////////////////////////////////
1332/// Destroy all children of this element.
1333
1335{
1336 while (HasChildren())
1337 {
1338 auto c = fChildren.front();
1339 if (c->fDenyDestroy <= 0)
1340 {
1341 try {
1342 c->Destroy();
1343 }
1344 catch (REveException &exc) {
1345 ::Warning("REveElement::DestroyElements", "element destruction failed: '%s'.", exc.what());
1347 }
1348 }
1349 else
1350 {
1351 if (gDebug > 0)
1352 ::Info("REveElement::DestroyElements", "element '%s' is protected against destruction, removing locally.", c->GetCName());
1354 }
1355 }
1356}
1357
1358////////////////////////////////////////////////////////////////////////////////
1359/// Returns state of flag determining if the element will be
1360/// destroyed when reference count reaches zero.
1361/// This is true by default.
1362
1367
1368////////////////////////////////////////////////////////////////////////////////
1369/// Sets the state of flag determining if the element will be
1370/// destroyed when reference count reaches zero.
1371/// This is true by default.
1372
1377
1378////////////////////////////////////////////////////////////////////////////////
1379/// Returns the number of times deny-destroy has been requested on
1380/// the element.
1381
1383{
1384 return fDenyDestroy;
1385}
1386
1387////////////////////////////////////////////////////////////////////////////////
1388/// Increases the deny-destroy count of the element.
1389/// Call this if you store an external pointer to the element.
1390
1395
1396////////////////////////////////////////////////////////////////////////////////
1397/// Decreases the deny-destroy count of the element.
1398/// Call this after releasing an external pointer to the element.
1399
1401{
1402 if (--fDenyDestroy <= 0)
1403 CheckReferenceCount("REveElement::DecDenyDestroy ");
1404}
1405
1406////////////////////////////////////////////////////////////////////////////////
1407/// Set pickable state on the element and all its children.
1408
1410{
1411 fPickable = p;
1412 for (auto &c: fChildren)
1413 c->SetPickableRecursively(p);
1414}
1415
1416////////////////////////////////////////////////////////////////////////////////
1417/// Returns the master element - that is:
1418/// - master of projectable, if this is a projected;
1419/// - master of compound, if fCompound is set;
1420/// - master of mother, if kSCBTakeMotherAsMaster bit is set;
1421/// If non of the above is true, *this* is returned.
1422
1424{
1426
1427 REveProjected* proj = dynamic_cast<REveProjected*>(this);
1428 if (proj)
1429 {
1430 return dynamic_cast<REveElement*>(proj->GetProjectable())->GetSelectionMaster();
1431 }
1432 if (fCompound)
1433 {
1434 return fCompound->GetSelectionMaster();
1435 }
1437 {
1438 return fMother->GetSelectionMaster();
1439 }
1440 return this;
1441}
1442
1443////////////////////////////////////////////////////////////////////////////////
1444/// Populate set impSelSet with derived / dependant elements.
1445///
1446/// If this is a REveProjectable, the projected replicas are added
1447/// to the set. Thus it does not have to be reimplemented for each
1448/// sub-class of REveProjected.
1449///
1450/// Note that this also takes care of projections of REveCompound
1451/// class, which is also a projectable.
1452
1453void REveElement::FillImpliedSelectedSet(Set_t &impSelSet, const std::set<int>&)
1454{
1455 REveProjectable* p = dynamic_cast<REveProjectable*>(this);
1456 if (p)
1457 p->AddProjectedsToSet(impSelSet);
1458}
1459
1460////////////////////////////////////////////////////////////////////////////////
1461/// Call this if it is possible that implied-selection or highlight
1462/// has changed for this element or for implied-selection this
1463/// element is member of and you want to maintain consistent
1464/// selection state.
1465/// This can happen if you add elements into compounds in response
1466/// to user-interaction.
1467
1469{
1470 // XXXX MT 2019-01 --- RecheckImpliedSelections
1471 //
1472 // With removal of selection state from this class there might be some
1473 // corner cases requiring checking of implied-selected state in
1474 // selection/highlight objects.
1475 //
1476 // This could be done as part of begin / end changes on the EveManager level.
1477 //
1478 // See also those functions in TEveSelection.
1479
1480 // if (fSelected || fImpliedSelected)
1481 // REX::gEve->GetSelection()->RecheckImpliedSetForElement(this);
1482
1483 // if (fHighlighted || fImpliedHighlighted)
1484 // REX::gEve->GetHighlight()->RecheckImpliedSetForElement(this);
1485}
1486
1487////////////////////////////////////////////////////////////////////////////////
1488/// Add (bitwise or) given stamps to fChangeBits.
1489/// Register this element to REX::gEve as stamped.
1490/// This method is virtual so that sub-classes can add additional
1491/// actions. The base-class method should still be called (or replicated).
1492
1494{
1495 if (bits & kCBObjProps)
1497
1499 {
1500 if (gDebug > 0)
1501 ::Info(Form("%s::AddStamp", GetCName()), "%d + (%d) -> %d", fChangeBits, bits, fChangeBits | bits);
1502
1503 if (fChangeBits == 0)
1504 {
1506 }
1507
1508 fChangeBits |= bits;
1509 }
1510}
1511
1512////////////////////////////////////////////////////////////////////////////////
1513/// Start filling the bounding box with BBoxCheckPoint(): min at +infinity,
1514/// max at -infinity, so the first point sets both. A box that no point
1515/// reached stays inverted, and AssertBBox() reports it as kBBoxNone.
1516
1518{
1519 const Float_t inf = std::numeric_limits<Float_t>::infinity();
1520 fBBoxMin.Set(inf, inf, inf);
1521 fBBoxMax.Set(-inf, -inf, -inf);
1523}
1524
1525////////////////////////////////////////////////////////////////////////////////
1526/// Set the bounding box to a cube of half-side `epsilon` at (`x`, `y`, `z`);
1527/// with the defaults, a point at the origin.
1528
1530{
1531 fBBoxMin.Set(x - epsilon, y - epsilon, z - epsilon);
1532 fBBoxMax.Set(x + epsilon, y + epsilon, z + epsilon);
1534}
1535
1536////////////////////////////////////////////////////////////////////////////////
1537/// Widen every side of the bounding box shorter than `epsilon` to `epsilon`,
1538/// keeping its centre.
1539
1541{
1542 if (fBBoxMin.fX > fBBoxMax.fX)
1543 return; // empty, see BBoxInit()
1544 for (Int_t i = 0; i < 3; ++i) {
1545 if (fBBoxMax[i] - fBBoxMin[i] < epsilon) {
1546 Float_t c = 0.5f * (fBBoxMin[i] + fBBoxMax[i]);
1547 fBBoxMin[i] = c - 0.5f * epsilon;
1548 fBBoxMax[i] = c + 0.5f * epsilon;
1549 }
1550 }
1551}
1552
1553////////////////////////////////////////////////////////////////////////////////
1554/// Compute the bounding box in the element's own frame, before fMainTrans.
1555/// Overrides fill it with BBoxInit() and BBoxCheckPoint(), or BBoxZero(), or
1556/// call BBoxNotInWorld() for screen-space content. This default is for an
1557/// element with no geometry of its own.
1558
1563
1564////////////////////////////////////////////////////////////////////////////////
1565/// Compute the bounding box if it is invalid, and return its state.
1566
1568{
1569 if (fBBoxState == kBBoxInvalid) {
1570 ComputeBBox();
1572 fBBoxState = kBBoxNone; // no point reached the box, see BBoxInit()
1573 }
1574 return fBBoxState;
1575}
1576
1577////////////////////////////////////////////////////////////////////////////////
1578/// Build fRenderData, what the client draws. An element with nothing to draw
1579/// leaves it empty, as this base does. The matrix goes as JSON, see
1580/// WriteCoreJson().
1581
1585
1586////////////////////////////////////////////////////////////////////////////////
1587/// Bring the render data entries named in `tags` up to date for a
1588/// kCBRenderEntries update, see StampRenderEntries(). This base rebuilds the
1589/// whole render data; a class that can refresh single entries of the existing
1590/// fRenderData in place may override it. Either way the entries must keep
1591/// their shape: type, item size, element count, bytes, texture format and
1592/// size, and draw ranges. The scene sends a full update when they did not.
1593/// The update sends no bounding box, so the geometry must not move.
1594
1595void REveElement::BuildRenderEntries(const std::set<std::string> & /* tags */)
1596{
1597 fRenderData.reset();
1599}
1600
1601////////////////////////////////////////////////////////////////////////////////
1602/// Stamp kCBRenderEntries for the render data entries named in `tags`: their
1603/// contents changed, their shapes did not. The tags accumulate until the
1604/// change is streamed. Like every stamp, it is recorded only while the scene
1605/// accepts changes.
1606
1607void REveElement::StampRenderEntries(const std::set<std::string> &tags)
1608{
1611 fChangedEntryTags.insert(tags.begin(), tags.end());
1612}
1613
1614namespace {
1615
1616////////////////////////////////////////////////////////////////////////////////
1617/// The 16 doubles of `t`, column-major, as base64 of their bytes. Exact, and
1618/// about half the size of the numbers as text.
1619
1620std::string TransBase64(const REveTrans &t)
1621{
1622 return TBase64::Encode(reinterpret_cast<const char *>(t.Array()), 16 * sizeof(Double_t)).Data();
1623}
1624
1625////////////////////////////////////////////////////////////////////////////////
1626/// The motion of `d` as JSON: start time, velocity, acceleration, spin and
1627/// trust window, see REveTrans::SetMotion().
1628
1629nlohmann::json MotionJson(const REveDeltaTrans &d)
1630{
1631 const REveVectorD &v = d.fVel, &a = d.fAcc, &s = d.fSpinAxis;
1632 // clang-format off
1633 return { {"t0", d.fMotionT0},
1634 {"vel", {v.fX, v.fY, v.fZ}},
1635 {"acc", {a.fX, a.fY, a.fZ}},
1636 {"axis", {s.fX, s.fY, s.fZ}},
1637 {"rate", d.fSpinRate},
1638 {"max_dt", d.fMaxDt} };
1639 // clang-format on
1640}
1641
1642} // namespace
1643
1644////////////////////////////////////////////////////////////////////////////////
1645/// Write the main transformation and its motion for a kCBTrans update.
1646/// No render data is written; the client applies it to the object it already
1647/// has. It goes out as JSON, so no offset is reserved in the binary blob for a
1648/// message that carries no geometry.
1649
1650void REveElement::WriteTransJson(nlohmann::json &cj)
1651{
1652 if (fMainTrans)
1653 cj["matrix"] = TransBase64(*fMainTrans);
1654
1655 if (fMainTrans && fMainTrans->HasMotion()) {
1656 cj["motion"] = MotionJson(*fMainTrans->GetDeltaTrans());
1657 } else {
1658 // Sent explicitly so that a stopped element cancels the client's
1659 // trajectory: a missing field in a partial update means unchanged.
1660 cj["motion"] = nullptr;
1661 }
1662}
1663
1664////////////////////////////////////////////////////////////////////////////////
1665/// Convert Bool_t to string - kTRUE or kFALSE.
1666/// Needed in WriteVizParams().
1667
1668const std::string& REveElement::ToString(Bool_t b)
1669{
1670 static const std::string true_str ("kTRUE");
1671 static const std::string false_str("kFALSE");
1672
1673 return b ? true_str : false_str;
1674}
1675
1676////////////////////////////////////////////////////////////////////////////////
1677/// Write core json. If rnr_offset is negative, render data shall not be
1678/// written.
1679/// Returns number of bytes written into binary render data.
1680
1681Int_t REveElement::WriteCoreJson(nlohmann::json &j, Int_t rnr_offset)
1682{
1683 j["_typename"] = IsA()->GetName();
1684 j["fName"] = fName;
1685 j["fTitle"] = fTitle;
1686 j["fElementId"] = GetElementId();
1687 j["fMotherId"] = get_mother_id();
1688 j["fSceneId"] = get_scene_id();
1689 j["fMasterId"] = GetSelectionMaster()->GetElementId();
1690
1691 j["fRnrSelf"] = GetRnrSelf();
1692 j["fRnrChildren"] = GetRnrChildren();
1693
1694 j["fMainColor"] = GetMainColor();
1695 j["fMainTransparency"] = GetMainTransparency();
1696 j["fPickable"] = fPickable;
1697
1698 Int_t ret = 0;
1699
1700 if (rnr_offset >= 0) {
1701 // An element with nothing to draw builds no render data. Without the
1702 // reset it would send the render data of its previous contents again.
1703 fRenderData.reset();
1705
1706 if (fRenderData) {
1707 nlohmann::json rd = {};
1708
1709 rd["rnr_offset"] = rnr_offset;
1710 rd["rnr_func"] = fRenderData->GetRnrFunc();
1711 fRenderData->WriteJson(rd);
1712
1713 j["render_data"] = rd;
1714
1715 ret = fRenderData->GetBinarySize();
1716
1717 // kCBObjProps invalidates the box, see AddStamp().
1718 switch (AssertBBox()) {
1719 case kBBoxSet:
1721 break;
1722 case kBBoxNotInWorld: j["bbox_not_in_world"] = true; break;
1723 default: {
1724 static std::mutex mtx;
1725 static std::set<std::string> warned;
1726 std::lock_guard<std::mutex> lock(mtx);
1727 if (warned.insert(IsA()->GetName()).second)
1728 ::Warning("REveElement::WriteCoreJson", "%s has render data but no bounding box.", IsA()->GetName());
1729 }
1730 }
1731 }
1732
1733 // With or without render data: the client sets it on the element's node.
1734 // A full write holds the whole transformation, so no motion means none.
1735 if (fMainTrans) {
1736 j["matrix"] = TransBase64(*fMainTrans);
1737 if (fMainTrans->HasMotion())
1738 j["motion"] = MotionJson(*fMainTrans->GetDeltaTrans());
1739 }
1740 }
1741
1742 return ret;
1743}
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
#define R__LOG_WARNING(...)
Definition RLogger.hxx:357
#define d(i)
Definition RSha256.hxx:102
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
#define g(i)
Definition RSha256.hxx:105
#define a(i)
Definition RSha256.hxx:99
#define e(i)
Definition RSha256.hxx:103
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
short Color_t
Color number (short)
Definition RtypesCore.h:100
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char)
Definition RtypesCore.h:53
char Char_t
Character 1 byte (char)
Definition RtypesCore.h:52
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition TError.cxx:241
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:208
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t dest
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void pixel
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char cname
char name[80]
Definition TGX11.cxx:142
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
Definition TROOT.cxx:792
#define gROOT
Definition TROOT.h:417
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2571
virtual REveElement * CloneElement() const
Clone the element via copy constructor.
static thread_local REveElement * stlMirAlpha
Bool_t ApplyVizTag(const TString &tag, const TString &fallback_tag="")
Set the VizTag, find model-element from the VizDB and copy visualization-parameters from it.
void DecDenyDestroy()
Decreases the deny-destroy count of the element.
virtual void DestroyOrWarn()
Destroy this element. Prints a warning if deny-destroy is in force.
const std::string & GetName() const
void SetNameTitle(const std::string &name, const std::string &title)
Set name and title of an element.
virtual void RemoveAunt(REveAunt *au)
Remove el from the list of aunts.
virtual void ExportToInterpreter(const char *var_name)
Export render-element to Cling with variable name var_name.
void SaveVizParams(std::ostream &out, const TString &tag, const TString &var)
Save visualization parameters for this element with given tag.
Int_t FindChildren(List_t &matches, const TString &name, const TClass *cls=nullptr)
Find all children with given name and append them to matches list.
REveElement * FindChild(const TString &name, const TClass *cls=nullptr)
Find the first child with given name.
TClass * IsA() const
Return class for this element Return REveElement class in case dicitonary is not exisiting.
virtual void BuildRenderEntries(const std::set< std::string > &tags)
Bring the render data entries named in tags up to date for a kCBRenderEntries update,...
virtual void Destroy()
Destroy this element.
virtual void PropagateVizParamsToChildren(REveElement *el=nullptr)
Propagate visualization parameters from element el (defaulting to this) to all children.
REveElement * LastChild() const
Returns the last child element or 0 if the list is empty.
virtual REveElement * GetSelectionMaster()
Returns the master element - that is:
virtual void RemoveElementsLocal()
Perform additional local removal of all elements.
virtual void AnnihilateElements()
Annihilate elements.
virtual REveTrans & RefMainTrans()
Return reference to main transformation.
void SetMainColorRGB(UChar_t r, UChar_t g, UChar_t b)
Convert RGB values to Color_t and call SetMainColor.
virtual void WriteTransJson(nlohmann::json &cj)
Write the main transformation and its motion for a kCBTrans update.
virtual std::string GetHighlightTooltip(const std::set< int > &) const
virtual void SetMainTransparency(Char_t t)
Set main-transparency.
virtual Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset)
Write core json.
void SetVizTag(const TString &tag)
virtual void SetTransMatrix(Double_t *carr)
Set transformation matrix from column-major array.
virtual void CopyVizParamsFromDB()
Copy visualization parameters from the model-element fVizModel.
void SetDestroyOnZeroRefCnt(Bool_t d)
Sets the state of flag determining if the element will be destroyed when reference count reaches zero...
void SetMainAlpha(Float_t alpha)
Set main-transparency via float alpha variable.
virtual void Annihilate()
Optimized destruction without check of reference-count.
virtual void PropagateMainColorToProjecteds(Color_t color, Color_t old_color)
Propagate color to projected elements.
void VizDB_Apply(const std::string &tag)
Set visual parameters for this object for given tag.
void SetupDefaultColorAndTransparency(Color_t col, Bool_t can_edit_color, Bool_t can_edit_transparency)
Set up element to use built-in main color and set flags allowing editing of main color and transparen...
const char * GetCName() const
virtual void AddElement(REveElement *el)
Add el to the list of children.
virtual void WriteVizParams(std::ostream &out, const TString &var)
Write-out visual parameters for this object.
virtual void RemoveElementLocal(REveElement *el)
Perform additional local removal of el.
Int_t fDenyDestroy
! Deny-destroy count.
void DisableListElements(Bool_t rnr_self=kFALSE, Bool_t rnr_children=kFALSE)
Disable rendering of children and their list contents.
std::set< std::string > fChangedEntryTags
! Render data entries stamped with kCBRenderEntries.
virtual Bool_t GetRnrSelf() const
virtual void DestroyMainTrans()
Destroy the main transformation matrix, it will always be taken as identity.
Int_t ComposeSceneTrans(REveTrans &t) const
Compose into t the matrices of this element and of its mothers up to, not including,...
static thread_local int stlMirError
virtual Bool_t SetRnrChildren(Bool_t rnr)
Set render state of this element's children, i.e.
void SetTitle(const std::string &title)
Set title of an element.
virtual void AnnihilateRecursively()
Protected member function called from REveElement::Annihilate().
void SetMainColorPixel(Pixel_t pixel)
Convert pixel to Color_t and call SetMainColor().
Bool_t SetVizModelByTag()
Find model element in VizDB that corresponds to previously assigned fVizTag and set fVizModel accordi...
void AssertBBoxExtents(Float_t epsilon=0.005)
Widen every side of the bounding box shorter than epsilon to epsilon, keeping its centre.
virtual void RemoveElementsInternal()
Remove all elements.
virtual void InitMainTrans(Bool_t can_edit=kTRUE)
Initialize the main transformation to identity matrix, without motion.
std::unique_ptr< REveRenderData > fRenderData
! Render data entries for the client's maker, see REveRenderData.
void VizDB_Insert(const std::string &tag, Bool_t replace=kTRUE, Bool_t update=kTRUE)
Create a replica of element and insert it into VizDB with given tag.
virtual void DestroyElements()
Destroy all children of this element.
REveElement * FirstChild() const
Returns the first child element or 0 if the list is empty.
void BBoxZero(Float_t epsilon=0, Float_t x=0, Float_t y=0, Float_t z=0)
Set the bounding box to a cube of half-side epsilon at (x, y, z); with the defaults,...
void EnableListElements(Bool_t rnr_self=kTRUE, Bool_t rnr_children=kTRUE)
Enable rendering of children and their list contents.
virtual REveTrans * PtrMainTrans(Bool_t create=kTRUE)
Return pointer to main transformation.
virtual Bool_t AcceptElement(REveElement *el)
Check if el can be added to this element.
virtual Char_t GetMainTransparency() const
static const std::string & ToString(Bool_t b)
Convert Bool_t to string - kTRUE or kFALSE.
virtual Bool_t SetRnrSelf(Bool_t rnr)
Set render state of this element, i.e.
virtual void AddAunt(REveAunt *au)
Add el into the list aunts.
virtual void PropagateMainTransparencyToProjecteds(Char_t t, Char_t old_t)
Propagate transparency to projected elements.
virtual Bool_t SetRnrState(Bool_t rnr)
Set render state of this element and of its children to the same value.
virtual void AddStamp(UChar_t bits)
Add (bitwise or) given stamps to fChangeBits.
void assign_scene_recursively(REveScene *s)
static void SetMirContext(REveElement *el)
Bool_t TestCSCBits(UChar_t f) const
ElementId_t get_mother_id() const
Int_t GetDenyDestroy() const
Returns the number of times deny-destroy has been requested on the element.
REveElement * fVizModel
! Element used as model from VizDB.
virtual Bool_t SetRnrSelfChildren(Bool_t rnr_self, Bool_t rnr_children)
Set state for rendering of this element and its children.
void SetPickableRecursively(Bool_t p)
Set pickable state on the element and all its children.
virtual void PropagateRnrStateToProjecteds()
Propagate render state to the projected replicas of this element.
void IncDenyDestroy()
Increases the deny-destroy count of the element.
void VizDB_Reapply()
Reset visual parameters for this object from VizDB.
virtual Bool_t GetRnrChildren() const
static thread_local std::string stlMirErrorString
virtual void CopyVizParams(const REveElement *el)
Copy visualization parameters from element el.
virtual void PreDeleteElement()
Called before the element is deleted, thus offering the last chance to detach from acquired resources...
virtual void CheckReferenceCount(const std::string &from="<unknown>")
Check external references to this and eventually auto-destruct the render-element.
virtual void CloneChildrenRecurse(REveElement *dest, Int_t level=0) const
Clone children and attach them to the dest element.
void BBoxInit()
Start filling the bounding box with BBoxCheckPoint(): min at +infinity, max at -infinity,...
void SetVizModel(REveElement *model)
Set visualization-parameter model element.
std::set< REveElement * > Set_t
void StampRenderEntries(const std::set< std::string > &tags)
Stamp kCBRenderEntries for the render data entries named in tags: their contents changed,...
ElementId_t GetElementId() const
EBBoxState AssertBBox()
Compute the bounding box if it is invalid, and return its state.
virtual void RemoveElements()
Remove all elements.
Bool_t GetDestroyOnZeroRefCnt() const
Returns state of flag determining if the element will be destroyed when reference count reaches zero.
virtual Bool_t SingleRnrState() const
virtual void SetMainColor(Color_t color)
Set main color of the element.
static void AppendMirErrorString(std::string_view err_str)
virtual void FillImpliedSelectedSet(Set_t &impSelSet, const std::set< int > &)
Populate set impSelSet with derived / dependant elements.
virtual ~REveElement()
Destructor.
void VizDB_UpdateModel(Bool_t update=kTRUE)
Copy visual parameters from this element to viz-db model.
virtual REveElement * CloneElementRecurse(Int_t level=0) const
Clone elements and recurse 'level' deep over children.
std::list< REveElement * > List_t
virtual void ComputeBBox()
Compute the bounding box in the element's own frame, before fMainTrans.
virtual void NameTitleChanged()
Virtual function called when a name or title of the element has been changed.
std::unique_ptr< REveTrans > fMainTrans
Bool_t HasChild(REveElement *el)
Check if element el is a child of this element.
static void SetMirError(int error, std::string_view err_str="")
REveElement(const std::string &name="", const std::string &title="")
Default constructor.
virtual Color_t GetMainColor() const
void RecheckImpliedSelections()
Call this if it is possible that implied-selection or highlight has changed for this element or for i...
void SetName(const std::string &name)
Set name of an element.
virtual void RemoveElement(REveElement *el)
Remove el from the list of children.
REveVector fBBoxMin
! Bounding box in the element's own frame.
ElementId_t get_scene_id() const
virtual void PropagateVizParamsToProjecteds()
Propagate visualization parameters to dependent elements.
virtual void BuildRenderData()
Build fRenderData, what the client draws.
virtual void ProjectAllChildren(Bool_t same_depth=kTRUE)
If this is a projectable, loop over all projected replicas and add the projected image of all childre...
virtual void ProjectChild(REveElement *el, Bool_t same_depth=kTRUE)
If this is a projectable, loop over all projected replicas and add the projected image of child 'el' ...
REveException Exception-type thrown by Eve classes.
Definition REveTypes.hxx:42
const char * what() const noexcept override
Definition REveTypes.hxx:52
void PreDeleteElement(REveElement *element)
Called from REveElement prior to its destruction so the framework components (like object editor) can...
void AssignElementId(REveElement *element)
Assign a unique ElementId to given element.
REveElement * FindVizDBEntry(const TString &tag)
Find a visualization-parameter database entry corresponding to tag.
Bool_t InsertVizDBEntry(const TString &tag, REveElement *model, Bool_t replace, Bool_t update)
Insert a new visualization-parameter database entry.
virtual void PropagateVizParams(REveElement *el=nullptr)
Set visualization parameters of projecteds.
virtual void PropagateMainColor(Color_t color, Color_t old_color)
Set main color of projecteds if their color is the same as old_color.
virtual void AnnihilateProjecteds()
Optimized destroy of projected elements with condition there is only one parent for projected element...
virtual void PropagateRenderState(Bool_t rnr_self, Bool_t rnr_children)
Set render state of projecteds.
virtual void PropagateMainTransparency(Char_t t, Char_t old_t)
Set main transparency of projecteds if their transparency is the same as the old one.
REveProjectable * GetProjectable() const
REveProjectionManager Manager class for steering of projections and managing projected objects.
virtual Int_t SubImportChildren(REveElement *el, REveElement *proj_parent)
Recursively import children elements of el and apply projection to the newly imported objects.
Bool_t IsAcceptingChanges() const
Definition REveScene.hxx:97
void SceneElementRemoved(ElementId_t id)
void SceneElementChanged(REveElement *element)
void SetFrom(Double_t *carr)
void MultLeft(const REveTrans &t)
Multiply from left: this = t * this.
void Set(const Float_t *v)
static TString Encode(const char *data)
Transform data into a null terminated base64 string.
Definition TBase64.cxx:106
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
Definition TClass.cxx:5107
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
Definition TClass.cxx:4991
TClass * IsA() const override
Definition TClass.h:638
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:2999
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
Definition TColor.cxx:1941
Geometrical transformation package.
Definition TGeoMatrix.h:39
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
Bool_t MatchB(const TString &s, const TString &mods="", Int_t start=0, Int_t nMaxMatch=10)
Definition TPRegexp.h:78
Basic string class.
Definition TString.h:137
Ssiz_t Length() const
Definition TString.h:426
const char * Data() const
Definition TString.h:385
Bool_t IsNull() const
Definition TString.h:423
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2460
static Int_t Pixel2Number(ULong_t pixel)
Static method returning color number for color specified by system dependent pixel value.
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Namespace for ROOT features in testing.
Definition TROOT.h:100
ROOT::RLogChannel & REveLog()
Log channel for Eve diagnostics.
Definition REveTypes.cxx:52
R__EXTERN REveManager * gEve
How a transformation is changing: the state REveTrans::SetMotion() records.
Definition REveTrans.hxx:32
TMarker m
Definition textangle.C:8