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"
14#include "TEveManager.h"
15
16#include <cassert>
17
18/** \class TEveProjectable
19\ingroup TEve
20Abstract base-class for non-linear projectable objects.
21
22Via ProjectedClass(const TEveProjection* p) method it returns a
23TClass instance for the projected class and keeps references to the
24projected objects.
25
26It is assumed that all classes deriving from TEveProjectable are also
27derived from TEveElement.
28
29See 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
86void 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
149Abstract base class for classes that hold results of a non-linear
150projection transformation.
151
152It is assumed that all classes deriving from TEveProjected are also
153derived 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;
197 fProjectable = model;
199}
200
201////////////////////////////////////////////////////////////////////////////////
202/// Remove reference to projectable.
203
204void 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 {
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}
#define d(i)
Definition: RSha256.hxx:102
char Char_t
Definition: RtypesCore.h:31
const Bool_t kFALSE
Definition: RtypesCore.h:90
short Color_t
Definition: RtypesCore.h:81
float Float_t
Definition: RtypesCore.h:55
#define ClassImp(name)
Definition: Rtypes.h:361
#define R__ASSERT(e)
Definition: TError.h:96
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition: TEveElement.h:34
void StampTransBBox()
Definition: TEveElement.h:396
virtual void CopyVizParams(const TEveElement *el)
Copy visualization parameters from element el.
Exception class thrown by TEve classes and macros.
Definition: TEveUtil.h:102
void PreDeleteElement(TEveElement *element)
Called from TEveElement prior to its destruction so the framework components (like object editor) can...
Abstract base-class for non-linear projectable objects.
virtual void ClearProjectedList()
TEveProjectable()
Constructor.
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.
virtual void AddProjected(TEveProjected *p)
virtual void AddProjectedsToSet(std::set< TEveElement * > &set)
Add the projected elements to the set, dyn-casting them to TEveElement.
virtual void PropagateRenderState(Bool_t rnr_self, Bool_t rnr_children)
Set render state of projecteds.
virtual void RemoveProjected(TEveProjected *p)
virtual ~TEveProjectable()
Destructor.
ProjList_t fProjectedList
virtual void PropagateVizParams(TEveElement *el=0)
Set visualization parameters of projecteds.
virtual void AnnihilateProjecteds()
Optimized destroy of projected elements with condition there is only one parent for projected element...
virtual void PropagateMainColor(Color_t color, Color_t old_color)
Set main color of projecteds if their color is the same as old_color.
std::list< TEveProjected * >::iterator ProjList_i
Abstract base class for classes that hold results of a non-linear projection transformation.
virtual void SetDepth(Float_t d)
Set depth coordinate for the element.
TEveProjected()
Constructor.
TEveProjectable * fProjectable
TEveProjectionManager * fManager
virtual void SetDepthLocal(Float_t d)
Base-class implementation – just sets fDepth.
virtual ~TEveProjected()
Destructor.
virtual void SetProjection(TEveProjectionManager *mng, TEveProjectable *model)
Sets projection manager and reference in the projectable object.
virtual TEveElement * GetProjectedAsElement()
Returns this projected dynamic-casted to TEveElement.
virtual void UnRefProjectable(TEveProjectable *assumed_parent, bool notifyParent=true)
Remove reference to projectable.
void SetDepthCommon(Float_t d, TEveElement *el, Float_t *bbox)
Utility function to update the z-values of the bounding-box.
Manager class for steering of projections and managing projected objects.
TEveProjection * GetProjection()
virtual Bool_t Is2D() const =0