]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/Reve/RGBAPaletteEditor.cxx
New files: a generic color palette with value to color mapping; to be used by most...
[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>
12#include <TGNumberEntry.h>
13#include <TGColorSelect.h>
14#include <TGSlider.h>
15#include <TGDoubleSlider.h>
16
17using namespace Reve;
18
19
20RGBAPaletteSubEditor::RGBAPaletteSubEditor(const TGWindow* p) :
21 TGVerticalFrame(p)
22{
23 // Create weeds.
24
25 Int_t labelW = 42;
26
27 {
28 TGHorizontalFrame* f = new TGHorizontalFrame(this);
29
30 fDefaultColor = new TGColorSelect(f, 0, -1);
31 f->AddFrame(fDefaultColor, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
32 fDefaultColor->Connect("ColorSelected(Pixel_t)",
33 "Reve::RGBAPaletteSubEditor", this, "DoDefaultColor(Pixel_t)");
34
35 fInterpolate = new TGCheckButton(f, "Interpolate");
36 f->AddFrame(fInterpolate, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
37 fInterpolate->Connect("Toggled(Bool_t)",
38 "Reve::RGBAPaletteSubEditor", this, "DoInterpolate()");
39
40 fWrap = new TGCheckButton(f, "Wrap");
41 f->AddFrame(fWrap, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
42 fWrap->Connect("Toggled(Bool_t)",
43 "Reve::RGBAPaletteSubEditor", this, "DoWrap()");
44 }
45
46 fMinVal = new RGValuator(this, "MinVal", 200, 0);
47 fMinVal->SetNELength(4);
48 fMinVal->SetLabelWidth(labelW);
49 fMinVal->Build();
50 fMinVal->GetSlider()->SetWidth(120);
51 fMinVal->Connect("ValueSet(Double_t)",
52 "Reve::RGBAPaletteSubEditor", this, "DoMinVal()");
53 AddFrame(fMinVal, new TGLayoutHints(kLHintsTop, 1, 1, 2, 1));
54
55 fMaxVal = new RGValuator(this,"MaxVal", 200, 0);
56 fMaxVal->SetNELength(4);
57 fMaxVal->SetLabelWidth(labelW);
58 fMaxVal->Build();
59 fMaxVal->GetSlider()->SetWidth(120);
60 fMaxVal->SetLimits(0, 500);
61 fMaxVal->Connect("ValueSet(Double_t)",
62 "Reve::RGBAPaletteSubEditor", this, "DoMaxVal()");
63 AddFrame(fMaxVal, new TGLayoutHints(kLHintsTop, 1, 1, 2, 1));
64
65}
66
67/**************************************************************************/
68
69void RGBAPaletteSubEditor::SetModel(RGBAPalette* p)
70{
71 fM = p;
72
73 fMinVal->SetValue(fM->fMinVal);
74 fMaxVal->SetValue(fM->fMaxVal);
75 fMaxVal->SetLimits(fM->fLowLimit, fM->fHighLimit);
76 fMinVal->SetLimits(fM->fLowLimit, fM->fHighLimit);
77 fInterpolate->SetState(fM->fInterpolate ? kButtonDown : kButtonUp);
78 fWrap->SetState(fM->fWrap ? kButtonDown : kButtonUp);
79 fDefaultColor->SetColor(TColor::Number2Pixel(fM->GetDefaultColor()), kFALSE);
80}
81
82/**************************************************************************/
83
84void RGBAPaletteSubEditor::Changed()
85{
86 Emit("Changed()");
87}
88
89/**************************************************************************/
90
91void RGBAPaletteSubEditor::DoMinVal()
92{
93 fM->SetMin((Int_t) fMinVal->GetValue());
94 fMinVal->SetValue(fM->fMinVal);
95 Changed();
96}
97
98void RGBAPaletteSubEditor::DoMaxVal()
99{
100 fM->SetMax((Int_t) fMaxVal->GetValue());
101 fMaxVal->SetValue(fM->fMaxVal);
102 Changed();
103}
104
105
106void RGBAPaletteSubEditor::DoInterpolate()
107{
108 fM->SetInterpolate(fInterpolate->IsOn());
109 Changed();
110}
111
112void RGBAPaletteSubEditor::DoWrap()
113{
114 fM->SetWrap(fWrap->IsOn());
115 Changed();
116}
117
118void RGBAPaletteSubEditor::DoDefaultColor(Pixel_t color)
119{
120 fM->SetDefaultColor(color);
121 Changed();
122}
123
124/**************************************************************************/
125/**************************************************************************/
126/**************************************************************************/
127/**************************************************************************/
128
129//______________________________________________________________________
130// RGBAPaletteEditor
131//
132
133ClassImp(RGBAPaletteEditor)
134
135RGBAPaletteEditor::RGBAPaletteEditor(const TGWindow *p, Int_t width, Int_t height,
136 UInt_t options, Pixel_t back) :
137 TGedFrame(p, width, height, options | kVerticalFrame, back),
138 fM (0),
139 fSE(0)
140{
141 MakeTitle("RGBAPalette");
142
143 fSE = new RGBAPaletteSubEditor(this);
144 AddFrame(fSE, new TGLayoutHints(kLHintsTop, 2, 0, 2, 2));
145 fSE->Connect("Changed()", "Reve::RGBAPaletteEditor", this, "Update()");
146}
147
148RGBAPaletteEditor::~RGBAPaletteEditor()
149{}
150
151/**************************************************************************/
152
153void RGBAPaletteEditor::SetModel(TObject* obj)
154{
155 fM = dynamic_cast<RGBAPalette*>(obj);
156 fSE->SetModel(fM);
157}