]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveDet/AliEveITSScaledModuleEditor.cxx
fix coverity
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveITSScaledModuleEditor.cxx
1 // $Id$
2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4 /**************************************************************************
5  * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6  * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
7  * full copyright notice.                                                 *
8  **************************************************************************/
9
10 #include "AliEveITSScaledModuleEditor.h"
11 #include <EveDet/AliEveITSScaledModule.h>
12
13 #include <TVirtualPad.h>
14 #include <TGedEditor.h>
15 #include <TGLabel.h>
16 #include <TG3DLine.h>
17 #include <TGNumberEntry.h>
18 #include <TGComboBox.h>
19
20 //==============================================================================
21 //==============================================================================
22 // AliEveITSScaledModuleEditor
23 //==============================================================================
24
25 //______________________________________________________________________________
26 //
27 // Editor for AliEveITSScaledModule.
28
29 ClassImp(AliEveITSScaledModuleEditor)
30
31 AliEveITSScaledModuleEditor::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)
40 {
41   // Constructor.
42
43   MakeTitle("AliEveITSScaledModule");
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);
55     fScale->Connect("ValueSet(Long_t)", "AliEveITSScaledModuleEditor", this, "DoScale()");
56
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);
66     fStatistic->Connect("Selected(Int_t)", "AliEveITSScaledModuleEditor", this, "DoStatType(Int_t)");
67     f->AddFrame(fStatistic, new TGLayoutHints(kLHintsLeft, 1, 2, 1, 1));
68     AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
69   }
70
71   CreateInfoFrame();
72 }
73
74 /******************************************************************************/
75
76 void AliEveITSScaledModuleEditor::CreateInfoFrame()
77 {
78   // Create a frame under tab "Info".
79
80   fInfoFrame = CreateEditorTabSubFrame("Info");
81   TGCompositeFrame *title1 = new TGCompositeFrame(fInfoFrame, 145, 10,
82                                                   kHorizontalFrame |
83                                                   kLHintsExpandX   |
84                                                   kFixedWidth      |
85                                                   kOwnBackground);
86
87   title1->AddFrame(new TGLabel(title1, "ScaledDigits Info"),
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
94   Int_t lp = 2;
95   fInfoLabel0 = new TGLabel(fInfoFrame);
96   fInfoLabel0->SetTextJustify(kTextLeft);
97   fInfoFrame->AddFrame(fInfoLabel0, new TGLayoutHints(kLHintsLeft|kLHintsExpandX,
98                                                       lp, 0, 8, 0));
99
100   fInfoLabel1 = new TGLabel(fInfoFrame);
101   fInfoLabel1->SetTextJustify(kTextLeft);
102   fInfoFrame->AddFrame(fInfoLabel1, new TGLayoutHints(kLHintsLeft|kLHintsExpandX,
103                                                       lp, 0, 2, 8));
104 }
105
106 /******************************************************************************/
107
108 void AliEveITSScaledModuleEditor::SetModel(TObject* obj)
109 {
110   // Set model object.
111
112   fModule = dynamic_cast<AliEveITSScaledModule*>(obj);
113
114   // widgets
115   fScale->SetIntNumber(fModule->GetScaleInfo()->GetScale());
116   fStatistic->Select(fModule->GetScaleInfo()->GetStatType(), kFALSE);
117
118   // text info
119   Int_t cnx, cnz, total;
120   fModule->GetScaleData(cnx, cnz, total);
121   fInfoLabel0->SetText(Form("Cell size:  Nx=%d Nz=%d", cnx, cnz));
122   fInfoLabel1->SetText(Form("Num cells:  %d", total));
123 }
124
125
126 /******************************************************************************/
127
128 void AliEveITSScaledModuleEditor::DoScale()
129 {
130   // Slot for Scale.
131
132   fModule->GetScaleInfo()->ScaleChanged(fScale->GetIntNumber());
133
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);
139 }
140
141 /******************************************************************************/
142
143 void AliEveITSScaledModuleEditor::DoStatType(Int_t v)
144 {
145   // Slot for StatType.
146
147   fModule->GetScaleInfo()->StatTypeChanged(v);
148   Update();
149   fGedEditor->SetModel(fGedEditor->GetPad(), fGedEditor->GetModel(), kButton1Down);
150 }