| Ilya Zakharevich on Thu, 17 Dec 1998 04:31:32 -0500 (EST) |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| 2.0.13: dynamic linking with gnuplot |
Math::Pari Perl module uses a specific way to allow plotting: instead
of compiling plotnull.c (sp?) it compiles plotgnuplot.c with a special
flag -DDYNAMIC_PLOTTING.
When this flag is present, no external plotting functions are
mentioned in plotgnuplot.c (thus the effect is the same as for
plotnull.c - no external libraries are needed). However, there is a
function which may be called to initialize 2 variables (sic, only two)
with addresses of a change-terminal function, and the GNUPLOT's table
of dispatch.
Thus the linking with high-resolution plotting is delayed until
runtime, when an external DLL may load GNUPLOT library, then call the
mentioned function in plotgnuplot.c with (now known) addresses.
This is the way Math::Pari module works: it may load the Term::Gnuplot
low-level plotting Perl module, and initialize the variables with the
data taken from the Term::Gnuplot.
Unfortunately, the gnuplot-output-file setting I added breaks this
harmony, since set_output_file() is called directly, without
redirection. The following patch fixes this.
Note that currently it is not possible to use the PARI function
plotfile() from Math::Pari. An extra change to Term::Gnuplot is
needed - it needs to export the address of term_set_output().
However, Term::Gnuplot has an independent way to set the output file.
Enjoy,
Ilya
--- pari-2.0.13.alpha/src/graph/plotgnuplot.c~ Tue Dec 15 10:30:11 1998
+++ pari-2.0.13.alpha/src/graph/plotgnuplot.c Thu Dec 17 02:28:56 1998
@@ -140,7 +140,7 @@ term_set(char *s)
reset();
strcpy(pari_plot.name,s);
if (!termset( s ))
- err(talker,"error setting terminal \"\%s\"", s);
+ err(talker,"error setting terminal \"%s\"", s);
do_init(); /* Init terminal. */
setpointsize(pointsize);
--- pari-2.0.13.alpha/src/graph/Gnuplot.h~ Wed Dec 9 11:23:02 1998
+++ pari-2.0.13.alpha/src/graph/Gnuplot.h Thu Dec 17 02:57:31 1998
@@ -281,11 +281,33 @@ static struct termentry dummy_term_tbl[]
};
static struct termentry *my_term_tbl = dummy_term_tbl;
+# define term_set_output (*term_set_outputp)
+static void
+myterm_set_output(char *s)
+{
+ croak("Change terminal not implemented yet with dynamic gnuplot");
+}
+
+typedef void (*TSET_FP)(char *s);
+TSET_FP term_set_outputp = &myterm_set_output;
+
/* This function should be called before any graphic code can be used... */
set_term_funcp(FUNC_PTR change_p, struct termentry *term_p)
{
my_term_tbl = term_p;
change_term_p = change_p;
+ /* XXXX Need to set term_set_outputp as well */
+}
+
+/* This function should be called before any graphic code can be used... */
+set_term_funcp3(FUNC_PTR change_p, struct termentry *term_p, TSET_FP tchange)
+{
+ my_term_tbl = term_p;
+ change_term_p = change_p;
+ if (tchange) {
+ term_set_outputp = tchange;
+ }
+ /* XXXX Need to set term_set_outputp as well */
}
#else /* !DYNAMIC_PLOTTING */