* bug #13651 fixed - an axes couldn't be copied in a uicontrol frame
[scilab.git] / scilab / modules / graphics / macros / %h_copy.sci
1 //
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) INRIA
4 // Copyright (C) 2013-2013 - Scilab Enterprises - Bruno JOFRET
5 // Copyright (C) 2016 - Samuel GOUGEON
6 //
7 // Copyright (C) 2012 - 2016 - Scilab Enterprises
8 //
9 // This file is hereby licensed under the terms of the GNU GPL v2.0,
10 // pursuant to article 5.3.4 of the CeCILL v.2.1.
11 // This file was originally licensed under the terms of the CeCILL v2.1,
12 // and continues to be available under such terms.
13 // For more information, see the COPYING file which you should have received
14 // along with this program.
15 //
16
17 function h = %h_copy(h,ax)
18     filename = tempname();
19     save(filename,"h")
20     if argn(2)<2 then
21         load(filename)
22     else
23         if ax.type=="Axes"  then
24             a=get("current_axes")
25             set("current_axes", ax)
26             load(filename)
27             set("current_axes", a)
28
29         elseif ax.type=="uicontrol" & ax.style=="frame"
30             set("current_entity",ax)
31             if h.type=="Axes"
32                 na = newaxes(ax)
33                 load(filename)
34                 swap_handles(ax.parent.children(1),na)
35                 delete(ax.parent.children(1))
36             else
37                 load(filename)
38             end
39
40         else
41             a = gcf()
42             scf(ax)
43             load(filename)
44             scf(a)
45         end
46     end
47     mdelete(filename)
48 endfunction