]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Reve/GridStepperEditor.cxx
84ef052c13f5bcaa4c1bb9a779dd2f0ddfd0eb88
[u/mrichter/AliRoot.git] / EVE / Reve / GridStepperEditor.cxx
1 // $Header$
2
3 #include "GridStepperEditor.h"
4 #include <Reve/GridStepper.h>
5 #include <Reve/RGValuators.h>
6
7 #include <TVirtualPad.h>
8 #include <TColor.h>
9
10 #include <TGLabel.h>
11 #include <TGSlider.h>
12 #include <TGButton.h>
13 #include <TGNumberEntry.h>
14
15 using namespace Reve;
16
17 //______________________________________________________________________
18 // GridStepperSubEditor
19 //
20 //
21
22 ClassImp(GridStepperSubEditor)
23
24 //______________________________________________________________________
25 GridStepperSubEditor::GridStepperSubEditor(const TGWindow *p) :
26   TGVerticalFrame(p),
27   fM             (0),
28
29   fNx            (0), 
30   fNy            (0),
31   fNz            (0),
32   fDx            (0), 
33   fDy            (0),
34   fDz            (0)
35 {
36   Int_t labelW = 15;
37
38   TGHorizontalFrame* VF = new TGHorizontalFrame(this);
39     
40   {
41     TGGroupFrame* f = new TGGroupFrame(VF, "NumRows", kVerticalFrame);
42     f->SetWidth(30);
43     VF->AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
44
45     fNx = new RGValuator(f,"X:", 200, 0);
46     fNx->SetNELength(3);
47     fNx->SetLabelWidth(labelW);
48     fNx->SetShowSlider(kFALSE);
49     fNx->Build();
50     fNx->SetLimits(1, 15);
51     fNx->Connect("ValueSet(Double_t)",
52                  "Reve::GridStepperSubEditor", this, "DoNs()");
53     f->AddFrame(fNx, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
54
55     fNy = new RGValuator(f,"Y:", 200, 0);
56     fNy->SetNELength(3);
57     fNy->SetLabelWidth(labelW);
58     fNy->SetShowSlider(kFALSE);
59     fNy->Build();
60     fNy->SetLimits(1, 15);
61     fNy->Connect("ValueSet(Double_t)",
62                  "Reve::GridStepperSubEditor", this, "DoNs()");
63     f->AddFrame(fNy, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
64
65     fNz = new RGValuator(f,"Z:", 200, 0);
66     fNz->SetNELength(3);
67     fNz->SetLabelWidth(labelW);
68     fNz->SetShowSlider(kFALSE);
69     fNz->Build();
70     fNz->SetLimits(1, 15);
71     fNz->Connect("ValueSet(Double_t)",
72                  "Reve::GridStepperSubEditor", this, "DoNs()");
73     f->AddFrame(fNz, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
74
75     //AddFrame(f, new TGLayoutHints(kLHintsExpandX, 2, 0, 0, 0));
76   }
77   {
78     TGGroupFrame* f = new TGGroupFrame(VF, "Step", kVerticalFrame);
79     f->SetWidth(130);
80     VF->AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
81
82     fDx = new RGValuator(f,"X:", 200, 0);
83     fDx->SetNELength(5);
84     fDx->SetLabelWidth(labelW);
85     fDx->SetShowSlider(kFALSE);
86     fDx->Build();
87     fDx->SetLimits(0.1, 100, 101, TGNumberFormat::kNESRealOne);
88     fDx->Connect("ValueSet(Double_t)",
89                  "Reve::GridStepperSubEditor", this, "DoDs()");
90     f->AddFrame(fDx, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
91
92     fDy = new RGValuator(f,"Y:", 200, 0);
93     fDy->SetNELength(5);
94     fDy->SetLabelWidth(labelW);
95     fDy->SetShowSlider(kFALSE);
96     fDy->Build();
97     fDy->SetLimits(0.1, 100, 101, TGNumberFormat::kNESRealOne);
98     fDy->Connect("ValueSet(Double_t)",
99                  "Reve::GridStepperSubEditor", this, "DoDs()");
100     f->AddFrame(fDy, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
101
102     fDz = new RGValuator(f,"Z:", 200, 0);
103     fDz->SetNELength(5);
104     fDz->SetLabelWidth(labelW);
105     fDz->SetShowSlider(kFALSE);
106     fDz->Build();
107     fDz->SetLimits(0.1, 100, 101, TGNumberFormat::kNESRealOne);
108     fDz->Connect("ValueSet(Double_t)",
109                  "Reve::GridStepperSubEditor", this, "DoDs()");
110     f->AddFrame(fDz, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
111
112     //AddFrame(f, new TGLayoutHints(kLHintsExpandX, 2, 0, 0, 0));
113   }
114   AddFrame(VF, new TGLayoutHints(kLHintsExpandX, 2, 0, 0, 0));
115 }
116
117 //______________________________________________________________________
118 void GridStepperSubEditor::SetModel(GridStepper* m)
119 {
120   // Set model object.
121   fM = m;
122
123   fNx->SetValue(m->Nx);
124   fNy->SetValue(m->Ny);
125   fNz->SetValue(m->Nz);
126
127   fDx->SetValue(m->Dx);
128   fDy->SetValue(m->Dy);
129   fDz->SetValue(m->Dz);
130 }
131
132 //______________________________________________________________________
133 void GridStepperSubEditor::Changed()
134 {
135   // Emit Changed signal.
136
137   Emit("Changed()");
138 }
139
140 //______________________________________________________________________
141 void GridStepperSubEditor::DoNs()
142 {
143   fM->SetNs((Int_t)fNx->GetValue(), (Int_t)fNy->GetValue(), (Int_t)fNz->GetValue()); 
144   Changed();
145 }
146
147 //______________________________________________________________________
148 void GridStepperSubEditor::DoDs()
149 {
150    // Set some value from some widget
151   fM->SetDs(fDx->GetValue(), fDy->GetValue(), fDz->GetValue()); 
152   Changed();
153 }
154
155 //______________________________________________________________________
156 // GridStepperEditor
157 //
158 //
159
160 ClassImp(GridStepperEditor)
161
162 //______________________________________________________________________
163 GridStepperEditor::GridStepperEditor(const TGWindow *p, Int_t width, Int_t height,
164              UInt_t options, Pixel_t back) :
165   TGedFrame(p, width, height, options | kVerticalFrame, back),
166   fM  (0),
167   fSE (0)
168 {
169   // Constructor.
170
171   MakeTitle("GridStepper");
172
173   fSE = new GridStepperSubEditor(this);
174   AddFrame(fSE, new TGLayoutHints(kLHintsTop, 2, 0, 2, 2));
175   fSE->Connect("Changed()", "GridStepperEditor", this, "Update()");
176 }
177
178 /**************************************************************************/
179
180 //______________________________________________________________________
181 void GridStepperEditor::SetModel(TObject* obj)
182 {
183   // Set model object.
184   fM = dynamic_cast<GridStepper*>(obj);
185   fSE->SetModel(fM);
186 }