TEveRGBAPaletteEditor.cxx

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: TEveRGBAPaletteEditor.cxx 30823 2009-10-21 13:58:59Z matevz $
00002 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #include "TEveRGBAPaletteEditor.h"
00013 #include "TEveRGBAPalette.h"
00014 #include "TEveGValuators.h"
00015 
00016 #include "TVirtualPad.h"
00017 #include "TColor.h"
00018 
00019 #include "TGLabel.h"
00020 #include "TGButton.h"
00021 #include "TGComboBox.h"
00022 #include "TGColorSelect.h"
00023 #include "TGSlider.h"
00024 #include "TGDoubleSlider.h"
00025 
00026 //______________________________________________________________________________
00027 //
00028 // Sub-editor for TEveRGBAPalette class.
00029 
00030 ClassImp(TEveRGBAPaletteSubEditor)
00031 
00032 //______________________________________________________________________________
00033 TEveRGBAPaletteSubEditor::TEveRGBAPaletteSubEditor(const TGWindow* p) :
00034    TGVerticalFrame(p),
00035 
00036    fM(0),
00037 
00038    fUnderflowAction (0),
00039    fUnderColor      (0),
00040    fOverflowAction  (0),
00041    fOverColor       (0),
00042 
00043    fMinMax(0),
00044 
00045    fInterpolate(0),
00046    fShowDefValue(0),
00047    fDefaultColor(0),
00048    fFixColorRange(0)
00049 {
00050    // Constructor.
00051 
00052    // Int_t labelW = 42;
00053 
00054    {
00055       TGHorizontalFrame* f = new TGHorizontalFrame(this);
00056 
00057       fInterpolate = new TGCheckButton(f, "Interpolate");
00058       f->AddFrame(fInterpolate, new TGLayoutHints(kLHintsLeft, 3, 1, 1, 0));
00059       fInterpolate->Connect("Toggled(Bool_t)",
00060                             "TEveRGBAPaletteSubEditor", this, "DoInterpolate()");
00061 
00062       AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
00063    }
00064 
00065    {
00066       TGHorizontalFrame* f = new TGHorizontalFrame(this);
00067 
00068       fShowDefValue = new TGCheckButton(f, "Show default value");
00069       f->AddFrame(fShowDefValue, new TGLayoutHints(kLHintsLeft, 3, 1, 1, 0));
00070       fShowDefValue->Connect("Toggled(Bool_t)",
00071                              "TEveRGBAPaletteSubEditor", this, "DoShowDefValue()");
00072 
00073       fDefaultColor = new TGColorSelect(f, 0, -1);
00074       f->AddFrame(fDefaultColor, new TGLayoutHints(kLHintsLeft|kLHintsTop, 0, 0, 0, 0));
00075       fDefaultColor->Connect("ColorSelected(Pixel_t)",
00076                              "TEveRGBAPaletteSubEditor", this, "DoDefaultColor(Pixel_t)");
00077 
00078       AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 2, 0));
00079    }
00080 
00081    {
00082       TGHorizontalFrame* f = new TGHorizontalFrame(this);
00083 
00084       fFixColorRange = new TGCheckButton(f, "Fix color range");
00085       f->AddFrame(fFixColorRange, new TGLayoutHints(kLHintsLeft, 3, 1, 0, 0));
00086       fFixColorRange->Connect("Toggled(Bool_t)",
00087                               "TEveRGBAPaletteSubEditor", this, "DoFixColorRange()");
00088 
00089       AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 0, 2));
00090    }
00091 
00092    { // Underflow
00093       TGHorizontalFrame* f = new TGHorizontalFrame(this);
00094       TGLabel* lab = new TGLabel(f, "Underflow:");
00095       f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 15, 1, 2));
00096       fUnderflowAction = new TGComboBox(f);
00097       fUnderflowAction->AddEntry("Cut", 0);
00098       fUnderflowAction->AddEntry("Mark", 1);
00099       fUnderflowAction->AddEntry("Clip", 2);
00100       fUnderflowAction->AddEntry("Wrap", 3);
00101       TGListBox* lb = fUnderflowAction->GetListBox();
00102       lb->Resize(lb->GetWidth(), 4*16);
00103       fUnderflowAction->Resize(59, 20);
00104       fUnderflowAction->Connect("Selected(Int_t)", "TEveRGBAPaletteSubEditor", this,
00105                                 "DoUnderflowAction(Int_t)");
00106       f->AddFrame(fUnderflowAction, new TGLayoutHints(kLHintsLeft, 1, 2, 1, 1));
00107 
00108       fUnderColor = new TGColorSelect(f, 0, -1);
00109       f->AddFrame(fUnderColor, new TGLayoutHints(kLHintsLeft|kLHintsTop, 1, 1, 0, 2));
00110       fUnderColor->Connect("ColorSelected(Pixel_t)",
00111                            "TEveRGBAPaletteSubEditor", this, "DoUnderColor(Pixel_t)");
00112 
00113       AddFrame(f);
00114    }
00115 
00116    { // Overflow
00117       TGHorizontalFrame* f = new TGHorizontalFrame(this);
00118       TGLabel* lab = new TGLabel(f, "Overflow:");
00119       f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 20, 1, 2));
00120       fOverflowAction = new TGComboBox(f);
00121       fOverflowAction->AddEntry("Cut", 0);
00122       fOverflowAction->AddEntry("Mark", 1);
00123       fOverflowAction->AddEntry("Clip", 2);
00124       fOverflowAction->AddEntry("Wrap", 3);
00125       TGListBox* lb = fOverflowAction->GetListBox();
00126       lb->Resize(lb->GetWidth(), 4*16);
00127       fOverflowAction->Resize(59, 20);
00128       fOverflowAction->Connect("Selected(Int_t)", "TEveRGBAPaletteSubEditor", this,
00129                                "DoOverflowAction(Int_t)");
00130       f->AddFrame(fOverflowAction, new TGLayoutHints(kLHintsLeft, 1, 2, 1, 1));
00131 
00132       fOverColor = new TGColorSelect(f, 0, -1);
00133       f->AddFrame(fOverColor, new TGLayoutHints(kLHintsLeft|kLHintsTop, 1, 1, 0, 2));
00134       fOverColor->Connect("ColorSelected(Pixel_t)",
00135                           "TEveRGBAPaletteSubEditor", this, "DoOverColor(Pixel_t)");
00136 
00137       AddFrame(f);
00138    }
00139 
00140    fMinMax = new TEveGDoubleValuator(this,"Main range:", 130, 0);
00141    fMinMax->SetNELength(5);
00142    fMinMax->SetLabelWidth(74);
00143    fMinMax->Build();
00144    fMinMax->GetSlider()->SetWidth(190);
00145    fMinMax->SetLimits(0, 1023, TGNumberFormat::kNESInteger);
00146    fMinMax->Connect("ValueSet()",
00147                     "TEveRGBAPaletteSubEditor", this, "DoMinMax()");
00148    AddFrame(fMinMax, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
00149 
00150 }
00151 
00152 /******************************************************************************/
00153 
00154 //______________________________________________________________________________
00155 void TEveRGBAPaletteSubEditor::SetModel(TEveRGBAPalette* p)
00156 {
00157    // Set model object.
00158 
00159    fM = p;
00160 
00161    fMinMax->SetValues(fM->fMinVal, fM->fMaxVal);
00162    fMinMax->SetLimits(fM->fLowLimit, fM->fHighLimit);
00163 
00164    fInterpolate  ->SetState(fM->fInterpolate ? kButtonDown : kButtonUp);
00165    fShowDefValue ->SetState(fM->fShowDefValue ? kButtonDown : kButtonUp);
00166    fDefaultColor ->SetColor(TColor::Number2Pixel(fM->GetDefaultColor()), kFALSE);
00167    fFixColorRange->SetState(fM->fFixColorRange ? kButtonDown : kButtonUp);
00168 
00169    fUnderColor->SetColor(TColor::Number2Pixel(fM->GetUnderColor()), kFALSE);
00170    fOverColor ->SetColor(TColor::Number2Pixel(fM->GetOverColor()), kFALSE);
00171 
00172    fUnderflowAction->Select(fM->fUnderflowAction, kFALSE);
00173    fOverflowAction ->Select(fM->fOverflowAction, kFALSE);
00174 }
00175 
00176 /******************************************************************************/
00177 
00178 //______________________________________________________________________________
00179 void TEveRGBAPaletteSubEditor::Changed()
00180 {
00181    // Emit "Changed()" signal.
00182 
00183    Emit("Changed()");
00184 }
00185 
00186 /******************************************************************************/
00187 
00188 //______________________________________________________________________________
00189 void TEveRGBAPaletteSubEditor::DoMinMax()
00190 {
00191    // Slot for MinMax.
00192 
00193    fM->SetMinMax((Int_t) fMinMax->GetMin(), (Int_t) fMinMax->GetMax());
00194    Changed();
00195    fM->MinMaxValChanged();
00196 }
00197 
00198 /******************************************************************************/
00199 
00200 //______________________________________________________________________________
00201 void TEveRGBAPaletteSubEditor::DoInterpolate()
00202 {
00203    // Slot for Interpolate.
00204 
00205    fM->SetInterpolate(fInterpolate->IsOn());
00206    Changed();
00207 }
00208 
00209 //______________________________________________________________________________
00210 void TEveRGBAPaletteSubEditor::DoShowDefValue()
00211 {
00212    // Slot for ShowDefValue.
00213 
00214    fM->SetShowDefValue(fShowDefValue->IsOn());
00215    Changed();
00216 }
00217 
00218 //______________________________________________________________________________
00219 void TEveRGBAPaletteSubEditor::DoDefaultColor(Pixel_t color)
00220 {
00221    // Slot for DefaultColor.
00222 
00223    fM->SetDefaultColorPixel(color);
00224    Changed();
00225 }
00226 
00227 //______________________________________________________________________________
00228 void TEveRGBAPaletteSubEditor::DoFixColorRange()
00229 {
00230    // Slot for FixColorRange.
00231 
00232    fM->SetFixColorRange(fFixColorRange->IsOn());
00233    Changed();
00234 }
00235 
00236 //______________________________________________________________________________
00237 void TEveRGBAPaletteSubEditor::DoUnderColor(Pixel_t color)
00238 {
00239    // Slot for UnderColor.
00240 
00241    fM->SetUnderColorPixel(color);
00242    Changed();
00243 }
00244 
00245 //______________________________________________________________________________
00246 void TEveRGBAPaletteSubEditor::DoOverColor(Pixel_t color)
00247 {
00248    // Slot for OverColor.
00249 
00250    fM->SetOverColorPixel(color);
00251    Changed();
00252 }
00253 
00254 //______________________________________________________________________________
00255 void TEveRGBAPaletteSubEditor::DoUnderflowAction(Int_t mode)
00256 {
00257    // Slot for UnderflowAction.
00258 
00259    fM->SetUnderflowAction(mode);
00260    Changed();
00261 }
00262 
00263 //______________________________________________________________________________
00264 void TEveRGBAPaletteSubEditor::DoOverflowAction(Int_t mode)
00265 {
00266    // Slot for OverflowAction.
00267 
00268    fM->SetOverflowAction(mode);
00269    Changed();
00270 }
00271 
00272 
00273 //______________________________________________________________________________
00274 //
00275 // Editor for TEveRGBAPalette class.
00276 
00277 ClassImp(TEveRGBAPaletteEditor)
00278 
00279 //______________________________________________________________________________
00280 TEveRGBAPaletteEditor::TEveRGBAPaletteEditor(const TGWindow *p, Int_t width, Int_t height,
00281                                              UInt_t options, Pixel_t back) :
00282    TGedFrame(p, width, height, options | kVerticalFrame, back),
00283    fM (0),
00284    fSE(0)
00285 {
00286    // Constructor.
00287 
00288    MakeTitle("TEveRGBAPalette");
00289 
00290    fSE = new TEveRGBAPaletteSubEditor(this);
00291    AddFrame(fSE, new TGLayoutHints(kLHintsTop, 2, 0, 2, 2));
00292    fSE->Connect("Changed()", "TEveRGBAPaletteEditor", this, "Update()");
00293 }
00294 
00295 /******************************************************************************/
00296 
00297 //______________________________________________________________________________
00298 void TEveRGBAPaletteEditor::SetModel(TObject* obj)
00299 {
00300    // Set model object.
00301 
00302    fM = dynamic_cast<TEveRGBAPalette*>(obj);
00303    fSE->SetModel(fM);
00304 }

Generated on Tue Jul 5 14:16:13 2011 for ROOT_528-00b_version by  doxygen 1.5.1