summaryrefslogtreecommitdiff
path: root/support/dktools/WxdkdrawTypes.h
blob: 5e6db512939611914b53754d127e92e8acbe4d7c (plain)
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
/*
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: WxdkdrawTypes.cpt
*/

#ifndef WXDKDRAWTYPES_H_INCLUDED
/** Avoid multiple inclusions. */
#define WXDKDRAWTYPES_H_INCLUDED 1


#line 8 "WxdkdrawTypes.cpt"

/**	@file	WxdkdrawTypes.h	Data types for the wxd2lat program.

	Here we have Wxd_... structures corresponding to the wxd_...
	structures from the wxd2lat/wxdtypes.h file.
*/

#ifndef	DK4CONF_H_INCLUDED
#include "dk4conf.h"
#endif

#ifndef	DK4TYPES_H_INCLUDED
#include "dk4types.h"
#endif

#ifndef	DK4BB_H_INCLUDED
#include "dk4bb.h"
#endif



#if	(DK4_HAVE_WXWIDGETS) && (defined(__cplusplus))


#ifndef	WX_WXPREC_H_INCLUDED
#include <wx/wxprec.h>
#define	WX_WXPREC_H_INCLUDED 1
#endif
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#if	DK4_HAVE_WX_CHARTYPE_H
#ifndef	WX_CHARTYPE_H_INCLUDED
#include <wx/chartype.h>
#define	WX_CHARTYPE_H_INCLUDED 1
#endif
#else
#if	DK4_HAVE_WX_WXCHAR_H
#ifndef	WX_WXCHAR_H_INCLUDED
#include <wx/wxchar.h>
#define	WX_WXCHAR_H_INCLUDED 1
#endif
#else
#ifndef	WX_WX_H_INCLUDED
#include <wx/wx.h>
#define	WX_WX_H_INCLUDED
#endif
#endif
#endif
#endif

#ifndef	WX_BITMAP_H_INCLUDED
#include <wx/bitmap.h>
#define	WX_BITMAP_H_INCLUDED	1
#endif

#ifndef	DK4STO_H_INCLUDED
#include "dk4sto.h"
#endif


/**	Marker 1: Mouse moved over object or object selected
	for copy/move/delete.
	Indicated by coloured markup.
*/
#define	OBJ_MARKER_1	((uint8_t)1U)

/**	Marker 2: Object selected for grouping or style editing.
	Indicated by black markup.
*/
#define	OBJ_MARKER_2	((uint8_t)2U)



/**	WXD font description.
*/
typedef struct {
	wxFont			*font;		/**< Font to be used for drawing. */
	uint16_t		 fsz;		/**< Font size in pt. */
	uint8_t			 find;		/**< Font index. */
	bool			 used;		/**< Font is used by drawing. */
	bool			 attempted;	/**< Already attempted to find font. */
} Wxd_font_t;



/**	Association of file name suffix and image type.
*/
typedef struct {
	wxChar const	*suffix;	/**< File name suffix. */
	wxBitmapType	 t;			/**< Corresponding image type. */
} Wxd_suffix_and_type_t;



/**	Polygon or polyline point.
*/
typedef struct {
	int32_t		x;	/**< X position. */
	int32_t		y;	/**< Y position. */
} Wxd_point_t;



/**	X-Spline point.
*/
typedef struct {
	double		s;	/**< S parameter. */
	int32_t		x;	/**< X position. */
	int32_t		y;	/**< Y position. */
} Wxd_spline_point_t;



/**	Bounding box values.
*/
typedef struct {
	int32_t			 xl;		/**< Left x. */
	int32_t			 xr;		/**< Right x. */
	int32_t			 yb;		/**< Bottom y. */
	int32_t			 yt;		/**< Top y. */
} Wxd_bb_t;



#define	WXD_TEXT_FLAG_NONE		((uint8_t)0U)
#define	WXD_TEXT_FLAG_LATEX		((uint8_t)1U)

#define	WXD_TEXT_ALIGN_LEFT		((uint8_t)0U)
#define	WXD_TEXT_ALIGN_CENTERED	((uint8_t)1U)
#define	WXD_TEXT_ALIGN_RIGHT	((uint8_t)2U)

