39 ClassImp(TGeoConeEditor);
42 kCONE_NAME, kCONE_RMIN1, kCONE_RMIN2, kCONE_RMAX1, kCONE_RMAX2, kCONE_Z,
43 kCONE_APPLY, kCONE_UNDO
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)
54 fRmini1 = fRmaxi1 = fRmini2 = fRmaxi2 = fDzi = 0.0;
57 fIsShapeEditable = kTRUE;
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));
68 MakeTitle(
"Cone dimensions");
69 TGCompositeFrame *compxyz =
new TGCompositeFrame(
this, 118, 30, kVerticalFrame | kRaisedFrame);
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));
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));
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));
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));
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));
131 compxyz->Resize(150,30);
132 AddFrame(compxyz,
new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
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));
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());
155 TGeoConeEditor::~TGeoConeEditor()
158 TIter next(GetList());
159 while ((el = (TGFrameElement *)next())) {
160 if (el->fFrame->IsComposite())
161 TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame);
169 void TGeoConeEditor::ConnectSignals2Slots()
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()");
191 void TGeoConeEditor::SetModel(TObject* obj)
193 if (obj == 0 || (obj->IsA()!=TGeoCone::Class())) {
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);
213 if (fInit) ConnectSignals2Slots();
220 Bool_t TGeoConeEditor::IsDelayed()
const
222 return (fDelayed->GetState() == kButtonDown);
228 void TGeoConeEditor::DoName()
236 void TGeoConeEditor::DoApply()
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;
249 if (rmin1==rmax1 && rmin2==rmax2)
return;
250 fShape->SetConeDimensions(dz, rmin1, rmax1, rmin2, rmax2);
251 fShape->ComputeBBox();
254 if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
256 fPad->GetView()->ShowAxis();
264 void TGeoConeEditor::DoModified()
266 fApply->SetEnabled();
272 void TGeoConeEditor::DoUndo()
274 fERmin1->SetNumber(fRmini1);
275 fERmin2->SetNumber(fRmini2);
276 fERmax1->SetNumber(fRmaxi1);
277 fERmax2->SetNumber(fRmaxi2);
278 fEDz->SetNumber(fDzi);
280 fUndo->SetEnabled(kFALSE);
281 fApply->SetEnabled(kFALSE);
287 void TGeoConeEditor::DoRmin1()
289 Double_t rmin1 = fERmin1->GetNumber();
290 Double_t rmax1 = fERmax1->GetNumber();
293 fERmin1->SetNumber(rmin1);
297 fERmin1->SetNumber(rmin1);
300 if (!IsDelayed()) DoApply();
306 void TGeoConeEditor::DoRmax1()
308 Double_t rmin1 = fERmin1->GetNumber();
309 Double_t rmax1 = fERmax1->GetNumber();
312 fERmax1->SetNumber(rmax1);
315 if (!IsDelayed()) DoApply();
321 void TGeoConeEditor::DoRmin2()
323 Double_t rmin2 = fERmin2->GetNumber();
324 Double_t rmax2 = fERmax2->GetNumber();
327 fERmin2->SetNumber(rmin2);
331 fERmin2->SetNumber(rmin2);
334 if (!IsDelayed()) DoApply();
340 void TGeoConeEditor::DoRmax2()
342 Double_t rmin2 = fERmin2->GetNumber();
343 Double_t rmax2 = fERmax2->GetNumber();
346 fERmax2->SetNumber(rmax2);
349 if (!IsDelayed()) DoApply();
355 void TGeoConeEditor::DoDz()
357 Double_t dz = fEDz->GetNumber();
363 if (!IsDelayed()) DoApply();
377 ClassImp(TGeoConeSegEditor);
379 enum ETGeoConeSegWid {
380 kCONESEG_PHI1, kCONESEG_PHI2, kCONESEG_PHI
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)
391 MakeTitle(
"Phi range");
393 TGCompositeFrame *compxyz =
new TGCompositeFrame(
this, 155, 110, kHorizontalFrame | kFixedWidth | kFixedHeight | kRaisedFrame);
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));
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));
420 AddFrame(compxyz,
new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
421 TGeoTabManager::MoveFrame(fDFrame,
this);
422 TGeoTabManager::MoveFrame(fBFrame,
this);
428 TGeoConeSegEditor::~TGeoConeSegEditor()
431 TIter next(GetList());
432 while ((el = (TGFrameElement *)next())) {
433 if (el->fFrame->IsComposite())
434 TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame);
442 void TGeoConeSegEditor::ConnectSignals2Slots()
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()");
453 fSPhi->Connect(
"PositionChanged()",
"TGeoConeSegEditor",
this,
"DoPhi()");
459 void TGeoConeSegEditor::SetModel(TObject* obj)
461 if (obj == 0 || (obj->IsA()!=TGeoConeSeg::Class())) {
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);
486 if (fInit) ConnectSignals2Slots();
493 void TGeoConeSegEditor::DoPhi1()
495 Double_t phi1 = fEPhi1->GetNumber();
496 Double_t phi2 = fEPhi2->GetNumber();
497 if (phi1 > 360-1.e-10) {
499 fEPhi1->SetNumber(phi1);
501 if (phi2<phi1+1.e-10) {
503 fEPhi1->SetNumber(phi1);
508 fSPhi->SetPosition(phi1,phi2);
509 }
else fLock = kFALSE;
510 if (!IsDelayed()) DoApply();
516 void TGeoConeSegEditor::DoPhi2()
518 Double_t phi1 = fEPhi1->GetNumber();
519 Double_t phi2 = fEPhi2->GetNumber();
520 if (phi2-phi1 > 360.) {
522 fEPhi2->SetNumber(phi2);
524 if (phi2<phi1+1.e-10) {
526 fEPhi2->SetNumber(phi2);
531 fSPhi->SetPosition(phi1,phi2);
532 }
else fLock = kFALSE;
533 if (!IsDelayed()) DoApply();
539 void TGeoConeSegEditor::DoPhi()
544 fEPhi1->SetNumber(fSPhi->GetMinPosition());
546 fEPhi2->SetNumber(fSPhi->GetMaxPosition());
547 }
else fLock = kFALSE;
548 if (!IsDelayed()) DoApply();
554 void TGeoConeSegEditor::DoApply()
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) {
571 fEPhi1->SetNumber(phi1);
572 fEPhi2->SetNumber(phi2);
574 fSPhi->SetPosition(phi1,phi2);
577 ((TGeoConeSeg*)fShape)->SetConsDimensions(dz, rmin1, rmax1, rmin2,rmax2, phi1, phi2);
578 fShape->ComputeBBox();
581 if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
583 fPad->GetView()->ShowAxis();
591 void TGeoConeSegEditor::DoUndo()
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);
602 fUndo->SetEnabled(kFALSE);
603 fApply->SetEnabled(kFALSE);