1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2017 - Samuel GOUGEON
5 // Copyright (C) 2012 - 2016 - Scilab Enterprises
7 // This file is hereby licensed under the terms of the GNU GPL v2.0,
8 // pursuant to article 5.3.4 of the CeCILL v.2.1.
9 // This file was originally licensed under the terms of the CeCILL v2.1,
10 // and continues to be available under such terms.
11 // For more information, see the COPYING file which you should have received
12 // along with this program.
14 function clf(varargin)
16 nbArg = size(varargin);
22 if type(varargin(1))==1 then // win num given
25 for k = 1:size(num,"*")
26 h = [h ; get_figure_handle(num(k))];
29 elseif type(varargin(1))==9 then // handle given
32 elseif type(varargin(1))==10 then // job given
37 if type(varargin(1))==1 then // win num given
40 for k = 1:size(num,"*")
41 h = [h ; get_figure_handle(num(k))];
43 elseif type(varargin(1))==9 then // handle given
48 msg = _("%s: Wrong number of input argument(s): %d to %d expected.")
49 error(msprintf(msg, "clf", 0, 2))
52 if and(job<>["clear","reset"]) then
53 msg = _("%s: Wrong value for input argument #%d: ''clear'' or ''reset'' expected.")
54 error(msprintf(msg, "clf", nbArg))
57 nbHandles = size(h,"*");
58 if nbHandles == 0 then
62 // check that all the handles are figures
65 if curFig.type <> "Figure" & (curFig.type <> "uicontrol" | curFig.style <> "frame")
66 msg = _("%s: Wrong type for input argument #%d: A vector of ''Figure'' or ''Frame'' handle expected.")
67 error(msprintf(msg, "clf", 1))
74 if curFig.type == "uicontrol" then
76 for kChild = 1:size(curFig.children, "*")
77 if curFig.children(kChild).type=="Axes" then
82 delete(curFig.children);
88 immediateMode = curFig.immediate_drawing;
89 curFig.immediate_drawing = "off";
90 delete(curFig.children);
91 curFig.info_message = ""; // Clears the infobar message
92 curFig.event_handler_enable = "off"; // Disables the event handler
93 // Restores the drawlater entry status:
94 curFig.immediate_drawing = immediateMode;
98 // reset figures to default values if needed
99 if (job == "reset") then
101 // This literal list should be replaced with a getproperties(gdf())
102 // when such a function will be available:
121 "event_handler_enable"
138 excluded0 = ["children" "dockable" "menubar" "toolbar" "immediate_drawing"]
139 excluded0 = [excluded0 "layout" "layout_options"] // http://bugzilla.scilab.org/14955
142 if curFig.type == "uicontrol" then
146 // Forces drawlater mode
147 curFig.immediate_drawing = "off";
151 if isDocked(curFig) // http://bugzilla.scilab.org/11476
152 excluded = [excluded "figure_position" "figure_size" "axes_size"]
154 defaultProps = setdiff(allprops, excluded);
157 for i = 1:size(defaultProps,"*")
158 defaultValue = get(defaultFig, defaultProps(i));
159 if (defaultProps(i) <> "figure_position" | defaultValue <> [-1,-1]) then
160 // don't reset figure pos is defaultValue is [-1,-1]
161 set(curFig, defaultProps(i), defaultValue);
164 set(curFig, "immediate_drawing", defaultFig.immediate_drawing)
169 function yn = isDocked(fh)
170 // http://fileexchange.scilab.org/toolboxes/360000
173 fs = matrix(fh.figure_size,2,-1)'
174 as = matrix(fh.axes_size,2,-1)'
176 yn = (fh.dockable=="on" & ((fs(:,1)-as(:,1)) > 20)')
177 // A test on vertical dimensions is more complicated, due to switchable
178 // menubar, toolbar and infobar.