[PD-cvs] pd/src desire.c,1.1.2.217.2.231,1.1.2.217.2.232

Mathieu Bouchard matju at users.sourceforge.net
Mon Aug 20 05:46:33 CEST 2007


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

Modified Files:
      Tag: desiredata
	desire.c 
Log Message:
fixed bugs in t_boxes and pd_scanargs; wrote some of t_gop_filtre


Index: desire.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v
retrieving revision 1.1.2.217.2.231
retrieving revision 1.1.2.217.2.232
diff -C2 -d -r1.1.2.217.2.231 -r1.1.2.217.2.232
*** desire.c	19 Aug 2007 05:04:01 -0000	1.1.2.217.2.231
--- desire.c	20 Aug 2007 03:46:28 -0000	1.1.2.217.2.232
***************
*** 98,102 ****
  		while (iter->second != x) iter++;
  		iter++;
! 		return iter->second;
  	}
  	void add(t_gobj *x) {map.insert(KV(x->dix->index,x)); invariant();}
--- 98,102 ----
  		while (iter->second != x) iter++;
  		iter++;
! 		return iter == map.end() ? 0 : iter->second;
  	}
  	void add(t_gobj *x) {map.insert(KV(x->dix->index,x)); invariant();}
***************
*** 111,114 ****
--- 111,117 ----
  }
  
+ void boxes_notice(t_boxes *self, t_gobj *origin, int argc, t_atom *argv) {
+ }
+ 
  void boxes_free(t_boxes *self) {self->~t_boxes();}
  
***************
*** 120,131 ****
  
  struct t_gop_filtre : t_gobj {
  };
  
! t_gobj *gop_filtre_new() {
  	t_gop_filtre *self = (t_gop_filtre *)pd_new(gop_filtre_class);
  	new(self) t_gop_filtre;
  	return self;
  }
  
  //--------------------------------------------------------------------------
  // t_appendix: an extension to t_gobj made by matju so that all t_gobj's may have new fields
--- 123,157 ----
  
  struct t_gop_filtre : t_gobj {
+ 	t_canvas *canvas;
  };
  
! // test for half-open interval membership
! bool inside (int x, int x0, int x1) {return x0<=x && x<x1;}
! 
! /* this method is always called when a canvas is in gop mode so we don't check for this */
! /* it doesn't filtre out all that needs to be filtred out, but does not filtre out anything that has to stay */
! void gop_filtre_notice(t_gop_filtre *self,t_gobj *origin, int argc, t_atom *argv) {
! 	/* here, assume that the canvas *is* a gop; else we wouldn't be in this method. */
! 	t_object *o = (t_object *)origin;
! 	t_canvas *c = self->canvas;
! 	if (c->goprect) {
! 		if (!inside(o->x, c->xmargin, c->xmargin + c->pixwidth )) return;
! 		if (!inside(o->y, c->ymargin, c->ymargin + c->pixheight)) return;
! 	} else {
! 		
! 	}
! 	gobj_changed3(self,origin,argc,argv);
! }
! 
! t_gobj *gop_filtre_new(t_canvas *canvas) {
  	t_gop_filtre *self = (t_gop_filtre *)pd_new(gop_filtre_class);
  	new(self) t_gop_filtre;
+ 	self->canvas = canvas;
+ 	gobj_subscribe(canvas->boxes,self);
  	return self;
  }
  
+ void gop_filtre_free(t_boxes *self) {}
+ 
  //--------------------------------------------------------------------------
  // t_appendix: an extension to t_gobj made by matju so that all t_gobj's may have new fields
***************
*** 2204,2224 ****
  }
  
- /* get the window location in pixels of a "text" object.  The object's x and y positions are in pixels
-    when the canvas they're in is toplevel.  Otherwise, if it's a new-style graph-on-parent (so goprect
-    is set) we use the offset into the framing subrectangle as an offset into the parent rectangle.
-    Finally, it might be an old, proportional-style GOP. In this case we do a coordinate transformation. */
- static int text_xpix(t_text *x, t_canvas *canvas) {
-     float width = canvas->x2-canvas->x1;
-     if (canvas->havewindow || !canvas->gop) return x->x;
-     if (canvas->goprect) return canvas->x+x->x-canvas->xmargin;
-     return canvas_xtopixels(canvas, canvas->x1 + width * x->x / (canvas->screenx2-canvas->screenx1));
- }
- static int text_ypix(t_text *x, t_canvas *canvas) {
-     float height = canvas->y2-canvas->y1;
-     if (canvas->havewindow || !canvas->gop) return x->y;
-     if (canvas->goprect) return canvas->y+x->y-canvas->ymargin;
-     return canvas_ytopixels(canvas, canvas->y1 + height* x->y / (canvas->screeny2-canvas->screeny1));
- }
- 
  /* --------------------------- widget behavior  ------------------- */
  /* don't remove this code yet: has to be rewritten in tcl */
--- 2230,2233 ----
***************
*** 2298,2303 ****
  #endif
  