/**	Details for a text.
	The 4 most significant bits in al represent the vertical
	text alignment, the 4 least significant bits represent the
	horizontal alignment.
*/
typedef struct {
	wxChar		*t;		/**< Text to export. */
	wxChar		*tsc;	/**< Text to show on screen. */
	Wxd_font_t	*font;	/**< WXD font structure. */
	int32_t		 x;		/**< X position. */
	int32_t		 y;		/**< Y position. */
	uint16_t	 fsz;	/**< Font size. */
	int16_t		 a;		/**< Rotation counterclockwise in degree. */
	uint8_t		 find;	/**< Font index. */
	uint8_t		 al;	/**< Horizontal and vertical 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).
*/
typedef struct {
	Wxd_spline_point_t	*p;	/**< Points. */
	uint16_t			 n;	/**< Number of points. */
} Wxd_det_xs_t;




#define	WXD_ARC_DIRECTION_POSITIVE	((int8_t)1)
#define	WXD_ARC_DIRECTION_NEGATIVE	((int8_t)-1)
#define	WXD_ARC_DIRECTION_UNKNOWN	((int8_t)0)

/**	Details for arcs (opened and closed).
	The x1, y1, x2, y2, x3, y3 components are read from file, the
	other values are calculated from the 3 points after reading
	the file and after each point modification.
*/
typedef struct {
	double		a;	/**< Start angle alpha counterclockwise in degree. */
	double		b;	/**< Angle range beta counterclockwise in degree. */
	double		x;	/**< X position of center point. */
	double		y;	/**< Y position of center point. */
	double		r;	/**< Radius. */
	int32_t		x1;	/**< X position of point 1. */
	int32_t		y1;	/**< Y position of point 1. */
	int32_t		x2;	/**< X position of point 2. */
	int32_t		y2;	/**< Y position of point 2. */
	int32_t		x3;	/**< X position of point 3. */
	int32_t		y3;	/**< Y position of point 3. */
	int8_t		d;	/**< Direction, 1=positive, -1=negative, 0=unknown. */
} Wxd_det_arc_t;


/**	Details for dot.
*/
typedef struct {
	int32_t		x;	/**< X position of center point. */
	int32_t		y;	/**< Y position of center point. */
	uint16_t	d;	/**< Diameter in multiples of the base line width. */
} Wxd_det_dot_t;


/**	Details for an ellipse or circle.
	For a circle ry and a are ignored.
*/
typedef struct {
	int32_t		x;	/**< X position of center point. */
	int32_t		y;	/**< Y position of center point. */
	uint32_t	rx;	/**< X radius for ellipse, radius for circle. */
	uint32_t	ry;	/**< Y radius for ellipse. */
	int16_t		a;	/**< Rotation counterclockwise in degree. */
} Wxd_det_ellipse_t;


/**	Radius value to indicate corner is not rounded.
*/
#define	WXD_BOX_CORNER_NONE	((uint32_t)0UL)

/**	Details for a box.
*/
typedef struct {
	Wxd_bb_t	b;	/**< Box rectangle. */
	uint32_t	r;	/**< Corner radius, 0 for no rounded corner. */
} Wxd_det_box_t;



/**	Details for an embedded image.
*/
typedef struct {
	wxChar		*fn;	/**< File name for image. */
	wxBitmap	*bm;	/**< Bitmap to draw on screen. */
	dk4_bb_t	 pl;	/**< Calculated coordinates for placement. */
	Wxd_bb_t	 br;	/**< Box rectangle from file. */
	double		 xres;	/**< Image x resolution. */
	double		 yres;	/**< Image y resolution. */
	uint16_t 	 fl;	/**< Image flags. */
	int8_t	 	 r2g;	/**< RGB to gray conversion method. */
	int8_t		 r2c;	/**< RGB to CMYK conversion method (unused). */
	wxBitmapType t;		/**< Bitmap type. */
} Wxd_det_image_t;



/**	Details for a group of objects.
*/
typedef struct Wxd_det_group__t {
	dk4_sto_t				*s_e;	/**< Elements storage. */
	dk4_sto_it_t			*i_e;	/**< Elements iterator. */
} Wxd_det_group_t;



/**	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;	/**< Details for a dot. */
	Wxd_det_ellipse_t	e;	/**< Ellipse details. */
	Wxd_det_box_t		b;	/**< Box details. */
	Wxd_det_image_t		i;	/**< Image details. */
	Wxd_det_group_t		g;	/**< Group details. */
} Wxd_det_t;



