1 /*
2 Copyright (C) 2011-2021, Dirk Krause
3 SPDX-License-Identifier: BSD-3-Clause
4 */
5 
6 /*
7 	WARNING: This file was generated by the dkct program (see
8 	http://dktools.sourceforge.net/ for details).
9 	Changes you make here will be lost if dkct is run again!
10 	You should modify the original source and run dkct on it.
11 	Original source: dk3fig.ctr
12 */
13 
14 /**	@file dk3fig.h Header file for the dk3fig module.
15 */
16 
17 #ifndef DK3FIG_H_INCLUDED
18 /** Avoid multiple inclusions. */
19 #define DK3FIG_H_INCLUDED 1
20 
21 
22 #include <libdk3c/dk3all.h>
23 #include <libdk3c/dk3bb.h>
24 
25 /**	Maximum input line size for Fig file.
26 	Although the Fig Format 3.2 specification does not set any limit for
27 	line sizes in Fig files we want to provide a buffer for input lines,
28 	so we must specify a buffer size.
29 */
30 #define	DK3_FIG_LINE_SIZE	1024
31 
32 
33 /**	Maximum difference to treat coordinates as equal.
34 */
35 #define	DK3_FIG_EPSILON		1.0e-6
36 
37 
38 
39 /**	@defgroup	dk3figoperations	Draw operations. */
40 /**@{*/
41 /**	Path operation: stroke.
42 */
43 #define	DK3_FIG_OP_STROKE	1
44 
45 /**	Path operation: fill.
46 */
47 #define	DK3_FIG_OP_FILL		2
48 
49 /**	Path operation: draw fill pattern.
50 */
51 #define	DK3_FIG_OP_PATTERN	4
52 
53 /**@}*/
54 
55 
56 
57 /**	@defgroup	dk3figcolors	Fig colors */
58 /**@{*/
59 /**	Use default color.
60 */
61 #define	DK3_FIG_COLOR_DEFAULT	(-1)
62 
63 /**	Black.
64 */
65 #define	DK3_FIG_COLOR_BLACK		0
66 
67 /**	Blue.
68 */
69 #define	DK3_FIG_COLOR_BLUE		1
70 
71 /**	Green.
72 */
73 #define	DK3_FIG_COLOR_GREEN		2
74 
75 /**	Cyan.
76 */
77 #define	DK3_FIG_COLOR_CYAN		3
78 
79 /**	Red.
80 */
81 #define	DK3_FIG_COLOR_RED		4
82 
83 /**	Magenta.
84 */
85 #define	DK3_FIG_COLOR_MAGENTA		5
86 
87 /**	Yellow.
88 */
89 #define	DK3_FIG_COLOR_YELLOW		6
90 
91 /**	White.
92 */
93 #define	DK3_FIG_COLOR_WHITE		7
94 
95 /**	Blue, 20 percent.
96 */
97 #define	DK3_FIG_COLOR_20_BLUE		8
98 
99 /**	Blue, 40 percent.
100 */
101 #define	DK3_FIG_COLOR_40_BLUE		9
102 
103 /**	Blue, 60 percent.
104 */
105 #define	DK3_FIG_COLOR_60_BLUE		10
106 
107 /**	Blue, 80 percent.
108 */
109 #define	DK3_FIG_COLOR_80_BLUE		11
110 
111 /**	Green, 25 percent.
112 */
113 #define	DK3_FIG_COLOR_25_GREEN		12
114 
115 /**	Green, 50 percent.
116 */
117 #define	DK3_FIG_COLOR_50_GREEN		13
118 
119 /**	Green, 75 percent.
120 */
121 #define	DK3_FIG_COLOR_75_GREEN		14
122 
123 /**	Cyan, 25 percent.
124 */
125 #define	DK3_FIG_COLOR_25_CYAN		15
126 
127 /**	Cyan, 50 percent.
128 */
129 #define	DK3_FIG_COLOR_50_CYAN		16
130 
131 /**	Cyan, 75 percent.
132 */
133 #define	DK3_FIG_COLOR_75_CYAN		17
134 
135 /**	Red, 25 percent.
136 */
137 #define	DK3_FIG_COLOR_25_RED		18
138 
139 /**	Red, 50 percent.
140 */
141 #define	DK3_FIG_COLOR_50_RED		19
142 
143 /**	Red, 75 percent.
144 */
145 #define	DK3_FIG_COLOR_75_RED		20
146 
147 /**	Magenta, 25 percent.
148 */
149 #define	DK3_FIG_COLOR_25_MAGENTA	21
150 
151 /**	Magenta, 50 percent.
152 */
153 #define	DK3_FIG_COLOR_50_MAGENTA	22
154 
155 /**	Magenta, 75 percent.
156 */
157 #define	DK3_FIG_COLOR_75_MAGENTA	23
158 
159 /**	Brown, 33 percent.
160 */
161 #define	DK3_FIG_COLOR_33_BROWN		24
162 
163 /**	Brown, 66 percent.
164 */
165 #define	DK3_FIG_COLOR_66_BROWN		25
166 
167 /**	Brown.
168 */
169 #define	DK3_FIG_COLOR_BROWN		26
170 
171 /**	Pink, 25 percent.
172 */
173 #define	DK3_FIG_COLOR_25_PINK		27
174 
175 /**	Pink, 50 percent.
176 */
177 #define	DK3_FIG_COLOR_50_PINK		28
178 
179 /**	Pink, 75 percent.
180 */
181 #define	DK3_FIG_COLOR_75_PINK		29
182 
183 /**	Pink.
184 */
185 #define	DK3_FIG_COLOR_PINK		30
186 
187 /**	Gold.
188 */
189 #define	DK3_FIG_COLOR_GOLD		31
190 
191 /**@}*/
192 
193 
194 
195 /**	@defgroup	dk3figobjtypes	Fig object types */
196 /**@{*/
197 /**	Color definition.
198 */
199 #define	DK3_FIG_OBJ_COLOR	0
200 
201 /**	Ellipse.
202 */
203 #define	DK3_FIG_OBJ_ELLIPSE	1
204 
205 /**	Polyline, polygon.
206 */
207 #define	DK3_FIG_OBJ_POLYLINE	2
208 
209 /**	Spline.
210 */
211 #define	DK3_FIG_OBJ_SPLINE	3
212 
213 /**	Text.
214 */
215 #define	DK3_FIG_OBJ_TEXT	4
216 
217 /**	Arc.
218 */
219 #define	DK3_FIG_OBJ_ARC		5
220 
221 /**	Compound object. Compound objects are resolved while reading
222 	the Fig file.
223 */
224 #define	DK3_FIG_OBJ_COMPOUND	6
225 
226 /**	End of compound object.
227 */
228 #define	DK3_FIG_OBJ_ENDCOMPOUND	(-6)
229 
230 /**	Not in Fig format definition, used for arrowheads
231 	6/0 and 6/1.
232 	Subtype 0: stroked only, 1: closed, filled.
233 	The cl attribute must be set correctly.
234 	This object type can not appear as primary object,
235 	only in arrowheads.
236 */
237 #define	DK3_FIG_OBJ_PSEUDO_HALF_CIRCLE	100
238 
239 /**	Not in Fig format definition, used for arrowheads.
240 	Subtype 0:	Open spline.
241 	Subtype	1:	Closed spline.
242 	The cl attribute must be set correctly.
243 	This object type can not appear as primary object,
244 	only in arrowheads.
245 */
246 #define	DK3_FIG_OBJ_PSEUDO_FAST_SPLINE	101
247 
248 /**@}*/
249 
250 
251 
252 /**	@defgroup	dk3figsubtypes	Fig object subtypes */
253 /**@{*/
254 
255 /**	Arc sub type: Open.
256 */
257 #define	DK3_FIG_OBJ_SUB_ARC_OPEN	1
258 
259 /**	Arc sub type: Closed.
260 */
261 #define	DK3_FIG_OBJ_SUB_ARC_CLOSED	2
262 
263 /**	Ellipse sub type: Defined by radii.
264 */
265 #define	DK3_FIG_OBJ_SUB_ELL_RADII	1
266 
267 /**	Ellipse sub type: Defined by diameters.
268 */
269 #define	DK3_FIG_OBJ_SUB_ELL_DIAMETERS	2
270 
271 /**	Ellipse sub type: Circle defined by radius.
272 */
273 #define	DK3_FIG_OBJ_SUB_CIR_RADIUS	3
274 
275 /**	Ellipse sub type: Circle defined by diameter.
276 */
277 #define	DK3_FIG_OBJ_SUB_CIR_DIAMETER	4
278 
279 /**	Polyline sub type: Polyline.
280 */
281 #define	DK3_FIG_OBJ_SUB_POLYLINE	1
282 
283 /**	Polyline sub type: Box.
284 */
285 #define	DK3_FIG_OBJ_SUB_BOX		2
286 
287 /**	Polyline sub type: Polygon.
288 */
289 #define	DK3_FIG_OBJ_SUB_POLYGON		3
290 
291 /**	Polyline sub type: Arc-box.
292 */
293 #define	DK3_FIG_OBJ_SUB_ARCBOX		4
294 
295 /**	Polyline sub type: Embedded image.
296 */
297 #define	DK3_FIG_OBJ_SUB_IMAGE		5
298 
299 /**	Spline sub type: Open approximated spline.
300 */
301 #define	DK3_FIG_OBJ_SUB_OPEN_APPRO	0
302 
303 /**	Spline sub type: Closed approximated spline.
304 */
305 #define DK3_FIG_OBJ_SUB_CLOSED_APPRO	1
306 
307 /**	Spline sub type: Open interpolated spline.
308 */
309 #define DK3_FIG_OBJ_SUB_OPEN_INT	2
310 
311 /**	Spline sub type: Closed interpolated spline.
312 */
313 #define DK3_FIG_OBJ_SUB_CLOSED_INT	3
314 
315 /**	Spline sub type: Open X-spline.
316 */
317 #define DK3_FIG_OBJ_SUB_OPEN_X		4
318 
319 /**	Spline sub type: Closed X-spline.
320 */
321 #define DK3_FIG_OBJ_SUB_CLOSED_X	5
322 
323 /**@}*/
324 
325 
326 /**	@defgroup	dk3figlinestyles	Fig line styles */
327 /**@{*/
328 
329 /**	Default line style.
330 */
331 #define	DK3_FIG_LS_DEFAULT		(-1)
332 
333 /**	Solid line.
334 */
335 #define	DK3_FIG_LS_SOLID		0
336 
337 /**	Dashed line.
338 */
339 #define	DK3_FIG_LS_DASHED		1
340 
341 /**	Dotted line.
342 */
343 #define	DK3_FIG_LS_DOTTED		2
344 
345 /**	Dash dot line.
346 */
347 #define	DK3_FIG_LS_DASH_DOTTED		3
348 
349 /**	Dash dot dot line.
350 */
351 #define	DK3_FIG_LS_DASH_DOUBLE_DOTTED	4
352 
353 /**	Dash dot dot dot line.
354 */
355 #define	DK3_FIG_LS_DASH_TRIPLE_DOTTED	5
356 
357 /**@}*/
358 
359 
360 
361 /**	@defgroup	dk3figlinejoin	Line join style */
362 /**@{*/
363 
364 /**	Mitered line join.
365 */
366 #define	DK3_FIG_LJ_MITER		0
367 
368 /**	Rounded line join.
369 */
370 #define	DK3_FIG_LJ_ROUND		1
371 
372 /**	Beveled line join.
373 */
374 #define	DK3_FIG_LJ_BEVEL		2
375 
376 /**@}*/
377 
378 
379 
380 /**	@defgroup	dk3figlinecap	Fig line cap style */
381 /**@{*/
382 
383 /**	Butted line cap.
384 */
385 #define	DK3_FIG_LC_BUTT			0
386 
387 /**	Rounded line cap.
388 */
389 #define	DK3_FIG_LC_ROUND		1
390 
391 /**	Projecting line cap.
392 */
393 #define	DK3_FIG_LC_PROJECTING		2
394 
395 /**@}*/
396 
397 
398 
399 /**	@defgroup	dk3figarrowstyles	Fig arrow styles */
400 /**@{*/
401 
402 /**	Polyline arrow head.
403 */
404 #define	DK3_FIG_AS_STICK			0
405 
406 /**	Polygon arrow head.
407 */
408 #define	DK3_FIG_AS_CLOSED			1
409 
410 /**	Arrow with indented butt.
411 */
412 #define	DK3_FIG_AS_INDENTED			2
413 
414 /**	Arrow with pointed butt.
415 */
416 #define	DK3_FIG_AS_POINTED			3
417 
418 /**	Arrow with rhombus.
419 */
420 #define	DK3_FIG_AS_RHOMBUS			4
421 
422 /**	Line end with circle.
423 */
424 #define DK3_FIG_AS_FULL_CIRCLE_END		5
425 
426 /**	Line end with half circle.
427 */
428 #define DK3_FIG_AS_HALF_CIRCLE_END		6
429 
430 /**	Line end with rectangle.
431 */
432 #define DK3_FIG_AS_RECTANGLE			7
433 
434 /**	Arrow inverted arrowhead.
435 */
436 #define DK3_FIG_AS_INVERSE			8
437 
438 /**	Arrow only one side filled.
439 */
440 #define DK3_FIG_AS_INDENTED_FILLED_HALF		9
441 
442 /**	Arrow only one side drawn (and filled).
443 */
444 #define DK3_FIG_AS_CLOSED_HALF			10
445 
446 /**	Arrow indented, only one side drawn (and filled).
447 */
448 #define DK3_FIG_AS_INDENTED_HALF		11
449 
450 /**	Arrow butted, only one side drawn (and filled).
451 */
452 #define DK3_FIG_AS_BUTTED_HALF			12
453 
454 /**	Line end with triangle fork or overstroke.
455 */
456 #define DK3_FIG_AS_TRIANGLE_FORK		13
457 
458 /**	Line end with forward or backward rectangle fork.
459 */
460 #define DK3_FIG_AS_RECTANGLE_FORK		14
461 
462 /**@}*/
463 
464 
465 
466 /**	@defgroup	dk3figarrowfill	Fig arrow head fill style */
467 /**@{*/
468 
469 /**	Hollow arrow head (white filled).
470 */
471 #define	DK3_FIG_AF_HOLLOW		0
472 
473 /**	Filled arrow head.
474 */
475 #define	DK3_FIG_AF_FILLED		1
476 
477 /**@}*/
478 
479 
480 /**	@defgroup dk3figfonts	Fig fonts */
481 /**@{*/
482 
483 /**	LaTeX font: Default font.
484 */
485 #define	DK3_FIG_FONT_LATEX_DEFAULT				0
486 
487 /**	LaTeX font: Roman font.
488 */
489 #define	DK3_FIG_FONT_LATEX_ROMAN				1
490 
491 /**	LaTeX font: Bold font (roman).
492 */
493 #define DK3_FIG_FONT_LATEX_BOLD					2
494 
495 /**	LaTeX font: Italic font (roman).
496 */
497 #define DK3_FIG_FONT_LATEX_ITALIC				3
498 
499 /**	LaTeX font: Sans-serif.
500 */
501 #define DK3_FIG_FONT_LATEX_SANS_SERIF				4
502 
503 /**	LaTeX font: Typewriter.
504 */
505 #define DK3_FIG_FONT_LATEX_TYPEWRITER				5
506 
507 /**@}*/
508 
509 
510 
511 /**	@defgroup	dk3figfontflags	Fig font flags */
512 /**@{*/
513 
514 /**	Rigid text (not scaled when scaling a compound).
515 */
516 #define	DK3_FIG_FONT_FLAG_RIGID			1
517 
518 /**	LaTeX special text.
519 */
520 #define DK3_FIG_FONT_FLAG_SPECIAL		2
521 
522 /**	PS font in use (LaTeX font otherwise).
523 */
524 #define DK3_FIG_FONT_FLAG_PS			4
525 
526 /**	Hidden text.
527 */
528 #define DK3_FIG_FONT_FLAG_HIDDEN		8
529 
530 /**@}*/
531 
532 
533 
534 /**	@defgroup	figsrctypes	Fig source types */
535 /**@{*/
536 
537 /**	Creator software unknown.
538 */
539 #define	DK3_FIG_SRCTYPE_UNKNOWN		(-1)
540 
541 /**	Fig created by XFig.
542 */
543 #define	DK3_FIG_SRCTYPE_XFIG		0
544 
545 /**	File created by jFig.
546 */
547 #define	DK3_FIG_SRCTYPE_JFIG		1
548 
549 /**	File created by WinFIG.
550 */
551 #define	DK3_FIG_SRCTYPE_WINFIG		2
552 
553 /**@}*/
554 
555 
556 
557 /**	@defgroup	figreaderstates	Fig reader states */
558 /**@{*/
559 
560 /**	Error occured.
561 */
562 #define	DK3_FIG_RD_STATE_ERROR			(-1)
563 
564 /**	Expecting file type line.
565 */
566 #define	DK3_FIG_RD_STATE_START			0
567 
568 /**	Waiting for line containing orientation.
569 */
570 #define	DK3_FIG_RD_STATE_EXPECT_ORIENTATION	1
571 
572 /**	Waiting for line containing justification.
573 */
574 #define	DK3_FIG_RD_STATE_EXPECT_JUSTIFICATION	2
575 
576 /**	Waiting for line containing units.
577 */
578 #define DK3_FIG_RD_STATE_EXPECT_UNITS		3
579 
580 /**	Waiting for line containing paper size.
581 */
582 #define DK3_FIG_RD_STATE_EXPECT_PAPERSIZE	4
583 
584 /**	Waiting for line containing magnification.
585 */
586 #define DK3_FIG_RD_STATE_EXPECT_MAGNIFICATION	5
587 
588 /**	Waiting for line containing multiplage or singlepage.
589 */
590 #define DK3_FIG_RD_STATE_EXPECT_MULTIPAGE	6
591 
592 /**	Waiting for line containing transparent color number.
593 */
594 #define DK3_FIG_RD_STATE_EXPECT_TRANSPARENT	7
595 
596 /**	Waiting for line containing resolution and coordinate system.
597 */
598 #define DK3_FIG_RD_STATE_EXPECT_RESOLUTION	8
599 
600 /**	Ready to start a new object.
601 */
602 #define	DK3_FIG_RD_STATE_READY			9
603 
604 /**	Expecting arc arrowhead forward.
605 */
606 #define DK3_FIG_RD_STATE_ARC_ARROW_FORWARD	10
607 
608 /**	Expecting arc arrowhead backward.
609 */
610 #define DK3_FIG_RD_STATE_ARC_ARROW_BACKWARD	11
611 
612 /**	Expecting polyline arrowhead forward.
613 */
614 #define DK3_FIG_RD_STATE_PL_ARROW_FORWARD	12
615 
616 /**	Expecting polyline arrowhead backward.
617 */
618 #define DK3_FIG_RD_STATE_PL_ARROW_BACKWARD	13
619 
620 /**	Expecting polyline image file name.
621 */
622 #define DK3_FIG_RD_STATE_PL_IMAGE		14
623 
624 /**	Expecting polyline point coordinates.
625 */
626 #define DK3_FIG_RD_STATE_PL_POINTS		15
627 
628 /**	Expecting spline arrowhead forward.
629 */
630 #define DK3_FIG_RD_STATE_SP_ARROW_FORWARD	16
631 
632 /**	Expecting spline arrowhead backward.
633 */
634 #define DK3_FIG_RD_STATE_SP_ARROW_BACKWARD	17
635 
636 /**	Expecting spline point coordinates.
637 */
638 #define DK3_FIG_RD_STATE_SP_POINTS		18
639 
640 /**	Expecting spline control values.
641 */
642 #define DK3_FIG_RD_STATE_SP_CONTROL		19
643 
644 /**@}*/
645 
646 
647 /**	Fig polygon or polyline point.
648 */
649 typedef struct {
650   double		x;	/**< X coordinate. */
651   double		y;	/**< Y coordinate. */
652 } dk3_fig_poly_point_t;
653 
654 
655 
656 /**	Fig X-spline point.
657 */
658 typedef struct {
659   double		x;	/**< X coordinate. */
660   double		y;	/**< Y coordinate. */
661   double		s;	/**< Shape factor. */
662 } dk3_fig_spline_point_t;
663 
664 
665 
666 /**	One X-spline segment.
667 */
668 typedef struct {
669   dk3_fig_spline_point_t	a;	/**< Left neighbour control point. */
670   dk3_fig_spline_point_t	b;	/**< Left endpoing of segment. */
671   dk3_fig_spline_point_t	c;	/**< Right endpoint of segment. */
672   dk3_fig_spline_point_t	d;	/**< Right neighbour control point. */
673   double			pa;	/**< Function parameter for A fct. */
674   double			pb;	/**< Function parameter for B fct. */
675   double			pc;	/**< Function parameter for C fct. */
676   double			pd;	/**< Function parameter for D fct. */
677   double			qa;	/**< Function parameter for A fct. */
678   double			qb;	/**< Function parameter for B fct. */
679   double			qc;	/**< Function parameter for C fct. */
680   double			qd;	/**< Function parameter for D fct. */
681   double			duadt;	/**< Window fct A du/dt. */
682   double			dubdt;	/**< Window fct B du/dt. */
683   double			ducdt;	/**< Window fct C du/dt. */
684   double			duddt;	/**< Window fct D du/dt. */
685   double			x;	/**< X result. */
686   double			y;	/**< Y result. */
687   double			dxdt;	/**< dx/dt result. */
688   double			dydt;	/**< dy/dt result. */
689   int				cb;	/**< Compatibility bug flag. */
690   int				ha;	/**< Flag: Have point A. */
691   int				hd;	/**< Flag: Have point D. */
692 } dk3_xspline_segment_t;
693 
694 
695 
696 /**	Fig arc details.
697 */
698 typedef struct {
699   double		xc;	/**< X center. */
700   double		yc;	/**< Y center. */
701   double		ra;	/**< Radius. */
702   double		x1;	/**< First x. */
703   double		y1;	/**< First y. */
704   double		x2;	/**< Second x. */
705   double		y2;	/**< Second y. */
706   double		x3;	/**< Third x. */
707   double		y3;	/**< Third y. */
708   double		as;	/**< Start alpha (if arrowhead back). */
709   double		ae;	/**< End alpha (if arrowhead forward). */
710   unsigned char		di;	/**< Direction: 0x00=clockwise, 0x01=counter. */
711 } dk3_fig_det_arc_t;
712 
713 
714 
715 /**	Fig ellipse details.
716 */
717 typedef struct {
718   double		 an;	/**< Angle (rotation) in radians. */
719   double		 cx;	/**< Center x position. */
720   double		 cy;	/**< Center y position. */
721   double		 rx;	/**< Radius x. */
722   double		 ry;	/**< Radius y. */
723 } dk3_fig_det_ell_t;
724 
725 
726 
727 /**	Fig polygon/polyline details.
728 */
729 typedef struct {
730   char const		*fn;	/**< File name for embedded image. */
731   dk3_fig_poly_point_t	*po;	/**< Point data. */
732   double		 ra;	/**< Radius for arc boxes. */
733 #if 1
734   double		 xs;	/**< Start x (if arrowhead back). */
735   double		 ys;	/**< Start y (if arrowhead back). */
736   double		 xe;	/**< End x (if arrowhead forward). */
737   double		 ye;	/**< End y (if arrowhead forward). */
738 #endif
739   size_t		 np;	/**< Number of points. */
740   int			 flf;	/**< Flip flag. */
741 } dk3_fig_det_pol_t;
742 
743 
744 
745 /**	Fig spline details.
746 */
747 typedef struct {
748   dk3_fig_spline_point_t	*po;	/**< Point data. */
749   double			*fslc;	/**< Full segment length cache. */
750   double			 ts;	/**< Start t (if arrowhead back). */
751   double			 te;	/**< End t (if arrowhead forward). */
752   size_t			 np;	/**< Number of points. */
753 } dk3_fig_det_spl_t;
754 
755 
756 
757 /**	Fig text details.
758 */
759 typedef struct {
760   char	const		*st;	/**< String. */
761   double		 x;	/**< X position. */
762   double		 y;	/**< Y position. */
763   double		 an;	/**< Rotation in radians. */
764   double		 fs;	/**< Font size. */
765   double		 he;	/**< Height. */
766   double		 wi;	/**< Width. */
767   int			 fo;	/**< Font, see @ref dk3figfonts. */
768   int			 ff;	/**< Font flags, see @ref dk3figfontflags. */
769 } dk3_fig_det_txt_t;
770 
771 
772 
773 /**	Half-circle, used for arrowheads.
774 */
775 typedef struct {
776   double		cx;	/**< Center point x. */
777   double		cy;	/**< Center point y. */
778   double		ra;	/**< Radius. */
779   double		an;	/**< Angle in radians, Fig space. */
780 } dk3_fig_det_hci_t;
781 
782 
783 
784 /**	Fig object details.
785 */
786 typedef union {
787   dk3_fig_det_arc_t	arc;	/**< Arc details. */
788   dk3_fig_det_ell_t	ell;	/**< Ellipse details. */
789   dk3_fig_det_pol_t	pol;	/**< Polygon or polyline details. */
790   dk3_fig_det_spl_t	spl;	/**< Spline details. */
791   dk3_fig_det_txt_t	txt;	/**< Text details. */
792   dk3_fig_det_hci_t	hci;	/**< Half-circle for arrowhead. */
793 } dk3_fig_obj_det_t;
794 
795 
796 
797 /**	Fig arrow head.
798 */
799 typedef struct {
800   void			*o1;	/**< Object 1 for arrowhead. */
801   void			*o2;	/**< Object 2 for arrowhead. */
802   double		 wi;	/**< Width. */
803   double		 he;	/**< Height. */
804   int			 as;	/**< Style, see @ref dk3figarrowstyles. */
805   int			 af;	/**< Fill style, see @ref dk3figarrowfill. */
806 } dk3_fig_ah_t;
807 
808 
809 
810 /**	Fig object.
811 */
812 typedef struct {
813   dk3_fig_obj_det_t	 dt;	/**< Object details, type-specific. */
814   dk3_fig_ah_t		*af;	/**< Arrow details forward. */
815   dk3_fig_ah_t		*ab;	/**< Arrow details backward. */
816   void			*dsd;	/**< Driver specific details. */
817   double		 sv;	/**< Style value (1/80) inch. */
818   unsigned long		 li;	/**< Line number of object definition. */
819   int			 la;	/**< Layer number. */
820   int			 ot;	/**< Object type, see @ref dk3figobjtypes. */
821   int			 st;	/**< Object subtype, see @ref dk3figsubtypes. */
822   int			 lw;	/**< Line width (1/80 inch). */
823   int			 pc;	/**< Pen+text color, see @ref dk3figcolors. */
824   int			 fc;	/**< Fill color, see @ref dk3figcolors. */
825   int			 fi;	/**< Area fill type. */
826   int			 cs;	/**< Cap style, see @ref dk3figlinecap. */
827   int			 js;	/**< Join style, see @ref dk3figlinejoin. */
828   int			 ls;	/**< Line style, see @ref dk3figlinestyles. */
829   unsigned char		 cl;	/**< Flag: Closed object. */
830 } dk3_fig_obj_t;
831 
832 
833 
834 /**	Fig color.
835 */
836 typedef struct {
837   int			 i;	/**< Color number. */
838   int			 r;	/**< Red component. */
839   int			 g;	/**< Green component. */
840   int			 b;	/**< Blue component. */
841 } dk3_fig_color_t;
842 
843 
844 
845 /**	Fig drawing.
846 */
847 typedef struct {
848   dk3_bb_t		 bb;		/**< Bounding box in Fig units. */
849   dkChar const * const	*msg;		/**< Localized Fig messages. */
850   dk3_app_t		*app;		/**< Application structure. */
851   dk3_sto_t		*sobj;		/**< Storage for objects. */
852   dk3_sto_it_t		*iobj;		/**< Iterator for objects storage. */
853   dk3_sto_t		*scol;		/**< Storage for colors. */
854   dk3_sto_it_t		*icol;		/**< Iterator for colors storage. */
855   dk3_fig_obj_t		*cobj;		/**< Current object. */
856   void			*dsd;		/**< Driver specific details. */
857   double		 res;		/**< Resolution. */
858   double		 arcspp;	/**< Spline points per arc. */
859   double		 splspp;	/**< Spline points per interval. */
860   double		 xsprec;	/**< Precision for iterations. */
861   double		 lwbp;		/**< Base line width in bp. */
862   unsigned long		 lineno;	/**< Line number. */
863   long			 lres;		/**< Resolution as integer value. */
864   size_t		 cind;		/**< Current point index. */
865   size_t		 xssbs;		/**< X-spline segements Bezier segs. */
866   size_t		 qbs;		/**< Quadrant Bezier segments. */
867   size_t		 minspp;	/**< Minimum spline points for arc. */
868   size_t		 codi;		/**< Color digits. */
869   int			 cxy;		/**< Flag: Read x (0) or y (1). */
870   int			 ec;		/**< Error code. */
871   int			 state;		/**< Reader state. */
872   int			 transcol;	/**< Transparent color. */
873   int			 srctype;	/**< Source type. */
874   int			 coah;		/**< Flag: Compatible arrowheads. */
875   int			 xsah;		/**< Flag: X-spline arrowheads. */
876   int			 cosp;		/**< Flag: Compatible splines. */
877   int			 cofop;		/**< Flag: Compat filled open paths. */
878   int			 bbts;		/**< Flag: Use text size for bb. */
879   int			 ahbs;		/**< Flag: Bisection for spline arrow */
880 } dk3_fig_drawing_t;
881 
882 
883 
884 /**	Fig document consisting of multiple pages.
885 */
886 typedef struct {
887   dk3_sto_t		*sdrw;	/**< Storage for Fig drawings. */
888   dk3_sto_it_t		*idrw;	/**< Iterator through drawing storage. */
889 } dk3_fig_writer_t;
890 
891 
892 
893 /**	Graphics state.
894 */
895 typedef struct {
896   dk3_rgb_color_t	c1;	/**< Current color or stroke color. */
897   dk3_rgb_color_t	c2;	/**< Non-stroking color if applicable. */
898   double		lw;	/**< Line width. */
899   double		sv;	/**< Style value. */
900   double		slw;	/**< Dash line width. */
901   double		fs;	/**< Font size. */
902   int			lc;	/**< Line cap, see @ref dk3figlinecap. */
903   int			lj;	/**< Line join, see @ref dk3figlinejoin. */
904   int			ls;	/**< Line style, see @ref dk3figlinestyles. */
905   int			fn;	/**< PS font number. */
906   int			hc1;	/**< Flag: c1 is set. */
907   int			hc2;	/**< Flag: c2 is set. */
908   int			hlc;	/**< Flag: lc is set. */
909   int			hlj;	/**< Flag: lj is set. */
910   int			hlw;	/**< Flag: lw is set. */
911   int			hls;	/**< Flag: ls is set. */
912   int			hfn;	/**< Flag: fn and fs set. */
913 } dk3_graphics_state_t;
914 
915 
916 
917 /**	Font as specified in the Fig file.
918 */
919 typedef struct {
920   int			psfont;	/**< Flag: PS font (1) or LaTeX font (0). */
921   int			fontno;	/**< Font number. */
922   double		fontsz;	/**< Font size. */
923 } dk3_fig_font_t;
924 
925 #ifdef __cplusplus
926 extern "C" {
927 #endif
928 
929 
930 
931 /*
932 	dk3fig module
933 	=============
934 */
935 
936 /**	Get localized message texts.
937 	@param	app	Application structure.
938 	@return	Pointer to localized message texts on success, NULL on error.
939 */
940 dkChar const * const *
941 dk3fig_get_localized_messages(dk3_app_t *app);
942 
943 /**	Create a new drawing structure.
944 	@param	app	Application structure, must not be NULL.
945 	@param	msg	Localized messages texts from dk3fig module.
946 	@return	Pointer to new structure on success, NULL on error.
947 */
948 dk3_fig_drawing_t *
949 dk3fig_drawing_new(dk3_app_t *app, dkChar const * const	*msg);
950 
951 /**	Set detail options for drawing.
952 	@param	drw	Drawing to set up.
953 	@param	xssbs	Number of Bezier segments for each X-spline segment.
954 	@param	qbs	Number of Bezier segments for a 90 degree arc.
955 */
956 void
957 dk3fig_set_options_bsegs(dk3_fig_drawing_t *drw, size_t xssbs, size_t qbs);
958 
959 /**	Set base line width in bp.
960 	@param	drw	Drawing to set up.
961 	@param	val	New value.
962 */
963 void
964 dk3fig_set_options_lwbp(dk3_fig_drawing_t *drw, double val);
965 
966 /**	Set flag for compatible arrowheads.
967 	@param	drw	Drawing to set up.
968 	@param	val	Flag value.
969 */
970 void
971 dk3fig_set_options_coah(dk3_fig_drawing_t *drw, int val);
972 
973 /**	Set flag for X-spline arrowheads (only used, when compatible
974 	arrowheads not used).
975 	@param	drw	Drawing to set up.
976 	@param	val	Flag value.
977 */
978 void
979 dk3fig_set_options_xsah(dk3_fig_drawing_t *drw, int val);
980 
981 /**	Set flag for compatible splines (reproduce XFig/fig2dev interpolated
982 	spline bug).
983 	@param	drw	Drawing to set up.
984 	@param	val	Flag value.
985 */
986 void
987 dk3fig_set_options_cosp(dk3_fig_drawing_t *drw, int val);
988 
989 /**	Set flag for bounding box with text sizes.
990 	@param	drw	Drawing to set up.
991 	@param	val	Flag value.
992 */
993 void
994 dk3fig_set_options_bbts(dk3_fig_drawing_t *drw, int val);
995 
996 /**	Set flag for compatible filled open paths.
997 	@param	drw	Drawing to set up.
998 	@param	val	Flag value.
999 */
1000 void
1001 dk3fig_set_options_cofop(dk3_fig_drawing_t *drw, int val);
1002 
1003 /**	Set flag for bisection iteration on arrowheads.
1004 	@param	drw	Drawing to set up.
1005 	@param	val	Flag value.
1006 */
1007 void
1008 dk3fig_set_options_ah_bisection(dk3_fig_drawing_t *drw, int val);
1009 
1010 /**	Set source type.
1011 	@param	drw	Drawing to set up.
1012 	@param	val	New source type value.
1013 */
1014 void
1015 dk3fig_set_options_srctype(dk3_fig_drawing_t *drw, int val);
1016 
1017 /**	Destroy drawing structure, release memory.
1018 	@param	drw	Structure to destroy.
1019 */
1020 void
1021 dk3fig_drawing_delete(dk3_fig_drawing_t *drw);
1022 
1023 /**	Destroy Fig object, release memory.
1024 	@param	obj	Object to destroy.
1025 */
1026 void
1027 dk3fig_obj_delete(dk3_fig_obj_t *obj);
1028 
1029 /**	Create new Fig object.
1030 	@param	li	Line number of object definition.
1031 	@param	la	Layer number.
1032 	@param	ot	Object type.
1033 	@param	st	Object subtype.
1034 	@param	lw	Line width.
1035 	@param	pc	Pen color.
1036 	@param	fc	Fill color.
1037 	@param	fi	Fill type.
1038 	@param	cs	Cap style.
1039 	@param	js	Join style.
1040 	@param	ls	Line style.
1041 	@param	sv	Style value.
1042 	@param	af	Flag: Arrowhead forward.
1043 	@param	ab	Flag: Arrowhead backward.
1044 	@param	np	Number of spline/polyline points.
1045 	@param	txt	Text string (for text objects).
1046 	@param	app	Application structure for diagnostics, may be NULL.
1047 	@return	Pointer to new object on success, NULL on error.
1048 */
1049 dk3_fig_obj_t *
1050 dk3fig_obj_new(
1051   unsigned long	 li,
1052   int		 la,
1053   int		 ot,
1054   int		 st,
1055   int		 lw,
1056   int		 pc,
1057   int		 fc,
1058   int		 fi,
1059   int		 cs,
1060   int		 js,
1061   int		 ls,
1062   double	 sv,
1063   int		 af,
1064   int		 ab,
1065   size_t	 np,
1066   char const	*txt,
1067   dk3_app_t	*app
1068 );
1069 
1070 /**	Initialize Fig object.
1071 	@param	obj	Object to initialize.
1072 */
1073 void
1074 dk3fig_obj_init(dk3_fig_obj_t *obj);
1075 
1076 /**	Initialize graphics state data.
1077 	@param	gs	Graphics state structure to initialize.
1078 */
1079 void
1080 dk3fig_gs_init(dk3_graphics_state_t *gs);
1081 
1082 /**	Set arrowhead spline options.
1083 	@param	drw	Drawing to set up.
1084 	@param	arcspp	Number of X-spline segments per 90 degree arc.
1085 	@param	splspp	Number of X-spline segments per X-spline interval.
1086 	@param	minspp	Minimum number of X-spline intervals for arrowhead edge.
1087 */
1088 void
1089 dk3fig_set_options_arrows(
1090   dk3_fig_drawing_t	*drw,
1091   double		 arcspp,
1092   double		 splspp,
1093   size_t		 minspp
1094 );
1095 
1096 /**	Set precision for X-splines iterations.
1097 	@param	drw	Drawing to set up.
1098 	@param	prec	Precision.
1099 */
1100 void
1101 dk3fig_set_options_iteration_precision(
1102   dk3_fig_drawing_t	*drw,
1103   double		 prec
1104 );
1105 
1106 /**	Set number of digits for colors.
1107 	@param	drw	Drawing to set up.
1108 	@param	codi	Number of color digits.
1109 */
1110 void
1111 dk3fig_set_options_codi(
1112   dk3_fig_drawing_t	*drw,
1113   size_t		 codi
1114 );
1115 
1116 /**	Set error code for drawing.
1117 	The new error code is set only if the current error code
1118 	of the drawing is 0 (indicates "no error found").
1119 	@param	drw	Drawing to set.
1120 	@param	ec	Error code to set.
1121 */
1122 void
1123 dk3fig_set_ec(dk3_fig_drawing_t *drw, int ec);
1124 
1125 #ifdef __cplusplus
1126 }
1127 #endif
1128 
1129 
1130 #endif
1131