Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
18using namespace ROOT::Experimental;
19namespace REX = ROOT::Experimental;
20
21/** \class REveProjectable
22\ingroup REve
23Abstract base-class for non-linear projectable objects.
24
25Via ProjectedClass(const REveProjection* p) method it returns a
26TClass instance for the projected class and keeps references to the
27projected objects.
28
29It is assumed that all classes deriving from REveProjectable are also
30derived from REveElement.
31
32See also REveProjectionManager::ImportElements().
33*/
34
35////////////////////////////////////////////////////////////////////////////////
36/// Constructor.
37
38REveProjectable::REveProjectable()
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 {
60
61 p->UnRefProjectable(this);
62 REveElement* el = p->GetProjectedAsElement();
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
97void 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
159Abstract base class for classes that hold results of a non-linear
160projection transformation.
161
162It is assumed that all classes deriving from REveProjected are also
163derived 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;
195 fProjectable = model;
197}
198
199////////////////////////////////////////////////////////////////////////////////
200/// Remove reference to projectable.
201
202void 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()) {
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}
#define d(i)
Definition RSha256.hxx:102
short Color_t
Definition RtypesCore.h:92
char Char_t
Definition RtypesCore.h:37
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
#define R__ASSERT(e)
Definition TError.h:117
winID h TVirtualViewer3D TVirtualGLPainter p
virtual void Annihilate()
Optimized destruction without check of reference-count.
virtual void CopyVizParams(const REveElement *el)
Copy visualization parameters from element el.
REveException Exception-type thrown by Eve classes.
Definition REveTypes.hxx:41
void PreDeleteElement(REveElement *element)
Called from REveElement prior to its destruction so the framework components (like object editor) can...
virtual void AddProjectedsToSet(std::set< REveElement * > &set)
Add the projected elements to the set, dyn-casting them to REveElement.
virtual void PropagateVizParams(REveElement *el=nullptr)
Set visualization parameters of projecteds.
virtual void RemoveProjected(REveProjected *p)
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 AddProjected(REveProjected *p)
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 REveElement * GetProjectedAsElement()
Returns this projected dynamic-casted to REveElement.
virtual void SetProjection(REveProjectionManager *mng, REveProjectable *model)
Sets projection manager and reference in the projectable object.
virtual void UnRefProjectable(REveProjectable *assumed_parent, bool notifyParent=true)
Remove reference to projectable.
void SetDepthCommon(Float_t d, REveElement *el, Float_t *bbox)
Utility function to update the z-values of the bounding-box.
virtual void SetDepth(Float_t d)
Set depth coordinate for the element.
virtual void SetDepthLocal(Float_t d)
Base-class implementation – just sets fDepth.
REveProjectionManager Manager class for steering of projections and managing projected objects.
virtual Bool_t Is2D() const =0
R__EXTERN REveManager * gEve