[PD-cvs] pd/src desire.c, 1.1.2.154, 1.1.2.155 desire.h, 1.1.2.27, 1.1.2.28

Mathieu Bouchard matju at users.sourceforge.net
Thu Sep 7 02:52:20 CEST 2006


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22719

Modified Files:
      Tag: devel_0_39
	desire.c desire.h 
Log Message:
more removal of prefixes: t_drawnumber t_curve t_plot ...


Index: desire.h
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.h,v
retrieving revision 1.1.2.27
retrieving revision 1.1.2.28
diff -C2 -d -r1.1.2.27 -r1.1.2.28
*** desire.h	7 Sep 2006 00:38:15 -0000	1.1.2.27
--- desire.h	7 Sep 2006 00:52:18 -0000	1.1.2.28
***************
*** 169,174 ****
  typedef struct _linetraverser {
      t_canvas *canvas;
!     t_object *from; int tr_nout; int outlet; t_outlet *outletp;
!     t_object *to;   int tr_nin;  int inlet;  t_inlet  *inletp;
      t_outconnect *next;
      int nextoutno;
--- 169,174 ----
  typedef struct _linetraverser {
      t_canvas *canvas;
!     t_object *from; int nout; int outlet; t_outlet *outletp;
!     t_object *to;   int nin;  int inlet;  t_inlet  *inletp;
      t_outconnect *next;
      int nextoutno;

Index: desire.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v
retrieving revision 1.1.2.154
retrieving revision 1.1.2.155
diff -C2 -d -r1.1.2.154 -r1.1.2.155
*** desire.c	7 Sep 2006 00:38:14 -0000	1.1.2.154
--- desire.c	7 Sep 2006 00:52:17 -0000	1.1.2.155
***************
*** 414,418 ****
      t->canvas = x;
      t->next = 0;
!     t->nextoutno = t->tr_nout = 0;
  }
  
--- 414,418 ----
      t->canvas = x;
      t->next = 0;
!     t->nextoutno = t->nout = 0;
  }
  
***************
*** 422,426 ****
      while (!rval) {
          outno = t->nextoutno;
!         while (outno == t->tr_nout) {
              t_gobj *y;
              t_object *ob = 0;
--- 422,426 ----
      while (!rval) {
          outno = t->nextoutno;
!         while (outno == t->nout) {
              t_gobj *y;
              t_object *ob = 0;
***************
*** 430,434 ****
              if (!ob) return 0;
              t->from = ob;
!             t->tr_nout = obj_noutlets(ob);
              outno = 0;
          }
--- 430,434 ----
              if (!ob) return 0;
              t->from = ob;
!             t->nout = obj_noutlets(ob);
              outno = 0;
          }
***************
*** 438,443 ****
      }
      t->next = obj_nexttraverseoutlet(rval, &t->to, &t->inletp, &t->inlet);
!     t->tr_nin = obj_ninlets(t->to);
!     if (!t->tr_nin) bug("linetraverser_next");
      return rval;
  }
--- 438,443 ----
      }
      t->next = obj_nexttraverseoutlet(rval, &t->to, &t->inletp, &t->inlet);
!     t->nin = obj_ninlets(t->to);
!     if (!t->nin) bug("linetraverser_next");
      return rval;
  }
***************
*** 501,506 ****
      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 */
--- 501,505 ----
      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 */
