annotate scripts/plot/util/hgsave.m @ 31751:e863066429f1

assume QOffscreenSurface is available QOffscreenSurface was introduced in Qt 5.1. * acinclude.m4 (OCTAVE_CHECK_QT_OPENGL_OFFSCREEN_OK): Delete. (OCTAVE_CHECK_QT_VERSION): Delete use. * configure.ac, geometryimages.m, interpimages.m, module.mk, plotimages.m, sparseimages.m, splineimages.m, GLCanvas.cc, GLCanvas.h, getframe.m, __check_rendering_capability__.m, copyobj.m, hgsave.m, jupyter-notebook.tst, publish.tst: Eliminate checks for Qt OffscreenSurface feature. Assume it is always available.
author John W. Eaton <jwe@octave.org>
date Tue, 17 Jan 2023 13:11:02 -0500
parents 597f3ee61a48
children 2e484f9f1f18
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
31706
597f3ee61a48 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30564
diff changeset
3 ## Copyright (C) 2014-2023 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27437
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
18580
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
7 ##
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
8 ## This file is part of Octave.
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24423
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
18580
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24423
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## (at your option) any later version.
18580
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
14 ##
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
18 ## GNU General Public License for more details.
18580
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
19 ##
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24423
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
18580
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
25
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
26 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20173
diff changeset
27 ## @deftypefn {} {} hgsave (@var{filename})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20173
diff changeset
28 ## @deftypefnx {} {} hgsave (@var{h}, @var{filename})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20173
diff changeset
29 ## @deftypefnx {} {} hgsave (@var{h}, @var{filename}, @var{fmt})
25989
0ab70de0348e Allow loading and saving of multiple graphic handles in a single file (bug #54924).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 25986
diff changeset
30 ## Save the graphics handle(s) @var{h} to the file @var{filename} in the format
18580
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
31 ## @var{fmt}.
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
32 ##
19597
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19278
diff changeset
33 ## If unspecified, @var{h} is the current figure as returned by @code{gcf}.
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
34 ##
18580
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
35 ## When @var{filename} does not have an extension the default filename
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
36 ## extension @file{.ofig} will be appended.
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
37 ##
25989
0ab70de0348e Allow loading and saving of multiple graphic handles in a single file (bug #54924).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 25986
diff changeset
38 ## If present, @var{fmt} must be one of the following:
18580
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
39 ##
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
40 ## @itemize @bullet
18815
19a140e93b1f doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 18679
diff changeset
41 ## @item @option{-binary}, @option{-float-binary}
19a140e93b1f doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 18679
diff changeset
42 ##
19a140e93b1f doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 18679
diff changeset
43 ## @item @option{-hdf5}, @option{-float-hdf5}
19a140e93b1f doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 18679
diff changeset
44 ##
24985
d85b2485af9e doc: grammarcheck m-files ahead of 4.4 release.
Rik <rik@octave.org>
parents: 24534
diff changeset
45 ## @item @option{-V7}, @option{-v7}, @option{-7}, @option{-mat7-binary}
18815
19a140e93b1f doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 18679
diff changeset
46 ##
24985
d85b2485af9e doc: grammarcheck m-files ahead of 4.4 release.
Rik <rik@octave.org>
parents: 24534
diff changeset
47 ## @item @option{-V6}, @option{-v6}, @option{-6}, @option{-mat6-binary}
18815
19a140e93b1f doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 18679
diff changeset
48 ##
19a140e93b1f doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 18679
diff changeset
49 ## @item @option{-text}
19a140e93b1f doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 18679
diff changeset
50 ##
19a140e93b1f doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 18679
diff changeset
51 ## @item @option{-zip}, @option{-z}
18580
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
52 ## @end itemize
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
53 ##
25989
0ab70de0348e Allow loading and saving of multiple graphic handles in a single file (bug #54924).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 25986
diff changeset
54 ## The default format is @option{-binary} to minimize storage.
0ab70de0348e Allow loading and saving of multiple graphic handles in a single file (bug #54924).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 25986
diff changeset
55 ##
0ab70de0348e Allow loading and saving of multiple graphic handles in a single file (bug #54924).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 25986
diff changeset
56 ## Programming Note: When producing graphics for final publication use
0ab70de0348e Allow loading and saving of multiple graphic handles in a single file (bug #54924).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 25986
diff changeset
57 ## @code{print} or @code{saveas}. When it is important to be able to continue
0ab70de0348e Allow loading and saving of multiple graphic handles in a single file (bug #54924).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 25986
diff changeset
58 ## to edit a figure as an Octave object, use @code{hgsave}/@code{hgload}.
0ab70de0348e Allow loading and saving of multiple graphic handles in a single file (bug #54924).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 25986
diff changeset
59 ## @seealso{hgload, hdl2struct, savefig, saveas, print}
18580
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
60 ## @end deftypefn
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
61
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
62 function hgsave (h, filename, fmt = "-binary")
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
63
28789
28de41192f3c Eliminate unneeded verification of nargin, nargout in m-files.
Rik <rik@octave.org>
parents: 27923
diff changeset
64 if (nargin < 1)
18580
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
65 print_usage ();
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
66 endif
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
67
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
68 ## Check input arguments
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
69 if (nargin == 1 && ischar (h))
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
70 filename = h;
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
71 h = get (0, "currentfigure");
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
72 if (isempty (h))
25986
07d14d092d77 hgsave.m: Validate there is only a single graphics handle input.
Rik <rik@octave.org>
parents: 25054
diff changeset
73 error ("hgsave: no current figure to save");
18580
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
74 endif
25989
0ab70de0348e Allow loading and saving of multiple graphic handles in a single file (bug #54924).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 25986
diff changeset
75 elseif (! (all (ishghandle (h)) && ischar (filename)))
18580
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
76 print_usage ();
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
77 endif
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
78
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
79 ## Check file extension
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
80 [~, ~, ext] = fileparts (filename);
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
81 if (isempty (ext))
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
82 filename = [filename ".ofig"];
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
83 endif
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
84
25989
0ab70de0348e Allow loading and saving of multiple graphic handles in a single file (bug #54924).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 25986
diff changeset
85 for i = 1:numel (h)
0ab70de0348e Allow loading and saving of multiple graphic handles in a single file (bug #54924).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 25986
diff changeset
86 s_oct40(i) = hdl2struct (h(i));
0ab70de0348e Allow loading and saving of multiple graphic handles in a single file (bug #54924).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 25986
diff changeset
87 endfor
18580
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
88 save (fmt, filename, "s_oct40");
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
89
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
90 endfunction
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
91
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
92
31751
e863066429f1 assume QOffscreenSurface is available
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
93 %!testif HAVE_MAGICK; (have_window_system () && any (strcmp ("qt", available_graphics_toolkits ())));
29860
2624ee427735 hgsave.m, copyobj.m: Use 'qt' graphics toolkit in BISTs.
Rik <rik@octave.org>
parents: 29859
diff changeset
94 %! toolkit = graphics_toolkit ();
2624ee427735 hgsave.m, copyobj.m: Use 'qt' graphics toolkit in BISTs.
Rik <rik@octave.org>
parents: 29859
diff changeset
95 %! graphics_toolkit ("qt");
29204
21dddfdaa636 hgsave.m: Allow test to run with qt or gnuplot graphics toolkits (bug #57241).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27923
diff changeset
96 %! h1 = figure ("visible", "off", "paperposition", [0.25, 2.5, 8.0, 6.0]);
18580
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
97 %! unwind_protect
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
98 %! x = 0:0.1:2*pi;
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
99 %! y1 = sin (x);
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
100 %! y2 = exp (x - 1);
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
101 %! ax = plotyy (x,y1, x-1,y2, @plot, @semilogy);
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
102 %! xlabel ("X");
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
103 %! ylabel (ax(1), "Axis 1");
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
104 %! ylabel (ax(2), "Axis 2");
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
105 %! axes (ax(1));
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
106 %! text (0.5, 0.5, "Left Axis", ...
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
107 %! "color", [0 0 1], "horizontalalignment", "center");
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
108 %! axes (ax(2));
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
109 %! text (4.5, 80, "Right Axis", ...
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
110 %! "color", [0 0.5 0], "horizontalalignment", "center");
19278
6ca096827123 Use tempname() rather than tmpnam() in core Octave.
Rik <rik@octave.org>
parents: 18815
diff changeset
111 %! ftmp = [tempname() ".ofig"];
6ca096827123 Use tempname() rather than tmpnam() in core Octave.
Rik <rik@octave.org>
parents: 18815
diff changeset
112 %! png1 = [tempname() ".png"];
6ca096827123 Use tempname() rather than tmpnam() in core Octave.
Rik <rik@octave.org>
parents: 18815
diff changeset
113 %! png2 = [tempname() ".png"];
18580
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
114 %! unwind_protect
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
115 %! hgsave (h1, ftmp);
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
116 %! print (h1, png1);
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
117 %! [img1, map1, alpha1] = imread (png1);
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
118 %! h2 = hgload (ftmp);
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
119 %! print (h2, png2);
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
120 %! [img2, map2, alpha2] = imread (png2);
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
121 %! unwind_protect_cleanup
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
122 %! unlink (ftmp);
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
123 %! unlink (png1);
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
124 %! unlink (png2);
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
125 %! end_unwind_protect
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
126 %! assert (img1, img2);
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
127 %! assert (map1, map2);
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
128 %! assert (alpha1, alpha2);
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
129 %! unwind_protect_cleanup
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
130 %! close (h1);
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
131 %! close (h2);
29860
2624ee427735 hgsave.m, copyobj.m: Use 'qt' graphics toolkit in BISTs.
Rik <rik@octave.org>
parents: 29859
diff changeset
132 %! graphics_toolkit (toolkit);
18580
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
133 %! end_unwind_protect
13c80c3e9660 Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
diff changeset
134
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
135 ## Test input validation
28886
d8318c12d903 test: remove unnecessary BIST tests in m-files checking for excessive number of inputs.
Rik <rik@octave.org>
parents: 28789
diff changeset
136 %!error <Invalid call> hgsave ()
25989
0ab70de0348e Allow loading and saving of multiple graphic handles in a single file (bug #54924).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 25986
diff changeset
137 %!error <no current figure to save>
25986
07d14d092d77 hgsave.m: Validate there is only a single graphics handle input.
Rik <rik@octave.org>
parents: 25054
diff changeset
138 %! unwind_protect
25989
0ab70de0348e Allow loading and saving of multiple graphic handles in a single file (bug #54924).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 25986
diff changeset
139 %! old_fig = get (0, "currentfigure");
0ab70de0348e Allow loading and saving of multiple graphic handles in a single file (bug #54924).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 25986
diff changeset
140 %! set (0, "currentfigure", []);
0ab70de0348e Allow loading and saving of multiple graphic handles in a single file (bug #54924).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 25986
diff changeset
141 %! hgsave ("foobar");
25986
07d14d092d77 hgsave.m: Validate there is only a single graphics handle input.
Rik <rik@octave.org>
parents: 25054
diff changeset
142 %! unwind_protect_cleanup
25989
0ab70de0348e Allow loading and saving of multiple graphic handles in a single file (bug #54924).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 25986
diff changeset
143 %! set (0, "currentfigure", old_fig);
25986
07d14d092d77 hgsave.m: Validate there is only a single graphics handle input.
Rik <rik@octave.org>
parents: 25054
diff changeset
144 %! end_unwind_protect
25989
0ab70de0348e Allow loading and saving of multiple graphic handles in a single file (bug #54924).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 25986
diff changeset
145 %!error hgsave ([0, -1], "foobar")
0ab70de0348e Allow loading and saving of multiple graphic handles in a single file (bug #54924).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 25986
diff changeset
146 %!error hgsave (0, { "foobar" })