Logo ROOT   6.10/09
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 //______________________________________________________________________________
13 //
14 // TGeoTranslationEditor, TGeoRotationEditor, TGeoCombiTransEditor
15 // Editors for different types of TGeo matrices.
16 //______________________________________________________________________________
17 
18 #include "TGeoMatrixEditor.h"
19 #include "TGeoTabManager.h"
20 #include "TGeoMatrix.h"
21 #include "TPad.h"
22 #include "TGTab.h"
23 #include "TGComboBox.h"
24 #include "TGButton.h"
25 #include "TGButtonGroup.h"
26 #include "TGTextEntry.h"
27 #include "TGNumberEntry.h"
28 #include "TGLabel.h"
29 
31 
36 };
37 
38 ////////////////////////////////////////////////////////////////////////////////
39 /// Constructor for translation editor
40 
42  Int_t height, UInt_t options, Pixel_t back)
43  : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
44 {
45  fTranslation = 0;
46  fDxi = fDyi = fDzi = 0.0;
47  fNamei = "";
50 
51  // TextEntry for name
52  MakeTitle("Name");
53  fTransName = new TGTextEntry(this, new TGTextBuffer(50), kMATRIX_NAME);
55  fTransName->SetToolTipText("Enter the translation name");
56  fTransName->Associate(this);
57  AddFrame(fTransName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
58 
59  TGTextEntry *nef;
60  MakeTitle("Translations on axes");
62  // Number entry for dx
63  TGCompositeFrame *f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
65  f1->AddFrame(new TGLabel(f1, "DX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
66  fTransDx = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
68  nef->SetToolTipText("Enter the translation on X");
69  fTransDx->Associate(this);
70  f1->AddFrame(fTransDx, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
71  compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
72 
73  // Number entry for dy
74  TGCompositeFrame *f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
76  f2->AddFrame(new TGLabel(f2, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
77  fTransDy = new TGNumberEntry(f2, 0., 5, kMATRIX_DY);
79  nef->SetToolTipText("Enter the translation on Y");
80  fTransDy->Associate(this);
81  f2->AddFrame(fTransDy, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
82  compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
83 
84  // Number entry for dx
85  TGCompositeFrame *f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
87  f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
88  fTransDz = new TGNumberEntry(f3, 0., 5, kMATRIX_DZ);
90  nef->SetToolTipText("Enter the translation on Z");
91  fTransDz->Associate(this);
92  f3->AddFrame(fTransDz, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
93  compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
94 
95  compxyz->Resize(150,30);
96  AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
97 
98  // Buttons
100  fApply = new TGTextButton(f23, "&Apply");
101  f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
102  fApply->Associate(this);
103  fCancel = new TGTextButton(f23, "&Cancel");
104  f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4));
105  fCancel->Associate(this);
106  fUndo = new TGTextButton(f23, " &Undo ");
107  f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
108  fUndo->Associate(this);
109  AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
112 }
113 
114 ////////////////////////////////////////////////////////////////////////////////
115 /// Destructor.
116 
118 {
119  TGFrameElement *el;
120  TIter next(GetList());
121  while ((el = (TGFrameElement *)next())) {
122  if (el->fFrame->IsComposite())
124  }
125  Cleanup();
126 }
127 
128 ////////////////////////////////////////////////////////////////////////////////
129 /// Connect signals to slots.
130 
132 {
133  fApply->Connect("Clicked()", "TGeoTranslationEditor", this, "DoApply()");
134  fCancel->Connect("Clicked()", "TGeoTranslationEditor", this, "DoCancel()");
135  fUndo->Connect("Clicked()", "TGeoTranslationEditor", this, "DoUndo()");
136  fTransName->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoModified()");
137  fTransDx->Connect("ValueSet(Long_t)", "TGeoTranslationEditor", this, "DoDx()");
138  fTransDy->Connect("ValueSet(Long_t)", "TGeoTranslationEditor", this, "DoDy()");
139  fTransDz->Connect("ValueSet(Long_t)", "TGeoTranslationEditor", this, "DoDz()");
140  fTransDx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoDx()");
141  fTransDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoDy()");
142  fTransDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoDz()");
143  fInit = kFALSE;
144 }
145 
146 
147 ////////////////////////////////////////////////////////////////////////////////
148 /// Connect to the new matrix.
149 
151 {
152  if (obj == 0 || (obj->IsA()!=TGeoTranslation::Class())) {
153  SetActive(kFALSE);
154  return;
155  }
160  const char *sname = fTranslation->GetName();
161  if (!strcmp(sname, fTranslation->ClassName())) fTransName->SetText("no_name");
162  else {
163  fTransName->SetText(sname);
164  fNamei = sname;
165  }
172 
174  SetActive();
175 }
176 
177 ////////////////////////////////////////////////////////////////////////////////
178 /// Slot for name.
179 
181 {
182  const char *name = fTransName->GetText();
183  if (!strcmp(name, "no_name") || !strcmp(name, fTranslation->GetName())) return;
184  fTranslation->SetName(name);
185 }
186 
187 ////////////////////////////////////////////////////////////////////////////////
188 /// Slot for checking parameters.
189 
191 {
192  Double_t dx = fTransDx->GetNumber();
193  Double_t dy = fTransDy->GetNumber();
194  Double_t dz = fTransDz->GetNumber();
195  Bool_t changed = kFALSE;
196  if (dx != fTranslation->GetTranslation()[0] ||
197  dy != fTranslation->GetTranslation()[1] ||
198  dz != fTranslation->GetTranslation()[2]) changed = kTRUE;
199  if (!changed) return kFALSE;
200  fUndo->SetEnabled();
201  fTranslation->SetTranslation(dx, dy, dz);
202  if (fPad) {
203  fPad->Modified();
204  fPad->Update();
205  }
206  return kTRUE;
207 }
208 
209 ////////////////////////////////////////////////////////////////////////////////
210 /// Slot for applying changes.
211 
213 {
214  DoName();
215  if (DoParameters()) {
216  fUndo->SetEnabled();
219  }
220 }
221 
222 ////////////////////////////////////////////////////////////////////////////////
223 /// Slot for cancelling last modifications non-applied.
224 
226 {
227  if (!fNamei.Length()) fTransName->SetText("no_name");
228  else fTransName->SetText(fNamei.Data());
235 }
236 
237 ////////////////////////////////////////////////////////////////////////////////
238 /// Slot for notifying changes.
239 
241 {
242  fApply->SetEnabled();
244 }
245 
246 ////////////////////////////////////////////////////////////////////////////////
247 /// Slot for undoing last operation.
248 
250 {
251  DoCancel();
252  DoParameters();
256 }
257 
258 ////////////////////////////////////////////////////////////////////////////////
259 /// Slot for dx.
260 
262 {
263  DoModified();
264 }
265 
266 ////////////////////////////////////////////////////////////////////////////////
267 /// Slot for dx.
268 
270 {
271  DoModified();
272 }
273 
274 ////////////////////////////////////////////////////////////////////////////////
275 /// Slot for dx.
276 
278 {
279  DoModified();
280 }
281 
282 //////////////////////////////////////////////////////////////////////////
283 // //
284 // TGeoRotationEditor //
285 // //
286 // Editor 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);
309  fRotName->Resize(135, fRotName->GetDefaultHeight());
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);
322  nef = (TGTextEntry*)fRotPhi->GetNumberEntry();
323  nef->SetToolTipText("Modify the first rotation angle about Z");
324  fRotPhi->Associate(this);
325  fRotPhi->Resize(90, fRotPhi->GetDefaultHeight());
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);
334  nef = (TGTextEntry*)fRotTheta->GetNumberEntry();
335  nef->SetToolTipText("Modify the second rotation angle about the new X");
336  fRotTheta->Associate(this);
337  fRotTheta->Resize(90, fRotTheta->GetDefaultHeight());
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);
346  nef = (TGTextEntry*)fRotPsi->GetNumberEntry();
347  nef->SetToolTipText("Modify the third rotation angle about Z");
348  fRotPsi->Associate(this);
349  fRotPsi->Resize(90, fRotPsi->GetDefaultHeight());
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);
363  nef = (TGTextEntry*)fRotAxis->GetNumberEntry();
364  nef->SetToolTipText("Enter the new rotation angle about the selected axis");
365  fRotAxis->Associate(this);
366  fRotAxis->Resize(90, fRotAxis->GetDefaultHeight());
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())) {
436  SetActive(kFALSE);
437  return;
438  }
439  fRotation = (TGeoRotation*)obj;
440  fRotation->GetAngles(fPhii, fThetai, fPsii);
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  }
447  fRotPhi->SetNumber(fPhii);
448  fRotTheta->SetNumber(fThetai);
449  fRotPsi->SetNumber(fPsii);
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;
467  fRotation->SetName(name);
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 {
485  if (fRotTheta->GetNumber() < 0.) fRotTheta->SetNumber(fRotTheta->GetNumber()+360.);
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());
560  fRotPhi->SetNumber(fPhii);
561  fRotTheta->SetNumber(fThetai);
562  fRotPsi->SetNumber(fPsii);
563  fRotAxis->SetNumber(0.0);
567 }
568 
569 ////////////////////////////////////////////////////////////////////////////////
570 /// Slot for notifying changes.
571 
573 {
574  fApply->SetEnabled();
576 }
577 
578 ////////////////////////////////////////////////////////////////////////////////
579 /// Slot for undoing last changes.
580 
582 {
583  DoCancel();
584  DoParameters();
588 }
589 
590 
591 //////////////////////////////////////////////////////////////////////////
592 // //
593 // TGeoCombiTransEditor //
594 // //
595 // Editor for a TGeoCombiTrans. //
596 // //
597 //////////////////////////////////////////////////////////////////////////
598 
600 
601 ////////////////////////////////////////////////////////////////////////////////
602 /// Constructor for combi matrix editor
603 
605  Int_t height, UInt_t options, Pixel_t back)
606  : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
607 {
608  fCombi = 0;
609  fPhii = fThetai = fPsii = 0.0;
610  fDxi = fDyi = fDzi = 0.0;
611  fAngleX = fAngleY = fAngleZ = 0.0;
612  fNamei = "";
615 
616  // TextEntry for name
617  MakeTitle("Name");
618  fRotName = new TGTextEntry(this, new TGTextBuffer(50), kMATRIX_NAME);
619  fRotName->Resize(135, fRotName->GetDefaultHeight());
620  fRotName->SetToolTipText("Enter the rotation name");
621  fRotName->Associate(this);
622  AddFrame(fRotName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
623 
624  TGTextEntry *nef;
625  MakeTitle("Translations on axes");
627  // Number entry for dx
628  TGCompositeFrame *f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
630  f1->AddFrame(new TGLabel(f1, "DX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
631  fTransDx = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
633  nef->SetToolTipText("Enter the translation on X");
634  fTransDx->Associate(this);
635  f1->AddFrame(fTransDx, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
636  compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
637 
638  // Number entry for dy
639  TGCompositeFrame *f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
641  f2->AddFrame(new TGLabel(f2, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
642  fTransDy = new TGNumberEntry(f2, 0., 5, kMATRIX_DY);
644  nef->SetToolTipText("Enter the translation on Y");
645  fTransDy->Associate(this);
646  f2->AddFrame(fTransDy, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
647  compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
648 
649  // Number entry for dx
650  TGCompositeFrame *f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
652  f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
653  fTransDz = new TGNumberEntry(f3, 0., 5, kMATRIX_DZ);
655  nef->SetToolTipText("Enter the translation on Z");
656  fTransDz->Associate(this);
657  f3->AddFrame(fTransDz, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
658  compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
659 
660  compxyz->Resize(150,30);
661  AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
662 
663 
664  MakeTitle("Euler angles");
665  compxyz = new TGCompositeFrame(this, 140, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
666  // Number entry for phi angle
667  f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
669  f1->AddFrame(new TGLabel(f1, " PHI "), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
670  fRotPhi = new TGNumberEntry(f1, 0., 5, kMATRIX_PHI);
671  nef = (TGTextEntry*)fRotPhi->GetNumberEntry();
672  nef->SetToolTipText("Modify the first rotation angle about Z");
673  fRotPhi->Associate(this);
674  fRotPhi->Resize(90, fRotPhi->GetDefaultHeight());
675  f1->AddFrame(fRotPhi, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
676  compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
677 
678  // Number entry for theta angle
679  f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
681  f2->AddFrame(new TGLabel(f2, "THETA"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
682  fRotTheta = new TGNumberEntry(f2, 0., 5, kMATRIX_THETA);
683  nef = (TGTextEntry*)fRotTheta->GetNumberEntry();
684  nef->SetToolTipText("Modify the second rotation angle about the new X");
685  fRotTheta->Associate(this);
686  fRotTheta->Resize(90, fRotTheta->GetDefaultHeight());
687  f2->AddFrame(fRotTheta, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
688  compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
689 
690  // Number entry for psi angle
691  f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
693  f3->AddFrame(new TGLabel(f3, " PSI "), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
694  fRotPsi = new TGNumberEntry(f3, 0., 5, kMATRIX_PSI);
695  nef = (TGTextEntry*)fRotPsi->GetNumberEntry();
696  nef->SetToolTipText("Modify the third rotation angle about Z");
697  fRotPsi->Associate(this);
698  fRotPsi->Resize(90, fRotPsi->GetDefaultHeight());
699  f3->AddFrame(fRotPsi, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
700  compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
701 
702  compxyz->Resize(150,compxyz->GetDefaultHeight());
703  AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
704 
705  MakeTitle("Rotate about axis");
706  compxyz = new TGCompositeFrame(this, 140, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
707  // Number entry for rotation angle about one axis
708  f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
710  f1->AddFrame(new TGLabel(f1, "ANGLE"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
711  fRotAxis = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
712  nef = (TGTextEntry*)fRotAxis->GetNumberEntry();
713  nef->SetToolTipText("Enter the new rotation angle about the selected axis");
714  fRotAxis->Associate(this);
715  fRotAxis->Resize(90, fRotAxis->GetDefaultHeight());
716  f1->AddFrame(fRotAxis, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
717  compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
718 
719  // Radio buttons group for axis selection
720  TGHButtonGroup *bg1 = new TGHButtonGroup(compxyz, " Axis ");
721  fRotX = new TGRadioButton(bg1, " &X ", kMATRIX_DX);
722  fRotY = new TGRadioButton(bg1, " &Y ", kMATRIX_DY);
723  fRotZ = new TGRadioButton(bg1, " &Z ", kMATRIX_DZ);
725  bg1->Show();
726  compxyz->AddFrame(bg1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
727 
728  compxyz->Resize(150,compxyz->GetDefaultHeight());
729  AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
730 
731 
732  // Buttons
734  fApply = new TGTextButton(f23, "&Apply");
735  f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
736  fApply->Associate(this);
737  fCancel = new TGTextButton(f23, "&Cancel");
738  f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4));
739  fCancel->Associate(this);
740  fUndo = new TGTextButton(f23, " &Undo ");
741  f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
742  fUndo->Associate(this);
743  AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
746 }
747 
748 ////////////////////////////////////////////////////////////////////////////////
749 /// Destructor
750 
752 {
753  TGFrameElement *el;
754  TIter next(GetList());
755  while ((el = (TGFrameElement *)next())) {
756  if (el->fFrame->IsComposite())
758  }
759  Cleanup();
760 }
761 
762 ////////////////////////////////////////////////////////////////////////////////
763 /// Connect signals to slots.
764 
766 {
767  fApply->Connect("Clicked()", "TGeoCombiTransEditor", this, "DoApply()");
768  fCancel->Connect("Clicked()", "TGeoCombiTransEditor", this, "DoCancel()");
769  fUndo->Connect("Clicked()", "TGeoCombiTransEditor", this, "DoUndo()");
770  fRotName->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoModified()");
771  fRotPhi->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotPhi()");
772  fRotTheta->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotTheta()");
773  fRotPsi->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotPsi()");
774  fRotAxis->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotAngle()");
775  fTransDx->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoDx()");
776  fTransDy->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoDy()");
777  fTransDz->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoDz()");
778  fTransDx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoDx()");
779  fTransDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoDy()");
780  fTransDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoDz()");
781  fInit = kFALSE;
782 }
783 
784 
785 ////////////////////////////////////////////////////////////////////////////////
786 /// Connect to the selected combi matrix.
787 
789 {
790  if (obj == 0 || (obj->IsA()!=TGeoCombiTrans::Class())) {
791  SetActive(kFALSE);
792  return;
793  }
794  fCombi = (TGeoCombiTrans*)obj;
795  TGeoRotation *rot = fCombi->GetRotation();
796  if (rot) rot->GetAngles(fPhii, fThetai, fPsii);
797  const char *sname = fCombi->GetName();
798  if (!strcmp(sname, fCombi->ClassName())) fRotName->SetText("no_name");
799  else {
800  fRotName->SetText(sname);
801  fNamei = sname;
802  }
803 
804  fDxi = fCombi->GetTranslation()[0];
805  fDyi = fCombi->GetTranslation()[1];
806  fDzi = fCombi->GetTranslation()[2];
810 
811  fRotPhi->SetNumber(fPhii);
812  fRotTheta->SetNumber(fThetai);
813  fRotPsi->SetNumber(fPsii);
814  fRotAxis->SetNumber(0.0);
815 
819 
821  SetActive();
822 }
823 
824 ////////////////////////////////////////////////////////////////////////////////
825 /// Slot for name.
826 
828 {
829  const char *name = fRotName->GetText();
830  if (!strcmp(name, "no_name") || !strcmp(name, fCombi->GetName())) return;
831  fCombi->SetName(name);
832 }
833 
834 ////////////////////////////////////////////////////////////////////////////////
835 /// Slot for phi (Euler X convention)
836 
838 {
839  if (fRotPhi->GetNumber() < 0.) fRotPhi->SetNumber(fRotPhi->GetNumber()+360.);
840  if (fRotPhi->GetNumber() >= 360.) fRotPhi->SetNumber(fRotPhi->GetNumber()-360.);
841  DoModified();
842 }
843 
844 ////////////////////////////////////////////////////////////////////////////////
845 /// Slot for theta (Euler X convention)
846 
848 {
849  if (fRotTheta->GetNumber() < 0.) fRotTheta->SetNumber(fRotTheta->GetNumber()+360.);
850  if (fRotTheta->GetNumber() >= 360.) fRotTheta->SetNumber(fRotTheta->GetNumber()-360.);
851  DoModified();
852 }
853 
854 ////////////////////////////////////////////////////////////////////////////////
855 /// Slot for psi (Euler X convention)
856 
858 {
859  if (fRotPsi->GetNumber() < 0.) fRotPsi->SetNumber(fRotPsi->GetNumber()+360.);
860  if (fRotPsi->GetNumber() >= 360.) fRotPsi->SetNumber(fRotPsi->GetNumber()-360.);
861  DoModified();
862 }
863 
864 ////////////////////////////////////////////////////////////////////////////////
865 /// Slot for additional rotation about one axis.
866 
868 {
869  if (fRotAxis->GetNumber() < 0.) fRotAxis->SetNumber(fRotAxis->GetNumber()+360.);
870  if (fRotAxis->GetNumber() >= 360.) fRotAxis->SetNumber(fRotAxis->GetNumber()-360.);
871  DoModified();
872 }
873 
874 ////////////////////////////////////////////////////////////////////////////////
875 /// Slot for checking parameters.
876 
878 {
879  Double_t dx = fTransDx->GetNumber();
880  Double_t dy = fTransDy->GetNumber();
881  Double_t dz = fTransDz->GetNumber();
882  Bool_t changedtr = kFALSE;
883  if (dx != fCombi->GetTranslation()[0] ||
884  dy != fCombi->GetTranslation()[1] ||
885  dz != fCombi->GetTranslation()[2]) changedtr = kTRUE;
886  if (changedtr) fCombi->SetTranslation(dx, dy, dz);
887  Double_t phi = fRotPhi->GetNumber();
888  Double_t theta = fRotTheta->GetNumber();
889  Double_t psi = fRotPsi->GetNumber();
890  Double_t angle = fRotAxis->GetNumber();
891  Double_t phi0 = 0., theta0 = 0., psi0 = 0.;
892  TGeoRotation *rot = fCombi->GetRotation();
893  if (rot) rot->GetAngles(phi0,theta0,psi0);
894  else {
895  if (phi!=fPhii || theta!=fThetai || psi!=fPsii) {
896  TGeoRotation r("rot",10.,0.,0.);
897  fCombi->SetRotation(r);
898  rot = fCombi->GetRotation();
899  rot->SetAngles(0.,0.,0.);
900  }
901  }
902  Bool_t changed = kFALSE;
903  if (phi != psi0 || theta != theta0 || psi != psi0) changed = kTRUE;
904  if (changed && rot) rot->SetAngles(phi, theta, psi);
905  // Check if we have to rotate about one axis
906  if (angle != 0.0) {
907  if (fRotX->IsOn()) {fCombi->RotateX(angle); changed = kTRUE;}
908  if (fRotY->IsOn()) {fCombi->RotateY(angle); changed = kTRUE;}
909  if (fRotZ->IsOn()) {fCombi->RotateZ(angle); changed = kTRUE;}
910  }
911  if (changedtr) changed = kTRUE;
912  if (!changed) return kFALSE;
913  fRotAxis->SetNumber(0.0);
914  fUndo->SetEnabled();
915  if (fPad) {
916  fPad->Modified();
917  fPad->Update();
918  }
919  return kTRUE;
920 }
921 
922 ////////////////////////////////////////////////////////////////////////////////
923 /// Slot for applying modifications.
924 
926 {
927  DoName();
928  if (DoParameters()) {
929  fUndo->SetEnabled();
932  }
933 }
934 
935 ////////////////////////////////////////////////////////////////////////////////
936 /// Slot for cancelling last un-applied operations.
937 
939 {
940  if (!fNamei.Length()) fRotName->SetText("no_name");
941  else fRotName->SetText(fNamei.Data());
945  fRotPhi->SetNumber(fPhii);
946  fRotTheta->SetNumber(fThetai);
947  fRotPsi->SetNumber(fPsii);
948  fRotAxis->SetNumber(0.0);
952 }
953 
954 ////////////////////////////////////////////////////////////////////////////////
955 /// Slot for notifying changes.
956 
958 {
959  fApply->SetEnabled();
961 }
962 
963 ////////////////////////////////////////////////////////////////////////////////
964 /// Slot for undoing last changes.
965 
967 {
968  DoCancel();
969  DoParameters();
973 }
974 
975 ////////////////////////////////////////////////////////////////////////////////
976 /// Slot for X.
977 
979 {
980  DoModified();
981 }
982 
983 ////////////////////////////////////////////////////////////////////////////////
984 /// Slot for Y.
985 
987 {
988  DoModified();
989 }
990 
991 ////////////////////////////////////////////////////////////////////////////////
992 /// Slot for Z.
993 
995 {
996  DoModified();
997 }
998 
void DoRotTheta()
Slot for theta (Euler X convention)
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
TGTextEntry * fTransName
void DoRotAngle()
Slot for additional rotation about one axis.
void DoDz()
Slot for dx.
void DoRotPsi()
Slot for psi (Euler X convention)
void DoRotTheta()
Slot for theta (Euler X convention)
void DoModified()
Slot for notifying changes.
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
virtual void Update()=0
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:131
void DoApply()
Slot for applying changes.
void DoName()
Slot for name.
TGNumberEntry * fTransDz
virtual void SetNumber(Double_t val)
void DoRotPsi()
Slot for psi (Euler X convention)
Bool_t DoParameters()
Slot for checking parameters.
Class describing translations.
Definition: TGeoMatrix.h:129
virtual ~TGeoRotationEditor()
Destructor.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:373
virtual Bool_t IsComposite() const
Definition: TGFrame.h:259
TGTextButton * fCancel
virtual void SetModel(TObject *obj)
Connect to the new matrix.
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hirarchically all daughters of a composite frame.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:135
ULong_t Pixel_t
Definition: GuiTypes.h:39
void Class()
Definition: Class.C:29
void DoApply()
Slot for applying modifications.
virtual void SetModel(TObject *obj)
Connect to the selected rotation.
virtual void SetActive(Bool_t active=kTRUE)
Set active GUI attribute frames related to the selected object.
TGCompositeFrame(const TGCompositeFrame &)
virtual void SetRadioButtonExclusive(Bool_t flag=kTRUE)
If enable is kTRUE, this button group will treat radio buttons as mutually exclusive, and other buttons according to IsExclusive().
void DoDz()
Slot for Z.
virtual TList * GetList() const
Definition: TGFrame.h:369
virtual EButtonState GetState() const
Definition: TGButton.h:112
void DoRotPhi()
Slot for phi (Euler X convention)
virtual const Double_t * GetTranslation() const
Definition: TGeoMatrix.h:164
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
virtual void Associate(const TGWindow *w)
Make w the window that will receive the generated messages.
void DoDy()
Slot for Y.
TGNumberEntry * fTransDy
void DoRotAngle()
Slot for additional rotation about one axis.
void DoUndo()
Slot for undoing last changes.
virtual void SetSize(const TGDimension &s)
Definition: TGFrame.h:299
void DoUndo()
Slot for undoing last operation.
TRandom2 r(17)
Class describing rotation + translation.
Definition: TGeoMatrix.h:283
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:84
void DoCancel()
Slot for cancelling last modifications non-applied.
void DoCancel()
Slot for cancelling last un-applied operations.
unsigned int UInt_t
Definition: RtypesCore.h:42
Ssiz_t Length() const
Definition: TString.h:388
TGFrame * fFrame
Definition: TGLayout.h:119
const std::string sname
Definition: testIO.cxx:45
Bool_t DoParameters()
Slot for checking parameters.
void DoCancel()
Slot for cancelling last un-applied operations.
Class describing rotations.
Definition: TGeoMatrix.h:178
const Bool_t kFALSE
Definition: RtypesCore.h:92
TGDimension GetSize() const
Definition: TGFrame.h:277
void DoName()
Slot for name.
const char * GetText() const
Definition: TGTextEntry.h:134
virtual void Modified(Bool_t flag=1)=0
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:238
virtual ~TGeoCombiTransEditor()
Destructor.
void DoName()
Slot for name.
#define ClassImp(name)
Definition: Rtypes.h:336
void GetAngles(Double_t &theta1, Double_t &phi1, Double_t &theta2, Double_t &phi2, Double_t &theta3, Double_t &phi3) const
Retrieve rotation angles.
double Double_t
Definition: RtypesCore.h:55
virtual void ConnectSignals2Slots()
Connect signals to slots.
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition: TGButton.cxx:409
virtual Double_t GetNumber() const
void DoApply()
Slot for applying modifications.
void DoModified()
Slot for notifying changes.
void DoDy()
Slot for dx.
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 Show()
Show group of buttons.
Mother of all ROOT objects.
Definition: TObject.h:37
void DoDx()
Slot for dx.
Bool_t fInit
Definition: TGedFrame.h:53
TGNumberEntryField * GetNumberEntry() const
Bool_t DoParameters()
Slot for checking parameters.
double f2(const double *x)
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 ConnectSignals2Slots()
Connect signals to slots.
TF1 * f1
Definition: legend1.C:11
void SetAngles(Double_t phi, Double_t theta, Double_t psi)
Set matrix elements according to Euler angles.
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...
void DoDx()
Slot for X.
TVirtualPad * fPad
Definition: TGeoGedFrame.h:26
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:949
const Bool_t kTRUE
Definition: RtypesCore.h:91
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
void DoUndo()
Slot for undoing last changes.
virtual void ConnectSignals2Slots()
Connect signals to slots.
void DoModified()
Slot for notifying changes.
TGNumberEntry * fTransDx
void SetTranslation(Double_t dx, Double_t dy, Double_t dz)
Set translation components.
Definition: TGeoMatrix.cxx:753
TGeoTranslation * fTranslation
void DoRotPhi()
Slot for phi (Euler X convention)
virtual void SetModel(TObject *obj)
Connect to the selected combi matrix.
virtual ~TGeoTranslationEditor()
Destructor.
ETGeoMatrixWid
const char * Data() const
Definition: TString.h:347