Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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;
17
18/** \class REveCompound
19\ingroup REve
20Description of REveCompound
21*/
22
23////////////////////////////////////////////////////////////////////////////////
24/// Constructor.
25
26REveCompound::REveCompound(const std::string& n, const std::string& t,
27 Bool_t doColor, Bool_t doTransparency) :
28 REveElement (n, t),
29 fCompoundOpen (0),
30 fDoColor (doColor),
31 fDoTransparency (doTransparency)
32{
33 if (fDoColor)
34 {
36 }
37}
38
39////////////////////////////////////////////////////////////////////////////////
40/// SetMainColor for the compound.
41/// The color is also propagated to children with compound set to this
42/// whose current color is the same as the old color.
43///
44/// The following CompoundSelectionColorBits have further influence:
45/// - kCSCBApplyMainColorToAllChildren - apply color to all children;
46/// - kCSCBApplyMainColorToMatchingChildren - apply color to children who have
47/// matching old color.
48
50{
51 if (!fDoColor) return;
52
53 Color_t old_color = GetMainColor();
54
56
59
60 for (auto &c: fChildren)
61 {
62 if (color_all || (color_matching && c->GetMainColor() == old_color) ||
63 (c->GetCompound() == this && c->GetMainColor() == old_color))
64 {
65 c->SetMainColor(color);
66 }
67 }
68}
69
70////////////////////////////////////////////////////////////////////////////////
71/// SetMainTransparency for the compound.
72/// The transparency is also propagated to children with compound set to this
73/// whose current transparency is the same as the old transparency.
74///
75/// The following CompoundSelectionColorBits have further influence:
76/// - kCSCBApplyMainTransparencyToAllChildren - apply transparency to all children;
77/// - kCSCBApplyMainTransparencyToMatchingChildren - apply transparency to children who have
78/// matching transparency.
79
81{
82 if ( ! fDoTransparency) return;
83
85
87
90
91 for (auto &c: fChildren) {
92 if (chg_all || (chg_matching && c->GetMainTransparency() == old_t) ||
93 (c->GetCompound() == this && c->GetMainTransparency() == old_t))
94 {
95 c->SetMainTransparency(t);
96 }
97 }
98}
99
100////////////////////////////////////////////////////////////////////////////////
101/// Call base-class implementation.
102/// If compound is open and compound of the new element is not set,
103/// the el's compound is set to this.
104/// You might also want to call RecheckImpliedSelections().
105
107{
109 if (IsCompoundOpen() && el->GetCompound() == nullptr)
110 el->SetCompound(this);
111}
112
113////////////////////////////////////////////////////////////////////////////////
114/// Decompoundofy el, call base-class version.
115
117{
118 if (el->GetCompound() == this)
119 el->SetCompound(0);
120
122}
123
124////////////////////////////////////////////////////////////////////////////////
125/// Decompoundofy children, call base-class version.
126
128{
129 for (auto &c: fChildren) {
130 if (c->GetCompound() == this)
131 c->SetCompound(nullptr);
132 }
133
135}
136
137////////////////////////////////////////////////////////////////////////////////
138/// Recurse on all children that are in this compound and
139/// call the base-class version.
140/// If SelectionColorBit kSCBImplySelectAllChildren is set, then all
141/// children are added to the set.
142///
143/// Note that projected replicas of the compound will be added to
144/// the set in base-class function that handles projectable.
145
146void REveCompound::FillImpliedSelectedSet(Set_t& impSelSet, const std::set<int>& sec_idcs)
147{
149
150 for (auto &c: fChildren) {
151 if (select_all || c->GetCompound() == this) {
152 if (impSelSet.insert(c).second) {
153 c->FillImpliedSelectedSet(impSelSet, sec_idcs);
154 }
155 }
156 }
157
158 REveElement::FillImpliedSelectedSet(impSelSet, sec_idcs);
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
short Color_t
Definition RtypesCore.h:92
char Char_t
Definition RtypesCore.h:37
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 RemoveElementsLocal() override
Decompoundofy children, call base-class version.
void FillImpliedSelectedSet(Set_t &impSelSet, const std::set< int > &) override
Recurse on all children that are in this compound and call the base-class version.
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 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
virtual void SetMainColor(Color_t color)
Set main color of the element.
virtual void FillImpliedSelectedSet(Set_t &impSelSet, const std::set< int > &)
Populate set impSelSet with derived / dependant elements.
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:81
const Int_t n
Definition legend1.C:16