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 "TVirtualPad.h"
17#include "TMath.h"
18
19#include "TGButton.h"
20#include "TGLabel.h"
21
22/** \class TEveTransSubEditor
23\ingroup TEve
24Sub-editor for TEveTrans class.
25*/
26
28
29////////////////////////////////////////////////////////////////////////////////
30/// Constructor.
31
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
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
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);
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
150 Float_t a[3];
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);
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
222Editor 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}
@ kVerticalFrame
Definition: GuiTypes.h:381
ULong_t Pixel_t
Definition: GuiTypes.h:39
#define e(i)
Definition: RSha256.hxx:103
const Bool_t kFALSE
Definition: RtypesCore.h:90
double Double_t
Definition: RtypesCore.h:57
float Float_t
Definition: RtypesCore.h:55
#define ClassImp(name)
Definition: Rtypes.h:361
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
@ kButtonDown
Definition: TGButton.h:54
@ kButtonUp
Definition: TGButton.h:53
#define gClient
Definition: TGClient.h:166
@ kLHintsLeft
Definition: TGLayout.h:31
@ kLHintsTop
Definition: TGLayout.h:34
@ kLHintsExpandX
Definition: TGLayout.h:37
Composite GUI element for setting three numerical values (label, three number-entries).
void GetValues(Float_t &v0, Float_t &v1, Float_t &v2) const
void SetLimits(Int_t min, Int_t max)
Set limits for all three number-entries, integer values.
void Build(Bool_t vertical, const char *lab0, const char *lab1, const char *lab2)
Create sub-components (label, number entries).
void SetValues(Float_t v0, Float_t v1, Float_t v2)
void SetNELength(Int_t l)
TEveGValuator * GetValuator(Int_t i) const
TGNumberEntry * GetEntry()
void SetToolTip(const char *tip)
Set the tooltip of the number-entry.
Editor for TEveTrans class.
TEveTransSubEditor * fSE
TEveTransEditor(const TEveTransEditor &)
TEveTrans * fM
virtual void SetModel(TObject *obj)
Set model object.
Sub-editor for TEveTrans class.
void UseTrans()
Emit "UseTrans()" signal.
void DoUseTrans()
Slot for UseTrans.
TEveGTriVecValuator * fScale
TGHorizontalFrame * fTopHorFrame
TGCheckButton * fUseTrans
void DoEditTrans()
Slot for EditTrans.
TGTextButton * fUpdate
void TransChanged()
Set transformation values from widget and emit "TransChanged()" signal.
void SetTransFromData()
Set model object from widget data.
void SetModel(TEveTrans *t)
Set model object.
void DoTransChanged()
Slot for TransChanged.
TGVerticalFrame * fEditTransFrame
TEveGTriVecValuator * fRot
TGCheckButton * fEditTrans
TGCheckButton * fAutoUpdate
TEveTransSubEditor(const TEveTransSubEditor &)
TEveGTriVecValuator * fPos
TEveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Definition: TEveTrans.h:27
void SetUseTrans(Bool_t v)
Definition: TEveTrans.h:169
Bool_t GetEditScale()
Definition: TEveTrans.h:174
Double_t * ArrT()
Definition: TEveTrans.h:98
Bool_t fUseTrans
Definition: TEveTrans.h:40
void Scale(Double_t sx, Double_t sy, Double_t sz)
Scale matrix. Translation part untouched.
Definition: TEveTrans.cxx:647
void SetRotByAngles(Float_t a1, Float_t a2, Float_t a3)
Definition: TEveTrans.cxx:572
void UnitTrans()
Reset matrix to unity.
Definition: TEveTrans.cxx:130
void SetEditTrans(Bool_t v)
Definition: TEveTrans.h:177
void GetScale(Double_t &sx, Double_t &sy, Double_t &sz) const
Deduce scales from sizes of base vectors.
Definition: TEveTrans.cxx:678
Bool_t fEditTrans
Definition: TEveTrans.h:41
void GetRotAngles(Float_t *x) const
Get Cardan rotation angles (pattern xYz above).
Definition: TEveTrans.cxx:623
void SetPos(Double_t x, Double_t y, Double_t z)
Set position (base-vec 4).
Definition: TEveTrans.cxx:507
Bool_t GetEditRotation()
Definition: TEveTrans.h:173
virtual Bool_t IsOn() const
Definition: TGButton.h:311
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set check button state.
Definition: TGButton.cxx:1202
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1101
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1241
Definition: TGFont.h:149
virtual void MapWindow()
map window
Definition: TGFrame.h:229
virtual void UnmapWindow()
unmap window
Definition: TGFrame.h:231
virtual void SetTextFont(TGFont *font, Bool_t global=kFALSE)
Changes text font specified by pointer to TGFont object.
Definition: TGLabel.cxx:322
virtual void SetState(Bool_t enable=kTRUE)
Set the active state.
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
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition: TGWindow.cxx:142
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
Mother of all ROOT objects.
Definition: TObject.h:37
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.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:866
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
constexpr Double_t DegToRad()
Conversion from degree to radian:
Definition: TMath.h:82
constexpr Double_t RadToDeg()
Conversion from radian to degree:
Definition: TMath.h:74
auto * a
Definition: textangle.C:12