changeset 6338:ec88b4ab6d10

[project @ 2007-02-22 07:07:19 by jwe]
author jwe
date Thu, 22 Feb 2007 07:07:20 +0000
parents 24e127df8e17
children 20c48710b2c7
files scripts/ChangeLog scripts/plot/__uiobject_draw_axes__.m src/ChangeLog src/error.cc src/error.h src/mex.cc src/mexproto.h src/ov.cc src/ov.h
diffstat 9 files changed, 174 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Thu Feb 22 07:03:51 2007 +0000
+++ b/scripts/ChangeLog	Thu Feb 22 07:07:20 2007 +0000
@@ -1,3 +1,8 @@
+2007-02-22  John W. Eaton  <jwe@octave.org>
+
+	* plot/__uiobject_draw_axes__.m: If not using gnuplot for images,
+	cache data and display after xlim and ylim have been determined.
+
 2007-02-22  Daniel J Sebald  <daniel.sebald@ieee.org>
 
 	* plot/__uiobject_draw_axes__.m:
--- a/scripts/plot/__uiobject_draw_axes__.m	Thu Feb 22 07:03:51 2007 +0000
+++ b/scripts/plot/__uiobject_draw_axes__.m	Thu Feb 22 07:07:20 2007 +0000
@@ -229,18 +229,26 @@
 
     palette_set = 0;
 
+    [view_cmd, view_fcn, view_zoom] = image_viewer ();
+    use_gnuplot_for_images = (ischar (view_fcn)
+			      && strcmp (view_fcn, "gnuplot_internal"));
+
+    ximg_data = {};
+    ximg_data_idx = 0;
+
     for i = 1:length (kids)
 
       obj = get (kids(i));
 
       switch (obj.type)
 	case "image"
-	  % FIXME - Is there a better way to determine if the plot command should
-	  % be "plot" or "splot"?????  Could have images projected into 3D so there
-	  % is really no reason to limit this.
+	  ## FIXME - Is there a better way to determine if the plot
+	  ## command should be "plot" or "splot"?????  Could have images
+	  ## projected into 3D so there is really no reason to limit
+	  ## this.
 	  if (nd == 0)
 	    nd = 2;
-	  end
+	  endif
 	  data_idx++;
 
 	  img_data = obj.cdata;
@@ -248,8 +256,7 @@
 	  img_xdata = obj.xdata;
 	  img_ydata = obj.ydata;
 
-	  [view_cmd, view_fcn, view_zoom] = image_viewer ();
-	  if (ischar (view_fcn) && strcmp (view_fcn, "gnuplot_internal"))
+	  if (use_gnuplot_for_images)
 
 	    [y_dim, x_dim] = size (img_data(:,:,1));
 	    if (x_dim > 1)
@@ -276,7 +283,8 @@
 	      fwrite (fid, img_data(:), "float");
 	      format = "1";
 	      imagetype = "image";
-	      % Only need to set pallete once because it doesn't change on a figure.
+	      ## Only need to set pallete once because it doesn't change
+	      ## on a figure.
 	      if (! palette_set)
 		palette_set = 1;
 		palette_size = rows (img_colormap);
@@ -289,10 +297,11 @@
 		  for i = 1:palette_size
 		    fprintf (plot_stream, "%g %g %g %g;\n",
 			     1e-3*round (1e3*[(i-1)/(palette_size-1), img_colormap(i,:)]));
-		  end
+		  endfor
 		  fprintf (plot_stream, "e;\n");
 		else
-		  # Let the file be deleted when Octave exits or `purge_tmp_files' is called.
+		  ## Let the file be deleted when Octave exits or
+		  ## `purge_tmp_files' is called.
 		  [fid, binary_fname, msg] = mkstemp (strcat (P_tmpdir, "/gpimageXXXXXX"), 1);
 		  fwrite (fid, img_colormap', "float32", 0, "ieee-le");
 		  fclose (fid);
@@ -310,10 +319,12 @@
 		x_dim, y_dim, x_origin, y_origin, dx, dy, format);
 	    withclause{data_idx} = sprintf ("with %s", imagetype);
 
