Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
32
33////////////////////////////////////////////////////////////////////////////////
34/// Constructor.
35
39
40////////////////////////////////////////////////////////////////////////////////
41/// Destructor.
42/// Force projected replicas to unreference *this, then destroy them.
43
45{
46 while ( ! fProjectedList.empty())
47 {
49 p->UnRefProjectable(this);
50 TEveElement* el = p->GetProjectedAsElement();
51 assert(el);
52 {
54 delete el;
55 }
56 }
57}
58
59////////////////////////////////////////////////////////////////////////////////
60/// Optimized destroy of projected elements with condition
61/// there is only one parent for projected element. Method is
62/// called from TEveElement::Annihilate().
63
65{
66 for (ProjList_i i=fProjectedList.begin(); i!=fProjectedList.end(); ++i)
67 {
68 (*i)->UnRefProjectable(this, kFALSE);
69 (*i)->GetProjectedAsElement()->Annihilate();
70 }
71 fProjectedList.clear();
72}
73
74////////////////////////////////////////////////////////////////////////////////
75
80
81////////////////////////////////////////////////////////////////////////////////
82/// Add the projected elements to the set, dyn-casting them to
83/// TEveElement.
84
85void TEveProjectable::AddProjectedsToSet(std::set<TEveElement*>& set)
86{
87 for (ProjList_i i=fProjectedList.begin(); i!=fProjectedList.end(); ++i)
88 {
89 set.insert((*i)->GetProjectedAsElement());
90 }
91}
92
93////////////////////////////////////////////////////////////////////////////////
94/// Set visualization parameters of projecteds.
95/// Use element el as model. If el == 0 (default), this casted to
96/// TEveElement is used.
97
99{
100 if (el == nullptr)
101 el = dynamic_cast<TEveElement*>(this);
102
103 for (ProjList_i i=fProjectedList.begin(); i!=fProjectedList.end(); ++i)
104 {
105 (*i)->GetProjectedAsElement()->CopyVizParams(el);
106 }
107}
108
109////////////////////////////////////////////////////////////////////////////////
110/// Set render state of projecteds.
111
113{
114 for (ProjList_i i=fProjectedList.begin(); i!=fProjectedList.end(); ++i)
115 {
116 if ((*i)->GetProjectedAsElement()->SetRnrSelfChildren(rnr_self, rnr_children))
117 (*i)->GetProjectedAsElement()->ElementChanged();
118 }
119}
120
121////////////////////////////////////////////////////////////////////////////////
122/// Set main color of projecteds if their color is the same as old_color.
123
125{
126 for (ProjList_i i=fProjectedList.begin(); i!=fProjectedList.end(); ++i)
127 {
128 if ((*i)->GetProjectedAsElement()->GetMainColor() == old_color)
129 (*i)->GetProjectedAsElement()->SetMainColor(color);
130 }
131}
132
133////////////////////////////////////////////////////////////////////////////////
134/// Set main transparency of projecteds if their transparency is the
135/// same as the old one.
136
138{
139 for (ProjList_i i=fProjectedList.begin(); i!=fProjectedList.end(); ++i)
140 {
141 if ((*i)->GetProjectedAsElement()->GetMainTransparency() == old_t)
142 (*i)->GetProjectedAsElement()->SetMainTransparency(t);
143 }
144}
145
146/** \class TEveProjected
147\ingroup TEve
148Abstract base class for classes that hold results of a non-linear
149projection transformation.
150
151It is assumed that all classes deriving from TEveProjected are also
152derived from TEveElement.
153*/
154
155
156////////////////////////////////////////////////////////////////////////////////
157/// Constructor.
158
160 fManager (nullptr),
161 fProjectable (nullptr),
162 fDepth (0)
163{
164}
165
166////////////////////////////////////////////////////////////////////////////////
167/// Destructor.
168/// If fProjectable is non-null, *this is removed from its list of
169/// projected replicas.
170
175
176////////////////////////////////////////////////////////////////////////////////
177/// Returns this projected dynamic-casted to TEveElement.
178/// This is needed as class TEveProjected is used as secondary
179/// inheritance.
180
182{
183 return dynamic_cast<TEveElement*>(this);
184}
185
186////////////////////////////////////////////////////////////////////////////////
187/// Sets projection manager and reference in the projectable object. Method called
188/// immediately after default constructor.
189/// See also TEveProjectionManager::ImportElements().
190
198
199////////////////////////////////////////////////////////////////////////////////
200/// Remove reference to projectable.
201
203{
204 static const TEveException eH("TEveProjected::UnRefProjectable ");
205
207
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 {
222 }
223 else
224 {
225 fDepth = d;
226 }
227}
228
229////////////////////////////////////////////////////////////////////////////////
230/// Utility function to update the z-values of the bounding-box.
231/// As this is an abstract interface, the element and bbox pointers
232/// must be passed from outside.
233
235{
236 Float_t delta = d - fDepth;
237 fDepth = d;
238 if (bbox) {
239 bbox[4] += delta;
240 bbox[5] += delta;
241 el->StampTransBBox();
242 }
243}
244
245////////////////////////////////////////////////////////////////////////////////
246/// Base-class implementation -- just sets fDepth.
247
#define d(i)
Definition RSha256.hxx:102
short Color_t
Color number (short)
Definition RtypesCore.h:99
char Char_t
Character 1 byte (char)
Definition RtypesCore.h:51
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:125
R__EXTERN TEveManager * gEve
winID h TVirtualViewer3D TVirtualGLPainter p
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition TEveElement.h:36
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()
virtual void PropagateVizParams(TEveElement *el=nullptr)
Set visualization parameters of projecteds.
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.
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