[genius] Thu Oct 14 00:00:18 2021 Jiri (George) Lebl <jirka 5z com>



commit c1327caacfb4572d12f6c299688857e888611241
Author: Jiri (George) Lebl <jiri lebl gmail com>
Date:   Thu Oct 14 00:00:20 2021 -0500

    Thu Oct 14 00:00:18 2021  Jiri (George) Lebl <jirka 5z com>
    
            * graphing.c: improve slightly the frozenness of 3d plots, and enable
              the stop button on the graph window the whole time a script is running.
    
            * examples/zoom-differentiability.gel: Example of zooming into a
              differentiable and a nondifferentiable function of two variables

 ChangeLog                           |  8 ++++++++
 NEWS                                |  1 +
 examples/Makefile.am                |  3 ++-
 examples/zoom-differentiability.gel | 23 +++++++++++++++++++++
 src/graphing.c                      | 40 +++++++++++++++++++++++++++----------
 5 files changed, 64 insertions(+), 11 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d64f231c..f66e9779 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Thu Oct 14 00:00:18 2021  Jiri (George) Lebl <jirka 5z com>
+
+       * graphing.c: improve slightly the frozenness of 3d plots, and enable
+         the stop button on the graph window the whole time a script is running.
+
+       * examples/zoom-differentiability.gel: Example of zooming into a
+         differentiable and a nondifferentiable function of two variables
+
 Wed Oct 13 17:41:48 2021  Jiri (George) Lebl <jirka 5z com>
 
        * src/gnome-genius.c: allow setting editor color scheme in the
diff --git a/NEWS b/NEWS
index 0e2875e8..c774ad9b 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Changes to 1.0.27
 * Allow setting editor color scheme in the settings dialog
 * Closing window acts exactly like the quit button/menu item
 * Remove menu icons
+* Leave the Stop button on the plot window enabled if a script is running
 
 Changes to 1.0.26
 
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 9fae9794..fd99a306 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -36,7 +36,8 @@ example_DATA = \
        riemann-integral-darboux.gel \
        plot-ode-runge-kutta.gel \
        plot-ode-trajectory-runge-kutta.gel \
-       plane-curves.gel
+       plane-curves.gel \
+       zoom-differentiability.gel
 
 EXTRA_DIST = \
        $(example_DATA)
diff --git a/examples/zoom-differentiability.gel b/examples/zoom-differentiability.gel
new file mode 100644
index 00000000..fb3e5111
--- /dev/null
+++ b/examples/zoom-differentiability.gel
@@ -0,0 +1,23 @@
+# Category: Calculus
+# Name: Differentiability of a function of two variables
+
+the_answer = AskButtons("Zoom into a...", "nondifferentiable function", "differentiable function");
+
+PlotWindowPresent(); # Make sure the window is raised
+
+SurfacePlotDrawLegends = false;
+
+# use standard variable names (in case they got reset)
+SurfacePlotVariableNames = ["x","y","z"];
+
+if the_answer == 1 then (
+     for n=1 to 100 do (
+        SurfacePlot(`(x,y)=if x!=0.0 or y!=0.0 then (y^3)/(x^2+y^2)+0.2*x^2-0.3*y^2 else 
0.0,(0.95^n)*[-5,5,-5,5,-5,5]);
+        wait(0.02);
+    )
+) else if the_answer == 2 then (
+    for n=1 to 100 do (
+        SurfacePlot(`(x,y)=0.4*x+0.3*y+0.2*x^2-0.3*y^2,(0.95^n)*[-5,5,-5,5,-5,5]);
+        wait(0.02);
+    )
+)
diff --git a/src/graphing.c b/src/graphing.c
index c5261fd9..0f1dd180 100644
--- a/src/graphing.c
+++ b/src/graphing.c
@@ -338,6 +338,9 @@ static void recompute_functions (gboolean fitting);
 /* surfaces */
 static void plot_surface_functions (gboolean do_window_present, gboolean fit_function);
 
