[genius] Tue Feb 02 10:32:53 2010 Jiri (George) Lebl <jirka 5z com>
- From: George Lebl <jirka src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [genius] Tue Feb 02 10:32:53 2010 Jiri (George) Lebl <jirka 5z com>
- Date: Tue, 2 Feb 2010 16:34:42 +0000 (UTC)
commit 517e7d192ae2fcfab5ce0131a346e798f8985a93
Author: Jiri (George) Lebl <jirka 5z com>
Date: Tue Feb 2 10:34:15 2010 -0600
Tue Feb 02 10:32:53 2010 Jiri (George) Lebl <jirka 5z com>
* src/graphing.c, help/C/gel-function-list.xml: Add SlopefieldTicks
and VectorfieldTicks, to allow setting ticks from the command line.
ChangeLog | 5 +
NEWS | 6 ++
help/C/gel-function-list.xml | 20 +++++
src/genius.c | 2 +-
src/graphing.c | 187 ++++++++++++++++++++++++++++++++++++++++-
5 files changed, 214 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1cd1e70..6b232ea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Feb 02 10:32:53 2010 Jiri (George) Lebl <jirka 5z com>
+
+ * src/graphing.c, help/C/gel-function-list.xml: Add SlopefieldTicks
+ and VectorfieldTicks, to allow setting ticks from the command line.
+
Wed Jan 27 00:52:13 2010 Jiri (George) Lebl <jirka 5z com>
* src/calc.h, src/genius.c, src/gnome-genius.c, src/funclib.c:
diff --git a/NEWS b/NEWS
index 7155285..e3e4bf8 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,9 @@
+Changes to 1.0.10
+
+* Add SlopefieldTicks and VectorfieldTicks parameters
+* Add AskButtons interactive function
+* Allow comparisons (== and !=) with null, treating it as an empty matrix
+
Changes to 1.0.9
* Fix matrix expansion. This also fixes AuxilliaryUnitMatrix and JordanBlock.
diff --git a/help/C/gel-function-list.xml b/help/C/gel-function-list.xml
index f978cff..a8d1b56 100644
--- a/help/C/gel-function-list.xml
+++ b/help/C/gel-function-list.xml
@@ -700,6 +700,16 @@ greater than or equal to
</listitem>
</varlistentry>
+ <varlistentry id="gel-function-SlopefieldTicks">
+ <term>SlopefieldTicks</term>
+ <listitem>
+ <synopsis>SlopefieldTicks = [vertical,horizontal]</synopsis>
+ <para>Sets the number of vertical and horizontal ticks in a
+slopefield plot. (See <link linkend="gel-function-SlopefieldPlot"><function>SlopefieldPlot</function></link>).
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry id="gel-function-SumProductNumberOfTries">
<term>SumProductNumberOfTries</term>
<listitem>
@@ -742,6 +752,16 @@ greater than or equal to
</listitem>
</varlistentry>
+ <varlistentry id="gel-function-VectorfieldTicks">
+ <term>VectorfieldTicks</term>
+ <listitem>
+ <synopsis>VectorfieldTicks = [vertical,horizontal]</synopsis>
+ <para>Sets the number of vertical and horizontal ticks in a
+vectorfield plot. (See <link linkend="gel-function-VectorfieldPlot"><function>VectorfieldPlot</function></link>).
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</sect1>
diff --git a/src/genius.c b/src/genius.c
index bbc9559..affd7e7 100644
--- a/src/genius.c
+++ b/src/genius.c
@@ -241,7 +241,7 @@ reread_buttons:
g_print ("\n%s\n", ve_sure_string (query));
i = 1;
for (li = buttons; li != NULL; li = li->next) {
- g_print ("%d) %s\n", i, ve_sure_string (li->data));
+ g_print ("%d) %s\n", i, ve_sure_string ((char *)li->data));
i++;
}
max = i-1;
diff --git a/src/graphing.c b/src/graphing.c
index 75d8857..74ce7ed 100644
--- a/src/graphing.c
+++ b/src/graphing.c
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 2003-2009 Jiri (George) Lebl
+ * Copyright (C) 2003-2010 Jiri (George) Lebl
*
* Author: Jiri (George) Lebl
*
@@ -172,6 +172,12 @@ static double reset_plotx2 = 10;
static double reset_ploty1 = -10;
static double reset_ploty2 = 10;
+static int plot_sf_Vtick = 20;
+static int plot_sf_Htick = 20;
+
+static int plot_vf_Vtick = 20;
+static int plot_vf_Htick = 20;
+
static int plotVtick = 20;
static int plotHtick = 20;
@@ -2787,26 +2793,39 @@ get_limits_from_matrix (GelETree *m, double *x1, double *x2, double *y1, double
return FALSE;
}
*x1 = mpw_get_double (t->val.value);
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
+ return FALSE;
+ }
+
t = gel_matrixw_vindex (m->mat.matrix, 1);
if (t->type != GEL_VALUE_NODE) {
gel_errorout (_("Graph limits not given as numbers"));
return FALSE;
}
*x2 = mpw_get_double (t->val.value);
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
+ return FALSE;
+ }
+
t = gel_matrixw_vindex (m->mat.matrix, 2);
if (t->type != GEL_VALUE_NODE) {
gel_errorout (_("Graph limits not given as numbers"));
return FALSE;
}
*y1 = mpw_get_double (t->val.value);
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
+ return FALSE;
+ }
+
t = gel_matrixw_vindex (m->mat.matrix, 3);
if (t->type != GEL_VALUE_NODE) {
gel_errorout (_("Graph limits not given as numbers"));
return FALSE;
}
*y2 = mpw_get_double (t->val.value);
-
- /* FIXME: what about errors */
if G_UNLIKELY (gel_error_num != 0) {
gel_error_num = 0;
return FALSE;
@@ -2870,38 +2889,61 @@ get_limits_from_matrix_surf (GelETree *m, double *x1, double *x2, double *y1, do
return FALSE;
}
*x1 = mpw_get_double (t->val.value);
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
+ return FALSE;
+ }
+
t = gel_matrixw_vindex (m->mat.matrix, 1);
if (t->type != GEL_VALUE_NODE) {
gel_errorout (_("Graph limits not given as numbers"));
return FALSE;
}
*x2 = mpw_get_double (t->val.value);
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
+ return FALSE;
+ }
+
t = gel_matrixw_vindex (m->mat.matrix, 2);
if (t->type != GEL_VALUE_NODE) {
gel_errorout (_("Graph limits not given as numbers"));
return FALSE;
}
*y1 = mpw_get_double (t->val.value);
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
+ return FALSE;
+ }
+
t = gel_matrixw_vindex (m->mat.matrix, 3);
if (t->type != GEL_VALUE_NODE) {
gel_errorout (_("Graph limits not given as numbers"));
return FALSE;
}
*y2 = mpw_get_double (t->val.value);
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
+ return FALSE;
+ }
+
t = gel_matrixw_vindex (m->mat.matrix, 4);
if (t->type != GEL_VALUE_NODE) {
gel_errorout (_("Graph limits not given as numbers"));
return FALSE;
}
*z1 = mpw_get_double (t->val.value);
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
+ return FALSE;
+ }
+
t = gel_matrixw_vindex (m->mat.matrix, 5);
if (t->type != GEL_VALUE_NODE) {
gel_errorout (_("Graph limits not given as numbers"));
return FALSE;
}
*z2 = mpw_get_double (t->val.value);
-
- /* FIXME: what about errors */
if G_UNLIKELY (gel_error_num != 0) {
gel_error_num = 0;
return FALSE;
@@ -2960,6 +3002,78 @@ make_matrix_from_limits_surf (void)
}
static gboolean
+get_ticks_from_matrix (GelETree *m, int *v, int *h)
+{
+ GelETree *t;
+
+ if (m->type == GEL_VALUE_NODE) {
+ long n = mpw_get_long (m->val.value);
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
+ return FALSE;
+ }
+ if (n <= 1 || n > 200) {
+ gel_errorout (_("Ticks must be between 2 and 200"));
+ return FALSE;
+ }
+ *v = *h = n;
+ return TRUE;
+ } else if (m->type == GEL_MATRIX_NODE &&
+ gel_matrixw_elements (m->mat.matrix) == 2) {
+ t = gel_matrixw_vindex (m->mat.matrix, 0);
+ if (t->type != GEL_VALUE_NODE) {
+ gel_errorout (_("Ticks not given as numbers"));
+ return FALSE;
+ }
+ *v = mpw_get_long (t->val.value);
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
+ return FALSE;
+ }
+ if (*v <= 1 || *v > 200) {
+ gel_errorout (_("Ticks must be between 2 and 200"));
+ return FALSE;
+ }
+ t = gel_matrixw_vindex (m->mat.matrix, 1);
+ if (t->type != GEL_VALUE_NODE) {
+ gel_errorout (_("Ticks not given as numbers"));
+ return FALSE;
+ }
+ *h = mpw_get_long (t->val.value);
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
+ return FALSE;
+ }
+ if (*h <= 1 || *h > 200) {
+ gel_errorout (_("Ticks must be between 2 and 200"));
+ return FALSE;
+ }
+ return TRUE;
+ } else {
+ gel_errorout (_("Ticks not given as a number or a 2-vector"));
+ return FALSE;
+ }
+}
+
+static GelETree *
+make_matrix_from_ticks (int v, int h)
+{
+ GelETree *n;
+ GelMatrixW *m;
+ /*make us a new empty node*/
+ GEL_GET_NEW_NODE (n);
+ n->type = GEL_MATRIX_NODE;
+ m = n->mat.matrix = gel_matrixw_new ();
+ n->mat.quoted = FALSE;
+ gel_matrixw_set_size (m, 2, 1);
+
+ gel_matrixw_set_index (m, 0, 0) = gel_makenum_si (v);
+ gel_matrixw_set_index (m, 1, 0) = gel_makenum_si (h);
+
+ return n;
+}
+
+static gboolean
parametric_get_value (double *x, double *y, double t)
{
static int hookrun = 0;
@@ -5431,6 +5545,9 @@ SlopefieldPlot_op (GelCtx *ctx, GelETree * * a, int *exception)
reset_ploty1 = ploty1 = y1;
reset_ploty2 = ploty2 = y2;
+ plotVtick = plot_sf_Vtick;
+ plotHtick = plot_sf_Htick;
+
plot_mode = MODE_LINEPLOT_SLOPEFIELD;
plot_functions (FALSE /* do_window_present */);
@@ -5547,6 +5664,9 @@ VectorfieldPlot_op (GelCtx *ctx, GelETree * * a, int *exception)
vectorfield_normalize_arrow_length =
vectorfield_normalize_arrow_length_parameter;
+ plotVtick = plot_vf_Vtick;
+ plotHtick = plot_vf_Htick;
+
plot_mode = MODE_LINEPLOT_VECTORFIELD;
plot_functions (FALSE /* do_window_present */);
@@ -6488,6 +6608,60 @@ get_SurfacePlotWindow (void)
}
static GelETree *
+set_SlopefieldTicks (GelETree * a)
+{
+ int v, h;
+ gboolean update = FALSE;
+
+ if G_UNLIKELY (plot_in_progress != 0) {
+ gel_errorout (_("%s: Plotting in progress, cannot call %s"),
+ "set_SlopefieldTicks", "set_SlopefieldTicks");
+ return NULL;
+ }
+
+ if G_UNLIKELY ( ! get_ticks_from_matrix (a, &v, &h))
+ return NULL;
+
+ plot_sf_Vtick = v;
+ plot_sf_Htick = h;
+
+ return make_matrix_from_ticks (plot_sf_Vtick, plot_sf_Htick);
+}
+
+static GelETree *
+get_SlopefieldTicks (void)
+{
+ return make_matrix_from_ticks (plot_sf_Vtick, plot_sf_Htick);
+}
+
+static GelETree *
+set_VectorfieldTicks (GelETree * a)
+{
+ int v, h;
+ gboolean update = FALSE;
+
+ if G_UNLIKELY (plot_in_progress != 0) {
+ gel_errorout (_("%s: Plotting in progress, cannot call %s"),
+ "set_VectorfieldTicks", "set_VectorfieldTicks");
+ return NULL;
+ }
+
+ if G_UNLIKELY ( ! get_ticks_from_matrix (a, &v, &h))
+ return NULL;
+
+ plot_vf_Vtick = v;
+ plot_vf_Htick = h;
+
+ return make_matrix_from_ticks (plot_vf_Vtick, plot_vf_Htick);
+}
+
+static GelETree *
+get_VectorfieldTicks (void)
+{
+ return make_matrix_from_ticks (plot_vf_Vtick, plot_vf_Htick);
+}
+
+static GelETree *
set_VectorfieldNormalized (GelETree * a)
{
if G_UNLIKELY (plot_in_progress != 0) {
@@ -6572,6 +6746,9 @@ gel_add_graph_functions (void)
FUNC (LinePlotClear, 0, "", "plotting", N_("Show the line plot window and clear out functions"));
VFUNC (LinePlotDrawLine, 2, "x1,y1,x2,y2,args", "plotting", N_("Draw a line from x1,y1 to x2,y2. x1,y1,x2,y2 can be replaced by a n by 2 matrix for a longer line"));
+ PARAMETER (SlopefieldTicks, N_("Number of slopefield ticks as a vector [vertical,horizontal]."));
+ PARAMETER (VectorfieldTicks, N_("Number of vectorfield ticks as a vector [vertical,horizontal]."));
+
PARAMETER (VectorfieldNormalized, N_("Normalize vectorfields if true. That is, only show direction and not magnitude."));
PARAMETER (LinePlotDrawLegends, N_("If to draw legends or not on line plots."));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]