Mercurial > octave
annotate scripts/plot/util/hdl2struct.m @ 30301:cb711825f8e5
hdl2struct.m: Save "appdata" with rest of handle data (bug #61491)
* hdl2struct.m (getprops): Add "__appdata__" to list of hidden properties that
should be tested for and possibly saved.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 18 Nov 2021 20:27:04 -0800 |
parents | 7854d5752dd2 |
children | 796f54d4ddbf |
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 ## |
29358
0a5b15007766
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29203
diff
changeset
|
3 ## Copyright (C) 2012-2021 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
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/>. |
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/>. |
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 ######################################################################## |
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 |
28891
de5f2f9a64ff
maint: Use same coding style when checking for a minimum of 1 input.
Rik <rik@octave.org>
parents:
28298
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)); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
61 nkids = length (kids); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
62 for i = nkids:-1:1 |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
63 s.children(++ii) = hdl2struct (kids(i)); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
64 endfor |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
65 endif |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
66 |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
67 ## add non "children" children objects (title, xlabel, ...) and |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
68 ## hggroup children and tag them in "special" |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
69 if (strcmp (s.type, "hggroup")) |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
70 special = allkids; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
71 else |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
72 special = []; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
73 endif |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
74 special = [special getspecial(h)]; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
75 nsp = length (special); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
76 while (nsp) |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
77 ii += 1; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
78 s.children(ii) = hdl2struct (special(nsp)); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
79 s.special(nsp) = ii; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
80 nsp -= 1; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
81 endwhile |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
82 |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
83 if (strcmp (s.type, "axes") && isempty (get (h, "tag"))) |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
84 ## 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
|
85 ## to the children list |
24498 | 86 try |
87 lg = get (h, "__legend_handle__"); | |
88 catch | |
89 lg = []; | |
90 end_try_catch | |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
91 nlg = length (lg); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
92 if (nlg == 1) |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
93 ii += 1; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
94 s.children(ii) = hdl2struct (lg); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
95 elseif (nlg > 1) |
24498 | 96 ## FIXME: Unreachable code now. Delete? |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
97 error ("hdl2struct: more than one legend found"); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
98 endif |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
99 |
24498 | 100 try |
101 cb = get (h, "__colorbar_handle__"); | |
102 catch | |
103 cb = []; | |
104 end_try_catch | |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
105 ncb = length (cb); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
106 if (ncb == 1) |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
107 ii += 1; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
108 s.children(ii) = hdl2struct (cb); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
109 elseif (ncb > 1) |
24498 | 110 ## FIXME: Unreachable code now. Delete? |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
111 error ("hdl2struct: more than one colorbar found"); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
112 endif |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
113 endif |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
114 |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
115 unwind_protect_cleanup |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
116 set (0, "showhiddenhandles", hiddenh); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
117 end_unwind_protect |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
118 |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
119 endfunction |
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 function hlist = getspecial (h) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
122 |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
123 ## return handles to special children |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
124 hlist = []; |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
125 |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
126 regkids = get (h, "children"); |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
127 ## 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
|
128 set (0, "showhiddenhandles", "on"); |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
129 allkids = get (h, "children"); |
15202
f3b5cadfd6d5
fix missing semicolons in various .m files
John W. Eaton <jwe@octave.org>
parents:
15017
diff
changeset
|
130 set (0, "showhiddenhandles", "off"); |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
131 speckids = ! ismember (allkids, regkids); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
132 hlist = allkids(speckids); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
133 hlist = hlist(:).'; # return row vector |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
134 |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
135 endfunction |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
136 |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
137 function propstruct = getprops (h) |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
138 |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
139 persistent excluded; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
140 |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
141 if (isempty (excluded)) |
28298
e55ff14249c3
Mirror new base property "contextmenu" in "uicontextmenu" (bug #58336).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27985
diff
changeset
|
142 excluded = cell2struct (repmat ({[]}, 1, 16), |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
143 {"beingdeleted", "busyaction", "buttondownfcn", ... |
28298
e55ff14249c3
Mirror new base property "contextmenu" in "uicontextmenu" (bug #58336).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27985
diff
changeset
|
144 "children", "clipping", "contextmenu", ... |
e55ff14249c3
Mirror new base property "contextmenu" in "uicontextmenu" (bug #58336).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27985
diff
changeset
|
145 "createfcn", "deletefcn", "handlevisibility", ... |
e55ff14249c3
Mirror new base property "contextmenu" in "uicontextmenu" (bug #58336).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27985
diff
changeset
|
146 "hittest", "interruptible", "parent", ... |
e55ff14249c3
Mirror new base property "contextmenu" in "uicontextmenu" (bug #58336).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27985
diff
changeset
|
147 "selected" , "selectionhighlight", "type", ... |
e55ff14249c3
Mirror new base property "contextmenu" in "uicontextmenu" (bug #58336).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27985
diff
changeset
|
148 "uicontextmenu"}, 2); |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
149 endif |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
150 |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
151 obj = get (h); |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
152 ## 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
|
153 fields = fieldnames (obj); |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
154 tf = isfield (excluded, fields); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
155 propstruct = rmfield (obj, fields(tf)); |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
156 |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
157 ## hidden properties |
30301
cb711825f8e5
hdl2struct.m: Save "appdata" with rest of handle data (bug #61491)
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
158 hidden_props = {"__appdata__", "__autopos_tag__", "looseinset", ... |
29203
9ec07d894070
hdl2struct.m: store hidden text properties (bug #57241)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
27985
diff
changeset
|
159 "positionmode", "rotationmode", ... |
9ec07d894070
hdl2struct.m: store hidden text properties (bug #57241)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
27985
diff
changeset
|
160 "horizontalalignmentmode", "verticalalignmentmode"}; |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
161 for prop = hidden_props |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
162 try |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
163 val = get (h, prop{1}); |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
164 propstruct.(prop{1}) = val; |
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
165 end_try_catch |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
166 endfor |
15011
f34bea431e4f
maint: Use Octave coding standards for copyobj.m, hdl2struct.m, struct2hdl.m.
Rik <rik@octave.org>
parents:
15007
diff
changeset
|
167 |
14867
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
168 endfunction |
97ce18b62d0f
New Functions; copyobj.m, hdl2struct.m, struct2hdl.m
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
diff
changeset
|
169 |
23084 | 170 ## 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
|
171 |
22876
763ec7cbee9e
hdl2struct.m: Recode for performance.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
172 ## FIXME: Need to test code for legends, colorbars. |