Logo ROOT   6.18/05
Reference Guide
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 "TPad.h"
23#include "TGTab.h"
24#include "TGComboBox.h"
25#include "TGButton.h"
26#include "TGButtonGroup.h"
27#include "TGTextEntry.h"
28#include "TGNumberEntry.h"
29#include "TGLabel.h"
30
32
37};
38
39////////////////////////////////////////////////////////////////////////////////
40/// Constructor for translation editor
41
43 Int_t height, UInt_t options, Pixel_t back)
44 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
45{
46 fTranslation = 0;
47 fDxi = fDyi = fDzi = 0.0;
48 fNamei = "";
51
52 // TextEntry for name
53 MakeTitle("Name");
54 fTransName = new TGTextEntry(this, new TGTextBuffer(50), kMATRIX_NAME);
56 fTransName->SetToolTipText("Enter the translation name");
57 fTransName->Associate(this);
59
60 TGTextEntry *nef;
61 MakeTitle("Translations on axes");
63 // Number entry for dx
64 TGCompositeFrame *f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
66 f1->AddFrame(new TGLabel(f1, "DX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
67 fTransDx = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
69 nef->SetToolTipText("Enter the translation on X");
70 fTransDx->Associate(this);
71 f1->AddFrame(fTransDx, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
72 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
73
74 // Number entry for dy
75 TGCompositeFrame *f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
77 f2->AddFrame(new TGLabel(f2, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
78 fTransDy = new TGNumberEntry(f2, 0., 5, kMATRIX_DY);
80 nef->SetToolTipText("Enter the translation on Y");
81 fTransDy->Associate(this);
83 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
84
85 // Number entry for dx
86 TGCompositeFrame *f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
88 f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
89 fTransDz = new TGNumberEntry(f3, 0., 5, kMATRIX_DZ);
91 nef->SetToolTipText("Enter the translation on Z");
92 fTransDz->Associate(this);
94 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
95
96 compxyz->Resize(150,30);
97 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
98
99 // Buttons
101 fApply = new TGTextButton(f23, "&Apply");
102 f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
103 fApply->Associate(this);
104 fCancel = new TGTextButton(f23, "&Cancel");
105 f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4));
106 fCancel->Associate(this);
107 fUndo = new TGTextButton(f23, " &Undo ");
108 f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
109 fUndo->Associate(this);
110 AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
113}
114
115////////////////////////////////////////////////////////////////////////////////
116/// Destructor.
117
119{
120 TGFrameElement *el;
121 TIter next(GetList());
122 while ((el = (TGFrameElement *)next())) {
123 if (el->fFrame->IsComposite())
125 }
126 Cleanup();
127}
128
129////////////////////////////////////////////////////////////////////////////////
130/// Connect signals to slots.
131
133{
134 fApply->Connect("Clicked()", "TGeoTranslationEditor", this, "DoApply()");
135 fCancel->Connect("Clicked()", "TGeoTranslationEditor", this, "DoCancel()");
136 fUndo->Connect("Clicked()", "TGeoTranslationEditor", this, "DoUndo()");
137 fTransName->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoModified()");
138 fTransDx->Connect("ValueSet(Long_t)", "TGeoTranslationEditor", this, "DoDx()");
139 fTransDy->Connect("ValueSet(Long_t)", "TGeoTranslationEditor", this, "DoDy()");
140 fTransDz->Connect("ValueSet(Long_t)", "TGeoTranslationEditor", this, "DoDz()");
141 fTransDx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoDx()");
142 fTransDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoDy()");
143 fTransDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoDz()");
144 fInit = kFALSE;
145}
146
147
148////////////////////////////////////////////////////////////////////////////////
149/// Connect to the new matrix.
150
152{
153 if (obj == 0 || (obj->IsA()!=TGeoTranslation::Class())) {
155 return;
156 }
161 const char *sname = fTranslation->GetName();
162 if (!strcmp(sname, fTranslation->ClassName())) fTransName->SetText("no_name");
163 else {
164 fTransName->SetText(sname);
165 fNamei = sname;
166 }
173
175 SetActive();
176}
177
178////////////////////////////////////////////////////////////////////////////////
179/// Slot for name.
180
182{
183 const char *name = fTransName->GetText();
184 if (!strcmp(name, "no_name") || !strcmp(name, fTranslation->GetName())) return;
186}
187
188////////////////////////////////////////////////////////////////////////////////
189/// Slot for checking parameters.
190
192{
196 Bool_t changed = kFALSE;
197 if (dx != fTranslation->GetTranslation()[0] ||
198 dy != fTranslation->GetTranslation()[1] ||
199 dz != fTranslation->GetTranslation()[2]) changed = kTRUE;
200 if (!changed) return kFALSE;
201 fUndo->SetEnabled();
202 fTranslation->SetTranslation(dx, dy, dz);
203 if (fPad) {
204 fPad->Modified();
205 fPad->Update();
206 }
207 return kTRUE;
208}
209
210////////////////////////////////////////////////////////////////////////////////
211/// Slot for applying changes.
212
214{
215 DoName();
216 if (DoParameters()) {
217 fUndo->SetEnabled();
220 }
221}
222
223////////////////////////////////////////////////////////////////////////////////
224/// Slot for cancelling last modifications non-applied.
225
227{
228 if (!fNamei.Length()) fTransName->SetText("no_name");
229 else fTransName->SetText(fNamei.Data());
236}
237
238////////////////////////////////////////////////////////////////////////////////
239/// Slot for notifying changes.
240
242{
245}
246
247////////////////////////////////////////////////////////////////////////////////
248/// Slot for undoing last operation.
249
251{
252 DoCancel();
253 DoParameters();
257}
258
259////////////////////////////////////////////////////////////////////////////////
260/// Slot for dx.
261
263{
264 DoModified();
265}
266
267////////////////////////////////////////////////////////////////////////////////
268/// Slot for dx.
269
271{
272 DoModified();
273}
274
275////////////////////////////////////////////////////////////////////////////////
276/// Slot for dx.
277
279{
280 DoModified();
281}
282
283/** \class TGeoRotationEditor
284\ingroup Geometry_builder
285
286Editor for a TGeoRotation.
287
288*/
289
291
292////////////////////////////////////////////////////////////////////////////////
293/// Constructor for rotation editor
294
296 Int_t height, UInt_t options, Pixel_t back)
297 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
298{
299 fRotation = 0;
300 fPhii = fThetai = fPsii = 0.0;
301 fAngleX = fAngleY = fAngleZ = 0.0;
302 fNamei = "";
305
306 // TextEntry for name
307 MakeTitle("Name");
308 fRotName = new TGTextEntry(this, new TGTextBuffer(50), kMATRIX_NAME);
310 fRotName->SetToolTipText("Enter the rotation name");
311 fRotName->Associate(this);
312 AddFrame(fRotName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
313
314 TGTextEntry *nef;
315 MakeTitle("Euler angles");
317 // Number entry for phi angle
318 TGCompositeFrame *f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
320 f1->AddFrame(new TGLabel(f1, " PHI "), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
321 fRotPhi = new TGNumberEntry(f1, 0., 5, kMATRIX_PHI);
323 nef->SetToolTipText("Modify the first rotation angle about Z");
324 fRotPhi->Associate(this);
326 f1->AddFrame(fRotPhi, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
327 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
328
329 // Number entry for theta angle
330 TGCompositeFrame *f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
332 f2->AddFrame(new TGLabel(f2, "THETA"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
333 fRotTheta = new TGNumberEntry(f2, 0., 5, kMATRIX_THETA);
335 nef->SetToolTipText("Modify the second rotation angle about the new X");
336 fRotTheta->Associate(this);
338 f2->AddFrame(fRotTheta, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
339 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
340
341 // Number entry for psi angle
342 TGCompositeFrame *f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
344 f3->AddFrame(new TGLabel(f3, " PSI "), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
345 fRotPsi = new TGNumberEntry(f3, 0., 5, kMATRIX_PSI);
347 nef->SetToolTipText("Modify the third rotation angle about Z");
348 fRotPsi->Associate(this);
350 f3->AddFrame(fRotPsi, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
351 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
352
353 compxyz->Resize(150,compxyz->GetDefaultHeight());
354 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
355
356 MakeTitle("Rotate about axis");
357 compxyz = new TGCompositeFrame(this, 140, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
358 // Number entry for rotation angle about one axis
359 f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
361 f1->AddFrame(new TGLabel(f1, "ANGLE"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
362 fRotAxis = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
364 nef->SetToolTipText("Enter the new rotation angle about the selected axis");
365 fRotAxis->Associate(this);
367 f1->AddFrame(fRotAxis, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
368 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
369
370 // Radio buttons group for axis selection
371 TGHButtonGroup *bg1 = new TGHButtonGroup(compxyz, " Axis ");
372 fRotX = new TGRadioButton(bg1, " &X ", kMATRIX_DX);
373 fRotY = new TGRadioButton(bg1, " &Y ", kMATRIX_DY);
374 fRotZ = new TGRadioButton(bg1, " &Z ", kMATRIX_DZ);
376 bg1->Show();
377 compxyz->AddFrame(bg1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
378
379 compxyz->Resize(150,compxyz->GetDefaultHeight());
380 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
381
382
383 // Buttons
385 fApply = new TGTextButton(f23, "Apply");
386 f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
387 fApply->Associate(this);
388 fCancel = new TGTextButton(f23, "Cancel");
389 f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4));
390 fCancel->Associate(this);
391 fUndo = new TGTextButton(f23, " Undo ");
392 f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
393 fUndo->Associate(this);
394 AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
397}
398
399////////////////////////////////////////////////////////////////////////////////
400/// Destructor
401
403{
404 TGFrameElement *el;
405 TIter next(GetList());
406 while ((el = (TGFrameElement *)next())) {
407 if (el->fFrame->IsComposite())
409 }
410 Cleanup();
411}
412
413////////////////////////////////////////////////////////////////////////////////
414/// Connect signals to slots.
415
417{
418 fApply->Connect("Clicked()", "TGeoRotationEditor", this, "DoApply()");
419 fCancel->Connect("Clicked()", "TGeoRotationEditor", this, "DoCancel()");
420 fUndo->Connect("Clicked()", "TGeoRotationEditor", this, "DoUndo()");
421 fRotName->Connect("TextChanged(const char *)", "TGeoRotationEditor", this, "DoModified()");
422 fRotPhi->Connect("ValueSet(Long_t)", "TGeoRotationEditor", this, "DoRotPhi()");
423 fRotTheta->Connect("ValueSet(Long_t)", "TGeoRotationEditor", this, "DoRotTheta()");
424 fRotPsi->Connect("ValueSet(Long_t)", "TGeoRotationEditor", this, "DoRotPsi()");
425 fRotAxis->Connect("ValueSet(Long_t)", "TGeoRotationEditor", this, "DoRotAngle()");
426 fInit = kFALSE;
427}
428
429
430////////////////////////////////////////////////////////////////////////////////
431/// Connect to the selected rotation.
432
434{
435 if (obj == 0 || (obj->IsA()!=TGeoRotation::Class())) {
437 return;
438 }
439 fRotation = (TGeoRotation*)obj;
441 const char *sname = fRotation->GetName();
442 if (!strcmp(sname, fRotation->ClassName())) fRotName->SetText("no_name");
443 else {
444 fRotName->SetText(sname);
445 fNamei = sname;
446 }
450 fRotAxis->SetNumber(0.0);
451
455
457 SetActive();
458}
459
460////////////////////////////////////////////////////////////////////////////////
461/// Slot for name.
462
464{
465 const char *name = fRotName->GetText();
466 if (!strcmp(name, "no_name") || !strcmp(name, fRotation->GetName())) return;
468}
469
470////////////////////////////////////////////////////////////////////////////////
471/// Slot for phi (Euler X convention)
472
474{
475 if (fRotPhi->GetNumber() < 0.) fRotPhi->SetNumber(fRotPhi->GetNumber()+360.);
476 if (fRotPhi->GetNumber() >= 360.) fRotPhi->SetNumber(fRotPhi->GetNumber()-360.);
477 DoModified();
478}
479
480////////////////////////////////////////////////////////////////////////////////
481/// Slot for theta (Euler X convention)
482
484{
486 if (fRotTheta->GetNumber() >= 360.) fRotTheta->SetNumber(fRotTheta->GetNumber()-360.);
487 DoModified();
488}
489
490////////////////////////////////////////////////////////////////////////////////
491/// Slot for psi (Euler X convention)
492
494{
495 if (fRotPsi->GetNumber() < 0.) fRotPsi->SetNumber(fRotPsi->GetNumber()+360.);
496 if (fRotPsi->GetNumber() >= 360.) fRotPsi->SetNumber(fRotPsi->GetNumber()-360.);
497 DoModified();
498}
499
500////////////////////////////////////////////////////////////////////////////////
501/// Slot for additional rotation about one axis.
502
504{
505 if (fRotAxis->GetNumber() < 0.) fRotAxis->SetNumber(fRotAxis->GetNumber()+360.);
506 if (fRotAxis->GetNumber() >= 360.) fRotAxis->SetNumber(fRotAxis->GetNumber()-360.);
507 DoModified();
508}
509
510////////////////////////////////////////////////////////////////////////////////
511/// Slot for checking parameters.
512
514{
515 Double_t phi = fRotPhi->GetNumber();
516 Double_t theta = fRotTheta->GetNumber();
517 Double_t psi = fRotPsi->GetNumber();
518 Double_t angle = fRotAxis->GetNumber();
519 Double_t phi0 = 0., theta0 = 0., psi0 = 0.;
520 fRotation->GetAngles(phi0,theta0,psi0);
521 Bool_t changed = kFALSE;
522 if (phi != psi0 || theta != theta0 || psi != psi0) changed = kTRUE;
523 if (changed) fRotation->SetAngles(phi, theta, psi);
524 // Check if we have to rotate about one axis
525 if (angle != 0.0) {
526 if (fRotX->IsOn()) {fRotation->RotateX(angle); changed = kTRUE;}
527 if (fRotY->IsOn()) {fRotation->RotateY(angle); changed = kTRUE;}
528 if (fRotZ->IsOn()) {fRotation->RotateZ(angle); changed = kTRUE;}
529 }
530 if (!changed) return kFALSE;
531 fRotAxis->SetNumber(0.0);
532 fUndo->SetEnabled();
533 if (fPad) {
534 fPad->Modified();
535 fPad->Update();
536 }
537 return kTRUE;
538}
539
540////////////////////////////////////////////////////////////////////////////////
541/// Slot for applying modifications.
542
544{
545 DoName();
546 if (DoParameters()) {
547 fUndo->SetEnabled();
550 }
551}
552
553////////////////////////////////////////////////////////////////////////////////
554/// Slot for cancelling last un-applied operations.
555
557{
558 if (!fNamei.Length()) fRotName->SetText("no_name");
559 else fRotName->SetText(fNamei.Data());
563 fRotAxis->SetNumber(0.0);
567}
568
569////////////////////////////////////////////////////////////////////////////////
570/// Slot for notifying changes.
571
573{
576}
577
578////////////////////////////////////////////////////////////////////////////////
579/// Slot for undoing last changes.
580
582{
583 DoCancel();
584 DoParameters();
588}
589
590/** \class TGeoCombiTransEditor
591\ingroup Geometry_builder
592
593Editor for a TGeoCombiTrans.
594
595*/
596
598
599////////////////////////////////////////////////////////////////////////////////
600/// Constructor for combi matrix editor
601
603 Int_t height, UInt_t options, Pixel_t back)
604 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
605{
606 fCombi = 0;
607 fPhii = fThetai = fPsii = 0.0;
608 fDxi = fDyi = fDzi = 0.0;
609 fAngleX = fAngleY = fAngleZ = 0.0;
610 fNamei = "";
613
614 // TextEntry for name
615 MakeTitle("Name");
616 fRotName = new TGTextEntry(this, new TGTextBuffer(50), kMATRIX_NAME);
618 fRotName->SetToolTipText("Enter the rotation name");
619 fRotName->Associate(this);
620 AddFrame(fRotName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
621
622 TGTextEntry *nef;
623 MakeTitle("Translations on axes");
625 // Number entry for dx
626 TGCompositeFrame *f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
628 f1->AddFrame(new TGLabel(f1, "DX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
629 fTransDx = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
631 nef->SetToolTipText("Enter the translation on X");
632 fTransDx->Associate(this);
633 f1->AddFrame(fTransDx, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
634 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
635
636 // Number entry for dy
637 TGCompositeFrame *f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
639 f2->AddFrame(new TGLabel(f2, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
640 fTransDy = new TGNumberEntry(f2, 0., 5, kMATRIX_DY);
642 nef->SetToolTipText("Enter the translation on Y");
643 fTransDy->Associate(this);
644 f2->AddFrame(fTransDy, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
645 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
646
647 // Number entry for dx
648 TGCompositeFrame *f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
650 f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
651 fTransDz = new TGNumberEntry(f3, 0., 5, kMATRIX_DZ);
653 nef->SetToolTipText("Enter the translation on Z");
654 fTransDz->Associate(this);
655 f3->AddFrame(fTransDz, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
656 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
657
658 compxyz->Resize(150,30);
659 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
660
661
662 MakeTitle("Euler angles");
663 compxyz = new TGCompositeFrame(this, 140, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
664 // Number entry for phi angle
665 f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
667 f1->AddFrame(new TGLabel(f1, " PHI "), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
668 fRotPhi = new TGNumberEntry(f1, 0., 5, kMATRIX_PHI);
670 nef->SetToolTipText("Modify the first rotation angle about Z");
671 fRotPhi->Associate(this);
673 f1->AddFrame(fRotPhi, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
674 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
675
676 // Number entry for theta angle
677 f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
679 f2->AddFrame(new TGLabel(f2, "THETA"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
680 fRotTheta = new TGNumberEntry(f2, 0., 5, kMATRIX_THETA);
682 nef->SetToolTipText("Modify the second rotation angle about the new X");
683 fRotTheta->Associate(this);
685 f2->AddFrame(fRotTheta, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
686 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
687
688 // Number entry for psi angle
689 f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
691 f3->AddFrame(new TGLabel(f3, " PSI "), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
692 fRotPsi = new TGNumberEntry(f3, 0., 5, kMATRIX_PSI);
694 nef->SetToolTipText("Modify the third rotation angle about Z");
695 fRotPsi->Associate(this);
697 f3->AddFrame(fRotPsi, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
698 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
699
700 compxyz->Resize(150,compxyz->GetDefaultHeight());
701 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
702
703 MakeTitle("Rotate about axis");
704 compxyz = new TGCompositeFrame(this, 140, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
705 // Number entry for rotation angle about one axis
706 f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
708 f1->AddFrame(new TGLabel(f1, "ANGLE"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
709 fRotAxis = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
711 nef->SetToolTipText("Enter the new rotation angle about the selected axis");
712 fRotAxis->Associate(this);
714 f1->AddFrame(fRotAxis, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
715 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
716
717 // Radio buttons group for axis selection
718 TGHButtonGroup *bg1 = new TGHButtonGroup(compxyz, " Axis ");
719 fRotX = new TGRadioButton(bg1, " &X ", kMATRIX_DX);
720 fRotY = new TGRadioButton(bg1, " &Y ", kMATRIX_DY);
721 fRotZ = new TGRadioButton(bg1, " &Z ", kMATRIX_DZ);
723 bg1->Show();
724 compxyz->AddFrame(bg1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
725
726 compxyz->Resize(150,compxyz->GetDefaultHeight());
727 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
728
729
730 // Buttons
732 fApply = new TGTextButton(f23, "&Apply");
733 f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
734 fApply->Associate(this);
735 fCancel = new TGTextButton(f23, "&Cancel");
736 f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4));
737 fCancel->Associate(this);
738 fUndo = new TGTextButton(f23, " &Undo ");
739 f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
740 fUndo->Associate(this);
741 AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
744}
745
746////////////////////////////////////////////////////////////////////////////////
747/// Destructor
748
750{
751 TGFrameElement *el;
752 TIter next(GetList());
753 while ((el = (TGFrameElement *)next())) {
754 if (el->fFrame->IsComposite())
756 }
757 Cleanup();
758}
759
760////////////////////////////////////////////////////////////////////////////////
761/// Connect signals to slots.
762
764{
765 fApply->Connect("Clicked()", "TGeoCombiTransEditor", this, "DoApply()");
766 fCancel->Connect("Clicked()", "TGeoCombiTransEditor", this, "DoCancel()");
767 fUndo->Connect("Clicked()", "TGeoCombiTransEditor", this, "DoUndo()");
768 fRotName->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoModified()");
769 fRotPhi->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotPhi()");
770 fRotTheta->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotTheta()");
771 fRotPsi->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotPsi()");
772 fRotAxis->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotAngle()");
773 fTransDx->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoDx()");
774 fTransDy->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoDy()");
775 fTransDz->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoDz()");
776 fTransDx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoDx()");
777 fTransDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoDy()");
778 fTransDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoDz()");
779 fInit = kFALSE;
780}
781
782
783////////////////////////////////////////////////////////////////////////////////
784/// Connect to the selected combi matrix.
785
787{
788 if (obj == 0 || (obj->IsA()!=TGeoCombiTrans::Class())) {
790 return;
791 }
792 fCombi = (TGeoCombiTrans*)obj;
794 if (rot) rot->GetAngles(fPhii, fThetai, fPsii);
795 const char *sname = fCombi->GetName();
796 if (!strcmp(sname, fCombi->ClassName())) fRotName->SetText("no_name");
797 else {
798 fRotName->SetText(sname);
799 fNamei = sname;
800 }
801
802 fDxi = fCombi->GetTranslation()[0];
803 fDyi = fCombi->GetTranslation()[1];
804 fDzi = fCombi->GetTranslation()[2];
808
812 fRotAxis->SetNumber(0.0);
813
817
819 SetActive();
820}
821
822////////////////////////////////////////////////////////////////////////////////
823/// Slot for name.
824
826{
827 const char *name = fRotName->GetText();
828 if (!strcmp(name, "no_name") || !strcmp(name, fCombi->GetName())) return;
830}
831
832////////////////////////////////////////////////////////////////////////////////
833/// Slot for phi (Euler X convention)
834
836{
837 if (fRotPhi->GetNumber() < 0.) fRotPhi->SetNumber(fRotPhi->GetNumber()+360.);
838 if (fRotPhi->GetNumber() >= 360.) fRotPhi->SetNumber(fRotPhi->GetNumber()-360.);
839 DoModified();
840}
841
842////////////////////////////////////////////////////////////////////////////////
843/// Slot for theta (Euler X convention)
844
846{
848 if (fRotTheta->GetNumber() >= 360.) fRotTheta->SetNumber(fRotTheta->GetNumber()-360.);
849 DoModified();
850}
851
852////////////////////////////////////////////////////////////////////////////////
853/// Slot for psi (Euler X convention)
854
856{
857 if (fRotPsi->GetNumber() < 0.) fRotPsi->SetNumber(fRotPsi->GetNumber()+360.);
858 if (fRotPsi->GetNumber() >= 360.) fRotPsi->SetNumber(fRotPsi->GetNumber()-360.);
859 DoModified();
860}
861
862////////////////////////////////////////////////////////////////////////////////
863/// Slot for additional rotation about one axis.
864
866{
867 if (fRotAxis->GetNumber() < 0.) fRotAxis->SetNumber(fRotAxis->GetNumber()+360.);
868 if (fRotAxis->GetNumber() >= 360.) fRotAxis->SetNumber(fRotAxis->GetNumber()-360.);
869 DoModified();
870}
871
872////////////////////////////////////////////////////////////////////////////////
873/// Slot for checking parameters.
874
876{
880 Bool_t changedtr = kFALSE;
881 if (dx != fCombi->GetTranslation()[0] ||
882 dy != fCombi->GetTranslation()[1] ||
883 dz != fCombi->GetTranslation()[2]) changedtr = kTRUE;
884 if (changedtr) fCombi->SetTranslation(dx, dy, dz);
885 Double_t phi = fRotPhi->GetNumber();
886 Double_t theta = fRotTheta->GetNumber();
887 Double_t psi = fRotPsi->GetNumber();
888 Double_t angle = fRotAxis->GetNumber();
889 Double_t phi0 = 0., theta0 = 0., psi0 = 0.;
891 if (rot) rot->GetAngles(phi0,theta0,psi0);
892 else {
893 if (phi!=fPhii || theta!=fThetai || psi!=fPsii) {
894 TGeoRotation r("rot",10.,0.,0.);
896 rot = fCombi->GetRotation();
897 rot->SetAngles(0.,0.,0.);
898 }
899 }
900 Bool_t changed = kFALSE;
901 if (phi != psi0 || theta != theta0 || psi != psi0) changed = kTRUE;
902 if (changed && rot) rot->SetAngles(phi, theta, psi);
903 // Check if we have to rotate about one axis
904 if (angle != 0.0) {
905 if (fRotX->IsOn()) {fCombi->RotateX(angle); changed = kTRUE;}
906 if (fRotY->IsOn()) {fCombi->RotateY(angle); changed = kTRUE;}
907 if (fRotZ->IsOn()) {fCombi->RotateZ(angle); changed = kTRUE;}
908 }
909 if (changedtr) changed = kTRUE;
910 if (!changed) return kFALSE;
911 fRotAxis->SetNumber(0.0);
912 fUndo->SetEnabled();
913 if (fPad) {
914 fPad->Modified();
915 fPad->Update();
916 }
917 return kTRUE;
918}
919
920////////////////////////////////////////////////////////////////////////////////
921/// Slot for applying modifications.
922
924{
925 DoName();
926 if (DoParameters()) {
927 fUndo->SetEnabled();
930 }
931}
932
933////////////////////////////////////////////////////////////////////////////////
934/// Slot for cancelling last un-applied operations.
935
937{
938 if (!fNamei.Length()) fRotName->SetText("no_name");
939 else fRotName->SetText(fNamei.Data());
946 fRotAxis->SetNumber(0.0);
950}
951
952////////////////////////////////////////////////////////////////////////////////
953/// Slot for notifying changes.
954
956{
959}
960
961////////////////////////////////////////////////////////////////////////////////
962/// Slot for undoing last changes.
963
965{
966 DoCancel();
967 DoParameters();
971}
972
973////////////////////////////////////////////////////////////////////////////////
974/// Slot for X.
975
977{
978 DoModified();
979}
980
981////////////////////////////////////////////////////////////////////////////////
982/// Slot for Y.
983
985{
986 DoModified();
987}
988
989////////////////////////////////////////////////////////////////////////////////
990/// Slot for Z.
991
993{
994 DoModified();
995}
996
void Class()
Definition: Class.C:29
ULong_t Pixel_t
Definition: GuiTypes.h:39
ROOT::R::TRInterface & r
Definition: Object.C:4
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:365
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
@ kButtonDisabled
Definition: TGButton.h:56
@ kRaisedFrame
Definition: TGFrame.h:62
@ kSunkenFrame
Definition: TGFrame.h:61
@ kVerticalFrame
Definition: TGFrame.h:59
@ kDoubleBorder
Definition: TGFrame.h:63
@ kFixedWidth
Definition: TGFrame.h:65
@ kHorizontalFrame
Definition: TGFrame.h:60
@ kOwnBackground
Definition: TGFrame.h:69
@ kLHintsRight
Definition: TGLayout.h:33
@ kLHintsLeft
Definition: TGLayout.h:31
@ kLHintsCenterX
Definition: TGLayout.h:32
@ kLHintsExpandX
Definition: TGLayout.h:37
char name[80]
Definition: TGX11.cxx:109
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:409
virtual TList * GetList() const
Definition: TGFrame.h:369
TGCompositeFrame(const TGCompositeFrame &)
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:949
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:373
TGFrame * fFrame
Definition: TGLayout.h:119
virtual void SetSize(const TGDimension &s)
Definition: TGFrame.h:299
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:238
TGDimension GetSize() const
Definition: TGFrame.h:277
virtual Bool_t IsComposite() const
Definition: TGFrame.h:259
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
virtual void SetNumber(Double_t val)
UInt_t GetDefaultHeight() const
TGNumberEntryField * GetNumberEntry() const
virtual void Associate(const TGWindow *w)
Make w the window that will receive the generated messages.
virtual Double_t GetNumber() const
virtual Bool_t IsOn() const
Definition: TGButton.h:370
const char * GetText() const
Definition: TGTextEntry.h:134
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:84
Bool_t fInit
Definition: TGedFrame.h:53
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
Editor for a TGeoCombiTrans.
TGNumberEntry * fTransDy
TGNumberEntry * fRotPsi
TGNumberEntry * fRotAxis
TGeoCombiTransEditor(const TGWindow *p=0, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for combi matrix editor.
void DoRotPsi()
Slot for psi (Euler X convention)
virtual ~TGeoCombiTransEditor()
Destructor.
TGNumberEntry * fTransDz
void DoModified()
Slot for notifying changes.
void DoDz()
Slot for Z.
TGTextButton * fCancel
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.
TGRadioButton * fRotX
TGeoCombiTrans * fCombi
void DoDx()
Slot for X.
TGRadioButton * fRotY
void DoRotPhi()
Slot for phi (Euler X convention)
TGNumberEntry * fRotPhi
TGRadioButton * fRotZ
void DoApply()
Slot for applying modifications.
void DoDy()
Slot for Y.
TGNumberEntry * fRotTheta
virtual void SetModel(TObject *obj)
Connect to the selected combi matrix.
virtual void ConnectSignals2Slots()
Connect signals to slots.
void DoRotTheta()
Slot for theta (Euler X convention)
void DoCancel()
Slot for cancelling last un-applied operations.
TGNumberEntry * fTransDx
Class describing rotation + translation.
Definition: TGeoMatrix.h:292
virtual const Double_t * GetTranslation() const
Definition: TGeoMatrix.h:336
virtual void RotateZ(Double_t angle)
Rotate about Z axis with angle expressed in degrees.
TGeoRotation * GetRotation() const
Definition: TGeoMatrix.h:334
void SetTranslation(const TGeoTranslation &tr)
copy the translation component
void SetRotation(const TGeoRotation &other)
Copy the rotation from another one.
virtual void RotateY(Double_t angle)
Rotate about Y axis with angle expressed in degrees.
virtual void RotateX(Double_t angle)
Rotate about X axis with angle expressed in degrees.
Common base class for geombuilder editors.
Definition: TGeoGedFrame.h:13
TVirtualPad * fPad
Definition: TGeoGedFrame.h:18
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.
virtual ~TGeoRotationEditor()
Destructor.
TGeoRotationEditor(const TGWindow *p=0, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for rotation editor.
void DoName()
Slot for name.
TGeoRotation * fRotation
TGRadioButton * fRotZ
Bool_t DoParameters()
Slot for checking parameters.
TGTextButton * fCancel
void DoModified()
Slot for notifying changes.
virtual void SetModel(TObject *obj)
Connect to the selected rotation.
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
void DoRotTheta()
Slot for theta (Euler X convention)
TGNumberEntry * fRotPsi
Class describing rotations.
Definition: TGeoMatrix.h:175
virtual void RotateY(Double_t angle)
Rotate about Y 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.
virtual void RotateX(Double_t angle)
Rotate about X 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.
virtual void RotateZ(Double_t angle)
Rotate about Z axis of the master frame with angle expressed in degrees.
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hierarchically all daughters of a composite frame.
Editor for a TGeoTranslation.
TGeoTranslation * fTranslation
TGTextEntry * fTransName
virtual ~TGeoTranslationEditor()
Destructor.
void DoModified()
Slot for notifying changes.
void DoName()
Slot for name.
TGTextButton * fCancel
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
TGeoTranslationEditor(const TGWindow *p=0, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for translation editor.
virtual void SetModel(TObject *obj)
Connect to the new matrix.
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:122
virtual const Double_t * GetTranslation() const
Definition: TGeoMatrix.h:160
void SetTranslation(Double_t dx, Double_t dy, Double_t dz)
Set translation components.
Definition: TGeoMatrix.cxx:750
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Mother of all ROOT objects.
Definition: TObject.h:37
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:128
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:867
Ssiz_t Length() const
Definition: TString.h:405
const char * Data() const
Definition: TString.h:364
virtual void Modified(Bool_t flag=1)=0
virtual void Update()=0
TF1 * f1
Definition: legend1.C:11