Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TEveGridStepperEditor.cxx
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "TEveGridStepperEditor.h"
13 #include "TEveGridStepper.h"
14 #include "TEveGValuators.h"
15 
16 #include "TVirtualPad.h"
17 #include "TColor.h"
18 
19 #include "TGLabel.h"
20 #include "TGSlider.h"
21 #include "TGButton.h"
22 #include "TGNumberEntry.h"
23 
24 /** \class TEveGridStepperSubEditor
25 \ingroup TEve
26 Sub-editor for TEveGridStepper class.
27 */
28 
29 ClassImp(TEveGridStepperSubEditor);
30 
31 ////////////////////////////////////////////////////////////////////////////////
32 /// Constructor.
33 
34 TEveGridStepperSubEditor::TEveGridStepperSubEditor(const TGWindow *p) :
35  TGVerticalFrame(p),
36  fM (0),
37  fNx(0), fNy(0), fNz(0),
38  fDx(0), fDy(0), fDz(0)
39 {
40  Int_t labelW = 15;
41 
42  TGHorizontalFrame* hf = new TGHorizontalFrame(this);
43 
44  {
45  TGGroupFrame* f = new TGGroupFrame(hf, "NumRows", kVerticalFrame);
46  f->SetWidth(30);
47  hf->AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
48 
49  fNx = new TEveGValuator(f,"X:", 200, 0);
50  fNx->SetNELength(3);
51  fNx->SetLabelWidth(labelW);
52  fNx->SetShowSlider(kFALSE);
53  fNx->Build();
54  fNx->SetLimits(1, 15);
55  fNx->Connect("ValueSet(Double_t)",
56  "TEveGridStepperSubEditor", this, "DoNs()");
57  f->AddFrame(fNx, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
58 
59  fNy = new TEveGValuator(f,"Y:", 200, 0);
60  fNy->SetNELength(3);
61  fNy->SetLabelWidth(labelW);
62  fNy->SetShowSlider(kFALSE);
63  fNy->Build();
64  fNy->SetLimits(1, 15);
65  fNy->Connect("ValueSet(Double_t)",
66  "TEveGridStepperSubEditor", this, "DoNs()");
67  f->AddFrame(fNy, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
68 
69  fNz = new TEveGValuator(f,"Z:", 200, 0);
70  fNz->SetNELength(3);
71  fNz->SetLabelWidth(labelW);
72  fNz->SetShowSlider(kFALSE);
73  fNz->Build();
74  fNz->SetLimits(1, 15);
75  fNz->Connect("ValueSet(Double_t)",
76  "TEveGridStepperSubEditor", this, "DoNs()");
77  f->AddFrame(fNz, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
78 
79  //AddFrame(f, new TGLayoutHints(kLHintsExpandX, 2, 0, 0, 0));
80  }
81  {
82  TGGroupFrame* f = new TGGroupFrame(hf, "Step", kVerticalFrame);
83  f->SetWidth(130);
84  hf->AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
85 
86  fDx = new TEveGValuator(f,"X:", 200, 0);
87  fDx->SetNELength(5);
88  fDx->SetLabelWidth(labelW);
89  fDx->SetShowSlider(kFALSE);
90  fDx->Build();
91  fDx->SetLimits(0.1, 100, 101, TGNumberFormat::kNESRealOne);
92  fDx->Connect("ValueSet(Double_t)",
93  "TEveGridStepperSubEditor", this, "DoDs()");
94  f->AddFrame(fDx, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
95 
96  fDy = new TEveGValuator(f,"Y:", 200, 0);
97  fDy->SetNELength(5);
98  fDy->SetLabelWidth(labelW);
99  fDy->SetShowSlider(kFALSE);
100  fDy->Build();
101  fDy->SetLimits(0.1, 100, 101, TGNumberFormat::kNESRealOne);
102  fDy->Connect("ValueSet(Double_t)",
103  "TEveGridStepperSubEditor", this, "DoDs()");
104  f->AddFrame(fDy, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
105 
106  fDz = new TEveGValuator(f,"Z:", 200, 0);
107  fDz->SetNELength(5);
108  fDz->SetLabelWidth(labelW);
109  fDz->SetShowSlider(kFALSE);
110  fDz->Build();
111  fDz->SetLimits(0.1, 100, 101, TGNumberFormat::kNESRealOne);
112  fDz->Connect("ValueSet(Double_t)",
113  "TEveGridStepperSubEditor", this, "DoDs()");
114  f->AddFrame(fDz, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
115 
116  //AddFrame(f, new TGLayoutHints(kLHintsExpandX, 2, 0, 0, 0));
117  }
118  AddFrame(hf, new TGLayoutHints(kLHintsExpandX, 2, 0, 0, 0));
119 }
120 
121 ////////////////////////////////////////////////////////////////////////////////
122 /// Set model object.
123 
124 void TEveGridStepperSubEditor::SetModel(TEveGridStepper* m)
125 {
126  fM = m;
127 
128  fNx->SetValue(fM->fNx);
129  fNy->SetValue(fM->fNy);
130  fNz->SetValue(fM->fNz);
131 
132  fDx->SetValue(fM->fDx);
133  fDy->SetValue(fM->fDy);
134  fDz->SetValue(fM->fDz);
135 }
136 
137 ////////////////////////////////////////////////////////////////////////////////
138 /// Emit Changed signal.
139 
140 void TEveGridStepperSubEditor::Changed()
141 {
142  Emit("Changed()");
143 }
144 
145 ////////////////////////////////////////////////////////////////////////////////
146 /// Slot for changing fN's.
147 
148 void TEveGridStepperSubEditor::DoNs()
149 {
150  fM->SetNs((Int_t)fNx->GetValue(), (Int_t)fNy->GetValue(), (Int_t)fNz->GetValue());
151  Changed();
152 }
153 
154 ////////////////////////////////////////////////////////////////////////////////
155 /// Slot for changing fD's.
156 
157 void TEveGridStepperSubEditor::DoDs()
158 {
159  fM->SetDs(fDx->GetValue(), fDy->GetValue(), fDz->GetValue());
160  Changed();
161 }
162 
163 /** \class TEveGridStepperEditor
164 \ingroup TEve
165 Editor for TEveGridStepper class.
166 */
167 
168 ClassImp(TEveGridStepperEditor);
169 
170 ////////////////////////////////////////////////////////////////////////////////
171 /// Constructor.
172 
173 TEveGridStepperEditor::TEveGridStepperEditor(const TGWindow *p, Int_t width, Int_t height,
174  UInt_t options, Pixel_t back) :
175  TGedFrame(p, width, height, options | kVerticalFrame, back),
176  fM (0),
177  fSE (0)
178 {
179  MakeTitle("TEveGridStepper");
180 
181  fSE = new TEveGridStepperSubEditor(this);
182  AddFrame(fSE, new TGLayoutHints(kLHintsTop, 2, 0, 2, 2));
183  fSE->Connect("Changed()", "TEveGridStepperEditor", this, "Update()");
184 }
185 
186 ////////////////////////////////////////////////////////////////////////////////
187 /// Set model object.
188 
189 void TEveGridStepperEditor::SetModel(TObject* obj)
190 {
191  fM = dynamic_cast<TEveGridStepper*>(obj);
192  fSE->SetModel(fM);
193 }