Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TGeoTubeEditor.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 TGeoTubeEditor
13\ingroup Geometry_builder
14
15Editor for a TGeoTube.
16
17\image html geom_tube_pic.png
18
19\image html geom_tube_ed.png
20
21*/
22
23#include "TGeoTubeEditor.h"
24#include "TGeoTabManager.h"
25#include "TGeoTube.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#include "TGDoubleSlider.h"
36
37
39
40////////////////////////////////////////////////////////////////////////////////
41/// Constructor for tube editor
42
43TGeoTubeEditor::TGeoTubeEditor(const TGWindow *p, Int_t width, Int_t height, UInt_t options, Pixel_t back)
44 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
45{
46 fShape = nullptr;
47 fRmini = fRmaxi = fDzi = 0.0;
48 fNamei = "";
51
52 // TextEntry for shape name
53 MakeTitle("Name");
54 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kTUBE_NAME);
55 fShapeName->Resize(135, fShapeName->GetDefaultHeight());
56 fShapeName->SetToolTipText("Enter the box name");
57 fShapeName->Associate(this);
59
60 TGTextEntry *nef;
61 MakeTitle("Tube dimensions");
62 TGCompositeFrame *compxyz = new TGCompositeFrame(this, 118, 30, kVerticalFrame | kRaisedFrame);
63 // Number entry for rmin
65 f1->AddFrame(new TGLabel(f1, "Rmin"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
66 fERmin = new TGNumberEntry(f1, 0., 5, kTUBE_RMIN);
68 nef = (TGTextEntry *)fERmin->GetNumberEntry();
69 nef->SetToolTipText("Enter the inner radius");
70 fERmin->Associate(this);
71 fERmin->Resize(100, fERmin->GetDefaultHeight());
72 f1->AddFrame(fERmin, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
73 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
74
75 // Number entry for Rmax
76 f1 = new TGCompositeFrame(compxyz, 155, 30, kHorizontalFrame | kFixedWidth);
77 f1->AddFrame(new TGLabel(f1, "Rmax"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
78 fERmax = new TGNumberEntry(f1, 0., 5, kTUBE_RMAX);
80 nef = (TGTextEntry *)fERmax->GetNumberEntry();
81 nef->SetToolTipText("Enter the outer radius");
82 fERmax->Associate(this);
83 fERmax->Resize(100, fERmax->GetDefaultHeight());
84 f1->AddFrame(fERmax, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
85 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
86
87 // Number entry for dz
88 f1 = new TGCompositeFrame(compxyz, 155, 30, kHorizontalFrame | kFixedWidth);
89 f1->AddFrame(new TGLabel(f1, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
90 fEDz = new TGNumberEntry(f1, 0., 5, kTUBE_Z);
92 nef = (TGTextEntry *)fEDz->GetNumberEntry();
93 nef->SetToolTipText("Enter the tube half-lenth in Z");
94 fEDz->Associate(this);
95 fEDz->Resize(100, fEDz->GetDefaultHeight());
96 f1->AddFrame(fEDz, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
97 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
98
99 // compxyz->Resize(150,30);
100 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
101
102 // Delayed draw
104 fDelayed = new TGCheckButton(fDFrame, "Delayed draw");
105 fDFrame->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
106 AddFrame(fDFrame, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
107
108 // Buttons
110 fApply = new TGTextButton(fBFrame, "Apply");
111 fBFrame->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
112 fApply->Associate(this);
113 fUndo = new TGTextButton(fBFrame, "Undo");
114 fBFrame->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
115 fUndo->Associate(this);
116 AddFrame(fBFrame, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
117 fUndo->SetSize(fApply->GetSize());
118}
119
120////////////////////////////////////////////////////////////////////////////////
121/// Destructor
122
124{
125 TGFrameElement *el;
126 TIter next(GetList());
127 while ((el = (TGFrameElement *)next())) {
128 if (el->fFrame->IsComposite())
130 }
131 Cleanup();
132}
133
134////////////////////////////////////////////////////////////////////////////////
135/// Connect signals to slots.
136
138{
139 fApply->Connect("Clicked()", "TGeoTubeEditor", this, "DoApply()");
140 fUndo->Connect("Clicked()", "TGeoTubeEditor", this, "DoUndo()");
141 fShapeName->Connect("TextChanged(const char *)", "TGeoTubeEditor", this, "DoModified()");
142 fERmin->Connect("ValueSet(Long_t)", "TGeoTubeEditor", this, "DoRmin()");
143 fERmax->Connect("ValueSet(Long_t)", "TGeoTubeEditor", this, "DoRmax()");
144 fEDz->Connect("ValueSet(Long_t)", "TGeoTubeEditor", this, "DoDz()");
145 fERmin->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTubeEditor", this, "DoRmin()");
146 fERmax->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTubeEditor", this, "DoRmax()");
147 fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTubeEditor", this, "DoDz()");
148 fInit = kFALSE;
149}
150
151////////////////////////////////////////////////////////////////////////////////
152/// Connect to the selected object.
153
155{
156 if (obj == nullptr || (obj->IsA() != TGeoTube::Class())) {
158 return;
159 }
160 fShape = (TGeoTube *)obj;
161 fRmini = fShape->GetRmin();
162 fRmaxi = fShape->GetRmax();
163 fDzi = fShape->GetDz();
164 fNamei = fShape->GetName();
165 fShapeName->SetText(fShape->GetName());
166 fERmin->SetNumber(fRmini);
167 fERmax->SetNumber(fRmaxi);
168 fEDz->SetNumber(fDzi);
169 fApply->SetEnabled(kFALSE);
170 fUndo->SetEnabled(kFALSE);
171
172 if (fInit)
174 SetActive();
175}
176
177////////////////////////////////////////////////////////////////////////////////
178/// Check if shape drawing is delayed.
179
181{
182 return (fDelayed->GetState() == kButtonDown);
183}
184
185////////////////////////////////////////////////////////////////////////////////
186/// Perform name change.
187
189{
190 DoModified();
191}
192
193////////////////////////////////////////////////////////////////////////////////
194/// Slot for applying modifications.
195
197{
198 const char *name = fShapeName->GetText();
199 if (strcmp(name, fShape->GetName()))
200 fShape->SetName(name);
201 Double_t rmin = fERmin->GetNumber();
202 Double_t rmax = fERmax->GetNumber();
203 Double_t dz = fEDz->GetNumber();
204 fShape->SetTubeDimensions(rmin, rmax, dz);
205 fShape->ComputeBBox();
206 fUndo->SetEnabled();
207 fApply->SetEnabled(kFALSE);
208 if (fPad) {
209 if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
210 fShape->Draw();
211 fPad->GetView()->ShowAxis();
212 } else
213 Update();
214 }
215}
216
217////////////////////////////////////////////////////////////////////////////////
218/// Slot for signaling modifications.
219
221{
222 fApply->SetEnabled();
223}
224
225////////////////////////////////////////////////////////////////////////////////
226/// Slot for undoing last operation.
227
229{
230 fERmin->SetNumber(fRmini);
231 fERmax->SetNumber(fRmaxi);
232 fEDz->SetNumber(fDzi);
233 DoApply();
234 fUndo->SetEnabled(kFALSE);
235 fApply->SetEnabled(kFALSE);
236}
237
238////////////////////////////////////////////////////////////////////////////////
239/// Slot for rmin.
240
242{
243 Double_t rmin = fERmin->GetNumber();
244 Double_t rmax = fERmax->GetNumber();
245 if (rmax < rmin + 1.e-10) {
246 rmin = rmax - 0.1;
247 fERmin->SetNumber(rmin);
248 }
249 DoModified();
250 if (!IsDelayed())
251 DoApply();
252}
253
254////////////////////////////////////////////////////////////////////////////////
255/// Slot for rmax.
256
258{
259 Double_t rmin = fERmin->GetNumber();
260 Double_t rmax = fERmax->GetNumber();
261 if (rmax <= 0.) {
262 rmax = 0.1;
263 fERmax->SetNumber(rmax);
264 }
265 if (rmax < rmin + 1.e-10) {
266 rmax = rmin + 0.1;
267 fERmax->SetNumber(rmax);
268 }
269 DoModified();
270 if (!IsDelayed())
271 DoApply();
272}
273
274////////////////////////////////////////////////////////////////////////////////
275/// Slot for dz.
276
278{
279 Double_t dz = fEDz->GetNumber();
280 if (dz <= 0) {
281 dz = 0.1;
282 fEDz->SetNumber(dz);
283 }
284 DoModified();
285 if (!IsDelayed())
286 DoApply();
287}
288
289/** \class TGeoTubeSegEditor
290\ingroup Geometry_builder
291
292Editor for a TGeoTubeSeg.
293
294\image html geom_tubs_pic.png
295
296\image html geom_tubs_ed.png
297
298*/
299
300
302
303////////////////////////////////////////////////////////////////////////////////
304/// Constructor for tube segment editor
305
307 : TGeoTubeEditor(p, width, height, options | kVerticalFrame, back)
308{
309 fLock = kFALSE;
310 MakeTitle("Phi range");
311 TGTextEntry *nef;
312 TGCompositeFrame *compxyz =
314 // Vertical slider
315 fSPhi = new TGDoubleVSlider(compxyz, 100);
316 fSPhi->SetRange(0., 720.);
317 fSPhi->Resize(fSPhi->GetDefaultWidth(), 100);
318 compxyz->AddFrame(fSPhi, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
320 f1->AddFrame(new TGLabel(f1, "Phi min."), new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 6, 0));
321 fEPhi1 = new TGNumberEntry(f1, 0., 5, kTUBESEG_PHI1);
322 fEPhi1->Resize(100, fEPhi1->GetDefaultHeight());
324 nef = (TGTextEntry *)fEPhi1->GetNumberEntry();
325 nef->SetToolTipText("Enter the phi1 value");
326 fEPhi1->Associate(this);
327 f1->AddFrame(fEPhi1, new TGLayoutHints(kLHintsTop | kLHintsRight, 2, 2, 2, 2));
328
329 fEPhi2 = new TGNumberEntry(f1, 0., 5, kTUBESEG_PHI2);
330 fEPhi2->Resize(100, fEPhi2->GetDefaultHeight());
332 nef = (TGTextEntry *)fEPhi2->GetNumberEntry();
333 nef->SetToolTipText("Enter the phi2 value");
334 fEPhi2->Associate(this);
335 f1->AddFrame(fEPhi2, new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 2, 2));
336 f1->AddFrame(new TGLabel(f1, "Phi max."), new TGLayoutHints(kLHintsBottom, 0, 0, 6, 2));
337 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
338
339 // compxyz->Resize(150,150);
340 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
343}
344
345////////////////////////////////////////////////////////////////////////////////
346/// Destructor
347
349{
350 TGFrameElement *el;
351 TIter next(GetList());
352 while ((el = (TGFrameElement *)next())) {
353 if (el->fFrame->IsComposite())
355 }
356 Cleanup();
357}
358
359////////////////////////////////////////////////////////////////////////////////
360/// Connect signals to slots.
361
363{
365 Disconnect(fApply, "Clicked()", (TGeoTubeEditor *)this, "DoApply()");
366 Disconnect(fUndo, "Clicked()", (TGeoTubeEditor *)this, "DoUndo()");
367 fApply->Connect("Clicked()", "TGeoTubeSegEditor", this, "DoApply()");
368 fUndo->Connect("Clicked()", "TGeoTubeSegEditor", this, "DoUndo()");
369 fEPhi1->Connect("ValueSet(Long_t)", "TGeoTubeSegEditor", this, "DoPhi1()");
370 fEPhi2->Connect("ValueSet(Long_t)", "TGeoTubeSegEditor", this, "DoPhi2()");
371 // fEPhi1->GetNumberEntry()->Connect("TextChanged(const char *)","TGeoTubeSegEditor", this, "DoPhi1()");
372 // fEPhi2->GetNumberEntry()->Connect("TextChanged(const char *)","TGeoTubeSegEditor", this, "DoPhi2()");
373 fSPhi->Connect("PositionChanged()", "TGeoTubeSegEditor", this, "DoPhi()");
374}
375
376////////////////////////////////////////////////////////////////////////////////
377/// Connect to the selected object.
378
380{
381 if (obj == nullptr || (obj->IsA() != TGeoTubeSeg::Class())) {
383 return;
384 }
385 fShape = (TGeoTube *)obj;
386 fRmini = fShape->GetRmin();
387 fRmaxi = fShape->GetRmax();
388 fDzi = fShape->GetDz();
389 fNamei = fShape->GetName();
390 fPmini = ((TGeoTubeSeg *)fShape)->GetPhi1();
391 fPmaxi = ((TGeoTubeSeg *)fShape)->GetPhi2();
392 fShapeName->SetText(fShape->GetName());
393 fEPhi1->SetNumber(fPmini);
394 fEPhi2->SetNumber(fPmaxi);
395 fSPhi->SetPosition(fPmini, fPmaxi);
396 fERmin->SetNumber(fRmini);
397 fERmax->SetNumber(fRmaxi);
398 fEDz->SetNumber(fDzi);
399 fApply->SetEnabled(kFALSE);
400 fUndo->SetEnabled(kFALSE);
401
402 if (fInit)
404 SetActive();
405}
406
407////////////////////////////////////////////////////////////////////////////////
408/// Slot for phi1.
409
411{
412 Double_t phi1 = fEPhi1->GetNumber();
413 Double_t phi2 = fEPhi2->GetNumber();
414 if (phi1 > 360 - 1.e-10) {
415 phi1 = 0.;
416 fEPhi1->SetNumber(phi1);
417 }
418 if (phi2 < phi1 + 1.e-10) {
419 phi1 = phi2 - 0.1;
420 fEPhi1->SetNumber(phi1);
421 }
422 if (!fLock) {
423 DoModified();
424 fLock = kTRUE;
425 fSPhi->SetPosition(phi1, phi2);
426 } else
427 fLock = kFALSE;
428 if (!IsDelayed())
429 DoApply();
430}
431
432////////////////////////////////////////////////////////////////////////////////
433/// Slot for phi2.
434
436{
437 Double_t phi1 = fEPhi1->GetNumber();
438 Double_t phi2 = fEPhi2->GetNumber();
439 if (phi2 - phi1 > 360.) {
440 phi2 -= 360.;
441 fEPhi2->SetNumber(phi2);
442 }
443 if (phi2 < phi1 + 1.e-10) {
444 phi2 = phi1 + 0.1;
445 fEPhi2->SetNumber(phi2);
446 }
447 if (!fLock) {
448 DoModified();
449 fLock = kTRUE;
450 fSPhi->SetPosition(phi1, phi2);
451 } else
452 fLock = kFALSE;
453 if (!IsDelayed())
454 DoApply();
455}
456
457////////////////////////////////////////////////////////////////////////////////
458/// Slot for phi slider.
459
461{
462 if (!fLock) {
463 DoModified();
464 fLock = kTRUE;
465 fEPhi1->SetNumber(fSPhi->GetMinPosition());
466 fLock = kTRUE;
467 fEPhi2->SetNumber(fSPhi->GetMaxPosition());
468 } else
469 fLock = kFALSE;
470 if (!IsDelayed())
471 DoApply();
472}
473
474////////////////////////////////////////////////////////////////////////////////
475/// Slot for applying modifications.
476
478{
479 fApply->SetEnabled(kFALSE);
480 const char *name = fShapeName->GetText();
481 if (strcmp(name, fShape->GetName()))
482 fShape->SetName(name);
483 Double_t rmin = fERmin->GetNumber();
484 Double_t rmax = fERmax->GetNumber();
485 if (rmin < 0 || rmax < rmin)
486 return;
487 Double_t dz = fEDz->GetNumber();
488 Double_t phi1 = fEPhi1->GetNumber();
489 Double_t phi2 = fEPhi2->GetNumber();
490 if ((phi2 - phi1) > 360.001) {
491 phi1 = 0.;
492 phi2 = 360.;
493 fEPhi1->SetNumber(phi1);
494 fEPhi2->SetNumber(phi2);
495 fLock = kTRUE;
496 fSPhi->SetPosition(phi1, phi2);
497 fLock = kFALSE;
498 }
499 ((TGeoTubeSeg *)fShape)->SetTubsDimensions(rmin, rmax, dz, phi1, phi2);
500 fShape->ComputeBBox();
501 fUndo->SetEnabled();
502 if (fPad) {
503 if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
504 fShape->Draw();
505 fPad->GetView()->ShowAxis();
506 } else
507 Update();
508 }
509}
510
511////////////////////////////////////////////////////////////////////////////////
512/// Slot for undoing last operation.
513
515{
516 fERmin->SetNumber(fRmini);
517 fERmax->SetNumber(fRmaxi);
518 fEDz->SetNumber(fDzi);
519 fEPhi1->SetNumber(fPmini);
520 fEPhi2->SetNumber(fPmaxi);
521 fSPhi->SetPosition(fPmini, fPmaxi);
522 DoApply();
523 fUndo->SetEnabled(kFALSE);
524 fApply->SetEnabled(kFALSE);
525}
526
527/** \class TGeoCtubEditor
528\ingroup Geometry_builder
529
530Editor for a TGeoCtub.
531
532\image html geom_ctub_pic.png
533
534\image html geom_ctub_ed.png
535
536*/
537
538
540
541////////////////////////////////////////////////////////////////////////////////
542/// Constructor for cut tube editor
543
544TGeoCtubEditor::TGeoCtubEditor(const TGWindow *p, Int_t width, Int_t height, UInt_t options, Pixel_t back)
545 : TGeoTubeSegEditor(p, width, height, options, back)
546{
547 MakeTitle("Theta/phi low");
548 TGTextEntry *nef;
549 // Number entry for theta/phi of the lower normal
550 TGCompositeFrame *compxyz = new TGCompositeFrame(this, 118, 30, kVerticalFrame | kRaisedFrame);
552 f1->AddFrame(new TGLabel(f1, "TH_LO"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
553 fEThlo = new TGNumberEntry(f1, 0., 5, kCTUB_THLO);
555 nef = (TGTextEntry *)fEThlo->GetNumberEntry();
556 nef->SetToolTipText("Enter the theta angle of the lower plane normal");
557 fEThlo->Associate(this);
558 fEThlo->Connect("ValueSet(Long_t)", "TGeoCtubEditor", this, "DoThlo()");
559 nef->Connect("TextChanged(const char *)", "TGeoCtubEditor", this, "DoModified()");
560 fEThlo->Resize(100, fEThlo->GetDefaultHeight());
561 f1->AddFrame(fEThlo, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
562 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
563
564 f1 = new TGCompositeFrame(compxyz, 155, 30, kHorizontalFrame | kFixedWidth);
565 f1->AddFrame(new TGLabel(f1, "PH_LO"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
566 fEPhlo = new TGNumberEntry(f1, 0., 5, kCTUB_PHLO);
568 nef = (TGTextEntry *)fEPhlo->GetNumberEntry();
569 nef->SetToolTipText("Enter the phi angle of the lower plane normal");
570 fEPhlo->Associate(this);
571 fEPhlo->Connect("ValueSet(Long_t)", "TGeoCtubEditor", this, "DoPhlo()");
572 nef->Connect("TextChanged(const char *)", "TGeoCtubEditor", this, "DoModified()");
573 fEPhlo->Resize(100, fEPhlo->GetDefaultHeight());
574 f1->AddFrame(fEPhlo, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
575 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
576 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
577
578 // Number entry for theta/phi of the lower normal
579 MakeTitle("Theta/phi high");
580 compxyz = new TGCompositeFrame(this, 118, 30, kVerticalFrame | kRaisedFrame);
581 f1 = new TGCompositeFrame(compxyz, 155, 30, kHorizontalFrame | kFixedWidth);
582 f1->AddFrame(new TGLabel(f1, "TH_HI"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
583 fEThhi = new TGNumberEntry(f1, 0., 5, kCTUB_THHI);
585 nef = (TGTextEntry *)fEThhi->GetNumberEntry();
586 nef->SetToolTipText("Enter the theta angle of the upper plane normal");
587 fEThhi->Associate(this);
588 fEThhi->Connect("ValueSet(Long_t)", "TGeoCtubEditor", this, "DoThhi()");
589 nef->Connect("TextChanged(const char *)", "TGeoCtubEditor", this, "DoModified()");
590 fEThhi->Resize(100, fEThhi->GetDefaultHeight());
591 f1->AddFrame(fEThhi, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
592 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
593
594 f1 = new TGCompositeFrame(compxyz, 155, 30, kHorizontalFrame | kFixedWidth);
595 f1->AddFrame(new TGLabel(f1, "PH_HI"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
596 fEPhhi = new TGNumberEntry(f1, 0., 5, kCTUB_PHHI);
598 nef = (TGTextEntry *)fEPhhi->GetNumberEntry();
599 nef->SetToolTipText("Enter the phi angle of the upper plane normal");
600 fEPhhi->Associate(this);
601 fEPhhi->Connect("ValueSet(Long_t)", "TGeoCtubEditor", this, "DoPhhi()");
602 nef->Connect("TextChanged(const char *)", "TGeoCtubEditor", this, "DoModified()");
603 fEPhhi->Resize(100, fEPhhi->GetDefaultHeight());
604 f1->AddFrame(fEPhhi, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
605 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
606 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
609}
610
611////////////////////////////////////////////////////////////////////////////////
612/// Destructor
613
615{
616 TGFrameElement *el;
617 TIter next(GetList());
618 while ((el = (TGFrameElement *)next())) {
619 if (el->fFrame->IsComposite())
621 }
622 Cleanup();
623}
624
625////////////////////////////////////////////////////////////////////////////////
626/// Connect to the selected object.
627
629{
630 if (obj == nullptr || (obj->IsA() != TGeoCtub::Class())) {
632 return;
633 }
634 fShape = (TGeoTube *)obj;
635 fRmini = fShape->GetRmin();
636 fRmaxi = fShape->GetRmax();
637 fDzi = fShape->GetDz();
638 fNamei = fShape->GetName();
639 fPmini = ((TGeoTubeSeg *)fShape)->GetPhi1();
640 fPmaxi = ((TGeoTubeSeg *)fShape)->GetPhi2();
641 const Double_t *nlo = ((TGeoCtub *)fShape)->GetNlow();
642 const Double_t *nhi = ((TGeoCtub *)fShape)->GetNhigh();
643 fThlo = TMath::RadToDeg() * TMath::ACos(nlo[2]);
644 fPhlo = TMath::RadToDeg() * TMath::ATan2(nlo[1], nlo[0]);
645 fThhi = TMath::RadToDeg() * TMath::ACos(nhi[2]);
646 fPhhi = TMath::RadToDeg() * TMath::ATan2(nhi[1], nhi[0]);
647
648 fShapeName->SetText(fShape->GetName());
649 fEPhi1->SetNumber(fPmini);
650 fEPhi2->SetNumber(fPmaxi);
651 fSPhi->SetPosition(fPmini, fPmaxi);
652 fERmin->SetNumber(fRmini);
653 fERmax->SetNumber(fRmaxi);
654 fEDz->SetNumber(fDzi);
655 fEThlo->SetNumber(fThlo);
656 fEPhlo->SetNumber(fPhlo);
657 fEThhi->SetNumber(fThhi);
658 fEPhhi->SetNumber(fPhhi);
659 fApply->SetEnabled(kFALSE);
660 fUndo->SetEnabled(kFALSE);
661
662 if (fInit)
664 SetActive();
665}
666
667////////////////////////////////////////////////////////////////////////////////
668/// Slot for phi1.
669
671{
672 Double_t thlo = fEThlo->GetNumber();
673 if (thlo <= 90.) {
674 thlo = 91.;
675 fEThlo->SetNumber(thlo);
676 }
677 if (thlo > 180.) {
678 thlo = 180.;
679 fEThlo->SetNumber(thlo);
680 }
681 DoModified();
682 if (!IsDelayed())
683 DoApply();
684}
685
686////////////////////////////////////////////////////////////////////////////////
687/// Slot for phi1.
688
690{
691 Double_t phlo = fEPhlo->GetNumber();
692 if (phlo >= 360.) {
693 phlo = 0.;
694 fEPhlo->SetNumber(phlo);
695 }
696 DoModified();
697 if (!IsDelayed())
698 DoApply();
699}
700
701////////////////////////////////////////////////////////////////////////////////
702/// Slot for phi1.
703
705{
706 Double_t thhi = fEThhi->GetNumber();
707 if (thhi >= 90.) {
708 thhi = 89.;
709 fEThhi->SetNumber(thhi);
710 }
711 DoModified();
712 if (!IsDelayed())
713 DoApply();
714}
715
716////////////////////////////////////////////////////////////////////////////////
717/// Slot for phi1.
718
720{
721 Double_t phhi = fEPhhi->GetNumber();
722 if (phhi >= 360.) {
723 phhi = 0.;
724 fEPhhi->SetNumber(phhi);
725 }
726 DoModified();
727 if (!IsDelayed())
728 DoApply();
729}
730
731////////////////////////////////////////////////////////////////////////////////
732/// Slot for applying modifications.
733
735{
736 fApply->SetEnabled(kFALSE);
737 const char *name = fShapeName->GetText();
738 if (strcmp(name, fShape->GetName()))
739 fShape->SetName(name);
740 Double_t rmin = fERmin->GetNumber();
741 Double_t rmax = fERmax->GetNumber();
742 if (rmin < 0 || rmax < rmin)
743 return;
744 Double_t dz = fEDz->GetNumber();
745 Double_t phi1 = fEPhi1->GetNumber();
746 Double_t phi2 = fEPhi2->GetNumber();
747 if ((phi2 - phi1) > 360.001) {
748 phi1 = 0.;
749 phi2 = 360.;
750 fEPhi1->SetNumber(phi1);
751 fEPhi2->SetNumber(phi2);
752 fLock = kTRUE;
753 fSPhi->SetPosition(phi1, phi2);
754 fLock = kFALSE;
755 }
756 Double_t thlo = TMath::DegToRad() * fEThlo->GetNumber();
757 Double_t phlo = TMath::DegToRad() * fEPhlo->GetNumber();
758 Double_t thhi = TMath::DegToRad() * fEThhi->GetNumber();
759 Double_t phhi = TMath::DegToRad() * fEPhhi->GetNumber();
760 Double_t lx = TMath::Sin(thlo) * TMath::Cos(phlo);
761 Double_t ly = TMath::Sin(thlo) * TMath::Sin(phlo);
762 Double_t lz = TMath::Cos(thlo);
763 Double_t tx = TMath::Sin(thhi) * TMath::Cos(phhi);
764 Double_t ty = TMath::Sin(thhi) * TMath::Sin(phhi);
765 Double_t tz = TMath::Cos(thhi);
766 ((TGeoCtub *)fShape)->SetCtubDimensions(rmin, rmax, dz, phi1, phi2, lx, ly, lz, tx, ty, tz);
767 fShape->ComputeBBox();
768 fUndo->SetEnabled();
769 if (fPad) {
770 if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
771 fShape->Draw();
772 fPad->GetView()->ShowAxis();
773 } else
774 Update();
775 }
776}
777
778////////////////////////////////////////////////////////////////////////////////
779/// Slot for undoing last operation.
780
782{
783 fERmin->SetNumber(fRmini);
784 fERmax->SetNumber(fRmaxi);
785 fEDz->SetNumber(fDzi);
786 fEPhi1->SetNumber(fPmini);
787 fEPhi2->SetNumber(fPmaxi);
788 fSPhi->SetPosition(fPmini, fPmaxi);
789 fEThlo->SetNumber(fThlo);
790 fEPhlo->SetNumber(fPhlo);
791 fEThhi->SetNumber(fThhi);
792 fEPhhi->SetNumber(fPhhi);
793
794 DoApply();
795 fUndo->SetEnabled(kFALSE);
796 fApply->SetEnabled(kFALSE);
797}
@ kRaisedFrame
Definition GuiTypes.h:385
@ kSunkenFrame
Definition GuiTypes.h:384
@ kVerticalFrame
Definition GuiTypes.h:382
@ kFixedWidth
Definition GuiTypes.h:388
@ kHorizontalFrame
Definition GuiTypes.h:383
@ kFixedHeight
Definition GuiTypes.h:390
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
@ kLHintsBottom
Definition TGLayout.h:29
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
char name[80]
Definition TGX11.cxx:148
externTGeoManager * gGeoManager
ETGeoTubeSegWid
@ kTUBESEG_PHI1
@ kTUBESEG_PHI2
@ kTUBESEG_PHI
ETGeoTubeWid
@ kTUBE_RMAX
@ kTUBE_UNDO
@ kTUBE_NAME
@ kTUBE_APPLY
@ kTUBE_Z
@ kTUBE_RMIN
ETGeoCtubSegWid
@ kCTUB_THLO
@ kCTUB_PHHI
@ kCTUB_PHLO
@ kCTUB_THHI
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
Dragging the slider will generate the event:
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.
@ kNEANonNegative
Non-negative 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 DoUndo() override
Slot for undoing last operation.
TGNumberEntry * fEPhlo
TGNumberEntry * fEPhhi
TGNumberEntry * fEThhi
TGNumberEntry * fEThlo
void DoPhlo()
Slot for phi1.
void DoThhi()
Slot for phi1.
~TGeoCtubEditor() override
Destructor.
TGeoCtubEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for cut tube editor.
void DoApply() override
Slot for applying modifications.
void SetModel(TObject *obj) override
Connect to the selected object.
void DoPhhi()
Slot for phi1.
void DoThlo()
Slot for phi1.
static TClass * Class()
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.
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.
virtual void ConnectSignals2Slots()
Connect signals to slots.
void DoRmax()
Slot for rmax.
void SetModel(TObject *obj) override
Connect to the selected object.
TGTextEntry * fShapeName
void DoRmin()
Slot for rmin.
TGCompositeFrame * fDFrame
~TGeoTubeEditor() override
Destructor.
Bool_t fIsShapeEditable
TGTextButton * fUndo
void DoModified()
Slot for signaling modifications.
TGTextButton * fApply
TGCompositeFrame * fBFrame
TGNumberEntry * fEDz
virtual void DoUndo()
Slot for undoing last operation.
TGNumberEntry * fERmax
TGeoTubeEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for tube editor.
void DoDz()
Slot for dz.
TGCheckButton * fDelayed
void DoName()
Perform name change.
TGNumberEntry * fERmin
Bool_t IsDelayed() const
Check if shape drawing is delayed.
TGeoTube * fShape
virtual void DoApply()
Slot for applying modifications.
void DoApply() override
Slot for applying modifications.
TGeoTubeSegEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for tube segment editor.
TGDoubleVSlider * fSPhi
void DoPhi2()
Slot for phi2.
TGNumberEntry * fEPhi1
void ConnectSignals2Slots() override
Connect signals to slots.
~TGeoTubeSegEditor() override
Destructor.
void DoPhi1()
Slot for phi1.
TGNumberEntry * fEPhi2
void DoPhi()
Slot for phi slider.
void DoUndo() override
Slot for undoing last operation.
void SetModel(TObject *obj) override
Connect to the selected object.
static TClass * Class()
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
Bool_t Disconnect(const char *signal=nullptr, void *receiver=nullptr, const char *slot=nullptr)
Disconnects signal of this object from slot of receiver.
TF1 * f1
Definition legend1.C:11
Double_t ACos(Double_t)
Returns the principal value of the arc cosine of x, expressed in radians.
Definition TMath.h:643
Double_t ATan2(Double_t y, Double_t x)
Returns the principal value of the arc tangent of y/x, expressed in radians.
Definition TMath.h:657
constexpr Double_t DegToRad()
Conversion from degree to radian: .
Definition TMath.h:82
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Definition TMath.h:605
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:599
constexpr Double_t RadToDeg()
Conversion from radian to degree: .
Definition TMath.h:75