38 ClassImp(TGeoSphereEditor);
41 kSPHERE_NAME, kSPHERE_RMIN, kSPHERE_RMAX, kSPHERE_THETA1,
42 kSPHERE_THETA2, kSPHERE_PHI1, kSPHERE_PHI2, kSPHERE_PHI, kSPHERE_THETA,
43 kSPHERE_APPLY, kSPHERE_UNDO
49 TGeoSphereEditor::TGeoSphereEditor(
const TGWindow *p, Int_t width,
50 Int_t height, UInt_t options, Pixel_t back)
51 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
54 fRmini = fRmaxi = fTheta1i = fTheta2i = fPhi1i = fPhi2i = 0.0;
57 fIsShapeEditable = kTRUE;
62 fShapeName =
new TGTextEntry(
this,
new TGTextBuffer(50), kSPHERE_NAME);
63 fShapeName->Resize(135, fShapeName->GetDefaultHeight());
64 fShapeName->SetToolTipText(
"Enter the sphere name");
65 fShapeName->Associate(
this);
66 AddFrame(fShapeName,
new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
69 MakeTitle(
"Sphere dimensions");
70 TGCompositeFrame *compxyz =
new TGCompositeFrame(
this, 118, 30, kVerticalFrame | kRaisedFrame);
72 TGCompositeFrame *f1 =
new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
73 kLHintsExpandX | kOwnBackground);
74 f1->AddFrame(
new TGLabel(f1,
"Rmin"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
75 fERmin =
new TGNumberEntry(f1, 0., 5, kSPHERE_RMIN);
76 fERmin->SetNumAttr(TGNumberFormat::kNEANonNegative);
77 nef = (TGTextEntry*)fERmin->GetNumberEntry();
78 nef->SetToolTipText(
"Enter the inner radius");
79 fERmin->Associate(
this);
80 fERmin->Resize(100, fERmin->GetDefaultHeight());
81 f1->AddFrame(fERmin,
new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
82 compxyz->AddFrame(f1,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
85 f1 =
new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
86 kLHintsExpandX | kOwnBackground);
87 f1->AddFrame(
new TGLabel(f1,
"Rmax"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
88 fERmax =
new TGNumberEntry(f1, 0., 5, kSPHERE_RMAX);
89 fERmax->SetNumAttr(TGNumberFormat::kNEANonNegative);
90 nef = (TGTextEntry*)fERmax->GetNumberEntry();
91 nef->SetToolTipText(
"Enter the outer radius");
92 fERmax->Associate(
this);
93 fERmax->Resize(100, fERmax->GetDefaultHeight());
94 f1->AddFrame(fERmax,
new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
95 compxyz->AddFrame(f1,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
96 AddFrame(compxyz,
new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
98 MakeTitle(
"Phi/theta range");
99 TGCompositeFrame *f11 =
new TGCompositeFrame(
this, 150,200, kHorizontalFrame);
100 compxyz =
new TGCompositeFrame(f11, 75, 200, kHorizontalFrame | kRaisedFrame);
102 fSPhi =
new TGDoubleVSlider(compxyz,140);
103 fSPhi->SetRange(0.,720.);
104 compxyz->AddFrame(fSPhi,
new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 2, 2, 4, 4));
105 f1 =
new TGCompositeFrame(compxyz, 50, 200, kVerticalFrame);
106 f1->AddFrame(
new TGLabel(f1,
"Phi min."),
new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2));
107 fEPhi1 =
new TGNumberEntry(f1, 0., 5, kSPHERE_PHI1);
108 fEPhi1->Resize(30, fEPhi1->GetDefaultHeight());
109 fEPhi1->SetNumAttr(TGNumberFormat::kNEANonNegative);
110 nef = (TGTextEntry*)fEPhi1->GetNumberEntry();
111 nef->SetToolTipText(
"Enter the phi1 value");
112 fEPhi1->Associate(
this);
113 f1->AddFrame(fEPhi1,
new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
115 fEPhi2 =
new TGNumberEntry(f1, 0., 5, kSPHERE_PHI2);
116 fEPhi2->Resize(30, fEPhi2->GetDefaultHeight());
117 fEPhi2->SetNumAttr(TGNumberFormat::kNEANonNegative);
118 nef = (TGTextEntry*)fEPhi2->GetNumberEntry();
119 nef->SetToolTipText(
"Enter the phi2 value");
120 fEPhi2->Associate(
this);
121 fEPhi2->Resize(30, fEPhi2->GetDefaultHeight());
122 f1->AddFrame(fEPhi2,
new TGLayoutHints(kLHintsBottom | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
123 f1->AddFrame(
new TGLabel(f1,
"Phi max."),
new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2));
124 compxyz->AddFrame(f1,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2));
126 compxyz->Resize(75,150);
127 f11->AddFrame(compxyz,
new TGLayoutHints(kLHintsLeft, 0,0,0,0));
129 compxyz =
new TGCompositeFrame(f11, 75, 200, kHorizontalFrame | kRaisedFrame);
131 fSTheta =
new TGDoubleVSlider(compxyz,140);
132 fSTheta->SetRange(0.,180.);
133 compxyz->AddFrame(fSTheta,
new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 2, 2, 4, 4));
134 f1 =
new TGCompositeFrame(compxyz, 50, 200, kVerticalFrame);
135 f1->AddFrame(
new TGLabel(f1,
"Theta min."),
new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2));
136 fETheta1 =
new TGNumberEntry(f1, 0., 5, kSPHERE_THETA1);
137 fETheta1->Resize(30, fETheta1->GetDefaultHeight());
138 fETheta1->SetNumAttr(TGNumberFormat::kNEANonNegative);
139 nef = (TGTextEntry*)fETheta1->GetNumberEntry();
140 nef->SetToolTipText(
"Enter the theta1 value");
141 fETheta1->Associate(
this);
142 f1->AddFrame(fETheta1,
new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
144 fETheta2 =
new TGNumberEntry(f1, 0., 5, kSPHERE_THETA2);
145 fETheta2->Resize(30, fETheta2->GetDefaultHeight());
146 fETheta2->SetNumAttr(TGNumberFormat::kNEANonNegative);
147 nef = (TGTextEntry*)fETheta2->GetNumberEntry();
148 nef->SetToolTipText(
"Enter the theta2 value");
149 fETheta2->Associate(
this);
150 f1->AddFrame(fETheta2,
new TGLayoutHints(kLHintsBottom | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
151 f1->AddFrame(
new TGLabel(f1,
"Theta max."),
new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2));
152 compxyz->AddFrame(f1,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2));
154 compxyz->Resize(75,150);
155 f11->AddFrame(compxyz,
new TGLayoutHints(kLHintsRight, 0, 0, 0, 0));
157 AddFrame(f11,
new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
160 f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth | kSunkenFrame);
161 fDelayed =
new TGCheckButton(f1,
"Delayed draw");
162 f1->AddFrame(fDelayed,
new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4));
163 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
166 f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
167 fApply =
new TGTextButton(f1,
"Apply");
168 f1->AddFrame(fApply,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
169 fApply->Associate(
this);
170 fUndo =
new TGTextButton(f1,
"Undo");
171 f1->AddFrame(fUndo,
new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
172 fUndo->Associate(
this);
173 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
174 fUndo->SetSize(fApply->GetSize());
180 TGeoSphereEditor::~TGeoSphereEditor()
183 TIter next(GetList());
184 while ((el = (TGFrameElement *)next())) {
185 if (el->fFrame->IsComposite())
186 TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame);
194 void TGeoSphereEditor::ConnectSignals2Slots()
196 fApply->Connect(
"Clicked()",
"TGeoSphereEditor",
this,
"DoApply()");
197 fUndo->Connect(
"Clicked()",
"TGeoSphereEditor",
this,
"DoUndo()");
198 fShapeName->Connect(
"TextChanged(const char *)",
"TGeoSphereEditor",
this,
"DoModified()");
199 fERmin->Connect(
"ValueSet(Long_t)",
"TGeoSphereEditor",
this,
"DoRmin()");
200 fERmax->Connect(
"ValueSet(Long_t)",
"TGeoSphereEditor",
this,
"DoRmax()");
201 fEPhi1->Connect(
"ValueSet(Long_t)",
"TGeoSphereEditor",
this,
"DoPhi1()");
202 fEPhi2->Connect(
"ValueSet(Long_t)",
"TGeoSphereEditor",
this,
"DoPhi2()");
203 fETheta1->Connect(
"ValueSet(Long_t)",
"TGeoSphereEditor",
this,
"DoTheta1()");
204 fETheta2->Connect(
"ValueSet(Long_t)",
"TGeoSphereEditor",
this,
"DoTheta2()");
205 fSPhi->Connect(
"PositionChanged()",
"TGeoSphereEditor",
this,
"DoPhi()");
206 fSTheta->Connect(
"PositionChanged()",
"TGeoSphereEditor",
this,
"DoTheta()");
214 void TGeoSphereEditor::SetModel(TObject* obj)
216 if (obj == 0 || (obj->IsA()!=TGeoSphere::Class())) {
220 fShape = (TGeoSphere*)obj;
221 fRmini = fShape->GetRmin();
222 fRmaxi = fShape->GetRmax();
223 fPhi1i = fShape->GetPhi1();
224 fPhi2i = fShape->GetPhi2();
225 fTheta1i = fShape->GetTheta1();
226 fTheta2i = fShape->GetTheta2();
227 fNamei = fShape->GetName();
228 fShapeName->SetText(fShape->GetName());
229 fERmin->SetNumber(fRmini);
230 fERmax->SetNumber(fRmaxi);
231 fEPhi1->SetNumber(fPhi1i);
232 fEPhi2->SetNumber(fPhi2i);
233 fETheta1->SetNumber(fTheta1i);
234 fETheta2->SetNumber(fTheta2i);
235 fSPhi->SetPosition(fPhi1i, fPhi2i);
236 fSTheta->SetPosition(fTheta1i, fTheta2i);
238 fApply->SetEnabled(kFALSE);
239 fUndo->SetEnabled(kFALSE);
241 if (fInit) ConnectSignals2Slots();
248 Bool_t TGeoSphereEditor::IsDelayed()
const
250 return (fDelayed->GetState() == kButtonDown);
256 void TGeoSphereEditor::DoName()
264 void TGeoSphereEditor::DoApply()
266 const char *name = fShapeName->GetText();
267 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
268 Double_t rmin = fERmin->GetNumber();
269 Double_t rmax = fERmax->GetNumber();
270 Double_t phi1 = fEPhi1->GetNumber();
271 Double_t phi2 = fEPhi2->GetNumber();
272 if ((phi2-phi1) > 360.001) {
275 fEPhi1->SetNumber(phi1);
276 fEPhi2->SetNumber(phi2);
278 fSPhi->SetPosition(phi1,phi2);
281 Double_t theta1 = fETheta1->GetNumber();
282 Double_t theta2 = fETheta2->GetNumber();
283 fShape->SetSphDimensions(rmin, rmax, theta1,theta2,phi1,phi2);
284 fShape->ComputeBBox();
286 fApply->SetEnabled(kFALSE);
288 if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
290 fPad->GetView()->ShowAxis();
298 void TGeoSphereEditor::DoModified()
300 fApply->SetEnabled();
306 void TGeoSphereEditor::DoUndo()
308 fERmin->SetNumber(fRmini);
309 fERmax->SetNumber(fRmaxi);
310 fEPhi1->SetNumber(fPhi1i);
311 fEPhi2->SetNumber(fPhi2i);
312 fSPhi->SetPosition(fPhi1i,fPhi2i);
313 fETheta1->SetNumber(fTheta1i);
314 fETheta2->SetNumber(fTheta2i);
315 fSTheta->SetPosition(fTheta1i,fTheta2i);
317 fUndo->SetEnabled(kFALSE);
318 fApply->SetEnabled(kFALSE);
324 void TGeoSphereEditor::DoRmin()
326 Double_t rmin = fERmin->GetNumber();
327 Double_t rmax = fERmax->GetNumber();
330 fERmin->SetNumber(rmin);
334 fERmin->SetNumber(rmin);
337 if (!IsDelayed()) DoApply();
343 void TGeoSphereEditor::DoRmax()
345 Double_t rmin = fERmin->GetNumber();
346 Double_t rmax = fERmax->GetNumber();
349 fERmax->SetNumber(rmax);
351 if (rmax < rmin+1.e-10) {
353 if (rmin < 0.) rmin = 0.;
354 fERmax->SetNumber(rmax);
357 if (!IsDelayed()) DoApply();
363 void TGeoSphereEditor::DoPhi1()
365 Double_t phi1 = fEPhi1->GetNumber();
366 Double_t phi2 = fEPhi2->GetNumber();
367 if (phi1 > 360-1.e-10) {
369 fEPhi1->SetNumber(phi1);
371 if (phi2<phi1+1.e-10) {
373 fEPhi1->SetNumber(phi1);
378 fSPhi->SetPosition(phi1,phi2);
379 }
else fLock = kFALSE;
380 if (!IsDelayed()) DoApply();
386 void TGeoSphereEditor::DoPhi2()
388 Double_t phi1 = fEPhi1->GetNumber();
389 Double_t phi2 = fEPhi2->GetNumber();
390 if (phi2-phi1 > 360.) {
392 fEPhi2->SetNumber(phi2);
394 if (phi2<phi1+1.e-10) {
396 fEPhi2->SetNumber(phi2);
401 fSPhi->SetPosition(phi1,phi2);
402 }
else fLock = kFALSE;
403 if (!IsDelayed()) DoApply();
409 void TGeoSphereEditor::DoPhi()
414 fEPhi1->SetNumber(fSPhi->GetMinPosition());
416 fEPhi2->SetNumber(fSPhi->GetMaxPosition());
417 }
else fLock = kFALSE;
418 if (!IsDelayed()) DoApply();
424 void TGeoSphereEditor::DoTheta1()
426 Double_t theta1 = fETheta1->GetNumber();
427 Double_t theta2 = fETheta2->GetNumber();
428 if (theta2<theta1+1.e-10) {
429 theta2 = theta1 + 0.1;
430 fETheta2->SetNumber(theta2);
435 fSTheta->SetPosition(theta1,theta2);
436 }
else fLock = kFALSE;
437 if (!IsDelayed()) DoApply();
443 void TGeoSphereEditor::DoTheta2()
445 Double_t theta1 = fETheta1->GetNumber();
446 Double_t theta2 = fETheta2->GetNumber();
447 if (theta2<theta1+1.e-10) {
448 theta1 = theta2 - 0.1;
449 fETheta1->SetNumber(theta1);
454 fSTheta->SetPosition(theta1,theta2);
455 }
else fLock = kFALSE;
456 if (!IsDelayed()) DoApply();
462 void TGeoSphereEditor::DoTheta()
467 fETheta1->SetNumber(fSTheta->GetMinPosition());
469 fETheta2->SetNumber(fSTheta->GetMaxPosition());
470 }
else fLock = kFALSE;
471 if (!IsDelayed()) DoApply();