changeset 5311:46de0f964c1b

[project @ 2005-04-27 21:05:43 by jwe]
author jwe
date Wed, 27 Apr 2005 21:05:43 +0000
parents 2fbcdc356fc7
children 80c1aa832cb2
files src/ChangeLog src/DLD-FUNCTIONS/gplot.l
diffstat 2 files changed, 109 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Wed Apr 27 15:38:53 2005 +0000
+++ b/src/ChangeLog	Wed Apr 27 21:05:43 2005 +0000
@@ -1,5 +1,14 @@
 2005-04-27  John W. Eaton  <jwe@octave.org>
 
+	* DLD-FUNCTIONS/gplot.l (gnuplot_init): New function to handle
+	initialization.  If builtin variables have already been installed,
+	simply update our cached values.
+	(F__gnuplot_init__): Call gnuplot_init to do all the real work.
+	(Fclearplot, Fcloseplot, Fhold, Fishold, Fpurge_tmp_files,
+	F__gnuplot_raw__, F__gnuplot_set__, F__gnuplot_plot__,
+	F__gnuplot_splot__, F__gnuplot_replot__, Fgplot, Fgsplot, Fgraw,
+	Fgset, Fgshow): Call gnuplot_init before doing anything.
+
 	* parse.y: (safe_fclose): Delete comment list to avoid memory leak.
 	(parse_and_execute (FILE *)): Also save and restore global_command.
 
--- a/src/DLD-FUNCTIONS/gplot.l	Wed Apr 27 15:38:53 2005 +0000
+++ b/src/DLD-FUNCTIONS/gplot.l	Wed Apr 27 21:05:43 2005 +0000
@@ -94,6 +94,8 @@
 
 static inline bool can_be_plotkw (void);
 
+static void gnuplot_init (void);
+
 static bool gpt_quote_is_transpose;
 static bool gpt_allow_plotkw;
 static int gpt_parens;
