]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/Reve/RGBAPaletteEditor.cxx
Reimplementation of over/undershoot handling with separate modes for both ends (cut...
[u/mrichter/AliRoot.git] / EVE / Reve / RGBAPaletteEditor.cxx
index d32722c853c319c77dbb9bb233a46660ed2ab38b..6cdc037f56228cd6f14dab358894769f0c42ee4d 100644 (file)
@@ -9,7 +9,7 @@
 
 #include <TGLabel.h>
 #include <TGButton.h>
-#include <TGNumberEntry.h>
+#include <TGComboBox.h>
 #include <TGColorSelect.h>
 #include <TGSlider.h>
 #include <TGDoubleSlider.h>
@@ -21,15 +21,19 @@ RGBAPaletteSubEditor::RGBAPaletteSubEditor(const TGWindow* p) :
   TGVerticalFrame(p),
 
   fM(0),
-  fMinVal(0),
-  fMaxVal(0),
+
+  fUndershootAction (0),
+  fUnderColor       (0), 
+  fOvershootAction  (0),
+  fOverColor        (0),
+
+  fMinMax(0),
+
   fInterpolate(0),
-  fWrap(0), 
+  fShowDefValue(0), 
   fDefaultColor(0)
 {
-  // Create weeds.
-
-  Int_t labelW = 42;
+  // Int_t labelW = 42;
 
   {
     TGHorizontalFrame* f = new TGHorizontalFrame(this);
@@ -44,30 +48,71 @@ RGBAPaletteSubEditor::RGBAPaletteSubEditor(const TGWindow* p) :
     fInterpolate->Connect("Toggled(Bool_t)",
                          "Reve::RGBAPaletteSubEditor", this, "DoInterpolate()");
 
-    fWrap = new TGCheckButton(f, "Wrap");
-    f->AddFrame(fWrap, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
-    fWrap->Connect("Toggled(Bool_t)",
-                  "Reve::RGBAPaletteSubEditor", this, "DoWrap()");
+    fShowDefValue = new TGCheckButton(f, "ShowDefValue");
+    f->AddFrame(fShowDefValue, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
+    fShowDefValue->Connect("Toggled(Bool_t)",
+                  "Reve::RGBAPaletteSubEditor", this, "DoShowDefValue()");
+
+    AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 2, 1));
   }
 
-  fMinVal = new RGValuator(this, "MinVal", 200, 0);
-  fMinVal->SetNELength(4);
-  fMinVal->SetLabelWidth(labelW);
-  fMinVal->Build();
-  fMinVal->GetSlider()->SetWidth(120);
-  fMinVal->Connect("ValueSet(Double_t)",
-                  "Reve::RGBAPaletteSubEditor", this, "DoMinVal()");
-  AddFrame(fMinVal, new TGLayoutHints(kLHintsTop, 1, 1, 2, 1));
-
-  fMaxVal = new RGValuator(this,"MaxVal", 200, 0);
-  fMaxVal->SetNELength(4);
-  fMaxVal->SetLabelWidth(labelW);
-  fMaxVal->Build();
-  fMaxVal->GetSlider()->SetWidth(120);
-  fMaxVal->SetLimits(0, 500);
-  fMaxVal->Connect("ValueSet(Double_t)",
-                  "Reve::RGBAPaletteSubEditor", this, "DoMaxVal()");
-  AddFrame(fMaxVal, new TGLayoutHints(kLHintsTop, 1, 1, 2, 1));
+  { // Undershoot
+    TGHorizontalFrame* f = new TGHorizontalFrame(this);
+    TGLabel* lab = new TGLabel(f, "Under-mode");
+    f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 10, 1, 2));
+    fUndershootAction = new TGComboBox(f);
+    fUndershootAction->AddEntry("Cut", 0);
+    fUndershootAction->AddEntry("Mark", 1);
+    fUndershootAction->AddEntry("Clip", 2);
+    fUndershootAction->AddEntry("Wrap", 3);
+    TGListBox* lb = fUndershootAction->GetListBox();
+    lb->Resize(lb->GetWidth(), 4*16);
+    fUndershootAction->Resize(80, 20);
+    fUndershootAction->Connect("Selected(Int_t)", "Reve::RGBAPaletteSubEditor", this,
+                      "DoUndershootAction(Int_t)");
+    f->AddFrame(fUndershootAction, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
+
+    fUnderColor = new TGColorSelect(f, 0, -1);
+    f->AddFrame(fUnderColor, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
+    fUnderColor->Connect("ColorSelected(Pixel_t)",
+                          "Reve::RGBAPaletteSubEditor", this, "DoUnderColor(Pixel_t)");
+  
+    AddFrame(f);
+  }
+
+  { // Overshoot
+    TGHorizontalFrame* f = new TGHorizontalFrame(this);
+    TGLabel* lab = new TGLabel(f, "Over-mode");
+    f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 10, 1, 2));
+    fOvershootAction = new TGComboBox(f);
+    fOvershootAction->AddEntry("Cut", 0);
+    fOvershootAction->AddEntry("Mark", 1);
+    fOvershootAction->AddEntry("Clip", 2);
+    fOvershootAction->AddEntry("Wrap", 3);
+    TGListBox* lb = fOvershootAction->GetListBox();
+    lb->Resize(lb->GetWidth(), 4*16);
+    fOvershootAction->Resize(80, 20);
+    fOvershootAction->Connect("Selected(Int_t)", "Reve::RGBAPaletteSubEditor", this,
+                      "DoOvershootAction(Int_t)");
+    f->AddFrame(fOvershootAction, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
+
+    fOverColor = new TGColorSelect(f, 0, -1);
+    f->AddFrame(fOverColor, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
+    fOverColor->Connect("ColorSelected(Pixel_t)",
+                          "Reve::RGBAPaletteSubEditor", this, "DoOverColor(Pixel_t)");
+  
+    AddFrame(f);
+  }
+
+  fMinMax = new RGDoubleValuator(this,"Min / Max", 200, 0);
+  fMinMax->SetNELength(4);
+  fMinMax->SetLabelWidth(64);
+  fMinMax->Build();
+  fMinMax->GetSlider()->SetWidth(224);
+  fMinMax->SetLimits(0, 1023, TGNumberFormat::kNESInteger);
+  fMinMax->Connect("ValueSet()",
+                  "Reve::RGBAPaletteSubEditor", this, "DoMinMax()");
+  AddFrame(fMinMax, new TGLayoutHints(kLHintsTop, 1, 1, 2, 1));
 
 }
 
@@ -77,13 +122,18 @@ void RGBAPaletteSubEditor::SetModel(RGBAPalette* p)
 {
   fM = p;
 
-  fMinVal->SetValue(fM->fMinVal);
-  fMaxVal->SetValue(fM->fMaxVal);
-  fMaxVal->SetLimits(fM->fLowLimit, fM->fHighLimit);
-  fMinVal->SetLimits(fM->fLowLimit, fM->fHighLimit);
+  fMinMax->SetValues(fM->fMinVal, fM->fMaxVal);
+  fMinMax->SetLimits(fM->fLowLimit, fM->fHighLimit);
+
   fInterpolate->SetState(fM->fInterpolate ? kButtonDown : kButtonUp);
-  fWrap->SetState(fM->fWrap ? kButtonDown : kButtonUp);
+  fShowDefValue->SetState(fM->fShowDefValue ? kButtonDown : kButtonUp);
   fDefaultColor->SetColor(TColor::Number2Pixel(fM->GetDefaultColor()), kFALSE);
+
+  fUnderColor->SetColor(TColor::Number2Pixel(fM->GetUnderColor()), kFALSE);
+  fOverColor->SetColor(TColor::Number2Pixel(fM->GetOverColor()), kFALSE);
+
+  fUndershootAction->Select(fM->fUndershootAction, kFALSE);
+  fOvershootAction->Select(fM->fOvershootAction, kFALSE);
 }
 
 /**************************************************************************/
@@ -95,36 +145,53 @@ void RGBAPaletteSubEditor::Changed()
 
 /**************************************************************************/
 
-void RGBAPaletteSubEditor::DoMinVal()
+void RGBAPaletteSubEditor::DoMinMax()
+{ 
+  fM->SetMinMax((Int_t) fMinMax->GetMin(), (Int_t) fMinMax->GetMax());
+  Changed();
+}
+
+/**************************************************************************/
+
+void RGBAPaletteSubEditor::DoInterpolate()
 {
-  fM->SetMin((Int_t) fMinVal->GetValue());
-  fMinVal->SetValue(fM->fMinVal);
+  fM->SetInterpolate(fInterpolate->IsOn());
   Changed();
 }
 
-void RGBAPaletteSubEditor::DoMaxVal()
+void RGBAPaletteSubEditor::DoShowDefValue()
 {
-  fM->SetMax((Int_t) fMaxVal->GetValue());
-  fMaxVal->SetValue(fM->fMaxVal);
+  fM->SetShowDefValue(fShowDefValue->IsOn());
   Changed();
 }
 
+void RGBAPaletteSubEditor::DoDefaultColor(Pixel_t color)
+{
+  fM->SetDefaultColor(color);
+  Changed();
+}
 
-void RGBAPaletteSubEditor::DoInterpolate()
+void RGBAPaletteSubEditor::DoUnderColor(Pixel_t color)
 {
-  fM->SetInterpolate(fInterpolate->IsOn());
+  fM->SetUnderColor(color);
   Changed();
 }
 
-void RGBAPaletteSubEditor::DoWrap()
+void RGBAPaletteSubEditor::DoOverColor(Pixel_t color)
 {
-  fM->SetWrap(fWrap->IsOn());
+  fM->SetOverColor(color);
   Changed();
 }
 
-void RGBAPaletteSubEditor::DoDefaultColor(Pixel_t color)
+void RGBAPaletteSubEditor::DoUndershootAction(Int_t mode)
 {
-  fM->SetDefaultColor(color);
+  fM->SetUndershootAction(mode);
+  Changed();
+}
+
+void RGBAPaletteSubEditor::DoOvershootAction(Int_t mode)
+{
+  fM->SetOvershootAction(mode);
   Changed();
 }