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