Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11493
Modified Files:
Tag: desiredata
desire.c
Log Message:
cleanup
Index: desire.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v
retrieving revision 1.1.2.217.2.182
retrieving revision 1.1.2.217.2.183
diff -C2 -d -r1.1.2.217.2.182 -r1.1.2.217.2.183
*** desire.c 1 Aug 2007 05:13:47 -0000 1.1.2.217.2.182
--- desire.c 1 Aug 2007 17:38:52 -0000 1.1.2.217.2.183
***************
*** 1514,1546 ****
int saveit = (flags&1)!=0;
int style = (flags>>1)&3;
! float stylewas = template_getfloat(
! template_findbyname(x->scalar->t), gensym("style"), x->scalar->v, 1);
! if (deleteit != 0) {
! canvas_delete(x->canvas,x);
! } else {
! int size;
! t_symbol *argname = sharptodollar(name);
! t_array *a = garray_getarray(x);
! t_template *scalartemplate;
! if (!a) {error("can't find array"); return;}
! if (!(scalartemplate = template_findbyname(x->scalar->t))) {error("no template of type %s", x->scalar->t->name); return;}
! if (argname != x->realname) {
! if (x->listviewing) garray_arrayviewlist_close(x);
! x->realname = argname; /* is this line supposed to exist? */
! pd_unbind(x,x->realname);
! x->realname = canvas_realizedollar(x->canvas, argname);
! pd_bind(x,x->realname);
! /* redraw the whole canvas, just so the name change shows up */
! if (x->canvas->havewindow) canvas_redraw(x->canvas);
! else if (canvas_isvisible(x->canvas->owner)) gobj_changed(x,0);
! }
! size = (int)fsize;
! if (size < 1) size = 1;
! if (size != a->n) garray_resize(x, size);
! else if (style != stylewas) garray_fittograph(x, size, style);
! template_setfloat(scalartemplate, gensym("style"), x->scalar->v, (float)style, 0);
! garray_setsaveit(x, saveit!=0);
! garray_redraw(x);
}
}
--- 1514,1540 ----
int saveit = (flags&1)!=0;
int style = (flags>>1)&3;
! float stylewas = template_getfloat(template_findbyname(x->scalar->t), gensym("style"), x->scalar->v, 1);
! if (deleteit) {canvas_delete(x->canvas,x); return;}
! t_symbol *argname = sharptodollar(name);
! t_array *a = garray_getarray(x);
! t_template *scalartemplate;
! if (!a) {error("can't find array"); return;}
! if (!(scalartemplate = template_findbyname(x->scalar->t))) {error("no template of type %s", x->scalar->t->name); return;}
! if (argname != x->realname) {
! if (x->listviewing) garray_arrayviewlist_close(x);
! x->realname = argname; /* is this line supposed to exist? */
! pd_unbind(x,x->realname);
! x->realname = canvas_realizedollar(x->canvas, argname);
! pd_bind(x,x->realname);
! /* redraw the whole canvas, just so the name change shows up */
! if (x->canvas->havewindow) canvas_redraw(x->canvas);
! else if (canvas_isvisible(x->canvas->owner)) gobj_changed(x,0);
}
+ int size = max(1,int(fsize));
+ if (size != a->n) garray_resize(x, size);
+ else if (style != stylewas) garray_fittograph(x, size, style);
+ template_setfloat(scalartemplate, gensym("style"), x->scalar->v, (float)style, 0);
+ garray_setsaveit(x, saveit!=0);
+ garray_redraw(x);
}
***************
*** 1636,1641 ****
ammo.ycumulative += dy * ammo.yperpix;
if (ammo.xfield) {// xy plot
! int i;
! for (i = 0; i < ammo.npoints; i++) {
t_word *thisword = (t_word *)(((char *)ammo.wp) + i*ammo.elemsize);
float xwas = slot_getcoord(ammo.xfield, ammo.t, thisword, 1);
--- 1630,1634 ----
ammo.ycumulative += dy * ammo.yperpix;
if (ammo.xfield) {// xy plot
! for (int i=0; i<ammo.npoints; i++) {
t_word *thisword = (t_word *)(((char *)ammo.wp) + i*ammo.elemsize);
float xwas = slot_getcoord(ammo.xfield, ammo.t, thisword, 1);
***************
*** 1645,1649 ****
if (ammo.fatten) {
if (i == 0) {
! float newy = max(0,ywas+dy*ammo.yperpix);
slot_setcoord(ammo.yfield, ammo.t, thisword, newy, 1);
}
--- 1638,1642 ----
if (ammo.fatten) {
if (i == 0) {
! float newy = max(0.f,ywas+dy*ammo.yperpix);
slot_setcoord(ammo.yfield, ammo.t, thisword, newy, 1);
}
***************
*** 1652,1657 ****
}
} else if (ammo.yfield) {// y plot
! int thisx = ammo.initx + ammo.xcumulative + 0.5, x2;
! int increment, i, nchange;
float newy = ammo.ycumulative;
float oldy = slot_getcoord(ammo.yfield, ammo.t, (t_word *)(((char *)ammo.wp) + ammo.elemsize * ammo.lastx), 1);
--- 1645,1650 ----
}
} else if (ammo.yfield) {// y plot
! int thisx = int(ammo.initx + ammo.xcumulative + 0.5), x2;
! int increment, nchange;
float newy = ammo.ycumulative;
float oldy = slot_getcoord(ammo.yfield, ammo.t, (t_word *)(((char *)ammo.wp) + ammo.elemsize * ammo.lastx), 1);
***************
*** 1660,1668 ****
increment = thisx > ammo.lastx ? -1 : 1;
nchange = 1 + increment * (ammo.lastx - thisx);
! for (i = 0, x2 = thisx; i < nchange; i++, x2 += increment) {
slot_setcoord(ammo.yfield, ammo.t, (t_word *)(((char *)ammo.wp) + ammo.elemsize * x2), newy, 1);
if (nchange > 1) newy -= ydiff/(nchange-1);
! }
! ammo.lastx = thisx;
}
if (ammo.scalar) scalar_redraw(ammo.scalar, ammo.canvas);
--- 1653,1662 ----
increment = thisx > ammo.lastx ? -1 : 1;
nchange = 1 + increment * (ammo.lastx - thisx);
! x2 = thisx;
! for (int i=0; i<nchange; i++, x2 += increment) {
slot_setcoord(ammo.yfield, ammo.t, (t_word *)(((char *)ammo.wp) + ammo.elemsize * x2), newy, 1);
if (nchange > 1) newy -= ydiff/(nchange-1);
! }
! ammo.lastx = thisx;
}
if (ammo.scalar) scalar_redraw(ammo.scalar, ammo.canvas);
***************
*** 2334,2338 ****
/* --------------------------- widget behavior ------------------- */
/* don't remove this code yet: has to be rewritten in tcl */
! #if 0
static void graph_vis(t_gobj *gr, int vis) {
t_canvas *x = (t_canvas *)gr;
--- 2328,2333 ----
/* --------------------------- widget behavior ------------------- */
/* don't remove this code yet: has to be rewritten in tcl */
! #if 1
! #define FONT "pourier"
static void graph_vis(t_gobj *gr, int vis) {
t_canvas *x = (t_canvas *)gr;
***************
*** 2351,2355 ****
return;
}
- float f;
/* draw a rectangle around the graph */
sys_vgui(".x%lx.c create line %d %d %d %d %d %d %d %d %d %d -tags %s\n",
--- 2346,2349 ----
***************
*** 2369,2372 ****
--- 2363,2367 ----
#define DRAWTICK(x1,y1,x2,y2) sys_vgui(".x%lx.c create line %d %d %d %d -tags %s\n", \
(long)c, int(x1),int(y1),int(x2),int(y2),tag)
+ float f;
if (x->xtick.lperb) {
float upix, lpix;
***************
*** 2416,2448 ****
}
! /*static float graph_lastxpix, graph_lastypix;
static void graph_motion(void *z, t_floatarg dx, t_floatarg dy) {
t_canvas *x = (t_canvas *)z;
float newxpix = graph_lastxpix + dx, newypix = graph_lastypix + dy;
t_garray *a = (t_garray *)x->list;
! int oldx = 0.5 + canvas_pixelstox(x, graph_lastxpix);
! int newx = 0.5 + canvas_pixelstox(x, newxpix);
! t_float *vec;
! int nelem, i;
float oldy = canvas_pixelstoy(x, graph_lastypix);
float newy = canvas_pixelstoy(x, newypix);
graph_lastxpix = newxpix;
graph_lastypix = newypix;
! // verify that the array is OK
if (!a || a->_class != garray_class) return;
if (!garray_getfloatarray(a, &nelem, &vec)) return;
if (oldx < 0) oldx = 0; else if (oldx >= nelem) oldx = nelem - 1;
if (newx < 0) newx = 0; else if (newx >= nelem) newx = nelem - 1;
! if (oldx < newx - 1) {
! for (i = oldx + 1; i <= newx; i++)
! vec[i] = newy + (oldy - newy) * ((float)(newx - i))/(float)(newx - oldx);
! } else if (oldx > newx + 1) {
! for (i = oldx - 1; i >= newx; i--)
! vec[i] = newy + (oldy - newy) * ((float)(newx - i))/(float)(newx - oldx);
! }
else vec[newx] = newy;
garray_redraw(a);
}
! */
/* fucntions to read and write canvases to files: canvas_savetofile() writes a root canvas to a "pd" file.
--- 2411,2439 ----
}
! #if 1
! static float graph_lastxpix, graph_lastypix;
static void graph_motion(void *z, t_floatarg dx, t_floatarg dy) {
t_canvas *x = (t_canvas *)z;
float newxpix = graph_lastxpix + dx, newypix = graph_lastypix + dy;
t_garray *a = (t_garray *)x->list;
! int oldx = int(0.5 + canvas_pixelstox(x, graph_lastxpix));
! int newx = int(0.5 + canvas_pixelstox(x, newxpix));
float oldy = canvas_pixelstoy(x, graph_lastypix);
float newy = canvas_pixelstoy(x, newypix);
graph_lastxpix = newxpix;
graph_lastypix = newypix;
! // verify that the array is OK
if (!a || a->_class != garray_class) return;
+ int nelem;
+ t_float *vec;
if (!garray_getfloatarray(a, &nelem, &vec)) return;
if (oldx < 0) oldx = 0; else if (oldx >= nelem) oldx = nelem - 1;
if (newx < 0) newx = 0; else if (newx >= nelem) newx = nelem - 1;
! if (oldx < newx - 1) {for (int i=oldx+1; i<=newx; i++) vec[i] = newy + (oldy-newy) * float(newx-i)/float(newx - oldx);}
! else if (oldx > newx + 1) {for (int i=oldx-1; i>=newx; i--) vec[i] = newy + (oldy-newy) * float(newx-i)/float(newx - oldx);}
else vec[newx] = newy;
garray_redraw(a);
}
! #endif
/* fucntions to read and write canvases to files: canvas_savetofile() writes a root canvas to a "pd" file.
***************
*** 2482,2486 ****
word_restore(w, t, argc, argv);
int n = t->n;
! for (int i = 0; i < n; i++) {
if (t->vec[i].type == DT_ARRAY) {
t_array *a = w[i].w_array;
--- 2473,2477 ----
word_restore(w, t, argc, argv);
int n = t->n;
! for (int i=0; i<n; i++) {
if (t->vec[i].type == DT_ARRAY) {
t_array *a = w[i].w_array;
***************
*** 2493,2497 ****
t_word *element;
int nline = canvas_scanbinbuf(natoms, vec, &message, p_nextmsg);
! /* empty line terminates array */
if (!nline) break;
array_resize(a, nitems + 1);
--- 2484,2488 ----
t_word *element;
int nline = canvas_scanbinbuf(natoms, vec, &message, p_nextmsg);
! /* empty line terminates array */
if (!nline) break;
array_resize(a, nitems + 1);
***************
*** 7407,7411 ****
dopost(error_string);
dopost("\n");
! error_object = pd_stackn ? pd_stack[pd_stackn-1].self : 0;
}
void error( const char *fmt, ...) {va_list ap; va_start(ap,fmt); verror(fmt,ap); va_end(ap);}
--- 7398,7403 ----
dopost(error_string);
dopost("\n");
! //post("at stack level %ld\n",pd_stackn);
! error_object = pd_stackn>=0 ? pd_stack[pd_stackn-1].self : 0;
}
void error( const char *fmt, ...) {va_list ap; va_start(ap,fmt); verror(fmt,ap); va_end(ap);}
***************
*** 7499,7501 ****
void gfxstub_deleteforkey () {BYE}
};
-
--- 7491,7492 ----