# HG changeset patch # User Jaroslav Hajek # Date 1277367383 -7200 # Node ID d699a6c63263d9471568d131d427deab2bd32e59 # Parent 58c1b54025882fa78a74e5a30b3ce639ba8c4df4# Parent 570f30a48732e9c2b151af22fdd32713fe582bfd merge with main repo diff -r 58c1b5402588 -r d699a6c63263 ChangeLog --- a/ChangeLog Thu Jun 24 10:14:44 2010 +0200 +++ b/ChangeLog Thu Jun 24 10:16:23 2010 +0200 @@ -1,3 +1,10 @@ +2010-06-23 Jaroslav Hajek + + * configure.ac: Temporarily include F77_INTEGER_8_FLAG in FFLAGS for + BLAS checking. + * mkoctfile.in: Include F77_INTEGER_8_FLAG in ALL_FFLAGS. + * mkoctfile.cc.in: Ditto. + 2010-05-18 Jaroslav Hajek * NEWS: Update. diff -r 58c1b5402588 -r d699a6c63263 configure.ac --- a/configure.ac Thu Jun 24 10:14:44 2010 +0200 +++ b/configure.ac Thu Jun 24 10:16:23 2010 +0200 @@ -942,18 +942,33 @@ AC_SUBST(XTRA_CRUFT_SH_LDFLAGS) ### Checks for BLAS and LAPACK libraries: + +## Need to adjust FFLAGS to include correct integer size. +save_FFLAGS="$FFLAGS" +FFLAGS="$FFLAGS $F77_INTEGER_8_FLAG" + ACX_BLAS_WITH_F77_FUNC([:], [:]) ACX_LAPACK([:], [:]) +## Restore FFLAGS. +FFLAGS="$save_FFLAGS" + +if test "x$acx_blas_f77_func_ok" = "xno"; then + if $USE_64_BIT_IDX_T && test "$acx_blas_integer_size_ok" = "no" ; then + ## Attempt to be more informative. + AC_MSG_ERROR([BLAS doesn't seem to support 64-bit integers. This is incompatible with --enable-64.]) + else + AC_MSG_ERROR([A BLAS library was detected but found incompatible with your Fortran 77 compiler settings.]) + fi +fi + if test x$acx_blas_ok = xno || test x$acx_lapack_ok = xno; then AC_MSG_ERROR([You are required to have BLAS and LAPACK libraries]) fi -if test "x$acx_blas_f77_func_ok" = "xno"; then - AC_MSG_ERROR([A BLAS library was detected but found incompatible with your Fortran 77 compiler]) -fi - -# Check for the qrupdate library +### Check for the qrupdate library +## No need to adjust FFLAGS because only link is attempted. +## Must supply proper LIBS, however. save_LIBS="$LIBS" LIBS="$LAPACK_LIBS $BLAS_LIBS $FLIBS $LIBS" diff -r 58c1b5402588 -r d699a6c63263 doc/ChangeLog --- a/doc/ChangeLog Thu Jun 24 10:14:44 2010 +0200 +++ b/doc/ChangeLog Thu Jun 24 10:16:23 2010 +0200 @@ -1,10 +1,18 @@ +2010-06-16 Rik + + * ChangeLog: Correctly break lines > 80 characters. + +2010-06-16 Rik + + * interpreter/intro.txi: Clarify wording. (bug #30165). + 2010-06-16 Rik * interpreter/set.txi: Remove reference to deprecated function. 2010-06-16 Rik - * interpreter/expr.txi, interpreter/func.txi, interpreter/install.txi, + * interpreter/expr.txi, interpreter/func.txi, interpreter/install.txi, interpreter/plot.txi, interpreter/sparse.txi: Periodic grammar check of documentation to ensure a common format. @@ -12,7 +20,7 @@ * interpreter/arith.txi, interpreter/diffeq.txi, interpreter/intro.txi, interpreter/nonlin.txi, interpreter/poly.txi, interpreter/sparse.txi: - Replace @ifinfo with @ifnottex. + Replace @ifinfo with @ifnottex. 2010-05-07 John W. Eaton @@ -20,7 +28,7 @@ 2010-05-02 Rik - * interpreter/contrib.txi, interpreter/install.txi, + * interpreter/contrib.txi, interpreter/install.txi, interpreter/plot.txi, interpreter/sparse.txi, interpreter/octave.texi: Remove tabs causing problems with pdf formatting. @@ -89,14 +97,14 @@ 2009-12-20 Rik - * interpreter/geometryimages.m: Correctly set postscript output when QHULL - library does not exist and sombrero image is printed. + * interpreter/geometryimages.m: Correctly set postscript output when + QHULL library does not exist and sombrero image is printed. 2009-12-19 Rik * Makefile.am, faq/Makefile.am, interpreter/Makefile.am, - liboctave/Makefile.am, refcard/Makefile.am, interpreter/images.awk: - Eliminate TOPDIR variable in favor of built-in automake variables of + liboctave/Makefile.am, refcard/Makefile.am, interpreter/images.awk: + Eliminate TOPDIR variable in favor of built-in automake variables of top_builddir and top_srcdir. 2009-12-17 Rik @@ -105,33 +113,33 @@ 2009-12-11 Rik - * interpreter/Makefile.am: remove install-local target and use automake + * interpreter/Makefile.am: remove install-local target and use automake syntax to install doc-cache file. 2009-12-10 Rik - * interpreter/Makefile.am: Replace distdir-local with dist-hook rule as it - is better supported by automake. + * interpreter/Makefile.am: Replace distdir-local with dist-hook rule as + it is better supported by automake. 2009-12-10 Rik - * interpreter/Makefile.am: new distdir-local rule to check for presence of - necessary libraries before packaging distribution + * interpreter/Makefile.am: new distdir-local rule to check for presence + of necessary libraries before packaging distribution 2009-12-08 Rik - * interpreter/Makefile.am: Distribute all generated documentation (.pdf, - .ps, .html, .dvi) to remove build requirement for TexInfo + * interpreter/Makefile.am: Distribute all generated documentation + (.pdf, .ps, .html, .dvi) to remove build requirement for TexInfo 2009-12-07 Rik - * interpreter/Makefile.am, faq/Makefile.am, liboctave/Makefile.am: Document - use of NOTPARALLEL directive. + * interpreter/Makefile.am, faq/Makefile.am, liboctave/Makefile.am: + Document use of NOTPARALLEL directive. 2009-12-07 Rik - * refcard/Makefile.am: Add CLEANFILES and MAINTAINERCLEANFILES objects to - properly clean directory. + * refcard/Makefile.am: Add CLEANFILES and MAINTAINERCLEANFILES objects + to properly clean directory. 2009-12-05 Rik @@ -146,25 +154,26 @@ 2009-12-04 Rik * Makefile.am, interpreter/Makefile.am, liboctave/Makefile.am: remove - lingering configuration support for conf.texi - * liboctave/Makefile.am: distribute .texi files + lingering configuration support for conf.texi. + * liboctave/Makefile.am: distribute .texi files. 2009-12-04 Rik * interpreter/geometryimages.m, interpreter/interpimages.m, interpreter/sparseimages.m, interpreter/plotimages.m: - Switch to color output for PostScript documentation images + Switch to color output for PostScript documentation images. 2009-12-04 Rik * interpreter/geometryimages.m, interpreter/interpimages.m, interpreter/sparseimages.m, interpreter/plotimages.m: - Set default paperorientation to landscape to stop warning message + Set default paperorientation to landscape to stop warning message. 2009-12-04 Ben Abbott * interpreter/geometryimages.m, interpreter/interpimages.m, - interpreter/sparseimages.m: Set default papersize to the desired imagesize + interpreter/sparseimages.m: Set default papersize to the desired + imagesize. 2009-12-04 John W. Eaton @@ -241,8 +250,8 @@ 2009-12-01 Rik - * faq/Makefile.am, doc/interpreter/bugs.txi, doc/interpreter/install.txi: - Eliminate false dependency on conf.texi + * faq/Makefile.am, doc/interpreter/bugs.txi, + doc/interpreter/install.txi: Eliminate false dependency on conf.texi. 2009-11-30 Rik @@ -283,13 +292,14 @@ 2009-11-25 Rik * interpreter/Makefile.am: - Simplify doc-cache handling in Makefile.am to use only install-data-local - target + Simplify doc-cache handling in Makefile.am to use only + install-data-local target 2009-11-24 Rik * interpreter/Makefile.am: - Correct Makefile so that it halts on error when unable to build doc-cache + Correct Makefile so that it halts on error when unable to build + doc-cache. 2009-11-23 Rik @@ -300,13 +310,13 @@ 2009-11-23 Rik * Makefile.am: Add . to SUBDIRS to force automake to compile this - directory, and make conf.texi, before recursively compiling SUBDIRS which - depend on conf.texi + directory, and make conf.texi, before recursively compiling SUBDIRS + which depend on conf.texi 2009-11-11 Rik - * Makefile.am: Add DISTCLEANFILES macro so that generated conf.texi can be - cleaned by automake. + * Makefile.am: Add DISTCLEANFILES macro so that generated conf.texi can + be cleaned by automake. 2009-11-10 John W. Eaton @@ -323,7 +333,7 @@ 2009-10-23 Rik - * various: Periodic grammar check of Octave documentation files to + * various: Periodic grammar check of Octave documentation files to ensure a standardized format. 2009-10-20 Rik @@ -413,10 +423,10 @@ 2009-06-03 Rik - * interpreter/plotimages.m: Correct errorbar plot for docs. Make hist plot - reprodroducible for docs. - * interpreter/interpimages.m: Correct typo in legend of interpft plot for - docs + * interpreter/plotimages.m: Correct errorbar plot for docs. Make hist + plot reprodroducible for docs. + * interpreter/interpimages.m: Correct typo in legend of interpft plot + for docs. 2009-06-03 Jaroslav Hajek @@ -446,8 +456,8 @@ 2009-05-21 Rik - * interpreter/Makefile.in, texmf.cnf: Change texi2pdf call to include local - TeX configuration file which increases save_history variable. + * interpreter/Makefile.in, texmf.cnf: Change texi2pdf call to include + local TeX configuration file which increases save_history variable. 2009-05-17 Rik @@ -456,8 +466,9 @@ 2009-05-17 Rik - * interpreter/*.txi: Simplify TeXinfo files by eliminating redundant @iftex - followed by @tex construction. Also, spellchecked all .txi and .texi files. + * interpreter/*.txi: Simplify TeXinfo files by eliminating redundant + @iftex followed by @tex construction. Also, spellchecked all .txi + and .texi files. 2009-05-14 Rik diff -r 58c1b5402588 -r d699a6c63263 doc/interpreter/intro.txi --- a/doc/interpreter/intro.txi Thu Jun 24 10:14:44 2010 +0200 +++ b/doc/interpreter/intro.txi Thu Jun 24 10:16:23 2010 +0200 @@ -72,7 +72,7 @@ capabilities. If you are new to Octave, I recommend that you try these examples to -begin learning Octave by using it. Lines marked with @samp{octave:13>} +begin learning Octave by using it. Lines marked like so, @samp{octave:13>}, are lines you type, ending each with a carriage return. Octave will respond with an answer, or by displaying a graph. diff -r 58c1b5402588 -r d699a6c63263 liboctave/CMatrix.cc --- a/liboctave/CMatrix.cc Thu Jun 24 10:14:44 2010 +0200 +++ b/liboctave/CMatrix.cc Thu Jun 24 10:16:23 2010 +0200 @@ -2665,6 +2665,10 @@ ps, rcon, rank, work.fortran_vec (), lwork, prwork, piwork, info)); + std::cerr << "work(0): " << work(0) << std::endl; + std::cerr << "rwork(0): " << rwork(0) << std::endl; + std::cerr << "iwork(0): " << iwork(0) << std::endl; + // The workspace query is broken in at least LAPACK 3.0.0 // through 3.1.1 when n >= mnthr. The obtuse formula below // should provide sufficient workspace for ZGELSD to operate @@ -2698,6 +2702,10 @@ lwork = static_cast (std::real (work(0))); work.resize (lwork, 1); + std::cerr << "work numel: " << work.numel () << std::endl; + std::cerr << "rwork numel: " << rwork.numel () << std::endl; + std::cerr << "iwork numel: " << iwork.numel () << std::endl; + F77_XFCN (zgelsd, ZGELSD, (m, n, nrhs, tmp_data, m, pretval, maxmn, ps, rcon, rank, work.fortran_vec (), lwork, diff -r 58c1b5402588 -r d699a6c63263 liboctave/ChangeLog --- a/liboctave/ChangeLog Thu Jun 24 10:14:44 2010 +0200 +++ b/liboctave/ChangeLog Thu Jun 24 10:16:23 2010 +0200 @@ -61,10 +61,10 @@ * dim-vector.cc: New source. * Makefile.am: Add it. - * dim-vector.h (dim_vector::chop_all_singletons, - dim_vector::str, dim_vector::num_ones, dim_vector::safe_numel, + * dim-vector.h (dim_vector::chop_all_singletons, + dim_vector::str, dim_vector::num_ones, dim_vector::safe_numel, dim_vector::squeeze, dim_vector::concat, dim_vector::redim): - Move bodies to dim_vector.cc. + Move bodies to dim_vector.cc. (dim_vector::concat): Rewrite. * Array.cc (Array::cat): Fix dim_vector concatenation. Don't use 0x0 as neutral element, because it isn't with dim > 1. diff -r 58c1b5402588 -r d699a6c63263 mkoctfile.cc.in --- a/mkoctfile.cc.in Thu Jun 24 10:14:44 2010 +0200 +++ b/mkoctfile.cc.in Thu Jun 24 10:16:23 2010 +0200 @@ -236,8 +236,9 @@ vars["LDFLAGS"] = get_variable ("LDFLAGS", %OCTAVE_CONF_LDFLAGS%); vars["LD_STATIC_FLAG"] = get_variable ("LD_STATIC_FLAG", %OCTAVE_CONF_LD_STATIC_FLAG%); vars["LFLAGS"] = get_variable ("LFLAGS", DEFAULT_LFLAGS); + vars["F77_INTEGER8_FLAG"] = get_variable ("F77_INTEGER8_FLAG", %OCTAVE_CONF_F77_INTEGER8_FLAG%); - vars["ALL_FFLAGS"] = vars["FFLAGS"]; + vars["ALL_FFLAGS"] = vars["FFLAGS"] + " " + vars["F77_INTEGER8_FLAG"]; vars["ALL_CFLAGS"] = vars["INCFLAGS"] + " " + vars["XTRA_CFLAGS"] + " " + vars["CFLAGS"]; diff -r 58c1b5402588 -r d699a6c63263 mkoctfile.in --- a/mkoctfile.in Thu Jun 24 10:14:44 2010 +0200 +++ b/mkoctfile.in Thu Jun 24 10:16:23 2010 +0200 @@ -103,8 +103,9 @@ : ${LDFLAGS=%OCTAVE_CONF_LDFLAGS%} : ${LD_STATIC_FLAG=%OCTAVE_CONF_LD_STATIC_FLAG%} : ${LFLAGS=$DEFAULT_LFLAGS} +: ${F77_INTEGER_8_FLAG=%F77_INTEGER_8_FLAG%} -: ${ALL_FFLAGS="$FFLAGS"} +: ${ALL_FFLAGS="$FFLAGS $F77_INTEGER_8_FLAG"} : ${ALL_CFLAGS="$INCFLAGS $XTRA_CFLAGS $CFLAGS"} diff -r 58c1b5402588 -r d699a6c63263 scripts/ChangeLog --- a/scripts/ChangeLog Thu Jun 24 10:14:44 2010 +0200 +++ b/scripts/ChangeLog Thu Jun 24 10:16:23 2010 +0200 @@ -1,3 +1,20 @@ +2010-06-24 Shai Ayal + + * plot/print.m: convert to wrapper for backend specific print functions + * plot/__gnuplot_print__.m: New gnuplot specific print function, + largely based on the former print.m + * plot/__fltk_print__.m: New fltk specific print function + * plot/__print_parse_opts__.m: New option parser for print + functions, largely based on the former print.m + * plot/module.mk: Add new m-files here + +2010-06-23 David Bateman + + * whitebg.m: New function. + * module.mk (plot_FCN_FILES): Add it here. + * __go_draw_figure__.m: Set the border color to the inverse of the + background color. + 2010-06-17 Brad Froehle * sparse/spy.m: Fix typo. @@ -8,13 +25,13 @@ 2010-06-16 Rik - * @ftp/dir.m, @ftp/ftp.m, @ftp/mget.m, @ftp/mput.m, @ftp/rename.m, - deprecated/fstat.m, general/accumdim.m, general/interp1.m, - linear-algebra/ishermitian.m, linear-algebra/issymmetric.m, - miscellaneous/substruct.m, optimization/fminbnd.m, + * @ftp/dir.m, @ftp/ftp.m, @ftp/mget.m, @ftp/mput.m, @ftp/rename.m, + deprecated/fstat.m, general/accumdim.m, general/interp1.m, + linear-algebra/ishermitian.m, linear-algebra/issymmetric.m, + miscellaneous/substruct.m, optimization/fminbnd.m, optimization/fsolve.m, plot/bar.m, plot/daspect.m, plot/pbaspect.m, plot/print.m, polynomial/mkpp.m, polynomial/ppval.m, set/union.m, - signal/unwrap.m, specfun/nthroot.m: Periodic grammar check of + signal/unwrap.m, specfun/nthroot.m: Periodic grammar check of documentation to ensure a common format. 2010-06-14 Rik @@ -49,8 +66,8 @@ 2010-06-08 Rik - * general/cumtrapz.m, general/postpad.m, general/prepad.m, - general/shift.m, general/trapz.m, signal/unwrap.m: Use common + * general/cumtrapz.m, general/postpad.m, general/prepad.m, + general/shift.m, general/trapz.m, signal/unwrap.m: Use common method to find first non-singleton dimension. 2010-06-08 Rik @@ -60,18 +77,18 @@ 2010-06-08 Rik - * general/cart2pol.m, general/cart2sph.m, general/pol2cart.m, - general/sph2cart.m: Add option to operate on column matrix of + * general/cart2pol.m, general/cart2sph.m, general/pol2cart.m, + general/sph2cart.m: Add option to operate on column matrix of coordinates. 2010-06-08 Rik - * general/arrayfun.m, general/cart2pol.m, general/cart2sph.m, - general/idivide.m, general/logspace.m, general/sph2cart.m, - general/structfun.m, image/imagesc.m, io/csvread.m, io/csvwrite.m, - linear-algebra/cond.m, linear-algebra/condest.m, - linear-algebra/isdefinite.m, linear-algebra/null.m, - linear-algebra/orth.m, miscellaneous/list_primes.m, + * general/arrayfun.m, general/cart2pol.m, general/cart2sph.m, + general/idivide.m, general/logspace.m, general/sph2cart.m, + general/structfun.m, image/imagesc.m, io/csvread.m, io/csvwrite.m, + linear-algebra/cond.m, linear-algebra/condest.m, + linear-algebra/isdefinite.m, linear-algebra/null.m, + linear-algebra/orth.m, miscellaneous/list_primes.m, optimization/fminunc.m, optimization/fzero.m, path/matlabroot.m, plot/axis.m, plot/plot.m, plot/semilogx.m, plot/semilogxerr.m, plot/semilogy.m, plot/semilogyerr.m, plot/stem.m, polynomial/poly.m, @@ -79,8 +96,8 @@ polynomial/polyout.m, polynomial/polyval.m, set/ismember.m, sparse/spfun.m, specfun/betaln.m, statistics/base/mean.m, statistics/base/median.m, statistics/base/mode.m, statistics/base/ols.m, - statistics/base/ranks.m, - statistics/distributions/kolmogorov_smirnov_cdf.m, + statistics/base/ranks.m, + statistics/distributions/kolmogorov_smirnov_cdf.m, statistics/distributions/wblpdf.m: Improve documentation strings 2010-06-07 Jaroslav Hajek @@ -96,11 +113,11 @@ 2010-06-03 Alois Schlögl - * signal/arch_test.m, statistics/tests/bartlett_test.m, - statistics/tests/chisquare_test_homogeneity.m, - statistics/tests/chisquare_test_independence.m, - statistics/tests/manova.m, statistics/tests/mcnemar_test.m, - statistics/tests/run_test.m, statistics/distributions/chi2pdf.m: + * signal/arch_test.m, statistics/tests/bartlett_test.m, + statistics/tests/chisquare_test_homogeneity.m, + statistics/tests/chisquare_test_independence.m, + statistics/tests/manova.m, statistics/tests/mcnemar_test.m, + statistics/tests/run_test.m, statistics/distributions/chi2pdf.m: Replace calls to obsolete chisquare_cdf with chi2cdf. 2010-06-03 Rik @@ -110,7 +127,7 @@ 2010-06-02 Rik * optimization/sqp.m: Overhaul sqp code. - Guarantee equivalent results if sqp called with or wihout bounds + Guarantee equivalent results if sqp called with or wihout bounds (bug #29989). Simplify input option handling and add %tests to check validation code. Rewrite documentation string. @@ -130,8 +147,8 @@ validation routines. 2010-05-30 Rik - - * sparse/svds.m: Overhaul code. + + * sparse/svds.m: Overhaul code. Return smallest singular values if sigma == 0 (Bug #29721). Avoid calculating U and V matrices unless requested. Correctly handle zero matrix input. @@ -139,11 +156,11 @@ 2010-05-26 Rik - * statistics/base/histc.m, statistics/base/iqr.m, - statistics/base/kurtosis.m, statistics/base/mode.m, - statistics/base/ranks.m, statistics/base/run_count.m, - statistics/base/skewness.m, statistics/base/statistics.m, - statistics/base/studentize.m: Improve validation of input arguments. + * statistics/base/histc.m, statistics/base/iqr.m, + statistics/base/kurtosis.m, statistics/base/mode.m, + statistics/base/ranks.m, statistics/base/run_count.m, + statistics/base/skewness.m, statistics/base/statistics.m, + statistics/base/studentize.m: Improve validation of input arguments. 2010-05-26 Jaroslav Hajek @@ -154,7 +171,7 @@ * plot/legend.m: Improve documentation string. 2010-05-26 Rik - + * sparse/svds.m: Check struct input arguments. Overhaul documentation. 2010-05-26 Ben Abbott @@ -186,12 +203,12 @@ non-singleton dimension computation. 2010-05-24 Rik - * general/private/__isequal__.m, image/image.m, + * general/private/__isequal__.m, image/image.m, statistics/base/ranks.m: Replace calls to deprecated functions. 2010-05-23 Rik - * image/imshow.m: Scale image point color according to colormap. + * image/imshow.m: Scale image point color according to colormap. Bug #29926. 2010-05-16 Rik @@ -225,7 +242,7 @@ 2010-05-16 Rik - * scripts/plot/contourc.m, scripts/plot/private/__contour__.m, + * scripts/plot/contourc.m, scripts/plot/private/__contour__.m, scripts/plot/surface.m, scripts/plot/surfnorm.m: Check input arguments for size and type (bug #29861). @@ -256,8 +273,8 @@ 2010-05-05 Rik - * statistics/tests/cor_test.m, statistics/tests/t_test.m, - statistics/tests/t_test_2.m, statistics/tests/t_test_regression.m, + * statistics/tests/cor_test.m, statistics/tests/t_test.m, + statistics/tests/t_test_2.m, statistics/tests/t_test_regression.m, statistics/tests/welch_test.m: Replace deprecated function calls. Patch provided by Alois Schlögl. @@ -854,7 +871,7 @@ * plot/axis.m, plot/__go_draw_axes__.m, plot/colorbar.m, plot/isocolors.m, plot/isonormals.m, plot/isosurface.m, - plot/plotyy.m, plot/polar.m, plot/surfl.m, + plot/plotyy.m, plot/polar.m, plot/surfl.m, plot/private/__actual_axis_position.m: Replace dataaspectratio and dataaspectratiomode properties with plotboxaspectratio and plotboxaspectratio properties. @@ -1037,7 +1054,7 @@ * general/structfun.m, miscellaneous/getfield.m, miscellaneous/orderfields.m, miscellaneous/setfield.m, - miscellaneous/substruct.m: Update documentation string. + miscellaneous/substruct.m: Update documentation string. 2010-01-16 David Bateman diff -r 58c1b5402588 -r d699a6c63263 scripts/plot/__fltk_print__.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/plot/__fltk_print__.m Thu Jun 24 10:16:23 2010 +0200 @@ -0,0 +1,29 @@ +## Copyright (C) 2010 Shai Ayal +## +## 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 3 of the License, 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, see +## . + +## -*- texinfo -*- +## @deftypefn {Function File} __fltk_print__ (@var{...}) +## Undocumented internal function. +## @end deftypefn + +function __fltk_print__ (varargin) + + opts = __print_parse_opts__ (varargin{:}); + drawnow ("eps", opts.name); + +endfunction diff -r 58c1b5402588 -r d699a6c63263 scripts/plot/__gnuplot_print__.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/plot/__gnuplot_print__.m Thu Jun 24 10:16:23 2010 +0200 @@ -0,0 +1,655 @@ +## Copyright (C) 1999, 2005, 2006, 2007, 2008, 2009 Daniel Heiserer +## Copyright (C) 2001 Laurent Mazet +## +## 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 3 of the License, 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, see +## . + +## -*- texinfo -*- +## @deftypefn {Function File} __gnuplot_ginput__ (@var{...}) +## Undocumented internal function. +## @end deftypefn + +## Author: Daniel Heiserer +## Adapted-By: jwe + +function __gnuplot_print__ (varargin) + + persistent warn_on_inconsistent_orientation = true + + persistent ghostscript_binary = ""; + if (isempty (ghostscript_binary)) + ghostscript_binary = getenv ("GSC"); + ng = 0; + if (isunix ()) + ## Unix - Includes Mac OSX and Cygwin. + gs_binaries = {"gs", "gs.exe"}; + else + ## pc - Includes Win32 and mingw. + gs_binaries = {"gs.exe", "gswin32c.exe"}; + endif + while (ng < numel (gs_binaries) && isempty (ghostscript_binary)) + ng = ng + 1; + ghostscript_binary = file_in_path (EXEC_PATH, gs_binaries{ng}); + endwhile + endif + + old_fig = get (0, "currentfigure"); + unwind_protect + opts = __print_parse_opts__ (varargin{:}); + have_ghostscript = (exist (ghostscript_binary, "file") == 2); + + doprint = isempty (opts.name); + if (doprint) + if (isempty (opts.devopt)) + if (opts.use_color < 0) + opts.devopt = "ps"; + printname = cstrcat (tmpnam, ".ps"); + else + opts.devopt = "psc"; + printname = cstrcat (tmpnam, ".psc"); + endif + else + printname = cstrcat (tmpnam, ".", devopt); + endif + opts.name = printname; + endif + + dot = rindex (opts.name, "."); + if (isempty (opts.devopt)) + if (dot == 0) + error ("print: no format specified"); + else + dev = tolower (opts.name(dot+1:end)); + endif + else + dev = opts.devopt; + endif + + dev_list = {"aifm", "corel", "fig", "png", "jpeg", ... + "gif", "pbm", "dxf", "mf", "svg", "hpgl", ... + "ps", "ps2", "psc", "psc2", "eps", "eps2", ... + "epsc", "epsc2", "emf", "pdf", "pslatex", ... + "epslatex", "epslatexstandalone", "pstex", "tikz"}; + suffixes = {"ai", "cdr", "fig", "png", "jpeg", ... + "gif", "pbm", "dxf", "mf", "svg", "hpgl", ... + "ps", "ps", "ps", "ps", "eps", "eps", ... + "eps", "eps", "emf", "pdf", "tex", ... + "tex", "tex", "tex", "tikz"}; + if (dot == 0) + opts.name = strcat (opts.name, ".", suffixes {strcmpi (dev_list, dev)}); + dot = rindex (name, "."); + endif + + if (opts.append_to_file) + if (any (strcmpi (dev, {"ps", "ps2", "psc", "psc2", "pdf"}))) + if (have_ghostscript) + file_exists = ((numel (dir (opts.name)) == 1) && (! isdir (opts.name))); + if (! file_exists) + opts.append_to_file = 0; + end + end + else + warning ("print.m: appended output is not supported for device '%s'", dev) + opts.append_to_file = 0; + endif + endif + + if (strcmp (dev, "tex")) + dev = "epslatex"; + elseif (strcmp (dev, "ill")) + dev = "aifm"; + elseif (strcmp (dev, "cdr")) + dev = "corel"; + elseif (strcmp (dev, "meta")) + dev = "emf"; + elseif (strcmp (dev, "jpg")) + dev = "jpeg"; + endif + + if (strcmp (dev, "epslatex")) + ## gnuplot 4.0 wants ".eps" in the output name + if (! __gnuplot_has_feature__ ("epslatex_implies_eps_filesuffix")) + opts.name = cstrcat (name(1:dot), "eps"); + endif + endif + + ## Check if the specified device is one that is supported by gnuplot. + ## If not, assume it is a device/format supported by Ghostscript. + if (! any (strcmp (dev, dev_list)) && have_ghostscript) + ghostscript_output = opts.name; + ghostscript_device = dev; + if (doprint) + ## If printing, use color postscript. + dev = "psc"; + opts.name = cstrcat (tmpnam, ".ps"); + else + ## If saving to a file, use color encapsulated postscript. + dev = "epsc"; + opts.name = cstrcat (tmpnam, ".eps"); + endif + elseif (doprint && all (! strcmpi (suffixes {strcmpi (dev_list, dev)}, + {"ps", "eps", "hpgl"}))) + ## When not using Ghostscript, verify the format is compatible with + ## hard copy output. + error ("print: missing file name, or invalid print format."); + else + ghostscript_output = ""; + endif + + termn = dev; + + ## SVG isn't actually a bitmap, but gnuplot treats its size option as it + ## does the bitmap terminals. + bitmap_devices = {"emf", "gif", "jpeg", "pbm", "png", "svg"}; + + if (any (strcmp (dev, {"ps", "ps2", "psc", "psc2", "epsc", "epsc2", ... + "eps", "eps2", "pstex", "pslatex", "epslatex", ... + "epslatexstandalone"}))) + + ## Various postscript options + if (any (strcmp (dev, {"pstex", "pslatex", "epslatex"}))) + options = ""; + elseif (strcmp (dev, "epslatexstandalone")) + if (__gnuplot_has_feature__ ("epslatexstandalone_terminal")) + termn = "epslatex"; + options = "standalone "; + else + error ("print: epslatexstandalone needs gnuplot 4.2 or higher"); + endif + else + if (dev(1) == "e") + options = "eps "; + else + options = ""; + endif + termn = "postscript"; + endif + + if (any (dev == "c") || opts.use_color > 0 + || (! isempty (strfind (dev, "tex")) && opts.use_color == 0)) + opts.use_color = 1; + else + opts.use_color = -1; + endif + + if (opts.use_color > 0) + if (opts.force_solid < 0) + options = cstrcat (options, "color dashed "); + else + options = cstrcat (options, "color solid "); + endif + else + if (opts.force_solid > 0) + options = cstrcat (options, "mono solid "); + else + options = cstrcat (options, "mono dashed "); + endif + endif + + if (! isempty (opts.font)) + options = cstrcat (options, "\"", opts.font, "\" "); + endif + if (! isempty (opts.fontsize)) + options = cstrcat (options, " ", opts.fontsize); + endif + + elseif (strcmp (dev, "tikz")) + if (! isempty (font) && ! isempty (opts.fontsize)) + options = cstrcat (options, "\"", opts.font, ",", opts.fontsize, "\" "); + elseif (! isempty (font)) + options = cstrcat (options, "\"", opts.font, "\" "); + else + options = ""; + endif + + elseif (strcmp (dev, "aifm") || strcmp (dev, "corel")) + ## Adobe Illustrator, CorelDraw + if (opts.use_color >= 0) + options = " color"; + else + options = " mono"; + endif + if (! isempty (opts.font)) + options = cstrcat (options, " \"", opts.font, "\""); + endif + if (! isempty (opts.fontsize)) + options = cstrcat (options, " ", opts.fontsize); + endif + + elseif (strcmp (dev, "fig")) + ## XFig + options = orientation; + if (opts.use_color >= 0) + options = " color"; + else + options = " mono"; + endif + options = cstrcat (options, " ", special_flag); + if (! isempty (opts.fontsize)) + options = cstrcat (options, " fontsize ", opts.fontsize); + endif + + elseif (strcmp (dev, "emf")) + ## Enhanced Metafile format + options = " "; + if (opts.use_color >= 0) + options = " color"; + else + options = " mono"; + endif + if (opts.force_solid >= 0) + options = cstrcat (options, " solid"); + endif + if (! isempty (opts.font)) + options = cstrcat (options, " \"", opts.font, "\""); + endif + if (! isempty (opts.fontsize)) + options = cstrcat (options, " ", opts.fontsize); + endif + + elseif (any (strcmp (dev, bitmap_devices))) + + if (isempty (opts.canvas_size) && isempty (opts.resolution) + && any (strcmp (dev, {"pbm", "gif", "jpeg", "png"}))) + options = ""; + elseif (strcmp (dev, "svg")) + ## Referring to size, either "dynamic" or "fixed" + options = "fixed"; + else + options = ""; + end + if (! isempty (opts.canvas_size)) + options = cstrcat (options, " size ", opts.canvas_size); + endif + + elseif (any (strcmp (dev, {"dxf", "mf", "hpgl"}))) + ## AutoCad DXF, METAFONT, HPGL + options = ""; + + elseif (strcmp (dev, "pdf")) + ## Portable Document format + options = " "; + if (opts.use_color >= 0) + options = "color"; + else + options = "mono"; + endif + if (opts.force_solid >= 0) + options = cstrcat (options, " solid"); + elseif (opts.force_solid < 0) + options = cstrcat (options, " dashed"); + endif + if (! isempty (opts.font)) + options = cstrcat (options, "\"", opts.font, "\" "); + endif + if (! isempty (opts.fontsize)) + options = cstrcat (options, " ", opts.fontsize); + endif + + endif + + if (__gnuplot_has_feature__ ("variable_GPVAL_TERMINALS")) + available_terminals = __gnuplot_get_var__ (gcf, "GPVAL_TERMINALS"); + available_terminals = regexp (available_terminals, "\\b\\w+\\b", "match"); + ## Favor the cairo terminals. + if (strcmp (termn, "pdf") + && any (strcmp (available_terminals, "pdfcairo"))) + termn = "pdfcairo"; + gnuplot_supports_term = true; + elseif (strcmp (termn, "png") + && any (strcmp (available_terminals, "pngcairo"))) + termn = "pngcairo"; + gnuplot_supports_term = true; + else + gnuplot_supports_term = any (strcmp (available_terminals, termn)); + endif + elseif (strcmp (termn, "pdf")) + ## Some Linux variants do not include a "pdf" capable gnuplot. + ## To be safe, use Ghostscript. + if (have_ghostscript) + gnuplot_supports_term = false; + ghostscript_device = "pdfwrite"; + else + gnuplot_supports_term = true; + endif + else + gnuplot_supports_term = true; + endif + + if (! gnuplot_supports_term) + if (strcmp (termn, "pdf")) + ## If there the installed gnuplot does not support pdf, use Ghostscript. + ghostscript_device = "pdfwrite"; + if (strfind (opts.name, ".pdf") == numel (opts.name) - 3) + ghostscript_output = opts.name; + else + ghostscript_output = strcat (opts.name, ".pdf"); + endif + name = cstrcat (tmpnam, ".ps"); + termn = "postscript"; + ## All "options" for pdf work for postscript as well. + else + error ("print: the device, \"%s\", is not available.", dev) + endif + endif + + is_eps_file = strncmp (dev, "eps", 3); + p.units = get (gcf, "units"); + p.paperunits = get (gcf, "paperunits"); + p.papersize = get (gcf, "papersize"); + p.paperposition = get (gcf, "paperposition"); + p.paperpositionmode = get (gcf, "paperpositionmode"); + p.paperorientation = get (gcf, "paperorientation"); + p.color = get (gcf, "color"); + if (p.papersize(1) > p.papersize(2)) + paperorientation = "landscape"; + else + paperorientation = "portrait"; + endif + if (! strcmp (paperorientation, get (gcf, "paperorientation")) + && warn_on_inconsistent_orientation) + msg = {"print.m - inconsistent papersize and paperorientation properties.\n", + sprintf(" papersize = %.2f, %.2f\n", p.papersize), + sprintf(" paperorientation = \"%s\"\n", p.paperorientation), + " the paperorientation property has been ignored"}; + warning ("%s",msg{:}) + warn_on_inconsistent_orientation = false; + endif + + if (strcmp (termn, "postscript") && ! strncmp (dev, "eps", 3)) + if (isempty (orientation)) + orientation = paperorientation; + endif + ## This is done here to accommodate ghostscript conversion. + options = cstrcat (orientation, " ", options); + end + + new_terminal = cstrcat (termn, " ", options); + + mono = (opts.use_color < 0); + + terminals_for_prn = {"postscript", "pdf", "pdfcairo"}; + output_for_printer = any (strncmp (termn, terminals_for_prn, numel(termn))); + + if (isempty (opts.resolution)) + if (any (strcmp (dev, {"emf", "svg"})) || output_for_printer) + opts.resolution = get (0, "screenpixelsperinch"); + else + opts.resolution = 150; + endif + else + opts.resolution = str2num (opts.resolution); + if (opts.resolution == 0) + opts.resolution = get (0, "screenpixelsperinch"); + endif + endif + figure_properties = get (gcf); + if (! isfield (figure_properties, "__pixels_per_inch__")) + addproperty ("__pixels_per_inch__", gcf, "double", opts.resolution); + endif + set (gcf, "__pixels_per_inch__", opts.resolution) + + unwind_protect + set (gcf, "paperunits", "inches"); + set (gcf, "units", "pixels"); + set (gcf, "color", "none"); + restore_properties = true; + if ((! output_for_printer || is_eps_file) && ! doprint) + ## If not PDF or PostScript, and the result is not being sent to a printer, + ## render an image the size of the paperposition box. + ## Trigger the listener to convert all paper props to inches. + if (! isempty (opts.canvas_size)) + size_in_pixels = sscanf (opts.canvas_size ,"%d, %d"); + size_in_pixels = reshape (size_in_pixels, [1, numel(size_in_pixels)]); + papersize_in_inches = size_in_pixels ./ opts.resolution; + paperposition_in_inches = [0, 0, papersize_in_inches]; + else + paperposition_in_inches = get (gcf, "paperposition"); + paperposition_in_inches(1:2) = 0; + papersize_in_inches = paperposition_in_inches(3:4); + endif + set (gcf, "papersize", papersize_in_inches); + set (gcf, "paperposition", paperposition_in_inches); + set (gcf, "paperpositionmode", "manual"); + else + if (strcmp (p.paperpositionmode, "auto")) + size_in_pixels = get (gcf, "position")(3:4); + paperposition_in_inches(3:4) = size_in_pixels ./ opts.resolution; + paperposition_in_inches(1:2) = (p.papersize - paperposition_in_inches(3:4))/2; + else + paperposition_in_inches = p.paperposition; + endif + if (! isempty (opts.orientation) && ! strcmp (opts.orientation, paperorientation)) + ## When -landscape/portrait changes the orientation, flip both the + ## papersize and paperposition. + restore_properties = true; + set (gcf, "papersize", p.papersize([2, 1])); + set (gcf, "paperposition", paperposition_in_inches([2, 1, 4, 3])); + else + set (gcf, "paperposition", paperposition_in_inches); + endif + endif + if (opts.use_color < 0) + [objs_with_color, color_of_objs] = convert_color2mono (gcf); + endif + if (opts.append_to_file) + appended_file_name = opts.name; + if (index(termn, "pdf")) + opts.name = cstrcat (tmpnam, ".pdf"); + temp_name = cstrcat (tmpnam, ".pdf"); + ghostscript_device = "pdfwrite"; + else + opts.name = cstrcat (tmpnam, ".ps"); + temp_name = cstrcat (tmpnam, ".ps"); + ghostscript_device = "pswrite"; + endif + endif + if (opts.debug) + drawnow (new_terminal, opts.name, mono, debug_file); + else + drawnow (new_terminal, opts.name, mono); + endif + if (opts.append_to_file) + ghostscript_options = "-q -dBATCH -dSAFER -dNOPAUSE"; + command = sprintf ("%s %s -sDEVICE=%s -sOutputFile=%s %s %s -q", ... + ghostscript_binary, ghostscript_options, ghostscript_device, ... + temp_name, appended_file_name, opts.name); + status1 = system (command); + status2 = system (sprintf ("mv %s %s", temp_name, appended_file_name)); + if (status1 != 0 || status2 != 0) + error ("print: output failed to append to '%s'.", appended_file_name); + endif + endif + unwind_protect_cleanup + ## FIXME - it would be nice to delete "__pixels_per_inch__" property here. + if (restore_properties) + props = fieldnames (p); + for n = 1:numel(props) + set (gcf, props{n}, p.(props{n})) + endfor + endif + if (opts.use_color < 0) + convert_mono_to_or_from_color (objs_with_color, color_of_objs, false); + endif + end_unwind_protect + + if (! isempty (ghostscript_output)) + if (is_eps_file && tight_flag) + ## If gnuplot's output is an eps-file then crop at the bounding box. + fix_eps_bbox (name, ghostscript_binary); + endif + ghostscript_options = "-q -dBATCH -dSAFER -dNOPAUSE -dTextAlphaBits=4"; + if (is_eps_file) + ghostscript_options = sprintf ("%s -dEPSCrop", ghostscript_options); + endif + if (isempty (strfind (lower (ghostscript_device), "write"))) + ## If output is a bitmap then include the resolution + ghostscript_options = sprintf ("%s -r%d", ghostscript_options, opts.resolution); + endif + ghostscript_options = sprintf ("%s -sDEVICE=%s", ghostscript_options, + ghostscript_device); + command = sprintf ("\"%s\" %s -sOutputFile=\"%s\" \"%s\" 2>&1", ghostscript_binary, + ghostscript_options, ghostscript_output, opts.name); + [errcode, output] = system (command); + unlink (name); + if (errcode) + error ("print: Conversion failed, %s -> %s.\nError was:\n%s\n", + name, ghostscript_output, output); + endif + elseif (is_eps_file && opts.tight_flag && ! doprint) + ## If the saved output file is an eps file, use ghostscript to set a tight bbox. + ## This may result in a smaller or larger bbox geometry. + if (have_ghostscript) + fix_eps_bbox (name, ghostscript_binary); + endif + endif + + if (doprint) + if (isunix ()) + prn_opt = "-l"; + elseif (ispc ()) + prn_opt = "-o l"; + else + ## FIXME - besides Unix and Windows, what other OS's might be considered. + prn_opt = ""; + endif + if (isempty (printer)) + prn_cmd = sprintf ("lpr %s '%s' 2>&1", prn_opt, printname); + else + prn_cmd = sprintf ("lpr %s -P %s '%s' 2>&1", prn_opt, printer, printname); + endif + [status, output] = system (prn_cmd); + if (status != 0) + disp (output) + warning ("print.m: printing failed.") + endif + [status, output] = unlink (printname); + if (status != 0) + disp (output) + warning ("print.m: failed to delete temporay file, '%s'.", printname) + endif + endif + + unwind_protect_cleanup + if (isfigure (old_fig)) + figure (old_fig) + endif + end_unwind_protect + +endfunction + +function bb = fix_eps_bbox (eps_file_name, ghostscript_binary) + + persistent warn_on_no_ghostscript = true + + box_string = "%%BoundingBox:"; + + ghostscript_options = "-q -dBATCH -dSAFER -dNOPAUSE -dTextAlphaBits=4 -sDEVICE=bbox"; + cmd = sprintf ("\"%s\" %s \"%s\" 2>&1", ghostscript_binary, + ghostscript_options, eps_file_name); + [status, output] = system (cmd); + + if (status == 0) + + pattern = strcat (box_string, "[^%]*"); + pattern = pattern(1:find(double(pattern)>32, 1, "last")); + bbox_line = regexp (output, pattern, "match"); + if (iscell (bbox_line)) + bbox_line = bbox_line{1}; + endif + ## Remore the EOL characters. + bbox_line(double(bbox_line)<32) = ""; + + fid = fopen (eps_file_name, "r+"); + unwind_protect + bbox_replaced = false; + while (! bbox_replaced) + current_line = fgetl (fid); + if (strncmpi (current_line, box_string, numel(box_string))) + line_length = numel (current_line); + num_spaces = line_length - numel (bbox_line); + if (numel (current_line) < numel (bbox_line)) + ## If there new line is longer, continue with the current line. + new_line = current_line; + else + new_line = bbox_line; + new_line(end+1:numel(current_line)) = " "; + endif + ## Back up to the beginning of the line (include EOL characters). + if (ispc ()) + fseek (fid, -line_length-2, "cof"); + else + fseek (fid, -line_length-1, "cof"); + endif + count = fprintf (fid, "%s", new_line); + bbox_replaced = true; + elseif (! ischar (current_line)) + bbox_replaced = true; + warning ("print.m: no bounding box found in '%s'.", eps_file_name) + endif + endwhile + unwind_protect_cleanup + fclose (fid); + end_unwind_protect + elseif (warn_on_no_ghostscript) + warn_on_no_ghostscript = false; + warning ("print.m: Ghostscript failed to determine the bounding box.\nError was:\n%s\n", output) + endif + +endfunction + +function [h, c] = convert_color2mono (hfig) + unwind_protect + showhiddenhandles = get (0, "showhiddenhandles"); + set (0, "showhiddenhandles", "on"); + h.color = findobj (hfig, "-property", "color"); + h.facecolor = findobj (hfig, "-property", "facecolor"); + h.edgecolor = findobj (hfig, "-property", "edgecolor"); + h.backgroundcolor = findobj (hfig, "-property", "backgroundcolor"); + h.colormap = findobj (hfig, "-property", "colormap"); + unwind_protect_cleanup + set (0, "showhiddenhandles", showhiddenhandles); + end_unwind_protect + f = fieldnames (h); + for nf = 1:numel(f) + if (! isempty (h.(f{nf}))) + v = get (h.(f{nf}), f{nf}); + if (! iscell (v)) + v = {v}; + endif + c.(f{nf}) = v; + endif + endfor + convert_mono_to_or_from_color (h, c, true) +endfunction + +function convert_mono_to_or_from_color (h, c, mono) + f = fieldnames (h); + for nf = 1:numel(f) + for nh = 1:numel (h.(f{nf})) + color = c.(f{nf}){nh}; + ## Ignore color == {"none", "flat", ...} + if (isfloat (color)) + if (mono) + ## Same method as used by rgb2gray in the image pkg. + color = rgb2ntsc (color)(:,1) * ones (1, 3); + endif + set (h.(f{nf})(nh), f{nf}, color); + endif + endfor + endfor +endfunction + diff -r 58c1b5402588 -r d699a6c63263 scripts/plot/__go_draw_figure__.m --- a/scripts/plot/__go_draw_figure__.m Thu Jun 24 10:14:44 2010 +0200 +++ b/scripts/plot/__go_draw_figure__.m Thu Jun 24 10:16:23 2010 +0200 @@ -92,6 +92,9 @@ else fg_is_set = false; endif + if (bg_is_set) + fprintf (plot_stream, "set border linecolor rgb \"#%02x%02x%02x\"\n", 255 * (1 - bg)); + endif if (output_to_paper) axes_position_on_page = orig_axes_position .* paper_position([3, 4, 3 ,4]); axes_position_on_page(1:2) = axes_position_on_page(1:2) + paper_position(1:2); diff -r 58c1b5402588 -r d699a6c63263 scripts/plot/__print_parse_opts__.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/plot/__print_parse_opts__.m Thu Jun 24 10:16:23 2010 +0200 @@ -0,0 +1,116 @@ +## Copyright (C) 2008, 2009 David Bateman +## +## 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 3 of the License, 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, see +## . + +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{x}, @var{y}, @var{buttons}] =} ginput (@var{n}) +## Return which mouse buttons were pressed and keys were hit on the current +## figure. If @var{n} is defined, then wait for @var{n} mouse clicks +## before returning. If @var{n} is not defined, then @code{ginput} will +## loop until the return key is pressed. +## @end deftypefn + +function arg_st = __print_parse_opts__ (varargin) + + arg_st.orientation = ""; + arg_st.use_color = 0; # 0=default, -1=mono, +1=color + arg_st.append_to_file = 0; + arg_st.force_solid = 0; # 0=default, -1=dashed, +1=solid + arg_st.fontsize = ""; + arg_st.font = ""; + arg_st.canvas_size = ""; + arg_st.name = ""; + arg_st.devopt = ""; + arg_st.printer = ""; + arg_st.debug = false; + arg_st.debug_file = "octave-print-commands.log"; + arg_st.special_flag = "textnormal"; + arg_st.tight_flag = false; + arg_st.resolution = ""; + + old_fig = get (0, "currentfigure"); + + unwind_protect + for i = 1:nargin + arg = varargin{i}; + if (ischar (arg)) + if (strcmp (arg, "-color")) + arg_st.use_color = 1; + elseif (strcmp (arg, "-append")) + arg_st.append_to_file = 1; + elseif (strcmp (arg, "-mono")) + arg_st.use_color = -1; + elseif (strcmp (arg, "-solid")) + arg_st.force_solid = 1; + elseif (strcmp (arg, "-dashed")) + arg_st.force_solid = -1; + elseif (strcmp (arg, "-portrait")) + arg_st.orientation = "portrait"; + elseif (strcmp (arg, "-landscape")) + arg_st.orientation = "landscape"; + elseif (strcmp (arg, "-tight")) + arg_st.tight_flag = true; + elseif (strcmp (arg, "-textspecial")) + arg_st.special_flag = "textspecial"; + elseif (strncmp (arg, "-debug", 6)) + arg_st.debug = true; + if (length (arg) > 7) + arg_st.debug_file = arg(8:end); + endif + elseif (length (arg) > 2 && arg(1:2) == "-d") + arg_st.devopt = tolower(arg(3:end)); + elseif (length (arg) > 2 && arg(1:2) == "-P") + arg_st.printer = arg; + elseif ((length (arg) > 2) && arg(1:2) == "-G") + arg_st.ghostscript_binary = arg(3:end); + if (exist (arg_st.ghostscript_binary, "file") != 2) + arg_st.ghostscript_binary = file_in_path (EXEC_PATH, arg_st.ghostscript_binary); + endif + if (isempty (arg_st.ghostscript_binary)) + error ("print: Ghostscript binary ""%s"" could not be located", arg(3:end)) + endif + elseif (length (arg) > 2 && arg(1:2) == "-F") + idx = rindex (arg, ":"); + if (idx) + arg_st.font = arg(3:idx-1); + arg_st.fontsize = arg(idx+1:length(arg)); + else + arg_st.font = arg(3:length(arg)); + endif + elseif (length (arg) > 2 && arg(1:2) == "-S") + arg_st.canvas_size = arg(3:length(arg)); + elseif (length (arg) > 2 && arg(1:2) == "-r") + arg_st.resolution = arg(3:length(arg)); + elseif (length (arg) >= 1 && arg(1) == "-") + error ("print: unknown option `%s'", arg); + elseif (length (arg) > 0) + arg_st.name = arg; + endif + elseif (isfigure (arg)) + arg_st.figure (arg); + else + error ("print: expecting inputs to be character string options or a figure handle"); + endif + endfor + unwind_protect_cleanup + if (isfigure (old_fig)) + figure (old_fig) + endif + end_unwind_protect + +endfunction + diff -r 58c1b5402588 -r d699a6c63263 scripts/plot/module.mk --- a/scripts/plot/module.mk Thu Jun 24 10:14:44 2010 +0200 +++ b/scripts/plot/module.mk Thu Jun 24 10:16:23 2010 +0200 @@ -124,6 +124,9 @@ plot/plotyy.m \ plot/polar.m \ plot/print.m \ + plot/__gnuplot_print__.m \ + plot/__fltk_print__.m \ + plot/__print_parse_opts__.m \ plot/quiver.m \ plot/quiver3.m \ plot/refresh.m \ @@ -157,6 +160,7 @@ plot/title.m \ plot/view.m \ plot/waitforbuttonpress.m \ + plot/whitebg.m \ plot/xlabel.m \ plot/xlim.m \ plot/ylabel.m \ diff -r 58c1b5402588 -r d699a6c63263 scripts/plot/print.m --- a/scripts/plot/print.m Thu Jun 24 10:14:44 2010 +0200 +++ b/scripts/plot/print.m Thu Jun 24 10:16:23 2010 +0200 @@ -1,5 +1,4 @@ -## Copyright (C) 1999, 2005, 2006, 2007, 2008, 2009 Daniel Heiserer -## Copyright (C) 2001 Laurent Mazet +## Copyright (C) 2008, 2009 David Bateman ## ## This file is part of Octave. ## @@ -175,714 +174,13 @@ ## The filename and options can be given in any order. ## @end deftypefn -## Author: Daniel Heiserer -## Adapted-By: jwe - -function print (varargin) - - persistent warn_on_inconsistent_orientation = true - orientation = ""; - use_color = 0; # 0=default, -1=mono, +1=color - append_to_file = 0; - force_solid = 0; # 0=default, -1=dashed, +1=solid - fontsize = ""; - font = ""; - canvas_size = ""; - name = ""; - devopt = ""; - printer = ""; - debug = false; - debug_file = "octave-print-commands.log"; - special_flag = "textnormal"; - tight_flag = false; - resolution = ""; - - persistent ghostscript_binary = ""; - if (isempty (ghostscript_binary)) - ghostscript_binary = getenv ("GSC"); - ng = 0; - if (isunix ()) - ## Unix - Includes Mac OSX and Cygwin. - gs_binaries = {"gs", "gs.exe"}; - else - ## pc - Includes Win32 and mingw. - gs_binaries = {"gs.exe", "gswin32c.exe"}; - endif - while (ng < numel (gs_binaries) && isempty (ghostscript_binary)) - ng = ng + 1; - ghostscript_binary = file_in_path (EXEC_PATH, gs_binaries{ng}); - endwhile - endif - - old_fig = get (0, "currentfigure"); - unwind_protect - ## Ensure the last figure is on the screen for single line commands like - ## plot(...); print(...); - drawnow (); - - for i = 1:nargin - arg = varargin{i}; - if (ischar (arg)) - if (strcmp (arg, "-color")) - use_color = 1; - elseif (strcmp (arg, "-append")) - append_to_file = 1; - elseif (strcmp (arg, "-mono")) - use_color = -1; - elseif (strcmp (arg, "-solid")) - force_solid = 1; - elseif (strcmp (arg, "-dashed")) - force_solid = -1; - elseif (strcmp (arg, "-portrait")) - orientation = "portrait"; - elseif (strcmp (arg, "-landscape")) - orientation = "landscape"; - elseif (strcmp (arg, "-tight")) - tight_flag = true; - elseif (strcmp (arg, "-textspecial")) - special_flag = "textspecial"; - elseif (strncmp (arg, "-debug", 6)) - debug = true; - if (length (arg) > 7) - debug_file = arg(8:end); - endif - elseif (length (arg) > 2 && arg(1:2) == "-d") - devopt = tolower(arg(3:end)); - elseif (length (arg) > 2 && arg(1:2) == "-P") - printer = arg; - elseif ((length (arg) > 2) && arg(1:2) == "-G") - ghostscript_binary = arg(3:end); - if (exist (ghostscript_binary, "file") != 2) - ghostscript_binary = file_in_path (EXEC_PATH, ghostscript_binary); - endif - if (isempty (ghostscript_binary)) - error ("print: Ghostscript binary ""%s"" could not be located", arg(3:end)) - endif - elseif (length (arg) > 2 && arg(1:2) == "-F") - idx = rindex (arg, ":"); - if (idx) - font = arg(3:idx-1); - fontsize = arg(idx+1:length(arg)); - else - font = arg(3:length(arg)); - endif - elseif (length (arg) > 2 && arg(1:2) == "-S") - canvas_size = arg(3:length(arg)); - elseif (length (arg) > 2 && arg(1:2) == "-r") - resolution = arg(3:length(arg)); - elseif (length (arg) >= 1 && arg(1) == "-") - error ("print: unknown option `%s'", arg); - elseif (length (arg) > 0) - name = arg; - endif - elseif (isfigure (arg)) - figure (arg); - else - error ("print: expecting inputs to be character string options or a figure handle"); - endif - endfor - - have_ghostscript = (exist (ghostscript_binary, "file") == 2); - - doprint = isempty (name); - if (doprint) - if (isempty (devopt)) - if (use_color < 0) - devopt = "ps"; - printname = cstrcat (tmpnam, ".ps"); - else - devopt = "psc"; - printname = cstrcat (tmpnam, ".psc"); - endif - else - printname = cstrcat (tmpnam, ".", devopt); - endif - name = printname; - endif - - dot = rindex (name, "."); - if (isempty (devopt)) - if (dot == 0) - error ("print: no format specified"); - else - dev = tolower (name(dot+1:end)); - endif - else - dev = devopt; - endif - - dev_list = {"aifm", "corel", "fig", "png", "jpeg", ... - "gif", "pbm", "dxf", "mf", "svg", "hpgl", ... - "ps", "ps2", "psc", "psc2", "eps", "eps2", ... - "epsc", "epsc2", "emf", "pdf", "pslatex", ... - "epslatex", "epslatexstandalone", "pstex", "tikz"}; - suffixes = {"ai", "cdr", "fig", "png", "jpeg", ... - "gif", "pbm", "dxf", "mf", "svg", "hpgl", ... - "ps", "ps", "ps", "ps", "eps", "eps", ... - "eps", "eps", "emf", "pdf", "tex", ... - "tex", "tex", "tex", "tikz"}; - if (dot == 0) - name = strcat (name, ".", suffixes {strcmpi (dev_list, dev)}); - dot = rindex (name, "."); - endif - - if (append_to_file) - if (any (strcmpi (dev, {"ps", "ps2", "psc", "psc2", "pdf"}))) - if (have_ghostscript) - file_exists = ((numel (dir (name)) == 1) && (! isdir (name))); - if (! file_exists) - append_to_file = 0; - end - end - else - warning ("print.m: appended output is not supported for device '%s'", dev) - append_to_file = 0; - endif - endif - - if (strcmp (dev, "tex")) - dev = "epslatex"; - elseif (strcmp (dev, "ill")) - dev = "aifm"; - elseif (strcmp (dev, "cdr")) - dev = "corel"; - elseif (strcmp (dev, "meta")) - dev = "emf"; - elseif (strcmp (dev, "jpg")) - dev = "jpeg"; - endif - - if (strcmp (dev, "epslatex")) - ## gnuplot 4.0 wants ".eps" in the output name - if (! __gnuplot_has_feature__ ("epslatex_implies_eps_filesuffix")) - name = cstrcat (name(1:dot), "eps"); - endif - endif - - ## Check if the specified device is one that is supported by gnuplot. - ## If not, assume it is a device/format supported by Ghostscript. - if (! any (strcmp (dev, dev_list)) && have_ghostscript) - ghostscript_output = name; - ghostscript_device = dev; - if (doprint) - ## If printing, use color postscript. - dev = "psc"; - name = cstrcat (tmpnam, ".ps"); - else - ## If saving to a file, use color encapsulated postscript. - dev = "epsc"; - name = cstrcat (tmpnam, ".eps"); - endif - elseif (doprint && all (! strcmpi (suffixes {strcmpi (dev_list, dev)}, - {"ps", "eps", "hpgl"}))) - ## When not using Ghostscript, verify the format is compatible with - ## hard copy output. - error ("print: missing file name, or invalid print format."); - else - ghostscript_output = ""; - endif - - termn = dev; - - ## SVG isn't actually a bitmap, but gnuplot treats its size option as it - ## does the bitmap terminals. - bitmap_devices = {"emf", "gif", "jpeg", "pbm", "png", "svg"}; - - if (any (strcmp (dev, {"ps", "ps2", "psc", "psc2", "epsc", "epsc2", ... - "eps", "eps2", "pstex", "pslatex", "epslatex", ... - "epslatexstandalone"}))) - - ## Various postscript options - if (any (strcmp (dev, {"pstex", "pslatex", "epslatex"}))) - options = ""; - elseif (strcmp (dev, "epslatexstandalone")) - if (__gnuplot_has_feature__ ("epslatexstandalone_terminal")) - termn = "epslatex"; - options = "standalone "; - else - error ("print: epslatexstandalone needs gnuplot 4.2 or higher"); - endif - else - if (dev(1) == "e") - options = "eps "; - else - options = ""; - endif - termn = "postscript"; - endif - - if (any (dev == "c") || use_color > 0 - || (! isempty (strfind (dev, "tex")) && use_color == 0)) - use_color = 1; - else - use_color = -1; - endif - - if (use_color > 0) - if (force_solid < 0) - options = cstrcat (options, "color dashed "); - else - options = cstrcat (options, "color solid "); - endif - else - if (force_solid > 0) - options = cstrcat (options, "mono solid "); - else - options = cstrcat (options, "mono dashed "); - endif - endif - - if (! isempty (font)) - options = cstrcat (options, "\"", font, "\" "); - endif - if (! isempty (fontsize)) - options = cstrcat (options, " ", fontsize); - endif - - elseif (strcmp (dev, "tikz")) - if (! isempty (font) && ! isempty (fontsize)) - options = cstrcat (options, "\"", font, ",", fontsize, "\" "); - elseif (! isempty (font)) - options = cstrcat (options, "\"", font, "\" "); - else - options = ""; - endif - - elseif (strcmp (dev, "aifm") || strcmp (dev, "corel")) - ## Adobe Illustrator, CorelDraw - if (use_color >= 0) - options = " color"; - else - options = " mono"; - endif - if (! isempty (font)) - options = cstrcat (options, " \"", font, "\""); - endif - if (! isempty (fontsize)) - options = cstrcat (options, " ", fontsize); - endif - - elseif (strcmp (dev, "fig")) - ## XFig - options = orientation; - if (use_color >= 0) - options = " color"; - else - options = " mono"; - endif - options = cstrcat (options, " ", special_flag); - if (! isempty (fontsize)) - options = cstrcat (options, " fontsize ", fontsize); - endif +function varargout = print (varargin) - elseif (strcmp (dev, "emf")) - ## Enhanced Metafile format - options = " "; - if (use_color >= 0) - options = " color"; - else - options = " mono"; - endif - if (force_solid >= 0) - options = cstrcat (options, " solid"); - endif - if (! isempty (font)) - options = cstrcat (options, " \"", font, "\""); - endif - if (! isempty (fontsize)) - options = cstrcat (options, " ", fontsize); - endif - - elseif (any (strcmp (dev, bitmap_devices))) - - if (isempty (canvas_size) && isempty (resolution) - && any (strcmp (dev, {"pbm", "gif", "jpeg", "png"}))) - options = ""; - elseif (strcmp (dev, "svg")) - ## Referring to size, either "dynamic" or "fixed" - options = "fixed"; - else - options = ""; - end - if (! isempty (canvas_size)) - options = cstrcat (options, " size ", canvas_size); - endif - - elseif (any (strcmp (dev, {"dxf", "mf", "hpgl"}))) - ## AutoCad DXF, METAFONT, HPGL - options = ""; - - elseif (strcmp (dev, "pdf")) - ## Portable Document format - options = " "; - if (use_color >= 0) - options = "color"; - else - options = "mono"; - endif - if (force_solid >= 0) - options = cstrcat (options, " solid"); - elseif (force_solid < 0) - options = cstrcat (options, " dashed"); - endif - if (! isempty (font)) - options = cstrcat (options, "\"", font, "\" "); - endif - if (! isempty (fontsize)) - options = cstrcat (options, " ", fontsize); - endif - - endif - - if (__gnuplot_has_feature__ ("variable_GPVAL_TERMINALS")) - available_terminals = __gnuplot_get_var__ (gcf, "GPVAL_TERMINALS"); - available_terminals = regexp (available_terminals, "\\b\\w+\\b", "match"); - ## Favor the cairo terminals. - if (strcmp (termn, "pdf") - && any (strcmp (available_terminals, "pdfcairo"))) - termn = "pdfcairo"; - gnuplot_supports_term = true; - elseif (strcmp (termn, "png") - && any (strcmp (available_terminals, "pngcairo"))) - termn = "pngcairo"; - gnuplot_supports_term = true; - else - gnuplot_supports_term = any (strcmp (available_terminals, termn)); - endif - elseif (strcmp (termn, "pdf")) - ## Some Linux variants do not include a "pdf" capable gnuplot. - ## To be safe, use Ghostscript. - if (have_ghostscript) - gnuplot_supports_term = false; - ghostscript_device = "pdfwrite"; - else - gnuplot_supports_term = true; - endif - else - gnuplot_supports_term = true; - endif - - if (! gnuplot_supports_term) - if (strcmp (termn, "pdf")) - ## If there the installed gnuplot does not support pdf, use Ghostscript. - ghostscript_device = "pdfwrite"; - if (strfind (name, ".pdf") == numel (name) - 3) - ghostscript_output = name; - else - ghostscript_output = strcat (name, ".pdf"); - endif - name = cstrcat (tmpnam, ".ps"); - termn = "postscript"; - ## All "options" for pdf work for postscript as well. - else - error ("print: the device, \"%s\", is not available.", dev) - endif - endif - - is_eps_file = strncmp (dev, "eps", 3); - p.units = get (gcf, "units"); - p.paperunits = get (gcf, "paperunits"); - p.papersize = get (gcf, "papersize"); - p.paperposition = get (gcf, "paperposition"); - p.paperpositionmode = get (gcf, "paperpositionmode"); - p.paperorientation = get (gcf, "paperorientation"); - p.color = get (gcf, "color"); - if (p.papersize(1) > p.papersize(2)) - paperorientation = "landscape"; - else - paperorientation = "portrait"; - endif - if (! strcmp (paperorientation, get (gcf, "paperorientation")) - && warn_on_inconsistent_orientation) - msg = {"print.m - inconsistent papersize and paperorientation properties.\n", - sprintf(" papersize = %.2f, %.2f\n", p.papersize), - sprintf(" paperorientation = \"%s\"\n", p.paperorientation), - " the paperorientation property has been ignored"}; - warning ("%s",msg{:}) - warn_on_inconsistent_orientation = false; - endif - - if (strcmp (termn, "postscript") && ! strncmp (dev, "eps", 3)) - if (isempty (orientation)) - orientation = paperorientation; - endif - ## This is done here to accommodate ghostscript conversion. - options = cstrcat (orientation, " ", options); - end - - new_terminal = cstrcat (termn, " ", options); - - mono = (use_color < 0); - - terminals_for_prn = {"postscript", "pdf", "pdfcairo"}; - output_for_printer = any (strncmp (termn, terminals_for_prn, numel(termn))); + f = gcf (); + drawnow (); + backend = (get (f, "__backend__")); - if (isempty (resolution)) - if (any (strcmp (dev, {"emf", "svg"})) || output_for_printer) - resolution = get (0, "screenpixelsperinch"); - else - resolution = 150; - endif - else - resolution = str2num (resolution); - if (resolution == 0) - resolution = get (0, "screenpixelsperinch"); - endif - endif - figure_properties = get (gcf); - if (! isfield (figure_properties, "__pixels_per_inch__")) - addproperty ("__pixels_per_inch__", gcf, "double", resolution); - endif - set (gcf, "__pixels_per_inch__", resolution) - - unwind_protect - set (gcf, "paperunits", "inches"); - set (gcf, "units", "pixels"); - set (gcf, "color", "none"); - restore_properties = true; - if ((! output_for_printer || is_eps_file) && ! doprint) - ## If not PDF or PostScript, and the result is not being sent to a printer, - ## render an image the size of the paperposition box. - ## Trigger the listener to convert all paper props to inches. - if (! isempty (canvas_size)) - size_in_pixels = sscanf (canvas_size ,"%d, %d"); - size_in_pixels = reshape (size_in_pixels, [1, numel(size_in_pixels)]); - papersize_in_inches = size_in_pixels ./ resolution; - paperposition_in_inches = [0, 0, papersize_in_inches]; - else - paperposition_in_inches = get (gcf, "paperposition"); - paperposition_in_inches(1:2) = 0; - papersize_in_inches = paperposition_in_inches(3:4); - endif - set (gcf, "papersize", papersize_in_inches); - set (gcf, "paperposition", paperposition_in_inches); - set (gcf, "paperpositionmode", "manual"); - else - if (strcmp (p.paperpositionmode, "auto")) - size_in_pixels = get (gcf, "position")(3:4); - paperposition_in_inches(3:4) = size_in_pixels ./ resolution; - paperposition_in_inches(1:2) = (p.papersize - paperposition_in_inches(3:4))/2; - else - paperposition_in_inches = p.paperposition; - endif - if (! isempty (orientation) && ! strcmp (orientation, paperorientation)) - ## When -landscape/portrait changes the orientation, flip both the - ## papersize and paperposition. - restore_properties = true; - set (gcf, "papersize", p.papersize([2, 1])); - set (gcf, "paperposition", paperposition_in_inches([2, 1, 4, 3])); - else - set (gcf, "paperposition", paperposition_in_inches); - endif - endif - if (use_color < 0) - [objs_with_color, color_of_objs] = convert_color2mono (gcf); - endif - if (append_to_file) - appended_file_name = name; - if (index(termn, "pdf")) - name = cstrcat (tmpnam, ".pdf"); - temp_name = cstrcat (tmpnam, ".pdf"); - ghostscript_device = "pdfwrite"; - else - name = cstrcat (tmpnam, ".ps"); - temp_name = cstrcat (tmpnam, ".ps"); - ghostscript_device = "pswrite"; - endif - endif - if (debug) - drawnow (new_terminal, name, mono, debug_file); - else - drawnow (new_terminal, name, mono); - endif - if (append_to_file) - ghostscript_options = "-q -dBATCH -dSAFER -dNOPAUSE"; - command = sprintf ("%s %s -sDEVICE=%s -sOutputFile=%s %s %s -q", ... - ghostscript_binary, ghostscript_options, ghostscript_device, ... - temp_name, appended_file_name, name); - status1 = system (command); - status2 = system (sprintf ("mv %s %s", temp_name, appended_file_name)); - if (status1 != 0 || status2 != 0) - error ("print: output failed to append to '%s'.", appended_file_name); - endif - endif - unwind_protect_cleanup - ## FIXME - it would be nice to delete "__pixels_per_inch__" property here. - if (restore_properties) - props = fieldnames (p); - for n = 1:numel(props) - set (gcf, props{n}, p.(props{n})) - endfor - endif - if (use_color < 0) - convert_mono_to_or_from_color (objs_with_color, color_of_objs, false); - endif - end_unwind_protect - - if (! isempty (ghostscript_output)) - if (is_eps_file && tight_flag) - ## If gnuplot's output is an eps-file then crop at the bounding box. - fix_eps_bbox (name, ghostscript_binary); - endif - ghostscript_options = "-q -dBATCH -dSAFER -dNOPAUSE -dTextAlphaBits=4"; - if (is_eps_file) - ghostscript_options = sprintf ("%s -dEPSCrop", ghostscript_options); - endif - if (isempty (strfind (lower (ghostscript_device), "write"))) - ## If output is a bitmap then include the resolution - ghostscript_options = sprintf ("%s -r%d", ghostscript_options, resolution); - endif - ghostscript_options = sprintf ("%s -sDEVICE=%s", ghostscript_options, - ghostscript_device); - command = sprintf ("\"%s\" %s -sOutputFile=\"%s\" \"%s\" 2>&1", ghostscript_binary, - ghostscript_options, ghostscript_output, name); - [errcode, output] = system (command); - unlink (name); - if (errcode) - error ("print: Conversion failed, %s -> %s.\nError was:\n%s\n", - name, ghostscript_output, output); - endif - elseif (is_eps_file && tight_flag && ! doprint) - ## If the saved output file is an eps file, use ghostscript to set a tight bbox. - ## This may result in a smaller or larger bbox geometry. - if (have_ghostscript) - fix_eps_bbox (name, ghostscript_binary); - endif - endif - - if (doprint) - if (isunix ()) - prn_opt = "-l"; - elseif (ispc ()) - prn_opt = "-o l"; - else - ## FIXME - besides Unix and Windows, what other OS's might be considered. - prn_opt = ""; - endif - if (isempty (printer)) - prn_cmd = sprintf ("lpr %s '%s' 2>&1", prn_opt, printname); - else - prn_cmd = sprintf ("lpr %s -P %s '%s' 2>&1", prn_opt, printer, printname); - endif - [status, output] = system (prn_cmd); - if (status != 0) - disp (output) - warning ("print.m: printing failed.") - endif - [status, output] = unlink (printname); - if (status != 0) - disp (output) - warning ("print.m: failed to delete temporay file, '%s'.", printname) - endif - endif - - unwind_protect_cleanup - if (isfigure (old_fig)) - figure (old_fig) - endif - end_unwind_protect + varargout = cell (1, nargout); + [varargout{:}] = feval (strcat ("__", backend, "_print__"), varargin{:}); endfunction - -function bb = fix_eps_bbox (eps_file_name, ghostscript_binary) - - persistent warn_on_no_ghostscript = true - - box_string = "%%BoundingBox:"; - - ghostscript_options = "-q -dBATCH -dSAFER -dNOPAUSE -dTextAlphaBits=4 -sDEVICE=bbox"; - cmd = sprintf ("\"%s\" %s \"%s\" 2>&1", ghostscript_binary, - ghostscript_options, eps_file_name); - [status, output] = system (cmd); - - if (status == 0) - - pattern = strcat (box_string, "[^%]*"); - pattern = pattern(1:find(double(pattern)>32, 1, "last")); - bbox_line = regexp (output, pattern, "match"); - if (iscell (bbox_line)) - bbox_line = bbox_line{1}; - endif - ## Remore the EOL characters. - bbox_line(double(bbox_line)<32) = ""; - - fid = fopen (eps_file_name, "r+"); - unwind_protect - bbox_replaced = false; - while (! bbox_replaced) - current_line = fgetl (fid); - if (strncmpi (current_line, box_string, numel(box_string))) - line_length = numel (current_line); - num_spaces = line_length - numel (bbox_line); - if (numel (current_line) < numel (bbox_line)) - ## If there new line is longer, continue with the current line. - new_line = current_line; - else - new_line = bbox_line; - new_line(end+1:numel(current_line)) = " "; - endif - ## Back up to the beginning of the line (include EOL characters). - if (ispc ()) - fseek (fid, -line_length-2, "cof"); - else - fseek (fid, -line_length-1, "cof"); - endif - count = fprintf (fid, "%s", new_line); - bbox_replaced = true; - elseif (! ischar (current_line)) - bbox_replaced = true; - warning ("print.m: no bounding box found in '%s'.", eps_file_name) - endif - endwhile - unwind_protect_cleanup - fclose (fid); - end_unwind_protect - elseif (warn_on_no_ghostscript) - warn_on_no_ghostscript = false; - warning ("print.m: Ghostscript failed to determine the bounding box.\nError was:\n%s\n", output) - endif - -endfunction - -function [h, c] = convert_color2mono (hfig) - unwind_protect - showhiddenhandles = get (0, "showhiddenhandles"); - set (0, "showhiddenhandles", "on"); - h.color = findobj (hfig, "-property", "color"); - h.facecolor = findobj (hfig, "-property", "facecolor"); - h.edgecolor = findobj (hfig, "-property", "edgecolor"); - h.backgroundcolor = findobj (hfig, "-property", "backgroundcolor"); - h.colormap = findobj (hfig, "-property", "colormap"); - unwind_protect_cleanup - set (0, "showhiddenhandles", showhiddenhandles); - end_unwind_protect - f = fieldnames (h); - for nf = 1:numel(f) - if (! isempty (h.(f{nf}))) - v = get (h.(f{nf}), f{nf}); - if (! iscell (v)) - v = {v}; - endif - c.(f{nf}) = v; - endif - endfor - convert_mono_to_or_from_color (h, c, true) -endfunction - -function convert_mono_to_or_from_color (h, c, mono) - f = fieldnames (h); - for nf = 1:numel(f) - for nh = 1:numel (h.(f{nf})) - color = c.(f{nf}){nh}; - ## Ignore color == {"none", "flat", ...} - if (isfloat (color)) - if (mono) - ## Same method as used by rgb2gray in the image pkg. - color = rgb2ntsc (color)(:,1) * ones (1, 3); - endif - set (h.(f{nf})(nh), f{nf}, color); - endif - endfor - endfor -endfunction - diff -r 58c1b5402588 -r d699a6c63263 scripts/plot/whitebg.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/plot/whitebg.m Thu Jun 24 10:16:23 2010 +0200 @@ -0,0 +1,143 @@ +## Copyright (C) 2010 David Bateman +## +## 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 3 of the License, 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, see +## . + +## -*- texinfo -*- +## @deftypefn {Function File} {} whitebg () +## @deftypefnx {Function File} {} whitebg (@var{color}) +## @deftypefnx {Function File} {} whitebg (@var{fig}) +## @deftypefnx {Function File} {} whitebg (@var{fig}, @var{color}) +## Inverts the colors in the current current. The root properties are +## also inverted such that all subsequent plot use the new color scheme. +## +## If defined, @var{fig} is the handle to the figure to be inverted. In +## this case only this figure has its color properties changed +## +## The background colors of the figure and its children can be set +## specifically if @var{color} is defined. @var{color} must be a valid +## color set as a string or an RGB triplet, or the value "none". +## +## @seealso{reset, colordef} +## @end deftypefn + +function whitebg (varargin) + h = 0; + color = NaN; + + if (nargin > 0 && nargin < 2) + if (ishandle (varargin{1})) + h = varargin{1}; + if (nargin == 2) + color = varargin{2}; + endif + elseif (nargin == 1) + color = varargin{1}; + else + print_usage (); + endif + elseif (nargin != 0) + print_usage (); + endif + + typ = get (h, "type"); + + if (strcmp (typ, "root")) + isroot = true; + fig = gcf (); + elseif (strcmp (typ, "figure")) + isroot = false; + fig = h; + else + error ("expecting a figure handle"); + endif + + axes = findall (fig, "type", "axes"); + if (isnan (color)) + ## Root figure. Set the default axes and figure properties so that + ## subsequent plots have the new color scheme + if (isroot) + fac = get (0, "factory"); + fields = fieldnames (fac); + fieldindex = intersect (find (!cellfun (@isempty, regexp(fields, ".*color.*"))), union (find (!cellfun (@isempty, regexp(fields, "factoryaxes.*"))), find (!cellfun (@isempty, regexp(fields, "factoryfigure.*"))))); + + ## Check whether the factory value has been replaced + for nf = 1 : numel (fieldindex); + defaultfield = strrep (fields {fieldindex (nf)}, "factory", "default"); + try + defaultvalue = 1 - get (0, defaultfield {n}); + catch + field = fields {fieldindex (nf)}; + defaultvalue = 1 - subsref (fac, struct ("type", ".", "subs", field)); + end_try_catch + set (0, defaultfield, defaultvalue); + endfor + endif + + ## Load all objects which qualify for being searched. + handles = fig; + h = fig; + while (numel (handles)) + children = []; + for n = 1 : numel (handles) + children = union (children, get(handles(n), "children")); + endfor + handles = children; + h = union (h, children); + endwhile + + for nh = 1 : numel(h) + p = get (h (nh)); + fields = fieldnames (p); + fieldindex = find (!cellfun (@isempty, regexp(fields, ".*color.*"))); + if (numel (fieldindex)) + for nf = 1 : numel (fieldindex); + field = fields {fieldindex (nf)}; + c = subsref (p, struct ("type", ".", "subs", field)); + if (! ischar(c) && columns(c) == 3) + set (h (nh), field, 1 - c); + endif + endfor + endif + + ## If h(nh) is a figure or axes invert default color properties + typ = subsref (p, struct ("type", ".", "subs", "type")); + if (strcmp (typ, "axes") || strcmp (typ, "figure")) + def = get (h (nh), "default"); + fields = fieldnames (def); + if (! isempty (fields)) + fieldindex = find (!cellfun (@isempty, regexp(fields, ".*color.*"))); + for nf = 1 : numel (fieldindex) + defaultfield = fields {fieldindex (nf)}; + defaultvalue = 1 - subsref (def, struct ("type", ".", "subs", defaultfield)); + set (h (nh), defaultfield, defaultvalue); + endfor + endif + endif + endfor + else + ## FIXME + ## Is this the right thing to do in this case? + set (findall (fig, "type", "axes"), "color", color); + if (isroot) + defs = get (0, "defaults"); + if (isfield (defs, "defaultaxescolor") + && strcmp (defs.defaultaxescolor, "none")) + set (0, "defaultaxescolor", color); + endif + endif + endif +endfunction diff -r 58c1b5402588 -r d699a6c63263 src/ChangeLog --- a/src/ChangeLog Thu Jun 24 10:14:44 2010 +0200 +++ b/src/ChangeLog Thu Jun 24 10:16:23 2010 +0200 @@ -15,9 +15,24 @@ * ov-class.h (octave_class::old_map_value): New override. * ov-class.cc: Use old_map_value for efficiency. +2010-06-23 David Bateman + + * graphics.cc (void root_figure::reset_default_properties (void), + void figure::reset_default_properties (void), + void figure::reset_default_properties (void), + Freset): New functions. + * graphics.h.in (void graphics_object:reset_default_properies (void), + virtual void base_graphics_object:reset_default_properies (void)): + New functions. + (void root_figure::reset_default_properties (void), + void figure::reset_default_properties (void), + void figure::reset_default_properties (void)): Declarations. + (std::string color_property::values_as_string (void) const, + Cell color_property::values_as_cell (void) const): New functions. + 2010-06-21 Rik - * DLD-FUNCTIONS/dlmread.cc: Fix spreadsheet style range option. + * DLD-FUNCTIONS/dlmread.cc: Fix spreadsheet style range option. (bug #30183). 2010-06-21 David Bateman @@ -67,11 +82,11 @@ 2010-06-16 Rik - * DLD-FUNCTIONS/cellfun.cc, DLD-FUNCTIONS/dot.cc, - DLD-FUNCTIONS/gammainc.cc, DLD-FUNCTIONS/lookup.cc, + * DLD-FUNCTIONS/cellfun.cc, DLD-FUNCTIONS/dot.cc, + DLD-FUNCTIONS/gammainc.cc, DLD-FUNCTIONS/lookup.cc, DLD-FUNCTIONS/lu.cc, DLD-FUNCTIONS/luinc.cc, DLD-FUNCTIONS/onCleanup.cc, DLD-FUNCTIONS/sparse.cc, DLD-FUNCTIONS/spparms.cc, DLD-FUNCTIONS/svd.cc, - data.cc, dirfns.cc, graphics.cc, mappers.cc, ov-cell.cc, ov-range.cc: + data.cc, dirfns.cc, graphics.cc, mappers.cc, ov-cell.cc, ov-range.cc: Periodic grammar check of documentation to ensure a common format. 2010-06-11 David Bateman @@ -129,9 +144,9 @@ 2010-06-08 Rik - * DLD-FUNCTIONS/bsxfun.cc, DLD-FUNCTIONS/cellfun.cc, - DLD-FUNCTIONS/det.cc, DLD-FUNCTIONS/lookup.cc, DLD-FUNCTIONS/lu.cc, - DLD-FUNCTIONS/rand.cc, DLD-FUNCTIONS/svd.cc, DLD-FUNCTIONS/tril.cc, + * DLD-FUNCTIONS/bsxfun.cc, DLD-FUNCTIONS/cellfun.cc, + DLD-FUNCTIONS/det.cc, DLD-FUNCTIONS/lookup.cc, DLD-FUNCTIONS/lu.cc, + DLD-FUNCTIONS/rand.cc, DLD-FUNCTIONS/svd.cc, DLD-FUNCTIONS/tril.cc, data.cc, ov.cc: Improve documentation string. 2010-06-06 Michael Goffioul @@ -278,7 +293,7 @@ 2010-05-13 Jaroslav Hajek * load-save.cc (install_loaded_variable): Pre-extract symbol record - reference to do all operations. + reference to do all operations. 2010-05-11 David Bateman @@ -299,7 +314,7 @@ 2010-05-10 Rik - * DLD-FUNCTIONS/qr.cc: Split qrdelete test into high precision test + * DLD-FUNCTIONS/qr.cc: Split qrdelete test into high precision test when QRUPDATE is present and low precision when it is not. 2010-05-10 Jaroslav Hajek @@ -383,7 +398,7 @@ 2010-05-02 Rik - * ov-cell.cc: Wrap documentation line to prevent overfull hbox + * ov-cell.cc: Wrap documentation line to prevent overfull hbox LaTex warning 2010-05-01 Ben Abbott @@ -777,12 +792,12 @@ 2010-03-09 Jaroslav Hajek - * ov-intx.h + * ov-intx.h (OCTAVE_INT_NDARRAY_T::convert_gripe): Remove method. (OCTAVE_INT_NDARRAY_T): Remove all uses. (OCTAVE_INT_T::convert_gripe): Remove method. (OCTAVE_INT_T): Remove all uses. - * ov.cc (convert_to_int_array, convert_to_octave_idx_type_array): + * ov.cc (convert_to_int_array, convert_to_octave_idx_type_array): Remove int conversion warnings. * data.cc (NATIVE_REDUCTION_1): Ditto. @@ -1938,7 +1953,7 @@ 2010-01-14 Jaroslav Hajek - * strfns.cc (do_strcmp_fun, + * strfns.cc (do_strcmp_fun, strcmp_array_op, strcmp_str_op, strcmpi_array_op, strcmpi_str_op, strncmp_array_op, strncmp_str_op, @@ -2105,7 +2120,7 @@ * ls-mat5.cc (read_mat5_binary_element): Ditto. * mex.cc (call_mex, mexGetVariable): Ditto. * oct-hist.cc (do_edit_history, do_run_history): Ditto. - * octave.cc (execute_startup_files, execute_eval_option_code, + * octave.cc (execute_startup_files, execute_eval_option_code, execute_command_line_file): Ditto. * ov-builtin.cc (octave_builtin::do_multi_index_op): Ditto. * ov-class.cc (octave_class::subsasgn, octave_class::print_raw): @@ -2150,7 +2165,7 @@ * DLD-FUNCTIONS/quad.cc (Fquad): Ditto. * DLD-FUNCTIONS/rand.cc (Frandn, Frande, Frandg, Frandp): Ditto. * DLD-FUNCTIONS/typecast.cc (get_data_and_bytesize, Ftypecast): Ditto. - * DLD-FUNCTIONS/urlwrite.cc (Furlwrite, mput_directory, + * DLD-FUNCTIONS/urlwrite.cc (Furlwrite, mput_directory, getallfiles, F__ftp_mget__): Ditto. 2010-01-05 Jaroslav Hajek @@ -2233,7 +2248,7 @@ * ov.cc (decode_subscripts): Move to utils.cc. * utils.cc (decode_subscripts): New func. * utils.h: Declare it. - * DLD-FUNCTIONS/cellfun.cc (Fcellfun): Optimize the + * DLD-FUNCTIONS/cellfun.cc (Fcellfun): Optimize the `cellfun (@subsref, args, {subs}, "uniformoutput", true)' case. 2009-12-26 Jaroslav Hajek diff -r 58c1b5402588 -r d699a6c63263 src/graphics.cc --- a/src/graphics.cc Thu Jun 24 10:14:44 2010 +0200 +++ b/src/graphics.cc Thu Jun 24 10:16:23 2010 +0200 @@ -2625,6 +2625,34 @@ property_list root_figure::factory_properties = root_figure::init_factory_properties (); +void +root_figure::reset_default_properties (void) +{ + property_list new_defaults; + + for (property_list::plist_map_const_iterator p = default_properties.begin (); + p != default_properties.end (); p++) + { + const property_list::pval_map_type pval_map = p->second; + std::string prefix = p->first; + + for (property_list::pval_map_const_iterator q = pval_map.begin (); + q != pval_map.end (); + q++) + { + std::string s = q->first; + + if (prefix == "axes" && (s == "position" || s == "units")) + new_defaults.set (prefix + s, q->second); + else if (prefix == "figure" && (s == "position" || s == "units" + || s == "windowstyle" + || s == "paperunits")) + new_defaults.set (prefix + s, q->second); + } + } + default_properties = new_defaults; +} + // --------------------------------------------------------------------- void @@ -2769,6 +2797,34 @@ return retval; } +void +figure::reset_default_properties (void) +{ + property_list new_defaults; + + for (property_list::plist_map_const_iterator p = default_properties.begin (); + p != default_properties.end (); p++) + { + const property_list::pval_map_type pval_map = p->second; + std::string prefix = p->first; + + for (property_list::pval_map_const_iterator q = pval_map.begin (); + q != pval_map.end (); + q++) + { + std::string s = q->first; + + if (prefix == "axes" && (s == "position" || s == "units")) + new_defaults.set (prefix + s, q->second); + else if (prefix == "figure" && (s == "position" || s == "units" + || s == "windowstyle" + || s == "paperunits")) + new_defaults.set (prefix + s, q->second); + } + } + default_properties = new_defaults; +} + // --------------------------------------------------------------------- void @@ -4286,6 +4342,34 @@ unzoom (); } +void +axes::reset_default_properties (void) +{ + property_list new_defaults; + + for (property_list::plist_map_const_iterator p = default_properties.begin (); + p != default_properties.end (); p++) + { + const property_list::pval_map_type pval_map = p->second; + std::string prefix = p->first; + + for (property_list::pval_map_const_iterator q = pval_map.begin (); + q != pval_map.end (); + q++) + { + std::string s = q->first; + + if (prefix == "axes" && (s == "position" || s == "units")) + new_defaults.set (prefix + s, q->second); + else if (prefix == "figure" && (s == "position" || s == "units" + || s == "windowstyle" + || s == "paperunits")) + new_defaults.set (prefix + s, q->second); + } + } + default_properties = new_defaults; +} + // --------------------------------------------------------------------- Matrix @@ -5032,6 +5116,35 @@ return retval; } +DEFUN (reset, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} reset (@var{h}, @var{property})\n\ +Removes any defaults set for the handle @var{h}. The default figure\n\ +properties \"position\", \"units\", \"windowstyle\" and\n\ +\"paperunits\" and the default axes properties \"position\" and \"units\"\n\ +are not reset.\n\ +@end deftypefn") +{ + int nargin = args.length (); + + if (nargin != 1) + print_usage (); + else + { + // get vector of graphics handles + ColumnVector hcv (args(0).vector_value ()); + + if (! error_state) + { + // loop over graphics objects + for (octave_idx_type n = 0; n < hcv.length (); n++) + gh_manager::get_object (hcv(n)).reset_default_properties (); + } + } + + return octave_value (); +} + DEFUN (set, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} set (@var{h}, @var{property}, @var{value}, @dots{})\n\ diff -r 58c1b5402588 -r d699a6c63263 src/graphics.h.in --- a/src/graphics.h.in Thu Jun 24 10:14:44 2010 +0200 +++ b/src/graphics.h.in Thu Jun 24 10:16:23 2010 +0200 @@ -970,6 +970,10 @@ base_property* clone (void) const { return new color_property (*this); } + std::string values_as_string (void) const { return radio_val.values_as_string (); } + + Cell values_as_cell (void) const { return radio_val.values_as_cell (); } + protected: OCTINTERP_API bool do_set (const octave_value& newval); @@ -2223,6 +2227,17 @@ virtual void remove_all_listeners (void); + virtual void reset_default_properties (void) + { + if (valid_object ()) + { + std::string msg = (type () + "::reset_default_properties"); + gripe_not_implemented (msg.c_str ()); + } + else + error ("base_graphics_object::default: invalid graphics object"); + } + protected: // A reference count. int count; @@ -2409,6 +2424,9 @@ listener_mode mode = POSTSET) { rep->delete_property_listener (nm, v, mode); } + void reset_default_properties (void) + { rep->reset_default_properties (); } + private: base_graphics_object *rep; }; @@ -2548,6 +2566,8 @@ bool valid_object (void) const { return true; } + void reset_default_properties (void); + private: property_list default_properties; @@ -2752,6 +2772,8 @@ bool valid_object (void) const { return true; } + void reset_default_properties (void); + private: property_list default_properties; }; @@ -3199,6 +3221,8 @@ bool valid_object (void) const { return true; } + void reset_default_properties (void); + private: property_list default_properties; };