b311480e |
1 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
2 | // |
3 | // The content of this file is subject to the Open CASCADE Technology Public |
4 | // License Version 6.5 (the "License"). You may not use the content of this file |
5 | // except in compliance with the License. Please obtain a copy of the License |
6 | // at http://www.opencascade.org and read it completely before using this file. |
7 | // |
8 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
9 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
10 | // |
11 | // The Original Code and all software distributed under the License is |
12 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
13 | // Initial Developer hereby disclaims all such warranties, including without |
14 | // limitation, any warranties of merchantability, fitness for a particular |
15 | // purpose or non-infringement. Please see the License for the specific terms |
16 | // and conditions governing the rights and limitations under the License. |
17 | |
7fd59977 |
18 | #include <stdio.h> |
19 | #include <stddef.h> |
20 | #include <stdlib.h> |
21 | |
22 | #define ASFS 18 |
23 | |
24 | typedef short Logical; |
25 | typedef long Index; |
26 | typedef unsigned short Enum; |
27 | typedef short Code; |
28 | typedef long Prec; |
29 | typedef unsigned long Posint; |
30 | typedef float Ptype; |
31 | typedef double Mtype; |
32 | |
33 | /* Define anything that has not been explicitly set **************/ |
34 | |
35 | #ifndef SignChar |
36 | #define SignChar signed char |
37 | #endif |
38 | #ifndef Int16 |
39 | #define Int16 short |
40 | #endif |
41 | #ifndef Char |
42 | #define Char char |
43 | #endif |
44 | #ifndef Int |
45 | #define Int int |
46 | #endif |
47 | #ifndef Long |
48 | #define Long long |
49 | #endif |
50 | #ifndef Float |
51 | #define Float float |
52 | #endif |
53 | #ifndef Double |
54 | #define Double double |
55 | #endif |
56 | |
57 | /* Define real precision structure (character encoding) */ |
58 | |
59 | struct real_prec { |
60 | Prec prec, min, defexp, expald; |
61 | }; |
62 | |
63 | /* CGM element codes for clear text input and output */ |
64 | struct colour { |
65 | Index index; |
66 | Posint red, green, blue; |
67 | }; |
68 | typedef struct colour Colour; |
69 | struct vdc { |
70 | long intr; |
71 | float real; |
72 | }; |
73 | typedef struct vdc Vdc; |
74 | struct point { |
75 | struct vdc x, y; |
76 | }; |
77 | typedef struct point Cpoint; |
78 | |
79 | struct rect { |
80 | struct point a, b; |
81 | }; |
82 | |
83 | typedef struct { float left, right, top, bot; } Rect; |
84 | |
85 | struct colourentry { |
86 | float red, green, blue; |
87 | }; |
88 | typedef struct colourentry Colourentry; |
89 | |
90 | struct commands { |
91 | Code code; |
92 | const char *string; |
93 | }; |
94 | |
95 | /* Structures for metafile default elements */ |
96 | |
97 | /* Encoding Specific defaults */ |
98 | |
99 | struct char_defaults{ |
100 | Prec int_prec, index_prec, vdcint_prec; |
101 | struct real_prec real, vdc; |
102 | Prec col_prec, colind_prec; |
103 | struct colour min_rgb, max_rgb; |
104 | long ring_angres, ring_int, ring_real; |
105 | }; |
106 | |
107 | struct text_defaults{ |
108 | long min_int, max_int, min_index, max_index; |
109 | float min_real, max_real; |
110 | Prec real_digits; |
111 | struct vdc min_vdc, max_vdc; |
112 | Prec vdc_digits, colind_prec, col_prec; |
113 | struct colour min_rgb, max_rgb; |
114 | }; |
115 | |
116 | struct bin_defaults{ |
117 | Prec int_prec, index_prec, vdcint_prec; |
118 | Enum real_type, vdc_type; |
119 | Prec real_whole, real_fraction, vdc_whole, vdc_fraction; |
120 | Prec col_prec, colind_prec; |
121 | struct colour min_rgb, max_rgb; |
122 | }; |
123 | |
124 | struct defaults { |
125 | |
126 | /* Encoding independent defaults */ |
127 | |
128 | Index max_colind; |
129 | Enum vdc_type, transparency, clip_ind; |
130 | Enum color_mode, scale_mode; |
131 | float scale_factor; |
132 | Enum linewidth_mode, markersize_mode, edgewidth_mode; |
133 | struct colour back, aux; |
134 | struct rect vdc_extent, clip_rect; |
135 | |
136 | /* Retain encoding defaults for common access */ |
137 | |
138 | Prec int_bits, /* integer prec in bits */ |
139 | index_bits, /* index prec in bits */ |
140 | vdcint_bits, /* vdc integer precision in bits */ |
141 | real_bits, /* real prec in bits */ |
142 | real_places, /* binary bits after decimal place */ |
143 | vdc_bits, /* vdc prec in bits */ |
144 | vdc_places, /* binary bits after decimal place */ |
145 | col_bits, /* colour prec in bits */ |
146 | colind_bits; /* colour index prec in bits */ |
147 | float min_real, /* min real value */ |
148 | max_real, /* max real value */ |
149 | realmin, /* smallest real value */ |
150 | min_vdc, /* min real vdc value */ |
151 | max_vdc, /* max real vdc value */ |
152 | vdcmin; /* smallest vdc real value */ |
153 | Prec real_defexp, /* Real default exponent */ |
154 | real_expald, /* Real exponenet allowed */ |
155 | vdc_defexp, /* VDC default exponent */ |
156 | vdc_expald; /* VDC exponenet allowed */ |
157 | struct colour min_rgb, /* integer values: index/RGB */ |
158 | max_rgb; /* integer values: index/RGB */ |
159 | Logical colprec_flag, /* Flag to show if colour precision set */ |
160 | colval_flag; /* Flag to show if colour value extent set */ |
161 | }; |
162 | |
163 | /* Graphics attributes */ |
164 | |
165 | struct attributes { |
166 | Index line_ind, mark_ind, text_ind, fill_ind, edge_ind; |
167 | Index line_type, mark_type, text_font, edge_type; |
168 | struct vdc line_width, mark_size, edge_width; |
169 | struct colour line, marker, text, fill, edge; |
170 | Enum text_prec, text_path, text_halign, text_valign, edge_vis; |
171 | float text_hcont, text_vcont; |
172 | Index char_set, altchar_set; |
173 | float char_exp, char_space; |
174 | struct point char_up, char_base; |
175 | struct vdc char_height; |
176 | Enum int_style; |
177 | Index hatch_ind, pat_ind; |
178 | struct point fill_ref; |
179 | struct rect pat_size; |
180 | Enum asf[ASFS]; |
181 | /* Flags for VDC dependent defaults */ |
182 | Logical linewidth_flag, markersize_flag, edgewidth_flag, |
183 | charheight_flag, cliprect_flag; |
184 | }; |
185 | |
186 | |
187 | /* Structure for attribute change flags */ |
188 | |
189 | struct flags { |
190 | Logical line_index, line_type, line_width, line_color; |
191 | Logical mark_index, mark_type, mark_size, mark_color; |
192 | Logical text_index, text_font, text_prec, char_expan, char_space, |
193 | text_color, char_height, char_orient, char_set, |
194 | altchar_set, text_path, text_align; |
195 | Logical fill_index, int_style, hatch_ind, |
196 | pat_ind, pat_size, fill_color, fill_ref; |
197 | Logical edge_index, edge_type, edge_width, edge_color, edge_vis; |
198 | }; |
199 | |
200 | |
201 | |
202 | /* Non-Op */ |
203 | |
204 | #define NONOP (Code) 0 |
205 | |
206 | /* Character CGM hex values */ |
207 | |
208 | #define BEGMF (Code) 0x3020 |
209 | #define ENDMF (Code) 0x3021 |
210 | #define BEGPIC (Code) 0x3022 |
211 | #define BEGPICBODY (Code) 0x3023 |
212 | #define ENDPIC (Code) 0x3024 |
213 | |
214 | /* Metafile Descriptor elements */ |
215 | |
216 | #define MFVERSION (Code) 0x3120 |
217 | #define MFDESC (Code) 0x3121 |
218 | #define VDCTYPE (Code) 0x3122 |
219 | #define INTEGERPREC (Code) 0x3123 |
220 | #define REALPREC (Code) 0x3124 |
221 | #define INDEXPREC (Code) 0x3125 |
222 | #define COLRPREC (Code) 0x3126 |
223 | #define COLRINDEXPREC (Code) 0x3127 |
224 | #define MAXCOLRINDEX (Code) 0x3128 |
225 | #define COLRVALUEEXT (Code) 0x3129 |
226 | #define MFELEMLIST (Code) 0x312A |
227 | #define BEGMFDEFAULTS (Code) 0x312B |
228 | #define ENDMFDEFAULTS (Code) 0x312C |
229 | #define FONTLIST (Code) 0x312D |
230 | #define CHARSETLIST (Code) 0x312E |
231 | #define CHARCODING (Code) 0x312F |
232 | |
233 | /* Picture descriptor elements */ |
234 | |
235 | #define SCALEMODE (Code) 0x3220 |
236 | #define COLRMODE (Code) 0x3221 |
237 | #define LINEWIDTHMODE (Code) 0x3222 |
238 | #define MARKERSIZEMODE (Code) 0x3223 |
239 | #define EDGEWIDTHMODE (Code) 0x3224 |
240 | #define VDCEXT (Code) 0x3225 |
241 | #define BACKCOLR (Code) 0x3226 |
242 | |
243 | /* Control elements */ |
244 | |
245 | #define VDCINTEGERPREC (Code) 0x3320 |
246 | #define VDCREALPREC (Code) 0x3321 |
247 | #define AUXCOLR (Code) 0x3322 |
248 | #define TRANSPARENCY (Code) 0x3323 |
249 | #define CLIPRECT (Code) 0x3324 |
250 | #define CLIP (Code) 0x3325 |
251 | |
252 | /* Graphics primitives */ |
253 | |
254 | #define LINE (Code) 0x20 |
255 | #define DISJTLINE (Code) 0x21 |
256 | #define MARKER (Code) 0x22 |
257 | #define TEXT (Code) 0x23 |
258 | #define RESTRTEXT (Code) 0x24 |
259 | #define APNDTEXT (Code) 0x25 |
260 | #define POLYGON (Code) 0x26 |
261 | #define POLYGONSET (Code) 0x27 |
262 | #define CELLARRAY (Code) 0x28 |
263 | #define GDP (Code) 0x29 |
264 | #define RECT (Code) 0x2A |
265 | |
266 | #define CIRCLE (Code) 0x3420 |
267 | #define ARC3PT (Code) 0x3421 |
268 | #define ARC3PTCLOSE (Code) 0x3422 |
269 | #define ARCCTR (Code) 0x3423 |
270 | #define ARCCTRCLOSE (Code) 0x3424 |
271 | #define ELLIPSE (Code) 0x3425 |
272 | #define ELLIPARC (Code) 0x3426 |
273 | #define ELLIPARCCLOSE (Code) 0x3427 |
274 | |
275 | /* Attribute elements */ |
276 | |
277 | #define LINEINDEX (Code) 0x3520 |
278 | #define LINETYPE (Code) 0x3521 |
279 | #define LINEWIDTH (Code) 0x3522 |
280 | #define LINECOLR (Code) 0x3523 |
281 | #define MARKERINDEX (Code) 0x3524 |
282 | #define MARKERTYPE (Code) 0x3525 |
283 | #define MARKERSIZE (Code) 0x3526 |
284 | #define MARKERCOLR (Code) 0x3527 |
285 | |
286 | #define TEXTINDEX (Code) 0x3530 |
287 | #define TEXTFONTINDEX (Code) 0x3531 |
288 | #define TEXTPREC (Code) 0x3532 |
289 | #define CHAREXPAN (Code) 0x3533 |
290 | #define CHARSPACE (Code) 0x3534 |
291 | #define TEXTCOLR (Code) 0x3535 |
292 | #define CHARHEIGHT (Code) 0x3536 |
293 | #define CHARORI (Code) 0x3537 |
294 | #define TEXTPATH (Code) 0x3538 |
295 | #define TEXTALIGN (Code) 0x3539 |
296 | #define CHARSETINDEX (Code) 0x353A |
297 | #define ALTCHARSETINDEX (Code) 0x353B |
298 | |
299 | #define FILLINDEX (Code) 0x3620 |
300 | #define INTSTYLE (Code) 0x3621 |
301 | #define FILLCOLR (Code) 0x3622 |
302 | #define HATCHINDEX (Code) 0x3623 |
303 | #define PATINDEX (Code) 0x3624 |
304 | #define EDGEINDEX (Code) 0x3625 |
305 | #define EDGETYPE (Code) 0x3626 |
306 | #define EDGEWIDTH (Code) 0x3627 |
307 | #define EDGECOLR (Code) 0x3628 |
308 | #define EDGEVIS (Code) 0x3629 |
309 | #define FILLREFPT (Code) 0x362A |
310 | #define PATTABLE (Code) 0x362B |
311 | #define PATSIZE (Code) 0x362C |
312 | |
313 | #define COLRTABLE (Code) 0x3630 |
314 | #define ASF (Code) 0x3631 |
315 | |
316 | /* Escape Elements */ |
317 | |
318 | #define ESCAPE (Code) 0x3720 |
319 | #define MESSAGE (Code) 0x3721 |
320 | #define APPLDATA (Code) 0x3722 |
321 | |
322 | #define DOMAINRING (Code) 0x3730 |
323 | |
324 | /* Version 2 Elements - Addendum 1 */ |
325 | |
326 | #if CGMVERSION > 1 |
327 | |
328 | #define BEGSEG (Code) 0x3025 |
329 | #define ENDSEG (Code) 0x3026 |
330 | #define BEGFIG (Code) 0x3027 |
331 | #define ENDFIG (Code) 0x3028 |
332 | |
333 | #define NAMEPREC (Code) 0x3130 |
334 | #define MAXVDCEXT (Code) 0x3131 |
335 | #define SEGPRIEXT (Code) 0x3132 |
336 | |
337 | #define DEVVP (Code) 0x3227 |
338 | #define DEVVPMODE (Code) 0x3228 |
339 | #define DEVVPMAP (Code) 0x3229 |
340 | #define LINEREP (Code) 0x322A |
341 | #define MARKERREP (Code) 0x322B |
342 | #define TEXTREP (Code) 0x322C |
343 | #define FILLREP (Code) 0x322D |
344 | #define EDGEREP (Code) 0x322E |
345 | |
346 | #define LINECLIPMODE (Code) 0x3326 |
347 | |
348 | #define MARKERCLIPMODE (Code) 0x3327 |
349 | |
350 | #define EDGECLIPMODE (Code) 0x3328 |
351 | |
352 | #define NEWREGION (Code) 0x3329 |
353 | #define SAVEPRIMCONT (Code) 0x332A |
354 | |
355 | #define RESPRIMCONT (Code) 0x332B |
356 | |
357 | #define ARCCTRREV (Code) 0x3428 |
358 | #define CONNEDGE (Code) 0x3429 |
359 | |
360 | #define PICKID (Code) 0x3632 |
361 | |
362 | #define COPYSEG (Code) 0x3820 |
363 | #define INHFILTER (Code) 0x3821 |
364 | #define CLIPINH (Code) 0x3822 |
365 | #define SEGTRANS (Code) 0x3823 |
366 | #define SEGHIGHLIGHT (Code) 0x3824 |
367 | |
368 | #define SEGDISPPRI (Code) 0x3825 |
369 | #define SEGPICKPRI (Code) 0x3826 |
370 | |
371 | /* GKS Annex elements */ |
372 | |
373 | #define BEGGKSSESSIONMF (Code) 0x3029 |
374 | #define BEGGKSSESSION (Code) 0x302A |
375 | #define ENDGKSSESSION (Code) 0x302B |
376 | |
377 | #define WSVP (Code) 0x332C |
378 | #define CLEAR (Code) 0x332D |
379 | #define UPD (Code) 0x332E |
380 | #define DEFERST (Code) 0x332F |
381 | |
382 | #define DELSEG (Code) 0x3827 |
383 | #define RENAMESEG (Code) 0x3828 |
384 | #define REDRAWALLSEG (Code) 0x3829 |
385 | #define SEGVIS (Code) 0x382A |
386 | #define SEGDET (Code) 0x382B |
387 | |
388 | /* Version 3 Elements - Addendum 3 */ |
389 | |
390 | #if CGMVERSION > 2 |
391 | |
392 | #define BEGPROTREGION (Code) 0x302C |
393 | #define ENDPROTREGION (Code) 0x302D |
394 | #define BEGCOMPOLINE (Code) 0x302E |
395 | #define ENDCOMPOLINE (Code) 0x302F |
396 | #define BEGCOMPOTEXTPATH (Code) 0x3030 |
397 | #define ENDCOMPOTEXTPATH (Code) 0x3031 |
398 | #define BEGTILEARRAY (Code) 0x3032 |
399 | #define ENDTILEARRAY (Code) 0x3033 |
400 | |
401 | #define COLRMODEL (Code) 0x3133 |
402 | #define COLRCALIB (Code) 0x3134 |
403 | #define FONTPROP (Code) 0x3135 |
404 | #define GLYPHMAP (Code) 0x3136 |
405 | #define SYMBOLLIBLIST (Code) 0x3137 |
406 | |
407 | #define INTSTYLEMODE (Code) 0x322F |
408 | #define LINEEDGETYPEDEF (Code) 0x3230 |
409 | #define HATCHSTYLEDEF (Code) 0x3231 |
410 | #define GEOPATDEF (Code) 0x3232 |
411 | |
412 | #define PROTREGION (Code) 0x3330 |
413 | #define GENTEXTPATHMODE (Code) 0x3331 |
414 | #define MITRELLIMIT (Code) 0x3332 |
415 | #define TRANSPCELLCOLR (Code) 0x3333 |
416 | |
417 | #define HYPERBARC (Code) 0x342A |
418 | #define PARABARC (Code) 0x342B |
419 | #define NUB (Code) 0x342C |
420 | #define NURB (Code) 0x342D |
421 | #define POLYBEZIER (Code) 0x342E |
422 | #define SYMBOL (Code) 0x342F |
423 | #define INCRSYMBOL (Code) 0x342F |
424 | #define BITONALTILE (Code) 0x3430 |
425 | #define TILE (Code) 0x3431 |
426 | |
427 | #define LINECAP (Code) 0x3528 |
428 | #define LINEJOIN (Code) 0x3529 |
429 | #define LINETYPECONT (Code) 0x352A |
430 | #define LINETYPEINITOFFSET (Code) 0x352B |
431 | #define TEXTSCORETYPE (Code) 0x352C |
432 | #define RESTTEXTTYPE (Code) 0x352D |
433 | #define INTERPINT (Code) 0x352E |
434 | #define EDGECAP (Code) 0x352F |
435 | #define EDGEJOIN (Code) 0x362D |
436 | #define EDGETYPECONT (Code) 0x362E |
437 | #define EDGETYPEINITOFFSET (Code) 0x362F |
438 | #define SYMBOLLIBINDEX (Code) 0x3633 |
439 | #define SYMBOLCOLR (Code) 0x3634 |
440 | #define SYMBOLSIZE (Code) 0x3635 |
441 | #define SYMBOLORI (Code) 0x3636 |
442 | |
443 | #endif /* Version 3 */ |
444 | |
445 | #endif /* Version 2 */ |
446 | |
447 | |
448 | |
449 | |
450 | /* CGM Statelists */ |
451 | |
452 | #define MF_CLOSED (Enum) 0 |
453 | #define MF_DESC (Enum) 1 |
454 | #define MF_ELEMLIST (Enum) 2 |
455 | #define MF_DEFAULTS (Enum) 3 |
456 | #define PIC_DESC (Enum) 4 |
457 | #define PIC_OPEN (Enum) 5 |
458 | #define PIC_CLOSED (Enum) 6 |
459 | #define TEXT_OPEN (Enum) 7 |
460 | |
461 | /* CGM Enumerated types */ |
462 | |
463 | #define INTEGER (Enum) 0 |
464 | #define REAL (Enum) 1 |
465 | |
466 | #define ABSTRACT (Enum) 0 |
467 | #define METRIC (Enum) 1 |
468 | |
469 | #define INDEXED (Enum) 0 |
470 | #define DIRECT (Enum) 1 |
471 | |
472 | #define ABS (Enum) 0 |
473 | #define ABSOLUTE (Enum) 0 |
474 | #define SCALED (Enum) 1 |
475 | |
476 | #define INDIV (Enum) 0 |
477 | #define INDIVIDUAL (Enum) 0 |
478 | #define BUNDLED (Enum) 1 |
479 | |
480 | #define ALLOWED (Enum) 0 |
481 | #define FORBIDDEN (Enum) 1 |
482 | |
483 | #define OFF (Enum) 0 |
484 | #define ON (Enum) 1 |
485 | |
486 | #define NOACTION (Enum) 0 |
487 | #define ACTION (Enum) 1 |
488 | |
489 | /* Enumerated types for text precision */ |
490 | #define STRING (Enum) 0 |
491 | #define CHAR (Enum) 1 |
492 | #define STROKE (Enum) 2 |
493 | |
494 | /* Enumerated types for Text Path Values */ |
495 | #define P_RIGHT (Enum) 0 |
496 | #define P_LEFT (Enum) 1 |
497 | #define P_UP (Enum) 2 |
498 | #define UP (Enum) 2 |
499 | #define P_DOWN (Enum) 3 |
500 | #define DOWN (Enum) 3 |
501 | |
502 | /* Enumerated types for Text's Horziontal Alignment */ |
503 | #define NORMHORIZ (Enum) 0 |
504 | #define LEFT (Enum) 1 |
505 | #define CTR (Enum) 2 |
506 | #define RIGHT (Enum) 3 |
507 | #define CONTHORIZ (Enum) 4 |
508 | |
509 | /* Enumerated types for Text's Vertical Alignment */ |
510 | #define NORMVERT (Enum) 0 |
511 | #define TOP (Enum) 1 |
512 | #define CAP (Enum) 2 |
513 | #define HALF (Enum) 3 |
514 | #define BASE (Enum) 4 |
515 | #define BOTTOM (Enum) 5 |
516 | #define CONTVERT (Enum) 6 |
517 | |
518 | /* Final text flag */ |
519 | #define NOTFINAL (Enum) 0 |
520 | #define FINAL (Enum) 1 |
521 | |
522 | /* Interior styles */ |
523 | #define HOLLOW (Enum) 0 |
524 | #define SOLID (Enum) 1 |
525 | #define PAT (Enum) 2 |
526 | #define PATTERN (Enum) 2 |
527 | #define HATCH (Enum) 3 |
528 | #define EMPTY (Enum) 4 |
529 | |
530 | /* Closure types */ |
531 | #define PIE (Enum) 0 |
532 | #define CHORD (Enum) 1 |
533 | #define NOCLOSE (Enum) 2 |
534 | |
535 | /* Polygon set enumerated types */ |
536 | |
537 | #define EDGEVISIB (Enum) 1 |
538 | #define EDGECLOSE (Enum) 2 |
539 | |
540 | #define INVIS (Enum) 0 |
541 | #define VIS (Enum) 1 |
542 | #define CLOSEINVIS (EDGECLOSE + INVIS) |
543 | #define CLOSEVIS (EDGECLOSE + VIS) |
544 | |
545 | /* MF element list extra elements */ |
546 | #define DRAWINGSET (Enum) 0 |
547 | #define DRAWINGSETPLUS (Enum) 1 |
548 | #define VER2 (Enum) 2 |
549 | #define EXTPRIM (Enum) 3 |
550 | #define VER2GKSM (Enum) 4 |
551 | |
552 | |
553 | /* Character sets enumerated types */ |
554 | #define STD94 (Enum) 0 |
555 | #define STD96 (Enum) 1 |
556 | #define STD94MULTIBYTE (Enum) 2 |
557 | #define STD96MULTIBYTE (Enum) 3 |
558 | #define COMPLETECODE (Enum) 4 |
559 | |
560 | /* Character coding announcer enumerated types */ |
561 | #define BASIC7BIT (Enum) 0 |
562 | #define BASIC8BIT (Enum) 1 |
563 | #define EXTD7BIT (Enum) 2 |
564 | #define EXTD8BIT (Enum) 3 |
565 | |
566 | /* ASF settings */ |
567 | |
568 | #define ALL (Enum) 511 |
569 | #define ALLLINE (Enum) 510 |
570 | #define ALLMARKER (Enum) 509 |
571 | #define ALLTEXT (Enum) 508 |
572 | #define ALLFILL (Enum) 507 |
573 | #define ALLEDGE (Enum) 506 |
574 | |
575 | /* New Version 2 Enumerated types */ |
576 | |
577 | #define FRACTION (Enum) 0 |
578 | #define MM (Enum) 1 |
579 | #define PHYDEVUNITS (Enum) 2 |
580 | |
581 | #define FORCED (Enum) 0 |
582 | #define NOTFORCED (Enum) 2 |
583 | |
584 | #define LOCUS (Enum) 0 |
585 | #define SHAPE (Enum) 1 |
586 | #define LOCUSTHENSHAPE (Enum) 2 |
587 | |
588 | #define NO (Enum) 0 |
589 | #define YES (Enum) 1 |
590 | |
591 | #define STATELIST (Enum) 0 |
592 | #define SEGMENT (Enum) 1 |
593 | #define INTERSECTION (Enum) 1 |
594 | |
595 | #define NORMAL (Enum) 0 |
596 | #define HIGHLIGHT (Enum) 1 |
597 | |
598 | /* Element Group names in addition to normal elements */ |
599 | |
600 | #define LINEATTR (Enum) 35 |
601 | #define MARKERATTR (Enum) 36 |
602 | #define TEXTATTR (Enum) 37 |
603 | #define CHARATTR (Enum) 38 |
604 | #define FILLATTR (Enum) 39 |
605 | #define EDGEATTR (Enum) 40 |
606 | #define PATATTR (Enum) 41 |
607 | #define OUTPUTCTRL (Enum) 42 |
608 | #define ALLATTRCTRL (Enum) 44 |
609 | #define ALLINH (Enum) 45 |
610 | #define LINETYPEASF (Enum) 46 |
611 | #define LINEWIDTHASF (Enum) 47 |
612 | #define LINECOLRASF (Enum) 48 |
613 | #define MARKERTYPEASF (Enum) 49 |
614 | #define MARKERSIZEASF (Enum) 50 |
615 | #define MARKERCOLRASF (Enum) 51 |
616 | #define TEXTFONTINDEXASF (Enum) 52 |
617 | #define TEXTPRECASF (Enum) 53 |
618 | #define CHAREXPANASF (Enum) 54 |
619 | #define CHARSPACEASF (Enum) 55 |
620 | #define TEXTCOLRASF (Enum) 56 |
621 | #define INTSTYLEASF (Enum) 57 |
622 | #define FILLCOLRASF (Enum) 58 |
623 | #define HATCHINDEXASF (Enum) 59 |
624 | #define PATINDEXASF (Enum) 60 |
625 | #define EDGETYPEASF (Enum) 61 |
626 | #define EDGEWIDTHASF (Enum) 62 |
627 | #define EDGECOLRASF (Enum) 63 |
628 | |
629 | /* Useful local Parameters for enumerated types */ |
630 | |
631 | #define VDC (Enum) 0 |
632 | |
633 | #define MULTIPLE FALSE |
634 | #define SINGLE TRUE |
635 | |
636 | #define NOSET (Enum) 0 |
637 | #define SET (Enum) 1 |
638 | |
639 | #define NOP (Enum) 0 |
640 | #define NONE (Enum) 0 |
641 | #define ANY (Enum) 0 |
642 | |
643 | /* Mathematical quantities */ |
644 | |
645 | #ifndef ZERO |
646 | #define ZERO (Int) 0 |
647 | #endif |
648 | |
649 | #define LOG2 0.30103 |
650 | #define PARABIT 0x40 |
651 | |
7fd59977 |
652 | |
653 | /* All default values set within the control program */ |
654 | /* with Character encoding defaults */ |
655 | |
656 | |
657 | /* Initialise flags */ |
658 | |
659 | #ifndef AIX |
660 | #define FALSE (Enum) 0 |
661 | #define TRUE (Enum) 1 |
662 | #endif |
663 | /* |
664 | Enum cgmstate = MF_CLOSED; Initial CGM State |
665 | |
666 | Logical cgmterm = FALSE; Flag set for input from stdin |
667 | |
668 | Logical cgmEOF = FALSE; End of File flag is OFF |
669 | |
670 | Logical cgmfinished = FALSE ; Interpreter finished flag |
671 | |
672 | Default string start and terminator |
673 | |
674 | Code st_start = 0x1b58, st_term = 0x1b5c; |
675 | |
676 | |
677 | Arrays for coding and decoding Clear Text elements */ |
678 | |
679 | const struct commands cgmelement[] = { |
680 | |
681 | /* Graphics primitives */ |
682 | |
683 | {0x20, "LINE"}, {0x20, "INCRLINE"}, |
684 | {0x21, "DISJTLINE"}, {0x21, "INCRDISJTLINE"}, |
685 | {0x22, "MARKER"}, {0x22, "INCRMARKER"}, |
686 | {0x23, "TEXT"}, |
687 | {0x24, "RESTRTEXT"}, |
688 | {0x25, "APNDTEXT"}, |
689 | {0x26, "POLYGON"}, {0x26, "INCRPOLYGON"}, |
690 | {0x27, "POLYGONSET"}, {0x27, "INCRPOLYGONSET"}, |
691 | {0x28, "CELLARRAY"}, |
692 | {0x29, "GDP"}, |
693 | {0x2A, "RECT"}, |
694 | |
695 | {0x3420, "CIRCLE"}, |
696 | {0x3421, "ARC3PT"}, |
697 | {0x3422, "ARC3PTCLOSE"}, |
698 | {0x3423, "ARCCTR"}, |
699 | {0x3424, "ARCCTRCLOSE"}, |
700 | {0x3425, "ELLIPSE"}, |
701 | {0x3426, "ELLIPARC"}, |
702 | {0x3427, "ELLIPARCCLOSE"}, |
703 | |
704 | /* Attribute elements */ |
705 | |
706 | {0x3520, "LINEINDEX"}, |
707 | {0x3521, "LINETYPE"}, |
708 | {0x3522, "LINEWIDTH"}, |
709 | {0x3523, "LINECOLR"}, |
710 | {0x3524, "MARKERINDEX"}, |
711 | {0x3525, "MARKERTYPE"}, |
712 | {0x3526, "MARKERSIZE"}, |
713 | {0x3527, "MARKERCOLR"}, |
714 | |
715 | {0x3530, "TEXTINDEX"}, |
716 | {0x3531, "TEXTFONTINDEX"}, |
717 | {0x3532, "TEXTPREC"}, |
718 | {0x3533, "CHAREXPAN"}, |
719 | {0x3534, "CHARSPACE"}, |
720 | {0x3535, "TEXTCOLR"}, |
721 | {0x3536, "CHARHEIGHT"}, |
722 | {0x3537, "CHARORI"}, |
723 | {0x3538, "TEXTPATH"}, |
724 | {0x3539, "TEXTALIGN"}, |
725 | {0x353A, "CHARSETINDEX"}, |
726 | {0x353B, "ALTCHARSETINDEX"}, |
727 | |
728 | {0x3620, "FILLINDEX"}, |
729 | {0x3621, "INTSTYLE"}, |
730 | {0x3622, "FILLCOLR"}, |
731 | {0x3623, "HATCHINDEX"}, |
732 | {0x3624, "PATINDEX"}, |
733 | {0x3625, "EDGEINDEX"}, |
734 | {0x3626, "EDGETYPE"}, |
735 | {0x3627, "EDGEWIDTH"}, |
736 | {0x3628, "EDGECOLR"}, |
737 | {0x3629, "EDGEVIS"}, |
738 | |
739 | {0x362A, "FILLREFPT"}, |
740 | {0x362B, "PATTABLE"}, |
741 | {0x362C, "PATSIZE"}, |
742 | {0x3630, "COLRTABLE"}, |
743 | {0x3631, "ASF"}, |
744 | |
745 | /* Control elements */ |
746 | |
747 | {0x3320, "VDCINTEGERPREC"}, |
748 | {0x3321, "VDCREALPREC"}, |
749 | {0x3322, "AUXCOLR"}, |
750 | {0x3323, "TRANSPARENCY"}, |
751 | {0x3324, "CLIPRECT"}, |
752 | {0x3325, "CLIP"}, |
753 | |
754 | /* Metafile Control Elements */ |
755 | |
756 | {0x3020, "BEGMF"}, |
757 | {0x3021, "ENDMF"}, |
758 | {0x3022, "BEGPIC"}, |
759 | {0x3023, "BEGPICBODY"}, |
760 | {0x3024, "ENDPIC"}, |
761 | |
762 | /* Metafile Descriptor elements */ |
763 | |
764 | {0x3120, "MFVERSION"}, |
765 | {0x3121, "MFDESC"}, |
766 | {0x3122, "VDCTYPE"}, |
767 | {0x3123, "INTEGERPREC"}, |
768 | {0x3124, "REALPREC"}, |
769 | {0x3125, "INDEXPREC"}, |
770 | {0x3126, "COLRPREC"}, |
771 | {0x3127, "COLRINDEXPREC"}, |
772 | {0x3128, "MAXCOLRINDEX"}, |
773 | {0x3129, "COLRVALUEEXT"}, |
774 | {0x312A, "MFELEMLIST"}, |
775 | {0x312B, "BEGMFDEFAULTS"}, |
776 | {0x312C, "ENDMFDEFAULTS"}, |
777 | {0x312D, "FONTLIST"}, |
778 | {0x312E, "CHARSETLIST"}, |
779 | {0x312F, "CHARCODING"}, |
780 | |
781 | /* Picture descriptor elements */ |
782 | |
783 | {0x3220, "SCALEMODE"}, |
784 | {0x3221, "COLRMODE"}, |
785 | {0x3222, "LINEWIDTHMODE"}, |
786 | {0x3223, "MARKERSIZEMODE"}, |
787 | {0x3224, "EDGEWIDTHMODE"}, |
788 | {0x3225, "VDCEXT"}, |
789 | {0x3226, "BACKCOLR"}, |
790 | |
791 | /* Escape Elements */ |
792 | |
793 | {0x3720, "ESCAPE"}, |
794 | {0x3721, "MESSAGE"}, |
795 | {0x3722, "APPLDATA"}, |
796 | |
797 | /* Version 2 element names */ |
798 | |
799 | #if CGMVERSION > 1 |
800 | {0x3025, "BEGSEG"}, |
801 | {0x3026, "ENDSEG"}, |
802 | {0x3027, "BEGFIG"}, |
803 | {0x3028, "ENDFIG"}, |
804 | |
805 | {0x3029, "BEGGKSSESSIONMF"}, |
806 | {0x302A, "BEGGKSSESSION"}, |
807 | {0x302B, "ENDGKSSESSION"}, |
808 | |
809 | {0x3130, "NAMEPREC"}, |
810 | {0x3131, "MAXVDCEXT"}, |
811 | {0x3132, "SEGPRIEXT"}, |
812 | |
813 | {0x3227, "DEVVP"}, |
814 | {0x3228, "DEVVPMODE"}, |
815 | {0x3229, "DEVVPMAP"}, |
816 | {0x322A, "LINEREP"}, |
817 | {0x322B, "MARKERREP"}, |
818 | {0x322C, "TEXTREP"}, |
819 | {0x322D, "FILLREP"}, |
820 | {0x322E, "EDGEREP"}, |
821 | |
822 | {0x3326, "LINECLIPMODE"}, |
823 | {0x3327, "MARKERCLIPMODE"}, |
824 | {0x3328, "EDGECLIPMODE"}, |
825 | {0x3329, "NEWREGION"}, |
826 | {0x332A, "SAVEPRIMCONT"}, |
827 | {0x332B, "RESPRIMCONT"}, |
828 | |
829 | {0x332C, "WSVP"}, |
830 | {0x332D, "CLEAR"}, |
831 | {0x332E, "UPD"}, |
832 | {0x332F, "DEFERST"}, |
833 | |
834 | {0x3428, "ARCCTRREV"}, |
835 | {0x3429, "CONNEDGE"}, |
836 | |
837 | {0x3632, "PICKID"}, |
838 | |
839 | {0x3820, "COPYSEG"}, |
840 | {0x3821, "INHFILTER"}, |
841 | {0x3822, "CLIPINH"}, |
842 | {0x3823, "SEGTRANS"}, |
843 | {0x3824, "SEGHIGHLIGHT"}, |
844 | {0x3825, "SEGDISPPRI"}, |
845 | {0x3826, "SEGPICKPRI"}, |
846 | |
847 | {0x3827, "DELSEG"}, |
848 | {0x3828, "RENAMESEG"}, |
849 | {0x3829, "REDRAWALLSEG"}, |
850 | {0x382A, "SEGVIS"}, |
851 | {0x382B, "SEGDET"}, |
852 | |
853 | #if CGMVERSION > 2 |
854 | |
855 | {0x302C, "BEGPROTREGION"}, |
856 | {0x302D, "ENDPROTREGION"}, |
857 | {0x302E, "BEGCOMPOLINE"}, |
858 | {0x302F, "ENDCOMPOLINE"}, |
859 | {0x3030, "BEGCOMPOTEXTPATH"}, |
860 | {0x3031, "ENDCOMPOTEXTPATH"}, |
861 | {0x3032, "BEGTILEARRAY"}, |
862 | {0x3033, "ENDTILEARRAY"}, |
863 | |
864 | {0x3133, "COLRMODEL"}, |
865 | {0x3134, "COLRCALIB"}, |
866 | {0x3135, "FONTPROP"}, |
867 | {0x3136, "GLYPHMAP"}, |
868 | {0x3137, "SYMBOLLIBLIST"}, |
869 | |
870 | {0x322F, "INTSTYLEMODE"}, |
871 | {0x3230, "LINEEDGETYPEDEF"}, |
872 | {0x3231, "HATCHSTYLEDEF"}, |
873 | {0x3232, "GEOPATDEF"}, |
874 | |
875 | {0x3330, "PROTREGION"}, |
876 | {0x3331, "GENTEXTPATHMODE"}, |
877 | {0x3332, "MITRELLIMIT"}, |
878 | {0x3333, "TRANSPCELLCOLR"}, |
879 | |
880 | {0x342A, "HYPERBARC"}, |
881 | {0x342B, "PARABARC"}, |
882 | {0x342C, "NUB"}, |
883 | {0x342D, "NURB"}, |
884 | {0x342E, "POLYBEZIER"}, |
885 | {0x342F, "SYMBOL"}, {0x342F, "INCRSYMBOL"}, |
886 | {0x3430, "BITONALTILE"}, |
887 | {0x3431, "TILE"}, |
888 | |
889 | {0x3528, "LINECAP"}, |
890 | {0x3529, "LINEJOIN"}, |
891 | {0x352A, "LINETYPECONT"}, |
892 | {0x352B, "LINETYPEINITOFFSET"}, |
893 | {0x352C, "TEXTSCORETYPE"}, |
894 | {0x352D, "RESTTEXTTYPE"}, |
895 | {0x352E, "INTERPINT"}, |
896 | {0x352F, "EDGECAP"}, |
897 | {0x362D, "EDGEJOIN"}, |
898 | {0x362E, "EDGETYPECONT"}, |
899 | {0x362F, "EDGETYPEINITOFFSET"}, |
900 | {0x3633, "SYMBOLLIBINDEX"}, |
901 | {0x3634, "SYMBOLCOLR"}, |
902 | {0x3635, "SYMBOLSIZE"}, |
903 | {0x3636, "SYMBOLORI"}, |
904 | |
905 | #endif |
906 | #endif |
907 | |
908 | /* MFelemlist special names */ |
909 | |
910 | {0x10, "DRAWINGSET"}, |
911 | {0x11, "DRAWINGPLUS"}, |
912 | #if CGMVERSION > 1 |
913 | {0x12, "VERSION2"}, |
914 | {0x13, "EXTDPRIM"}, |
915 | {0x14, "VERSION2GKSM"}, |
916 | #if CGMVERSION > 2 |
917 | {0x15, "VERSION3"}, |
918 | #endif |
919 | #endif |
920 | {EOF, "EOF"} |
921 | }; |
922 | |
923 | extern "C" { |
924 | /* Metafile Default settings */ |
925 | extern struct char_defaults mfchar, mfichar, curichar, curchar, oldchar; |
926 | extern struct text_defaults mftext, mfitext, curitext, curtext; |
927 | extern struct bin_defaults mfbin, mfibin, curibin, curbin; |
928 | extern struct defaults mf, cur, old; |
929 | extern struct attributes mfatt, curatt, oldatt; |
930 | |
931 | /* Flags for changes to attributes - initially set to false */ |
932 | extern struct flags att; |
933 | |
934 | /* |
935 | FILE* OPEN_FILE(char*,int); |
936 | void CLOSE_FILE(); |
937 | */ |
938 | void CGMOtext(FILE*,Code, Long*,float*,char*); |
939 | void CGMObin (FILE*,Code, Long*,float*,char*); |
940 | void CGMOchar (FILE*,Code, Long*,float*,char*); |
941 | FILE* getfd(); |
942 | } |
943 | FILE* OPEN_FILE(char*,int); |
944 | void CLOSE_FILE(); |