Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGeoConeEditor.cxx
Go to the documentation of this file.
1 // @(#):$Id$
2 // Author: M.Gheata
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2002, 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 /** \class TGeoConeEditor
13 \ingroup Geometry_builder
14 
15 Editor for a TGeoCone.
16 
17 \image html geom_cone_pic.png
18 
19 \image html geom_cone_ed.png
20 
21 */
22 
23 
24 #include "TGeoConeEditor.h"
25 #include "TGeoTabManager.h"
26 #include "TGeoCone.h"
27 #include "TGeoManager.h"
28 #include "TVirtualGeoPainter.h"
29 #include "TPad.h"
30 #include "TView.h"
31 #include "TGTab.h"
32 #include "TGComboBox.h"
33 #include "TGButton.h"
34 #include "TGTextEntry.h"
35 #include "TGNumberEntry.h"
36 #include "TGLabel.h"
37 #include "TGDoubleSlider.h"
38 
39 ClassImp(TGeoConeEditor);
40 
41 enum ETGeoConeWid {
42  kCONE_NAME, kCONE_RMIN1, kCONE_RMIN2, kCONE_RMAX1, kCONE_RMAX2, kCONE_Z,
43  kCONE_APPLY, kCONE_UNDO
44 };
45 
46 ////////////////////////////////////////////////////////////////////////////////
47 /// Constructor for volume editor
48 
49 TGeoConeEditor::TGeoConeEditor(const TGWindow *p, Int_t width,
50  Int_t height, UInt_t options, Pixel_t back)
51  : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
52 {
53  fShape = 0;
54  fRmini1 = fRmaxi1 = fRmini2 = fRmaxi2 = fDzi = 0.0;
55  fNamei = "";
56  fIsModified = kFALSE;
57  fIsShapeEditable = kTRUE;
58 
59  // TextEntry for shape name
60  MakeTitle("Name");
61  fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kCONE_NAME);
62  fShapeName->Resize(135, fShapeName->GetDefaultHeight());
63  fShapeName->SetToolTipText("Enter the cone name");
64  fShapeName->Associate(this);
65  AddFrame(fShapeName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
66 
67  TGTextEntry *nef;
68  MakeTitle("Cone dimensions");
69  TGCompositeFrame *compxyz = new TGCompositeFrame(this, 118, 30, kVerticalFrame | kRaisedFrame);
70 
71  // Number entry for Rmin1
72  TGCompositeFrame *f1 = new TGCompositeFrame(compxyz, 155, 30, kHorizontalFrame | kFixedWidth);
73  f1->AddFrame(new TGLabel(f1, "Rmin1"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
74  fERmin1 = new TGNumberEntry(f1, 0., 5, kCONE_RMIN1);
75  fERmin1->SetNumAttr(TGNumberFormat::kNEANonNegative);
76  nef = (TGTextEntry*)fERmin1->GetNumberEntry();
77  nef->SetToolTipText("Enter the inner radius");
78  fERmin1->Associate(this);
79  fERmin1->Resize(100, fERmin1->GetDefaultHeight());
80  f1->AddFrame(fERmin1, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
81  compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
82 
83  // Number entry for Rmax1
84  f1 = new TGCompositeFrame(compxyz, 155, 30, kHorizontalFrame | kFixedWidth);
85  f1->AddFrame(new TGLabel(f1, "Rmax1"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
86  fERmax1 = new TGNumberEntry(f1, 0., 5, kCONE_RMAX1);
87  fERmax1->SetNumAttr(TGNumberFormat::kNEANonNegative);
88  nef = (TGTextEntry*)fERmax1->GetNumberEntry();
89  nef->SetToolTipText("Enter the outer radius");
90  fERmax1->Associate(this);
91  fERmax1->Resize(100, fERmax1->GetDefaultHeight());
92  f1->AddFrame(fERmax1, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
93  compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
94 
95  // Number entry for Rmin2
96  f1 = new TGCompositeFrame(compxyz, 155, 30, kHorizontalFrame | kFixedWidth);
97  f1->AddFrame(new TGLabel(f1, "Rmin2"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
98  fERmin2 = new TGNumberEntry(f1, 0., 5, kCONE_RMIN2);
99  fERmin2->SetNumAttr(TGNumberFormat::kNEANonNegative);
100  nef = (TGTextEntry*)fERmin2->GetNumberEntry();
101  nef->SetToolTipText("Enter the inner radius");
102  fERmin2->Associate(this);
103  fERmin2->Resize(100, fERmin2->GetDefaultHeight());
104  f1->AddFrame(fERmin2, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
105  compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
106 
107  // Number entry for Rmax2
108  f1 = new TGCompositeFrame(compxyz, 155, 30, kHorizontalFrame | kFixedWidth);
109  f1->AddFrame(new TGLabel(f1, "Rmax2"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
110  fERmax2 = new TGNumberEntry(f1, 0., 5, kCONE_RMAX2);
111  fERmax2->SetNumAttr(TGNumberFormat::kNEANonNegative);
112  nef = (TGTextEntry*)fERmax1->GetNumberEntry();
113  nef->SetToolTipText("Enter the outer radius");
114  fERmax2->Associate(this);
115  fERmax2->Resize(100, fERmax2->GetDefaultHeight());
116  f1->AddFrame(fERmax2, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
117  compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
118 
119  // Number entry for dz
120  f1 = new TGCompositeFrame(compxyz, 155, 30, kHorizontalFrame | kFixedWidth);
121  f1->AddFrame(new TGLabel(f1, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
122  fEDz = new TGNumberEntry(f1, 0., 5, kCONE_Z);
123  fEDz->SetNumAttr(TGNumberFormat::kNEAPositive);
124  nef = (TGTextEntry*)fEDz->GetNumberEntry();
125  nef->SetToolTipText("Enter the cone half-lenth in Z");
126  fEDz->Associate(this);
127  fEDz->Resize(100, fEDz->GetDefaultHeight());
128  f1->AddFrame(fEDz, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
129  compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
130 
131  compxyz->Resize(150,30);
132  AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
133 
134  // Delayed draw
135  fDFrame = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth | kSunkenFrame);
136  fDelayed = new TGCheckButton(fDFrame, "Delayed draw");
137  fDFrame->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 2, 2));
138  AddFrame(fDFrame, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
139 
140  // Buttons
141  fBFrame = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
142  fApply = new TGTextButton(fBFrame, "Apply");
143  fBFrame->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
144  fApply->Associate(this);
145  fUndo = new TGTextButton(fBFrame, "Undo");
146  fBFrame->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
147  fUndo->Associate(this);
148  AddFrame(fBFrame, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
149  fUndo->SetSize(fApply->GetSize());
150 }
151 
152 ////////////////////////////////////////////////////////////////////////////////
153 /// Destructor
154 
155 TGeoConeEditor::~TGeoConeEditor()
156 {
157  TGFrameElement *el;
158  TIter next(GetList());
159  while ((el = (TGFrameElement *)next())) {
160  if (el->fFrame->IsComposite())
161  TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame);
162  }
163  Cleanup();
164 }
165 
166 ////////////////////////////////////////////////////////////////////////////////
167 /// Connect signals to slots.
168 
169 void TGeoConeEditor::ConnectSignals2Slots()
170 {
171  fApply->Connect("Clicked()", "TGeoConeEditor", this, "DoApply()");
172  fUndo->Connect("Clicked()", "TGeoConeEditor", this, "DoUndo()");
173  fShapeName->Connect("TextChanged(const char *)", "TGeoConeEditor", this, "DoModified()");
174  fERmin1->Connect("ValueSet(Long_t)", "TGeoConeEditor", this, "DoRmin1()");
175  fERmin2->Connect("ValueSet(Long_t)", "TGeoConeEditor", this, "DoRmin2()");
176  fERmax1->Connect("ValueSet(Long_t)", "TGeoConeEditor", this, "DoRmax1()");
177  fERmax2->Connect("ValueSet(Long_t)", "TGeoConeEditor", this, "DoRmax2()");
178  fEDz->Connect("ValueSet(Long_t)", "TGeoConeEditor", this, "DoDz()");
179  fERmin1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoConeEditor", this, "DoRmin1()");
180  fERmin2->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoConeEditor", this, "DoRmin2()");
181  fERmax1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoConeEditor", this, "DoRmax1()");
182  fERmax2->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoConeEditor", this, "DoRmax2()");
183  fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoConeEditor", this, "DoDz()");
184  fInit = kFALSE;
185 }
186 
187 
188 ////////////////////////////////////////////////////////////////////////////////
189 /// Connect to the selected object.
190 
191 void TGeoConeEditor::SetModel(TObject* obj)
192 {
193  if (obj == 0 || (obj->IsA()!=TGeoCone::Class())) {
194  SetActive(kFALSE);
195  return;
196  }
197  fShape = (TGeoCone*)obj;
198  fRmini1 = fShape->GetRmin1();
199  fRmini2 = fShape->GetRmin2();
200  fRmaxi1 = fShape->GetRmax1();
201  fRmaxi2 = fShape->GetRmax2();
202  fDzi = fShape->GetDz();
203  fNamei = fShape->GetName();
204  fShapeName->SetText(fShape->GetName());
205  fERmin1->SetNumber(fRmini1);
206  fERmin2->SetNumber(fRmini2);
207  fERmax1->SetNumber(fRmaxi1);
208  fERmax2->SetNumber(fRmaxi2);
209  fEDz->SetNumber(fDzi);
210  fApply->SetEnabled(kFALSE);
211  fUndo->SetEnabled(kFALSE);
212 
213  if (fInit) ConnectSignals2Slots();
214  SetActive();
215 }
216 
217 ////////////////////////////////////////////////////////////////////////////////
218 /// Check if shape drawing is delayed.
219 
220 Bool_t TGeoConeEditor::IsDelayed() const
221 {
222  return (fDelayed->GetState() == kButtonDown);
223 }
224 
225 ////////////////////////////////////////////////////////////////////////////////
226 /// Slot for name.
227 
228 void TGeoConeEditor::DoName()
229 {
230  DoModified();
231 }
232 
233 ////////////////////////////////////////////////////////////////////////////////
234 ///Slot for applying current parameters.
235 
236 void TGeoConeEditor::DoApply()
237 {
238  fApply->SetEnabled(kFALSE);
239  const char *name = fShapeName->GetText();
240  if (strcmp(name,fShape->GetName())) fShape->SetName(name);
241  Double_t rmin1 = fERmin1->GetNumber();
242  Double_t rmin2 = fERmin2->GetNumber();
243  Double_t rmax1 = fERmax1->GetNumber();
244  Double_t rmax2 = fERmax2->GetNumber();
245  Double_t dz = fEDz->GetNumber();
246  if (rmin1<0 || rmin1>rmax1) return;
247  if (rmin2<0 || rmin2>rmax2) return;
248  if (dz<=0) return;
249  if (rmin1==rmax1 && rmin2==rmax2) return;
250  fShape->SetConeDimensions(dz, rmin1, rmax1, rmin2, rmax2);
251  fShape->ComputeBBox();
252  fUndo->SetEnabled();
253  if (fPad) {
254  if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
255  fShape->Draw();
256  fPad->GetView()->ShowAxis();
257  } else Update();
258  }
259 }
260 
261 ////////////////////////////////////////////////////////////////////////////////
262 ///Slot for modifying current parameters.
263 
264 void TGeoConeEditor::DoModified()
265 {
266  fApply->SetEnabled();
267 }
268 
269 ////////////////////////////////////////////////////////////////////////////////
270 /// Slot for undoing current operation.
271 
272 void TGeoConeEditor::DoUndo()
273 {
274  fERmin1->SetNumber(fRmini1);
275  fERmin2->SetNumber(fRmini2);
276  fERmax1->SetNumber(fRmaxi1);
277  fERmax2->SetNumber(fRmaxi2);
278  fEDz->SetNumber(fDzi);
279  DoApply();
280  fUndo->SetEnabled(kFALSE);
281  fApply->SetEnabled(kFALSE);
282 }
283 
284 ////////////////////////////////////////////////////////////////////////////////
285 /// Slot for Rmin1
286 
287 void TGeoConeEditor::DoRmin1()
288 {
289  Double_t rmin1 = fERmin1->GetNumber();
290  Double_t rmax1 = fERmax1->GetNumber();
291  if (rmin1<0) {
292  rmin1 = 0;
293  fERmin1->SetNumber(rmin1);
294  }
295  if (rmin1>rmax1) {
296  rmin1 = rmax1;
297  fERmin1->SetNumber(rmin1);
298  }
299  DoModified();
300  if (!IsDelayed()) DoApply();
301 }
302 
303 ////////////////////////////////////////////////////////////////////////////////
304 /// Slot for Rmax1
305 
306 void TGeoConeEditor::DoRmax1()
307 {
308  Double_t rmin1 = fERmin1->GetNumber();
309  Double_t rmax1 = fERmax1->GetNumber();
310  if (rmax1<rmin1) {
311  rmax1 = rmin1;
312  fERmax1->SetNumber(rmax1);
313  }
314  DoModified();
315  if (!IsDelayed()) DoApply();
316 }
317 
318 ////////////////////////////////////////////////////////////////////////////////
319 /// Slot for Rmin2
320 
321 void TGeoConeEditor::DoRmin2()
322 {
323  Double_t rmin2 = fERmin2->GetNumber();
324  Double_t rmax2 = fERmax2->GetNumber();
325  if (rmin2<0) {
326  rmin2 = 0;
327  fERmin2->SetNumber(rmin2);
328  }
329  if (rmin2>rmax2) {
330  rmin2 = rmax2;
331  fERmin2->SetNumber(rmin2);
332  }
333  DoModified();
334  if (!IsDelayed()) DoApply();
335 }
336 
337 ////////////////////////////////////////////////////////////////////////////////
338 /// Slot for Rmax2
339 
340 void TGeoConeEditor::DoRmax2()
341 {
342  Double_t rmin2 = fERmin2->GetNumber();
343  Double_t rmax2 = fERmax2->GetNumber();
344  if (rmax2<rmin2) {
345  rmax2 = rmin2;
346  fERmax2->SetNumber(rmax2);
347  }
348  DoModified();
349  if (!IsDelayed()) DoApply();
350 }
351 
352 ////////////////////////////////////////////////////////////////////////////////
353 /// Slot for Dz
354 
355 void TGeoConeEditor::DoDz()
356 {
357  Double_t dz = fEDz->GetNumber();
358  if (dz<=0) {
359  dz = 0.1;
360  fEDz->SetNumber(dz);
361  }
362  DoModified();
363  if (!IsDelayed()) DoApply();
364 }
365 
366 /** \class TGeoConeSegEditor
367 \ingroup Geometry_builder
368 
369 Editor for a cone segment.
370 
371 \image html geom_cons_pic.png
372 
373 \image html geom_cons_ed.png
374 
375 */
376 
377 ClassImp(TGeoConeSegEditor);
378 
379 enum ETGeoConeSegWid {
380  kCONESEG_PHI1, kCONESEG_PHI2, kCONESEG_PHI
381 };
382 
383 ////////////////////////////////////////////////////////////////////////////////
384 /// Constructor for cone segment editor
385 
386 TGeoConeSegEditor::TGeoConeSegEditor(const TGWindow *p, Int_t width,
387  Int_t height, UInt_t options, Pixel_t back)
388  : TGeoConeEditor(p, width, height, options | kVerticalFrame, back)
389 {
390  fLock = kFALSE;
391  MakeTitle("Phi range");
392  TGTextEntry *nef;
393  TGCompositeFrame *compxyz = new TGCompositeFrame(this, 155, 110, kHorizontalFrame | kFixedWidth | kFixedHeight | kRaisedFrame);
394  // Vertical slider
395  fSPhi = new TGDoubleVSlider(compxyz,100);
396  fSPhi->SetRange(0.,720.);
397  fSPhi->Resize(fSPhi->GetDefaultWidth(), 100);
398  compxyz->AddFrame(fSPhi, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
399  TGCompositeFrame *f1 = new TGCompositeFrame(compxyz, 135, 100, kVerticalFrame | kFixedHeight);
400  f1->AddFrame(new TGLabel(f1, "Phi min."), new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 6, 0));
401  fEPhi1 = new TGNumberEntry(f1, 0., 5, kCONESEG_PHI1);
402  fEPhi1->Resize(100, fEPhi1->GetDefaultHeight());
403  fEPhi1->SetNumAttr(TGNumberFormat::kNEANonNegative);
404  nef = (TGTextEntry*)fEPhi1->GetNumberEntry();
405  nef->SetToolTipText("Enter the phi1 value");
406  fEPhi1->Associate(this);
407  f1->AddFrame(fEPhi1, new TGLayoutHints(kLHintsTop | kLHintsRight, 2, 2, 2, 2));
408 
409  fEPhi2 = new TGNumberEntry(f1, 0., 5, kCONESEG_PHI2);
410  fEPhi2->Resize(100, fEPhi2->GetDefaultHeight());
411  fEPhi2->SetNumAttr(TGNumberFormat::kNEANonNegative);
412  nef = (TGTextEntry*)fEPhi2->GetNumberEntry();
413  nef->SetToolTipText("Enter the phi2 value");
414  fEPhi2->Associate(this);
415  f1->AddFrame(fEPhi2, new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 2, 2));
416  f1->AddFrame(new TGLabel(f1, "Phi max."), new TGLayoutHints(kLHintsBottom, 0, 0, 6, 2));
417  compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
418 
419 // compxyz->Resize(150,150);
420  AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
421  TGeoTabManager::MoveFrame(fDFrame, this);
422  TGeoTabManager::MoveFrame(fBFrame, this);
423 }
424 
425 ////////////////////////////////////////////////////////////////////////////////
426 /// Destructor
427 
428 TGeoConeSegEditor::~TGeoConeSegEditor()
429 {
430  TGFrameElement *el;
431  TIter next(GetList());
432  while ((el = (TGFrameElement *)next())) {
433  if (el->fFrame->IsComposite())
434  TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame);
435  }
436  Cleanup();
437 }
438 
439 ////////////////////////////////////////////////////////////////////////////////
440 /// Connect signals to slots.
441 
442 void TGeoConeSegEditor::ConnectSignals2Slots()
443 {
444  TGeoConeEditor::ConnectSignals2Slots();
445  Disconnect(fApply, "Clicked()",(TGeoConeEditor*)this, "DoApply()");
446  Disconnect(fUndo, "Clicked()",(TGeoConeEditor*)this, "DoUndo()");
447  fApply->Connect("Clicked()", "TGeoConeSegEditor", this, "DoApply()");
448  fUndo->Connect("Clicked()", "TGeoConeSegEditor", this, "DoUndo()");
449  fEPhi1->Connect("ValueSet(Long_t)", "TGeoConeSegEditor", this, "DoPhi1()");
450  fEPhi2->Connect("ValueSet(Long_t)", "TGeoConeSegEditor", this, "DoPhi2()");
451 // fEPhi1->GetNumberEntry()->Connect("TextChanged(const char *)","TGeoConeSegEditor", this, "DoPhi1()");
452 // fEPhi2->GetNumberEntry()->Connect("TextChanged(const char *)","TGeoConeSegEditor", this, "DoPhi2()");
453  fSPhi->Connect("PositionChanged()","TGeoConeSegEditor", this, "DoPhi()");
454 }
455 
456 ////////////////////////////////////////////////////////////////////////////////
457 /// Connect to the selected object.
458 
459 void TGeoConeSegEditor::SetModel(TObject* obj)
460 {
461  if (obj == 0 || (obj->IsA()!=TGeoConeSeg::Class())) {
462  SetActive(kFALSE);
463  return;
464  }
465  fShape = (TGeoCone*)obj;
466  fRmini1 = fShape->GetRmin1();
467  fRmaxi1 = fShape->GetRmax1();
468  fRmini2 = fShape->GetRmin2();
469  fRmaxi2 = fShape->GetRmax2();
470  fDzi = fShape->GetDz();
471  fNamei = fShape->GetName();
472  fPmini = ((TGeoConeSeg*)fShape)->GetPhi1();
473  fPmaxi = ((TGeoConeSeg*)fShape)->GetPhi2();
474  fShapeName->SetText(fShape->GetName());
475  fEPhi1->SetNumber(fPmini);
476  fEPhi2->SetNumber(fPmaxi);
477  fSPhi->SetPosition(fPmini,fPmaxi);
478  fERmin1->SetNumber(fRmini1);
479  fERmax1->SetNumber(fRmaxi1);
480  fERmin2->SetNumber(fRmini2);
481  fERmax2->SetNumber(fRmaxi2);
482  fEDz->SetNumber(fDzi);
483  fApply->SetEnabled(kFALSE);
484  fUndo->SetEnabled(kFALSE);
485 
486  if (fInit) ConnectSignals2Slots();
487  SetActive();
488 }
489 
490 ////////////////////////////////////////////////////////////////////////////////
491 ///Slot for Phi1
492 
493 void TGeoConeSegEditor::DoPhi1()
494 {
495  Double_t phi1 = fEPhi1->GetNumber();
496  Double_t phi2 = fEPhi2->GetNumber();
497  if (phi1 > 360-1.e-10) {
498  phi1 = 0.;
499  fEPhi1->SetNumber(phi1);
500  }
501  if (phi2<phi1+1.e-10) {
502  phi1 = phi2 - 0.1;
503  fEPhi1->SetNumber(phi1);
504  }
505  if (!fLock) {
506  DoModified();
507  fLock = kTRUE;
508  fSPhi->SetPosition(phi1,phi2);
509  } else fLock = kFALSE;
510  if (!IsDelayed()) DoApply();
511 }
512 
513 ////////////////////////////////////////////////////////////////////////////////
514 /// Slot for Phi2
515 
516 void TGeoConeSegEditor::DoPhi2()
517 {
518  Double_t phi1 = fEPhi1->GetNumber();
519  Double_t phi2 = fEPhi2->GetNumber();
520  if (phi2-phi1 > 360.) {
521  phi2 -= 360.;
522  fEPhi2->SetNumber(phi2);
523  }
524  if (phi2<phi1+1.e-10) {
525  phi2 = phi1 + 0.1;
526  fEPhi2->SetNumber(phi2);
527  }
528  if (!fLock) {
529  DoModified();
530  fLock = kTRUE;
531  fSPhi->SetPosition(phi1,phi2);
532  } else fLock = kFALSE;
533  if (!IsDelayed()) DoApply();
534 }
535 
536 ////////////////////////////////////////////////////////////////////////////////
537 /// Slot for Phi
538 
539 void TGeoConeSegEditor::DoPhi()
540 {
541  if (!fLock) {
542  DoModified();
543  fLock = kTRUE;
544  fEPhi1->SetNumber(fSPhi->GetMinPosition());
545  fLock = kTRUE;
546  fEPhi2->SetNumber(fSPhi->GetMaxPosition());
547  } else fLock = kFALSE;
548  if (!IsDelayed()) DoApply();
549 }
550 
551 ////////////////////////////////////////////////////////////////////////////////
552 /// Slot for applying current parameters.
553 
554 void TGeoConeSegEditor::DoApply()
555 {
556  fApply->SetEnabled(kFALSE);
557  const char *name = fShapeName->GetText();
558  if (strcmp(name,fShape->GetName())) fShape->SetName(name);
559  Double_t rmin1 = fERmin1->GetNumber();
560  Double_t rmax1 = fERmax1->GetNumber();
561  if (rmin1<0 || rmax1<rmin1) return;
562  Double_t rmin2 = fERmin2->GetNumber();
563  Double_t rmax2 = fERmax2->GetNumber();
564  if (rmin2<0 || rmax2<rmin2) return;
565  Double_t dz = fEDz->GetNumber();
566  Double_t phi1 = fEPhi1->GetNumber();
567  Double_t phi2 = fEPhi2->GetNumber();
568  if ((phi2-phi1) > 360.001) {
569  phi1 = 0.;
570  phi2 = 360.;
571  fEPhi1->SetNumber(phi1);
572  fEPhi2->SetNumber(phi2);
573  fLock = kTRUE;
574  fSPhi->SetPosition(phi1,phi2);
575  fLock = kFALSE;
576  }
577  ((TGeoConeSeg*)fShape)->SetConsDimensions(dz, rmin1, rmax1, rmin2,rmax2, phi1, phi2);
578  fShape->ComputeBBox();
579  fUndo->SetEnabled();
580  if (fPad) {
581  if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
582  fShape->Draw();
583  fPad->GetView()->ShowAxis();
584  } else Update();
585  }
586 }
587 
588 ////////////////////////////////////////////////////////////////////////////////
589 /// Slot for undoing last operation.
590 
591 void TGeoConeSegEditor::DoUndo()
592 {
593  fERmin1->SetNumber(fRmini1);
594  fERmin2->SetNumber(fRmini2);
595  fERmax1->SetNumber(fRmaxi1);
596  fERmax2->SetNumber(fRmaxi2);
597  fEDz->SetNumber(fDzi);
598  fEPhi1->SetNumber(fPmini);
599  fEPhi2->SetNumber(fPmaxi);
600  fSPhi->SetPosition(fPmini,fPmaxi);
601  DoApply();
602  fUndo->SetEnabled(kFALSE);
603  fApply->SetEnabled(kFALSE);
604 }
605 
606 
607 
608