KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
isolate_axes.m
Go to the documentation of this file.
1 
2 
3 /* (Autoinserted by mtoc++)
4  * This source code has been filtered by the mtoc++ executable,
5  * which generates code that can be processed by the doxygen documentation tool.
6  *
7  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
8  * Except for the comments, the function bodies of your M-file functions are untouched.
9  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
10  * attached source files that are highly readable by humans.
11  *
12  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
13  * the correct locations in the source code browser.
14  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
15  */
16 
17 function fh = isolate_axes(ah,vis) {
18 if ~all(ishandle(ah))
19  error(" ah must be an array of handles ");
20 end
21 /* Check that the handles are all for axes or uipanels, and are all in the same figure */
22 fh = ancestor(ah(1), " figure ");
23 nAx = numel(ah);
24 for a = 1:nAx
25  if ~ismember(get(ah(a), " Type "), [" axes ", " uipanel "])
26  error(" All handles must be axes or uipanel handles. ");
27  end
28  if ~isequal(ancestor(ah(a), " figure "), fh)
29  error(" Axes must all come from the same figure. ");
30  end
31 end
32 /* Tag the objects so we can find them in the copy */
33 old_tag = get(ah, " Tag ");
34 if nAx == 1
35  old_tag = [old_tag];
36 end
37 set(ah, " Tag ", " ObjectToCopy ");
38 /* Create a new figure exactly the same as the old one */
39 fh = copyfig(fh); /* copyobj(fh, 0); */
40 
41 if nargin < 2 || ~vis
42  set(fh, " Visible ", " off ");
43 end
44 /* Reset the object tags */
45 for a = 1:nAx
46  set(ah(a), " Tag ", old_tag[a]);
47 end
48 /* Find the objects to save */
49 ah = findall(fh, " Tag ", " ObjectToCopy ");
50 if numel(ah) ~= nAx
51  close(fh);
52  error(" Incorrect number of objects found. ");
53 end
54 /* Set the axes tags to what they should be */
55 for a = 1:nAx
56  set(ah(a), " Tag ", old_tag[a]);
57 end
58 /* Keep any legends and colorbars which overlap the subplots */
59 lh = findall(fh, " Type ", " axes ", " -and ", [" Tag ", " legend ", " -or ", " Tag ", " Colorbar "]);
60 nLeg = numel(lh);
61 if nLeg > 0
62  ax_pos = get(ah, " OuterPosition ");
63  if nAx > 1
64  ax_pos = cell2mat(ax_pos(:));
65  end
66  ax_pos(:,3:4) = ax_pos(:,3:4) + ax_pos(:,1:2);
67  leg_pos = get(lh, " OuterPosition ");
68  if nLeg > 1;
69  leg_pos = cell2mat(leg_pos);
70  end
71  leg_pos(:,3:4) = leg_pos(:,3:4) + leg_pos(:,1:2);
72  for a = 1:nAx
73  /* Overlap test */
74  ah = [ah; lh(leg_pos(:,1) < ax_pos(a,3) & leg_pos(:,2) < ax_pos(a,4) &...
75  leg_pos(:,3) > ax_pos(a,1) & leg_pos(:,4) > ax_pos(a,2))];
76  end
77 end
78 /* Get all the objects in the figure */
79 axs = findall(fh);
80 /* Delete everything except for the input objects and associated items */
81 delete(axs(~ismember(axs, [ah; allchildren(ah); allancestors(ah)])));
82 return
83 
84 }
95 function ah = isolateaxes>allchildren(ah) {
96 ah = allchild(ah);
97 if iscell(ah)
98  ah = cell2mat(ah);
99 end
100 ah = ah(:);
101 return
102 
103 }
104 
105 function ph = isolateaxes>allancestors(ah) {
106 ph = [];
107 for a = 1:numel(ah)
108  h = get(ah(a), " parent ");
109  while h ~= 0
110  ph = [ph; h];
111  h = get(h, " parent ");
112  end
113 end
114 return
115 }
116 
function fh = isolate_axes(ah, vis)
Make sure we have an array of handles.
Definition: isolate_axes.m:17
function ph = isolateaxes>allancestors(ah)
Definition: isolate_axes.m:105
Speed test * all(1:3)
function ah = isolateaxes>allchildren(ah)
Definition: isolate_axes.m:95
function fh = copyfig(fh)
Set the default.
Definition: copyfig.m:17