forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TEveElementEditor.cxx
185 lines (153 loc) · 5.82 KB
/
TEveElementEditor.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
// @(#)root/eve:$Id$
// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 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 "TEveElementEditor.h"
#include "TEveElement.h"
#include "TEveTransEditor.h"
#include "TColor.h"
#include "TGLabel.h"
#include "TGNumberEntry.h"
#include "TGColorSelect.h"
/** \class TEveElementEditor
\ingroup TEve
Editor for TEveElement class.
*/
ClassImp(TEveElementEditor);
////////////////////////////////////////////////////////////////////////////////
/// Constructor.
TEveElementEditor::TEveElementEditor(const TGWindow *p,
Int_t width, Int_t height,
UInt_t options, Pixel_t back) :
TGedFrame(p, width, height, options | kVerticalFrame, back),
fRE (nullptr),
fHFrame (nullptr),
fPreLabel (nullptr),
fRnrSelf (nullptr),
fRnrChildren (nullptr),
fRnrState (nullptr),
fMainColor (nullptr),
fTransparency (nullptr),
fTrans (nullptr)
{
MakeTitle("TEveElement");
fPriority = 0;
fHFrame = new TGHorizontalFrame(this);
fPreLabel = new TGLabel(fHFrame, "Show:");
fHFrame->AddFrame(fPreLabel, new TGLayoutHints(kLHintsLeft, 1, 6, 2, 0));
fRnrSelf = new TGCheckButton(fHFrame, "Self");
fHFrame->AddFrame(fRnrSelf, new TGLayoutHints(kLHintsLeft, 0, 2, 1, 1));
fRnrSelf->Connect
("Toggled(Bool_t)",
"TEveElementEditor", this, "DoRnrSelf()");
fRnrChildren = new TGCheckButton(fHFrame, "Children");
fHFrame->AddFrame(fRnrChildren, new TGLayoutHints(kLHintsLeft, 0, 1, 1, 1));
fRnrChildren->Connect
("Toggled(Bool_t)",
"TEveElementEditor", this, "DoRnrChildren()");
fRnrState = new TGCheckButton(fHFrame, "");
fHFrame->AddFrame(fRnrState, new TGLayoutHints(kLHintsLeft, 1, 2, 1, 1));
fRnrState->Connect
("Toggled(Bool_t)",
"TEveElementEditor", this, "DoRnrState()");
fMainColor = new TGColorSelect(fHFrame, 0, -1);
fHFrame->AddFrame(fMainColor, new TGLayoutHints(kLHintsLeft, 2, 0, -2, 0));
fMainColor->Connect
("ColorSelected(Pixel_t)",
"TEveElementEditor", this, "DoMainColor(Pixel_t)");
fTransparency = new TGNumberEntry(fHFrame, 0., 2, -1,
TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
TGNumberFormat::kNELLimitMinMax, 0, 100);
fTransparency->SetHeight(18);
fTransparency->GetNumberEntry()->SetToolTipText("Transparency: 0 is opaque, 100 fully transparent.");
fHFrame->AddFrame(fTransparency, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
fTransparency->Connect
("ValueSet(Long_t)",
"TEveElementEditor", this, "DoTransparency()");
AddFrame(fHFrame, new TGLayoutHints(kLHintsTop, 0, 0, 0, 0));
fTrans = new TEveTransSubEditor(this);
fTrans->Connect("UseTrans()", "TEveElementEditor", this, "Update()");
fTrans->Connect("TransChanged()", "TEveElementEditor", this, "Update()");
AddFrame(fTrans, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 0, 0));
}
////////////////////////////////////////////////////////////////////////////////
/// Set model object.
void TEveElementEditor::SetModel(TObject* obj)
{
fRE = dynamic_cast<TEveElement*>(obj);
fPreLabel ->UnmapWindow();
fRnrSelf ->UnmapWindow();
fRnrChildren->UnmapWindow();
fRnrState ->UnmapWindow();
if (fRE->CanEditElement()) {
fPreLabel->MapWindow();
if (fRE->SingleRnrState()) {
fRnrState->SetState(fRE->GetRnrState() ? kButtonDown : kButtonUp);
fRnrState->MapWindow();
} else {
fRnrSelf->SetState(fRE->GetRnrSelf() ? kButtonDown : kButtonUp);
fRnrChildren->SetState(fRE->GetRnrChildren() ? kButtonDown : kButtonUp);
fRnrSelf->MapWindow();
fRnrChildren->MapWindow();
}
}
if (fRE->CanEditMainColor()) {
fMainColor->SetColor(TColor::Number2Pixel(fRE->GetMainColor()), kFALSE);
fMainColor->MapWindow();
} else {
fMainColor->UnmapWindow();
}
if (fRE->CanEditMainTransparency()) {
fTransparency->SetNumber(fRE->GetMainTransparency());
fTransparency->MapWindow();
} else {
fTransparency->UnmapWindow();
}
if (fRE->CanEditMainTrans()) {
fTrans->SetModel(fRE->PtrMainTrans());
fTrans->MapWindow();
} else {
fTrans->UnmapWindow();
}
fHFrame->Layout();
}
////////////////////////////////////////////////////////////////////////////////
/// Slot for RnrSelf.
void TEveElementEditor::DoRnrSelf()
{
fRE->SetRnrSelf(fRnrSelf->IsOn());
Update();
}
////////////////////////////////////////////////////////////////////////////////
/// Slot for RnrChildren.
void TEveElementEditor::DoRnrChildren()
{
fRE->SetRnrChildren(fRnrChildren->IsOn());
Update();
}
////////////////////////////////////////////////////////////////////////////////
/// Slot for RnrState.
void TEveElementEditor::DoRnrState()
{
fRE->SetRnrState(fRnrState->IsOn());
Update();
}
////////////////////////////////////////////////////////////////////////////////
/// Slot for MainColor.
void TEveElementEditor::DoMainColor(Pixel_t color)
{
fRE->SetMainColorPixel(color);
Update();
}
////////////////////////////////////////////////////////////////////////////////
/// Slot for Transparency.
void TEveElementEditor::DoTransparency()
{
fRE->SetMainTransparency((Char_t)(fTransparency->GetNumber()));
Update();
}