Logo ROOT  
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 "TMath.h"
17 
18 #include "TGButton.h"
19 #include "TGLabel.h"
20 
21 /** \class TEveTransSubEditor
22 \ingroup TEve
23 Sub-editor for TEveTrans class.
24 */
25 
27 
28 ////////////////////////////////////////////////////////////////////////////////
29 /// Constructor.
30 
32  TGVerticalFrame (p),
33  fTrans (0),
34  fTopHorFrame (0),
35  fUseTrans (0),
36  fEditTrans (0),
37  fEditTransFrame (0),
38  fPos (0),
39  fRot (0),
40  fScale (0),
41  fAutoUpdate (0),
42  fUpdate (0)
43 {
44  // --- Top controls
45 
46  fTopHorFrame = new TGHorizontalFrame(this);
47 
48  fUseTrans = new TGCheckButton(fTopHorFrame, "UseTrans");
50  fUseTrans->Connect("Toggled(Bool_t)", "TEveTransSubEditor", this, "DoUseTrans()");
51  fEditTrans = new TGCheckButton(fTopHorFrame, "EditTrans");
53  fEditTrans->Connect("Toggled(Bool_t)", "TEveTransSubEditor", this, "DoEditTrans()");
54 
56 
57  // --- Trans edit part
58 
59  fEditTransFrame = new TGVerticalFrame(this);
60 
61  TGFont *font = gClient->GetFont("-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1");
62 
64  TGLabel* labp = new TGLabel(hfp, "Location");
65  labp->SetTextFont(font);
66  hfp->AddFrame(labp);
68  fPos = new TEveGTriVecValuator(fEditTransFrame, "Pos", 160, 20);
69  fPos->SetNELength(6);
70  fPos->Build(kFALSE, "", "", "");
72  fPos->GetValuator(0)->SetToolTip("X coordinate");
73  fPos->GetValuator(1)->SetToolTip("Y coordinate");
74  fPos->GetValuator(2)->SetToolTip("Z coordinate");
76 
78  TGLabel* labr = new TGLabel(hfr, "Rotation");
79  labr->SetTextFont(font);
80  hfr->AddFrame(labr);
82  fRot = new TEveGTriVecValuator(fEditTransFrame, "Rot", 160, 20);
83  fRot->SetNELength(6);
84  fRot->Build(kFALSE, "", "", "");
86  fRot->GetValuator(0)->SetToolTip("X coordinate");
87  fRot->GetValuator(1)->SetToolTip("Y coordinate");
88  fRot->GetValuator(2)->SetToolTip("Z coordinate");
90 
92  TGLabel* labs = new TGLabel(hfs, "Scale");
93  labs->SetTextFont(font);
94  hfs->AddFrame(labs);
96  fScale = new TEveGTriVecValuator(fEditTransFrame, "Scale", 160, 20);
97  fScale->SetNELength(6);
98  fScale->Build(kFALSE, "", "", "");
100  fScale->GetValuator(0)->SetToolTip("X coordinate");
101  fScale->GetValuator(1)->SetToolTip("Y coordinate");
102  fScale->GetValuator(2)->SetToolTip("Z coordinate");
104 
105  fPos ->Connect("ValueSet()", "TEveTransSubEditor", this, "DoTransChanged()");
106  fRot ->Connect("ValueSet()", "TEveTransSubEditor", this, "DoTransChanged()");
107  fScale->Connect("ValueSet()", "TEveTransSubEditor", this, "DoTransChanged()");
108 
109  {
111  fAutoUpdate = new TGCheckButton(hframe, "AutoUpdate");
112  hframe->AddFrame(fAutoUpdate, new TGLayoutHints(kLHintsLeft, 1,1,1,1));
113  fUpdate = new TGTextButton(hframe, "Update");
114  hframe->AddFrame(fUpdate, new TGLayoutHints(kLHintsLeft, 0,0,1,1));
115  fUpdate->Connect("Clicked()", "TEveTransSubEditor", this, "TransChanged()");
116 
117  fEditTransFrame->AddFrame(hframe, new TGLayoutHints(kLHintsTop , 0,0,4,0));
118  }
119 
121 }
122 
123 ////////////////////////////////////////////////////////////////////////////////
124 /// Set model object.
125 
127 {
128  fTrans = t;
129 
132  if (fTrans->fEditTrans)
133  {
134  for (Int_t i=0; i<3; ++i)
135  {
138  }
140  }
141  else
142  {
144  }
145 
147 
148  fPos->SetValues(fTrans->ArrT());
149  Float_t a[3];
151  a[0] *= TMath::RadToDeg();
152  a[1] *= TMath::RadToDeg();
153  a[2] *= TMath::RadToDeg();
154  fRot->SetValues(a);
155  Double_t x, y, z;
156  fTrans->GetScale(x, y, z);
157  fScale->SetValues(x, y, z);
158 }
159 
160 ////////////////////////////////////////////////////////////////////////////////
161 /// Set model object from widget data.
162 
164 {
165  Double_t v[3];
166  fTrans->UnitTrans();
167  fRot->GetValues(v);
169  fPos->GetValues(v);
170  fTrans->SetPos(v);
171  fScale->GetValues(v);
172  fTrans->Scale(v[0], v[1], v[2]);
173 }
174 
175 ////////////////////////////////////////////////////////////////////////////////
176 /// Emit "UseTrans()" signal.
177 
179 {
180  Emit("UseTrans()");
181 }
182 
183 ////////////////////////////////////////////////////////////////////////////////
184 /// Set transformation values from widget and emit "TransChanged()" signal.
185 
187 {
189  Emit("TransChanged()");
190 }
191 
192 ////////////////////////////////////////////////////////////////////////////////
193 /// Slot for UseTrans.
194 
196 {
198  UseTrans();
199 }
200 
201 ////////////////////////////////////////////////////////////////////////////////
202 /// Slot for EditTrans.
203 
205 {
207  TransChanged();
208 }
209 
210 ////////////////////////////////////////////////////////////////////////////////
211 /// Slot for TransChanged.
212 
214 {
215  if (fAutoUpdate->IsOn())
216  TransChanged();
217 }
218 
219 /** \class TEveTransEditor
220 \ingroup TEve
221 Editor for TEveTrans class.
222 */
223 
225 
226 ////////////////////////////////////////////////////////////////////////////////
227 /// Constructor.
228 
230  UInt_t options, Pixel_t back) :
231  TGedFrame(p, width, height, options | kVerticalFrame, back),
232  fM (0),
233  fSE(0)
234 {
235  MakeTitle("TEveTrans");
236 
237  fSE = new TEveTransSubEditor(this);
238  AddFrame(fSE, new TGLayoutHints(kLHintsTop, 2, 0, 2, 2));
239  fSE->Connect("UseTrans()", "TEveTransEditor", this, "Update()");
240  fSE->Connect("TransChanged()", "TEveTransEditor", this, "Update()");
241 }
242 
243 ////////////////////////////////////////////////////////////////////////////////
244 /// Set model object.
245 
247 {
248  fM = dynamic_cast<TEveTrans*>(obj);
249  fSE->SetModel(fM);
250 }
TEveTrans::GetEditScale
Bool_t GetEditScale()
Definition: TEveTrans.h:174
TEveTransSubEditor::TEveTransSubEditor
TEveTransSubEditor(const TEveTransSubEditor &)
TGWindow
Definition: TGWindow.h:31
TGCheckButton::SetState
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set check button state.
Definition: TGButton.cxx:1203
TEveTrans
Definition: TEveTrans.h:26
e
#define e(i)
Definition: RSha256.hxx:121
TGMainFrame
Definition: TGFrame.h:444
TEveTransSubEditor
Definition: TEveTransEditor.h:24
TEveTransSubEditor::fEditTrans
TGCheckButton * fEditTrans
Definition: TEveTransEditor.h:35
TEveGTriVecValuator::SetValues
void SetValues(Float_t v0, Float_t v1, Float_t v2)
Definition: TEveGValuators.h:181
TMath::RadToDeg
constexpr Double_t RadToDeg()
Conversion from radian to degree:
Definition: TMath.h:79
TEveGTriVecValuator
Definition: TEveGValuators.h:150
TEveGTriVecValuator::GetValuator
TEveGValuator * GetValuator(Int_t i) const
Definition: TEveGValuators.h:169
TEveTransEditor::fSE
TEveTransSubEditor * fSE
Definition: TEveTransEditor.h:76
TEveGTriVecValuator::Build
void Build(Bool_t vertical, const char *lab0, const char *lab1, const char *lab2)
Create sub-components (label, number entries).
Definition: TEveGValuators.cxx:437
kButtonDown
@ kButtonDown
Definition: TGButton.h:60
TEveTrans::ArrT
Double_t * ArrT()
Definition: TEveTrans.h:98
kLHintsTop
@ kLHintsTop
Definition: TGLayout.h:40
Pixel_t
ULong_t Pixel_t
Definition: GuiTypes.h:39
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TEveTransSubEditor::DoEditTrans
void DoEditTrans()
Slot for EditTrans.
Definition: TEveTransEditor.cxx:204
TGCheckButton::IsOn
virtual Bool_t IsOn() const
Definition: TGButton.h:311
kVerticalFrame
@ kVerticalFrame
Definition: GuiTypes.h:381
TGNumberFormat::kNESRealThree
@ kNESRealThree
Definition: TGNumberEntry.h:49
kLHintsLeft
@ kLHintsLeft
Definition: TGLayout.h:37
TGLabel
Definition: TGLabel.h:32
kButtonUp
@ kButtonUp
Definition: TGButton.h:59
TMath::DegToRad
constexpr Double_t DegToRad()
Conversion from degree to radian:
Definition: TMath.h:87
Float_t
float Float_t
Definition: RtypesCore.h:57
width
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
TGTextButton
Definition: TGButton.h:142
TEveTransEditor::fM
TEveTrans * fM
Definition: TEveTransEditor.h:75
x
Double_t x[n]
Definition: legend1.C:17
TEveGTriVecValuator::GetValues
void GetValues(Float_t &v0, Float_t &v1, Float_t &v2) const
Definition: TEveGValuators.h:174
TGVerticalFrame::TGVerticalFrame
TGVerticalFrame(const TGWindow *p=0, UInt_t w=1, UInt_t h=1, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Definition: TGFrame.h:414
TGNumberFormat::kNESRealTwo
@ kNESRealTwo
Definition: TGNumberEntry.h:48
TGHorizontalFrame
Definition: TGFrame.h:423
v
@ v
Definition: rootcling_impl.cxx:3635
TEveGValuators.h
TGFrame::MapWindow
virtual void MapWindow()
map window
Definition: TGFrame.h:229
TEveTransSubEditor::fTrans
TEveTrans * fTrans
Definition: TEveTransEditor.h:30
TEveTransEditor::TEveTransEditor
TEveTransEditor(const TEveTransEditor &)
TEveTransSubEditor::fTopHorFrame
TGHorizontalFrame * fTopHorFrame
Definition: TEveTransEditor.h:32
gClient
#define gClient
Definition: TGClient.h:166
TGCheckButton
Definition: TGButton.h:264
TGNumberFormat::kNESRealOne
@ kNESRealOne
Definition: TGNumberEntry.h:47
TEveTransSubEditor::fPos
TEveGTriVecValuator * fPos
Definition: TEveTransEditor.h:39
TEveTrans::GetRotAngles
void GetRotAngles(Float_t *x) const
Get Cardan rotation angles (pattern xYz above).
Definition: TEveTrans.cxx:622
TEveTrans::UnitTrans
void UnitTrans()
Reset matrix to unity.
Definition: TEveTrans.cxx:129
TEveTrans::SetRotByAngles
void SetRotByAngles(Float_t a1, Float_t a2, Float_t a3)
Definition: TEveTrans.cxx:571
TEveGValuator::GetEntry
TGNumberEntry * GetEntry()
Definition: TEveGValuators.h:88
TGVerticalFrame
Definition: TGFrame.h:412
TEveTransEditor.h
a
auto * a
Definition: textangle.C:12
TEveTransSubEditor::TransChanged
void TransChanged()
Set transformation values from widget and emit "TransChanged()" signal.
Definition: TEveTransEditor.cxx:186
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TEveTransSubEditor::fAutoUpdate
TGCheckButton * fAutoUpdate
Definition: TEveTransEditor.h:43
TEveTransSubEditor::DoTransChanged
void DoTransChanged()
Slot for TransChanged.
Definition: TEveTransEditor.cxx:213
TGLayoutHints
Definition: TGLayout.h:57
TEveTrans::GetEditRotation
Bool_t GetEditRotation()
Definition: TEveTrans.h:173
TEveTrans::SetPos
void SetPos(Double_t x, Double_t y, Double_t z)
Set position (base-vec 4).
Definition: TEveTrans.cxx:506
TEveTransSubEditor::DoUseTrans
void DoUseTrans()
Slot for UseTrans.
Definition: TEveTransEditor.cxx:195
TEveGTriVecValuator::SetNELength
void SetNELength(Int_t l)
Definition: TEveGValuators.h:192
TEveTransSubEditor::SetTransFromData
void SetTransFromData()
Set model object from widget data.
Definition: TEveTransEditor.cxx:163
y
Double_t y[n]
Definition: legend1.C:17
TEveTrans.h
TGedFrame::MakeTitle
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
TEveTransSubEditor::SetModel
void SetModel(TEveTrans *t)
Set model object.
Definition: TEveTransEditor.cxx:126
TEveTrans::fUseTrans
Bool_t fUseTrans
Definition: TEveTrans.h:40
TEveTransEditor
Definition: TEveTransEditor.h:68
TEveTransEditor::SetModel
virtual void SetModel(TObject *obj)
Set model object.
Definition: TEveTransEditor.cxx:246
unsigned int
TGLabel::SetTextFont
virtual void SetTextFont(TGFont *font, Bool_t global=kFALSE)
Changes text font specified by pointer to TGFont object.
Definition: TGLabel.cxx:323
TGedFrame
Definition: TGedFrame.h:33
TGLabel.h
TEveTrans::GetScale
void GetScale(Double_t &sx, Double_t &sy, Double_t &sz) const
Deduce scales from sizes of base vectors.
Definition: TEveTrans.cxx:677
TEveGValuator::SetToolTip
void SetToolTip(const char *tip)
Set the tooltip of the number-entry.
Definition: TEveGValuators.cxx:221
TEveTransSubEditor::UseTrans
void UseTrans()
Emit "UseTrans()" signal.
Definition: TEveTransEditor.cxx:178
Double_t
double Double_t
Definition: RtypesCore.h:59
TQObject::Connect
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:864
TGFrame::UnmapWindow
virtual void UnmapWindow()
unmap window
Definition: TGFrame.h:231
TEveTransSubEditor::fUpdate
TGTextButton * fUpdate
Definition: TEveTransEditor.h:44
TGWindow::GetMainFrame
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition: TGWindow.cxx:133
TEveGTriVecValuator::SetLimits
void SetLimits(Int_t min, Int_t max)
Set limits for all three number-entries, integer values.
Definition: TEveGValuators.cxx:470
TObject
Definition: TObject.h:37
TEveTrans::SetUseTrans
void SetUseTrans(Bool_t v)
Definition: TEveTrans.h:169
TGButton.h
TEveTransSubEditor::fUseTrans
TGCheckButton * fUseTrans
Definition: TEveTransEditor.h:34
TEveTrans::SetEditTrans
void SetEditTrans(Bool_t v)
Definition: TEveTrans.h:177
kLHintsExpandX
@ kLHintsExpandX
Definition: TGLayout.h:43
TGFont
Definition: TGFont.h:149
TEveTransSubEditor::fEditTransFrame
TGVerticalFrame * fEditTransFrame
Definition: TEveTransEditor.h:37
TEveTrans::Scale
void Scale(Double_t sx, Double_t sy, Double_t sz)
Scale matrix. Translation part untouched.
Definition: TEveTrans.cxx:646
TGNumberEntry::SetState
virtual void SetState(Bool_t enable=kTRUE)
Set the active state.
Definition: TGNumberEntry.cxx:2028
TGCompositeFrame::AddFrame
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1102
TGCompositeFrame::Layout
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1242
TEveTransSubEditor::fRot
TEveGTriVecValuator * fRot
Definition: TEveTransEditor.h:40
TQObject::Emit
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
TEveTrans::fEditTrans
Bool_t fEditTrans
Definition: TEveTrans.h:41
TMath.h
TEveTransSubEditor::fScale
TEveGTriVecValuator * fScale
Definition: TEveTransEditor.h:41
int