Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGeoMatrixEditor.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 TGeoTranslationEditor
13\ingroup Geometry_builder
14
15Editor for a TGeoTranslation.
16
17*/
18
19#include "TGeoMatrixEditor.h"
20#include "TGeoTabManager.h"
21#include "TGeoMatrix.h"
22#include "TVirtualPad.h"
23#include "TGButton.h"
24#include "TGButtonGroup.h"
25#include "TGTextEntry.h"
26#include "TGNumberEntry.h"
27#include "TGLabel.h"
28
29
42
43////////////////////////////////////////////////////////////////////////////////
44/// Constructor for translation editor
45
47 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
48{
49 fTranslation = nullptr;
50 fDxi = fDyi = fDzi = 0.0;
51 fNamei = "";
54
55 // TextEntry for name
56 MakeTitle("Name");
57 fTransName = new TGTextEntry(this, new TGTextBuffer(50), kMATRIX_NAME);
59 fTransName->SetToolTipText("Enter the translation name");
60 fTransName->Associate(this);
62
64 MakeTitle("Translations on axes");
66 // Number entry for dx
69 f1->AddFrame(new TGLabel(f1, "DX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
70 fTransDx = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
72 nef->SetToolTipText("Enter the translation on X");
73 fTransDx->Associate(this);
74 f1->AddFrame(fTransDx, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
75 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
76
77 // Number entry for dy
80 f2->AddFrame(new TGLabel(f2, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
81 fTransDy = new TGNumberEntry(f2, 0., 5, kMATRIX_DY);
83 nef->SetToolTipText("Enter the translation on Y");
84 fTransDy->Associate(this);
86 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
87
88 // Number entry for dx
91 f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
92 fTransDz = new TGNumberEntry(f3, 0., 5, kMATRIX_DZ);
94 nef->SetToolTipText("Enter the translation on Z");
95 fTransDz->Associate(this);
97 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
98
99 compxyz->Resize(150, 30);
100 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
101
102 // Buttons
104 fApply = new TGTextButton(f23, "&Apply");
105 f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
106 fApply->Associate(this);
107 fCancel = new TGTextButton(f23, "&Cancel");
108 f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4));
109 fCancel->Associate(this);
110 fUndo = new TGTextButton(f23, " &Undo ");
111 f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
112 fUndo->Associate(this);
113 AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
116}
117
118////////////////////////////////////////////////////////////////////////////////
119/// Destructor.
120
122{
124 TIter next(GetList());
125 while ((el = (TGFrameElement *)next())) {
126 if (el->fFrame->IsComposite())
128 }
129 Cleanup();
130}
131
132////////////////////////////////////////////////////////////////////////////////
133/// Connect signals to slots.
134
136{
137 fApply->Connect("Clicked()", "TGeoTranslationEditor", this, "DoApply()");
138 fCancel->Connect("Clicked()", "TGeoTranslationEditor", this, "DoCancel()");
139 fUndo->Connect("Clicked()", "TGeoTranslationEditor", this, "DoUndo()");
140 fTransName->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoModified()");
141 fTransDx->Connect("ValueSet(Long_t)", "TGeoTranslationEditor", this, "DoDx()");
142 fTransDy->Connect("ValueSet(Long_t)", "TGeoTranslationEditor", this, "DoDy()");
143 fTransDz->Connect("ValueSet(Long_t)", "TGeoTranslationEditor", this, "DoDz()");
144 fTransDx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoDx()");
145 fTransDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoDy()");
146 fTransDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoDz()");
147 fInit = kFALSE;
148}
149
150////////////////////////////////////////////////////////////////////////////////
151/// Connect to the new matrix.
152
154{
155 if (obj == nullptr || (obj->IsA() != TGeoTranslation::Class())) {
157 return;
158 }
163 const char *sname = fTranslation->GetName();
165 fTransName->SetText("no_name");
166 else {
168 fNamei = sname;
169 }
176
177 if (fInit)
179 SetActive();
180}
181
182////////////////////////////////////////////////////////////////////////////////
183/// Slot for name.
184
186{
187 const char *name = fTransName->GetText();
188 if (!strcmp(name, "no_name") || !strcmp(name, fTranslation->GetName()))
189 return;
191}
192
193////////////////////////////////////////////////////////////////////////////////
194/// Slot for checking parameters.
195
197{
202 if (dx != fTranslation->GetTranslation()[0] || dy != fTranslation->GetTranslation()[1] ||
204 changed = kTRUE;
205 if (!changed)
206 return kFALSE;
207 fUndo->SetEnabled();
209 if (fPad) {
210 fPad->Modified();
211 fPad->Update();
212 }
213 return kTRUE;
214}
215
216////////////////////////////////////////////////////////////////////////////////
217/// Slot for applying changes.
218
220{
221 DoName();
222 if (DoParameters()) {
223 fUndo->SetEnabled();
226 }
227}
228
229////////////////////////////////////////////////////////////////////////////////
230/// Slot for cancelling last modifications non-applied.
231
245
246////////////////////////////////////////////////////////////////////////////////
247/// Slot for notifying changes.
248
255
256////////////////////////////////////////////////////////////////////////////////
257/// Slot for undoing last operation.
258
267
268////////////////////////////////////////////////////////////////////////////////
269/// Slot for dx.
270
275
276////////////////////////////////////////////////////////////////////////////////
277/// Slot for dx.
278
283
284////////////////////////////////////////////////////////////////////////////////
285/// Slot for dx.
286
291
292/** \class TGeoRotationEditor
293\ingroup Geometry_builder
294
295Editor for a TGeoRotation.
296
297*/
298
299
300////////////////////////////////////////////////////////////////////////////////
301/// Constructor for rotation editor
302
304 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
305{
306 fRotation = nullptr;
307 fPhii = fThetai = fPsii = 0.0;
308 fAngleX = fAngleY = fAngleZ = 0.0;
309 fNamei = "";
312
313 // TextEntry for name
314 MakeTitle("Name");
315 fRotName = new TGTextEntry(this, new TGTextBuffer(50), kMATRIX_NAME);
317 fRotName->SetToolTipText("Enter the rotation name");
318 fRotName->Associate(this);
319 AddFrame(fRotName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
320
322 MakeTitle("Euler angles");
324 // Number entry for phi angle
327 f1->AddFrame(new TGLabel(f1, " PHI "), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
328 fRotPhi = new TGNumberEntry(f1, 0., 5, kMATRIX_PHI);
330 nef->SetToolTipText("Modify the first rotation angle about Z");
331 fRotPhi->Associate(this);
333 f1->AddFrame(fRotPhi, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
334 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
335
336 // Number entry for theta angle
337 TGCompositeFrame *f2 =
339 f2->AddFrame(new TGLabel(f2, "THETA"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
340 fRotTheta = new TGNumberEntry(f2, 0., 5, kMATRIX_THETA);
342 nef->SetToolTipText("Modify the second rotation angle about the new X");
343 fRotTheta->Associate(this);
345 f2->AddFrame(fRotTheta, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
346 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
347
348 // Number entry for psi angle
349 TGCompositeFrame *f3 =
351 f3->AddFrame(new TGLabel(f3, " PSI "), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
352 fRotPsi = new TGNumberEntry(f3, 0., 5, kMATRIX_PSI);
354 nef->SetToolTipText("Modify the third rotation angle about Z");
355 fRotPsi->Associate(this);
357 f3->AddFrame(fRotPsi, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
358 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
359
360 compxyz->Resize(150, compxyz->GetDefaultHeight());
361 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
362
363 MakeTitle("Rotate about axis");
365 // Number entry for rotation angle about one axis
367 f1->AddFrame(new TGLabel(f1, "ANGLE"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
368 fRotAxis = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
370 nef->SetToolTipText("Enter the new rotation angle about the selected axis");
371 fRotAxis->Associate(this);
373 f1->AddFrame(fRotAxis, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
374 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
375
376 // Radio buttons group for axis selection
377 TGHButtonGroup *bg1 = new TGHButtonGroup(compxyz, " Axis ");
378 fRotX = new TGRadioButton(bg1, " &X ", kMATRIX_DX);
379 fRotY = new TGRadioButton(bg1, " &Y ", kMATRIX_DY);
380 fRotZ = new TGRadioButton(bg1, " &Z ", kMATRIX_DZ);
381 bg1->SetRadioButtonExclusive();
382 bg1->Show();
383 compxyz->AddFrame(bg1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
384
385 compxyz->Resize(150, compxyz->GetDefaultHeight());
386 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
387
388 // Buttons
390 fApply = new TGTextButton(f23, "Apply");
391 f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
392 fApply->Associate(this);
393 fCancel = new TGTextButton(f23, "Cancel");
394 f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4));
395 fCancel->Associate(this);
396 fUndo = new TGTextButton(f23, " Undo ");
397 f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
398 fUndo->Associate(this);
399 AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
402}
403
404////////////////////////////////////////////////////////////////////////////////
405/// Destructor
406
408{
410 TIter next(GetList());
411 while ((el = (TGFrameElement *)next())) {
412 if (el->fFrame->IsComposite())
414 }
415 Cleanup();
416}
417
418////////////////////////////////////////////////////////////////////////////////
419/// Connect signals to slots.
420
422{
423 fApply->Connect("Clicked()", "TGeoRotationEditor", this, "DoApply()");
424 fCancel->Connect("Clicked()", "TGeoRotationEditor", this, "DoCancel()");
425 fUndo->Connect("Clicked()", "TGeoRotationEditor", this, "DoUndo()");
426 fRotName->Connect("TextChanged(const char *)", "TGeoRotationEditor", this, "DoModified()");
427 fRotPhi->Connect("ValueSet(Long_t)", "TGeoRotationEditor", this, "DoRotPhi()");
428 fRotTheta->Connect("ValueSet(Long_t)", "TGeoRotationEditor", this, "DoRotTheta()");
429 fRotPsi->Connect("ValueSet(Long_t)", "TGeoRotationEditor", this, "DoRotPsi()");
430 fRotAxis->Connect("ValueSet(Long_t)", "TGeoRotationEditor", this, "DoRotAngle()");
431 fInit = kFALSE;
432}
433
434////////////////////////////////////////////////////////////////////////////////
435/// Connect to the selected rotation.
436
438{
439 if (obj == nullptr || (obj->IsA() != TGeoRotation::Class())) {
441 return;
442 }
443 fRotation = (TGeoRotation *)obj;
445 const char *sname = fRotation->GetName();
447 fRotName->SetText("no_name");
448 else {
450 fNamei = sname;
451 }
455 fRotAxis->SetNumber(0.0);
456
460
461 if (fInit)
463 SetActive();
464}
465
466////////////////////////////////////////////////////////////////////////////////
467/// Slot for name.
468
470{
471 const char *name = fRotName->GetText();
472 if (!strcmp(name, "no_name") || !strcmp(name, fRotation->GetName()))
473 return;
475}
476
477////////////////////////////////////////////////////////////////////////////////
478/// Slot for phi (Euler X convention)
479
481{
482 if (fRotPhi->GetNumber() < 0.)
484 if (fRotPhi->GetNumber() >= 360.)
486 DoModified();
487}
488
489////////////////////////////////////////////////////////////////////////////////
490/// Slot for theta (Euler X convention)
491
493{
494 if (fRotTheta->GetNumber() < 0.)
496 if (fRotTheta->GetNumber() >= 360.)
498 DoModified();
499}
500
501////////////////////////////////////////////////////////////////////////////////
502/// Slot for psi (Euler X convention)
503
505{
506 if (fRotPsi->GetNumber() < 0.)
508 if (fRotPsi->GetNumber() >= 360.)
510 DoModified();
511}
512
513////////////////////////////////////////////////////////////////////////////////
514/// Slot for additional rotation about one axis.
515
517{
518 if (fRotAxis->GetNumber() < 0.)
520 if (fRotAxis->GetNumber() >= 360.)
522 DoModified();
523}
524
525////////////////////////////////////////////////////////////////////////////////
526/// Slot for checking parameters.
527
529{
530 Double_t phi = fRotPhi->GetNumber();
531 Double_t theta = fRotTheta->GetNumber();
534 Double_t phi0 = 0., theta0 = 0., psi0 = 0.;
537 if (phi != psi0 || theta != theta0 || psi != psi0)
538 changed = kTRUE;
539 if (changed)
540 fRotation->SetAngles(phi, theta, psi);
541 // Check if we have to rotate about one axis
542 if (angle != 0.0) {
543 if (fRotX->IsOn()) {
545 changed = kTRUE;
546 }
547 if (fRotY->IsOn()) {
549 changed = kTRUE;
550 }
551 if (fRotZ->IsOn()) {
553 changed = kTRUE;
554 }
555 }
556 if (!changed)
557 return kFALSE;
558 fRotAxis->SetNumber(0.0);
559 fUndo->SetEnabled();
560 if (fPad) {
561 fPad->Modified();
562 fPad->Update();
563 }
564 return kTRUE;
565}
566
567////////////////////////////////////////////////////////////////////////////////
568/// Slot for applying modifications.
569
571{
572 DoName();
573 if (DoParameters()) {
574 fUndo->SetEnabled();
577 }
578}
579
580////////////////////////////////////////////////////////////////////////////////
581/// Slot for cancelling last un-applied operations.
582
597
598////////////////////////////////////////////////////////////////////////////////
599/// Slot for notifying changes.
600
607
608////////////////////////////////////////////////////////////////////////////////
609/// Slot for undoing last changes.
610
619
620/** \class TGeoCombiTransEditor
621\ingroup Geometry_builder
622
623Editor for a TGeoCombiTrans.
624
625*/
626
627
628////////////////////////////////////////////////////////////////////////////////
629/// Constructor for combi matrix editor
630
632 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
633{
634 fCombi = nullptr;
635 fPhii = fThetai = fPsii = 0.0;
636 fDxi = fDyi = fDzi = 0.0;
637 fAngleX = fAngleY = fAngleZ = 0.0;
638 fNamei = "";
641
642 // TextEntry for name
643 MakeTitle("Name");
644 fRotName = new TGTextEntry(this, new TGTextBuffer(50), kMATRIX_NAME);
646 fRotName->SetToolTipText("Enter the rotation name");
647 fRotName->Associate(this);
648 AddFrame(fRotName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
649
651 MakeTitle("Translations on axes");
653 // Number entry for dx
656 f1->AddFrame(new TGLabel(f1, "DX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
657 fTransDx = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
659 nef->SetToolTipText("Enter the translation on X");
660 fTransDx->Associate(this);
661 f1->AddFrame(fTransDx, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
662 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
663
664 // Number entry for dy
665 TGCompositeFrame *f2 =
667 f2->AddFrame(new TGLabel(f2, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
668 fTransDy = new TGNumberEntry(f2, 0., 5, kMATRIX_DY);
670 nef->SetToolTipText("Enter the translation on Y");
671 fTransDy->Associate(this);
673 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
674
675 // Number entry for dx
676 TGCompositeFrame *f3 =
678 f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
679 fTransDz = new TGNumberEntry(f3, 0., 5, kMATRIX_DZ);
681 nef->SetToolTipText("Enter the translation on Z");
682 fTransDz->Associate(this);
684 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
685
686 compxyz->Resize(150, 30);
687 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
688
689 MakeTitle("Euler angles");
691 // Number entry for phi angle
693 f1->AddFrame(new TGLabel(f1, " PHI "), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
694 fRotPhi = new TGNumberEntry(f1, 0., 5, kMATRIX_PHI);
696 nef->SetToolTipText("Modify the first rotation angle about Z");
697 fRotPhi->Associate(this);
699 f1->AddFrame(fRotPhi, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
700 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
701
702 // Number entry for theta angle
704 f2->AddFrame(new TGLabel(f2, "THETA"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
705 fRotTheta = new TGNumberEntry(f2, 0., 5, kMATRIX_THETA);
707 nef->SetToolTipText("Modify the second rotation angle about the new X");
708 fRotTheta->Associate(this);
710 f2->AddFrame(fRotTheta, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
711 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
712
713 // Number entry for psi angle
715 f3->AddFrame(new TGLabel(f3, " PSI "), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
716 fRotPsi = new TGNumberEntry(f3, 0., 5, kMATRIX_PSI);
718 nef->SetToolTipText("Modify the third rotation angle about Z");
719 fRotPsi->Associate(this);
721 f3->AddFrame(fRotPsi, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
722 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
723
724 compxyz->Resize(150, compxyz->GetDefaultHeight());
725 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
726
727 MakeTitle("Rotate about axis");
729 // Number entry for rotation angle about one axis
731 f1->AddFrame(new TGLabel(f1, "ANGLE"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
732 fRotAxis = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
734 nef->SetToolTipText("Enter the new rotation angle about the selected axis");
735 fRotAxis->Associate(this);
737 f1->AddFrame(fRotAxis, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
738 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
739
740 // Radio buttons group for axis selection
741 TGHButtonGroup *bg1 = new TGHButtonGroup(compxyz, " Axis ");
742 fRotX = new TGRadioButton(bg1, " &X ", kMATRIX_DX);
743 fRotY = new TGRadioButton(bg1, " &Y ", kMATRIX_DY);
744 fRotZ = new TGRadioButton(bg1, " &Z ", kMATRIX_DZ);
745 bg1->SetRadioButtonExclusive();
746 bg1->Show();
747 compxyz->AddFrame(bg1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
748
749 compxyz->Resize(150, compxyz->GetDefaultHeight());
750 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
751
752 // Buttons
754 fApply = new TGTextButton(f23, "&Apply");
755 f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
756 fApply->Associate(this);
757 fCancel = new TGTextButton(f23, "&Cancel");
758 f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4));
759 fCancel->Associate(this);
760 fUndo = new TGTextButton(f23, " &Undo ");
761 f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
762 fUndo->Associate(this);
763 AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
766}
767
768////////////////////////////////////////////////////////////////////////////////
769/// Destructor
770
772{
774 TIter next(GetList());
775 while ((el = (TGFrameElement *)next())) {
776 if (el->fFrame->IsComposite())
778 }
779 Cleanup();
780}
781
782////////////////////////////////////////////////////////////////////////////////
783/// Connect signals to slots.
784
786{
787 fApply->Connect("Clicked()", "TGeoCombiTransEditor", this, "DoApply()");
788 fCancel->Connect("Clicked()", "TGeoCombiTransEditor", this, "DoCancel()");
789 fUndo->Connect("Clicked()", "TGeoCombiTransEditor", this, "DoUndo()");
790 fRotName->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoModified()");
791 fRotPhi->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotPhi()");
792 fRotTheta->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotTheta()");
793 fRotPsi->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotPsi()");
794 fRotAxis->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotAngle()");
795 fTransDx->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoDx()");
796 fTransDy->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoDy()");
797 fTransDz->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoDz()");
798 fTransDx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoDx()");
799 fTransDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoDy()");
800 fTransDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoDz()");
801 fInit = kFALSE;
802}
803
804////////////////////////////////////////////////////////////////////////////////
805/// Connect to the selected combi matrix.
806
808{
809 if (obj == nullptr || (obj->IsA() != TGeoCombiTrans::Class())) {
811 return;
812 }
813 fCombi = (TGeoCombiTrans *)obj;
815 if (rot)
816 rot->GetAngles(fPhii, fThetai, fPsii);
817 const char *sname = fCombi->GetName();
818 if (!strcmp(sname, fCombi->ClassName()))
819 fRotName->SetText("no_name");
820 else {
822 fNamei = sname;
823 }
824
825 fDxi = fCombi->GetTranslation()[0];
826 fDyi = fCombi->GetTranslation()[1];
827 fDzi = fCombi->GetTranslation()[2];
831
835 fRotAxis->SetNumber(0.0);
836
840
841 if (fInit)
843 SetActive();
844}
845
846////////////////////////////////////////////////////////////////////////////////
847/// Slot for name.
848
850{
851 const char *name = fRotName->GetText();
852 if (!strcmp(name, "no_name") || !strcmp(name, fCombi->GetName()))
853 return;
855}
856
857////////////////////////////////////////////////////////////////////////////////
858/// Slot for phi (Euler X convention)
859
861{
862 if (fRotPhi->GetNumber() < 0.)
864 if (fRotPhi->GetNumber() >= 360.)
866 DoModified();
867}
868
869////////////////////////////////////////////////////////////////////////////////
870/// Slot for theta (Euler X convention)
871
873{
874 if (fRotTheta->GetNumber() < 0.)
876 if (fRotTheta->GetNumber() >= 360.)
878 DoModified();
879}
880
881////////////////////////////////////////////////////////////////////////////////
882/// Slot for psi (Euler X convention)
883
885{
886 if (fRotPsi->GetNumber() < 0.)
888 if (fRotPsi->GetNumber() >= 360.)
890 DoModified();
891}
892
893////////////////////////////////////////////////////////////////////////////////
894/// Slot for additional rotation about one axis.
895
897{
898 if (fRotAxis->GetNumber() < 0.)
900 if (fRotAxis->GetNumber() >= 360.)
902 DoModified();
903}
904
905////////////////////////////////////////////////////////////////////////////////
906/// Slot for checking parameters.
907
909{
914 if (dx != fCombi->GetTranslation()[0] || dy != fCombi->GetTranslation()[1] || dz != fCombi->GetTranslation()[2])
916 if (changedtr)
918 Double_t phi = fRotPhi->GetNumber();
919 Double_t theta = fRotTheta->GetNumber();
922 Double_t phi0 = 0., theta0 = 0., psi0 = 0.;
924 if (rot)
925 rot->GetAngles(phi0, theta0, psi0);
926 else {
927 if (phi != fPhii || theta != fThetai || psi != fPsii) {
928 TGeoRotation r("rot", 10., 0., 0.);
931 rot->SetAngles(0., 0., 0.);
932 }
933 }
935 if (phi != psi0 || theta != theta0 || psi != psi0)
936 changed = kTRUE;
937 if (changed && rot)
938 rot->SetAngles(phi, theta, psi);
939 // Check if we have to rotate about one axis
940 if (angle != 0.0) {
941 if (fRotX->IsOn()) {
943 changed = kTRUE;
944 }
945 if (fRotY->IsOn()) {
947 changed = kTRUE;
948 }
949 if (fRotZ->IsOn()) {
951 changed = kTRUE;
952 }
953 }
954 if (changedtr)
955 changed = kTRUE;
956 if (!changed)
957 return kFALSE;
958 fRotAxis->SetNumber(0.0);
959 fUndo->SetEnabled();
960 if (fPad) {
961 fPad->Modified();
962 fPad->Update();
963 }
964 return kTRUE;
965}
966
967////////////////////////////////////////////////////////////////////////////////
968/// Slot for applying modifications.
969
971{
972 DoName();
973 if (DoParameters()) {
974 fUndo->SetEnabled();
977 }
978}
979
980////////////////////////////////////////////////////////////////////////////////
981/// Slot for cancelling last un-applied operations.
982
1000
1001////////////////////////////////////////////////////////////////////////////////
1002/// Slot for notifying changes.
1003
1010
1011////////////////////////////////////////////////////////////////////////////////
1012/// Slot for undoing last changes.
1013
1022
1023////////////////////////////////////////////////////////////////////////////////
1024/// Slot for X.
1025
1027{
1028 DoModified();
1029}
1030
1031////////////////////////////////////////////////////////////////////////////////
1032/// Slot for Y.
1033
1035{
1036 DoModified();
1037}
1038
1039////////////////////////////////////////////////////////////////////////////////
1040/// Slot for Z.
1041
1043{
1044 DoModified();
1045}
@ kRaisedFrame
Definition GuiTypes.h:384
@ kSunkenFrame
Definition GuiTypes.h:383
@ kVerticalFrame
Definition GuiTypes.h:381
@ kDoubleBorder
Definition GuiTypes.h:385
@ kFixedWidth
Definition GuiTypes.h:387
@ kFitWidth
Definition GuiTypes.h:386
@ kHorizontalFrame
Definition GuiTypes.h:382
@ kOwnBackground
Definition GuiTypes.h:391
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ kButtonDisabled
Definition TGButton.h:56
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsCenterX
Definition TGLayout.h:25
@ kLHintsExpandX
Definition TGLayout.h:30
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint angle
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
char name[80]
Definition TGX11.cxx:110
@ kMATRIX_NAME
ETGeoMatrixWid
@ kMATRIX_DX
@ kMATRIX_PSI
@ kMATRIX_NAME
@ kMATRIX_CANCEL
@ kMATRIX_DY
@ kMATRIX_PHI
@ kMATRIX_THETA
@ kMATRIX_APPLY
@ kMATRIX_UNDO
@ kMATRIX_DZ
virtual EButtonState GetState() const
Definition TGButton.h:112
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition TGButton.cxx:453
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
virtual void SetSize(const TGDimension &s)
Definition TGFrame.h:254
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:193
TGDimension GetSize() const
Definition TGFrame.h:232
Organizes TGButton widgets in a group with one horizontal row.
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.
TGNumberEntryField * GetNumberEntry() const
Get the number entry field.
void Associate(const TGWindow *w) override
Make w the window that will receive the generated messages.
virtual Double_t GetNumber() const
virtual void SetNumber(Double_t val, Bool_t emit=kTRUE)
UInt_t GetDefaultHeight() const override
Selects different options.
Definition TGButton.h:321
Bool_t IsOn() const override
Definition TGButton.h:369
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
const char * GetText() const
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Sets text entry to text, clears the selection and moves the cursor to the end of the line.
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:72
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
TGNumberEntry * fTransDy
TGNumberEntry * fRotPsi
TGeoCombiTransEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for combi matrix editor.
TGNumberEntry * fRotAxis
void DoRotPsi()
Slot for psi (Euler X convention)
TGNumberEntry * fTransDz
void DoModified()
Slot for notifying changes.
void DoUndo()
Slot for undoing last changes.
Bool_t DoParameters()
Slot for checking parameters.
void DoName()
Slot for name.
void DoRotAngle()
Slot for additional rotation about one axis.
TGeoCombiTrans * fCombi
void DoRotPhi()
Slot for phi (Euler X convention)
TGNumberEntry * fRotPhi
void DoApply()
Slot for applying modifications.
TGNumberEntry * fRotTheta
virtual void ConnectSignals2Slots()
Connect signals to slots.
void SetModel(TObject *obj) override
Connect to the selected combi matrix.
void DoRotTheta()
Slot for theta (Euler X convention)
void DoCancel()
Slot for cancelling last un-applied operations.
TGNumberEntry * fTransDx
~TGeoCombiTransEditor() override
Destructor.
Class describing rotation + translation.
Definition TGeoMatrix.h:317
const Double_t * GetTranslation() const override
Definition TGeoMatrix.h:361
void RotateY(Double_t angle) override
Rotate about Y axis with angle expressed in degrees.
void RotateX(Double_t angle) override
Rotate about X axis with angle expressed in degrees.
TGeoRotation * GetRotation() const
Definition TGeoMatrix.h:359
static TClass * Class()
void SetTranslation(const TGeoTranslation &tr)
copy the translation component
void SetRotation(const TGeoRotation &other)
Copy the rotation from another one.
void RotateZ(Double_t angle) override
Rotate about Z axis with angle expressed in degrees.
Common base class for geombuilder editors.
TVirtualPad * fPad
virtual void SetActive(Bool_t active=kTRUE)
Set active GUI attribute frames related to the selected object.
void DoApply()
Slot for applying modifications.
void DoRotPhi()
Slot for phi (Euler X convention)
void DoRotAngle()
Slot for additional rotation about one axis.
TGRadioButton * fRotY
void DoCancel()
Slot for cancelling last un-applied operations.
TGNumberEntry * fRotTheta
void DoUndo()
Slot for undoing last changes.
void SetModel(TObject *obj) override
Connect to the selected rotation.
void DoName()
Slot for name.
TGeoRotation * fRotation
TGRadioButton * fRotZ
Bool_t DoParameters()
Slot for checking parameters.
TGTextButton * fCancel
void DoModified()
Slot for notifying changes.
TGTextButton * fApply
TGNumberEntry * fRotPhi
TGNumberEntry * fRotAxis
TGTextButton * fUndo
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGTextEntry * fRotName
void DoRotPsi()
Slot for psi (Euler X convention)
TGRadioButton * fRotX
~TGeoRotationEditor() override
Destructor.
void DoRotTheta()
Slot for theta (Euler X convention)
TGeoRotationEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for rotation editor.
TGNumberEntry * fRotPsi
Class describing rotations.
Definition TGeoMatrix.h:168
static TClass * Class()
void RotateX(Double_t angle) override
Rotate about X axis of the master frame with angle expressed in degrees.
void SetAngles(Double_t phi, Double_t theta, Double_t psi)
Set matrix elements according to Euler angles.
void RotateY(Double_t angle) override
Rotate about Y axis of the master frame with angle expressed in degrees.
void RotateZ(Double_t angle) override
Rotate about Z axis of the master frame with angle expressed in degrees.
void GetAngles(Double_t &theta1, Double_t &phi1, Double_t &theta2, Double_t &phi2, Double_t &theta3, Double_t &phi3) const
Retrieve rotation angles.
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hierarchically all daughters of a composite frame.
~TGeoTranslationEditor() override
Destructor.
TGeoTranslation * fTranslation
void SetModel(TObject *obj) override
Connect to the new matrix.
void DoModified()
Slot for notifying changes.
void DoName()
Slot for name.
TGeoTranslationEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for translation editor.
void DoUndo()
Slot for undoing last operation.
void DoDy()
Slot for dx.
TGNumberEntry * fTransDy
Bool_t DoParameters()
Slot for checking parameters.
void DoCancel()
Slot for cancelling last modifications non-applied.
TGNumberEntry * fTransDx
void DoDz()
Slot for dx.
TGNumberEntry * fTransDz
virtual void ConnectSignals2Slots()
Connect signals to slots.
void DoApply()
Slot for applying changes.
void DoDx()
Slot for dx.
Class describing translations.
Definition TGeoMatrix.h:116
static TClass * Class()
void SetTranslation(Double_t dx, Double_t dy, Double_t dz)
Set translation components.
const Double_t * GetTranslation() const override
Definition TGeoMatrix.h:154
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:149
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:226
virtual TClass * IsA() const
Definition TObject.h:246
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
Ssiz_t Length() const
Definition TString.h:425
const char * Data() const
Definition TString.h:384
virtual void Modified(Bool_t flag=1)=0
virtual void Update()=0
TF1 * f1
Definition legend1.C:11