Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
23Collection of named parameters.
24*/
25
27
28////////////////////////////////////////////////////////////////////////////////
29/// Constructor.
30
31TEveParamList::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
87GUI editor for TEveParamList.
88
89Slot methods from this object do not call Update, instead they call
90their model's ParamChanged(const char* name) function which emits a
91corresponding signal.
92
93This helps in handling of parameter changes as they are probably
94related to displayed objects in a more complicated way. Further,
95the TGCheckButton::HandleButton() emits more signal after the
96Clicked() signal and if model is reset in the editor, its contents
97is 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
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 }
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}
@ kVerticalFrame
Definition GuiTypes.h:381
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
#define ClassImp(name)
Definition Rtypes.h:377
@ kButtonDown
Definition TGButton.h:54
@ kButtonUp
Definition TGButton.h:53
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsCenterY
Definition TGLayout.h:28
@ kLHintsTop
Definition TGLayout.h:27
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
char name[80]
Definition TGX11.cxx:110
R__EXTERN void * gTQSender
Definition TQObject.h:46
void SetMainColorPtr(Color_t *color)
Exception class thrown by TEve classes and macros.
Definition TEveUtil.h:102
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.
IntConfigVec_t::const_iterator IntConfigVec_ci
TEveParamList(const TEveParamList &)
BoolConfigVec_t::const_iterator BoolConfigVec_ci
IntConfigVec_t fIntParameters
FloatConfigVec_t::const_iterator FloatConfigVec_ci
void ParamChanged(const char *name)
Emit ParamChanged() signal.
IntConfig_t GetIntParameter(const TString &name)
Get config-struct for int parameter 'name'.
BoolConfigVec_t fBoolParameters
Bool_t GetBoolParameter(const TString &name)
Get value for bool parameter 'name'.
FloatConfigVec_t fFloatParameters
FloatConfig_t GetFloatParameter(const TString &name)
Get config-struct for float parameter 'name'.
Selects different options.
Definition TGButton.h:264
Bool_t IsOn() const override
Definition TGButton.h:310
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1164
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition TGFrame.cxx:1149
void UnmapWindow() override
unmap window
Definition TGFrame.h:206
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:385
This class handles GUI labels.
Definition TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
virtual Long_t GetIntNumber() const
Get the numeric value (integer representation).
virtual Double_t GetNumber() const
Get the numeric value (floating point representation).
TGNumberEntry is a number entry input widget with up/down buttons.
TGNumberEntryField * GetNumberEntry() const
Get the number entry field.
@ kNEAAnyNumber
Attributes of number entry field.
@ kNESReal
Real number.
@ kNESInteger
Style of number entry field.
@ kNELLimitMinMax
Both lower and upper limits.
A composite frame that layout their children in vertical way.
Definition TGFrame.h:374
Int_t WidgetId() const
Definition TGWidget.h:68
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual void DestroyWindow()
destroy window
Definition TGWindow.cxx:192
Base frame for implementing GUI - a service class.
Definition TGedFrame.h:27
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition TGedFrame.cxx:95
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
Mother of all ROOT objects.
Definition TObject.h:41
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:970
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
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:869
Basic string class.
Definition TString.h:139
const Int_t n
Definition legend1.C:16