comparison scripts/plot/copyobj.m @ 15710:cd3d7f126190

copyobj.m: ensure gca() and gcf() are reset to original values
author pantxo <pantxo.diribarne@gmail.com>
date Mon, 19 Nov 2012 16:15:05 +0100
parents efbc896c1ecc
children 84db9338c448
comparison
equal deleted inserted replaced
15709:9fee0b741de6 15710:cd3d7f126190
39 hparent = figure (fix (hparent)); 39 hparent = figure (fix (hparent));
40 elseif (! any (strcmpi (get (hparent).type, partypes))) 40 elseif (! any (strcmpi (get (hparent).type, partypes)))
41 print_usage (); 41 print_usage ();
42 endif 42 endif
43 43
44 ## current figure and axes
45 cf = gcf ();
46 ca = gca ();
47
44 ## compatibility of input handles 48 ## compatibility of input handles
45 kididx = find (strcmp (alltypes, get (horig).type)); 49 kididx = find (strcmp (alltypes, get (horig).type));
46 paridx = find (strcmp (alltypes, get (hparent).type)); 50 paridx = find (strcmp (alltypes, get (hparent).type));
47 51
48 if (kididx <= paridx) 52 if (kididx <= paridx)
54 else 58 else
55 str = hdl2struct (horig); 59 str = hdl2struct (horig);
56 hnew = struct2hdl (str, hparent); 60 hnew = struct2hdl (str, hparent);
57 endif 61 endif
58 62
63 ## reset current figure (and eventually axes) to original
64 set (0, "currentfigure", cf);
65 if (get (hnew, "parent") == cf)
66 set (cf, "currentaxes", ca)
67 endif
68
59 endfunction 69 endfunction
60 70
61 71
62 %!demo 72 %!demo
63 %! hdl = figure (1234); 73 %! hdl = figure (1234);