Logo ROOT  
Reference Guide
REveCompound.cxx
Go to the documentation of this file.
1// @(#)root/eve7:$Id$
2// Author: Matevz Tadel 2007, 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#include <ROOT/REveCompound.hxx>
13
14#include "TClass.h"
15
16using namespace ROOT::Experimental;
17namespace REX = ROOT::Experimental;
18
19/** \class REveCompound
20\ingroup REve
21Description of REveCompound
22*/
23
24////////////////////////////////////////////////////////////////////////////////
25/// Constructor.
26
27REveCompound::REveCompound(const std::string& n, const std::string& t,
28 Bool_t doColor, Bool_t doTransparency) :
29 REveElement (n, t),
30 fCompoundOpen (0),
31 fDoColor (doColor),
32 fDoTransparency (doTransparency)
33{
34 if (fDoColor)
35 {
37 }
38}
39
40////////////////////////////////////////////////////////////////////////////////
41/// SetMainColor for the compound.
42/// The color is also propagated to children with compound set to this
43/// whose current color is the same as the old color.
44///
45/// The following CompoundSelectionColorBits have further influence:
46/// - kCSCBApplyMainColorToAllChildren - apply color to all children;
47/// - kCSCBApplyMainColorToMatchingChildren - apply color to children who have
48/// matching old color.
49
51{
52 if (!fDoColor) return;
53
54 Color_t old_color = GetMainColor();
55
57
60
61 for (auto &c: fChildren)
62 {
63 if (color_all || (color_matching && c->GetMainColor() == old_color) ||
64 (c->GetCompound() == this && c->GetMainColor() == old_color))
65 {
66 c->SetMainColor(color);
67 }
68 }
69}
70
71////////////////////////////////////////////////////////////////////////////////
72/// SetMainTransparency for the compound.
73/// The transparency is also propagated to children with compound set to this
74/// whose current transparency is the same as the old transparency.
75///
76/// The following CompoundSelectionColorBits have further influence:
77/// - kCSCBApplyMainTransparencyToAllChildren - apply transparency to all children;
78/// - kCSCBApplyMainTransparencyToMatchingChildren - apply transparency to children who have
79/// matching transparency.
80
82{
83 if ( ! fDoTransparency) return;
84
86
88
91
92 for (auto &c: fChildren) {
93 if (chg_all || (chg_matching && c->GetMainTransparency() == old_t) ||
94 (c->GetCompound() == this && c->GetMainTransparency() == old_t))
95 {
96 c->SetMainTransparency(t);
97 }
98 }
99}
100
101////////////////////////////////////////////////////////////////////////////////
102/// Call base-class implementation.
103/// If compound is open and compound of the new element is not set,
104/// the el's compound is set to this.
105/// You might also want to call RecheckImpliedSelections().
106
108{
110 if (IsCompoundOpen() && el->GetCompound() == nullptr)
111 el->SetCompound(this);
112}
113
114////////////////////////////////////////////////////////////////////////////////
115/// Decompoundofy el, call base-class version.
116
118{
119 if (el->GetCompound() == this)
120 el->SetCompound(0);
121
123}
124
125////////////////////////////////////////////////////////////////////////////////
126/// Decompoundofy children, call base-class version.
127
129{
130 for (auto &c: fChildren) {
131 if (c->GetCompound() == this)
132 c->SetCompound(nullptr);
133 }
134
136}
137
138////////////////////////////////////////////////////////////////////////////////
139/// Recurse on all children that are in this compound and
140/// call the base-class version.
141/// If SelectionColorBit kSCBImplySelectAllChildren is set, then all
142/// children are added to the set.
143///
144/// Note that projected replicas of the compound will be added to
145/// the set in base-class function that handles projectable.
146
148{
150
151 for (auto &c: fChildren) {
152 if (select_all || c->GetCompound() == this) {
153 if (impSelSet.insert(c).second)
154 c->FillImpliedSelectedSet(impSelSet);
155 }
156 }
157
159}
160
161////////////////////////////////////////////////////////////////////////////////
162/// Virtual from REveProjectable, returns REveCompoundProjected class.
163
165{
166 return TClass::GetClass<REveCompoundProjected>();
167}
168
169
170/** \class REveCompoundProjected
171\ingroup REve
172Description of REveCompoundProjected
173*/
174
175////////////////////////////////////////////////////////////////////////////////
176/// Constructor.
177
179 REveCompound (),
181{
182}
183
184////////////////////////////////////////////////////////////////////////////////
185/// Revert back to the behaviour of REveElement as color
186/// is propagated:
187/// 1. from projectable -> projected
188/// 2. from compound -> compound elements
189/// and we do not need to do this twice for projected-compound-elements.
190
192{
194}
#define c(i)
Definition: RSha256.hxx:101
char Char_t
Definition: RtypesCore.h:29
bool Bool_t
Definition: RtypesCore.h:59
short Color_t
Definition: RtypesCore.h:79
virtual void SetMainColor(Color_t color)
Revert back to the behaviour of REveElement as color is propagated:
void AddElement(REveElement *el) override
Call base-class implementation.
void FillImpliedSelectedSet(Set_t &impSelSet) override
Recurse on all children that are in this compound and call the base-class version.
void RemoveElementsLocal() override
Decompoundofy children, call base-class version.
REveCompound(const REveCompound &)
TClass * ProjectedClass(const REveProjection *p) const override
Virtual from REveProjectable, returns REveCompoundProjected class.
void RemoveElementLocal(REveElement *el) override
Decompoundofy el, call base-class version.
void SetMainTransparency(Char_t t) override
SetMainTransparency for the compound.
void SetMainColor(Color_t color) override
SetMainColor for the compound.
virtual void FillImpliedSelectedSet(Set_t &impSelSet)
Populate set impSelSet with derived / dependant elements.
virtual void RemoveElementsLocal()
Perform additional local removal of all elements.
void SetCompound(REveCompound *c)
virtual void SetMainTransparency(Char_t t)
Set main-transparency.
void SetupDefaultColorAndTransparency(Color_t col, Bool_t can_edit_color, Bool_t can_edit_transparency)
Set up element to use built-in main color and set flags allowing editing of main color and transparen...
virtual void AddElement(REveElement *el)
Add el to the list of children.
virtual void RemoveElementLocal(REveElement *el)
Perform additional local removal of el.
virtual Char_t GetMainTransparency() const
Bool_t TestCSCBits(UChar_t f) const
std::set< REveElement * > Set_t
Definition: REveElement.hxx:79
virtual void SetMainColor(Color_t color)
Set main color of the element.
virtual Color_t GetMainColor() const
REveProjection Base for specific classes that implement non-linear projections.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:75
const Int_t n
Definition: legend1.C:16