-	    data{data_idx} = 0; % Data in file, set to zero for data available test to pass below.
+	    ## Data in file, set to zero for data available test to pass
+	    ## below.
+	    data{data_idx} = 0; 
 
 	  else
-	    view_fcn (xlim, ylim, img_data, view_zoom, view_cmd);
+	    ximg_data{++ximg_data_idx} = img_data;
 	  endif
 
 	case "line"
@@ -616,6 +627,12 @@
     fputs (plot_stream, "set style data lines;\n");
     fflush (plot_stream);
 
+    if (! use_gnuplot_for_images)
+      for i = 1:ximg_data_idx
+	view_fcn (xlim, ylim, ximg_data{i}, view_zoom, view_cmd);
+      endfor
+    endif
+
     if (have_data)
 
       if (nd == 2)
--- a/src/ChangeLog	Thu Feb 22 07:03:51 2007 +0000
+++ b/src/ChangeLog	Thu Feb 22 07:07:20 2007 +0000
@@ -1,5 +1,17 @@
 2007-02-21  John W. Eaton  <jwe@octave.org>
 
+	* mex.cc (mexErrMsgIdAndTxt, mexWarnMsgIdAndTxt): Handle second
+	arg as format and accept variable number of arguments.
+	* mexproto.h: Fix decls.
+
+	* error.h, error.cc (vmessage, vusage, vwarning, verror,
+	vparse_error, vmessage_with_id, vusage_with_id, vwarning_with_id,
+	verror_with_id, vparse_error_with_id): Provide va_list versions of
+	variadic error, warning, and message functions.
+	(message, usage, warning, error, parse_error, message_with_id,
+	usage_with_id, warning_with_id, error_with_id,
+	parse_error_with_id): Call va_list versions.
+
 	* DLD-FUNCTIONS/urlwrite.cc (Furlwrite, Furlread): Return error
 	code and message instead of throwing error if functionality is
 	missing.
--- a/src/error.cc	Thu Feb 22 07:03:51 2007 +0000
+++ b/src/error.cc	Thu Feb 22 07:07:20 2007 +0000
@@ -286,20 +286,33 @@
 }
 
 void
+vmessage (const char *name, const char *fmt, va_list args)
+{
+  verror (false, std::cerr, name, "", fmt, args);
+}
+
+void
 message (const char *name, const char *fmt, ...)
 {
   va_list args;
   va_start (args, fmt);
-  verror (false, std::cerr, name, "", fmt, args);
+  vmessage (name, fmt, args);
   va_end (args);
 }
 
 void
+vmessage_with_id (const char *name, const char *id, const char *fmt,
+		  va_list args)
+{
+  verror (false, std::cerr, name, id, fmt, args);
+}
+
+void
 message_with_id (const char *name, const char *id, const char *fmt, ...)
 {
   va_list args;
   va_start (args, fmt);
-  verror (false, std::cerr, name, id, fmt, args);
+  vmessage_with_id (name, id, fmt, args);
   va_end (args);
 }
 
@@ -311,20 +324,32 @@
 }
 
 void
+vusage (const char *fmt, va_list args)
+{
+  usage_1 ("", fmt, args);
+}
+
+void
 usage (const char *fmt, ...)
 {
   va_list args;
   va_start (args, fmt);
-  usage_1 ("", fmt, args);
+  vusage (fmt, args);
   va_end (args);
 }
 
 void
+vusage_with_id (const char *id, const char *fmt, va_list args)
+{
+  usage_1 (id, fmt, args);
+}
+
+void
 usage_with_id (const char *id, const char *fmt, ...)
 {
   va_list args;
   va_start (args, fmt);
-  usage_1 (id, fmt, args);
+  vusage_with_id (id, fmt, args);
   va_end (args);
 }
 
@@ -454,20 +479,32 @@
 }
 
 void
+verror (const char *fmt, va_list args)
+{
+  error_2 ("", fmt, args);
+}
+
+void
 error (const char *fmt, ...)
 {
   va_list args;
   va_start (args, fmt);
-  error_2 ("", fmt, args);
+  verror (fmt, args);
   va_end (args);
 }
 
 void