+static void plot_freeze (void);
+static void plot_thaw (void);
+
 /* replot the slope/vector fields after zoom or other axis changing event */
 static void replot_fields (void);
 
@@ -476,7 +479,7 @@ plot_window_setup (void)
                        genius_unsetup_window_cursor (plot_canvas);
 
                gtk_dialog_set_response_sensitive (GTK_DIALOG (graph_window),
-                                                  RESPONSE_STOP, plot_in_progress);
+                                                  RESPONSE_STOP, plot_in_progress || gel_calc_running);
                gtk_widget_set_sensitive (plot_zoomout_item, ! plot_in_progress);
                gtk_widget_set_sensitive (plot_zoomin_item, ! plot_in_progress);
 
@@ -818,7 +821,7 @@ graph_window_response (GtkWidget *w, int response, gpointer data)
                } else {
                        gtk_widget_destroy (graph_window);
                }
-       } else if (response == RESPONSE_STOP && plot_in_progress > 0) {
+       } else if (response == RESPONSE_STOP && (plot_in_progress > 0 || gel_calc_running > 0)) {
                gel_interrupted = TRUE;
        }
 }
@@ -5002,15 +5005,15 @@ plot_functions (gboolean do_window_present,
                gtk_plot_canvas_thaw (GTK_PLOT_CANVAS (plot_canvas));
                gtk_plot_canvas_paint (GTK_PLOT_CANVAS (plot_canvas));
                gtk_widget_queue_draw (GTK_WIDGET (plot_canvas));
-
-               if (gel_evalnode_hook != NULL)
-                       (*gel_evalnode_hook)();
        }
 
        gtk_plot_thaw (GTK_PLOT (line_plot));
        plot_in_progress --;
        gel_calc_running --;
        plot_window_setup ();
+
+       if (gel_evalnode_hook != NULL)
+               (*gel_evalnode_hook)();
 }
 
 static void
@@ -8349,9 +8352,8 @@ SurfacePlotClear_op (GelCtx *ctx, GelETree * * a, int *exception)
 
 static int plot_canvas_freeze_count = 0;
 
-static GelETree *
-PlotCanvasFreeze_op (GelCtx *ctx, GelETree * * a, int *exception)
-{
+static void
+plot_freeze (void) {
        if (plot_canvas_freeze_count == 0) {
                if (plot_canvas != NULL /* sanity */)
                        gtk_plot_canvas_freeze (GTK_PLOT_CANVAS (plot_canvas));
@@ -8359,25 +8361,43 @@ PlotCanvasFreeze_op (GelCtx *ctx, GelETree * * a, int *exception)
 
        plot_canvas_freeze_count ++;
 
-       return gel_makenum_null ();
 }
 
 static GelETree *
-PlotCanvasThaw_op (GelCtx *ctx, GelETree * * a, int *exception)
+PlotCanvasFreeze_op (GelCtx *ctx, GelETree * * a, int *exception)
+{
+       plot_freeze ();
+
+       return gel_makenum_null ();
+}
+
+static void
+plot_thaw (void)
 {
        if (plot_canvas_freeze_count > 0) {
                plot_canvas_freeze_count --;
                if (plot_canvas_freeze_count == 0) {
                        if (plot_canvas != NULL /* sanity */) {
+                               plot_in_progress ++;
+                               gel_calc_running ++;
                                gtk_plot_canvas_thaw (GTK_PLOT_CANVAS (plot_canvas));
                                gtk_plot_canvas_paint (GTK_PLOT_CANVAS (plot_canvas));
                                gtk_widget_queue_draw (GTK_WIDGET (plot_canvas));
+                               plot_in_progress --;
+                               gel_calc_running --;
+                               plot_window_setup ();
 
                                if (gel_evalnode_hook != NULL)
                                        (*gel_evalnode_hook)();
                        }
                }
        }
+}
+
+static GelETree *
+PlotCanvasThaw_op (GelCtx *ctx, GelETree * * a, int *exception)
+{
+       plot_thaw ();
 
        return gel_makenum_null ();
 }


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