]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Alieve/ITSScaledModuleEditor.cxx
09fb8a12e939d46ae2a9066a2b6b5e05a254500e
[u/mrichter/AliRoot.git] / EVE / Alieve / ITSScaledModuleEditor.cxx
1 // $Header$
2
3 #include "ITSScaledModuleEditor.h"
4 #include <Alieve/ITSScaledModule.h>
5 #include <Reve/ZTransEditor.h>
6 #include <Reve/RGValuators.h>
7
8 #include <TVirtualPad.h>
9 #include <TColor.h>
10 #include <TMath.h>
11
12 #include <TGedEditor.h>
13 #include <TGLabel.h>
14 #include <TG3DLine.h>
15 #include <TGButton.h>
16 #include <TGNumberEntry.h>
17 #include <TGColorSelect.h>
18 #include <TGComboBox.h>
19
20 using namespace Reve;
21 using namespace Alieve;
22
23 //______________________________________________________________________
24 // ITSScaledModuleEditor 
25 //
26
27 ClassImp(ITSScaledModuleEditor)
28
29   ITSScaledModuleEditor::ITSScaledModuleEditor(const TGWindow *p, Int_t width, Int_t height,
30                                                UInt_t options, Pixel_t back) :
31     TGedFrame(p, width, height, options | kVerticalFrame, back),
32
33     fInfoFrame(0),
34
35     fModule(0), 
36
37     fScale(0),
38     fStatistic(0),
39     fInfoLabel0(0),
40     fInfoLabel1(0)
41 {
42   MakeTitle("ITSScaledModule");
43   // Create widgets
44   {
45     TGHorizontalFrame* f = new TGHorizontalFrame(this);
46     TGLabel *l = new TGLabel(f, "Scale:");
47     f->AddFrame(l, new TGLayoutHints(kLHintsTop | kLHintsCenterY, 0, 5, 1, 1));
48     fScale = new TGNumberEntry(f, 0, 2, -1,
49                                TGNumberFormat::kNESInteger, TGNumberFormat::kNEAPositive,
50                                TGNumberFormat::kNELLimitMinMax, 1, 5);
51     fScale->GetNumberEntry()->SetToolTipText("Set cell size.");
52     f->AddFrame(fScale, new TGLayoutHints(kLHintsLeft, 1, 7, 1, 1));
53     fScale->Associate(f);
54     fScale->Connect("ValueSet(Long_t)", "Alieve::ITSScaledModuleEditor", this, "DoScale()");
55     
56     TGLabel* lab = new TGLabel(f, "Statistic:");
57     f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 2, 1, 2));
58     fStatistic = new TGComboBox(f);
59     fStatistic->AddEntry("Occup", 0);
60     fStatistic->AddEntry("Average", 1);
61     fStatistic->AddEntry("RMS", 2);
62     TGListBox* lb = fStatistic->GetListBox();
63     lb->Resize(lb->GetWidth(), 3*16);
64     fStatistic->Resize(74, 20);
65     fStatistic->Connect("Selected(Int_t)", "Alieve::ITSScaledModuleEditor", this, "DoStatType(Int_t)");
66     f->AddFrame(fStatistic, new TGLayoutHints(kLHintsLeft, 1, 2, 1, 1));
67     AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
68   }
69
70   CreateInfoFrame();
71 }
72
73 /*************************************************************************/
74 ITSScaledModuleEditor::~ITSScaledModuleEditor()
75 {}
76
77 /*************************************************************************/
78 void ITSScaledModuleEditor::CreateInfoFrame()
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
109 void ITSScaledModuleEditor::SetModel(TObject* obj)
110 {
111   fModule = dynamic_cast<ITSScaledModule*>(obj); 
112
113   // widgets
114   fScale->SetIntNumber(fModule->GetScaleInfo()->GetScale());
115   fStatistic->Select(fModule->GetScaleInfo()->GetStatType(), kFALSE);
116
117   // text info  
118   Int_t cnx, cnz, total;
119   fModule->GetScaleData(cnx, cnz, total);
120   fInfoLabel0->SetText(Form("Cell size:  Nx=%d Nz=%d", cnx, cnz));
121   fInfoLabel1->SetText(Form("Num cells:  %d", total));
122 }
123
124
125 /**************************************************************************/
126
127 void ITSScaledModuleEditor::DoScale()
128 {
129   fModule->GetScaleInfo()->ScaleChanged(fScale->GetIntNumber());
130
131   Int_t cnx, cnz, total;
132   fModule->GetScaleData(cnx, cnz, total);
133   fInfoLabel0->SetText(Form("Cell size:  Nx=%d Nz=%d", cnx, cnz));
134   Update();
135   fGedEditor->SetModel(fGedEditor->GetPad(), fGedEditor->GetModel(), kButton1Down);
136 }
137
138 /**************************************************************************/
139
140 void ITSScaledModuleEditor::DoStatType(Int_t v)
141 {
142   fModule->GetScaleInfo()->StatTypeChanged(v);
143   Update();
144   fGedEditor->SetModel(fGedEditor->GetPad(), fGedEditor->GetModel(), kButton1Down);
145 }