@@ -1136,6 +1138,8 @@
 {
   octave_value_list retval;
 
+  gnuplot_init ();
+
   send_to_plot_stream ("clear\n");
 
   // XXX FIXME XXX -- instead of just clearing these things, it would
@@ -1164,7 +1168,15 @@
 @end deftypefn")
 {
   octave_value_list retval;
+
+  gnuplot_init ();
+
+  parametric_plot = false;
+
+  set_global_value ("__multiplot_mode__", 0.0);
+
   close_plot_stream ();
+
   return retval;
 }
 
@@ -1188,6 +1200,8 @@
 {
   octave_value_list retval;
 
+  gnuplot_init ();
+
   int argc = args.length () + 1;
 
   string_vector argv = args.make_argv ("hold");
@@ -1225,6 +1239,8 @@
 the plot device will be cleared before drawing the next line.\n\
 @end deftypefn")
 {
+  gnuplot_init ();
+
   return octave_value (! clear_before_plotting);
 }
 
@@ -1243,7 +1259,11 @@
 @end deftypefn")
 {
   octave_value_list retval;
+
+  gnuplot_init ();
+
   cleanup_tmp_files ();
+
   return retval;
 }
 
@@ -1255,6 +1275,8 @@
 {
   octave_value_list retval;
 
+  gnuplot_init ();
+
   if (args.length () == 1 && args(0).is_string ())
     {
       std::string cmd = args(0).string_value ();
@@ -1283,6 +1305,8 @@
 {
   octave_value_list retval;
 
+  gnuplot_init ();
+
   int argc = args.length () + 1;
 
   string_vector argv = args.make_argv ("set");
@@ -1337,6 +1361,8 @@
 {
   octave_value_list retval;
 
+  gnuplot_init ();
+
   int argc = args.length () + 1;
 
   string_vector argv = args.make_argv ("show");
@@ -1364,6 +1390,8 @@
 DEFUN_DLD (__gnuplot_plot__, args, ,
   "Plot with gnuplot.\n")
 {
+  gnuplot_init ();
+
   doplot ("plot", args);
   return octave_value_list ();
 }
@@ -1371,6 +1399,8 @@
 DEFUN_DLD (__gnuplot_splot__, args, ,
   "Plot with gnuplot.\n")
 {
+  gnuplot_init ();
+
   doplot ("splot", args);
   return octave_value_list ();
 }
@@ -1378,6 +1408,8 @@
 DEFUN_DLD (__gnuplot_replot__, args, ,
   "Plot with gnuplot.\n")
 {
+  gnuplot_init ();
+
   doplot ("replot", args);
   return octave_value_list ();
 }
@@ -1412,30 +1444,40 @@
 DEFUN_DLD (gplot, args, ,
   "")
 {
+  gnuplot_init ();
+
   DEPRECATED_BODY (gplot, __gnuplot_plot__);
 }
 
 DEFUN_DLD (gsplot, args, ,
   "")
 {
+  gnuplot_init ();
+
   DEPRECATED_BODY (gsplot, __gnuplot_splot__);
 }
 
 DEFUN_DLD (graw, args, ,
   "")
 {
+  gnuplot_init ();
+
   DEPRECATED_BODY (graw, __gnuplot_raw__);
 }
 
 DEFUN_DLD (gset, args, ,
   "")
 {
+  gnuplot_init ();
+
   DEPRECATED_BODY (gset, __gnuplot_set__);
 }
 
 DEFUN_DLD (gshow, args, ,
   "")
 {
+  gnuplot_init ();
+
   DEPRECATED_BODY (gshow, __gnuplot_show__);
 }
 
@@ -1527,21 +1569,20 @@
   return 0;
 }
 
-DEFUN_DLD (__gnuplot_init__, , ,
-  "-*- texinfo -*-\n\
-@deftypefn {Loadable Function} __gnuplot_init__ ()\n\
-@end deftypefn")
+static void
+gnuplot_init (void)
 {
-  octave_value_list retval;
-
   static bool gnuplot_initialized = false;
 
   if (gnuplot_initialized)
-    return retval;
+    return;
 
   gnuplot_initialized = true;
 
-  DEFVAR (automatic_replot, true, automatic_replot,
+  if (is_builtin_variable ("automatic_replot"))
+    automatic_replot ();
+  else
+    DEFVAR (automatic_replot, true, automatic_replot,
     "-*- texinfo -*-\n\
 @defvr {Built-in Variable} automatic_replot\n\
 You can tell Octave to redisplay the plot each time anything about it\n\
@@ -1551,49 +1592,76 @@
 compatibility with Matlab.\n\
 @end defvr");
 
-  DEFVAR (gnuplot_binary, GNUPLOT_BINARY, gnuplot_binary,
+  if (is_builtin_variable ("gnuplot_binary"))
+    gnuplot_binary ();
+  else
+    DEFVAR (gnuplot_binary, GNUPLOT_BINARY, gnuplot_binary,
     "-*- texinfo -*-\n\
 @defvr {Built-in Variable} gnuplot_binary\n\
 The name of the program invoked by the plot command.  The default value\n\
 is @code{\"gnuplot\"}.  @xref{Installation}.\n\
 @end defvr");
 
-  DEFVAR (gnuplot_command_plot, "pl", gnuplot_command_plot,
+  if (is_builtin_variable ("gnuplot_command_plot"))
+    gnuplot_command_plot ();
+  else
+    DEFVAR (gnuplot_command_plot, "pl", gnuplot_command_plot,
     "-*- texinfo -*-\n\
 @defvr {Built-in Variable} gnuplot_command_plot\n\
 @end defvr");
 
-  DEFVAR (gnuplot_command_replot, "rep", gnuplot_command_replot,
+  if (is_builtin_variable ("gnuplot_command_replot"))
+    gnuplot_command_replot ();
+  else
+    DEFVAR (gnuplot_command_replot, "rep", gnuplot_command_replot,
     "-*- texinfo -*-\n\
 @defvr {Built-in Variable} gnuplot_command_replot\n\
 @end defvr");
 
-  DEFVAR (gnuplot_command_splot, "sp", gnuplot_command_splot,
+  if (is_builtin_variable ("gnuplot_command_splot"))
+    gnuplot_command_splot ();
+  else
+    DEFVAR (gnuplot_command_splot, "sp", gnuplot_command_splot,
     "-*- texinfo -*-\n\
 @defvr {Built-in Variable} gnuplot_command_splot\n\
 @end defvr");
 
-  DEFVAR (gnuplot_command_using, "u", gnuplot_command_using,
+  if (is_builtin_variable ("gnuplot_command_using"))
+    gnuplot_command_using ();
+  else
+    DEFVAR (gnuplot_command_using, "u", gnuplot_command_using,
     "-*- texinfo -*-\n\
 @defvr {Built-in Variable} gnuplot_command_using\n\
 @end defvr");
 
-  DEFVAR (gnuplot_command_with, "w", gnuplot_command_with,
+  if (is_builtin_variable ("gnuplot_command_with"))
+    gnuplot_command_with ();
+  else
+    DEFVAR (gnuplot_command_with, "w", gnuplot_command_with,
     "-*- texinfo -*-\n\
 @defvr {Built-in Variable} gnuplot_command_with\n\
 @end defvr");
 
-  DEFVAR (gnuplot_command_axes, "ax", gnuplot_command_axes,
+  if (is_builtin_variable ("gnuplot_command_axes"))
+    gnuplot_command_axes ();
+  else
+    DEFVAR (gnuplot_command_axes, "ax", gnuplot_command_axes,
     "-*- texinfo -*-\n\
 @defvr {Built-in Variable} gnuplot_command_axes\n\
 @end defvr");
 
-  DEFVAR (gnuplot_command_title, "t", gnuplot_command_title,
+  if (is_builtin_variable ("gnuplot_command_title"))
+    gnuplot_command_title ();
+  else
+    DEFVAR (gnuplot_command_title, "t", gnuplot_command_title,
     "-*- texinfo -*-\n\
 @defvr {Built-in Variable} gnuplot_command_title\n\
 @end defvr");
 
-  DEFVAR (gnuplot_command_end, "\n", gnuplot_command_end,
+  if (is_builtin_variable ("gnuplot_command_end"))
+    gnuplot_command_end ();
+  else
+    DEFVAR (gnuplot_command_end, "\n", gnuplot_command_end,
     "-*- texinfo -*-\n\
 @defvr {Built-in Variable} gnuplot_command_end\n\
 @end defvr");
@@ -1604,7 +1672,10 @@
   bool with_frames = false;
 #endif
 
-  DEFVAR (gnuplot_has_frames, with_frames, gnuplot_has_frames,
+  if (is_builtin_variable ("gnuplot_has_frames"))
+    gnuplot_has_frames ();
+  else
+    DEFVAR (gnuplot_has_frames, with_frames, gnuplot_has_frames,
     "-*- texinfo -*-\n\
 @defvr {Built-in Variable} gnuplot_has_frames\n\
 If the value of this variable is nonzero, Octave assumes that your copy\n\
@@ -1614,5 +1685,16 @@
 configure got it wrong, or if you upgrade your gnuplot installation.\n\
 @end defvr");
 
+}
+
+DEFUN_DLD (__gnuplot_init__, , ,
+  "-*- texinfo -*-\n\
+@deftypefn {Loadable Function} __gnuplot_init__ ()\n\
+@end deftypefn")
+{
+  octave_value_list retval;
+
+  gnuplot_init ();
+
   return retval;
 }