gdevcgml.h 13 KB

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