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