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
27
28////////////////////////////////////////////////////////////////////////////////
29/// Constructor.
30
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
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
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);
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
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);
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
221Editor 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}
@ kVerticalFrame
Definition GuiTypes.h:381
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
#define a(i)
Definition RSha256.hxx:99
#define e(i)
Definition RSha256.hxx:103
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
#define ClassImp(name)
Definition Rtypes.h:377
@ 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
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
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 &)
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.
void SetRotByAngles(Float_t a1, Float_t a2, Float_t a3)
void UnitTrans()
Reset matrix to unity.
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.
Bool_t fEditTrans
Definition TEveTrans.h:41
void GetRotAngles(Float_t *x) const
Get Cardan rotation angles (pattern xYz above).
void SetPos(Double_t x, Double_t y, Double_t z)
Set position (base-vec 4).
Bool_t GetEditRotation()
Definition TEveTrans.h:173
Selects different options.
Definition TGButton.h:264
Bool_t IsOn() const override
Definition TGButton.h:310
void SetState(EButtonState state, Bool_t emit=kFALSE) override
Set check button state.
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1257
Encapsulate fonts used in the GUI system.
Definition TGFont.h:140
void MapWindow() override
map window
Definition TGFrame.h:204
void UnmapWindow() override
unmap window
Definition TGFrame.h:206
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:385
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:324
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:397
virtual void SetState(Bool_t enable=kTRUE)
Set the active state.
@ 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
A composite frame that layout their children in vertical way.
Definition TGFrame.h:374
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition TGWindow.cxx:152
Base frame for implementing GUI - a service class.
Definition TGedFrame.h:27
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition TGedFrame.cxx:95
Mother of all ROOT objects.
Definition TObject.h:41
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:869
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:79
constexpr Double_t RadToDeg()
Conversion from radian to degree: .
Definition TMath.h:72