+verror_with_id (const char *id, const char *fmt, va_list args)
+{
+  error_2 (id, fmt, args);
+}
+
+void
 error_with_id (const char *id, const char *fmt, ...)
 {
   va_list args;
   va_start (args, fmt);
-  error_2 (id, fmt, args);
+  verror_with_id (id, fmt, args);
   va_end (args);
 }
 
@@ -595,38 +632,62 @@
 }
 
 void
+vwarning (const char *fmt, va_list args)
+{
+  warning_1 ("", fmt, args);
+}
+
+void
 warning (const char *fmt, ...)
 {
   va_list args;
   va_start (args, fmt);
-  warning_1 ("", fmt, args);
+  vwarning (fmt, args);
   va_end (args);
 }
 
 void
+vwarning_with_id (const char *id, const char *fmt, va_list args)
+{
+  warning_1 (id, fmt, args);
+}
+
+void
 warning_with_id (const char *id, const char *fmt, ...)
 {
   va_list args;
   va_start (args, fmt);
-  warning_1 (id, fmt, args);
+  vwarning_with_id (id, fmt, args);
   va_end (args);
 }
 
 void
+vparse_error (const char *fmt, va_list args)
+{
+  error_1 (std::cerr, 0, "", fmt, args);
+}
+
+void
 parse_error (const char *fmt, ...)
 {
   va_list args;
   va_start (args, fmt);
-  error_1 (std::cerr, 0, "", fmt, args);
+  vparse_error (fmt, args);
   va_end (args);
 }
 
 void
+vparse_error_with_id (const char *id, const char *fmt, va_list args)
+{
+  error_1 (std::cerr, 0, id, fmt, args);
+}
+
+void
 parse_error_with_id (const char *id, const char *fmt, ...)
 {
   va_list args;
   va_start (args, fmt);
-  error_1 (std::cerr, 0, id, fmt, args);
+  vparse_error_with_id (id, fmt, args);
   va_end (args);
 }
 
--- a/src/error.h	Thu Feb 22 07:03:51 2007 +0000
+++ b/src/error.h	Thu Feb 22 07:07:20 2007 +0000
@@ -34,25 +34,49 @@
 
 extern OCTINTERP_API int warning_enabled (const std::string& id);
 
+extern OCTINTERP_API void vmessage (const char *name, const char *fmt, va_list args);
 extern OCTINTERP_API void message (const char *name, const char *fmt, ...);
+
+extern OCTINTERP_API void vusage (const char *fmt, va_list args);
 extern OCTINTERP_API void usage (const char *fmt, ...);
+
+extern OCTINTERP_API void vwarning (const char *fmt, va_list args);
 extern OCTINTERP_API void warning (const char *fmt, ...);
+
+extern OCTINTERP_API void verror (const char *fmt, va_list args);
 extern OCTINTERP_API void error (const char *fmt, ...);
+
+extern OCTINTERP_API void vparse_error (const char *fmt, va_list args);
 extern OCTINTERP_API void parse_error (const char *fmt, ...);
 
 extern OCTINTERP_API void
+vmessage_with_id (const char *id, const char *name, const char *fmt, va_list args);
+
+extern OCTINTERP_API void
 message_with_id (const char *id, const char *name, const char *fmt, ...);
 
 extern OCTINTERP_API void
+vusage_with_id (const char *id, const char *fmt, va_list args);
+
+extern OCTINTERP_API void
 usage_with_id (const char *id, const char *fmt, ...);
 
 extern OCTINTERP_API void
+vwarning_with_id (const char *id, const char *fmt, va_list args);
+
+extern OCTINTERP_API void
 warning_with_id (const char *id, const char *fmt, ...);
 
 extern OCTINTERP_API void
+verror_with_id (const char *id, const char *fmt, va_list args);
+
+extern OCTINTERP_API void
 error_with_id (const char *id, const char *fmt, ...);
 
 extern OCTINTERP_API void
+vparse_error_with_id (const char *id, const char *fmt, va_list args);
+
+extern OCTINTERP_API void
 parse_error_with_id (const char *id, const char *fmt, ...);
 
 extern OCTINTERP_API void panic (const char *fmt, ...) GCC_ATTR_NORETURN;
