[xiph-commits] r11987 - trunk/sushivision

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Wed Nov 1 18:17:00 PST 2006


Author: xiphmont
Date: 2006-11-01 18:16:58 -0800 (Wed, 01 Nov 2006)
New Revision: 11987

Modified:
   trunk/sushivision/panel-2d.c
   trunk/sushivision/panel-2d.h
   trunk/sushivision/plot.c
   trunk/sushivision/plot.h
Log:
Connect up rubber-band-box zoom in widget to actual zoom function



Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c	2006-11-01 22:36:07 UTC (rev 11986)
+++ trunk/sushivision/panel-2d.c	2006-11-02 02:16:58 UTC (rev 11987)
@@ -150,6 +150,7 @@
 	gtk_widget_set_sensitive(p2->dim_yb[i],FALSE);
       // set the x dim flag
       p2->x_d = p->dimension_list[i];
+      p2->x_scale = p2->dim_scales[i];
       // set panel x scale to this dim
       p2->x = scalespace_linear(p2->x_d->bracket[0],
 				p2->x_d->bracket[1],
@@ -167,6 +168,7 @@
 	gtk_widget_set_sensitive(p2->dim_xb[i],FALSE);
       // set the y dim
       p2->y_d = p->dimension_list[i];
+      p2->y_scale = p2->dim_scales[i];
       // set panel y scale to this dim
       p2->y = scalespace_linear(p2->y_d->bracket[0],
 				p2->y_d->bracket[1],
@@ -569,9 +571,11 @@
 
 static void dimchange_callback_2d(GtkWidget *button,gpointer in){
   sushiv_panel_t *p = (sushiv_panel_t *)in;
+  sushiv_panel2d_t *p2 = (sushiv_panel2d_t *)p->internal;
   if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))){
     update_xy_availability(p);
     update_crosshairs(p);
+    plot_unset_box(PLOT(p2->graph));
     _mark_recompute_2d(p);
   }
 }
@@ -593,6 +597,22 @@
   }
 }
 
+static void box_callback(void *in){
+  sushiv_panel_t *p = (sushiv_panel_t *)in;
+  sushiv_panel2d_t *p2 = (sushiv_panel2d_t *)p->internal;
+  Plot *plot = PLOT(p2->graph);
+
+  // zoom current dimensions to box
+  double corners[4];
+  plot_box_vals(plot,corners);
+
+  slider_set_value(p2->x_scale,0,corners[0]);
+  slider_set_value(p2->x_scale,2,corners[1]);
+  slider_set_value(p2->y_scale,0,corners[2]);
+  slider_set_value(p2->y_scale,2,corners[3]);
+
+}
+
 // called from one/all of the worker threads; the idea is that several
 // of the threads will all call this and they collectively interleave
 // ongoing computation of the pane
@@ -750,7 +770,8 @@
   
   /* graph */
   p2->graph = GTK_WIDGET(plot_new(recompute_callback_2d,p,
-				  crosshairs_callback,p)); 
+				  crosshairs_callback,p,
+				  box_callback,p)); 
   gtk_table_attach(GTK_TABLE(p2->top_table),p2->graph,0,5,0,1,
 		   GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,0,5);
 

Modified: trunk/sushivision/panel-2d.h
===================================================================
--- trunk/sushivision/panel-2d.h	2006-11-01 22:36:07 UTC (rev 11986)
+++ trunk/sushivision/panel-2d.h	2006-11-02 02:16:58 UTC (rev 11987)
@@ -45,6 +45,8 @@
 
   sushiv_dimension_t *x_d;
   sushiv_dimension_t *y_d;
+  Slider *x_scale;
+  Slider *y_scale;
 
   int last_line;
   int dirty_flag;

Modified: trunk/sushivision/plot.c
===================================================================
--- trunk/sushivision/plot.c	2006-11-01 22:36:07 UTC (rev 11986)
+++ trunk/sushivision/plot.c	2006-11-02 02:16:58 UTC (rev 11987)
@@ -352,6 +352,7 @@
   widget->allocation = *allocation;
   p->x = scalespace_linear(p->x.lo,p->x.hi,widget->allocation.width,p->scalespacing);
   p->y = scalespace_linear(p->y.lo,p->y.hi,widget->allocation.height,p->scalespacing);
+  plot_unset_box(p);
   plot_draw_scales(p);
   if(p->recompute_callback)p->recompute_callback(p->app_data);
 
@@ -382,12 +383,12 @@
     p->boxB_y = y;
   }
   
-  if(inside_box(p,x,y))
-    p->box_active = 2;
-  else
-    p->box_active = 1;
-  
   if(p->box_active){
+    if(inside_box(p,x,y) && !p->button_down)
+      p->box_active = 2;
+    else
+      p->box_active = 1;
+    
     int bx = (p->boxA_x<p->boxB_x ? p->boxA_x : p->boxB_x);
     int by = (p->boxA_y<p->boxB_y ? p->boxA_y : p->boxB_y);
     int bw = abs(p->boxA_x-p->boxB_x)+1;
@@ -504,13 +505,16 @@
 }
 
 Plot *plot_new (void (*callback)(void *),void *app_data,
-		void (*cross_callback)(void *),void *cross_data) {
+		void (*cross_callback)(void *),void *cross_data,
+		void (*box_callback)(void *),void *box_data) {
   GtkWidget *g = GTK_WIDGET (g_object_new (PLOT_TYPE, NULL));
   Plot *p = PLOT (g);
   p->recompute_callback = callback;
   p->app_data = app_data;
   p->crosshairs_callback = cross_callback;
   p->cross_data = cross_data;
+  p->box_callback = box_callback;
+  p->box_data = box_data;
   return p;
 }
 
@@ -607,3 +611,19 @@
   plot_expose_request(p);
   gdk_threads_leave();
 }
+
+void plot_unset_box(Plot *p){
+  p->box_active = 0;
+}
+
+void plot_box_vals(Plot *p, double ret[4]){
+  int bx1 = (p->boxA_x<p->boxB_x ? p->boxA_x : p->boxB_x);
+  int by1 = (p->boxA_y<p->boxB_y ? p->boxA_y : p->boxB_y);
+  int bx2 = abs(p->boxA_x-p->boxB_x)+bx1+1;
+  int by2 = abs(p->boxA_y-p->boxB_y)+by1+1;
+  
+  ret[0] = scalespace_value(&p->x,bx1);
+  ret[1] = scalespace_value(&p->x,bx2);
+  ret[2] = scalespace_value(&p->y,by1);
+  ret[3] = scalespace_value(&p->y,by2);
+}

Modified: trunk/sushivision/plot.h
===================================================================
--- trunk/sushivision/plot.h	2006-11-01 22:36:07 UTC (rev 11986)
+++ trunk/sushivision/plot.h	2006-11-02 02:16:58 UTC (rev 11987)
@@ -79,8 +79,9 @@
 };
 
 GType     plot_get_type        (void);
-Plot*     plot_new             (void (*callback)(void *),void *app_data,
-				void (*cross_callback)(void *),void *cross_data);
+Plot     *plot_new (void (*callback)(void *),void *app_data,
+		    void (*cross_callback)(void *),void *cross_data,
+		    void (*box_callback)(void *),void *box_data);
 
 G_END_DECLS
 
@@ -96,3 +97,5 @@
 cairo_t *plot_get_background_cairo(Plot *p);
 void plot_set_crosshairs(Plot *p, double x, double y);
 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