Mercurial > octave
annotate scripts/plot/util/openfig.m @ 32632:2e484f9f1f18 stable
maint: update Octave Project Developers copyright for the new year
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 22 Dec 2023 12:08:17 -0500 |
parents | 939e5d952675 |
children |
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 ## |
32632
2e484f9f1f18
maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
32002
diff
changeset
|
3 ## Copyright (C) 2018-2024 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26617
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/>. |
25973
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
7 ## |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
8 ## This filename is part of Octave. |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
9 ## |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
11 ## under the terms of the GNU General Public License as published by |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
13 ## (at your option) any later version. |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
14 ## your option) any later version. |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
15 ## |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
16 ## Octave is distributed in the hope that it will be useful, but |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
17 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
18 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
19 ## GNU General Public License for more details. |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
20 ## |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
21 ## You should have received a copy of the GNU General Public License |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
22 ## along with Octave; see the filename COPYING. If not, see |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
23 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
25 ######################################################################## |
25973
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
26 |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
27 ## -*- texinfo -*- |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
28 ## @deftypefn {} {} openfig |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
29 ## @deftypefnx {} {} openfig (@var{filename}) |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
30 ## @deftypefnx {} {} openfig (@dots{}, @var{copies}) |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
31 ## @deftypefnx {} {} openfig (@dots{}, @var{visibility}) |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
32 ## @deftypefnx {} {@var{h} =} openfig (@dots{}) |
25989
0ab70de0348e
Allow loading and saving of multiple graphic handles in a single file (bug #54924).
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
25984
diff
changeset
|
33 ## Read saved figure window(s) from @var{filename} and return graphics |
0ab70de0348e
Allow loading and saving of multiple graphic handles in a single file (bug #54924).
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
25984
diff
changeset
|
34 ## handle(s) @var{h}. |
25973
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
35 ## |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
36 ## By default, @var{filename} is @qcode{"Untitled.fig"}. If a full path is not |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
37 ## specified, the file opened will be the first one encountered in the load |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
38 ## path. If @var{filename} is not found and does not have an extension, a |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
39 ## search will take place for the first file in the load path with extension |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
40 ## @qcode{".fig"} or @qcode{".ofig"}, in that order. |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
41 ## |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
42 ## @var{copies} is an optional input indicating whether a new figure should |
25983
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
43 ## be created (@qcode{"new"}) or whether an existing figure may be reused |
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
44 ## (@qcode{"reuse"}). An existing figure may be reused if the |
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
45 ## @qcode{"FileName"} property matches the specified input @var{filename}. |
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
46 ## When a figure is reused it becomes the active figure and is shown on top |
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
47 ## of other figures. If the figure was offscreen, it is re-positioned to be |
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
48 ## onscreen. The default value for @var{copies} is @qcode{"new"}. |
25973
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
49 ## |
25983
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
50 ## @var{visibility} is an optional input indicating whether to show the figure |
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
51 ## (@qcode{"visible"}) or not (@qcode{"invisible"}). When @var{visibility} is |
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
52 ## specified as an input to @code{openfig} it overrides the visibility setting |
25989
0ab70de0348e
Allow loading and saving of multiple graphic handles in a single file (bug #54924).
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
25984
diff
changeset
|
53 ## stored in @var{filename}. |
25973
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
54 ## |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
55 ## @seealso{open, hgload, savefig, struct2hdl} |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
56 ## @end deftypefn |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
57 |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
58 function h = openfig (filename = "Untitled.fig", varargin) |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
59 |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
60 if (nargin > 3) |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
61 print_usage (); |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
62 endif |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
63 |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
64 ## Check input filename |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
65 if (isempty (file_in_loadpath (filename))) |
25983
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
66 [d,n,ext] = fileparts (filename); |
25973
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
67 if (isempty (ext)) |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
68 filename = fullfile (d, [n ".fig"]); |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
69 if (isempty (file_in_loadpath (filename))) |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
70 filename = fullfile (d, [n ".ofig"]); |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
71 if (isempty (file_in_loadpath (filename))) |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
72 error ("openfig: cannot find file '%s'", filename); |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
73 endif |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
74 endif |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
75 else |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
76 error ("openfig: cannot find file '%s'", filename); |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
77 endif |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
78 endif |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
79 filename = file_in_loadpath (filename); |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
80 |
25983
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
81 ## Process optional arguments |
25973
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
82 copies = true; |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
83 visibility = {}; |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
84 for i = 1:numel (varargin) |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
85 if (! ischar (varargin{i})) |
25984
a807865bd78b
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25983
diff
changeset
|
86 error ("openfig: input argument %d must be a string", i+1); |
25973
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
87 endif |
32002
939e5d952675
Use upper/lower in preference to toupper/tolower to match Matlab.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
88 switch (lower (varargin{i})) |
25973
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
89 case "reuse" |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
90 copies = false; |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
91 case "new" |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
92 copies = true; |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
93 case "visible" |
25983
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
94 visibility = {"visible", "on"}; |
25973
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
95 case "invisible" |
25983
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
96 visibility = {"visible", "off"}; |
25973
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
97 otherwise |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
98 error ("openfig: unknown option '%s'", varargin{i}); |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
99 endswitch |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
100 endfor |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
101 |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
102 ## Reuse an existing figure? |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
103 if (! copies) |
25992
2d739bbe744b
openfig.m: Only return graphics handle output if requested.
Rik <rik@octave.org>
parents:
25989
diff
changeset
|
104 htmp = findobj (allchild (0), "type", "figure", "FileName", filename); |
2d739bbe744b
openfig.m: Only return graphics handle output if requested.
Rik <rik@octave.org>
parents:
25989
diff
changeset
|
105 if (! isempty (htmp)) |
2d739bbe744b
openfig.m: Only return graphics handle output if requested.
Rik <rik@octave.org>
parents:
25989
diff
changeset
|
106 htmp = htmp(end); |
25973
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
107 if (! isempty (visibility)) |
25992
2d739bbe744b
openfig.m: Only return graphics handle output if requested.
Rik <rik@octave.org>
parents:
25989
diff
changeset
|
108 set (htmp, visibility{:}); |
25973
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
109 endif |
25992
2d739bbe744b
openfig.m: Only return graphics handle output if requested.
Rik <rik@octave.org>
parents:
25989
diff
changeset
|
110 movegui (htmp, "onscreen"); |
2d739bbe744b
openfig.m: Only return graphics handle output if requested.
Rik <rik@octave.org>
parents:
25989
diff
changeset
|
111 if (nargout > 0) |
2d739bbe744b
openfig.m: Only return graphics handle output if requested.
Rik <rik@octave.org>
parents:
25989
diff
changeset
|
112 h = htmp; |
2d739bbe744b
openfig.m: Only return graphics handle output if requested.
Rik <rik@octave.org>
parents:
25989
diff
changeset
|
113 endif |
25973
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
114 return; |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
115 endif |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
116 endif |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
117 |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
118 ## Load graphics objects from file |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
119 prop_struct = cell2struct (visibility(2:2:end), visibility(1:2:end), 2); |
25992
2d739bbe744b
openfig.m: Only return graphics handle output if requested.
Rik <rik@octave.org>
parents:
25989
diff
changeset
|
120 htmp = hgload (filename, prop_struct); |
2d739bbe744b
openfig.m: Only return graphics handle output if requested.
Rik <rik@octave.org>
parents:
25989
diff
changeset
|
121 set (htmp, "FileName", filename); |
2d739bbe744b
openfig.m: Only return graphics handle output if requested.
Rik <rik@octave.org>
parents:
25989
diff
changeset
|
122 |
2d739bbe744b
openfig.m: Only return graphics handle output if requested.
Rik <rik@octave.org>
parents:
25989
diff
changeset
|
123 if (nargout > 0) |
2d739bbe744b
openfig.m: Only return graphics handle output if requested.
Rik <rik@octave.org>
parents:
25989
diff
changeset
|
124 h = htmp; |
2d739bbe744b
openfig.m: Only return graphics handle output if requested.
Rik <rik@octave.org>
parents:
25989
diff
changeset
|
125 endif |
25973
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
126 |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
127 endfunction |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
128 |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
129 |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
130 %!test |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
131 %! unwind_protect |
25983
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
132 %! h1 = figure ("visible", "off"); |
25973
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
133 %! ftmp = [tempname() ".ofig"]; |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
134 %! hgsave (h1, ftmp); |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
135 %! close (h1); |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
136 %! h2 = openfig (ftmp, "new", "invisible"); |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
137 %! h3 = openfig (ftmp, "reuse"); |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
138 %! assert (h2 == h3); |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
139 %! close (h2); |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
140 %! unwind_protect_cleanup |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
141 %! unlink (ftmp); |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
142 %! try, close (h1); end_try_catch |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
143 %! try, close (h2); end_try_catch |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
144 %! try, close (h3); end_try_catch |
c9ae077dedd1
New function openfig.m (bug #44670)
Guillaume Flandin <guillaume.offline@gmail.com>
parents:
diff
changeset
|
145 %! end_unwind_protect |
25983
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
146 |
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
147 %!error openfig (1, 2, 3, 4) |
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
148 %!error <cannot find file> openfig ("%%_A_REALLY_UNLIKELY_FILENAME_%%") |
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
149 %!error <cannot find file> openfig ("%%_A_REALLY_UNLIKELY_FILENAME_%%.fig") |
25984
a807865bd78b
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25983
diff
changeset
|
150 %!error <input argument 3 must be a string> |
a807865bd78b
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25983
diff
changeset
|
151 %! unwind_protect |
a807865bd78b
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25983
diff
changeset
|
152 %! h = figure ("visible", "off"); |
a807865bd78b
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25983
diff
changeset
|
153 %! ftmp = [tempname() ".ofig"]; |
a807865bd78b
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25983
diff
changeset
|
154 %! hgsave (h, ftmp); |
26617
98afb8bbd1f6
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
155 %! openfig (ftmp, "new", [1, 2, 3]); |
25984
a807865bd78b
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25983
diff
changeset
|
156 %! unwind_protect_cleanup |
a807865bd78b
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25983
diff
changeset
|
157 %! unlink (ftmp); |
a807865bd78b
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25983
diff
changeset
|
158 %! close (h); |
a807865bd78b
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25983
diff
changeset
|
159 %! end_unwind_protect |
25983
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
160 %!error <unknown option 'foobar'> |
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
161 %! unwind_protect |
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
162 %! h = figure ("visible", "off"); |
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
163 %! ftmp = [tempname() ".ofig"]; |
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
164 %! hgsave (h, ftmp); |
26617
98afb8bbd1f6
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
165 %! openfig (ftmp, "foobar"); |
25983
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
166 %! unwind_protect_cleanup |
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
167 %! unlink (ftmp); |
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
168 %! close (h); |
c0593ffc62a0
openfig.m: Improve documentation and add BIST tests.
Rik <rik@octave.org>
parents:
25973
diff
changeset
|
169 %! end_unwind_protect |