Coverity
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveITSScaledModuleEditor.cxx
CommitLineData
d810d0de 1// $Id$
2// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3b868b75 3
d810d0de 4/**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
51346b82 7 * full copyright notice. *
d810d0de 8 **************************************************************************/
9
10#include "AliEveITSScaledModuleEditor.h"
cb4245bb 11#include <EveDet/AliEveITSScaledModule.h>
3b868b75 12
13#include <TVirtualPad.h>
3b868b75 14#include <TGedEditor.h>
15#include <TGLabel.h>
32e219c2 16#include <TG3DLine.h>
3b868b75 17#include <TGNumberEntry.h>
3b868b75 18#include <TGComboBox.h>
d810d0de 19
a15e6d7d 20//==============================================================================
21//==============================================================================
22// AliEveITSScaledModuleEditor
23//==============================================================================
3b868b75 24
57ffa5fb 25//______________________________________________________________________________
3b868b75 26//
698e2c9b 27// Editor for AliEveITSScaledModule.
32e219c2 28
d810d0de 29ClassImp(AliEveITSScaledModuleEditor)
32e219c2 30
698e2c9b 31AliEveITSScaledModuleEditor::AliEveITSScaledModuleEditor(const TGWindow *p, Int_t width, Int_t height,
32 UInt_t options, Pixel_t back) :
33 TGedFrame(p, width, height, options | kVerticalFrame, back),
34 fModule(0),
35 fScale(0),
36 fStatistic(0),
37 fInfoFrame(0),
38 fInfoLabel0(0),
39 fInfoLabel1(0)
3b868b75 40{
698e2c9b 41 // Constructor.
42
d810d0de 43 MakeTitle("AliEveITSScaledModule");
3b868b75 44 // Create widgets
45 {
46 TGHorizontalFrame* f = new TGHorizontalFrame(this);
47 TGLabel *l = new TGLabel(f, "Scale:");
48 f->AddFrame(l, new TGLayoutHints(kLHintsTop | kLHintsCenterY, 0, 5, 1, 1));
49 fScale = new TGNumberEntry(f, 0, 2, -1,
50 TGNumberFormat::kNESInteger, TGNumberFormat::kNEAPositive,
51 TGNumberFormat::kNELLimitMinMax, 1, 5);
52 fScale->GetNumberEntry()->SetToolTipText("Set cell size.");
53 f->AddFrame(fScale, new TGLayoutHints(kLHintsLeft, 1, 7, 1, 1));
54 fScale->Associate(f);
d810d0de 55 fScale->Connect("ValueSet(Long_t)", "AliEveITSScaledModuleEditor", this, "DoScale()");
51346b82 56
3b868b75 57 TGLabel* lab = new TGLabel(f, "Statistic:");
58 f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 2, 1, 2));
59 fStatistic = new TGComboBox(f);
60 fStatistic->AddEntry("Occup", 0);
61 fStatistic->AddEntry("Average", 1);
62 fStatistic->AddEntry("RMS", 2);
63 TGListBox* lb = fStatistic->GetListBox();
64 lb->Resize(lb->GetWidth(), 3*16);
65 fStatistic->Resize(74, 20);
d810d0de 66 fStatistic->Connect("Selected(Int_t)", "AliEveITSScaledModuleEditor", this, "DoStatType(Int_t)");
3b868b75 67 f->AddFrame(fStatistic, new TGLayoutHints(kLHintsLeft, 1, 2, 1, 1));
68 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
69 }
70
32e219c2 71 CreateInfoFrame();
72}
73
57ffa5fb 74/******************************************************************************/
32e219c2 75
d810d0de 76void AliEveITSScaledModuleEditor::CreateInfoFrame()
32e219c2 77{
698e2c9b 78 // Create a frame under tab "Info".
79
32e219c2 80 fInfoFrame = CreateEditorTabSubFrame("Info");
51346b82 81 TGCompositeFrame *title1 = new TGCompositeFrame(fInfoFrame, 145, 10,
82 kHorizontalFrame |
83 kLHintsExpandX |
84 kFixedWidth |
32e219c2 85 kOwnBackground);
86
51346b82 87 title1->AddFrame(new TGLabel(title1, "ScaledDigits Info"),
32e219c2 88 new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
89 title1->AddFrame(new TGHorizontal3DLine(title1),
90 new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
91 fInfoFrame->AddFrame(title1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
92
93
3b868b75 94 Int_t lp = 2;
32e219c2 95 fInfoLabel0 = new TGLabel(fInfoFrame);
3b868b75 96 fInfoLabel0->SetTextJustify(kTextLeft);
32e219c2 97 fInfoFrame->AddFrame(fInfoLabel0, new TGLayoutHints(kLHintsLeft|kLHintsExpandX,
698e2c9b 98 lp, 0, 8, 0));
3b868b75 99
32e219c2 100 fInfoLabel1 = new TGLabel(fInfoFrame);
3b868b75 101 fInfoLabel1->SetTextJustify(kTextLeft);
32e219c2 102 fInfoFrame->AddFrame(fInfoLabel1, new TGLayoutHints(kLHintsLeft|kLHintsExpandX,
698e2c9b 103 lp, 0, 2, 8));
3b868b75 104}
105
57ffa5fb 106/******************************************************************************/
3b868b75 107
d810d0de 108void AliEveITSScaledModuleEditor::SetModel(TObject* obj)
3b868b75 109{
698e2c9b 110 // Set model object.
111
51346b82 112 fModule = dynamic_cast<AliEveITSScaledModule*>(obj);
32e219c2 113
114 // widgets
03dfc4a7 115 fScale->SetIntNumber(fModule->GetScaleInfo()->GetScale());
116 fStatistic->Select(fModule->GetScaleInfo()->GetStatType(), kFALSE);
32e219c2 117
51346b82 118 // text info
3b868b75 119 Int_t cnx, cnz, total;
32e219c2 120 fModule->GetScaleData(cnx, cnz, total);
3b868b75 121 fInfoLabel0->SetText(Form("Cell size: Nx=%d Nz=%d", cnx, cnz));
122 fInfoLabel1->SetText(Form("Num cells: %d", total));
3b868b75 123}
124
3b868b75 125
57ffa5fb 126/******************************************************************************/
3b868b75 127
d810d0de 128void AliEveITSScaledModuleEditor::DoScale()
3b868b75 129{
698e2c9b 130 // Slot for Scale.
131
03dfc4a7 132 fModule->GetScaleInfo()->ScaleChanged(fScale->GetIntNumber());
3b868b75 133
32e219c2 134 Int_t cnx, cnz, total;
135 fModule->GetScaleData(cnx, cnz, total);
136 fInfoLabel0->SetText(Form("Cell size: Nx=%d Nz=%d", cnx, cnz));
137 Update();
138 fGedEditor->SetModel(fGedEditor->GetPad(), fGedEditor->GetModel(), kButton1Down);
3b868b75 139}
140
57ffa5fb 141/******************************************************************************/
3b868b75 142
d810d0de 143void AliEveITSScaledModuleEditor::DoStatType(Int_t v)
3b868b75 144{
698e2c9b 145 // Slot for StatType.
146
32e219c2 147 fModule->GetScaleInfo()->StatTypeChanged(v);
148 Update();
149 fGedEditor->SetModel(fGedEditor->GetPad(), fGedEditor->GetModel(), kButton1Down);
3b868b75 150}