[xiph-commits] r12802 - trunk/sushivision

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Fri Mar 23 04:30:20 PDT 2007


Author: xiphmont
Date: 2007-03-23 04:30:16 -0700 (Fri, 23 Mar 2007)
New Revision: 12802

Modified:
   trunk/sushivision/dimension.c
   trunk/sushivision/example_spirograph.c
   trunk/sushivision/internal.h
   trunk/sushivision/main.c
   trunk/sushivision/panel-1d.c
   trunk/sushivision/panel-1d.h
   trunk/sushivision/panel-2d.c
   trunk/sushivision/panel-2d.h
   trunk/sushivision/panel-xy.c
   trunk/sushivision/panel-xy.h
   trunk/sushivision/panel.c
   trunk/sushivision/scale.c
   trunk/sushivision/sushivision.h
Log:
Implement factoring adjustment callbacks for spirograph demo

Minor scale gen fix for xy panels; don't manipulate _v, _i scales
against panel aperture when panel aperture has no bearing on an
iterator in an xy panel




Modified: trunk/sushivision/dimension.c
===================================================================
--- trunk/sushivision/dimension.c	2007-03-23 08:24:32 UTC (rev 12801)
+++ trunk/sushivision/dimension.c	2007-03-23 11:30:16 UTC (rev 12802)
@@ -71,9 +71,11 @@
     {
       //double ceil = d->scale->val_list[d->scale->vals-1] * dimneg;
       double fl = ((d->flags & SV_DIM_ZEROINDEX) ? d->scale->val_list[0] : 0.);
-      *panel = _sv_scalespace_linear(lo, hi, panel_w, spacing, legend);
 
-      if(panel_w == data_w){
+      if(panel)
+	*panel = _sv_scalespace_linear(lo, hi, panel_w, spacing, legend);
+
+      if(panel && panel_w == data_w){
 	
 	*iter = *data = *panel;
 
@@ -81,18 +83,19 @@
 	*data = _sv_scalespace_linear(lo, hi, data_w, 1, legend);
 	*iter = _sv_scalespace_linear(lo-fl, hi-fl, data_w, 1, legend);
 	
-	
-	/* if possible, the data/iterator scales should cover the entire pane exposed
-	   by the panel scale so long as there's room left to extend them without
-	   overflowing the lo/hi fenceposts */
-	while(1){
-	  double panel2 = _sv_scalespace_value(panel,panel_w-1)*pneg;
-	  double data2 = _sv_scalespace_value(data,data_w-1)*pneg;
-	  
-	  if(data2>=panel2)break;
-	  data_w++;
+	if(panel){
+	  /* if possible, the data/iterator scales should cover the entire pane exposed
+	     by the panel scale so long as there's room left to extend them without
+	     overflowing the lo/hi fenceposts */
+	  while(1){
+	    double panel2 = _sv_scalespace_value(panel,panel_w-1)*pneg;
+	    double data2 = _sv_scalespace_value(data,data_w-1)*pneg;
+	    
+	    if(data2>=panel2)break;
+	    data_w++;
+	  }
 	}
-	
+
 	data->pixels = data_w;
 	iter->pixels = data_w;
       }
@@ -121,32 +124,37 @@
 	if(hi_i < ceil_i)hi_i = ceil_i;
       }
 
-      *panel = _sv_scalespace_linear((double)(lo_i-pneg*.4) * d->private->discrete_numerator / 
-				     d->private->discrete_denominator,
-				     (double)(hi_i+pneg*.4) * d->private->discrete_numerator / 
-				     d->private->discrete_denominator,
-				     panel_w, spacing, legend);
+      if(panel){
+	*panel = _sv_scalespace_linear((double)(lo_i-pneg*.4) * d->private->discrete_numerator / 
+				       d->private->discrete_denominator,
+				       (double)(hi_i+pneg*.4) * d->private->discrete_numerator / 
+				       d->private->discrete_denominator,
+				       panel_w, spacing, legend);
 
-      /* if possible, the data/iterator scales should cover the entire pane exposed
-	 by the panel scale so long as there's room left to extend them without
-	 overflowing the lo/hi fenceposts */
-      double panel1 = _sv_scalespace_value(panel,0)*pneg;
-      double panel2 = _sv_scalespace_value(panel,panel->pixels)*pneg;
-      double data1 = (double)(lo_i-.49*pneg) * d->private->discrete_numerator / 
-	d->private->discrete_denominator*pneg;
-      double data2 = (double)(hi_i-.51*pneg) * d->private->discrete_numerator / 
-	d->private->discrete_denominator*pneg;
-      
-      while(data1 > panel1 && lo_i*dimneg > floor_i*dimneg){
-	lo_i -= pneg;
-	data1 = (double)(lo_i-.49*pneg) * d->private->discrete_numerator / 
+	/* if possible, the data/iterator scales should cover the entire pane exposed
+	   by the panel scale so long as there's room left to extend them without
+	   overflowing the lo/hi fenceposts */
+	double panel1 = _sv_scalespace_value(panel,0)*pneg;
+	double panel2 = _sv_scalespace_value(panel,panel->pixels)*pneg;
+	double data1 = (double)(lo_i-.49*pneg) * d->private->discrete_numerator / 
 	  d->private->discrete_denominator*pneg;
-      }
-      
-      while(data2 < panel2 && hi_i*dimneg <= ceil_i*dimneg){ // inclusive upper
-	hi_i += pneg;
-	data2 = (double)(hi_i-.51*pneg) * d->private->discrete_numerator / 
+	double data2 = (double)(hi_i-.51*pneg) * d->private->discrete_numerator / 
 	  d->private->discrete_denominator*pneg;
+	
+	while(data1 > panel1 && lo_i*dimneg > floor_i*dimneg){
+	  lo_i -= pneg;
+	  data1 = (double)(lo_i-.49*pneg) * d->private->discrete_numerator / 
+	    d->private->discrete_denominator*pneg;
+	}
+	
+	while(data2 < panel2 && hi_i*dimneg <= ceil_i*dimneg){ // inclusive upper
+	  hi_i += pneg;
+	  data2 = (double)(hi_i-.51*pneg) * d->private->discrete_numerator / 
+	    d->private->discrete_denominator*pneg;
+	}
+	
+      }else{
+	hi_i += pneg; // because upper bound is inclusive, and this val is one-past
       }
 
       /* cosmetic adjustment complete, generate the scales */

Modified: trunk/sushivision/example_spirograph.c
===================================================================
--- trunk/sushivision/example_spirograph.c	2007-03-23 08:24:32 UTC (rev 12801)
+++ trunk/sushivision/example_spirograph.c	2007-03-23 11:30:16 UTC (rev 12802)
@@ -27,13 +27,19 @@
 #define MAX_TEETH 100
 
 int mult[MAX_TEETH+1][MAX_TEETH+1];
+sv_dim_t *d0;
+sv_dim_t *d1;
+sv_dim_t *d2;
+sv_dim_t *d3;
+sv_dim_t *d4;
 
 static void inner(double *d, double *ret){
   double R = d[0];
   double r = d[1];
   double p = d[2];
-  double t = d[3]*M_PI*2.*mult[(int)R][(int)r];
-  
+  int factor_p = rint(d[4]);
+  double t = d[3]*M_PI*2. * (factor_p*mult[(int)R][(int)r] + (1.-factor_p)*r);
+
   ret[0] = (R-r) * cos(t) + p * cos((R-r)*t/r);
   ret[1] = (R-r) * sin(t) - p * sin((R-r)*t/r);
 }
@@ -42,8 +48,9 @@
   double R = d[0];
   double r = d[1];
   double p = d[2];
-  double t = d[3]*M_PI*2.*mult[(int)R][(int)r];
-
+  int factor_p = rint(d[4]);
+  double t = d[3]*M_PI*2. * (factor_p*mult[(int)R][(int)r] + (1.-factor_p)*r);
+  
   ret[0] = (R+r) * cos(t) - p * cos((R+r)*t/r);
   ret[1] = (R+r) * sin(t) + p * sin((R+r)*t/r);
 }
@@ -51,8 +58,7 @@
 int factored_mult(int x, int y){
   int d = 2;
   while(d<x){
-    if((x / d * d) == x &&
-       (y / d * d) == y){
+    if((x / d * d) == x && (y / d * d) == y){
       x/=d;
       y/=d;
     }else{
@@ -62,6 +68,28 @@
   return y;
 }
 
+// the number of 'spins' we want to have a go at depends on which X
+// dim we're iterating; if we're doing a normal spirograph, we want to
+// factor the 'r' by 'R' and not do redundant loops.  However, the
+// loops aren't 'redundant' when iterating the other dims, so 'r'
+// should not be factored then.
+
+// we store the decision of which to do in a shadow dimension because
+// that way access is properly managed/locked; function computation
+// happens outside of any locks so we need to make sure a protected
+// copy is passed, and this is an easy way.
+int set_mult(sv_panel_t *p, void *user_data){
+  sv_dim_t *d = sv_panel_get_axis(p,'X');
+  
+  if(d->number == 3){
+    // iterating on dim 3; normal spirograph mode
+    sv_dim_set_value(d4, 1, 1.);
+  }else{
+    sv_dim_set_value(d4, 1, 0.);
+  }
+  return 0;
+}
+
 int sv_submain(int argc, char *argv[]){
   int i,j;
   for(i=0;i<=MAX_TEETH;i++)
@@ -70,20 +98,22 @@
 
   sv_instance_t *s = sv_new(0,"spirograph");
 
-  sv_dim_t *d0 = sv_dim_new(s,0,"ring teeth",0);
+  d0 = sv_dim_new(s,0,"ring teeth",0);
   sv_dim_make_scale(d0,2,(double []){11,MAX_TEETH},NULL,0);
   sv_dim_set_discrete(d0,1,1);
 
-  sv_dim_t *d1 = sv_dim_new(s,1,"wheel teeth",0);
+  d1 = sv_dim_new(s,1,"wheel teeth",0);
   sv_dim_make_scale(d1,2,(double []){7,MAX_TEETH},NULL,0);
   sv_dim_set_discrete(d1,1,1);
 		    
-  sv_dim_t *d2 = sv_dim_new(s,2,"wheel pen",0);
+  d2 = sv_dim_new(s,2,"wheel pen",0);
   sv_dim_make_scale(d2,2,(double []){0,MAX_TEETH},NULL,0);
 
-  sv_dim_t *d3 = sv_dim_new(s,3,"trace",0);
-  sv_dim_make_scale(d3,2,(double []){0,1},(char *[]){"start","end"},0);
+  d3 = sv_dim_new(s,3,"trace",0);
+  sv_dim_make_scale(d3,2,(double []){0,1},(char *[]){"0%","100%"},0);
 
+  d4 = sv_dim_new(s,4,"hidden mult",0);
+
   sv_func_t *f0 = sv_func_new(s, 0, 2, inner, 0);
   sv_func_t *f1 = sv_func_new(s, 1, 2, outer, 0);
   
@@ -99,15 +129,17 @@
   
   sv_scale_t *axis = sv_scale_new(NULL,3,(double []){-MAX_TEETH*3,0,MAX_TEETH*3},NULL,0);
 
-  sv_panel_new_xy(s,0,"spirograph (TM)",
-		  axis,axis,
-		  (sv_obj_t *[]){o0,o1,NULL},
-		  (sv_dim_t *[]){d3,d0,d1,d2,NULL},
-		  0);
-
+  sv_panel_t *p = sv_panel_new_xy(s,0,"spirograph (TM)",
+				  axis,axis,
+				  (sv_obj_t *[]){o0,o1,NULL},
+				  (sv_dim_t *[]){d3,d0,d1,d2,NULL},
+				  0);
+  
   sv_dim_set_value(d0,1,100);
   sv_dim_set_value(d1,1,70);
   sv_dim_set_value(d2,1,50);
 
+  sv_panel_callback_recompute(p,set_mult,NULL);
+
   return 0;
 }

Modified: trunk/sushivision/internal.h
===================================================================
--- trunk/sushivision/internal.h	2007-03-23 08:24:32 UTC (rev 12801)
+++ trunk/sushivision/internal.h	2007-03-23 11:30:16 UTC (rev 12802)
@@ -97,6 +97,9 @@
   _sv_spinner_t *spinner;
   GtkWidget *popmenu;
 
+  sv_dim_t *x_d;
+  sv_dim_t *y_d;
+
   enum sv_background bg_type;
   _sv_dim_widget_t **dim_scales;
   int oldbox_active;
@@ -126,6 +129,9 @@
   int def_oversample_n;
   int def_oversample_d;
 
+  int (*callback_precompute)(sv_panel_t *,void*);
+  void *callback_precompute_data;
+
   // function bundles 
   void (*realize)(sv_panel_t *p);
   int (*map_action)(sv_panel_t *p, _sv_bythread_cache_t *c);

Modified: trunk/sushivision/main.c
===================================================================
--- trunk/sushivision/main.c	2007-03-23 08:24:32 UTC (rev 12801)
+++ trunk/sushivision/main.c	2007-03-23 11:30:16 UTC (rev 12802)
@@ -123,6 +123,12 @@
 	    // pending computation work?
 	    if(p->private->plot_active){
 	      _sv_spinner_set_busy(p->private->spinner);
+
+	      if(p->private->plot_progress_count==0){    
+		if(p->private->callback_precompute)
+		  p->private->callback_precompute(p,p->private->callback_precompute_data);
+	      }
+
 	      flag |= p->private->compute_action(p,&c[j][i]); // may drop lock internally
 	    }
 	    

Modified: trunk/sushivision/panel-1d.c
===================================================================
--- trunk/sushivision/panel-1d.c	2007-03-23 08:24:32 UTC (rev 12801)
+++ trunk/sushivision/panel-1d.c	2007-03-23 11:30:16 UTC (rev 12802)
@@ -388,7 +388,7 @@
       // display decimal precision relative to bracket
       //int depth = del_depth(p->dimension_list[i].d->bracket[0],
       //		    p->dimension_list[i].d->bracket[1]) + offset;
-      if( d!=p1->x_d ||
+      if( d!=p->private->x_d ||
 	  plot->cross_active){
 	
 	snprintf(buffer,320,"%s = %+.*f",
@@ -404,9 +404,9 @@
       sv_dim_t *d;
       int depth=0;
       if(p1->link_x)
-	d = p1->link_x->subtype->p2->x_d;
+	d = p1->link_x->private->x_d;
       else
-	d = p1->link_y->subtype->p2->y_d;
+	d = p1->link_y->private->y_d;
       
       // add each dimension to the legend
       // display decimal precision relative to display scales
@@ -579,7 +579,7 @@
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p1->dim_xb[i]))){
       
       // set the x dim flag
-      p1->x_d = p->dimension_list[i].d;
+      p->private->x_d = p->dimension_list[i].d;
       p1->x_scale = p->private->dim_scales[i];
       p1->x_dnum = i;
     }
@@ -667,23 +667,23 @@
 
   if(p1->link_x){
     dw = p2->x_v.pixels;
-    p1->x_d = p2->x_d;
+    p->private->x_d = link->private->x_d;
     p1->x_scale = p2->x_scale;
   }
   if(p1->link_y){
     dw = p2->y_v.pixels;
-    p1->x_d = p2->y_d;
+    p->private->x_d = link->private->y_d;
     p1->x_scale = p2->y_scale;
   }
 
   if(plot && GTK_WIDGET_REALIZED(GTK_WIDGET(plot))){
     if(p1->flip){
-      dw = _sv_dim_scales(p1->x_d, 
-			  p1->x_d->bracket[1],
-			  p1->x_d->bracket[0],
+      dw = _sv_dim_scales(p->private->x_d, 
+			  p->private->x_d->bracket[1],
+			  p->private->x_d->bracket[0],
 			  h,dw * p->private->oversample_n / p->private->oversample_d,
 			  plot->scalespacing,
-			  p1->x_d->name,
+			  p->private->x_d->name,
 			  &p1->x,
 			  &p1->x_v,
 			  &p1->x_i);
@@ -695,12 +695,12 @@
 				    p1->range_scale->legend);
       
     }else{
-      dw = _sv_dim_scales(p1->x_d, 
-				    p1->x_d->bracket[0],
-				    p1->x_d->bracket[1],
+      dw = _sv_dim_scales(p->private->x_d, 
+				    p->private->x_d->bracket[0],
+				    p->private->x_d->bracket[1],
 				    w,dw * p->private->oversample_n / p->private->oversample_d,
 				    plot->scalespacing,
-				    p1->x_d->name,
+				    p->private->x_d->name,
 				    &p1->x,
 				    &p1->x_v,
 				    &p1->x_i);
@@ -786,13 +786,13 @@
   if(link){
     for(i=0;i<link->dimensions;i++){
       sv_dim_t *d = link->dimension_list[i].d;
-      if(d == p1->x_d)
+      if(d == p->private->x_d)
 	x = link->dimension_list[i].d->val;
     }
   }else{
     for(i=0;i<p->dimensions;i++){
       sv_dim_t *d = p->dimension_list[i].d;
-      if(d == p1->x_d)
+      if(d == p->private->x_d)
 	x = p->dimension_list[i].d->val;
     }
   }
@@ -810,7 +810,7 @@
   for(i=0;i<p->dimensions;i++){
     sv_dim_t *d = p->dimension_list[i].d;
     _sv_panel1d_t *p1 = p->subtype->p1;
-    if(d == p1->x_d){
+    if(d == p->private->x_d){
       if(p1->flip)
 	d->val = _sv_scalespace_value(&plot->x,_sv_plot_get_crosshair_ypixel(plot));
       else
@@ -847,8 +847,7 @@
 static void _sv_panel1d_center_callback(sv_dim_list_t *dptr){
   sv_dim_t *d = dptr->d;
   sv_panel_t *p = dptr->p;
-  _sv_panel1d_t *p1 = p->subtype->p1;
-  int axisp = (d == p1->x_d);
+  int axisp = (d == p->private->x_d);
 
   if(!axisp){
     // mid slider of a non-axis dimension changed, rerender
@@ -862,8 +861,7 @@
 static void _sv_panel1d_bracket_callback(sv_dim_list_t *dptr){
   sv_dim_t *d = dptr->d;
   sv_panel_t *p = dptr->p;
-  _sv_panel1d_t *p1 = p->subtype->p1;
-  int axisp = d == p1->x_d;
+  int axisp = d == p->private->x_d;
     
   if(axisp)
     _sv_panel1d_mark_recompute(p);
@@ -919,8 +917,7 @@
 
     for(i=0;i<p->dimensions;i++){
       sv_dim_t *d = p->dimension_list[i].d;
-      _sv_panel1d_t *p1 = p->subtype->p1;
-      if(d == p1->x_d)
+      if(d == p->private->x_d)
 	_sv_dim_set_value(p->private->dim_scales[i],1,x);
 	            
       p->private->oldbox_active = 0;
@@ -1071,7 +1068,7 @@
   double dim_vals[p->sushi->dimensions];
 
   /* get iterator bounds, use iterator scale */
-  x_d = p1->x_d->number;
+  x_d = p->private->x_d->number;
 
   if(p1->flip){
     plot->x = sy;

Modified: trunk/sushivision/panel-1d.h
===================================================================
--- trunk/sushivision/panel-1d.h	2007-03-23 08:24:32 UTC (rev 12801)
+++ trunk/sushivision/panel-1d.h	2007-03-23 11:30:16 UTC (rev 12802)
@@ -57,7 +57,6 @@
 
   GtkWidget **dim_xb;
 
-  sv_dim_t *x_d;
   _sv_dim_widget_t *x_scale;
   int x_dnum; // number of dimension within panel, not global instance
 } _sv_panel1d_t;

Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c	2007-03-23 08:24:32 UTC (rev 12801)
+++ trunk/sushivision/panel-2d.c	2007-03-23 11:30:16 UTC (rev 12802)
@@ -143,14 +143,13 @@
 // call with lock
 static void _sv_panel2d_compute_point(sv_panel_t *p,sv_obj_t *o, double x, double y, compute_result *out){
   double dim_vals[p->sushi->dimensions];
-  _sv_panel2d_t *p2 = p->subtype->p2;
   int i,j;
   int pflag=0;
   int eflag=0;
 
   // fill in dimensions
-  int x_d = p2->x_d->number;
-  int y_d = p2->y_d->number;
+  int x_d = p->private->x_d->number;
+  int y_d = p->private->y_d->number;
 
   for(i=0;i<p->sushi->dimensions;i++){
     sv_dim_t *dim = p->sushi->dimension_list[i];
@@ -894,7 +893,7 @@
       depth = 3-_sv_scalespace_decimal_exponent(&p2->y);
     for(i=0;i<p->dimensions;i++){
       sv_dim_t *d = p->dimension_list[i].d;
-      if( (d!=p2->x_d && d!=p2->y_d) ||
+      if( (d!=p->private->x_d && d!=p->private->y_d) ||
 	  plot->cross_active){
 	snprintf(buffer,320,"%s = %+.*f",
 		 p->dimension_list[i].d->name,
@@ -993,7 +992,7 @@
 	_gtk_widget_set_sensitive_fixup(p2->dim_yb[i],FALSE);
 
       // set the x dim flag
-      p2->x_d = p->dimension_list[i].d;
+      p->private->x_d = p->dimension_list[i].d;
       p2->x_scale = p->private->dim_scales[i];
       p2->x_dnum = i;
     }else{
@@ -1008,7 +1007,7 @@
 	_gtk_widget_set_sensitive_fixup(p2->dim_xb[i],FALSE);
 
       // set the y dim
-      p2->y_d = p->dimension_list[i].d;
+      p->private->y_d = p->dimension_list[i].d;
       p2->y_scale = p->private->dim_scales[i];
       p2->y_dnum = i;
     }else{
@@ -1215,16 +1214,15 @@
 }
 
 static void _sv_panel2d_update_crosshairs(sv_panel_t *p){
-  _sv_panel2d_t *p2 = p->subtype->p2;
   _sv_plot_t *plot = PLOT(p->private->graph);
   double x=0,y=0;
   int i;
   
   for(i=0;i<p->dimensions;i++){
     sv_dim_t *d = p->dimension_list[i].d;
-    if(d == p2->x_d)
+    if(d == p->private->x_d)
       x = d->val;
-    if(d == p2->y_d)
+    if(d == p->private->y_d)
       y = d->val;
     
   }
@@ -1237,9 +1235,7 @@
 static void _sv_panel2d_center_callback(sv_dim_list_t *dptr){
   sv_dim_t *d = dptr->d;
   sv_panel_t *p = dptr->p;
-  _sv_panel2d_t *p2 = p->subtype->p2;
-  //_sv_plot_t *plot = PLOT(p->private->graph);
-  int axisp = (d == p2->x_d || d == p2->y_d);
+  int axisp = (d == p->private->x_d || d == p->private->y_d);
 
   if(!axisp){
     // mid slider of a non-axis dimension changed, rerender
@@ -1247,15 +1243,14 @@
   }else{
     // mid slider of an axis dimension changed, move crosshairs
     _sv_panel2d_update_crosshairs(p);
-    _sv_panel1d_update_linked_crosshairs(p,d==p2->x_d,d==p2->y_d); 
+    _sv_panel1d_update_linked_crosshairs(p,d==p->private->x_d,d==p->private->y_d); 
   }
 }
 
 static void _sv_panel2d_bracket_callback(sv_dim_list_t *dptr){
   sv_dim_t *d = dptr->d;
   sv_panel_t *p = dptr->p;
-  _sv_panel2d_t *p2 = p->subtype->p2;
-  int axisp = (d == p2->x_d || d == p2->y_d);
+  int axisp = (d == p->private->x_d || d == p->private->y_d);
 
   if(axisp)
     _sv_panel2d_mark_recompute(p);
@@ -1282,7 +1277,6 @@
 }
 
 static void _sv_panel2d_crosshairs_callback(sv_panel_t *p){
-  _sv_panel2d_t *p2 = p->subtype->p2;
   double x=PLOT(p->private->graph)->selx;
   double y=PLOT(p->private->graph)->sely;
   int i;
@@ -1294,11 +1288,11 @@
 
   for(i=0;i<p->dimensions;i++){
     sv_dim_t *d = p->dimension_list[i].d;
-    if(d == p2->x_d){
+    if(d == p->private->x_d){
       _sv_dim_set_value(p->private->dim_scales[i],1,x);
     }
 
-    if(d == p2->y_d){
+    if(d == p->private->y_d){
       _sv_dim_set_value(p->private->dim_scales[i],1,y);
     }
     
@@ -1307,8 +1301,8 @@
 
   // dimension setting might have enforced granularity restrictions;
   // have the display reflect that
-  x = p2->x_d->val;
-  y = p2->y_d->val;
+  x = p->private->x_d->val;
+  y = p->private->y_d->val;
 
   _sv_plot_set_crosshairs(PLOT(p->private->graph),x,y);
 
@@ -1419,8 +1413,8 @@
   pw = plot->x.pixels;
   ph = plot->y.pixels;
   
-  x_d = p2->x_d->number;
-  y_d = p2->y_d->number;
+  x_d = p->private->x_d->number;
+  y_d = p->private->y_d->number;
 
   // beginning of computation init
   if(p->private->plot_progress_count==0){
@@ -1432,21 +1426,21 @@
     _sv_scalespace_t old_yv = p2->y_v;
 
     // generate new scales
-    _sv_dim_scales(p2->x_d, 
-		   p2->x_d->bracket[0],
-		   p2->x_d->bracket[1],
+    _sv_dim_scales(p->private->x_d, 
+		   p->private->x_d->bracket[0],
+		   p->private->x_d->bracket[1],
 		   pw,pw * p->private->oversample_n / p->private->oversample_d,
 		   plot->scalespacing,
-		   p2->x_d->name,
+		   p->private->x_d->name,
 		   &sx,
 		   &sx_v,
 		   &sx_i);
-    _sv_dim_scales(p2->y_d, 
-		   p2->y_d->bracket[1],
-		   p2->y_d->bracket[0],
+    _sv_dim_scales(p->private->y_d, 
+		   p->private->y_d->bracket[1],
+		   p->private->y_d->bracket[0],
 		   ph,ph * p->private->oversample_n / p->private->oversample_d,
 		   plot->scalespacing,
-		   p2->y_d->name,
+		   p->private->y_d->name,
 		   &sy,
 		   &sy_v,
 		   &sy_i);
@@ -1521,6 +1515,7 @@
       _sv_plot_draw_scales(plot); // this should happen outside lock
       gdk_threads_enter ();      
     }
+
     _sv_map_set_throttle_time(p); // swallow the first 'throttled' remap which would only be a single line;
 
     return 1;

Modified: trunk/sushivision/panel-2d.h
===================================================================
--- trunk/sushivision/panel-2d.h	2007-03-23 08:24:32 UTC (rev 12801)
+++ trunk/sushivision/panel-2d.h	2007-03-23 11:30:16 UTC (rev 12802)
@@ -75,8 +75,6 @@
   GtkWidget **dim_xb;
   GtkWidget **dim_yb;
 
-  sv_dim_t *x_d;
-  sv_dim_t *y_d;
   _sv_dim_widget_t *x_scale;
   _sv_dim_widget_t *y_scale;
   int x_dnum; // panel, not global list context

Modified: trunk/sushivision/panel-xy.c
===================================================================
--- trunk/sushivision/panel-xy.c	2007-03-23 08:24:32 UTC (rev 12801)
+++ trunk/sushivision/panel-xy.c	2007-03-23 11:30:16 UTC (rev 12802)
@@ -361,7 +361,7 @@
     for(i=0;i<p->dimensions;i++){
       sv_dim_t *d = p->dimension_list[i].d;
 
-      if(d != xy->x_d ||
+      if(d != p->private->x_d ||
 	 plot->cross_active){
 	
 	snprintf(buffer,320,"%s = %+.*f",
@@ -386,7 +386,7 @@
 
   // if this is a discrete data set, size/view changes cannot affect
   // the data spacing; that's set by the discrete scale
-  if(xy->x_d->type != SV_DIM_CONTINUOUS) return -1;
+  if(p->private->x_d->type != SV_DIM_CONTINUOUS) return -1;
 
   double xscale = _sv_scalespace_pixel(&xy->x,1.) - _sv_scalespace_pixel(&xy->x,0.);
   double yscale = _sv_scalespace_pixel(&xy->y,1.) - _sv_scalespace_pixel(&xy->y,0.);
@@ -441,7 +441,7 @@
   _sv_panelxy_t *xy = p->subtype->xy;
 
   // discrete val dimensions are immune to rerender by metric changes
-  if(xy->x_d->type != SV_DIM_CONTINUOUS) return 0; 
+  if(p->private->x_d->type != SV_DIM_CONTINUOUS) return 0; 
 
   double target = (double) p->private->oversample_d / p->private->oversample_n;
   double full = _sv_panelxy_zoom_metric(p, 1);
@@ -616,7 +616,7 @@
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(xy->dim_xb[i]))){
       
       // set the x dim flag
-      xy->x_d = p->dimension_list[i].d;
+      p->private->x_d = p->dimension_list[i].d;
       xy->x_widget = p->private->dim_scales[i];
       xy->x_dnum = i;
     }
@@ -646,6 +646,7 @@
   int i,j,fn=p->sushi->functions;
   int w = sxi.pixels;
 
+
   /* by x */
   for(j=0;j<w;j++){
     if(!prefilled[j]){
@@ -738,12 +739,12 @@
   if(!xy->x_vec[xy->cross_objnum] || !xy->y_vec[xy->cross_objnum])return;
 
   // get bin number of dim value
-  int x_bin = rint(_sv_scalespace_pixel(&xy->data_v, xy->x_d->val));
+  int x_bin = rint(_sv_scalespace_pixel(&xy->data_v, p->private->x_d->val));
   double x = xy->x_vec[xy->cross_objnum][x_bin];
   double y = xy->y_vec[xy->cross_objnum][x_bin];
 
   _sv_plot_set_crosshairs(plot,x,y);
-  sv_dim_set_value(xy->x_d,1,_sv_scalespace_value(&xy->data_v, x_bin));
+  sv_dim_set_value(p->private->x_d,1,_sv_scalespace_value(&xy->data_v, x_bin));
 
   _sv_panel_dirty_legend(p);
 }
@@ -751,8 +752,7 @@
 static void _sv_panelxy_center_callback(sv_dim_list_t *dptr){
   sv_dim_t *d = dptr->d;
   sv_panel_t *p = dptr->p;
-  _sv_panelxy_t *xy = p->subtype->xy;
-  int axisp = (d == xy->x_d);
+  int axisp = (d == p->private->x_d);
 
   if(!axisp){
     // mid slider of a non-axis dimension changed, rerender
@@ -767,8 +767,7 @@
 static void _sv_panelxy_bracket_callback(sv_dim_list_t *dptr){
   sv_dim_t *d = dptr->d;
   sv_panel_t *p = dptr->p;
-  _sv_panelxy_t *xy = p->subtype->xy;
-  int axisp = (d == xy->x_d);
+  int axisp = (d == p->private->x_d);
     
   // always need to recompute, may also need to update zoom
 
@@ -816,16 +815,18 @@
   int bestbin=-1;
   double bestdist;
 
-  for(i=0;i<p->objectives;i++){
-    if(xy->x_vec[i] && xy->y_vec[i] && !_sv_mapping_inactive_p(xy->mappings+i)){
-      for(j=0;j<xy->data_v.pixels;j++){
-	double xd = x - xy->x_vec[i][j];
-	double yd = y - xy->y_vec[i][j];
-	double dist = xd*xd + yd*yd;
-	if(besto==-1 || dist<bestdist){
-	  besto = i;
-	  bestbin = j;
-	  bestdist = dist;
+  if(xy->x_vec && xy->y_vec){
+    for(i=0;i<p->objectives;i++){
+      if(xy->x_vec[i] && xy->y_vec[i] && !_sv_mapping_inactive_p(xy->mappings+i)){
+	for(j=0;j<xy->data_v.pixels;j++){
+	  double xd = x - xy->x_vec[i][j];
+	  double yd = y - xy->y_vec[i][j];
+	  double dist = xd*xd + yd*yd;
+	  if(besto==-1 || dist<bestdist){
+	    besto = i;
+	    bestbin = j;
+	    bestdist = dist;
+	  }
 	}
       }
     }
@@ -835,14 +836,16 @@
     x = xy->x_vec[besto][bestbin];
     y = xy->y_vec[besto][bestbin];
 
-    PLOT(p->private->graph)->selx = x;
-    PLOT(p->private->graph)->sely = y;
     xy->cross_objnum = besto;
     
     double dimval = _sv_scalespace_value(&xy->data_v, bestbin);
-    sv_dim_set_value(xy->x_d,1,dimval);  
+    sv_dim_set_value(p->private->x_d,1,dimval);  
   }
   
+
+  PLOT(p->private->graph)->selx = x;
+  PLOT(p->private->graph)->sely = y;
+  
   p->private->oldbox_active = 0;
   _sv_undo_resume(p->sushi);
   _sv_panel_dirty_legend(p);
@@ -953,18 +956,17 @@
 // to the same grid regardless of zoom level or starting bracket as
 // well as only encompass the desired range
 static int _sv_panelxy_generate_dimscale(sv_dim_t *d, int zoom, _sv_scalespace_t *v, _sv_scalespace_t *i){
-  _sv_scalespace_t x;
   
   if(d->type != SV_DIM_CONTINUOUS){
     // non-continuous is unaffected by zoom
-    _sv_dim_scales(d, d->bracket[0], d->bracket[1], 2, 2, 1, d->name, &x, v, i);
+    _sv_dim_scales(d, d->bracket[0], d->bracket[1], 2, 2, 1, d->name, NULL, v, i);
     return 0;
   }
 
   // continuous dimensions are, in some ways, handled like a discrete dim.
   double lo = d->scale->val_list[0];
   double hi = d->scale->val_list[d->scale->vals-1];
-  _sv_dim_scales(d, lo, hi, 2, 2, 1, d->name, &x, v, i);
+  _sv_dim_scales(d, lo, hi, 2, 2, 1, d->name, NULL, v, i);
 
   // this is iterative, not direct computation, so that at each level
   // we have a small adjustment (as opposed to one huge adjustment at
@@ -1083,12 +1085,12 @@
   double dim_vals[p->sushi->dimensions];
 
   /* get iterator bounds, use iterator scale */
-  x_d = xy->x_d->number;
+  x_d = p->private->x_d->number;
 
   /* generate a new data_v/data_i */
   _sv_scalespace_t newv;
   _sv_scalespace_t newi;
-  _sv_panelxy_generate_dimscale(xy->x_d, zoom, &newv, &newi);
+  _sv_panelxy_generate_dimscale(p->private->x_d, zoom, &newv, &newi);
   dw = newv.pixels;
 
   /* compare new/old data scales; pre-fill the data vec with values
@@ -1631,6 +1633,6 @@
   p->private->def_oversample_n = p->private->oversample_n = 1;
   p->private->def_oversample_d = p->private->oversample_d = 8;
   
-  return 0;
+  return p;
 }
 

Modified: trunk/sushivision/panel-xy.h
===================================================================
--- trunk/sushivision/panel-xy.h	2007-03-23 08:24:32 UTC (rev 12801)
+++ trunk/sushivision/panel-xy.h	2007-03-23 11:30:16 UTC (rev 12802)
@@ -57,7 +57,6 @@
 
   GtkWidget **dim_xb;
 
-  sv_dim_t *x_d;
   _sv_dim_widget_t *x_widget;
   int x_dnum; // number of dimension within panel, not global instance
 } _sv_panelxy_t;

Modified: trunk/sushivision/panel.c
===================================================================
--- trunk/sushivision/panel.c	2007-03-23 08:24:32 UTC (rev 12801)
+++ trunk/sushivision/panel.c	2007-03-23 11:30:16 UTC (rev 12802)
@@ -1019,3 +1019,25 @@
 
   return warn;
 }
+
+int sv_panel_callback_recompute (sv_panel_t *p,
+				 int (*callback)(sv_panel_t *p,void *data),
+				 void *data){
+
+  p->private->callback_precompute = callback;
+  p->private->callback_precompute_data = data;
+  return 0;
+}
+
+sv_dim_t *sv_panel_get_axis(sv_panel_t *p, char axis){
+  switch(axis){
+
+  case 'x': case 'X':
+    return p->private->x_d;
+
+  case 'y': case 'Y':
+    return p->private->y_d;
+  }
+  
+  return NULL;
+}

Modified: trunk/sushivision/scale.c
===================================================================
--- trunk/sushivision/scale.c	2007-03-23 08:24:32 UTC (rev 12801)
+++ trunk/sushivision/scale.c	2007-03-23 11:30:16 UTC (rev 12802)
@@ -408,7 +408,7 @@
       }
     }
 
-    while((first+neg) * ret.expm * neg < lowpoint*neg)
+    while((first+neg) * ret.expm * neg <= lowpoint*neg)
       first += neg;
     
     if(neg<0){

Modified: trunk/sushivision/sushivision.h
===================================================================
--- trunk/sushivision/sushivision.h	2007-03-23 08:24:32 UTC (rev 12801)
+++ trunk/sushivision/sushivision.h	2007-03-23 11:30:16 UTC (rev 12802)
@@ -282,7 +282,8 @@
 				 unsigned flags);
 
 int sv_panel_callback_recompute (sv_panel_t *p,
-				 int (*callback)(sv_panel_t *p));
+				 int (*callback)(sv_panel_t *p,void *data),
+				 void *data);
 
 int       sv_panel_set_resample (sv_panel_t *p,
 				 int numerator,
@@ -302,9 +303,7 @@
 int     sv_panel_get_background (sv_panel_t *p,
 				 enum sv_background *bg);
 
-int           sv_panel_get_axis (sv_panel_t *p,
-				 char axis,
-				 sv_dim_t **d);
+sv_dim_t     *sv_panel_get_axis (sv_panel_t *p, char axis);
 				    
 
 #endif



More information about the commits mailing list