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#include <ROOT/RLogger.hxx>
18#include <ROOT/REveScene.hxx>
19
20#include <cassert>
21
22using namespace ROOT::Experimental;
23
24
25REveDataProxyBuilderBase::Product::Product(std::string iViewType, const REveViewContext* c) : m_viewType(iViewType), m_viewContext(c), m_elements(nullptr)
26{
27 m_elements = new REveCompound("ProxyProduct", "", false);
29}
30
31//______________________________________________________________________________
32
33
35 m_collection(nullptr),
36 m_haveWindow(false)
37{
38}
39
41{
42 // remove product from projected scene (RhoPhi or RhoZ)
43 for (auto i : m_elements->RefProjecteds())
44 {
45 REveElement *projected = i->GetProjectedAsElement();
46 projected->GetMother()->RemoveElement(projected);
47 }
48
49 // XXXX This might break now ... m_elements will auto drestruct, no?
50 // We don't set incdenydestroy or additional something, do we?
51
52 // remove from 3D scenes
54 {
56 }
57
61//------------------------------------------------------------------------------
62
64{
66}
67
68//------------------------------------------------------------------------------
69
71{
72 if (m_collection)
73 {
74 // printf("REveDataProxyBuilderBase::Build %p %s products %lu\n", m_collection, m_collection->GetCName(), m_products.size());
75 try
76 {
77 auto itemSize = m_collection->GetNItems(); //cashed
78
79 Clean();
80
82 return;
83
84 for (auto &pp: m_products)
85 {
86 REveElement* product = pp->m_elements;
87 auto oldSize = product->NumChildren();
89 {
90 BuildProduct(m_collection, product, pp->m_viewContext);
91 }
92 else
93 {
94 BuildProductViewType(m_collection, product, 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* pableProduct = dynamic_cast<REveProjectable*>(product);
101 if (pableProduct->HasProjecteds())
102 {
103 // loop projected holders
104 for (auto &projectedProduct: pableProduct->RefProjecteds())
105 {
106 REveProjectionManager *pmgr = projectedProduct->GetManager();
107 Float_t oldDepth = pmgr->GetCurrentDepth();
109 Int_t cnt = 0;
110 REveElement *projectedProductAsElement = projectedProduct->GetProjectedAsElement();
111 // printf("projectedProduct children %d, product children %d\n", projectedProductAsElement->NumChildren(), product->NumChildren());
112 auto parentIt = projectedProductAsElement->RefChildren().begin();
113 for (auto &holder: product->RefChildren())
114 {
115 // reused projected holder
116 if (cnt < oldSize)
117 {
118 pmgr->SubImportChildren(holder, *parentIt);
119 ++parentIt;
120 }
121 else if (cnt < itemSize)
122 {
123 // new product holder
124 pmgr->SubImportElements(holder, projectedProductAsElement);
125 }
126 else {
127 break;
128 }
129 ++cnt;
130 }
131 pmgr->SetCurrentDepth(oldDepth);
132 }
133 }
134 }
135 }
136 catch (const std::runtime_error &iException) {
137 R__LOG_ERROR(REveLog()) << "Caught exception in build function for item " << m_collection->GetName() << ":\n"
138 << iException.what() << std::endl;
139 }
140 }
141}
142
143//------------------------------------------------------------------------------
144
145void
147{
148 assert("virtual Build(const REveEventItem*, REveElement*, const REveViewContext*) not implemented by inherited class");
149}
150
151
152void
154{
155 assert("virtual BuildViewType(const FWEventItem*, TEveElementList*, FWViewType::EType, const FWViewContext*) not implemented by inherited class");
156}
157
158//------------------------------------------------------------------------------
159
161REveDataProxyBuilderBase::CreateProduct( const std::string& viewType, const REveViewContext* viewContext)
162{
163 if ( m_products.empty() == false)
164 {
165 if (HaveSingleProduct()) {
166 return m_products.back()->m_elements;
167 }
168 else {
169
170 for (auto &prod: m_products)
171 {
172 if (viewType == prod->m_viewType)
173 return prod->m_elements;
174 }
175 }
176 }
177
178 auto product = new Product(viewType, viewContext);
179 m_products.push_back(product);
180
181 if (m_collection)
182 {
183 // debug info in eve browser
184 product->m_elements->SetName(TString::Format("product %s viewtype %s", m_collection->GetCName(), viewType.c_str()).Data());
185 }
186 return product->m_elements;
187}
188
189//______________________________________________________________________________
190
191void
193{
194 // Nothing to be done in base class.
195 // Visibility, main color and main transparency are handled automatically throught compound.
196}
197//------------------------------------------------------------------------------
198
199void
201{
202 for (auto &prod: m_products)
203 {
204 FillImpliedSelected(impSet, sec_idcs, prod);
205 }
206}
207
208//------------------------------------------------------------------------------
209
210void
212{
213 if(m_haveWindow) {
214 for (auto &prod: m_products)
215 {
216 ModelChanges(iIds, prod);
217 }
218 m_modelsChanged = false;
219 } else {
220 m_modelsChanged = true;
221 }
222}
223
224
225//______________________________________________________________________________
226void
228{
229 if(m_haveWindow) {
230 Build();
231 }
232}
233
234//------------------------------------------------------------------------------
235
236void
238{
239 SetupElement(el, color);
240 // AMT -- this temprary to get right tooltip
241 el->SetName(parent->GetName());
242 parent->AddElement(el);
243}
244
245/** This method is invoked to setup the per element properties of the various
246 objects being drawn.
247 */
248void
250{
252 el->SetPickable(true);
253
254 if (color)
255 {
260 }
261}
262
263//------------------------------------------------------------------------------
264
266{
267 for (auto &prod : m_products) {
268 ScaleProduct(prod->m_elements, prod->m_viewType);
269 }
270}
271//------------------------------------------------------------------------------
272
274{
275 // Cleans local common element list.
276 for (auto &prod: m_products)
277 {
278 if (prod->m_elements)
279 prod->m_elements->DestroyElements();
280 }
281
282 CleanLocal();
283}
284
286{
287 // Cleans local common element list.
288}
289
291{
292 m_collection = nullptr;
293
294 CleanLocal();
295
296 for (auto &prod: m_products)
297 {
298 // (*i)->m_scaleConnection.disconnect();
299 delete prod;
300 }
301
302 m_products.clear();
303}
304
306{
307 return false;
308}
309
311{
312 m_haveWindow = iHaveAWindow;
313}
#define R__LOG_ERROR(...)
Definition RLogger.hxx:362
#define c(i)
Definition RSha256.hxx:101
virtual void ScaleProduct(REveElement *, const std::string &)
virtual bool VisibilityModelChanges(int idx, REveElement *, const std::string &viewType, const REveViewContext *)
virtual void LocalModelChanges(int idx, REveElement *el, const REveViewContext *ctx)
virtual REveElement * CreateProduct(const std::string &viewType, const REveViewContext *)
virtual void CollectionBeingDestroyed(const REveDataCollection *)
virtual void BuildProduct(const REveDataCollection *iItem, REveElement *product, const REveViewContext *)
void FillImpliedSelected(REveElement::Set_t &impSet, const std::set< int > &)
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)
virtual void BuildProductViewType(const REveDataCollection *iItem, REveElement *product, const std::string &viewType, const REveViewContext *)
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 * Data() const
Definition TString.h:376
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2378
RLogChannel & REveLog()
Log channel for Eve diagnostics.
Definition REveTypes.cxx:51
Product(std::string viewType, const REveViewContext *c)