[genius] Sat Aug 30 15:40:00 2014 Jiri (George) Lebl <jirka 5z com>



commit 5d3bc243ee31e72667e340383335e520349dc48e
Author: Jiri (George) Lebl <jiri lebl gmail com>
Date:   Sat Aug 30 15:40:03 2014 -0500

    Sat Aug 30 15:40:00 2014  Jiri (George) Lebl <jirka 5z com>
    
        * gtkextra/gtkplotflux.c: fix almost zero arrows causing NaNs causing
          postscript errors.

 ChangeLog              |    5 +++++
 gtkextra/gtkplotflux.c |   22 ++++++++++++++++------
 2 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index df8f9bf..cdee044 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Aug 30 15:40:00 2014  Jiri (George) Lebl <jirka 5z com>
+
+       * gtkextra/gtkplotflux.c: fix almost zero arrows causing NaNs causing
+         postscript errors.
+
 Fri Aug 29 10:41:36 2014  Jiri (George) Lebl <jirka 5z com>
 
        * src/gnome-genius.c: fix compilation on my old ubuntu 10.04 laptop
diff --git a/gtkextra/gtkplotflux.c b/gtkextra/gtkplotflux.c
index f1a2994..feea0be 100644
--- a/gtkextra/gtkplotflux.c
+++ b/gtkextra/gtkplotflux.c
@@ -502,18 +502,25 @@ gtk_plot_flux_draw_symbol(GtkPlotData *dataset,
                             &x1, &y1, &z1);
   }else{
        if(plot->clip_data && 
-          (x < plot->xmin || x > plot->xmax || y <plot->ymin || y > plot->ymax))
+          (x < plot->xmin || x > plot->xmax || y < plot->ymin || y > plot->ymax))
             return;
 
        xm = sqrt(dx * dx + dy * dy);
        factor = xm / flux->scale_max;
        size = factor * flux->size_max;
-       x2 = size * dx / xm;    
-       y2 = size * dy / xm;    
-  
+
        gtk_plot_get_pixel(plot, x, y, &x1, &y1);
 
-       gtk_plot_flux_draw_arrow (flux, x1, y1, x1+x2*m, y1-y2*m);
+       if (xm > 0.0) {
+              x2 = size * dx / xm;    
+              y2 = size * dy / xm;    
+
+              /* check for NaN */
+              if (x2 == x2 && y2 == y2)
+                      gtk_plot_flux_draw_arrow (flux, x1, y1, x1+x2*m, y1-y2*m);
+       }
+  
+
        gtk_plot_data_draw_symbol(dataset, x1, y1);
   }
 
@@ -681,6 +688,9 @@ gtk_plot_flux_draw_arrow(GtkPlotFlux *flux, gdouble x1, gdouble y1, gdouble x2,
   width = fabs(x2 - x1);
   height = fabs(y2 - y1);
 
+  /* This is a nan */
+  if (width != width || height != height) return;
+
   if(width == 0 && height == 0) return;
   if(width != 0)
       angle = atan2((y2 - y1), (x2 - x1));
@@ -688,7 +698,7 @@ gtk_plot_flux_draw_arrow(GtkPlotFlux *flux, gdouble x1, gdouble y1, gdouble x2,
       angle = asin((y2 - y1)/height);
 
   length = (y2 - y1)*(y2 - y1) + (x2 - x1)*(x2 - x1);
-  if(length > 0.0) length = sqrt(length);
+  if (length > 0.0) length = sqrt(length);
 
   arrow_width = flux->arrow_width;
   line_width = data->symbol.border.line_width;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]