31 ClassImp(TEveRGBAPaletteSubEditor);
36 TEveRGBAPaletteSubEditor::TEveRGBAPaletteSubEditor(
const TGWindow* p) :
46 fMinMax(0), fOldMin(0), fOldMax(0),
54 TGHorizontalFrame* f =
new TGHorizontalFrame(
this);
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()");
61 AddFrame(f,
new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
65 TGHorizontalFrame* f =
new TGHorizontalFrame(
this);
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()");
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)");
77 AddFrame(f,
new TGLayoutHints(kLHintsTop, 1, 1, 2, 0));
81 TGHorizontalFrame* f =
new TGHorizontalFrame(
this);
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()");
88 AddFrame(f,
new TGLayoutHints(kLHintsTop, 1, 1, 0, 2));
92 TGHorizontalFrame* f =
new TGHorizontalFrame(
this);
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));
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)");
116 TGHorizontalFrame* f =
new TGHorizontalFrame(
this);
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));
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)");
139 fMinMax =
new TEveGDoubleValuator(
this,
"Main range:", 130, 0);
140 fMinMax->SetNELength(5);
141 fMinMax->SetLabelWidth(74);
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));
153 void TEveRGBAPaletteSubEditor::SetModel(TEveRGBAPalette* p)
157 if (fM->fUIDoubleRep)
159 fMinMax->SetValues(fM->IntToDouble(fM->fMinVal), fM->IntToDouble(fM->fMaxVal));
160 Double_t ll = fM->IntToDouble(fM->fLowLimit);
161 Double_t hl = fM->IntToDouble(fM->fHighLimit);
162 Int_t mgk = TMath::Min(3, TMath::Max(0, 3 - TMath::Nint(TMath::Log10(hl-ll))));
163 fMinMax->SetLimits(ll, hl, (TGNumberFormat::EStyle)(TGNumberFormat::kNESInteger + mgk));
164 fOldMin = fMinMax->GetMin();
165 fOldMax = fMinMax->GetMax();
169 fMinMax->SetValues(fM->fMinVal, fM->fMaxVal);
170 fMinMax->SetLimits(fM->fLowLimit, fM->fHighLimit, TGNumberFormat::kNESInteger);
173 fInterpolate ->SetState(fM->fInterpolate ? kButtonDown : kButtonUp);
174 fShowDefValue ->SetState(fM->fShowDefValue ? kButtonDown : kButtonUp);
175 fDefaultColor ->SetColor(TColor::Number2Pixel(fM->GetDefaultColor()), kFALSE);
176 fFixColorRange->SetState(fM->fFixColorRange ? kButtonDown : kButtonUp);
178 fUnderColor->SetColor(TColor::Number2Pixel(fM->GetUnderColor()), kFALSE);
179 fOverColor ->SetColor(TColor::Number2Pixel(fM->GetOverColor()), kFALSE);
181 fUnderflowAction->Select(fM->fUnderflowAction, kFALSE);
182 fOverflowAction ->Select(fM->fOverflowAction, kFALSE);
188 void TEveRGBAPaletteSubEditor::Changed()
196 void TEveRGBAPaletteSubEditor::DoMinMax()
198 if (fM->fUIDoubleRep)
200 Double_t min = fMinMax->GetMin();
201 if (min != fOldMin && fM->DoubleToInt(min) == fM->fMinVal)
204 min = fM->IntToDouble(fM->fMinVal - 1);
206 min = fM->IntToDouble(fM->fMinVal + 1);
208 Double_t max = fMinMax->GetMax();
209 if (max != fOldMax && fM->DoubleToInt(max) == fM->fMaxVal)
212 max = fM->IntToDouble(fM->fMaxVal - 1);
214 max = fM->IntToDouble(fM->fMaxVal + 1);
216 fM->SetMinMax(fM->DoubleToInt(min), fM->DoubleToInt(max));
220 fM->SetMinMax((Int_t) fMinMax->GetMin(), (Int_t) fMinMax->GetMax());
224 fM->MinMaxValChanged();
230 void TEveRGBAPaletteSubEditor::DoInterpolate()
232 fM->SetInterpolate(fInterpolate->IsOn());
239 void TEveRGBAPaletteSubEditor::DoShowDefValue()
241 fM->SetShowDefValue(fShowDefValue->IsOn());
248 void TEveRGBAPaletteSubEditor::DoDefaultColor(Pixel_t color)
250 fM->SetDefaultColorPixel(color);
257 void TEveRGBAPaletteSubEditor::DoFixColorRange()
259 fM->SetFixColorRange(fFixColorRange->IsOn());
266 void TEveRGBAPaletteSubEditor::DoUnderColor(Pixel_t color)
268 fM->SetUnderColorPixel(color);
275 void TEveRGBAPaletteSubEditor::DoOverColor(Pixel_t color)
277 fM->SetOverColorPixel(color);
284 void TEveRGBAPaletteSubEditor::DoUnderflowAction(Int_t mode)
286 fM->SetUnderflowAction(mode);
293 void TEveRGBAPaletteSubEditor::DoOverflowAction(Int_t mode)
295 fM->SetOverflowAction(mode);
305 ClassImp(TEveRGBAPaletteEditor);
310 TEveRGBAPaletteEditor::TEveRGBAPaletteEditor(
const TGWindow *p, Int_t width, Int_t height,
311 UInt_t options, Pixel_t back) :
312 TGedFrame(p, width, height, options | kVerticalFrame, back),
316 MakeTitle(
"TEveRGBAPalette");
318 fSE =
new TEveRGBAPaletteSubEditor(
this);
319 AddFrame(fSE,
new TGLayoutHints(kLHintsTop, 2, 0, 2, 2));
320 fSE->Connect(
"Changed()",
"TEveRGBAPaletteEditor",
this,
"Update()");
326 void TEveRGBAPaletteEditor::SetModel(TObject* obj)
328 fM =
dynamic_cast<TEveRGBAPalette*
>(obj);