--- a/src/mex.cc	Thu Feb 22 07:03:51 2007 +0000
+++ b/src/mex.cc	Thu Feb 22 07:07:20 2007 +0000
@@ -3124,10 +3124,19 @@
 }
 
 void
-mexErrMsgIdAndTxt (const char *id, const char *s)
+mexErrMsgIdAndTxt (const char *id, const char *fmt, ...)
 {
-  if (s && strlen (s) > 0)
-    error_with_id (id, "%s: %s", mexFunctionName (), s);
+  if (fmt && strlen (fmt) > 0)
+    {
+      const char *fname = mexFunctionName ();
+      size_t len = strlen (fname) + 2 + strlen (fmt) + 1;
+      OCTAVE_LOCAL_BUFFER (char, tmpfmt, len);
+      sprintf (tmpfmt, "%s: %s", fname, fmt);
+      va_list args;
+      va_start (args, fmt);
+      verror_with_id (id, tmpfmt, args);
+      va_end (args);
+    }
   else
     // Just set the error state; don't print msg.
     error ("");
@@ -3142,9 +3151,22 @@
 }
 
 void
-mexWarnMsgIdAndTxt (const char *id, const char *s)
+mexWarnMsgIdAndTxt (const char *id, const char *fmt, ...)
 {
-  warning_with_id (id, "%s", s);
+  // FIXME -- is this right?  What does Matlab do if fmt is NULL or
+  // an empty string?
+
+  if (fmt && strlen (fmt) > 0)
+    {
+      const char *fname = mexFunctionName ();
+      size_t len = strlen (fname) + 2 + strlen (fmt) + 1;
+      OCTAVE_LOCAL_BUFFER (char, tmpfmt, len);
+      sprintf (tmpfmt, "%s: %s", fname, fmt);
+      va_list args;
+      va_start (args, fmt);
+      vwarning_with_id (id, tmpfmt, args);
+      va_end (args);
+    }
 }
 
 void
--- a/src/mexproto.h	Thu Feb 22 07:03:51 2007 +0000
+++ b/src/mexproto.h	Thu Feb 22 07:07:20 2007 +0000
@@ -71,9 +71,9 @@
 extern OCTINTERP_API void mexSetTrapFlag (int flag);
 extern OCTINTERP_API int mexEvalString (const char *s);
 extern OCTINTERP_API void mexErrMsgTxt (const char *s);
-extern OCTINTERP_API void mexErrMsgIdAndTxt (const char *id, const char *s);
+extern OCTINTERP_API void mexErrMsgIdAndTxt (const char *id, const char *s, ...);
 extern OCTINTERP_API void mexWarnMsgTxt (const char *s);
-extern OCTINTERP_API void mexWarnMsgIdAndTxt (const char *id, const char *s);
+extern OCTINTERP_API void mexWarnMsgIdAndTxt (const char *id, const char *s, ...);
 extern OCTINTERP_API void mexPrintf (const char *fmt, ...);
   
 extern OCTINTERP_API mxArray *mexGetVariable (const char *space, const char *name);
--- a/src/ov.cc	Thu Feb 22 07:03:51 2007 +0000
+++ b/src/ov.cc	Thu Feb 22 07:07:20 2007 +0000
@@ -681,17 +681,6 @@
 {
 }
 
-octave_value::~octave_value (void)
-{
-#if defined (MDEBUG)
-  std::cerr << "~octave_value: rep: " << rep
-	    << " rep->count: " << rep->count << std::endl;
-#endif
-
-  if (--rep->count == 0)
-    delete rep;
-}
-
 octave_base_value *
 octave_value::clone (void) const
 {
--- a/src/ov.h	Thu Feb 22 07:03:51 2007 +0000
+++ b/src/ov.h	Thu Feb 22 07:07:20 2007 +0000
@@ -239,7 +239,11 @@
   // Delete the representation of this constant if the count drops to
   // zero.
 
-  ~octave_value (void);
+  ~octave_value (void)
+  {
+    if (--rep->count == 0)
+      delete rep;
+  }
 
   void make_unique (void)
     {