/* 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: wxd2lout.ctr */ /** @file wxd2lout.c The wxd2lout module. */ #line 65 "wxd2lout.ctr" #ifndef WXD2LAT_H_INCLUDED #include "wxd2lat.h" #endif #line 73 "wxd2lout.ctr" static const dkChar *kwnl[] = { /* 0 */ dkT(".tex"), NULL #line 83 "wxd2lout.ctr" }; double wxd2lout_convert_x(wxd_drawing_t *drw, wxd2lat_job_t *job, double x) { #if TRACE_DEBUG double back; #line 93 "wxd2lout.ctr" back = ((9.0 * (x - drw->bbxl)) / 2032000.0) + job->shiftx; #line 95 "wxd2lout.ctr" return back; #else return (((9.0 * (x - drw->bbxl)) / 2032000.0) + job->shiftx); #endif } double wxd2lout_convert_y(wxd_drawing_t *drw, wxd2lat_job_t *job, double y) { #if TRACE_DEBUG double back; #line 109 "wxd2lout.ctr" back = ((9.0 * (y - drw->bbyb)) / 2032000.0) + job->shifty; #line 111 "wxd2lout.ctr" return back; #else return (((9.0 * (y - drw->bbyb)) / 2032000.0) + job->shifty); #endif } /** Convert distance value from WXD coordinates to bp. @param r Distance to convert @return Conversion result. */ double wxd2lout_convert_r(double r) { #if TRACE_DEBUG double back; #line 129 "wxd2lout.ctr" back = ((9.0 * r) / 2032000.0); #line 131 "wxd2lout.ctr" return back; #else return ((9.0 * r) / 2032000.0); #endif } /** Prepare job structure, calculate coordinates transformations and create output file name. @param drw Drawing to convert. @param job Job structure. @param fn File name. @return 1 on success (output possible), 0 on error. */ static int wxd2lout_prepare_job(wxd_drawing_t *drw, wxd2lat_job_t *job, const dkChar *fn) { dkChar *ptr; double dwidth; double dheight; double cwidth; double cheight; int back = 1; #line 158 "wxd2lout.ctr" dwidth = (9.0 * (drw->bbxr - drw->bbxl)) / 2032000.0; dheight = (9.0 * (drw->bbyt - drw->bbyb)) / 2032000.0; cwidth = ceil(dwidth); cheight = ceil(dheight); if (cwidth > dwidth) { job->shiftx = (cwidth - dwidth) / 2.0; #line 165 "wxd2lout.ctr" } if (cheight > dheight) { job->shifty = (cheight - dheight) / 2.0; #line 169 "wxd2lout.ctr" } if ((0 == dk4ma_is_finite(dwidth)) || (0 == dk4ma_is_finite(cwidth))) { back = 0; /* ERROR: Numeric overflow in width calculation */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 36 ); } if ((0 == dk4ma_is_finite(dheight)) || (0 == dk4ma_is_finite(cheight))) { back = 0; /* ERROR: Numeric overflow in height calculation */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 36 ); } if ((double)(SIZE_MAX) < cwidth) { back = 0; /* ERROR: Numeric overflow in width calculation */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 36 ); } else { job->szwidth = (size_t)cwidth; #line 194 "wxd2lout.ctr" } if ((double)(SIZE_MAX) < cheight) { back = 0; /* ERROR: Numeric overflow in height calculation */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 36 ); } else { job->szheight = (size_t)cheight; #line 205 "wxd2lout.ctr" } if (0 != dk4str_cpy_s(job->fno1, job->szfnb, fn, NULL)) { ptr = dk4path_get_suffix(job->fno1, NULL); if (NULL != ptr) { *ptr = dkT('\0'); } if (0 == dk4str_cat_s(job->fno1, job->szfnb, kwnl[0], NULL)) { back = 0; /* ERROR: File name too long */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 37 ); } } else { /* ERROR: File name too long */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 37 ); back = 0; } #line 225 "wxd2lout.ctr" return back; } /** Set clip region to used coordinates ranges. @param drw Drawing to convert. @param job Job structure. @return 1 on success, 0 on error. */ static int wxd2lout_clip_to_used_region(wxd2lat_job_t *job) { dk4_er_t er; int back = 1; double xl; double xr; double yb; double yt; #line 246 "wxd2lout.ctr" if ((0.0 < job->shiftx) || (0.0 < job->shifty)) { xl = job->shiftx; if (0.0 > xl) { xl = 0.0; } xr = (double)(job->szwidth) - job->shiftx; yb = job->shifty; if (0.0 > yb) { yb = 0.0; } yt = (double)(job->szheight) - job->shifty; dk4error_init(&er); dk4pppt_newpath_moveto(job->ppp, xl, yb, NULL, &back, &er); dk4pppt_lineto(job->ppp, xr, yb, NULL, &back, &er); dk4pppt_lineto(job->ppp, xr, yt, NULL, &back, &er); dk4pppt_lineto(job->ppp, xl, yt, NULL, &back, &er); dk4pppt_lineto(job->ppp, xl, yb, NULL, &back, &er); dk4pppt_closepath(job->ppp, &back, &er); dk4pppt_clip(job->ppp, &back, &er); if (0 == back) { /* ERROR: Failed to clip region */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 38 ); } } #line 269 "wxd2lout.ctr" return back; } /** Set stroke RGB colour. @param job Job structure. @param pobj Current object. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. @return 1 on success, 0 on error. */ static void wxd2lout_stroke_rgb( wxd2lat_job_t *job, wxd_object_t *pobj, int *backptr, dk4_er_t *erp ) { #line 291 "wxd2lout.ctr" dk4pppt_set_stroke_rgb( job->ppp, (((double)(pobj->sc[0])) / 255.0), (((double)(pobj->sc[1])) / 255.0), (((double)(pobj->sc[2])) / 255.0), backptr, erp ); #line 299 "wxd2lout.ctr" #line 300 "wxd2lout.ctr" } /** Set stroke line width. @param drw Drawing structure. @param job Job structure. @param pobj Current object. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. @return 1 on success, 0 on error. */ static void wxd2lout_line_width( wxd_drawing_t *drw, wxd2lat_job_t *job, wxd_object_t *pobj, int *backptr, dk4_er_t *erp ) { #line 323 "wxd2lout.ctr" dk4pppt_set_line_width( job->ppp, wxd2lat_object_linewidth(pobj, drw, job), backptr, erp ); #line 328 "wxd2lout.ctr" #line 329 "wxd2lout.ctr" } /** Set stroke line style. @param drw Drawing structure. @param job Job structure. @param pobj Current object. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. @return 1 on success, 0 on error. */ static void wxd2lout_line_style( wxd_drawing_t *drw, wxd2lat_job_t *job, wxd_object_t *pobj, int *backptr, dk4_er_t *erp ) { double sv; dk4_gra_ls_t ls = DK4_GRA_LS_SOLID; #line 354 "wxd2lout.ctr" switch (pobj->ls) { case WXD_LS_SOLID : { ls = DK4_GRA_LS_SOLID; } break; case WXD_LS_DASH : { ls = DK4_GRA_LS_DASH; } break; case WXD_LS_DOT : { ls = DK4_GRA_LS_DOT; } break; case WXD_LS_DASH_DOT : { ls = DK4_GRA_LS_DASH_DOT; } break; case WXD_LS_DASH_DOT_DOT : { ls = DK4_GRA_LS_DASH_DOT_DOT; } break; case WXD_LS_DASH_DOT_DOT_DOT : { ls = DK4_GRA_LS_DASH_DOT_DOT_DOT; } break; } sv = (double)(pobj->sl) * wxd2lat_object_linewidth(pobj, drw, job); dk4pppt_set_line_style(job->ppp, ls, sv, backptr, erp); #line 377 "wxd2lout.ctr" #line 378 "wxd2lout.ctr" } /** Set stroke line cap. @param job Job structure. @param pobj Current object. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. @return 1 on success, 0 on error. */ static void wxd2lout_line_cap( wxd2lat_job_t *job, wxd_object_t *pobj, int *backptr, dk4_er_t *erp ) { dk4_gra_lc_t lc = DK4_GRA_LC_BUTTED; #line 400 "wxd2lout.ctr" switch (pobj->csfs) { case WXD_LC_BUTTED : { lc = DK4_GRA_LC_BUTTED; } break; case WXD_LC_ROUNDED : { lc = DK4_GRA_LC_ROUNDED; } break; case WXD_LC_PROJECTING : { lc = DK4_GRA_LC_PROJECTING; } break; } dk4pppt_set_line_cap(job->ppp, lc, backptr, erp); #line 413 "wxd2lout.ctr" #line 414 "wxd2lout.ctr" } /** Set stroke line join. @param job Job structure. @param pobj Current object. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. @return 1 on success, 0 on error. */ static void wxd2lout_line_join( wxd2lat_job_t *job, wxd_object_t *pobj, int *backptr, dk4_er_t *erp ) { dk4_gra_lj_t lj = DK4_GRA_LJ_MITERED; #line 436 "wxd2lout.ctr" switch ( (int)(pobj->ot) ) { case WXD_OT_O_ARC : case WXD_OT_C_ARC : case WXD_OT_CIRCLE : case WXD_OT_ELLIPSE : { lj = DK4_GRA_LJ_ROUNDED; } break; default : { switch (pobj->js) { case WXD_LJ_MITERED : { lj = DK4_GRA_LJ_MITERED; } break; case WXD_LJ_ROUNDED : { lj = DK4_GRA_LJ_ROUNDED; } break; case WXD_LJ_BEVELED : { lj = DK4_GRA_LJ_BEVELED; } break; } } break; } #line 457 "wxd2lout.ctr" #line 458 "wxd2lout.ctr" if ((uint8_t)0U == pobj->ml) { pobj->ml = (uint8_t)1U; } dk4pppt_set_line_join(job->ppp, lj, (double)(pobj->ml), backptr, erp); #line 461 "wxd2lout.ctr" #line 462 "wxd2lout.ctr" } /** Set fill RGB colour. @param job Job structure. @param pobj Current object. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. @return 1 on success, 0 on error. */ static void wxd2lout_fill_rgb( wxd2lat_job_t *job, wxd_object_t *pobj, int *backptr, dk4_er_t *erp ) { #line 483 "wxd2lout.ctr" #line 484 "wxd2lout.ctr" #line 485 "wxd2lout.ctr" #line 486 "wxd2lout.ctr" #line 487 "wxd2lout.ctr" #line 488 "wxd2lout.ctr" #line 489 "wxd2lout.ctr" #line 490 "wxd2lout.ctr" #line 491 "wxd2lout.ctr" dk4pppt_set_fill_rgb( job->ppp, (((double)(pobj->fc[0])) / 255.0), (((double)(pobj->fc[1])) / 255.0), (((double)(pobj->fc[2])) / 255.0), backptr, erp ); #line 499 "wxd2lout.ctr" #line 500 "wxd2lout.ctr" } /** Set fill attributes. @param job Job structure. @param pobj Current object. @param backptr Address of success variable to reset on errors. @param erp Error report, may be NULL. @return 1 on success, 0 on error. */ static void wxd2lout_attributes_fill( wxd2lat_job_t *job, wxd_object_t *pobj, int *backptr, dk4_er_t *erp ) { /* Fill colour */ #line 523 "wxd2lout.ctr" wxd2lout_fill_rgb(job, pobj, backptr, erp); #line 525 "wxd2lout.ctr" #line 526 "wxd2lout.ctr" } /** Return pattern for object. @param pobj Object to pattern. @return Pattern number as dk4_gra_pattern_t. */ static dk4_gra_pattern_t wxd2lout_find_pattern(wxd_object_t *pobj) { dk4_gra_pattern_t back = DK4_GRA_PATTERN_30_DEGREE_LEFT; #line 540 "wxd2lout.ctr" switch (pobj->csfs) { case WXD_FS_30_DEGREE_LEFT : { back = DK4_GRA_PATTERN_30_DEGREE_LEFT; } break; case WXD_FS_30_DEGREE_RIGHT : { back = DK4_GRA_PATTERN_30_DEGREE_RIGHT; } break; case WXD_FS_30_DEGREE_SIEVE : { back = DK4_GRA_PATTERN_30_DEGREE_SIEVE; } break; case WXD_FS_45_DEGREE_LEFT : { back = DK4_GRA_PATTERN_45_DEGREE_LEFT; } break; case WXD_FS_45_DEGREE_RIGHT : { back = DK4_GRA_PATTERN_45_DEGREE_RIGHT; } break; case WXD_FS_45_DEGREE_SIEVE : { back = DK4_GRA_PATTERN_45_DEGREE_SIEVE; } break; case WXD_FS_HORIZONTAL_BRICKS : { back = DK4_GRA_PATTERN_HORIZONTAL_BRICKS; } break; case WXD_FS_VERTICAL_BRICKS : { back = DK4_GRA_PATTERN_VERTICAL_BRICKS; } break; case WXD_FS_HORIZONTAL_LINES : { back = DK4_GRA_PATTERN_HORIZONTAL_LINES; } break; case WXD_FS_VERTICAL_LINES : { back = DK4_GRA_PATTERN_VERTICAL_LINES; } break; case WXD_FS_HORIZONTAL_VERTICAL_SIEVE : { back = DK4_GRA_PATTERN_HORIZONTAL_VERTICAL_SIEVE; } break; case WXD_FS_HORIZONTAL_SHINGLES_LEFT : { back = DK4_GRA_PATTERN_HORIZONTAL_SHINGLES_LEFT; } break; case WXD_FS_HORIZONTAL_SHINGLES_RIGHT : { back = DK4_GRA_PATTERN_HORIZONTAL_SHINGLES_RIGHT; } break; case WXD_FS_VERTICAL_SHINGLES_1 : { back = DK4_GRA_PATTERN_VERTICAL_SHINGLES_1; } break; case WXD_FS_VERTICAL_SHINGLES_2 : { back = DK4_GRA_PATTERN_VERTICAL_SHINGLES_2; } break; case WXD_FS_LARGE_FISH_SCALES : { back = DK4_GRA_PATTERN_LARGE_FISH_SCALES; } break; case WXD_FS_SMALL_FISH_SCALES : { back = DK4_GRA_PATTERN_SMALL_FISH_SCALES; } break; case WXD_FS_CIRCLES : { back = DK4_GRA_PATTERN_CIRCLES; } break; case WXD_FS_HEXAGONS : { back = DK4_GRA_PATTERN_HEXAGONS; } break; case WXD_FS_OCTAGONS : { back = DK4_GRA_PATTERN_OCTAGONS; } break; case WXD_FS_HORIZONTAL_TIRES : { back = DK4_GRA_PATTERN_HORIZONTAL_TIRES; } break; case WXD_FS_VERTICAL_TIRES : { back = DK4_GRA_PATTERN_VERTICAL_TIRES; } break; } #line 610 "wxd2lout.ctr" return back; } /** Set stroke attributes. @param drw Drawing structure. @param job Job structure. @param pobj Current object. @param backptr Address of success variable to reset on errors. @param use_lc Flag: Also set line cap. @param use_lj Flag: Use join style and miter limit. @param erp Error report, may be NULL. @return 1 on success, 0 on error. */ static void wxd2lout_attributes_stroke( wxd_drawing_t *drw, wxd2lat_job_t *job, wxd_object_t *pobj, int *backptr, int use_lc, dk4_er_t *erp ) { #line 637 "wxd2lout.ctr" /* Stroke colour */ wxd2lout_stroke_rgb(job, pobj, backptr, erp); #line 641 "wxd2lout.ctr" /* Line width */ wxd2lout_line_width(drw, job, pobj, backptr, erp); #line 646 "wxd2lout.ctr" /* Line style and dash length */ wxd2lout_line_style(drw, job, pobj, backptr, erp); #line 651 "wxd2lout.ctr" /* Line cap */ if (0 != use_lc) { wxd2lout_line_cap(job, pobj, backptr, erp); #line 657 "wxd2lout.ctr" } /* Line join */ switch (pobj->ot) { case WXD_OT_POLYLINE : case WXD_OT_O_SPLINE : case WXD_OT_POLYGON : case WXD_OT_C_SPLINE : case WXD_OT_C_ARC: case WXD_OT_BOX : { wxd2lout_line_join(job, pobj, backptr, erp); } break; } #line 669 "wxd2lout.ctr" #line 670 "wxd2lout.ctr" } /** Create polygon or polyline without arrowheads path. @param job Job structure. @param pobj Object to create path for. @param backptr Address of success variable to reset on error. @param pbb Bounding box for path, may be NULL. @param erp Error report, may be NULL. @param iscl Flag: Closed path. */ static void wxd2lout_path_pl_no_arrows( wxd2lat_job_t *job, wxd_object_t *pobj, int *backptr, dk4_bb_t *pbb, dk4_er_t *erp, int iscl ) { uint16_t i; #line 695 "wxd2lout.ctr" dk4pppt_newpath_moveto( job->ppp, ((pobj->det).p.p)[0].x, ((pobj->det).p.p)[0].y, pbb, backptr, erp ); for (i = 1; i < (pobj->det).p.n; i++) { dk4pppt_lineto( job->ppp, ((pobj->det).p.p)[i].x, ((pobj->det).p.p)[i].y, pbb, backptr, erp ); } if (0 != iscl) { dk4pppt_lineto( job->ppp, ((pobj->det).p.p)[0].x, ((pobj->det).p.p)[0].y, pbb, backptr, erp ); dk4pppt_closepath(job->ppp, backptr, erp); } #line 713 "wxd2lout.ctr" } /** Create Bezier segments for one X-spline segment. The X-spline segment is drawn completely, 8 Bezier segments are used per X-spline segment. @param job Job structure. @param xs X-spline structure, control points are set up. @param ib Index of point B (0 for first segment). @param backptr Address of success variable to reset on error. @param pbb Bounding box for path, may be NULL. @param erp Error report, may be NULL. */ static void wxd2lout_path_spline_segment_normal( wxd2lat_job_t *job, dk4_xsp_2d_t *xs, uint16_t ib, int *backptr, dk4_bb_t *pbb, dk4_er_t *erp ) { double v0[4]; double v1[4]; double t; double divisor; unsigned i; #line 744 "wxd2lout.ctr" divisor = 3.0 * (double)((job->grco).xsss); if (0 != dk4xsp2d_calculate_value_derivative(v0, xs, 0.0, erp)) { v0[1] = v0[1] / divisor; v0[3] = v0[3] / divisor; if ((uint16_t)0U == ib) { dk4pppt_newpath_moveto(job->ppp, v0[0], v0[2], pbb, backptr, erp); } for (i = 1; i <= (job->grco).xsss; i++) { t = (double)i / (double)((job->grco).xsss); if ((job->grco).xsss == i) { t = 1.0; } if (0 != dk4xsp2d_calculate_value_derivative(v1, xs, t, erp)) { v1[1] = v1[1] / divisor; v1[3] = v1[3] / divisor; dk4pppt_curveto( job->ppp, (v0[0]+v0[1]), (v0[2]+v0[3]), (v1[0]-v1[1]), (v1[2]-v1[3]), v1[0], v1[2], pbb, backptr, erp ); DK4_MEMCPY(v0,v1,sizeof(v0)); } else { if (NULL != backptr) { *backptr = 0; } /* ERROR: X-spline calculation failed */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 39 ); } } } else { if (NULL != backptr) { *backptr = 0; } /* ERROR: X-spline calculation failed */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 39 ); } #line 783 "wxd2lout.ctr" } /** Create spline path for closed spline or open spline without arrowheads. @param job Job structure. @param pobj Object to create path for. @param backptr Address of success variable to reset on error. @param pbb Bounding box for path, may be NULL. @param erp Error report, may be NULL. @param iscl Flag: Closed path. */ static void wxd2lout_path_spline_no_arrows( wxd2lat_job_t *job, wxd_object_t *pobj, int *backptr, dk4_bb_t *pbb, dk4_er_t *erp, int iscl ) { dk4_xsp_2d_t xs; /* X-spline */ uint16_t sgn; /* Current segment to process */ #if VERSION_BEFORE_20190110 uint16_t ia; /* Index of point A */ uint16_t id; /* Index of point D */ #endif uint16_t ib; /* Index of point B */ uint16_t ic; /* Index of point C */ #line 815 "wxd2lout.ctr" dk4xsp2d_reset(&xs); for (sgn = 0; sgn < (pobj->det).s.n - 1; sgn++) { ib = sgn; ic = ib + (uint16_t)1U; if ( (1.0e-8 > fabs(((pobj->det).s.p)[ib].s)) && (1.0e-8 > fabs(((pobj->det).s.p)[ic].s)) ) { if (0 == sgn) { dk4pppt_newpath_moveto( job->ppp, ((pobj->det).s.p)[ib].x, ((pobj->det).s.p)[ib].y, pbb, backptr, erp ); } dk4pppt_lineto( job->ppp, ((pobj->det).s.p)[ic].x, ((pobj->det).s.p)[ic].y, pbb, backptr, erp ); } else { #if VERSION_BEFORE_20190110 id = ib + (uint16_t)2U; ia = ib - (uint16_t)1U; dk4xsp2d_reset_points(&xs); dk4xsp2d_set_point( &xs, ((pobj->det).s.p)[ib].x, ((pobj->det).s.p)[ib].y, ((pobj->det).s.p)[ib].s, 1 ); dk4xsp2d_set_point( &xs, ((pobj->det).s.p)[ic].x, ((pobj->det).s.p)[ic].y, ((pobj->det).s.p)[ic].s, 2 ); if ((uint16_t)0U != ib) { dk4xsp2d_set_point( &xs, ((pobj->det).s.p)[ia].x, ((pobj->det).s.p)[ia].y, ((pobj->det).s.p)[ia].s, 0 ); } else { if (0 != iscl) { ia = (pobj->det).s.n - (uint16_t)1U; dk4xsp2d_set_point( &xs, ((pobj->det).s.p)[ia].x, ((pobj->det).s.p)[ia].y, ((pobj->det).s.p)[ia].s, 0 ); } } if (id < (pobj->det).s.n) { dk4xsp2d_set_point( &xs, ((pobj->det).s.p)[id].x, ((pobj->det).s.p)[id].y, ((pobj->det).s.p)[id].s, 3 ); } else { if (0 != iscl) { id = (uint16_t)0U; dk4xsp2d_set_point( &xs, ((pobj->det).s.p)[id].x, ((pobj->det).s.p)[id].y, ((pobj->det).s.p)[id].s, 3 ); } } #else wxd2lxs_set_xspline(&xs, pobj, ib); #endif wxd2lout_path_spline_segment_normal( job, &xs, sgn, backptr, pbb, erp ); } } if (0 != iscl) { ib = (pobj->det).s.n - (uint16_t)1U; ic = (uint16_t)0U; if ( (1.0e-8 > fabs(((pobj->det).s.p)[ib].s)) && (1.0e-8 > fabs(((pobj->det).s.p)[ic].s)) ) { dk4pppt_lineto( job->ppp, ((pobj->det).s.p)[ic].x, ((pobj->det).s.p)[ic].y, pbb, backptr, erp ); } else { #if VERSION_BEFORE_20190110 ia = (pobj->det).s.n - (uint16_t)2U; id = (uint16_t)1U; dk4xsp2d_reset_points(&xs); dk4xsp2d_set_point( &xs, ((pobj->det).s.p)[ia].x, ((pobj->det).s.p)[ia].y, ((pobj->det).s.p)[ia].s, 0 ); dk4xsp2d_set_point( &xs, ((pobj->det).s.p)[ib].x, ((pobj->det).s.p)[ib].y, ((pobj->det).s.p)[ib].s, 1 ); dk4xsp2d_set_point( &xs, ((pobj->det).s.p)[ic].x, ((pobj->det).s.p)[ic].y, ((pobj->det).s.p)[ic].s, 2 ); dk4xsp2d_set_point( &xs, ((pobj->det).s.p)[id].x, ((pobj->det).s.p)[id].y, ((pobj->det).s.p)[id].s, 3 ); #else wxd2lxs_set_xspline(&xs, pobj, ib); #endif wxd2lout_path_spline_segment_normal( job, &xs, ib, backptr, pbb, erp ); } dk4pppt_closepath(job->ppp, backptr, erp); } #line 941 "wxd2lout.ctr" } /** Create arc path for given start and end angle. @param drw Drawing structure. @param job Job structure. @param pobj Object to create path for. @param alpha Start angle in radians. @param beta End angle in radians. @param backptr Address of success variable to reset on error. @param pbb Bounding box for path, may be NULL. @param erp Error report, may be NULL. @param iscl Flag: Closed path. */ static void wxd2lout_path_arc_angles( wxd_drawing_t *drw, wxd2lat_job_t *job, wxd_object_t *pobj, double alpha, double beta, int *backptr, dk4_bb_t *pbb, dk4_er_t *erp, int iscl ) { double v0[4]; /* Start point of current segment */ double v1[4]; /* End point of current segment */ double angle; /* Complete arc angle */ double pos; /* Angle position at end of current segment */ double kappa; /* Kappa value */ double segan; /* Segment angle */ size_t nsegs; /* Number of segments */ size_t i; /* Current segment */ #line 979 "wxd2lout.ctr" if (0 != (pobj->det).a.d) { /* Real arc. */ angle = beta - alpha; #line 985 "wxd2lout.ctr" nsegs = (size_t)ceil(4.0 * fabs(angle) / M_PI); if (1 > nsegs) { nsegs = 1; } #line 988 "wxd2lout.ctr" segan = angle / (double)nsegs; #line 990 "wxd2lout.ctr" kappa = dk4gratool_kappa_for_angle(fabs(segan)); #line 992 "wxd2lout.ctr" v0[0] = (pobj->det).a.x + (pobj->det).a.r * cos(alpha); v0[1] = (pobj->det).a.y + (pobj->det).a.r * sin(alpha); v0[2] = -1.0 * kappa * segan * (pobj->det).a.r * sin(alpha); v0[3] = kappa * segan * (pobj->det).a.r * cos(alpha); for (i = 0; i < nsegs; i++) { if (0 == i) { dk4pppt_newpath_moveto( job->ppp, v0[0], v0[1], NULL, backptr, erp ); } if (i < (nsegs - 1)) { pos = alpha + ((angle * (double)(i + (size_t)1U)) / (double)nsegs); } else { pos = beta; } v1[0] = (pobj->det).a.x + (pobj->det).a.r * cos(pos); v1[1] = (pobj->det).a.y + (pobj->det).a.r * sin(pos); v1[2] = -1.0 * kappa * segan * (pobj->det).a.r * sin(pos); v1[3] = kappa * segan * (pobj->det).a.r * cos(pos); dk4pppt_curveto( job->ppp, (v0[0] + v0[2]), (v0[1] + v0[3]), (v1[0] - v1[2]), (v1[1] - v1[3]), v1[0], v1[1], pbb, backptr, erp ); DK4_MEMCPY(v0,v1,sizeof(v0)); } if (0 != iscl) { dk4pppt_lineto( job->ppp, (pobj->det).a.x, (pobj->det).a.y, pbb, backptr, erp ); v0[0] = (pobj->det).a.x + (pobj->det).a.r * cos(alpha); v0[1] = (pobj->det).a.y + (pobj->det).a.r * sin(alpha); dk4pppt_lineto( job->ppp, v0[0], v0[1], pbb, backptr, erp ); } } else { /* Malformed arc, points either on one line or equal. */ dk4pppt_newpath_moveto( job->ppp, wxd2lout_convert_x(drw, job, (double)((pobj->det).a.x1)), wxd2lout_convert_y(drw, job, (double)((pobj->det).a.y1)), NULL, backptr, erp ); dk4pppt_lineto( job->ppp, wxd2lout_convert_x(drw, job, (double)((pobj->det).a.x2)), wxd2lout_convert_y(drw, job, (double)((pobj->det).a.y2)), NULL, backptr, erp ); dk4pppt_lineto( job->ppp, wxd2lout_convert_x(drw, job, (double)((pobj->det).a.x3)), wxd2lout_convert_y(drw, job, (double)((pobj->det).a.y3)), NULL, backptr, erp ); if (0 != iscl) { dk4pppt_lineto( job->ppp, wxd2lout_convert_x(drw, job, (double)((pobj->det).a.x1)), wxd2lout_convert_y(drw, job, (double)((pobj->det).a.y1)), NULL, backptr, erp ); dk4pppt_closepath(job->ppp, backptr, erp); } } #line 1065 "wxd2lout.ctr" } /** Create arc path for closed arcs or open arcs without arrowheads. @param drw Drawing structure. @param job Job structure. @param pobj Object to create path for. @param backptr Address of success variable to reset on error. @param pbb Bounding box for path, may be NULL. @param erp Error report, may be NULL. @param iscl Flag: Closed path. */ static void wxd2lout_path_arc_no_arrows( wxd_drawing_t *drw, wxd2lat_job_t *job, wxd_object_t *pobj, int *backptr, dk4_bb_t *pbb, dk4_er_t *erp, int iscl ) { #line 1091 "wxd2lout.ctr" wxd2lout_path_arc_angles( drw, job, pobj, (pobj->det).a.a, (pobj->det).a.b, backptr, pbb, erp, iscl ); #line 1096 "wxd2lout.ctr" } /** Create polyline with arrowheads path. @param job Job structure. @param pobj Object to create path for. @param backptr Address of success variable to reset on error. @param pbb Bounding box for path, may be NULL. @param erp Error report, may be NULL. */ static void wxd2lout_path_pl_with_arrows( wxd2lat_job_t *job, wxd_object_t *pobj, int *backptr, dk4_bb_t *pbb, dk4_er_t *erp ) { double x0; /* X coordinate first/last point */ double y0; /* Y coordinate first/last point */ double x1; /* X coordinate second/penultimate point */ double y1; /* Y coordinate second/penultimate point */ double sl; /* Segment length */ double cl; /* Cut length */ double nl; /* Non-cut length */ uint16_t i; /* Current inner point */ #line 1126 "wxd2lout.ctr" /* Move to first point */ x0 = ((pobj->det).p.p)[0].x; y0 = ((pobj->det).p.p)[0].y; #line 1132 "wxd2lout.ctr" if (0 != (pobj->ab).type) { x1 = ((pobj->det).p.p)[1].x; y1 = ((pobj->det).p.p)[1].y; sl = sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)); cl = (pobj->ab).cut; nl = sl - cl; x0 = ((x0 * nl) + (x1 * cl)) / sl; y0 = ((y0 * nl) + (y1 * cl)) / sl; } #line 1142 "wxd2lout.ctr" dk4pppt_newpath_moveto(job->ppp, x0, y0, pbb, backptr, erp); /* Lines to inner points */ if ((uint16_t)2U < (pobj->det).p.n) { for (i = (uint16_t)1U; i < ((pobj->det).p.n) - (uint16_t)1U; i++) { #line 1149 "wxd2lout.ctr" dk4pppt_lineto( job->ppp, ((pobj->det).p.p)[i].x, ((pobj->det).p.p)[i].y, pbb, backptr, erp ); } } /* Line to last point */ x0 = ((pobj->det).p.p)[(pobj->det).p.n - (uint16_t)1U].x; y0 = ((pobj->det).p.p)[(pobj->det).p.n - (uint16_t)1U].y; #line 1160 "wxd2lout.ctr" if (0 != (pobj->af).type) { x1 = ((pobj->det).p.p)[(pobj->det).p.n - (uint16_t)2U].x; y1 = ((pobj->det).p.p)[(pobj->det).p.n - (uint16_t)2U].y; sl = sqrt((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0)); cl = (pobj->af).cut; nl = sl - cl; x0 = (x0 * nl + x1 * cl) / sl; y0 = (y0 * nl + y1 * cl) / sl; } #line 1170 "wxd2lout.ctr" dk4pppt_lineto(job->ppp, x0, y0, pbb, backptr, erp); #line 1172 "wxd2lout.ctr" } /** Create spline path for open spline with arrowheads. @param job Job structure. @param pobj Object to create path for. @param ts Start parameter t. @param te End parameter t. @param npmoveto Flag: Start new path and move to first point. @param fullseg Flag: This is a full segment. @param backptr Address of success variable to reset on error. @param pbb Bounding box for path, may be NULL. @param erp Error report, may be NULL. @param iscl Flag: Closed path. */ static void wxd2lout_spline_seg( wxd2lat_job_t *job, wxd_object_t *pobj, double ts, double te, int npmoveto, int fullseg, int *backptr, dk4_bb_t *pbb, dk4_er_t *erp ) { double v0[4]; /* Start of segment */ double v1[4]; /* End of segment */ dk4_xsp_2d_t xs; /* X-spline structure */ double diff; /* Parameter t difference start to end */ double coeff; /* Coefficient for derivatives */ double t; /* Current parameter t in range 0 to 1 */ unsigned nsubs; /* Number of sub segments */ unsigned i; /* Current sub segment */ int res; /* Step calculation result */ uint16_t ib; /* X-spline segment index */ #line 1213 "wxd2lout.ctr" ib = (uint16_t)floor(ts); wxd2lxs_set_xspline(&xs, pobj, ib); diff = te - ts; nsubs = (job->grco).xsss; if (0 != fullseg) { nsubs = (unsigned)ceil(fabs(diff * (double)nsubs)); if (0U == nsubs) { nsubs = 1U; } } coeff = diff / (3.0 * (double)nsubs); t = ts - (double)ib; res = dk4xsp2d_calculate_value_derivative(v0, &xs, t, erp); if (0 != res) { v0[1] *= coeff; v0[3] *= coeff; for (i = 0U; i < nsubs; i++) { if ((nsubs - 1U) == i) { t = te; } else { t = ts + ((diff * (double)(i + 1U)) / (double)nsubs); } t = t - (double)ib; res = dk4xsp2d_calculate_value_derivative(v1, &xs, t, erp); if (0 != res) { v1[1] *= coeff; v1[3] *= coeff; if ((0U == i) && (0 != npmoveto)) { dk4pppt_newpath_moveto( job->ppp, v0[0], v0[2], pbb, backptr, erp ); } dk4pppt_curveto( job->ppp, (v0[0]+v0[1]), (v0[2]+v0[3]), (v1[0]-v1[1]), (v1[2]-v1[3]), v1[0], v1[2], pbb, backptr, erp ); } else { #line 1248 "wxd2lout.ctr" *backptr = 0; /* ERROR: Calculation failed */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 39 ); } DK4_MEMCPY(v0,v1,sizeof(v0)); } } else { #line 1258 "wxd2lout.ctr" *backptr = 0; /* ERROR: Calculation failed */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 39 ); } #line 1265 "wxd2lout.ctr" } /** Create spline path for open spline with arrowheads. @param drw Drawing structure. @param job Job structure. @param pobj Object to create path for. @param backptr Address of success variable to reset on error. @param pbb Bounding box for path, may be NULL. @param erp Error report, may be NULL. @param iscl Flag: Closed path. */ static void wxd2lout_path_spline_with_arrows( wxd2lat_job_t *job, wxd_object_t *pobj, int *backptr, dk4_bb_t *pbb, dk4_er_t *erp ) { uint16_t ss; uint16_t se; uint16_t i; #line 1291 "wxd2lout.ctr" ss = (uint16_t)floor((pobj->det).s.ts); se = (uint16_t)floor((pobj->det).s.te); if (0 != (pobj->ab).type) { if (0 != (pobj->af).type) { if (se > ss) { wxd2lout_spline_seg( job, pobj, (pobj->det).s.ts, (double)(ss + 1), 1, 0, backptr, pbb, erp ); for (i = ss + 1; i < se; i++) { wxd2lout_spline_seg( job, pobj, (double)i, (double)(i + 1), 0, 1, backptr, pbb, erp ); } if ((pobj->det).s.te > floor((pobj->det).s.te)) { wxd2lout_spline_seg( job, pobj, (double)se, (pobj->det).s.te, 0, 0, backptr, pbb, erp ); } } else { wxd2lout_spline_seg( job, pobj, (pobj->det).s.ts, (pobj->det).s.te, 1, 0, backptr, pbb, erp ); } } else { wxd2lout_spline_seg( job, pobj, (pobj->det).s.ts, (double)(ss + 1), 1, 0, backptr, pbb, erp ); for (i = ss + 1; i < (pobj->det).s.n - 1; i++) { wxd2lout_spline_seg( job, pobj, (double)i, (double)(i + 1), 0, 1, backptr, pbb, erp ); } } } else { if (0 != (pobj->af).type) { for (i = 0; i < se; i++) { wxd2lout_spline_seg( job, pobj, (double)i, (double)(i + 1), ((0 == i) ? 1 : 0), 1, backptr, pbb, erp ); } if ((pobj->det).s.te > floor((pobj->det).s.te)) { wxd2lout_spline_seg( job, pobj, (double)se, (pobj->det).s.te, 0, 0, backptr, pbb, erp ); } } else { wxd2lout_path_spline_no_arrows(job, pobj, backptr, pbb, erp, 0); } } #line 1353 "wxd2lout.ctr" } /** Create arc path for open arcs with at least one arrowhead. @param drw Drawing structure. @param job Job structure. @param pobj Object to create path for. @param backptr Address of success variable to reset on error. @param pbb Bounding box for path, may be NULL. @param erp Error report, may be NULL. @param iscl Flag: Closed path. */ static void wxd2lout_path_arc_with_arrows( wxd_drawing_t *drw, wxd2lat_job_t *job, wxd_object_t *pobj, int *backptr, dk4_bb_t *pbb, dk4_er_t *erp, int iscl ) { double alpha; /* Start angle */ double beta; /* End angle */ double x1; /* X coordinate point 1 */ double y1; /* Y coordinate point 1 */ double x2; /* X coordinate point 2 */ double y2; /* Y coordinate point 2 */ double x3; /* X coordinate point 3 */ double y3; /* Y coordinate point 3 */ double sl; /* Segment length */ double cl; /* Cut length */ double nl; /* Non-cut length */ #line 1390 "wxd2lout.ctr" if (0 != (pobj->det).a.d) { alpha = (pobj->det).a.a; beta = (pobj->det).a.b; #line 1394 "wxd2lout.ctr" #line 1395 "wxd2lout.ctr" if (0 < (pobj->det).a.d) { #line 1396 "wxd2lout.ctr" if (0 != (pobj->ab).type) { #line 1398 "wxd2lout.ctr" alpha += (pobj->ab).cut / (pobj->det).a.r; #line 1400 "wxd2lout.ctr" } if (0 != (pobj->af).type) { #line 1403 "wxd2lout.ctr" beta -= (pobj->af).cut / (pobj->det).a.r; #line 1405 "wxd2lout.ctr" } } else { #line 1408 "wxd2lout.ctr" if (0 != (pobj->ab).type) { #line 1410 "wxd2lout.ctr" alpha -= (pobj->ab).cut / (pobj->det).a.r; #line 1412 "wxd2lout.ctr" } if (0 != (pobj->af).type) { #line 1415 "wxd2lout.ctr" beta += (pobj->af).cut / (pobj->det).a.r; #line 1417 "wxd2lout.ctr" } } wxd2lout_path_arc_angles( drw, job, pobj, alpha, beta, backptr, pbb, erp, iscl ); } else { /* Malformed arc as polygon, cut ends for arrows. */ x1 = wxd2lout_convert_x(drw, job, (double)((pobj->det).a.x1)); x2 = wxd2lout_convert_x(drw, job, (double)((pobj->det).a.x2)); x3 = wxd2lout_convert_x(drw, job, (double)((pobj->det).a.x3)); y1 = wxd2lout_convert_y(drw, job, (double)((pobj->det).a.y1)); y2 = wxd2lout_convert_y(drw, job, (double)((pobj->det).a.y2)); y3 = wxd2lout_convert_y(drw, job, (double)((pobj->det).a.y3)); if (0 != (pobj->ab).type) { sl = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); cl = (pobj->ab).cut; nl = sl - cl; x1 = (x1 * nl + x2 * cl) / sl; y1 = (y1 * nl + y2 * cl) / sl; } dk4pppt_newpath_moveto(job->ppp, x1, y1, pbb, backptr, erp); dk4pppt_lineto(job->ppp, x2, y2, pbb, backptr, erp); if (0 != (pobj->af).type) { sl = sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3)); cl = (pobj->af).cut; nl = sl - cl; x3 = (x3 * nl + x2 * cl) / sl; y3 = (y3 * nl + y2 * cl) / sl; } dk4pppt_lineto(job->ppp, x3, y3, pbb, backptr, erp); } #line 1451 "wxd2lout.ctr" } /** Create polyline or polygon path. @param job Job structure. @param pobj Object to create path for. @param backptr Address of success variable to reset on error. @param pbb Bounding box for path, may be NULL. @param erp Error report, may be NULL. @param iscl Flag: Closed path. */ static void wxd2lout_path_polyline( wxd2lat_job_t *job, wxd_object_t *pobj, int *backptr, dk4_bb_t *pbb, dk4_er_t *erp, int iscl ) { #line 1475 "wxd2lout.ctr" if ( (0 != iscl) || (((uint8_t)0U == pobj->af.type) && ((uint8_t)0U == pobj->ab.type)) ) { /* Closed polygon or polyline without arrows. */ wxd2lout_path_pl_no_arrows(job, pobj, backptr, pbb, erp, iscl); } else { /* Polyline with at least one arrow. */ wxd2lout_path_pl_with_arrows(job, pobj, backptr, pbb, erp); } #line 1489 "wxd2lout.ctr" } /** Create spline path. @param job Job structure. @param pobj Object to create path for. @param backptr Address of success variable to reset on error. @param pbb Bounding box for path, may be NULL. @param erp Error report, may be NULL. @param iscl Flag: Closed path. */ static void wxd2lout_path_spline( wxd2lat_job_t *job, wxd_object_t *pobj, int *backptr, dk4_bb_t *pbb, dk4_er_t *erp, int iscl ) { #line 1513 "wxd2lout.ctr" if ( (0 != iscl) || (((uint8_t)0U == pobj->af.type) && ((uint8_t)0U == pobj->ab.type)) ) { /* Closed spline or open spline without arrowheads. */ wxd2lout_path_spline_no_arrows(job, pobj, backptr, pbb, erp, iscl); } else { /* Open spline with at least one arrowhead. */ wxd2lout_path_spline_with_arrows(job, pobj, backptr, pbb, erp); } #line 1527 "wxd2lout.ctr" } /** Create arc path. @param drw Drawing structure. @param job Job structure. @param pobj Object to create path for. @param backptr Address of success variable to reset on error. @param pbb Bounding box for path, may be NULL. @param erp Error report, may be NULL. @param iscl Flag: Closed path. */ static void wxd2lout_path_arc( wxd_drawing_t *drw, wxd2lat_job_t *job, wxd_object_t *pobj, int *backptr, dk4_bb_t *pbb, dk4_er_t *erp, int iscl ) { #line 1553 "wxd2lout.ctr" if ( (0 != iscl) || (((uint8_t)0U == pobj->af.type) && ((uint8_t)0U == pobj->ab.type)) ) { /* Closed arc or open arc without arrowheads. */ wxd2lout_path_arc_no_arrows(drw,job,pobj,backptr,pbb,erp,iscl); } else { /* Open arc with at least one arrowhead. */ wxd2lout_path_arc_with_arrows(drw,job,pobj,backptr,pbb,erp,iscl); } #line 1567 "wxd2lout.ctr" } /** Create circle path. @param job Job structure. @param pobj Object to create path for. @param backptr Address of success variable to reset on error. @param pbb Bounding box for path, may be NULL. @param erp Error report, may be NULL. */ static void wxd2lout_path_circle( wxd2lat_job_t *job, wxd_object_t *pobj, int *backptr, dk4_bb_t *pbb, dk4_er_t *erp ) { #line 1589 "wxd2lout.ctr" #line 1590 "wxd2lout.ctr" #line 1591 "wxd2lout.ctr" #line 1592 "wxd2lout.ctr" dk4pppt_circle( job->ppp, (pobj->det).e.x, (pobj->det).e.y, (pobj->det).e.rx, pbb, backptr, erp ); #line 1598 "wxd2lout.ctr" } /** Create ellipse path. @param job Job structure. @param pobj Object to create path for. @param backptr Address of success variable to reset on error. @param pbb Bounding box for path, may be NULL. @param erp Error report, may be NULL. */ static void wxd2lout_path_ellipse( wxd2lat_job_t *job, wxd_object_t *pobj, int *backptr, dk4_bb_t *pbb, dk4_er_t *erp ) { #line 1620 "wxd2lout.ctr" dk4pppt_ellipse( job->ppp, (pobj->det).e.x, (pobj->det).e.y, (pobj->det).e.rx, (pobj->det).e.ry, (pobj->det).e.a, pbb, backptr, erp ); #line 1626 "wxd2lout.ctr" } /** Create box path. @param job Job structure. @param pobj Object to create path for. @param backptr Address of success variable to reset on error. @param pbb Bounding box for path, may be NULL. @param erp Error report, may be NULL. */ static void wxd2lout_path_box( wxd2lat_job_t *job, wxd_object_t *pobj, int *backptr, dk4_bb_t *pbb, dk4_er_t *erp ) { #line 1648 "wxd2lout.ctr" dk4pppt_rectangle( job->ppp, (pobj->det).b.xl, (pobj->det).b.xr, (pobj->det).b.yb, (pobj->det).b.yt, ((0.0 < (pobj->det).b.r) ? ((pobj->det).b.r) : (-1.0)), pbb, backptr, erp ); #line 1656 "wxd2lout.ctr" } /** Create dot path. @param job Job structure. @param pobj Object to create path for. @param backptr Address of success variable to reset on error. @param pbb Bounding box for path, may be NULL. @param erp Error report, may be NULL. */ static void wxd2lout_path_dot( wxd2lat_job_t *job, wxd_object_t *pobj, int *backptr, dk4_bb_t *pbb, dk4_er_t *erp ) { #line 1678 "wxd2lout.ctr" dk4pppt_circle( job->ppp, (pobj->det).d.x, (pobj->det).d.y, ((pobj->det).d.d / 2.0), pbb, backptr, erp ); #line 1683 "wxd2lout.ctr" } /** Create object path. @param drw Drawing structure. @param job Job structure. @param pobj Object to create path for. @param backptr Address of success variable to reset on error. @param pbb Bounding box for path, may be NULL. @param erp Error report, may be NULL. */ static void wxd2lout_object_path( wxd_drawing_t *drw, wxd2lat_job_t *job, wxd_object_t *pobj, int *backptr, dk4_bb_t *pbb, dk4_er_t *erp ) { #line 1708 "wxd2lout.ctr" switch (pobj->ot) { case WXD_OT_POLYLINE : { wxd2lout_path_polyline(job, pobj, backptr, pbb, erp, 0); } break; case WXD_OT_O_SPLINE : { wxd2lout_path_spline(job, pobj, backptr, pbb, erp, 0); } break; case WXD_OT_O_ARC : { wxd2lout_path_arc(drw, job, pobj, backptr, pbb, erp, 0); } break; case WXD_OT_POLYGON : { wxd2lout_path_polyline(job, pobj, backptr, pbb, erp, 1); } break; case WXD_OT_C_SPLINE : { wxd2lout_path_spline(job, pobj, backptr, pbb, erp, 1); } break; case WXD_OT_C_ARC : { wxd2lout_path_arc(drw, job, pobj, backptr, pbb, erp, 1); } break; case WXD_OT_CIRCLE : { wxd2lout_path_circle(job, pobj, backptr, pbb, erp); } break; case WXD_OT_ELLIPSE : { wxd2lout_path_ellipse(job, pobj, backptr, pbb, erp); } break; case WXD_OT_BOX : { wxd2lout_path_box(job, pobj, backptr, pbb, erp); } break; case WXD_OT_DOT_FILLED : { wxd2lout_path_dot(job, pobj, backptr, pbb, erp); } break; case WXD_OT_DOT_WHITE : { wxd2lout_path_dot(job, pobj, backptr, pbb, erp); } break; } #line 1744 "wxd2lout.ctr" } static dk4_text_align_h_t wxd2lout_h_text_align(uint8_t a) { dk4_text_align_h_t back = DK4_TEXT_ALIGN_H_LEFT; switch ((int)a) { case 1: { back = DK4_TEXT_ALIGN_H_CENTERED; } break; case 2: { back = DK4_TEXT_ALIGN_H_RIGHT; } break; } return back; } /** Create output for one text object. @param job Job structure containing the output structure. @param pobj Object to process. @return 1 on success, 0 on error. */ static int wxd2lout_text_object( wxd2lat_job_t *job, wxd_object_t *pobj ) { dkChar buf[2048]; dk4_er_t er; int back = 1; int res; dk4_gra_tf_t fonttype = DK4_GRA_TF_SIMILAR_SIZE; #line 1784 "wxd2lout.ctr" if (DK4_GRA_PURPOSE_DOCUMENT == (job->grco).purpose) { fonttype = DK4_GRA_TF_EXACT_SIZE; } dk4error_init(&er); res = dk4recode_c8_to_dk( buf, DK4_SIZEOF(buf,dkChar), dk4app_get_encoding(job->app), (pobj->det).t.t, DK4_ENCODING_UTF8, &er ); if (0 != res) { wxd2lout_fill_rgb(job, pobj, &back, &er); if (0 != back) { if (0x00 != (0x01 & ((pobj->det).t.fl))) { #line 1796 "wxd2lout.ctr" /* Special text */ fonttype = DK4_GRA_TF_NONE_NONE; dk4pppt_special_text( job->ppp, (pobj->det).t.x, (pobj->det).t.y, (pobj->det).t.a, (pobj->det).t.t, NULL, wxd2lout_h_text_align((pobj->det).t.al), DK4_TEXT_ALIGN_V_BASELINE, (int)((pobj->det).t.find), (double)((pobj->det).t.fsz), fonttype, 0, &back, &er ); } else { #line 1809 "wxd2lout.ctr" /* Normal text */ dk4pppt_simple_utf8_text( job->ppp, (pobj->det).t.x, (pobj->det).t.y, (pobj->det).t.a, (pobj->det).t.t, NULL, wxd2lout_h_text_align((pobj->det).t.al), DK4_TEXT_ALIGN_V_BASELINE, (int)((pobj->det).t.find), (double)((pobj->det).t.fsz), fonttype, job->uc2l, 0, &back, &er ); } if (0 == back) { #line 1821 "wxd2lout.ctr" /* ERROR: Failed to write text */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 40 ); } } else { #line 1828 "wxd2lout.ctr" /* ERROR: Failed to set fill colour */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 41 ); } } else { #line 1835 "wxd2lout.ctr" back = 0; /* ERROR: UTF-8 decoding failed */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 42 ); } #line 1842 "wxd2lout.ctr" return back; } /** Create output for one open path object probably with arrowheads attached. @param drw Original drawing. @param job Job structure containing the output structure. @param pobj Object to process. @return 1 on success, 0 on error. */ static int wxd2lout_open_path_object( wxd_drawing_t *drw, wxd2lat_job_t *job, wxd_object_t *pobj ) { dk4_er_t er; int myback; int back = 1; #line 1865 "wxd2lout.ctr" dk4error_init(&er); if (0.0 < pobj->lw) { wxd2lout_attributes_stroke(drw, job, pobj, &back, 1, &er); #line 1869 "wxd2lout.ctr" dk4pppt_prepare_stroke(job->ppp, &back, &er); #line 1871 "wxd2lout.ctr" wxd2lout_object_path(drw, job, pobj, &back, NULL, &er); #line 1873 "wxd2lout.ctr" dk4pppt_stroke(job->ppp, &back, &er); #line 1875 "wxd2lout.ctr" if (0 == back) { /* ERROR: Failed to create graphics object */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 43 ); } if ((uint8_t)0U != (pobj->af).type) { myback = 1; wxd2lah_arrowhead(&(pobj->af), drw, job, pobj, 0, &myback, &er); if (0 == myback) { back = 0; /* ERROR: Failed to create forward arrowhead */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 44 ); } #line 1892 "wxd2lout.ctr" } if ((uint8_t)0U != (pobj->ab).type) { myback = 1; wxd2lah_arrowhead(&(pobj->ab), drw, job, pobj, 1, &myback, &er); if (0 == myback) { back = 0; /* ERROR: Failed to create backward arrowhead */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 45 ); } #line 1904 "wxd2lout.ctr" } } else { #line 1907 "wxd2lout.ctr" /* Object skipped */ /* INFO: Skipping object due to non-positive line-width */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_INFO, 46 ); } #line 1914 "wxd2lout.ctr" return back; } /** Create output for one closed path object, probably filled or pattern filled. @param drw Original drawing. @param job Job structure containing the output structure. @param pobj Object to process. @return 1 on success, 0 on error. */ static int wxd2lout_closed_path_object( wxd_drawing_t *drw, wxd2lat_job_t *job, wxd_object_t *pobj ) { dk4_bb_t pbb; dk4_er_t er; int back = 1; int must_stroke = 0; int must_fill = 0; int must_pattern = 0; int combined = 0; #line 1941 "wxd2lout.ctr" dk4bb_init(&pbb); dk4error_init(&er); if (0.0 < pobj->lw) { must_stroke = 1; } if ((uint8_t)(WXD_FS_NONE) != pobj->csfs) { must_fill = 1; } if ((uint8_t)(WXD_FS_PURE) < pobj->csfs) { must_pattern = 1; } if ((0 != must_stroke) && (0 != must_fill)) { if (0 != dk4pppt_can_fill_and_stroke(job->ppp)) { combined = 1; } } if (0 != combined) { #line 1958 "wxd2lout.ctr" wxd2lout_attributes_fill(job, pobj, &back, &er); #line 1960 "wxd2lout.ctr" wxd2lout_attributes_stroke(drw, job, pobj, &back, 0, &er); #line 1962 "wxd2lout.ctr" dk4pppt_prepare_fill_and_stroke(job->ppp, &back, &er); #line 1964 "wxd2lout.ctr" wxd2lout_object_path(drw, job, pobj, &back, NULL, &er); #line 1966 "wxd2lout.ctr" dk4pppt_fill_and_stroke(job->ppp, &back, &er); #line 1968 "wxd2lout.ctr" if (0 != must_pattern) { dk4pppt_gsave(job->ppp, &back, &er); #line 1971 "wxd2lout.ctr" wxd2lout_object_path(drw, job, pobj, &back, &pbb, &er); #line 1973 "wxd2lout.ctr" dk4pppt_clip(job->ppp, &back, &er); #line 1975 "wxd2lout.ctr" dk4pppt_pattern( job->ppp, pbb.xmin, pbb.xmax, pbb.ymin, pbb.ymax, wxd2lout_find_pattern(pobj), &back, &er ); #line 1980 "wxd2lout.ctr" dk4pppt_grestore(job->ppp, &back, &er); #line 1982 "wxd2lout.ctr" } } else { #line 1985 "wxd2lout.ctr" if (0 != must_fill) { #line 1986 "wxd2lout.ctr" wxd2lout_attributes_fill(job, pobj, &back, &er); #line 1988 "wxd2lout.ctr" dk4pppt_prepare_fill(job->ppp, &back, &er); #line 1990 "wxd2lout.ctr" wxd2lout_object_path(drw, job, pobj, &back, NULL, &er); #line 1992 "wxd2lout.ctr" dk4pppt_fill(job->ppp, &back, &er); #line 1994 "wxd2lout.ctr" } if (0 != must_pattern) { #line 1996 "wxd2lout.ctr" dk4pppt_gsave(job->ppp, &back, &er); #line 1998 "wxd2lout.ctr" wxd2lout_object_path(drw, job, pobj, &back, &pbb, &er); #line 2000 "wxd2lout.ctr" dk4pppt_clip(job->ppp, &back, &er); #line 2002 "wxd2lout.ctr" dk4pppt_pattern( job->ppp, pbb.xmin, pbb.xmax, pbb.ymin, pbb.ymax, wxd2lout_find_pattern(pobj), &back, &er ); #line 2007 "wxd2lout.ctr" dk4pppt_grestore(job->ppp, &back, &er); #line 2009 "wxd2lout.ctr" } if (0 != must_stroke) { #line 2011 "wxd2lout.ctr" wxd2lout_attributes_stroke(drw, job, pobj, &back, 0, &er); #line 2013 "wxd2lout.ctr" dk4pppt_prepare_stroke(job->ppp, &back, &er); #line 2015 "wxd2lout.ctr" wxd2lout_object_path(drw, job, pobj, &back, NULL, &er); #line 2017 "wxd2lout.ctr" dk4pppt_stroke(job->ppp, &back, &er); #line 2019 "wxd2lout.ctr" } } if (0 == back) { /* ERROR: Failed to create graphics object */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 43 ); } #line 2028 "wxd2lout.ctr" return back; } /** Create output for one dot object. @param drw Original drawing. @param job Job structure containing the output structure. @param pobj Object to process. @return 1 on success, 0 on error. */ static int wxd2lout_dot_object( wxd_drawing_t *drw, wxd2lat_job_t *job, wxd_object_t *pobj ) { dk4_er_t er; double lw; int back = 1; #line 2051 "wxd2lout.ctr" dk4error_init(&er); #line 2053 "wxd2lout.ctr" switch (pobj->ot) { case WXD_OT_DOT_FILLED : { #line 2055 "wxd2lout.ctr" wxd2lout_attributes_fill(job, pobj, &back, &er); if (1 == back) { dk4pppt_prepare_fill(job->ppp, &back, &er); if (1 == back) { dk4pppt_circle( job->ppp, (pobj->det).d.x, (pobj->det).d.y, ((pobj->det).d.d / 2.0), NULL, &back, &er ); dk4pppt_fill(job->ppp, &back, &er); if (0 == back) { #line 2065 "wxd2lout.ctr" /* ERROR: Failed to create filled circle */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 47 ); } } else { #line 2072 "wxd2lout.ctr" /* ERROR: Failed to set up filling */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 48 ); } } else { #line 2079 "wxd2lout.ctr" /* ERROR: Failed to set up filling */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 48 ); } } break; case WXD_OT_DOT_WHITE : { #line 2086 "wxd2lout.ctr" lw = wxd2lat_object_linewidth(pobj, drw, job); if (lw >= (pobj->det).d.d) { dk4pppt_set_fill_rgb( job->ppp, (((double)(pobj->sc[0])) / 255.0), (((double)(pobj->sc[1])) / 255.0), (((double)(pobj->sc[2])) / 255.0), &back, &er ); dk4pppt_prepare_fill(job->ppp, &back, &er); dk4pppt_circle( job->ppp, (pobj->det).d.x, (pobj->det).d.y, ((lw + (pobj->det).d.d) / 2.0), NULL, &back, &er ); dk4pppt_fill(job->ppp, &back, &er); } else { if (0 != dk4pppt_can_fill_and_stroke(job->ppp)) { #line 2104 "wxd2lout.ctr" wxd2lout_attributes_fill(job, pobj, &back, &er); wxd2lout_attributes_stroke(drw, job, pobj, &back, 0, &er); dk4pppt_prepare_fill_and_stroke(job->ppp, &back, &er); if (1 == back) { dk4pppt_circle( job->ppp, (pobj->det).d.x, (pobj->det).d.y, ((pobj->det).d.d / 2.0), NULL, &back, &er ); dk4pppt_fill_and_stroke(job->ppp, &back, &er); if (0 == back) { #line 2114 "wxd2lout.ctr" /* ERROR: Failed to create filled circle */ dk4app_log_1( job->app,job->msg,job->sz_msg,DK4_LL_ERROR,47 ); } } else { #line 2122 "wxd2lout.ctr" /* ERROR: Failed to set up fill and stroke */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 49 ); } } else { #line 2129 "wxd2lout.ctr" wxd2lout_attributes_fill(job, pobj, &back, &er); dk4pppt_prepare_fill(job->ppp, &back, &er); if (0 != back) { dk4pppt_circle( job->ppp, (pobj->det).d.x, (pobj->det).d.y, ((pobj->det).d.d / 2.0), NULL, &back, &er ); dk4pppt_fill(job->ppp, &back, &er); if (0 != back) { wxd2lout_attributes_stroke( drw, job, pobj, &back, 0, &er ); dk4pppt_prepare_stroke(job->ppp, &back, &er); if (0 != back) { dk4pppt_circle( job->ppp, (pobj->det).d.x, (pobj->det).d.y, ((pobj->det).d.d / 2.0), NULL, &back, &er ); dk4pppt_stroke(job->ppp, &back, &er); if (0 == back) { #line 2149 "wxd2lout.ctr" /* ERROR: Failed to stroke circle */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 36 ); } } else { #line 2158 "wxd2lout.ctr" /* ERROR: Failed to set up stroke */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 51 ); } } else { #line 2166 "wxd2lout.ctr" /* Failed to create filled circle */ dk4app_log_1( job->app,job->msg,job->sz_msg,DK4_LL_ERROR,47 ); } } else { #line 2173 "wxd2lout.ctr" /* ERROR: Failed to set up fill */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 48 ); } } } } break; } #line 2183 "wxd2lout.ctr" return back; } /** Create output for one image object. @param job Job structure containing the output structure. @param pobj Object to process. @return 1 on success, 0 on error. */ static int wxd2lout_image_object( wxd2lat_job_t *job, wxd_object_t *pobj ) { dkChar fnb[DK4_MAX_PATH]; /* File name buffer */ dk4_px_t bg[4]; /* Background colour */ dk4_cs_conv_ctx_t ctx; /* RGB to gray conv context */ dk4_er_t er; /* Error report */ dk4_bif_t *pbif = NULL; /* Bitmap image */ int back = 1; /* Function result */ int ifl = 0; /* Image flags */ int fbg = 0; /* Flag: Force background */ int res = 0; /* Step result */ #line 2210 "wxd2lout.ctr" DK4_MEMCPY(&ctx,&((job->grco).ctx),sizeof(dk4_cs_conv_ctx_t)); bg[0] = (dk4_px_t)(pobj->fc[0]); bg[1] = (dk4_px_t)(pobj->fc[1]); bg[2] = (dk4_px_t)(pobj->fc[2]); if (DK4_CS_CONV_RGB_TO_GRAY_MIN <= (pobj->det).i.r2g) { if (DK4_CS_CONV_RGB_TO_GRAY_MAX >= (pobj->det).i.r2g) { ctx.rgb_to_gray = (dk4_cs_conv_rgb_to_gray_t)((pobj->det).i.r2g); } } if (0x00 != (0x20 & ((pobj->det).i.fl))) { fbg = 1; } if (0x00 != (0x02 & ((pobj->det).i.fl))) { /* Alpha mix */ ctx.alpha = DK4_CS_CONV_ALPHA_MIX; } else { /* Alpha ignore */ ctx.alpha = DK4_CS_CONV_ALPHA_FOREGROUND; } if (0 != (job->grco).color) { ifl |= DK4_GRA_IMG_FLAG_COLOR; } if (0 != (job->grco).ps_lzw) { ifl |= DK4_GRA_IMG_FLAG_LZW; } if (0x00 != (0x08 & ((pobj->det).i.fl))) { ifl |= DK4_GRA_IMG_FLAG_DCT; } if (0x00 != (0x04 & ((pobj->det).i.fl))) { ifl |= DK4_GRA_IMG_FLAG_INTERPOLATION; } if (0x00 != (0x10 & ((pobj->det).i.fl))) { ifl |= DK4_GRA_IMG_FLAG_DCT_INTERPOLATION; } ifl |= DK4_GRA_IMG_FLAG_ANALYZE_BPC; ifl |= DK4_GRA_IMG_FLAG_ANALYZE_COLOR; ifl |= DK4_GRA_IMG_FLAG_ANALYZE_ALPHA; if (0x00 == (0x01 & ((pobj->det).i.fl))) { ifl |= DK4_GRA_IMG_FLAG_IGNORE_ASPECT_RATIO; } res = dk4recode_c8_to_dk( fnb, DK4_SIZEOF(fnb,dkChar), dk4app_get_encoding(job->app), (pobj->det).i.fn, DK4_ENCODING_UTF8, &er ); if (0 != res) { if (0 <= dk4bif_type_for_suffix(fnb)) { pbif = dk4bif_open_app(fnb, 0, &ctx, job->app); if (NULL != pbif) { dk4error_init(&er); dk4bif_set_background(pbif, bg, 3, 8, fbg); dk4pppt_bif_image( job->ppp, (pobj->det).i.x, ((pobj->det).i.x + (pobj->det).i.w), (pobj->det).i.y, ((pobj->det).i.y + (pobj->det).i.h), pbif, fnb, (size_t)0U, ifl, NULL, &back, &er ); dk4bif_close(pbif); if (0 == back) { #line 2270 "wxd2lout.ctr" /* ERROR: Failed to add bitmap image */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 52 ); } } else { #line 2277 "wxd2lout.ctr" back = 0; /* ERROR: Failed to open file */ } } else { #line 2282 "wxd2lout.ctr" back = 0; /* ERROR: Not a supported bitmap type */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 53 ); } } else { #line 2290 "wxd2lout.ctr" back = 0; /* ERROR: Failed to decode file name! */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 54 ); } #line 2297 "wxd2lout.ctr" return back; } /** Check one text object if information is complete and object can be drawn. @param job Job structure. @param pobj Object to check. @return 1 on success (further handling possible), 0 otherwise. */ static int wxd2lout_check_one_text_object( wxd2lat_job_t *job, wxd_object_t *pobj ) { int back = 0; #line 2317 "wxd2lout.ctr" if (NULL != (pobj->det).t.t) { if ((uint16_t)0U != (pobj->det).t.fsz) { back = 1; } else { if ((uint8_t)0x00 != ((uint8_t)0x01 & (pobj->det).t.fl)) { back = 1; } else { #line 2326 "wxd2lout.ctr" /* ERROR: Font size 0 */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 55 ); } } } else { #line 2334 "wxd2lout.ctr" /* ERROR: No text on object */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 56 ); } #line 2340 "wxd2lout.ctr" return back; } /** Check one polyline/polygon object if information is complete and object can be drawn. @param job Job structure. @param pobj Object to check. @return 1 on success (further handling possible), 0 otherwise. */ static int wxd2lout_check_one_polyline_object( wxd2lat_job_t *job, wxd_object_t *pobj ) { double x0; /* Coordinate of first point */ double y0; /* Coordinate of first point */ double x1; /* Coordinate of second point */ double y1; /* Coordinate of second point */ double lseg; /* Segment length */ size_t lp; /* Index of last point */ int back = 0; #line 2366 "wxd2lout.ctr" if (NULL != (pobj->det).p.p) { if ((uint16_t)1U < (pobj->det).p.n) { back = 1; /* For polyline check whether first and last segment are long enough for arrowhead cuts. */ if (WXD_OT_POLYLINE == pobj->ot) { lseg = 0.0; if (0 != (pobj->ab).type) { x0 = ((pobj->det).p.p)[0].x; x1 = ((pobj->det).p.p)[1].x; y0 = ((pobj->det).p.p)[0].y; y1 = ((pobj->det).p.p)[1].y; x1 = x1 - x0; y1 = y1 - y0; lseg = sqrt(x1 * x1 + y1 * y1); if (lseg <= (pobj->ab).cut) { back = 0; #line 2385 "wxd2lout.ctr" /* ERROR: First segment too short */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 57 ); } } if (0 != (pobj->af).type) { lp = (pobj->det).p.n - 1; x0 = ((pobj->det).p.p)[lp].x; x1 = ((pobj->det).p.p)[lp - 1].x; y0 = ((pobj->det).p.p)[lp].y; y1 = ((pobj->det).p.p)[lp - 1].y; x1 = x1 - x0; y1 = y1 - y0; /* Just one segment or multiple segments? */ if ((uint16_t)2U == (pobj->det).p.n) { /* If the polyline has just one segment (only 2 points) the cuts for forward and backward arrow are both applied to the same segment. So the segment must be longer than the summary of the two cuts. */ lseg += sqrt(x1 * x1 + y1 * y1); } else { /* Polyline has more than one segments, the final segment is cutted for the forward arrowhead only. */ lseg = sqrt(x1 * x1 + y1 * y1); } if (lseg <= (pobj->af).cut) { back = 0; #line 2421 "wxd2lout.ctr" /* ERROR: Last segment too short */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 58 ); } } } } else { #line 2430 "wxd2lout.ctr" /* ERROR: Too few points */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 59 ); } } else { #line 2437 "wxd2lout.ctr" /* ERROR: No points for object */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 60 ); } #line 2443 "wxd2lout.ctr" return back; } /** Check one spline object if information is complete and object can be drawn. @param drw Drawing structure. @param job Job structure. @param pobj Object to check. @return 1 on success (further handling possible), 0 otherwise. */ static int wxd2lout_check_one_spline_object( wxd_drawing_t *drw, wxd2lat_job_t *job, wxd_object_t *pobj ) { double cutl; /* Length to cut, length of arrowhead */ int back = 0; #line 2465 "wxd2lout.ctr" if (NULL != (pobj->det).s.p) { if ((uint16_t)1U < (pobj->det).s.n) { back = 1; /* For open spline object check whether spline is long enough for arrowhead cuts. */ if (WXD_OT_O_SPLINE == pobj->ot) { if ( (0 != (pobj->af).type) || (0 != (pobj->ab).type) ) { cutl = 0.0; if (0 != (pobj->af).type) { cutl += ((pobj->af).cut + (pobj->af).cuttol); } if (0 != (pobj->ab).type) { cutl += ((pobj->ab).cut + (pobj->ab).cuttol); } if (cutl >= (pobj->det).s.suml) { back = 0; #line 2486 "wxd2lout.ctr" /* ERROR: Spline too short */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 61 ); } if (0 != (pobj->af).type) { cutl = (pobj->af).offset + (double)((pobj->af).length) * wxd2lat_object_linewidth(pobj, drw, job); if (cutl >= (pobj->det).s.suml) { back = 0; #line 2497 "wxd2lout.ctr" /* ERROR: Forward arrow too long */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 62 ); } } if (0 != (pobj->ab).type) { cutl = (pobj->ab).offset + (double)((pobj->ab).length) * wxd2lat_object_linewidth(pobj, drw, job); if (cutl >= (pobj->det).s.suml) { back = 0; #line 2510 "wxd2lout.ctr" /* ERROR: Backward arrow too long */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 63 ); } } } } } else { #line 2521 "wxd2lout.ctr" /* ERROR: Too few points */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 59 ); } } else { #line 2528 "wxd2lout.ctr" /* ERROR: No points for object */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 60 ); } #line 2534 "wxd2lout.ctr" return back; } /** Check one arc object if information is complete and object can be drawn. @param drw Drawing structure. @param job Job structure. @param pobj Object to check. @return 1 on success (further handling possible), 0 otherwise. */ static int wxd2lout_check_one_arc_object( wxd_drawing_t *drw, wxd2lat_job_t *job, wxd_object_t *pobj ) { double x0; /* Coordinate of first point */ double y0; /* Coordinate of first point */ double x1; /* Coordinate of second point */ double y1; /* Coordinate of second point */ double cutl; /* Length to cut, length of arrowhead */ double lseg; /* Segment length */ int back = 0; #line 2563 "wxd2lout.ctr" /* For open arc object check whether arc is long enough for arrowhead cuts. For malformed arc check whether segments are long enough for the arrowhead cuts. */ back = 1; if (WXD_OT_O_ARC == pobj->ot) { if ((0 != (pobj->af).type) || (0 != (pobj->ab).type)) { if (0 != (pobj->det).a.d) { /* Real arc */ lseg = fabs( (pobj->det).a.r * ((pobj->det).a.b - (pobj->det).a.a) ); cutl = 0.0; if (0 != (pobj->af).type) { cutl = (pobj->af).cut; } if (0 != (pobj->ab).type) { cutl += (pobj->ab).cut; } if (cutl > lseg) { back = 0; /* ERROR: Arc too short for arrows */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 64 ); } if (0 != (pobj->af).type) { cutl = (pobj->af).offset + (double)((pobj->af).length) * wxd2lat_object_linewidth(pobj, drw, job); if (cutl > lseg) { back = 0; /* ERROR: Forward arrow too long */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 62 ); } } if (0 != (pobj->ab).type) { cutl = (pobj->ab).offset + (double)((pobj->ab).length) * wxd2lat_object_linewidth(pobj, drw, job); if (cutl > lseg) { back = 0; /* ERROR: Backward arrow too long */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 63 ); } } } else { /* Malformed arc drawn as polyline */ if (0 != (pobj->af).type) { x0 = wxd2lout_convert_x(drw,job,(double)((pobj->det).a.x2)); y0 = wxd2lout_convert_y(drw,job,(double)((pobj->det).a.y2)); x1 = wxd2lout_convert_x(drw,job,(double)((pobj->det).a.x3)); y1 = wxd2lout_convert_y(drw,job,(double)((pobj->det).a.y3)); x1 = x1 - x0; y1 = y1 - y0; lseg = sqrt(x1 * x1 + y1 * y1); if (lseg <= (pobj->af).cut) { back = 0; /* ERROR: Forward arrow too long */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 62 ); } } if (0 != (pobj->ab).type) { x0 = wxd2lout_convert_x(drw,job,(double)((pobj->det).a.x2)); y0 = wxd2lout_convert_y(drw,job,(double)((pobj->det).a.y2)); x1 = wxd2lout_convert_x(drw,job,(double)((pobj->det).a.x1)); y1 = wxd2lout_convert_y(drw,job,(double)((pobj->det).a.y1)); x1 = x1 - x0; y1 = y1 - y0; lseg = sqrt(x1 * x1 + y1 * y1); if (lseg <= (pobj->ab).cut) { back = 0; /* ERROR: Backward arrow too long */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 63 ); } } } } } #line 2658 "wxd2lout.ctr" return back; } /** Check one circle object if information is complete and object can be drawn. @param job Job structure. @param pobj Object to check. @return 1 on success (further handling possible), 0 otherwise. */ static int wxd2lout_check_one_circle_object( wxd2lat_job_t *job, wxd_object_t *pobj ) { int back = 0; #line 2678 "wxd2lout.ctr" if (0.0 < (pobj->det).e.rx) { back = 1; } else { #line 2682 "wxd2lout.ctr" /* ERROR: Radius 0 */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 65 ); } #line 2688 "wxd2lout.ctr" return back; } /** Check one ellipse object if information is complete and object can be drawn. @param job Job structure. @param pobj Object to check. @return 1 on success (further handling possible), 0 otherwise. */ static int wxd2lout_check_one_ellipse_object( wxd2lat_job_t *job, wxd_object_t *pobj ) { int back = 0; #line 2708 "wxd2lout.ctr" if ((0.0 < (pobj->det).e.rx) && (0.0 < (pobj->det).e.ry)) { back = 1; } else { #line 2712 "wxd2lout.ctr" /* ERROR: Radius 0 */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 65 ); } #line 2718 "wxd2lout.ctr" return back; } /** Check one box object if information is complete and object can be drawn. @param job Job structure. @param pobj Object to check. @return 1 on success (further handling possible), 0 otherwise. */ static int wxd2lout_check_one_box_object( wxd2lat_job_t *job, wxd_object_t *pobj ) { double w; double h; int back = 1; #line 2740 "wxd2lout.ctr" w = fabs((pobj->det).b.xr - (pobj->det).b.xl); h = fabs((pobj->det).b.yt - (pobj->det).b.yb); if (h < w) { w = h; } if ((pobj->det).b.r > (w / 2.0)) { back = 0; /* ERROR: Box radius too large */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 66 ); } #line 2753 "wxd2lout.ctr" return back; } /** Check one dot object if information is complete and object can be drawn. @param job Job structure. @param pobj Object to check. @return 1 on success (further handling possible), 0 otherwise. */ static int wxd2lout_check_one_dot_object( wxd2lat_job_t *job, wxd_object_t *pobj ) { int back = 0; #line 2773 "wxd2lout.ctr" if (0.0 < (pobj->det).d.d) { back = 1; } else { #line 2777 "wxd2lout.ctr" /* ERROR: Diameter 0 */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 67 ); } #line 2783 "wxd2lout.ctr" return back; } /** Check one image object if information is complete and object can be drawn. @param job Job structure. @param pobj Object to check. @return 1 on success (further handling possible), 0 otherwise. */ static int wxd2lout_check_one_image_object( wxd2lat_job_t *job, wxd_object_t *pobj ) { int back = 0; #line 2803 "wxd2lout.ctr" if (NULL != (pobj->det).i.fn) { if ((0.0 < (pobj->det).i.w) && (0.0 < (pobj->det).i.h)) { back = 1; } else { #line 2808 "wxd2lout.ctr" /* ERROR: Width and height must be positive */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 68 ); } } else { #line 2815 "wxd2lout.ctr" /* ERROR: No file name */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 69 ); } #line 2821 "wxd2lout.ctr" return back; } /** Check one graphics object if information is complete and object can be drawn. @param drw Drawing structure. @param job Job structure. @param pobj Object to check. @return 1 on success (further handling possible), 0 otherwise. */ static int wxd2lout_check_one_graphics_object( wxd_drawing_t *drw, wxd2lat_job_t *job, wxd_object_t *pobj ) { int back = 0; #line 2843 "wxd2lout.ctr" switch (pobj->ot) { case WXD_OT_TEXT : { back = wxd2lout_check_one_text_object(job, pobj); } break; case WXD_OT_POLYLINE : case WXD_OT_POLYGON : { back = wxd2lout_check_one_polyline_object(job, pobj); } break; case WXD_OT_O_SPLINE : case WXD_OT_C_SPLINE : { back = wxd2lout_check_one_spline_object(drw, job, pobj); } break; case WXD_OT_O_ARC : case WXD_OT_C_ARC : { back = wxd2lout_check_one_arc_object(drw, job, pobj); } break; case WXD_OT_CIRCLE : { back = wxd2lout_check_one_circle_object(job, pobj); } break; case WXD_OT_ELLIPSE : { back = wxd2lout_check_one_ellipse_object(job, pobj); } break; case WXD_OT_BOX : { back = wxd2lout_check_one_box_object(job, pobj); } break; case WXD_OT_DOT_FILLED : case WXD_OT_DOT_WHITE : { back = wxd2lout_check_one_dot_object(job, pobj); } break; case WXD_OT_IMAGE : { back = wxd2lout_check_one_image_object(job, pobj); } break; default : { #line 2872 "wxd2lout.ctr" /* ERROR: Illegal object type */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 70 ); } break; } if (0 == back) { /* ERROR: Object check failed */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 71 ); } #line 2885 "wxd2lout.ctr" return back; } static int wxd2lout_is_abnormal_circle( wxd_drawing_t *drw, wxd2lat_job_t *job, wxd_object_t *pobj ) { double lw; int back = 0; #line 2901 "wxd2lout.ctr" lw = wxd2lat_object_linewidth(pobj, drw, job); if ((pobj->det).e.rx <= (lw / 2.0)) { back = 1; } #line 2906 "wxd2lout.ctr" return back; } /** Check whether circle is abnormal (diameter smaller than line width). @param drw Drawing structure. @param job Job structure. @param pobj Object to check. @return 1 for abnormal circle, 0 for normal circle. */ static int wxd2lout_abnormal_circle( wxd_drawing_t *drw, wxd2lat_job_t *job, wxd_object_t *pobj ) { dk4_er_t er; double lw; int back = 1; #line 2929 "wxd2lout.ctr" lw = wxd2lat_object_linewidth(pobj, drw, job); dk4error_init(&er); dk4pppt_set_fill_rgb( job->ppp, (((double)(pobj->sc[0])) / 255.0), (((double)(pobj->sc[1])) / 255.0), (((double)(pobj->sc[2])) / 255.0), &back, &er ); dk4pppt_prepare_fill(job->ppp, &back, &er); dk4pppt_circle( job->ppp, (pobj->det).e.x, (pobj->det).e.y, ((pobj->det).e.rx + lw / 2.0), NULL, &back, &er ); dk4pppt_fill(job->ppp, &back, &er); #line 2945 "wxd2lout.ctr" return back; } /** Draw abnormal stroked circle as filled circle. @param drw Drawing structure. @param job Job structure. @param pobj Circle object to draw. @return 1 on success, 0 on error. */ static int wxd2lout_is_abnormal_ellipse( wxd_drawing_t *drw, wxd2lat_job_t *job, wxd_object_t *pobj ) { double lw; int back = 0; #line 2967 "wxd2lout.ctr" lw = wxd2lat_object_linewidth(pobj, drw, job) / 2.0; if (((pobj->det).e.rx <= lw) || ((pobj->det).e.ry <= lw)) { back = 1; } #line 2972 "wxd2lout.ctr" return back; } /** Check whether ellipse is abnormal (one diameter smaller than line width). @param drw Drawing structure. @param job Job structure. @param pobj Ellipse object to check. @return 1 for abnormal ellipse, 0 for normal ellipse. */ static int wxd2lout_abnormal_ellipse( wxd_drawing_t *drw, wxd2lat_job_t *job, wxd_object_t *pobj ) { dk4_er_t er; double lw; int back = 1; #line 2995 "wxd2lout.ctr" lw = wxd2lat_object_linewidth(pobj, drw, job); dk4error_init(&er); dk4pppt_set_fill_rgb( job->ppp, (((double)(pobj->sc[0])) / 255.0), (((double)(pobj->sc[1])) / 255.0), (((double)(pobj->sc[2])) / 255.0), &back, &er ); dk4pppt_prepare_fill(job->ppp, &back, &er); dk4pppt_ellipse( job->ppp, (pobj->det).e.x, (pobj->det).e.y, ((pobj->det).e.rx + lw / 2.0), ((pobj->det).e.ry + lw / 2.0), (pobj->det).e.a, NULL, &back, &er ); dk4pppt_fill(job->ppp, &back, &er); #line 3012 "wxd2lout.ctr" return back; } static int wxd2lout_is_abnormal_box( wxd_drawing_t *drw, wxd2lat_job_t *job, wxd_object_t *pobj ) { double lw; int back = 0; #line 3028 "wxd2lout.ctr" lw = wxd2lat_object_linewidth(pobj, drw, job); if ( (lw >= fabs((pobj->det).b.xr - (pobj->det).b.xl)) || (lw >= fabs((pobj->det).b.yt - (pobj->det).b.yb)) ) { back = 1; } #line 3036 "wxd2lout.ctr" return back; } static int wxd2lout_abnormal_box( wxd_drawing_t *drw, wxd2lat_job_t *job, wxd_object_t *pobj ) { dk4_er_t er; double lw; double xl; double xr; double yt; double yb; double ra; double dx; double dy; int back = 1; #line 3060 "wxd2lout.ctr" lw = wxd2lat_object_linewidth(pobj, drw, job) / 2.0; dk4error_init(&er); dk4pppt_set_fill_rgb( job->ppp, (((double)(pobj->sc[0])) / 255.0), (((double)(pobj->sc[1])) / 255.0), (((double)(pobj->sc[2])) / 255.0), &back, &er ); #line 3070 "wxd2lout.ctr" dk4pppt_prepare_fill(job->ppp, &back, &er); #line 3072 "wxd2lout.ctr" if ((pobj->det).b.xr >= (pobj->det).b.xl) { xl = (pobj->det).b.xl - lw; xr = (pobj->det).b.xr + lw; } else { xl = (pobj->det).b.xr - lw; xr = (pobj->det).b.xl + lw; } if ((pobj->det).b.yt >= (pobj->det).b.yb) { yb = (pobj->det).b.yb - lw; yt = (pobj->det).b.yt + lw; } else { yb = (pobj->det).b.yt - lw; yt = (pobj->det).b.yb + lw; } if (0.0 < (pobj->det).b.r) { ra = (pobj->det).b.r + lw; dx = fabs(xr - xl); dy = fabs(yb - yt); if (dy < dx) { dx = dy; } dx *= 0.4998; if (dx < ra) { ra = dx; } } else { ra = -1.0; } dk4pppt_rectangle(job->ppp, xl, xr, yb, yt, ra, NULL, &back, &er); #line 3103 "wxd2lout.ctr" dk4pppt_fill(job->ppp, &back, &er); #line 3105 "wxd2lout.ctr" return back; } /** Draw one graphics object. @param drw Drawing structure. @param job Job structure. @param pobj Graphics object to draw. @return 1 on success, 0 on error. */ static int wxd2lout_one_graphics_object( wxd_drawing_t *drw, wxd2lat_job_t *job, wxd_object_t *pobj ) { int back = 1; #line 3128 "wxd2lout.ctr" if (0 != wxd2lout_check_one_graphics_object(drw, job, pobj)) { switch (pobj->ot) { case WXD_OT_TEXT : { back = wxd2lout_text_object(job, pobj); } break; case WXD_OT_POLYLINE : case WXD_OT_O_SPLINE : case WXD_OT_O_ARC : { back = wxd2lout_open_path_object(drw, job, pobj); } break; case WXD_OT_POLYGON : case WXD_OT_C_SPLINE : case WXD_OT_C_ARC : { back = wxd2lout_closed_path_object(drw, job, pobj); } break; case WXD_OT_CIRCLE : { if (0 != wxd2lout_is_abnormal_circle(drw, job, pobj)) { back = wxd2lout_abnormal_circle(drw, job, pobj); } else { back = wxd2lout_closed_path_object(drw, job, pobj); } } break; case WXD_OT_ELLIPSE : { if (0 != wxd2lout_is_abnormal_ellipse(drw, job, pobj)) { back = wxd2lout_abnormal_ellipse(drw, job, pobj); } else { back = wxd2lout_closed_path_object(drw, job, pobj); } } break; case WXD_OT_BOX : { if (0 != wxd2lout_is_abnormal_box(drw, job, pobj)) { back = wxd2lout_abnormal_box(drw, job, pobj); } else { back = wxd2lout_closed_path_object(drw, job, pobj); } } break; case WXD_OT_DOT_FILLED : case WXD_OT_DOT_WHITE : { #line 3165 "wxd2lout.ctr" back = wxd2lout_dot_object(drw, job, pobj); } break; case WXD_OT_IMAGE : { back = wxd2lout_image_object(job, pobj); } break; } if (0 == back) { /* ERROR: Failed to write graphics object */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 72 ); } } else { back = 0; } #line 3182 "wxd2lout.ctr" return back; } /** Create output for all graphics objects in a drawing. @param drw Original drawing. @param job Job structure containing the output structure. @return 1 on success, 0 on error. */ static int wxd2lout_all_graphics_objects( wxd_drawing_t *drw, wxd2lat_job_t *job ) { wxd_object_t *pobj; dk4_um_t oldline; int back = 1; #line 3204 "wxd2lout.ctr" oldline = dk4app_get_log_source_line(job->app); dk4sto_it_reset(drw->i_flat); do { pobj = (wxd_object_t *)dk4sto_it_next(drw->i_flat); if (NULL != pobj) { dk4app_set_log_source_line(job->app, pobj->lino); if (0 == wxd2lout_one_graphics_object(drw, job, pobj)) { back = 0; } } } while (NULL != pobj); dk4app_set_log_source_line(job->app, oldline); #line 3217 "wxd2lout.ctr" return back; } static int wxd2lout_check_arrows( wxd_drawing_t *drw, wxd2lat_job_t *job, wxd_object_t *pobj ) { int back = 1; #line 3232 "wxd2lout.ctr" if ((uint8_t)0U != (pobj->af).type) { if (0 == wxd2lah_one_arrowhead(&(pobj->af), pobj, drw, job)) { back = 0; /* ERROR: Forward arrow calculation failed */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 73 ); } } if ((uint8_t)0U != (pobj->ab).type) { if (0 == wxd2lah_one_arrowhead(&(pobj->ab), pobj, drw, job)) { back = 0; /* ERROR: Backward arrow calculation failed */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 74 ); } } #line 3251 "wxd2lout.ctr" return back; } static int wxd2out_all_calculations(wxd_drawing_t *drw, wxd2lat_job_t *job) { wxd_object_t *pobj; dk4_um_t oldline; int back = 1; int myback = 0; uint16_t u16; #line 3266 "wxd2lout.ctr" oldline = dk4app_get_log_source_line(job->app); dk4sto_it_reset(drw->i_flat); do { pobj = (wxd_object_t *)dk4sto_it_next(drw->i_flat); if (NULL != pobj) { dk4app_set_log_source_line(job->app, pobj->lino); switch (pobj->ot) { case WXD_OT_TEXT : { (pobj->det).t.x = wxd2lout_convert_x(drw, job, (pobj->det).t.x); (pobj->det).t.y = wxd2lout_convert_y(drw, job, (pobj->det).t.y); #if 0 (pobj->det).t.a = (M_PI * (pobj->det).t.a) / 180.0; #endif } break; case WXD_OT_POLYLINE : { u16 = (uint16_t)0U; if ((NULL != (pobj->det).p.p) && (u16 < (pobj->det).p.n)) { for (u16 = (uint16_t)0U; u16 < (pobj->det).p.n; u16++) { ((pobj->det).p.p)[u16].x = wxd2lout_convert_x( drw, job, ((pobj->det).p.p)[u16].x ); ((pobj->det).p.p)[u16].y = wxd2lout_convert_y( drw, job, ((pobj->det).p.p)[u16].y ); } } if (0 == wxd2lout_check_arrows(drw, job, pobj)) { /* Errors already reported */ back = 0; } } break; case WXD_OT_O_SPLINE : { u16 = (uint16_t)0U; if ((NULL != (pobj->det).s.p) && (u16 < (pobj->det).s.n)) { for (u16 = (uint16_t)0U; u16 < (pobj->det).s.n; u16++) { ((pobj->det).s.p)[u16].x = wxd2lout_convert_x( drw, job, ((pobj->det).s.p)[u16].x ); ((pobj->det).s.p)[u16].y = wxd2lout_convert_y( drw, job, ((pobj->det).s.p)[u16].y ); } } if (0 == wxd2lout_check_arrows(drw, job, pobj)) { /* Errors already reported */ back = 0; } if ( ((uint8_t)0U != (pobj->af).type) || ((uint8_t)0U != (pobj->ab).type) ) { (pobj->det).s.ts = -1.0; (pobj->det).s.te = -1.0; myback = 1; wxd2lxs_calculate_spline_segments(job, pobj, &myback); if (0 == myback) { back = 0; /* ERROR: Spline segment calculation failed */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 75 ); } } } break; case WXD_OT_O_ARC : { #line 3338 "wxd2lout.ctr" (pobj->det).a.x = wxd2lout_convert_x(drw, job, (pobj->det).a.x); (pobj->det).a.y = wxd2lout_convert_y(drw, job, (pobj->det).a.y); #line 3343 "wxd2lout.ctr" (pobj->det).a.r = wxd2lout_convert_r((pobj->det).a.r); if (0 == wxd2lout_check_arrows(drw, job, pobj)) { /* Errors already reported */ back = 0; } } break; case WXD_OT_POLYGON : { u16 = (uint16_t)0U; if ((NULL != (pobj->det).p.p) && (u16 < (pobj->det).p.n)) { for (u16 = (uint16_t)0U; u16 < (pobj->det).p.n; u16++) { ((pobj->det).p.p)[u16].x = wxd2lout_convert_x( drw, job, ((pobj->det).p.p)[u16].x ); ((pobj->det).p.p)[u16].y = wxd2lout_convert_y( drw, job, ((pobj->det).p.p)[u16].y ); } } } break; case WXD_OT_C_SPLINE : { u16 = (uint16_t)0U; if ((NULL != (pobj->det).s.p) && (u16 < (pobj->det).s.n)) { for (u16 = (uint16_t)0U; u16 < (pobj->det).s.n; u16++) { ((pobj->det).s.p)[u16].x = wxd2lout_convert_x( drw, job, ((pobj->det).s.p)[u16].x ); ((pobj->det).s.p)[u16].y = wxd2lout_convert_y( drw, job, ((pobj->det).s.p)[u16].y ); } } } break; case WXD_OT_C_ARC : { #line 3381 "wxd2lout.ctr" (pobj->det).a.x = wxd2lout_convert_x(drw, job, (pobj->det).a.x); (pobj->det).a.y = wxd2lout_convert_y(drw, job, (pobj->det).a.y); #line 3386 "wxd2lout.ctr" (pobj->det).a.r = wxd2lout_convert_r((pobj->det).a.r); } break; case WXD_OT_CIRCLE : case WXD_OT_ELLIPSE : { #line 3390 "wxd2lout.ctr" (pobj->det).e.x = wxd2lout_convert_x(drw, job, (pobj->det).e.x); (pobj->det).e.y = wxd2lout_convert_y(drw, job, (pobj->det).e.y); #line 3395 "wxd2lout.ctr" (pobj->det).e.rx = wxd2lout_convert_r((pobj->det).e.rx); #line 3398 "wxd2lout.ctr" #line 3399 "wxd2lout.ctr" (pobj->det).e.ry = wxd2lout_convert_r((pobj->det).e.ry); #line 3402 "wxd2lout.ctr" } break; case WXD_OT_BOX : { #line 3404 "wxd2lout.ctr" #line 3405 "wxd2lout.ctr" #line 3406 "wxd2lout.ctr" #line 3407 "wxd2lout.ctr" #line 3408 "wxd2lout.ctr" #line 3409 "wxd2lout.ctr" (pobj->det).b.xl = wxd2lout_convert_x(drw, job, (pobj->det).b.xl); (pobj->det).b.xr = wxd2lout_convert_x(drw, job, (pobj->det).b.xr); (pobj->det).b.yb = wxd2lout_convert_y(drw, job, (pobj->det).b.yb); (pobj->det).b.yt = wxd2lout_convert_y(drw, job, (pobj->det).b.yt); if (0.0 < (pobj->det).b.r) { #line 3419 "wxd2lout.ctr" (pobj->det).b.r = wxd2lout_convert_r((pobj->det).b.r); } #line 3422 "wxd2lout.ctr" #line 3423 "wxd2lout.ctr" #line 3424 "wxd2lout.ctr" #line 3425 "wxd2lout.ctr" #line 3426 "wxd2lout.ctr" } break; case WXD_OT_IMAGE : { #line 3428 "wxd2lout.ctr" (pobj->det).i.x = wxd2lout_convert_x(drw, job, (pobj->det).i.x); (pobj->det).i.y = wxd2lout_convert_y(drw, job, (pobj->det).i.y); #line 3433 "wxd2lout.ctr" #line 3434 "wxd2lout.ctr" (pobj->det).i.w = wxd2lout_convert_r((pobj->det).i.w); (pobj->det).i.h = wxd2lout_convert_r((pobj->det).i.h); } break; case WXD_OT_DOT_FILLED : case WXD_OT_DOT_WHITE : { #line 3439 "wxd2lout.ctr" (pobj->det).d.x = wxd2lout_convert_x(drw, job, (pobj->det).d.x); (pobj->det).d.y = wxd2lout_convert_y(drw, job, (pobj->det).d.y); #line 3444 "wxd2lout.ctr" if (0.0 < job->baselw) { (pobj->det).d.d *= job->baselw; } else { (pobj->det).d.d *= drw->baselw; } #line 3451 "wxd2lout.ctr" } break; } } } while (NULL != pobj); dk4app_set_log_source_line(job->app, oldline); #line 3457 "wxd2lout.ctr" return back; } void wxd2lat_output(wxd_drawing_t *drw, wxd2lat_job_t *job, const dkChar *fn) { dk4_er_t er; dk4_pppt_driver_t dr; int flags = 0; int ok = 0; #line 3471 "wxd2lout.ctr" /* Calculate image width and coordinates shift values. */ if (0 == wxd2lout_prepare_job(drw, job, fn)) { /* All errors already reported */ job->exval = EXIT_FAILURE; goto finished; } /* Convert coordinates to bp, pre-calculate arrowhead data. */ if (0 == wxd2out_all_calculations(drw, job)) { /* All errors already reported */ job->exval = EXIT_FAILURE; goto finished; } /* Open output structure */ dr = DK4_PPPT_DR_PDF_TEX; switch ((job->grco).driver) { #if 0 case DK4_GRA_DRIVER_PDF : { dr = DK4_PPPT_DR_PDF_TEX; } break; #endif case DK4_GRA_DRIVER_PS : case DK4_GRA_DRIVER_EPS : { dr = DK4_PPPT_DR_EPS_TEX; } break; case DK4_GRA_DRIVER_PGF : { dr = DK4_PPPT_DR_PGF; } break; } if (0 == job->whitebg) { flags |= DK4_GRA_PAGE_FLAG_NO_BG; } if (0 == (job->grco).color) { flags |= DK4_GRA_DOC_FLAG_FORCE_GRAY; } if (DK4_PPPT_DR_EPS_TEX == dr) { if (2 == (job->grco).ps_level) { flags |= DK4_GRA_DOC_FLAG_PS2; } if (0 != (job->grco).ps_dsc) { flags |= DK4_GRA_DOC_FLAG_PS_DSC; } if (DK4_GRA_DRIVER_EPS == (job->grco).driver) { flags |= DK4_GRA_DOC_FLAG_EPS; } } dk4error_init(&er); job->ppp = dk4pppt_open( job->fno1, dr, ((DK4_GRA_PURPOSE_DOCUMENT == (job->grco).purpose) ? (1) : (0)), flags, job->szwidth, job->szheight, &er ); if (NULL == job->ppp) { /* ERROR: Failed to open output structure */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 76 ); job->exval = EXIT_FAILURE; goto finished; } dk4pppt_set_gs_for_pattern_only(job->ppp, 1, NULL); if (0.0 < job->patlw) { dk4pppt_set_pattern_line_width(job->ppp, job->patlw); } else { dk4pppt_set_pattern_line_width(job->ppp, 0.45); } /* Clip if shiftx and/or shifty is used */ if (0 == wxd2lout_clip_to_used_region(job)) { /* All errors already reported */ job->exval = EXIT_FAILURE; goto finished; } /* Draw all graphics objects */ if (0 == wxd2lout_all_graphics_objects(drw, job)) { /* All errors already reported */ job->exval = EXIT_FAILURE; goto finished; } /* Finally indicate success */ ok = 1; /* Produce output files if success so far, clean up */ finished: if (NULL != job->ppp) { if (0 != ok) { dk4error_init(&er); ok = dk4pppt_write_and_close(job->ppp, &er); if (0 == ok) { /* ERROR: Failed to write output */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 77 ); job->exval = EXIT_FAILURE; } } else { dk4pppt_close(job->ppp); /* ERROR: Skipping output due to previous errors */ dk4app_log_1( job->app, job->msg, job->sz_msg, DK4_LL_ERROR, 78 ); job->exval = EXIT_FAILURE; } } job->ppp = NULL; #line 3586 "wxd2lout.ctr" } /* vim: set ai sw=4 ts=4 : */