forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TEveCompound.cxx
186 lines (149 loc) · 6.06 KB
/
TEveCompound.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
// @(#)root/eve:$Id$
// Author: Matevz Tadel 2007
/*************************************************************************
* Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#include "TEveCompound.h"
/** \class TEveCompound
\ingroup TEve
Description of TEveCompound
*/
ClassImp(TEveCompound);
////////////////////////////////////////////////////////////////////////////////
/// Constructor.
TEveCompound::TEveCompound(const char* n, const char* t, Bool_t doColor, Bool_t doTransparency) :
TEveElementList (n, t, doColor, doTransparency),
fCompoundOpen (0)
{
}
////////////////////////////////////////////////////////////////////////////////
/// SetMainColor for the compound.
/// The color is also propagated to children with compound set to this
/// whose current color is the same as the old color.
///
/// The following CompoundSelectionColorBits have further influence:
/// - kCSCBApplyMainColorToAllChildren - apply color to all children;
/// - kCSCBApplyMainColorToMatchingChildren - apply color to children who have
/// matching old color.
void TEveCompound::SetMainColor(Color_t color)
{
Color_t old_color = GetMainColor();
TEveElement::SetMainColor(color);
Bool_t color_all = TestCSCBits(kCSCBApplyMainColorToAllChildren);
Bool_t color_matching = TestCSCBits(kCSCBApplyMainColorToMatchingChildren);
for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
{
if (color_all || (color_matching && (*i)->GetMainColor() == old_color) ||
((*i)->GetCompound() == this && (*i)->GetMainColor() == old_color))
{
(*i)->SetMainColor(color);
}
}
}
////////////////////////////////////////////////////////////////////////////////
/// SetMainTransparency for the compound.
/// The transparency is also propagated to children with compound set to this
/// whose current transparency is the same as the old transparency.
///
/// The following CompoundSelectionColorBits have further influence:
/// - kCSCBApplyMainTransparencyToAllChildren - apply transparency to all children;
/// - kCSCBApplyMainTransparencyToMatchingChildren - apply transparency to children who have
/// matching transparency.
void TEveCompound::SetMainTransparency(Char_t t)
{
Char_t old_t = GetMainTransparency();
TEveElement::SetMainTransparency(t);
Bool_t chg_all = TestCSCBits(kCSCBApplyMainTransparencyToAllChildren);
Bool_t chg_matching = TestCSCBits(kCSCBApplyMainTransparencyToMatchingChildren);
for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
{
if (chg_all || (chg_matching && (*i)->GetMainTransparency() == old_t) ||
((*i)->GetCompound() == this && (*i)->GetMainTransparency() == old_t))
{
(*i)->SetMainTransparency(t);
}
}
}
////////////////////////////////////////////////////////////////////////////////
/// Call base-class implementation.
/// If compound is open and compound of the new element is not set,
/// the el's compound is set to this.
/// You might also want to call RecheckImpliedSelections().
void TEveCompound::AddElement(TEveElement* el)
{
TEveElementList::AddElement(el);
if (IsCompoundOpen() && el->GetCompound() == 0)
el->SetCompound(this);
}
////////////////////////////////////////////////////////////////////////////////
/// Decompoundofy el, call base-class version.
void TEveCompound::RemoveElementLocal(TEveElement* el)
{
if (el->GetCompound() == this)
el->SetCompound(0);
TEveElementList::RemoveElementLocal(el);
}
////////////////////////////////////////////////////////////////////////////////
/// Decompoundofy children, call base-class version.
void TEveCompound::RemoveElementsLocal()
{
for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i)
{
if ((*i)->GetCompound() == this)
(*i)->SetCompound(0);
}
TEveElementList::RemoveElementsLocal();
}
////////////////////////////////////////////////////////////////////////////////
/// Recurse on all children that are in this compound and
/// call the base-class version.
/// If SelectionColorBit kSCBImplySelectAllChildren is set, then all
/// children are added to the set.
///
/// Note that projected replicas of the compound will be added to
/// the set in base-class function that handles projectable.
void TEveCompound::FillImpliedSelectedSet(Set_t& impSelSet)
{
Bool_t select_all = TestCSCBits(kCSCBImplySelectAllChildren);
for (List_i i = fChildren.begin(); i != fChildren.end(); ++i)
{
if (select_all || (*i)->GetCompound() == this)
{
if (impSelSet.insert(*i).second)
(*i)->FillImpliedSelectedSet(impSelSet);
}
}
TEveElementList::FillImpliedSelectedSet(impSelSet);
}
////////////////////////////////////////////////////////////////////////////////
/// Virtual from TEveProjectable, returns TEveCompoundProjected class.
TClass* TEveCompound::ProjectedClass(const TEveProjection*) const
{
return TEveCompoundProjected::Class();
}
/** \class TEveCompoundProjected
\ingroup TEve
Description of TEveCompoundProjected
*/
ClassImp(TEveCompoundProjected);
////////////////////////////////////////////////////////////////////////////////
/// Constructor.
TEveCompoundProjected::TEveCompoundProjected() :
TEveCompound (),
TEveProjected ()
{
}
////////////////////////////////////////////////////////////////////////////////
/// Revert back to the behaviour of TEveElement as color
/// is propagated:
/// 1. from projectable -> projected
/// 2. from compound -> compound elements
/// and we do not need to do this twice for projected-compound-elements.
void TEveCompoundProjected::SetMainColor(Color_t color)
{
TEveElement::SetMainColor(color);
}