forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TEveElementEditor.cxx
196 lines (161 loc) · 6.31 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
186
187
188
189
190
191
192
193
194
195
196
// @(#)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 "TVirtualPad.h"
#include "TColor.h"
#include "TGLabel.h"
#include "TGButton.h"
#include "TGNumberEntry.h"
#include "TGColorSelect.h"
#include "TGDoubleSlider.h"
//==============================================================================
//==============================================================================
// TEveElementEditor
//==============================================================================
//______________________________________________________________________________
//
// Editor for TEveElement class.
ClassImp(TEveElementEditor);
//______________________________________________________________________________
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 (0),
fHFrame (0),
fPreLabel (0),
fRnrSelf (0),
fRnrChildren (0),
fRnrState (0),
fMainColor (0),
fTransparency (0),
fTrans (0)
{
// Constructor.
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));
}
/******************************************************************************/
//______________________________________________________________________________
void TEveElementEditor::SetModel(TObject* obj)
{
// Set model object.
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();
}
/******************************************************************************/
//______________________________________________________________________________
void TEveElementEditor::DoRnrSelf()
{
// Slot for RnrSelf.
fRE->SetRnrSelf(fRnrSelf->IsOn());
Update();
}
//______________________________________________________________________________
void TEveElementEditor::DoRnrChildren()
{
// Slot for RnrChildren.
fRE->SetRnrChildren(fRnrChildren->IsOn());
Update();
}
//______________________________________________________________________________
void TEveElementEditor::DoRnrState()
{
// Slot for RnrState.
fRE->SetRnrState(fRnrState->IsOn());
Update();
}
//______________________________________________________________________________
void TEveElementEditor::DoMainColor(Pixel_t color)
{
// Slot for MainColor.
fRE->SetMainColorPixel(color);
Update();
}
//______________________________________________________________________________
void TEveElementEditor::DoTransparency()
{
// Slot for Transparency.
fRE->SetMainTransparency((Char_t)(fTransparency->GetNumber()));
Update();
}