From 1f457376b478257b88d4a857f5ec1b6155442dd7 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sun, 20 Sep 2020 03:03:26 +0000 Subject: CTAN sync 202009200303 --- support/dktools/wxdtypes.ctr | 304 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 304 insertions(+) create mode 100644 support/dktools/wxdtypes.ctr (limited to 'support/dktools/wxdtypes.ctr') diff --git a/support/dktools/wxdtypes.ctr b/support/dktools/wxdtypes.ctr new file mode 100644 index 0000000000..3f9e98f3fd --- /dev/null +++ b/support/dktools/wxdtypes.ctr @@ -0,0 +1,304 @@ +%% options + +copyright owner = Dirk Krause +copyright year = 2018-xxxx +SPDX-License-Identifier: BSD-3-Clause + +%% header + +/** @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 : */ + -- cgit v1.2.3