39 ClassImp(TGeoTubeEditor);
42 kTUBE_NAME, kTUBE_RMIN, kTUBE_RMAX, kTUBE_Z,
43 kTUBE_APPLY, kTUBE_UNDO
49 TGeoTubeEditor::TGeoTubeEditor(
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 = fDzi = 0.0;
57 fIsShapeEditable = kTRUE;
61 fShapeName =
new TGTextEntry(
this,
new TGTextBuffer(50), kTUBE_NAME);
62 fShapeName->Resize(135, fShapeName->GetDefaultHeight());
63 fShapeName->SetToolTipText(
"Enter the box name");
64 fShapeName->Associate(
this);
65 AddFrame(fShapeName,
new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
68 MakeTitle(
"Tube dimensions");
69 TGCompositeFrame *compxyz =
new TGCompositeFrame(
this, 118, 30, kVerticalFrame | kRaisedFrame);
71 TGCompositeFrame *f1 =
new TGCompositeFrame(compxyz, 155, 30, kHorizontalFrame | kFixedWidth);
72 f1->AddFrame(
new TGLabel(f1,
"Rmin"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
73 fERmin =
new TGNumberEntry(f1, 0., 5, kTUBE_RMIN);
74 fERmin->SetNumAttr(TGNumberFormat::kNEANonNegative);
75 nef = (TGTextEntry*)fERmin->GetNumberEntry();
76 nef->SetToolTipText(
"Enter the inner radius");
77 fERmin->Associate(
this);
78 fERmin->Resize(100,fERmin->GetDefaultHeight());
79 f1->AddFrame(fERmin,
new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
80 compxyz->AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
83 f1 =
new TGCompositeFrame(compxyz, 155, 30, kHorizontalFrame | kFixedWidth);
84 f1->AddFrame(
new TGLabel(f1,
"Rmax"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
85 fERmax =
new TGNumberEntry(f1, 0., 5, kTUBE_RMAX);
86 fERmax->SetNumAttr(TGNumberFormat::kNEANonNegative);
87 nef = (TGTextEntry*)fERmax->GetNumberEntry();
88 nef->SetToolTipText(
"Enter the outer radius");
89 fERmax->Associate(
this);
90 fERmax->Resize(100,fERmax->GetDefaultHeight());
91 f1->AddFrame(fERmax,
new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
92 compxyz->AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
95 f1 =
new TGCompositeFrame(compxyz, 155, 30, kHorizontalFrame | kFixedWidth);
96 f1->AddFrame(
new TGLabel(f1,
"DZ"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
97 fEDz =
new TGNumberEntry(f1, 0., 5, kTUBE_Z);
98 fEDz->SetNumAttr(TGNumberFormat::kNEAPositive);
99 nef = (TGTextEntry*)fEDz->GetNumberEntry();
100 nef->SetToolTipText(
"Enter the tube half-lenth in Z");
101 fEDz->Associate(
this);
102 fEDz->Resize(100,fEDz->GetDefaultHeight());
103 f1->AddFrame(fEDz,
new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
104 compxyz->AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
107 AddFrame(compxyz,
new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
110 fDFrame =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth | kSunkenFrame);
111 fDelayed =
new TGCheckButton(fDFrame,
"Delayed draw");
112 fDFrame->AddFrame(fDelayed,
new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4));
113 AddFrame(fDFrame,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
116 fBFrame =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
117 fApply =
new TGTextButton(fBFrame,
"Apply");
118 fBFrame->AddFrame(fApply,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
119 fApply->Associate(
this);
120 fUndo =
new TGTextButton(fBFrame,
"Undo");
121 fBFrame->AddFrame(fUndo,
new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
122 fUndo->Associate(
this);
123 AddFrame(fBFrame,
new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
124 fUndo->SetSize(fApply->GetSize());
130 TGeoTubeEditor::~TGeoTubeEditor()
133 TIter next(GetList());
134 while ((el = (TGFrameElement *)next())) {
135 if (el->fFrame->IsComposite())
136 TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame);
144 void TGeoTubeEditor::ConnectSignals2Slots()
146 fApply->Connect(
"Clicked()",
"TGeoTubeEditor",
this,
"DoApply()");
147 fUndo->Connect(
"Clicked()",
"TGeoTubeEditor",
this,
"DoUndo()");
148 fShapeName->Connect(
"TextChanged(const char *)",
"TGeoTubeEditor",
this,
"DoModified()");
149 fERmin->Connect(
"ValueSet(Long_t)",
"TGeoTubeEditor",
this,
"DoRmin()");
150 fERmax->Connect(
"ValueSet(Long_t)",
"TGeoTubeEditor",
this,
"DoRmax()");
151 fEDz->Connect(
"ValueSet(Long_t)",
"TGeoTubeEditor",
this,
"DoDz()");
152 fERmin->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoTubeEditor",
this,
"DoRmin()");
153 fERmax->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoTubeEditor",
this,
"DoRmax()");
154 fEDz->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoTubeEditor",
this,
"DoDz()");
162 void TGeoTubeEditor::SetModel(TObject* obj)
164 if (obj == 0 || (obj->IsA()!=TGeoTube::Class())) {
168 fShape = (TGeoTube*)obj;
169 fRmini = fShape->GetRmin();
170 fRmaxi = fShape->GetRmax();
171 fDzi = fShape->GetDz();
172 fNamei = fShape->GetName();
173 fShapeName->SetText(fShape->GetName());
174 fERmin->SetNumber(fRmini);
175 fERmax->SetNumber(fRmaxi);
176 fEDz->SetNumber(fDzi);
177 fApply->SetEnabled(kFALSE);
178 fUndo->SetEnabled(kFALSE);
180 if (fInit) ConnectSignals2Slots();
187 Bool_t TGeoTubeEditor::IsDelayed()
const
189 return (fDelayed->GetState() == kButtonDown);
195 void TGeoTubeEditor::DoName()
203 void TGeoTubeEditor::DoApply()
205 const char *name = fShapeName->GetText();
206 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
207 Double_t rmin = fERmin->GetNumber();
208 Double_t rmax = fERmax->GetNumber();
209 Double_t dz = fEDz->GetNumber();
210 fShape->SetTubeDimensions(rmin, rmax, dz);
211 fShape->ComputeBBox();
213 fApply->SetEnabled(kFALSE);
215 if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
217 fPad->GetView()->ShowAxis();
225 void TGeoTubeEditor::DoModified()
227 fApply->SetEnabled();
233 void TGeoTubeEditor::DoUndo()
235 fERmin->SetNumber(fRmini);
236 fERmax->SetNumber(fRmaxi);
237 fEDz->SetNumber(fDzi);
239 fUndo->SetEnabled(kFALSE);
240 fApply->SetEnabled(kFALSE);
246 void TGeoTubeEditor::DoRmin()
248 Double_t rmin = fERmin->GetNumber();
249 Double_t rmax = fERmax->GetNumber();
250 if (rmax<rmin+1.e-10) {
252 fERmin->SetNumber(rmin);
255 if (!IsDelayed()) DoApply();
261 void TGeoTubeEditor::DoRmax()
263 Double_t rmin = fERmin->GetNumber();
264 Double_t rmax = fERmax->GetNumber();
267 fERmax->SetNumber(rmax);
269 if (rmax<rmin+1.e-10) {
271 fERmax->SetNumber(rmax);
274 if (!IsDelayed()) DoApply();
280 void TGeoTubeEditor::DoDz()
282 Double_t dz = fEDz->GetNumber();
288 if (!IsDelayed()) DoApply();
302 ClassImp(TGeoTubeSegEditor);
304 enum ETGeoTubeSegWid {
305 kTUBESEG_PHI1, kTUBESEG_PHI2, kTUBESEG_PHI
311 TGeoTubeSegEditor::TGeoTubeSegEditor(
const TGWindow *p, Int_t width,
312 Int_t height, UInt_t options, Pixel_t back)
313 : TGeoTubeEditor(p, width, height, options | kVerticalFrame, back)
316 MakeTitle(
"Phi range");
318 TGCompositeFrame *compxyz =
new TGCompositeFrame(
this, 155, 110, kHorizontalFrame | kFixedWidth | kFixedHeight | kRaisedFrame);
320 fSPhi =
new TGDoubleVSlider(compxyz,100);
321 fSPhi->SetRange(0.,720.);
322 fSPhi->Resize(fSPhi->GetDefaultWidth(), 100);
323 compxyz->AddFrame(fSPhi,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
324 TGCompositeFrame *f1 =
new TGCompositeFrame(compxyz, 135, 100, kVerticalFrame | kFixedHeight);
325 f1->AddFrame(
new TGLabel(f1,
"Phi min."),
new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 6, 0));
326 fEPhi1 =
new TGNumberEntry(f1, 0., 5, kTUBESEG_PHI1);
327 fEPhi1->Resize(100, fEPhi1->GetDefaultHeight());
328 fEPhi1->SetNumAttr(TGNumberFormat::kNEANonNegative);
329 nef = (TGTextEntry*)fEPhi1->GetNumberEntry();
330 nef->SetToolTipText(
"Enter the phi1 value");
331 fEPhi1->Associate(
this);
332 f1->AddFrame(fEPhi1,
new TGLayoutHints(kLHintsTop | kLHintsRight, 2, 2, 2, 2));
334 fEPhi2 =
new TGNumberEntry(f1, 0., 5, kTUBESEG_PHI2);
335 fEPhi2->Resize(100, fEPhi2->GetDefaultHeight());
336 fEPhi2->SetNumAttr(TGNumberFormat::kNEANonNegative);
337 nef = (TGTextEntry*)fEPhi2->GetNumberEntry();
338 nef->SetToolTipText(
"Enter the phi2 value");
339 fEPhi2->Associate(
this);
340 f1->AddFrame(fEPhi2,
new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 2, 2));
341 f1->AddFrame(
new TGLabel(f1,
"Phi max."),
new TGLayoutHints(kLHintsBottom, 0, 0, 6, 2));
342 compxyz->AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
345 AddFrame(compxyz,
new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
346 TGeoTabManager::MoveFrame(fDFrame,
this);
347 TGeoTabManager::MoveFrame(fBFrame,
this);
353 TGeoTubeSegEditor::~TGeoTubeSegEditor()
356 TIter next(GetList());
357 while ((el = (TGFrameElement *)next())) {
358 if (el->fFrame->IsComposite())
359 TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame);
367 void TGeoTubeSegEditor::ConnectSignals2Slots()
369 TGeoTubeEditor::ConnectSignals2Slots();
370 Disconnect(fApply,
"Clicked()",(TGeoTubeEditor*)
this,
"DoApply()");
371 Disconnect(fUndo,
"Clicked()",(TGeoTubeEditor*)
this,
"DoUndo()");
372 fApply->Connect(
"Clicked()",
"TGeoTubeSegEditor",
this,
"DoApply()");
373 fUndo->Connect(
"Clicked()",
"TGeoTubeSegEditor",
this,
"DoUndo()");
374 fEPhi1->Connect(
"ValueSet(Long_t)",
"TGeoTubeSegEditor",
this,
"DoPhi1()");
375 fEPhi2->Connect(
"ValueSet(Long_t)",
"TGeoTubeSegEditor",
this,
"DoPhi2()");
378 fSPhi->Connect(
"PositionChanged()",
"TGeoTubeSegEditor",
this,
"DoPhi()");
384 void TGeoTubeSegEditor::SetModel(TObject* obj)
386 if (obj == 0 || (obj->IsA()!=TGeoTubeSeg::Class())) {
390 fShape = (TGeoTube*)obj;
391 fRmini = fShape->GetRmin();
392 fRmaxi = fShape->GetRmax();
393 fDzi = fShape->GetDz();
394 fNamei = fShape->GetName();
395 fPmini = ((TGeoTubeSeg*)fShape)->GetPhi1();
396 fPmaxi = ((TGeoTubeSeg*)fShape)->GetPhi2();
397 fShapeName->SetText(fShape->GetName());
398 fEPhi1->SetNumber(fPmini);
399 fEPhi2->SetNumber(fPmaxi);
400 fSPhi->SetPosition(fPmini,fPmaxi);
401 fERmin->SetNumber(fRmini);
402 fERmax->SetNumber(fRmaxi);
403 fEDz->SetNumber(fDzi);
404 fApply->SetEnabled(kFALSE);
405 fUndo->SetEnabled(kFALSE);
407 if (fInit) ConnectSignals2Slots();
414 void TGeoTubeSegEditor::DoPhi1()
416 Double_t phi1 = fEPhi1->GetNumber();
417 Double_t phi2 = fEPhi2->GetNumber();
418 if (phi1 > 360-1.e-10) {
420 fEPhi1->SetNumber(phi1);
422 if (phi2<phi1+1.e-10) {
424 fEPhi1->SetNumber(phi1);
429 fSPhi->SetPosition(phi1,phi2);
430 }
else fLock = kFALSE;
431 if (!IsDelayed()) DoApply();
437 void TGeoTubeSegEditor::DoPhi2()
439 Double_t phi1 = fEPhi1->GetNumber();
440 Double_t phi2 = fEPhi2->GetNumber();
441 if (phi2-phi1 > 360.) {
443 fEPhi2->SetNumber(phi2);
445 if (phi2<phi1+1.e-10) {
447 fEPhi2->SetNumber(phi2);
452 fSPhi->SetPosition(phi1,phi2);
453 }
else fLock = kFALSE;
454 if (!IsDelayed()) DoApply();
460 void TGeoTubeSegEditor::DoPhi()
465 fEPhi1->SetNumber(fSPhi->GetMinPosition());
467 fEPhi2->SetNumber(fSPhi->GetMaxPosition());
468 }
else fLock = kFALSE;
469 if (!IsDelayed()) DoApply();
475 void TGeoTubeSegEditor::DoApply()
477 fApply->SetEnabled(kFALSE);
478 const char *name = fShapeName->GetText();
479 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
480 Double_t rmin = fERmin->GetNumber();
481 Double_t rmax = fERmax->GetNumber();
482 if (rmin<0 || rmax<rmin)
return;
483 Double_t dz = fEDz->GetNumber();
484 Double_t phi1 = fEPhi1->GetNumber();
485 Double_t phi2 = fEPhi2->GetNumber();
486 if ((phi2-phi1) > 360.001) {
489 fEPhi1->SetNumber(phi1);
490 fEPhi2->SetNumber(phi2);
492 fSPhi->SetPosition(phi1,phi2);
495 ((TGeoTubeSeg*)fShape)->SetTubsDimensions(rmin, rmax, dz, phi1, phi2);
496 fShape->ComputeBBox();
499 if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
501 fPad->GetView()->ShowAxis();
509 void TGeoTubeSegEditor::DoUndo()
511 fERmin->SetNumber(fRmini);
512 fERmax->SetNumber(fRmaxi);
513 fEDz->SetNumber(fDzi);
514 fEPhi1->SetNumber(fPmini);
515 fEPhi2->SetNumber(fPmaxi);
516 fSPhi->SetPosition(fPmini,fPmaxi);
518 fUndo->SetEnabled(kFALSE);
519 fApply->SetEnabled(kFALSE);
533 ClassImp(TGeoCtubEditor);
535 enum ETGeoCtubSegWid {
536 kCTUB_THLO, kCTUB_PHLO, kCTUB_THHI, kCTUB_PHHI
542 TGeoCtubEditor::TGeoCtubEditor(
const TGWindow *p, Int_t width,
543 Int_t height, UInt_t options, Pixel_t back)
544 : TGeoTubeSegEditor(p, width, height, options, back)
546 MakeTitle(
"Theta/phi low");
549 TGCompositeFrame *compxyz =
new TGCompositeFrame(
this, 118, 30, kVerticalFrame | kRaisedFrame);
550 TGCompositeFrame *f1 =
new TGCompositeFrame(compxyz, 155, 30, kHorizontalFrame | kFixedWidth);
551 f1->AddFrame(
new TGLabel(f1,
"TH_LO"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
552 fEThlo =
new TGNumberEntry(f1, 0., 5, kCTUB_THLO);
553 fEThlo->SetNumAttr(TGNumberFormat::kNEANonNegative);
554 nef = (TGTextEntry*)fEThlo->GetNumberEntry();
555 nef->SetToolTipText(
"Enter the theta angle of the lower plane normal");
556 fEThlo->Associate(
this);
557 fEThlo->Connect(
"ValueSet(Long_t)",
"TGeoCtubEditor",
this,
"DoThlo()");
558 nef->Connect(
"TextChanged(const char *)",
"TGeoCtubEditor",
this,
"DoModified()");
559 fEThlo->Resize(100,fEThlo->GetDefaultHeight());
560 f1->AddFrame(fEThlo,
new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
561 compxyz->AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
563 f1 =
new TGCompositeFrame(compxyz, 155, 30, kHorizontalFrame | kFixedWidth);
564 f1->AddFrame(
new TGLabel(f1,
"PH_LO"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
565 fEPhlo =
new TGNumberEntry(f1, 0., 5, kCTUB_PHLO);
566 fEPhlo->SetNumAttr(TGNumberFormat::kNEANonNegative);
567 nef = (TGTextEntry*)fEPhlo->GetNumberEntry();
568 nef->SetToolTipText(
"Enter the phi angle of the lower plane normal");
569 fEPhlo->Associate(
this);
570 fEPhlo->Connect(
"ValueSet(Long_t)",
"TGeoCtubEditor",
this,
"DoPhlo()");
571 nef->Connect(
"TextChanged(const char *)",
"TGeoCtubEditor",
this,
"DoModified()");
572 fEPhlo->Resize(100,fEPhlo->GetDefaultHeight());
573 f1->AddFrame(fEPhlo,
new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
574 compxyz->AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
575 AddFrame(compxyz,
new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
578 MakeTitle(
"Theta/phi high");
579 compxyz =
new TGCompositeFrame(
this, 118, 30, kVerticalFrame | kRaisedFrame);
580 f1 =
new TGCompositeFrame(compxyz, 155, 30, kHorizontalFrame | kFixedWidth);
581 f1->AddFrame(
new TGLabel(f1,
"TH_HI"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
582 fEThhi =
new TGNumberEntry(f1, 0., 5, kCTUB_THHI);
583 fEThhi->SetNumAttr(TGNumberFormat::kNEANonNegative);
584 nef = (TGTextEntry*)fEThhi->GetNumberEntry();
585 nef->SetToolTipText(
"Enter the theta angle of the upper plane normal");
586 fEThhi->Associate(
this);
587 fEThhi->Connect(
"ValueSet(Long_t)",
"TGeoCtubEditor",
this,
"DoThhi()");
588 nef->Connect(
"TextChanged(const char *)",
"TGeoCtubEditor",
this,
"DoModified()");
589 fEThhi->Resize(100,fEThhi->GetDefaultHeight());
590 f1->AddFrame(fEThhi,
new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
591 compxyz->AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
593 f1 =
new TGCompositeFrame(compxyz, 155, 30, kHorizontalFrame | kFixedWidth);
594 f1->AddFrame(
new TGLabel(f1,
"PH_HI"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
595 fEPhhi =
new TGNumberEntry(f1, 0., 5, kCTUB_PHHI);
596 fEPhhi->SetNumAttr(TGNumberFormat::kNEANonNegative);
597 nef = (TGTextEntry*)fEPhhi->GetNumberEntry();
598 nef->SetToolTipText(
"Enter the phi angle of the upper plane normal");
599 fEPhhi->Associate(
this);
600 fEPhhi->Connect(
"ValueSet(Long_t)",
"TGeoCtubEditor",
this,
"DoPhhi()");
601 nef->Connect(
"TextChanged(const char *)",
"TGeoCtubEditor",
this,
"DoModified()");
602 fEPhhi->Resize(100,fEPhhi->GetDefaultHeight());
603 f1->AddFrame(fEPhhi,
new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
604 compxyz->AddFrame(f1,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
605 AddFrame(compxyz,
new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
606 TGeoTabManager::MoveFrame(fDFrame,
this);
607 TGeoTabManager::MoveFrame(fBFrame,
this);
613 TGeoCtubEditor::~TGeoCtubEditor()
616 TIter next(GetList());
617 while ((el = (TGFrameElement *)next())) {
618 if (el->fFrame->IsComposite())
619 TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame);
627 void TGeoCtubEditor::SetModel(TObject* obj)
629 if (obj == 0 || (obj->IsA()!=TGeoCtub::Class())) {
633 fShape = (TGeoTube*)obj;
634 fRmini = fShape->GetRmin();
635 fRmaxi = fShape->GetRmax();
636 fDzi = fShape->GetDz();
637 fNamei = fShape->GetName();
638 fPmini = ((TGeoTubeSeg*)fShape)->GetPhi1();
639 fPmaxi = ((TGeoTubeSeg*)fShape)->GetPhi2();
640 const Double_t *nlo = ((TGeoCtub*)fShape)->GetNlow();
641 const Double_t *nhi = ((TGeoCtub*)fShape)->GetNhigh();
642 fThlo = TMath::RadToDeg() * TMath::ACos(nlo[2]);
643 fPhlo = TMath::RadToDeg() * TMath::ATan2(nlo[1], nlo[0]);
644 fThhi = TMath::RadToDeg() * TMath::ACos(nhi[2]);
645 fPhhi = TMath::RadToDeg() * TMath::ATan2(nhi[1], nhi[0]);
647 fShapeName->SetText(fShape->GetName());
648 fEPhi1->SetNumber(fPmini);
649 fEPhi2->SetNumber(fPmaxi);
650 fSPhi->SetPosition(fPmini,fPmaxi);
651 fERmin->SetNumber(fRmini);
652 fERmax->SetNumber(fRmaxi);
653 fEDz->SetNumber(fDzi);
654 fEThlo->SetNumber(fThlo);
655 fEPhlo->SetNumber(fPhlo);
656 fEThhi->SetNumber(fThhi);
657 fEPhhi->SetNumber(fPhhi);
658 fApply->SetEnabled(kFALSE);
659 fUndo->SetEnabled(kFALSE);
661 if (fInit) ConnectSignals2Slots();
668 void TGeoCtubEditor::DoThlo()
670 Double_t thlo = fEThlo->GetNumber();
671 if (thlo <= 90.) {thlo = 91.; fEThlo->SetNumber(thlo);}
672 if (thlo > 180.) {thlo = 180.; fEThlo->SetNumber(thlo);}
674 if (!IsDelayed()) DoApply();
680 void TGeoCtubEditor::DoPhlo()
682 Double_t phlo = fEPhlo->GetNumber();
685 fEPhlo->SetNumber(phlo);
688 if (!IsDelayed()) DoApply();
694 void TGeoCtubEditor::DoThhi()
696 Double_t thhi = fEThhi->GetNumber();
697 if (thhi >= 90.) {thhi = 89.; fEThhi->SetNumber(thhi);}
699 if (!IsDelayed()) DoApply();
705 void TGeoCtubEditor::DoPhhi()
707 Double_t phhi = fEPhhi->GetNumber();
710 fEPhhi->SetNumber(phhi);
713 if (!IsDelayed()) DoApply();
719 void TGeoCtubEditor::DoApply()
721 fApply->SetEnabled(kFALSE);
722 const char *name = fShapeName->GetText();
723 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
724 Double_t rmin = fERmin->GetNumber();
725 Double_t rmax = fERmax->GetNumber();
726 if (rmin<0 || rmax<rmin)
return;
727 Double_t dz = fEDz->GetNumber();
728 Double_t phi1 = fEPhi1->GetNumber();
729 Double_t phi2 = fEPhi2->GetNumber();
730 if ((phi2-phi1) > 360.001) {
733 fEPhi1->SetNumber(phi1);
734 fEPhi2->SetNumber(phi2);
736 fSPhi->SetPosition(phi1,phi2);
739 Double_t thlo = TMath::DegToRad()*fEThlo->GetNumber();
740 Double_t phlo = TMath::DegToRad()*fEPhlo->GetNumber();
741 Double_t thhi = TMath::DegToRad()*fEThhi->GetNumber();
742 Double_t phhi = TMath::DegToRad()*fEPhhi->GetNumber();
743 Double_t lx = TMath::Sin(thlo)*TMath::Cos(phlo);
744 Double_t ly = TMath::Sin(thlo)*TMath::Sin(phlo);
745 Double_t lz = TMath::Cos(thlo);
746 Double_t tx = TMath::Sin(thhi)*TMath::Cos(phhi);
747 Double_t ty = TMath::Sin(thhi)*TMath::Sin(phhi);
748 Double_t tz = TMath::Cos(thhi);
749 ((TGeoCtub*)fShape)->SetCtubDimensions(rmin, rmax, dz, phi1, phi2, lx,ly,lz,tx,ty,tz);
750 fShape->ComputeBBox();
753 if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
755 fPad->GetView()->ShowAxis();
763 void TGeoCtubEditor::DoUndo()
765 fERmin->SetNumber(fRmini);
766 fERmax->SetNumber(fRmaxi);
767 fEDz->SetNumber(fDzi);
768 fEPhi1->SetNumber(fPmini);
769 fEPhi2->SetNumber(fPmaxi);
770 fSPhi->SetPosition(fPmini,fPmaxi);
771 fEThlo->SetNumber(fThlo);
772 fEPhlo->SetNumber(fPhlo);
773 fEThhi->SetNumber(fThhi);
774 fEPhhi->SetNumber(fPhhi);
777 fUndo->SetEnabled(kFALSE);
778 fApply->SetEnabled(kFALSE);