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
30
31////////////////////////////////////////////////////////////////////////////////
32/// Constructor.
33
36
37 fM(nullptr),
38
39 fUnderflowAction (nullptr),
40 fUnderColor (nullptr),
41 fOverflowAction (nullptr),
42 fOverColor (nullptr),
43
44 fMinMax(nullptr), fOldMin(0), fOldMax(0),
45
46 fInterpolate(nullptr),
47 fShowDefValue(nullptr),
48 fDefaultColor(nullptr),
49 fFixColorRange(nullptr)
50{
51 {
53
54 fInterpolate = new TGCheckButton(f, "Interpolate");
55 f->AddFrame(fInterpolate, new TGLayoutHints(kLHintsLeft, 3, 1, 1, 0));
56 fInterpolate->Connect("Toggled(Bool_t)",
57 "TEveRGBAPaletteSubEditor", this, "DoInterpolate()");
58
59 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
60 }
61
62 {
64
65 fShowDefValue = new TGCheckButton(f, "Show default value");
66 f->AddFrame(fShowDefValue, new TGLayoutHints(kLHintsLeft, 3, 1, 1, 0));
67 fShowDefValue->Connect("Toggled(Bool_t)",
68 "TEveRGBAPaletteSubEditor", this, "DoShowDefValue()");
69
70 fDefaultColor = new TGColorSelect(f, 0, -1);
71 f->AddFrame(fDefaultColor, new TGLayoutHints(kLHintsLeft|kLHintsTop, 0, 0, 0, 0));
72 fDefaultColor->Connect("ColorSelected(Pixel_t)",
73 "TEveRGBAPaletteSubEditor", this, "DoDefaultColor(Pixel_t)");
74
75 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 2, 0));
76 }
77
78 {
80
81 fFixColorRange = new TGCheckButton(f, "Fix color range");
82 f->AddFrame(fFixColorRange, new TGLayoutHints(kLHintsLeft, 3, 1, 0, 0));
83 fFixColorRange->Connect("Toggled(Bool_t)",
84 "TEveRGBAPaletteSubEditor", this, "DoFixColorRange()");
85
86 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 0, 2));
87 }
88
89 { // Underflow
91 TGLabel* lab = new TGLabel(f, "Underflow:");
92 f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 15, 1, 2));
94 fUnderflowAction->AddEntry("Cut", 0);
95 fUnderflowAction->AddEntry("Mark", 1);
96 fUnderflowAction->AddEntry("Clip", 2);
97 fUnderflowAction->AddEntry("Wrap", 3);
99 lb->Resize(lb->GetWidth(), 4*16);
100 fUnderflowAction->Resize(59, 20);
101 fUnderflowAction->Connect("Selected(Int_t)", "TEveRGBAPaletteSubEditor", this,
102 "DoUnderflowAction(Int_t)");
103 f->AddFrame(fUnderflowAction, new TGLayoutHints(kLHintsLeft, 1, 2, 1, 1));
104
105 fUnderColor = new TGColorSelect(f, 0, -1);
106 f->AddFrame(fUnderColor, new TGLayoutHints(kLHintsLeft|kLHintsTop, 1, 1, 0, 2));
107 fUnderColor->Connect("ColorSelected(Pixel_t)",
108 "TEveRGBAPaletteSubEditor", this, "DoUnderColor(Pixel_t)");
109
110 AddFrame(f);
111 }
112
113 { // Overflow
115 TGLabel* lab = new TGLabel(f, "Overflow:");
116 f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 20, 1, 2));
118 fOverflowAction->AddEntry("Cut", 0);
119 fOverflowAction->AddEntry("Mark", 1);
120 fOverflowAction->AddEntry("Clip", 2);
121 fOverflowAction->AddEntry("Wrap", 3);
123 lb->Resize(lb->GetWidth(), 4*16);
124 fOverflowAction->Resize(59, 20);
125 fOverflowAction->Connect("Selected(Int_t)", "TEveRGBAPaletteSubEditor", this,
126 "DoOverflowAction(Int_t)");
127 f->AddFrame(fOverflowAction, new TGLayoutHints(kLHintsLeft, 1, 2, 1, 1));
128
129 fOverColor = new TGColorSelect(f, 0, -1);
130 f->AddFrame(fOverColor, new TGLayoutHints(kLHintsLeft|kLHintsTop, 1, 1, 0, 2));
131 fOverColor->Connect("ColorSelected(Pixel_t)",
132 "TEveRGBAPaletteSubEditor", this, "DoOverColor(Pixel_t)");
133
134 AddFrame(f);
135 }
136
137 fMinMax = new TEveGDoubleValuator(this,"Main range:", 130, 0);
140 fMinMax->Build();
141 fMinMax->GetSlider()->SetWidth(190);
143 fMinMax->Connect("ValueSet()",
144 "TEveRGBAPaletteSubEditor", this, "DoMinMax()");
145 AddFrame(fMinMax, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
146}
147
148////////////////////////////////////////////////////////////////////////////////
149/// Set model object.
150
152{
153 fM = p;
154
155 if (fM->fUIDoubleRep)
156 {
160 Int_t mgk = TMath::Min(3, TMath::Max(0, 3 - TMath::Nint(TMath::Log10(hl-ll))));
164 }
165 else
166 {
169 }
170
175
178
181}
182
183////////////////////////////////////////////////////////////////////////////////
184/// Emit "Changed()" signal.
185
187{
188 Emit("Changed()");
189}
190
191////////////////////////////////////////////////////////////////////////////////
192/// Slot for MinMax.
193
195{
196 if (fM->fUIDoubleRep)
197 {
198 Double_t min = fMinMax->GetMin();
199 if (min != fOldMin && fM->DoubleToInt(min) == fM->fMinVal)
200 {
201 if (min < fOldMin)
202 min = fM->IntToDouble(fM->fMinVal - 1);
203 else
204 min = fM->IntToDouble(fM->fMinVal + 1);
205 }
206 Double_t max = fMinMax->GetMax();
207 if (max != fOldMax && fM->DoubleToInt(max) == fM->fMaxVal)
208 {
209 if (max < fOldMax)
210 max = fM->IntToDouble(fM->fMaxVal - 1);
211 else
212 max = fM->IntToDouble(fM->fMaxVal + 1);
213 }
214 fM->SetMinMax(fM->DoubleToInt(min), fM->DoubleToInt(max));
215 }
216 else
217 {
219 }
220
221 Changed();
223}
224
225////////////////////////////////////////////////////////////////////////////////
226/// Slot for Interpolate.
227
229{
231 Changed();
232}
233
234////////////////////////////////////////////////////////////////////////////////
235/// Slot for ShowDefValue.
236
238{
240 Changed();
241}
242
243////////////////////////////////////////////////////////////////////////////////
244/// Slot for DefaultColor.
245
247{
248 fM->SetDefaultColorPixel(color);
249 Changed();
250}
251
252////////////////////////////////////////////////////////////////////////////////
253/// Slot for FixColorRange.
254
256{
258 Changed();
259}
260
261////////////////////////////////////////////////////////////////////////////////
262/// Slot for UnderColor.
263
265{
266 fM->SetUnderColorPixel(color);
267 Changed();
268}
269
270////////////////////////////////////////////////////////////////////////////////
271/// Slot for OverColor.
272
274{
275 fM->SetOverColorPixel(color);
276 Changed();
277}
278
279////////////////////////////////////////////////////////////////////////////////
280/// Slot for UnderflowAction.
281
283{
285 Changed();
286}
287
288////////////////////////////////////////////////////////////////////////////////
289/// Slot for OverflowAction.
290
292{
294 Changed();
295}
296
297
298/** \class TEveRGBAPaletteEditor
299\ingroup TEve
300Editor for TEveRGBAPalette class.
301*/
302
304
305////////////////////////////////////////////////////////////////////////////////
306/// Constructor.
307
309 UInt_t options, Pixel_t back) :
310 TGedFrame(p, width, height, options | kVerticalFrame, back),
311 fM (nullptr),
312 fSE(nullptr)
313{
314 MakeTitle("TEveRGBAPalette");
315
316 fSE = new TEveRGBAPaletteSubEditor(this);
317 AddFrame(fSE, new TGLayoutHints(kLHintsTop, 2, 0, 2, 2));
318 fSE->Connect("Changed()", "TEveRGBAPaletteEditor", this, "Update()");
319}
320
321////////////////////////////////////////////////////////////////////////////////
322/// Set model object.
323
325{
326 fM = dynamic_cast<TEveRGBAPalette*>(obj);
327 fSE->SetModel(fM);
328}
@ 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:101
#define ClassImp(name)
Definition Rtypes.h:377
@ 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:2320
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)
Editor for TEveRGBAPalette class.
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:1117
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
virtual void SetWidth(UInt_t w)
Definition TGFrame.h:246
UInt_t GetWidth() const
Definition TGFrame.h:224
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
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.
A composite frame that layout their children in vertical way.
Definition TGFrame.h:374
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:95
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:869
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
Definition TMath.h:693
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:250
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:198
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Definition TMath.h:762