From 49c5f3374ea117d203d2adec589a899ace16f02f Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic <ico@vt.edu> Date: Wed, 17 Sep 2014 21:14:30 -0400 Subject: [PATCH] *fixed inconsistent display of array styles between pd-l2ork and vanilla. LATER consider cleaning this up by adjusting g_canvas.h instead of all these workarounds. --- pd/src/g_array.c | 18 ++++++++++++------ pd/src/g_template.c | 14 ++++++++++++-- pd/src/pd.tk | 9 +++++---- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/pd/src/g_array.c b/pd/src/g_array.c index e40296597..f9a45d520 100644 --- a/pd/src/g_array.c +++ b/pd/src/g_array.c @@ -442,8 +442,8 @@ t_garray *graph_array(t_glist *gl, t_symbol *s, int argc, t_atom *argv) int flags = fflags; int filestyle = ((flags & 6) >> 1); //fprintf(stderr,"filestyle = %d\n", filestyle); - int style = (filestyle == 0 ? PLOTSTYLE_POINTS : - (filestyle == 1 ? PLOTSTYLE_POLY : filestyle)); + int style = (filestyle == 0 ? PLOTSTYLE_POLY : + (filestyle == 1 ? PLOTSTYLE_POINTS : filestyle)); if (templateargsym != &s_float) { error("array %s: only 'float' type understood", templateargsym->s_name); @@ -536,10 +536,13 @@ void garray_properties(t_garray *x, t_glist *canvas) /* create dialog window. LATER fix this to escape '$' properly; right now we just detect a leading '$' and escape it. There should be a systematic way of doing this. */ + int filestyle = (x->x_style == 0 ? PLOTSTYLE_POLY : + (x->x_style == 1 ? PLOTSTYLE_POINTS : x->x_style)); + //fprintf(stderr," garray_properties %d\n", filestyle); sprintf(cmdbuf, ((x->x_name->s_name[0] == '$') ? "pdtk_array_dialog %%s \\%s %d %d 0 .x%lx %s %s\n" : "pdtk_array_dialog %%s %s %d %d 0 .x%lx %s %s\n"), x->x_name->s_name, - a->a_n, x->x_saveit + 2 * x->x_style + 8 * x->x_hidename + + a->a_n, x->x_saveit + 2 * filestyle + 8 * x->x_hidename + 16 * x->x_joc, (long unsigned int)glist_getcanvas(canvas), x->x_fillcolor->s_name, x->x_outlinecolor->s_name); gfxstub_new(&x->x_gobj.g_pd, x, cmdbuf); @@ -637,7 +640,9 @@ void garray_arraydialog(t_garray *x, t_symbol *s, int argc, t_atom *argv) t_symbol *fill = atom_getsymbolarg(6, argc, argv); t_symbol *outline = atom_getsymbolarg(7, argc, argv); int saveit = ((flags & 1) != 0); - int style = ((flags & 6) >> 1); + int filestyle = ((flags & 6) >> 1); + int style = (filestyle == 0 ? PLOTSTYLE_POLY : + (filestyle == 1 ? PLOTSTYLE_POINTS : filestyle)); /* todo: revisit this filestyle business if (style < 2) style = !style; @@ -967,6 +972,7 @@ static void array_motion(void *z, t_floatarg dx, t_floatarg dy) array_motion_elemsize * array_motion_lastx), 1); // here we block scalar from exceeding the array GOP edges + // LATER: see if we need to do the same for an x plot if (graph) { if (graph->gl_y1 > graph->gl_y2) @@ -1448,8 +1454,8 @@ static void garray_save(t_gobj *z, t_binbuf *b) } /* style = template_getfloat(scalartemplate, gensym("style"), x->x_scalar->sc_vec, 0); */ - filestyle = (x->x_style == PLOTSTYLE_POINTS ? 0 : - (x->x_style == PLOTSTYLE_POLY ? 1 : x->x_style)); + filestyle = (x->x_style == PLOTSTYLE_POINTS ? 1 : + (x->x_style == PLOTSTYLE_POLY ? 0 : x->x_style)); binbuf_addv(b, "sssisiss;", gensym("#X"), gensym("array"), x->x_name, array->a_n, &s_float, diff --git a/pd/src/g_template.c b/pd/src/g_template.c index 9ae1727d6..ecc5bb7ad 100644 --- a/pd/src/g_template.c +++ b/pd/src/g_template.c @@ -5019,11 +5019,15 @@ static void plot_vis(t_gobj *z, t_glist *glist, t_glist *parentglist, if (ndrawn > 2000 || ixpix >= 3000) break; } /* end of the path item from above */ + // Ico 2014-09-17: we keep style the same for both because stroke + // already gives us the thickness matching that of vanilla pd + // The code is left here in its redundant form for future reference + // in case we encounter regressions. sys_vgui("} -fill %s -stroke %s -strokewidth %d " "-parent {.dgroup%lx.%lx} " "-tags {.x%lx.x%lx.template%lx array}\n", symfill->s_name, symoutline->s_name, - style == PLOTSTYLE_POINTS ? 0 : 1, + style == PLOTSTYLE_POINTS ? 0 : 0, x->x_canvas, data, glist_getcanvas(glist), glist, data); } @@ -5725,6 +5729,8 @@ static void old_plot_vis(t_gobj *z, t_glist *glist, t_glist *parentglist, nelem = array->a_n; elem = (char *)array->a_vec; + //fprintf(stderr,"old_plot_vis style=%g\n", style); + if (tovis) { /* check if old 3-digit color field is being used... */ @@ -5852,10 +5858,14 @@ static void old_plot_vis(t_gobj *z, t_glist *glist, t_glist *parentglist, if (ndrawn > 2000 || ixpix >= 3000) break; } /* end of the path item from above */ + // Ico 2014-09-17: we keep style the same for both because stroke + // already gives us the thickness matching that of vanilla pd + // The code is left here in its redundant form for future reference + // in case we encounter regressions. sys_vgui("} -fill %s -stroke %s -strokewidth %d " "-tags {.x%lx.x%lx.template%lx array}\n", symfill->s_name, symoutline->s_name, - style == PLOTSTYLE_POINTS ? 0 : 1, + style == PLOTSTYLE_POINTS ? 0 : 0, glist_getcanvas(glist), glist, data); } else diff --git a/pd/src/pd.tk b/pd/src/pd.tk index 6898f6845..8d82d8f55 100644 --- a/pd/src/pd.tk +++ b/pd/src/pd.tk @@ -6067,6 +6067,7 @@ proc array_apply {id canvas} { set outline $::dialog($vid:outline) # puts stderr "...[expr $saveit + 2 * $drawasrects + 16 * $joc]" + # puts stderr "tk drawasrects=$drawasrects" set xdraw [expr int([$canvas.c canvasx 0])] set ydraw [expr int([$canvas.c canvasy 0])] @@ -6270,14 +6271,14 @@ if {[catch { pack $id.drawasrects -side top -pady 3 -anchor w match_linux_wm [list label $id.drawasrects.l -text "draw as:"] pack $id.drawasrects.l -side top -pady 3 -anchor w - match_linux_wm [list radiobutton $id.drawasrects.drawasrects0 -value 0 \ + match_linux_wm [list radiobutton $id.drawasrects.drawasrects0 -value 1 \ -variable ::dialog($vid:drawasrects) \ -text "points" \ - -command "array_update_drawas 0 $ffr $ofr $olabel"] - match_linux_wm [list radiobutton $id.drawasrects.drawasrects1 -value 1 \ + -command "array_update_drawas 1 $ffr $ofr $olabel"] + match_linux_wm [list radiobutton $id.drawasrects.drawasrects1 -value 0 \ -variable ::dialog($vid:drawasrects) \ -text "polygon" \ - -command "array_update_drawas 1 $ffr $ofr $olabel"] + -command "array_update_drawas 0 $ffr $ofr $olabel"] #match_linux_wm [list radiobutton $id.drawasrects.drawasrects2 -value 2 \ # -variable ::dialog($vid:drawasrects) \ # -text "bezier curve" \ -- GitLab