[xiph-commits] r12461 - trunk/sushivision

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Mon Feb 12 19:38:07 PST 2007


Author: xiphmont
Date: 2007-02-12 19:38:05 -0800 (Mon, 12 Feb 2007)
New Revision: 12461

Modified:
   trunk/sushivision/example_fractal.c
   trunk/sushivision/panel-1d.c
   trunk/sushivision/panel-2d.c
   trunk/sushivision/plot.c
   trunk/sushivision/plot.h
Log:
Make certain displayed crosshairs are snapped to a valid dimension value.



Modified: trunk/sushivision/example_fractal.c
===================================================================
--- trunk/sushivision/example_fractal.c	2007-02-13 02:01:51 UTC (rev 12460)
+++ trunk/sushivision/example_fractal.c	2007-02-13 03:38:05 UTC (rev 12461)
@@ -54,12 +54,12 @@
 
   s=sushiv_new_instance();
 
-  sushiv_new_dimension_discrete(s,0,"Re(c)",
-				5,(double []){-2.25,-0.75,0,0.25,0.75},
-				NULL,1,1000,0);
-  sushiv_new_dimension_discrete(s,1,"Im(c)",
-				5,(double []){-2,-1,0,1,2},
-				NULL,1,1000,0);
+  sushiv_new_dimension(s,0,"Re(c)",
+		       5,(double []){-2.25,-0.75,0,0.25,0.75},
+		       NULL,0);
+  sushiv_new_dimension(s,1,"Im(c)",
+		       5,(double []){-2,-1,0,1,2},
+		       NULL,0);
 
   sushiv_new_dimension(s,2,"Re(z0)",
 		       5,(double []){-2.25,-1,0,1,2.25},

Modified: trunk/sushivision/panel-1d.c
===================================================================
--- trunk/sushivision/panel-1d.c	2007-02-13 02:01:51 UTC (rev 12460)
+++ trunk/sushivision/panel-1d.c	2007-02-13 03:38:05 UTC (rev 12461)
@@ -942,6 +942,7 @@
   int x_d=-1;
   int render_scale_flag = 0;
   scalespace sy;
+  scalespace syv;
 
   scalespace sx;
   scalespace sxv;
@@ -981,9 +982,13 @@
   if(p1->flip){
     plot->x = sy;
     plot->y = sx;
+    plot->x_v = sy;
+    plot->y_v = sxv;
   }else{
     plot->x = sx;
     plot->y = sy;
+    plot->x_v = sxv;
+    plot->y_v = sy;
   }
 
   // Bulletproofing; shouldn't ever come up

Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c	2007-02-13 02:01:51 UTC (rev 12460)
+++ trunk/sushivision/panel-2d.c	2007-02-13 03:38:05 UTC (rev 12461)
@@ -954,21 +954,28 @@
   _sushiv_panel_undo_push(p);
   _sushiv_panel_undo_suspend(p);
 
+  //plot_snap_crosshairs(PLOT(p->private->graph));
+
   for(i=0;i<p->dimensions;i++){
     sushiv_dimension_t *d = p->dimension_list[i].d;
     if(d == p2->x_d){
-      if(p2->x_d->val != x)
-	_sushiv_dimension_set_value(p->private->dim_scales[i],1,x);
+      _sushiv_dimension_set_value(p->private->dim_scales[i],1,x);
     }
 
     if(d == p2->y_d){
-      if(p2->y_d->val != y)
-	_sushiv_dimension_set_value(p->private->dim_scales[i],1,y);
+      _sushiv_dimension_set_value(p->private->dim_scales[i],1,y);
     }
     
     p2->oldbox_active = 0;
   }
 
+  // dimension setting might have enforced granularity restrictions;
+  // have the display reflect that
+  x = p2->x_d->val;
+  y = p2->y_d->val;
+
+  plot_set_crosshairs(PLOT(p->private->graph),x,y);
+
   _sushiv_panel_dirty_legend(p);
   _sushiv_panel_undo_resume(p);
 }
@@ -1096,6 +1103,8 @@
 
     plot->x = sx;
     plot->y = sy;
+    plot->x_v = sx_v;
+    plot->y_v = sy_v;
 
     p2->last_line++;
     ++p2->serialno; // we're about to free the old data rectangles

