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