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
30
42};
43
44////////////////////////////////////////////////////////////////////////////////
45/// Constructor for translation editor
46
48 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
49{
50 fTranslation = nullptr;
51 fDxi = fDyi = fDzi = 0.0;
52 fNamei = "";
55
56 // TextEntry for name
57 MakeTitle("Name");
58 fTransName = new TGTextEntry(this, new TGTextBuffer(50), kMATRIX_NAME);
60 fTransName->SetToolTipText("Enter the translation name");
61 fTransName->Associate(this);
63
64 TGTextEntry *nef;
65 MakeTitle("Translations on axes");
67 // Number entry for dx
70 f1->AddFrame(new TGLabel(f1, "DX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
71 fTransDx = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
73 nef->SetToolTipText("Enter the translation on X");
74 fTransDx->Associate(this);
75 f1->AddFrame(fTransDx, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
76 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
77
78 // Number entry for dy
81 f2->AddFrame(new TGLabel(f2, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
82 fTransDy = new TGNumberEntry(f2, 0., 5, kMATRIX_DY);
84 nef->SetToolTipText("Enter the translation on Y");
85 fTransDy->Associate(this);
87 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
88
89 // Number entry for dx
92 f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
93 fTransDz = new TGNumberEntry(f3, 0., 5, kMATRIX_DZ);
95 nef->SetToolTipText("Enter the translation on Z");
96 fTransDz->Associate(this);
98 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
99
100 compxyz->Resize(150, 30);
101 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
102
103 // Buttons
105 fApply = new TGTextButton(f23, "&Apply");
106 f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
107 fApply->Associate(this);
108 fCancel = new TGTextButton(f23, "&Cancel");
109 f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4));
110 fCancel->Associate(this);
111 fUndo = new TGTextButton(f23, " &Undo ");
112 f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
113 fUndo->Associate(this);
114 AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
117}
118
119////////////////////////////////////////////////////////////////////////////////
120/// Destructor.
121
123{
124 TGFrameElement *el;
125 TIter next(GetList());
126 while ((el = (TGFrameElement *)next())) {
127 if (el->fFrame->IsComposite())
129 }
130 Cleanup();
131}
132
133////////////////////////////////////////////////////////////////////////////////
134/// Connect signals to slots.
135
137{
138 fApply->Connect("Clicked()", "TGeoTranslationEditor", this, "DoApply()");
139 fCancel->Connect("Clicked()", "TGeoTranslationEditor", this, "DoCancel()");
140 fUndo->Connect("Clicked()", "TGeoTranslationEditor", this, "DoUndo()");
141 fTransName->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoModified()");
142 fTransDx->Connect("ValueSet(Long_t)", "TGeoTranslationEditor", this, "DoDx()");
143 fTransDy->Connect("ValueSet(Long_t)", "TGeoTranslationEditor", this, "DoDy()");
144 fTransDz->Connect("ValueSet(Long_t)", "TGeoTranslationEditor", this, "DoDz()");
145 fTransDx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoDx()");
146 fTransDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoDy()");
147 fTransDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoDz()");
148 fInit = kFALSE;
149}
150
151////////////////////////////////////////////////////////////////////////////////
152/// Connect to the new matrix.
153
155{
156 if (obj == nullptr || (obj->IsA() != TGeoTranslation::Class())) {
158 return;
159 }
164 const char *sname = fTranslation->GetName();
165 if (!strcmp(sname, fTranslation->ClassName()))
166 fTransName->SetText("no_name");
167 else {
168 fTransName->SetText(sname);
169 fNamei = sname;
170 }
177
178 if (fInit)
180 SetActive();
181}
182
183////////////////////////////////////////////////////////////////////////////////
184/// Slot for name.
185
187{
188 const char *name = fTransName->GetText();
189 if (!strcmp(name, "no_name") || !strcmp(name, fTranslation->GetName()))
190 return;
192}
193
194////////////////////////////////////////////////////////////////////////////////
195/// Slot for checking parameters.
196
198{
202 Bool_t changed = kFALSE;
203 if (dx != fTranslation->GetTranslation()[0] || dy != fTranslation->GetTranslation()[1] ||
204 dz != fTranslation->GetTranslation()[2])
205 changed = kTRUE;
206 if (!changed)
207 return kFALSE;
208 fUndo->SetEnabled();
209 fTranslation->SetTranslation(dx, dy, dz);
210 if (fPad) {
211 fPad->Modified();
212 fPad->Update();
213 }
214 return kTRUE;
215}
216
217////////////////////////////////////////////////////////////////////////////////
218/// Slot for applying changes.
219
221{
222 DoName();
223 if (DoParameters()) {
224 fUndo->SetEnabled();
227 }
228}
229
230////////////////////////////////////////////////////////////////////////////////
231/// Slot for cancelling last modifications non-applied.
232
234{
235 if (!fNamei.Length())
236 fTransName->SetText("no_name");
237 else
245}
246
247////////////////////////////////////////////////////////////////////////////////
248/// Slot for notifying changes.
249
251{
255}
256
257////////////////////////////////////////////////////////////////////////////////
258/// Slot for undoing last operation.
259
261{
262 DoCancel();
263 DoParameters();
267}
268
269////////////////////////////////////////////////////////////////////////////////
270/// Slot for dx.
271
273{
274 DoModified();
275}
276
277////////////////////////////////////////////////////////////////////////////////
278/// Slot for dx.
279
281{
282 DoModified();
283}
284
285////////////////////////////////////////////////////////////////////////////////
286/// Slot for dx.
287
289{
290 DoModified();
291}
292
293/** \class TGeoRotationEditor
294\ingroup Geometry_builder
295
296Editor for a TGeoRotation.
297
298*/
299
301
302////////////////////////////////////////////////////////////////////////////////
303/// Constructor for rotation editor
304
306 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
307{
308 fRotation = nullptr;
309 fPhii = fThetai = fPsii = 0.0;
310 fAngleX = fAngleY = fAngleZ = 0.0;
311 fNamei = "";
314
315 // TextEntry for name
316 MakeTitle("Name");
317 fRotName = new TGTextEntry(this, new TGTextBuffer(50), kMATRIX_NAME);
319 fRotName->SetToolTipText("Enter the rotation name");
320 fRotName->Associate(this);
321 AddFrame(fRotName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
322
323 TGTextEntry *nef;
324 MakeTitle("Euler angles");
326 // Number entry for phi angle
329 f1->AddFrame(new TGLabel(f1, " PHI "), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
330 fRotPhi = new TGNumberEntry(f1, 0., 5, kMATRIX_PHI);
332 nef->SetToolTipText("Modify the first rotation angle about Z");
333 fRotPhi->Associate(this);
335 f1->AddFrame(fRotPhi, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
336 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
337
338 // Number entry for theta angle
339 TGCompositeFrame *f2 =
341 f2->AddFrame(new TGLabel(f2, "THETA"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
342 fRotTheta = new TGNumberEntry(f2, 0., 5, kMATRIX_THETA);
344 nef->SetToolTipText("Modify the second rotation angle about the new X");
345 fRotTheta->Associate(this);
347 f2->AddFrame(fRotTheta, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
348 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
349
350 // Number entry for psi angle
351 TGCompositeFrame *f3 =
353 f3->AddFrame(new TGLabel(f3, " PSI "), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
354 fRotPsi = new TGNumberEntry(f3, 0., 5, kMATRIX_PSI);
356 nef->SetToolTipText("Modify the third rotation angle about Z");
357 fRotPsi->Associate(this);
359 f3->AddFrame(fRotPsi, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
360 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
361
362 compxyz->Resize(150, compxyz->GetDefaultHeight());
363 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
364
365 MakeTitle("Rotate about axis");
366 compxyz = new TGCompositeFrame(this, 140, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
367 // Number entry for rotation angle about one axis
369 f1->AddFrame(new TGLabel(f1, "ANGLE"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
370 fRotAxis = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
372 nef->SetToolTipText("Enter the new rotation angle about the selected axis");
373 fRotAxis->Associate(this);
375 f1->AddFrame(fRotAxis, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
376 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
377
378 // Radio buttons group for axis selection
379 TGHButtonGroup *bg1 = new TGHButtonGroup(compxyz, " Axis ");
380 fRotX = new TGRadioButton(bg1, " &X ", kMATRIX_DX);
381 fRotY = new TGRadioButton(bg1, " &Y ", kMATRIX_DY);
382 fRotZ = new TGRadioButton(bg1, " &Z ", kMATRIX_DZ);
384 bg1->Show();
385 compxyz->AddFrame(bg1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
386
387 compxyz->Resize(150, compxyz->GetDefaultHeight());
388 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
389
390 // Buttons
392 fApply = new TGTextButton(f23, "Apply");
393 f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
394 fApply->Associate(this);
395 fCancel = new TGTextButton(f23, "Cancel");
396 f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4));
397 fCancel->Associate(this);
398 fUndo = new TGTextButton(f23, " Undo ");
399 f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
400 fUndo->Associate(this);
401 AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
404}
405
406////////////////////////////////////////////////////////////////////////////////
407/// Destructor
408
410{
411 TGFrameElement *el;
412 TIter next(GetList());
413 while ((el = (TGFrameElement *)next())) {
414 if (el->fFrame->IsComposite())
416 }
417 Cleanup();
418}
419
420////////////////////////////////////////////////////////////////////////////////
421/// Connect signals to slots.
422
424{
425 fApply->Connect("Clicked()", "TGeoRotationEditor", this, "DoApply()");
426 fCancel->Connect("Clicked()", "TGeoRotationEditor", this, "DoCancel()");
427 fUndo->Connect("Clicked()", "TGeoRotationEditor", this, "DoUndo()");
428 fRotName->Connect("TextChanged(const char *)", "TGeoRotationEditor", this, "DoModified()");
429 fRotPhi->Connect("ValueSet(Long_t)", "TGeoRotationEditor", this, "DoRotPhi()");
430 fRotTheta->Connect("ValueSet(Long_t)", "TGeoRotationEditor", this, "DoRotTheta()");
431 fRotPsi->Connect("ValueSet(Long_t)", "TGeoRotationEditor", this, "DoRotPsi()");
432 fRotAxis->Connect("ValueSet(Long_t)", "TGeoRotationEditor", this, "DoRotAngle()");
433 fInit = kFALSE;
434}
435
436////////////////////////////////////////////////////////////////////////////////
437/// Connect to the selected rotation.
438
440{
441 if (obj == nullptr || (obj->IsA() != TGeoRotation::Class())) {
443 return;
444 }
445 fRotation = (TGeoRotation *)obj;
447 const char *sname = fRotation->GetName();
448 if (!strcmp(sname, fRotation->ClassName()))
449 fRotName->SetText("no_name");
450 else {
451 fRotName->SetText(sname);
452 fNamei = sname;
453 }
457 fRotAxis->SetNumber(0.0);
458
462
463 if (fInit)
465 SetActive();
466}
467
468////////////////////////////////////////////////////////////////////////////////
469/// Slot for name.
470
472{
473 const char *name = fRotName->GetText();
474 if (!strcmp(name, "no_name") || !strcmp(name, fRotation->GetName()))
475 return;
477}
478
479////////////////////////////////////////////////////////////////////////////////
480/// Slot for phi (Euler X convention)
481
483{
484 if (fRotPhi->GetNumber() < 0.)
486 if (fRotPhi->GetNumber() >= 360.)
488 DoModified();
489}
490
491////////////////////////////////////////////////////////////////////////////////
492/// Slot for theta (Euler X convention)
493
495{
496 if (fRotTheta->GetNumber() < 0.)
498 if (fRotTheta->GetNumber() >= 360.)
500 DoModified();
501}
502
503////////////////////////////////////////////////////////////////////////////////
504/// Slot for psi (Euler X convention)
505
507{
508 if (fRotPsi->GetNumber() < 0.)
510 if (fRotPsi->GetNumber() >= 360.)
512 DoModified();
513}
514
515////////////////////////////////////////////////////////////////////////////////
516/// Slot for additional rotation about one axis.
517
519{
520 if (fRotAxis->GetNumber() < 0.)
522 if (fRotAxis->GetNumber() >= 360.)
524 DoModified();
525}
526
527////////////////////////////////////////////////////////////////////////////////
528/// Slot for checking parameters.
529
531{
532 Double_t phi = fRotPhi->GetNumber();
533 Double_t theta = fRotTheta->GetNumber();
534 Double_t psi = fRotPsi->GetNumber();
536 Double_t phi0 = 0., theta0 = 0., psi0 = 0.;
537 fRotation->GetAngles(phi0, theta0, psi0);
538 Bool_t changed = kFALSE;
539 if (phi != psi0 || theta != theta0 || psi != psi0)
540 changed = kTRUE;
541 if (changed)
542 fRotation->SetAngles(phi, theta, psi);
543 // Check if we have to rotate about one axis
544 if (angle != 0.0) {
545 if (fRotX->IsOn()) {
547 changed = kTRUE;
548 }
549 if (fRotY->IsOn()) {
551 changed = kTRUE;
552 }
553 if (fRotZ->IsOn()) {
555 changed = kTRUE;
556 }
557 }
558 if (!changed)
559 return kFALSE;
560 fRotAxis->SetNumber(0.0);
561 fUndo->SetEnabled();
562 if (fPad) {
563 fPad->Modified();
564 fPad->Update();
565 }
566 return kTRUE;
567}
568
569////////////////////////////////////////////////////////////////////////////////
570/// Slot for applying modifications.
571
573{
574 DoName();
575 if (DoParameters()) {
576 fUndo->SetEnabled();
579 }
580}
581
582////////////////////////////////////////////////////////////////////////////////
583/// Slot for cancelling last un-applied operations.
584
586{
587 if (!fNamei.Length())
588 fRotName->SetText("no_name");
589 else
594 fRotAxis->SetNumber(0.0);
598}
599
600////////////////////////////////////////////////////////////////////////////////
601/// Slot for notifying changes.
602
604{
608}
609
610////////////////////////////////////////////////////////////////////////////////
611/// Slot for undoing last changes.
612
614{
615 DoCancel();
616 DoParameters();
620}
621
622/** \class TGeoCombiTransEditor
623\ingroup Geometry_builder
624
625Editor for a TGeoCombiTrans.
626
627*/
628
630
631////////////////////////////////////////////////////////////////////////////////
632/// Constructor for combi matrix editor
633
635 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
636{
637 fCombi = nullptr;
638 fPhii = fThetai = fPsii = 0.0;
639 fDxi = fDyi = fDzi = 0.0;
640 fAngleX = fAngleY = fAngleZ = 0.0;
641 fNamei = "";
644
645 // TextEntry for name
646 MakeTitle("Name");
647 fRotName = new TGTextEntry(this, new TGTextBuffer(50), kMATRIX_NAME);
649 fRotName->SetToolTipText("Enter the rotation name");
650 fRotName->Associate(this);
651 AddFrame(fRotName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
652
653 TGTextEntry *nef;
654 MakeTitle("Translations on axes");
656 // Number entry for dx
659 f1->AddFrame(new TGLabel(f1, "DX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
660 fTransDx = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
662 nef->SetToolTipText("Enter the translation on X");
663 fTransDx->Associate(this);
664 f1->AddFrame(fTransDx, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
665 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
666
667 // Number entry for dy
668 TGCompositeFrame *f2 =
670 f2->AddFrame(new TGLabel(f2, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
671 fTransDy = new TGNumberEntry(f2, 0., 5, kMATRIX_DY);
673 nef->SetToolTipText("Enter the translation on Y");
674 fTransDy->Associate(this);
676 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
677
678 // Number entry for dx
679 TGCompositeFrame *f3 =
681 f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
682 fTransDz = new TGNumberEntry(f3, 0., 5, kMATRIX_DZ);
684 nef->SetToolTipText("Enter the translation on Z");
685 fTransDz->Associate(this);
687 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
688
689 compxyz->Resize(150, 30);
690 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
691
692 MakeTitle("Euler angles");
693 compxyz = new TGCompositeFrame(this, 140, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
694 // Number entry for phi angle
696 f1->AddFrame(new TGLabel(f1, " PHI "), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
697 fRotPhi = new TGNumberEntry(f1, 0., 5, kMATRIX_PHI);
699 nef->SetToolTipText("Modify the first rotation angle about Z");
700 fRotPhi->Associate(this);
702 f1->AddFrame(fRotPhi, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
703 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
704
705 // Number entry for theta angle
706 f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame | kFitWidth | kFixedWidth | kOwnBackground);
707 f2->AddFrame(new TGLabel(f2, "THETA"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
708 fRotTheta = new TGNumberEntry(f2, 0., 5, kMATRIX_THETA);
710 nef->SetToolTipText("Modify the second rotation angle about the new X");
711 fRotTheta->Associate(this);
713 f2->AddFrame(fRotTheta, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
714 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
715
716 // Number entry for psi angle
717 f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame | kFitWidth | kFixedWidth | kOwnBackground);
718 f3->AddFrame(new TGLabel(f3, " PSI "), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
719 fRotPsi = new TGNumberEntry(f3, 0., 5, kMATRIX_PSI);
721 nef->SetToolTipText("Modify the third rotation angle about Z");
722 fRotPsi->Associate(this);
724 f3->AddFrame(fRotPsi, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
725 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
726
727 compxyz->Resize(150, compxyz->GetDefaultHeight());
728 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
729
730 MakeTitle("Rotate about axis");
731 compxyz = new TGCompositeFrame(this, 140, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
732 // Number entry for rotation angle about one axis
734 f1->AddFrame(new TGLabel(f1, "ANGLE"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
735 fRotAxis = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
737 nef->SetToolTipText("Enter the new rotation angle about the selected axis");
738 fRotAxis->Associate(this);
740 f1->AddFrame(fRotAxis, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
741 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
742
743 // Radio buttons group for axis selection
744 TGHButtonGroup *bg1 = new TGHButtonGroup(compxyz, " Axis ");
745 fRotX = new TGRadioButton(bg1, " &X ", kMATRIX_DX);
746 fRotY = new TGRadioButton(bg1, " &Y ", kMATRIX_DY);
747 fRotZ = new TGRadioButton(bg1, " &Z ", kMATRIX_DZ);
749 bg1->Show();
750 compxyz->AddFrame(bg1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
751
752 compxyz->Resize(150, compxyz->GetDefaultHeight());
753 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
754
755 // Buttons
757 fApply = new TGTextButton(f23, "&Apply");
758 f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
759 fApply->Associate(this);
760 fCancel = new TGTextButton(f23, "&Cancel");
761 f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4));
762 fCancel->Associate(this);
763 fUndo = new TGTextButton(f23, " &Undo ");
764 f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
765 fUndo->Associate(this);
766 AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
769}
770
771////////////////////////////////////////////////////////////////////////////////
772/// Destructor
773
775{
776 TGFrameElement *el;
777 TIter next(GetList());
778 while ((el = (TGFrameElement *)next())) {
779 if (el->fFrame->IsComposite())
781 }
782 Cleanup();
783}
784
785////////////////////////////////////////////////////////////////////////////////
786/// Connect signals to slots.
787
789{
790 fApply->Connect("Clicked()", "TGeoCombiTransEditor", this, "DoApply()");
791 fCancel->Connect("Clicked()", "TGeoCombiTransEditor", this, "DoCancel()");
792 fUndo->Connect("Clicked()", "TGeoCombiTransEditor", this, "DoUndo()");
793 fRotName->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoModified()");
794 fRotPhi->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotPhi()");
795 fRotTheta->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotTheta()");
796 fRotPsi->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotPsi()");
797 fRotAxis->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotAngle()");
798 fTransDx->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoDx()");
799 fTransDy->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoDy()");
800 fTransDz->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoDz()");
801 fTransDx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoDx()");
802 fTransDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoDy()");
803 fTransDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoDz()");
804 fInit = kFALSE;
805}
806
807////////////////////////////////////////////////////////////////////////////////
808/// Connect to the selected combi matrix.
809
811{
812 if (obj == nullptr || (obj->IsA() != TGeoCombiTrans::Class())) {
814 return;
815 }
816 fCombi = (TGeoCombiTrans *)obj;
818 if (rot)
820 const char *sname = fCombi->GetName();
821 if (!strcmp(sname, fCombi->ClassName()))
822 fRotName->SetText("no_name");
823 else {
824 fRotName->SetText(sname);
825 fNamei = sname;
826 }
827
828 fDxi = fCombi->GetTranslation()[0];
829 fDyi = fCombi->GetTranslation()[1];
830 fDzi = fCombi->GetTranslation()[2];
834
838 fRotAxis->SetNumber(0.0);
839
843
844 if (fInit)
846 SetActive();
847}
848
849////////////////////////////////////////////////////////////////////////////////
850/// Slot for name.
851
853{
854 const char *name = fRotName->GetText();
855 if (!strcmp(name, "no_name") || !strcmp(name, fCombi->GetName()))
856 return;
858}
859
860////////////////////////////////////////////////////////////////////////////////
861/// Slot for phi (Euler X convention)
862
864{
865 if (fRotPhi->GetNumber() < 0.)
867 if (fRotPhi->GetNumber() >= 360.)
869 DoModified();
870}
871
872////////////////////////////////////////////////////////////////////////////////
873/// Slot for theta (Euler X convention)
874
876{
877 if (fRotTheta->GetNumber() < 0.)
879 if (fRotTheta->GetNumber() >= 360.)
881 DoModified();
882}
883
884////////////////////////////////////////////////////////////////////////////////
885/// Slot for psi (Euler X convention)
886
888{
889 if (fRotPsi->GetNumber() < 0.)
891 if (fRotPsi->GetNumber() >= 360.)
893 DoModified();
894}
895
896////////////////////////////////////////////////////////////////////////////////
897/// Slot for additional rotation about one axis.
898
900{
901 if (fRotAxis->GetNumber() < 0.)
903 if (fRotAxis->GetNumber() >= 360.)
905 DoModified();
906}
907
908////////////////////////////////////////////////////////////////////////////////
909/// Slot for checking parameters.
910
912{
916 Bool_t changedtr = kFALSE;
917 if (dx != fCombi->GetTranslation()[0] || dy != fCombi->GetTranslation()[1] || dz != fCombi->GetTranslation()[2])
918 changedtr = kTRUE;
919 if (changedtr)
920 fCombi->SetTranslation(dx, dy, dz);
921 Double_t phi = fRotPhi->GetNumber();
922 Double_t theta = fRotTheta->GetNumber();
923 Double_t psi = fRotPsi->GetNumber();
925 Double_t phi0 = 0., theta0 = 0., psi0 = 0.;
927 if (rot)
928 rot->GetAngles(phi0, theta0, psi0);
929 else {
930 if (phi != fPhii || theta != fThetai || psi != fPsii) {
931 TGeoRotation r("rot", 10., 0., 0.);
933 rot = fCombi->GetRotation();
934 rot->SetAngles(0., 0., 0.);
935 }
936 }
937 Bool_t changed = kFALSE;
938 if (phi != psi0 || theta != theta0 || psi != psi0)
939 changed = kTRUE;
940 if (changed && rot)
941 rot->SetAngles(phi, theta, psi);
942 // Check if we have to rotate about one axis
943 if (angle != 0.0) {
944 if (fRotX->IsOn()) {
946 changed = kTRUE;
947 }
948 if (fRotY->IsOn()) {
950 changed = kTRUE;
951 }
952 if (fRotZ->IsOn()) {
954 changed = kTRUE;
955 }
956 }
957 if (changedtr)
958 changed = kTRUE;
959 if (!changed)
960 return kFALSE;
961 fRotAxis->SetNumber(0.0);
962 fUndo->SetEnabled();
963 if (fPad) {
964 fPad->Modified();
965 fPad->Update();
966 }
967 return kTRUE;
968}
969
970////////////////////////////////////////////////////////////////////////////////
971/// Slot for applying modifications.
972
974{
975 DoName();
976 if (DoParameters()) {
977 fUndo->SetEnabled();
980 }
981}
982
983////////////////////////////////////////////////////////////////////////////////
984/// Slot for cancelling last un-applied operations.
985
987{
988 if (!fNamei.Length())
989 fRotName->SetText("no_name");
990 else
998 fRotAxis->SetNumber(0.0);
1002}
1003
1004////////////////////////////////////////////////////////////////////////////////
1005/// Slot for notifying changes.
1006
1008{
1009 fApply->SetEnabled();
1010 if (fUndo->GetState() == kButtonDisabled)
1012}
1013
1014////////////////////////////////////////////////////////////////////////////////
1015/// Slot for undoing last changes.
1016
1018{
1019 DoCancel();
1020 DoParameters();
1024}
1025
1026////////////////////////////////////////////////////////////////////////////////
1027/// Slot for X.
1028
1030{
1031 DoModified();
1032}
1033
1034////////////////////////////////////////////////////////////////////////////////
1035/// Slot for Y.
1036
1038{
1039 DoModified();
1040}
1041
1042////////////////////////////////////////////////////////////////////////////////
1043/// Slot for Z.
1044
1046{
1047 DoModified();
1048}
@ 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:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:377
@ 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 void SetRadioButtonExclusive(Bool_t flag=kTRUE)
If enable is kTRUE, this button group will treat radio buttons as mutually exclusive,...
virtual void Show()
Show group of buttons.
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:459
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
virtual TList * GetList() const
Definition TGFrame.h:310
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:967
UInt_t GetDefaultHeight() const override
Definition TGFrame.h:314
TGFrame * fFrame
Definition TGLayout.h:112
virtual void SetSize(const TGDimension &s)
Definition TGFrame.h:252
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:191
TGDimension GetSize() const
Definition TGFrame.h:230
virtual Bool_t IsComposite() const
Definition TGFrame.h:212
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:95
Editor for a TGeoCombiTrans.
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.
Editor for a TGeoRotation.
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.
Editor for a TGeoTranslation.
~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:47
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:140
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:207
virtual TClass * IsA() const
Definition TObject.h:243
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:869
Ssiz_t Length() const
Definition TString.h:417
const char * Data() const
Definition TString.h:376
virtual void Modified(Bool_t flag=1)=0
virtual void Update()=0
TF1 * f1
Definition legend1.C:11