[PD-cvs] pd/src desire.c,1.1.2.156,1.1.2.157
Mathieu Bouchard
matju at users.sourceforge.net
Thu Sep 7 03:10:19 CEST 2006
Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29756
Modified Files:
Tag: devel_0_39
desire.c
Log Message:
more renaming of fields in t_fielddesc
Index: desire.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v
retrieving revision 1.1.2.156
retrieving revision 1.1.2.157
diff -C2 -d -r1.1.2.156 -r1.1.2.157
*** desire.c 7 Sep 2006 01:01:59 -0000 1.1.2.156
--- desire.c 7 Sep 2006 01:10:16 -0000 1.1.2.157
***************
*** 2864,2875 ****
proportional-style GOP. In this case we do a coordinate transformation. */
static int text_xpix(t_text *x, t_glist *glist) {
if (glist->havewindow || !glist->isgraph) return x->te_xpix;
if (glist->goprect) return glist->gl_obj.te_xpix + x->te_xpix - glist->xmargin;
! return glist_xtopixels(glist, glist->gl_x1 + (glist->gl_x2 - glist->gl_x1) * x->te_xpix / (glist->screenx2 - glist->screenx1));
}
static int text_ypix(t_text *x, t_glist *glist) {
if (glist->havewindow || !glist->isgraph) return x->te_ypix;
if (glist->goprect) return glist->gl_obj.te_ypix + x->te_ypix - glist->ymargin;
! return glist_ytopixels(glist, glist->gl_y1 + (glist->gl_y2 - glist->gl_y1) * x->te_ypix / (glist->screeny2 - glist->screeny1));
}
--- 2864,2877 ----
proportional-style GOP. In this case we do a coordinate transformation. */
static int text_xpix(t_text *x, t_glist *glist) {
+ float width = glist->gl_x2-glist->gl_x1;
if (glist->havewindow || !glist->isgraph) return x->te_xpix;
if (glist->goprect) return glist->gl_obj.te_xpix + x->te_xpix - glist->xmargin;
! return glist_xtopixels(glist, glist->gl_x1 + width * x->te_xpix / (glist->screenx2-glist->screenx1));
}
static int text_ypix(t_text *x, t_glist *glist) {
+ float height = glist->gl_y2-glist->gl_y1;
if (glist->havewindow || !glist->isgraph) return x->te_ypix;
if (glist->goprect) return glist->gl_obj.te_ypix + x->te_ypix - glist->ymargin;
! return glist_ytopixels(glist, glist->gl_y1 + height* x->te_ypix / (glist->screeny2-glist->screeny1));
}
***************
*** 2932,2936 ****
g = x->list;
if (g && !g->g_next && g->g_pd == garray_class) {
! int ymin = (y1 < y2 ? y1 : y2);
t_symbol *s = garray_getname((t_garray *)g);
sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor sw\
--- 2934,2938 ----
g = x->list;
if (g && !g->g_next && g->g_pd == garray_class) {
! int ymin = y1<y2 ? y1 : y2;
t_symbol *s = garray_getname((t_garray *)g);
sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor sw\
***************
*** 2981,2995 ****
for (i = 0; i < x->nxlabels; i++)
sys_vgui(".x%lx.c create text %d %d -text {%s} -font -*-courier-bold--normal--%d-* -tags %s\n",
! (long)glist_getcanvas(x),
! (int)glist_xtopixels(x, atof(x->xlabel[i]->s_name)),
! (int)glist_ytopixels(x, x->xlabely), x->xlabel[i]->s_name,
! glist_getfont(x), tag);
/* draw y labels */
for (i = 0; i < x->nylabels; i++)
sys_vgui(".x%lx.c create text %d %d -text {%s} -font -*-courier-bold--normal--%d-* -tags %s\n",
! (long)glist_getcanvas(x),
! (int)glist_xtopixels(x, x->ylabelx),
! (int)glist_ytopixels(x, atof(x->ylabel[i]->s_name)),
! x->ylabel[i]->s_name,
glist_getfont(x), tag);
/* draw contents of graph as glist */
--- 2983,2993 ----
for (i = 0; i < x->nxlabels; i++)
sys_vgui(".x%lx.c create text %d %d -text {%s} -font -*-courier-bold--normal--%d-* -tags %s\n",
! (long)glist_getcanvas(x), (int)glist_xtopixels(x, atof(x->xlabel[i]->s_name)),
! (int)glist_ytopixels(x, x->xlabely), x->xlabel[i]->s_name, glist_getfont(x), tag);
/* draw y labels */
for (i = 0; i < x->nylabels; i++)
sys_vgui(".x%lx.c create text %d %d -text {%s} -font -*-courier-bold--normal--%d-* -tags %s\n",
! (long)glist_getcanvas(x), (int)glist_xtopixels(x, x->ylabelx),
! (int)glist_ytopixels(x, atof(x->ylabel[i]->s_name)), x->ylabel[i]->s_name,
glist_getfont(x), tag);
/* draw contents of graph as glist */
***************
*** 4935,4945 ****
struct _fielddesc {
! char fd_type; /* LATER consider removing this? */
! char fd_var;
union {
! t_float fd_float; /* the field is a constant float */
! t_symbol *fd_symbol; /* the field is a constant symbol */
! t_symbol *fd_varsym; /* the field is variable and this is the name */
! } fd_un;
float min,max;
float scrmin,scrmax; /* min and max screen values */
--- 4933,4943 ----
struct _fielddesc {
! char type; /* LATER consider removing this? */
! char var;
union {
! t_float f; /* the field is a constant float */
! t_symbol *s; /* the field is a constant symbol */
! t_symbol *varsym; /* the field is variable and this is the name */
! } u;
float min,max;
float scrmin,scrmax; /* min and max screen values */
***************
*** 4948,4956 ****
static void fielddesc_setfloat_const(t_fielddesc *fd, float f) {
! fd->fd_type = A_FLOAT; fd->fd_var = 0; fd->fd_un.fd_float = f;
fd->min = fd->max = fd->scrmin = fd->scrmax = fd->quantum = 0;
}
static void fielddesc_setsymbol_const(t_fielddesc *fd, t_symbol *s) {
! fd->fd_type = A_SYMBOL; fd->fd_var = 0; fd->fd_un.fd_symbol = s;
fd->min = fd->max = fd->scrmin = fd->scrmax = fd->quantum = 0;
}
--- 4946,4954 ----
static void fielddesc_setfloat_const(t_fielddesc *fd, float f) {
! fd->type = A_FLOAT; fd->var = 0; fd->u.f = f;
fd->min = fd->max = fd->scrmin = fd->scrmax = fd->quantum = 0;
}
static void fielddesc_setsymbol_const(t_fielddesc *fd, t_symbol *s) {
! fd->type = A_SYMBOL; fd->var = 0; fd->u.s = s;
fd->min = fd->max = fd->scrmin = fd->scrmax = fd->quantum = 0;
}
***************
*** 4958,4965 ****
static void fielddesc_setfloat_var(t_fielddesc *fd, t_symbol *s) {
char *s1, *s2, *s3, strbuf[MAXPDSTRING];
! fd->fd_type = A_FLOAT;
! fd->fd_var = 1;
if (!(s1 = strchr(s->s_name, '(')) || !(s2 = strchr(s->s_name, ')')) || s1>s2) {
! fd->fd_un.fd_varsym = s;
fd->min = fd->max = fd->scrmin = fd->scrmax = fd->quantum = 0;
} else {
--- 4956,4963 ----
static void fielddesc_setfloat_var(t_fielddesc *fd, t_symbol *s) {
char *s1, *s2, *s3, strbuf[MAXPDSTRING];
! fd->type = A_FLOAT;
! fd->var = 1;
if (!(s1 = strchr(s->s_name, '(')) || !(s2 = strchr(s->s_name, ')')) || s1>s2) {
! fd->u.varsym = s;
fd->min = fd->max = fd->scrmin = fd->scrmax = fd->quantum = 0;
} else {
***************
*** 4969,4973 ****
strncpy(strbuf, s->s_name, cpy);
strbuf[cpy] = 0;
! fd->fd_un.fd_varsym = gensym(strbuf);
got = sscanf(s1, "(%f:%f)(%f:%f)(%f)", &fd->min, &fd->max, &fd->scrmin, &fd->scrmax, &fd->quantum);
if (got < 2) goto fail;
--- 4967,4971 ----
strncpy(strbuf, s->s_name, cpy);
strbuf[cpy] = 0;
! fd->u.varsym = gensym(strbuf);
got = sscanf(s1, "(%f:%f)(%f:%f)(%f)", &fd->min, &fd->max, &fd->scrmin, &fd->scrmax, &fd->quantum);
if (got < 2) goto fail;
***************
*** 5001,5007 ****
if (argc <= 0) fielddesc_setsymbol_const(fd, &s_);
else if (argv->a_type == A_SYMBOL) {
! fd->fd_type = A_SYMBOL;
! fd->fd_var = 1;
! fd->fd_un.fd_varsym = argv->a_w.w_symbol;
fd->min = fd->max = fd->scrmin = fd->scrmax = fd->quantum = 0;
}
--- 4999,5005 ----
if (argc <= 0) fielddesc_setsymbol_const(fd, &s_);
else if (argv->a_type == A_SYMBOL) {
! fd->type = A_SYMBOL;
! fd->var = 1;
! fd->u.varsym = argv->a_w.w_symbol;
fd->min = fd->max = fd->scrmin = fd->scrmax = fd->quantum = 0;
}
***************
*** 5012,5018 ****
if (argc <= 0) fielddesc_setfloat_const(fd, 0);
else if (argv->a_type == A_SYMBOL) {
! fd->fd_type = A_ARRAY;
! fd->fd_var = 1;
! fd->fd_un.fd_varsym = argv->a_w.w_symbol;
} else fielddesc_setfloat_const(fd, argv->a_w.w_float);
}
--- 5010,5016 ----
if (argc <= 0) fielddesc_setfloat_const(fd, 0);
else if (argv->a_type == A_SYMBOL) {
! fd->type = A_ARRAY;
! fd->var = 1;
! fd->u.varsym = argv->a_w.w_symbol;
} else fielddesc_setfloat_const(fd, argv->a_w.w_float);
}
***************
*** 5021,5027 ****
the above are setting up the fielddesc itself. */
static t_float fielddesc_getfloat(t_fielddesc *f, t_template *template, t_word *wp, int loud) {
! if (f->fd_type!=A_FLOAT) {if (loud) error("symbolic data field used as number"); return 0;}
! if (f->fd_var) return template_getfloat(template, f->fd_un.fd_varsym, wp, loud);
! return f->fd_un.fd_float;
}
--- 5019,5025 ----
the above are setting up the fielddesc itself. */
static t_float fielddesc_getfloat(t_fielddesc *f, t_template *template, t_word *wp, int loud) {
! if (f->type!=A_FLOAT) {if (loud) error("symbolic data field used as number"); return 0;}
! if (f->var) return template_getfloat(template, f->u.varsym, wp, loud);
! return f->u.f;
}
***************
*** 5034,5051 ****
extreme = f->scrmin<f->scrmax ? f->scrmin : f->scrmax; if (coord<extreme) coord = extreme;
extreme = f->scrmin>f->scrmax ? f->scrmin : f->scrmax; if (coord>extreme) coord = extreme;
! return (coord);
}
/* read a variable via fielddesc and convert to screen coordinate */
t_float fielddesc_getcoord(t_fielddesc *f, t_template *template, t_word *wp, int loud) {
! if (f->fd_type!=A_FLOAT) {if (loud) error("symbolic data field used as number"); return 0;}
! if (f->fd_var) return fielddesc_cvttocoord(f, template_getfloat(template, f->fd_un.fd_varsym, wp, loud));
! return f->fd_un.fd_float;
}
static t_symbol *fielddesc_getsymbol(t_fielddesc *f, t_template *template, t_word *wp, int loud) {
! if (f->fd_type!=A_SYMBOL) {if (loud) error("numeric data field used as symbol"); return &s_;}
! if (f->fd_var) return template_getsymbol(template, f->fd_un.fd_varsym, wp, loud);
! return f->fd_un.fd_symbol;
}
--- 5032,5049 ----
extreme = f->scrmin<f->scrmax ? f->scrmin : f->scrmax; if (coord<extreme) coord = extreme;
extreme = f->scrmin>f->scrmax ? f->scrmin : f->scrmax; if (coord>extreme) coord = extreme;
! return coord;
}
/* read a variable via fielddesc and convert to screen coordinate */
t_float fielddesc_getcoord(t_fielddesc *f, t_template *template, t_word *wp, int loud) {
! if (f->type!=A_FLOAT) {if (loud) error("symbolic data field used as number"); return 0;}
! if (f->var) return fielddesc_cvttocoord(f, template_getfloat(template, f->u.varsym, wp, loud));
! return f->u.f;
}
static t_symbol *fielddesc_getsymbol(t_fielddesc *f, t_template *template, t_word *wp, int loud) {
! if (f->type!=A_SYMBOL) {if (loud) error("numeric data field used as symbol"); return &s_;}
! if (f->var) return template_getsymbol(template, f->u.varsym, wp, loud);
! return f->u.s;
}
***************
*** 5066,5072 ****
void fielddesc_setcoord(t_fielddesc *f, t_template *template, t_word *wp, float coord, int loud) {
! if (f->fd_type == A_FLOAT && f->fd_var) {
float val = fielddesc_cvtfromcoord(f, coord);
! template_setfloat(template, f->fd_un.fd_varsym, wp, val, loud);
} else {
if (loud) error("attempt to set constant or symbolic data field to a number");
--- 5064,5070 ----
void fielddesc_setcoord(t_fielddesc *f, t_template *template, t_word *wp, float coord, int loud) {
! if (f->type == A_FLOAT && f->var) {
float val = fielddesc_cvtfromcoord(f, coord);
! template_setfloat(template, f->u.varsym, wp, val, loud);
} else {
if (loud) error("attempt to set constant or symbolic data field to a number");
***************
*** 5136,5144 ****
void curve_float(t_curve *x, t_floatarg f) {
int viswas;
! if (x->vis.fd_type != A_FLOAT || x->vis.fd_var) {
pd_error(x, "global vis/invis for a template with variable visibility");
return;
}
! viswas = (x->vis.fd_un.fd_float != 0);
if ((f != 0 && viswas) || (f == 0 && !viswas)) return;
canvas_redrawallfortemplatecanvas(x->canvas, 2);
--- 5134,5142 ----
void curve_float(t_curve *x, t_floatarg f) {
int viswas;
! if (x->vis.type != A_FLOAT || x->vis.var) {
pd_error(x, "global vis/invis for a template with variable visibility");
return;
}
! viswas = (x->vis.u.f != 0);
if ((f != 0 && viswas) || (f == 0 && !viswas)) return;
canvas_redrawallfortemplatecanvas(x->canvas, 2);
***************
*** 5265,5272 ****
curve_motion_xcumulative += dx;
curve_motion_ycumulative += dy;
! if (f[0].fd_var && dx!=0)
fielddesc_setcoord(f, curve_motion_template, curve_motion_wp,
curve_motion_xbase + curve_motion_xcumulative * curve_motion_xper, 1);
! if (f[1].fd_var && dy!=0)
fielddesc_setcoord(f+1, curve_motion_template, curve_motion_wp,
curve_motion_ybase + curve_motion_ycumulative * curve_motion_yper, 1);
--- 5263,5270 ----
curve_motion_xcumulative += dx;
curve_motion_ycumulative += dy;
! if (f[0].var && dx!=0)
fielddesc_setcoord(f, curve_motion_template, curve_motion_wp,
curve_motion_xbase + curve_motion_xcumulative * curve_motion_xper, 1);
! if (f[1].var && dy!=0)
fielddesc_setcoord(f+1, curve_motion_template, curve_motion_wp,
curve_motion_ybase + curve_motion_ycumulative * curve_motion_yper, 1);
***************
*** 5289,5293 ****
int yval = fielddesc_getcoord(f+1, template, data, 0), yloc = glist_ytopixels(glist, basey + yval);
int xerr = xloc - xpix, yerr = yloc - ypix;
! if (!f->fd_var && !(f+1)->fd_var) continue;
if (xerr < 0) xerr = -xerr;
if (yerr < 0) yerr = -yerr;
--- 5287,5291 ----
int yval = fielddesc_getcoord(f+1, template, data, 0), yloc = glist_ytopixels(glist, basey + yval);
int xerr = xloc - xpix, yerr = yloc - ypix;
! if (!f->var && !(f+1)->var) continue;
if (xerr < 0) xerr = -xerr;
if (yerr < 0) yerr = -yerr;
***************
*** 5395,5403 ****
void plot_float(t_plot *x, t_floatarg f) {
int viswas;
! if (x->vis.fd_type != A_FLOAT || x->vis.fd_var) {
pd_error(x, "global vis/invis for a template with variable visibility");
return;
}
! viswas = x->vis.fd_un.fd_float != 0;
if ((f != 0 && viswas) || (f == 0 && !viswas)) return;
canvas_redrawallfortemplatecanvas(x->canvas, 2);
--- 5393,5401 ----
void plot_float(t_plot *x, t_floatarg f) {
int viswas;
! if (x->vis.type != A_FLOAT || x->vis.var) {
pd_error(x, "global vis/invis for a template with variable visibility");
return;
}
! viswas = x->vis.u.f != 0;
if ((f != 0 && viswas) || (f == 0 && !viswas)) return;
canvas_redrawallfortemplatecanvas(x->canvas, 2);
***************
*** 5419,5432 ****
/* find the data and verify it's an array */
! if (x->data.fd_type != A_ARRAY || !x->data.fd_var) {
error("plot: needs an array field");
return -1;
}
! if (!template_find_field(ownertemplate, x->data.fd_un.fd_varsym, &arrayonset, &type, &elemtemplatesym)) {
! error("plot: %s: no such field", x->data.fd_un.fd_varsym->s_name);
return -1;
}
if (type != DT_ARRAY) {
! error("plot: %s: not an array", x->data.fd_un.fd_varsym->s_name);
return -1;
}
--- 5417,5430 ----
/* find the data and verify it's an array */
! if (x->data.type != A_ARRAY || !x->data.var) {
error("plot: needs an array field");
return -1;
}
! if (!template_find_field(ownertemplate, x->data.u.varsym, &arrayonset, &type, &elemtemplatesym)) {
! error("plot: %s: no such field", x->data.u.varsym->s_name);
return -1;
}
if (type != DT_ARRAY) {
! error("plot: %s: not an array", x->data.u.varsym->s_name);
return -1;
}
***************
*** 5469,5477 ****
}
elemsize = elemtemplate->t_n * sizeof(t_word);
! if (yfielddesc && yfielddesc->fd_var) varname = yfielddesc->fd_un.fd_varsym; else varname = gensym("y");
if (!template_find_field(elemtemplate,varname,&yonset,&type,&dummy) || type!=DT_FLOAT) yonset=-1;
! if (xfielddesc && xfielddesc->fd_var) varname = xfielddesc->fd_un.fd_varsym; else varname = gensym("x");
if (!template_find_field(elemtemplate,varname,&xonset,&type,&dummy) || type!=DT_FLOAT) xonset=-1;
! if (wfielddesc && wfielddesc->fd_var) varname = wfielddesc->fd_un.fd_varsym; else varname = gensym("w");
if (!template_find_field(elemtemplate,varname,&wonset,&type,&dummy) || type!=DT_FLOAT) wonset=-1;
--- 5467,5475 ----
}
elemsize = elemtemplate->t_n * sizeof(t_word);
! if (yfielddesc && yfielddesc->var) varname = yfielddesc->u.varsym; else varname = gensym("y");
if (!template_find_field(elemtemplate,varname,&yonset,&type,&dummy) || type!=DT_FLOAT) yonset=-1;
! if (xfielddesc && xfielddesc->var) varname = xfielddesc->u.varsym; else varname = gensym("x");
if (!template_find_field(elemtemplate,varname,&xonset,&type,&dummy) || type!=DT_FLOAT) xonset=-1;
! if (wfielddesc && wfielddesc->var) varname = wfielddesc->u.varsym; else varname = gensym("w");
if (!template_find_field(elemtemplate,varname,&wonset,&type,&dummy) || type!=DT_FLOAT) wonset=-1;
***************
*** 5800,5808 ****
void drawnumber_float(t_drawnumber *x, t_floatarg f) {
int viswas;
! if (x->vis.fd_type != A_FLOAT || x->vis.fd_var) {
pd_error(x, "global vis/invis for a template with variable visibility");
return;
}
! viswas = (x->vis.fd_un.fd_float != 0);
if ((f != 0 && viswas) || (f == 0 && !viswas)) return;
canvas_redrawallfortemplatecanvas(x->canvas, 2);
--- 5798,5806 ----
void drawnumber_float(t_drawnumber *x, t_floatarg f) {
int viswas;
! if (x->vis.type != A_FLOAT || x->vis.var) {
pd_error(x, "global vis/invis for a template with variable visibility");
return;
}
! viswas = (x->vis.u.f != 0);
if ((f != 0 && viswas) || (f == 0 && !viswas)) return;
canvas_redrawallfortemplatecanvas(x->canvas, 2);
***************
*** 5888,5892 ****
drawnumber_motion_ycumulative -= dy;
template_setfloat(drawnumber_motion_template,
! f->fd_un.fd_varsym, drawnumber_motion_wp, drawnumber_motion_ycumulative, 1);
if (drawnumber_motion_scalar) scalar_redraw(drawnumber_motion_scalar, drawnumber_motion_glist);
if (drawnumber_motion_array) array_redraw(drawnumber_motion_array, drawnumber_motion_glist);
--- 5886,5890 ----
drawnumber_motion_ycumulative -= dy;
template_setfloat(drawnumber_motion_template,
! f->u.varsym, drawnumber_motion_wp, drawnumber_motion_ycumulative, 1);
if (drawnumber_motion_scalar) scalar_redraw(drawnumber_motion_scalar, drawnumber_motion_glist);
if (drawnumber_motion_array) array_redraw(drawnumber_motion_array, drawnumber_motion_glist);
***************
*** 5899,5903 ****
drawnumber_getrect(z, glist, data, template, basex, basey, &x1, &y1, &x2, &y2);
if (xpix >= x1 && xpix <= x2 && ypix >= y1 && ypix <= y2
! && x->value.fd_var && fielddesc_getfloat(&x->vis, template, data, 0)) {
if (doit) {
drawnumber_motion_glist = glist;
--- 5897,5901 ----
drawnumber_getrect(z, glist, data, template, basex, basey, &x1, &y1, &x2, &y2);
if (xpix >= x1 && xpix <= x2 && ypix >= y1 && ypix <= y2
! && x->value.var && fielddesc_getfloat(&x->vis, template, data, 0)) {
if (doit) {
drawnumber_motion_glist = glist;
More information about the Pd-cvs
mailing list