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
31#include <cassert>
32#include <algorithm>
33#include <limits>
34#include <mutex>
35#include <set>
36
37#include <nlohmann/json.hpp>
38
39using namespace ROOT::Experimental;
40namespace REX = ROOT::Experimental;
41
42/** \class REveElement
43\ingroup REve
44Base class for REveUtil visualization elements, providing hierarchy
45management, rendering control and list-tree item management.
46
47Class of acceptable children can be limited by setting the
48fChildClass member.
49*/
50
51////////////////////////////////////////////////////////////////////////////////
52/// Default constructor.
53
54REveElement::REveElement(const std::string& name, const std::string& title) :
55 fName (name),
56 fTitle (title)
57{
58}
59
60////////////////////////////////////////////////////////////////////////////////
61/// Copy constructor. Does shallow copy.
62/// For deep-cloning and children-cloning, see:
63/// ~~~ {.cpp}
64/// REveElement* CloneElementRecurse(Int_t level)
65/// void CloneChildrenRecurse(REveElement* dest, Int_t level)
66/// ~~~
67/// 'void* UserData' is NOT copied.
68/// If the element is projectable, its projections are NOT copied.
69///
70/// Not implemented for most sub-classes, let us know.
71/// Note that sub-classes of REveProjected are NOT and will NOT be copyable.
72
74 fName (e.fName),
75 fTitle (e.fTitle),
76 fChildClass (e.fChildClass),
77 fVizTag (e.fVizTag),
78 fDestroyOnZeroRefCnt (e.fDestroyOnZeroRefCnt),
79 fRnrSelf (e.fRnrSelf),
80 fRnrChildren (e.fRnrChildren),
81 fCanEditMainColor (e.fCanEditMainColor),
82 fCanEditMainTransparency(e.fCanEditMainTransparency),
83 fCanEditMainTrans (e.fCanEditMainTrans),
84 fMainTransparency (e.fMainTransparency),
85 fPickable (e.fPickable),
86 fCSCBits (e.fCSCBits)
87{
88 SetVizModel(e.fVizModel);
89 // FIXME: from Sergey: one have to use other way to referencing main color
90 if (e.fMainColorPtr)
91 fMainColorPtr = (Color_t*)((const char*) this + ((const char*) e.fMainColorPtr - (const char*) &e));
92 if (e.fMainTrans)
93 fMainTrans = std::make_unique<REveTrans>(*e.fMainTrans.get());
94}
95
96////////////////////////////////////////////////////////////////////////////////
97/// Destructor. Do not call this method directly, either call Destroy() or
98/// Annihilate(). See also DestroyElements() and AnnihilateElements() if you
99/// need to delete all children of an element.
100
102{
104 {
107
108 if (fMother) {
110 fMother->fChildren.remove(this);
111 }
112
113 if (fScene) {
115 }
116
117 for (auto &au : fAunts)
118 {
119 au->RemoveNieceInternal(this);
120 }
121 }
122}
123
124// MIR execution variables and helper functions
125
126thread_local REveElement *REveElement::stlMirAlpha = nullptr;
127thread_local int REveElement::stlMirError = 0;
128thread_local std::string REveElement::stlMirErrorString;
129
131 stlMirAlpha = nullptr;
132 stlMirError = 0;
133 stlMirErrorString.clear();
134}
135
139
140void REveElement::SetMirError(int error, std::string_view err_str) {
141 stlMirError = error;
142 if ( ! err_str.empty()) {
143 AppendMirErrorString(err_str);
144 }
145}
146
147void REveElement::AppendMirErrorString(std::string_view err_str) {
148 if (stlMirErrorString.empty()) {
149 stlMirErrorString = err_str;
150 } else {
151 std::string s;
152 s.reserve(stlMirErrorString.size() + err_str.size() + 4);
153 s = err_str;
154 s += " :: ";
156 stlMirErrorString.swap(s);
158}
159
160// Element IDs etc
161
166
168{
169 return fScene ? fScene->GetElementId() : 0;
170}
171
173{
174 assert(fElementId == 0);
175
177 for (auto &c : fChildren)
178 c->assign_element_id_recurisvely();
179}
180
181std::string REveElement::GetHighlightTooltip(const std::set<int>& iSet) const
182{
183 std::string res = fTitle;
184 if (res.empty())
185 res = fName;
186
187 if (!iSet.empty())
188 res = TString::Format("%s idx=%d", res.c_str(), *iSet.begin());
189
190 return res;
191}
192
194{
195 assert(fScene == nullptr);
196
197 fScene = s;
198
199 // XXX MT -- Why do we have fDestructing here? Can this really happen?
200 // If yes, shouldn't we block it in AddElement() already?
202 {
204 }
205 for (auto &c : fChildren)
206 c->assign_scene_recursively(s);
207}
208
209////////////////////////////////////////////////////////////////////////////////
210/// Called before the element is deleted, thus offering the last chance
211/// to detach from acquired resources and from the framework itself.
212/// Here the request is just passed to REveManager.
213/// If you override it, make sure to call base-class version.
214
216{
217 if (fElementId != 0)
218 {
220 }
221}
222
223////////////////////////////////////////////////////////////////////////////////
224/// Clone the element via copy constructor.
225/// Should be implemented for all classes that require cloning support.
226
228{
229 return new REveElement(*this);
230}
231
232////////////////////////////////////////////////////////////////////////////////
233/// Clone elements and recurse 'level' deep over children.
234/// - If level == 0, only the element itself is cloned (default).
235/// - If level == -1, all the hierarchy is cloned.
236
238{
240 if (level--)
241 {
242 CloneChildrenRecurse(el, level);
243 }
244 return el;
245}
246
247////////////////////////////////////////////////////////////////////////////////
248/// Clone children and attach them to the dest element.
249/// If level == 0, only the direct descendants are cloned (default).
250/// If level == -1, all the hierarchy is cloned.
251
253{
254 for (auto &c: fChildren)
255 dest->AddElement(c->CloneElementRecurse(level));
256}
257
258
259//==============================================================================
260
261////////////////////////////////////////////////////////////////////////////////
262/// Set name of an element.
263
264void REveElement::SetName(const std::string& name)
265{
266 fName = name;
268}
269
270////////////////////////////////////////////////////////////////////////////////
271/// Set title of an element.
272
273void REveElement::SetTitle(const std::string& title)
274{
275 fTitle = title;
277}
278
279////////////////////////////////////////////////////////////////////////////////
280/// Set name and title of an element.
281/// Here we attempt to cast the assigned object into TNamed and call
282/// SetNameTitle() there.
283/// If you override this call NameTitleChanged() from there.
284
285void REveElement::SetNameTitle(const std::string& name, const std::string& title)
286{
287 fName = name;
288 fTitle = title;
290}
291
292////////////////////////////////////////////////////////////////////////////////
293/// Virtual function called when a name or title of the element has
294/// been changed. Stamps kCBCoreJson, which streams both to the client.
295/// If you override this, call also the version of your direct base-class.
296
301
302////////////////////////////////////////////////////////////////////////////////
303/// Set visualization-parameter model element.
304/// Calling of this function from outside of EVE should in principle
305/// be avoided as it can lead to dis-synchronization of viz-tag and
306/// viz-model.
307
309{
310 fVizModel = model;
311}
312
313////////////////////////////////////////////////////////////////////////////////
314/// Find model element in VizDB that corresponds to previously
315/// assigned fVizTag and set fVizModel accordingly.
316/// If the tag is not found in VizDB, the old model-element is kept
317/// and false is returned.
318
320{
322 if (model)
323 {
324 SetVizModel(model);
325 return kTRUE;
326 }
327 else
328 {
329 return kFALSE;
330 }
331}
332
333////////////////////////////////////////////////////////////////////////////////
334/// Set the VizTag, find model-element from the VizDB and copy
335/// visualization-parameters from it. If the model is not found and
336/// fallback_tag is non-null, search for it is attempted as well.
337/// For example: ApplyVizTag("TPC Clusters", "Clusters");
338///
339/// If the model-element can not be found a warning is printed and
340/// false is returned.
341
342Bool_t REveElement::ApplyVizTag(const TString& tag, const TString& fallback_tag)
343{
344 REveElement* model;
345
346 if ((model = REX::gEve->FindVizDBEntry(tag)) != nullptr)
347 {
348 SetVizTag(tag);
349 }
350 else if ( ! fallback_tag.IsNull() && (model = REX::gEve->FindVizDBEntry(fallback_tag)) != nullptr)
351 {
352 SetVizTag(fallback_tag);
353 }
354
355 if (model)
356 {
357 SetVizModel(model);
359 return true;
360 }
361 Warning("REveElement::ApplyVizTag", "entry for tag '%s' not found in VizDB.", tag.Data());
362 return false;
363}
364
365////////////////////////////////////////////////////////////////////////////////
366/// Propagate visualization parameters to dependent elements.
367///
368/// MainColor is propagated independently in SetMainColor().
369/// In this case, as fMainColor is a pointer to Color_t, it should
370/// be set in TProperClass::CopyVizParams().
371///
372/// Render state is not propagated. Maybe it should be, at least optionally.
373
375{
376 REveProjectable* pable = dynamic_cast<REveProjectable*>(this);
377 if (pable && pable->HasProjecteds())
378 {
379 pable->PropagateVizParams();
380 }
381}
382
383////////////////////////////////////////////////////////////////////////////////
384/// Propagate visualization parameters from element el (defaulting
385/// to this) to all children.
386///
387/// The primary use of this is for model-elements from
388/// visualization-parameter database.
389
391{
392 if (!el) el = this;
393
394 for (auto &c : fChildren)
395 {
396 c->CopyVizParams(el);
397 }
398}
399
400////////////////////////////////////////////////////////////////////////////////
401/// Copy visualization parameters from element el.
402/// This method needs to be overriden by any class that introduces
403/// new parameters.
404
414
415////////////////////////////////////////////////////////////////////////////////
416/// Copy visualization parameters from the model-element fVizModel.
417/// A warning is printed if the model-element fVizModel is not set.
418
420{
421 if (fVizModel)
422 {
424 }
425 else
426 {
427 Warning("REveElement::CopyVizParamsFromDB", "VizModel has not been set.");
428 }
429}
430
431////////////////////////////////////////////////////////////////////////////////
432/// Save visualization parameters for this element with given tag.
433///
434/// This function creates the instantiation code, calls virtual
435/// WriteVizParams() and, at the end, writes out the code for
436/// registration of the model into the VizDB.
437
438void REveElement::SaveVizParams(std::ostream& out, const TString& tag, const TString& var)
439{
440 static const REveException eh("REveElement::GetObject ");
441
442 TString t = " ";
443 TString cls(IsA()->GetName());
444
445 out << "\n";
446
447 TString intro = " TAG='" + tag + "', CLASS='" + cls + "'";
448 out << " //" << intro << "\n";
449 out << " //" << TString('-', intro.Length()) << "\n";
450 out << t << cls << "* " << var <<" = new " << cls << ";\n";
451
452 WriteVizParams(out, var);
453
454 out << t << "REX::gEve->InsertVizDBEntry(\"" << tag << "\", "<< var <<");\n";
455}
456
457////////////////////////////////////////////////////////////////////////////////
458/// Write-out visual parameters for this object.
459/// This is a virtual function and all sub-classes are required to
460/// first call the base-element version.
461/// The name of the element pointer is 'x%03d', due to historical CINT limitations.
462/// Three spaces should be used for indentation, same as in
463/// SavePrimitive() methods.
464
465void REveElement::WriteVizParams(std::ostream& out, const TString& var)
466{
467 TString t = " " + var + "->";
468
469 out << t << "SetElementName(\"" << fName << "\");\n";
470 out << t << "SetElementTitle(\"" << fTitle << "\");\n";
471 out << t << "SetEditMainColor(" << fCanEditMainColor << ");\n";
472 out << t << "SetEditMainTransparency(" << fCanEditMainTransparency << ");\n";
473 out << t << "SetMainTransparency(" << fMainTransparency << ");\n";
474}
475
476////////////////////////////////////////////////////////////////////////////////
477/// Set visual parameters for this object for given tag.
478
479void REveElement::VizDB_Apply(const std::string& tag)
480{
481 if (ApplyVizTag(tag))
482 {
484 }
485}
486
487////////////////////////////////////////////////////////////////////////////////
488/// Reset visual parameters for this object from VizDB.
489/// The model object must be already set.
490
499
500////////////////////////////////////////////////////////////////////////////////
501/// Copy visual parameters from this element to viz-db model.
502/// If update is set, all clients of the model will be updated to
503/// the new value.
504/// A warning is printed if the model-element fVizModel is not set.
505
507{
508 if (fVizModel)
509 {
511 if (update)
512 {
513 // XXX Back references from vizdb templates have been removed in Eve7.
514 // XXX We could traverse all scenes and elementes and reset those that
515 // XXX have a matching fVizModel. Or something.
516 Error("VizDB_UpdateModel", "update from vizdb -> elements not implemented.");
517 // fVizModel->PropagateVizParamsToElements(fVizModel);
518 }
519 }
520 else
521 {
522 Warning("VizDB_UpdateModel", "VizModel has not been set.");
523 }
524}
525
526////////////////////////////////////////////////////////////////////////////////
527/// Create a replica of element and insert it into VizDB with given tag.
528/// If replace is true an existing element with the same tag will be replaced.
529/// If update is true, existing client of tag will be updated.
530
531void REveElement::VizDB_Insert(const std::string& tag, Bool_t replace, Bool_t update)
532{
533 static const REveException eh("REveElement::GetObject ");
534
535 TClass* cls = IsA();
536 REveElement* el = reinterpret_cast<REveElement*>(cls->New());
537 if (!el) {
538 Error("VizDB_Insert", "Creation of replica failed.");
539 return;
540 }
541 el->CopyVizParams(this);
542 REX::gEve->InsertVizDBEntry(tag, el, replace, update);
543}
544
545////////////////////////////////////////////////////////////////////////////////
546/// Add el into the list aunts.
547///
548/// Adding aunt is subordinate to adding a niece.
549/// This is an internal function.
550
552{
553 assert(au != nullptr);
554
555 fAunts.emplace_back(au);
556}
557
558////////////////////////////////////////////////////////////////////////////////
559/// Remove el from the list of aunts.
560/// Removing aunt is subordinate to removing a niece.
561/// This is an internal function.
562
564{
565 assert(au != nullptr);
566
567 fAunts.remove(au);
568}
569
570/******************************************************************************/
571
572////////////////////////////////////////////////////////////////////////////////
573/// Check external references to this and eventually auto-destruct
574/// the render-element.
575
576void REveElement::CheckReferenceCount(const std::string& from)
577{
578 if (fDestructing != kNone)
579 return;
580
581 if (fMother == nullptr && fDestroyOnZeroRefCnt && fDenyDestroy <= 0)
582 {
583 if (gDebug > 0)
584 Info("REveElement::CheckReferenceCount", "(called from %s) auto-destructing '%s' on zero reference count.",
585 from.c_str(), GetCName());
586
588 delete this;
589 }
590}
591
592////////////////////////////////////////////////////////////////////////////////
593/// Return class for this element
594/// Return REveElement class in case dicitonary is not exisiting
595////////////////////////////////////////////////////////////////////////////////
596
598{
599 TClass* res = TClass::GetClass(typeid(*this), kTRUE, kTRUE);
600 if (!res) {
601 R__LOG_WARNING(REveLog()) << "REveElement::IsA() no dictionary found for " << typeid(*this).name();
602 res = TClass::GetClass("ROOT::Experimental::REveElement");
603 }
604 return res;
605}
606
607////////////////////////////////////////////////////////////////////////////////
608/// Export render-element to Cling with variable name var_name.
609
610void REveElement::ExportToInterpreter(const char *var_name)
611{
612 const char* cname = IsA()->GetName();
613 gROOT->ProcessLine(TString::Format("%s* %s = (%s*)0x%zx;", cname, var_name, cname, (size_t)this));
614}
615
616////////////////////////////////////////////////////////////////////////////////
617/// Set render state of this element, i.e. if it will be published
618/// on next scene update pass.
619/// Returns true if the state has changed.
620
622{
623 if (SingleRnrState())
624 {
625 return SetRnrState(rnr);
626 }
627
628 if (rnr != fRnrSelf)
629 {
630 fRnrSelf = rnr;
633
634 return kTRUE;
635 }
636 return kFALSE;
637}
638
639////////////////////////////////////////////////////////////////////////////////
640/// Set render state of this element's children, i.e. if they will
641/// be published on next scene update pass.
642/// Returns true if the state has changed.
643
645{
646 if (SingleRnrState())
647 {
648 return SetRnrState(rnr);
649 }
650
651 if (rnr != fRnrChildren)
652 {
653 fRnrChildren = rnr;
656 return kTRUE;
657 }
658 return kFALSE;
659}
660
661////////////////////////////////////////////////////////////////////////////////
662/// Set state for rendering of this element and its children.
663/// Returns true if the state has changed.
664
666{
667 if (SingleRnrState())
668 {
669 return SetRnrState(rnr_self);
670 }
671
672 if (fRnrSelf != rnr_self || fRnrChildren != rnr_children)
673 {
674 fRnrSelf = rnr_self;
675 fRnrChildren = rnr_children;
678 return kTRUE;
679 }
680 return kFALSE;
681}
682
683////////////////////////////////////////////////////////////////////////////////
684/// Set render state of this element and of its children to the same
685/// value.
686/// Returns true if the state has changed.
687
689{
690 if (fRnrSelf != rnr || fRnrChildren != rnr)
691 {
692 fRnrSelf = fRnrChildren = rnr;
695 return kTRUE;
696 }
697 return kFALSE;
698}
699
700////////////////////////////////////////////////////////////////////////////////
701/// Propagate render state to the projected replicas of this element.
702/// Maybe this should be optional on REX::gEve/element level.
703
705{
706 REveProjectable *pable = dynamic_cast<REveProjectable*>(this);
707 if (pable && pable->HasProjecteds())
708 {
710 }
711}
712
713////////////////////////////////////////////////////////////////////////////////
714/// Set up element to use built-in main color and set flags allowing editing
715/// of main color and transparency.
716
717void REveElement::SetupDefaultColorAndTransparency(Color_t col, Bool_t can_edit_color, Bool_t can_edit_transparency)
718{
720 fDefaultColor = col;
721 fCanEditMainColor = can_edit_color;
722 fCanEditMainTransparency = can_edit_transparency;
723}
724
725////////////////////////////////////////////////////////////////////////////////
726/// Set main color of the element.
727
729{
730 Color_t old_color = GetMainColor();
731
732 if (fMainColorPtr)
733 {
734 *fMainColorPtr = color;
736 }
737
738 PropagateMainColorToProjecteds(color, old_color);
739}
740
741////////////////////////////////////////////////////////////////////////////////
742/// Convert pixel to Color_t and call SetMainColor().
743
748
749////////////////////////////////////////////////////////////////////////////////
750/// Convert RGB values to Color_t and call SetMainColor.
751
756
757////////////////////////////////////////////////////////////////////////////////
758/// Convert RGB values to Color_t and call SetMainColor.
759
764
765////////////////////////////////////////////////////////////////////////////////
766/// Propagate color to projected elements.
767
769{
770 REveProjectable* pable = dynamic_cast<REveProjectable*>(this);
771 if (pable && pable->HasProjecteds())
772 {
773 pable->PropagateMainColor(color, old_color);
774 }
775}
776
777////////////////////////////////////////////////////////////////////////////////
778/// Set main-transparency.
779/// Transparency is clamped to [0, 100].
780
782{
783 Char_t old_t = GetMainTransparency();
784
785 if (t > 100) t = 100;
788
790}
791
792////////////////////////////////////////////////////////////////////////////////
793/// Set main-transparency via float alpha variable.
794/// Value of alpha is clamped t0 [0, 1].
795
797{
798 if (alpha < 0) alpha = 0;
799 if (alpha > 1) alpha = 1;
800 SetMainTransparency((Char_t) (100.0f*(1.0f - alpha)));
801}
802
803////////////////////////////////////////////////////////////////////////////////
804/// Propagate transparency to projected elements.
805
807{
808 REveProjectable* pable = dynamic_cast<REveProjectable*>(this);
809 if (pable && pable->HasProjecteds())
810 {
811 pable->PropagateMainTransparency(t, old_t);
812 }
813}
814
815////////////////////////////////////////////////////////////////////////////////
816/// Return pointer to main transformation. If 'create' flag is set (default)
817/// it is created if not yet existing.
818
820{
821 if (!fMainTrans && create)
823
824 return fMainTrans.get();
825}
826
827////////////////////////////////////////////////////////////////////////////////
828/// Return reference to main transformation. It is created if not yet
829/// existing.
830
832{
833 if (!fMainTrans)
835
836 return *fMainTrans.get();
837}
838
839////////////////////////////////////////////////////////////////////////////////
840/// Initialize the main transformation to identity matrix, without motion.
841/// If can_edit is true (default), the user will be able to edit the
842/// transformation parameters via GUI.
843
845{
846 if (fMainTrans) {
847 fMainTrans->UnitTrans();
848 fMainTrans->ClearMotion();
849 } else {
850 fMainTrans = std::make_unique<REveTrans>();
851 }
852 fCanEditMainTrans = can_edit;
853 StampTrans();
854}
855
856////////////////////////////////////////////////////////////////////////////////
857/// Destroy the main transformation matrix, it will always be taken
858/// as identity. Editing of transformation parameters is disabled.
859/// The motion goes with it.
860
862{
863 fMainTrans.reset(nullptr);
865 StampTrans();
866}
867
868////////////////////////////////////////////////////////////////////////////////
869/// Set transformation matrix from column-major array.
870
872{
873 RefMainTrans().SetFrom(carr);
874 StampTrans();
875}
876
877////////////////////////////////////////////////////////////////////////////////
878/// Set transformation matrix from TGeo's matrix.
879
881{
882 RefMainTrans().SetFrom(mat);
883 StampTrans();
884}
885
886////////////////////////////////////////////////////////////////////////////////
887/// Compose into `t` the matrices of this element and of its mothers up to,
888/// not including, its REveScene: the frame the client draws the element in.
889/// Returns the number of matrices; `t` is set only when it is non-zero.
890
892{
893 Int_t n = 0;
894 for (const REveElement *el = this; el && !dynamic_cast<const REveScene *>(el); el = el->fMother) {
895 if (const REveTrans *m = el->fMainTrans.get()) {
896 if (n++ == 0)
897 t = *m;
898 else
899 t.MultLeft(*m);
900 }
901 }
902 return n;
903}
904
905////////////////////////////////////////////////////////////////////////////////
906/// Check if el can be added to this element.
907///
908/// Here we make sure the new child is not equal to this and, if fChildClass
909/// is set, that it is inherited from it.
910
912{
913 if (el == this)
914 return kFALSE;
915 if (fChildClass && ! el->IsA()->InheritsFrom(fChildClass))
916 return kFALSE;
917 return kTRUE;
918}
919
920////////////////////////////////////////////////////////////////////////////////
921/// Add el to the list of children.
922
924{
925 static const REveException eh("REveElement::AddElement ");
926
927 if (!el) throw eh + "called with nullptr argument.";
928 if ( ! AcceptElement(el)) throw eh + Form("parent '%s' rejects '%s'.", GetCName(), el->GetCName());
929 if (el->fElementId) throw eh + "element already has an id.";
930 // if (el->fScene) throw eh + "element already has a Scene.";
931 if (el->fMother) throw eh + "element already has a Mother.";
932
933 // XXX Implement reparent --> MoveElement() ????
934 // Actually, better to do new = old.Clone(), RemoveElement(old), AddElement(new);
935 // Or do magick with Inc/DecDenyDestroy().
936 // PITA with existing children !!!! Need to re-scene them.
937
939 if (fScene && ! el->fScene) el->assign_scene_recursively(fScene);
940
941 el->fMother = this;
942
943 fChildren.emplace_back(el);
944
945 // XXXX This should be element added. Also, should be different for
946 // "full (re)construction". Scenes should manage that and have
947 // state like: none - constructing - clearing - nominal - updating.
948 // I recon this means an element should have a ptr to its scene.
949 //
950 // ElementChanged();
951}
952
953////////////////////////////////////////////////////////////////////////////////
954/// Remove el from the list of children.
955
957{
958 static const REveException eh("REveElement::RemoveElement ");
959
960 if (!el) throw eh + "called with nullptr argument.";
961 if (el->fMother != this) throw eh + "this element is not mother of el.";
962
964
966 el->fMother = nullptr;
967 el->fScene = nullptr;
968
970
971 fChildren.remove(el);
972
973 // XXXX This should be ElementRemoved(). Also, think about recursion, deletion etc.
974 // Also, this seems to be done above, in the call to fScene.
975 //
976 // ElementChanged();
977}
978
979////////////////////////////////////////////////////////////////////////////////
980/// Perform additional local removal of el.
981/// Called from RemoveElement() which does whole untangling.
982/// Put into special function as framework-related handling of
983/// element removal should really be common to all classes and
984/// clearing of local structures happens in between removal
985/// of list-tree-items and final removal.
986/// If you override this, you should also override
987/// RemoveElementsLocal().
988
992
993////////////////////////////////////////////////////////////////////////////////
994/// Remove all elements. This assumes removing of all elements can
995/// be done more efficiently then looping over them and removing one
996/// by one. This protected function performs the removal on the
997/// level of REveElement.
998
1000{
1002
1003 for (auto &c : fChildren)
1004 {
1005 c->fScene->SceneElementRemoved(c->fElementId);
1006 c->fMother = nullptr;
1007 c->fScene = nullptr;
1008
1009 c->CheckReferenceCount();
1010 }
1011
1012 fChildren.clear();
1013}
1014
1015////////////////////////////////////////////////////////////////////////////////
1016/// Remove all elements. This assumes removing of all elements can
1017/// be done more efficiently then looping over them and removing
1018/// them one by one.
1019
1021{
1022 if (HasChildren())
1023 {
1025 // ElementChanged();
1026 }
1027}
1028
1029////////////////////////////////////////////////////////////////////////////////
1030/// Perform additional local removal of all elements.
1031/// See comment to RemoveElementLocal(REveElement*).
1032
1036
1037////////////////////////////////////////////////////////////////////////////////
1038/// If this is a projectable, loop over all projected replicas and
1039/// add the projected image of child 'el' there. This is supposed to
1040/// be called after you add a child to a projectable after it has
1041/// already been projected.
1042/// You might also want to call RecheckImpliedSelections() on this
1043/// element or 'el'.
1044///
1045/// If 'same_depth' flag is true, the same depth as for parent object
1046/// is used in every projection. Otherwise current depth of each
1047/// relevant projection-manager is used.
1048
1050{
1051 REveProjectable* pable = dynamic_cast<REveProjectable*>(this);
1052 if (pable && HasChild(el))
1053 {
1054 for (auto &pp: pable->RefProjecteds())
1055 {
1056 auto pmgr = pp->GetManager();
1057 Float_t cd = pmgr->GetCurrentDepth();
1058 if (same_depth) pmgr->SetCurrentDepth(pp->GetDepth());
1059
1060 pmgr->SubImportElements(el, pp->GetProjectedAsElement());
1061
1062 if (same_depth) pmgr->SetCurrentDepth(cd);
1063 }
1064 }
1065}
1066
1067////////////////////////////////////////////////////////////////////////////////
1068/// If this is a projectable, loop over all projected replicas and
1069/// add the projected image of all children there. This is supposed
1070/// to be called after you destroy all children and then add new
1071/// ones after this element has already been projected.
1072/// You might also want to call RecheckImpliedSelections() on this
1073/// element.
1074///
1075/// If 'same_depth' flag is true, the same depth as for the
1076/// projected element is used in every projection. Otherwise current
1077/// depth of each relevant projection-manager is used.
1078
1080{
1081 REveProjectable* pable = dynamic_cast<REveProjectable*>(this);
1082 if (pable)
1083 {
1084 for (auto &pp: pable->RefProjecteds())
1085 {
1086 REveProjectionManager *pmgr = pp->GetManager();
1087 Float_t cd = pmgr->GetCurrentDepth();
1088 if (same_depth) pmgr->SetCurrentDepth(pp->GetDepth());
1089
1090 pmgr->SubImportChildren(this, pp->GetProjectedAsElement());
1091
1092 if (same_depth) pmgr->SetCurrentDepth(cd);
1093 }
1094 }
1095}
1096
1097////////////////////////////////////////////////////////////////////////////////
1098/// Check if element el is a child of this element.
1099
1101{
1102 return (std::find(fChildren.begin(), fChildren.end(), el) != fChildren.end());
1103}
1104
1105////////////////////////////////////////////////////////////////////////////////
1106/// Find the first child with given name. If cls is specified (non
1107/// 0), it is also checked.
1108///
1109/// Returns nullptr if not found.
1110
1112{
1113 for (auto &c: fChildren)
1114 {
1115 if (name.CompareTo(c->GetCName()) == 0)
1116 {
1117 if (!cls || c->IsA()->InheritsFrom(cls))
1118 return c;
1119 }
1120 }
1121 return nullptr;
1122}
1123
1124////////////////////////////////////////////////////////////////////////////////
1125/// Find the first child whose name matches regexp. If cls is
1126/// specified (non 0), it is also checked.
1127///
1128/// Returns nullptr if not found.
1129
1131{
1132 for (auto &c: fChildren)
1133 {
1134 if (regexp.MatchB(c->GetName()))
1135 {
1136 if (!cls || c->IsA()->InheritsFrom(cls))
1137 return c;
1138 }
1139 }
1140 return nullptr;
1141}
1142
1143////////////////////////////////////////////////////////////////////////////////
1144/// Find all children with given name and append them to matches
1145/// list. If class is specified (non 0), it is also checked.
1146///
1147/// Returns number of elements added to the list.
1148
1150 const TString& name, const TClass* cls)
1151{
1152 Int_t count = 0;
1153 for (auto &c: fChildren)
1154 {
1155 if (name.CompareTo(c->GetCName()) == 0)
1156 {
1157 if (!cls || c->IsA()->InheritsFrom(cls))
1158 {
1159 matches.push_back(c);
1160 ++count;
1161 }
1162 }
1163 }
1164 return count;
1165}
1166
1167////////////////////////////////////////////////////////////////////////////////
1168/// Find all children whose name matches regexp and append them to
1169/// matches list.
1170///
1171/// Returns number of elements added to the list.
1172
1174 TPRegexp &regexp, const TClass *cls)
1175{
1176 Int_t count = 0;
1177 for (auto &c : fChildren)
1178 {
1179 if (regexp.MatchB(c->GetCName()))
1180 {
1181 if (!cls || c->IsA()->InheritsFrom(cls))
1182 {
1183 matches.push_back(c);
1184 ++count;
1185 }
1186 }
1187 }
1188 return count;
1189}
1190
1191////////////////////////////////////////////////////////////////////////////////
1192/// Returns the first child element or 0 if the list is empty.
1193
1195{
1196 return HasChildren() ? fChildren.front() : nullptr;
1197}
1198
1199////////////////////////////////////////////////////////////////////////////////
1200/// Returns the last child element or 0 if the list is empty.
1201
1203{
1204 return HasChildren() ? fChildren.back() : nullptr;
1205}
1206
1207////////////////////////////////////////////////////////////////////////////////
1208/// Enable rendering of children and their list contents.
1209/// Arguments control how to set self/child rendering.
1210
1212{
1213 for (auto &c: fChildren)
1214 c->SetRnrSelfChildren(rnr_self, rnr_children);
1215}
1216
1217////////////////////////////////////////////////////////////////////////////////
1218/// Disable rendering of children and their list contents.
1219/// Arguments control how to set self/child rendering.
1220///
1221/// Same as above function, but default arguments are different. This
1222/// is convenient for calls via context menu.
1223
1225{
1226 for (auto &c: fChildren)
1227 c->SetRnrSelfChildren(rnr_self, rnr_children);
1228}
1229
1230////////////////////////////////////////////////////////////////////////////////
1231/// Protected member function called from REveElement::Annihilate().
1232
1234{
1235 // projected were already destroyed in REveElement::Anihilate(), now only clear its list
1236 REveProjectable* pable = dynamic_cast<REveProjectable*>(this);
1237 if (pable && pable->HasProjecteds())
1238 pable->ClearProjectedList();
1239
1240 // same as REveElement::RemoveElementsInternal(), except parents are ignored
1242 for (auto &c : fChildren)
1243 c->AnnihilateRecursively();
1244
1245 fChildren.clear();
1246
1249
1250 delete this;
1251}
1252
1253////////////////////////////////////////////////////////////////////////////////
1254/// Optimized destruction without check of reference-count.
1255/// Parents are not notified about child destruction.
1256/// The method should only be used when an element does not have
1257/// more than one parent -- otherwise an exception is thrown.
1258
1260{
1261 static const REveException eh("REveElement::Annihilate ");
1262
1264
1265 // recursive annihilation of projecteds
1266 REveProjectable* pable = dynamic_cast<REveProjectable*>(this);
1267 if (pable && pable->HasProjecteds())
1268 {
1269 pable->AnnihilateProjecteds();
1270 }
1271
1272 // detach from the parent
1273 if (fMother)
1274 {
1275 fMother->RemoveElement(this);
1276 }
1277
1278 // XXXX wont the above already start off the destruction cascade ?????
1279
1281
1282 // XXXX ????? Annihilate flag ???? Is it different than regular remove ????
1283}
1284
1285////////////////////////////////////////////////////////////////////////////////
1286/// Annihilate elements.
1287
1289{
1290 while (!fChildren.empty())
1291 {
1292 auto c = fChildren.front();
1293 c->Annihilate();
1294 }
1295}
1296
1297////////////////////////////////////////////////////////////////////////////////
1298/// Destroy this element. Throws an exception if deny-destroy is in force.
1299/// This method should be called instead of a destructor.
1300/// Note that an exception will be thrown if the element has been
1301/// protected against destruction with IncDenyDestroy().
1302
1304{
1305 static const REveException eh("REveElement::Destroy ");
1306
1307 if (fDenyDestroy > 0)
1308 throw eh + TString::Format("element '%s' (%s*) %p is protected against destruction.",
1309 GetCName(), IsA()->GetName(), this);
1310
1312 delete this;
1313}
1314
1315////////////////////////////////////////////////////////////////////////////////
1316/// Destroy this element. Prints a warning if deny-destroy is in force.
1317
1319{
1320 try
1321 {
1322 Destroy();
1323 }
1324 catch (REveException &exc)
1325 {
1326 ::Warning("REveElement::DestroyOrWarn", "Error while destroy element %p : %s", this, exc.what());
1327 }
1328}
1329
1330////////////////////////////////////////////////////////////////////////////////
1331/// Destroy all children of this element.
1332
1334{
1335 while (HasChildren())
1336 {
1337 auto c = fChildren.front();
1338 if (c->fDenyDestroy <= 0)
1339 {
1340 try {
1341 c->Destroy();
1342 }
1343 catch (REveException &exc) {
1344 ::Warning("REveElement::DestroyElements", "element destruction failed: '%s'.", exc.what());
1346 }
1347 }
1348 else
1349 {
1350 if (gDebug > 0)
1351 ::Info("REveElement::DestroyElements", "element '%s' is protected against destruction, removing locally.", c->GetCName());
1353 }
1354 }
1355}
1356
1357////////////////////////////////////////////////////////////////////////////////
1358/// Returns state of flag determining if the element will be
1359/// destroyed when reference count reaches zero.
1360/// This is true by default.
1361
1366
1367////////////////////////////////////////////////////////////////////////////////
1368/// Sets the state of flag determining if the element will be
1369/// destroyed when reference count reaches zero.
1370/// This is true by default.
1371
1376
1377////////////////////////////////////////////////////////////////////////////////
1378/// Returns the number of times deny-destroy has been requested on
1379/// the element.
1380
1382{
1383 return fDenyDestroy;
1384}
1385
1386////////////////////////////////////////////////////////////////////////////////
1387/// Increases the deny-destroy count of the element.
1388/// Call this if you store an external pointer to the element.
1389
1394
1395////////////////////////////////////////////////////////////////////////////////
1396/// Decreases the deny-destroy count of the element.
1397/// Call this after releasing an external pointer to the element.
1398
1400{
1401 if (--fDenyDestroy <= 0)
1402 CheckReferenceCount("REveElement::DecDenyDestroy ");
1403}
1404
1405////////////////////////////////////////////////////////////////////////////////
1406/// Set pickable state on the element and all its children.
1407
1409{
1410 fPickable = p;
1411 for (auto &c: fChildren)
1412 c->SetPickableRecursively(p);
1413}
1414
1415////////////////////////////////////////////////////////////////////////////////
1416/// Returns the master element - that is:
1417/// - master of projectable, if this is a projected;
1418/// - master of compound, if fCompound is set;
1419/// - master of mother, if kSCBTakeMotherAsMaster bit is set;
1420/// If non of the above is true, *this* is returned.
1421
1423{
1425
1426 REveProjected* proj = dynamic_cast<REveProjected*>(this);
1427 if (proj)
1428 {
1429 return dynamic_cast<REveElement*>(proj->GetProjectable())->GetSelectionMaster();
1430 }
1431 if (fCompound)
1432 {
1433 return fCompound->GetSelectionMaster();
1434 }
1436 {
1437 return fMother->GetSelectionMaster();
1438 }
1439 return this;
1440}
1441
1442////////////////////////////////////////////////////////////////////////////////
1443/// Populate set impSelSet with derived / dependant elements.
1444///
1445/// If this is a REveProjectable, the projected replicas are added
1446/// to the set. Thus it does not have to be reimplemented for each
1447/// sub-class of REveProjected.
1448///
1449/// Note that this also takes care of projections of REveCompound
1450/// class, which is also a projectable.
1451
1452void REveElement::FillImpliedSelectedSet(Set_t &impSelSet, const std::set<int>&)
1453{
1454 REveProjectable* p = dynamic_cast<REveProjectable*>(this);
1455 if (p)
1456 p->AddProjectedsToSet(impSelSet);
1457}
1458
1459////////////////////////////////////////////////////////////////////////////////
1460/// Call this if it is possible that implied-selection or highlight
1461/// has changed for this element or for implied-selection this
1462/// element is member of and you want to maintain consistent
1463/// selection state.
1464/// This can happen if you add elements into compounds in response
1465/// to user-interaction.
1466
1468{
1469 // XXXX MT 2019-01 --- RecheckImpliedSelections
1470 //
1471 // With removal of selection state from this class there might be some
1472 // corner cases requiring checking of implied-selected state in
1473 // selection/highlight objects.
1474 //
1475 // This could be done as part of begin / end changes on the EveManager level.
1476 //
1477 // See also those functions in TEveSelection.
1478
1479 // if (fSelected || fImpliedSelected)
1480 // REX::gEve->GetSelection()->RecheckImpliedSetForElement(this);
1481
1482 // if (fHighlighted || fImpliedHighlighted)
1483 // REX::gEve->GetHighlight()->RecheckImpliedSetForElement(this);
1484}
1485
1486////////////////////////////////////////////////////////////////////////////////
1487/// Add (bitwise or) given stamps to fChangeBits.
1488/// Register this element to REX::gEve as stamped.
1489/// This method is virtual so that sub-classes can add additional
1490/// actions. The base-class method should still be called (or replicated).
1491
1493{
1494 if (bits & kCBObjProps)
1496
1498 {
1499 if (gDebug > 0)
1500 ::Info(Form("%s::AddStamp", GetCName()), "%d + (%d) -> %d", fChangeBits, bits, fChangeBits | bits);
1501
1502 if (fChangeBits == 0)
1503 {
1505 }
1506
1507 fChangeBits |= bits;
1508 }
1509}
1510
1511////////////////////////////////////////////////////////////////////////////////
1512/// Start filling the bounding box with BBoxCheckPoint(): min at +infinity,
1513/// max at -infinity, so the first point sets both. A box that no point
1514/// reached stays inverted, and AssertBBox() reports it as kBBoxNone.
1515
1517{
1518 const Float_t inf = std::numeric_limits<Float_t>::infinity();
1519 fBBoxMin.Set(inf, inf, inf);
1520 fBBoxMax.Set(-inf, -inf, -inf);
1522}
1523
1524////////////////////////////////////////////////////////////////////////////////
1525/// Set the bounding box to a cube of half-side `epsilon` at (`x`, `y`, `z`);
1526/// with the defaults, a point at the origin.
1527
1529{
1530 fBBoxMin.Set(x - epsilon, y - epsilon, z - epsilon);
1531 fBBoxMax.Set(x + epsilon, y + epsilon, z + epsilon);
1533}
1534
1535////////////////////////////////////////////////////////////////////////////////
1536/// Widen every side of the bounding box shorter than `epsilon` to `epsilon`,
1537/// keeping its centre.
1538
1540{
1541 if (fBBoxMin.fX > fBBoxMax.fX)
1542 return; // empty, see BBoxInit()
1543 for (Int_t i = 0; i < 3; ++i) {
1544 if (fBBoxMax[i] - fBBoxMin[i] < epsilon) {
1545 Float_t c = 0.5f * (fBBoxMin[i] + fBBoxMax[i]);
1546 fBBoxMin[i] = c - 0.5f * epsilon;
1547 fBBoxMax[i] = c + 0.5f * epsilon;
1548 }
1549 }
1550}
1551
1552////////////////////////////////////////////////////////////////////////////////
1553/// Compute the bounding box in the element's own frame, before fMainTrans.
1554/// Overrides fill it with BBoxInit() and BBoxCheckPoint(), or BBoxZero(), or
1555/// call BBoxNotInWorld() for screen-space content. This default is for an
1556/// element with no geometry of its own.
1557
1562
1563////////////////////////////////////////////////////////////////////////////////
1564/// Compute the bounding box if it is invalid, and return its state.
1565
1567{
1568 if (fBBoxState == kBBoxInvalid) {
1569 ComputeBBox();
1571 fBBoxState = kBBoxNone; // no point reached the box, see BBoxInit()
1572 }
1573 return fBBoxState;
1574}
1575
1576////////////////////////////////////////////////////////////////////////////////
1577/// Build fRenderData, what the client draws. An element with nothing to draw
1578/// leaves it empty, as this base does. The matrix goes as JSON, see
1579/// WriteCoreJson().
1580
1584
1585namespace {
1586
1587////////////////////////////////////////////////////////////////////////////////
1588/// The 16 doubles of `t`, column-major, as base64 of their bytes. Exact, and
1589/// about half the size of the numbers as text.
1590
1591std::string TransBase64(const REveTrans &t)
1592{
1593 return TBase64::Encode(reinterpret_cast<const char *>(t.Array()), 16 * sizeof(Double_t)).Data();
1594}
1595
1596////////////////////////////////////////////////////////////////////////////////
1597/// The motion of `d` as JSON: start time, velocity, acceleration, spin and
1598/// trust window, see REveTrans::SetMotion().
1599
1600nlohmann::json MotionJson(const REveDeltaTrans &d)
1601{
1602 const REveVectorD &v = d.fVel, &a = d.fAcc, &s = d.fSpinAxis;
1603 // clang-format off
1604 return { {"t0", d.fMotionT0},
1605 {"vel", {v.fX, v.fY, v.fZ}},
1606 {"acc", {a.fX, a.fY, a.fZ}},
1607 {"axis", {s.fX, s.fY, s.fZ}},
1608 {"rate", d.fSpinRate},
1609 {"max_dt", d.fMaxDt} };
1610 // clang-format on
1611}
1612
1613} // namespace
1614
1615////////////////////////////////////////////////////////////////////////////////
1616/// Write the main transformation and its motion for a kCBTrans update.
1617/// No render data is written; the client applies it to the object it already
1618/// has. It goes out as JSON, so no offset is reserved in the binary blob for a
1619/// message that carries no geometry.
1620
1621void REveElement::WriteTransJson(nlohmann::json &cj)
1622{
1623 if (fMainTrans)
1624 cj["matrix"] = TransBase64(*fMainTrans);
1625
1626 if (fMainTrans && fMainTrans->HasMotion()) {
1627 cj["motion"] = MotionJson(*fMainTrans->GetDeltaTrans());
1628 } else {
1629 // Sent explicitly so that a stopped element cancels the client's
1630 // trajectory: a missing field in a partial update means unchanged.
1631 cj["motion"] = nullptr;
1632 }
1633}
1634
1635////////////////////////////////////////////////////////////////////////////////
1636/// Convert Bool_t to string - kTRUE or kFALSE.
1637/// Needed in WriteVizParams().
1638
1639const std::string& REveElement::ToString(Bool_t b)
1640{
1641 static const std::string true_str ("kTRUE");
1642 static const std::string false_str("kFALSE");
1643
1644 return b ? true_str : false_str;
1645}
1646
1647////////////////////////////////////////////////////////////////////////////////
1648/// Write core json. If rnr_offset is negative, render data shall not be
1649/// written.
1650/// Returns number of bytes written into binary render data.
1651
1652Int_t REveElement::WriteCoreJson(nlohmann::json &j, Int_t rnr_offset)
1653{
1654 j["_typename"] = IsA()->GetName();
1655 j["fName"] = fName;
1656 j["fTitle"] = fTitle;
1657 j["fElementId"] = GetElementId();
1658 j["fMotherId"] = get_mother_id();
1659 j["fSceneId"] = get_scene_id();
1660 j["fMasterId"] = GetSelectionMaster()->GetElementId();
1661
1662 j["fRnrSelf"] = GetRnrSelf();
1663 j["fRnrChildren"] = GetRnrChildren();
1664
1665 j["fMainColor"] = GetMainColor();
1666 j["fMainTransparency"] = GetMainTransparency();
1667 j["fPickable"] = fPickable;
1668
1669 Int_t ret = 0;
1670
1671 if (rnr_offset >= 0) {
1672 // An element with nothing to draw builds no render data. Without the
1673 // reset it would send the render data of its previous contents again.
1674 fRenderData.reset();
1676
1677 if (fRenderData) {
1678 nlohmann::json rd = {};
1679
1680 rd["rnr_offset"] = rnr_offset;
1681 rd["rnr_func"] = fRenderData->GetRnrFunc();
1682 rd["vert_size"] = fRenderData->SizeV();
1683 rd["norm_size"] = fRenderData->SizeN();
1684 rd["index_size"] = fRenderData->SizeI();
1685
1686 j["render_data"] = rd;
1687
1688 ret = fRenderData->GetBinarySize();
1689
1690 // kCBObjProps invalidates the box, see AddStamp().
1691 switch (AssertBBox()) {
1692 case kBBoxSet:
1694 break;
1695 case kBBoxNotInWorld: j["bbox_not_in_world"] = true; break;
1696 default: {
1697 static std::mutex mtx;
1698 static std::set<std::string> warned;
1699 std::lock_guard<std::mutex> lock(mtx);
1700 if (warned.insert(IsA()->GetName()).second)
1701 ::Warning("REveElement::WriteCoreJson", "%s has render data but no bounding box.", IsA()->GetName());
1702 }
1703 }
1704 }
1705
1706 // With or without render data: the client sets it on the element's node.
1707 // A full write holds the whole transformation, so no motion means none.
1708 if (fMainTrans) {
1709 j["matrix"] = TransBase64(*fMainTrans);
1710 if (fMainTrans->HasMotion())
1711 j["motion"] = MotionJson(*fMainTrans->GetDeltaTrans());
1712 }
1713 }
1714
1715 return ret;
1716}
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 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.
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
! Vertex / normal / triangle index information for rendering.
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
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:5111
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
Definition TClass.cxx:4995
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:1939
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
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