# HG changeset patch # User jwe # Date 1173891090 0 # Node ID b298a4c12fc3dd13589263fd2b42758e4b591338 # Parent 2005c0169e364f3c7c6d8a052383f2653944a21d [project @ 2007-03-14 16:51:28 by jwe] diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,78 @@ +2007-03-14 John W. Eaton + + * plot/__axis_label__.m: Convert arg to text handle before calling set. + + * plot/__plt__.m: Return line handles from all calls to __plt1__ + and __plt2__, not just the last. + + * plot/Makefile.in (SOURCES): Rename from SOURCES_M. + (SOURCES_IN, GEN_M): Delete. + (FCN_FILES): Don't include $(GEN_M). + (all): Don't depend on $(GEN_M). + ($(GEN_M) : %.m : %.in): Delete pattern rule. + + * plot/text.m: Use __go_text__ instead of __uiboject_text_ctor__. + + * plot/newplot.m: Call __go_axes_init__ instead of + __uiobject_axes_init__. + + * plot/mesh.m: Use __go_surface__ instead of + __uiobject_surface_ctor__. Don't access object fields directly. + + * plot/line.m: Use __line__ to do actual work. + * plot/__line__.m: New function. + + * plot/axes.m: Use __go_axes__ to create axes graphics handle. + Use get and set instead of accessing object fields directly. + + * plot/figure.m: Use __go_figure__ to create figure graphics + handle. + + * plot/drawnow.m: Register __go_close_all__ with atexit instead of + __uiobject_close_all. Call __go_draw_figure__ instead of + __uiobject_draw_figure__. + + * plot/clf.m: Use get instead of accessing object fields + directly. Simply delete children. Don't set currentaxes. + + * plot/close.m (close_all_figures): New subfunction. + Use it instead of getting list of figures to close from + __uiobject_figures__. + + * plot/closereq.m: Simply delete the current figure. Don't set + currentfigure. + + * plot/__errplot__.m: Call __line__ instead of + __uiobject_line_ctor__. Use set instead of accesing object fields + directly. Don't call __uiobject_adopt__. + + * plot/__uiobject_adopt__.m, plot/__uiobject_alloc__.in, + plot/__uiobject_axes_ctor__.m, plot/__uiobject_axes_dtor__.m, + plot/__uiobject_axes_init__.in, plot/__uiobject_axes_setr__.m, + plot/__uiobject_delete__.m, plot/__uiobject_figure_ctor__.m, + plot/__uiobject_figures__.in, plot/__uiobject_free__.in, + plot/__uiobject_get_handle__.in, plot/__uiobject_globals__.m, + plot/__uiobject_grow_list__.in, plot/__uiobject_handle2idx__.in, + plot/__uiobject_image_ctor__.m, plot/__uiobject_init_figure__.in, + plot/__uiobject_init_root_figure__.in, + plot/__uiobject_line_ctor__.m, plot/__uiobject_make_handle__.in, + plot/__uiobject_root_figure_ctor__.m, + plot/__uiobject_surface_ctor__.m, plot/__uiobject_text_ctor__.m: + plot/get.in, plot/include-globals.awk, plot/ishandle.m, + plot/set.in: Delete. + + * plot/__go_close_all__.m: Rename from __uiobject_close_all.m. + Pass "hidden" as second arg to close. + * plot/__go_draw_axes__.m: Rename from __uiobject_draw_axes.m. + * plot/__go_draw_figure__.m: Rename from __uiobject_draw_figure.m. + + * image/__img__.m: Use __go_image__ to create image graphics + handle. + + * miscellaneous/delete.m: Call __go_delete__, not + __uiobject_delete__. Check that arg is a graphics handle before + calling __go_delete__. + 2007-03-13 John W. Eaton * miscellaneous/cast.m: Use feval and strcmp with cell to check diff --git a/scripts/image/__img__.m b/scripts/image/__img__.m --- a/scripts/image/__img__.m +++ b/scripts/image/__img__.m @@ -52,15 +52,7 @@ ca = gca (); - s = __uiobject_image_ctor__ (ca); - - s.cdata = img; - s.xdata = xlim; - s.ydata = ylim; - - tmp = __uiobject_make_handle__ (s); - - __uiobject_adopt__ (ca, tmp); + tmp = __go_image__ (ca, "cdata", img, "xdata", xlim, "ydata", ylim); set (ca, "view", [0, 90]); diff --git a/scripts/miscellaneous/delete.m b/scripts/miscellaneous/delete.m --- a/scripts/miscellaneous/delete.m +++ b/scripts/miscellaneous/delete.m @@ -32,8 +32,11 @@ if (nargin == 1) if (ischar (arg)) unlink (arg); + elseif (ishandle (arg)) + ## Delete a graphics object. + __go_delete__ (arg); else - __uiobject_delete__ (arg); + error ("delete: expecting argument to be a filename or graphics handle"); endif else print_usage (); diff --git a/scripts/plot/Makefile.in b/scripts/plot/Makefile.in --- a/scripts/plot/Makefile.in +++ b/scripts/plot/Makefile.in @@ -20,7 +20,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ -SOURCES_M = \ +SOURCES = \ __axis_label__.m \ __default_colormap__.m \ __default_plot_options__.m \ @@ -108,30 +108,12 @@ ylabel.m \ zlabel.m -SOURCES_IN = \ - __uiobject_alloc__.in \ - __uiobject_axes_init__.in \ - __uiobject_figures__.in \ - __uiobject_free__.in \ - __uiobject_get_handle__.in \ - __uiobject_grow_list__.in \ - __uiobject_handle2idx__.in \ - __uiobject_init_figure__.in \ - __uiobject_init_root_figure__.in \ - __uiobject_make_handle__.in \ - get.in \ - set.in - -GEN_M = $(SOURCES_IN:.in=.m) - -SOURCES = $(SOURCES_M) $(SOURCES_IN) - DISTFILES = Makefile.in include-globals.awk $(SOURCES) -FCN_FILES = $(addprefix $(srcdir)/, $(SOURCES_M)) $(GEN_M) +FCN_FILES = $(addprefix $(srcdir)/, $(SOURCES_M)) FCN_FILES_NO_DIR = $(notdir $(FCN_FILES)) -all: $(GEN_M) PKG_ADD +all: PKG_ADD .PHONY: all install install-strip: @@ -169,7 +151,3 @@ dist: $(LN_S) $(DISTFILES) ../../`cat ../../.fname`/scripts/plot .PHONY: dist - -$(GEN_M) : %.m : %.in __uiobject_globals__.m - $(AWK) -f $(srcdir)/include-globals.awk file=$(srcdir)/__uiobject_globals__.m $< > $@-t - $(simple-move-if-change-rule) diff --git a/scripts/plot/__axis_label__.m b/scripts/plot/__axis_label__.m --- a/scripts/plot/__axis_label__.m +++ b/scripts/plot/__axis_label__.m @@ -32,7 +32,8 @@ if (nargin == 2) if (ischar (txt)) ca = gca (); - set (ca, caller, txt); + ## FIXME -- should be able to use text instead of __go_text__. + set (ca, caller, __go_text__ (ca, "string", txt)); if (nargout > 0) retval = get (ca, caller); endif diff --git a/scripts/plot/__errplot__.m b/scripts/plot/__errplot__.m --- a/scripts/plot/__errplot__.m +++ b/scripts/plot/__errplot__.m @@ -33,7 +33,7 @@ ## Author: Teemu Ikonen ## Keywords: errorbar, plotting -function __errplot__ (fstr, h, a1, a2, a3, a4, a5, a6) +function h = __errplot__ (fstr, p, a1, a2, a3, a4, a5, a6) if (nargin < 4 || nargin > 8) # at least two data arguments needed print_usage (); @@ -45,47 +45,44 @@ for i = 1:nplots ifmt = fmt{1+mod(i-1,numel(fmt))}; - s = __uiobject_line_ctor__ (h); + h = __line__ (p); switch (nargin - 2) case 2 - s.xdata = (1:len)'; - s.ydata = a1(:,i); - s.ldata = a2(:,i); - s.udata = a2(:,i); + set (h, "xdata", (1:len)'); + set (h, "ydata", a1(:,i)); + set (h, "ldata", a2(:,i)); + set (h, "udata", a2(:,i)); case 3 - s.xdata = a1(:,i); - s.ydata = a2(:,i); - s.ldata = a3(:,i); - s.udata = a3(:,i); + set (h, "xdata", a1(:,i)); + set (h, "ydata", a2(:,i)); + set (h, "ldata", a3(:,i)); + set (h, "udata", a3(:,i)); case 4 - s.xdata = a1(:,i); - s.ydata = a2(:,i); + set (h, "xdata", a1(:,i)); + set (h, "ydata", a2(:,i)); if (index (ifmt, "boxxy") || index (ifmt, "xyerr")) - s.xldata = a3(:,i); - s.xudata = a3(:,i); - s.ldata = a4(:,i); - s.udata = a4(:,i); + set (h, "xldata", a3(:,i)); + set (h, "xudata", a3(:,i)); + set (h, "ldata", a4(:,i)); + set (h, "udata", a4(:,i)); elseif (index (ifmt, "xerr")) - s.xldata = a3(:,i); - s.xudata = a4(:,i); + set (h, "xldata", a3(:,i)); + set (h, "xudata", a4(:,i)); else - s.ldata = a3(:,i); - s.udata = a4(:,i); + set (h, "ldata", a3(:,i)); + set (h, "udata", a4(:,i)); endif case 5 error ("error plot requires 2, 3, 4 or 6 columns"); case 6 - s.xdata = a1(:,i); - s.ydata = a2(:,i); - s.xldata = a3(:,i); - s.xudata = a4(:,i); - s.ldata = a5(:,i); - s.udata = a6(:,i); + set (h, "xdata", a1(:,i)); + set (h, "ydata", a2(:,i)); + set (h, "xldata", a3(:,i)); + set (h, "xudata", a4(:,i)); + set (h, "ldata", a5(:,i)); + set (h, "udata", a6(:,i)); endswitch - - __uiobject_adopt__ (h, __uiobject_make_handle__ (s)); - endfor endfunction diff --git a/scripts/plot/__go_close_all__.m b/scripts/plot/__go_close_all__.m new file mode 100644 --- /dev/null +++ b/scripts/plot/__go_close_all__.m @@ -0,0 +1,30 @@ +## Copyright (C) 2007 John W. Eaton +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2, or (at your option) +## any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, write to the Free +## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +## 02110-1301, USA. + +## -*- texinfo -*- +## @deftypefn {Function File} {} __go_close_all__ () +## Internal function to close all figures. +## @seealso{drawnow} +## @end deftypefn + +## Author: jwe + +function __go_close_all__ () + close ("all", "hidden"); +endfunction diff --git a/scripts/plot/__go_draw_axes__.m b/scripts/plot/__go_draw_axes__.m new file mode 100644 --- /dev/null +++ b/scripts/plot/__go_draw_axes__.m @@ -0,0 +1,871 @@ +## Copyright (C) 2005 John W. Eaton +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2, or (at your option) +## any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, write to the Free +## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +## 02110-1301, USA. + +## -*- texinfo -*- +## @deftypefn {Function File} {} __go_draw_axes__ (@var{axis_obj}, @var{plot_stream}) +## Display the axes @var{axis_obj} on @var{plot_stream}. +## @end deftypefn + +## Author: jwe + +function __go_draw_axes__ (h, plot_stream) + + if (nargin == 2) + + axis_obj = get (h); + + parent_figure_obj = get (axis_obj.parent); + + have_newer_gnuplot = compare_versions (__gnuplot_version__ (), "4.0", ">"); + + ## Set axis properties here? + + if (! isempty (axis_obj.outerposition)) + pos = axis_obj.outerposition; + fprintf (plot_stream, "set origin %g, %g;\n", pos(1), pos(2)); + fprintf (plot_stream, "set size %g, %g;\n", pos(3), pos(4)); + endif + + if (! isempty (axis_obj.position)) + pos = axis_obj.position; + fprintf (plot_stream, "set origin %g, %g;\n", pos(1), pos(2)); + fprintf (plot_stream, "set size %g, %g;\n", pos(3), pos(4)); + endif + + if (strcmp (axis_obj.dataaspectratiomode, "manual")) + r = axis_obj.dataaspectratio; + fprintf (plot_stream, "set size ratio %g;\n", -r(2)/r(1)); + else + fputs (plot_stream, "set size noratio;\n"); + endif + + if (! isempty (axis_obj.title)) + t = get (axis_obj.title); + if (isempty (t.string)) + fputs (plot_stream, "unset title;\n"); + else + fprintf (plot_stream, "set title \"%s\";\n", + undo_string_escapes (t.string)); + endif + endif + + if (! isempty (axis_obj.xlabel)) + t = get (axis_obj.xlabel); + if (isempty (t.string)) + fputs (plot_stream, "unset xlabel;\n"); + else + fprintf (plot_stream, "set xlabel \"%s\";\n", + undo_string_escapes (t.string)); + endif + endif + + if (! isempty (axis_obj.ylabel)) + t = get (axis_obj.ylabel); + if (isempty (t.string)) + fputs (plot_stream, "unset ylabel;\n"); + else + fprintf (plot_stream, "set ylabel \"%s\";\n", + undo_string_escapes (t.string)); + endif + endif + + if (! isempty (axis_obj.zlabel)) + t = get (axis_obj.zlabel); + if (isempty (t.string)) + fputs (plot_stream, "unset zlabel;\n"); + else + fprintf (plot_stream, "set zlabel \"%s\";\n", + undo_string_escapes (t.string)); + endif + endif + + if (strcmp (axis_obj.xgrid, "on")) + fputs (plot_stream, "set grid xtics;\n"); + else + fputs (plot_stream, "set grid noxtics;\n"); + endif + + if (strcmp (axis_obj.ygrid, "on")) + fputs (plot_stream, "set grid ytics;\n"); + else + fputs (plot_stream, "set grid noytics;\n"); + endif + + if (strcmp (axis_obj.zgrid, "on")) + fputs (plot_stream, "set grid ztics;\n"); + else + fputs (plot_stream, "set grid ztics;\n"); + endif + + if (strcmp (axis_obj.xminorgrid, "on")) + fputs (plot_stream, "set mxtics 5;\n"); + fputs (plot_stream, "set grid mxtics;\n"); + else + fputs (plot_stream, "set grid nomxtics;\n"); + endif + + if (strcmp (axis_obj.yminorgrid, "on")) + fputs (plot_stream, "set mytics 5;\n"); + fputs (plot_stream, "set grid mytics;\n"); + else + fputs (plot_stream, "set grid nomytics;\n"); + endif + + if (strcmp (axis_obj.zminorgrid, "on")) + fputs (plot_stream, "set mztics 5;\n"); + fputs (plot_stream, "set grid mztics;\n"); + else + fputs (plot_stream, "set grid nomztics;\n"); + endif + + if (strcmp (axis_obj.xtickmode, "manual")) + xtic = axis_obj.xtick; + if (isempty (xtic)) + fputs (plot_stream, "unset xtics;\n"); + else + ## FIXME + endif + else + fputs (plot_stream, "set xtics;\n"); + endif + + if (strcmp (axis_obj.ytickmode, "manual")) + ytic = axis_obj.ytick; + if (isempty (ytic)) + fputs (plot_stream, "unset ytics;\n"); + else + ## FIXME + endif + else + fputs (plot_stream, "set ytics;\n"); + endif + + if (strcmp (axis_obj.ztickmode, "manual")) + ztic = axis_obj.ztick; + if (isempty (ztic)) + fputs (plot_stream, "unset ztics;\n"); + else + ## FIXME + endif + else + fputs (plot_stream, "set ztics;\n"); + endif + + if (strcmp (axis_obj.xticklabelmode, "manual")) + ## FIXME -- we should be able to specify the actual tick labels, + ## not just the format. + xticlabel = axis_obj.xticklabel; + fprintf (plot_stream, "set format x \"%s\";\n", xticlabel); + else + fputs (plot_stream, "set xtics;\n"); + endif + + if (strcmp (axis_obj.yticklabelmode, "manual")) + ## FIXME -- we should be able to specify the actual tick labels, + ## not just the format. + yticlabel = axis_obj.yticklabel; + fprintf (plot_stream, "set format y \"%s\";\n", yticlabel); + else + fputs (plot_stream, "set ytics;\n"); + endif + + if (strcmp (axis_obj.zticklabelmode, "manual")) + ## FIXME -- we should be able to specify the actual tick labels, + ## not just the format. + zticlabel = axis_obj.zticklabel; + fprintf (plot_stream, "set format z \"%s\";\n", zticlabel); + else + fputs (plot_stream, "set ztics;\n"); + endif + + xlogscale = strcmp (axis_obj.xscale, "log"); + if (xlogscale) + fputs (plot_stream, "set logscale x;\n"); + else + fputs (plot_stream, "unset logscale x;\n"); + endif + + ylogscale = strcmp (axis_obj.yscale, "log"); + if (ylogscale) + fputs (plot_stream, "set logscale y;\n"); + else + fputs (plot_stream, "unset logscale y;\n"); + endif + + zlogscale = strcmp (axis_obj.zscale, "log"); + if (zlogscale) + fputs (plot_stream, "set logscale z;\n"); + else + fputs (plot_stream, "unset logscale z;\n"); + endif + + xautoscale = strcmp (axis_obj.xlimmode, "auto"); + yautoscale = strcmp (axis_obj.ylimmode, "auto"); + zautoscale = strcmp (axis_obj.zlimmode, "auto"); + + kids = axis_obj.children; + + nd = 0; + data_idx = 0; + data = cell (); + + xminp = yminp = zminp = Inf; + xmax = ymax = zmax = -Inf; + xmin = ymin = zmin = Inf; + + 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. + if (nd == 0) + nd = 2; + endif + + img_data = obj.cdata; + img_colormap = parent_figure_obj.colormap; + img_xdata = obj.xdata; + img_ydata = obj.ydata; + + if (use_gnuplot_for_images) + + data_idx++; + + [y_dim, x_dim] = size (img_data(:,:,1)); + if (x_dim > 1) + dx = abs (img_xdata(2)-img_xdata(1))/(x_dim-1); + else + dx = 1; + endif + if (y_dim > 1) + dy = abs (img_ydata(2)-img_ydata(1))/(y_dim-1); + else + dy = 1; + endif + x_origin = min (img_xdata); + y_origin = min (img_ydata); + + if (nd == 2) + if (xautoscale) + xmin = min (xmin, min (img_xdata) - dx/2); + xmax = max (xmax, max (img_xdata) + dx/2); + xminp = min (xminp, min (img_xdata((img_xdata - dx/2)>0)) - dx/2); + endif + if (yautoscale) + ymin = min (ymin, min (img_ydata) - dy/2); + ymax = max (ymax, max (img_ydata) + dy/2); + yminp = min (yminp, min (img_ydata((img_ydata - dy/2)>0)) - dy/2); + endif + else + ## Can have images in 3D, but the image routines don't seem + ## to have a means of arbitrary projection. + endif + + ## Let the file be deleted when Octave exits or `purge_tmp_files' + ## is called. + [img_fid, img_fname] = mkstemp (fullfile (P_tmpdir, "gpimageXXXXXX"), 1); + if (ndims (img_data) == 3) + fwrite (img_fid, permute (img_data, [3, 1, 2])(:), "float"); + format = "1:2:3"; + imagetype = "rgbimage"; + else + fwrite (img_fid, img_data(:), "float"); + format = "1"; + imagetype = "image"; + ## 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); + fprintf (plot_stream, + "set palette positive color model RGB maxcolors %i;\n", + palette_size); + if (palette_size <= 128) + ## Break up command to avoid buffer overflow. + fprintf (plot_stream, "set palette file \"-\" using 1:2:3:4;\n"); + 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,:)])); + endfor + fprintf (plot_stream, "e;\n"); + else + ## Let the file be deleted when Octave exits or + ## `purge_tmp_files' is called. + [cmap_fid, cmap_fname, msg] = mkstemp (fullfile (P_tmpdir, "gpimageXXXXXX"), 1); + fwrite (cmap_fid, img_colormap', "float32", 0, "ieee-le"); + fclose (cmap_fid); + fprintf (plot_stream, + "set palette file \"%s\" binary record=%d using 1:2:3;\n", + cmap_fname, palette_size); + endif + endif + endif + fclose (img_fid); + + filespec{data_idx} = img_fname; + titlespec{data_idx} = ""; + usingclause{data_idx} = sprintf ("binary array=%dx%d scan=yx flipy origin=(%g,%g) dx=%g dy=%g using %s", + x_dim, y_dim, x_origin, y_origin, dx, dy, format); + withclause{data_idx} = sprintf ("with %s", imagetype); + + ## Data in file, set to zero for data available test to pass + ## below. + data{data_idx} = 0; + + else + ximg_data{++ximg_data_idx} = img_data; + endif + + case "line" + data_idx++; + filespec{data_idx} = '-'; + if (isempty (obj.keylabel)) + titlespec{data_idx} = "title \"\""; + else + titlespec{data_idx} = strcat ("title \"", obj.keylabel, "\""); + endif + style = do_linestyle_command (obj, data_idx, plot_stream); + usingclause{data_idx} = ""; + withclause{data_idx} = sprintf ("with %s linestyle %d", + style, data_idx); + parametric(i) = true; + if (! isempty (obj.zdata)) + nd = 3; + xdat = obj.xdata(:); + ydat = obj.ydata(:); + zdat = obj.zdata(:); + if (xautoscale) + xmin = min (xmin, min (xdat)); + xmax = max (xmax, max (xdat)); + xminp = min (xminp, min (xdat(xdat>0))); + endif + if (yautoscale) + ymin = min (ymin, min (ydat)); + ymax = max (ymax, max (ydat)); + yminp = min (yminp, min (ydat(ydat>0))); + endif + if (zautoscale) + zmin = min (zmin, min (zdat)); + zmax = max (zmax, max (zdat)); + zminp = min (zminp, min (zdat(zdat>0))); + endif + data{data_idx} = [xdat, ydat, zdat]'; + usingclause{data_idx} = "using ($1):($2):($3)"; + fputs (plot_stream, "set parametric;\n"); + fputs (plot_stream, "unset hidden3d;\n"); + fputs (plot_stream, "set style data lines;\n"); + fputs (plot_stream, "set surface;\n"); + fputs (plot_stream, "unset contour;\n"); + else + nd = 2; + xdat = obj.xdata(:); + ydat = obj.ydata(:); + ldat = obj.ldata; + yerr = xerr = false; + if (! isempty (ldat)) + yerr = true; + ldat = ldat(:); + endif + udat = obj.udata; + if (! isempty (udat)) + udat = udat(:); + endif + xldat = obj.xldata; + if (! isempty (xldat)) + xerr = true; + xldat = xldat(:); + endif + xudat = obj.xudata; + if (! isempty (xudat)) + xudat = xudat(:); + endif + if (yerr) + ylo = ydat-ldat; + yhi = ydat+udat; + if (yautoscale) + ty = [ydat; ylo; yhi]; + ymin = min (ymin, min (ty)); + ymax = max (ymax, max (ty)); + yminp = min (yminp, min (ty(ty>0))); + endif + if (xerr) + xlo = xdat-xldat; + xhi = xdat+xudat; + if (xautoscale) + tx = [xdat; xlo; xhi]; + xmin = min (xmin, min (tx)); + xmax = max (xmax, max (tx)); + xminp = min (xminp, min (tx(tx>0))); + endif + data{data_idx} = [xdat, ydat, xlo, xhi, ylo, yhi]'; + usingclause{data_idx} = "using ($1):($2):($3):($4):($5):($6)"; + withclause{data_idx} = sprintf ("with xyerrorbars linestyle %d", + data_idx); + else + if (xautoscale) + xmin = min (xmin, min (xdat)); + xmax = max (xmax, max (xdat)); + xminp = min (xminp, min (tx(tx>0))); + endif + data{data_idx} = [xdat, ydat, ylo, yhi]'; + usingclause{data_idx} = "using ($1):($2):($3):($4)"; + withclause{data_idx} = sprintf ("with yerrorbars linestyle %d", + data_idx); + endif + elseif (xerr) + xlo = xdat-xldat; + xhi = xdat+xudat; + if (xautoscale) + tx = [xdat; xlo; xhi]; + xmin = min (xmin, min (tx)); + xmax = max (xmax, max (tx)); + xminp = min (xminp, min (tx(tx>0))); + endif + if (yautoscale) + ymin = min (ymin, min (ydat)); + ymax = max (ymax, max (ydat)); + yminp = min (yminp, min (ty(ty>0))); + endif + data{data_idx} = [xdat, ydat, xlo, xhi]'; + usingclause{data_idx} = "using ($1):($2):($3):($4)"; + withclause{data_idx} = sprintf ("with xerrorbars linestyle %d", + data_idx); + else + if (xautoscale) + xmin = min (xmin, min (xdat)); + xmax = max (xmax, max (xdat)); + xminp = min (xminp, min (xdat(xdat>0))); + endif + if (yautoscale) + ymin = min (ymin, min (ydat)); + ymax = max (ymax, max (ydat)); + yminp = min (yminp, min (ydat(ydat>0))); + endif + data{data_idx} = [xdat, ydat]'; + usingclause{data_idx} = "using ($1):($2)"; + endif + endif + + case "surface" + data_idx++; + style = do_linestyle_command (obj, data_idx, plot_stream); + filespec{data_idx} = '-'; + if (isempty (obj.keylabel)) + titlespec{data_idx} = "title \"\""; + else + titlespec{data_idx} = strcat ("title \"", obj.keylabel, "\""); + endif + usingclause{data_idx} = ""; + withclause{data_idx} = sprintf ("with %s linestyle %d", + style, data_idx); + parametric(i) = false; + nd = 3; + xdat = obj.xdata; + ydat = obj.ydata; + zdat = obj.zdata; + if (xautoscale) + tx = xdat(:); + xmin = min (xmin, min (tx)); + xmax = max (xmax, max (tx)); + xminp = min (xminp, min (tx(tx>0))); + endif + if (yautoscale) + ty = ydat(:); + ymin = min (ymin, min (ty)); + ymax = max (ymax, max (ty)); + yminp = min (yminp, min (ty(ty>0))); + endif + if (zautoscale) + tz = zdat(:); + zmin = min (zmin, min (tz)); + zmax = max (zmax, max (tz)); + zminp = min (zminp, min (tz(tz>0))); + endif + err = false; + if (isvector (xdat) && isvector (ydat) && ismatrix (zdat)) + if (rows (zdat) == length (ydat) && columns (zdat) == length (xdat)) + [xdat, ydat] = meshgrid (xdat, ydat); + else + err = true; + endif + elseif (ismatrix (xdat) && ismatrix (ydat) && ismatrix (zdat)) + if (! (size_equal (xdat, ydat) && size_equal (xdat, zdat))) + err = true; + endif + else + err = true; + endif + if (err) + error ("__go_draw_axes__: invalid grid data"); + endif + xlen = columns (zdat); + ylen = rows (zdat); + if (xlen == columns (xdat) && xlen == columns (ydat) + && ylen == rows (xdat) && ylen == rows (ydat)) + len = 3 * xlen; + zz = zeros (ylen, len); + k = 1; + for kk = 1:3:len + zz(:,kk) = xdat(:,k); + zz(:,kk+1) = ydat(:,k); + zz(:,kk+2) = zdat(:,k); + k++; + endfor + data{data_idx} = zz; + endif + usingclause{data_idx} = "using ($1):($2):($3)"; + withclause{data_idx} = "with line palette"; + + fputs (plot_stream, "unset parametric;\n"); + fputs (plot_stream, "set hidden3d;\n"); + fputs (plot_stream, "set style data lines;\n"); + fputs (plot_stream, "set surface;\n"); + fputs (plot_stream, "unset contour;\n"); + fputs (plot_stream, "set palette defined (0 \"dark-blue\", 1 \"blue\", 2 \"cyan\", 3 \"yellow\", 4 \"red\" , 5 \"dark-red\");\n"); + fputs (plot_stream, "unset colorbox;\n"); + + case "text" + lpos = obj.position; + label = obj.string; + halign = obj.horizontalalignment; + if (nd == 3) + fprintf (plot_stream, "set label \"%s\" at %d,%d,%d %s;\n", + undo_string_escapes (label), + lpos(1), lpos(2), lpos(3), halign); + else + fprintf (plot_stream, "set label \"%s\" at %d,%d %s;\n", + undo_string_escapes (label), + lpos(1), lpos(2), halign); + endif + + otherwise + error ("__go_draw_axes__: unknown object class, %s", + obj.type); + endswitch + + endfor + + have_data = ! isempty (data); + + if (xautoscale && have_data) + xlim = get_axis_limits (xmin, xmax, xminp, xlogscale); + set (h, "xlim", xlim, "xlimmode", "auto"); + else + xlim = axis_obj.xlim; + endif + if (strcmp (axis_obj.xdir, "reverse")) + xdir = "reverse"; + else + xdir = "noreverse"; + endif + fprintf (plot_stream, "set xrange [%g:%g] %s;\n", xlim, xdir); + + if (yautoscale && have_data) + ylim = get_axis_limits (ymin, ymax, yminp, ylogscale); + set (h, "ylim", ylim, "ylimmode", "auto"); + else + ylim = axis_obj.ylim; + endif + if (strcmp (axis_obj.ydir, "reverse")) + ydir = "reverse"; + else + ydir = "noreverse"; + endif + fprintf (plot_stream, "set yrange [%g:%g] %s;\n", ylim, ydir); + + if (nd == 3) + if (zautoscale && have_data) + zlim = get_axis_limits (zmin, zmax, zminp, zlogscale); + set (h, "zlim", zlim, "zlimmode", "auto"); + else + zlim = axis_obj.zlim; + endif + if (strcmp (axis_obj.zdir, "reverse")) + zdir = "reverse"; + else + zdir = "noreverse"; + endif + fprintf (plot_stream, "set zrange [%g:%g] %s;\n", zlim, zdir); + endif + + if (strcmp (axis_obj.box, "on")) + if (nd == 3) + fputs (plot_stream, "set border 4095;\n"); + else + fputs (plot_stream, "set border 431;\n"); + endif + else + if (nd == 3) + fputs (plot_stream, "set border 895;\n"); + else + fputs (plot_stream, "set border 3;\n"); + fputs (plot_stream, "set xtics nomirror; set ytics nomirror;\n"); + endif + endif + + if (strcmp (axis_obj.key, "on")) + if (strcmp (axis_obj.keybox, "on")) + box = "box"; + else + box = "nobox"; + endif + inout = "inside"; + switch (axis_obj.keypos) + case -1 + pos = "right bottom"; + inout = "outside"; + case 1 + pos = "right top"; + case 2 + pos = "left top"; + case 3 + pos = "left bottom"; + case 4 + pos = "right bottom"; + otherwise + pos = ""; + endswitch + if (! have_newer_gnuplot) + inout = ""; + endif + fprintf (plot_stream, "set key %s %s %s;\n", inout, pos, box); + else + fputs (plot_stream, "unset key;\n"); + endif + + fputs (plot_stream, "set style data lines;\n"); + + 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) + plot_cmd = "plot"; + else + plot_cmd = "splot"; + rot_x = 90 - axis_obj.view(2); + rot_z = axis_obj.view(1); + while (rot_z < 0) + rot_z += 360; + endwhile + fprintf (plot_stream, "set view %g, %g;\n", rot_x, rot_z); + endif + fprintf (plot_stream, "%s \"%s\" %s %s %s", plot_cmd, + filespec{1}, usingclause{1}, titlespec{1}, withclause{1}); + for i = 2:data_idx + fprintf (plot_stream, ", \"%s\" %s %s %s", + filespec{i}, usingclause{i}, titlespec{i}, withclause{i}); + endfor + fputs (plot_stream, ";\n"); + for i = 1:data_idx + if (strcmp (filespec{i}, "-")) + if (nd == 2) + fprintf (plot_stream, + strcat (repmat ("%g ", 1, rows (data{i})), "\n"), + data{i}); + else + if (parametric(i)) + fprintf (plot_stream, "%g %g %g\n", data{i}); + else + tmp = data{i}; + nc = columns (tmp); + for j = 1:3:nc + fprintf (plot_stream, "%g %g %g\n", tmp(:,j:j+2)'); + fputs (plot_stream, "\n"); + endfor + endif + endif + fputs (plot_stream, "e\n"); + endif + endfor + endif + + fflush (plot_stream); + + else + print_usage (); + endif + +endfunction + +## Attempt to make "nice" limits from the actual max and min of the +## data. For log plots, we will also use the smallest strictly positive +## value. + +function lim = get_axis_limits (min_val, max_val, min_pos, logscale) + + if (logscale) + if (isinf (min_pos)) + warning ("axis: logscale with no positive values to plot"); + endif + if (min_val < 0) + min_val = min_pos; + if (max_val < 0) + max_val = min_pos; + endif + warning ("axis: omitting negative data in log plot"); + endif + if (min_val == max_val) + min_val = 0.9 * min_val; + max_val = 1.1 * max_val; + endif + min_val = 10 ^ floor (log10 (min_val)); + max_val = 10 ^ ceil (log10 (max_val)); + else + if (min_val == 0 && max_val == 0) + min_val = -1; + max_val = 1; + elseif (min_val == max_val) + min_val = 0.9 * min_val; + max_val = 1.1 * max_val; + endif + ## FIXME -- to do a better job, we should consider the tic spacing. + scale = 10 ^ floor (log10 (max_val - min_val) - 1); + min_val = scale * floor (min_val / scale); + max_val = scale * ceil (max_val / scale); + endif + + lim = [min_val, max_val]; + +endfunction + +function style = do_linestyle_command (obj, idx, plot_stream) + + have_newer_gnuplot = compare_versions (__gnuplot_version__ (), "4.0", ">"); + + if (have_newer_gnuplot) + fprintf (plot_stream, "set style line %d default;\n", idx); + endif + fprintf (plot_stream, "set style line %d", idx); + + found_style = false; + + if (isfield (obj, "color") && have_newer_gnuplot) + color = obj.color; + if (isnumeric (color)) + fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"", + round (255*color)); + endif + found_style = true; + endif + + if (isfield (obj, "linestyle")) + switch (obj.linestyle) + case "-" + lt = "lines"; + case "--" + lt = ""; + case ":" + lt = ""; + case "-." + lt = ""; + case "none" + lt = ""; + otherwise + lt = ""; + endswitch + else + lt = ""; + endif + + if (isfield (obj, "linewidth")) + fprintf (plot_stream, " linewidth %f", obj.linewidth); + found_style = true; + endif + + if (isfield (obj, "marker")) + switch (obj.marker) + case "+" + pt = "1"; + case "o" + pt = "7"; + case "*" + pt = "3"; + case "." + pt = "0"; + case "x" + pt = "2"; + case {"square", "s"} + pt = "5"; + case {"diamond", "d"} + pt = "13"; + case "^" + pt = "9"; + case "v" + pt = "11"; + case ">" + pt = "8"; + case "<" + pt = "10"; + case {"pentagram", "p"} + pt = "4"; + case {"hexagram", "h"} + pt = "6"; + case "none" + pt = ""; + otherwise + pt = ""; + endswitch + if (! isempty (pt)) + fprintf (plot_stream, " pointtype %s", pt); + found_style = true; + endif + else + pt = ""; + endif + + if (isfield (obj, "markersize")) + fprintf (plot_stream, " pointsize %f", obj.markersize); + found_style = true; + endif + + style = "lines"; + if (isempty (lt)) + if (! isempty (pt)) + style = "points"; + endif + elseif (! isempty (pt)) + style = "linespoints"; + endif + + if (have_newer_gnuplot && ! found_style) + fputs (plot_stream, " default"); + endif + + fputs (plot_stream, ";\n"); + +endfunction diff --git a/scripts/plot/__go_draw_figure__.m b/scripts/plot/__go_draw_figure__.m new file mode 100644 --- /dev/null +++ b/scripts/plot/__go_draw_figure__.m @@ -0,0 +1,81 @@ +## Copyright (C) 2005 John W. Eaton +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2, or (at your option) +## any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, write to the Free +## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +## 02110-1301, USA. + +## -*- texinfo -*- +## @deftypefn {Function File} {} __go_draw_figure__ (f) +## Display the figure @var{f}. +## @end deftypefn + +## Author: jwe + +function __go_draw_figure__ (f, plot_stream) + + if (nargin == 2) + if (strcmp (f.type, "figure")) + + ## Set figure properties here? + + kids = f.children; + nkids = length (kids); + + if (nkids > 0) + axes_count = 0; + for i = 1:nkids + obj = get (kids(i)); + switch (obj.type) + case "axes" + axes_count++; + endswitch + endfor + + multiplot_mode = axes_count > 1; + + if (multiplot_mode) + fputs (plot_stream, "reset; set multiplot;\n"); + endif + + for i = 1:nkids + obj = get (kids(i)); + switch (obj.type) + case "axes" + __go_draw_axes__ (kids(i), plot_stream); + + otherwise + error ("__go_draw_figure__: unknown object class, %s", + obj.type); + endswitch + endfor + + if (multiplot_mode) + fputs (plot_stream, "unset multiplot;\n"); + endif + else + fputs (plot_stream, "reset; clear;\n"); + fflush (plot_stream); + endif + else + error ("__go_draw_figure__: expecting figure object, found `%s'", + f.type); + endif + else + print_usage (); + endif + +endfunction + diff --git a/scripts/plot/__line__.m b/scripts/plot/__line__.m new file mode 100644 --- /dev/null +++ b/scripts/plot/__line__.m @@ -0,0 +1,65 @@ +## Copyright (C) 2005 John W. Eaton +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2, or (at your option) +## any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, write to the Free +## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +## 02110-1301, USA. + +## -*- texinfo -*- +## @deftypefn {Function File} {} __line__ (@var{p}, @var{x}, @var{y}) +## @deftypefnx {Function File} {} line (@var{p}, @var{x}, @var{y}, @var{z}) +## Create line object from @var{x} and @var{y} with parent @var{p}. +## Return handle to line object. +## @end deftypefn + +## Author: jwe + +function h = __line__ (p, varargin) + + if (nargin < 1) + print_usage (); + endif + + nvargs = numel (varargin); + + if (nvargs > 1 && isnumeric (varargin{1}) && isnumeric (varargin{2})) + if (nvargs > 2 && isnumeric (varargin{3})) + num_data_args = 3; + else + num_data_args = 2; + endif + else + num_data_args = 0; + endif + + if (rem (nvargs - num_data_args, 2) == 0) + else + print_usage ("line"); + endif + + h = __go_line__ (p); + + if (num_data_args > 1) + set (h, "xdata", varargin{1}, "ydata", varargin{2}); + if (num_data_args == 3) + set (h, "zdata", varargin{3}); + endif + endif + + if (nvargs > num_data_args) + set (h, varargin{num_data_args+1:end}); + endif + +endfunction diff --git a/scripts/plot/__plt__.m b/scripts/plot/__plt__.m --- a/scripts/plot/__plt__.m +++ b/scripts/plot/__plt__.m @@ -36,6 +36,8 @@ ## Gather arguments, decode format, gather plot strings, and plot lines. + retval = []; + while (nargs > 0 || x_set) if (nargs == 0) @@ -51,9 +53,11 @@ if (x_set) options = __pltopt__ (caller, next_arg); if (y_set) - retval = __plt2__ (h, x, y, options); + tmp = __plt2__ (h, x, y, options); + retval = [retval; tmp]; else - retval = __plt1__ (h, x, options); + tmp = __plt1__ (h, x, options); + retval = [retval; tmp]; endif x_set = false; y_set = false; @@ -63,7 +67,8 @@ elseif (x_set) if (y_set) options = __pltopt__ (caller, {""}); - retval = __plt2__ (h, x, y, options); + tmp = __plt2__ (h, x, y, options); + retval = [retval; tmp]; x = next_arg; y_set = false; else diff --git a/scripts/plot/__uiobject_adopt__.m b/scripts/plot/__uiobject_adopt__.m deleted file mode 100644 --- a/scripts/plot/__uiobject_adopt__.m +++ /dev/null @@ -1,45 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} __uiobject_adopt__ (@var{parent}, @var{child}) -## Add @var{child} to the list of children in @var{parent}. -## @end deftypefn - -## Author: jwe - -function s = __uiobject_adopt__ (parent, child) - - if (nargin == 2) - obj = get (parent); - if (! isempty (obj)) - kids = obj.children; - ## Put this child at the end of the list. If it is already in - ## the list, move it. - kids(kids == child) = []; - kids = [kids, child]; - set (parent, "children", kids); - else - error ("__uiobject_adopt__: expecting parent to be a handle"); - endif - else - print_usage (); - endif - -endfunction diff --git a/scripts/plot/__uiobject_alloc__.in b/scripts/plot/__uiobject_alloc__.in deleted file mode 100644 --- a/scripts/plot/__uiobject_alloc__.in +++ /dev/null @@ -1,42 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} __uiobject_alloc__ () -## Return an index that points to an unused element of -## @code{__uiobject_list__}. -## @end deftypefn - -## Author: jwe - -function idx = __uiobject_alloc__ () - - __uiobject_globals__; - - if (nargin == 0) - if (! (__uiobject_head__ && __uiobject_list__(__uiobject_head__).next)) - __uiobject_grow_list__ (); - endif - idx = __uiobject_head__; - __uiobject_list__(__uiobject_head__).in_use = true; - __uiobject_head__ = __uiobject_list__(__uiobject_head__).next; - else - print_usage (); - endif -endfunction diff --git a/scripts/plot/__uiobject_axes_ctor__.m b/scripts/plot/__uiobject_axes_ctor__.m deleted file mode 100644 --- a/scripts/plot/__uiobject_axes_ctor__.m +++ /dev/null @@ -1,45 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} __uiobject_axes_ctor__ (p) -## Create an axes object with parent @var{p}. -## @end deftypefn - -## Author: jwe - -function h = __uiobject_axes_ctor__ (p, varargin) - - if (nargin > 0) - s.type = "axes"; - s.__dtor__ = @__uiobject_axes_dtor__; - s.parent = p; - s.children = []; - s.position = []; - - h = __uiobject_make_handle__ (s); - - __uiobject_axes_init__ (h); - - set (h, varargin{:}); - else - print_usage (); - endif - -endfunction diff --git a/scripts/plot/__uiobject_axes_dtor__.m b/scripts/plot/__uiobject_axes_dtor__.m deleted file mode 100644 --- a/scripts/plot/__uiobject_axes_dtor__.m +++ /dev/null @@ -1,47 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} __uiobject_axes_dtor__ (@var{obj}) -## Delete an axes object @var{obj}. -## @end deftypefn - -## Author: jwe - -function __uiobject_axes_dtor__ (obj) - - if (nargin == 1) - delete (obj.title); - delete (obj.xlabel); - delete (obj.ylabel); - delete (obj.zlabel); - - obj.title = []; - obj.xlabel = []; - obj.ylabel = []; - obj.zlabel = []; - - for child = obj.children - delete (child); - endfor - else - print_usage (); - endif - -endfunction diff --git a/scripts/plot/__uiobject_axes_init__.in b/scripts/plot/__uiobject_axes_init__.in deleted file mode 100644 --- a/scripts/plot/__uiobject_axes_init__.in +++ /dev/null @@ -1,137 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {@var{s}} __uiobject_axes_init__ (@var{s}) -## Initialize axes object. -## @end deftypefn - -## Author: jwe - -function h = __uiobject_axes_init__ (h, mode) - - __uiobject_globals__; - - if (nargin == 1) - mode = ""; - endif - - if (nargin == 1 || nargin == 2) - - s = get (h); - - s.__setter__ = @__uiobject_axes_setr__; - - if (isfield (s, "title") && ! isempty (s.title)) - delete (s.title); - endif - s.title = __uiobject_text_ctor__ (h); - - s.box = "on"; - s.key = "off"; - s.keybox = "off"; - s.keypos = 1; - - s.dataaspectratio = [1, 1, 1]; - s.dataaspectratiomode = "auto"; - - s.xlim = [0, 1]; - s.ylim = [0, 1]; - s.zlim = [0, 1]; - - s.xlimmode = "auto"; - s.ylimmode = "auto"; - s.zlimmode = "auto"; - - if (isfield (s, "xlabel") && ! isempty (s.xlabel)) - delete (s.xlabel); - endif - if (isfield (s, "ylabel") && ! isempty (s.ylabel)) - delete (s.ylabel); - endif - if (isfield (s, "zlabel") && ! isempty (s.zlabel)) - delete (s.zlabel); - endif - s.xlabel = __uiobject_text_ctor__ (h); - s.ylabel = __uiobject_text_ctor__ (h); - s.zlabel = __uiobject_text_ctor__ (h); - - s.xgrid = "off"; - s.ygrid = "off"; - s.zgrid = "off"; - - s.xminorgrid = "off"; - s.yminorgrid = "off"; - s.zminorgrid = "off"; - - s.xtick = []; - s.ytick = []; - s.ztick = []; - - s.xtickmode = "auto"; - s.ytickmode = "auto"; - s.ztickmode = "auto"; - - s.xticklabel = []; - s.yticklabel = []; - s.zticklabel = []; - - s.xticklabelmode = "auto"; - s.yticklabelmode = "auto"; - s.zticklabelmode = "auto"; - - s.xscale = "linear"; - s.yscale = "linear"; - s.zscale = "linear"; - - s.xdir = "normal"; - s.ydir = "normal"; - s.zdir = "normal"; - - s.view = [0, 90]; - - s.nextplot = "replace"; - - ## FIXME -- this is not quite right; we should preserve "position" - ## and "units". - if (! isfield (s, "outerposition") - || (isempty (s.outerposition) || ! strcmp (mode, "replace"))) - s.outerposition = [0, 0, 1, 1]; - endif - - s.dataaspectratio = []; - s.dataaspectratiomode = "auto"; - - for child = s.children - delete (child); - endfor - - s.children = []; - - ## XXX FIXME XXX -- need to intialize all properties to default - ## values here. - - idx = __uiobject_handle2idx__ (h); - __uiobject_list__(idx).object = s; - - else - print_usage (); - endif - -endfunction diff --git a/scripts/plot/__uiobject_axes_setr__.m b/scripts/plot/__uiobject_axes_setr__.m deleted file mode 100644 --- a/scripts/plot/__uiobject_axes_setr__.m +++ /dev/null @@ -1,79 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {@var{s}} __uiobject_axes_setr__ (@var{p}, @var{v}, @dots{})) -## Set properties for axes objects. -## @end deftypefn - -## Author: jwe - -function obj = __uiobject_axes_setr__ (h, varargin) - - obj = get (h); - - if (rem (nargin-1, 2) == 0) - if (isstruct (obj)) - for i = 1:2:nargin-1 - property = varargin{i}; - if (ischar (property)) - key = tolower (property); - if (isfield (obj, key)) - val = varargin{i+1}; - if (isfield (obj, "__validators__")) - validators = obj.__validators__; - if (isfield (validators, key)) - feval (validators.(key), val); - endif - endif - switch (key) - case {"title", "xlabel", "ylabel", "zlabel"} - delete (obj.(key)); - val = __uiobject_text_ctor__ (h, "string", val); - - case {"xlim", "ylim", "zlim"} - obj.(strcat (key, "mode")) = "manual"; - - case "dataaspectratio" - obj.dataaspectratiomode = "manual"; - - case {"xtick", "ytick", "ztick"} - obj.(strcat (key, "mode")) = "manual"; - - case {"xticklabel", "yticklabel", "zticklabel"} - obj.(strcat (key, "mode")) = "manual"; - - endswitch - obj.(key) = val; - else - warning ("set: unrecognized property `%s' for uiobject `%s'", - property, obj.type); - endif - else - error ("set: expecting property name to be a character string"); - endif - endfor - else - error ("__uiobject_axes_setr__: expecting axes object as first arg"); - endif - else - print_usage (); - endif - -endfunction diff --git a/scripts/plot/__uiobject_close_all__.m b/scripts/plot/__uiobject_close_all__.m deleted file mode 100644 --- a/scripts/plot/__uiobject_close_all__.m +++ /dev/null @@ -1,30 +0,0 @@ -## Copyright (C) 2007 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} __uiobject_close_all__ () -## Internal function to close all figures. -## @seealso{drawnow} -## @end deftypefn - -## Author: jwe - -function __uiobject_close_all__ () - close ("all"); -endfunction diff --git a/scripts/plot/__uiobject_delete__.m b/scripts/plot/__uiobject_delete__.m deleted file mode 100644 --- a/scripts/plot/__uiobject_delete__.m +++ /dev/null @@ -1,62 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} delete (@var{h}) -## Delete the graphics object @var{h} -## @end deftypefn - -## Author: jwe - -function __uiobject_delete__ (h) - - if (nargin == 1) - if (ishandle (h)) - obj = get (h); - if (strcmp (obj.type, "figure")) - ps = obj.__plot_stream__; - if (any (ps == fopen ("all"))) - fputs (ps, "\nquit;\n"); - fflush (ps); - pclose (ps); - endif - endif - if (isfield (obj, "__dtor__")) - feval (obj.__dtor__, obj); - else - for child = obj.children - delete (child); - endfor - endif - ## Also remove this object from its parent's list of children. - if (isfield (obj, "parent")) - parent = obj.parent; - kids = get (parent, "children"); - kids(kids == h) = []; - set (parent, "children", kids); - endif - __uiobject_free__ (h); - else - error ("delete: expecting argument to be a graphics object"); - endif - else - print_usage (); - endif - -endfunction diff --git a/scripts/plot/__uiobject_draw_axes__.m b/scripts/plot/__uiobject_draw_axes__.m deleted file mode 100644 --- a/scripts/plot/__uiobject_draw_axes__.m +++ /dev/null @@ -1,871 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} __uiobject_draw_axes__ (@var{axis_obj}, @var{plot_stream}) -## Display the axes @var{axis_obj} on @var{plot_stream}. -## @end deftypefn - -## Author: jwe - -function __uiobject_draw_axes__ (h, plot_stream) - - if (nargin == 2) - - axis_obj = get (h); - - parent_figure_obj = get (axis_obj.parent); - - have_newer_gnuplot = compare_versions (__gnuplot_version__ (), "4.0", ">"); - - ## Set axis properties here? - - if (! isempty (axis_obj.outerposition)) - pos = axis_obj.outerposition; - fprintf (plot_stream, "set origin %g, %g;\n", pos(1), pos(2)); - fprintf (plot_stream, "set size %g, %g;\n", pos(3), pos(4)); - endif - - if (! isempty (axis_obj.position)) - pos = axis_obj.position; - fprintf (plot_stream, "set origin %g, %g;\n", pos(1), pos(2)); - fprintf (plot_stream, "set size %g, %g;\n", pos(3), pos(4)); - endif - - if (strcmp (axis_obj.dataaspectratiomode, "manual")) - r = axis_obj.dataaspectratio; - fprintf (plot_stream, "set size ratio %g;\n", -r(2)/r(1)); - else - fputs (plot_stream, "set size noratio;\n"); - endif - - if (! isempty (axis_obj.title)) - t = get (axis_obj.title); - if (isempty (t.string)) - fputs (plot_stream, "unset title;\n"); - else - fprintf (plot_stream, "set title \"%s\";\n", - undo_string_escapes (t.string)); - endif - endif - - if (! isempty (axis_obj.xlabel)) - t = get (axis_obj.xlabel); - if (isempty (t.string)) - fputs (plot_stream, "unset xlabel;\n"); - else - fprintf (plot_stream, "set xlabel \"%s\";\n", - undo_string_escapes (t.string)); - endif - endif - - if (! isempty (axis_obj.ylabel)) - t = get (axis_obj.ylabel); - if (isempty (t.string)) - fputs (plot_stream, "unset ylabel;\n"); - else - fprintf (plot_stream, "set ylabel \"%s\";\n", - undo_string_escapes (t.string)); - endif - endif - - if (! isempty (axis_obj.zlabel)) - t = get (axis_obj.zlabel); - if (isempty (t.string)) - fputs (plot_stream, "unset zlabel;\n"); - else - fprintf (plot_stream, "set zlabel \"%s\";\n", - undo_string_escapes (t.string)); - endif - endif - - if (strcmp (axis_obj.xgrid, "on")) - fputs (plot_stream, "set grid xtics;\n"); - else - fputs (plot_stream, "set grid noxtics;\n"); - endif - - if (strcmp (axis_obj.ygrid, "on")) - fputs (plot_stream, "set grid ytics;\n"); - else - fputs (plot_stream, "set grid noytics;\n"); - endif - - if (strcmp (axis_obj.zgrid, "on")) - fputs (plot_stream, "set grid ztics;\n"); - else - fputs (plot_stream, "set grid ztics;\n"); - endif - - if (strcmp (axis_obj.xminorgrid, "on")) - fputs (plot_stream, "set mxtics 5;\n"); - fputs (plot_stream, "set grid mxtics;\n"); - else - fputs (plot_stream, "set grid nomxtics;\n"); - endif - - if (strcmp (axis_obj.yminorgrid, "on")) - fputs (plot_stream, "set mytics 5;\n"); - fputs (plot_stream, "set grid mytics;\n"); - else - fputs (plot_stream, "set grid nomytics;\n"); - endif - - if (strcmp (axis_obj.zminorgrid, "on")) - fputs (plot_stream, "set mztics 5;\n"); - fputs (plot_stream, "set grid mztics;\n"); - else - fputs (plot_stream, "set grid nomztics;\n"); - endif - - if (strcmp (axis_obj.xtickmode, "manual")) - xtic = axis_obj.xtick; - if (isempty (xtic)) - fputs (plot_stream, "unset xtics;\n"); - else - ## FIXME - endif - else - fputs (plot_stream, "set xtics;\n"); - endif - - if (strcmp (axis_obj.ytickmode, "manual")) - ytic = axis_obj.ytick; - if (isempty (ytic)) - fputs (plot_stream, "unset ytics;\n"); - else - ## FIXME - endif - else - fputs (plot_stream, "set ytics;\n"); - endif - - if (strcmp (axis_obj.ztickmode, "manual")) - ztic = axis_obj.ztick; - if (isempty (ztic)) - fputs (plot_stream, "unset ztics;\n"); - else - ## FIXME - endif - else - fputs (plot_stream, "set ztics;\n"); - endif - - if (strcmp (axis_obj.xticklabelmode, "manual")) - ## FIXME -- we should be able to specify the actual tick labels, - ## not just the format. - xticlabel = axis_obj.xticklabel; - fprintf (plot_stream, "set format x \"%s\";\n", xticlabel); - else - fputs (plot_stream, "set xtics;\n"); - endif - - if (strcmp (axis_obj.yticklabelmode, "manual")) - ## FIXME -- we should be able to specify the actual tick labels, - ## not just the format. - yticlabel = axis_obj.yticklabel; - fprintf (plot_stream, "set format y \"%s\";\n", yticlabel); - else - fputs (plot_stream, "set ytics;\n"); - endif - - if (strcmp (axis_obj.zticklabelmode, "manual")) - ## FIXME -- we should be able to specify the actual tick labels, - ## not just the format. - zticlabel = axis_obj.zticklabel; - fprintf (plot_stream, "set format z \"%s\";\n", zticlabel); - else - fputs (plot_stream, "set ztics;\n"); - endif - - xlogscale = strcmp (axis_obj.xscale, "log"); - if (xlogscale) - fputs (plot_stream, "set logscale x;\n"); - else - fputs (plot_stream, "unset logscale x;\n"); - endif - - ylogscale = strcmp (axis_obj.yscale, "log"); - if (ylogscale) - fputs (plot_stream, "set logscale y;\n"); - else - fputs (plot_stream, "unset logscale y;\n"); - endif - - zlogscale = strcmp (axis_obj.zscale, "log"); - if (zlogscale) - fputs (plot_stream, "set logscale z;\n"); - else - fputs (plot_stream, "unset logscale z;\n"); - endif - - xautoscale = strcmp (axis_obj.xlimmode, "auto"); - yautoscale = strcmp (axis_obj.ylimmode, "auto"); - zautoscale = strcmp (axis_obj.zlimmode, "auto"); - - kids = axis_obj.children; - - nd = 0; - data_idx = 0; - data = cell (); - - xminp = yminp = zminp = Inf; - xmax = ymax = zmax = -Inf; - xmin = ymin = zmin = Inf; - - 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. - if (nd == 0) - nd = 2; - endif - - img_data = obj.cdata; - img_colormap = parent_figure_obj.colormap; - img_xdata = obj.xdata; - img_ydata = obj.ydata; - - if (use_gnuplot_for_images) - - data_idx++; - - [y_dim, x_dim] = size (img_data(:,:,1)); - if (x_dim > 1) - dx = abs (img_xdata(2)-img_xdata(1))/(x_dim-1); - else - dx = 1; - endif - if (y_dim > 1) - dy = abs (img_ydata(2)-img_ydata(1))/(y_dim-1); - else - dy = 1; - endif - x_origin = min (img_xdata); - y_origin = min (img_ydata); - - if (nd == 2) - if (xautoscale) - xmin = min (xmin, min (img_xdata) - dx/2); - xmax = max (xmax, max (img_xdata) + dx/2); - xminp = min (xminp, min (img_xdata((img_xdata - dx/2)>0)) - dx/2); - endif - if (yautoscale) - ymin = min (ymin, min (img_ydata) - dy/2); - ymax = max (ymax, max (img_ydata) + dy/2); - yminp = min (yminp, min (img_ydata((img_ydata - dy/2)>0)) - dy/2); - endif - else - ## Can have images in 3D, but the image routines don't seem - ## to have a means of arbitrary projection. - endif - - ## Let the file be deleted when Octave exits or `purge_tmp_files' - ## is called. - [img_fid, img_fname] = mkstemp (fullfile (P_tmpdir, "gpimageXXXXXX"), 1); - if (ndims (img_data) == 3) - fwrite (img_fid, permute (img_data, [3, 1, 2])(:), "float"); - format = "1:2:3"; - imagetype = "rgbimage"; - else - fwrite (img_fid, img_data(:), "float"); - format = "1"; - imagetype = "image"; - ## 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); - fprintf (plot_stream, - "set palette positive color model RGB maxcolors %i;\n", - palette_size); - if (palette_size <= 128) - ## Break up command to avoid buffer overflow. - fprintf (plot_stream, "set palette file \"-\" using 1:2:3:4;\n"); - 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,:)])); - endfor - fprintf (plot_stream, "e;\n"); - else - ## Let the file be deleted when Octave exits or - ## `purge_tmp_files' is called. - [cmap_fid, cmap_fname, msg] = mkstemp (fullfile (P_tmpdir, "gpimageXXXXXX"), 1); - fwrite (cmap_fid, img_colormap', "float32", 0, "ieee-le"); - fclose (cmap_fid); - fprintf (plot_stream, - "set palette file \"%s\" binary record=%d using 1:2:3;\n", - cmap_fname, palette_size); - endif - endif - endif - fclose (img_fid); - - filespec{data_idx} = img_fname; - titlespec{data_idx} = ""; - usingclause{data_idx} = sprintf ("binary array=%dx%d scan=yx flipy origin=(%g,%g) dx=%g dy=%g using %s", - x_dim, y_dim, x_origin, y_origin, dx, dy, format); - withclause{data_idx} = sprintf ("with %s", imagetype); - - ## Data in file, set to zero for data available test to pass - ## below. - data{data_idx} = 0; - - else - ximg_data{++ximg_data_idx} = img_data; - endif - - case "line" - data_idx++; - filespec{data_idx} = '-'; - if (isempty (obj.keylabel)) - titlespec{data_idx} = "title \"\""; - else - titlespec{data_idx} = strcat ("title \"", obj.keylabel, "\""); - endif - style = do_linestyle_command (obj, data_idx, plot_stream); - usingclause{data_idx} = ""; - withclause{data_idx} = sprintf ("with %s linestyle %d", - style, data_idx); - parametric(i) = true; - if (! isempty (obj.zdata)) - nd = 3; - xdat = obj.xdata(:); - ydat = obj.ydata(:); - zdat = obj.zdata(:); - if (xautoscale) - xmin = min (xmin, min (xdat)); - xmax = max (xmax, max (xdat)); - xminp = min (xminp, min (xdat(xdat>0))); - endif - if (yautoscale) - ymin = min (ymin, min (ydat)); - ymax = max (ymax, max (ydat)); - yminp = min (yminp, min (ydat(ydat>0))); - endif - if (zautoscale) - zmin = min (zmin, min (zdat)); - zmax = max (zmax, max (zdat)); - zminp = min (zminp, min (zdat(zdat>0))); - endif - data{data_idx} = [xdat, ydat, zdat]'; - usingclause{data_idx} = "using ($1):($2):($3)"; - fputs (plot_stream, "set parametric;\n"); - fputs (plot_stream, "unset hidden3d;\n"); - fputs (plot_stream, "set style data lines;\n"); - fputs (plot_stream, "set surface;\n"); - fputs (plot_stream, "unset contour;\n"); - else - nd = 2; - xdat = obj.xdata(:); - ydat = obj.ydata(:); - ldat = obj.ldata; - yerr = xerr = false; - if (! isempty (ldat)) - yerr = true; - ldat = ldat(:); - endif - udat = obj.udata; - if (! isempty (udat)) - udat = udat(:); - endif - xldat = obj.xldata; - if (! isempty (xldat)) - xerr = true; - xldat = xldat(:); - endif - xudat = obj.xudata; - if (! isempty (xudat)) - xudat = xudat(:); - endif - if (yerr) - ylo = ydat-ldat; - yhi = ydat+udat; - if (yautoscale) - ty = [ydat; ylo; yhi]; - ymin = min (ymin, min (ty)); - ymax = max (ymax, max (ty)); - yminp = min (yminp, min (ty(ty>0))); - endif - if (xerr) - xlo = xdat-xldat; - xhi = xdat+xudat; - if (xautoscale) - tx = [xdat; xlo; xhi]; - xmin = min (xmin, min (tx)); - xmax = max (xmax, max (tx)); - xminp = min (xminp, min (tx(tx>0))); - endif - data{data_idx} = [xdat, ydat, xlo, xhi, ylo, yhi]'; - usingclause{data_idx} = "using ($1):($2):($3):($4):($5):($6)"; - withclause{data_idx} = sprintf ("with xyerrorbars linestyle %d", - data_idx); - else - if (xautoscale) - xmin = min (xmin, min (xdat)); - xmax = max (xmax, max (xdat)); - xminp = min (xminp, min (tx(tx>0))); - endif - data{data_idx} = [xdat, ydat, ylo, yhi]'; - usingclause{data_idx} = "using ($1):($2):($3):($4)"; - withclause{data_idx} = sprintf ("with yerrorbars linestyle %d", - data_idx); - endif - elseif (xerr) - xlo = xdat-xldat; - xhi = xdat+xudat; - if (xautoscale) - tx = [xdat; xlo; xhi]; - xmin = min (xmin, min (tx)); - xmax = max (xmax, max (tx)); - xminp = min (xminp, min (tx(tx>0))); - endif - if (yautoscale) - ymin = min (ymin, min (ydat)); - ymax = max (ymax, max (ydat)); - yminp = min (yminp, min (ty(ty>0))); - endif - data{data_idx} = [xdat, ydat, xlo, xhi]'; - usingclause{data_idx} = "using ($1):($2):($3):($4)"; - withclause{data_idx} = sprintf ("with xerrorbars linestyle %d", - data_idx); - else - if (xautoscale) - xmin = min (xmin, min (xdat)); - xmax = max (xmax, max (xdat)); - xminp = min (xminp, min (xdat(xdat>0))); - endif - if (yautoscale) - ymin = min (ymin, min (ydat)); - ymax = max (ymax, max (ydat)); - yminp = min (yminp, min (ydat(ydat>0))); - endif - data{data_idx} = [xdat, ydat]'; - usingclause{data_idx} = "using ($1):($2)"; - endif - endif - - case "surface" - data_idx++; - style = do_linestyle_command (obj, data_idx, plot_stream); - filespec{data_idx} = '-'; - if (isempty (obj.keylabel)) - titlespec{data_idx} = "title \"\""; - else - titlespec{data_idx} = strcat ("title \"", obj.keylabel, "\""); - endif - usingclause{data_idx} = ""; - withclause{data_idx} = sprintf ("with %s linestyle %d", - style, data_idx); - parametric(i) = false; - nd = 3; - xdat = obj.xdata; - ydat = obj.ydata; - zdat = obj.zdata; - if (xautoscale) - tx = xdat(:); - xmin = min (xmin, min (tx)); - xmax = max (xmax, max (tx)); - xminp = min (xminp, min (tx(tx>0))); - endif - if (yautoscale) - ty = ydat(:); - ymin = min (ymin, min (ty)); - ymax = max (ymax, max (ty)); - yminp = min (yminp, min (ty(ty>0))); - endif - if (zautoscale) - tz = zdat(:); - zmin = min (zmin, min (tz)); - zmax = max (zmax, max (tz)); - zminp = min (zminp, min (tz(tz>0))); - endif - err = false; - if (isvector (xdat) && isvector (ydat) && ismatrix (zdat)) - if (rows (zdat) == length (ydat) && columns (zdat) == length (xdat)) - [xdat, ydat] = meshgrid (xdat, ydat); - else - err = true; - endif - elseif (ismatrix (xdat) && ismatrix (ydat) && ismatrix (zdat)) - if (! (size_equal (xdat, ydat) && size_equal (xdat, zdat))) - err = true; - endif - else - err = true; - endif - if (err) - error ("__uiobject_draw_axes__: invalid grid data"); - endif - xlen = columns (zdat); - ylen = rows (zdat); - if (xlen == columns (xdat) && xlen == columns (ydat) - && ylen == rows (xdat) && ylen == rows (ydat)) - len = 3 * xlen; - zz = zeros (ylen, len); - k = 1; - for kk = 1:3:len - zz(:,kk) = xdat(:,k); - zz(:,kk+1) = ydat(:,k); - zz(:,kk+2) = zdat(:,k); - k++; - endfor - data{data_idx} = zz; - endif - usingclause{data_idx} = "using ($1):($2):($3)"; - withclause{data_idx} = "with line palette"; - - fputs (plot_stream, "unset parametric;\n"); - fputs (plot_stream, "set hidden3d;\n"); - fputs (plot_stream, "set style data lines;\n"); - fputs (plot_stream, "set surface;\n"); - fputs (plot_stream, "unset contour;\n"); - fputs (plot_stream, "set palette defined (0 \"dark-blue\", 1 \"blue\", 2 \"cyan\", 3 \"yellow\", 4 \"red\" , 5 \"dark-red\");\n"); - fputs (plot_stream, "unset colorbox;\n"); - - case "text" - lpos = obj.position; - label = obj.string; - halign = obj.horizontalalignment; - if (nd == 3) - fprintf (plot_stream, "set label \"%s\" at %d,%d,%d %s;\n", - undo_string_escapes (label), - lpos(1), lpos(2), lpos(3), halign); - else - fprintf (plot_stream, "set label \"%s\" at %d,%d %s;\n", - undo_string_escapes (label), - lpos(1), lpos(2), halign); - endif - - otherwise - error ("__uiobject_draw_axes__: unknown object class, %s", - obj.type); - endswitch - - endfor - - have_data = ! isempty (data); - - if (xautoscale && have_data) - xlim = get_axis_limits (xmin, xmax, xminp, xlogscale); - set (h, "xlim", xlim, "xlimmode", "auto"); - else - xlim = axis_obj.xlim; - endif - if (strcmp (axis_obj.xdir, "reverse")) - xdir = "reverse"; - else - xdir = "noreverse"; - endif - fprintf (plot_stream, "set xrange [%g:%g] %s;\n", xlim, xdir); - - if (yautoscale && have_data) - ylim = get_axis_limits (ymin, ymax, yminp, ylogscale); - set (h, "ylim", ylim, "ylimmode", "auto"); - else - ylim = axis_obj.ylim; - endif - if (strcmp (axis_obj.ydir, "reverse")) - ydir = "reverse"; - else - ydir = "noreverse"; - endif - fprintf (plot_stream, "set yrange [%g:%g] %s;\n", ylim, ydir); - - if (nd == 3) - if (zautoscale && have_data) - zlim = get_axis_limits (zmin, zmax, zminp, zlogscale); - set (h, "zlim", zlim, "zlimmode", "auto"); - else - zlim = axis_obj.zlim; - endif - if (strcmp (axis_obj.zdir, "reverse")) - zdir = "reverse"; - else - zdir = "noreverse"; - endif - fprintf (plot_stream, "set zrange [%g:%g] %s;\n", zlim, zdir); - endif - - if (strcmp (axis_obj.box, "on")) - if (nd == 3) - fputs (plot_stream, "set border 4095;\n"); - else - fputs (plot_stream, "set border 431;\n"); - endif - else - if (nd == 3) - fputs (plot_stream, "set border 895;\n"); - else - fputs (plot_stream, "set border 3;\n"); - fputs (plot_stream, "set xtics nomirror; set ytics nomirror;\n"); - endif - endif - - if (strcmp (axis_obj.key, "on")) - if (strcmp (axis_obj.keybox, "on")) - box = "box"; - else - box = "nobox"; - endif - inout = "inside"; - switch (axis_obj.keypos) - case -1 - pos = "right bottom"; - inout = "outside"; - case 1 - pos = "right top"; - case 2 - pos = "left top"; - case 3 - pos = "left bottom"; - case 4 - pos = "right bottom"; - otherwise - pos = ""; - endswitch - if (! have_newer_gnuplot) - inout = ""; - endif - fprintf (plot_stream, "set key %s %s %s;\n", inout, pos, box); - else - fputs (plot_stream, "unset key;\n"); - endif - - fputs (plot_stream, "set style data lines;\n"); - - 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) - plot_cmd = "plot"; - else - plot_cmd = "splot"; - rot_x = 90 - axis_obj.view(2); - rot_z = axis_obj.view(1); - while (rot_z < 0) - rot_z += 360; - endwhile - fprintf (plot_stream, "set view %g, %g;\n", rot_x, rot_z); - endif - fprintf (plot_stream, "%s \"%s\" %s %s %s", plot_cmd, - filespec{1}, usingclause{1}, titlespec{1}, withclause{1}); - for i = 2:data_idx - fprintf (plot_stream, ", \"%s\" %s %s %s", - filespec{i}, usingclause{i}, titlespec{i}, withclause{i}); - endfor - fputs (plot_stream, ";\n"); - for i = 1:data_idx - if (strcmp (filespec{i}, "-")) - if (nd == 2) - fprintf (plot_stream, - strcat (repmat ("%g ", 1, rows (data{i})), "\n"), - data{i}); - else - if (parametric(i)) - fprintf (plot_stream, "%g %g %g\n", data{i}); - else - tmp = data{i}; - nc = columns (tmp); - for j = 1:3:nc - fprintf (plot_stream, "%g %g %g\n", tmp(:,j:j+2)'); - fputs (plot_stream, "\n"); - endfor - endif - endif - fputs (plot_stream, "e\n"); - endif - endfor - endif - - fflush (plot_stream); - - else - print_usage (); - endif - -endfunction - -## Attempt to make "nice" limits from the actual max and min of the -## data. For log plots, we will also use the smallest strictly positive -## value. - -function lim = get_axis_limits (min_val, max_val, min_pos, logscale) - - if (logscale) - if (isinf (min_pos)) - warning ("axis: logscale with no positive values to plot"); - endif - if (min_val < 0) - min_val = min_pos; - if (max_val < 0) - max_val = min_pos; - endif - warning ("axis: omitting negative data in log plot"); - endif - if (min_val == max_val) - min_val = 0.9 * min_val; - max_val = 1.1 * max_val; - endif - min_val = 10 ^ floor (log10 (min_val)); - max_val = 10 ^ ceil (log10 (max_val)); - else - if (min_val == 0 && max_val == 0) - min_val = -1; - max_val = 1; - elseif (min_val == max_val) - min_val = 0.9 * min_val; - max_val = 1.1 * max_val; - endif - ## FIXME -- to do a better job, we should consider the tic spacing. - scale = 10 ^ floor (log10 (max_val - min_val) - 1); - min_val = scale * floor (min_val / scale); - max_val = scale * ceil (max_val / scale); - endif - - lim = [min_val, max_val]; - -endfunction - -function style = do_linestyle_command (obj, idx, plot_stream) - - have_newer_gnuplot = compare_versions (__gnuplot_version__ (), "4.0", ">"); - - if (have_newer_gnuplot) - fprintf (plot_stream, "set style line %d default;\n", idx); - endif - fprintf (plot_stream, "set style line %d", idx); - - found_style = false; - - if (isfield (obj, "color") && have_newer_gnuplot) - color = obj.color; - if (isnumeric (color)) - fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"", - round (255*color)); - endif - found_style = true; - endif - - if (isfield (obj, "linestyle")) - switch (obj.linestyle) - case "-" - lt = "lines"; - case "--" - lt = ""; - case ":" - lt = ""; - case "-." - lt = ""; - case "none" - lt = ""; - otherwise - lt = ""; - endswitch - else - lt = ""; - endif - - if (isfield (obj, "linewidth")) - fprintf (plot_stream, " linewidth %f", obj.linewidth); - found_style = true; - endif - - if (isfield (obj, "marker")) - switch (obj.marker) - case "+" - pt = "1"; - case "o" - pt = "7"; - case "*" - pt = "3"; - case "." - pt = "0"; - case "x" - pt = "2"; - case {"square", "s"} - pt = "5"; - case {"diamond", "d"} - pt = "13"; - case "^" - pt = "9"; - case "v" - pt = "11"; - case ">" - pt = "8"; - case "<" - pt = "10"; - case {"pentagram", "p"} - pt = "4"; - case {"hexagram", "h"} - pt = "6"; - case "none" - pt = ""; - otherwise - pt = ""; - endswitch - if (! isempty (pt)) - fprintf (plot_stream, " pointtype %s", pt); - found_style = true; - endif - else - pt = ""; - endif - - if (isfield (obj, "markersize")) - fprintf (plot_stream, " pointsize %f", obj.markersize); - found_style = true; - endif - - style = "lines"; - if (isempty (lt)) - if (! isempty (pt)) - style = "points"; - endif - elseif (! isempty (pt)) - style = "linespoints"; - endif - - if (have_newer_gnuplot && ! found_style) - fputs (plot_stream, " default"); - endif - - fputs (plot_stream, ";\n"); - -endfunction diff --git a/scripts/plot/__uiobject_draw_figure__.m b/scripts/plot/__uiobject_draw_figure__.m deleted file mode 100644 --- a/scripts/plot/__uiobject_draw_figure__.m +++ /dev/null @@ -1,81 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} __uiobject_draw_figure__ (f) -## Display the figure @var{f}. -## @end deftypefn - -## Author: jwe - -function __uiobject_draw_figure__ (f, plot_stream) - - if (nargin == 2) - if (strcmp (f.type, "figure")) - - ## Set figure properties here? - - kids = f.children; - nkids = length (kids); - - if (nkids > 0) - axes_count = 0; - for i = 1:nkids - obj = get (kids(i)); - switch (obj.type) - case "axes" - axes_count++; - endswitch - endfor - - multiplot_mode = axes_count > 1; - - if (multiplot_mode) - fputs (plot_stream, "reset; set multiplot;\n"); - endif - - for i = 1:nkids - obj = get (kids(i)); - switch (obj.type) - case "axes" - __uiobject_draw_axes__ (kids(i), plot_stream); - - otherwise - error ("__uiobject_draw_figure__: unknown object class, %s", - obj.type); - endswitch - endfor - - if (multiplot_mode) - fputs (plot_stream, "unset multiplot;\n"); - endif - else - fputs (plot_stream, "reset; clear;\n"); - fflush (plot_stream); - endif - else - error ("__uiobject_draw_figure__: expecting figure object, found `%s'", - f.type); - endif - else - print_usage (); - endif - -endfunction - diff --git a/scripts/plot/__uiobject_figure_ctor__.m b/scripts/plot/__uiobject_figure_ctor__.m deleted file mode 100644 --- a/scripts/plot/__uiobject_figure_ctor__.m +++ /dev/null @@ -1,47 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} __uiobject_figure_ctor__ () -## Create a figure object with default properties. -## @end deftypefn - -## Author: jwe - -function s = __uiobject_figure_ctor__ () - - if (nargin == 0) - ## XXX FIXME XXX -- need to intialize all properties to default - ## values here. - s.type = "figure"; - s.__plot_stream__ = []; - ## ??? Are all figures children of the root figure? - s.parent = 0; - s.children = []; - s.nextplot = "replace"; - s.closerequestfcn = @closereq; - s.currentaxes = []; - s.colormap = __default_colormap__ (); - s.visible = "on"; - s.paperorientation = "portrait"; - else - print_usage (); - endif - -endfunction diff --git a/scripts/plot/__uiobject_figures__.in b/scripts/plot/__uiobject_figures__.in deleted file mode 100644 --- a/scripts/plot/__uiobject_figures__.in +++ /dev/null @@ -1,41 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} __uiobject_figures__ () -## Return a mstrix containing the handles of all figures (excluding the -## root figure). -## @end deftypefn - -## Author: jwe - -function retval = __uiobject_figures__ () - - __uiobject_globals__; - - if (nargin == 0) - ## Ensure that we have a root figure object. - __uiobject_init_root_figure__ (); - handles = [__uiobject_list__.handle]; - retval = handles(handles > 0); - else - print_usage (); - endif - -endfunction diff --git a/scripts/plot/__uiobject_free__.in b/scripts/plot/__uiobject_free__.in deleted file mode 100644 --- a/scripts/plot/__uiobject_free__.in +++ /dev/null @@ -1,56 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} __uiobject_free__ (@var{h}) -## Clear the contents of the element of the @code{__uiobject_list__} -## corresponding to the handle @var{h} and return the element to the -## free list. -## @end deftypefn - -## Author: jwe - -function __uiobject_free__ (h) - - __uiobject_globals__; - - if (nargin == 1) - idx = __uiobject_handle2idx__ (h); - if (! isempty (idx)) - if (! isempty (__uiobject_list__) && __uiobject_list__(idx).in_use) - h = __uiobject_list__(idx).handle; - __uiobject_handles__ = complement (h, __uiobject_handles__); - __uiobject_list__(idx).next = __uiobject_head__; - __uiobject_list__(idx).in_use = false; - __uiobject_list__(idx).handle = NaN; - __uiobject_list__(idx).object = NaN; - __uiobject_head__ = idx; - if (h < 0) - __uiobject_handles_free_list__(end+1) = h; - elseif (h > 0) - __uiobject_figure_handles_free_list__(end+1) = h; - endif - else - error ("__uiobject_free__: attempt to free unallocated element"); - endif - endif - else - print_usage (); - endif -endfunction diff --git a/scripts/plot/__uiobject_get_handle__.in b/scripts/plot/__uiobject_get_handle__.in deleted file mode 100644 --- a/scripts/plot/__uiobject_get_handle__.in +++ /dev/null @@ -1,40 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} __uiobject_get_handle__ () -## Return an unused uiobject handle. -## @end deftypefn - -## Author: jwe - -function h = __uiobject_get_handle__ () - - __uiobject_globals__; - - if (isempty (__uiobject_handles_free_list__)) - h = min (__uiobject_handles__) - 1; - else - h = __uiobject_handles_free_list__(1); - __uiobject_handles_free_list__(1) = []; - endif - - __uiobject_handles__ = union (__uiobject_handles__, h); - -endfunction diff --git a/scripts/plot/__uiobject_globals__.m b/scripts/plot/__uiobject_globals__.m deleted file mode 100644 --- a/scripts/plot/__uiobject_globals__.m +++ /dev/null @@ -1,74 +0,0 @@ - - ## The collection of current figure handles. We need this to be able to - ## allocate the next unused figure number. - - global __uiobject_figure_handles__; - - if (isempty (__uiobject_figure_handles__)) - __uiobject_figure_handles__ = create_set (0); - __lock_global__ ("__uiobject_figure_handles__"); - endif - - ## The collection of current handles to other graphics objects. We need - ## this to be able to allocate the next unused handle. Zero means we - ## don't have any objects yet. - - global __uiobject_handles__; - - if (isempty (__uiobject_handles__)) - __uiobject_handles__ = create_set (0); - __lock_global__ ("__uiobject_handles__"); - endif - - ## A structure array of UI objects. Allocating and freeing elements - ## from the array is handled by __uiobject_alloc__ and - ## __uiobject_free__. - ## - ## Each element in the array contains the fields - ## - ## next Index of next free element - ## - ## in_use True if allocated, false otherwise - ## - ## An object in the list that has been initialized (by a function like - ## figure, axes, line, etc.) will also have the following fields: - ## - ## handle Integer graphics "handle". For figure objects, this is - ## non-negative integer (the "root" figure is 0). For other - ## objects, the handle is a negative integer. You are not - ## supposed to care about the specific value of the handle. - ## - ## object Structure containing the actual UI object (figure, axes, - ## line, etc). - - global __uiobject_list__; - - if (isempty (__uiobject_list__)) - __lock_global__ ("__uiobject_list__"); - endif - - ## Index of the first free object in __uiobject_list__. If this is - ## zero, it means the list has not been created. - - global __uiobject_head__; - - if (isempty (__uiobject_head__)) - __uiobject_head__ = 0; - __lock_global__ ("__uiobject_head__"); - endif - - ## A list of available figure handles - - global __uiobject_figure_handles_free_list__; - - if (isempty (__uiobject_figure_handles_free_list__)) - __lock_global__ ("__uiobject_figure_handles_free_list__"); - endif - - ## A list of available uiobject handles - - global __uiobject_handles_free_list__; - - if (isempty (__uiobject_handles_free_list__)) - __lock_global__ ("__uiobject_handles_free_list__"); - endif diff --git a/scripts/plot/__uiobject_grow_list__.in b/scripts/plot/__uiobject_grow_list__.in deleted file mode 100644 --- a/scripts/plot/__uiobject_grow_list__.in +++ /dev/null @@ -1,57 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} __uiobject_grow_list__ () -## Create or increase the size of @code{__uiobject_list__}. -## @end deftypefn - -## Author: jwe - -function __uiobject_grow_list__ () - - __uiobject_globals__; - - if (nargin == 0) - static grow_size = 100; - curr_size = length (__uiobject_list__); - new_size = curr_size + grow_size; - __uiobject_list__(new_size).next = 0; - __uiobject_list__(new_size).in_use = false; - __uiobject_list__(new_size).handle = NaN; - __uiobject_list__(new_size).object = NaN; - if (curr_size == 0) - __uiobject_head__ = 1; - else - __uiobject_list__(curr_size).next = curr_size+1; - __uiobject_list__(curr_size).in_use = false; - __uiobject_list__(curr_size).handle = NaN; - __uiobject_list__(curr_size).object = NaN; - endif - for i = new_size-1:-1:curr_size+1 - __uiobject_list__(i).next = i+1; - __uiobject_list__(i).in_use = false; - __uiobject_list__(i).handle = NaN; - __uiobject_list__(i).object = NaN; - endfor - else - print_usage (); - endif - -endfunction diff --git a/scripts/plot/__uiobject_handle2idx__.in b/scripts/plot/__uiobject_handle2idx__.in deleted file mode 100644 --- a/scripts/plot/__uiobject_handle2idx__.in +++ /dev/null @@ -1,38 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} __uiobject_handle2idx__ (@var{h}) -## Return the index in the __uiobject_list__ corresponding to the handle -## @var{h}. -## @end deftypefn - -## Author: jwe - -function idx = __uiobject_handle2idx__ (h) - - __uiobject_globals__; - - if (nargin == 1) - idx = find ([__uiobject_list__.handle] == h); - else - print_usage (); - endif - -endfunction diff --git a/scripts/plot/__uiobject_image_ctor__.m b/scripts/plot/__uiobject_image_ctor__.m deleted file mode 100644 --- a/scripts/plot/__uiobject_image_ctor__.m +++ /dev/null @@ -1,44 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} __uiobject_line_ctor__ (@var{p}) -## Create an image object with parent @var{p}. -## @end deftypefn - -## Author: jwe - -function s = __uiobject_image_ctor__ (p) - - if (nargin == 1) - s.type = "image"; - s.parent = p; - s.children = []; - - s.cdata = []; - s.xdata = []; - s.ydata = []; - - ## XXX FIXME XXX -- need to intialize all properties to default - ## values here. - else - print_usage (); - endif - -endfunction diff --git a/scripts/plot/__uiobject_init_figure__.in b/scripts/plot/__uiobject_init_figure__.in deleted file mode 100644 --- a/scripts/plot/__uiobject_init_figure__.in +++ /dev/null @@ -1,58 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {@var{f} =} __uiobject_init_figure__ (@var{f}) -## Create figure in __uiobject_list__ and make it the current figure. -## If @var{f} already exists, make it the current figure but don't -## reinitialize it. If @var{f} is not specified, allocate a new -## figure handle and initialize it. -## @end deftypefn - -## Author: jwe - -function f = __uiobject_init_figure__ (f) - - __uiobject_globals__; - - if (nargin == 0 || nargin == 1) - - if (nargin == 0 || isempty (f)) - if (isempty (__uiobject_figure_handles_free_list__)) - f = max (__uiobject_handles__) + 1; - else - f = __uiobject_figure_handles_free_list__(1); - __uiobject_figure_handles_free_list__(1) = []; - endif - endif - - __uiobject_handles__ = union (__uiobject_handles__, f); - - if (! ishandle (f)) - idx = __uiobject_alloc__ (); - __uiobject_list__(idx).handle = f; - __uiobject_list__(idx).object = __uiobject_figure_ctor__ (); - __uiobject_adopt__ (0, f); - endif - set (0, "currentfigure", f); - else - print_usage (); - endif - -endfunction diff --git a/scripts/plot/__uiobject_init_root_figure__.in b/scripts/plot/__uiobject_init_root_figure__.in deleted file mode 100644 --- a/scripts/plot/__uiobject_init_root_figure__.in +++ /dev/null @@ -1,41 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} __uiobject_init_root_figure__ () -## Create the root figure object, if it doesn't already exist. -## @end deftypefn - -## Author: jwe - -function __uiobject_init_root_figure__ () - - __uiobject_globals__; - - if (nargin == 0) - if (isempty (__uiobject_list__)) - idx = __uiobject_alloc__ (); - __uiobject_list__(idx).handle = 0; - __uiobject_list__(idx).object = __uiobject_root_figure_ctor__ (); - endif - else - print_usage (); - endif - -endfunction diff --git a/scripts/plot/__uiobject_line_ctor__.m b/scripts/plot/__uiobject_line_ctor__.m deleted file mode 100644 --- a/scripts/plot/__uiobject_line_ctor__.m +++ /dev/null @@ -1,59 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} __uiobject_line_ctor__ (@var{p}) -## Create a line object with parent @var{p}. -## @end deftypefn - -## Author: jwe - -function s = __uiobject_line_ctor__ (p) - - if (nargin == 1) - s.type = "line"; - s.parent = p; - s.children = []; - - s.xdata = []; - s.ydata = []; - s.zdata = []; - - s.ldata = []; - s.udata = []; - - s.xldata = []; - s.xudata = []; - - s.color = [0, 0, 1]; - s.linestyle = "-"; - s.linewidth = 0.5; - - s.marker = "none"; - s.markersize = 1; - - s.keylabel = ""; - - ## XXX FIXME XXX -- need to intialize all properties to default - ## values here. - else - print_usage (); - endif - -endfunction diff --git a/scripts/plot/__uiobject_make_handle__.in b/scripts/plot/__uiobject_make_handle__.in deleted file mode 100644 --- a/scripts/plot/__uiobject_make_handle__.in +++ /dev/null @@ -1,41 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {@var{h} =} __uiobject_make_handle__ (@var{object}) -## Create handle for @var{object}. -## @end deftypefn - -## Author: jwe - -function h = __uiobject_make_handle__ (s) - - __uiobject_globals__; - - if (nargin == 1) - idx = __uiobject_alloc__ (); - h = __uiobject_get_handle__ (); - __uiobject_list__(idx).handle = h; - __uiobject_list__(idx).object = s; - __request_drawnow__ (); - else - print_usage (); - endif - -endfunction diff --git a/scripts/plot/__uiobject_root_figure_ctor__.m b/scripts/plot/__uiobject_root_figure_ctor__.m deleted file mode 100644 --- a/scripts/plot/__uiobject_root_figure_ctor__.m +++ /dev/null @@ -1,42 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} __uiobject_root_figure_ctor__ () -## Create the root figure object with default properties. -## @end deftypefn - -## Author: jwe - -function s = __uiobject_root_figure_ctor__ () - - if (nargin == 0) - ## XXX FIXME XXX -- need to intialize all properties to default - ## values here. - s.type = "root figure"; - s.__plot_stream__ = []; - s.currentaxes = []; - s.currentfigure = []; - s.children = []; - s.visible = "on"; - else - print_usage (); - endif - -endfunction diff --git a/scripts/plot/__uiobject_surface_ctor__.m b/scripts/plot/__uiobject_surface_ctor__.m deleted file mode 100644 --- a/scripts/plot/__uiobject_surface_ctor__.m +++ /dev/null @@ -1,46 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} __uiobject_surface_ctor__ (@var{p}) -## Create a surface object with parent @var{p}. -## @end deftypefn - -## Author: jwe - -function s = __uiobject_surface_ctor__ (p) - - if (nargin == 1) - s.type = "surface"; - s.parent = p; - s.children = []; - - s.xdata = []; - s.ydata = []; - s.zdata = []; - - s.keylabel = ""; - - ## XXX FIXME XXX -- need to intialize all properties to default - ## values here. - else - print_usage (); - endif - -endfunction diff --git a/scripts/plot/__uiobject_text_ctor__.m b/scripts/plot/__uiobject_text_ctor__.m deleted file mode 100644 --- a/scripts/plot/__uiobject_text_ctor__.m +++ /dev/null @@ -1,50 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} __uiobject_text_ctor__ (p) -## Create a text object with parent @var{p}. -## @end deftypefn - -## Author: jwe - -function h = __uiobject_text_ctor__ (p, varargin) - - if (nargin > 0) - ## XXX FIXME XXX -- need to intialize all properties to default - ## values here. - s.type = "text"; - s.parent = p; - s.children = []; - s.string = ""; - - s.units = "data"; - s.position = [0, 0, 0]; - s.horizontalalignment = "left"; - - s.__validators__.string = @ischar; - - h = __uiobject_make_handle__ (s); - - set (h, varargin{:}); - else - print_usage (); - endif - -endfunction diff --git a/scripts/plot/axes.m b/scripts/plot/axes.m --- a/scripts/plot/axes.m +++ b/scripts/plot/axes.m @@ -32,18 +32,16 @@ ## make default axes object, and make it the current axes for the ## current figure. cf = gcf (); - tmp = __uiobject_axes_ctor__ (cf, varargin{:}); - __uiobject_adopt__ (cf, tmp); + tmp = __go_axes__ (cf, varargin{:}); set (cf, "currentaxes", tmp); elseif (nargin == 1) ## arg is axes handle, make it the current axes for the current ## figure. tmp = varargin{1}; - obj = get (tmp); - if (! isempty (obj) && strcmp (obj.type, "axes")) - cf = gcf (); - __uiobject_adopt__ (cf, tmp); - set (cf, "currentaxes", tmp); + if (ishandle (tmp) && strcmp (get (tmp, "type"), "axes")) + parent = get (tmp, "parent"); + set (0, "currentfigure", parent); + set (parent, "currentaxes", tmp); else error ("axes: expecting argument to be axes handle"); endif diff --git a/scripts/plot/clf.m b/scripts/plot/clf.m --- a/scripts/plot/clf.m +++ b/scripts/plot/clf.m @@ -27,12 +27,9 @@ function clf () if (nargin == 0) - f = gcf (); - obj = get (f); - for child = obj.children - delete (child); + for k = get (gcf (), children) + delete (k); endfor - set (f, "currentaxes", []); drawnow (); else print_usage (); diff --git a/scripts/plot/close.m b/scripts/plot/close.m --- a/scripts/plot/close.m +++ b/scripts/plot/close.m @@ -31,6 +31,8 @@ function retval = close (arg1, arg2) + figs = []; + if (nargin == 0) ## Close current figure. Don't use gcf because that will open a new ## plot window if one doesn't exist. @@ -40,8 +42,7 @@ endif elseif (nargin == 1) if (ischar (arg1) && strcmp (arg1, "all")) - ## Close all figures. - figs = __uiobject_figures__ (); + close_all_figures (false); elseif (isfigure (arg1)) figs = arg1; else @@ -50,7 +51,7 @@ elseif (nargin == 2 && ischar (arg1) && strcmp (arg1, "all") && ischar (arg2) && strcmp (arg2, "hidden")) - figs = __uiobject_figures__ (); + close_all_figures (true); else print_usage (); endif @@ -65,3 +66,14 @@ endif endfunction + +function close_all_figures (close_hidden_figs) + + while (! isempty (fig = get (0, "currentfigure"))) + ## handlevisibility = get (fig, "handlevisibility") + ## if (close_hidden_figs || ! strcmp (handlevisibility, "off")) + close (fig); + ## endif + endwhile + +endfunction diff --git a/scripts/plot/closereq.m b/scripts/plot/closereq.m --- a/scripts/plot/closereq.m +++ b/scripts/plot/closereq.m @@ -30,12 +30,6 @@ cf = get (0, "currentfigure"); if (cf != 0) delete (cf); - figs = __uiobject_figures__ (); - if (isempty (figs)) - set (0, "currentfigure", 0); - else - set (0, "currentfigure", figs(1)); - endif endif else print_usage (); diff --git a/scripts/plot/drawnow.m b/scripts/plot/drawnow.m --- a/scripts/plot/drawnow.m +++ b/scripts/plot/drawnow.m @@ -28,9 +28,9 @@ ## Use this instead of persistent and mlock so that drawnow can be ## replaced. - global __uiobject_close_all_registered__; - if (isempty (__uiobject_close_all_registered__)) - __lock_global__ ("__uiobject_close_all_registered__"); + global __go_close_all_registered__; + if (isempty (__go_close_all_registered__)) + __lock_global__ ("__go_close_all_registered__"); endif ## Use this instead of calling gcf to avoid creating a figure. @@ -49,9 +49,9 @@ cmd = sprintf ("%s -title \"Figure %d\"", cmd, h); endif plot_stream = popen (cmd, "w"); - if (isempty (__uiobject_close_all_registered__)) - atexit ("__uiobject_close_all__"); - __uiobject_close_all_registered__ = true; + if (isempty (__go_close_all_registered__)) + atexit ("__go_close_all__"); + __go_close_all_registered__ = true; endif if (plot_stream < 0) error ("drawnow: failed to open connection to gnuplot"); @@ -70,7 +70,7 @@ endif if (nargin == 2 || strcmp (f.visible, "on")) - __uiobject_draw_figure__ (f, plot_stream); + __go_draw_figure__ (f, plot_stream); endif __request_drawnow__ (false); diff --git a/scripts/plot/figure.m b/scripts/plot/figure.m --- a/scripts/plot/figure.m +++ b/scripts/plot/figure.m @@ -30,7 +30,7 @@ nargs = nargin; - f = []; + f = NaN; init_new_figure = false; if (mod (nargs, 2) == 1) @@ -54,19 +54,18 @@ ## or switching to. cf = get (0, "currentfigure"); if (! isempty (cf) && cf != 0) - if (isempty (f) || cf != f) + if (isnan (f) || cf != f) drawnow (); endif endif if (rem (nargs, 2) == 0) - if (isempty (f) || init_new_figure) - f = __uiobject_init_figure__ (f); + if (isnan (f) || init_new_figure) + f = __go_figure__ (f); endif if (nargs > 0) set (f, varargin{:}); endif - __uiobject_adopt__ (0, f); set (0, "currentfigure", f); else print_usage (); diff --git a/scripts/plot/get.in b/scripts/plot/get.in deleted file mode 100644 --- a/scripts/plot/get.in +++ /dev/null @@ -1,57 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} get (@var{h}, @var{p}) -## Return the named property @var{p} from the graphics handle @var{h}. -## If @var{p} is omitted, return the complete property list for @var{h}. -## @end deftypefn - -## Author: jwe - -function retval = get (h, property) - - __uiobject_globals__; - - if (nargin == 1 || nargin == 2) - if (ishandle (h)) - idx = __uiobject_handle2idx__ (h); - obj = __uiobject_list__(idx).object; - if (nargin == 2) - if (ischar (property)) - key = tolower (property); - if (isfield (obj, key)) - retval = obj.(key); - else - error ("get: object has no property named `%s'", property); - endif - else - error ("get: expecting property to be a character string"); - endif - else - retval = obj; - endif - else - error ("get: invalid handle = %d", h); - endif - else - print_usage (); - endif - -endfunction diff --git a/scripts/plot/include-globals.awk b/scripts/plot/include-globals.awk deleted file mode 100644 --- a/scripts/plot/include-globals.awk +++ /dev/null @@ -1,8 +0,0 @@ -/^ *__uiobject_globals__;?.*$/ { - print " ## BEGIN text from __uiobject_globals__.m"; - system (sprintf ("cat %s", file)); - print " ## END text from __uiobject_globals__.m"; - next; -} { - print $0; -} diff --git a/scripts/plot/ishandle.m b/scripts/plot/ishandle.m deleted file mode 100644 --- a/scripts/plot/ishandle.m +++ /dev/null @@ -1,38 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} ishandle (@var{h}) -## Return 1 if @var{h} is a graphics handle and 0 otherwise. -## @end deftypefn - -## Author: jwe - -function retval = ishandle (h) - - if (nargin == 1) - ## Ensure that we have a root figure object. - __uiobject_init_root_figure__ (); - retval = (isnumeric (h) && isscalar (h) && round (h) == h - && ! isempty (__uiobject_handle2idx__ (h))); - else - print_usage (); - endif - -endfunction diff --git a/scripts/plot/line.m b/scripts/plot/line.m --- a/scripts/plot/line.m +++ b/scripts/plot/line.m @@ -18,8 +18,10 @@ ## 02110-1301, USA. ## -*- texinfo -*- -## @deftypefn {Function File} {} line (@var{x}, @var{y}) +## @deftypefn {Function File} {} line () +## @deftypefnx {Function File} {} line (@var{x}, @var{y}) ## @deftypefnx {Function File} {} line (@var{x}, @var{y}, @var{z}) +## @deftypefnx {Function File} {} line (@var{x}, @var{y}, @var{z}, @var{opts}) ## Create line object from @var{x} and @var{y} and insert in current ## axes object. Return handle to line object. ## @end deftypefn @@ -28,34 +30,12 @@ function h = line (varargin) - nargs = nargin; + ## make a default line object, and make it the current axes for + ## the current figure. + tmp = __line__ (gca (), varargin{:}); - if (nargs > 1) - if (isnumeric (varargin{1}) && isnumeric (varargin{2})) - ## make a default line object, and make it the current axes for - ## the current figure. - ca = gca (); - s = __uiobject_line_ctor__ (ca); - s.xdata = varargin{1}; - s.ydata = varargin{2}; - num_data_args = 2; - if (nargs > 2 && isnumeric (varargin{3})) - s.zdata = varargin{3}; - num_data_args = 3; - endif - tmp = __uiobject_make_handle__ (s); - if (nargs > num_data_args) - set (tmp, varargin{num_data_args+1:end}); - endif - __uiobject_adopt__ (ca, tmp); - if (nargout > 0) - h = tmp; - endif - else - error ("expecting numeric arguments for line data"); - endif - else - print_usage (); + if (nargout > 0) + h = tmp; endif endfunction diff --git a/scripts/plot/mesh.m b/scripts/plot/mesh.m --- a/scripts/plot/mesh.m +++ b/scripts/plot/mesh.m @@ -68,18 +68,10 @@ ## current figure. ca = gca (); - s = __uiobject_surface_ctor__ (ca); - - s.xdata = x; - s.ydata = y; - s.zdata = z; + tmp = __go_surface__ (ca, "xdata", x, "ydata", y, "zdata", z); set (ca, "view", [-37.5, 30]); - tmp = __uiobject_make_handle__ (s); - - __uiobject_adopt__ (ca, tmp); - if (nargout > 0) h = tmp; endif diff --git a/scripts/plot/newplot.m b/scripts/plot/newplot.m --- a/scripts/plot/newplot.m +++ b/scripts/plot/newplot.m @@ -43,7 +43,7 @@ case "add" case "replacechildren" case "replace" - __uiobject_axes_init__ (ca, "replace"); + __go_axes_init__ (ca, "replace"); otherwise error ("newplot: unrecognized nextplot property for current axes"); endswitch diff --git a/scripts/plot/set.in b/scripts/plot/set.in deleted file mode 100644 --- a/scripts/plot/set.in +++ /dev/null @@ -1,74 +0,0 @@ -## Copyright (C) 2005 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} set (@var{h}, @var{p}, @var{v}, @dots{}) -## Set the named property @var{p} to the value @var{v} in the graphics -## handle @var{h}. -## @end deftypefn - -## Author: jwe - -function retval = set (h, varargin) - - __uiobject_globals__; - - if (rem (nargin-1, 2) == 0) - if (ishandle (h)) - idx = __uiobject_handle2idx__ (h); - obj = __uiobject_list__(idx).object; - - if (isfield (obj, "__setter__")) - obj = feval (obj.__setter__, h, varargin{:}); - else - for i = 1:2:nargin-1 - property = varargin{i}; - if (ischar (property)) - key = tolower (property); - if (isfield (obj, key)) - val = varargin{i+1}; - if (isfield (obj, "__validators__")) - validators = obj.__validators__; - if (isfield (validators, key)) - feval (validators.(key), val); - endif - endif - obj.(key) = val; - else - warning ("set: unrecognized property `%s' for uiobject `%s'", - property, obj.type); - endif - else - error ("set: expecting property name to be a character string"); - endif - endfor - endif - __uiobject_list__(idx).object = obj; - __request_drawnow__ (); - if (nargout > 0) - retval = h; - endif - else - error ("set: invalid handle"); - endif - else - print_usage (); - endif - -endfunction diff --git a/scripts/plot/text.m b/scripts/plot/text.m --- a/scripts/plot/text.m +++ b/scripts/plot/text.m @@ -29,14 +29,13 @@ function h = text (varargin) - if (nargin > 2) - x = y = z = 0; - if (isnumeric (varargin{1}) && isnumeric (varargin{2})) - x = varargin{1}; - y = varargin{2}; - else - error ("text: expecting first two arguments to be numeric"); - endif + nargs = nargin; + offset = 0; + + if (nargs > 2 && isnumeric (varargin{1}) && isnumeric (varargin{2})) + x = varargin{1}; + y = varargin{2}; + offset = 3; if (nargin > 3 && isnumeric (varargin{3})) z = varargin{3}; @@ -56,36 +55,41 @@ nx = numel (x); ny = numel (y); nz = numel (z); - if (nx == ny && nx == nz) - pos = [x(:), y(:), z(:)]; - ca = gca (); - tmp = zeros (n, 1); - if (n == 1) - label = label{1}; - for i = 1:nx - tmp(i) = __uiobject_text_ctor__ (ca, "string", label, - "position", pos(i,:), - varargin{:}); - endfor - elseif (n == nx) - for i = 1:nx - tmp(i) = __uiobject_text_ctor__ (ca, "string", label{i}, - "position", pos(i,:), - varargin{:}); - endfor - else - error ("text: dimension mismatch for coordinates and label"); - endif - else - error ("text: dimension mismatch for coordinates"); - endif else error ("text: expecting label to be a character string or cell array of character strings"); endif + else + x = y = z = 0; + nx = ny = nz = 1; + label = {""}; + n = 1; + endif - for i = 1:numel (tmp) - __uiobject_adopt__ (ca, tmp(i)); - endfor + if (rem (numel (varargin), 2) == 0) + + if (nx == ny && nx == nz) + pos = [x(:), y(:), z(:)]; + ca = gca (); + tmp = zeros (n, 1); + if (n == 1) + label = label{1}; + for i = 1:nx + tmp(i) = __go_text__ (ca, "string", label, + "position", pos(i,:), + varargin{:}); + endfor + elseif (n == nx) + for i = 1:nx + tmp(i) = __go_text__ (ca, "string", label{i}, + "position", pos(i,:), + varargin{:}); + endfor + else + error ("text: dimension mismatch for coordinates and label"); + endif + else + error ("text: dimension mismatch for coordinates"); + endif if (nargout > 0) h = tmp; diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2007-03-14 John W. Eaton + + * graphics.cc: New file. + * Makefile.in (DIST_SRC): Add it to the list. + +2007-03-13 John W. Eaton + + * file-io.cc (do_stream_open): Use binary mode if 't' is not + specified in mode, but don't add 'b' if it is already present. + 2007-03-09 David Bateman * data.cc (do_cat): Also treat case of all empty matrices. diff --git a/src/Makefile.in b/src/Makefile.in --- a/src/Makefile.in +++ b/src/Makefile.in @@ -169,7 +169,7 @@ DIST_SRC := Cell.cc bitfcns.cc c-file-ptr-stream.cc comment-list.cc \ cutils.c data.cc debug.cc defaults.cc defun.cc dirfns.cc \ - dynamic-ld.cc error.cc file-io.cc gripes.cc \ + dynamic-ld.cc error.cc file-io.cc graphics.cc gripes.cc \ help.cc input.cc lex.l load-path.cc load-save.cc ls-hdf5.cc \ ls-mat-ascii.cc ls-mat4.cc ls-mat5.cc ls-oct-ascii.cc \ ls-oct-binary.cc ls-utils.cc main.c mappers.cc matherr.c \ diff --git a/src/file-io.cc b/src/file-io.cc --- a/src/file-io.cc +++ b/src/file-io.cc @@ -415,6 +415,15 @@ #if defined (HAVE_ZLIB) std::string tmode = mode; + // Use binary mode if 't' is not specified, but don't add + // 'b' if it is already present. + + size_t bpos = tmode.find ('b'); + size_t tpos = tmode.find ('t'); + + if (bpos == NPOS && tpos == NPOS) + tmode += 'b'; + size_t pos = tmode.find ('z'); if (pos != NPOS) @@ -434,7 +443,7 @@ else #endif { - FILE *fptr = ::fopen (fname.c_str (), mode.c_str ()); + FILE *fptr = ::fopen (fname.c_str (), tmode.c_str ()); retval = octave_stdiostream::create (fname, fptr, md, flt_fmt);