Modified: trunk/sushivision/plot.c
===================================================================
--- trunk/sushivision/plot.c	2007-02-13 02:01:51 UTC (rev 12460)
+++ trunk/sushivision/plot.c	2007-02-13 03:38:05 UTC (rev 12461)
@@ -272,8 +272,8 @@
 static void plot_init (Plot *p){
   // instance initialization
   p->scalespacing = 50;
-  p->x = scalespace_linear(0.0,1.0,400,p->scalespacing,NULL);
-  p->y = scalespace_linear(0.0,1.0,200,p->scalespacing,NULL);
+  p->x_v = p->x = scalespace_linear(0.0,1.0,400,p->scalespacing,NULL);
+  p->y_v = p->y = scalespace_linear(0.0,1.0,200,p->scalespacing,NULL);
 }
 
 static void plot_destroy (GtkObject *object){
@@ -587,6 +587,7 @@
       
       p->selx = scalespace_value(&p->x,event->x);
       p->sely = scalespace_value(&p->y,event->y);
+      plot_snap_crosshairs(p);
       p->cross_active=1;
       
       if(p->box_callback)
@@ -616,6 +617,7 @@
   if(!p->box_active && p->button_down){
     p->selx = scalespace_value(&p->x,event->x);
     p->sely = scalespace_value(&p->y,event->y);
+    plot_snap_crosshairs(p);
     p->cross_active=1;
 
     if(p->crosshairs_callback)
@@ -688,11 +690,11 @@
 
   case GDK_Left:
     {
-      double x = scalespace_pixel(&p->x,p->selx)-1;
+      double x = scalespace_pixel(&p->x_v,p->selx)-1;
       p->cross_active=1;
       if(shift)
 	x-=9;
-      p->selx = scalespace_value(&p->x,x);
+      p->selx = scalespace_value(&p->x_v,x);
       if(p->crosshairs_callback)
 	p->crosshairs_callback(p->cross_data);
 
@@ -708,11 +710,11 @@
 
   case GDK_Right:
     {
-      double x = scalespace_pixel(&p->x,p->selx)+1;
+      double x = scalespace_pixel(&p->x_v,p->selx)+1;
       p->cross_active=1;
       if(shift)
 	x+=9;
-      p->selx = scalespace_value(&p->x,x);
+      p->selx = scalespace_value(&p->x_v,x);
        if(p->crosshairs_callback)
 	p->crosshairs_callback(p->cross_data);
 
@@ -728,11 +730,11 @@
     return TRUE;
   case GDK_Up:
     {
-      double y = scalespace_pixel(&p->y,p->sely)-1;
+      double y = scalespace_pixel(&p->y_v,p->sely)-1;
       p->cross_active=1;
       if(shift)
 	y-=9;
-      p->sely = scalespace_value(&p->y,y);
+      p->sely = scalespace_value(&p->y_v,y);
       if(p->crosshairs_callback)
 	p->crosshairs_callback(p->cross_data);
 
@@ -747,11 +749,11 @@
     return TRUE;
   case GDK_Down:
     {
-      double y = scalespace_pixel(&p->y,p->sely)+1;
+      double y = scalespace_pixel(&p->y_v,p->sely)+1;
       p->cross_active=1;
       if(shift)
 	y+=9;
-      p->sely = scalespace_value(&p->y,y);
+      p->sely = scalespace_value(&p->y_v,y);
       if(p->crosshairs_callback)
 	p->crosshairs_callback(p->cross_data);
       
@@ -890,43 +892,6 @@
   gdk_threads_leave();
 }
 
-void plot_set_x_scale(Plot *p, scalespace x){
-  scalespace temp = p->x;
-  p->x = x;
-  if(memcmp(&temp,&p->x,sizeof(temp)))
-    plot_draw_scales(p);
-}
-
-void plot_set_y_scale(Plot *p, scalespace y){
-  //GtkWidget *widget = GTK_WIDGET(p);
-  scalespace temp = p->y;
-  p->y = y;
-  if(memcmp(&temp,&p->y,sizeof(temp)))
-    plot_draw_scales(p);
-}
-
-void plot_set_x_name(Plot *p, char *name){
-  p->namex = name;
-  plot_draw_scales(p); // releases one lock level
-}
-
-void plot_set_y_name(Plot *p, char *name){
-  p->namey = name;
-  plot_draw_scales(p); // releases one lock level
-}
-
-u_int32_t *plot_get_background_line(Plot *p, int num){
-  GtkWidget *widget = GTK_WIDGET(p);
-  return p->datarect + num*widget->allocation.width;
-}
-
-cairo_t *plot_get_background_cairo(Plot *p){
-  gdk_threads_enter();
-  cairo_t *ret= cairo_create(p->back);
-  gdk_threads_leave();
-  return ret;
-}
-
 void plot_set_crosshairs(Plot *p, double x, double y){
   gdk_threads_enter();
 
@@ -940,17 +905,30 @@
 
 void plot_set_crosshairs_snap(Plot *p, double x, double y){
   gdk_threads_enter();
-  double xpixel =  rint(scalespace_pixel(&p->x,x));
-  double ypixel =  rint(scalespace_pixel(&p->y,y));
+  double xpixel =  rint(scalespace_pixel(&p->x_v,x));
+  double ypixel =  rint(scalespace_pixel(&p->y_v,y));
 
-  p->selx = scalespace_value(&p->x,xpixel);
-  p->sely = scalespace_value(&p->y,ypixel);
+  p->selx = scalespace_value(&p->x_v,xpixel);
+  p->sely = scalespace_value(&p->y_v,ypixel);
   p->cross_active=1;
 
   plot_expose_request(p);
   gdk_threads_leave();
 }
 
+void plot_snap_crosshairs(Plot *p){
+  gdk_threads_enter();
+
+  double xpixel =  rint(scalespace_pixel(&p->x_v,p->selx));
+  double ypixel =  rint(scalespace_pixel(&p->y_v,p->sely));
+
+  p->selx = scalespace_value(&p->x_v,xpixel);
+  p->sely = scalespace_value(&p->y_v,ypixel);
+
+  plot_expose_request(p);
+  gdk_threads_leave();
+}
+
 int plot_get_crosshair_xpixel(Plot *p){
   scalespace x;
   double v;

Modified: trunk/sushivision/plot.h
===================================================================
--- trunk/sushivision/plot.h	2007-02-13 02:01:51 UTC (rev 12460)
+++ trunk/sushivision/plot.h	2007-02-13 03:38:05 UTC (rev 12461)
@@ -48,7 +48,9 @@
 
   int scalespacing;
   scalespace x;
+  scalespace x_v;
   scalespace y;
+  scalespace y_v;
   char *namex;
   char *namey;
 
@@ -102,6 +104,7 @@
 cairo_t *plot_get_background_cairo(Plot *p);
 void plot_set_crosshairs(Plot *p, double x, double y);
 void plot_set_crosshairs_snap(Plot *p, double x, double y);
+void plot_snap_crosshairs(Plot *p);
 void plot_draw_scales(Plot *p);
 void plot_unset_box(Plot *p);
 void plot_box_vals(Plot *p, double ret[4]);



More information about the commits mailing list