Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TGeoTrapEditor.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 TGeoTrapEditor
13\ingroup Geometry_builder
14
15Editor for a TGeoTrap.
16
17\image html geom_trap_pic.png
18
19\image html geom_trap_ed.png
20
21*/
22
23#include "TGeoTrapEditor.h"
24#include "TGeoTabManager.h"
25#include "TGeoArb8.h"
26#include "TGeoManager.h"
27#include "TVirtualGeoPainter.h"
28#include "TVirtualPad.h"
29#include "TView.h"
30#include "TMath.h"
31#include "TGButton.h"
32#include "TGTextEntry.h"
33#include "TGNumberEntry.h"
34#include "TGLabel.h"
35
36
51
52////////////////////////////////////////////////////////////////////////////////
53/// Constructor for para editor
54
55TGeoTrapEditor::TGeoTrapEditor(const TGWindow *p, Int_t width, Int_t height, UInt_t options, Pixel_t back)
56 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
57{
58 fShape = nullptr;
59 fH1i = fBl1i = fTl1i = fDzi = fAlpha1i = fThetai = fPhii = fSci = 0.0;
60 fNamei = "";
63
64 // TextEntry for shape name
65 MakeTitle("Name");
66 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kTRAP_NAME);
67 fShapeName->Resize(135, fShapeName->GetDefaultHeight());
68 fShapeName->SetToolTipText("Enter the parallelepiped name");
69 fShapeName->Associate(this);
71
72 TGTextEntry *nef;
73 MakeTitle("Dimensions");
74 // Number entry for H1
76 f1->AddFrame(new TGLabel(f1, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
77 fEH1 = new TGNumberEntry(f1, 0., 5, kTRAP_H1);
79 fEH1->Resize(100, fEH1->GetDefaultHeight());
80 nef = (TGTextEntry *)fEH1->GetNumberEntry();
81 nef->SetToolTipText("Enter the half length in y at low z");
82 fEH1->Associate(this);
83 f1->AddFrame(fEH1, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
84 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
85
86 // Number entry for Bl1
87 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
88 f1->AddFrame(new TGLabel(f1, "DX1"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
89 fEBl1 = new TGNumberEntry(f1, 0., 5, kTRAP_BL1);
91 fEBl1->Resize(100, fEBl1->GetDefaultHeight());
92 nef = (TGTextEntry *)fEBl1->GetNumberEntry();
93 nef->SetToolTipText("Enter the half length in x at low z and y low edge");
94 fEBl1->Associate(this);
95 f1->AddFrame(fEBl1, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
96 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
97
98 // Number entry for Tl1
99 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
100 f1->AddFrame(new TGLabel(f1, "DX2"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
101 fETl1 = new TGNumberEntry(f1, 0., 5, kTRAP_TL1);
103 fETl1->Resize(100, fETl1->GetDefaultHeight());
104 nef = (TGTextEntry *)fETl1->GetNumberEntry();
105 nef->SetToolTipText("Enter the half length in x at low z and y high edge");
106 fETl1->Associate(this);
107 f1->AddFrame(fETl1, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
108 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
109
110 // Number entry for scale factor
111 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
112 f1->AddFrame(new TGLabel(f1, "SC1"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
113 fESc1 = new TGNumberEntry(f1, 0., 5, kTRAP_SC1);
115 fESc1->Resize(100, fESc1->GetDefaultHeight());
116 nef = (TGTextEntry *)fESc1->GetNumberEntry();
117 nef->SetToolTipText("Enter the scale factor for lower Z face");
118 fESc1->Associate(this);
119 f1->AddFrame(fESc1, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
120 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
121
122 // Number entry for scale factor
123 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
124 f1->AddFrame(new TGLabel(f1, "SC2"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
125 fESc2 = new TGNumberEntry(f1, 0., 5, kTRAP_SC2);
127 fESc2->Resize(100, fESc2->GetDefaultHeight());
128 nef = (TGTextEntry *)fESc2->GetNumberEntry();
129 nef->SetToolTipText("Enter the scale factor for upper Z face");
130 fESc2->Associate(this);
131 f1->AddFrame(fESc2, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
132 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
133
134 // Number entry for dz
135 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
136 f1->AddFrame(new TGLabel(f1, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
137 fEDz = new TGNumberEntry(f1, 0., 5, kTRAP_DZ);
139 fEDz->Resize(100, fEDz->GetDefaultHeight());
140 nef = (TGTextEntry *)fEDz->GetNumberEntry();
141 nef->SetToolTipText("Enter the half-length in Z");
142 fEDz->Associate(this);
143 f1->AddFrame(fEDz, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
144 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
145
146 // Number entry for Alpha1
147 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
148 f1->AddFrame(new TGLabel(f1, "ALPHA"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
149 fEAlpha1 = new TGNumberEntry(f1, 0., 5, kTRAP_ALPHA1);
150 fEAlpha1->Resize(100, fEAlpha1->GetDefaultHeight());
151 nef = (TGTextEntry *)fEAlpha1->GetNumberEntry();
152 nef->SetToolTipText("Enter angle between centers of x edges an y axis at low z");
153 fEAlpha1->Associate(this);
154 f1->AddFrame(fEAlpha1, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
155 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
156
157 // Number entry for Theta
158 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
159 f1->AddFrame(new TGLabel(f1, "Theta"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
160 fETheta = new TGNumberEntry(f1, 0., 5, kTRAP_THETA);
162 fETheta->Resize(100, fETheta->GetDefaultHeight());
163 nef = (TGTextEntry *)fETheta->GetNumberEntry();
164 nef->SetToolTipText("Enter initial theta");
165 fETheta->Associate(this);
166 f1->AddFrame(fETheta, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
167 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
168
169 // Number entry for Phi
170 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
171 f1->AddFrame(new TGLabel(f1, "Phi"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
172 fEPhi = new TGNumberEntry(f1, 0., 5, kTRAP_PHI);
174 fEPhi->Resize(100, fEPhi->GetDefaultHeight());
175 nef = (TGTextEntry *)fEPhi->GetNumberEntry();
176 nef->SetToolTipText("Enter initial phi");
177 fEPhi->Associate(this);
178 f1->AddFrame(fEPhi, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
179 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
180
181 // Delayed draw
183 fDelayed = new TGCheckButton(fDFrame, "Delayed draw");
184 fDFrame->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
185 AddFrame(fDFrame, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
186
187 // Buttons
189 fApply = new TGTextButton(fBFrame, "Apply");
190 fBFrame->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
191 fApply->Associate(this);
192 fUndo = new TGTextButton(fBFrame, "Undo");
193 fBFrame->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
194 fUndo->Associate(this);
195 AddFrame(fBFrame, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
196 fUndo->SetSize(fApply->GetSize());
197}
198
199////////////////////////////////////////////////////////////////////////////////
200/// Destructor
201
203{
204 TGFrameElement *el;
205 TIter next(GetList());
206 while ((el = (TGFrameElement *)next())) {
207 if (el->fFrame->IsComposite())
209 }
210 Cleanup();
211}
212
213////////////////////////////////////////////////////////////////////////////////
214/// Connect signals to slots.
215
217{
218 fApply->Connect("Clicked()", "TGeoTrapEditor", this, "DoApply()");
219 fUndo->Connect("Clicked()", "TGeoTrapEditor", this, "DoUndo()");
220 fShapeName->Connect("TextChanged(const char *)", "TGeoTrapEditor", this, "DoModified()");
221 fEH1->Connect("ValueSet(Long_t)", "TGeoTrapEditor", this, "DoH1()");
222 fEBl1->Connect("ValueSet(Long_t)", "TGeoTrapEditor", this, "DoBl1()");
223 fETl1->Connect("ValueSet(Long_t)", "TGeoTrapEditor", this, "DoTl1()");
224 fEDz->Connect("ValueSet(Long_t)", "TGeoTrapEditor", this, "DoDz()");
225 fESc1->Connect("ValueSet(Long_t)", "TGeoTrapEditor", this, "DoSc1()");
226 fESc2->Connect("ValueSet(Long_t)", "TGeoTrapEditor", this, "DoSc2()");
227 fEAlpha1->Connect("ValueSet(Long_t)", "TGeoTrapEditor", this, "DoAlpha1()");
228 fETheta->Connect("ValueSet(Long_t)", "TGeoTrapEditor", this, "DoTheta()");
229 fEPhi->Connect("ValueSet(Long_t)", "TGeoTrapEditor", this, "DoPhi()");
230 fEH1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrapEditor", this, "DoModified()");
231 fEBl1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrapEditor", this, "DoModified()");
232 fETl1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrapEditor", this, "DoModified()");
233 fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrapEditor", this, "DoModified()");
234 fESc1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrapEditor", this, "DoModified()");
235 fESc2->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrapEditor", this, "DoModified()");
236 fEAlpha1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrapEditor", this, "DoModified()");
237 fETheta->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrapEditor", this, "DoModified()");
238 fEPhi->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrapEditor", this, "DoModified()");
239 fInit = kFALSE;
240}
241
242////////////////////////////////////////////////////////////////////////////////
243/// Connect to the selected object.
244
246{
247 if (obj == nullptr || (obj->IsA() != TGeoTrap::Class())) {
249 return;
250 }
251 fShape = (TGeoTrap *)obj;
252 fH1i = fShape->GetH1();
253 fBl1i = fShape->GetBl1();
254 fTl1i = fShape->GetTl1();
255 fDzi = fShape->GetDz();
256 Double_t h2i = fShape->GetH2();
257 // Double_t bl2i = fShape->GetBl2();
258 // Double_t tl2i = fShape->GetTl2();
259 fSci = h2i / fH1i;
260 fAlpha1i = fShape->GetAlpha1();
261 fThetai = fShape->GetTheta();
262 fPhii = fShape->GetPhi();
263 const char *sname = fShape->GetName();
264 if (!strcmp(sname, fShape->ClassName()))
265 fShapeName->SetText("-no_name");
266 else {
267 fShapeName->SetText(sname);
268 fNamei = sname;
269 }
270 fEH1->SetNumber(fH1i);
271 fEBl1->SetNumber(fBl1i);
272 fETl1->SetNumber(fTl1i);
273 fEDz->SetNumber(fDzi);
274 fESc1->SetNumber(1.);
275 fESc2->SetNumber(fSci);
276 fEAlpha1->SetNumber(fAlpha1i);
277 fETheta->SetNumber(fThetai);
278 fEPhi->SetNumber(fPhii);
279 fApply->SetEnabled(kFALSE);
280 fUndo->SetEnabled(kFALSE);
281
282 if (fInit)
284 SetActive();
285}
286
287////////////////////////////////////////////////////////////////////////////////
288/// Check if shape drawing is delayed.
289
291{
292 return (fDelayed->GetState() == kButtonDown);
293}
294
295////////////////////////////////////////////////////////////////////////////////
296/// Slot for name.
297
299{
300 DoModified();
301}
302
303////////////////////////////////////////////////////////////////////////////////
304/// Slot for applying current settings.
305
307{
308 const char *name = fShapeName->GetText();
309 if (strcmp(name, fShape->GetName()))
310 fShape->SetName(name);
311 Double_t sc1 = fESc1->GetNumber();
312 Double_t sc2 = fESc2->GetNumber();
313 Double_t h1 = sc1 * fEH1->GetNumber();
314 Double_t bl1 = sc1 * fEBl1->GetNumber();
315 Double_t tl1 = sc1 * fETl1->GetNumber();
316 Double_t h2 = sc2 * fEH1->GetNumber();
317 Double_t bl2 = sc2 * fEBl1->GetNumber();
318 Double_t tl2 = sc2 * fETl1->GetNumber();
319 Double_t dz = fEDz->GetNumber();
320 Double_t alpha1 = fEAlpha1->GetNumber();
321 Double_t theta = fETheta->GetNumber();
322 Double_t phi = fEPhi->GetNumber();
323 Double_t param[11];
324 param[0] = dz;
325 param[1] = theta;
326 param[2] = phi;
327 param[3] = h1;
328 param[7] = h2;
329 param[4] = bl1;
330 param[8] = bl2;
331 param[5] = tl1;
332 param[9] = tl2;
333 param[6] = alpha1;
334 param[10] = alpha1;
335 fShape->SetDimensions(param);
336 fShape->ComputeBBox();
337 fUndo->SetEnabled();
338 fApply->SetEnabled(kFALSE);
339 if (fPad) {
340 if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
341 TView *view = fPad->GetView();
342 if (!view) {
343 fShape->Draw();
344 fPad->GetView()->ShowAxis();
345 } else {
346 view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(), fShape->GetDX(), fShape->GetDY(),
347 fShape->GetDZ());
348 Update();
349 }
350 } else
351 Update();
352 }
353}
354
355////////////////////////////////////////////////////////////////////////////////
356/// Slot for notifying modifications.
357
359{
360 fApply->SetEnabled();
361}
362
363////////////////////////////////////////////////////////////////////////////////
364/// Slot for undoing last operation.
365
367{
368 fEH1->SetNumber(fH1i);
369 fEBl1->SetNumber(fBl1i);
370 fETl1->SetNumber(fTl1i);
371 fESc1->SetNumber(1.);
372 fESc2->SetNumber(fSci);
373 fEDz->SetNumber(fDzi);
374 fEAlpha1->SetNumber(fAlpha1i);
375 fETheta->SetNumber(fThetai);
376 fEPhi->SetNumber(fPhii);
377 DoApply();
378 fUndo->SetEnabled(kFALSE);
379 fApply->SetEnabled(kFALSE);
380}
381
382////////////////////////////////////////////////////////////////////////////////
383/// Slot for H1.
384
386{
387 Double_t h1 = fEH1->GetNumber();
388 if (h1 <= 0) {
389 h1 = 0.1;
390 fEH1->SetNumber(h1);
391 }
392 DoModified();
393 if (!IsDelayed())
394 DoApply();
395}
396
397////////////////////////////////////////////////////////////////////////////////
398/// Slot for Bl1.
399
401{
402 Double_t bl1 = fEBl1->GetNumber();
403 if (bl1 <= 0) {
404 bl1 = 0.1;
405 fEBl1->SetNumber(bl1);
406 }
407 DoModified();
408 if (!IsDelayed())
409 DoApply();
410}
411
412////////////////////////////////////////////////////////////////////////////////
413/// Slot for Tl1.
414
416{
417 Double_t tl1 = fETl1->GetNumber();
418 if (tl1 <= 0) {
419 tl1 = 0.1;
420 fETl1->SetNumber(tl1);
421 }
422 DoModified();
423 if (!IsDelayed())
424 DoApply();
425}
426
427////////////////////////////////////////////////////////////////////////////////
428/// Slot for Z.
429
431{
432 Double_t dz = fEDz->GetNumber();
433 if (dz <= 0) {
434 dz = 0.1;
435 fEDz->SetNumber(dz);
436 }
437 DoModified();
438 if (!IsDelayed())
439 DoApply();
440}
441
442////////////////////////////////////////////////////////////////////////////////
443/// Slot for H2.
444
446{
447 Double_t sc1 = fESc1->GetNumber();
448 if (sc1 <= 0) {
449 sc1 = 0.1;
450 fESc1->SetNumber(sc1);
451 }
452 DoModified();
453 if (!IsDelayed())
454 DoApply();
455}
456
457////////////////////////////////////////////////////////////////////////////////
458/// Slot for H2.
459
461{
462 Double_t sc2 = fESc2->GetNumber();
463 if (sc2 <= 0) {
464 sc2 = 0.1;
465 fESc2->SetNumber(sc2);
466 }
467 DoModified();
468 if (!IsDelayed())
469 DoApply();
470}
471
472////////////////////////////////////////////////////////////////////////////////
473/// Slot for alpha1.
474
476{
477 Double_t alpha1 = fEAlpha1->GetNumber();
478 if (TMath::Abs(alpha1) >= 90) {
479 alpha1 = 89.9 * TMath::Sign(1., alpha1);
480 fEAlpha1->SetNumber(alpha1);
481 }
482 DoModified();
483 if (!IsDelayed())
484 DoApply();
485}
486
487////////////////////////////////////////////////////////////////////////////////
488/// Slot for theta.
489
491{
492 Double_t theta = fETheta->GetNumber();
493 if (theta < 0) {
494 theta = 0;
495 fETheta->SetNumber(theta);
496 }
497 if (theta > 180) {
498 theta = 180;
499 fETheta->SetNumber(theta);
500 }
501 DoModified();
502 if (!IsDelayed())
503 DoApply();
504}
505
506////////////////////////////////////////////////////////////////////////////////
507/// Slot for phi.
508
510{
511 Double_t phi = fEPhi->GetNumber();
512 if (phi < 0 || phi > 360) {
513 phi = 0;
514 fEPhi->SetNumber(phi);
515 }
516 DoModified();
517 if (!IsDelayed())
518 DoApply();
519}
520
521
523
524/** \class TGeoGtraEditor
525\ingroup Geometry_builder
526
527Editor for a TGeoGtra.
528
529\image html geom_gtra_pic.png
530
531\image html geom_gtra_ed.png
532
533*/
534
535////////////////////////////////////////////////////////////////////////////////
536/// Constructor for gtra editor
537
538TGeoGtraEditor::TGeoGtraEditor(const TGWindow *p, Int_t width, Int_t height, UInt_t options, Pixel_t back)
539 : TGeoTrapEditor(p, width, height, options, back)
540{
541 fTwisti = 0;
542 TGTextEntry *nef;
543 // Number entry for Twist angle
545 f1->AddFrame(new TGLabel(f1, "TWIST"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
546 fETwist = new TGNumberEntry(f1, 0., 5, kGTRA_TWIST);
547 fETwist->Resize(100, fETwist->GetDefaultHeight());
548 nef = (TGTextEntry *)fETwist->GetNumberEntry();
549 nef->SetToolTipText("Enter twist angle");
550 fETwist->Associate(this);
551 f1->AddFrame(fETwist, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
552 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
555 fETwist->Connect("ValueSet(Long_t)", "TGeoGtraEditor", this, "DoTwist()");
556 nef->Connect("TextChanged(const char *)", "TGeoGtraEditor", this, "DoModified()");
557}
558////////////////////////////////////////////////////////////////////////////////
559/// Destructor
560
562{
563 TGFrameElement *el;
564 TIter next(GetList());
565 while ((el = (TGFrameElement *)next())) {
566 if (el->fFrame->IsComposite())
568 }
569 Cleanup();
570}
571
572////////////////////////////////////////////////////////////////////////////////
573/// Connect to a given twisted trapezoid.
574
576{
577 if (obj == nullptr || (obj->IsA() != TGeoGtra::Class())) {
579 return;
580 }
581 fShape = (TGeoTrap *)obj;
582 fH1i = fShape->GetH1();
583 fBl1i = fShape->GetBl1();
584 fTl1i = fShape->GetTl1();
585 fDzi = fShape->GetDz();
586 Double_t h2i = fShape->GetH2();
587 // Double_t bl2i = fShape->GetBl2();
588 // Double_t tl2i = fShape->GetTl2();
589 fSci = h2i / fH1i;
590 fAlpha1i = fShape->GetAlpha1();
591 fThetai = fShape->GetTheta();
592 fPhii = fShape->GetPhi();
593 fTwisti = ((TGeoGtra *)fShape)->GetTwistAngle();
594 const char *sname = fShape->GetName();
595 if (!strcmp(sname, fShape->ClassName()))
596 fShapeName->SetText("-no_name");
597 else {
598 fShapeName->SetText(sname);
599 fNamei = sname;
600 }
601 fEH1->SetNumber(fH1i);
602 fEBl1->SetNumber(fBl1i);
603 fETl1->SetNumber(fTl1i);
604 fEDz->SetNumber(fDzi);
605 fESc1->SetNumber(1.);
606 fESc2->SetNumber(fSci);
607 fEAlpha1->SetNumber(fAlpha1i);
608 fETheta->SetNumber(fThetai);
609 fEPhi->SetNumber(fPhii);
610 fETwist->SetNumber(fTwisti);
611 fApply->SetEnabled(kFALSE);
612 fUndo->SetEnabled(kFALSE);
613
614 if (fInit)
616 SetActive();
617}
618
619////////////////////////////////////////////////////////////////////////////////
620/// Slot for applying current settings.
621
623{
624 const char *name = fShapeName->GetText();
625 if (strcmp(name, fShape->GetName()))
626 fShape->SetName(name);
627 Double_t sc1 = fESc1->GetNumber();
628 Double_t sc2 = fESc2->GetNumber();
629 Double_t h1 = sc1 * fEH1->GetNumber();
630 Double_t bl1 = sc1 * fEBl1->GetNumber();
631 Double_t tl1 = sc1 * fETl1->GetNumber();
632 Double_t h2 = sc2 * fEH1->GetNumber();
633 Double_t bl2 = sc2 * fEBl1->GetNumber();
634 Double_t tl2 = sc2 * fETl1->GetNumber();
635 Double_t dz = fEDz->GetNumber();
636 Double_t alpha1 = fEAlpha1->GetNumber();
637 Double_t theta = fETheta->GetNumber();
638 Double_t phi = fEPhi->GetNumber();
639 Double_t twist = fETwist->GetNumber();
640 Double_t param[12];
641 param[0] = dz;
642 param[1] = theta;
643 param[2] = phi;
644 param[3] = h1;
645 param[7] = h2;
646 param[4] = bl1;
647 param[8] = bl2;
648 param[5] = tl1;
649 param[9] = tl2;
650 param[6] = alpha1;
651 param[10] = alpha1;
652 param[11] = twist;
653 TGeoGtra *shape = (TGeoGtra *)fShape;
654 shape->SetDimensions(param);
655 shape->ComputeBBox();
656 fUndo->SetEnabled();
657 fApply->SetEnabled(kFALSE);
658 if (fPad) {
659 if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
660 TView *view = fPad->GetView();
661 if (!view) {
662 fShape->Draw();
663 fPad->GetView()->ShowAxis();
664 } else {
665 view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(), fShape->GetDX(), fShape->GetDY(),
666 fShape->GetDZ());
667 Update();
668 }
669 } else
670 Update();
671 }
672}
673
674////////////////////////////////////////////////////////////////////////////////
675/// Slot for undoing last operation.
676
678{
679 fEH1->SetNumber(fH1i);
680 fEBl1->SetNumber(fBl1i);
681 fETl1->SetNumber(fTl1i);
682 fESc1->SetNumber(1.);
683 fESc2->SetNumber(fSci);
684 fEDz->SetNumber(fDzi);
685 fEAlpha1->SetNumber(fAlpha1i);
686 fETheta->SetNumber(fThetai);
687 fEPhi->SetNumber(fPhii);
688 fETwist->SetNumber(fTwisti);
689 DoApply();
690 fUndo->SetEnabled(kFALSE);
691 fApply->SetEnabled(kFALSE);
692}
693
694////////////////////////////////////////////////////////////////////////////////
695/// Change the twist angle.
696
698{
699 Double_t twist = fETwist->GetNumber();
700 if (twist <= -180 || twist >= 180) {
701 twist = 0.;
702 fETwist->SetNumber(twist);
703 }
704 DoModified();
705 if (!IsDelayed())
706 DoApply();
707}
@ kSunkenFrame
Definition GuiTypes.h:384
@ kVerticalFrame
Definition GuiTypes.h:382
@ kFixedWidth
Definition GuiTypes.h:388
@ kHorizontalFrame
Definition GuiTypes.h:383
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
@ kButtonDown
Definition TGButton.h:54
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsLeft
Definition TGLayout.h:24
char name[80]
Definition TGX11.cxx:148
externTGeoManager * gGeoManager
ETGeoGtraWid
@ kGTRA_TWIST
ETGeoTrapWid
@ kTRAP_SC1
@ kTRAP_APPLY
@ kTRAP_ALPHA1
@ kTRAP_SC2
@ kTRAP_UNDO
@ kTRAP_H1
@ kTRAP_DZ
@ kTRAP_NAME
@ kTRAP_THETA
@ kTRAP_PHI
@ kTRAP_BL1
@ kTRAP_TL1
Selects different options.
Definition TGButton.h:264
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
virtual TList * GetList() const
Definition TGFrame.h:312
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:959
TGCompositeFrame(const TGCompositeFrame &)=delete
TGFrame * fFrame
Definition TGLayout.h:112
virtual Bool_t IsComposite() const
Definition TGFrame.h:214
This class handles GUI labels.
Definition TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
TGNumberEntry is a number entry input widget with up/down buttons.
@ kNEAPositive
Positive number.
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
Yield an action as soon as it is clicked.
Definition TGButton.h:142
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
ROOT GUI Window base class.
Definition TGWindow.h:23
Bool_t fInit
init flag for setting signals/slots
Definition TGedFrame.h:47
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition TGedFrame.cxx:94
void ComputeBBox() override
void Update() override
Override Update from TGedFrame as fGedEditor can be null.
TVirtualPad * fPad
TGeoGedFrame(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor.
virtual void SetActive(Bool_t active=kTRUE)
Set active GUI attribute frames related to the selected object.
TGNumberEntry * fETwist
~TGeoGtraEditor() override
Destructor.
void SetModel(TObject *obj) override
Connect to a given twisted trapezoid.
void DoUndo() override
Slot for undoing last operation.
void DoApply() override
Slot for applying current settings.
TGeoGtraEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for gtra editor.
void DoTwist()
Change the twist angle.
void SetDimensions(Double_t *param) override
static TClass * Class()
static void MoveFrame(TGCompositeFrame *fr, TGCompositeFrame *p)
Move frame fr at the end of the list of parent p.
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hierarchically all daughters of a composite frame.
TGTextButton * fApply
TGNumberEntry * fEPhi
TGCompositeFrame * fDFrame
TGNumberEntry * fEBl1
void DoTl1()
Slot for Tl1.
void DoSc2()
Slot for H2.
void DoH1()
Slot for H1.
TGCheckButton * fDelayed
TGNumberEntry * fETl1
TGNumberEntry * fEDz
TGeoTrapEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for para editor.
void SetModel(TObject *obj) override
Connect to the selected object.
Bool_t fIsShapeEditable
virtual void DoUndo()
Slot for undoing last operation.
~TGeoTrapEditor() override
Destructor.
TGTextEntry * fShapeName
TGNumberEntry * fEH1
void DoPhi()
Slot for phi.
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGNumberEntry * fETheta
void DoName()
Slot for name.
void DoSc1()
Slot for H2.
TGCompositeFrame * fBFrame
void DoAlpha1()
Slot for alpha1.
TGNumberEntry * fESc2
void DoBl1()
Slot for Bl1.
virtual void DoApply()
Slot for applying current settings.
TGNumberEntry * fESc1
void DoDz()
Slot for Z.
void DoTheta()
Slot for theta.
void DoModified()
Slot for notifying modifications.
TGeoTrap * fShape
Bool_t IsDelayed() const
Check if shape drawing is delayed.
TGTextButton * fUndo
TGNumberEntry * fEAlpha1
static TClass * Class()
Mother of all ROOT objects.
Definition TObject.h:42
virtual TClass * IsA() const
Definition TObject.h:248
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition TQObject.cxx:865
See TView3D.
Definition TView.h:25
virtual void SetRange(const Double_t *min, const Double_t *max)=0
TH1F * h1
Definition legend1.C:5
TF1 * f1
Definition legend1.C:11
T1 Sign(T1 a, T2 b)
Returns a value with the magnitude of a and the sign of b.
Definition TMathBase.h:174
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:122