Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

open-axiom repository from github

24005 views
1
/*
2
Copyright (C) 1991-2002, The Numerical Algorithms Group Ltd.
3
All rights reserved.
4
Copyright (C) 2007-2008, Gabriel Dos Reis.
5
All rights reserved.
6
7
Redistribution and use in source and binary forms, with or without
8
modification, are permitted provided that the following conditions are
9
met:
10
11
- Redistributions of source code must retain the above copyright
12
notice, this list of conditions and the following disclaimer.
13
14
- Redistributions in binary form must reproduce the above copyright
15
notice, this list of conditions and the following disclaimer in
16
the documentation and/or other materials provided with the
17
distribution.
18
19
- Neither the name of The Numerical Algorithms Group Ltd. nor the
20
names of its contributors may be used to endorse or promote products
21
derived from this software without specific prior written permission.
22
23
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
24
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
26
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
27
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
*/
35
36
#define _BUTTONS3D_C
37
#include "openaxiom-c-macros.h"
38
39
#include "header.h"
40
#include "cpanel.h"
41
42
#include "all_3d.H1"
43
#define BH 31 /* button window height */
44
#define PH 80 /* potentiometer window height */
45
#define XEDGE 5 /* leftmost button starts here */
46
47
/*****************************************************
48
* int initButtons(buttons) *
49
* *
50
* Creates the fields for each button window in the *
51
* three dimensional control panel, and returns the *
52
* number of buttons created. *
53
* *
54
*****************************************************/
55
56
int
57
initButtons (buttonStruct *buttons)
58
{
59
60
int PBY = 297; /* panel button Y coordinate at which buttons appear */
61
int ii, num = 0;
62
63
/* Rotate, Zoom, and Translate Potentiometer Buttons */
64
65
/* Title: "Rotate" */
66
ii = rotate;
67
buttons[ii].buttonX = XEDGE; buttons[ii].buttonY = 85;
68
buttons[ii].buttonWidth = 110; buttons[ii].buttonHeight = PH;
69
buttons[ii].buttonKey = ii;
70
buttons[ii].pot = yes; /* rotate is a potentiometer */
71
buttons[ii].mask = potMASK;
72
buttons[ii].textColor = 139; /* line color of rotate dial */
73
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
74
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
75
++num;
76
77
/* Title: "Scale" */
78
ii = zoom;
79
buttons[ii].buttonX = 121; buttons[ii].buttonY = 85;
80
buttons[ii].buttonWidth = 58; buttons[ii].buttonHeight = PH;
81
buttons[ii].buttonKey = ii;
82
buttons[ii].pot = yes; /* zoom(scale) is a potentiometer */
83
buttons[ii].mask = potMASK;
84
buttons[ii].textColor = 165; /* line color of scale arrow */
85
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
86
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
87
++num;
88
89
90
/* Title: "Translate" */
91
ii = translate;
92
buttons[ii].buttonX = 185; buttons[ii].buttonY = 85;
93
buttons[ii].buttonWidth = 110; buttons[ii].buttonHeight = PH;
94
buttons[ii].buttonKey = ii;
95
buttons[ii].pot = yes; /* translate is a potentiometer */
96
buttons[ii].mask = potMASK;
97
buttons[ii].textColor = 21; /* line color of translate arrows */
98
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
99
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
100
++num;
101
102
/* All the rest of the buttons are regular, toggle only buttons and
103
have the potentiometer variable set to "no". */
104
105
/* First Row of Buttons */
106
/* The four rendering mode buttons:
107
wireframe, hiddenline solid, hiddenline shaded and smooth shaded **/
108
109
/* Wirefram mesh */
110
ii = transparent;
111
buttons[ii].buttonX = XEDGE; buttons[ii].buttonY = PBY;
112
buttons[ii].buttonWidth = 45; buttons[ii].buttonHeight = BH;
113
buttons[ii].buttonKey = ii;
114
buttons[ii].pot = no;
115
buttons[ii].mask = buttonMASK;
116
buttons[ii].text = "Wire";
117
buttons[ii].textColor = modeColor;
118
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
119
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
120
++num;
121
122
/* Hidden surface mesh */
123
ii = opaqueMesh;
124
buttons[ii].buttonX = 55; buttons[ii].buttonY = PBY;
125
buttons[ii].buttonWidth = 53; buttons[ii].buttonHeight = BH;
126
buttons[ii].buttonKey = ii;
127
buttons[ii].pot = no;
128
buttons[ii].mask = buttonMASK;
129
buttons[ii].text = "Solid";
130
buttons[ii].textColor = modeColor;
131
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
132
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
133
++num;
134
135
/* Lambertian polygon fill with phong illumination model */
136
ii = render;
137
buttons[ii].buttonX = 113; buttons[ii].buttonY = PBY;
138
buttons[ii].buttonWidth = 53; buttons[ii].buttonHeight = BH;
139
buttons[ii].buttonKey = ii;
140
buttons[ii].pot = no;
141
buttons[ii].mask = buttonMASK;
142
buttons[ii].text = "Shade";
143
buttons[ii].textColor = modeColor;
144
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
145
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
146
++num;
147
148
/* Phong smooth shading and illumination */
149
ii = smooth;
150
buttons[ii].buttonX = 171; buttons[ii].buttonY = PBY;
151
buttons[ii].buttonWidth = 59; buttons[ii].buttonHeight = BH;
152
buttons[ii].buttonKey = ii;
153
buttons[ii].pot = no;
154
buttons[ii].mask = buttonMASK;
155
buttons[ii].text = "Smooth";
156
buttons[ii].textColor = modeColor;
157
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
158
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
159
++num;
160
161
/* Reset View Position Button */
162
ii = resetView;
163
buttons[ii].buttonX = 240; buttons[ii].buttonY = PBY;
164
buttons[ii].buttonWidth = 53; buttons[ii].buttonHeight = BH;
165
buttons[ii].buttonKey = ii;
166
buttons[ii].pot = no;
167
buttons[ii].mask = buttonMASK;
168
buttons[ii].text = "Reset";
169
buttons[ii].textColor = 149;
170
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
171
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
172
++num;
173
174
175
/* Second Row of Buttons */
176
177
/* update y displacement of buttons row */
178
PBY=PBY+BH+3;
179
180
/* Bounding Region On/Off */
181
ii = region3D;
182
buttons[ii].buttonX = XEDGE; buttons[ii].buttonY = PBY;
183
buttons[ii].buttonWidth = 58; buttons[ii].buttonHeight = BH;
184
buttons[ii].buttonKey = ii;
185
buttons[ii].pot = no;
186
buttons[ii].mask = buttonMASK;
187
buttons[ii].text = "Bounds";
188
buttons[ii].textColor = 6;
189
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
190
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
191
++num;
192
193
/* Axes Turned On/Off */
194
ii = axesOnOff;
195
buttons[ii].buttonX = 68; buttons[ii].buttonY = PBY;
196
buttons[ii].buttonWidth = 49; buttons[ii].buttonHeight = BH;
197
buttons[ii].buttonKey = ii;
198
buttons[ii].pot = no;
199
buttons[ii].mask = buttonMASK;
200
buttons[ii].text = "Axes";
201
buttons[ii].textColor = offColor;
202
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
203
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
204
++num;
205
206
/* Outline polygons with black lines in render mode */
207
ii = outlineOnOff;
208
buttons[ii].buttonX = 122; buttons[ii].buttonY = PBY;
209
buttons[ii].buttonWidth = 70; buttons[ii].buttonHeight = BH;
210
buttons[ii].buttonKey = ii;
211
buttons[ii].pot = no;
212
buttons[ii].mask = buttonMASK;
213
buttons[ii].text = "Outline";
214
buttons[ii].textColor = offColor;
215
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
216
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
217
++num;
218
219
/* Display as if a 1-bit plane image */
220
ii = bwColor;
221
buttons[ii].buttonX = 197; buttons[ii].buttonY = PBY;
222
buttons[ii].buttonWidth = 33; buttons[ii].buttonHeight = BH;
223
buttons[ii].buttonKey = ii;
224
buttons[ii].pot = no;
225
buttons[ii].mask = buttonMASK;
226
buttons[ii].text = "BW";
227
buttons[ii].textColor = offColor;
228
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
229
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
230
++num;
231
232
/* Hide Control Panel */
233
ii = hideControl;
234
buttons[ii].buttonX = 240; buttons[ii].buttonY = PBY;
235
buttons[ii].buttonWidth = 53; buttons[ii].buttonHeight = BH;
236
buttons[ii].buttonKey = ii;
237
buttons[ii].pot = no;
238
buttons[ii].mask = buttonMASK;
239
buttons[ii].text = "Hide";
240
buttons[ii].textColor = 149;
241
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
242
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
243
++num;
244
245
246
/* Third Row of Buttons */
247
248
/* update y displacement of buttons row */
249
PBY=PBY+BH+3;
250
251
/* Shows Lighting Control Panel */
252
ii = lighting;
253
buttons[ii].buttonX = XEDGE; buttons[ii].buttonY = PBY;
254
buttons[ii].buttonWidth = 65; buttons[ii].buttonHeight = BH;
255
buttons[ii].buttonKey = ii;
256
buttons[ii].pot = no;
257
buttons[ii].mask = buttonMASK;
258
buttons[ii].text = "Light";
259
buttons[ii].textColor = 149;
260
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
261
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
262
++num;
263
264
/* Shows View Volume Control Panel */
265
ii = viewVolume;
266
buttons[ii].buttonX = 75; buttons[ii].buttonY = PBY;
267
buttons[ii].buttonWidth = 100; buttons[ii].buttonHeight = BH;
268
buttons[ii].buttonKey = ii;
269
buttons[ii].pot = no;
270
buttons[ii].mask = buttonMASK;
271
buttons[ii].text = "View Volume";
272
buttons[ii].textColor = 149;
273
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
274
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
275
++num;
276
277
/* Shows Save Panel */
278
ii = saveit;
279
buttons[ii].buttonX = 180; buttons[ii].buttonY = PBY;
280
buttons[ii].buttonWidth = 50; buttons[ii].buttonHeight = BH;
281
buttons[ii].buttonKey = ii;
282
buttons[ii].pot = no;
283
buttons[ii].mask = buttonMASK;
284
buttons[ii].text = "Save";
285
buttons[ii].textColor = 149;
286
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
287
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
288
++num;
289
290
/* Exits from the viewport running */
291
ii = closeAll;
292
buttons[ii].buttonX = 240; buttons[ii].buttonY = PBY;
293
buttons[ii].buttonWidth = 53; buttons[ii].buttonHeight = BH;
294
buttons[ii].buttonKey = ii;
295
buttons[ii].pot = no;
296
buttons[ii].mask = buttonMASK;
297
buttons[ii].text = "Quit";
298
buttons[ii].textColor = offColor;
299
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
300
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
301
++num;
302
303
/* Buttons to control potentiometers */
304
/* These buttons appear above the potentiometer windows which they affect. */
305
306
/* Rotate potentiometer buttons */
307
308
/* Rotate about the origin indicated by the axes */
309
/* Red is off, Green is on */
310
ii = originr;
311
buttons[ii].buttonX = XEDGE; buttons[ii].buttonY = 55;
312
buttons[ii].buttonWidth = 53; buttons[ii].buttonHeight = 25;
313
buttons[ii].buttonKey = ii;
314
buttons[ii].pot = no;
315
buttons[ii].mask = buttonMASK;
316
buttons[ii].text = "origin";
317
buttons[ii].textColor = onColor;
318
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
319
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
320
++num;
321
322
/* Rotate about the objects center of volume */
323
/* Red is off, Green is on */
324
ii = objectr;
325
buttons[ii].buttonX = 62; buttons[ii].buttonY = 55;
326
buttons[ii].buttonWidth = 53; buttons[ii].buttonHeight = 25;
327
buttons[ii].buttonKey = ii;
328
buttons[ii].pot = no;
329
buttons[ii].mask = buttonMASK;
330
buttons[ii].text = "object";
331
buttons[ii].textColor = offColor;
332
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
333
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
334
++num;
335
336
/* Scale potentiometer buttons */
337
338
/* Scale along X axis: Red is off, Green is on */
339
ii = zoomx;
340
buttons[ii].buttonX = 121; buttons[ii].buttonY = 55;
341
buttons[ii].buttonWidth = 17; buttons[ii].buttonHeight = 25;
342
buttons[ii].buttonKey = ii;
343
buttons[ii].pot = no;
344
buttons[ii].mask = buttonMASK;
345
buttons[ii].text = "x";
346
buttons[ii].textColor = onColor;
347
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
348
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
349
++num;
350
351
/* Scale along Y axis: Red is off, Green is on */
352
ii = zoomy;
353
buttons[ii].buttonX = 141; buttons[ii].buttonY = 55;
354
buttons[ii].buttonWidth = 17; buttons[ii].buttonHeight = 25;
355
buttons[ii].buttonKey = ii;
356
buttons[ii].pot = no;
357
buttons[ii].mask = buttonMASK;
358
buttons[ii].text = "y";
359
buttons[ii].textColor = onColor;
360
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
361
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
362
++num;
363
364
/* Zoom along Z axis: Red is off, Green is on */
365
ii = zoomz;
366
buttons[ii].buttonX = 161; buttons[ii].buttonY = 55;
367
buttons[ii].buttonWidth = 17; buttons[ii].buttonHeight = 25;
368
buttons[ii].buttonKey = ii;
369
buttons[ii].pot = no;
370
buttons[ii].mask = buttonMASK;
371
buttons[ii].text = "z";
372
buttons[ii].textColor = onColor;
373
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
374
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
375
++num;
376
377
/* Translate potentiometer buttons */
378
379
/* Indicates an orthographic projection of the xy-plane,
380
translation is in x and y coordinates */
381
ii = xy;
382
buttons[ii].buttonX = 185; buttons[ii].buttonY = 55;
383
buttons[ii].buttonWidth= 34; buttons[ii].buttonHeight = 25;
384
buttons[ii].buttonKey = ii;
385
buttons[ii].pot = no;
386
buttons[ii].mask = buttonMASK;
387
buttons[ii].text = "xy";
388
buttons[ii].textColor = 35;
389
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
390
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
391
++num;
392
393
/* Indicates an orthographic projection of the xz-plane,
394
translation is in x and z coordinates */
395
ii = xz;
396
buttons[ii].buttonX = 223; buttons[ii].buttonY = 55;
397
buttons[ii].buttonWidth= 34; buttons[ii].buttonHeight = 25;
398
buttons[ii].buttonKey = ii;
399
buttons[ii].pot = no;
400
buttons[ii].mask = buttonMASK;
401
buttons[ii].text = "xz";
402
buttons[ii].textColor = 35;
403
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
404
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
405
++num;
406
407
/* Indicates an orthographic projection of the yz-plane,
408
translation is in y and z coordinates */
409
ii = yz;
410
buttons[ii].buttonX = 261; buttons[ii].buttonY = 55;
411
buttons[ii].buttonWidth= 34; buttons[ii].buttonHeight = 25;
412
buttons[ii].buttonKey = ii;
413
buttons[ii].pot = no;
414
buttons[ii].mask = buttonMASK;
415
buttons[ii].text = "yz";
416
buttons[ii].textColor = 35;
417
buttons[ii].xHalf = buttons[ii].buttonWidth/2;
418
buttons[ii].yHalf = buttons[ii].buttonHeight/2;
419
++num;
420
421
return(num);
422
423
} /* initButtons() */
424
425
426