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