Mercurial > octave-nkf
annotate scripts/plot/util/copyobj.m @ 19312:6ca096827123
Use tempname() rather than tmpnam() in core Octave.
* scripts/miscellaneous/tempname.m: Removed m-file as function is now C++.
* scripts/miscellaneous/tmpnam.m: New m-file is an alias that calls tempname.
* scripts/miscellaneous/module.mk: Add tmpnam.m to build system.
* io.txi: Place tempname, tempdir, P_tmpdir docstrings in section on temporary
files.
* system.txi: Remove tempname, tempdir, P_tmpdir docstrings from generic
system functions section of manual.
* dirfns.cc, dlmread.cc, md5sum.cc, ov-fcn-handle.cc: Replace instances
of tmpnam with tempname in BIST code.
* file-io.cc (Ftempname): Change DEFUNX for tmpnam to DEFUN for tempname.
Remove seealso links to tmpnam.
* ftp.m, playaudio.m, wavwrite.m, imformats.m, imread.m, imwrite.m, imageIO.m,
csvwrite.m, dlmwrite.m, fileread.m, importdata.m, textread.m, textscan.m,
genvarname.m, unpack.m, install.m, legend.m, __gnuplot_drawnow__.m,
copyobj.m, hgsave.m, print.m, __ghostscript__.m, __gnuplot_get_var__.m,
__gnuplot_ginput__.m, __gnuplot_print__.m: Replace tmpnam with tempname in
core code.
* build-sparse-tests.sh, io.tst, prefer.tst, system.tst: Replace tmpnam with
tempname in test code.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 22 Oct 2014 10:41:15 -0700 |
parents | 9a5e03801d23 |
children | 0e1f5a750d00 |
rev | line source |
---|---|
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17572
diff
changeset
|
1 ## Copyright (C) 2012-2013 pdiribarne |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
2 ## |
17795
0a8c35ae5ce1
maint: Fix various problems with GPL copyright statements.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
3 ## This file is part of Octave. |
0a8c35ae5ce1
maint: Fix various problems with GPL copyright statements.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4 ## |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
5 ## This program is free software; you can redistribute it and/or modify |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
6 ## it under the terms of the GNU General Public License as published by |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
8 ## (at your option) any later version. |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
9 ## |
17795
0a8c35ae5ce1
maint: Fix various problems with GPL copyright statements.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10 ## Octave is distributed in the hope that it will be useful, |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
13 ## GNU General Public License for more details. |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
14 ## |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
16 ## along with Octave; see the file COPYING. If not, see |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
18 |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
15007
8f0e3c5bfa5f
doc: Periodic grammarcheck of documentation
Rik <rik@octave.org>
parents:
14867
diff
changeset
|
20 ## @deftypefn {Function File} {@var{hnew} =} copyobj (@var{horig}) |
8f0e3c5bfa5f
doc: Periodic grammarcheck of documentation
Rik <rik@octave.org>
parents:
14867
diff
changeset
|
21 ## @deftypefnx {Function File} {@var{hnew} =} copyobj (@var{horig}, @var{hparent}) |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17006
diff
changeset
|
22 ## Construct a copy of the graphic object associated with handle @var{horig} |
15007
8f0e3c5bfa5f
doc: Periodic grammarcheck of documentation
Rik <rik@octave.org>
parents:
14867
diff
changeset
|
23 ## and return a handle @var{hnew} to the new object. |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17006
diff
changeset
|
24 ## |
15007
8f0e3c5bfa5f
doc: Periodic grammarcheck of documentation
Rik <rik@octave.org>
parents:
14867
diff
changeset
|
25 ## If a parent handle @var{hparent} (root, figure, axes, or hggroup) is |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17006
diff
changeset
|
26 ## specified, the copied object will be created as a child of @var{hparent}. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17006
diff
changeset
|
27 ## @seealso{struct2hdl, hdl2struct, findobj} |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
28 ## @end deftypefn |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
29 |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
30 ## Author: pdiribarne <pdiribarne@new-host.home> |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
31 ## Created: 2012-04-01 |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
32 |
15011
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
33 function hnew = copyobj (horig, hparent = 0) |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
34 |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
35 partypes = {"root", "figure", "axes", "hggroup"}; |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
36 othertypes = {"line", "patch", "surface", "image", "text"}; |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
37 alltypes = [partypes othertypes]; |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
38 |
15011
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
39 if (! ishandle (horig) || nargin > 2) |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
40 print_usage (); |
15011
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
41 elseif (! ishandle (hparent)) |
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
42 hparent = figure (fix (hparent)); |
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
43 elseif (! any (strcmpi (get (hparent).type, partypes))) |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
44 print_usage (); |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
45 endif |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
46 |
15710
cd3d7f126190
copyobj.m: ensure gca() and gcf() are reset to original values
pantxo <pantxo.diribarne@gmail.com>
parents:
15328
diff
changeset
|
47 ## current figure and axes |
cd3d7f126190
copyobj.m: ensure gca() and gcf() are reset to original values
pantxo <pantxo.diribarne@gmail.com>
parents:
15328
diff
changeset
|
48 cf = gcf (); |
18570
5ec4b7006b82
copyobj.m: Fix bug when restoring axes to a figure that had no axes to begin with (bug #41849).
Rik <rik@octave.org>
parents:
18528
diff
changeset
|
49 ca = get (cf, "currentaxes"); |
15710
cd3d7f126190
copyobj.m: ensure gca() and gcf() are reset to original values
pantxo <pantxo.diribarne@gmail.com>
parents:
15328
diff
changeset
|
50 |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
51 ## compatibility of input handles |
15011
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
52 kididx = find (strcmp (alltypes, get (horig).type)); |
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
53 paridx = find (strcmp (alltypes, get (hparent).type)); |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
54 |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
55 if (kididx <= paridx) |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
56 error ("copyobj: %s object can't be children to %s.", |
15011
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
57 alltypes{kididx}, alltypes{paridx}); |
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
58 elseif (nargin == 1) |
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
59 str = hdl2struct (horig); |
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
60 hnew = struct2hdl (str); |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
61 else |
15011
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
62 str = hdl2struct (horig); |
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
63 hnew = struct2hdl (str, hparent); |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
64 endif |
15011
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
65 |
15710
cd3d7f126190
copyobj.m: ensure gca() and gcf() are reset to original values
pantxo <pantxo.diribarne@gmail.com>
parents:
15328
diff
changeset
|
66 ## reset current figure (and eventually axes) to original |
cd3d7f126190
copyobj.m: ensure gca() and gcf() are reset to original values
pantxo <pantxo.diribarne@gmail.com>
parents:
15328
diff
changeset
|
67 set (0, "currentfigure", cf); |
18570
5ec4b7006b82
copyobj.m: Fix bug when restoring axes to a figure that had no axes to begin with (bug #41849).
Rik <rik@octave.org>
parents:
18528
diff
changeset
|
68 if (get (hnew, "parent") == cf && ! isempty (ca)) |
15710
cd3d7f126190
copyobj.m: ensure gca() and gcf() are reset to original values
pantxo <pantxo.diribarne@gmail.com>
parents:
15328
diff
changeset
|
69 set (cf, "currentaxes", ca) |
cd3d7f126190
copyobj.m: ensure gca() and gcf() are reset to original values
pantxo <pantxo.diribarne@gmail.com>
parents:
15328
diff
changeset
|
70 endif |
cd3d7f126190
copyobj.m: ensure gca() and gcf() are reset to original values
pantxo <pantxo.diribarne@gmail.com>
parents:
15328
diff
changeset
|
71 |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
72 endfunction |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
73 |
15011
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
74 |
18528
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
75 ## Absurd number of drawnow() function calls in demos is due to problem |
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
76 ## with FLTK backend which is not respecting the set ('position') call. |
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
77 |
15011
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
78 %!demo |
18528
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
79 %! hobj = figure ('name', 'Original', 'numbertitle', 'off'); |
15011
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
80 %! hold on; |
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
81 %! x = 1:10; |
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
82 %! y = x.^2; |
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
83 %! dy = 2 * (.2 * x); |
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
84 %! y2 = (x - 3).^2; |
18958
9a5e03801d23
Update some plot %!demos so that they run under Matlab.
Rik <rik@octave.org>
parents:
18659
diff
changeset
|
85 %! hg = errorbar (x, y, dy); |
15011
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
86 %! set (hg, 'marker', '^', 'markerfacecolor', rand (1,3)); |
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
87 %! plot (x, y2, 'ok-'); |
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
88 %! legend ('errorbar', 'line'); |
18528
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
89 %! drawnow (); |
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
90 %! pos = get (hobj, 'position'); |
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
91 %! scrn = get (0, 'screensize'); |
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
92 %! set (hobj, 'position', [scrn(3)/2-pos(3)-10, scrn(4)/2-pos(4)/2, pos(3:4)]); |
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
93 %! drawnow (); |
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
94 %! hnew = copyobj (hobj); |
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
95 %! drawnow (); |
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
96 %! set (hnew, 'name', 'Copyobj'); |
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
97 %! drawnow (); |
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
98 %! set (hnew, 'position', [scrn(3)/2, scrn(4)/2-pos(4)/2, pos(3:4)]); |
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
99 %! drawnow (); |
15011
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
100 |
18317
0187ed948627
Fix segfault with copyobj() and patch objects.
Rik <rik@octave.org>
parents:
17795
diff
changeset
|
101 %!demo |
18528
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
102 %! hobj = figure ('name', 'Original', 'numbertitle', 'off'); |
18317
0187ed948627
Fix segfault with copyobj() and patch objects.
Rik <rik@octave.org>
parents:
17795
diff
changeset
|
103 %! subplot (2,2,1); |
0187ed948627
Fix segfault with copyobj() and patch objects.
Rik <rik@octave.org>
parents:
17795
diff
changeset
|
104 %! hold on; |
0187ed948627
Fix segfault with copyobj() and patch objects.
Rik <rik@octave.org>
parents:
17795
diff
changeset
|
105 %! contourf (rand (10, 10)); |
0187ed948627
Fix segfault with copyobj() and patch objects.
Rik <rik@octave.org>
parents:
17795
diff
changeset
|
106 %! colorbar (); |
0187ed948627
Fix segfault with copyobj() and patch objects.
Rik <rik@octave.org>
parents:
17795
diff
changeset
|
107 %! subplot (2,2,2); |
0187ed948627
Fix segfault with copyobj() and patch objects.
Rik <rik@octave.org>
parents:
17795
diff
changeset
|
108 %! quiver (rand (10, 10), rand (10, 10)); |
0187ed948627
Fix segfault with copyobj() and patch objects.
Rik <rik@octave.org>
parents:
17795
diff
changeset
|
109 %! subplot (2,2,3); |
0187ed948627
Fix segfault with copyobj() and patch objects.
Rik <rik@octave.org>
parents:
17795
diff
changeset
|
110 %! colormap (jet (64)); |
0187ed948627
Fix segfault with copyobj() and patch objects.
Rik <rik@octave.org>
parents:
17795
diff
changeset
|
111 %! hold on; |
0187ed948627
Fix segfault with copyobj() and patch objects.
Rik <rik@octave.org>
parents:
17795
diff
changeset
|
112 %! sombrero (); |
0187ed948627
Fix segfault with copyobj() and patch objects.
Rik <rik@octave.org>
parents:
17795
diff
changeset
|
113 %! colorbar ('peer', gca, 'NorthOutside'); |
0187ed948627
Fix segfault with copyobj() and patch objects.
Rik <rik@octave.org>
parents:
17795
diff
changeset
|
114 %! subplot (2,2,4); |
0187ed948627
Fix segfault with copyobj() and patch objects.
Rik <rik@octave.org>
parents:
17795
diff
changeset
|
115 %! imagesc (rand (30, 30)); |
0187ed948627
Fix segfault with copyobj() and patch objects.
Rik <rik@octave.org>
parents:
17795
diff
changeset
|
116 %! text (15, 15, 'Rotated text', ... |
0187ed948627
Fix segfault with copyobj() and patch objects.
Rik <rik@octave.org>
parents:
17795
diff
changeset
|
117 %! 'HorizontAlalignment', 'Center', 'Rotation', 30); |
18528
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
118 %! drawnow (); |
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
119 %! pos = get (hobj, 'position'); |
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
120 %! scrn = get (0, 'screensize'); |
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
121 %! set (hobj, 'position', [scrn(3)/2-pos(3)-10, scrn(4)/2-pos(4)/2, pos(3:4)]); |
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
122 %! drawnow (); |
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
123 %! hnew = copyobj (hobj); |
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
124 %! drawnow (); |
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
125 %! set (hnew, 'name', 'Copyobj'); |
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
126 %! drawnow (); |
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
127 %! set (hnew, 'position', [scrn(3)/2, scrn(4)/2-pos(4)/2, pos(3:4)]); |
9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
Rik <rik@octave.org>
parents:
18317
diff
changeset
|
128 %! drawnow (); |
15011
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
129 |
15328
efbc896c1ecc
Disable tests calling imread if not using GraphicsMagick
Mike Miller <mtmiller@ieee.org>
parents:
15011
diff
changeset
|
130 %!testif HAVE_MAGICK |
17150
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
131 %! toolkit = graphics_toolkit (); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
132 %! graphics_toolkit ("gnuplot"); |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
133 %! unwind_protect |
17150
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
134 %! h1 = figure ("visible", "off"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
135 %! x = 0:0.1:2*pi; |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
136 %! y1 = sin (x); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
137 %! y2 = exp (x - 1); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
138 %! ax = plotyy (x,y1, x-1,y2, @plot, @semilogy); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
139 %! xlabel ("X"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
140 %! ylabel (ax(1), "Axis 1"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
141 %! ylabel (ax(2), "Axis 2"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
142 %! axes (ax(1)); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
143 %! text (0.5, 0.5, "Left Axis", ... |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
144 %! "color", [0 0 1], "horizontalalignment", "center"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
145 %! axes (ax(2)); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
146 %! text (4.5, 80, "Right Axis", ... |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
147 %! "color", [0 0.5 0], "horizontalalignment", "center"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
148 %! s1 = hdl2struct (h1); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
149 %! h2 = struct2hdl (s1); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
150 %! s2 = hdl2struct (h2); |
19312
6ca096827123
Use tempname() rather than tmpnam() in core Octave.
Rik <rik@octave.org>
parents:
18958
diff
changeset
|
151 %! png1 = [tempname() ".png"]; |
6ca096827123
Use tempname() rather than tmpnam() in core Octave.
Rik <rik@octave.org>
parents:
18958
diff
changeset
|
152 %! png2 = [tempname() ".png"]; |
17150
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
153 %! unwind_protect |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
154 %! print (h1, png1); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
155 %! [img1, map1, alpha1] = imread (png1); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
156 %! print (h2, png2); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
157 %! [img2, map2, alpha2] = imread (png2); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
158 %! unwind_protect_cleanup |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
159 %! unlink (png1); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
160 %! unlink (png2); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
161 %! end_unwind_protect |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
162 %! assert (img1, img2); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
163 %! assert (map1, map2); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
164 %! assert (alpha1, alpha2); |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
165 %! unwind_protect_cleanup |
17150
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
166 %! close (h1); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
167 %! close (h2); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
168 %! graphics_toolkit (toolkit); |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
169 %! end_unwind_protect |
17150
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
170 |
18659
ee125c82e01e
struct2hdl.m: handle properly objects with non-empy "tag" (bug #42047).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18570
diff
changeset
|
171 %!test |
ee125c82e01e
struct2hdl.m: handle properly objects with non-empy "tag" (bug #42047).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18570
diff
changeset
|
172 %! unwind_protect |
ee125c82e01e
struct2hdl.m: handle properly objects with non-empy "tag" (bug #42047).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18570
diff
changeset
|
173 %! tag = "foo"; |
ee125c82e01e
struct2hdl.m: handle properly objects with non-empy "tag" (bug #42047).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18570
diff
changeset
|
174 %! hf = figure ("visible", "off"); |
ee125c82e01e
struct2hdl.m: handle properly objects with non-empy "tag" (bug #42047).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18570
diff
changeset
|
175 %! hax = axes ("tag", tag); |
ee125c82e01e
struct2hdl.m: handle properly objects with non-empy "tag" (bug #42047).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18570
diff
changeset
|
176 %! hpa = patch (); |
ee125c82e01e
struct2hdl.m: handle properly objects with non-empy "tag" (bug #42047).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18570
diff
changeset
|
177 %! set (hpa, "facecolor", [.5 .5 .5], "tag", tag) |
ee125c82e01e
struct2hdl.m: handle properly objects with non-empy "tag" (bug #42047).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18570
diff
changeset
|
178 %! hax2 = copyobj (hax, hf); |
ee125c82e01e
struct2hdl.m: handle properly objects with non-empy "tag" (bug #42047).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18570
diff
changeset
|
179 %! assert (get (hax2, "tag"), tag) |
ee125c82e01e
struct2hdl.m: handle properly objects with non-empy "tag" (bug #42047).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18570
diff
changeset
|
180 %! hpa2 = get (hax2, "children"); |
ee125c82e01e
struct2hdl.m: handle properly objects with non-empy "tag" (bug #42047).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18570
diff
changeset
|
181 %! assert (get (hpa2, "facecolor"), [.5 .5 .5]) |
ee125c82e01e
struct2hdl.m: handle properly objects with non-empy "tag" (bug #42047).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18570
diff
changeset
|
182 %! unwind_protect_cleanup |
ee125c82e01e
struct2hdl.m: handle properly objects with non-empy "tag" (bug #42047).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18570
diff
changeset
|
183 %! close (hf) |
ee125c82e01e
struct2hdl.m: handle properly objects with non-empy "tag" (bug #42047).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18570
diff
changeset
|
184 %! end_unwind_protect |