37 ClassImp(TGeoTrapEditor);
40 kTRAP_NAME, kTRAP_H1, kTRAP_BL1, kTRAP_TL1, kTRAP_DZ, kTRAP_ALPHA1,
41 kTRAP_SC1, kTRAP_SC2, kTRAP_THETA, kTRAP_PHI, kTRAP_APPLY, kTRAP_UNDO
47 TGeoTrapEditor::TGeoTrapEditor(
const TGWindow *p, Int_t width,
48 Int_t height, UInt_t options, Pixel_t back)
49 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
52 fH1i = fBl1i = fTl1i = fDzi = fAlpha1i = fThetai = fPhii = fSci = 0.0;
55 fIsShapeEditable = kTRUE;
59 fShapeName =
new TGTextEntry(
this,
new TGTextBuffer(50), kTRAP_NAME);
60 fShapeName->Resize(135, fShapeName->GetDefaultHeight());
61 fShapeName->SetToolTipText(
"Enter the parallelepiped name");
62 fShapeName->Associate(
this);
63 AddFrame(fShapeName,
new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
66 MakeTitle(
"Dimensions");
68 TGCompositeFrame *f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
69 f1->AddFrame(
new TGLabel(f1,
"DY"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
70 fEH1 =
new TGNumberEntry(f1, 0., 5, kTRAP_H1);
71 fEH1->SetNumAttr(TGNumberFormat::kNEAPositive);
72 fEH1->Resize(100, fEH1->GetDefaultHeight());
73 nef = (TGTextEntry*)fEH1->GetNumberEntry();
74 nef->SetToolTipText(
"Enter the half length in y at low z");
75 fEH1->Associate(
this);
76 f1->AddFrame(fEH1,
new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
77 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
80 f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
81 f1->AddFrame(
new TGLabel(f1,
"DX1"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
82 fEBl1 =
new TGNumberEntry(f1, 0., 5, kTRAP_BL1);
83 fEBl1->SetNumAttr(TGNumberFormat::kNEAPositive);
84 fEBl1->Resize(100, fEBl1->GetDefaultHeight());
85 nef = (TGTextEntry*)fEBl1->GetNumberEntry();
86 nef->SetToolTipText(
"Enter the half length in x at low z and y low edge");
87 fEBl1->Associate(
this);
88 f1->AddFrame(fEBl1,
new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
89 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
92 f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
93 f1->AddFrame(
new TGLabel(f1,
"DX2"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
94 fETl1 =
new TGNumberEntry(f1, 0., 5, kTRAP_TL1);
95 fETl1->SetNumAttr(TGNumberFormat::kNEAPositive);
96 fETl1->Resize(100, fETl1->GetDefaultHeight());
97 nef = (TGTextEntry*)fETl1->GetNumberEntry();
98 nef->SetToolTipText(
"Enter the half length in x at low z and y high edge");
99 fETl1->Associate(
this);
100 f1->AddFrame(fETl1,
new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
101 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
104 f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
105 f1->AddFrame(
new TGLabel(f1,
"SC1"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
106 fESc1 =
new TGNumberEntry(f1, 0., 5, kTRAP_SC1);
107 fESc1->SetNumAttr(TGNumberFormat::kNEAPositive);
108 fESc1->Resize(100, fESc1->GetDefaultHeight());
109 nef = (TGTextEntry*)fESc1->GetNumberEntry();
110 nef->SetToolTipText(
"Enter the scale factor for lower Z face");
111 fESc1->Associate(
this);
112 f1->AddFrame(fESc1,
new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
113 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
116 f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
117 f1->AddFrame(
new TGLabel(f1,
"SC2"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
118 fESc2 =
new TGNumberEntry(f1, 0., 5, kTRAP_SC2);
119 fESc2->SetNumAttr(TGNumberFormat::kNEAPositive);
120 fESc2->Resize(100, fESc2->GetDefaultHeight());
121 nef = (TGTextEntry*)fESc2->GetNumberEntry();
122 nef->SetToolTipText(
"Enter the scale factor for upper Z face");
123 fESc2->Associate(
this);
124 f1->AddFrame(fESc2,
new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
125 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
128 f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
129 f1->AddFrame(
new TGLabel(f1,
"DZ"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
130 fEDz =
new TGNumberEntry(f1, 0., 5, kTRAP_DZ);
131 fEDz->SetNumAttr(TGNumberFormat::kNEAPositive);
132 fEDz->Resize(100, fEDz->GetDefaultHeight());
133 nef = (TGTextEntry*)fEDz->GetNumberEntry();
134 nef->SetToolTipText(
"Enter the half-length in Z");
135 fEDz->Associate(
this);
136 f1->AddFrame(fEDz,
new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
137 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
140 f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
141 f1->AddFrame(
new TGLabel(f1,
"ALPHA"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
142 fEAlpha1 =
new TGNumberEntry(f1, 0., 5, kTRAP_ALPHA1);
143 fEAlpha1->Resize(100, fEAlpha1->GetDefaultHeight());
144 nef = (TGTextEntry*)fEAlpha1->GetNumberEntry();
145 nef->SetToolTipText(
"Enter angle between centers of x edges an y axis at low z");
146 fEAlpha1->Associate(
this);
147 f1->AddFrame(fEAlpha1,
new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
148 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
151 f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
152 f1->AddFrame(
new TGLabel(f1,
"Theta"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
153 fETheta =
new TGNumberEntry(f1, 0., 5, kTRAP_THETA);
154 fETheta->SetNumAttr(TGNumberFormat::kNEAPositive);
155 fETheta->Resize(100, fETheta->GetDefaultHeight());
156 nef = (TGTextEntry*)fETheta->GetNumberEntry();
157 nef->SetToolTipText(
"Enter initial theta");
158 fETheta->Associate(
this);
159 f1->AddFrame(fETheta,
new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
160 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
163 f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
164 f1->AddFrame(
new TGLabel(f1,
"Phi"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
165 fEPhi =
new TGNumberEntry(f1, 0., 5, kTRAP_PHI);
166 fEPhi->SetNumAttr(TGNumberFormat::kNEAPositive);
167 fEPhi->Resize(100, fEPhi->GetDefaultHeight());
168 nef = (TGTextEntry*)fEPhi->GetNumberEntry();
169 nef->SetToolTipText(
"Enter initial phi");
170 fEPhi->Associate(
this);
171 f1->AddFrame(fEPhi,
new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
172 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
175 fDFrame =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth | kSunkenFrame);
176 fDelayed =
new TGCheckButton(fDFrame,
"Delayed draw");
177 fDFrame->AddFrame(fDelayed,
new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4));
178 AddFrame(fDFrame,
new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
181 fBFrame =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
182 fApply =
new TGTextButton(fBFrame,
"Apply");
183 fBFrame->AddFrame(fApply,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
184 fApply->Associate(
this);
185 fUndo =
new TGTextButton(fBFrame,
"Undo");
186 fBFrame->AddFrame(fUndo,
new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
187 fUndo->Associate(
this);
188 AddFrame(fBFrame,
new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
189 fUndo->SetSize(fApply->GetSize());
195 TGeoTrapEditor::~TGeoTrapEditor()
198 TIter next(GetList());
199 while ((el = (TGFrameElement *)next())) {
200 if (el->fFrame->IsComposite())
201 TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame);
209 void TGeoTrapEditor::ConnectSignals2Slots()
211 fApply->Connect(
"Clicked()",
"TGeoTrapEditor",
this,
"DoApply()");
212 fUndo->Connect(
"Clicked()",
"TGeoTrapEditor",
this,
"DoUndo()");
213 fShapeName->Connect(
"TextChanged(const char *)",
"TGeoTrapEditor",
this,
"DoModified()");
214 fEH1->Connect(
"ValueSet(Long_t)",
"TGeoTrapEditor",
this,
"DoH1()");
215 fEBl1->Connect(
"ValueSet(Long_t)",
"TGeoTrapEditor",
this,
"DoBl1()");
216 fETl1->Connect(
"ValueSet(Long_t)",
"TGeoTrapEditor",
this,
"DoTl1()");
217 fEDz->Connect(
"ValueSet(Long_t)",
"TGeoTrapEditor",
this,
"DoDz()");
218 fESc1->Connect(
"ValueSet(Long_t)",
"TGeoTrapEditor",
this,
"DoSc1()");
219 fESc2->Connect(
"ValueSet(Long_t)",
"TGeoTrapEditor",
this,
"DoSc2()");
220 fEAlpha1->Connect(
"ValueSet(Long_t)",
"TGeoTrapEditor",
this,
"DoAlpha1()");
221 fETheta->Connect(
"ValueSet(Long_t)",
"TGeoTrapEditor",
this,
"DoTheta()");
222 fEPhi->Connect(
"ValueSet(Long_t)",
"TGeoTrapEditor",
this,
"DoPhi()");
223 fEH1->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoTrapEditor",
this,
"DoModified()");
224 fEBl1->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoTrapEditor",
this,
"DoModified()");
225 fETl1->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoTrapEditor",
this,
"DoModified()");
226 fEDz->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoTrapEditor",
this,
"DoModified()");
227 fESc1->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoTrapEditor",
this,
"DoModified()");
228 fESc2->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoTrapEditor",
this,
"DoModified()");
229 fEAlpha1->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoTrapEditor",
this,
"DoModified()");
230 fETheta->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoTrapEditor",
this,
"DoModified()");
231 fEPhi->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoTrapEditor",
this,
"DoModified()");
238 void TGeoTrapEditor::SetModel(TObject* obj)
240 if (obj == 0 || (obj->IsA()!=TGeoTrap::Class())) {
244 fShape = (TGeoTrap*)obj;
245 fH1i = fShape->GetH1();
246 fBl1i = fShape->GetBl1();
247 fTl1i = fShape->GetTl1();
248 fDzi = fShape->GetDz();
249 Double_t h2i = fShape->GetH2();
253 fAlpha1i = fShape->GetAlpha1();
254 fThetai = fShape->GetTheta();
255 fPhii = fShape->GetPhi();
256 const char *sname = fShape->GetName();
257 if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText(
"-no_name");
259 fShapeName->SetText(sname);
262 fEH1->SetNumber(fH1i);
263 fEBl1->SetNumber(fBl1i);
264 fETl1->SetNumber(fTl1i);
265 fEDz->SetNumber(fDzi);
266 fESc1->SetNumber(1.);
267 fESc2->SetNumber(fSci);
268 fEAlpha1->SetNumber(fAlpha1i);
269 fETheta->SetNumber(fThetai);
270 fEPhi->SetNumber(fPhii);
271 fApply->SetEnabled(kFALSE);
272 fUndo->SetEnabled(kFALSE);
274 if (fInit) ConnectSignals2Slots();
281 Bool_t TGeoTrapEditor::IsDelayed()
const
283 return (fDelayed->GetState() == kButtonDown);
289 void TGeoTrapEditor::DoName()
297 void TGeoTrapEditor::DoApply()
299 const char *name = fShapeName->GetText();
300 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
301 Double_t sc1 = fESc1->GetNumber();
302 Double_t sc2 = fESc2->GetNumber();
303 Double_t h1 = sc1*fEH1->GetNumber();
304 Double_t bl1 = sc1*fEBl1->GetNumber();
305 Double_t tl1 = sc1*fETl1->GetNumber();
306 Double_t h2 = sc2*fEH1->GetNumber();
307 Double_t bl2 = sc2*fEBl1->GetNumber();
308 Double_t tl2 = sc2*fETl1->GetNumber();
309 Double_t dz = fEDz->GetNumber();
310 Double_t alpha1 = fEAlpha1->GetNumber();
311 Double_t theta = fETheta->GetNumber();
312 Double_t phi = fEPhi->GetNumber();
325 fShape->SetDimensions(param);
326 fShape->ComputeBBox();
328 fApply->SetEnabled(kFALSE);
330 if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
331 TView *view = fPad->GetView();
334 fPad->GetView()->ShowAxis();
336 view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(),
337 fShape->GetDX(), fShape->GetDY(), fShape->GetDZ());
347 void TGeoTrapEditor::DoModified()
349 fApply->SetEnabled();
355 void TGeoTrapEditor::DoUndo()
357 fEH1->SetNumber(fH1i);
358 fEBl1->SetNumber(fBl1i);
359 fETl1->SetNumber(fTl1i);
360 fESc1->SetNumber(1.);
361 fESc2->SetNumber(fSci);
362 fEDz->SetNumber(fDzi);
363 fEAlpha1->SetNumber(fAlpha1i);
364 fETheta->SetNumber(fThetai);
365 fEPhi->SetNumber(fPhii);
367 fUndo->SetEnabled(kFALSE);
368 fApply->SetEnabled(kFALSE);
374 void TGeoTrapEditor::DoH1()
376 Double_t h1 = fEH1->GetNumber();
382 if (!IsDelayed()) DoApply();
388 void TGeoTrapEditor::DoBl1()
390 Double_t bl1 = fEBl1->GetNumber();
393 fEBl1->SetNumber(bl1);
396 if (!IsDelayed()) DoApply();
402 void TGeoTrapEditor::DoTl1()
404 Double_t tl1 = fETl1->GetNumber();
407 fETl1->SetNumber(tl1);
410 if (!IsDelayed()) DoApply();
416 void TGeoTrapEditor::DoDz()
418 Double_t dz = fEDz->GetNumber();
424 if (!IsDelayed()) DoApply();
430 void TGeoTrapEditor::DoSc1()
432 Double_t sc1 = fESc1->GetNumber();
435 fESc1->SetNumber(sc1);
438 if (!IsDelayed()) DoApply();
444 void TGeoTrapEditor::DoSc2()
446 Double_t sc2 = fESc2->GetNumber();
449 fESc2->SetNumber(sc2);
452 if (!IsDelayed()) DoApply();
458 void TGeoTrapEditor::DoAlpha1()
460 Double_t alpha1 = fEAlpha1->GetNumber();
461 if (TMath::Abs(alpha1)>=90) {
462 alpha1 = 89.9*TMath::Sign(1.,alpha1);
463 fEAlpha1->SetNumber(alpha1);
466 if (!IsDelayed()) DoApply();
472 void TGeoTrapEditor::DoTheta()
474 Double_t theta = fETheta->GetNumber();
477 fETheta->SetNumber(theta);
481 fETheta->SetNumber(theta);
484 if (!IsDelayed()) DoApply();
490 void TGeoTrapEditor::DoPhi()
492 Double_t phi = fEPhi->GetNumber();
493 if (phi<0 || phi>360) {
495 fEPhi->SetNumber(phi);
498 if (!IsDelayed()) DoApply();
501 ClassImp(TGeoGtraEditor);
521 TGeoGtraEditor::TGeoGtraEditor(
const TGWindow *p, Int_t width,
522 Int_t height, UInt_t options, Pixel_t back)
523 : TGeoTrapEditor(p, width, height, options, back)
528 TGCompositeFrame *f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
529 f1->AddFrame(
new TGLabel(f1,
"TWIST"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
530 fETwist =
new TGNumberEntry(f1, 0., 5, kGTRA_TWIST);
531 fETwist->Resize(100, fETwist->GetDefaultHeight());
532 nef = (TGTextEntry*)fETwist->GetNumberEntry();
533 nef->SetToolTipText(
"Enter twist angle");
534 fETwist->Associate(
this);
535 f1->AddFrame(fETwist,
new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
536 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
537 TGeoTabManager::MoveFrame(fDFrame,
this);
538 TGeoTabManager::MoveFrame(fBFrame,
this);
539 fETwist->Connect(
"ValueSet(Long_t)",
"TGeoGtraEditor",
this,
"DoTwist()");
540 nef->Connect(
"TextChanged(const char *)",
"TGeoGtraEditor",
this,
"DoModified()");
545 TGeoGtraEditor::~TGeoGtraEditor()
548 TIter next(GetList());
549 while ((el = (TGFrameElement *)next())) {
550 if (el->fFrame->IsComposite())
551 TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame);
559 void TGeoGtraEditor::SetModel(TObject* obj)
561 if (obj == 0 || (obj->IsA()!=TGeoGtra::Class())) {
565 fShape = (TGeoTrap*)obj;
566 fH1i = fShape->GetH1();
567 fBl1i = fShape->GetBl1();
568 fTl1i = fShape->GetTl1();
569 fDzi = fShape->GetDz();
570 Double_t h2i = fShape->GetH2();
574 fAlpha1i = fShape->GetAlpha1();
575 fThetai = fShape->GetTheta();
576 fPhii = fShape->GetPhi();
577 fTwisti = ((TGeoGtra*)fShape)->GetTwistAngle();
578 const char *sname = fShape->GetName();
579 if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText(
"-no_name");
581 fShapeName->SetText(sname);
584 fEH1->SetNumber(fH1i);
585 fEBl1->SetNumber(fBl1i);
586 fETl1->SetNumber(fTl1i);
587 fEDz->SetNumber(fDzi);
588 fESc1->SetNumber(1.);
589 fESc2->SetNumber(fSci);
590 fEAlpha1->SetNumber(fAlpha1i);
591 fETheta->SetNumber(fThetai);
592 fEPhi->SetNumber(fPhii);
593 fETwist->SetNumber(fTwisti);
594 fApply->SetEnabled(kFALSE);
595 fUndo->SetEnabled(kFALSE);
597 if (fInit) ConnectSignals2Slots();
604 void TGeoGtraEditor::DoApply()
606 const char *name = fShapeName->GetText();
607 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
608 Double_t sc1 = fESc1->GetNumber();
609 Double_t sc2 = fESc2->GetNumber();
610 Double_t h1 = sc1*fEH1->GetNumber();
611 Double_t bl1 = sc1*fEBl1->GetNumber();
612 Double_t tl1 = sc1*fETl1->GetNumber();
613 Double_t h2 = sc2*fEH1->GetNumber();
614 Double_t bl2 = sc2*fEBl1->GetNumber();
615 Double_t tl2 = sc2*fETl1->GetNumber();
616 Double_t dz = fEDz->GetNumber();
617 Double_t alpha1 = fEAlpha1->GetNumber();
618 Double_t theta = fETheta->GetNumber();
619 Double_t phi = fEPhi->GetNumber();
620 Double_t twist = fETwist->GetNumber();
634 TGeoGtra *shape = (TGeoGtra*)fShape;
635 shape->SetDimensions(param);
636 shape->ComputeBBox();
638 fApply->SetEnabled(kFALSE);
640 if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
641 TView *view = fPad->GetView();
644 fPad->GetView()->ShowAxis();
646 view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(),
647 fShape->GetDX(), fShape->GetDY(), fShape->GetDZ());
657 void TGeoGtraEditor::DoUndo()
659 fEH1->SetNumber(fH1i);
660 fEBl1->SetNumber(fBl1i);
661 fETl1->SetNumber(fTl1i);
662 fESc1->SetNumber(1.);
663 fESc2->SetNumber(fSci);
664 fEDz->SetNumber(fDzi);
665 fEAlpha1->SetNumber(fAlpha1i);
666 fETheta->SetNumber(fThetai);
667 fEPhi->SetNumber(fPhii);
668 fETwist->SetNumber(fTwisti);
670 fUndo->SetEnabled(kFALSE);
671 fApply->SetEnabled(kFALSE);
677 void TGeoGtraEditor::DoTwist()
679 Double_t twist = fETwist->GetNumber();
680 if (twist<=-180 || twist>=180) {
682 fETwist->SetNumber(twist);
685 if (!IsDelayed()) DoApply();