[genius: 1/3] Sun Apr 26 12:33:06 2015 Jiri (George) Lebl <jirka 5z com>



commit 5bd0cbb20bda3027a5da3b943dde1e9ecc49bfb4
Author: Jiri (George) Lebl <jiri lebl gmail com>
Date:   Sun Apr 26 12:33:09 2015 -0500

    Sun Apr 26 12:33:06 2015  Jiri (George) Lebl <jirka 5z com>
    
        * src/graphing.c: Fix SurfacePlotVariableNames to redraw things
          and also to init vars before resetting them, since otherwise it
          will all be forgotten.
    
        * examples/explicit-fdm-heat.gel: set the variable names to match,
          and a tiny bit of cleanup

 ChangeLog                      |    9 +++++++++
 examples/explicit-fdm-heat.gel |   26 ++++++++++++++++----------
 src/graphing.c                 |   20 ++++++++++++++++++++
 3 files changed, 45 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fb8878b..8e62ef9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Sun Apr 26 12:33:06 2015  Jiri (George) Lebl <jirka 5z com>
+
+       * src/graphing.c: Fix SurfacePlotVariableNames to redraw things
+         and also to init vars before resetting them, since otherwise it
+         will all be forgotten.
+
+       * examples/explicit-fdm-heat.gel: set the variable names to match,
+         and a tiny bit of cleanup
+
 Sun Apr 26 11:57:32 2015  Jiri (George) Lebl <jirka 5z com>
 
        * examples/Makefile.am, examples/explicit-fdm-heat.gel: Add example
diff --git a/examples/explicit-fdm-heat.gel b/examples/explicit-fdm-heat.gel
index 1987738..0d88575 100644
--- a/examples/explicit-fdm-heat.gel
+++ b/examples/explicit-fdm-heat.gel
@@ -5,6 +5,9 @@
 # times are solved for, though of course we must skip graphing some times when
 # there are too many steps.
 #
+# NOTE that this program changes your variable names in the surface plotting.
+# To set them back to default do SurfacePlotVariableNames = ["x","y","z"];
+#
 # The equation is u_t = u_{xx} where 0 < x < 1
 # The boundary conditions are insulated on x=0, u_x(0,t) = 0
 # and Dirichlet condition on x=1, u(1,t) = 0
@@ -28,25 +31,28 @@ m := round(maxt/k);
 # Never plot more than 4*n steps in the t (that is y) direction
 # rather skip rows.  If you do not want to skip rows, comment out
 # the next line.
-plotevery = max(1,floor(m/(2*n)));
+plotevery := max(1,floor(m/(2*n)));
 
 #Set up initial value
 u := null;
 data := null;
 for j=1 to n+1 do (
-  x = (j-1)*h;
+  x := (j-1)*h;
   u@(j) := initialf(x);
   data := [data;[x,0,u@(j)]]
 );
 
-SurfacePlotDrawLegends = true;
+SurfacePlotDrawLegends := true;
+SurfacePlotVariableNames := ["x","t","u"];
+PlotWindowPresent(); # Make sure the window is raised
+
 
 # If you change it from 0 to plotevery, then no plots will be generated
-toplot = 0;
-#toplot = plotevery;
+toplot := 0;
+#toplot := plotevery;
 
 for i=1 to m do (
-  v = u;
+  v := u;
   for j=2 to n do (
     u@(j) := v@(j) + (k/(h^2))*(v@(j+1)+v@(j-1)-2*v@(j))
   );
@@ -55,12 +61,12 @@ for i=1 to m do (
 
   increment toplot;
   if toplot == plotevery then (
-    toplot = 0;
+    toplot := 0;
     for j=2 to n do (
-      data = [data;[(j-1)*h,i*k,u@(j)]]
+      data := [data;[(j-1)*h,i*k,u@(j)]]
     );
-    data = [data;[0,i*k,u@(1)]];
-    data = [data;[1,i*k,u@(n+1)]];
+    data := [data;[0,i*k,u@(1)]];
+    data := [data;[1,i*k,u@(n+1)]];
     SurfacePlotData(data,"u",[0,1,0,maxt])
   )
 );
diff --git a/src/graphing.c b/src/graphing.c
index 229ef8a..3679451 100644
--- a/src/graphing.c
+++ b/src/graphing.c
@@ -10341,6 +10341,8 @@ set_LinePlotVariableNames (GelETree * a)
        GelETree *t;
        char *sx, *sy, *sz, *st;
 
+       init_var_names ();
+
        if G_UNLIKELY (plot_in_progress != 0) {
                gel_errorout (_("%s: Plotting in progress, cannot call %s"),
                              "set_LinePlotVariableNames", "set_LinePlotVariableNames");
@@ -10432,6 +10434,8 @@ set_SurfacePlotVariableNames (GelETree * a)
        GelETree *t;
        char *sx, *sy, *sz;
 
+       init_var_names ();
+
        if G_UNLIKELY (plot_in_progress != 0) {
                gel_errorout (_("%s: Plotting in progress, cannot call %s"),
                              "set_SurfacePlotVariableNames", "set_SurfacePlotVariableNames");
@@ -10493,6 +10497,22 @@ set_SurfacePlotVariableNames (GelETree * a)
 
        set_surface_labels ();
 
+       if (surface_plot != NULL) {
+               GtkPlotAxis *a;
+
+               a = gtk_plot_get_axis (GTK_PLOT (surface_plot), GTK_PLOT_AXIS_BOTTOM);
+               gtk_plot_axis_set_title (a, sp_x_name);
+               a = gtk_plot_get_axis (GTK_PLOT (surface_plot), GTK_PLOT_AXIS_LEFT);
+               gtk_plot_axis_set_title (a, sp_y_name);
+               a = gtk_plot_get_axis (GTK_PLOT (surface_plot), GTK_PLOT_AXIS_TOP);
+               gtk_plot_axis_set_title (a, "");
+
+               if (plot_canvas != NULL) {
+                       gtk_plot_canvas_paint (GTK_PLOT_CANVAS (plot_canvas));
+                       gtk_widget_queue_draw (GTK_WIDGET (plot_canvas));
+               }
+       }
+
        return make_matrix_from_sp_varnames ();
 }
 


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