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
35};
36
37////////////////////////////////////////////////////////////////////////////////
38/// Constructor for translation editor
39
41 Int_t height, UInt_t options, Pixel_t back)
42 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
43{
44 fTranslation = 0;
45 fDxi = fDyi = fDzi = 0.0;
46 fNamei = "";
49
50 // TextEntry for name
51 MakeTitle("Name");
52 fTransName = new TGTextEntry(this, new TGTextBuffer(50), kMATRIX_NAME);
54 fTransName->SetToolTipText("Enter the translation name");
55 fTransName->Associate(this);
57
58 TGTextEntry *nef;
59 MakeTitle("Translations on axes");
61 // Number entry for dx
62 TGCompositeFrame *f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
64 f1->AddFrame(new TGLabel(f1, "DX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
65 fTransDx = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
67 nef->SetToolTipText("Enter the translation on X");
68 fTransDx->Associate(this);
69 f1->AddFrame(fTransDx, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
70 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
71
72 // Number entry for dy
73 TGCompositeFrame *f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
75 f2->AddFrame(new TGLabel(f2, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
76 fTransDy = new TGNumberEntry(f2, 0., 5, kMATRIX_DY);
78 nef->SetToolTipText("Enter the translation on Y");
79 fTransDy->Associate(this);
81 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
82
83 // Number entry for dx
84 TGCompositeFrame *f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
86 f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
87 fTransDz = new TGNumberEntry(f3, 0., 5, kMATRIX_DZ);
89 nef->SetToolTipText("Enter the translation on Z");
90 fTransDz->Associate(this);
92 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
93
94 compxyz->Resize(150,30);
95 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
96
97 // Buttons
99 fApply = new TGTextButton(f23, "&Apply");
100 f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
101 fApply->Associate(this);
102 fCancel = new TGTextButton(f23, "&Cancel");
103 f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4));
104 fCancel->Associate(this);
105 fUndo = new TGTextButton(f23, " &Undo ");
106 f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
107 fUndo->Associate(this);
108 AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
111}
112
113////////////////////////////////////////////////////////////////////////////////
114/// Destructor.
115
117{
118 TGFrameElement *el;
119 TIter next(GetList());
120 while ((el = (TGFrameElement *)next())) {
121 if (el->fFrame->IsComposite())
123 }
124 Cleanup();
125}
126
127////////////////////////////////////////////////////////////////////////////////
128/// Connect signals to slots.
129
131{
132 fApply->Connect("Clicked()", "TGeoTranslationEditor", this, "DoApply()");
133 fCancel->Connect("Clicked()", "TGeoTranslationEditor", this, "DoCancel()");
134 fUndo->Connect("Clicked()", "TGeoTranslationEditor", this, "DoUndo()");
135 fTransName->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoModified()");
136 fTransDx->Connect("ValueSet(Long_t)", "TGeoTranslationEditor", this, "DoDx()");
137 fTransDy->Connect("ValueSet(Long_t)", "TGeoTranslationEditor", this, "DoDy()");
138 fTransDz->Connect("ValueSet(Long_t)", "TGeoTranslationEditor", this, "DoDz()");
139 fTransDx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoDx()");
140 fTransDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoDy()");
141 fTransDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoDz()");
142 fInit = kFALSE;
143}
144
145
146////////////////////////////////////////////////////////////////////////////////
147/// Connect to the new matrix.
148
150{
151 if (obj == 0 || (obj->IsA()!=TGeoTranslation::Class())) {
153 return;
154 }
159 const char *sname = fTranslation->GetName();
160 if (!strcmp(sname, fTranslation->ClassName())) fTransName->SetText("no_name");
161 else {
162 fTransName->SetText(sname);
163 fNamei = sname;
164 }
171
173 SetActive();
174}
175
176////////////////////////////////////////////////////////////////////////////////
177/// Slot for name.
178
180{
181 const char *name = fTransName->GetText();
182 if (!strcmp(name, "no_name") || !strcmp(name, fTranslation->GetName())) return;
184}
185
186////////////////////////////////////////////////////////////////////////////////
187/// Slot for checking parameters.
188
190{
194 Bool_t changed = kFALSE;
195 if (dx != fTranslation->GetTranslation()[0] ||
196 dy != fTranslation->GetTranslation()[1] ||
197 dz != fTranslation->GetTranslation()[2]) changed = kTRUE;
198 if (!changed) return kFALSE;
199 fUndo->SetEnabled();
200 fTranslation->SetTranslation(dx, dy, dz);
201 if (fPad) {
202 fPad->Modified();
203 fPad->Update();
204 }
205 return kTRUE;
206}
207
208////////////////////////////////////////////////////////////////////////////////
209/// Slot for applying changes.
210
212{
213 DoName();
214 if (DoParameters()) {
215 fUndo->SetEnabled();
218 }
219}
220
221////////////////////////////////////////////////////////////////////////////////
222/// Slot for cancelling last modifications non-applied.
223
225{
226 if (!fNamei.Length()) fTransName->SetText("no_name");
227 else fTransName->SetText(fNamei.Data());
234}
235
236////////////////////////////////////////////////////////////////////////////////
237/// Slot for notifying changes.
238
240{
243}
244
245////////////////////////////////////////////////////////////////////////////////
246/// Slot for undoing last operation.
247
249{
250 DoCancel();
251 DoParameters();
255}
256
257////////////////////////////////////////////////////////////////////////////////
258/// Slot for dx.
259
261{
262 DoModified();
263}
264
265////////////////////////////////////////////////////////////////////////////////
266/// Slot for dx.
267
269{
270 DoModified();
271}
272
273////////////////////////////////////////////////////////////////////////////////
274/// Slot for dx.
275
277{
278 DoModified();
279}
280
281/** \class TGeoRotationEditor
282\ingroup Geometry_builder
283
284Editor for a TGeoRotation.
285
286*/
287
289
290////////////////////////////////////////////////////////////////////////////////
291/// Constructor for rotation editor
292
294 Int_t height, UInt_t options, Pixel_t back)
295 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
296{
297 fRotation = 0;
298 fPhii = fThetai = fPsii = 0.0;
299 fAngleX = fAngleY = fAngleZ = 0.0;
300 fNamei = "";
303
304 // TextEntry for name
305 MakeTitle("Name");
306 fRotName = new TGTextEntry(this, new TGTextBuffer(50), kMATRIX_NAME);
308 fRotName->SetToolTipText("Enter the rotation name");
309 fRotName->Associate(this);
310 AddFrame(fRotName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
311
312 TGTextEntry *nef;
313 MakeTitle("Euler angles");
315 // Number entry for phi angle
316 TGCompositeFrame *f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
318 f1->AddFrame(new TGLabel(f1, " PHI "), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
319 fRotPhi = new TGNumberEntry(f1, 0., 5, kMATRIX_PHI);
321 nef->SetToolTipText("Modify the first rotation angle about Z");
322 fRotPhi->Associate(this);
324 f1->AddFrame(fRotPhi, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
325 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
326
327 // Number entry for theta angle
328 TGCompositeFrame *f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
330 f2->AddFrame(new TGLabel(f2, "THETA"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
331 fRotTheta = new TGNumberEntry(f2, 0., 5, kMATRIX_THETA);
333 nef->SetToolTipText("Modify the second rotation angle about the new X");
334 fRotTheta->Associate(this);
336 f2->AddFrame(fRotTheta, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
337 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
338
339 // Number entry for psi angle
340 TGCompositeFrame *f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
342 f3->AddFrame(new TGLabel(f3, " PSI "), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
343 fRotPsi = new TGNumberEntry(f3, 0., 5, kMATRIX_PSI);
345 nef->SetToolTipText("Modify the third rotation angle about Z");
346 fRotPsi->Associate(this);
348 f3->AddFrame(fRotPsi, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
349 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
350
351 compxyz->Resize(150,compxyz->GetDefaultHeight());
352 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
353
354 MakeTitle("Rotate about axis");
355 compxyz = new TGCompositeFrame(this, 140, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
356 // Number entry for rotation angle about one axis
357 f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
359 f1->AddFrame(new TGLabel(f1, "ANGLE"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
360 fRotAxis = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
362 nef->SetToolTipText("Enter the new rotation angle about the selected axis");
363 fRotAxis->Associate(this);
365 f1->AddFrame(fRotAxis, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
366 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
367
368 // Radio buttons group for axis selection
369 TGHButtonGroup *bg1 = new TGHButtonGroup(compxyz, " Axis ");
370 fRotX = new TGRadioButton(bg1, " &X ", kMATRIX_DX);
371 fRotY = new TGRadioButton(bg1, " &Y ", kMATRIX_DY);
372 fRotZ = new TGRadioButton(bg1, " &Z ", kMATRIX_DZ);
374 bg1->Show();
375 compxyz->AddFrame(bg1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
376
377 compxyz->Resize(150,compxyz->GetDefaultHeight());
378 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
379
380
381 // Buttons
383 fApply = new TGTextButton(f23, "Apply");
384 f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
385 fApply->Associate(this);
386 fCancel = new TGTextButton(f23, "Cancel");
387 f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4));
388 fCancel->Associate(this);
389 fUndo = new TGTextButton(f23, " Undo ");
390 f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
391 fUndo->Associate(this);
392 AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
395}
396
397////////////////////////////////////////////////////////////////////////////////
398/// Destructor
399
401{
402 TGFrameElement *el;
403 TIter next(GetList());
404 while ((el = (TGFrameElement *)next())) {
405 if (el->fFrame->IsComposite())
407 }
408 Cleanup();
409}
410
411////////////////////////////////////////////////////////////////////////////////
412/// Connect signals to slots.
413
415{
416 fApply->Connect("Clicked()", "TGeoRotationEditor", this, "DoApply()");
417 fCancel->Connect("Clicked()", "TGeoRotationEditor", this, "DoCancel()");
418 fUndo->Connect("Clicked()", "TGeoRotationEditor", this, "DoUndo()");
419 fRotName->Connect("TextChanged(const char *)", "TGeoRotationEditor", this, "DoModified()");
420 fRotPhi->Connect("ValueSet(Long_t)", "TGeoRotationEditor", this, "DoRotPhi()");
421 fRotTheta->Connect("ValueSet(Long_t)", "TGeoRotationEditor", this, "DoRotTheta()");
422 fRotPsi->Connect("ValueSet(Long_t)", "TGeoRotationEditor", this, "DoRotPsi()");
423 fRotAxis->Connect("ValueSet(Long_t)", "TGeoRotationEditor", this, "DoRotAngle()");
424 fInit = kFALSE;
425}
426
427
428////////////////////////////////////////////////////////////////////////////////
429/// Connect to the selected rotation.
430
432{
433 if (obj == 0 || (obj->IsA()!=TGeoRotation::Class())) {
435 return;
436 }
437 fRotation = (TGeoRotation*)obj;
439 const char *sname = fRotation->GetName();
440 if (!strcmp(sname, fRotation->ClassName())) fRotName->SetText("no_name");
441 else {
442 fRotName->SetText(sname);
443 fNamei = sname;
444 }
448 fRotAxis->SetNumber(0.0);
449
453
455 SetActive();
456}
457
458////////////////////////////////////////////////////////////////////////////////
459/// Slot for name.
460
462{
463 const char *name = fRotName->GetText();
464 if (!strcmp(name, "no_name") || !strcmp(name, fRotation->GetName())) return;
466}
467
468////////////////////////////////////////////////////////////////////////////////
469/// Slot for phi (Euler X convention)
470
472{
473 if (fRotPhi->GetNumber() < 0.) fRotPhi->SetNumber(fRotPhi->GetNumber()+360.);
474 if (fRotPhi->GetNumber() >= 360.) fRotPhi->SetNumber(fRotPhi->GetNumber()-360.);
475 DoModified();
476}
477
478////////////////////////////////////////////////////////////////////////////////
479/// Slot for theta (Euler X convention)
480
482{
484 if (fRotTheta->GetNumber() >= 360.) fRotTheta->SetNumber(fRotTheta->GetNumber()-360.);
485 DoModified();
486}
487
488////////////////////////////////////////////////////////////////////////////////
489/// Slot for psi (Euler X convention)
490
492{
493 if (fRotPsi->GetNumber() < 0.) fRotPsi->SetNumber(fRotPsi->GetNumber()+360.);
494 if (fRotPsi->GetNumber() >= 360.) fRotPsi->SetNumber(fRotPsi->GetNumber()-360.);
495 DoModified();
496}
497
498////////////////////////////////////////////////////////////////////////////////
499/// Slot for additional rotation about one axis.
500
502{
503 if (fRotAxis->GetNumber() < 0.) fRotAxis->SetNumber(fRotAxis->GetNumber()+360.);
504 if (fRotAxis->GetNumber() >= 360.) fRotAxis->SetNumber(fRotAxis->GetNumber()-360.);
505 DoModified();
506}
507
508////////////////////////////////////////////////////////////////////////////////
509/// Slot for checking parameters.
510
512{
513 Double_t phi = fRotPhi->GetNumber();
514 Double_t theta = fRotTheta->GetNumber();
515 Double_t psi = fRotPsi->GetNumber();
516 Double_t angle = fRotAxis->GetNumber();
517 Double_t phi0 = 0., theta0 = 0., psi0 = 0.;
518 fRotation->GetAngles(phi0,theta0,psi0);
519 Bool_t changed = kFALSE;
520 if (phi != psi0 || theta != theta0 || psi != psi0) changed = kTRUE;
521 if (changed) fRotation->SetAngles(phi, theta, psi);
522 // Check if we have to rotate about one axis
523 if (angle != 0.0) {
524 if (fRotX->IsOn()) {fRotation->RotateX(angle); changed = kTRUE;}
525 if (fRotY->IsOn()) {fRotation->RotateY(angle); changed = kTRUE;}
526 if (fRotZ->IsOn()) {fRotation->RotateZ(angle); changed = kTRUE;}
527 }
528 if (!changed) return kFALSE;
529 fRotAxis->SetNumber(0.0);
530 fUndo->SetEnabled();
531 if (fPad) {
532 fPad->Modified();
533 fPad->Update();
534 }
535 return kTRUE;
536}
537
538////////////////////////////////////////////////////////////////////////////////
539/// Slot for applying modifications.
540
542{
543 DoName();
544 if (DoParameters()) {
545 fUndo->SetEnabled();
548 }
549}
550
551////////////////////////////////////////////////////////////////////////////////
552/// Slot for cancelling last un-applied operations.
553
555{
556 if (!fNamei.Length()) fRotName->SetText("no_name");
557 else fRotName->SetText(fNamei.Data());
561 fRotAxis->SetNumber(0.0);
565}
566
567////////////////////////////////////////////////////////////////////////////////
568/// Slot for notifying changes.
569
571{
574}
575
576////////////////////////////////////////////////////////////////////////////////
577/// Slot for undoing last changes.
578
580{
581 DoCancel();
582 DoParameters();
586}
587
588/** \class TGeoCombiTransEditor
589\ingroup Geometry_builder
590
591Editor for a TGeoCombiTrans.
592
593*/
594
596
597////////////////////////////////////////////////////////////////////////////////
598/// Constructor for combi matrix editor
599
601 Int_t height, UInt_t options, Pixel_t back)
602 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
603{
604 fCombi = 0;
605 fPhii = fThetai = fPsii = 0.0;
606 fDxi = fDyi = fDzi = 0.0;
607 fAngleX = fAngleY = fAngleZ = 0.0;
608 fNamei = "";
611
612 // TextEntry for name
613 MakeTitle("Name");
614 fRotName = new TGTextEntry(this, new TGTextBuffer(50), kMATRIX_NAME);
616 fRotName->SetToolTipText("Enter the rotation name");
617 fRotName->Associate(this);
618 AddFrame(fRotName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
619
620 TGTextEntry *nef;
621 MakeTitle("Translations on axes");
623 // Number entry for dx
624 TGCompositeFrame *f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
626 f1->AddFrame(new TGLabel(f1, "DX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
627 fTransDx = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
629 nef->SetToolTipText("Enter the translation on X");
630 fTransDx->Associate(this);
631 f1->AddFrame(fTransDx, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
632 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
633
634 // Number entry for dy
635 TGCompositeFrame *f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
637 f2->AddFrame(new TGLabel(f2, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
638 fTransDy = new TGNumberEntry(f2, 0., 5, kMATRIX_DY);
640 nef->SetToolTipText("Enter the translation on Y");
641 fTransDy->Associate(this);
642 f2->AddFrame(fTransDy, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
643 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
644
645 // Number entry for dx
646 TGCompositeFrame *f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
648 f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
649 fTransDz = new TGNumberEntry(f3, 0., 5, kMATRIX_DZ);
651 nef->SetToolTipText("Enter the translation on Z");
652 fTransDz->Associate(this);
653 f3->AddFrame(fTransDz, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
654 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
655
656 compxyz->Resize(150,30);
657 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
658
659
660 MakeTitle("Euler angles");
661 compxyz = new TGCompositeFrame(this, 140, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
662 // Number entry for phi angle
663 f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
665 f1->AddFrame(new TGLabel(f1, " PHI "), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
666 fRotPhi = new TGNumberEntry(f1, 0., 5, kMATRIX_PHI);
668 nef->SetToolTipText("Modify the first rotation angle about Z");
669 fRotPhi->Associate(this);
671 f1->AddFrame(fRotPhi, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
672 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
673
674 // Number entry for theta angle
675 f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
677 f2->AddFrame(new TGLabel(f2, "THETA"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
678 fRotTheta = new TGNumberEntry(f2, 0., 5, kMATRIX_THETA);
680 nef->SetToolTipText("Modify the second rotation angle about the new X");
681 fRotTheta->Associate(this);
683 f2->AddFrame(fRotTheta, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
684 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
685
686 // Number entry for psi angle
687 f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
689 f3->AddFrame(new TGLabel(f3, " PSI "), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
690 fRotPsi = new TGNumberEntry(f3, 0., 5, kMATRIX_PSI);
692 nef->SetToolTipText("Modify the third rotation angle about Z");
693 fRotPsi->Associate(this);
695 f3->AddFrame(fRotPsi, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
696 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
697
698 compxyz->Resize(150,compxyz->GetDefaultHeight());
699 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
700
701 MakeTitle("Rotate about axis");
702 compxyz = new TGCompositeFrame(this, 140, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
703 // Number entry for rotation angle about one axis
704 f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
706 f1->AddFrame(new TGLabel(f1, "ANGLE"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
707 fRotAxis = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
709 nef->SetToolTipText("Enter the new rotation angle about the selected axis");
710 fRotAxis->Associate(this);
712 f1->AddFrame(fRotAxis, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
713 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
714
715 // Radio buttons group for axis selection
716 TGHButtonGroup *bg1 = new TGHButtonGroup(compxyz, " Axis ");
717 fRotX = new TGRadioButton(bg1, " &X ", kMATRIX_DX);
718 fRotY = new TGRadioButton(bg1, " &Y ", kMATRIX_DY);
719 fRotZ = new TGRadioButton(bg1, " &Z ", kMATRIX_DZ);
721 bg1->Show();
722 compxyz->AddFrame(bg1, 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
728 // Buttons
730 fApply = new TGTextButton(f23, "&Apply");
731 f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
732 fApply->Associate(this);
733 fCancel = new TGTextButton(f23, "&Cancel");
734 f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4));
735 fCancel->Associate(this);
736 fUndo = new TGTextButton(f23, " &Undo ");
737 f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
738 fUndo->Associate(this);
739 AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
742}
743
744////////////////////////////////////////////////////////////////////////////////
745/// Destructor
746
748{
749 TGFrameElement *el;
750 TIter next(GetList());
751 while ((el = (TGFrameElement *)next())) {
752 if (el->fFrame->IsComposite())
754 }
755 Cleanup();
756}
757
758////////////////////////////////////////////////////////////////////////////////
759/// Connect signals to slots.
760
762{
763 fApply->Connect("Clicked()", "TGeoCombiTransEditor", this, "DoApply()");
764 fCancel->Connect("Clicked()", "TGeoCombiTransEditor", this, "DoCancel()");
765 fUndo->Connect("Clicked()", "TGeoCombiTransEditor", this, "DoUndo()");
766 fRotName->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoModified()");
767 fRotPhi->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotPhi()");
768 fRotTheta->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotTheta()");
769 fRotPsi->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotPsi()");
770 fRotAxis->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotAngle()");
771 fTransDx->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoDx()");
772 fTransDy->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoDy()");
773 fTransDz->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoDz()");
774 fTransDx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoDx()");
775 fTransDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoDy()");
776 fTransDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoDz()");
777 fInit = kFALSE;
778}
779
780
781////////////////////////////////////////////////////////////////////////////////
782/// Connect to the selected combi matrix.
783
785{
786 if (obj == 0 || (obj->IsA()!=TGeoCombiTrans::Class())) {
788 return;
789 }
790 fCombi = (TGeoCombiTrans*)obj;
792 if (rot) rot->GetAngles(fPhii, fThetai, fPsii);
793 const char *sname = fCombi->GetName();
794 if (!strcmp(sname, fCombi->ClassName())) fRotName->SetText("no_name");
795 else {
796 fRotName->SetText(sname);
797 fNamei = sname;
798 }
799
800 fDxi = fCombi->GetTranslation()[0];
801 fDyi = fCombi->GetTranslation()[1];
802 fDzi = fCombi->GetTranslation()[2];
806
810 fRotAxis->SetNumber(0.0);
811
815
817 SetActive();
818}
819
820////////////////////////////////////////////////////////////////////////////////
821/// Slot for name.
822
824{
825 const char *name = fRotName->GetText();
826 if (!strcmp(name, "no_name") || !strcmp(name, fCombi->GetName())) return;
828}
829
830////////////////////////////////////////////////////////////////////////////////
831/// Slot for phi (Euler X convention)
832
834{
835 if (fRotPhi->GetNumber() < 0.) fRotPhi->SetNumber(fRotPhi->GetNumber()+360.);
836 if (fRotPhi->GetNumber() >= 360.) fRotPhi->SetNumber(fRotPhi->GetNumber()-360.);
837 DoModified();
838}
839
840////////////////////////////////////////////////////////////////////////////////
841/// Slot for theta (Euler X convention)
842
844{
846 if (fRotTheta->GetNumber() >= 360.) fRotTheta->SetNumber(fRotTheta->GetNumber()-360.);
847 DoModified();
848}
849
850////////////////////////////////////////////////////////////////////////////////
851/// Slot for psi (Euler X convention)
852
854{
855 if (fRotPsi->GetNumber() < 0.) fRotPsi->SetNumber(fRotPsi->GetNumber()+360.);
856 if (fRotPsi->GetNumber() >= 360.) fRotPsi->SetNumber(fRotPsi->GetNumber()-360.);
857 DoModified();
858}
859
860////////////////////////////////////////////////////////////////////////////////
861/// Slot for additional rotation about one axis.
862
864{
865 if (fRotAxis->GetNumber() < 0.) fRotAxis->SetNumber(fRotAxis->GetNumber()+360.);
866 if (fRotAxis->GetNumber() >= 360.) fRotAxis->SetNumber(fRotAxis->GetNumber()-360.);
867 DoModified();
868}
869
870////////////////////////////////////////////////////////////////////////////////
871/// Slot for checking parameters.
872
874{
878 Bool_t changedtr = kFALSE;
879 if (dx != fCombi->GetTranslation()[0] ||
880 dy != fCombi->GetTranslation()[1] ||
881 dz != fCombi->GetTranslation()[2]) changedtr = kTRUE;
882 if (changedtr) fCombi->SetTranslation(dx, dy, dz);
883 Double_t phi = fRotPhi->GetNumber();
884 Double_t theta = fRotTheta->GetNumber();
885 Double_t psi = fRotPsi->GetNumber();
886 Double_t angle = fRotAxis->GetNumber();
887 Double_t phi0 = 0., theta0 = 0., psi0 = 0.;
889 if (rot) rot->GetAngles(phi0,theta0,psi0);
890 else {
891 if (phi!=fPhii || theta!=fThetai || psi!=fPsii) {
892 TGeoRotation r("rot",10.,0.,0.);
894 rot = fCombi->GetRotation();
895 rot->SetAngles(0.,0.,0.);
896 }
897 }
898 Bool_t changed = kFALSE;
899 if (phi != psi0 || theta != theta0 || psi != psi0) changed = kTRUE;
900 if (changed && rot) rot->SetAngles(phi, theta, psi);
901 // Check if we have to rotate about one axis
902 if (angle != 0.0) {
903 if (fRotX->IsOn()) {fCombi->RotateX(angle); changed = kTRUE;}
904 if (fRotY->IsOn()) {fCombi->RotateY(angle); changed = kTRUE;}
905 if (fRotZ->IsOn()) {fCombi->RotateZ(angle); changed = kTRUE;}
906 }
907 if (changedtr) changed = kTRUE;
908 if (!changed) return kFALSE;
909 fRotAxis->SetNumber(0.0);
910 fUndo->SetEnabled();
911 if (fPad) {
912 fPad->Modified();
913 fPad->Update();
914 }
915 return kTRUE;
916}
917
918////////////////////////////////////////////////////////////////////////////////
919/// Slot for applying modifications.
920
922{
923 DoName();
924 if (DoParameters()) {
925 fUndo->SetEnabled();
928 }
929}
930
931////////////////////////////////////////////////////////////////////////////////
932/// Slot for cancelling last un-applied operations.
933
935{
936 if (!fNamei.Length()) fRotName->SetText("no_name");
937 else fRotName->SetText(fNamei.Data());
944 fRotAxis->SetNumber(0.0);
948}
949
950////////////////////////////////////////////////////////////////////////////////
951/// Slot for notifying changes.
952
954{
957}
958
959////////////////////////////////////////////////////////////////////////////////
960/// Slot for undoing last changes.
961
963{
964 DoCancel();
965 DoParameters();
969}
970
971////////////////////////////////////////////////////////////////////////////////
972/// Slot for X.
973
975{
976 DoModified();
977}
978
979////////////////////////////////////////////////////////////////////////////////
980/// Slot for Y.
981
983{
984 DoModified();
985}
986
987////////////////////////////////////////////////////////////////////////////////
988/// Slot for Z.
989
991{
992 DoModified();
993}
994
@ 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
@ kHorizontalFrame
Definition GuiTypes.h:382
@ kOwnBackground
Definition GuiTypes.h:391
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
ROOT::R::TRInterface & r
Definition Object.C:4
const Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
const Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:364
include TDocParser_001 C image html pict1_TDocParser_001 png width
@ 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
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 TList * GetList() const
Definition TGFrame.h:310
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:967
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:314
TGFrame * fFrame
Definition TGLayout.h:112
virtual void SetSize(const TGDimension &s)
Definition TGFrame.h:252
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
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition TGFrame.cxx:605
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.
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 void SetNumber(Double_t val, Bool_t emit=kTRUE)
Selects different options.
Definition TGButton.h:322
virtual Bool_t IsOn() const
Definition TGButton.h:370
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
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 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 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.
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.
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
virtual ~TGeoTranslationEditor()
Destructor.
void DoModified()
Slot for notifying changes.
void DoName()
Slot for name.
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.
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:41
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:200
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:410
const char * Data() const
Definition TString.h:369
virtual void Modified(Bool_t flag=1)=0
virtual void Update()=0
TF1 * f1
Definition legend1.C:11