[PD-cvs] pd/src desire.c,1.1.2.176,1.1.2.177
Mathieu Bouchard
matju at users.sourceforge.net
Mon Sep 11 08:49:46 CEST 2006
Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23606
Modified Files:
Tag: devel_0_39
desire.c
Log Message:
.
Index: desire.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v
retrieving revision 1.1.2.176
retrieving revision 1.1.2.177
diff -C2 -d -r1.1.2.176 -r1.1.2.177
*** desire.c 11 Sep 2006 05:00:42 -0000 1.1.2.176
--- desire.c 11 Sep 2006 06:49:42 -0000 1.1.2.177
***************
*** 24,27 ****
--- 24,28 ----
#include "m_simd.h"
#include <errno.h>
+ #include <math.h>
#ifdef MSW
***************
*** 63,66 ****
--- 64,70 ----
static void postatom2(const char *s, int argc, t_atom *argv);
+ int imin(int a, int b) {return a<b?a:b;}
+ int imax(int a, int b) {return a>b?a:b;}
+ t_symbol *s_empty, *s_pd, *s_Pd;
//--------------------------------------------------------------------------
***************
*** 371,381 ****
t_symbol *ret;
char *name = s->s_name;
! if (*name == '$' && name[1] >= '0' && name[1] <= '9') {
t_canvasenvironment *env = canvas_getenv(x);
pd_pushsym((t_pd *)x);
ret = binbuf_realizedollsym(gensym(name+1), env->argc, env->argv, 1);
pd_popsym((t_pd *)x);
! }
! else ret = s;
return ret;
}
--- 375,384 ----
t_symbol *ret;
char *name = s->s_name;
! if (*name == '$' && isdigit(name[1])) {
t_canvasenvironment *env = canvas_getenv(x);
pd_pushsym((t_pd *)x);
ret = binbuf_realizedollsym(gensym(name+1), env->argc, env->argv, 1);
pd_popsym((t_pd *)x);
! } else ret = s;
return ret;
}
***************
*** 404,410 ****
t_symbol *bs = canvas_makebindsym(x->name);
t_symbol *Pd = gensym("Pd");
! if (x->name==Pd) pd_unbind((t_pd *)x, bs);
x->name = s;
! if (x->name==Pd) pd_bind((t_pd *)x, bs);
if (dir && dir != &s_) canvas_getenv(x)->dir = dir;
gobj_changed(x,0);
--- 407,413 ----
t_symbol *bs = canvas_makebindsym(x->name);
t_symbol *Pd = gensym("Pd");
! if (x->name!=Pd) pd_unbind((t_pd *)x, bs);
x->name = s;
! if (x->name!=Pd) pd_bind((t_pd *)x, bs);
if (dir && dir != &s_) canvas_getenv(x)->dir = dir;
gobj_changed(x,0);
***************
*** 480,486 ****
t_canvas *owner = canvas_getcurrent();
t_symbol *s = &s_;
! int vis = 0, width = CANVAS_DEFCANVASWIDTH, height = CANVAS_DEFCANVASHEIGHT;
! int xloc = 0, yloc = CANVAS_DEFCANVASYLOC;
! int font = (owner ? owner->font : sys_defaultfont);
char buf[40];
canvas_init(x);
--- 483,489 ----
t_canvas *owner = canvas_getcurrent();
t_symbol *s = &s_;
! int width = CANVAS_DEFCANVASWIDTH, xloc = 0;
! int height = CANVAS_DEFCANVASHEIGHT, yloc = CANVAS_DEFCANVASYLOC;
! int vis=0, font = owner?owner->font:sys_defaultfont;
char buf[40];
canvas_init(x);
***************
*** 512,517 ****
canvas_setbounds(x, xloc, yloc, xloc + width, yloc + height);
x->owner = owner;
! x->name = *s->s_name ? s : canvas_newfilename ? canvas_newfilename : gensym("Pd");
! if (strcmp(x->name->s_name, "Pd")) pd_bind((t_pd *)x, canvas_makebindsym(x->name));
x->loading = 1;
x->goprect = 0; /* no GOP rectangle unless it's turned on later */
--- 515,520 ----
canvas_setbounds(x, xloc, yloc, xloc + width, yloc + height);
x->owner = owner;
! x->name = *s->s_name ? s : canvas_newfilename ? canvas_newfilename : s_Pd;
! if (x->name != s_Pd) pd_bind((t_pd *)x, canvas_makebindsym(x->name));
x->loading = 1;
x->goprect = 0; /* no GOP rectangle unless it's turned on later */
***************
*** 575,579 ****
if (x1 == x2 || y1 == y2) {x1=0; x2=100; y1=1; y2=-1;}
if (px1 >= px2 || py1 >= py2) {
! px1=100; py1=20; px2=100+CANVAS_DEFGRAPHWIDTH; py2=20+CANVAS_DEFGRAPHHEIGHT;
}
x->name = sym;
--- 578,583 ----
if (x1 == x2 || y1 == y2) {x1=0; x2=100; y1=1; y2=-1;}
if (px1 >= px2 || py1 >= py2) {
! px1=100; px2=px1+CANVAS_DEFGRAPHWIDTH;
! py1=20; py2=py1+CANVAS_DEFGRAPHHEIGHT;
}
x->name = sym;
***************
*** 582,586 ****
x->font = (canvas_getcurrent() ? canvas_getcurrent()->font : sys_defaultfont);
x->screenx1 = x->screeny1 = 0; x->screenx2 = 450; x->screeny2 = 300;
! if (strcmp(x->name->s_name, "Pd")) pd_bind((t_pd *)x, canvas_makebindsym(x->name));
x->owner = g;
x->isgraph = 1;
--- 586,590 ----
x->font = (canvas_getcurrent() ? canvas_getcurrent()->font : sys_defaultfont);
x->screenx1 = x->screeny1 = 0; x->screenx2 = 450; x->screeny2 = 300;
! if (x->name != s_Pd) pd_bind((t_pd *)x, canvas_makebindsym(x->name));
x->owner = g;
x->isgraph = 1;
***************
*** 702,706 ****
canvas_vis(x, 0);
sys_mgui(x,"delete","");
! if (strcmp(x->name->s_name, "Pd")) pd_unbind((t_pd *)x, canvas_makebindsym(x->name));
if (x->env) {
freebytes(x->env->argv, x->env->argc * sizeof(t_atom));
--- 706,710 ----
canvas_vis(x, 0);
sys_mgui(x,"delete","");
! if (x->name != s_Pd) pd_unbind((t_pd *)x, canvas_makebindsym(x->name));
if (x->env) {
freebytes(x->env->argv, x->env->argc * sizeof(t_atom));
***************
*** 759,764 ****
if (ap->a_type == A_SYMBOL) {
char *buf=ap->a_w.w_symbol->s_name, *bufp;
! if (*buf == '$' && buf[1] >= '0' && buf[1] <= '9') {
! for (bufp = buf+2; *bufp; bufp++) if (*bufp < '0' || *bufp > '9') {
SETDOLLSYM(ap, gensym(buf+1));
goto didit;
--- 763,768 ----
if (ap->a_type == A_SYMBOL) {
char *buf=ap->a_w.w_symbol->s_name, *bufp;
! if (*buf == '$' && isdigit(buf[1])) {
! for (bufp = buf+2; *bufp; bufp++) if (!isdigit(*bufp)) {
SETDOLLSYM(ap, gensym(buf+1));
goto didit;
***************
*** 770,775 ****
if (ap->a_type == A_DOLLSYM) {
t_canvasenvironment *e = canvas_getenv(canvas_getcurrent());
! canvas_rename(x, binbuf_realizedollsym(ap->a_w.w_symbol,
! e->argc, e->argv, 1), 0);
} else if (ap->a_type == A_SYMBOL)
canvas_rename(x, argv[3].a_w.w_symbol, 0);
--- 774,778 ----
if (ap->a_type == A_DOLLSYM) {
t_canvasenvironment *e = canvas_getenv(canvas_getcurrent());
! canvas_rename(x, binbuf_realizedollsym(ap->a_w.w_symbol, e->argc, e->argv, 1), 0);
} else if (ap->a_type == A_SYMBOL)
canvas_rename(x, argv[3].a_w.w_symbol, 0);
***************
*** 1297,1301 ****
for (i = 0; i < ac; i++) {
if (av[i].a_type == A_SYMBOL) {
! if (!strcmp(av[i].a_w.w_symbol->s_name, "_semi_")) SETSEMI(&av[i]);
else if (!strcmp(av[i].a_w.w_symbol->s_name, "_comma_")) SETCOMMA(&av[i]);
}
--- 1300,1304 ----
for (i = 0; i < ac; i++) {
if (av[i].a_type == A_SYMBOL) {
! if (!strcmp(av[i].a_w.w_symbol->s_name, "_semi_")) SETSEMI(&av[i]);
else if (!strcmp(av[i].a_w.w_symbol->s_name, "_comma_")) SETCOMMA(&av[i]);
}
***************
*** 1742,1747 ****
for (i = page * ARRAYPAGESIZE; (i < (page+1)*ARRAYPAGESIZE && i < a->n); i++) {
yval = *(float *)(a->vec + elemsize*i + yonset);
! sys_vgui(".%sArrayWindow.lb insert %d {%d) %g}\n",
! x->realname->s_name, i % ARRAYPAGESIZE, i, yval);
}
}
--- 1745,1749 ----
for (i = page * ARRAYPAGESIZE; (i < (page+1)*ARRAYPAGESIZE && i < a->n); i++) {
yval = *(float *)(a->vec + elemsize*i + yonset);
! sys_vgui(".%sArrayWindow.lb insert %d {%d) %g}\n", x->realname->s_name, i%ARRAYPAGESIZE, i, yval);
}
}
***************
*** 1752,1758 ****
gfxstub_deleteforkey(x);
pd_unbind(&x->x_gobj.g_pd, x->realname);
! /* LATER find a way to get #A unbound earlier (at end of load?) */
! while ((x2 = pd_findbyclass(gensym("#A"), garray_class)))
! pd_unbind(x2, gensym("#A"));
pd_free(&x->scalar->sc_gobj.g_pd);
}
--- 1754,1759 ----
gfxstub_deleteforkey(x);
pd_unbind(&x->x_gobj.g_pd, x->realname);
! /* LATER find a way to get #A unbound earlier (at end of load?) */
! while ((x2 = pd_findbyclass(gensym("#A"), garray_class))) pd_unbind(x2, gensym("#A"));
pd_free(&x->scalar->sc_gobj.g_pd);
}
***************
*** 1779,1784 ****
/* found "w" field which controls linewidth. */
float wval = *(float *)(elem + wonset);
! wpix = canvas_ytopixels(canvas, basey + slot_cvttocoord(yslot, yval) +
! slot_cvttocoord(wslot, wval)) - ypix;
if (wpix < 0) wpix = -wpix;
} else wpix = 1;
--- 1780,1785 ----
/* found "w" field which controls linewidth. */
float wval = *(float *)(elem + wonset);
! wpix = canvas_ytopixels(canvas,
! basey + slot_cvttocoord(yslot,yval) + slot_cvttocoord(wslot,wval)) - ypix;
if (wpix < 0) wpix = -wpix;
} else wpix = 1;
***************
*** 1796,1805 ****
t_word *wp;
t_template *template;
! int npoints;
! int elemsize;
! float initx;
! float xperpix, yperpix;
! int lastx;
! int fatten;
} ammo;
--- 1797,1803 ----
t_word *wp;
t_template *template;
! int npoints, elemsize;
! float initx, xperpix, yperpix;
! int lastx, fatten;
} ammo;
***************
*** 1820,1830 ****
if (ammo.fatten) {
if (i == 0) {
! float newy = ywas + dy * ammo.yperpix;
! if (newy < 0) newy = 0;
slot_setcoord(ammo.yfield, ammo.template, thisword, newy, 1);
}
! } else {
! slot_setcoord(ammo.yfield, ammo.template, thisword, ywas + dy*ammo.yperpix, 1);
! }
}
}
--- 1818,1825 ----
if (ammo.fatten) {
if (i == 0) {
! float newy = MAX(0,ywas+dy*ammo.yperpix);
slot_setcoord(ammo.yfield, ammo.template, thisword, newy, 1);
}
! } else slot_setcoord(ammo.yfield, ammo.template, thisword, ywas + dy*ammo.yperpix, 1);
}
}
***************
*** 1832,1848 ****
int thisx = ammo.initx + ammo.xcumulative + 0.5, x2;
int increment, i, nchange;
! float newy = ammo.ycumulative,
! oldy = slot_getcoord(ammo.yfield,
ammo.template, (t_word *)(((char *)ammo.wp) + ammo.elemsize * ammo.lastx), 1);
! float ydiff = newy - oldy;
! if (thisx < 0) thisx = 0;
! else if (thisx >= ammo.npoints) thisx = ammo.npoints - 1;
! 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.template, (t_word *)(((char *)ammo.wp) + ammo.elemsize * x2), newy, 1);
! if (nchange > 1) newy -= ydiff * (1./(nchange - 1));
}
ammo.lastx = thisx;
--- 1827,1841 ----
int thisx = ammo.initx + ammo.xcumulative + 0.5, x2;
int increment, i, nchange;
! float newy = ammo.ycumulative;
! float oldy = slot_getcoord(ammo.yfield,
ammo.template, (t_word *)(((char *)ammo.wp) + ammo.elemsize * ammo.lastx), 1);
! float ydiff = newy-oldy;
! CLAMP(thisx,0,1);
! 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.template, (t_word *)(((char *)ammo.wp) + ammo.elemsize * x2), newy, 1);
! if (nchange > 1) newy -= ydiff/(nchange-1);
}
ammo.lastx = thisx;
***************
*** 1890,1899 ****
}
- /* cursor definitions; used as return value for t_parentclickfn */
- #define CURSOR_RUNMODE_CLICKME 1
- #define CURSOR_RUNMODE_THICKEN 2
- #define CURSOR_RUNMODE_ADDPOINT 3
- #define CURSOR_EDITMODE_DISCONNECT 6
-
static float canvas_pixelstox(t_canvas *x, float xpix);
static float canvas_pixelstoy(t_canvas *x, float xpix);
--- 1883,1886 ----
***************
*** 1918,1933 ****
for (i = 0; i < array->n; i += incr) {
float pxpix, pypix, pwpix, dx, dy;
! array_getcoordinate(canvas, array->vec + elemsize*i, xonset, yonset, wonset, i,
xloc, yloc, xinc, xfield, yfield, wfield, &pxpix, &pypix, &pwpix);
if (pwpix < 4) pwpix = 4;
! dx = pxpix-xpix; if (dx<0) dx=-dx; else if (dx>8) continue;
! dy = pypix-ypix; if (dy<0) dy=-dy; else if (dx+dy<best) best=dx+dy;
if (wonset >= 0) {
! dy = pypix+pwpix-ypix;
! if (dy < 0) dy=-dy;
! if (dx+dy < best) best = dx+dy;
! dy = pypix-pwpix-ypix;
! if (dy < 0) dy=-dy;
! if (dx+dy < best) best = dx+dy;
}
} if (best > 8) {
--- 1905,1916 ----
for (i = 0; i < array->n; i += incr) {
float pxpix, pypix, pwpix, dx, dy;
! array_getcoordinate(canvas, &array->vec[elemsize*i], xonset, yonset, wonset, i,
xloc, yloc, xinc, xfield, yfield, wfield, &pxpix, &pypix, &pwpix);
if (pwpix < 4) pwpix = 4;
! dx = fabs(pxpix-xpix); if (dx>8) continue;
! dy = fabs(pypix-ypix); if (dx+dy<best) best=dx+dy;
if (wonset >= 0) {
! dy = fabs(pypix+pwpix-ypix); if (dx+dy < best) best = dx+dy;
! dy = fabs(pypix-pwpix-ypix); if (dx+dy < best) best = dx+dy;
}
} if (best > 8) {
***************
*** 1942,1950 ****
xloc, yloc, xinc, xfield, yfield, wfield, &pxpix, &pypix, &pwpix);
if (pwpix < 4) pwpix = 4;
! dx = pxpix-xpix; if (dx<0) dx=-dx;
! dy = pypix-ypix; if (dy<0) dy=-dy;
if (wonset >= 0) {
! dy2 = pypix+pwpix-ypix; if (dy2<0) dy2=-dy2;
! dy3 = pypix-pwpix-ypix; if (dy3<0) dy3=-dy3;
if (yonset < 0) dy = 100;
} else dy2 = dy3 = 100;
--- 1925,1933 ----
xloc, yloc, xinc, xfield, yfield, wfield, &pxpix, &pypix, &pwpix);
if (pwpix < 4) pwpix = 4;
! dx = fabs(pxpix-xpix);
! dy = fabs(pypix-ypix);
if (wonset >= 0) {
! dy2 = fabs(pypix+pwpix-ypix);
! dy3 = fabs(pypix-pwpix-ypix);
if (yonset < 0) dy = 100;
} else dy2 = dy3 = 100;
***************
*** 1954,1958 ****
else ammo.fatten = 1;
if (doit) {
! char *elem = (char *)array->vec;
ammo.elemsize = elemsize;
ammo.canvas = canvas;
--- 1937,1941 ----
else ammo.fatten = 1;
if (doit) {
! char *elem = array->vec;
ammo.elemsize = elemsize;
ammo.canvas = canvas;
***************
*** 1971,1975 ****
/* add a point (after the clicked-on one) */
array_resize_and_redraw(array, array->n + 1);
! elem = (char *)array->vec;
memmove(elem + elemsize * (i+1), elem + elemsize*i, (array->n-i-1) * elemsize);
i++;
--- 1954,1958 ----
/* add a point (after the clicked-on one) */
array_resize_and_redraw(array, array->n + 1);
! elem = array->vec;
memmove(elem + elemsize * (i+1), elem + elemsize*i, (array->n-i-1) * elemsize);
i++;
***************
*** 2003,2010 ****
/* canvas_grab(canvas, 0, array_motion, 0, xpix, ypix); */
}
! if (alt) {
! if (xpix < pxpix) return CURSOR_EDITMODE_DISCONNECT;
! else return CURSOR_RUNMODE_ADDPOINT;
! } else return ammo.fatten ? CURSOR_RUNMODE_THICKEN : CURSOR_RUNMODE_CLICKME;
}
}
--- 1986,1990 ----
/* canvas_grab(canvas, 0, array_motion, 0, xpix, ypix); */
}
! return 0;
}
}
***************
*** 2013,2018 ****
}
- #define ARRAYWRITECHUNKSIZE 1000
-
static void garray_save(t_gobj *z, t_binbuf *b) {
int style, filestyle;
--- 1993,1996 ----
***************
*** 2036,2042 ****
int n = array->n, n2 = 0;
while (n2 < n) {
! int chunk = n - n2, i;
! if (chunk > ARRAYWRITECHUNKSIZE)
! chunk = ARRAYWRITECHUNKSIZE;
binbuf_addv(b, "si", gensym("#A"), n2);
for (i = 0; i < chunk; i++) binbuf_addv(b, "f", ((float *)array->vec)[n2+i]);
--- 2014,2018 ----
int n = array->n, n2 = 0;
while (n2 < n) {
! int chunk = imin(n-n2,1000), i;
binbuf_addv(b, "si", gensym("#A"), n2);
for (i = 0; i < chunk; i++) binbuf_addv(b, "f", ((float *)array->vec)[n2+i]);
***************
*** 2079,2084 ****
t_array *array = garray_getarray_floatonly(x, &yonset, &elemsize);
TEMPLATE_FLOATY(x,array,)
! for (i = 0; i < array->n; i++)
! *((float *)((char *)array->vec + elemsize*i) + yonset) = g;
garray_redraw(x);
}
--- 2055,2059 ----
t_array *array = garray_getarray_floatonly(x, &yonset, &elemsize);
TEMPLATE_FLOATY(x,array,)
! for (i = 0; i < array->n; i++) *((float *)(array->vec + elemsize*i) + yonset) = g;
garray_redraw(x);
}
***************
*** 2099,2103 ****
if (sineflag) for (j=0, fj=phase; j<nsin; j++, fj+=phase) sum += vsin[j] * sin(fj);
else for (j=0, fj= 0; j<nsin; j++, fj+=phase) sum += vsin[j] * cos(fj);
! *((float *)((array->vec + elemsize*i)) + yonset) = sum;
}
garray_redraw(x);
--- 2074,2078 ----
if (sineflag) for (j=0, fj=phase; j<nsin; j++, fj+=phase) sum += vsin[j] * sin(fj);
else for (j=0, fj= 0; j<nsin; j++, fj+=phase) sum += vsin[j] * cos(fj);
! *((float *)(array->vec + elemsize*i) + yonset) = sum;
}
garray_redraw(x);
***************
*** 2203,2207 ****
}
for (i = 0; i < nelem; i++) {
! if (!fscanf(fd, "%f", ((float *)(array->vec + elemsize*i) + yonset))) {
post("%s: read %d elements into table of size %d", filename->s_name, i, nelem);
break;
--- 2178,2182 ----
}
for (i = 0; i < nelem; i++) {
! if (!fscanf(fd, "%f", (float *)(array->vec + elemsize*i) + yonset)) {
post("%s: read %d elements into table of size %d", filename->s_name, i, nelem);
break;
***************
*** 2920,2926 ****
/* check for file type */
nline = canvas_scanbinbuf(natoms, vec, &message, &nextmsg);
! if (nline != 1 && vec[message].a_type != A_SYMBOL &&
! strcmp(vec[message].a_w.w_symbol->s_name, "data"))
! {
pd_error(x, "%s: file apparently of wrong type", filename);
binbuf_free(b);
--- 2895,2899 ----
/* check for file type */
nline = canvas_scanbinbuf(natoms, vec, &message, &nextmsg);
! if (nline!=1 && vec[message].a_type != A_SYMBOL && strcmp(vec[message].a_w.w_symbol->s_name, "data")) {
pd_error(x, "%s: file apparently of wrong type", filename);
binbuf_free(b);
***************
*** 4308,4314 ****
/* globally conform all scalars from one template to another */
void template_conform(t_template *tfrom, t_template *tto) {
! int nto = tto->n, nfrom = tfrom->n, i, j,
! *conformaction = (int *)getbytes(sizeof(int) * nto),
! *conformedfrom = (int *)getbytes(sizeof(int) * nfrom), doit = 0;
for (i=0; i< nto; i++) conformaction[i] = -1;
for (i=0; i<nfrom; i++) conformedfrom[i] = 0;
--- 4281,4287 ----
/* globally conform all scalars from one template to another */
void template_conform(t_template *tfrom, t_template *tto) {
! int nto = tto->n, nfrom = tfrom->n, i, j, doit = 0;
! int *conformaction = (int *)getbytes(sizeof(int) * nto);
! int *conformedfrom = (int *)getbytes(sizeof(int) * nfrom);
for (i=0; i< nto; i++) conformaction[i] = -1;
for (i=0; i<nfrom; i++) conformedfrom[i] = 0;
***************
*** 4469,4473 ****
static void *gtemplate_new(t_symbol *s, int argc, t_atom *argv) {
t_symbol *sym = atom_getsymbolarg(0, argc, argv);
! if (argc >= 1) argc--; argv++;
return (gtemplate_donew(canvas_makebindsym(sym), argc, argv));
}
--- 4442,4446 ----
static void *gtemplate_new(t_symbol *s, int argc, t_atom *argv) {
t_symbol *sym = atom_getsymbolarg(0, argc, argv);
! if (argc >= 1) {argc--; argv++;}
return (gtemplate_donew(canvas_makebindsym(sym), argc, argv));
}
***************
*** 4481,4485 ****
warned = 1;
}
! return (gtemplate_donew(sym, argc, argv));
}
--- 4454,4458 ----
warned = 1;
}
! return gtemplate_donew(sym, argc, argv);
}
***************
*** 4552,4555 ****
--- 4525,4531 ----
}
+ float MIN(float a, float b) {return a<b?a:b;}
+ float MAX(float a, float b) {return a>b?a:b;}
+
static void slot_setfloat_var(t_slot *fd, t_symbol *s) {
char *s1, *s2, *s3, strbuf[MAXPDSTRING];
***************
*** 4560,4566 ****
fd->min = fd->max = fd->scrmin = fd->scrmax = fd->quantum = 0;
} else {
! int cpy = s1 - s->s_name, got;
! if (cpy > MAXPDSTRING-5)
! cpy = MAXPDSTRING-5;
strncpy(strbuf, s->s_name, cpy);
strbuf[cpy] = 0;
--- 4536,4540 ----
fd->min = fd->max = fd->scrmin = fd->scrmax = fd->quantum = 0;
} else {
! int cpy = MIN(s1-s->s_name,MAXPDSTRING-5), got;
strncpy(strbuf, s->s_name, cpy);
strbuf[cpy] = 0;
***************
*** 4736,4742 ****
/* -------------------- widget behavior for curve ------------ */
! static void curve_getrect(t_gobj *z, t_canvas *canvas,
! t_word *data, t_template *template, float basex, float basey,
! int *xp1, int *yp1, int *xp2, int *yp2) {
t_curve *x = (t_curve *)z;
int i, n = x->npoints;
--- 4710,4715 ----
/* -------------------- widget behavior for curve ------------ */
! static void curve_getrect(t_gobj *z, t_canvas *canvas, t_word *data, t_template *template,
! float basex, float basey, int *xp1, int *yp1, int *xp2, int *yp2) {
t_curve *x = (t_curve *)z;
int i, n = x->npoints;
***************
*** 4751,4780 ****
int xloc = canvas_xtopixels(canvas, basex + slot_getcoord(f , template, data, 0));
int yloc = canvas_ytopixels(canvas, basey + slot_getcoord(f+1, template, data, 0));
! if (xloc < x1) x1 = xloc;
! if (xloc > x2) x2 = xloc;
! if (yloc < y1) y1 = yloc;
! if (yloc > y2) y2 = yloc;
}
! *xp1 = x1;
! *yp1 = y1;
! *xp2 = x2;
! *yp2 = y2;
}
! /* 0 to 9 in 5 steps */
! static int rangecolor(int n) {
! int n2 = n/2; /* 0 to 4 */
! int ret = (n2 << 6); /* 0 to 256 in 5 steps */
! if (ret > 255) ret = 255;
! return ret;
! }
static void numbertocolor(int n, char *s) {
! int red, blue, green;
! if (n < 0) n = 0;
! red = n / 100;
! blue = ((n / 10) % 10);
! green = n % 10;
! sprintf(s, "#%2.2x%2.2x%2.2x", rangecolor(red), rangecolor(blue), rangecolor(green));
}
--- 4724,4741 ----
int xloc = canvas_xtopixels(canvas, basex + slot_getcoord(f , template, data, 0));
int yloc = canvas_ytopixels(canvas, basey + slot_getcoord(f+1, template, data, 0));
! x1=imin(x1,xloc); y1=imin(y1,yloc);
! x2=imax(x2,xloc); y2=imax(y2,yloc);
}
! *xp1 = x1; *yp1 = y1;
! *xp2 = x2; *yp2 = y2;
}
! /* this seems dumb */
! //static int rangecolor(int n) {return min((n/2)<<6,255);}
! static int rangecolor(int n) {return n*9/255;}
static void numbertocolor(int n, char *s) {
! n = MAX(n,0);
! sprintf(s, "#%2.2x%2.2x%2.2x", rangecolor(n/100), rangecolor((n/10)%10), rangecolor(n%10));
}
***************
*** 4788,4798 ****
if (n > 1) {
int flags = x->flags;
- float width = slot_getfloat(&x->width, template, data, 1);
char outline[20], fill[20];
int pix[200];
if (n > 100) n = 100;
! /* calculate the pixel values before we start printing
! out the TK message so that "error" printout won't be
! interspersed with it. Only show up to 100 points so we don't
have to allocate memory here. */
for (i = 0, f = x->vec; i < n; i++, f += 2) {
--- 4749,4757 ----
if (n > 1) {
int flags = x->flags;
char outline[20], fill[20];
int pix[200];
if (n > 100) n = 100;
! /* calculate the pixel values before we start printing out the TK message so that
! "error" printout won't be interspersed with it. Only show up to 100 points so we don't
have to allocate memory here. */
for (i = 0, f = x->vec; i < n; i++, f += 2) {
***************
*** 4800,4804 ****
pix[2*i+1] = canvas_ytopixels(canvas, basey + slot_getcoord(f+1, template, data, 1));
}
- if (width < 1) width = 1;
numbertocolor(slot_getfloat(&x->outlinecolor, template, data, 1), outline);
if (flags & CLOSED) {
--- 4759,4762 ----
***************
*** 4807,4811 ****
} else sys_vgui(".x%lx.c create line\\\n", (long)canvas_getcanvas(canvas));
for (i = 0; i < n; i++) sys_vgui("%d %d\\\n", pix[2*i], pix[2*i+1]);
! sys_vgui("-width %f\\\n", width);
if (flags & CLOSED) sys_vgui("-fill %s -outline %s\\\n", fill, outline);
else sys_vgui("-fill %s\\\n", outline);
--- 4765,4769 ----
} else sys_vgui(".x%lx.c create line\\\n", (long)canvas_getcanvas(canvas));
for (i = 0; i < n; i++) sys_vgui("%d %d\\\n", pix[2*i], pix[2*i+1]);
! sys_vgui("-width %f\\\n", MAX(slot_getfloat(&x->width, template, data, 1),1));
if (flags & CLOSED) sys_vgui("-fill %s -outline %s\\\n", fill, outline);
else sys_vgui("-fill %s\\\n", outline);
***************
*** 6248,6253 ****
} t_nbx;
- t_symbol *s_empty;
-
typedef struct t_foo { int argc; t_atom *argv; t_binbuf *b; } t_foo;
static int pd_pickle(t_foo *foo, char *fmt, ...);
--- 6206,6209 ----
***************
*** 6591,6597 ****
/* special case: if pd args change just pass the message on. */
if (natom1 >= 1 && natom2 >= 1 &&
! vec1[0].a_type == A_SYMBOL && !strcmp(vec1[0].a_w.w_symbol->s_name, "pd") &&
! vec2[0].a_type == A_SYMBOL && !strcmp(vec2[0].a_w.w_symbol->s_name, "pd")) {
! typedmess(&x->te_pd, gensym("rename"), natom2-1, vec2+1);
binbuf_free(x->te_binbuf);
x->te_binbuf = b;
--- 6547,6553 ----
/* special case: if pd args change just pass the message on. */
if (natom1 >= 1 && natom2 >= 1 &&
! vec1[0].a_type == A_SYMBOL && vec1[0].a_w.w_symbol == s_pd &&
! vec2[0].a_type == A_SYMBOL && vec2[0].a_w.w_symbol == s_pd) {
! typedmess((t_pd *)x, gensym("rename"), natom2-1, vec2+1);
binbuf_free(x->te_binbuf);
x->te_binbuf = b;
***************
*** 6987,6991 ****
static void iemgui_subclass (t_class *c) {
- s_empty = gensym("empty");
class_addmethod3(c, iemgui_delta, "delta","*");
class_addmethod3(c, iemgui_pos, "pos","*");
--- 6943,6946 ----
***************
*** 7962,7965 ****
--- 7917,7923 ----
void desire_setup(void) {
+ s_empty = gensym("empty");
+ s_Pd = gensym("Pd");
+ s_pd = gensym("pd");
manager_class = class_new(gensym("__manager"), (t_newmethod)manager_new,
(t_method)manager_free, sizeof(t_manager), CLASS_GOBJ, A_GIMME, 0);
More information about the Pd-cvs
mailing list