TEveCaloLegoEditor.cxx

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: TEveCaloLegoEditor.cxx 33864 2010-06-14 09:47:19Z matevz $
00002 // Author: Matevz Tadel 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 "TEveCaloLegoEditor.h"
00013 #include "TEveCalo.h"
00014 #include "TEveGValuators.h"
00015 #include "TGComboBox.h"
00016 
00017 #include "TColor.h"
00018 #include "TGColorSelect.h"
00019 #include "TGLabel.h"
00020 #include "TG3DLine.h"
00021 
00022 //______________________________________________________________________________
00023 // GUI editor for TEveCaloLego.
00024 //
00025 
00026 ClassImp(TEveCaloLegoEditor);
00027 
00028 //______________________________________________________________________________
00029 TEveCaloLegoEditor::TEveCaloLegoEditor(const TGWindow *p, Int_t width, Int_t height,
00030                                        UInt_t options, Pixel_t back) :
00031    TGedFrame(p, width, height, options | kVerticalFrame, back),
00032    fM(0),
00033    fGridColor(0),
00034    fFontColor(0),
00035    fPlaneColor(0),
00036    fTransparency(0),
00037 
00038    fProjection(0),
00039    f2DMode(0),
00040    fBoxMode(0),
00041 
00042    fCell2DTextMin(0),
00043 
00044    fRebinFrame(0),
00045    fAutoRebin(0),
00046    fPixelsPerBin(0),
00047    fNormalizeRebin(0)
00048 
00049 {
00050    // Constructor.
00051 
00052    MakeTitle("TEveCaloLego");
00053 
00054    {  // grid color
00055       TGHorizontalFrame* f = new TGHorizontalFrame(this);
00056       TGLabel* lab = new TGLabel(f, "GridColor:");
00057       f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 10, 1, 1));
00058 
00059       fGridColor = new TGColorSelect(f, 0, -1);
00060       f->AddFrame(fGridColor, new TGLayoutHints(kLHintsLeft|kLHintsTop, 3, 1, 0, 1));
00061       fGridColor->Connect("ColorSelected(Pixel_t)", "TEveCaloLegoEditor", this, "DoGridColor(Pixel_t)");
00062 
00063       AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
00064    }
00065    // axis
00066    {
00067       // font color
00068       TGHorizontalFrame* f = new TGHorizontalFrame(this);
00069       TGLabel* lab = new TGLabel(f, "FontColor:");
00070       f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 8, 1, 1));
00071 
00072       fFontColor = new TGColorSelect(f, 0, -1);
00073       f->AddFrame(fFontColor, new TGLayoutHints(kLHintsLeft|kLHintsTop, 3, 1, 0, 1));
00074       fFontColor->Connect("ColorSelected(Pixel_t)", "TEveCaloLegoEditor", this, "DoFontColor(Pixel_t)");
00075 
00076       AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
00077    }
00078    {
00079       // plane color
00080       TGHorizontalFrame* f = new TGHorizontalFrame(this);
00081       TGLabel* lab = new TGLabel(f, "PlaneColor:");
00082       f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 1, 1, 1));
00083 
00084       fPlaneColor = new TGColorSelect(f, 0, -1);
00085       f->AddFrame(fPlaneColor, new TGLayoutHints(kLHintsLeft|kLHintsTop, 3, 1, 0, 1));
00086       fPlaneColor->Connect("ColorSelected(Pixel_t)", "TEveCaloLegoEditor", this, "DoPlaneColor(Pixel_t)");
00087 
00088       fTransparency = new TGNumberEntry(f, 0., 2, -1,
00089                                         TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
00090                                         TGNumberFormat::kNELLimitMinMax, 0, 100);
00091       fTransparency->SetHeight(18);
00092       fTransparency->GetNumberEntry()->SetToolTipText("Transparency: 0 is opaque, 100 fully transparent.");
00093       f->AddFrame(fTransparency, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
00094       fTransparency->Connect("ValueSet(Long_t)","TEveCaloLegoEditor", this, "DoTransparency()");
00095 
00096       AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
00097    }
00098 
00099    Int_t lw = 80;
00100 
00101    fProjection = MakeLabeledCombo("Project:", 1);
00102    fProjection->AddEntry("Auto", TEveCaloLego::kAuto);
00103    fProjection->AddEntry("3D", TEveCaloLego::k3D);
00104    fProjection->AddEntry("2D", TEveCaloLego::k2D);
00105    fProjection->Connect("Selected(Int_t)", "TEveCaloLegoEditor", this, "DoProjection()");
00106 
00107    f2DMode = MakeLabeledCombo("2DMode:", 4);
00108    f2DMode->AddEntry("ValColor", TEveCaloLego::kValColor);
00109    f2DMode->AddEntry("ValSize",  TEveCaloLego::kValSize);
00110    f2DMode->AddEntry("ValSizeOutline",  TEveCaloLego::kValSizeOutline);
00111    f2DMode->Connect("Selected(Int_t)", "TEveCaloLegoEditor", this, "Do2DMode()");
00112 
00113    fBoxMode = MakeLabeledCombo("Box:", 4);
00114    fBoxMode->AddEntry("None", TEveCaloLego::kNone);
00115    fBoxMode->AddEntry("Back",  TEveCaloLego::kBack);
00116    fBoxMode->AddEntry("FrontBack",  TEveCaloLego::kFrontBack);
00117    fBoxMode->Connect("Selected(Int_t)", "TEveCaloLegoEditor", this, "DoBoxMode()");
00118 
00119    fCell2DTextMin = new TEveGValuator(this, "Cell2DTexMin:", 90, 0);
00120    fCell2DTextMin->SetLabelWidth(lw);
00121    fCell2DTextMin->SetNELength(5);
00122    fCell2DTextMin->SetShowSlider(kFALSE);
00123    fCell2DTextMin->Build();
00124    fCell2DTextMin->SetLimits(1, 1000);
00125    fCell2DTextMin->SetToolTip("Draw cell values above N pixels.");
00126    fCell2DTextMin->Connect("ValueSet(Double_t)", "TEveCaloLegoEditor", this, "DoCell2DTextMin()");
00127    AddFrame(fCell2DTextMin, new TGLayoutHints(kLHintsTop, 1, 2, 1, 2));
00128 
00129    MakeRebinFrame();
00130 }
00131 
00132 //______________________________________________________________________________
00133 void  TEveCaloLegoEditor::MakeRebinFrame()
00134 {
00135    fRebinFrame = CreateEditorTabSubFrame("Rebin");
00136 
00137    fAutoRebin  = new TGCheckButton(fRebinFrame, "AutoRebin");
00138    fRebinFrame->AddFrame(fAutoRebin, new TGLayoutHints(kLHintsLeft, 3, 5, 3, 0));
00139    fAutoRebin->Connect("Toggled(Bool_t)", "TEveCaloLegoEditor", this, "DoAutoRebin()");
00140 
00141    fNormalizeRebin  = new TGCheckButton(fRebinFrame, "NormalizeRebin");
00142    fRebinFrame->AddFrame(fNormalizeRebin, new TGLayoutHints(kLHintsLeft, 3, 5, 3, 0));
00143    fNormalizeRebin->Connect("Toggled(Bool_t)", "TEveCaloLegoEditor", this, "DoNormalize()");
00144 
00145    fPixelsPerBin = new TEveGValuator(fRebinFrame, "PixelsPerBin:", 90, 0);
00146    fPixelsPerBin->SetLabelWidth(80);
00147    fPixelsPerBin->SetNELength(5);
00148    fPixelsPerBin->SetShowSlider(kFALSE);
00149    fPixelsPerBin->Build();
00150    fPixelsPerBin->SetLimits(1, 50);
00151    fPixelsPerBin->SetToolTip("Number of labels along the Z axis.");
00152    fPixelsPerBin->Connect("ValueSet(Double_t)", "TEveCaloLegoEditor", this, "DoPixelsPerBin()");
00153    fRebinFrame->AddFrame(fPixelsPerBin, new TGLayoutHints(kLHintsTop, 4, 2, 1, 2));
00154 }
00155 
00156 //______________________________________________________________________________
00157 TGComboBox* TEveCaloLegoEditor::MakeLabeledCombo(const char* name, Int_t off)
00158 {
00159    // Helper function. Creates TGComboBox with fixed size TGLabel.
00160 
00161    UInt_t labelW = 60;
00162    UInt_t labelH = 20;
00163    TGHorizontalFrame* hf = new TGHorizontalFrame(this);
00164    // label
00165    TGCompositeFrame *labfr = new TGHorizontalFrame(hf, labelW, labelH, kFixedSize);
00166    TGLabel* label = new TGLabel(labfr, name);
00167    labfr->AddFrame(label, new TGLayoutHints(kLHintsLeft  | kLHintsBottom));
00168    hf->AddFrame(labfr, new TGLayoutHints(kLHintsLeft));
00169    // combo
00170    TGLayoutHints*  clh =  new TGLayoutHints(kLHintsLeft, 0,0,0,0);
00171    TGComboBox* combo = new TGComboBox(hf);
00172    combo->Resize(90, 20);
00173    hf->AddFrame(combo, clh);
00174 
00175    AddFrame(hf, new TGLayoutHints(kLHintsTop, 1, 1, 1, off));
00176    return combo;
00177 }
00178 
00179 //______________________________________________________________________________
00180 void TEveCaloLegoEditor::SetModel(TObject* obj)
00181 {
00182    // Set model object.
00183 
00184    fM = dynamic_cast<TEveCaloLego*>(obj);
00185 
00186    fGridColor->SetColor(TColor::Number2Pixel(fM->GetGridColor() < 0 ? 0 : fM->GetGridColor()), kFALSE);
00187    fFontColor->SetColor(TColor::Number2Pixel(fM->GetFontColor() < 0 ? 0 : fM->GetFontColor()), kFALSE);
00188 
00189    fPlaneColor->SetColor(TColor::Number2Pixel(fM->GetPlaneColor()), kFALSE);
00190    fTransparency->SetNumber(fM->GetPlaneTransparency());
00191 
00192    fCell2DTextMin->SetValue(fM->GetDrawNumberCellPixels());
00193 
00194    fProjection->Select(fM->GetProjection(), kFALSE);
00195    f2DMode->Select(fM->Get2DMode(), kFALSE);
00196    fBoxMode->Select(fM->GetBoxMode(), kFALSE);
00197 
00198    fPixelsPerBin->SetValue(fM->GetPixelsPerBin());
00199    fAutoRebin->SetState(fM->GetAutoRebin() ? kButtonDown : kButtonUp);
00200    fNormalizeRebin->SetState(fM->GetNormalizeRebin() ? kButtonDown : kButtonUp);
00201 }
00202 
00203 //______________________________________________________________________________
00204 void TEveCaloLegoEditor::DoGridColor(Pixel_t pixel)
00205 {
00206    // Slot for GridColor.
00207 
00208    fM->SetGridColor(Color_t(TColor::GetColor(pixel)));
00209    Update();
00210 }
00211 
00212 //______________________________________________________________________________
00213 void TEveCaloLegoEditor::DoFontColor(Pixel_t pixel)
00214 {
00215    // Slot for FontColor.
00216 
00217    fM->SetFontColor(Color_t(TColor::GetColor(pixel)));
00218    Update();
00219 }
00220 
00221 //______________________________________________________________________________
00222 void TEveCaloLegoEditor::DoPlaneColor(Pixel_t pixel)
00223 {
00224    // Slot for PlaneColor.
00225 
00226    fM->SetPlaneColor(Color_t(TColor::GetColor(pixel)));
00227    Update();
00228 }
00229 
00230 //______________________________________________________________________________
00231 void TEveCaloLegoEditor::DoCell2DTextMin()
00232 {
00233    // Slot for setting limit in pixels in which cell value is rendered.
00234 
00235    fM->SetDrawNumberCellPixels((Int_t)fCell2DTextMin->GetValue());
00236    Update();
00237 }
00238 
00239 
00240 //______________________________________________________________________________
00241 void TEveCaloLegoEditor::DoProjection()
00242 {
00243    // Slot for projection.
00244 
00245    fM->SetProjection((TEveCaloLego::EProjection_e)fProjection->GetSelected());
00246    Update();
00247 }
00248 
00249 //______________________________________________________________________________
00250 void TEveCaloLegoEditor::Do2DMode()
00251 {
00252    // Slot for projection.
00253 
00254    fM->Set2DMode((TEveCaloLego::E2DMode_e)f2DMode->GetSelected());
00255    Update();
00256 }
00257 
00258 //______________________________________________________________________________
00259 void TEveCaloLegoEditor::DoBoxMode()
00260 {
00261    // Slot for projection.
00262 
00263    fM->SetBoxMode((TEveCaloLego::EBoxMode_e)fBoxMode->GetSelected());
00264    Update();
00265 }
00266 
00267 //______________________________________________________________________________
00268 void TEveCaloLegoEditor::DoTransparency()
00269 {
00270    // Slot for Transparency.
00271 
00272    fM->SetPlaneTransparency((Char_t)(fTransparency->GetNumber()));
00273    Update();
00274 }
00275 
00276 //______________________________________________________________________________
00277 void TEveCaloLegoEditor::DoPixelsPerBin()
00278 {
00279    // Slot for PixelsPerBin.
00280 
00281    fM->SetPixelsPerBin((Int_t)fPixelsPerBin->GetValue());
00282    Update();
00283 }
00284 
00285 //______________________________________________________________________________
00286 void TEveCaloLegoEditor::DoAutoRebin()
00287 {
00288    fM->SetAutoRebin(fAutoRebin->IsOn());
00289    Update();
00290 }
00291 
00292 //______________________________________________________________________________
00293 void TEveCaloLegoEditor::DoNormalize()
00294 {
00295    fM->SetNormalizeRebin(fNormalizeRebin->IsOn());
00296    Update();
00297 }

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