Debian Codegraph @

editor/ViewerPropDlg.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/editor/ViewerPropDlg.cpp $
21 * $Revision: 1.1.1.1 $
22 * $Date: 2003-08-26 03:57:39 $
23 * $Author: kevinb $
24 *
25 * Viewer Properties Dialog Implementation
26 *
27 * $Log: not supported by cvs2svn $
28 *
29 * 3 4/17/99 2:46p Matt
30 * Implemented viewer properties dialog functions.
31 *
32 * 2 4/16/99 3:53p Nate
33 * Initial version
34 *
35 * $NoKeywords: $
36 */
37
38 // ViewerPropDlg.cpp : implementation file
39 //
40
41 #include "stdafx.h"
42 #include "editor.h"
43 #include "ViewerPropDlg.h"
44 #include "object.h"
45
46 #ifdef _DEBUG
47 #define new DEBUG_NEW
48 #undef THIS_FILE
49 static char THIS_FILE[] = __FILE__;
50 #endif
51
52 /////////////////////////////////////////////////////////////////////////////
53 // CViewerPropDlg dialog
54
55 CViewerPropDlg::CViewerPropDlg(CWnd *pParent /*=NULL*/) : CDialog(CViewerPropDlg::IDD, pParent) {
56 //{{AFX_DATA_INIT(CViewerPropDlg)
57 // NOTE: the ClassWizard will add member initialization here
58 //}}AFX_DATA_INIT
59 }
60
61 void CViewerPropDlg::DoDataExchange(CDataExchange *pDX) {
62 CDialog::DoDataExchange(pDX);
63 //{{AFX_DATA_MAP(CViewerPropDlg)
64 DDX_Control(pDX, IDC_ZPOS_EDIT, m_ZPosEdit);
65 DDX_Control(pDX, IDC_YPOS_EDIT, m_YPosEdit);
66 DDX_Control(pDX, IDC_XPOS_EDIT, m_XPosEdit);
67 DDX_Control(pDX, IDC_ZMOVE_CHECK, m_ZMoveCheck);
68 DDX_Control(pDX, IDC_YMOVE_CHECK, m_YMoveCheck);
69 DDX_Control(pDX, IDC_XMOVE_CHECK, m_XMoveCheck);
70 DDX_Control(pDX, IDC_PITCH_EDIT, m_PitchEdit);
71 DDX_Control(pDX, IDC_HEADING_EDIT, m_HeadingEdit);
72 DDX_Control(pDX, IDC_BANK_EDIT, m_BankEdit);
73 //}}AFX_DATA_MAP
74 }
75
76 BEGIN_MESSAGE_MAP(CViewerPropDlg, CDialog)
77 //{{AFX_MSG_MAP(CViewerPropDlg)
78 ON_WM_DESTROY()
79 ON_BN_CLICKED(IDC_ALIGN_UPYPOS_BUTTON, OnAlignUpWithYposButton)
80 ON_BN_CLICKED(IDC_ALIGN_XNEG_BUTTON, OnAlignXnegButton)
81 ON_BN_CLICKED(IDC_ALIGN_XPOS_BUTTON, OnAlignXposButton)
82 ON_BN_CLICKED(IDC_ALIGN_YNEG_BUTTON, OnAlignYnegButton)
83 ON_BN_CLICKED(IDC_ALIGN_YPOS_BUTTON, OnAlignYposButton)
84 ON_BN_CLICKED(IDC_ALIGN_ZNEG_BUTTON, OnAlignZnegButton)
85 ON_BN_CLICKED(IDC_ALIGN_ZPOS_BUTTON, OnAlignZposButton)
86 ON_BN_CLICKED(IDC_ORIENT_COMMIT_BUTTON, OnOrientCommitButton)
87 ON_BN_CLICKED(IDC_POS_COMMIT_BUTTON, OnPosCommitButton)
88 ON_WM_CLOSE()
89 ON_BN_CLICKED(IDC_XMOVE_CHECK, OnXMoveCheck)
90 ON_BN_CLICKED(IDC_YMOVE_CHECK, OnYMoveCheck)
91 ON_BN_CLICKED(IDC_ZMOVE_CHECK, OnZMoveCheck)
92 //}}AFX_MSG_MAP
93 END_MESSAGE_MAP()
94
95 /////////////////////////////////////////////////////////////////////////////
96 // CViewerPropDlg message handlers
97
98 BOOL CViewerPropDlg::OnInitDialog() {
99 CDialog::OnInitDialog();
100
101 // Set Defaults
102 m_XMoveCheck.SetCheck(1);
103 m_YMoveCheck.SetCheck(1);
104 m_ZMoveCheck.SetCheck(1);
105
106 UpdatePosition();
107 UpdateOrientation();
108
109 ((CButton *)GetDlgItem(IDC_POS_COMMIT_BUTTON))->EnableWindow(0);
110
111 return TRUE; // return TRUE unless you set the focus to a control
112 // EXCEPTION: OCX Property Pages should return FALSE
113 }
114
115 void CViewerPropDlg::PostNcDestroy() {
116 // Set the pointer back to null so rest of app knows Viewer Prog dlg has shut down
117 theApp.m_ViewerPropDlgPtr = NULL;
118
119 // Delete the viewer prop instance
120 delete this;
121 }
122
123 void CViewerPropDlg::OnClose() {
124 // Shut it all down
125 DestroyWindow();
126 }
127
128 extern int Slew_limitations;
129
130 void CViewerPropDlg::OnDestroy() {
131 CDialog::OnDestroy();
132
133 Slew_limitations = 0;
134 }
135
136 void CViewerPropDlg::OnAlignUpWithYposButton() {
137 matrix *m = &Viewer_object->orient;
138
139 m->rvec.y = m->fvec.y = m->uvec.x = m->uvec.z = 0;
140 m->uvec.y = 1.0;
141
142 vm_Orthogonalize(m);
143
144 Viewer_moved = 1;
145 }
146
147 void CViewerPropDlg::OnAlignXnegButton() {
148 matrix *m = &Viewer_object->orient;
149
150 m->fvec.x = -1.0;
151 m->fvec.y = m->fvec.z = 0;
152 m->uvec.y = 1.0;
153 m->uvec.x = m->uvec.z = 0;
154 m->rvec.z = 1.0;
155 m->rvec.x = m->rvec.y = 0;
156
157 Viewer_moved = 1;
158 }
159
160 void CViewerPropDlg::OnAlignXposButton() {
161 matrix *m = &Viewer_object->orient;
162
163 m->fvec.x = 1.0;
164 m->fvec.y = m->fvec.z = 0;
165 m->uvec.y = 1.0;
166 m->uvec.x = m->uvec.z = 0;
167 m->rvec.z = -1.0;
168 m->rvec.x = m->rvec.y = 0;
169
170 Viewer_moved = 1;
171 }
172
173 void CViewerPropDlg::OnAlignYnegButton() {
174 matrix *m = &Viewer_object->orient;
175
176 m->fvec.y = -1.0;
177 m->fvec.x = m->fvec.z = 0;
178 m->uvec.z = 1.0;
179 m->uvec.x = m->uvec.y = 0;
180 m->rvec.x = 1.0;
181 m->rvec.y = m->rvec.z = 0;
182
183 Viewer_moved = 1;
184 }
185
186 void CViewerPropDlg::OnAlignYposButton() {
187 matrix *m = &Viewer_object->orient;
188
189 m->fvec.y = 1.0;
190 m->fvec.x = m->fvec.z = 0;
191 m->uvec.z = -1.0;
192 m->uvec.x = m->uvec.y = 0;
193 m->rvec.x = 1.0;
194 m->rvec.y = m->rvec.z = 0;
195
196 Viewer_moved = 1;
197 }
198
199 void CViewerPropDlg::OnAlignZnegButton() {
200 matrix *m = &Viewer_object->orient;
201
202 m->fvec.z = -1.0;
203 m->fvec.x = m->fvec.y = 0;
204 m->uvec.y = 1.0;
205 m->uvec.x = m->uvec.z = 0;
206 m->rvec.x = -1.0;
207 m->rvec.y = m->rvec.z = 0;
208
209 Viewer_moved = 1;
210 }
211
212 void CViewerPropDlg::OnAlignZposButton() {
213 matrix *m = &Viewer_object->orient;
214
215 m->fvec.z = 1.0;
216 m->fvec.x = m->fvec.y = 0;
217 m->uvec.y = 1.0;
218 m->uvec.x = m->uvec.z = 0;
219 m->rvec.x = 1.0;
220 m->rvec.y = m->rvec.z = 0;
221
222 Viewer_moved = 1;
223 }
224
225 void CViewerPropDlg::OnOrientCommitButton() {
226 angle p, b, h;
227 char buf[10];
228
229 m_PitchEdit.GetWindowText(buf, sizeof(buf));
230 p = atof(buf) * 65536 / 360;
231
232 m_HeadingEdit.GetWindowText(buf, sizeof(buf));
233 h = atof(buf) * 65536 / 360;
234
235 m_BankEdit.GetWindowText(buf, sizeof(buf));
236 b = atof(buf) * 65536 / 360;
237
238 mprintf(0, "Agngles %x %x %x\n", p, h, b);
239
240 vm_AnglesToMatrix(&Viewer_object->orient, p, h, b);
241
242 State_changed = Viewer_moved = 1;
243 }
244
245 #include "findintersection.h"
246
247 void CViewerPropDlg::OnPosCommitButton() {
248 vector pos;
249 char buf[10];
250
251 m_XPosEdit.GetWindowText(buf, sizeof(buf));
252 pos.x = atof(buf);
253
254 m_YPosEdit.GetWindowText(buf, sizeof(buf));
255 pos.y = atof(buf);
256
257 m_ZPosEdit.GetWindowText(buf, sizeof(buf));
258 pos.z = atof(buf);
259 }
260
261 void CViewerPropDlg::UpdateOrientation() {
262 char buf[10];
263 angvec angs;
264
265 vm_ExtractAnglesFromMatrix(&angs, &Viewer_object->orient);
266
267 sprintf(buf, "%d", (int)angs.p * 360 / 65536);
268 m_PitchEdit.SetWindowText(buf);
269
270 sprintf(buf, "%d", (int)angs.h * 360 / 65536);
271 m_HeadingEdit.SetWindowText(buf);
272
273 sprintf(buf, "%d", (int)angs.b * 360 / 65536);
274 m_BankEdit.SetWindowText(buf);
275 }
276
277 void CViewerPropDlg::UpdatePosition() {
278 char buf[10];
279
280 sprintf(buf, "%.2f", Viewer_object->pos.x);
281 m_XPosEdit.SetWindowText(buf);
282
283 sprintf(buf, "%.2f", Viewer_object->pos.y);
284 m_YPosEdit.SetWindowText(buf);
285
286 sprintf(buf, "%.2f", Viewer_object->pos.z);
287 m_ZPosEdit.SetWindowText(buf);
288 }
289
290 void CViewerPropDlg::OnXMoveCheck() {
291 if (m_XMoveCheck.GetCheck())
292 Slew_limitations &= ~1;
293 else
294 Slew_limitations |= 1;
295 }
296
297 void CViewerPropDlg::OnYMoveCheck() {
298 if (m_YMoveCheck.GetCheck())
299 Slew_limitations &= ~2;
300 else
301 Slew_limitations |= 2;
302 }
303
304 void CViewerPropDlg::OnZMoveCheck() {
305 if (m_ZMoveCheck.GetCheck())
306 Slew_limitations &= ~4;
307 else
308 Slew_limitations |= 4;
309 }