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);
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);
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);
139 fMinMax->Build();
140 fMinMax->GetSlider()->SetWidth(190);
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
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 {
218 }
219
220 Changed();
222}
223
224////////////////////////////////////////////////////////////////////////////////
225/// Slot for Interpolate.
226
232
233////////////////////////////////////////////////////////////////////////////////
234/// Slot for ShowDefValue.
235
241
242////////////////////////////////////////////////////////////////////////////////
243/// Slot for DefaultColor.
244
250
251////////////////////////////////////////////////////////////////////////////////
252/// Slot for FixColorRange.
253
259
260////////////////////////////////////////////////////////////////////////////////
261/// Slot for UnderColor.
262
268
269////////////////////////////////////////////////////////////////////////////////
270/// Slot for OverColor.
271
277
278////////////////////////////////////////////////////////////////////////////////
279/// Slot for UnderflowAction.
280
286
287////////////////////////////////////////////////////////////////////////////////
288/// Slot for OverflowAction.
289
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:381
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
#define f(i)
Definition RSha256.hxx:104
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
@ 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
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char mode
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
static ULong_t Number2Pixel(Int_t ci)
Static method that given a color index number, returns the corresponding pixel value.
Definition TColor.cxx:2445
Composite GUI element for selection of range (label, two number-entries and double-slider).
Float_t GetMin() const
void Build(Bool_t connect=kTRUE) override
Create sub-components (label, number entries, double-slider).
TGDoubleHSlider * GetSlider()
void SetLimits(Int_t min, Int_t max)
Set limits of the represented range for integer values.
Float_t GetMax() const
void SetValues(Float_t min, Float_t max, Bool_t emit=kFALSE)
Set min/max values, optionally emit signal.
void SetLabelWidth(Int_t w)
void SetNELength(Int_t l)
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...
void SetUnderColorPixel(Pixel_t pix)
Set underflow color.
Color_t GetUnderColor() const
void SetInterpolate(Bool_t b)
Set interpolation flag.
Color_t GetOverColor() const
Int_t DoubleToInt(Double_t d) const
void SetShowDefValue(Bool_t v)
Color_t GetDefaultColor() const
void SetDefaultColorPixel(Pixel_t pix)
Set default color.
Double_t IntToDouble(Int_t i) const
void SetUnderflowAction(Int_t a)
void SetOverColorPixel(Pixel_t pix)
Set overflow color.
void SetFixColorRange(Bool_t v)
Set flag specifying how the palette is mapped to signal values: true - LowLimit -> HighLimit false - ...
void SetMinMax(Int_t min, Int_t max)
Set current min/max values.
void MinMaxValChanged()
Emit the "MinMaxValChanged()" signal.
void SetOverflowAction(Int_t a)
Selects different options.
Definition TGButton.h:264
Bool_t IsOn() const override
Definition TGButton.h:310
void SetState(EButtonState state, Bool_t emit=kFALSE) override
Set check button state.
Like a checkbutton but instead of the check mark there is color area with a little down arrow.
void SetColor(Pixel_t color, Bool_t emit=kTRUE)
Set color.
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 AddEntry(TGString *s, Int_t id)
Definition TGComboBox.h:86
virtual TGListBox * GetListBox() const
Definition TGComboBox.h:110
virtual void Select(Int_t id, Bool_t emit=kTRUE)
Make the selected item visible in the combo box window and emit signals according to the second param...
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
virtual void SetWidth(UInt_t w)
Definition TGFrame.h:248
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
@ kNESInteger
Style of number entry field.
A composite frame that layout their children in vertical way.
Definition TGFrame.h:376
ROOT GUI Window base class.
Definition TGWindow.h:23
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:94
Mother of all ROOT objects.
Definition TObject.h:41
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
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:251
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:199
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Definition TMath.h:773