ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
12 #include "TEveRGBAPaletteEditor.h"
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
28 Sub-editor for TEveRGBAPalette class.
29 */
30 
32 
33 ////////////////////////////////////////////////////////////////////////////////
34 /// Constructor.
35 
37  TGVerticalFrame(p),
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));
95  fUnderflowAction = new TGComboBox(f);
96  fUnderflowAction->AddEntry("Cut", 0);
97  fUnderflowAction->AddEntry("Mark", 1);
98  fUnderflowAction->AddEntry("Clip", 2);
99  fUnderflowAction->AddEntry("Wrap", 3);
100  TGListBox* lb = fUnderflowAction->GetListBox();
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));
119  fOverflowAction = new TGComboBox(f);
120  fOverflowAction->AddEntry("Cut", 0);
121  fOverflowAction->AddEntry("Mark", 1);
122  fOverflowAction->AddEntry("Clip", 2);
123  fOverflowAction->AddEntry("Wrap", 3);
124  TGListBox* lb = fOverflowAction->GetListBox();
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);
140  fMinMax->SetNELength(5);
141  fMinMax->SetLabelWidth(74);
142  fMinMax->Build();
143  fMinMax->GetSlider()->SetWidth(190);
144  fMinMax->SetLimits(0, 1023, TGNumberFormat::kNESInteger);
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))));
164  fOldMin = fMinMax->GetMin();
165  fOldMax = fMinMax->GetMax();
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();
224  fM->MinMaxValChanged();
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
302 Editor 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 }
void DoDefaultColor(Pixel_t color)
Slot for DefaultColor.
A generic, speed-optimised mapping from value to RGBA color supporting different wrapping and range t...
virtual void Resize(UInt_t w, UInt_t h)
Resize the listbox widget.
Definition: TGListBox.cxx:1419
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Definition: vector.h:433
void DoMinMax()
Slot for MinMax.
UInt_t GetWidth() const
Definition: TGFrame.h:287
void SetColor(Pixel_t color, Bool_t emit=kTRUE)
Set color.
Int_t DoubleToInt(Double_t d) const
void DoOverColor(Pixel_t color)
Slot for OverColor.
void SetLimits(Int_t min, Int_t max)
Set limits of the represented range for integer values.
void DoFixColorRange()
Slot for FixColorRange.
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:170
int Int_t
Definition: RtypesCore.h:41
Color_t GetUnderColor() const
const Bool_t kFALSE
Definition: Rtypes.h:92
TEveGDoubleValuator * fMinMax
Double_t IntToDouble(Int_t i) const
void SetOverflowAction(Int_t a)
TFile * f
void Changed()
Emit "Changed()" signal.
void DoUnderflowAction(Int_t mode)
Slot for UnderflowAction.
void SetFixColorRange(Bool_t v)
Set flag specifying how the palette is mapped to signal values: true - LowLimit -> HighLimit false - ...
ULong_t Pixel_t
Definition: GuiTypes.h:41
Double_t Log10(Double_t x)
Definition: TMath.h:529
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
void SetDefaultColorPixel(Pixel_t pix)
Set default color.
void DoUnderColor(Pixel_t color)
Slot for UnderColor.
void Emit(const char *signal)
Acitvate signal without args.
Definition: TQObject.cxx:559
Sub-editor for TEveRGBAPalette class.
ClassImp(TEveRGBAPaletteSubEditor) TEveRGBAPaletteSubEditor
Constructor.
virtual void SetModel(TObject *obj)
Set model object.
Color_t GetDefaultColor() const
void SetShowDefValue(Bool_t v)
void SetMinMax(Int_t min, Int_t max)
Set current min/max values.
unsigned int UInt_t
Definition: RtypesCore.h:42
void DoInterpolate()
Slot for Interpolate.
virtual Bool_t IsOn() const
Definition: TGButton.h:315
Float_t GetMin() const
void DoOverflowAction(Int_t mode)
Slot for OverflowAction.
void SetModel(TEveRGBAPalette *p)
Set model object.
void SetValues(Float_t min, Float_t max, Bool_t emit=kFALSE)
Set min/max values, optionally emit signal.
static ULong_t Number2Pixel(Int_t ci)
Static method that given a color index number, returns the corresponding pixel value.
Definition: TColor.cxx:1219
Color_t GetOverColor() const
double Double_t
Definition: RtypesCore.h:55
Editor for TEveRGBAPalette class.
TEveRGBAPaletteSubEditor * fSE
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
Definition: vector.h:440
Mother of all ROOT objects.
Definition: TObject.h:58
void SetInterpolate(Bool_t b)
Set interpolation flag.
Float_t GetMax() const
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:202
void MinMaxValChanged()
Emit the "MinMaxValChanged()" signal.
void SetUnderflowAction(Int_t a)
Composite GUI element for selection of range (label, two number-entries and double-slider).
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set check button state.
Definition: TGButton.cxx:1200
TObject * obj
void SetOverColorPixel(Pixel_t pix)
Set overflow color.
Int_t Nint(T x)
Definition: TMath.h:480
void SetUnderColorPixel(Pixel_t pix)
Set underflow color.
void DoShowDefValue()
Slot for ShowDefValue.