Mercurial > jwe > octave
annotate scripts/plot/util/hdl2struct.m @ 30825:620607ec6608 stable
Fix saving and loading of polar plots (bug #62093)
* hdl2struct.m: When converting an axes handle, check whether there is a hidden
hggroup wit the "polar_grid" tag. If there is, add it to the list of handles
to be converted.
* struct2hdl.m (createhg): When creating an hggroup, check if the tag property
is "polar_grid" and if so then change "handlevisibility" property to "off".
author | Rik <rik@octave.org> |
---|---|
date | Sun, 06 Mar 2022 17:51:22 -0800 |
parents | 796f54d4ddbf |
children | e219aacda1e5 |
rev | line source |
---|---|
27928
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27924
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27924
diff
changeset
|
2 ## |
30569
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30306
diff
changeset
|
3 ## Copyright (C) 2012-2022 The Octave Project Developers |
27923
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26379
diff
changeset
|
4 ## |
27928
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27924
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:
27924
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
7 ## |
17795
0a8c35ae5ce1
maint: Fix various problems with GPL copyright statements.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8 ## This file is part of Octave. |
0a8c35ae5ce1
maint: Fix various problems with GPL copyright statements.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
9 ## |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24498
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22665
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:
24498
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
13 ## (at your option) any later version. |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
14 ## |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22665
diff
changeset
|
15 ## Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22665
diff
changeset
|
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
17 ## 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
|
18 ## 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
|
19 ## |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
20 ## 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
|
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:
24498
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27928
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27924
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27924
diff
changeset
|
24 ######################################################################## |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
25 |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
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:
20735
diff
changeset
|
27 ## @deftypefn {} {@var{s} =} hdl2struct (@var{h}) |
15007
8f0e3c5bfa5f
doc: Periodic grammarcheck of documentation
Rik <rik@octave.org>
parents:
14867
diff
changeset
|
28 ## Return a structure, @var{s}, whose fields describe the properties |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
29 ## of the object, and its children, associated with the handle, @var{h}. |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
30 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
31 ## The fields of the structure @var{s} are @qcode{"type"}, @qcode{"handle"}, |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
32 ## @qcode{"properties"}, @qcode{"children"}, and @qcode{"special"}. |
18580
13c80c3e9660
Add new functions hgsave and hgload (bug #39532).
Massimiliano Fasi <mogrob.sanit@gmail.com> and Rik <rik@octave.org>
parents:
17795
diff
changeset
|
33 ## @seealso{struct2hdl, hgsave, findobj} |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
34 ## @end deftypefn |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
35 |
15011
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
36 function s = hdl2struct (h) |
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
37 |
28896
de5f2f9a64ff
maint: Use same coding style when checking for a minimum of 1 input.
Rik <rik@octave.org>
parents:
28303
diff
changeset
|
38 if (nargin < 1 || ! ishghandle (h)) |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
39 print_usage (); |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
40 endif |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
41 |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
42 hiddenh = get (0, "showhiddenhandles"); |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
43 unwind_protect |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
44 set (0, "showhiddenhandles", "off"); |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
45 |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
46 ## main object |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
47 s.handle = h; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
48 s.type = get (h, "type"); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
49 s.properties = getprops (h); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
50 s.children = []; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
51 s.special = []; |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
52 |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
53 ## Process, in reverse order, all children except for |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
54 ## legends, colorbars, uimenu, and hggroup children |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
55 ii = 0; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
56 allkids = get (h, "children"); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
57 if (! strcmp (s.type, "hggroup")) |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
58 hnot = findobj (h, "-depth", 1, "tag", "legend", "-or", "tag", "colorbar", |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
59 "-or", "type", "uimenu"); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
60 kids = allkids(! ismember (allkids, hnot)); |
30825
620607ec6608
Fix saving and loading of polar plots (bug #62093)
Rik <rik@octave.org>
parents:
30569
diff
changeset
|
61 if (strcmp (s.type, "axes")) |
620607ec6608
Fix saving and loading of polar plots (bug #62093)
Rik <rik@octave.org>
parents:
30569
diff
changeset
|
62 ## Check for polar plots with special "polar_grid" object |
620607ec6608
Fix saving and loading of polar plots (bug #62093)
Rik <rik@octave.org>
parents:
30569
diff
changeset
|
63 ## FIXME: A hack to fix bug #62093. |
620607ec6608
Fix saving and loading of polar plots (bug #62093)
Rik <rik@octave.org>
parents:
30569
diff
changeset
|
64 kids = [kids; findall(h, "tag", "polar_grid")]; |
620607ec6608
Fix saving and loading of polar plots (bug #62093)
Rik <rik@octave.org>
parents:
30569
diff
changeset
|
65 endif |
620607ec6608
Fix saving and loading of polar plots (bug #62093)
Rik <rik@octave.org>
parents:
30569
diff
changeset
|
66 |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
67 nkids = length (kids); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
68 for i = nkids:-1:1 |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
69 s.children(++ii) = hdl2struct (kids(i)); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
70 endfor |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
71 endif |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
72 |
30825
620607ec6608
Fix saving and loading of polar plots (bug #62093)
Rik <rik@octave.org>
parents:
30569
diff
changeset
|
73 ## Add non "children" children objects (title, xlabel, ...) and |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
74 ## hggroup children and tag them in "special" |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
75 if (strcmp (s.type, "hggroup")) |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
76 special = allkids; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
77 else |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
78 special = []; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
79 endif |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
80 special = [special getspecial(h)]; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
81 nsp = length (special); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
82 while (nsp) |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
83 ii += 1; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
84 s.children(ii) = hdl2struct (special(nsp)); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
85 s.special(nsp) = ii; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
86 nsp -= 1; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
87 endwhile |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
88 |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
89 if (strcmp (s.type, "axes") && isempty (get (h, "tag"))) |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
90 ## look for legends and colorbars among axes brothers and add them |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
91 ## to the children list |
24498 | 92 try |
93 lg = get (h, "__legend_handle__"); | |
94 catch | |
95 lg = []; | |
96 end_try_catch | |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
97 nlg = length (lg); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
98 if (nlg == 1) |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
99 ii += 1; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
100 s.children(ii) = hdl2struct (lg); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
101 elseif (nlg > 1) |
24498 | 102 ## FIXME: Unreachable code now. Delete? |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
103 error ("hdl2struct: more than one legend found"); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
104 endif |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
105 |
24498 | 106 try |
107 cb = get (h, "__colorbar_handle__"); | |
108 catch | |
109 cb = []; | |
110 end_try_catch | |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
111 ncb = length (cb); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
112 if (ncb == 1) |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
113 ii += 1; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
114 s.children(ii) = hdl2struct (cb); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
115 elseif (ncb > 1) |
24498 | 116 ## FIXME: Unreachable code now. Delete? |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
117 error ("hdl2struct: more than one colorbar found"); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
118 endif |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
119 endif |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
120 |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
121 unwind_protect_cleanup |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
122 set (0, "showhiddenhandles", hiddenh); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
123 end_unwind_protect |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
124 |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
125 endfunction |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
126 |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
127 function hlist = getspecial (h) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
128 |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
129 ## return handles to special children |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
130 hlist = []; |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
131 |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
132 regkids = get (h, "children"); |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
133 ## inline version of allchild() for performance |
15202
f3b5cadfd6d5
fix missing semicolons in various .m files
John W. Eaton <jwe@octave.org>
parents:
15017
diff
changeset
|
134 set (0, "showhiddenhandles", "on"); |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
135 allkids = get (h, "children"); |
15202
f3b5cadfd6d5
fix missing semicolons in various .m files
John W. Eaton <jwe@octave.org>
parents:
15017
diff
changeset
|
136 set (0, "showhiddenhandles", "off"); |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
137 speckids = ! ismember (allkids, regkids); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
138 hlist = allkids(speckids); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
139 hlist = hlist(:).'; # return row vector |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
140 |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
141 endfunction |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
142 |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
143 function propstruct = getprops (h) |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
144 |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
145 persistent excluded; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
146 |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
147 if (isempty (excluded)) |
28303
e55ff14249c3
Mirror new base property "contextmenu" in "uicontextmenu" (bug #58336).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27990
diff
changeset
|
148 excluded = cell2struct (repmat ({[]}, 1, 16), |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
149 {"beingdeleted", "busyaction", "buttondownfcn", ... |
28303
e55ff14249c3
Mirror new base property "contextmenu" in "uicontextmenu" (bug #58336).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27990
diff
changeset
|
150 "children", "clipping", "contextmenu", ... |
e55ff14249c3
Mirror new base property "contextmenu" in "uicontextmenu" (bug #58336).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27990
diff
changeset
|
151 "createfcn", "deletefcn", "handlevisibility", ... |
e55ff14249c3
Mirror new base property "contextmenu" in "uicontextmenu" (bug #58336).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27990
diff
changeset
|
152 "hittest", "interruptible", "parent", ... |
e55ff14249c3
Mirror new base property "contextmenu" in "uicontextmenu" (bug #58336).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27990
diff
changeset
|
153 "selected" , "selectionhighlight", "type", ... |
e55ff14249c3
Mirror new base property "contextmenu" in "uicontextmenu" (bug #58336).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27990
diff
changeset
|
154 "uicontextmenu"}, 2); |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
155 endif |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
156 |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
157 obj = get (h); |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
158 ## get useful properties rejecting readonly, children, handles ... |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
159 fields = fieldnames (obj); |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
160 tf = isfield (excluded, fields); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
161 propstruct = rmfield (obj, fields(tf)); |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
162 |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
163 ## hidden properties |
30306
cb711825f8e5
hdl2struct.m: Save "appdata" with rest of handle data (bug #61491)
Rik <rik@octave.org>
parents:
29364
diff
changeset
|
164 hidden_props = {"__appdata__", "__autopos_tag__", "looseinset", ... |
29208
9ec07d894070
hdl2struct.m: store hidden text properties (bug #57241)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
27990
diff
changeset
|
165 "positionmode", "rotationmode", ... |
9ec07d894070
hdl2struct.m: store hidden text properties (bug #57241)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
27990
diff
changeset
|
166 "horizontalalignmentmode", "verticalalignmentmode"}; |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
167 for prop = hidden_props |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
168 try |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
169 val = get (h, prop{1}); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
170 propstruct.(prop{1}) = val; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
171 end_try_catch |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
172 endfor |
15011
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
173 |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
174 endfunction |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
175 |
23084 | 176 ## FIXME: need validation tests |
15011
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
177 |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
178 ## FIXME: Need to test code for legends, colorbars. |