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