Commit 63df5d82 authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

*Jonathan Wilkes' 2 patches addressing:

- nested plots display properly
- plot is vis'd and unvis'd properly when deleting plot or struct
- commented out ugly plot_displace hack-- multiple plots should work just fine
- separated out garray dependencies into class "old_plot".  This way the changes I made don't affect garrays.  _Very_ ugly hack, but it was pretty simple to implement and will be easy to remove later.
- no crashes when non-existent arrays are entered into a [struct] that has scalars hanging around
- template_cancreate ported from 0.45
- added a function to get the offending struct (to use with "Find last error").  Not using it yet, though.
+ For creating scalars using an object box:
- scalar must have initial "float x float y" fields, in that order.  This means you can't accidentally type the name of the hidden garray structs and create a scalar.  (Nor any other structs that only have a "y" field, etc.)
- broken object box returned if the struct has a bogus array template.  (Although currently I'm just refusing to create such a struct.)
parent 799ced4d
......@@ -151,7 +151,7 @@ static char garray_arraytemplatefile[] = "\
#N canvas 0 0 458 153 10;\n\
#X obj 43 31 struct _float_array array z float float style\n\
float linewidth float color symbol fillcolor symbol outlinecolor;\n\
#X obj 43 70 plot z color linewidth 0 0 1 style fillcolor outlinecolor;\n\
#X obj 43 70 old_plot z color linewidth 0 0 1 style fillcolor outlinecolor;\n\
";
static char garray_floattemplatefile[] = "\
#N canvas 0 0 458 153 10;\n\
......
......@@ -1634,7 +1634,10 @@ static void glist_redrawall(t_template *template, t_glist *gl, int action)
{
t_class *cl;
if (vis && g->g_pd == scalar_class &&
template == template_findbyname(((t_scalar *)g)->sc_template))
((template == template_findbyname(((t_scalar *)g)->sc_template))
|| template_has_elemtemplate(
template_findbyname(((t_scalar *)g)->sc_template),
template)))
{
if (action == 1)
{
......
......@@ -629,6 +629,7 @@ EXTERN t_scalar *scalar_new(t_glist *owner,
EXTERN void word_free(t_word *wp, t_template *tmpl);
EXTERN void scalar_getbasexy(t_scalar *x, t_float *basex, t_float *basey);
EXTERN void scalar_redraw(t_scalar *x, t_glist *glist);
EXTERN int template_has_elemtemplate(t_template *t, t_template *template);
/* ------helper routines for "garrays" and "plots" -------------- */
EXTERN int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap,
......@@ -666,6 +667,8 @@ EXTERN void template_setsymbol(t_template *x, t_symbol *fieldname,
EXTERN t_template *gtemplate_get(t_gtemplate *x);
EXTERN t_template *template_findbyname(t_symbol *s);
EXTERN int template_cancreate(t_template *template);
EXTERN int template_hasxy(t_template *template);
EXTERN t_canvas *template_findcanvas(t_template *tmpl);
EXTERN void template_notify(t_template *tmpl,
t_symbol *s, int argc, t_atom *argv);
......
......@@ -87,6 +87,74 @@ void word_free(t_word *wp, t_template *template)
}
}
/* some of this code is used in a function in g_canvas.c...
need to modularize it */
static t_object *template_getstruct(t_template *template)
{
if (template)
{
t_gobj *y;
t_canvas *c;
if (c = template_findcanvas(template))
{
t_symbol *s1 = gensym("struct");
for (y = c->gl_list; y; y = y->g_next)
{
t_object *ob = pd_checkobject(&y->g_pd);
t_atom *argv;
if (!ob || ob->te_type != T_OBJECT ||
binbuf_getnatom(ob->te_binbuf) < 2)
continue;
argv = binbuf_getvec(ob->te_binbuf);
if (argv[0].a_w.w_symbol != s1)
continue;
if (canvas_makebindsym(argv[1].a_w.w_symbol) == template->t_sym)
return (ob);
}
}
}
return (0);
}
int template_hasxy(t_template *template)
{
t_symbol *zz;
int xonset, yonset, xtype, ytype, gotx, goty;
if (!template)
{
error("struct: couldn't find template %s", template->t_sym->s_name);
return 0;
}
gotx = template_find_field(template, gensym("x"), &xonset, &xtype, &zz);
goty = template_find_field(template, gensym("y"), &yonset, &ytype, &zz);
if ((gotx && (xtype == DT_FLOAT)) &&
(goty && (ytype == DT_FLOAT)) &&
(xonset == 0) && (yonset == sizeof(t_word)))
{
return 1;
}
else
return 0;
}
int template_cancreate(t_template *template)
{
int i, type, nitems = template->t_n;
t_dataslot *datatypes = template->t_vec;
t_template *elemtemplate;
for (i = 0; i < nitems; i++, datatypes++)
if (datatypes->ds_type == DT_ARRAY &&
(!(elemtemplate = template_findbyname(datatypes->ds_arraytemplate))
|| !template_cancreate(elemtemplate)))
{
t_object *ob = template_getstruct(template);
pd_error(ob, "%s: no such template",
datatypes->ds_arraytemplate->s_name);
return (0);
}
return (1);
}
/* make a new scalar and add to the glist. We create a "gp" here which
will be used for array items to point back here. This gp doesn't do
reference counting or "validation" updates though; the parent won't go away
......@@ -105,6 +173,8 @@ t_scalar *scalar_new(t_glist *owner, t_symbol *templatesym)
error("scalar: couldn't find template %s", templatesym->s_name);
return (0);
}
if (!template_cancreate(template))
return (0);
x = (t_scalar *)getbytes(sizeof(t_scalar) +
(template->t_n - 1) * sizeof(*x->sc_vec));
x->sc_gobj.g_pd = scalar_class;
......@@ -147,6 +217,36 @@ void glist_scalar(t_glist *glist,
binbuf_free(b);
}
/* search template fields recursively to see if the template
depends on elemtemplate */
int template_has_elemtemplate(t_template *t, t_template *elemtemplate)
{
int returnval = 0;
if (t && elemtemplate)
{
int i;
t_dataslot *d = t->t_vec;
for (i = 0; i < t->t_n; i++, d++)
{
if (d->ds_type == DT_ARRAY)
{
if (d->ds_arraytemplate == elemtemplate->t_sym)
{
returnval = 1;
break;
}
else
{
returnval = template_has_elemtemplate(
template_findbyname(d->ds_arraytemplate),
elemtemplate);
}
}
}
}
return (returnval);
}
/* -------------------- widget behavior for scalar ------------ */
void scalar_getbasexy(t_scalar *x, t_float *basex, t_float *basey)
{
......@@ -506,8 +606,11 @@ static void scalar_displace_withtag(t_gobj *z, t_glist *glist, int dx, int dy)
behavior, so we don't use the hack for them. (Non-garray scalars
should follow that behavior too, but cannot atm for the reason given
in the comment above scalar_select...)
*/
Apparently this is no longer needed, so it is commented out. Once
we test it we should be able to delete it for good... */
/*
if (template->t_sym != gensym("_float_array"))
{
t_gobj *y;
......@@ -520,6 +623,7 @@ static void scalar_displace_withtag(t_gobj *z, t_glist *glist, int dx, int dy)
basex, basey, dx, dy);
}
}
*/
//scalar_redraw(x, glist);
}
......
......@@ -588,6 +588,7 @@ static void *gtemplate_donew(t_symbol *sym, int argc, t_atom *argv)
}
t_gtemplate *x = (t_gtemplate *)pd_new(gtemplate_class);
t_template *t = template_findbyname(sym);
int i;
t_symbol *sx = gensym("x");
x->x_owner = canvas_getcurrent();
......@@ -618,6 +619,17 @@ static void *gtemplate_donew(t_symbol *sym, int argc, t_atom *argv)
/* if there's none, we just replace the template with
our own and conform it. */
t_template *y = template_new(&s_, argc, argv);
/* I'm not _exactly_ sure about this. It's possible
that the user could screw up a nested array construction
and end up with scalars that aren't able to conform. On
the other hand, this keeps us from crashing if a non-
existent array template is typed into the box. */
if (!template_cancreate(y))
{
return 0;
}
canvas_redrawallfortemplate(t, 2);
/* Unless the new template is different from the old one,
there's nothing to do. */
......@@ -4032,8 +4044,13 @@ static void plot_displace(t_gobj *z, t_glist *glist,
int dx, int dy)
{
/* a very temporary hack. See comment inside scalar_displace_withtag */
/* Looks like it's no longer needed, so we're commenting it out for
the time being. */
/*
sys_vgui(".x%lx.c move .x%lx.x%lx.template%lx %d %d\n",
glist_getcanvas(glist), glist_getcanvas(glist), glist, data, dx, dy);
*/
/* not yet */
}
......@@ -4110,6 +4127,11 @@ static void plot_vis(t_gobj *z, t_glist *glist, t_scalar *sc,
if (tovis)
{
int in_array = (sc->sc_vec == data) ? 0 : 1;
if (in_array)
sys_vgui(".x%lx.c create group -tags {.scelem%lx} "
"-parent .dgroup%lx -matrix { {1 0} {0 1} {%g %g} }\n",
glist_getcanvas(glist), data, sc->sc_vec, basex, basey);
/* check if old 3-digit color field is being used... */
int dscolor = fielddesc_getfloat(&x->x_outlinecolor, template, data, 1);
if (dscolor != 0)
......@@ -4126,15 +4148,16 @@ static void plot_vis(t_gobj *z, t_glist *glist, t_scalar *sc,
t_float minyval = 1e20, maxyval = -1e20;
int ndrawn = 0;
sys_vgui(".x%lx.c create path { \\\n", glist_getcanvas(glist));
for (xsum = basex + xloc, i = 0; i < nelem; i++)
for (xsum = xloc, i = 0; i < nelem; i++)
{
t_float yval, xpix, ypix, nextxloc;
int ixpix, inextx;
if (xonset >= 0)
{
usexloc = basex + xloc +
usexloc = xloc +
*(t_float *)((elem + elemsize * i) + xonset);
// revisite xtopixels...
ixpix = glist_xtopixels(glist,
fielddesc_cvttocoord(xfielddesc, usexloc));
inextx = ixpix + 2;
......@@ -4162,7 +4185,7 @@ static void plot_vis(t_gobj *z, t_glist *glist, t_scalar *sc,
int border = 0;
if(style == PLOTSTYLE_POINTS)
py2 = (int)(glist_ytopixels(glist,
basey + fielddesc_cvttocoord(yfielddesc, maxyval))
fielddesc_cvttocoord(yfielddesc, maxyval))
+ linewidth) - 1;
else
{
......@@ -4204,19 +4227,21 @@ static void plot_vis(t_gobj *z, t_glist *glist, t_scalar *sc,
a separate canvas item for each element...
sys_vgui(".x%lx.c create prect %d %d %d %d -fill %s "
"-stroke %s -strokewidth %d "
"-parent .dgroup%lx "
"-tags {.x%lx.x%lx.template%lx array}\n",
glist_getcanvas(glist),
ixpix, (int)glist_ytopixels(glist,
basey + fielddesc_cvttocoord(yfielddesc, minyval)) - 1,
fielddesc_cvttocoord(yfielddesc, minyval)) - 1,
inextx, py2, symfill->s_name, symoutline->s_name,
border, glist_getcanvas(glist), glist, data);
border, data,
glist_getcanvas(glist), glist, data);
*/
/* For efficiency, we make a single path item
for the trace or bargraph */
int mex1 = ixpix;
int mey1 = (int)glist_ytopixels(glist,
basey + fielddesc_cvttocoord(yfielddesc, minyval)) - 1;
fielddesc_cvttocoord(yfielddesc, minyval)) - 1;
int mex2 = inextx;
int mey2 = py2;
sys_vgui("M %d %d H %d V %d H %d z \\\n",
......@@ -4230,10 +4255,17 @@ static void plot_vis(t_gobj *z, t_glist *glist, t_scalar *sc,
}
/* end of the path item from above */
sys_vgui("} -fill %s -stroke %s -strokewidth %d "
"-tags {.x%lx.x%lx.template%lx array}\n",
"-parent {.dgroup%lx} "
"-tags {.x%lx.x%lx.template%lx array}\\\n",
symfill->s_name, symoutline->s_name,
style == PLOTSTYLE_POINTS ? 0 : 1,
data,
glist_getcanvas(glist), glist, data);
if (in_array)
sys_vgui("-parent .scelem%lx \n", data);
else
sys_vgui("-parent .dgroup%lx \n", sc->sc_vec);
}
else
{
......@@ -4262,13 +4294,13 @@ static void plot_vis(t_gobj *z, t_glist *glist, t_scalar *sc,
else yval = 0;
wval = *(t_float *)((elem + elemsize * i) + wonset);
xpix = glist_xtopixels(glist,
basex + fielddesc_cvttocoord(xfielddesc, usexloc));
fielddesc_cvttocoord(xfielddesc, usexloc));
ixpix = xpix + 0.5;
if (xonset >= 0 || ixpix != lastpixel)
{
sys_vgui("%d %f \\\n", ixpix,
glist_ytopixels(glist,
basey + fielddesc_cvttocoord(yfielddesc,
fielddesc_cvttocoord(yfielddesc,
yloc + yval) -
fielddesc_cvttocoord(wfielddesc,wval)));
ndrawn++;
......@@ -4289,12 +4321,12 @@ static void plot_vis(t_gobj *z, t_glist *glist, t_scalar *sc,
else yval = 0;
wval = *(t_float *)((elem + elemsize * i) + wonset);
xpix = glist_xtopixels(glist,
basex + fielddesc_cvttocoord(xfielddesc, usexloc));
fielddesc_cvttocoord(xfielddesc, usexloc));
ixpix = xpix + 0.5;
if (xonset >= 0 || ixpix != lastpixel)
{
sys_vgui("%d %f \\\n", ixpix, glist_ytopixels(glist,
basey + yloc + fielddesc_cvttocoord(yfielddesc,
yloc + fielddesc_cvttocoord(yfielddesc,
yval) +
fielddesc_cvttocoord(wfielddesc, wval)));
ndrawn++;
......@@ -4307,11 +4339,11 @@ static void plot_vis(t_gobj *z, t_glist *glist, t_scalar *sc,
if (ndrawn < 4)
{
sys_vgui("%d %f \\\n", ixpix + 10, glist_ytopixels(glist,
basey + yloc + fielddesc_cvttocoord(yfielddesc,
yloc + fielddesc_cvttocoord(yfielddesc,
yval) +
fielddesc_cvttocoord(wfielddesc, wval)));
sys_vgui("%d %f \\\n", ixpix + 10, glist_ytopixels(glist,
basey + yloc + fielddesc_cvttocoord(yfielddesc,
yloc + fielddesc_cvttocoord(yfielddesc,
yval) -
fielddesc_cvttocoord(wfielddesc, wval)));
}
......@@ -4320,7 +4352,10 @@ static void plot_vis(t_gobj *z, t_glist *glist, t_scalar *sc,
symfill->s_name, symoutline->s_name);
// this doesn't work with tkpath...
//if (style == PLOTSTYLE_BEZ) sys_vgui("-smooth 1 \\\n");
if (in_array)
sys_vgui(" -parent .scelem%lx \\\n", data);
else
sys_vgui(" -parent .dgroup%lx \\\n", sc->sc_vec);
sys_vgui("-tags {.x%lx.x%lx.template%lx scalar%lx}\n",
glist_getcanvas(glist), glist, data, sc);
}
......@@ -4342,13 +4377,13 @@ static void plot_vis(t_gobj *z, t_glist *glist, t_scalar *sc,
yval = *(t_float *)((elem + elemsize * i) + yonset);
else yval = 0;
xpix = glist_xtopixels(glist,
basex + fielddesc_cvttocoord(xfielddesc, usexloc));
fielddesc_cvttocoord(xfielddesc, usexloc));
ixpix = xpix + 0.5;
if (xonset >= 0 || ixpix != lastpixel)
{
sys_vgui("%d %f \\\n", ixpix,
glist_ytopixels(glist,
basey + yloc + fielddesc_cvttocoord(yfielddesc,
yloc + fielddesc_cvttocoord(yfielddesc,
yval)));
ndrawn++;
}
......@@ -4358,7 +4393,7 @@ static void plot_vis(t_gobj *z, t_glist *glist, t_scalar *sc,
/* TK will complain if there aren't at least 2 points... */
if (ndrawn == 0) sys_vgui("0 0 0 0 \\\n");
else if (ndrawn == 1) sys_vgui("%d %f \\\n", ixpix + 10,
glist_ytopixels(glist, basey + yloc +
glist_ytopixels(glist, yloc +
fielddesc_cvttocoord(yfielddesc, yval)));
//sys_vgui("-strokewidth %f \\\n", linewidth);
......@@ -4366,8 +4401,13 @@ static void plot_vis(t_gobj *z, t_glist *glist, t_scalar *sc,
sys_vgui("-strokewidth %f -stroke %s \\\n", linewidth, symoutline->s_name);
//sys_vgui("-fill %s \\\n", symoutline->s_name);
//if (style == PLOTSTYLE_BEZ) sys_vgui("-smooth 1 \\\n"); //this doesn't work with tkpath
if (in_array)
sys_vgui(" -parent .scelem%lx \\\n", data);
else
sys_vgui(" -parent .dgroup%lx \\\n", sc->sc_vec);
sys_vgui("-tags {.x%lx.x%lx.template%lx scalar%lx}\n", glist_getcanvas(glist), glist, data,sc);
sys_vgui("-tags {.x%lx.x%lx.template%lx scalar%lx}\n",
glist_getcanvas(glist), glist, data,sc);
}
}
/* make sure the array drawings are behind the graph */
......@@ -4379,18 +4419,20 @@ static void plot_vis(t_gobj *z, t_glist *glist, t_scalar *sc,
searched for drawing instructions for every last point. */
if (scalarvis != 0)
{
t_float xoffset = in_array ? basex : 0;
t_float yoffset = in_array ? basey : 0;
for (xsum = xloc, i = 0; i < nelem; i++)
{
t_float usexloc, useyloc;
t_gobj *y;
if (xonset >= 0)
usexloc = /* basex */ + xloc +
usexloc = xloc + xoffset +
*(t_float *)((elem + elemsize * i) + xonset);
else usexloc = /* basex */ + xsum, xsum += xinc;
else usexloc = xoffset + xsum, xsum += xinc;
if (yonset >= 0)
yval = *(t_float *)((elem + elemsize * i) + yonset);
else yval = 0;
useyloc = /* basey */ + yloc +
useyloc = yloc + yoffset +
fielddesc_cvttocoord(yfielddesc, yval);
for (y = elemtemplatecanvas->gl_list; y; y = y->g_next)
{
......@@ -4425,6 +4467,7 @@ static void plot_vis(t_gobj *z, t_glist *glist, t_scalar *sc,
{
/* un-draw the individual points */
//fprintf(stderr,"plot_vis UNVIS\n");
if (scalarvis != 0)
{
int i;
......@@ -4441,6 +4484,7 @@ static void plot_vis(t_gobj *z, t_glist *glist, t_scalar *sc,
}
}
}
/* and then the trace */
sys_vgui(".x%lx.c delete .x%lx.x%lx.template%lx\n",
glist_getcanvas(glist), glist_getcanvas(glist), glist, data);
......@@ -4517,6 +4561,790 @@ static void plot_setup(void)
class_setparentwidget(plot_class, &plot_widgetbehavior);
}
/* --------- old plot code used for garrays --------------- */
t_class *old_plot_class;
typedef struct _old_plot
{
t_object x_obj;
t_canvas *x_canvas;
t_fielddesc x_outlinecolor;
t_fielddesc x_width;
t_fielddesc x_xloc;
t_fielddesc x_yloc;
t_fielddesc x_xinc;
t_fielddesc x_style;
t_fielddesc x_data;
t_fielddesc x_xpoints;
t_fielddesc x_ypoints;
t_fielddesc x_wpoints;
t_fielddesc x_vis; /* visible */
t_fielddesc x_scalarvis; /* true if drawing the scalar at each point */
t_fielddesc x_symoutlinecolor; /* color as hex symbol */
t_fielddesc x_symfillcolor; /* fill color as hex symbol */
} t_old_plot;
static void *old_plot_new(t_symbol *classsym, t_int argc, t_atom *argv)
{
t_old_plot *x = (t_old_plot *)pd_new(old_plot_class);
int defstyle = PLOTSTYLE_POLY;
x->x_canvas = canvas_getcurrent();
//fprintf(stderr,"plot new %s\n",
// (canvas_makebindsym(x->x_canvas->gl_name))->s_name);
t_template *t = template_findbyname(
canvas_makebindsym(x->x_canvas->gl_name));
if (t)
{
/* increment variable of the template
to prevent transform as that would
make arrays break their hitboxes
and all kinds of other bad stuff */
t->t_transformable++;
}
fielddesc_setfloat_var(&x->x_xpoints, gensym("x"));
fielddesc_setfloat_var(&x->x_ypoints, gensym("y"));
fielddesc_setfloat_var(&x->x_wpoints, gensym("w"));
fielddesc_setfloat_const(&x->x_vis, 1);
fielddesc_setfloat_const(&x->x_scalarvis, 1);
while (1)
{
t_symbol *firstarg = atom_getsymbolarg(0, argc, argv);
if (!strcmp(firstarg->s_name, "curve") ||
!strcmp(firstarg->s_name, "-c"))
{
defstyle = PLOTSTYLE_BEZ;
argc--, argv++;
}
else if (!strcmp(firstarg->s_name, "-v") && argc > 1)
{
fielddesc_setfloatarg(&x->x_vis, 1, argv+1);
argc -= 2; argv += 2;
}
else if (!strcmp(firstarg->s_name, "-vs") && argc > 1)
{
fielddesc_setfloatarg(&x->x_scalarvis, 1, argv+1);
argc -= 2; argv += 2;
}
else if (!strcmp(firstarg->s_name, "-x") && argc > 1)
{
fielddesc_setfloatarg(&x->x_xpoints, 1, argv+1);
argc -= 2; argv += 2;
}
else if (!strcmp(firstarg->s_name, "-y") && argc > 1)
{
fielddesc_setfloatarg(&x->x_ypoints, 1, argv+1);
argc -= 2; argv += 2;
}
else if (!strcmp(firstarg->s_name, "-w") && argc > 1)
{
fielddesc_setfloatarg(&x->x_wpoints, 1, argv+1);
argc -= 2; argv += 2;
}
else break;
}
if (argc) fielddesc_setarrayarg(&x->x_data, argc--, argv++);
else fielddesc_setfloat_const(&x->x_data, 1);
if (argc) fielddesc_setfloatarg(&x->x_outlinecolor, argc--, argv++);
else fielddesc_setfloat_const(&x->x_outlinecolor, 0);
if (argc) fielddesc_setfloatarg(&x->x_width, argc--, argv++);
else fielddesc_setfloat_const(&x->x_width, 1);
if (argc) fielddesc_setfloatarg(&x->x_xloc, argc--, argv++);
else fielddesc_setfloat_const(&x->x_xloc, 1);
if (argc) fielddesc_setfloatarg(&x->x_yloc, argc--, argv++);
else fielddesc_setfloat_const(&x->x_yloc, 1);
if (argc) fielddesc_setfloatarg(&x->x_xinc, argc--, argv++);
else fielddesc_setfloat_const(&x->x_xinc, 1);
if (argc) fielddesc_setfloatarg(&x->x_style, argc--, argv++);
else fielddesc_setfloat_const(&x->x_style, defstyle);
if (argc) fielddesc_setsymbolarg(&x->x_symfillcolor, argc--, argv++);
else argc--, argv++;
if (argc) fielddesc_setsymbolarg(&x->x_symoutlinecolor, argc--, argv++);
return (x);
}
void old_plot_float(t_old_plot *x, t_floatarg f)
{
int viswas;
if (x->x_vis.fd_type != A_FLOAT || x->x_vis.fd_var)
{
pd_error(x, "global vis/invis for a template with variable visibility");
return;
}
viswas = (x->x_vis.fd_un.fd_float != 0);
if ((f != 0 && viswas) || (f == 0 && !viswas))
return;
canvas_redrawallfortemplatecanvas(x->x_canvas, 2);
fielddesc_setfloat_const(&x->x_vis, (f != 0));
canvas_redrawallfortemplatecanvas(x->x_canvas, 1);
}
/* -------------------- widget behavior for plot ------------ */
/* get everything we'll need from the owner template of the array being
plotted. Not used for garrays, but see below */
static int old_plot_readownertemplate(t_old_plot *x,
t_word *data, t_template *ownertemplate,
t_symbol **elemtemplatesymp, t_array **arrayp,
t_float *linewidthp, t_float *xlocp, t_float *xincp, t_float *ylocp, t_float *stylep,
t_float *visp, t_float *scalarvisp,
t_fielddesc **xfield, t_fielddesc **yfield, t_fielddesc **wfield, t_symbol **fillcolorp,
t_symbol **outlinecolorp)
{
int arrayonset, type;
t_symbol *elemtemplatesym;
t_array *array;
/* find the data and verify it's an array */
if (x->x_data.fd_type != A_ARRAY || !x->x_data.fd_var)
{
error("old_plot: needs an array field");
return (-1);
}
if (!template_find_field(ownertemplate, x->x_data.fd_un.fd_varsym,
&arrayonset, &type, &elemtemplatesym))
{
error("old_plot: %s: no such field", x->x_data.fd_un.fd_varsym->s_name);
return (-1);
}
if (type != DT_ARRAY)
{
error("old_plot: %s: not an array", x->x_data.fd_un.fd_varsym->s_name);
return (-1);
}
array = *(t_array **)(((char *)data) + arrayonset);
*linewidthp = fielddesc_getfloat(&x->x_width, ownertemplate, data, 1);
*xlocp = fielddesc_getfloat(&x->x_xloc, ownertemplate, data, 1);
*xincp = fielddesc_getfloat(&x->x_xinc, ownertemplate, data, 1);
*ylocp = fielddesc_getfloat(&x->x_yloc, ownertemplate, data, 1);
*stylep = fielddesc_getfloat(&x->x_style, ownertemplate, data, 1);
*visp = fielddesc_getfloat(&x->x_vis, ownertemplate, data, 1);
*scalarvisp = fielddesc_getfloat(&x->x_scalarvis, ownertemplate, data, 1);
*elemtemplatesymp = elemtemplatesym;
*arrayp = array;
*xfield = &x->x_xpoints;
*yfield = &x->x_ypoints;
*wfield = &x->x_wpoints;
*fillcolorp = fielddesc_getsymbol(&x->x_symfillcolor, ownertemplate,
data, 0);
*outlinecolorp = fielddesc_getsymbol(&x->x_symoutlinecolor, ownertemplate,