! /* get the graph's rectangle, not counting extra swelling for controls
!    to keep them inside the graph.  This is the "logical" pixel size. */
  static void graph_graphrect(t_gobj *z, t_canvas *canvas, int *xp1, int *yp1, int *xp2, int *yp2) {
      t_canvas *x = (t_canvas *)z;
--- 2307,2322 ----
  #endif
  
! static int text_xpix(t_text *x, t_canvas *canvas) {
!     float width = canvas->x2-canvas->x1;
!     if (canvas->havewindow || !canvas->gop) return x->x;
!     if (canvas->goprect) return canvas->x+x->x-canvas->xmargin;
!     return canvas_xtopixels(canvas, canvas->x1 + width * x->x / (canvas->screenx2-canvas->screenx1));
! }
! static int text_ypix(t_text *x, t_canvas *canvas) {
!     float height = canvas->y2-canvas->y1;
!     if (canvas->havewindow || !canvas->gop) return x->y;
!     if (canvas->goprect) return canvas->y+x->y-canvas->ymargin;
!     return canvas_ytopixels(canvas, canvas->y1 + height* x->y / (canvas->screeny2-canvas->screeny1));
! }
  static void graph_graphrect(t_gobj *z, t_canvas *canvas, int *xp1, int *yp1, int *xp2, int *yp2) {
      t_canvas *x = (t_canvas *)z;
***************
*** 5721,5739 ****
  int pd_vscanargs(int argc, t_atom *argv, char *fmt, va_list val) {
      int optional=0;
!     int i;
!     for (i=0; i<argc; i++) {
  	switch (fmt[i]) {
! 	    case  0 : goto err; /* too many args */
  	    case '*': goto break1; /* rest is any type */
  	    case 'F': case 'f': case 'd': case 'i': case 'c': case 'b':
! 		if (!IS_A_FLOAT(argv,i)) goto err; break;
! 	    case 'S': case 's': if (!IS_A_SYMBOL(argv,i)) goto err; break;
  	    case '?': break;
! 	    case 'a': if (!IS_A_FLOAT(argv,i) && !IS_A_SYMBOL(argv,i)) goto err; break;
  	    case ';': optional=1; break;
! 	    default: post("WARNING: bug using pd_scanargs()"); goto err; /* WHAT? */
  	}
      }
!     if (fmt[i]!=0 && !optional) goto err; /* not enough args */
  break1:
      i=0;
--- 5740,5763 ----
  int pd_vscanargs(int argc, t_atom *argv, char *fmt, va_list val) {
      int optional=0;
!     int i,j=0;
!     for (i=0; fmt[i]; i++) {
  	switch (fmt[i]) {
! 	    case 0: error("too many args"); return 0;
  	    case '*': goto break1; /* rest is any type */
  	    case 'F': case 'f': case 'd': case 'i': case 'c': case 'b':
! 		if (!IS_A_FLOAT(argv,j)) {error("expected float in $%d",i+1); return 0;}
! 		j++; break;
! 	    case 'S': case 's':
! 		if (!IS_A_SYMBOL(argv,j)) {error("expected symbol in $%d",i+1); return 0;}
! 		j++; break;
  	    case '?': break;
! 	    case 'a':
! 		if (!IS_A_FLOAT(argv,j) && !IS_A_SYMBOL(argv,j)) {error("expected float or symbol in $%d",i+1); return 0;}
! 		j++; break;
  	    case ';': optional=1; break;
! 	    default: error("bad format string"); return 0;
  	}
      }
!     if (j<argc && !optional) {error("not enough args"); return 0;}
  break1:
      i=0;
***************
*** 5760,5764 ****
  		}
  	    break;
! 	    default: post("WARNING: bug using pd_scanargs()"); goto err; /* WHAT? */
  	}
  	i++;
--- 5784,5788 ----
  		}
  	    break;
! 	    default: post("WARNING: bug using pd_scanargs()"); return 0; /* hmm? */
  	}
  	i++;
***************
*** 5766,5773 ****
  break2:
      return 1;
- err:
-     /* maybe it should fill in some default values */
-     //post("WARNING: pd_scanargs failed; fmt=%s, i=%d",fmt,i);
-     return 0;
  }
  
--- 5790,5793 ----
***************
*** 6053,6057 ****
      bng_check_minmax(x);
      outlet_new(x, &s_bang);
!     bng_reload(x,0,argc,argv);
      return x;
  }
--- 6073,6077 ----
      bng_check_minmax(x);
      outlet_new(x, &s_bang);
!     if (argc) bng_reload(x,0,argc,argv);
      return x;
  }
***************
*** 6828,6832 ****
  
  extern "C" void boxes_init() {
!     boxes_class = class_new2("__boxes",boxes_new,boxes_free,sizeof(t_boxes),CLASS_GOBJ,"");
  }
  
--- 6848,6856 ----
  
  extern "C" void boxes_init() {
!     t_class *c;
!     c =      boxes_class = class_new2("__boxes"     ,0/*boxes_new*/     ,     boxes_free,sizeof(t_boxes),CLASS_GOBJ,"");
!     class_setnotice(c,t_notice(boxes_notice));
!     c = gop_filtre_class = class_new2("__gop_filtre",0/*gop_filtre_new*/,gop_filtre_free,sizeof(t_boxes),CLASS_GOBJ,"");
!     class_setnotice(c,t_notice(gop_filtre_notice));
  }
  





More information about the Pd-cvs mailing list