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
|
/*
Copyright (C) 2018-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: wxdtypes.ctr
*/
#ifndef WXDTYPES_H_INCLUDED
/** Avoid multiple inclusions. */
#define WXDTYPES_H_INCLUDED 1
#line 8 "wxdtypes.ctr"
/** @file wxdtypes.h Data types for the wxd2lat program.
The wxd_... types correspond to the Wxd_... type in the
../wxdkdraw/drawtypes.h file.
Here we use char for UTF-8 encoded strings, in the
../wxdkdraw/drawtypes.h file we use wxChar for strings
shown in the GUI.
Although coordinates are defined as int in the file format
we use double here to avoid extra memory allocations for
coordinate values in bp and to avoid lots of (double) casts
in calculations.
*/
#ifndef DK4STO_H_INCLUDED
#include "dk4sto.h"
#endif
/** Arrowhead data.
Type, length and width are obtained from file.
Offset, cut and cut tolerance are calculated by the program.
For polyline and arc the minimal cut is used, calculation is
straightforward. The calculation on splines is iterative, so we
accept a tolerance.
*/
typedef struct {
double offset; /**< Offset arrow end point to draw point in bp. */
double cut; /**< Amount to cut the line in bp. */
double cuttol; /**< Cutting tolerance in bp. */
uint8_t type; /**< Arrowead type. */
uint8_t length; /**< Arrowhead length. */
uint8_t width; /**< Arrowhead width. */
} wxd_arrow_t;
#if 0
/** Polygon or polyline point.
*/
typedef struct {
double x; /**< X position. */
double y; /**< Y position. */
} wxd_point_t;
#else
/** Polygon or polyline point.
*/
typedef dk4_gra_point_t wxd_point_t;
#endif
/** X-Spline point.
*/
typedef struct {
double x; /**< X position. */
double y; /**< Y position. */
double s; /**< S parameter. */
} wxd_spline_point_t;
/** Details for a text.
*/
typedef struct {
char *t; /**< Text to export, UTF-8 encoded. */
char *tsc; /**< Text to show on screen, UTF-8 encoded. */
double x; /**< X position. */
double y; /**< Y position. */
double a; /**< Rotation counterclockwise in degree. */
uint16_t fsz; /**< Font size. */
uint8_t find; /**< Font index. */
uint8_t al; /**< Horizontal align. */
uint8_t fl; /**< Text flags. */
} wxd_det_text_t;
/** Polygon and polyline details.
*/
typedef struct {
wxd_point_t *p; /**< Points. */
uint16_t n; /**< Number of points. */
} wxd_det_pl_t;
/** X-Spline details (opened and closed).
The sl and suml components are only used for open splines
with at least one arrowhead.
*/
typedef struct {
wxd_spline_point_t *p; /**< Points. */
double *sl; /**< Segment lengths. */
double ts; /**< Parameter t to start drawing. */
double te; /**< Parameter t to end drawing. */
double suml; /**< Summary of segment lengths. */
uint16_t n; /**< Number of points. */
} wxd_det_xs_t;
/** Details for arcs (opened and closed).
*/
typedef struct {
double a; /**< Start angle alpha counterclockwise in radians. */
double b; /**< End angle beta counterclockwise in radians. */
double x; /**< X position of center point. */
double y; /**< Y position of center point. */
double r; /**< Radius. */
int32_t x1; /**< X position point 1 in wxdkdraw units. */
int32_t y1; /**< Y position point 1 in wxdkdraw units. */
int32_t x2; /**< X position point 2 in wxdkdraw units. */
int32_t y2; /**< Y position point 2 in wxdkdraw units. */
int32_t x3; /**< X position point 3 in wxdkdraw units. */
int32_t y3; /**< Y position point 3 in wxdkdraw units. */
int8_t d; /**< Direction: 1=positive, -1=negative, 0=unknown. */
} wxd_det_arc_t;
/** Details for dot.
*/
typedef struct {
double x; /**< X position of center point. */
double y; /**< Y position of center point. */
double d; /**< Diameter in multiples of the base line width. */
} wxd_det_dot_t;
/** Details for an ellipse or a circle.
*/
typedef struct {
double x; /**< X position of center point. */
double y; /**< Y position of center point. */
double rx; /**< X radius for ellipse, radius for circle. */
double ry; /**< Y radius for ellipse. */
double a; /**< Rotation counterclockwise in degree. */
} wxd_det_ellipse_t;
/** Details for a box.
*/
typedef struct {
double xl; /**< Left X position. */
double xr; /**< Right X position. */
double yb; /**< Bottom Y position. */
double yt; /**< Top Y position. */
double r; /**< Corner radius, 0 for no rounded corner. */
} wxd_det_box_t;
/** Details for an embedded image.
*/
typedef struct {
char *fn; /**< File name for image, UTF-8 encoded. */
double x; /**< X position (left bottom point). */
double y; /**< Y position (left bottom point). */
double w; /**< Width of image range. */
double h; /**< Height of image range. */
uint8_t fl; /**< Image flags. */
int8_t r2g; /**< RGB to gray conversion method. */
int8_t r2c; /**< RGB to CMYK conversion method. */
} wxd_det_image_t;
/* 2018-05-25 No details for groups.
Conversion programs only need the flattened object list and are not
interested in keeping the group structure.
*/
/** Union of different details.
*/
typedef union {
wxd_det_text_t t; /**< Text details. */
wxd_det_pl_t p; /**< Polygon and polyline details. */
wxd_det_xs_t s; /**< Spline details. */
wxd_det_arc_t a; /**< Arc and circle details. */
wxd_det_dot_t d; /**< Dot details. */
wxd_det_ellipse_t e; /**< Ellipse details. */
wxd_det_box_t b; /**< Box details. */
wxd_det_image_t i; /**< Image details. */
} wxd_det_t;
/** One drawing element.
The csfs component contains the line cap style for open objects,
the fill style for closed objects.
The forward arrow and backward arrow components are ignored for
closed objects.
*/
typedef struct {
wxd_det_t det; /**< Graphics element details. */
wxd_arrow_t af; /**< Arrowhead forward. */
wxd_arrow_t ab; /**< Arrowhead backward. */
double lw; /**< Line width in multiples of the base width. */
dk4_um_t lino; /**< Line number. */
int16_t lay; /**< Layer number. */
int16_t ot; /**< Object type. */
uint8_t fc[3]; /**< Fill color. */
uint8_t sc[3]; /**< Stroke color. */
uint8_t csfs; /**< Line cap style (open), fill style (close). */
uint8_t ls; /**< Line style. */
uint8_t sl; /**< Style length. */
uint8_t js; /**< Line join style. */
uint8_t ml; /**< Miter limit for mitered line join. */
} wxd_object_t;
/** Entire drawing.
The flattened container contains all objects of the drawing without
any group structure. In the drawing application elements are sorted
by layer number, in the exporting application they are sorted by
layer number and style attributes.
The drawing program uses a second container s_grob representing
the drawing inclusive group structure.
For conversion programs like wxd2lat there is no need to keep the
group structure, s_grob is not defined in these programs.
*/
typedef struct {
dk4_sto_t *s_flat; /**< Flattened container of all objects. */
dk4_sto_it_t *i_flat; /**< Iterator for flattened container. */
double bbxl; /**< Bounding box, x left. */
double bbxr; /**< Bounding box, x right. */
double bbyb; /**< Bounding box, y bottom. */
double bbyt; /**< Bounding box, y top. */
double baselw; /**< Base line width in bp. */
uint16_t fv_maj; /**< Format version major number. */
uint16_t fv_min; /**< Format version minor number. */
} wxd_drawing_t;
/** One segment of an arrowhead on an arc.
*/
typedef struct {
/** The following points are in p:
- Left end point (0).
- Left control point (1).
- Right control point (2).
- Right end point (3).
*/
dk4_gra_point_t p[4];
} arc_ah_seg_t;
/** Details for a spline arrowhead.
*/
typedef struct {
wxd_point_t *ppoints; /**< Calculated points. */
double lo; /**< Length to offset (arrow head point). */
double lb; /**< Lenth to end of front side. */
double lc; /**< Length to end of back side, start center. */
double to; /**< Parameter for offset (arrow head point). */
double tb; /**< Parameter at end of front side. */
double tc; /**< Parameter at end of back side, start center. */
double csgn; /**< Coefficient for lengths. */
double lw; /**< Line width. */
double x0; /**< First point x. */
double y0; /**< First point y. */
double x1; /**< Second point x. */
double y1; /**< Second point y. */
size_t nf; /**< Number of segments in front side edges. */
size_t nb; /**< Number of segments in back side edges. */
size_t nc; /**< Number of segments in center side edge. */
size_t ifl; /**< Start index of first front left edge point. */
size_t ifr; /**< Start index of first front right edge point. */
size_t ibl; /**< Start index of first back left edge point. */
size_t ibr; /**< Start index of first back right edge point. */
size_t ic; /**< Start index of first center edge point. */
} sp_ah_t;
/** Iteration object for X-spline calculations.
*/
typedef struct {
wxd_object_t *pobj;
dk4_er_t *erp;
double l;
double xslp;
} wxd2lxs_iter_t;
/* vim: set ai sw=4 ts=4 : */
#endif
|