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