1 /* Copyright (C) 1995, 1996 Aladdin Enterprises. All rights reserved. 2 3 This software is provided AS-IS with no warranty, either express or 4 implied. 5 6 This software is distributed under license and may not be copied, 7 modified or distributed except as expressly authorized under the terms 8 of the license contained in the file LICENSE in this distribution. 9 10 For more information about licensing, please refer to 11 http://www.ghostscript.com/licensing/. For information on 12 commercial licensing, go to http://www.artifex.com/licensing/ or 13 contact Artifex Software, Inc., 101 Lucas Valley Road #110, 14 San Rafael, CA 94903, U.S.A., +1(415)492-9861. 15 */ 16 17 /* $Id: gdevcgml.h,v 1.5 2002/06/16 07:25:26 lpd Exp $ */ 18 /* Interface definitions for CGM-writing library */ 19 20 #ifndef gdevcgml_INCLUDED 21 # define gdevcgml_INCLUDED 22 23 /* The names in the following follow the CGM standard exactly, */ 24 /* except that we have substituted the American spellings of */ 25 /* color (colour) and center (centre). */ 26 27 /* ================ Types ================ */ 28 29 /* Define the abstract type for the CGM writer state. */ 30 typedef struct cgm_state_s cgm_state; 31 32 /* Define the type for the allocator used by the CGM writer. */ 33 typedef struct cgm_allocator_s { 34 void *private_data; 35 void *(*alloc) (void *, uint); 36 void (*free) (void *, void *); 37 } cgm_allocator; 38 39 /* Define types for CGM coordinates. */ 40 typedef int cgm_int; 41 typedef double cgm_real; 42 typedef union cgm_vdc_s { 43 cgm_int integer; 44 cgm_real real; 45 } cgm_vdc; 46 typedef struct cgm_int_point_s { 47 cgm_int x, y; 48 } cgm_int_point; 49 typedef struct cgm_real_point_s { 50 cgm_real x, y; 51 } cgm_real_point; 52 typedef union cgm_point_s { 53 cgm_int_point integer; 54 cgm_real_point real; 55 } cgm_point; 56 57 /* Define types for colors. */ 58 typedef struct cgm_rgb_s { 59 cgm_int r, g, b; 60 } cgm_rgb; 61 typedef union cgm_color_s { 62 cgm_int index; 63 cgm_rgb rgb; 64 } cgm_color; 65 66 /* 67 * Define other types used in CGM elements or API calls. 68 * If cgm_xxx is an enumerated type, let xxx' be xxx with any of the 69 * following words dropped: mode, specification, type; then the values 70 * of the enumerated type are named cgm_xxx'_yyy. 71 */ 72 typedef enum { 73 cgm_vdc_integer = 0, 74 cgm_vdc_real 75 } cgm_vdc_type; 76 typedef struct cgm_string_s { 77 const char *chars; 78 uint length; 79 } cgm_string; 80 typedef enum { 81 cgm_scaling_abstract = 0, 82 cgm_scaling_metric 83 } cgm_scaling_mode; 84 typedef enum { 85 cgm_color_selection_indexed = 0, 86 cgm_color_selection_direct 87 } cgm_color_selection_mode; 88 typedef enum { 89 cgm_line_marker_absolute = 0, 90 cgm_line_marker_scaled 91 } cgm_line_marker_specification_mode; 92 typedef cgm_line_marker_specification_mode 93 cgm_line_width_specification_mode, cgm_marker_size_specification_mode, 94 cgm_edge_width_specification_mode; 95 typedef union cgm_line_marker_extent_s { 96 cgm_vdc absolute; 97 cgm_real scaled; 98 } cgm_line_marker_extent; 99 typedef cgm_line_marker_extent 100 cgm_line_width, cgm_marker_size, cgm_edge_width; 101 typedef enum { 102 cgm_transparency_off = 0, 103 cgm_transparency_on 104 } cgm_transparency; 105 typedef enum { 106 cgm_clip_off = 0, 107 cgm_clip_on 108 } cgm_clip_indicator; 109 typedef struct cgm_precision_s { 110 enum { 111 cgm_representation_floating, cgm_representation_fixed 112 } representation; 113 int exponent_or_whole_width; 114 int fraction_width; 115 } cgm_precision; 116 typedef enum { 117 cgm_line_solid = 1, 118 cgm_line_dash, 119 cgm_line_dot, 120 cgm_line_dash_dot, 121 cgm_line_dash_dot_dot 122 } cgm_line_type; 123 typedef enum { 124 cgm_marker_dot = 1, 125 cgm_marker_plus, 126 cgm_marker_asterisk, 127 cgm_marker_circle, 128 cgm_marker_cross 129 } cgm_marker_type; 130 typedef enum { 131 cgm_text_precision_string = 0, 132 cgm_text_precision_character, 133 cgm_text_precision_stroke 134 } cgm_text_precision; 135 typedef enum { 136 cgm_text_path_right = 0, 137 cgm_text_path_left, 138 cgm_text_path_up, 139 cgm_text_path_down 140 } cgm_text_path; 141 typedef enum { 142 cgm_text_horizontal_normal = 0, 143 cgm_text_horizontal_left, 144 cgm_text_horizontal_center, 145 cgm_text_horizontal_right, 146 cgm_text_horizontal_continuous 147 } cgm_text_alignment_horizontal; 148 typedef enum { 149 cgm_text_vertical_normal = 0, 150 cgm_text_vertical_top, 151 cgm_text_vertical_cap, 152 cgm_text_vertical_half, 153 cgm_text_vertical_base, 154 cgm_text_vertical_bottom, 155 cgm_text_vertical_continuous 156 } cgm_text_alignment_vertical; 157 typedef enum { 158 cgm_interior_style_hollow = 0, 159 cgm_interior_style_solid, 160 cgm_interior_style_pattern, 161 cgm_interior_style_hatch, 162 cgm_interior_style_empty 163 } cgm_interior_style; 164 typedef enum { 165 cgm_hatch_horizontal = 1, 166 cgm_hatch_vertical, 167 cgm_hatch_positive_slope, 168 cgm_hatch_negative_slope, 169 cgm_hatch_combined_v_h_slant, 170 cgm_hatch_combined_l_r_slant 171 } cgm_hatch_index; 172 typedef enum { 173 cgm_arc_closure_pie = 0, 174 cgm_arc_closure_chord 175 } cgm_arc_closure; 176 typedef enum { 177 cgm_edge_out_invisible = 0, 178 cgm_edge_out_visible, 179 cgm_edge_out_close_invisible, 180 cgm_edge_out_close_visible 181 } cgm_edge_out; 182 typedef struct cgm_polygon_edge_s { 183 cgm_point vertex; 184 cgm_edge_out edge_out; 185 } cgm_polygon_edge; 186 typedef enum { 187 cgm_cell_mode_run_length = 0, 188 cgm_cell_mode_packed 189 } cgm_cell_representation_mode; 190 typedef enum { 191 cgm_edge_solid = 1, 192 cgm_edge_dash, 193 cgm_edge_dot, 194 cgm_edge_dash_dot, 195 cgm_edge_dash_dot_dot 196 } cgm_edge_type; 197 typedef enum { 198 cgm_aspect_source_individual = 0, 199 cgm_aspect_source_bundled 200 } cgm_aspect_source; 201 typedef enum { 202 cgm_aspect_line_type = 0, 203 cgm_aspect_line_width, 204 cgm_aspect_line_color, 205 cgm_aspect_marker_type, 206 cgm_aspect_marker_size, 207 cgm_aspect_marker_color, 208 cgm_aspect_text_font_index, 209 cgm_aspect_text_precision, 210 cgm_aspect_character_expansion_factor, 211 cgm_aspect_character_spacing, 212 cgm_aspect_text_color, 213 cgm_aspect_interior_style, 214 cgm_aspect_fill_color, 215 cgm_aspect_hatch_index, 216 cgm_aspect_pattern_index, 217 cgm_aspect_edge_type, 218 cgm_aspect_edge_width, 219 cgm_aspect_edge_color 220 } cgm_aspect_type; 221 typedef struct cgm_aspect_source_flag_s { 222 cgm_aspect_type type; 223 cgm_aspect_source source; 224 } cgm_aspect_source_flag; 225 226 /* ================ API ================ */ 227 228 typedef enum { 229 cgm_result_ok = 0, 230 cgm_result_wrong_state = -1, 231 cgm_result_out_of_range = -2, 232 cgm_result_io_error = -3, 233 cgm_result_out_of_memory = -4 234 } cgm_result; 235 236 /* ---------------- Initialize/terminate ---------------- */ 237 238 cgm_state *cgm_initialize(FILE *, const cgm_allocator *); 239 cgm_result cgm_terminate(cgm_state *); 240 241 /* ---------------- Metafile elements ---------------- */ 242 243 typedef struct cgm_metafile_elements_s { 244 cgm_int metafile_version; 245 cgm_string metafile_description; 246 cgm_vdc_type vdc_type; 247 int integer_precision; 248 cgm_precision real_precision; 249 int index_precision; 250 int color_precision; 251 int color_index_precision; 252 cgm_int maximum_color_index; 253 cgm_color color_value_extent[2]; 254 const int *metafile_element_list; 255 int metafile_element_list_count; 256 const cgm_string *font_list; 257 int font_list_count; 258 /* character_set_list */ 259 /* character_coding_announcer */ 260 } cgm_metafile_elements; 261 262 #define cgm_set_METAFILE_VERSION (1L<<0) 263 #define cgm_set_METAFILE_DESCRIPTION (1L<<1) 264 #define cgm_set_VDC_TYPE (1L<<2) 265 #define cgm_set_INTEGER_PRECISION (1L<<3) 266 #define cgm_set_REAL_PRECISION (1L<<4) 267 #define cgm_set_INDEX_PRECISION (1L<<5) 268 #define cgm_set_COLOR_PRECISION (1L<<6) 269 #define cgm_set_COLOR_INDEX_PRECISION (1L<<7) 270 #define cgm_set_MAXIMUM_COLOR_INDEX (1L<<8) 271 #define cgm_set_COLOR_VALUE_EXTENT (1L<<9) 272 #define cgm_set_METAFILE_ELEMENT_LIST (1L<<10) 273 #define cgm_set_FONT_LIST (1L<<11) 274 #define cgm_set_CHARACTER_SET_LIST (1L<<12) 275 #define cgm_set_CHARACTER_CODING_ANNOUNCER (1L<<13) 276 277 cgm_result 278 cgm_BEGIN_METAFILE(cgm_state *, const char *, uint), 279 cgm_set_metafile_elements(cgm_state *, 280 const cgm_metafile_elements *, long), 281 cgm_END_METAFILE(cgm_state *); 282 283 /* ---------------- Picture elements ---------------- */ 284 285 typedef struct cgm_picture_elements_s { 286 cgm_scaling_mode scaling_mode; 287 cgm_real scale_factor; 288 cgm_color_selection_mode color_selection_mode; 289 cgm_line_width_specification_mode line_width_specification_mode; 290 cgm_marker_size_specification_mode marker_size_specification_mode; 291 cgm_edge_width_specification_mode edge_width_specification_mode; 292 cgm_point vdc_extent[2]; 293 cgm_color background_color; 294 } cgm_picture_elements; 295 296 #define cgm_set_SCALING_MODE (1L<<0) 297 #define cgm_set_COLOR_SELECTION_MODE (1L<<1) 298 #define cgm_set_LINE_WIDTH_SPECIFICATION_MODE (1L<<2) 299 #define cgm_set_MARKER_SIZE_SPECIFICATION_MODE (1L<<3) 300 #define cgm_set_EDGE_WIDTH_SPECIFICATION_MODE (1L<<4) 301 #define cgm_set_VDC_EXTENT (1L<<5) 302 #define cgm_set_BACKGROUND_COLOR (1L<<6) 303 304 cgm_result 305 cgm_BEGIN_PICTURE(cgm_state *, const char *, uint), 306 cgm_set_picture_elements(cgm_state *, 307 const cgm_picture_elements *, long), 308 cgm_BEGIN_PICTURE_BODY(cgm_state *), 309 cgm_END_PICTURE(cgm_state *); 310 311 /* ---------------- Control elements ---------------- */ 312 313 cgm_result 314 cgm_VDC_INTEGER_PRECISION(cgm_state *, int), 315 cgm_VDC_REAL_PRECISION(cgm_state *, const cgm_precision *), 316 cgm_AUXILIARY_COLOR(cgm_state *, const cgm_color *), 317 cgm_TRANSPARENCY(cgm_state *, cgm_transparency), 318 cgm_CLIP_RECTANGLE(cgm_state *, const cgm_point[2]), 319 cgm_CLIP_INDICATOR(cgm_state *, cgm_clip_indicator); 320 321 /* ---------------- Graphical primitive elements ---------------- */ 322 323 cgm_result 324 cgm_POLYLINE(cgm_state *, const cgm_point *, int), 325 cgm_DISJOINT_POLYLINE(cgm_state *, const cgm_point *, int), 326 cgm_POLYMARKER(cgm_state *, const cgm_point *, int), 327 cgm_TEXT(cgm_state *, const cgm_point *, bool, const char *, uint), 328 cgm_RESTRICTED_TEXT(cgm_state *, const cgm_vdc *, const cgm_vdc *, 329 const cgm_point *, bool, const char *, uint), 330 cgm_APPEND_TEXT(cgm_state *, bool, const char *, uint), 331 cgm_POLYGON(cgm_state *, const cgm_point *, int), 332 cgm_POLYGON_SET(cgm_state *, const cgm_polygon_edge *, int), 333 cgm_CELL_ARRAY(cgm_state *, const cgm_point * /*[3] */ , cgm_int, 334 cgm_int, cgm_int, cgm_cell_representation_mode, 335 const byte *, uint, uint), 336 cgm_RECTANGLE(cgm_state *, const cgm_point *, const cgm_point *), 337 cgm_CIRCLE(cgm_state *, const cgm_point *, const cgm_vdc *), 338 cgm_CIRCULAR_ARC_3_POINT(cgm_state *, const cgm_point *, 339 const cgm_point *, const cgm_point *), 340 cgm_CIRCULAR_ARC_3_POINT_CLOSE(cgm_state *, const cgm_point *, 341 const cgm_point *, 342 const cgm_point *, cgm_arc_closure), 343 cgm_CIRCULAR_ARC_CENTER(cgm_state *, const cgm_point *, 344 const cgm_vdc *, const cgm_vdc *, 345 const cgm_vdc *, const cgm_vdc *, 346 const cgm_vdc *), 347 cgm_CIRCULAR_ARC_CENTER_CLOSE(cgm_state *, const cgm_point *, 348 const cgm_vdc *, const cgm_vdc *, 349 const cgm_vdc *, const cgm_vdc *, 350 const cgm_vdc *, cgm_arc_closure), 351 cgm_ELLIPSE(cgm_state *, const cgm_point *, const cgm_point *, 352 const cgm_point *), 353 cgm_ELLIPTICAL_ARC(cgm_state *, const cgm_point *, 354 const cgm_point *, const cgm_point *, 355 const cgm_vdc *, const cgm_vdc *, 356 const cgm_vdc *, const cgm_vdc *), 357 cgm_ELLIPTICAL_ARC_CLOSE(cgm_state *, const cgm_point *, 358 const cgm_point *, const cgm_point *, 359 const cgm_vdc *, const cgm_vdc *, 360 const cgm_vdc *, const cgm_vdc *, 361 cgm_arc_closure); 362 363 /* ---------------- Attribute elements ---------------- */ 364 365 cgm_result 366 cgm_LINE_BUNDLE_INDEX(cgm_state *, cgm_int), 367 cgm_LINE_TYPE(cgm_state *, cgm_line_type), 368 cgm_LINE_WIDTH(cgm_state *, const cgm_line_width *), 369 cgm_LINE_COLOR(cgm_state *, const cgm_color *), 370 cgm_MARKER_BUNDLE_INDEX(cgm_state *, cgm_int), 371 cgm_MARKER_TYPE(cgm_state *, cgm_marker_type), 372 cgm_MARKER_SIZE(cgm_state *, const cgm_marker_size *), 373 cgm_MARKER_COLOR(cgm_state *, const cgm_color *), 374 cgm_TEXT_BUNDLE_INDEX(cgm_state *, cgm_int), 375 cgm_TEXT_FONT_INDEX(cgm_state *, cgm_int), 376 cgm_TEXT_PRECISION(cgm_state *, cgm_text_precision), 377 cgm_CHARACTER_EXPANSION_FACTOR(cgm_state *, cgm_real), 378 cgm_CHARACTER_SPACING(cgm_state *, cgm_real), 379 cgm_TEXT_COLOR(cgm_state *, const cgm_color *), 380 cgm_CHARACTER_HEIGHT(cgm_state *, const cgm_vdc *), 381 cgm_CHARACTER_ORIENTATION(cgm_state *, const cgm_vdc *, 382 const cgm_vdc *, const cgm_vdc *, 383 const cgm_vdc *), 384 cgm_TEXT_PATH(cgm_state *, cgm_text_path), 385 cgm_TEXT_ALIGNMENT(cgm_state *, cgm_text_alignment_horizontal, 386 cgm_text_alignment_vertical, cgm_real, cgm_real), 387 cgm_CHARACTER_SET_INDEX(cgm_state *, cgm_int), 388 /* The following should be cgm_ALTERNATE_..., but the VAX DEC C */ 389 /* compiler gives an error for names longer than 31 characters. */ 390 cgm_ALT_CHARACTER_SET_INDEX(cgm_state *, cgm_int), 391 cgm_FILL_BUNDLE_INDEX(cgm_state *, cgm_int), 392 cgm_INTERIOR_STYLE(cgm_state *, cgm_interior_style), 393 cgm_FILL_COLOR(cgm_state *, const cgm_color *), 394 cgm_HATCH_INDEX(cgm_state *, cgm_hatch_index), 395 cgm_PATTERN_INDEX(cgm_state *, cgm_int), 396 cgm_EDGE_BUNDLE_INDEX(cgm_state *, cgm_int), 397 cgm_EDGE_TYPE(cgm_state *, cgm_edge_type), 398 cgm_EDGE_WIDTH(cgm_state *, const cgm_edge_width *), 399 cgm_EDGE_COLOR(cgm_state *, const cgm_color *), 400 cgm_EDGE_VISIBILITY(cgm_state *, bool), 401 cgm_FILL_REFERENCE_POINT(cgm_state *, const cgm_point *), 402 /* PATTERN_TABLE */ 403 cgm_PATTERN_SIZE(cgm_state *, const cgm_vdc *, const cgm_vdc *, 404 const cgm_vdc *, const cgm_vdc *), 405 cgm_COLOR_TABLE(cgm_state *, cgm_int, const cgm_color *, int), 406 cgm_ASPECT_SOURCE_FLAGS(cgm_state *, const cgm_aspect_source_flag *, int); 407 408 #endif /* gdevcgml_INCLUDED */ 409