[xiph-commits] r12062 - trunk/sushivision

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Wed Nov 8 04:14:51 PST 2006


Author: xiphmont
Date: 2006-11-08 04:14:48 -0800 (Wed, 08 Nov 2006)
New Revision: 12062

Modified:
   trunk/sushivision/panel-2d.c
   trunk/sushivision/scale.c
   trunk/sushivision/scale.h
   trunk/sushivision/slice.c
   trunk/sushivision/slice.h
Log:
Expand useful scale resolution down to the natural width of the double
(48 bit mantissa) as opposed to the 32 bit limitations of previous
scale setup due to 32 bit integer ops.

Eliminate lockup possibilities from scale underflow; report inability to zoom past possible limits (rendering will get blocky well before the scale calculation udnderflows now).



Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c	2006-11-07 20:35:29 UTC (rev 12061)
+++ trunk/sushivision/panel-2d.c	2006-11-08 12:14:48 UTC (rev 12062)
@@ -571,28 +571,31 @@
   sushiv_panel_t *p = d->panel;
   sushiv_panel2d_t *p2 = (sushiv_panel2d_t *)p->internal;
   int dnum = dptr - p->dimension_list;
-  int axisp = (d == p2->x_d || d == p2->y_d);
   double lo = slider_get_value(p2->dim_scales[dnum],0);
   double hi = slider_get_value(p2->dim_scales[dnum],2);
+  
 
+  double xy_p = d == p2->x_d;
+  scalespace s = scalespace_linear(lo,hi,(xy_p?p2->data_w:p2->data_h),
+				   PLOT(p2->graph)->scalespacing);
   if(buttonstate == 0){
     panel2d_undo_push(p);
     panel2d_undo_suspend(p);
   }
 
-  if(axisp){  
-    double xy_p = d == p2->x_d;
-    scalespace s = scalespace_linear(lo,hi,(xy_p?p2->data_w:p2->data_h),
-				     PLOT(p2->graph)->scalespacing);
+  if(s.m == 0){
+    if(xy_p)
+      fprintf(stderr,"X scale underflow; cannot zoom further.\n");
+    else
+      fprintf(stderr,"Y scale underflow; cannot zoom further.\n");
+  }else{
     xy_p?(p2->x=s):(p2->y=s);
-  }
 
-  d->bracket[0] = lo;
-  d->bracket[1] = hi;
-
-  // if the bracketing of an axis dimension changed, rerender
-  if(axisp)
+    d->bracket[0] = lo;
+    d->bracket[1] = hi;
+    
     _mark_recompute_2d(p);
+  }
  
   if(buttonstate == 2)
     panel2d_undo_resume(p);

Modified: trunk/sushivision/scale.c
===================================================================
--- trunk/sushivision/scale.c	2006-11-07 20:35:29 UTC (rev 12061)
+++ trunk/sushivision/scale.c	2006-11-08 12:14:48 UTC (rev 12062)
@@ -147,7 +147,7 @@
 /* plot and graph scales */
 
 double scalespace_value(scalespace *s, double pixel){
-  double val = (double)((pixel-s->first_pixel)*s->step_val)/s->step_pixel + s->first_val;
+  double val = (pixel-s->first_pixel)*s->step_val/s->step_pixel + s->first_val;
   return val * s->m;
 }
 
@@ -183,13 +183,18 @@
 
   int place = 0;
   int step = 1;
-  int first;
+  long long first;
 
   ret.lo = lowpoint;
   ret.hi = highpoint;
   ret.init = 1;
   ret.pixels=pixels;
 
+  if(range == 0){
+    ret.m = 0;
+    return ret;
+  }
+
   if(range!=0.){
     while(pixels / range < max_spacing){
       place++;
@@ -218,14 +223,26 @@
   else
     ret.step_pixel = rint(pixels / range);
   ret.m = pow(10,place);
-  first = (int)(lowpoint/ret.m)/step*step;
+  first = (long long)(lowpoint/ret.m)/step*step;
 
+  if(LLONG_MAX * ret.m < lowpoint){
+    ret.m = 0;
+    return ret;
+  }
+
   while(first * ret.m < lowpoint)
     first += step;
+
+  if(LLONG_MIN * ret.m > highpoint){
+    ret.m = 0;
+    return ret;
+  }
+
   while(first * ret.m > highpoint)
     first -= step;
 
   ret.first_val = first;
+
   ret.first_pixel = rint((first - (lowpoint / ret.m)) * ret.step_pixel / ret.step_val);
 
   return ret;

Modified: trunk/sushivision/scale.h
===================================================================
--- trunk/sushivision/scale.h	2006-11-07 20:35:29 UTC (rev 12061)
+++ trunk/sushivision/scale.h	2006-11-08 12:14:48 UTC (rev 12062)
@@ -23,7 +23,7 @@
   double lo;
   double hi;
 
-  long first_val;
+  long long first_val;
   long first_pixel;
   
   long step_val;

Modified: trunk/sushivision/slice.c
===================================================================
--- trunk/sushivision/slice.c	2006-11-07 20:35:29 UTC (rev 12061)
+++ trunk/sushivision/slice.c	2006-11-08 12:14:48 UTC (rev 12062)
@@ -246,7 +246,7 @@
   draw_and_expose(GTK_WIDGET(s));
 }
 
-void slice_thumb_set(Slice *s,float v){
+void slice_thumb_set(Slice *s,double v){
   GtkWidget *w=GTK_WIDGET(s);
 
   s->thumb_val=v;

Modified: trunk/sushivision/slice.h
===================================================================
--- trunk/sushivision/slice.h	2006-11-07 20:35:29 UTC (rev 12061)
+++ trunk/sushivision/slice.h	2006-11-08 12:14:48 UTC (rev 12062)
@@ -67,7 +67,7 @@
 extern GType slice_get_type        (void);
 extern GtkWidget* slice_new (void (*callback)(void *,int), void *data);
 extern void slice_set_active(Slice *s, int activep);
-extern void slice_thumb_set(Slice *s,float v);
+extern void slice_thumb_set(Slice *s,double v);
 
 G_END_DECLS
 #endif



More information about the commits mailing list