Logo ROOT   6.16/01
Reference Guide
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 "TVirtualPad.h"
17#include "TColor.h"
18
19#include "TGLabel.h"
20#include "TGButton.h"
21#include "TGComboBox.h"
22#include "TGColorSelect.h"
23#include "TGSlider.h"
24#include "TGDoubleSlider.h"
25
26/** \class TEveRGBAPaletteSubEditor
27\ingroup TEve
28Sub-editor for TEveRGBAPalette class.
29*/
30
32
33////////////////////////////////////////////////////////////////////////////////
34/// Constructor.
35
38
39 fM(0),
40
41 fUnderflowAction (0),
42 fUnderColor (0),
43 fOverflowAction (0),
44 fOverColor (0),
45
46 fMinMax(0), fOldMin(0), fOldMax(0),
47
48 fInterpolate(0),
49 fShowDefValue(0),
50 fDefaultColor(0),
51 fFixColorRange(0)
52{
53 {
55
56 fInterpolate = new TGCheckButton(f, "Interpolate");
57 f->AddFrame(fInterpolate, new TGLayoutHints(kLHintsLeft, 3, 1, 1, 0));
58 fInterpolate->Connect("Toggled(Bool_t)",
59 "TEveRGBAPaletteSubEditor", this, "DoInterpolate()");
60
61 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
62 }
63
64 {
66
67 fShowDefValue = new TGCheckButton(f, "Show default value");
68 f->AddFrame(fShowDefValue, new TGLayoutHints(kLHintsLeft, 3, 1, 1, 0));
69 fShowDefValue->Connect("Toggled(Bool_t)",
70 "TEveRGBAPaletteSubEditor", this, "DoShowDefValue()");
71
72 fDefaultColor = new TGColorSelect(f, 0, -1);
73 f->AddFrame(fDefaultColor, new TGLayoutHints(kLHintsLeft|kLHintsTop, 0, 0, 0, 0));
74 fDefaultColor->Connect("ColorSelected(Pixel_t)",
75 "TEveRGBAPaletteSubEditor", this, "DoDefaultColor(Pixel_t)");
76
77 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 2, 0));
78 }
79
80 {
82
83 fFixColorRange = new TGCheckButton(f, "Fix color range");
84 f->AddFrame(fFixColorRange, new TGLayoutHints(kLHintsLeft, 3, 1, 0, 0));
85 fFixColorRange->Connect("Toggled(Bool_t)",
86 "TEveRGBAPaletteSubEditor", this, "DoFixColorRange()");
87
88 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 0, 2));
89 }
90
91 { // Underflow
93 TGLabel* lab = new TGLabel(f, "Underflow:");
94 f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 15, 1, 2));
96 fUnderflowAction->AddEntry("Cut", 0);
97 fUnderflowAction->AddEntry("Mark", 1);
98 fUnderflowAction->AddEntry("Clip", 2);
99 fUnderflowAction->AddEntry("Wrap", 3);
101 lb->Resize(lb->GetWidth(), 4*16);
102 fUnderflowAction->Resize(59, 20);
103 fUnderflowAction->Connect("Selected(Int_t)", "TEveRGBAPaletteSubEditor", this,
104 "DoUnderflowAction(Int_t)");
105 f->AddFrame(fUnderflowAction, new TGLayoutHints(kLHintsLeft, 1, 2, 1, 1));
106
107 fUnderColor = new TGColorSelect(f, 0, -1);
108 f->AddFrame(fUnderColor, new TGLayoutHints(kLHintsLeft|kLHintsTop, 1, 1, 0, 2));
109 fUnderColor->Connect("ColorSelected(Pixel_t)",
110 "TEveRGBAPaletteSubEditor", this, "DoUnderColor(Pixel_t)");
111
112 AddFrame(f);
113 }
114
115 { // Overflow
117 TGLabel* lab = new TGLabel(f, "Overflow:");
118 f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 20, 1, 2));
120 fOverflowAction->AddEntry("Cut", 0);
121 fOverflowAction->AddEntry("Mark", 1);
122 fOverflowAction->AddEntry("Clip", 2);
123 fOverflowAction->AddEntry("Wrap", 3);
125 lb->Resize(lb->GetWidth(), 4*16);
126 fOverflowAction->Resize(59, 20);
127 fOverflowAction->Connect("Selected(Int_t)", "TEveRGBAPaletteSubEditor", this,
128 "DoOverflowAction(Int_t)");
129 f->AddFrame(fOverflowAction, new TGLayoutHints(kLHintsLeft, 1, 2, 1, 1));
130
131 fOverColor = new TGColorSelect(f, 0, -1);
132 f->AddFrame(fOverColor, new TGLayoutHints(kLHintsLeft|kLHintsTop, 1, 1, 0, 2));
133 fOverColor->Connect("ColorSelected(Pixel_t)",
134 "TEveRGBAPaletteSubEditor", this, "DoOverColor(Pixel_t)");
135
136 AddFrame(f);
137 }
138
139 fMinMax = new TEveGDoubleValuator(this,"Main range:", 130, 0);
142 fMinMax->Build();
143 fMinMax->GetSlider()->SetWidth(190);
145 fMinMax->Connect("ValueSet()",
146 "TEveRGBAPaletteSubEditor", this, "DoMinMax()");
147 AddFrame(fMinMax, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
148}
149
150////////////////////////////////////////////////////////////////////////////////
151/// Set model object.
152
154{
155 fM = p;
156
157 if (fM->fUIDoubleRep)
158 {
162 Int_t mgk = TMath::Min(3, TMath::Max(0, 3 - TMath::Nint(TMath::Log10(hl-ll))));
166 }
167 else
168 {
171 }
172
177
180
183}
184
185////////////////////////////////////////////////////////////////////////////////
186/// Emit "Changed()" signal.
187
189{
190 Emit("Changed()");
191}
192
193////////////////////////////////////////////////////////////////////////////////
194/// Slot for MinMax.
195
197{
198 if (fM->fUIDoubleRep)
199 {
200 Double_t min = fMinMax->GetMin();
201 if (min != fOldMin && fM->DoubleToInt(min) == fM->fMinVal)
202 {
203 if (min < fOldMin)
204 min = fM->IntToDouble(fM->fMinVal - 1);
205 else
206 min = fM->IntToDouble(fM->fMinVal + 1);
207 }
208 Double_t max = fMinMax->GetMax();
209 if (max != fOldMax && fM->DoubleToInt(max) == fM->fMaxVal)
210 {
211 if (max < fOldMax)
212 max = fM->IntToDouble(fM->fMaxVal - 1);
213 else
214 max = fM->IntToDouble(fM->fMaxVal + 1);
215 }
216 fM->SetMinMax(fM->DoubleToInt(min), fM->DoubleToInt(max));
217 }
218 else
219 {
221 }
222
223 Changed();
225}
226
227////////////////////////////////////////////////////////////////////////////////
228/// Slot for Interpolate.
229
231{
233 Changed();
234}
235
236////////////////////////////////////////////////////////////////////////////////
237/// Slot for ShowDefValue.
238
240{
242 Changed();
243}
244
245////////////////////////////////////////////////////////////////////////////////
246/// Slot for DefaultColor.
247
249{
250 fM->SetDefaultColorPixel(color);
251 Changed();
252}
253
254////////////////////////////////////////////////////////////////////////////////
255/// Slot for FixColorRange.
256
258{
260 Changed();
261}
262
263////////////////////////////////////////////////////////////////////////////////
264/// Slot for UnderColor.
265
267{
268 fM->SetUnderColorPixel(color);
269 Changed();
270}
271
272////////////////////////////////////////////////////////////////////////////////
273/// Slot for OverColor.
274
276{
277 fM->SetOverColorPixel(color);
278 Changed();
279}
280
281////////////////////////////////////////////////////////////////////////////////
282/// Slot for UnderflowAction.
283
285{
286 fM->SetUnderflowAction(mode);
287 Changed();
288}
289
290////////////////////////////////////////////////////////////////////////////////
291/// Slot for OverflowAction.
292
294{
295 fM->SetOverflowAction(mode);
296 Changed();
297}
298
299
300/** \class TEveRGBAPaletteEditor
301\ingroup TEve
302Editor for TEveRGBAPalette class.
303*/
304
306
307////////////////////////////////////////////////////////////////////////////////
308/// Constructor.
309
311 UInt_t options, Pixel_t back) :
312 TGedFrame(p, width, height, options | kVerticalFrame, back),
313 fM (0),
314 fSE(0)
315{
316 MakeTitle("TEveRGBAPalette");
317
318 fSE = new TEveRGBAPaletteSubEditor(this);
319 AddFrame(fSE, new TGLayoutHints(kLHintsTop, 2, 0, 2, 2));
320 fSE->Connect("Changed()", "TEveRGBAPaletteEditor", this, "Update()");
321}
322
323////////////////////////////////////////////////////////////////////////////////
324/// Set model object.
325
327{
328 fM = dynamic_cast<TEveRGBAPalette*>(obj);
329 fSE->SetModel(fM);
330}
ULong_t Pixel_t
Definition: GuiTypes.h:39
#define f(i)
Definition: RSha256.hxx:104
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
double Double_t
Definition: RtypesCore.h:55
#define ClassImp(name)
Definition: Rtypes.h:363
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
@ kButtonDown
Definition: TGButton.h:54
@ kButtonUp
Definition: TGButton.h:53
@ kVerticalFrame
Definition: TGFrame.h:59
@ kLHintsLeft
Definition: TGLayout.h:31
@ kLHintsBottom
Definition: TGLayout.h:36
@ kLHintsTop
Definition: TGLayout.h:34
static ULong_t Number2Pixel(Int_t ci)
Static method that given a color index number, returns the corresponding pixel value.
Definition: TColor.cxx:1997
Composite GUI element for selection of range (label, two number-entries and double-slider).
Float_t GetMin() const
TGDoubleHSlider * GetSlider()
void SetLimits(Int_t min, Int_t max)
Set limits of the represented range for integer values.
Float_t GetMax() const
virtual void Build(Bool_t connect=kTRUE)
Create sub-components (label, number entries, double-slider).
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.
TEveRGBAPaletteEditor(const TEveRGBAPaletteEditor &)
TEveRGBAPaletteSubEditor * fSE
virtual void SetModel(TObject *obj)
Set model object.
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)
virtual Bool_t IsOn() const
Definition: TGButton.h:311
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set check button state.
Definition: TGButton.cxx:1200
void SetColor(Pixel_t color, Bool_t emit=kTRUE)
Set color.
virtual void AddEntry(TGString *s, Int_t id)
Definition: TGComboBox.h:106
virtual TGListBox * GetListBox() const
Definition: TGComboBox.h:130
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...
Definition: TGComboBox.cxx:443
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
virtual void SetWidth(UInt_t w)
Definition: TGFrame.h:293
UInt_t GetWidth() const
Definition: TGFrame.h:271
virtual void Resize(UInt_t w, UInt_t h)
Resize the listbox widget.
Definition: TGListBox.cxx:1419
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
Mother of all ROOT objects.
Definition: TObject.h:37
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:165
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:867
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
Definition: TMath.h:701
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:180
Double_t Log10(Double_t x)
Definition: TMath.h:752