***************
*** 523,528 ****
  
  static void canvas_coords(t_glist *x, t_symbol *s, int argc, t_atom *argv) {
!     pd_scanargs(argc,argv,"iiiiii;",&x->gl_x1,&x->gl_y1,&x->gl_x2,&x->gl_y2,
! 	&x->pixwidth,&x->pixheight);
      if (argc <= 7) canvas_setgraph(x, atom_getintarg(6, argc, argv), 1);
      else {
--- 522,526 ----
  
  static void canvas_coords(t_glist *x, t_symbol *s, int argc, t_atom *argv) {
!     pd_scanargs(argc,argv,"iiiiii;",&x->gl_x1,&x->gl_y1,&x->gl_x2,&x->gl_y2,&x->pixwidth,&x->pixheight);
      if (argc <= 7) canvas_setgraph(x, atom_getintarg(6, argc, argv), 1);
      else {
***************
*** 553,560 ****
          sym = gensym(buf);
          menu = 1;
!     }
!     else if (!strncmp((str = sym->s_name), "graph", 5)
!         && (zz = atoi(str + 5)) > gcount)
!             gcount = zz;
          /* in 0.34 and earlier, the pixel rectangle and the y bounds were
          reversed; this would behave the same, except that the dialog window
--- 551,555 ----
          sym = gensym(buf);
          menu = 1;
!     } else if (!strncmp((str = sym->s_name), "graph", 5) && (zz = atoi(str + 5)) > gcount) gcount = zz;
          /* in 0.34 and earlier, the pixel rectangle and the y bounds were
          reversed; this would behave the same, except that the dialog window
***************
*** 600,614 ****
      int heightwas = y2 - y1;
      if (x->screenx1 == x1 && x->screeny1 == y1 &&
!         x->screenx2 == x2 && x->screeny2 == y2)
!             return;
!     x->screenx1 = x1;
!     x->screeny1 = y1;
!     x->screenx2 = x2;
!     x->screeny2 = y2;
      if (!x->isgraph && (x->gl_y2 < x->gl_y1)) {
!             /* if it's flipped so that y grows upward,
!             fix so that zero is bottom edge and redraw.  This is
!             only appropriate if we're a regular "text" object on the
!             parent. */
          float diff = x->gl_y1 - x->gl_y2;
          x->gl_y1 = heightwas * diff;
--- 595,604 ----
      int heightwas = y2 - y1;
      if (x->screenx1 == x1 && x->screeny1 == y1 &&
!         x->screenx2 == x2 && x->screeny2 == y2) return;
!     x->screenx1 = x1; x->screeny1 = y1;
!     x->screenx2 = x2; x->screeny2 = y2;
      if (!x->isgraph && (x->gl_y2 < x->gl_y1)) {
!         /* if it's flipped so that y grows upward, fix so that zero is bottom edge and redraw.
! 	   This is only appropriate if we're a regular "text" object on the parent. */
          float diff = x->gl_y1 - x->gl_y2;
          x->gl_y1 = heightwas * diff;
***************
*** 3690,3694 ****
  typedef struct _vinlet {
      t_object x_obj;
!     t_canvas *x_canvas;
      t_inlet *x_inlet;
      int x_bufsize;
--- 3680,3684 ----
  typedef struct _vinlet {
      t_object x_obj;
!     t_canvas *canvas;
      t_inlet *x_inlet;
      int x_bufsize;
***************
*** 3706,3711 ****
  static void *vinlet_new(t_symbol *s) {
      t_vinlet *x = (t_vinlet *)pd_new(vinlet_class);
!     x->x_canvas = canvas_getcurrent();
!     x->x_inlet = canvas_addinlet(x->x_canvas, &x->x_obj.ob_pd, 0, s);
      x->x_bufsize = 0;
      x->x_buf = 0;
--- 3696,3701 ----
  static void *vinlet_new(t_symbol *s) {
      t_vinlet *x = (t_vinlet *)pd_new(vinlet_class);
!     x->canvas = canvas_getcurrent();
!     x->x_inlet = canvas_addinlet(x->canvas, &x->x_obj.ob_pd, 0, s);
      x->x_bufsize = 0;
      x->x_buf = 0;
***************
*** 3728,3732 ****
  
  static void vinlet_free(t_vinlet *x) {
!     canvas_rminlet(x->x_canvas, x->x_inlet);
      resample_free(&x->x_updown);
  }
--- 3718,3722 ----
  
  static void vinlet_free(t_vinlet *x) {
!     canvas_rminlet(x->canvas, x->x_inlet);
      resample_free(&x->x_updown);
  }
***************
*** 3882,3887 ****
  static void *vinlet_newsig(t_symbol *s) {
      t_vinlet *x = (t_vinlet *)pd_new(vinlet_class);
!     x->x_canvas = canvas_getcurrent();
!     x->x_inlet = canvas_addinlet(x->x_canvas, &x->x_obj.ob_pd, &s_signal,s);
      x->x_endbuf = x->x_buf = (t_float *)getalignedbytes(0);
      x->x_bufsize = 0;
--- 3872,3877 ----
  static void *vinlet_newsig(t_symbol *s) {
      t_vinlet *x = (t_vinlet *)pd_new(vinlet_class);
!     x->canvas = canvas_getcurrent();
!     x->x_inlet = canvas_addinlet(x->canvas, &x->x_obj.ob_pd, &s_signal,s);
      x->x_endbuf = x->x_buf = (t_float *)getalignedbytes(0);
      x->x_bufsize = 0;
***************
*** 3926,3930 ****
  typedef struct _voutlet {
      t_object x_obj;
!     t_canvas *x_canvas;
      t_outlet *x_parentoutlet;
      int x_bufsize;
--- 3916,3920 ----
  typedef struct _voutlet {
      t_object x_obj;
!     t_canvas *canvas;
      t_outlet *x_parentoutlet;
      int x_bufsize;
***************
*** 3946,3951 ****
  static void *voutlet_new(t_symbol *s) {
      t_voutlet *x = (t_voutlet *)pd_new(voutlet_class);
!     x->x_canvas = canvas_getcurrent();
!     x->x_parentoutlet = canvas_addoutlet(x->x_canvas, &x->x_obj.ob_pd, 0);
      inlet_new(&x->x_obj, &x->x_obj.ob_pd, 0, 0);
      x->x_bufsize = 0;
--- 3936,3941 ----
  static void *voutlet_new(t_symbol *s) {
      t_voutlet *x = (t_voutlet *)pd_new(voutlet_class);
!     x->canvas = canvas_getcurrent();
!     x->x_parentoutlet = canvas_addoutlet(x->canvas, &x->x_obj.ob_pd, 0);
      inlet_new(&x->x_obj, &x->x_obj.ob_pd, 0, 0);
      x->x_bufsize = 0;
***************
*** 3968,3972 ****
  
  static void voutlet_free(t_voutlet *x) {
!     canvas_rmoutlet(x->x_canvas, x->x_parentoutlet);
      resample_free(&x->x_updown);
  }
--- 3958,3962 ----
  
  static void voutlet_free(t_voutlet *x) {
!     canvas_rmoutlet(x->canvas, x->x_parentoutlet);
      resample_free(&x->x_updown);
  }
***************
*** 4136,4141 ****
  static void *voutlet_newsig(t_symbol *s) {
      t_voutlet *x = (t_voutlet *)pd_new(voutlet_class);
!     x->x_canvas = canvas_getcurrent();
!     x->x_parentoutlet = canvas_addoutlet(x->x_canvas, &x->x_obj.ob_pd, &s_signal);
      inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
      x->x_endbuf = x->x_buf = (t_float *)getalignedbytes(0);
--- 4126,4131 ----
  static void *voutlet_newsig(t_symbol *s) {
      t_voutlet *x = (t_voutlet *)pd_new(voutlet_class);
!     x->canvas = canvas_getcurrent();
!     x->x_parentoutlet = canvas_addoutlet(x->canvas, &x->x_obj.ob_pd, &s_signal);
      inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
      x->x_endbuf = x->x_buf = (t_float *)getalignedbytes(0);
***************
*** 5111,5122 ****
  typedef struct _curve {
      t_object x_obj;
!     int x_flags;            /* CLOSED and/or BEZ */
!     t_fielddesc x_fillcolor;
!     t_fielddesc x_outlinecolor;
!     t_fielddesc x_width;
!     t_fielddesc x_vis;
!     int x_npoints;
!     t_fielddesc *x_vec;
!     t_canvas *x_canvas;
  } t_curve;
  
--- 5101,5112 ----
  typedef struct _curve {
      t_object x_obj;
!     int flags;            /* CLOSED and/or BEZ */
!     t_fielddesc fillcolor;
!     t_fielddesc outlinecolor;
!     t_fielddesc width;
!     t_fielddesc vis;
!     int npoints;
!     t_fielddesc *vec;
!     t_canvas *canvas;
  } t_curve;
  
***************
*** 5127,5131 ****
      int nxy, i;
      t_fielddesc *fd;
!     x->x_canvas = canvas_getcurrent();
      if (classname[0] == 'f') {
          classname += 6;
--- 5117,5121 ----
      int nxy, i;
      t_fielddesc *fd;
!     x->canvas = canvas_getcurrent();
      if (classname[0] == 'f') {
          classname += 6;
***************
*** 5134,5155 ****
      else classname += 4;
      if (classname[0] == 'c') flags |= BEZ;
!     x->x_flags = flags;
!     fielddesc_setfloat_const(&x->x_vis, 1);
      while (1) {
          t_symbol *firstarg = atom_getsymbolarg(0, argc, argv);
          if (!strcmp(firstarg->s_name, "-v") && argc > 1) {
!             fielddesc_setfloatarg(&x->x_vis, 1, argv+1);
              argc -= 2; argv += 2;
          } else break;
      }
!     if ((flags & CLOSED) && argc) fielddesc_setfloatarg(&x->x_fillcolor, argc--, argv++); else fielddesc_setfloat_const(&x->x_fillcolor, 0); 
!     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 < 0) argc = 0;
!     nxy =  (argc + (argc & 1));
!     x->x_npoints = (nxy>>1);
!     x->x_vec = (t_fielddesc *)t_getbytes(nxy * sizeof(t_fielddesc));
!     for (i = 0, fd = x->x_vec; i < argc; i++, fd++, argv++)
!         fielddesc_setfloatarg(fd, 1, argv);
      if (argc & 1) fielddesc_setfloat_const(fd, 0);
      return x;
--- 5124,5148 ----
      else classname += 4;
      if (classname[0] == 'c') flags |= BEZ;
!     x->flags = flags;
!     fielddesc_setfloat_const(&x->vis, 1);
      while (1) {
          t_symbol *firstarg = atom_getsymbolarg(0, argc, argv);
          if (!strcmp(firstarg->s_name, "-v") && argc > 1) {
!             fielddesc_setfloatarg(&x->vis, 1, argv+1);
              argc -= 2; argv += 2;
          } else break;
      }
! 
!     if (flags&CLOSED&&argc) fielddesc_setfloatarg(&x->fillcolor,   argc--,argv++);
!     else                 fielddesc_setfloat_const(&x->fillcolor,   0);
!     if (argc)               fielddesc_setfloatarg(&x->outlinecolor,argc--,argv++);
!     else                 fielddesc_setfloat_const(&x->outlinecolor,0);
!     if (argc)               fielddesc_setfloatarg(&x->width,       argc--,argv++);
!     else                 fielddesc_setfloat_const(&x->width,       1);
      if (argc < 0) argc = 0;
!     nxy = argc + (argc&1);
!     x->npoints = (nxy>>1);
!     x->vec = (t_fielddesc *)t_getbytes(nxy * sizeof(t_fielddesc));
!     for (i = 0, fd = x->vec; i < argc; i++, fd++, argv++) fielddesc_setfloatarg(fd, 1, argv);
      if (argc & 1) fielddesc_setfloat_const(fd, 0);
      return x;
***************
*** 5158,5170 ****
  void curve_float(t_curve *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);
  }
  
--- 5151,5163 ----
  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);
!     fielddesc_setfloat_const(&x->vis, (f != 0));
!     canvas_redrawallfortemplatecanvas(x->canvas, 1);
  }
  
***************
*** 5175,5187 ****
  int *xp1, int *yp1, int *xp2, int *yp2) {
      t_curve *x = (t_curve *)z;
!     int i, n = x->x_npoints;
!     t_fielddesc *f = x->x_vec;
      int x1 = 0x7fffffff, x2 = -0x7fffffff, y1 = 0x7fffffff, y2 = -0x7fffffff;
!     if (!fielddesc_getfloat(&x->x_vis, template, data, 0)) {
          *xp1 = *yp1 = 0x7fffffff;
          *xp2 = *yp2 = -0x7fffffff;
          return;
      }
!     for (i = 0, f = x->x_vec; i < n; i++, f += 2) {
          int xloc = glist_xtopixels(glist, basex + fielddesc_getcoord(f  , template, data, 0));
          int yloc = glist_ytopixels(glist, basey + fielddesc_getcoord(f+1, template, data, 0));
--- 5168,5180 ----
  int *xp1, int *yp1, int *xp2, int *yp2) {
      t_curve *x = (t_curve *)z;
!     int i, n = x->npoints;
!     t_fielddesc *f = x->vec;
      int x1 = 0x7fffffff, x2 = -0x7fffffff, y1 = 0x7fffffff, y2 = -0x7fffffff;
!     if (!fielddesc_getfloat(&x->vis, template, data, 0)) {
          *xp1 = *yp1 = 0x7fffffff;
          *xp2 = *yp2 = -0x7fffffff;
          return;
      }
!     for (i = 0, f = x->vec; i < n; i++, f += 2) {
          int xloc = glist_xtopixels(glist, basex + fielddesc_getcoord(f  , template, data, 0));
          int yloc = glist_ytopixels(glist, basey + fielddesc_getcoord(f+1, template, data, 0));
***************
*** 5202,5210 ****
  }
  
- static void curve_select(t_gobj *z, t_glist *glist,
- t_word *data, t_template *template, float basex, float basey, int state) {
-     /* fill in later */
- }
- 
  static void curve_activate(t_gobj *z, t_glist *glist,
  t_word *data, t_template *template, float basex, float basey, int state) {
--- 5195,5198 ----
***************
*** 5232,5242 ****
  float basex, float basey, int vis) {
      t_curve *x = (t_curve *)z;
!     int i, n = x->x_npoints;
!     t_fielddesc *f = x->x_vec;
!     if (!fielddesc_getfloat(&x->x_vis, template, data, 0)) return;
      if (vis) {
          if (n > 1) {
!             int flags = x->x_flags;
!             float width = fielddesc_getfloat(&x->x_width, template, data, 1);
              char outline[20], fill[20];
              int pix[200];
--- 5220,5230 ----
  float basex, float basey, int vis) {
      t_curve *x = (t_curve *)z;
!     int i, n = x->npoints;
!     t_fielddesc *f = x->vec;
!     if (!fielddesc_getfloat(&x->vis, template, data, 0)) return;
      if (vis) {
          if (n > 1) {
!             int flags = x->flags;
!             float width = fielddesc_getfloat(&x->width, template, data, 1);
              char outline[20], fill[20];
              int pix[200];
***************
*** 5246,5250 ****
                 interspersed with it.  Only show up to 100 points so we don't
                 have to allocate memory here. */
!             for (i = 0, f = x->x_vec; i < n; i++, f += 2) {
                  pix[2*i] = glist_xtopixels(glist,
                      basex + fielddesc_getcoord(f, template, data, 1));
--- 5234,5238 ----
                 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) {
                  pix[2*i] = glist_xtopixels(glist,
                      basex + fielddesc_getcoord(f, template, data, 1));
***************
*** 5253,5259 ****
              }
              if (width < 1) width = 1;
!             numbertocolor(fielddesc_getfloat(&x->x_outlinecolor, template, data, 1), outline);
              if (flags & CLOSED) {
!                 numbertocolor(fielddesc_getfloat(&x->x_fillcolor, template, data, 1), fill);
                  sys_vgui(".x%lx.c create polygon\\\n", (long)glist_getcanvas(glist));
              } else sys_vgui(".x%lx.c create line\\\n", (long)glist_getcanvas(glist));
--- 5241,5247 ----
              }
              if (width < 1) width = 1;
!             numbertocolor(fielddesc_getfloat(&x->outlinecolor, template, data, 1), outline);
              if (flags & CLOSED) {
!                 numbertocolor(fielddesc_getfloat(&x->fillcolor, template, data, 1), fill);
                  sys_vgui(".x%lx.c create polygon\\\n", (long)glist_getcanvas(glist));
              } else sys_vgui(".x%lx.c create line\\\n", (long)glist_getcanvas(glist));
***************
*** 5283,5293 ****
  static t_template *curve_motion_template;
  
!     /* LATER protect against the template changing or the scalar disappearing
!     probably by attaching a gpointer here ... */
  
  #if 0
  static void curve_motion(void *z, t_floatarg dx, t_floatarg dy) {
      t_curve *x = (t_curve *)z;
!     t_fielddesc *f = x->x_vec + curve_motion_field;
      curve_motion_xcumulative += dx;
      curve_motion_ycumulative += dy;
--- 5271,5281 ----
  static t_template *curve_motion_template;
  
! /* LATER protect against the template changing or the scalar disappearing
!    probably by attaching a gpointer here ... */
  
  #if 0
  static void curve_motion(void *z, t_floatarg dx, t_floatarg dy) {
      t_curve *x = (t_curve *)z;
!     t_fielddesc *f = x->vec + curve_motion_field;
      curve_motion_xcumulative += dx;
      curve_motion_ycumulative += dy;
***************
*** 5307,5316 ****
  float basex, float basey, int xpix, int ypix, int shift, int alt, int dbl, int doit) {
      t_curve *x = (t_curve *)z;
!     int i, n = x->x_npoints;
      int bestn = -1;
      int besterror = 0x7fffffff;
      t_fielddesc *f;
!     if (!fielddesc_getfloat(&x->x_vis, template, data, 0)) return 0;
!     for (i = 0, f = x->x_vec; i < n; i++, f += 2) {
          int xval = fielddesc_getcoord(f, template, data, 0),   xloc = glist_xtopixels(glist, basex + xval);
          int yval = fielddesc_getcoord(f+1, template, data, 0), yloc = glist_ytopixels(glist, basey + yval);
--- 5295,5304 ----
  float basex, float basey, int xpix, int ypix, int shift, int alt, int dbl, int doit) {
      t_curve *x = (t_curve *)z;
!     int i, n = x->npoints;
      int bestn = -1;
      int besterror = 0x7fffffff;
      t_fielddesc *f;
!     if (!fielddesc_getfloat(&x->vis, template, data, 0)) return 0;
!     for (i = 0, f = x->vec; i < n; i++, f += 2) {
          int xval = fielddesc_getcoord(f, template, data, 0),   xloc = glist_xtopixels(glist, basex + xval);
          int yval = fielddesc_getcoord(f+1, template, data, 0), yloc = glist_ytopixels(glist, basey + yval);
***************
*** 5344,5358 ****
  }
  
! t_parentwidgetbehavior curve_widgetbehavior = {
!     curve_getrect,
!     curve_displace,
!     curve_select,
!     curve_activate,
!     curve_vis,
!     curve_click,
! };
  
  static void curve_free(t_curve *x) {
!     t_freebytes(x->x_vec, 2 * x->x_npoints * sizeof(*x->x_vec));
  }
  
--- 5332,5339 ----
  }
  
! t_parentwidgetbehavior curve_widgetbehavior = {curve_getrect,curve_displace,0,0,curve_vis,curve_click};
  
  static void curve_free(t_curve *x) {
!     t_freebytes(x->vec, 2 * x->npoints * sizeof(*x->vec));
  }
  
***************
*** 5374,5390 ****
  typedef struct _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_plot;
  
--- 5355,5369 ----
  typedef struct _plot {
      t_object x_obj;
!     t_canvas *canvas;
!     t_fielddesc outlinecolor;
!     t_fielddesc width;
!     t_fielddesc xloc, yloc;
!     t_fielddesc xinc;
!     t_fielddesc style;
!     t_fielddesc data;
!     t_fielddesc xpoints, ypoints;
!     t_fielddesc wpoints;
!     t_fielddesc vis;          /* visible */
!     t_fielddesc scalarvis;    /* true if drawing the scalar at each point */
  } t_plot;
  
***************
*** 5392,5401 ****
      t_plot *x = (t_plot *)pd_new(plot_class);
      int defstyle = PLOTSTYLE_POLY;
!     x->x_canvas = canvas_getcurrent();
!     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);
--- 5371,5380 ----
      t_plot *x = (t_plot *)pd_new(plot_class);
      int defstyle = PLOTSTYLE_POLY;
!     x->canvas = canvas_getcurrent();
!     fielddesc_setfloat_var(&x->xpoints, gensym("x"));
!     fielddesc_setfloat_var(&x->ypoints, gensym("y"));
!     fielddesc_setfloat_var(&x->wpoints, gensym("w"));
!     fielddesc_setfloat_const(&x->vis, 1);
!     fielddesc_setfloat_const(&x->scalarvis, 1);
      while (1) {
          t_symbol *firstarg = atom_getsymbolarg(0, argc, argv);
***************
*** 5405,5429 ****
              argc--, argv++;
          }
!         else if (!strcmp(f,"-v") &&argc>1) {fielddesc_setfloatarg(&x->x_vis,      1,argv+1);argc-=2;argv+=2;}
!         else if (!strcmp(f,"-vs")&&argc>1) {fielddesc_setfloatarg(&x->x_scalarvis,1,argv+1);argc-=2;argv+=2;}
!         else if (!strcmp(f,"-x") &&argc>1) {fielddesc_setfloatarg(&x->x_xpoints,  1,argv+1);argc-=2;argv+=2;}
!         else if (!strcmp(f,"-y") &&argc>1) {fielddesc_setfloatarg(&x->x_ypoints,  1,argv+1);argc-=2;argv+=2;}
! 	else if (!strcmp(f,"-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);
      return x;
  }
--- 5384,5408 ----
              argc--, argv++;
          }
!         else if (!strcmp(f,"-v") &&argc>1) {fielddesc_setfloatarg(&x->vis,      1,argv+1);argc-=2;argv+=2;}
!         else if (!strcmp(f,"-vs")&&argc>1) {fielddesc_setfloatarg(&x->scalarvis,1,argv+1);argc-=2;argv+=2;}
!         else if (!strcmp(f,"-x") &&argc>1) {fielddesc_setfloatarg(&x->xpoints,  1,argv+1);argc-=2;argv+=2;}
!         else if (!strcmp(f,"-y") &&argc>1) {fielddesc_setfloatarg(&x->ypoints,  1,argv+1);argc-=2;argv+=2;}
! 	else if (!strcmp(f,"-w") &&argc>1) {fielddesc_setfloatarg(&x->wpoints,  1,argv+1);argc-=2;argv+=2;}
          else break;
      }
!     if (argc) fielddesc_setarrayarg(   &x->data,         argc--, argv++);
! 	 else fielddesc_setfloat_const(&x->data, 1);
!     if (argc) fielddesc_setfloatarg(   &x->outlinecolor, argc--, argv++);
! 	 else fielddesc_setfloat_const(&x->outlinecolor, 0);
!     if (argc) fielddesc_setfloatarg(   &x->width,        argc--, argv++);
! 	 else fielddesc_setfloat_const(&x->width, 1);
!     if (argc) fielddesc_setfloatarg(   &x->xloc,         argc--, argv++);
! 	 else fielddesc_setfloat_const(&x->xloc, 1);
!     if (argc) fielddesc_setfloatarg(   &x->yloc,         argc--, argv++);
! 	 else fielddesc_setfloat_const(&x->yloc, 1);
!     if (argc) fielddesc_setfloatarg(   &x->xinc,         argc--, argv++);
! 	 else fielddesc_setfloat_const(&x->xinc, 1);
!     if (argc) fielddesc_setfloatarg(   &x->style,        argc--, argv++);
! 	 else fielddesc_setfloat_const(&x->style, defstyle);
      return x;
  }
***************
*** 5431,5443 ****
  void plot_float(t_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);
  }
  
--- 5410,5422 ----
  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);
!     fielddesc_setfloat_const(&x->vis, (f != 0));
!     canvas_redrawallfortemplatecanvas(x->canvas, 1);
  }
  
***************
*** 5455,5484 ****
  
          /* find the data and verify it's an array */
!     if (x->x_data.fd_type != A_ARRAY || !x->x_data.fd_var) {
          error("plot: needs an array field");
          return -1;
      }
!     if (!template_find_field(ownertemplate, x->x_data.fd_un.fd_varsym,
        &arrayonset, &type, &elemtemplatesym)) {
!         error("plot: %s: no such field", x->x_data.fd_un.fd_varsym->s_name);
          return -1;
      }
      if (type != DT_ARRAY) {
!         error("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;
      return 0;
  }
--- 5434,5463 ----
  
          /* 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;
      }
      array = *(t_array **)(((char *)data) + arrayonset);
!     *linewidthp = fielddesc_getfloat(&x->width, ownertemplate, data, 1);
!     *xlocp = fielddesc_getfloat(&x->xloc, ownertemplate, data, 1);
!     *xincp = fielddesc_getfloat(&x->xinc, ownertemplate, data, 1);
!     *ylocp = fielddesc_getfloat(&x->yloc, ownertemplate, data, 1);
!     *stylep = fielddesc_getfloat(&x->style, ownertemplate, data, 1);
!     *visp = fielddesc_getfloat(&x->vis, ownertemplate, data, 1);
!     *scalarvisp = fielddesc_getfloat(&x->scalarvis, ownertemplate, data, 1);
      *elemtemplatesymp = elemtemplatesym;
      *arrayp = array;
!     *xfield = &x->xpoints;
!     *yfield = &x->ypoints;
!     *wfield = &x->wpoints;
      return 0;
  }
***************
*** 5643,5647 ****
              int ixpix = 0;
  	    /* draw the trace */
!             numbertocolor(fielddesc_getfloat(&x->x_outlinecolor, template, data, 1), outline);
              if (wonset >= 0) {
  	    /* found "w" field which controls linewidth.  The trace is
--- 5622,5626 ----
              int ixpix = 0;
  	    /* draw the trace */
!             numbertocolor(fielddesc_getfloat(&x->outlinecolor, template, data, 1), outline);
              if (wonset >= 0) {
  	    /* found "w" field which controls linewidth.  The trace is
***************
*** 5798,5809 ****
  typedef struct _drawnumber {
      t_object x_obj;
!     t_fielddesc x_value;
!     t_fielddesc x_xloc;
!     t_fielddesc x_yloc;
!     t_fielddesc x_color;
!     t_fielddesc x_vis;
!     t_symbol *x_label;
!     int x_flags;
!     t_canvas *x_canvas;
  } t_drawnumber;
  
--- 5777,5788 ----
  typedef struct _drawnumber {
      t_object x_obj;
!     t_fielddesc value;
!     t_fielddesc xloc;
!     t_fielddesc yloc;
!     t_fielddesc color;
!     t_fielddesc vis;
!     t_symbol *label;
!     int flags;
!     t_canvas *canvas;
  } t_drawnumber;
  
***************
*** 5813,5837 ****
      int flags = 0;
      if (classname[4] == 's') flags |= DRAW_SYMBOL;
!     x->x_flags = flags;
!     fielddesc_setfloat_const(&x->x_vis, 1);
!     x->x_canvas = canvas_getcurrent();
      while (1) {
          t_symbol *firstarg = atom_getsymbolarg(0, argc, argv);
          if (!strcmp(firstarg->s_name, "-v") && argc > 1) {
!             fielddesc_setfloatarg(&x->x_vis, 1, argv+1);
              argc -= 2; argv += 2;
          } else break;
      }
      if (flags & DRAW_SYMBOL) {
!         if (argc) fielddesc_setsymbolarg(   &x->x_value,argc--,argv++);
! 	else      fielddesc_setsymbol_const(&x->x_value,&s_);
      } else {
!         if (argc) fielddesc_setfloatarg(    &x->x_value,argc--,argv++);
! 	else      fielddesc_setfloat_const( &x->x_value, 0);
      }
!     if (argc) fielddesc_setfloatarg(&x->x_xloc, argc--,argv++); else fielddesc_setfloat_const(&x->x_xloc, 0);
!     if (argc) fielddesc_setfloatarg(&x->x_yloc, argc--,argv++); else fielddesc_setfloat_const(&x->x_yloc, 0);
!     if (argc) fielddesc_setfloatarg(&x->x_color,argc--,argv++); else fielddesc_setfloat_const(&x->x_color, 1);
!     if (argc) x->x_label = atom_getsymbolarg(0, argc, argv); else x->x_label = &s_;
      return x;
  }
--- 5792,5816 ----
      int flags = 0;
      if (classname[4] == 's') flags |= DRAW_SYMBOL;
!     x->flags = flags;
!     fielddesc_setfloat_const(&x->vis, 1);
!     x->canvas = canvas_getcurrent();
      while (1) {
          t_symbol *firstarg = atom_getsymbolarg(0, argc, argv);
          if (!strcmp(firstarg->s_name, "-v") && argc > 1) {
!             fielddesc_setfloatarg(&x->vis, 1, argv+1);
              argc -= 2; argv += 2;
          } else break;
      }
      if (flags & DRAW_SYMBOL) {
!         if (argc) fielddesc_setsymbolarg(   &x->value,argc--,argv++);
! 	else      fielddesc_setsymbol_const(&x->value,&s_);
      } else {
!         if (argc) fielddesc_setfloatarg(    &x->value,argc--,argv++);
! 	else      fielddesc_setfloat_const( &x->value, 0);
      }
!     if (argc) fielddesc_setfloatarg(&x->xloc, argc--,argv++); else fielddesc_setfloat_const(&x->xloc, 0);
!     if (argc) fielddesc_setfloatarg(&x->yloc, argc--,argv++); else fielddesc_setfloat_const(&x->yloc, 0);
!     if (argc) fielddesc_setfloatarg(&x->color,argc--,argv++); else fielddesc_setfloat_const(&x->color, 1);
!     if (argc) x->label = atom_getsymbolarg(0, argc, argv); else x->label = &s_;
      return x;
  }
***************
*** 5839,5851 ****
  void drawnumber_float(t_drawnumber *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);
  }
  
--- 5818,5830 ----
  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);
!     fielddesc_setfloat_const(&x->vis, f!=0);
!     canvas_redrawallfortemplatecanvas(x->canvas, 1);
  }
  
***************
*** 5855,5859 ****
  static void drawnumber_sprintf(t_drawnumber *x, char *buf, t_atom *ap) {
      int nchars;
!     strncpy(buf, x->x_label->s_name, DRAWNUMBER_BUFSIZE);
      buf[DRAWNUMBER_BUFSIZE - 1] = 0;
      nchars = strlen(buf);
--- 5834,5838 ----
  static void drawnumber_sprintf(t_drawnumber *x, char *buf, t_atom *ap) {
      int nchars;
!     strncpy(buf, x->label->s_name, DRAWNUMBER_BUFSIZE);
      buf[DRAWNUMBER_BUFSIZE - 1] = 0;
      nchars = strlen(buf);
***************
*** 5867,5880 ****
      int xloc, yloc;
      char buf[DRAWNUMBER_BUFSIZE];
!     if (!fielddesc_getfloat(&x->x_vis, template, data, 0)) {
          *xp1 = *yp1 = 0x7fffffff;
          *xp2 = *yp2 = -0x7fffffff;
          return;
      }
!     xloc = glist_xtopixels(glist, basex + fielddesc_getcoord(&x->x_xloc, template, data, 0));
!     yloc = glist_ytopixels(glist, basey + fielddesc_getcoord(&x->x_yloc, template, data, 0));
!     if (x->x_flags & DRAW_SYMBOL)
!         SETSYMBOL(&at, fielddesc_getsymbol(&x->x_value, template, data, 0));
!     else SETFLOAT(&at,  fielddesc_getfloat(&x->x_value, template, data, 0));
      drawnumber_sprintf(x, buf, &at);
      *xp1 = xloc;
--- 5846,5859 ----
      int xloc, yloc;
      char buf[DRAWNUMBER_BUFSIZE];
!     if (!fielddesc_getfloat(&x->vis, template, data, 0)) {
          *xp1 = *yp1 = 0x7fffffff;
          *xp2 = *yp2 = -0x7fffffff;
          return;
      }
!     xloc = glist_xtopixels(glist, basex + fielddesc_getcoord(&x->xloc, template, data, 0));
!     yloc = glist_ytopixels(glist, basey + fielddesc_getcoord(&x->yloc, template, data, 0));
!     if (x->flags & DRAW_SYMBOL)
!         SETSYMBOL(&at, fielddesc_getsymbol(&x->value, template, data, 0));
!     else SETFLOAT(&at,  fielddesc_getfloat(&x->value, template, data, 0));
      drawnumber_sprintf(x, buf, &at);
      *xp1 = xloc;
***************
*** 5892,5905 ****
  float basex, float basey, int vis) {
      t_drawnumber *x = (t_drawnumber *)z;
!     if (!fielddesc_getfloat(&x->x_vis, template, data, 0)) return;
      if (vis) {
          t_atom at;
!         int xloc = glist_xtopixels(glist, basex + fielddesc_getcoord(&x->x_xloc, template, data, 0));
!         int yloc = glist_ytopixels(glist, basey + fielddesc_getcoord(&x->x_yloc, template, data, 0));
          char colorstring[20], buf[DRAWNUMBER_BUFSIZE];
!         numbertocolor(fielddesc_getfloat(&x->x_color, template, data, 1), colorstring);
!         if (x->x_flags & DRAW_SYMBOL)
!             SETSYMBOL(&at, fielddesc_getsymbol(&x->x_value, template, data, 0));
!         else SETFLOAT(&at, fielddesc_getfloat( &x->x_value, template, data, 0));
          drawnumber_sprintf(x, buf, &at);
          sys_vgui(".x%lx.c create text %d %d -anchor nw -fill %s -text {%s}",
--- 5871,5884 ----
  float basex, float basey, int vis) {
      t_drawnumber *x = (t_drawnumber *)z;
!     if (!fielddesc_getfloat(&x->vis, template, data, 0)) return;
      if (vis) {
          t_atom at;
!         int xloc = glist_xtopixels(glist, basex + fielddesc_getcoord(&x->xloc, template, data, 0));
!         int yloc = glist_ytopixels(glist, basey + fielddesc_getcoord(&x->yloc, template, data, 0));
          char colorstring[20], buf[DRAWNUMBER_BUFSIZE];
!         numbertocolor(fielddesc_getfloat(&x->color, template, data, 1), colorstring);
!         if (x->flags & DRAW_SYMBOL)
!             SETSYMBOL(&at, fielddesc_getsymbol(&x->value, template, data, 0));
!         else SETFLOAT(&at, fielddesc_getfloat( &x->value, template, data, 0));
          drawnumber_sprintf(x, buf, &at);
          sys_vgui(".x%lx.c create text %d %d -anchor nw -fill %s -text {%s}",
***************
*** 5924,5928 ****
  static void drawnumber_motion(void *z, t_floatarg dx, t_floatarg dy) {
      t_drawnumber *x = (t_drawnumber *)z;
!     t_fielddesc *f = &x->x_value;
      drawnumber_motion_ycumulative -= dy;
      template_setfloat(drawnumber_motion_template,
--- 5903,5907 ----
  static void drawnumber_motion(void *z, t_floatarg dx, t_floatarg dy) {
      t_drawnumber *x = (t_drawnumber *)z;
!     t_fielddesc *f = &x->value;
      drawnumber_motion_ycumulative -= dy;
      template_setfloat(drawnumber_motion_template,
***************
*** 5938,5942 ****
      drawnumber_getrect(z, glist, data, template, basex, basey, &x1, &y1, &x2, &y2);
      if (xpix >= x1 && xpix <= x2 && ypix >= y1 && ypix <= y2
!       && x->x_value.fd_var && fielddesc_getfloat(&x->x_vis, template, data, 0)) {
          if (doit) {
              drawnumber_motion_glist = glist;
--- 5917,5921 ----
      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;
***************
*** 5945,5949 ****
              drawnumber_motion_scalar = sc;
              drawnumber_motion_array = ap;
!             drawnumber_motion_ycumulative = fielddesc_getfloat(&x->x_value, template, data, 0);
              /* glist_grab(glist, z, drawnumber_motion, 0, xpix, ypix); */
          }
--- 5924,5928 ----
              drawnumber_motion_scalar = sc;
              drawnumber_motion_array = ap;
!             drawnumber_motion_ycumulative = fielddesc_getfloat(&x->value, template, data, 0);
              /* glist_grab(glist, z, drawnumber_motion, 0, xpix, ypix); */
          }





More information about the Pd-cvs mailing list