[genius] Fri Jun 14 15:19:19 2013 Jiri (George) Lebl <jirka 5z com>



commit ff5e784decf947c72fae9d2409ad7cb4ca7ead3d
Author: Jiri (George) Lebl <jirka 5z com>
Date:   Fri Jun 14 15:19:21 2013 -0500

    Fri Jun 14 15:19:19 2013  Jiri (George) Lebl <jirka 5z com>
    
        * gtkextra/gtkplot3d.c: fix placement of labels.
    
        * src/graphing.c: make surface plot slightly smaller so that it fits
          on screen.

 ChangeLog            |    7 +++++++
 NEWS                 |    1 +
 gtkextra/gtkplot3d.c |   48 ++++++++++++++++++------------------------------
 src/graphing.c       |    4 ++--
 4 files changed, 28 insertions(+), 32 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index cd6bf45..3939bb6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Jun 14 15:19:19 2013  Jiri (George) Lebl <jirka 5z com>
+
+       * gtkextra/gtkplot3d.c: fix placement of labels.
+
+       * src/graphing.c: make surface plot slightly smaller so that it fits
+         on screen.
+
 Fri Jun 14 12:01:24 2013  Jiri (George) Lebl <jirka 5z com>
 
        * src/graphing.c: fix precision when the starting limit is 0 or much
diff --git a/NEWS b/NEWS
index eb95716..7c96933 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,7 @@ Changes to 1.0.17
 * Completion for "help on function" in the GUI
 * Fix FindRootBisection and FindRootMullersMethod
 * Factors is now a lot faster on very large numbers (as fast as Factorize)
+* Fix placement of labels on surface plots
 * A few small fixes and updates to the documentation
 * A few minor bugfixes
 * Update mersenne primes (new one is known)
diff --git a/gtkextra/gtkplot3d.c b/gtkextra/gtkplot3d.c
index 34ad193..7f6438c 100644
--- a/gtkextra/gtkplot3d.c
+++ b/gtkextra/gtkplot3d.c
@@ -2067,9 +2067,9 @@ gtk_plot3d_draw_labels(GtkPlot3D *plot,
   gint ntick;
   gdouble m;
   gdouble size, ox, oy, oz;
+  gdouble sx, sy, sz;
   gdouble y = 0;
-  GtkPlotVector ticks_direction, center, aux;
-  gdouble proj;
+  GtkPlotVector ticks_direction, center;
   gboolean veto = FALSE;
   GtkAllocation allocation;
 
@@ -2107,31 +2107,19 @@ gtk_plot3d_draw_labels(GtkPlot3D *plot,
   center.y = (plot->ay->ticks.max + plot->ay->ticks.min) / 2.0;
   center.z = (plot->az->ticks.max + plot->az->ticks.min) / 2.0;
 
-  ticks_direction.x = axis->origin.x + delta.x - center.x;
-  ticks_direction.y = axis->origin.y + delta.y - center.y;
-  ticks_direction.z = axis->origin.z + delta.z - center.z;
+  gtk_plot3d_get_pixel(plot, 
+                      axis->origin.x + delta.x + center.x * axis->direction.x,
+                      axis->origin.y + delta.y + center.y * axis->direction.y,
+                      axis->origin.z + delta.z + center.z * axis->direction.z,
+                      &ox, &oy, &oz);
+  gtk_plot3d_get_pixel(plot, 
+                      center.x,
+                      center.y,
+                      center.z,
+                      &sx, &sy, &sz);
 
-  proj = ticks_direction.x * axis->direction.x +
-         ticks_direction.y * axis->direction.y +
-         ticks_direction.z * axis->direction.z;
-
-  ticks_direction.x -= proj * axis->direction.x;
-  ticks_direction.y -= proj * axis->direction.y;
-  ticks_direction.z -= proj * axis->direction.z;
-
-  proj = sqrt(ticks_direction.x * ticks_direction.x +
-              ticks_direction.y * ticks_direction.y +
-              ticks_direction.z * ticks_direction.z);
-
-  ticks_direction.x /= proj;
-  ticks_direction.y /= proj;
-  ticks_direction.z /= proj;
-
-  aux = ticks_direction;
-
-  ticks_direction.x = aux.x*plot->e1.x + aux.y*plot->e2.x + aux.z*plot->e3.x; 
-  ticks_direction.y = aux.x*plot->e1.y + aux.y*plot->e2.y + aux.z*plot->e3.y; 
-  ticks_direction.z = aux.x*plot->e1.z + aux.y*plot->e2.z + aux.z*plot->e3.z; 
+  ticks_direction.x = (ox-sx)/sqrt((ox-sx)*(ox-sx) + (oy-sy)*(oy-sy));
+  ticks_direction.y = (oy-sy)/sqrt((ox-sx)*(ox-sx) + (oy-sy)*(oy-sy));
 
   for(ntick = 0;
       axis->ticks.values != NULL &&
@@ -2144,8 +2132,8 @@ gtk_plot3d_draw_labels(GtkPlot3D *plot,
                          axis->origin.z + axis->direction.z * xx + delta.z,
                          &ox, &oy, &oz);
    
-    tick.x = ox +  axis->labels_offset * ticks_direction.x; 
-    tick.y = oy +  axis->labels_offset * ticks_direction.y; 
+    tick.x = ox + m * axis->labels_offset * ticks_direction.x;
+    tick.y = oy + m * axis->labels_offset * ticks_direction.y;
 
     tick_value = axis->ticks.values[ntick].value;
 
@@ -2181,8 +2169,8 @@ gtk_plot3d_draw_labels(GtkPlot3D *plot,
                        axis->origin.z + center.z * axis->direction.z + delta.z, 
                        &ox, &oy, &oz);
     
-         title.x = ox + plot->titles_offset * ticks_direction.x; 
-         title.y = oy + plot->titles_offset * ticks_direction.y; 
+         title.x = ox + m * plot->titles_offset * ticks_direction.x; 
+         title.y = oy + m * plot->titles_offset * ticks_direction.y; 
 
          title.x = title.x / (gdouble)allocation.width;
          title.y = title.y / (gdouble)allocation.height;
diff --git a/src/graphing.c b/src/graphing.c
index 9905b8c..0a29ae9 100644
--- a/src/graphing.c
+++ b/src/graphing.c
@@ -346,7 +346,7 @@ static void set_surface_labels (void);
 #define PROPORTION3D 0.80
 #define PROPORTION_OFFSETX 0.1
 #define PROPORTION_OFFSETY 0.075
-#define PROPORTION3D_OFFSET 0.1
+#define PROPORTION3D_OFFSET 0.12
 
 #include "funclibhelper.cP"
 
@@ -1764,7 +1764,7 @@ add_surface_plot (void)
        GtkPlotAxis *xy, *xz, *yx, *yz, *zx, *zy;
        GtkPlotAxis *top, *left, *bottom;
 
-       surface_plot = gtk_plot3d_new_with_size (NULL, PROPORTION3D, PROPORTION3D);
+       surface_plot = gtk_plot3d_new (NULL);
        gtk_widget_show (surface_plot);
        g_signal_connect (G_OBJECT (surface_plot),
                          "destroy",


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