/**	Stipple bitmap (fill pattern).
*/
typedef struct Wxd__stipple__t {
	uint8_t		 cd[8];	/**< Color data. */
	wxBitmap	*bm;	/**< Stipple bit map. */
} Wxd_stipple_t;
/*
	The color data array cd contains the following data:
	0	fill style (pattern number)
	1	fill red
	2	fill green
	3	fill blue
	4	stroke red
	5	stroke green
	6	stroke blue
	7	Flag: Stipple is in use
*/



/**	Information about a layer.
*/
typedef struct Wxd__layer__t {
	int16_t				lay;		/**< Layer number. */
	uint8_t				active;		/**< Flag: Layer is active. */
	uint8_t				used;		/**< Flag: Layer is used. */
} Wxd_layer_t;



/**	One drawing element.
	The forward arrow and backward arrow components are ignored for
	closed objects.
*/
typedef struct Wxd__object__t {
	Wxd_det_t				 det;	/**< Graphics element details. */
	dk4_bb_t				 bb;	/**< Object bounding box. */
	struct Wxd__object__t	*pa;	/**< Parent group. */
	Wxd_stipple_t			*psti;	/**< Stipple for some fill patterns. */
	Wxd_layer_t				*play;	/**< Layer management information. */
	int16_t					 lay;	/**< Layer number. */
	uint16_t				 lw;	/**< Line width, multiples of base width. */
	uint8_t					 fc[3];	/**< Fill color. */
	uint8_t					 sc[3];	/**< Stroke and text color. */
	uint8_t					 cs;	/**< Cap style. */
	uint8_t					 fs;	/**< Fill style. */
	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. */
	uint8_t					 aft;	/**< Arrowhead forward type. */
	uint8_t					 afl;	/**< Length of arrowhead forward. */
	uint8_t					 afw;	/**< Width of arrowhead forward. */
	uint8_t					 abt;	/**< Arrowhead backward type. */
	uint8_t					 abl;	/**< Length of arrowhead backward. */
	uint8_t					 abw;	/**< Width of arrowhead backward. */
	uint8_t					 mark;	/**< Markers or-combined.  */
	int8_t					 ot;	/**< Object type. */
} Wxd_object_t;



/**	Entire drawing.
	The flattened container contains all objects of the drawing without
	any group structure. Elements are sorted by layer number.
	A second container s_stru contains the group structure.
*/
typedef struct {
	dk4_sto_t		*s_stru;	/**< Structured container of all objects. */
	dk4_sto_it_t	*i_stru;	/**< Iterator for structured container. */
	dk4_sto_t		*s_flat;	/**< Flattened container of all objects. */
	dk4_sto_it_t	*i_flat;	/**< Iterator for flattened container. */
	dk4_sto_t		*s_stip;	/**< Stipples container. */
	dk4_sto_it_t	*i_stip;	/**< Stipples iterator. */
	dk4_sto_t		*s_layers;	/**< Layer management storage. */
	dk4_sto_it_t	*i_layers;	/**< Layer management iterator. */
	dk4_sto_t		*s_fonts;	/**< Fonts storage. */
	dk4_sto_it_t	*i_fonts;	/**< Fonts storage iterator. */
	Wxd_bb_t		 bb;		/**< Bounding box. */
	size_t			 xsubs;		/**< Sub segments per X-spline segment. */
	int32_t			 cx;		/**< X coordinate in center of control. */
	int32_t			 cy;		/**< Y coordinate in center of control. */
	uint32_t		 baselw;	/**< Base line width in wxd units. */
	uint32_t		 bleft;		/**< Left border. */
	uint32_t		 bright;	/**< Right border. */
	uint32_t		 bbottom;	/**< Bottom border. */
	uint32_t		 btop;		/**< Top border. */
	int				 redraw;	/**< Required redraw level. */
	uint16_t		 fv_maj;	/**< Format version major number. */
	uint16_t		 fv_min;	/**< Format version minor number. */
	int8_t			 zl;		/**< Zoom level. */
	uint8_t			 gridunit;	/**< Grid unit (0=inch, 1=cm). */
	uint8_t			 gridbase;	/**< Grid base (0=powers of 2, 1=of 10). */
} Wxd_drawing_t;



