]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/Reve/RGBAPaletteEditor.cxx
Missing initialization; fiddle with the track marker-style a bit more.
[u/mrichter/AliRoot.git] / EVE / Reve / RGBAPaletteEditor.cxx
CommitLineData
8373e543 1// $Header$
2
3#include "RGBAPaletteEditor.h"
4#include <Reve/RGBAPalette.h>
5#include <Reve/RGValuators.h>
6
7#include <TVirtualPad.h>
8#include <TColor.h>
9
10#include <TGLabel.h>
11#include <TGButton.h>
bc5158df 12#include <TGComboBox.h>
8373e543 13#include <TGColorSelect.h>
14#include <TGSlider.h>
15#include <TGDoubleSlider.h>
16
17using namespace Reve;
18
19
20RGBAPaletteSubEditor::RGBAPaletteSubEditor(const TGWindow* p) :
3c67f72c 21 TGVerticalFrame(p),
22
23 fM(0),
bc5158df 24
b615ecc5 25 fUnderflowAction (0),
26 fUnderColor (0),
27 fOverflowAction (0),
28 fOverColor (0),
bc5158df 29
30 fMinMax(0),
31
3c67f72c 32 fInterpolate(0),
bc5158df 33 fShowDefValue(0),
3c67f72c 34 fDefaultColor(0)
8373e543 35{
bc5158df 36 // Int_t labelW = 42;
8373e543 37
38 {
39 TGHorizontalFrame* f = new TGHorizontalFrame(this);
40
8373e543 41 fInterpolate = new TGCheckButton(f, "Interpolate");
b615ecc5 42 f->AddFrame(fInterpolate, new TGLayoutHints(kLHintsLeft, 3, 1, 1, 0));
8373e543 43 fInterpolate->Connect("Toggled(Bool_t)",
44 "Reve::RGBAPaletteSubEditor", this, "DoInterpolate()");
45
b615ecc5 46 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
47 }
48
49 {
50 TGHorizontalFrame* f = new TGHorizontalFrame(this);
51
52 fShowDefValue = new TGCheckButton(f, "Show default value");
53 f->AddFrame(fShowDefValue, new TGLayoutHints(kLHintsLeft, 3, 1, 1, 0));
bc5158df 54 fShowDefValue->Connect("Toggled(Bool_t)",
55 "Reve::RGBAPaletteSubEditor", this, "DoShowDefValue()");
56
b615ecc5 57 fDefaultColor = new TGColorSelect(f, 0, -1);
58 f->AddFrame(fDefaultColor, new TGLayoutHints(kLHintsLeft|kLHintsTop, 3, 1, 0, 2));
59 fDefaultColor->Connect("ColorSelected(Pixel_t)",
60 "Reve::RGBAPaletteSubEditor", this, "DoDefaultColor(Pixel_t)");
61
62 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
8373e543 63 }
64
b615ecc5 65 { // Underflow
bc5158df 66 TGHorizontalFrame* f = new TGHorizontalFrame(this);
b615ecc5 67 TGLabel* lab = new TGLabel(f, "Underflow:");
68 f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 15, 1, 2));
69 fUnderflowAction = new TGComboBox(f);
70 fUnderflowAction->AddEntry("Cut", 0);
71 fUnderflowAction->AddEntry("Mark", 1);
72 fUnderflowAction->AddEntry("Clip", 2);
73 fUnderflowAction->AddEntry("Wrap", 3);
74 TGListBox* lb = fUnderflowAction->GetListBox();
bc5158df 75 lb->Resize(lb->GetWidth(), 4*16);
b615ecc5 76 fUnderflowAction->Resize(59, 20);
77 fUnderflowAction->Connect("Selected(Int_t)", "Reve::RGBAPaletteSubEditor", this,
78 "DoUnderflowAction(Int_t)");
79 f->AddFrame(fUnderflowAction, new TGLayoutHints(kLHintsLeft, 1, 2, 1, 1));
bc5158df 80
81 fUnderColor = new TGColorSelect(f, 0, -1);
b615ecc5 82 f->AddFrame(fUnderColor, new TGLayoutHints(kLHintsLeft|kLHintsTop, 1, 1, 0, 2));
bc5158df 83 fUnderColor->Connect("ColorSelected(Pixel_t)",
b615ecc5 84 "Reve::RGBAPaletteSubEditor", this, "DoUnderColor(Pixel_t)");
bc5158df 85
86 AddFrame(f);
87 }
88
b615ecc5 89 { // Overflow
bc5158df 90 TGHorizontalFrame* f = new TGHorizontalFrame(this);
b615ecc5 91 TGLabel* lab = new TGLabel(f, "Overflow:");
92 f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 20, 1, 2));
93 fOverflowAction = new TGComboBox(f);
94 fOverflowAction->AddEntry("Cut", 0);
95 fOverflowAction->AddEntry("Mark", 1);
96 fOverflowAction->AddEntry("Clip", 2);
97 fOverflowAction->AddEntry("Wrap", 3);
98 TGListBox* lb = fOverflowAction->GetListBox();
bc5158df 99 lb->Resize(lb->GetWidth(), 4*16);
b615ecc5 100 fOverflowAction->Resize(59, 20);
101 fOverflowAction->Connect("Selected(Int_t)", "Reve::RGBAPaletteSubEditor", this,
102 "DoOverflowAction(Int_t)");
103 f->AddFrame(fOverflowAction, new TGLayoutHints(kLHintsLeft, 1, 2, 1, 1));
bc5158df 104
105 fOverColor = new TGColorSelect(f, 0, -1);
b615ecc5 106 f->AddFrame(fOverColor, new TGLayoutHints(kLHintsLeft|kLHintsTop, 1, 1, 0, 2));
bc5158df 107 fOverColor->Connect("ColorSelected(Pixel_t)",
b615ecc5 108 "Reve::RGBAPaletteSubEditor", this, "DoOverColor(Pixel_t)");
bc5158df 109
110 AddFrame(f);
111 }
112
b615ecc5 113 fMinMax = new RGDoubleValuator(this,"Main range:", 200, 0);
114 fMinMax->SetNELength(5);
115 fMinMax->SetLabelWidth(74);
bc5158df 116 fMinMax->Build();
117 fMinMax->GetSlider()->SetWidth(224);
118 fMinMax->SetLimits(0, 1023, TGNumberFormat::kNESInteger);
119 fMinMax->Connect("ValueSet()",
120 "Reve::RGBAPaletteSubEditor", this, "DoMinMax()");
b615ecc5 121 AddFrame(fMinMax, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
8373e543 122
123}
124
125/**************************************************************************/
126
127void RGBAPaletteSubEditor::SetModel(RGBAPalette* p)
128{
129 fM = p;
130
bc5158df 131 fMinMax->SetValues(fM->fMinVal, fM->fMaxVal);
132 fMinMax->SetLimits(fM->fLowLimit, fM->fHighLimit);
133
8373e543 134 fInterpolate->SetState(fM->fInterpolate ? kButtonDown : kButtonUp);
bc5158df 135 fShowDefValue->SetState(fM->fShowDefValue ? kButtonDown : kButtonUp);
8373e543 136 fDefaultColor->SetColor(TColor::Number2Pixel(fM->GetDefaultColor()), kFALSE);
bc5158df 137
138 fUnderColor->SetColor(TColor::Number2Pixel(fM->GetUnderColor()), kFALSE);
139 fOverColor->SetColor(TColor::Number2Pixel(fM->GetOverColor()), kFALSE);
140
b615ecc5 141 fUnderflowAction->Select(fM->fUnderflowAction, kFALSE);
142 fOverflowAction->Select(fM->fOverflowAction, kFALSE);
8373e543 143}
144
145/**************************************************************************/
146
147void RGBAPaletteSubEditor::Changed()
148{
149 Emit("Changed()");
150}
151
152/**************************************************************************/
153
bc5158df 154void RGBAPaletteSubEditor::DoMinMax()
155{
156 fM->SetMinMax((Int_t) fMinMax->GetMin(), (Int_t) fMinMax->GetMax());
157 Changed();
158}
159
160/**************************************************************************/
161
162void RGBAPaletteSubEditor::DoInterpolate()
8373e543 163{
bc5158df 164 fM->SetInterpolate(fInterpolate->IsOn());
8373e543 165 Changed();
166}
167
bc5158df 168void RGBAPaletteSubEditor::DoShowDefValue()
8373e543 169{
bc5158df 170 fM->SetShowDefValue(fShowDefValue->IsOn());
8373e543 171 Changed();
172}
173
bc5158df 174void RGBAPaletteSubEditor::DoDefaultColor(Pixel_t color)
175{
176 fM->SetDefaultColor(color);
177 Changed();
178}
8373e543 179
bc5158df 180void RGBAPaletteSubEditor::DoUnderColor(Pixel_t color)
8373e543 181{
bc5158df 182 fM->SetUnderColor(color);
8373e543 183 Changed();
184}
185
bc5158df 186void RGBAPaletteSubEditor::DoOverColor(Pixel_t color)
8373e543 187{
bc5158df 188 fM->SetOverColor(color);
8373e543 189 Changed();
190}
191
b615ecc5 192void RGBAPaletteSubEditor::DoUnderflowAction(Int_t mode)
8373e543 193{
b615ecc5 194 fM->SetUnderflowAction(mode);
bc5158df 195 Changed();
196}
197
b615ecc5 198void RGBAPaletteSubEditor::DoOverflowAction(Int_t mode)
bc5158df 199{
b615ecc5 200 fM->SetOverflowAction(mode);
8373e543 201 Changed();
202}
203
204/**************************************************************************/
205/**************************************************************************/
206/**************************************************************************/
207/**************************************************************************/
208
209//______________________________________________________________________
210// RGBAPaletteEditor
211//
212
213ClassImp(RGBAPaletteEditor)
214
215RGBAPaletteEditor::RGBAPaletteEditor(const TGWindow *p, Int_t width, Int_t height,
216 UInt_t options, Pixel_t back) :
217 TGedFrame(p, width, height, options | kVerticalFrame, back),
218 fM (0),
219 fSE(0)
220{
221 MakeTitle("RGBAPalette");
222
223 fSE = new RGBAPaletteSubEditor(this);
224 AddFrame(fSE, new TGLayoutHints(kLHintsTop, 2, 0, 2, 2));
225 fSE->Connect("Changed()", "Reve::RGBAPaletteEditor", this, "Update()");
226}
227
228RGBAPaletteEditor::~RGBAPaletteEditor()
229{}
230
231/**************************************************************************/
232
233void RGBAPaletteEditor::SetModel(TObject* obj)
234{
235 fM = dynamic_cast<RGBAPalette*>(obj);
236 fSE->SetModel(fM);
237}