Logo ROOT   6.16/01
Reference Guide
TEveParamList.cxx
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Author: Dmytro Kovalskyi, 28.2.2008
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, 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 "TEveParamList.h"
13
14// Cleanup these includes:
15#include "TGLabel.h"
16#include "TGButton.h"
17#include "TGNumberEntry.h"
18#include "TGColorSelect.h"
19#include "TGDoubleSlider.h"
20
21#include "TEveGValuators.h"
22#include "TGNumberEntry.h"
23#include "TGedEditor.h"
24
25/** \class TEveParamList
26\ingroup TEve
27Collection of named parameters.
28*/
29
31
32////////////////////////////////////////////////////////////////////////////////
33/// Constructor.
34
35TEveParamList::TEveParamList(const char* n, const char* t, Bool_t doColor) :
36 TNamed(n, t),
37 fColor(0)
38{
39 if (doColor) SetMainColorPtr(&fColor);
40}
41
42////////////////////////////////////////////////////////////////////////////////
43/// Get config-struct for float parameter 'name'.
44
46{
47 static const TEveException eh("TEveParamList::GetFloatParameter ");
48
49 for (FloatConfigVec_ci itr = fFloatParameters.begin(); itr != fFloatParameters.end(); ++itr)
50 if (itr->fName.CompareTo(name)==0 ) return *itr;
51 Error(eh, "parameter not found.");
52 return FloatConfig_t();
53}
54
55////////////////////////////////////////////////////////////////////////////////
56/// Get config-struct for int parameter 'name'.
57
59{
60 static const TEveException eh("TEveParamList::GetIntParameter ");
61
62 for (IntConfigVec_ci itr = fIntParameters.begin(); itr != fIntParameters.end(); ++itr)
63 if (itr->fName.CompareTo(name) == 0) return *itr;
64 Error(eh, "parameter not found.");
65 return IntConfig_t();
66}
67
68////////////////////////////////////////////////////////////////////////////////
69/// Get value for bool parameter 'name'.
70
72{
73 static const TEveException eh("TEveParamList::GetBoolParameter ");
74
75 for (BoolConfigVec_ci itr = fBoolParameters.begin(); itr != fBoolParameters.end(); ++itr)
76 if ( itr->fName.CompareTo(name)==0 ) return itr->fValue;
77 Error(eh, "parameter not found.");
78 return kFALSE;
79}
80
81////////////////////////////////////////////////////////////////////////////////
82/// Emit ParamChanged() signal.
83
85{
86 Emit("ParamChanged(char*)", name);
87}
88
89/** \class TEveParamListEditor
90\ingroup TEve
91GUI editor for TEveParamList.
92
93Slot methods from this object do not call Update, instead they call
94their model's ParamChanged(const char* name) function which emits a
95corresponding signal.
96
97This helps in handling of parameter changes as they are probably
98related to displayed objects in a more complicated way. Further,
99the TGCheckButton::HandleButton() emits more signal after the
100Clicked() signal and if model is reset in the editor, its contents
101is removed. This results in a crash.
102*/
103
105
106////////////////////////////////////////////////////////////////////////////////
107/// Constructor.
108
110 UInt_t options, Pixel_t back) :
111 TGedFrame(p, width, height, options | kVerticalFrame, back),
112 fM (0),
113 fParamFrame (0)
114{
115 MakeTitle("TEveParamList");
116}
117
118////////////////////////////////////////////////////////////////////////////////
119/// Initialize widgets when a new object is selected.
120
122{
123 fM = dynamic_cast<TEveParamList*>(obj);
124
125 if (fParamFrame) {
129 delete fParamFrame;
130 }
131 fParamFrame = new TGVerticalFrame(this);
133
134 // integers
135 fIntParameters.clear();
136 for (UInt_t i = 0; i < fM->fIntParameters.size(); ++i)
137 {
139
140 // number entry widget
141 TGNumberEntry* widget = new TGNumberEntry
142 (frame, fM->fIntParameters[i].fValue,
143 5, // number of digits
144 i, // widget ID
146 TGNumberFormat::kNEAAnyNumber, // input value filter
147 TGNumberFormat::kNELLimitMinMax, // specify limits
148 fM->fIntParameters[i].fMin, // min value
149 fM->fIntParameters[i].fMax); // max value
150 frame->AddFrame(widget, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,8,2,2));
151 widget->Connect("ValueSet(Long_t)", "TEveParamListEditor", this, "DoIntUpdate()");
152 fIntParameters.push_back(widget);
153
154 // label
155 frame->AddFrame(new TGLabel(frame,fM->fIntParameters[i].fName.Data()),
157
159 }
160
161
162 // floats
163 fFloatParameters.clear();
164 for (UInt_t i = 0; i < fM->fFloatParameters.size(); ++i)
165 {
167
168 // number entry widget
169 TGNumberEntry* widget = new TGNumberEntry
170 (frame, fM->fFloatParameters[i].fValue,
171 5, // number of digits
172 i, // widget ID
174 TGNumberFormat::kNEAAnyNumber, // input value filter
175 TGNumberFormat::kNELLimitMinMax, // specify limits
176 fM->fFloatParameters[i].fMin, // min value
177 fM->fFloatParameters[i].fMax); // max value
178 frame->AddFrame(widget, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,8,2,2));
179 widget->Connect("ValueSet(Long_t)", "TEveParamListEditor", this, "DoFloatUpdate()");
180 fFloatParameters.push_back( widget );
181
182 // label
183 frame->AddFrame(new TGLabel(frame,fM->fFloatParameters[i].fName.Data()),
185
187 }
188
189 // boolean
190 fBoolParameters.clear();
191 for (UInt_t i = 0; i < fM->fBoolParameters.size(); ++i)
192 {
194 fM->fBoolParameters[i].fName.Data(),
195 i);
196 widget->Connect("Clicked()", "TEveParamListEditor", this, "DoBoolUpdate()");
197 fBoolParameters.push_back(widget);
198
199 fParamFrame->AddFrame(widget, new TGLayoutHints(kLHintsTop,2,0,1,1));
200 }
202}
203
204////////////////////////////////////////////////////////////////////////////////
205/// Set model object.
206
208{
209 InitModel(obj);
210
211 for (UInt_t i = 0; i < fIntParameters.size(); ++i)
212 fIntParameters[i]->GetNumberEntry()->SetIntNumber(fM->fIntParameters[i].fValue);
213
214 for (UInt_t i = 0; i < fFloatParameters.size(); ++i)
215 fFloatParameters[i]->GetNumberEntry()->SetNumber(fM->fFloatParameters[i].fValue);
216
217 for (UInt_t i = 0; i < fBoolParameters.size(); ++i)
218 fBoolParameters[i]->SetState( fM->fBoolParameters[i].fValue ? kButtonDown : kButtonUp);
219}
220
221////////////////////////////////////////////////////////////////////////////////
222/// Slot for integer parameter update.
223
225{
227 Int_t id = widget->WidgetId();
228 if (id < 0 || id >= (int) fM->fIntParameters.size()) return;
229 fM->fIntParameters[id].fValue = widget->GetNumberEntry()->GetIntNumber();
230
231 fM->ParamChanged(fM->fIntParameters[id].fName);
232 gTQSender = (void*) widget;
233}
234
235////////////////////////////////////////////////////////////////////////////////
236/// Slot for float parameter update.
237
239{
241 Int_t id = widget->WidgetId();
242 if (id < 0 || id >= (int) fM->fFloatParameters.size()) return;
243 fM->fFloatParameters[id].fValue = widget->GetNumberEntry()->GetNumber();
244
245 fM->ParamChanged(fM->fFloatParameters[id].fName);
246 gTQSender = (void*) widget;
247}
248
249////////////////////////////////////////////////////////////////////////////////
250/// Slot for bool parameter update.
251
253{
255 Int_t id = widget->WidgetId();
256 if (id < 0 || id >= (int) fM->fBoolParameters.size()) return;
257 fM->fBoolParameters[id].fValue = widget->IsOn();
258
259 fM->ParamChanged(fM->fBoolParameters[id].fName);
260 gTQSender = (void*) widget;
261}
ULong_t Pixel_t
Definition: GuiTypes.h:39
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
#define ClassImp(name)
Definition: Rtypes.h:363
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
@ kButtonDown
Definition: TGButton.h:54
@ kButtonUp
Definition: TGButton.h:53
@ kVerticalFrame
Definition: TGFrame.h:59
@ kLHintsLeft
Definition: TGLayout.h:31
@ kLHintsCenterY
Definition: TGLayout.h:35
@ kLHintsTop
Definition: TGLayout.h:34
R__EXTERN void * gTQSender
Definition: TQObject.h:45
void SetMainColorPtr(Color_t *color)
Definition: TEveElement.h:267
Exception class thrown by TEve classes and macros.
Definition: TEveUtil.h:103
GUI editor for TEveParamList.
TGVerticalFrame * fParamFrame
virtual void InitModel(TObject *obj)
Initialize widgets when a new object is selected.
std::vector< TGCheckButton * > fBoolParameters
std::vector< TGNumberEntry * > fIntParameters
void DoFloatUpdate()
Slot for float parameter update.
TEveParamListEditor(const TEveParamListEditor &)
void DoIntUpdate()
Slot for integer parameter update.
virtual void SetModel(TObject *obj)
Set model object.
void DoBoolUpdate()
Slot for bool parameter update.
TEveParamList * fM
std::vector< TGNumberEntry * > fFloatParameters
Collection of named parameters.
Definition: TEveParamList.h:27
IntConfigVec_t::const_iterator IntConfigVec_ci
Definition: TEveParamList.h:57
TEveParamList(const TEveParamList &)
BoolConfigVec_t::const_iterator BoolConfigVec_ci
Definition: TEveParamList.h:69
Color_t fColor
Definition: TEveParamList.h:76
IntConfigVec_t fIntParameters
Definition: TEveParamList.h:78
FloatConfigVec_t::const_iterator FloatConfigVec_ci
Definition: TEveParamList.h:43
void ParamChanged(const char *name)
Emit ParamChanged() signal.
IntConfig_t GetIntParameter(const TString &name)
Get config-struct for int parameter 'name'.
BoolConfigVec_t fBoolParameters
Definition: TEveParamList.h:79
Bool_t GetBoolParameter(const TString &name)
Get value for bool parameter 'name'.
FloatConfigVec_t fFloatParameters
Definition: TEveParamList.h:77
FloatConfig_t GetFloatParameter(const TString &name)
Get config-struct for float parameter 'name'.
virtual Bool_t IsOn() const
Definition: TGButton.h:311
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1146
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition: TGFrame.cxx:1131
virtual void UnmapWindow()
Definition: TGFrame.h:253
virtual Long_t GetIntNumber() const
Get the numeric value (integer representation).
virtual Double_t GetNumber() const
Get the numeric value (floating point representation).
TGNumberEntryField * GetNumberEntry() const
Int_t WidgetId() const
Definition: TGWidget.h:80
virtual void DestroyWindow()
Definition: TGWindow.h:92
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:165
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition: TQObject.cxx:867
Basic string class.
Definition: TString.h:131
const Int_t n
Definition: legend1.C:16