Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TEveGValuators.cxx
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
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 "TEveGValuators.h"
13
14#include "TMath.h"
15#include "TGLabel.h"
16#include "TGSlider.h"
17#include "TGDoubleSlider.h"
18
19/** \class TEveGValuatorBase
20\ingroup TEve
21Base class for composite GUI elements for setting of numeric values.
22*/
23
24
25////////////////////////////////////////////////////////////////////////////////
26/// Constructor.
27
31
32 fLabelWidth (0),
33 fAlignRight (kFALSE),
34 fShowSlider (kTRUE),
35
36 fNELength (5),
37 fNEHeight (20),
38
39 fLabel (nullptr)
40{
42}
43
44/** \class TEveGValuator
45\ingroup TEve
46Composite GUI element for single value selection (supports label,
47number-entry and slider).
48*/
49
50
51////////////////////////////////////////////////////////////////////////////////
52/// Constructor.
53
54TEveGValuator::TEveGValuator(const TGWindow *p, const char* title,
56 TEveGValuatorBase(p, title, w, h, widgetId),
57
58 fValue (0),
59 fMin (0),
60 fMax (0),
61
62 fSliderNewLine (kFALSE),
63 fSliderDivs (-1),
64 fEntry (nullptr),
65 fSlider (nullptr)
66{
67}
68
69////////////////////////////////////////////////////////////////////////////////
70/// Create sub-components (label, number entry, slider).
71
73{
77 hf1 = new TGHorizontalFrame(this);
78 hf1->SetLayoutManager(new TGHorizontalLayout(hf1));
79 AddFrame(hf1, new TGLayoutHints(kLHintsTop, 0,0,0,0));
80 hfs = new TGHorizontalFrame(this);
81 hfs->SetLayoutManager(new TGHorizontalLayout(hfs));
82 AddFrame(hfs, new TGLayoutHints(kLHintsTop, 0,0,0,0));
83 } else {
84 hf1 = this;
85 hfs = this;
87 }
88
89 // label
90 {
92 if(fAlignRight) {
95 } else {
98 }
102 fLabel = new TGLabel(labfr, fName);
103 labfr->AddFrame(fLabel, labh);
104 hf1->AddFrame(labfr, labfrh);
105 }
106
107 // number-entry
111 fEntry->GetNumberEntry()->SetToolTipText("Enter Slider Value");
112 hf1->AddFrame(fEntry, elh);
113
114 if (connect)
115 fEntry->Connect("ValueSet(Long_t)",
116 "TEveGValuator", this, "EntryCallback()");
117
118 // slider
119 if(fShowSlider) {
121 hfs->AddFrame(fSlider, new TGLayoutHints(kLHintsLeft|kLHintsTop, 1,1,0,0));
122
123 if (connect)
124 fSlider->Connect("PositionChanged(Int_t)",
125 "TEveGValuator", this, "SliderCallback()");
126 }
127}
128
129////////////////////////////////////////////////////////////////////////////////
130/// Set limits of the represented value.
131
134{
135 fMin = Float_t(min);
136 fMax = Float_t(max);
139
140 if(fSlider) {
141 fSliderDivs = npos - 1;
143 }
144}
145
146////////////////////////////////////////////////////////////////////////////////
147/// Set limits of the represented value for integer values.
148
150{
151 fMin = Float_t(min);
152 fMax = Float_t(max);
155
156 if(fSlider) {
157 fSliderDivs = max - min;
159 }
160}
161
162////////////////////////////////////////////////////////////////////////////////
163/// Return slider position for given value.
164
169
170////////////////////////////////////////////////////////////////////////////////
171/// Callback for change in number-entry.
172
181
182////////////////////////////////////////////////////////////////////////////////
183/// Callback for change in slider position.
184
191
192
193////////////////////////////////////////////////////////////////////////////////
194/// Emit "ValueSet(Double_t)" signal.
195
197{
198 Emit("ValueSet(Double_t)", val);
199}
200
201////////////////////////////////////////////////////////////////////////////////
202/// Set value, optionally emit signal.
203
205{
206 fValue = val;
208
209 if(fSlider){
211 }
212 if(emit)
213 ValueSet(val);
214}
215
216////////////////////////////////////////////////////////////////////////////////
217/// Set the tooltip of the number-entry.
218
223
224////////////////////////////////////////////////////////////////////////////////
225/// Set enabled state of the whole widget.
226
228{
230 fEntry->GetButtonUp()->SetEnabled(state);
232 if(fSlider) {
233 if(state) fSlider->MapWindow();
234 else fSlider->UnmapWindow();
235 }
236}
237
238/** \class TEveGDoubleValuator
239\ingroup TEve
240Composite GUI element for selection of range (label, two
241number-entries and double-slider).
242*/
243
244
245////////////////////////////////////////////////////////////////////////////////
246/// Constructor.
247
250 TEveGValuatorBase(p, title, w, h, widgetId),
251
252 fMinEntry(nullptr),
253 fMaxEntry(nullptr),
254 fSlider(nullptr)
255{
256}
257
258////////////////////////////////////////////////////////////////////////////////
259/// Create sub-components (label, number entries, double-slider).
260
262{
264 if(fShowSlider) {
266 hf1 = new TGHorizontalFrame(this);
267 hf1->SetLayoutManager(new TGHorizontalLayout(hf1));
269 hfs = new TGHorizontalFrame(this);
270 hfs->SetLayoutManager(new TGHorizontalLayout(hfs));
272 } else {
273 hf1 = this;
274 hfs = this;
276 }
277
278 // label
280 if(fAlignRight)
281 lh = new TGLayoutHints(kLHintsRight | kLHintsBottom, 4,0,0,0);
282 else
283 lh = new TGLayoutHints(kLHintsLeft | kLHintsBottom, 0,4,0,0);
284
285 if(fLabelWidth > 0) {
287 fLabel = new TGLabel(lf, fName);
288 lf->AddFrame(fLabel, lh);
289 // add label frame to top horizontal frame
291 hf1->AddFrame(lf, lfh);
292 } else {
293 fLabel = new TGLabel(hf1, fName);
294 hf1->AddFrame(fLabel, lh);
295 }
296
297 // entries
300 fMinEntry->GetNumberEntry()->SetToolTipText("Enter Slider Min Value");
301 hf1->AddFrame(fMinEntry, new TGLayoutHints(kLHintsLeft, 0,0,0,0));
302 if (connect)
303 fMinEntry->Connect("ValueSet(Long_t)",
304 "TEveGDoubleValuator", this, "MinEntryCallback()");
305
308 fMaxEntry->GetNumberEntry()->SetToolTipText("Enter Slider Max Value");
309 hf1->AddFrame(fMaxEntry, new TGLayoutHints(kLHintsLeft, 2,0,0,0));
310 if (connect)
311 fMaxEntry->Connect("ValueSet(Long_t)",
312 "TEveGDoubleValuator", this, "MaxEntryCallback()");
313
314 // slider
315 if(fShowSlider) {
317 hfs->AddFrame(fSlider, new TGLayoutHints(kLHintsTop|kLHintsLeft, 0,0,1,0));
318 if (connect)
319 fSlider->Connect("PositionChanged()",
320 "TEveGDoubleValuator", this, "SliderCallback()");
321 }
322}
323
324////////////////////////////////////////////////////////////////////////////////
325/// Set limits of the represented range for integer values.
326
338
339////////////////////////////////////////////////////////////////////////////////
340/// Set limits of the represented range.
341
344{
345 // printf("TEveGDoubleValuator::SetLimits(Float_t min, Float_t max, Int_ \n");
350
351 if(fSlider) fSlider->SetRange(min, max);
352}
353
354////////////////////////////////////////////////////////////////////////////////
355/// Callback for change in low number-entry.
356
364
365////////////////////////////////////////////////////////////////////////////////
366/// Callback for change in high number-entry.
367
375
376////////////////////////////////////////////////////////////////////////////////
377/// Callback for change in slider position / width.
378
387
388////////////////////////////////////////////////////////////////////////////////
389/// Set min/max values, optionally emit signal.
390
392{
393 fMinEntry->SetNumber(min);
394 fMaxEntry->SetNumber(max);
395
396 if(fSlider) fSlider->SetPosition(min, max);
397 if(emit) ValueSet();
398}
399
400////////////////////////////////////////////////////////////////////////////////
401/// Emit "ValueSet()" signal.
402
404{
405 Emit("ValueSet()");
406}
407
408/** \class TEveGTriVecValuator
409\ingroup TEve
410Composite GUI element for setting three numerical values (label,
411three number-entries). All three values have the same number-format
412and value-range.
413*/
414
415
416////////////////////////////////////////////////////////////////////////////////
417/// Constructor.
418
422
423 fLabelWidth (0),
424 fNELength (5),
425 fNEHeight (20)
426{
427 SetName(name);
428}
429
430////////////////////////////////////////////////////////////////////////////////
431/// Create sub-components (label, number entries).
432
433void TEveGTriVecValuator::Build(Bool_t vertical, const char* lab0, const char* lab1, const char* lab2)
434{
436 else SetLayoutManager(new TGHorizontalLayout(this));
437
438 const char *labs[3] = { lab0, lab1, lab2 };
440 for (Int_t i=0; i<3; ++i) {
441 fVal[i] = new TEveGValuator(this, labs[i], 10, 0);
446 fVal[i]->Build();
447 fVal[i]->Connect
448 ("ValueSet(Double_t)", "TEveGTriVecValuator", this, "ValueSet()");
449 if (vertical) lh = new TGLayoutHints(kLHintsTop, 1, 1, 1, 1);
450 else lh = new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 1, 1);
451 AddFrame(fVal[i], lh);
452 }
453}
454
455////////////////////////////////////////////////////////////////////////////////
456/// Emit "ValueSet()" signal.
457
459{
460 Emit("ValueSet()");
461}
462
463////////////////////////////////////////////////////////////////////////////////
464/// Set limits for all three number-entries, integer values.
465
467{
468 for (Int_t i=0; i<3; ++i)
469 fVal[i]->SetLimits(min, max);
470}
471
472////////////////////////////////////////////////////////////////////////////////
473/// Set limits for all three number-entries.
474
477{
478 for (Int_t i=0; i<3; ++i)
479 fVal[i]->SetLimits(min, max, 0, nef);
480}
481
@ kFixedHeight
Definition GuiTypes.h:389
@ kFixedSize
Definition GuiTypes.h:390
#define h(i)
Definition RSha256.hxx:106
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ kDoubleScaleBoth
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsBottom
Definition TGLayout.h:29
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
@ kScaleBoth
Definition TGSlider.h:36
@ kSlider1
Definition TGSlider.h:30
winID h TVirtualViewer3D TVirtualGLPainter p
char name[80]
Definition TGX11.cxx:110
void MinEntryCallback()
Callback for change in low number-entry.
Float_t GetMin() const
TGNumberEntry * fMaxEntry
void Build(Bool_t connect=kTRUE) override
Create sub-components (label, number entries, double-slider).
TEveGDoubleValuator(const TEveGDoubleValuator &)
void SetLimits(Int_t min, Int_t max)
Set limits of the represented range for integer values.
void ValueSet()
Emit "ValueSet()" signal.
TGDoubleHSlider * fSlider
Float_t GetMax() const
void MaxEntryCallback()
Callback for change in high number-entry.
void SliderCallback()
Callback for change in slider position / width.
TGNumberEntry * fMinEntry
void SetValues(Float_t min, Float_t max, Bool_t emit=kFALSE)
Set min/max values, optionally emit signal.
TEveGValuator * fVal[3]
void ValueSet()
Emit "ValueSet()" signal.
void SetLimits(Int_t min, Int_t max)
Set limits for all three number-entries, integer values.
void Build(Bool_t vertical, const char *lab0, const char *lab1, const char *lab2)
Create sub-components (label, number entries).
TEveGTriVecValuator(const TEveGTriVecValuator &)
Base class for composite GUI elements for setting of numeric values.
void SetLabelWidth(Int_t w)
void SetNEHeight(Int_t h)
void SetShowSlider(Bool_t s=kTRUE)
void SetNELength(Int_t l)
TEveGValuatorBase(const TEveGValuatorBase &)
Composite GUI element for single value selection (supports label, number-entry and slider).
TGNumberEntry * fEntry
TEveGValuator(const TEveGValuator &)
void ValueSet(Double_t)
Emit "ValueSet(Double_t)" signal.
void Build(Bool_t connect=kTRUE) override
Create sub-components (label, number entry, slider).
void SetEnabled(Bool_t state)
Set enabled state of the whole widget.
Int_t CalcSliderPos(Float_t v)
Return slider position for given value.
TGHSlider * fSlider
void SetToolTip(const char *tip)
Set the tooltip of the number-entry.
void SetLimits(Int_t min, Int_t max)
Set limits of the represented value for integer values.
Bool_t fSliderNewLine
void SliderCallback()
Callback for change in slider position.
void EntryCallback()
Callback for change in number-entry.
virtual void SetValue(Float_t v, Bool_t emit=kFALSE)
Set value, optionally emit signal.
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition TGButton.cxx:453
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
virtual void SetLayoutManager(TGLayoutManager *l)
Set the layout manager for the composite frame.
Definition TGFrame.cxx:992
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
Dragging the slider will generate the event:
virtual void GetPosition(Float_t &min, Float_t &max) const
virtual void SetRange(Float_t min, Float_t max)
virtual void SetPosition(Float_t min, Float_t max)
void MapWindow() override
map window
Definition TGFrame.h:206
void UnmapWindow() override
unmap window
Definition TGFrame.h:208
UInt_t GetWidth() const
Definition TGFrame.h:226
virtual void SetHeight(UInt_t h)
Definition TGFrame.h:249
Concrete class for horizontal slider.
Definition TGSlider.h:119
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:387
This class handles GUI labels.
Definition TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
TGNumberEntry is a number entry input widget with up/down buttons.
TGNumberEntryField * GetNumberEntry() const
Get the number entry field.
virtual void SetLimits(ELimit limits=TGNumberFormat::kNELNoLimits, Double_t min=0, Double_t max=1)
TGButton * GetButtonDown() const
Get the down button.
virtual void SetFormat(EStyle style, EAttribute attr=TGNumberFormat::kNEAAnyNumber)
virtual Double_t GetNumber() const
virtual void SetNumber(Double_t val, Bool_t emit=kTRUE)
TGButton * GetButtonUp() const
Get the up button.
@ kNESInteger
Style of number entry field.
@ kNELLimitMinMax
Both lower and upper limits.
virtual Int_t GetPosition() const
Definition TGSlider.h:77
virtual void SetPosition(Int_t pos)
Set slider position.
Definition TGSlider.cxx:107
virtual void SetRange(Int_t min, Int_t max)
Set slider range.
Definition TGSlider.cxx:96
void SetEnabled(Bool_t flag=kTRUE)
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
The widget base class.
Definition TGWidget.h:43
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual void SetName(const char *name)
Definition TGWindow.h:121
TString fName
name of the window used in SavePrimitive()
Definition TGWindow.h:30
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:865
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
Definition TMath.h:704