Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TEveRGBAPaletteEditor.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
13#include "TEveRGBAPalette.h"
14#include "TEveGValuators.h"
15
16#include "TColor.h"
17
18#include "TGLabel.h"
19#include "TGButton.h"
20#include "TGComboBox.h"
21#include "TGColorSelect.h"
22#include "TGDoubleSlider.h"
23
24/** \class TEveRGBAPaletteSubEditor
25\ingroup TEve
26Sub-editor for TEveRGBAPalette class.
27*/
28
29
30////////////////////////////////////////////////////////////////////////////////
31/// Constructor.
32
35
36 fM(nullptr),
37
38 fUnderflowAction (nullptr),
39 fUnderColor (nullptr),
40 fOverflowAction (nullptr),
41 fOverColor (nullptr),
42
43 fMinMax(nullptr), fOldMin(0), fOldMax(0),
44
45 fInterpolate(nullptr),
46 fShowDefValue(nullptr),
47 fDefaultColor(nullptr),
48 fFixColorRange(nullptr)
49{
50 {
52
53 fInterpolate = new TGCheckButton(f, "Interpolate");
54 f->AddFrame(fInterpolate, new TGLayoutHints(kLHintsLeft, 3, 1, 1, 0));
55 fInterpolate->Connect("Toggled(Bool_t)",
56 "TEveRGBAPaletteSubEditor", this, "DoInterpolate()");
57
58 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
59 }
60
61 {
63
64 fShowDefValue = new TGCheckButton(f, "Show default value");
65 f->AddFrame(fShowDefValue, new TGLayoutHints(kLHintsLeft, 3, 1, 1, 0));
66 fShowDefValue->Connect("Toggled(Bool_t)",
67 "TEveRGBAPaletteSubEditor", this, "DoShowDefValue()");
68
69 fDefaultColor = new TGColorSelect(f, 0, -1);
70 f->AddFrame(fDefaultColor, new TGLayoutHints(kLHintsLeft|kLHintsTop, 0, 0, 0, 0));
71 fDefaultColor->Connect("ColorSelected(Pixel_t)",
72 "TEveRGBAPaletteSubEditor", this, "DoDefaultColor(Pixel_t)");
73
74 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 2, 0));
75 }
76
77 {
79
80 fFixColorRange = new TGCheckButton(f, "Fix color range");
81 f->AddFrame(fFixColorRange, new TGLayoutHints(kLHintsLeft, 3, 1, 0, 0));
82 fFixColorRange->Connect("Toggled(Bool_t)",
83 "TEveRGBAPaletteSubEditor", this, "DoFixColorRange()");
84
85 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 0, 2));
86 }
87
88 { // Underflow
90 TGLabel* lab = new TGLabel(f, "Underflow:");
91 f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 15, 1, 2));
93 fUnderflowAction->AddEntry("Cut", 0);
94 fUnderflowAction->AddEntry("Mark", 1);
95 fUnderflowAction->AddEntry("Clip", 2);
96 fUnderflowAction->AddEntry("Wrap", 3);
97 TGListBox* lb = fUnderflowAction->GetListBox();
98 lb->Resize(lb->GetWidth(), 4*16);
99 fUnderflowAction->Resize(59, 20);
100 fUnderflowAction->Connect("Selected(Int_t)", "TEveRGBAPaletteSubEditor", this,
101 "DoUnderflowAction(Int_t)");
102 f->AddFrame(fUnderflowAction, new TGLayoutHints(kLHintsLeft, 1, 2, 1, 1));
103
104 fUnderColor = new TGColorSelect(f, 0, -1);
105 f->AddFrame(fUnderColor, new TGLayoutHints(kLHintsLeft|kLHintsTop, 1, 1, 0, 2));
106 fUnderColor->Connect("ColorSelected(Pixel_t)",
107 "TEveRGBAPaletteSubEditor", this, "DoUnderColor(Pixel_t)");
108
109 AddFrame(f);
110 }
111
112 { // Overflow
114 TGLabel* lab = new TGLabel(f, "Overflow:");
115 f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 20, 1, 2));
117 fOverflowAction->AddEntry("Cut", 0);
118 fOverflowAction->AddEntry("Mark", 1);
119 fOverflowAction->AddEntry("Clip", 2);
120 fOverflowAction->AddEntry("Wrap", 3);
121 TGListBox* lb = fOverflowAction->GetListBox();
122 lb->Resize(lb->GetWidth(), 4*16);
123 fOverflowAction->Resize(59, 20);
124 fOverflowAction->Connect("Selected(Int_t)", "TEveRGBAPaletteSubEditor", this,
125 "DoOverflowAction(Int_t)");
126 f->AddFrame(fOverflowAction, new TGLayoutHints(kLHintsLeft, 1, 2, 1, 1));
127
128 fOverColor = new TGColorSelect(f, 0, -1);
129 f->AddFrame(fOverColor, new TGLayoutHints(kLHintsLeft|kLHintsTop, 1, 1, 0, 2));
130 fOverColor->Connect("ColorSelected(Pixel_t)",
131 "TEveRGBAPaletteSubEditor", this, "DoOverColor(Pixel_t)");
132
133 AddFrame(f);
134 }
135
136 fMinMax = new TEveGDoubleValuator(this,"Main range:", 130, 0);
137 fMinMax->SetNELength(5);
138 fMinMax->SetLabelWidth(74);
139 fMinMax->Build();
140 fMinMax->GetSlider()->SetWidth(190);
141 fMinMax->SetLimits(0, 1023, TGNumberFormat::kNESInteger);
142 fMinMax->Connect("ValueSet()",
143 "TEveRGBAPaletteSubEditor", this, "DoMinMax()");
144 AddFrame(fMinMax, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
145}
146
147////////////////////////////////////////////////////////////////////////////////
148/// Set model object.
149
151{
152 fM = p;
153
154 if (fM->fUIDoubleRep)
155 {
156 fMinMax->SetValues(fM->IntToDouble(fM->fMinVal), fM->IntToDouble(fM->fMaxVal));
157 Double_t ll = fM->IntToDouble(fM->fLowLimit);
158 Double_t hl = fM->IntToDouble(fM->fHighLimit);
159 Int_t mgk = TMath::Min(3, TMath::Max(0, 3 - TMath::Nint(TMath::Log10(hl-ll))));
161 fOldMin = fMinMax->GetMin();
162 fOldMax = fMinMax->GetMax();
163 }
164 else
165 {
166 fMinMax->SetValues(fM->fMinVal, fM->fMaxVal);
167 fMinMax->SetLimits(fM->fLowLimit, fM->fHighLimit, TGNumberFormat::kNESInteger);
168 }
169
170 fInterpolate ->SetState(fM->fInterpolate ? kButtonDown : kButtonUp);
171 fShowDefValue ->SetState(fM->fShowDefValue ? kButtonDown : kButtonUp);
172 fDefaultColor ->SetColor(TColor::Number2Pixel(fM->GetDefaultColor()), kFALSE);
173 fFixColorRange->SetState(fM->fFixColorRange ? kButtonDown : kButtonUp);
174
175 fUnderColor->SetColor(TColor::Number2Pixel(fM->GetUnderColor()), kFALSE);
176 fOverColor ->SetColor(TColor::Number2Pixel(fM->GetOverColor()), kFALSE);
177
178 fUnderflowAction->Select(fM->fUnderflowAction, kFALSE);
179 fOverflowAction ->Select(fM->fOverflowAction, kFALSE);
180}
181
182////////////////////////////////////////////////////////////////////////////////
183/// Emit "Changed()" signal.
184
186{
187 Emit("Changed()");
188}
189
190////////////////////////////////////////////////////////////////////////////////
191/// Slot for MinMax.
192
194{
195 if (fM->fUIDoubleRep)
196 {
197 Double_t min = fMinMax->GetMin();
198 if (min != fOldMin && fM->DoubleToInt(min) == fM->fMinVal)
199 {
200 if (min < fOldMin)
201 min = fM->IntToDouble(fM->fMinVal - 1);
202 else
203 min = fM->IntToDouble(fM->fMinVal + 1);
204 }
205 Double_t max = fMinMax->GetMax();
206 if (max != fOldMax && fM->DoubleToInt(max) == fM->fMaxVal)
207 {
208 if (max < fOldMax)
209 max = fM->IntToDouble(fM->fMaxVal - 1);
210 else
211 max = fM->IntToDouble(fM->fMaxVal + 1);
212 }
213 fM->SetMinMax(fM->DoubleToInt(min), fM->DoubleToInt(max));
214 }
215 else
216 {
217 fM->SetMinMax((Int_t) fMinMax->GetMin(), (Int_t) fMinMax->GetMax());
218 }
219
220 Changed();
221 fM->MinMaxValChanged();
222}
223
224////////////////////////////////////////////////////////////////////////////////
225/// Slot for Interpolate.
226
228{
229 fM->SetInterpolate(fInterpolate->IsOn());
230 Changed();
231}
232
233////////////////////////////////////////////////////////////////////////////////
234/// Slot for ShowDefValue.
235
237{
238 fM->SetShowDefValue(fShowDefValue->IsOn());
239 Changed();
240}
241
242////////////////////////////////////////////////////////////////////////////////
243/// Slot for DefaultColor.
244
246{
247 fM->SetDefaultColorPixel(color);
248 Changed();
249}
250
251////////////////////////////////////////////////////////////////////////////////
252/// Slot for FixColorRange.
253
255{
256 fM->SetFixColorRange(fFixColorRange->IsOn());
257 Changed();
258}
259
260////////////////////////////////////////////////////////////////////////////////
261/// Slot for UnderColor.
262
264{
265 fM->SetUnderColorPixel(color);
266 Changed();
267}
268
269////////////////////////////////////////////////////////////////////////////////
270/// Slot for OverColor.
271
273{
274 fM->SetOverColorPixel(color);
275 Changed();
276}
277
278////////////////////////////////////////////////////////////////////////////////
279/// Slot for UnderflowAction.
280
282{
283 fM->SetUnderflowAction(mode);
284 Changed();
285}
286
287////////////////////////////////////////////////////////////////////////////////
288/// Slot for OverflowAction.
289
291{
292 fM->SetOverflowAction(mode);
293 Changed();
294}
295
296
297/** \class TEveRGBAPaletteEditor
298\ingroup TEve
299Editor for TEveRGBAPalette class.
300*/
301
302
303////////////////////////////////////////////////////////////////////////////////
304/// Constructor.
305
307 UInt_t options, Pixel_t back) :
308 TGedFrame(p, width, height, options | kVerticalFrame, back),
309 fM (nullptr),
310 fSE(nullptr)
311{
312 MakeTitle("TEveRGBAPalette");
313
314 fSE = new TEveRGBAPaletteSubEditor(this);
315 AddFrame(fSE, new TGLayoutHints(kLHintsTop, 2, 0, 2, 2));
316 fSE->Connect("Changed()", "TEveRGBAPaletteEditor", this, "Update()");
317}
318
319////////////////////////////////////////////////////////////////////////////////
320/// Set model object.
321
323{
324 fM = dynamic_cast<TEveRGBAPalette*>(obj);
325 fSE->SetModel(fM);
326}
@ kVerticalFrame
Definition GuiTypes.h:382
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
#define f(i)
Definition RSha256.hxx:104
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
@ kButtonDown
Definition TGButton.h:54
@ kButtonUp
Definition TGButton.h:53
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsBottom
Definition TGLayout.h:29
@ kLHintsTop
Definition TGLayout.h:27
static ULong_t Number2Pixel(Int_t ci)
Composite GUI element for selection of range (label, two number-entries and double-slider).
void SetModel(TObject *obj) override
Set model object.
TEveRGBAPaletteEditor(const TEveRGBAPaletteEditor &)
TEveRGBAPaletteSubEditor * fSE
Sub-editor for TEveRGBAPalette class.
void DoUnderflowAction(Int_t mode)
Slot for UnderflowAction.
void DoUnderColor(Pixel_t color)
Slot for UnderColor.
void DoFixColorRange()
Slot for FixColorRange.
void DoOverColor(Pixel_t color)
Slot for OverColor.
void DoShowDefValue()
Slot for ShowDefValue.
void DoDefaultColor(Pixel_t color)
Slot for DefaultColor.
TEveRGBAPaletteSubEditor(const TEveRGBAPaletteSubEditor &)
void DoOverflowAction(Int_t mode)
Slot for OverflowAction.
void DoInterpolate()
Slot for Interpolate.
void Changed()
Emit "Changed()" signal.
TEveGDoubleValuator * fMinMax
void DoMinMax()
Slot for MinMax.
void SetModel(TEveRGBAPalette *p)
Set model object.
A generic, speed-optimised mapping from value to RGBA color supporting different wrapping and range t...
Selects different options.
Definition TGButton.h:264
Like a checkbutton but instead of the check mark there is color area with a little down arrow.
A combobox (also known as a drop down listbox) allows the selection of one item out of a list of item...
Definition TGComboBox.h:47
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
UInt_t GetWidth() const
Definition TGFrame.h:226
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
A listbox is a box, possibly with scrollbar, containing entries.
Definition TGListBox.h:221
void Resize(UInt_t w, UInt_t h) override
Resize the listbox widget.
@ kNESInteger
Style of number entry field.
TGVerticalFrame(const TGWindow *p=nullptr, UInt_t w=1, UInt_t h=1, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Definition TGFrame.h:378
ROOT GUI Window base class.
Definition TGWindow.h:23
TGedFrame(const TGedFrame &)=delete
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition TGedFrame.cxx:94
Mother of all ROOT objects.
Definition TObject.h:42
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
Definition TMath.h:704
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:249
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:197
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Definition TMath.h:773