/* HBB 20021128: removed GP_INLINE qualifier to avoid MSVC++ silliness */ void draw3d_line_unconditional( p_vertex v1, p_vertex v2, struct lp_style_type *lp, int linetype) { unsigned int x1, y1, x2, y2; struct lp_style_type ls = *lp; /* HBB 20020312: v2 can be NULL, if this call is coming from draw_line_hidden. --> redirect to point drawing routine */ if (! v2) { draw3d_point_unconditional(v1, lp); return; } TERMCOORD(v1, x1, y1); TERMCOORD(v2, x2, y2); /* User-specified line styles */ if (prefer_line_styles && linetype >= 0) lp_use_properties(&ls, linetype+1); /* The usual case of auto-generated line types */ else ls.l_type = linetype; /* Color by Z value */ if (ls.pm3d_color.type == TC_Z) ls.pm3d_color.value = (v1->real_z + v2->real_z) * 0.5; term_apply_lp_properties(&ls); draw_clip_line(x1,y1,x2,y2); }
void apply_pm3dcolor(struct t_colorspec *tc, const struct termentry *t) { /* V5 - term->linetype(LT_BLACK) would clobber the current */ /* dashtype so instead we use term->set_color(black). */ static t_colorspec black = BLACK_COLORSPEC; double cbval; /* Replace colorspec with that of the requested line style */ struct lp_style_type style; if (tc->type == TC_LINESTYLE) { lp_use_properties(&style, tc->lt); tc = &style.pm3d_color; } if (tc->type == TC_DEFAULT) { t->set_color(&black); return; } if (tc->type == TC_LT) { /* Removed Jan 2015 if (!monochrome_terminal) */ t->set_color(tc); return; } if (tc->type == TC_RGB) { /* FIXME: several plausible ways for monochrome terminals to handle color request * (1) Allow all color requests despite the label "monochrome" * (2) Choose any color you want so long as it is black * (3) Convert colors to gray scale (NTSC?) */ /* Monochrome terminals are still allowed to display rgb variable colors */ if (monochrome_terminal && tc->value >= 0) t->set_color(&black); else t->set_color(tc); return; } if (!is_plot_with_palette()) { t->set_color(&black); return; } switch (tc->type) { case TC_Z: set_color(cb2gray(z2cb(tc->value))); break; case TC_CB: if (CB_AXIS.log) cbval = (tc->value <= 0) ? CB_AXIS.min : (log(tc->value) / CB_AXIS.log_base); else cbval = tc->value; set_color(cb2gray(cbval)); break; case TC_FRAC: set_color(sm_palette.positive == SMPAL_POSITIVE ? tc->value : 1-tc->value); break; } }
void apply_pm3dcolor(struct t_colorspec *tc, const struct termentry *t) { /* Replace colorspec with that of the requested line style */ struct lp_style_type style; if (tc->type == TC_LINESTYLE) { lp_use_properties(&style, tc->lt); (*t->linetype)(style.l_type); tc = &style.pm3d_color; } if (tc->type == TC_DEFAULT) { (*t->linetype)(LT_BLACK); return; } if (tc->type == TC_LT) { if (t->set_color) t->set_color(tc); else (*t->linetype)(tc->lt); return; } if (tc->type == TC_RGB && t->set_color) { t->set_color(tc); return; } if (!is_plot_with_palette() || !t->set_color) { (*t->linetype)(LT_BLACK); return; } switch (tc->type) { case TC_Z: set_color(cb2gray(z2cb(tc->value))); break; case TC_CB: set_color(cb2gray(tc->value)); break; case TC_FRAC: set_color(sm_palette.positive == SMPAL_POSITIVE ? tc->value : 1-tc->value); break; } }
/* * allow_ls controls whether we are allowed to accept linestyle in * the current context [ie not when doing a set linestyle command] * allow_point is whether we accept a point command */ int lp_parse(struct lp_style_type *lp, TBOOLEAN allow_ls, TBOOLEAN allow_point) { /* keep track of which options were set during this call */ int set_lt = 0, set_pal = 0, set_lw = 0, set_pt = 0, set_ps = 0, set_pi = 0; int new_lt = 0; /* EAM Mar 2010 - We don't want properties from a user-defined default * linetype to override properties explicitly set here. So fill in a * local lp_style_type as we go and then copy over the specifically * requested properties on top of the default ones. */ struct lp_style_type newlp = *lp; if (allow_ls && (almost_equals(c_token, "lines$tyle") || equals(c_token, "ls"))) { c_token++; lp_use_properties(lp, int_expression()); } while (!END_OF_COMMAND) { if (almost_equals(c_token, "linet$ype") || equals(c_token, "lt")) { if (set_lt++) break; c_token++; if (almost_equals(c_token, "rgb$color")) { if (set_pal++) break; c_token--; parse_colorspec(&(newlp.pm3d_color), TC_RGB); newlp.use_palette = 1; } else /* both syntaxes allowed: 'with lt pal' as well as 'with pal' */ if (almost_equals(c_token, "pal$ette")) { if (set_pal++) break; c_token--; parse_colorspec(&(newlp.pm3d_color), TC_Z); newlp.use_palette = 1; } else if (equals(c_token,"bgnd")) { *lp = background_lp; c_token++; } else { /* These replace the base style */ new_lt = int_expression(); lp->l_type = new_lt - 1; /* user may prefer explicit line styles */ if (prefer_line_styles && allow_ls) lp_use_properties(lp, new_lt); else load_linetype(lp, new_lt); } } /* linetype, lt */ /* both syntaxes allowed: 'with lt pal' as well as 'with pal' */ if (almost_equals(c_token, "pal$ette")) { if (set_pal++) break; c_token--; parse_colorspec(&(newlp.pm3d_color), TC_Z); newlp.use_palette = 1; continue; } if (equals(c_token,"lc") || almost_equals(c_token,"linec$olor") || equals(c_token,"fc") || almost_equals(c_token,"fillc$olor")) { newlp.use_palette = 1; if (set_pal++) break; c_token++; if (almost_equals(c_token, "rgb$color")) { c_token--; parse_colorspec(&(newlp.pm3d_color), TC_RGB); } else if (almost_equals(c_token, "pal$ette")) { c_token--; parse_colorspec(&(newlp.pm3d_color), TC_Z); } else if (equals(c_token,"bgnd")) { newlp.pm3d_color.type = TC_LT; newlp.pm3d_color.lt = LT_BACKGROUND; c_token++; } else if (almost_equals(c_token, "var$iable")) { c_token++; newlp.l_type = LT_COLORFROMCOLUMN; newlp.pm3d_color.type = TC_LINESTYLE; } else { /* Pull the line colour from a default linetype, but */ /* only if we are not in the middle of defining one! */ if (allow_ls) { struct lp_style_type temp; load_linetype(&temp, int_expression()); newlp.pm3d_color = temp.pm3d_color; } else { newlp.pm3d_color.type = TC_LT; newlp.pm3d_color.lt = int_expression() - 1; } } continue; } if (almost_equals(c_token, "linew$idth") || equals(c_token, "lw")) { if (set_lw++) break; c_token++; newlp.l_width = real_expression(); if (newlp.l_width < 0) newlp.l_width = 0; continue; } if (equals(c_token,"bgnd")) { if (set_lt++) break;; c_token++; *lp = background_lp; continue; } if (almost_equals(c_token, "pointt$ype") || equals(c_token, "pt")) { if (allow_point) { if (set_pt++) break; c_token++; newlp.p_type = int_expression() - 1; } else { int_warn(c_token, "No pointtype specifier allowed, here"); c_token += 2; } continue; } if (almost_equals(c_token, "points$ize") || equals(c_token, "ps")) { if (allow_point) { if (set_ps++) break; c_token++; if (almost_equals(c_token, "var$iable")) { newlp.p_size = PTSZ_VARIABLE; c_token++; } else if (almost_equals(c_token, "def$ault")) { newlp.p_size = PTSZ_DEFAULT; c_token++; } else { newlp.p_size = real_expression(); if (newlp.p_size < 0) newlp.p_size = 0; } } else { int_warn(c_token, "No pointsize specifier allowed, here"); c_token += 2; } continue; } if (almost_equals(c_token, "pointi$nterval") || equals(c_token, "pi")) { c_token++; if (allow_point) { newlp.p_interval = int_expression(); set_pi = 1; } else { int_warn(c_token, "No pointinterval specifier allowed, here"); int_expression(); } continue; } /* caught unknown option -> quit the while(1) loop */ break; } if (set_lt > 1 || set_pal > 1 || set_lw > 1 || set_pt > 1 || set_ps > 1) int_error(c_token, "duplicated arguments in style specification"); if (set_pal) { lp->pm3d_color = newlp.pm3d_color; lp->use_palette = newlp.use_palette; /* FIXME: This was used by hidden3d, but breaks contour coloring */ /* new_lt = LT_SINGLECOLOR; */ } if (set_lw) lp->l_width = newlp.l_width; if (set_pt) lp->p_type = newlp.p_type; if (set_ps) lp->p_size = newlp.p_size; if (set_pi) lp->p_interval = newlp.p_interval; if (newlp.l_type == LT_COLORFROMCOLUMN) lp->l_type = LT_COLORFROMCOLUMN; return new_lt; }
/* Finally the main colour smooth box drawing routine */ void draw_color_smooth_box(int plot_mode) { double tmp; FILE *out = gppsfile; /* either gpoutfile or PSLATEX_auxfile */ if (color_box.where == SMCOLOR_BOX_NO) return; if (!term->filled_polygon) return; /* firstly, choose some good position of the color box user's position like that (?): else { x_from = color_box.xlow; x_to = color_box.xhigh; } */ if (color_box.where == SMCOLOR_BOX_USER) { if (!is_3d_plot) { double xtemp, ytemp; map_position(&color_box.origin, &color_box.bounds.xleft, &color_box.bounds.ybot, "cbox"); map_position_r(&color_box.size, &xtemp, &ytemp, "cbox"); color_box.bounds.xright = xtemp; color_box.bounds.ytop = ytemp; } else if (splot_map && is_3d_plot) { /* In map view mode we allow any coordinate system for placement */ double xtemp, ytemp; map3d_position_double(&color_box.origin, &xtemp, &ytemp, "cbox"); color_box.bounds.xleft = xtemp; color_box.bounds.ybot = ytemp; map3d_position_r(&color_box.size, &color_box.bounds.xright, &color_box.bounds.ytop, "cbox"); } else { /* But in full 3D mode we only allow screen coordinates */ color_box.bounds.xleft = color_box.origin.x * (term->xmax) + 0.5; color_box.bounds.ybot = color_box.origin.y * (term->ymax) + 0.5; color_box.bounds.xright = color_box.size.x * (term->xmax-1) + 0.5; color_box.bounds.ytop = color_box.size.y * (term->ymax-1) + 0.5; } color_box.bounds.xright += color_box.bounds.xleft; color_box.bounds.ytop += color_box.bounds.ybot; } else { /* color_box.where == SMCOLOR_BOX_DEFAULT */ if (plot_mode == MODE_SPLOT && !splot_map) { /* HBB 20031215: new code. Constants fixed to what the result * of the old code in default view (set view 60,30,1,1) * happened to be. Somebody fix them if they're not right! */ color_box.bounds.xleft = xmiddle + 0.709 * xscaler; color_box.bounds.xright = xmiddle + 0.778 * xscaler; color_box.bounds.ybot = ymiddle - 0.147 * yscaler; color_box.bounds.ytop = ymiddle + 0.497 * yscaler; } else if (is_3d_plot) { /* MWS 09-Dec-05, make color box full size for splot maps. */ double dx = (X_AXIS.max - X_AXIS.min); map3d_xy(X_AXIS.max + dx * 0.025, Y_AXIS.min, base_z, &color_box.bounds.xleft, &color_box.bounds.ybot); map3d_xy(X_AXIS.max + dx * 0.075, Y_AXIS.max, ceiling_z, &color_box.bounds.xright, &color_box.bounds.ytop); } else { /* 2D plot */ struct position default_origin = {graph,graph,graph, 1.025, 0, 0}; struct position default_size = {graph,graph,graph, 0.05, 1.0, 0}; double xtemp, ytemp; map_position(&default_origin, &color_box.bounds.xleft, &color_box.bounds.ybot, "cbox"); color_box.bounds.xleft += color_box.xoffset; map_position_r(&default_size, &xtemp, &ytemp, "cbox"); color_box.bounds.xright = xtemp + color_box.bounds.xleft; color_box.bounds.ytop = ytemp + color_box.bounds.ybot; } /* now corrections for outer tics */ if (color_box.rotation == 'v') { int cblen = (CB_AXIS.tic_in ? -1 : 1) * CB_AXIS.ticscale * (term->h_tic); /* positive for outer tics */ int ylen = (Y_AXIS.tic_in ? -1 : 1) * Y_AXIS.ticscale * (term->h_tic); /* positive for outer tics */ if ((cblen > 0) && (CB_AXIS.ticmode & TICS_MIRROR)) { color_box.bounds.xleft += cblen; color_box.bounds.xright += cblen; } if ((ylen > 0) && (axis_array[FIRST_Y_AXIS].ticmode & TICS_MIRROR)) { color_box.bounds.xleft += ylen; color_box.bounds.xright += ylen; } } } if (color_box.bounds.ybot > color_box.bounds.ytop) { /* switch them */ tmp = color_box.bounds.ytop; color_box.bounds.ytop = color_box.bounds.ybot; color_box.bounds.ybot = tmp; } /* Optimized version of the smooth colour box in postscript. Advantage: only few lines of code is written into the output file. */ if (gppsfile) draw_inside_color_smooth_box_postscript(out); else draw_inside_color_smooth_box_bitmap(out); if (color_box.border) { /* now make boundary around the colour box */ if (color_box.border_lt_tag >= 0) { /* user specified line type */ struct lp_style_type lp = border_lp; lp_use_properties(&lp, color_box.border_lt_tag); term_apply_lp_properties(&lp); } else { /* black solid colour should be chosen, so it's border linetype */ term_apply_lp_properties(&border_lp); } newpath(); (term->move) (color_box.bounds.xleft, color_box.bounds.ybot); (term->vector) (color_box.bounds.xright, color_box.bounds.ybot); (term->vector) (color_box.bounds.xright, color_box.bounds.ytop); (term->vector) (color_box.bounds.xleft, color_box.bounds.ytop); (term->vector) (color_box.bounds.xleft, color_box.bounds.ybot); closepath(); /* Set line properties to some value, this also draws lines in postscript terminals. */ term_apply_lp_properties(&border_lp); } /* draw tics */ if (axis_array[COLOR_AXIS].ticmode) { term_apply_lp_properties(&border_lp); /* border linetype */ gen_tics(COLOR_AXIS, cbtick_callback ); } /* write the colour box label */ if (CB_AXIS.label.text) { int x, y; apply_pm3dcolor(&(CB_AXIS.label.textcolor),term); if (color_box.rotation == 'h') { int len = CB_AXIS.ticscale * (CB_AXIS.tic_in ? 1 : -1) * (term->v_tic); map3d_position_r(&(CB_AXIS.label.offset), &x, &y, "smooth_box"); x += (color_box.bounds.xleft + color_box.bounds.xright) / 2; #define DEFAULT_Y_DISTANCE 1.0 y += color_box.bounds.ybot + (- DEFAULT_Y_DISTANCE - 1.7) * term->v_char; #undef DEFAULT_Y_DISTANCE if (len < 0) y += len; if (x<0) x = 0; if (y<0) y = 0; write_multiline(x, y, CB_AXIS.label.text, CENTRE, JUST_CENTRE, 0, CB_AXIS.label.font); } else { int len = CB_AXIS.ticscale * (CB_AXIS.tic_in ? -1 : 1) * (term->h_tic); /* calculate max length of cb-tics labels */ widest_tic_strlen = 0; if (CB_AXIS.ticmode & TICS_ON_BORDER) { widest_tic_strlen = 0; /* reset the global variable */ gen_tics(COLOR_AXIS, /* 0, */ widest_tic_callback); } map3d_position_r(&(CB_AXIS.label.offset), &x, &y, "smooth_box"); #define DEFAULT_X_DISTANCE 0.0 x += color_box.bounds.xright + (widest_tic_strlen + DEFAULT_X_DISTANCE + 1.5) * term->h_char; #undef DEFAULT_X_DISTANCE if (len > 0) x += len; y += (color_box.bounds.ybot + color_box.bounds.ytop) / 2; if (x<0) x = 0; if (y<0) y = 0; if ((*term->text_angle)(CB_AXIS.label.rotate)) { write_multiline(x, y, CB_AXIS.label.text, CENTRE, JUST_TOP, CB_AXIS.label.rotate, CB_AXIS.label.font); (*term->text_angle)(0); } else { write_multiline(x, y, CB_AXIS.label.text, LEFT, JUST_TOP, 0, CB_AXIS.label.font); } } reset_textcolor(&(CB_AXIS.label.textcolor),term); } }
/* * destination_class tells us whether we are filling in a line style ('set style line'), * a persistant linetype ('set linetype') or an ad hoc set of properties for a single * use ('plot ... lc foo lw baz'). * allow_point controls whether we accept a point attribute in this lp_style. */ int lp_parse(struct lp_style_type *lp, lp_class destination_class, TBOOLEAN allow_point) { /* keep track of which options were set during this call */ int set_lt = 0, set_pal = 0, set_lw = 0; int set_pt = 0, set_ps = 0, set_pi = 0; int set_dt = 0; int new_lt = 0; /* EAM Mar 2010 - We don't want properties from a user-defined default * linetype to override properties explicitly set here. So fill in a * local lp_style_type as we go and then copy over the specifically * requested properties on top of the default ones. */ struct lp_style_type newlp = *lp; if ((destination_class == LP_ADHOC) && (almost_equals(c_token, "lines$tyle") || equals(c_token, "ls"))) { c_token++; lp_use_properties(lp, int_expression()); } while (!END_OF_COMMAND) { /* This special case is to flag an attemp to "set object N lt <lt>", * which would otherwise be accepted but ignored, leading to confusion * FIXME: Couldn't this be handled at a higher level? */ if ((destination_class == LP_NOFILL) && (equals(c_token,"lt") || almost_equals(c_token,"linet$ype"))) { int_error(c_token, "object linecolor must be set using fillstyle border"); } if (almost_equals(c_token, "linet$ype") || equals(c_token, "lt")) { if (set_lt++) break; if (destination_class == LP_TYPE) int_error(c_token, "linetype definition cannot use linetype"); c_token++; if (almost_equals(c_token, "rgb$color")) { if (set_pal++) break; c_token--; parse_colorspec(&(newlp.pm3d_color), TC_RGB); } else /* both syntaxes allowed: 'with lt pal' as well as 'with pal' */ if (almost_equals(c_token, "pal$ette")) { if (set_pal++) break; c_token--; parse_colorspec(&(newlp.pm3d_color), TC_Z); } else if (equals(c_token,"bgnd")) { *lp = background_lp; c_token++; } else if (equals(c_token,"black")) { *lp = default_border_lp; c_token++; } else if (equals(c_token,"nodraw")) { lp->l_type = LT_NODRAW; c_token++; } else { /* These replace the base style */ new_lt = int_expression(); lp->l_type = new_lt - 1; /* user may prefer explicit line styles */ if (prefer_line_styles && (destination_class != LP_STYLE)) lp_use_properties(lp, new_lt); else load_linetype(lp, new_lt); } } /* linetype, lt */ /* both syntaxes allowed: 'with lt pal' as well as 'with pal' */ if (almost_equals(c_token, "pal$ette")) { if (set_pal++) break; c_token--; parse_colorspec(&(newlp.pm3d_color), TC_Z); continue; } /* This is so that "set obj ... lw N fc <colorspec>" doesn't eat up the * fc colorspec as a line property. We need to parse it later as a * _fill_ property. Also prevents "plot ... fc <col1> fs <foo> lw <baz>" * from generating an error claiming redundant line properties. */ if ((destination_class == LP_NOFILL || destination_class == LP_ADHOC) && (equals(c_token,"fc") || almost_equals(c_token,"fillc$olor"))) break; if (equals(c_token,"lc") || almost_equals(c_token,"linec$olor") || equals(c_token,"fc") || almost_equals(c_token,"fillc$olor") ) { if (set_pal++) break; c_token++; if (almost_equals(c_token, "rgb$color") || isstring(c_token)) { c_token--; parse_colorspec(&(newlp.pm3d_color), TC_RGB); } else if (almost_equals(c_token, "pal$ette")) { c_token--; parse_colorspec(&(newlp.pm3d_color), TC_Z); } else if (equals(c_token,"bgnd")) { newlp.pm3d_color.type = TC_LT; newlp.pm3d_color.lt = LT_BACKGROUND; c_token++; } else if (equals(c_token,"black")) { newlp.pm3d_color.type = TC_LT; newlp.pm3d_color.lt = LT_BLACK; c_token++; } else if (almost_equals(c_token, "var$iable")) { c_token++; newlp.l_type = LT_COLORFROMCOLUMN; newlp.pm3d_color.type = TC_LINESTYLE; } else { /* Pull the line colour from a default linetype, but */ /* only if we are not in the middle of defining one! */ if (destination_class != LP_STYLE) { struct lp_style_type temp; load_linetype(&temp, int_expression()); newlp.pm3d_color = temp.pm3d_color; } else { newlp.pm3d_color.type = TC_LT; newlp.pm3d_color.lt = int_expression() - 1; } } continue; } if (almost_equals(c_token, "linew$idth") || equals(c_token, "lw")) { if (set_lw++) break; c_token++; newlp.l_width = real_expression(); if (newlp.l_width < 0) newlp.l_width = 0; continue; } if (equals(c_token,"bgnd")) { if (set_lt++) break;; c_token++; *lp = background_lp; continue; } if (equals(c_token,"black")) { if (set_lt++) break;; c_token++; *lp = default_border_lp; continue; } if (almost_equals(c_token, "pointt$ype") || equals(c_token, "pt")) { if (allow_point) { char *symbol; if (set_pt++) break; c_token++; if ((symbol = try_to_get_string())) { newlp.p_type = PT_CHARACTER; /* An alternative mechanism would be to use * utf8toulong(&newlp.p_char, symbol); */ strncpy((char *)(&newlp.p_char), symbol, 3); /* Truncate ascii text to single character */ if ((((char *)&newlp.p_char)[0] & 0x80) == 0) ((char *)&newlp.p_char)[1] = '\0'; /* UTF-8 characters may use up to 3 bytes */ ((char *)&newlp.p_char)[3] = '\0'; free(symbol); } else { newlp.p_type = int_expression() - 1; } } else { int_warn(c_token, "No pointtype specifier allowed, here"); c_token += 2; } continue; } if (almost_equals(c_token, "points$ize") || equals(c_token, "ps")) { if (allow_point) { if (set_ps++) break; c_token++; if (almost_equals(c_token, "var$iable")) { newlp.p_size = PTSZ_VARIABLE; c_token++; } else if (almost_equals(c_token, "def$ault")) { newlp.p_size = PTSZ_DEFAULT; c_token++; } else { newlp.p_size = real_expression(); if (newlp.p_size < 0) newlp.p_size = 0; } } else { int_warn(c_token, "No pointsize specifier allowed, here"); c_token += 2; } continue; } if (almost_equals(c_token, "pointi$nterval") || equals(c_token, "pi")) { c_token++; if (allow_point) { newlp.p_interval = int_expression(); set_pi = 1; } else { int_warn(c_token, "No pointinterval specifier allowed, here"); int_expression(); } continue; } if (almost_equals(c_token, "dasht$ype") || equals(c_token, "dt")) { int tmp; if (set_dt++) break; c_token++; tmp = parse_dashtype(&newlp.custom_dash_pattern); /* Pull the dashtype from the list of already defined dashtypes, */ /* but only if it we didn't get an explicit one back from parse_dashtype */ if (tmp == DASHTYPE_AXIS) lp->l_type = LT_AXIS; if (tmp >= 0) tmp = load_dashtype(&newlp.custom_dash_pattern, tmp + 1); newlp.d_type = tmp; continue; } /* caught unknown option -> quit the while(1) loop */ break; } if (set_lt > 1 || set_pal > 1 || set_lw > 1 || set_pt > 1 || set_ps > 1 || set_dt > 1) int_error(c_token, "duplicated arguments in style specification"); if (set_pal) { lp->pm3d_color = newlp.pm3d_color; /* hidden3d uses this to decide that a single color surface is wanted */ lp->flags |= LP_EXPLICIT_COLOR; } else { lp->flags &= ~LP_EXPLICIT_COLOR; } if (set_lw) lp->l_width = newlp.l_width; if (set_pt) { lp->p_type = newlp.p_type; lp->p_char = newlp.p_char; } if (set_ps) lp->p_size = newlp.p_size; if (set_pi) lp->p_interval = newlp.p_interval; if (newlp.l_type == LT_COLORFROMCOLUMN) lp->l_type = LT_COLORFROMCOLUMN; if (set_dt) { lp->d_type = newlp.d_type; lp->custom_dash_pattern = newlp.custom_dash_pattern; } return new_lt; }
/* * allow_ls controls whether we are allowed to accept linestyle in * the current context [ie not when doing a set linestyle command] * allow_point is whether we accept a point command * allow any order of options - pm 24.11.2001 * EAM Oct 2005 - Require that default values have been placed in lp by the caller */ void lp_parse(struct lp_style_type *lp, TBOOLEAN allow_ls, TBOOLEAN allow_point) { /* avoid duplicating options */ int set_lt = 0, set_pal = 0, set_lw = 0, set_pt = 0, set_ps = 0; if (allow_ls && (almost_equals(c_token, "lines$tyle") || equals(c_token, "ls"))) { c_token++; lp_use_properties(lp, int_expression()); } while (!END_OF_COMMAND) { if (almost_equals(c_token, "linet$ype") || equals(c_token, "lt")) { if (set_lt++) break; c_token++; if (almost_equals(c_token, "rgb$color")) { if (set_pal++) break; c_token--; parse_colorspec(&lp->pm3d_color, TC_RGB); lp->use_palette = 1; } else /* both syntaxes allowed: 'with lt pal' as well as 'with pal' */ if (almost_equals(c_token, "pal$ette")) { if (set_pal++) break; c_token--; parse_colorspec(&lp->pm3d_color, TC_Z); lp->use_palette = 1; #ifdef KEYWORD_BGND } else if (equals(c_token,"bgnd")) { lp->l_type = LT_BACKGROUND; c_token++; #endif } else { int lt = int_expression(); lp->l_type = lt - 1; /* user may prefer explicit line styles */ if (prefer_line_styles && allow_ls) lp_use_properties(lp, lt); } } /* linetype, lt */ /* both syntaxes allowed: 'with lt pal' as well as 'with pal' */ if (almost_equals(c_token, "pal$ette")) { if (set_pal++) break; c_token--; parse_colorspec(&lp->pm3d_color, TC_Z); lp->use_palette = 1; continue; } if (equals(c_token,"lc") || almost_equals(c_token,"linec$olor")) { lp->use_palette = 1; if (set_pal++) break; c_token++; if (almost_equals(c_token, "rgb$color")) { c_token--; parse_colorspec(&lp->pm3d_color, TC_RGB); } else if (almost_equals(c_token, "pal$ette")) { c_token--; parse_colorspec(&lp->pm3d_color, TC_Z); #ifdef KEYWORD_BGND } else if (equals(c_token,"bgnd")) { lp->pm3d_color.type = TC_LT; lp->pm3d_color.lt = LT_BACKGROUND; c_token++; #endif } else if (almost_equals(c_token, "var$iable")) { c_token++; lp->l_type = LT_COLORFROMCOLUMN; lp->pm3d_color.type = TC_LINESTYLE; } else { lp->pm3d_color.type = TC_LT; lp->pm3d_color.lt = int_expression() - 1; } continue; } if (almost_equals(c_token, "linew$idth") || equals(c_token, "lw")) { if (set_lw++) break; c_token++; lp->l_width = real_expression(); if (lp->l_width < 0) lp->l_width = 0; continue; } if (equals(c_token,"bgnd")) { lp->l_type = LT_BACKGROUND; lp->use_palette = 0; c_token++; continue; } if (almost_equals(c_token, "pointt$ype") || equals(c_token, "pt")) { if (allow_point) { if (set_pt++) break; c_token++; lp->p_type = int_expression() - 1; } else { int_warn(c_token, "No pointtype specifier allowed, here"); c_token += 2; } continue; } if (almost_equals(c_token, "points$ize") || equals(c_token, "ps")) { if (allow_point) { if (set_ps++) break; c_token++; if (almost_equals(c_token, "var$iable")) { lp->p_size = PTSZ_VARIABLE; c_token++; } else if (almost_equals(c_token, "def$ault")) { lp->p_size = PTSZ_DEFAULT; c_token++; } else { lp->p_size = real_expression(); if (lp->p_size < 0) lp->p_size = 0; } } else { int_warn(c_token, "No pointsize specifier allowed, here"); c_token += 2; } continue; } if (almost_equals(c_token, "pointi$nterval") || equals(c_token, "pi")) { c_token++; if (allow_point) { lp->p_interval = int_expression(); } else { int_warn(c_token, "No pointinterval specifier allowed, here"); int_expression(); } continue; } /* unknown option catched -> quit the while(1) loop */ break; } if (set_lt > 1 || set_pal > 1 || set_lw > 1 || set_pt > 1 || set_ps > 1) int_error(c_token, "duplicated arguments in style specification"); }