]>
Commit | Line | Data |
---|---|---|
37b09b91 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
76082cd6 | 17 | |
18 | #include "ZTransEditor.h" | |
19 | #include <Reve/ZTrans.h> | |
20 | #include <Reve/RGValuators.h> | |
21 | ||
22 | #include <TVirtualPad.h> | |
37b09b91 | 23 | #include <TMath.h> |
76082cd6 | 24 | |
25 | #include <TGButton.h> | |
26 | ||
27 | ||
28 | using namespace Reve; | |
29 | ||
30 | //______________________________________________________________________ | |
31 | // ZTransSubEditor | |
32 | // | |
33 | ||
34 | ClassImp(ZTransSubEditor) | |
35 | ||
36 | ZTransSubEditor::ZTransSubEditor(TGWindow* p) : | |
37 | TGVerticalFrame(p), | |
3c67f72c | 38 | fTrans (0), |
39 | ||
40 | fTopHorFrame(0), | |
41 | ||
42 | fUseTrans(0), | |
43 | fEditTrans(0), | |
44 | ||
45 | fEditTransFrame(0), | |
46 | ||
47 | fPos(0), | |
48 | fRot(0), | |
49 | fScale(0), | |
50 | ||
51 | fAutoUpdate(0), | |
52 | fUpdate(0) | |
76082cd6 | 53 | { |
54 | // --- Top controls | |
55 | ||
56 | fTopHorFrame = new TGHorizontalFrame(this); | |
57 | ||
58 | fUseTrans = new TGCheckButton(fTopHorFrame, "UseTrans"); | |
59 | fTopHorFrame->AddFrame(fUseTrans, new TGLayoutHints(kLHintsLeft, 1,2,0,0)); | |
60 | fUseTrans->Connect("Toggled(Bool_t)", "Reve::ZTransSubEditor", this, "DoUseTrans()"); | |
61 | fEditTrans = new TGCheckButton(fTopHorFrame, "EditTrans"); | |
62 | fTopHorFrame->AddFrame(fEditTrans, new TGLayoutHints(kLHintsLeft, 2,1,0,0)); | |
63 | fEditTrans->Connect("Toggled(Bool_t)"," Reve::ZTransSubEditor", this, "DoEditTrans()"); | |
64 | ||
65 | AddFrame(fTopHorFrame, new TGLayoutHints(kLHintsTop, 0,0,2,1)); | |
66 | ||
67 | ||
68 | // --- Trans edit part | |
69 | ||
70 | fEditTransFrame = new TGVerticalFrame(this); | |
71 | ||
72 | fPos = new RGTriVecValuator(fEditTransFrame, "Pos", 160, 20); | |
73 | fPos->SetLabelWidth(9); | |
74 | fPos->SetNELength(6); | |
75 | fPos->Build(kFALSE, "x", "y", "z"); | |
76 | fPos->SetLimits(-1e5, 1e5, TGNumberFormat::kNESRealThree); | |
77 | fEditTransFrame->AddFrame(fPos, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0,0,0,0)); | |
78 | ||
79 | fRot = new RGTriVecValuator(fEditTransFrame, "Rot", 160, 20); | |
80 | fRot->SetLabelWidth(17); | |
81 | fRot->SetNELength(5); | |
82 | fRot->Build(kFALSE, "Rz", "RY", "Rx"); | |
83 | fRot->SetLimits(-360, 360, TGNumberFormat::kNESRealOne); | |
84 | fEditTransFrame->AddFrame(fRot, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0,0,0,0)); | |
85 | ||
86 | fScale = new RGTriVecValuator(fEditTransFrame, "Scale", 160, 20); | |
87 | fScale->SetLabelWidth(17); | |
88 | fScale->SetNELength(5); | |
89 | fScale->Build(kFALSE, "Sx", "Sy", "Sz"); | |
90 | fScale->SetLimits(1e-2, 1e2, TGNumberFormat::kNESRealTwo); | |
91 | fEditTransFrame->AddFrame(fScale, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0,0,0,0)); | |
92 | ||
93 | fPos ->Connect("ValueSet()", "Reve::ZTransSubEditor", this, "DoTransChanged()"); | |
94 | fRot ->Connect("ValueSet()", "Reve::ZTransSubEditor", this, "DoTransChanged()"); | |
95 | fScale->Connect("ValueSet()", "Reve::ZTransSubEditor", this, "DoTransChanged()"); | |
96 | ||
97 | { | |
98 | TGHorizontalFrame* hframe = new TGHorizontalFrame(fEditTransFrame); | |
99 | ||
100 | fAutoUpdate = new TGCheckButton(hframe, "AutoUpdate"); | |
101 | hframe->AddFrame(fAutoUpdate, new TGLayoutHints(kLHintsLeft, 1,10,1,1)); | |
102 | fUpdate = new TGTextButton(hframe, "Update"); | |
103 | hframe->AddFrame(fUpdate, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 5,5,1,1)); | |
104 | fUpdate->Connect("Clicked()", "Reve::ZTransSubEditor", this, "TransChanged()"); | |
105 | ||
106 | fEditTransFrame->AddFrame(hframe, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0,0,0,0)); | |
107 | } | |
108 | ||
109 | AddFrame(fEditTransFrame, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0,0,1,2)); | |
110 | } | |
111 | ||
112 | /**************************************************************************/ | |
113 | ||
114 | void ZTransSubEditor::SetDataFromTrans(ZTrans* t) | |
115 | { | |
116 | fTrans = t; | |
117 | ||
118 | fUseTrans ->SetState(fTrans->fUseTrans ? kButtonDown : kButtonUp); | |
119 | fEditTrans->SetState(fTrans->fEditTrans ? kButtonDown : kButtonUp); | |
120 | if (fTrans->fEditTrans) | |
121 | fEditTransFrame->MapWindow(); | |
122 | else | |
123 | fEditTransFrame->UnmapWindow(); | |
124 | ((TGMainFrame*)fEditTransFrame->GetMainFrame())->Layout(); | |
125 | ||
126 | fPos->SetValues(fTrans->ArrT()); | |
127 | Float_t a[3]; | |
128 | fTrans->GetRotAngles(a); | |
129 | a[0] *= TMath::RadToDeg(); | |
130 | a[1] *= TMath::RadToDeg(); | |
131 | a[2] *= TMath::RadToDeg(); | |
132 | fRot->SetValues(a); | |
133 | Double_t x, y, z; | |
134 | fTrans->GetScale(x, y, z); | |
135 | fScale->SetValues(x, y, z); | |
136 | } | |
137 | ||
138 | void ZTransSubEditor::SetTransFromData() | |
139 | { | |
140 | Double_t v[3]; | |
141 | fTrans->UnitTrans(); | |
142 | fRot->GetValues(v); | |
143 | fTrans->SetRotByAngles(v[0]*TMath::DegToRad(), v[1]*TMath::DegToRad(), v[2]*TMath::DegToRad()); | |
144 | fPos->GetValues(v); | |
145 | fTrans->SetPos(v); | |
146 | fScale->GetValues(v); | |
147 | fTrans->Scale(v[0], v[1], v[2]); | |
148 | } | |
149 | ||
150 | /**************************************************************************/ | |
151 | ||
152 | void ZTransSubEditor::UseTrans() | |
153 | { | |
154 | Emit("UseTrans()"); | |
155 | } | |
156 | ||
157 | void ZTransSubEditor::TransChanged() | |
158 | { | |
159 | SetTransFromData(); | |
160 | Emit("TransChanged()"); | |
161 | } | |
162 | ||
163 | /**************************************************************************/ | |
164 | ||
165 | void ZTransSubEditor::DoUseTrans() | |
166 | { | |
167 | fTrans->SetUseTrans(fUseTrans->IsOn()); | |
168 | UseTrans(); | |
169 | } | |
170 | ||
171 | void ZTransSubEditor::DoEditTrans() | |
172 | { | |
173 | fTrans->SetEditTrans(fEditTrans->IsOn()); | |
174 | if (fEditTrans->IsOn()) | |
175 | fEditTransFrame->MapWindow(); | |
176 | else | |
177 | fEditTransFrame->UnmapWindow(); | |
178 | ((TGMainFrame*)fEditTransFrame->GetMainFrame())->Layout(); | |
179 | } | |
180 | ||
181 | void ZTransSubEditor::DoTransChanged() | |
182 | { | |
183 | if (fAutoUpdate->IsOn()) | |
184 | TransChanged(); | |
185 | } | |
186 | ||
187 | /**************************************************************************/ | |
188 | /**************************************************************************/ | |
189 | /**************************************************************************/ | |
190 | ||
191 | //______________________________________________________________________ | |
192 | // ZTransEditor | |
193 | // | |
194 | ||
195 | ClassImp(ZTransEditor) | |
196 | ||
197 | ZTransEditor::ZTransEditor(const TGWindow *p, Int_t width, Int_t height, | |
198 | UInt_t options, Pixel_t back) : | |
199 | TGedFrame(p, width, height, options | kVerticalFrame, back), | |
200 | fM(0) | |
201 | // Initialize widget pointers to 0 | |
202 | { | |
203 | MakeTitle("ZTrans"); | |
204 | ||
205 | // Create widgets | |
206 | // fXYZZ = new TGSomeWidget(this, ...); | |
207 | // AddFrame(fXYZZ, new TGLayoutHints(...)); | |
208 | // fXYZZ->Connect("SignalName()", "Reve::ZTransEditor", this, "DoXYZZ()"); | |
209 | } | |
210 | ||
211 | ZTransEditor::~ZTransEditor() | |
212 | {} | |
213 | ||
214 | /**************************************************************************/ | |
215 | ||
216 | void ZTransEditor::SetModel(TObject* obj) | |
217 | { | |
218 | fM = dynamic_cast<ZTrans*>(obj); | |
219 | ||
220 | // Set values of widgets | |
221 | // fXYZZ->SetValue(fM->GetXYZZ()); | |
222 | } | |
223 | ||
224 | /**************************************************************************/ | |
225 | ||
226 | // Implements callback/slot methods | |
227 | ||
228 | // void ZTransEditor::DoXYZZ() | |
229 | // { | |
230 | // fM->SetXYZZ(fXYZZ->GetValue()); | |
231 | // Update(); | |
232 | // } |