Logo ROOT  
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 
12 #include "TEveRGBAPaletteEditor.h"
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
26 Sub-editor for TEveRGBAPalette class.
27 */
28 
30 
31 ////////////////////////////////////////////////////////////////////////////////
32 /// Constructor.
33 
35  TGVerticalFrame(p),
36 
37  fM(0),
38 
39  fUnderflowAction (0),
40  fUnderColor (0),
41  fOverflowAction (0),
42  fOverColor (0),
43 
44  fMinMax(0), fOldMin(0), fOldMax(0),
45 
46  fInterpolate(0),
47  fShowDefValue(0),
48  fDefaultColor(0),
49  fFixColorRange(0)
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);
138  fMinMax->SetNELength(5);
139  fMinMax->SetLabelWidth(74);
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))));
162  fOldMin = fMinMax->GetMin();
163  fOldMax = fMinMax->GetMax();
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();
222  fM->MinMaxValChanged();
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 {
284  fM->SetUnderflowAction(mode);
285  Changed();
286 }
287 
288 ////////////////////////////////////////////////////////////////////////////////
289 /// Slot for OverflowAction.
290 
292 {
293  fM->SetOverflowAction(mode);
294  Changed();
295 }
296 
297 
298 /** \class TEveRGBAPaletteEditor
299 \ingroup TEve
300 Editor 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 (0),
312  fSE(0)
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 }
TGComboBox.h
TEveRGBAPalette::SetMinMax
void SetMinMax(Int_t min, Int_t max)
Set current min/max values.
Definition: TEveRGBAPalette.cxx:215
TGListBox
Definition: TGListBox.h:288
TEveRGBAPaletteSubEditor::DoOverflowAction
void DoOverflowAction(Int_t mode)
Slot for OverflowAction.
Definition: TEveRGBAPaletteEditor.cxx:291
TGWindow
Definition: TGWindow.h:31
TEveRGBAPaletteEditor::fSE
TEveRGBAPaletteSubEditor * fSE
Definition: TEveRGBAPaletteEditor.h:82
TGCheckButton::SetState
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set check button state.
Definition: TGButton.cxx:1203
TGDoubleSlider.h
TEveRGBAPaletteSubEditor::DoInterpolate
void DoInterpolate()
Slot for Interpolate.
Definition: TEveRGBAPaletteEditor.cxx:228
f
#define f(i)
Definition: RSha256.hxx:122
TEveRGBAPalette::SetFixColorRange
void SetFixColorRange(Bool_t v)
Set flag specifying how the palette is mapped to signal values: true - LowLimit -> HighLimit false - ...
Definition: TEveRGBAPalette.cxx:252
TMath::Max
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
TEveRGBAPalette::SetShowDefValue
void SetShowDefValue(Bool_t v)
Definition: TEveRGBAPalette.h:117
TEveRGBAPalette::fShowDefValue
Bool_t fShowDefValue
Definition: TEveRGBAPalette.h:55
kButtonDown
@ kButtonDown
Definition: TGButton.h:60
kLHintsTop
@ kLHintsTop
Definition: TGLayout.h:40
Pixel_t
ULong_t Pixel_t
Definition: GuiTypes.h:39
TEveRGBAPalette::SetDefaultColorPixel
void SetDefaultColorPixel(Pixel_t pix)
Set default color.
Definition: TEveRGBAPalette.cxx:270
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TGComboBox::AddEntry
virtual void AddEntry(TGString *s, Int_t id)
Definition: TGComboBox.h:106
TGCheckButton::IsOn
virtual Bool_t IsOn() const
Definition: TGButton.h:311
kVerticalFrame
@ kVerticalFrame
Definition: GuiTypes.h:381
kLHintsLeft
@ kLHintsLeft
Definition: TGLayout.h:37
TEveRGBAPalette::SetOverColorPixel
void SetOverColorPixel(Pixel_t pix)
Set overflow color.
Definition: TEveRGBAPalette.cxx:328
TGLabel
Definition: TGLabel.h:32
TGListBox::Resize
virtual void Resize(UInt_t w, UInt_t h)
Resize the listbox widget.
Definition: TGListBox.cxx:1420
kButtonUp
@ kButtonUp
Definition: TGButton.h:59
TEveRGBAPaletteSubEditor::DoDefaultColor
void DoDefaultColor(Pixel_t color)
Slot for DefaultColor.
Definition: TEveRGBAPaletteEditor.cxx:246
width
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
TEveRGBAPaletteEditor.h
TEveRGBAPalette.h
TEveRGBAPaletteSubEditor
Definition: TEveRGBAPaletteEditor.h:25
TEveGDoubleValuator::GetMin
Float_t GetMin() const
Definition: TEveGValuators.h:139
TGComboBox::Select
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:451
TColor.h
TColor::Number2Pixel
static ULong_t Number2Pixel(Int_t ci)
Static method that given a color index number, returns the corresponding pixel value.
Definition: TColor.cxx:2013
TGHorizontalFrame
Definition: TGFrame.h:423
TEveRGBAPaletteSubEditor::fDefaultColor
TGColorSelect * fDefaultColor
Definition: TEveRGBAPaletteEditor.h:45
TEveRGBAPaletteEditor::fM
TEveRGBAPalette * fM
Definition: TEveRGBAPaletteEditor.h:81
TEveRGBAPalette::fMaxVal
Int_t fMaxVal
Definition: TEveRGBAPalette.h:51
TEveRGBAPalette::GetDefaultColor
Color_t GetDefaultColor() const
Definition: TEveRGBAPalette.h:129
TEveGValuators.h
TEveGDoubleValuator::Build
virtual void Build(Bool_t connect=kTRUE)
Create sub-components (label, number entries, double-slider).
Definition: TEveGValuators.cxx:264
TGFrame::GetWidth
UInt_t GetWidth() const
Definition: TGFrame.h:249
TEveRGBAPalette::GetUnderColor
Color_t GetUnderColor() const
Definition: TEveRGBAPalette.h:140
TEveRGBAPaletteSubEditor::DoOverColor
void DoOverColor(Pixel_t color)
Slot for OverColor.
Definition: TEveRGBAPaletteEditor.cxx:273
TEveRGBAPaletteSubEditor::fInterpolate
TGCheckButton * fInterpolate
Definition: TEveRGBAPaletteEditor.h:43
TEveRGBAPaletteSubEditor::fUnderflowAction
TGComboBox * fUnderflowAction
Definition: TEveRGBAPaletteEditor.h:34
kLHintsBottom
@ kLHintsBottom
Definition: TGLayout.h:42
TGCheckButton
Definition: TGButton.h:264
TEveRGBAPalette::IntToDouble
Double_t IntToDouble(Int_t i) const
Definition: TEveRGBAPalette.h:74
TEveRGBAPalette::GetOverColor
Color_t GetOverColor() const
Definition: TEveRGBAPalette.h:151
TEveRGBAPalette::SetUnderColorPixel
void SetUnderColorPixel(Pixel_t pix)
Set underflow color.
Definition: TEveRGBAPalette.cxx:299
TEveGDoubleValuator::SetLimits
void SetLimits(Int_t min, Int_t max)
Set limits of the represented range for integer values.
Definition: TEveGValuators.cxx:330
TMath::Nint
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
Definition: TMath.h:702
TMath::Log10
Double_t Log10(Double_t x)
Definition: TMath.h:753
TEveRGBAPaletteSubEditor::DoShowDefValue
void DoShowDefValue()
Slot for ShowDefValue.
Definition: TEveRGBAPaletteEditor.cxx:237
TGVerticalFrame
Definition: TGFrame.h:412
TEveRGBAPalette::fLowLimit
Int_t fLowLimit
Definition: TEveRGBAPalette.h:48
TGFrame::Resize
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:590
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TEveRGBAPalette::fMinVal
Int_t fMinVal
Definition: TEveRGBAPalette.h:50
TEveRGBAPalette::DoubleToInt
Int_t DoubleToInt(Double_t d) const
Definition: TEveRGBAPalette.h:75
TEveRGBAPalette::fFixColorRange
Bool_t fFixColorRange
Definition: TEveRGBAPalette.h:56
TGLayoutHints
Definition: TGLayout.h:57
TEveGDoubleValuator::SetValues
void SetValues(Float_t min, Float_t max, Bool_t emit=kFALSE)
Set min/max values, optionally emit signal.
Definition: TEveGValuators.cxx:394
TEveRGBAPaletteSubEditor::fOverColor
TGColorSelect * fOverColor
Definition: TEveRGBAPaletteEditor.h:37
TEveGValuatorBase::SetNELength
void SetNELength(Int_t l)
Definition: TEveGValuators.h:46
TEveGDoubleValuator
Definition: TEveGValuators.h:108
TEveRGBAPalette::fHighLimit
Int_t fHighLimit
Definition: TEveRGBAPalette.h:49
TGComboBox::GetListBox
virtual TGListBox * GetListBox() const
Definition: TGComboBox.h:130
TEveRGBAPalette::SetUnderflowAction
void SetUnderflowAction(Int_t a)
Definition: TEveRGBAPalette.h:124
TEveRGBAPaletteSubEditor::fFixColorRange
TGCheckButton * fFixColorRange
Definition: TEveRGBAPaletteEditor.h:46
TEveGDoubleValuator::GetMax
Float_t GetMax() const
Definition: TEveGValuators.h:140
TGedFrame::MakeTitle
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
TEveRGBAPalette::fOverflowAction
Int_t fOverflowAction
Definition: TEveRGBAPalette.h:58
TEveRGBAPaletteEditor::TEveRGBAPaletteEditor
TEveRGBAPaletteEditor(const TEveRGBAPaletteEditor &)
TEveGDoubleValuator::GetSlider
TGDoubleHSlider * GetSlider()
Definition: TEveGValuators.h:129
TEveRGBAPaletteSubEditor::DoUnderColor
void DoUnderColor(Pixel_t color)
Slot for UnderColor.
Definition: TEveRGBAPaletteEditor.cxx:264
TEveRGBAPaletteSubEditor::fUnderColor
TGColorSelect * fUnderColor
Definition: TEveRGBAPaletteEditor.h:35
TEveRGBAPaletteSubEditor::DoMinMax
void DoMinMax()
Slot for MinMax.
Definition: TEveRGBAPaletteEditor.cxx:194
TEveRGBAPaletteEditor::SetModel
virtual void SetModel(TObject *obj)
Set model object.
Definition: TEveRGBAPaletteEditor.cxx:324
TMath::Min
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:180
unsigned int
TEveRGBAPaletteEditor
Definition: TEveRGBAPaletteEditor.h:74
TGComboBox
Definition: TGComboBox.h:67
TEveRGBAPalette::SetInterpolate
void SetInterpolate(Bool_t b)
Set interpolation flag.
Definition: TEveRGBAPalette.cxx:241
TGedFrame
Definition: TGedFrame.h:33
TGLabel.h
TEveRGBAPaletteSubEditor::fMinMax
TEveGDoubleValuator * fMinMax
Definition: TEveRGBAPaletteEditor.h:39
TEveRGBAPalette::fUnderflowAction
Int_t fUnderflowAction
Definition: TEveRGBAPalette.h:57
Double_t
double Double_t
Definition: RtypesCore.h:59
TQObject::Connect
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:864
TEveRGBAPaletteSubEditor::fOverflowAction
TGComboBox * fOverflowAction
Definition: TEveRGBAPaletteEditor.h:36
TGFrame::SetWidth
virtual void SetWidth(UInt_t w)
Definition: TGFrame.h:271
TEveRGBAPaletteSubEditor::SetModel
void SetModel(TEveRGBAPalette *p)
Set model object.
Definition: TEveRGBAPaletteEditor.cxx:151
TObject
Definition: TObject.h:37
TGButton.h
TEveGValuatorBase::SetLabelWidth
void SetLabelWidth(Int_t w)
Definition: TEveGValuators.h:42
TEveRGBAPaletteSubEditor::fOldMin
Double_t fOldMin
Definition: TEveRGBAPaletteEditor.h:40
TEveRGBAPaletteSubEditor::DoUnderflowAction
void DoUnderflowAction(Int_t mode)
Slot for UnderflowAction.
Definition: TEveRGBAPaletteEditor.cxx:282
TEveRGBAPaletteSubEditor::fOldMax
Double_t fOldMax
Definition: TEveRGBAPaletteEditor.h:41
TGColorSelect::SetColor
void SetColor(Pixel_t color, Bool_t emit=kTRUE)
Set color.
Definition: TGColorSelect.cxx:636
TGColorSelect
Definition: TGColorSelect.h:127
TEveRGBAPaletteSubEditor::TEveRGBAPaletteSubEditor
TEveRGBAPaletteSubEditor(const TEveRGBAPaletteSubEditor &)
TEveRGBAPaletteSubEditor::Changed
void Changed()
Emit "Changed()" signal.
Definition: TEveRGBAPaletteEditor.cxx:186
TGColorSelect.h
TEveRGBAPaletteSubEditor::fM
TEveRGBAPalette * fM
Definition: TEveRGBAPaletteEditor.h:32
TEveRGBAPalette::fUIDoubleRep
Bool_t fUIDoubleRep
Definition: TEveRGBAPalette.h:53
TEveRGBAPalette::fInterpolate
Bool_t fInterpolate
Definition: TEveRGBAPalette.h:54
TEveRGBAPaletteSubEditor::fShowDefValue
TGCheckButton * fShowDefValue
Definition: TEveRGBAPaletteEditor.h:44
TGCompositeFrame::AddFrame
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1102
TGNumberFormat::EStyle
EStyle
Definition: TGNumberEntry.h:39
TGNumberFormat::kNESInteger
@ kNESInteger
Definition: TGNumberEntry.h:46
TEveRGBAPalette::MinMaxValChanged
void MinMaxValChanged()
Emit the "MinMaxValChanged()" signal.
Definition: TEveRGBAPalette.cxx:351
TEveRGBAPalette::SetOverflowAction
void SetOverflowAction(Int_t a)
Definition: TEveRGBAPalette.h:125
TQObject::Emit
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
int
TEveRGBAPaletteSubEditor::DoFixColorRange
void DoFixColorRange()
Slot for FixColorRange.
Definition: TEveRGBAPaletteEditor.cxx:255
TEveRGBAPalette
Definition: TEveRGBAPalette.h:22