# HG changeset patch # User Rik # Date 1379626007 25200 # Node ID 359366a4994f8f9132fdcc98605b0652feea0697 # Parent 9e4e24a0a118ea61dc20122970603287317024ee waitbar.m: Use Octave coding conventions. * scripts/plot/waitbar.m: Rename 'retval' to 'h' to match documentation. Use 'hf', 'hp' for figure and patch graphics handles. diff -r 9e4e24a0a118 -r 359366a4994f scripts/plot/waitbar.m --- a/scripts/plot/waitbar.m Thu Sep 19 14:03:11 2013 -0700 +++ b/scripts/plot/waitbar.m Thu Sep 19 14:26:47 2013 -0700 @@ -38,7 +38,7 @@ ## Author: jwe -function retval = waitbar (varargin) +function h = waitbar (varargin) persistent curr_waitbar; @@ -55,20 +55,16 @@ ## Use existing waitbar if it still points to a valid graphics handle. if (nargin == 1 && ishandle (curr_waitbar)) - h = curr_waitbar; + hf = curr_waitbar; else - h = false; + hf = false; endif if (! isempty (varargin) && isnumeric (varargin{1})) - if (! ishandle (varargin{1})) + hf = varargin{1}; + varargin(1) = []; + if (! isfigure (hf) || ! strcmp (get (hf, "tag"), "waitbar")) error ("waitbar: H must be a handle to a waitbar object"); - else - h = varargin{1}; - varargin(1) = []; - if (! isfigure (h) || ! strcmp (get (h, "tag"), "waitbar")) - error ("waitbar: H must be a handle to a waitbar object"); - endif endif endif @@ -83,16 +79,16 @@ endif if (rem (numel (varargin), 2) != 0) - error ("waitbar: invalid number of property-value pairs"); + error ("waitbar: invalid number of property/value pairs"); endif - if (h) - gd = get (h, "__guidata__"); + if (hf) + gd = get (hf, "__guidata__"); ## Get the cached handles. ax = gd(1); - p = gd(2); + hp = gd(2); - set (p, "xdata", [0; frac; frac; 0]); + set (hp, "xdata", [0; frac; frac; 0]); if (ischar (msg) || iscellstr (msg)) th = get (ax, "title"); @@ -110,23 +106,23 @@ ## Save and restore current figure cf = get (0, "currentfigure"); - h = figure ("position", [250, 500, 400, 100], - "numbertitle", "off", - "toolbar", "none", "menubar", "none", - "integerhandle", "off", - "handlevisibility", "callback", - "tag", "waitbar", - varargin{:}); + hf = figure ("position", [250, 500, 400, 100], + "numbertitle", "off", + "menubar", "none", "toolbar", "none", + "integerhandle", "off", + "handlevisibility", "callback", + "tag", "waitbar", + varargin{:}); - ax = axes ("parent", h, "xtick", [], "ytick", [], + ax = axes ("parent", hf, + "xtick", [], "ytick", [], "xlim", [0, 1], "ylim", [0, 1], - "xlimmode", "manual", "ylimmode", "manual", "position", [0.1, 0.3, 0.8, 0.2]); - p = patch (ax, [0; frac; frac; 0], [0; 0; 1; 1], [0, 0.35, 0.75]); + hp = patch (ax, [0; frac; frac; 0], [0; 0; 1; 1], [0, 0.35, 0.75]); ## Cache the axes and patch handles. - set (h, "__guidata__", [ax p]); + set (hf, "__guidata__", [ax hp]); if (! (ischar (msg) || iscellstr (msg))) msg = "Please wait..."; @@ -141,11 +137,11 @@ drawnow (); if (nargout > 0) - retval = h; + h = hf; endif ## If there were no errors, update current waitbar. - curr_waitbar = h; + curr_waitbar = hf; endfunction @@ -199,5 +195,5 @@ %!error waitbar (-0.5) %!error waitbar (1.5) %!error waitbar (0.5, struct ()) -%!error waitbar (0.5, "msg", "Name") +%!error waitbar (0.5, "msg", "Name")