Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
REveDataProxyBuilderBase.cxx
Go to the documentation of this file.
1// @(#)root/eve7:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel, 2018
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
12
16#include <ROOT/REveCompound.hxx>
17
18#include <cassert>
19
20using namespace ROOT::Experimental;
21
22
23REveDataProxyBuilderBase::Product::Product(std::string iViewType, const REveViewContext* c) : m_viewType(iViewType), m_viewContext(c), m_elements(0)
24{
25 m_elements = new REveCompound("ProxyProduct", "", false);
27}
28
29//______________________________________________________________________________
30
31
33 m_collection(nullptr),
34 m_haveWindow(false)
35{
36}
37
39{
40 // remove product from projected scene (RhoPhi or RhoZ)
41 for (auto i : m_elements->RefProjecteds())
42 {
43 REveElement *projected = i->GetProjectedAsElement();
44 projected->GetMother()->RemoveElement(projected);
45 }
46
47 // XXXX This might break now ... m_elements will auto drestruct, no?
48 // We don't set incdenydestroy or additional something, do we?
49
50 // remove from 3D scenes
51 if (m_elements->HasMother())
52 {
54 }
55
57}
58
59//------------------------------------------------------------------------------
62{
64}
65
66//------------------------------------------------------------------------------
67
69{
70 if (m_collection)
71 {
72 // printf("Base %p %s %s\n", m_collection, m_collection->GetCName(), m_type.c_str());
73 try
74 {
75 auto itemSize = m_collection->GetNItems(); //cashed
76
78
80 return;
81
82 for (auto &pp: m_products)
83 {
84 // printf("build() %s \n", m_collection->GetCName());
85 REveElement* elms = pp->m_elements;
86 auto oldSize = elms->NumChildren();
87
89 {
90 Build(m_collection, elms, pp->m_viewContext);
91 }
92 else
93 {
94 BuildViewType(m_collection, elms, pp->m_viewType, pp->m_viewContext);
95 }
96
97 // Project all children of current product.
98 // If product is not registered into any projection-manager,
99 // this does nothing.
100 REveProjectable* pable = dynamic_cast<REveProjectable*>(elms);
101 if (pable->HasProjecteds())
102 {
103 // loop projected holders
104 for (auto &prj: pable->RefProjecteds())
105 {
106 REveProjectionManager *pmgr = prj->GetManager();
107 Float_t oldDepth = pmgr->GetCurrentDepth();
109 Int_t cnt = 0;
110
111 REveElement *projectedAsElement = prj->GetProjectedAsElement();
112 auto parentIt = projectedAsElement->RefChildren().begin();
113 for (auto &prod: elms->RefChildren())
114 {
115 // reused projected holder
116 if (cnt < oldSize)
117 {
118 /*
119 // AMT no use case for this at the moment
120 if ((*parentIt)->NumChildren()) {
121 // update projected (mislleading name)
122 for ( REveElement::List_i pci = (*parentIt)->BeginChildren(); pci != (*parentIt)->EndChildren(); pci++)
123 pmgr->ProjectChildrenRecurse(*pci);
124 }
125 */
126 // import projectable
127 pmgr->SubImportChildren(prod, *parentIt);
128
129 ++parentIt;
130 }
131 else if (cnt < itemSize)
132 {
133 // new product holder
134 pmgr->SubImportElements(prod, projectedAsElement);
135 }
136 else
137 {
138 break;
139 }
140 ++cnt;
141 }
142 pmgr->SetCurrentDepth(oldDepth);
143 }
144 }
145
146 /*
147 if (m_interactionList && itemSize > oldSize)
148 {
149 auto elIt = elms->RefChildren().begin();
150 for (size_t cnt = 0; cnt < itemSize; ++cnt, ++elIt)
151 {
152 if (cnt >= oldSize )
153 m_interactionList->Added(*elIt, cnt);
154 }
155 }
156 */
157 }
158 }
159 catch (const std::runtime_error& iException)
160 {
161 std::cout << "Caught exception in build function for item " << m_collection->GetName() << ":\n"
162 << iException.what() << std::endl;
163 exit(1);
164 }
165 }
166}
167
168//------------------------------------------------------------------------------
169
170void
172{
173 assert("virtual Build(const REveEventItem*, REveElement*, const REveViewContext*) not implemented by inherited class");
174}
175
176
177void
179{
180 assert("virtual BuildViewType(const FWEventItem*, TEveElementList*, FWViewType::EType, const FWViewContext*) not implemented by inherited class");
181}
182
183//------------------------------------------------------------------------------
184
186REveDataProxyBuilderBase::CreateProduct( const std::string& viewType, const REveViewContext* viewContext)
187{
188 if ( m_products.empty() == false)
189 {
190 if (HaveSingleProduct()) {
191 return m_products.back()->m_elements;
192 }
193 else {
194
195 for (auto &prod: m_products)
196 {
197 if (viewType == prod->m_viewType)
198 return prod->m_elements;
199 }
200 }
201 }
202
203 auto product = new Product(viewType, viewContext);
204 m_products.push_back(product);
205
206 if (m_collection)
207 {
208 // debug info in eve browser
209 product->m_elements->SetName(Form("product %s", m_collection->GetCName()));
210 }
211 return product->m_elements;
212}
213
214//______________________________________________________________________________
215
216void
218{
219 // Nothing to be done in base class.
220 // Visibility, main color and main transparency are handled automatically throught compound.
221}
222//------------------------------------------------------------------------------
223
224void
226{
227 for (auto &prod: m_products)
228 {
229 FillImpliedSelected(impSet, prod);
230 }
231}
232
233//------------------------------------------------------------------------------
234
235void
237{
238 if(m_haveWindow) {
239 for (auto &prod: m_products)
240 {
241 ModelChanges(iIds, prod);
242 }
243 m_modelsChanged = false;
244 } else {
245 m_modelsChanged = true;
246 }
247}
248
249
250//______________________________________________________________________________
251void
253{
254 if(m_haveWindow) {
255 Build();
256 }
257}
258
259//------------------------------------------------------------------------------
260
261void
263{
264 SetupElement(el, color);
265 // AMT -- this temprary to get right tooltip
266 el->SetName(parent->GetName());
267 parent->AddElement(el);
268}
269
270/** This method is invoked to setup the per element properties of the various
271 objects being drawn.
272 */
273void
275{
277 el->SetPickable(true);
278
279 if (color)
280 {
285 }
286}
287
288
289//------------------------------------------------------------------------------
290
292{
293 // Cleans local common element list.
294 for (auto &prod: m_products)
295 {
296 if (prod->m_elements)
297 prod->m_elements->DestroyElements();
298 }
299
300 CleanLocal();
301}
302
304{
305 // Cleans local common element list.
306}
307
309{
310 m_collection = nullptr;
311
312 CleanLocal();
313
314 for (auto &prod: m_products)
315 {
316 // (*i)->m_scaleConnection.disconnect();
317 delete prod;
318 }
319
320 m_products.clear();
321}
322
324{
325 return false;
326}
327
329{
330 m_haveWindow = iHaveAWindow;
331}
#define c(i)
Definition RSha256.hxx:101
char * Form(const char *fmt,...)
virtual void BuildViewType(const REveDataCollection *iItem, REveElement *product, const std::string &viewType, const REveViewContext *)
virtual bool VisibilityModelChanges(int idx, REveElement *, const std::string &viewType, const REveViewContext *)
virtual void LocalModelChanges(int idx, REveElement *el, const REveViewContext *ctx)
REveElement * CreateProduct(const std::string &viewType, const REveViewContext *)
virtual void CollectionBeingDestroyed(const REveDataCollection *)
void ModelChanges(const REveDataCollection::Ids_t &)
void SetupElement(REveElement *el, bool color=true)
This method is invoked to setup the per element properties of the various objects being drawn.
void SetupAddElement(REveElement *el, REveElement *parent, bool set_color=true)
const std::string & GetName() const
virtual void SetMainTransparency(Char_t t)
Set main-transparency.
virtual void Annihilate()
Optimized destruction without check of reference-count.
const char * GetCName() const
virtual void AddElement(REveElement *el)
Add el to the list of children.
virtual Bool_t GetRnrSelf() const
virtual Char_t GetMainTransparency() const
void IncDenyDestroy()
Increases the deny-destroy count of the element.
std::set< REveElement * > Set_t
virtual void SetMainColor(Color_t color)
Set main color of the element.
virtual Color_t GetMainColor() const
void SetName(const std::string &name)
Set name of an element.
virtual void RemoveElement(REveElement *el)
Remove el from the list of children.
REveProjectionManager Manager class for steering of projections and managing projected objects.
virtual REveElement * SubImportElements(REveElement *el, REveElement *proj_parent)
Recursively import elements and apply projection to the newly imported objects.
virtual Int_t SubImportChildren(REveElement *el, REveElement *proj_parent)
Recursively import children elements of el and apply projection to the newly imported objects.
const char * cnt
Definition TXMLSetup.cxx:75
Product(std::string viewType, const REveViewContext *c)