/**	Error codes for reader module.
*/
enum {
	WXDRD_E_NONE		=	0,	/**< No error occured. */
	WXDRD_E_MEMORY ,			/**< Not enough memory. */
	WXDRD_E_TEXT_PARTS ,		/**< Expected number of texts ot found. */
	WXDRD_E_NUM_CONV ,			/**< Conversion of text to number failed. */
	WXDRD_E_RECODE_TEXT ,		/**< Recoding failed for text label. */
	WXDRD_E_RECODE_FILENAME ,	/**< Recoding failed for file name. */
	WXDRD_E_INVALID_ARGS ,		/**< Invalid function arguments. */
	WXDRD_E_NO_VERSION ,		/**< File format information not found. */
	WXDRD_E_NO_BB ,				/**< No bounding box information found. */
	WXDRD_E_NO_WXD ,			/**< Not a WXD file. */
	WXDRD_E_WRONG_VERSION ,		/**< File format too new. */
	WXDRD_E_EXPECTED_OBJSTART ,	/**< Object start line expected. */
	WXDRD_E_EXPECTED_DETAILS ,	/**< Details line expected. */
	WXDRD_E_READER_STATE ,		/**< Wrong reader state. */
	WXDRD_E_OBJTYPE ,			/**< Illegal object or subobject type. */
	WXDRD_E_COORD_OVERFLOW ,	/**< Mathematical overflow in coordinates. */
	WXDRD_E_NO_GROUP_TO_END ,	/**< No open group to end. */
	WXDRD_E_TOO_FEW_POINTS ,	/**< Too few points. */
	WXDRD_E_EMPTY_FILENAME ,	/**< Empty image file name. */
	WXDRD_E_FILENAME_TOO_LONG ,	/**< Image file name too long. */
	WXDRD_E_BOX_NO_AREA ,		/**< Box does not span an area. */
};



/**	Reader status.
*/
typedef struct {
	Wxd_bb_t		 bb;	/**< Drawing bounding box. */
	wxChar			*dirn;	/**< Directory file resides in. */
	unsigned long	 ln;	/**< Line number error occured in. */
	size_t			 te;	/**< Number of text element not convertable. */
	int				 ec;	/**< Error code from module. */
	int				 wxe;	/**< Encoding used for wxChar. */
	int				 mod;	/**< Flag: Modified by corrections. */
} wxdrd_status_t;



/**	Errors occuring in write operations.
*/
enum {
	WXDWR_E_NONE			= 0,	/**< No error occured. */
	WXDWR_E_WRITE ,					/**< Error in write operation. */
	WXDWR_E_STRING_TOO_LONG ,		/**< String is too long. */
	WXDWR_E_RECODE_TEXT ,			/**< Failed to recode a text. */
	WXDWR_E_RECODE_FILENAME ,		/**< Failed to recode a file name. */
	WXDWR_E_STRING_EMPTY ,			/**< Empty string. */
};


/**	Writer status.
*/
typedef struct {
	int				 ec;	/**< Error code. */
	int				 wxe;	/**< Encoding used for wxChar strings. */
	wxChar			*str;	/**< String for which conversion failed. */
	wxChar			*dirn;	/**< Directory name for output file. */
} wxdwr_status_t;



#endif
/* if (DK4_HAVE_WXWIDGETS) && (defined(__cplusplus)) */


/* vim: set ai sw=4 ts=4 : */


#endif