Logo ROOT  
Reference Guide
REveProjectionBases.cxx
Go to the documentation of this file.
1 // @(#)root/eve7:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
14 #include <ROOT/REveManager.hxx>
15 
16 #include <cassert>
17 
18 using namespace ROOT::Experimental;
19 namespace REX = ROOT::Experimental;
20 
21 /** \class REveProjectable
22 \ingroup REve
23 Abstract base-class for non-linear projectable objects.
24 
25 Via ProjectedClass(const REveProjection* p) method it returns a
26 TClass instance for the projected class and keeps references to the
27 projected objects.
28 
29 It is assumed that all classes deriving from REveProjectable are also
30 derived from REveElement.
31 
32 See also REveProjectionManager::ImportElements().
33 */
34 
35 ////////////////////////////////////////////////////////////////////////////////
36 /// Constructor.
37 
39 {
40 }
41 
42 ////////////////////////////////////////////////////////////////////////////////
43 /// Copy constructor. Does shallow copy
44 
46 {
47 }
48 
49 ////////////////////////////////////////////////////////////////////////////////
50 /// Destructor.
51 /// Force projected replicas to unreference *this, then destroy them.
52 
54 {
55  // FIXME: fomr SL: how list becomes empty here???
56 
57  while ( ! fProjectedList.empty())
58  {
59  REveProjected* p = fProjectedList.front();
60 
61  p->UnRefProjectable(this);
63  assert(el);
64  {
65  // FIXME: SL: no any globals !!!
67  delete el;
68  }
69  }
70 }
71 
72 ////////////////////////////////////////////////////////////////////////////////
73 /// Optimized destroy of projected elements with condition
74 /// there is only one parent for projected element. Method is
75 /// called from REveElement::Annihilate().
76 
78 {
79  for (auto &&proj : fProjectedList) {
80  proj->UnRefProjectable(this, kFALSE);
81  proj->GetProjectedAsElement()->Annihilate();
82  }
83  fProjectedList.clear();
84 }
85 
86 ////////////////////////////////////////////////////////////////////////////////
87 
89 {
90  fProjectedList.clear();
91 }
92 
93 ////////////////////////////////////////////////////////////////////////////////
94 /// Add the projected elements to the set, dyn-casting them to
95 /// REveElement.
96 
97 void REveProjectable::AddProjectedsToSet(std::set<REveElement*> &set)
98 {
99  for (auto &proj : fProjectedList)
100  set.insert(proj->GetProjectedAsElement());
101 }
102 
103 ////////////////////////////////////////////////////////////////////////////////
104 /// Set visualization parameters of projecteds.
105 /// Use element el as model. If el == 0 (default), this casted to
106 /// REveElement is used.
107 
109 {
110  if (el == nullptr)
111  el = dynamic_cast<REveElement*>(this);
112 
113  for (auto &proj : fProjectedList)
114  proj->GetProjectedAsElement()->CopyVizParams(el);
115 }
116 
117 ////////////////////////////////////////////////////////////////////////////////
118 /// Set render state of projecteds.
119 
121 {
122  for (auto &&proj : fProjectedList) {
123  if (proj->GetProjectedAsElement()->SetRnrSelfChildren(rnr_self, rnr_children))
124  proj->GetProjectedAsElement()->StampVisibility();
125  }
126 }
127 
128 ////////////////////////////////////////////////////////////////////////////////
129 /// Set main color of projecteds if their color is the same as old_color.
130 
132 {
133  for (auto &&proj : fProjectedList) {
134  auto p_as_el = proj->GetProjectedAsElement();
135  if (p_as_el->GetMainColor() == old_color) {
136  p_as_el->SetMainColor(color);
137  p_as_el->StampColorSelection();
138  }
139  }
140 }
141 
142 ////////////////////////////////////////////////////////////////////////////////
143 /// Set main transparency of projecteds if their transparency is the
144 /// same as the old one.
145 
147 {
148  for (auto &&proj : fProjectedList) {
149  auto p_as_el = proj->GetProjectedAsElement();
150  if (p_as_el->GetMainTransparency() == old_t) {
151  p_as_el->SetMainTransparency(t);
152  p_as_el->StampColorSelection();
153  }
154  }
155 }
156 
157 /** \class REveProjected
158 \ingroup REve
159 Abstract base class for classes that hold results of a non-linear
160 projection transformation.
161 
162 It is assumed that all classes deriving from REveProjected are also
163 derived from REveElement.
164 */
165 
166 ////////////////////////////////////////////////////////////////////////////////
167 /// Destructor.
168 /// If fProjectable is non-null, *this is removed from its list of
169 /// projected replicas.
170 
172 {
174 }
175 
176 ////////////////////////////////////////////////////////////////////////////////
177 /// Returns this projected dynamic-casted to REveElement.
178 /// This is needed as class REveProjected is used as secondary
179 /// inheritance.
180 
182 {
183  return dynamic_cast<REveElement*>(this);
184 }
185 
186 ////////////////////////////////////////////////////////////////////////////////
187 /// Sets projection manager and reference in the projectable object. Method called
188 /// immediately after default constructor.
189 /// See also REveProjectionManager::ImportElements().
190 
192 {
193  fManager = mng;
197 }
198 
199 ////////////////////////////////////////////////////////////////////////////////
200 /// Remove reference to projectable.
201 
202 void REveProjected::UnRefProjectable(REveProjectable* assumed_parent, bool notifyParent)
203 {
204  static const REveException eH("REveProjected::UnRefProjectable ");
205 
206  R__ASSERT(fProjectable == assumed_parent);
207 
208  if (notifyParent) fProjectable->RemoveProjected(this);
209  fProjectable = nullptr;
210 }
211 
212 ////////////////////////////////////////////////////////////////////////////////
213 /// Set depth coordinate for the element.
214 /// Bounding-box should also be updated.
215 /// If projection type is 3D, this only sets fDepth member.
216 
218 {
219  if (fManager->GetProjection()->Is2D()) {
220  SetDepthLocal(d);
221  } else {
222  fDepth = d;
223  }
224 }
225 
226 ////////////////////////////////////////////////////////////////////////////////
227 /// Utility function to update the z-values of the bounding-box.
228 /// As this is an abstract interface, the element and bbox pointers
229 /// must be passed from outside.
230 
232 {
233  Float_t delta = d - fDepth;
234  fDepth = d;
235  if (bbox) {
236  bbox[4] += delta;
237  bbox[5] += delta;
238  el->StampTransBBox();
239  }
240 }
241 
242 ////////////////////////////////////////////////////////////////////////////////
243 /// Base-class implementation -- just sets fDepth.
244 
246 {
247  fDepth = d;
248 }
ROOT::Experimental::REveProjected
Definition: REveProjectionBases.hxx:81
ROOT::Experimental::REveProjection::Is2D
virtual Bool_t Is2D() const =0
ROOT::Experimental::REveProjected::SetDepthCommon
void SetDepthCommon(Float_t d, REveElement *el, Float_t *bbox)
Utility function to update the z-values of the bounding-box.
Definition: REveProjectionBases.cxx:231
ROOT::Experimental::REveProjectable::~REveProjectable
virtual ~REveProjectable()
Destructor.
Definition: REveProjectionBases.cxx:53
ROOT::Experimental::REveProjectable::REveProjectable
REveProjectable()
Constructor.
Definition: REveProjectionBases.cxx:38
REveProjectionBases.hxx
ROOT::Experimental::REveProjected::fDepth
Float_t fDepth
Definition: REveProjectionBases.hxx:89
ROOT::Experimental::REveProjectable::AddProjected
virtual void AddProjected(REveProjected *p)
Definition: REveProjectionBases.hxx:59
ROOT::Experimental::REveProjectable::PropagateMainColor
virtual void PropagateMainColor(Color_t color, Color_t old_color)
Set main color of projecteds if their color is the same as old_color.
Definition: REveProjectionBases.cxx:131
ROOT::Experimental::REveProjectable::PropagateRenderState
virtual void PropagateRenderState(Bool_t rnr_self, Bool_t rnr_children)
Set render state of projecteds.
Definition: REveProjectionBases.cxx:120
ROOT::Experimental::REveElement::StampTransBBox
void StampTransBBox()
Definition: REveElement.hxx:340
ROOT::Experimental::REveProjectable::AnnihilateProjecteds
virtual void AnnihilateProjecteds()
Optimized destroy of projected elements with condition there is only one parent for projected element...
Definition: REveProjectionBases.cxx:77
ROOT::Experimental::REveProjected::SetProjection
virtual void SetProjection(REveProjectionManager *mng, REveProjectable *model)
Sets projection manager and reference in the projectable object.
Definition: REveProjectionBases.cxx:191
ROOT::Experimental::REveProjected::SetDepthLocal
virtual void SetDepthLocal(Float_t d)
Base-class implementation – just sets fDepth.
Definition: REveProjectionBases.cxx:245
ROOT::Experimental::REveProjected::GetProjectedAsElement
virtual REveElement * GetProjectedAsElement()
Returns this projected dynamic-casted to REveElement.
Definition: REveProjectionBases.cxx:181
ROOT::Experimental::REveProjectable::PropagateVizParams
virtual void PropagateVizParams(REveElement *el=nullptr)
Set visualization parameters of projecteds.
Definition: REveProjectionBases.cxx:108
ROOT::Experimental::REveProjected::SetDepth
virtual void SetDepth(Float_t d)
Set depth coordinate for the element.
Definition: REveProjectionBases.cxx:217
ROOT::Experimental::REveElement
Definition: REveElement.hxx:41
Color_t
short Color_t
Definition: RtypesCore.h:83
gEve
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
bool
ROOT::Experimental::REveProjected::UnRefProjectable
virtual void UnRefProjectable(REveProjectable *assumed_parent, bool notifyParent=true)
Remove reference to projectable.
Definition: REveProjectionBases.cxx:202
ROOT::Experimental::REveProjected::~REveProjected
virtual ~REveProjected()
Destructor.
Definition: REveProjectionBases.cxx:171
ROOT::Experimental::REveProjectable::fProjectedList
ProjList_t fProjectedList
Definition: REveProjectionBases.hxx:46
ROOT::Experimental::REveElement::CopyVizParams
virtual void CopyVizParams(const REveElement *el)
Copy visualization parameters from element el.
Definition: REveElement.cxx:363
ROOT::Experimental::REveException
REveException Exception-type thrown by Eve classes.
Definition: REveTypes.hxx:40
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
ROOT::Experimental::REveProjectable
Definition: REveProjectionBases.hxx:38
ROOT::Experimental::REveProjectable::AddProjectedsToSet
virtual void AddProjectedsToSet(std::set< REveElement * > &set)
Add the projected elements to the set, dyn-casting them to REveElement.
Definition: REveProjectionBases.cxx:97
ROOT::Experimental::REveProjectable::PropagateMainTransparency
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.
Definition: REveProjectionBases.cxx:146
TEveManager::PreDeleteElement
void PreDeleteElement(TEveElement *element)
Called from TEveElement prior to its destruction so the framework components (like object editor) can...
Definition: TEveManager.cxx:564
REveProjectionManager.hxx
REveManager.hxx
R__ASSERT
#define R__ASSERT(e)
Definition: TError.h:120
ROOT::Experimental::REveProjectable::ClearProjectedList
virtual void ClearProjectedList()
Definition: REveProjectionBases.cxx:88
ROOT::Experimental::REveProjectable::RemoveProjected
virtual void RemoveProjected(REveProjected *p)
Definition: REveProjectionBases.hxx:60
ROOT::Experimental::REveProjected::fManager
REveProjectionManager * fManager
Definition: REveProjectionBases.hxx:87
d
#define d(i)
Definition: RSha256.hxx:102
ROOT::Experimental::REveProjectionManager::GetProjection
REveProjection * GetProjection()
Definition: REveProjectionManager.hxx:57
make_cnn_model.model
model
Definition: make_cnn_model.py:6
ROOT::Experimental
Definition: RDirectory.hxx:30
Float_t
ROOT::Experimental::REveProjectionManager
REveProjectionManager Manager class for steering of projections and managing projected objects.
Definition: REveProjectionManager.hxx:30
Char_t
char Char_t
Definition: RtypesCore.h:33
ROOT::Experimental::REveProjected::fProjectable
REveProjectable * fProjectable
Definition: REveProjectionBases.hxx:88