Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
REveDataSimpleProxyBuilder.cxx
Go to the documentation of this file.
1// @(#)root/eve7:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel: 2020
3
4/*************************************************************************
5 * Copyright (C) 1995-2020, 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
13
15#include <ROOT/REveCompound.hxx>
16#include <ROOT/REveScene.hxx>
17#include <cassert>
18#include <TClass.h>
19
20using namespace ROOT::Experimental;
21
23{
24}
25
26
28{
29}
31void
33{
34 for (auto &p: m_products)
35 {
36 if (p->m_elements)
37 {
38 REveElement *elms = p->m_elements;
39 for (auto &c: elms->RefChildren())
41 }
42 }
44 CleanLocal();
45}
46
47//______________________________________________________________________________
48
49void
51 REveElement* product, const REveViewContext* vc)
52{
53 // printf("REveDataSimpleProxyBuilder::Build %s %d\n", collection->GetCName(), collection->GetNItems());
54 auto size = collection->GetNItems();
55 auto pIdx = product->RefChildren().begin();
56 for (int index = 0; index < size; ++index)
57 {
58 const REveDataItem* di = Collection()->GetDataItem(index);
59 REveElement *itemHolder = nullptr;
60
61 if (index < product->NumChildren())
62 {
63 itemHolder = *pIdx;
64 itemHolder->SetRnrSelfChildren(true, true);
65 ++pIdx;
66 }
67 else
68 {
69 itemHolder = CreateCompound(true, true);
70 itemHolder->SetMainColor(collection->GetMainColor());
71 itemHolder->SetName(Form("%s %d", collection->GetCName(), index));
72
73 product->AddElement(itemHolder);
74 }
75
76
77 if (di->GetRnrSelf() && !di->GetFiltered())
78 {
79 Build(collection->GetDataPtr(index), index, itemHolder, vc);
80 }
81 }
82}
83
84void
86 REveElement* product, const std::string& viewType, const REveViewContext* vc)
87{
88 auto size = collection->GetNItems();
89 auto pIdx = product->RefChildren().begin();
90 for (int index = 0; index < size; ++index)
91 {
92 auto di = Collection()->GetDataItem(index);
93 REveElement* itemHolder = nullptr;
94
95 if (index < product->NumChildren())
96 {
97 itemHolder = *pIdx;
98 itemHolder->SetRnrSelfChildren(true, true);
99 ++pIdx;
100 }
101 else
102 {
103 itemHolder = CreateCompound(true, true);
104 itemHolder->SetMainColor(collection->GetMainColor());
105 itemHolder->SetName(Form("%s %d", collection->GetCName(), index));
106
107 product->AddElement(itemHolder);
108 }
109
110
111 if (di->GetRnrSelf() && !di->GetFiltered())
112 {
113 BuildViewType(collection->GetDataPtr(index), index, itemHolder, viewType, vc);
114 }
115 }
116}
117
118//______________________________________________________________________________
119
120namespace
121{
122 void applyColorAttrToChildren(REveElement* p) {
123 for (auto &it: p->RefChildren())
124 {
125 REveElement* c = it;
126 if (c->GetMainColor() != p->GetMainColor())
127 {
129 // printf("apply color %d to %s\n", p->GetMainColor(), c->GetCName());
130 }
131 applyColorAttrToChildren(c);
132 }
133 }
134}
135
136void
138{
139 // printf("REveDataSimple ProxyBuilderBase::ModelChanges >>>>> (%p) %s \n", (void*)this, Collection()->GetCName());
140 REveElement* elms = p->m_elements;
141 assert(Collection() && static_cast<int>(Collection()->GetNItems()) <= elms->NumChildren() && "can not use default modelChanges implementation");
142
143 for (auto itemIdx: iIds)
144 {
145 const REveDataItem* item = Collection()->GetDataItem(itemIdx);
146
147 // printf("Edit compound for item index %d \n", itemIdx);
148 // imitate FWInteractionList::modelChanges
149 auto itElement = elms->RefChildren().begin();
150 std::advance(itElement, itemIdx);
151 REveElement* comp = *itElement;
152 bool visible = ((!item->GetFiltered()) && item->GetRnrSelf()) && Collection()->GetRnrSelf();
153 comp->SetRnrSelf(visible);
154 comp->SetRnrChildren(visible);
155
156 // printf("comapre %d %d\n", item->GetMainColor(), comp->GetMainColor());
157 if (item->GetMainColor() != comp->GetMainColor()) {
158 //printf("ffffffffffffffffffffffff set color to comp \n");
159 comp->SetMainColor(item->GetMainColor());
160
161 }
162 applyColorAttrToChildren(comp);
163
164 if (VisibilityModelChanges(itemIdx, comp, p->m_viewType, p->m_viewContext))
165 {
166 elms->ProjectChild(comp);
167 // printf("---REveDataProxyBuilderBase project child\n");
168 }
169 else
170 {
171 LocalModelChanges(itemIdx, comp, p->m_viewContext);
172 }
173 }
174}
175
176
178REveDataSimpleProxyBuilder::CreateCompound(bool set_color, bool propagate_color_to_all_children)
179{
181 c->CSCImplySelectAllChildren();
182 c->SetPickable(true);
183 if (set_color)
184 {
185 c->SetMainColor(Collection()->GetMainColor());
186 c->SetMainTransparency(Collection()->GetMainTransparency());
187 }
188 if (propagate_color_to_all_children)
189 {
190 c->CSCApplyMainColorToAllChildren();
191 c->CSCApplyMainTransparencyToAllChildren();
192 }
193 else
194 {
195 c->CSCApplyMainColorToMatchingChildren();
196 c->CSCApplyMainTransparencyToMatchingChildren();
197 }
198 return c;
199}
200//______________________________________________________________________________
201
202bool
203REveDataSimpleProxyBuilder::VisibilityModelChanges(int idx, REveElement* iCompound, const std::string& viewType, const REveViewContext* vc)
204{
205 const REveDataItem *item = Collection()->GetDataItem(idx);
206 bool returnValue = false;
207 if (item->GetVisible() && iCompound->NumChildren() == 0) {
208 if (HaveSingleProduct())
209 Build(Collection()->GetDataPtr(idx), idx, iCompound, vc);
210 else
211 BuildViewType(Collection()->GetDataPtr(idx), idx, iCompound, viewType, vc);
212 returnValue = true;
213 }
214 return returnValue;
215}
216
217//______________________________________________________________________________
218
219void
221{
222 REveElement* elms = p->m_elements;
223 for (auto &s: Collection()->GetItemList()->RefSelectedSet()) {
224
225 auto it = elms->RefChildren().begin();
226 std::advance(it, s);
227 REveElement* comp = *it;
228 comp->FillImpliedSelectedSet(impSet);
229 }
230}
231
232//==============================================================================
233
234//==============================================================================
235
236//==============================================================================
238{
239 SetSelectionMaster(collection);
240 // deny destroy ??
241}
242
243//______________________________________________________________________________
244
246{
247 // deny destroy ??
248}
249
250//______________________________________________________________________________
251
252
254{
257
258 auto m = GetMother();
259 int idx = 0;
260 for (auto &c : m->RefChildren()) {
261 REveElement* ctest = c;
262 if (ctest == this)
263 {
264 fCollection->GetItemList()->RefSelectedSet().insert(idx);
265 break;
266 }
267 ++idx;
268 }
269
270 return fCollection->GetItemList();
271}
#define c(i)
Definition RSha256.hxx:101
char * Form(const char *fmt,...)
virtual REveElement * GetSelectionMaster() override
Returns the master element - that is:
const REveDataItem * GetDataItem(Int_t i) const
virtual void LocalModelChanges(int idx, REveElement *el, const REveViewContext *ctx)
void BuildViewType(const REveDataCollection *iCollection, REveElement *product, const std::string &viewType, const REveViewContext *) override
void FillImpliedSelected(REveElement::Set_t &impSet, Product *p) override
bool VisibilityModelChanges(int idx, REveElement *, const std::string &viewType, const REveViewContext *) override
void ModelChanges(const REveDataCollection::Ids_t &iIds, Product *p) override
REveCompound * CreateCompound(bool set_color=true, bool propagate_color_to_all_children=false)
virtual void FillImpliedSelectedSet(Set_t &impSelSet)
Populate set impSelSet with derived / dependant elements.
const char * GetCName() const
virtual void AddElement(REveElement *el)
Add el to the list of children.
virtual Bool_t GetRnrSelf() const
virtual Bool_t SetRnrChildren(Bool_t rnr)
Set render state of this element's children, i.e.
virtual void DestroyElements()
Destroy all children of this element.
virtual Bool_t SetRnrSelf(Bool_t rnr)
Set render state of this element, i.e.
void SetSelectionMaster(REveElement *el)
virtual Bool_t SetRnrSelfChildren(Bool_t rnr_self, Bool_t rnr_children)
Set state for rendering of this element and its children.
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 ProjectChild(REveElement *el, Bool_t same_depth=kTRUE)
If this is a projectable, loop over all projected replicas and add the projected image of child 'el' ...
Bool_t IsAcceptingChanges() const
Definition REveScene.hxx:97
auto * m
Definition textangle.C:8