Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
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
23Sub-editor for TEveTrans class.
24*/
25
26
27////////////////////////////////////////////////////////////////////////////////
28/// Constructor.
29
32 fTrans (nullptr),
33 fTopHorFrame (nullptr),
34 fUseTrans (nullptr),
35 fEditTrans (nullptr),
36 fEditTransFrame (nullptr),
37 fPos (nullptr),
38 fRot (nullptr),
39 fScale (nullptr),
40 fAutoUpdate (nullptr),
41 fUpdate (nullptr)
42{
43 // --- Top controls
44
46
47 fUseTrans = new TGCheckButton(fTopHorFrame, "UseTrans");
48 fTopHorFrame->AddFrame(fUseTrans, new TGLayoutHints(kLHintsLeft, 1,2,0,0));
49 fUseTrans->Connect("Toggled(Bool_t)", "TEveTransSubEditor", this, "DoUseTrans()");
50 fEditTrans = new TGCheckButton(fTopHorFrame, "EditTrans");
51 fTopHorFrame->AddFrame(fEditTrans, new TGLayoutHints(kLHintsLeft, 2,1,0,0));
52 fEditTrans->Connect("Toggled(Bool_t)", "TEveTransSubEditor", this, "DoEditTrans()");
53
55
56 // --- Trans edit part
57
59
60 TGFont *font = gClient->GetFont("-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1");
61
63 TGLabel* labp = new TGLabel(hfp, "Location");
64 labp->SetTextFont(font);
65 hfp->AddFrame(labp);
66 fEditTransFrame->AddFrame(hfp, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0,0,2,0));
67 fPos = new TEveGTriVecValuator(fEditTransFrame, "Pos", 160, 20);
68 fPos->SetNELength(6);
69 fPos->Build(kFALSE, "", "", "");
70 fPos->SetLimits(-1e5, 1e5, TGNumberFormat::kNESRealThree);
71 fPos->GetValuator(0)->SetToolTip("X coordinate");
72 fPos->GetValuator(1)->SetToolTip("Y coordinate");
73 fPos->GetValuator(2)->SetToolTip("Z coordinate");
74 fEditTransFrame->AddFrame(fPos, new TGLayoutHints(kLHintsTop , 0,0,0,0));
75
77 TGLabel* labr = new TGLabel(hfr, "Rotation");
78 labr->SetTextFont(font);
79 hfr->AddFrame(labr);
80 fEditTransFrame->AddFrame(hfr, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0,0,2,0));
81 fRot = new TEveGTriVecValuator(fEditTransFrame, "Rot", 160, 20);
82 fRot->SetNELength(6);
83 fRot->Build(kFALSE, "", "", "");
84 fRot->SetLimits(-360, 360, TGNumberFormat::kNESRealOne);
85 fRot->GetValuator(0)->SetToolTip("X coordinate");
86 fRot->GetValuator(1)->SetToolTip("Y coordinate");
87 fRot->GetValuator(2)->SetToolTip("Z coordinate");
88 fEditTransFrame->AddFrame(fRot, new TGLayoutHints(kLHintsTop , 0,0, 0, 0));
89
91 TGLabel* labs = new TGLabel(hfs, "Scale");
92 labs->SetTextFont(font);
93 hfs->AddFrame(labs);
94 fEditTransFrame->AddFrame(hfs, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0,0,2,0));
95 fScale = new TEveGTriVecValuator(fEditTransFrame, "Scale", 160, 20);
96 fScale->SetNELength(6);
97 fScale->Build(kFALSE, "", "", "");
98 fScale->SetLimits(1e-2, 1e2, TGNumberFormat::kNESRealTwo);
99 fScale->GetValuator(0)->SetToolTip("X coordinate");
100 fScale->GetValuator(1)->SetToolTip("Y coordinate");
101 fScale->GetValuator(2)->SetToolTip("Z coordinate");
102 fEditTransFrame->AddFrame(fScale, new TGLayoutHints(kLHintsTop , 0,0,0, 2));
103
104 fPos ->Connect("ValueSet()", "TEveTransSubEditor", this, "DoTransChanged()");
105 fRot ->Connect("ValueSet()", "TEveTransSubEditor", this, "DoTransChanged()");
106 fScale->Connect("ValueSet()", "TEveTransSubEditor", this, "DoTransChanged()");
107
108 {
110 fAutoUpdate = new TGCheckButton(hframe, "AutoUpdate");
111 hframe->AddFrame(fAutoUpdate, new TGLayoutHints(kLHintsLeft, 1,1,1,1));
112 fUpdate = new TGTextButton(hframe, "Update");
113 hframe->AddFrame(fUpdate, new TGLayoutHints(kLHintsLeft, 0,0,1,1));
114 fUpdate->Connect("Clicked()", "TEveTransSubEditor", this, "TransChanged()");
115
116 fEditTransFrame->AddFrame(hframe, new TGLayoutHints(kLHintsTop , 0,0,4,0));
117 }
118
120}
121
122////////////////////////////////////////////////////////////////////////////////
123/// Set model object.
124
126{
127 fTrans = t;
128
129 fUseTrans ->SetState(fTrans->fUseTrans ? kButtonDown : kButtonUp);
130 fEditTrans->SetState(fTrans->fEditTrans ? kButtonDown : kButtonUp);
131 if (fTrans->fEditTrans)
132 {
133 for (Int_t i=0; i<3; ++i)
134 {
135 fRot ->GetValuator(i)->GetEntry()->SetState(fTrans->GetEditRotation());
136 fScale->GetValuator(i)->GetEntry()->SetState(fTrans->GetEditScale());
137 }
138 fEditTransFrame->MapWindow();
139 }
140 else
141 {
142 fEditTransFrame->UnmapWindow();
143 }
144
145 ((TGMainFrame*)fEditTransFrame->GetMainFrame())->Layout();
146
147 fPos->SetValues(fTrans->ArrT());
148 Float_t a[3];
149 fTrans->GetRotAngles(a);
150 a[0] *= TMath::RadToDeg();
151 a[1] *= TMath::RadToDeg();
152 a[2] *= TMath::RadToDeg();
153 fRot->SetValues(a);
154 Double_t x, y, z;
155 fTrans->GetScale(x, y, z);
156 fScale->SetValues(x, y, z);
157}
158
159////////////////////////////////////////////////////////////////////////////////
160/// Set model object from widget data.
161
163{
164 Double_t v[3];
165 fTrans->UnitTrans();
166 fRot->GetValues(v);
167 fTrans->SetRotByAngles(v[0]*TMath::DegToRad(), v[1]*TMath::DegToRad(), v[2]*TMath::DegToRad());
168 fPos->GetValues(v);
169 fTrans->SetPos(v);
170 fScale->GetValues(v);
171 fTrans->Scale(v[0], v[1], v[2]);
172}
173
174////////////////////////////////////////////////////////////////////////////////
175/// Emit "UseTrans()" signal.
176
178{
179 Emit("UseTrans()");
180}
181
182////////////////////////////////////////////////////////////////////////////////
183/// Set transformation values from widget and emit "TransChanged()" signal.
184
186{
188 Emit("TransChanged()");
189}
190
191////////////////////////////////////////////////////////////////////////////////
192/// Slot for UseTrans.
193
195{
196 fTrans->SetUseTrans(fUseTrans->IsOn());
197 UseTrans();
198}
199
200////////////////////////////////////////////////////////////////////////////////
201/// Slot for EditTrans.
202
204{
205 fTrans->SetEditTrans(fEditTrans->IsOn());
206 TransChanged();
207}
208
209////////////////////////////////////////////////////////////////////////////////
210/// Slot for TransChanged.
211
213{
214 if (fAutoUpdate->IsOn())
215 TransChanged();
216}
217
218/** \class TEveTransEditor
219\ingroup TEve
220Editor for TEveTrans class.
221*/
222
223
224////////////////////////////////////////////////////////////////////////////////
225/// Constructor.
226
228 UInt_t options, Pixel_t back) :
229 TGedFrame(p, width, height, options | kVerticalFrame, back),
230 fM (nullptr),
231 fSE(nullptr)
232{
233 MakeTitle("TEveTrans");
234
235 fSE = new TEveTransSubEditor(this);
236 AddFrame(fSE, new TGLayoutHints(kLHintsTop, 2, 0, 2, 2));
237 fSE->Connect("UseTrans()", "TEveTransEditor", this, "Update()");
238 fSE->Connect("TransChanged()", "TEveTransEditor", this, "Update()");
239}
240
241////////////////////////////////////////////////////////////////////////////////
242/// Set model object.
243
245{
246 fM = dynamic_cast<TEveTrans*>(obj);
247 fSE->SetModel(fM);
248}
@ kVerticalFrame
Definition GuiTypes.h:382
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
#define a(i)
Definition RSha256.hxx:99
#define e(i)
Definition RSha256.hxx:103
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
float Float_t
Float 4 bytes (float).
Definition RtypesCore.h:71
@ kButtonDown
Definition TGButton.h:54
@ kButtonUp
Definition TGButton.h:53
#define gClient
Definition TGClient.h:157
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
Composite GUI element for setting three numerical values (label, three number-entries).
TEveTransSubEditor * fSE
void SetModel(TObject *obj) override
Set model object.
TEveTransEditor(const TEveTransEditor &)
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
Selects different options.
Definition TGButton.h:264
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
Encapsulate fonts used in the GUI system.
Definition TGFont.h:140
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:387
This class handles GUI labels.
Definition TGLabel.h:24
virtual void SetTextFont(TGFont *font, Bool_t global=kFALSE)
Changes text font specified by pointer to TGFont object.
Definition TGLabel.cxx:323
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
Defines top level windows that interact with the system Window Manager.
Definition TGFrame.h:399
@ kNESRealOne
Fixed fraction real, one digit.
@ kNESRealThree
Fixed fraction real, three digit.
@ kNESRealTwo
Fixed fraction real, two digit.
Yield an action as soon as it is clicked.
Definition TGButton.h:142
TGVerticalFrame(const TGWindow *p=nullptr, UInt_t w=1, UInt_t h=1, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Definition TGFrame.h:378
ROOT GUI Window base class.
Definition TGWindow.h:23
TGedFrame(const TGedFrame &)=delete
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition TGedFrame.cxx:94
Mother of all ROOT objects.
Definition TObject.h:42
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
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:75