Logo ROOT   6.10/09
Reference Guide
TEveTransEditor.cxx
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, 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 #include "TEveTransEditor.h"
13 #include "TEveTrans.h"
14 #include "TEveGValuators.h"
15 
16 #include "TVirtualPad.h"
17 #include "TMath.h"
18 
19 #include "TGButton.h"
20 #include "TGLabel.h"
21 
22 /** \class TEveTransSubEditor
23 \ingroup TEve
24 Sub-editor for TEveTrans class.
25 */
26 
28 
29 ////////////////////////////////////////////////////////////////////////////////
30 /// Constructor.
31 
33  TGVerticalFrame (p),
34  fTrans (0),
35  fTopHorFrame (0),
36  fUseTrans (0),
37  fEditTrans (0),
38  fEditTransFrame (0),
39  fPos (0),
40  fRot (0),
41  fScale (0),
42  fAutoUpdate (0),
43  fUpdate (0)
44 {
45  // --- Top controls
46 
47  fTopHorFrame = new TGHorizontalFrame(this);
48 
49  fUseTrans = new TGCheckButton(fTopHorFrame, "UseTrans");
51  fUseTrans->Connect("Toggled(Bool_t)", "TEveTransSubEditor", this, "DoUseTrans()");
52  fEditTrans = new TGCheckButton(fTopHorFrame, "EditTrans");
54  fEditTrans->Connect("Toggled(Bool_t)", "TEveTransSubEditor", this, "DoEditTrans()");
55 
57 
58  // --- Trans edit part
59 
60  fEditTransFrame = new TGVerticalFrame(this);
61 
62  TGFont *font = gClient->GetFont("-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1");
63 
65  TGLabel* labp = new TGLabel(hfp, "Location");
66  labp->SetTextFont(font);
67  hfp->AddFrame(labp);
69  fPos = new TEveGTriVecValuator(fEditTransFrame, "Pos", 160, 20);
70  fPos->SetNELength(6);
71  fPos->Build(kFALSE, "", "", "");
73  fPos->GetValuator(0)->SetToolTip("X coordinate");
74  fPos->GetValuator(1)->SetToolTip("Y coordinate");
75  fPos->GetValuator(2)->SetToolTip("Z coordinate");
77 
79  TGLabel* labr = new TGLabel(hfr, "Rotation");
80  labr->SetTextFont(font);
81  hfr->AddFrame(labr);
83  fRot = new TEveGTriVecValuator(fEditTransFrame, "Rot", 160, 20);
84  fRot->SetNELength(6);
85  fRot->Build(kFALSE, "", "", "");
87  fRot->GetValuator(0)->SetToolTip("X coordinate");
88  fRot->GetValuator(1)->SetToolTip("Y coordinate");
89  fRot->GetValuator(2)->SetToolTip("Z coordinate");
91 
93  TGLabel* labs = new TGLabel(hfs, "Scale");
94  labs->SetTextFont(font);
95  hfs->AddFrame(labs);
97  fScale = new TEveGTriVecValuator(fEditTransFrame, "Scale", 160, 20);
98  fScale->SetNELength(6);
99  fScale->Build(kFALSE, "", "", "");
101  fScale->GetValuator(0)->SetToolTip("X coordinate");
102  fScale->GetValuator(1)->SetToolTip("Y coordinate");
103  fScale->GetValuator(2)->SetToolTip("Z coordinate");
105 
106  fPos ->Connect("ValueSet()", "TEveTransSubEditor", this, "DoTransChanged()");
107  fRot ->Connect("ValueSet()", "TEveTransSubEditor", this, "DoTransChanged()");
108  fScale->Connect("ValueSet()", "TEveTransSubEditor", this, "DoTransChanged()");
109 
110  {
112  fAutoUpdate = new TGCheckButton(hframe, "AutoUpdate");
113  hframe->AddFrame(fAutoUpdate, new TGLayoutHints(kLHintsLeft, 1,1,1,1));
114  fUpdate = new TGTextButton(hframe, "Update");
115  hframe->AddFrame(fUpdate, new TGLayoutHints(kLHintsLeft, 0,0,1,1));
116  fUpdate->Connect("Clicked()", "TEveTransSubEditor", this, "TransChanged()");
117 
118  fEditTransFrame->AddFrame(hframe, new TGLayoutHints(kLHintsTop , 0,0,4,0));
119  }
120 
122 }
123 
124 ////////////////////////////////////////////////////////////////////////////////
125 /// Set model object.
126 
128 {
129  fTrans = t;
130 
133  if (fTrans->fEditTrans)
134  {
135  for (Int_t i=0; i<3; ++i)
136  {
139  }
141  }
142  else
143  {
145  }
146 
148 
149  fPos->SetValues(fTrans->ArrT());
150  Float_t a[3];
151  fTrans->GetRotAngles(a);
152  a[0] *= TMath::RadToDeg();
153  a[1] *= TMath::RadToDeg();
154  a[2] *= TMath::RadToDeg();
155  fRot->SetValues(a);
156  Double_t x, y, z;
157  fTrans->GetScale(x, y, z);
158  fScale->SetValues(x, y, z);
159 }
160 
161 ////////////////////////////////////////////////////////////////////////////////
162 /// Set model object from widget data.
163 
165 {
166  Double_t v[3];
167  fTrans->UnitTrans();
168  fRot->GetValues(v);
170  fPos->GetValues(v);
171  fTrans->SetPos(v);
172  fScale->GetValues(v);
173  fTrans->Scale(v[0], v[1], v[2]);
174 }
175 
176 ////////////////////////////////////////////////////////////////////////////////
177 /// Emit "UseTrans()" signal.
178 
180 {
181  Emit("UseTrans()");
182 }
183 
184 ////////////////////////////////////////////////////////////////////////////////
185 /// Set transformation values from widget and emit "TransChanged()" signal.
186 
188 {
190  Emit("TransChanged()");
191 }
192 
193 ////////////////////////////////////////////////////////////////////////////////
194 /// Slot for UseTrans.
195 
197 {
199  UseTrans();
200 }
201 
202 ////////////////////////////////////////////////////////////////////////////////
203 /// Slot for EditTrans.
204 
206 {
208  TransChanged();
209 }
210 
211 ////////////////////////////////////////////////////////////////////////////////
212 /// Slot for TransChanged.
213 
215 {
216  if (fAutoUpdate->IsOn())
217  TransChanged();
218 }
219 
220 /** \class TEveTransEditor
221 \ingroup TEve
222 Editor for TEveTrans class.
223 */
224 
226 
227 ////////////////////////////////////////////////////////////////////////////////
228 /// Constructor.
229 
231  UInt_t options, Pixel_t back) :
232  TGedFrame(p, width, height, options | kVerticalFrame, back),
233  fM (0),
234  fSE(0)
235 {
236  MakeTitle("TEveTrans");
237 
238  fSE = new TEveTransSubEditor(this);
239  AddFrame(fSE, new TGLayoutHints(kLHintsTop, 2, 0, 2, 2));
240  fSE->Connect("UseTrans()", "TEveTransEditor", this, "Update()");
241  fSE->Connect("TransChanged()", "TEveTransEditor", this, "Update()");
242 }
243 
244 ////////////////////////////////////////////////////////////////////////////////
245 /// Set model object.
246 
248 {
249  fM = dynamic_cast<TEveTrans*>(obj);
250  fSE->SetModel(fM);
251 }
TEveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Definition: TEveTrans.h:26
TGNumberEntry * GetEntry()
Composite GUI element for setting three numerical values (label, three number-entries).
void DoUseTrans()
Slot for UseTrans.
Bool_t GetEditRotation()
Definition: TEveTrans.h:173
void SetLimits(Int_t min, Int_t max)
Set limits for all three number-entries, integer values.
void SetNELength(Int_t l)
float Float_t
Definition: RtypesCore.h:53
void DoTransChanged()
Slot for TransChanged.
TEveTrans * fM
Bool_t fUseTrans
Definition: TEveTrans.h:40
void UseTrans()
Emit "UseTrans()" signal.
virtual void SetModel(TObject *obj)
Set model object.
#define gClient
Definition: TGClient.h:166
int Int_t
Definition: RtypesCore.h:41
TArc * a
Definition: textangle.C:12
virtual void SetState(Bool_t enable=kTRUE)
Set the active state.
TGTextButton * fUpdate
void SetToolTip(const char *tip)
Set the tooltip of the number-entry.
virtual void SetTextFont(TGFont *font, Bool_t global=kFALSE)
Changes text font specified by pointer to TGFont object.
Definition: TGLabel.cxx:321
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1239
void SetUseTrans(Bool_t v)
Definition: TEveTrans.h:169
void DoEditTrans()
Slot for EditTrans.
Double_t x[n]
Definition: legend1.C:17
ULong_t Pixel_t
Definition: GuiTypes.h:39
void SetRotByAngles(Float_t a1, Float_t a2, Float_t a3)
Definition: TEveTrans.cxx:572
constexpr Double_t DegToRad()
Definition: TMath.h:64
void SetValues(Float_t v0, Float_t v1, Float_t v2)
virtual Bool_t IsOn() const
Definition: TGButton.h:311
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition: TGWindow.cxx:133
TEveGValuator * GetValuator(Int_t i) const
void Scale(Double_t sx, Double_t sy, Double_t sz)
Scale matrix. Translation part untouched.
Definition: TEveTrans.cxx:647
TGVerticalFrame * fEditTransFrame
TGCheckButton * fAutoUpdate
void Build(Bool_t vertical, const char *lab0, const char *lab1, const char *lab2)
Create sub-components (label, number entries).
void TransChanged()
Set transformation values from widget and emit "TransChanged()" signal.
Bool_t fEditTrans
Definition: TEveTrans.h:41
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
SVector< double, 2 > v
Definition: Dict.h:5
unsigned int UInt_t
Definition: RtypesCore.h:42
Editor for TEveTrans class.
TGCheckButton * fEditTrans
void SetTransFromData()
Set model object from widget data.
TGVerticalFrame(const TGWindow *p=0, UInt_t w=1, UInt_t h=1, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Definition: TGFrame.h:436
Double_t * ArrT()
Definition: TEveTrans.h:98
void GetScale(Double_t &sx, Double_t &sy, Double_t &sz) const
Deduce scales from sizes of base vectors.
Definition: TEveTrans.cxx:678
const Bool_t kFALSE
Definition: RtypesCore.h:92
TEveTransSubEditor(const TEveTransSubEditor &)
void SetPos(Double_t x, Double_t y, Double_t z)
Set position (base-vec 4).
Definition: TEveTrans.cxx:507
#define ClassImp(name)
Definition: Rtypes.h:336
double Double_t
Definition: RtypesCore.h:55
TEveTransSubEditor * fSE
Sub-editor for TEveTrans class.
TEveTransEditor(const TEveTransEditor &)
Definition: TGFont.h:149
Double_t y[n]
Definition: legend1.C:17
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
void SetModel(TEveTrans *t)
Set model object.
void GetValues(Float_t &v0, Float_t &v1, Float_t &v2) const
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
Mother of all ROOT objects.
Definition: TObject.h:37
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
constexpr Double_t RadToDeg()
Definition: TMath.h:60
TEveGTriVecValuator * fScale
virtual void UnmapWindow()
Definition: TGFrame.h:253
TGCheckButton * fUseTrans
TEveGTriVecValuator * fRot
TGHorizontalFrame * fTopHorFrame
virtual void MapWindow()
Definition: TGFrame.h:251
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set check button state.
Definition: TGButton.cxx:1200
Bool_t GetEditScale()
Definition: TEveTrans.h:174
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
void GetRotAngles(Float_t *x) const
Get Cardan rotation angles (pattern xYz above).
Definition: TEveTrans.cxx:623
TEveGTriVecValuator * fPos
void SetEditTrans(Bool_t v)
Definition: TEveTrans.h:177
void UnitTrans()
Reset matrix to unity.
Definition: TEveTrans.cxx:130