% --------------------------------------------------------------------------------- % % Name: progressBar.m % Author: Steve Hoelzer % Project: Any % Description: Graphical indication of progress. Calling progressBar.m % repeatedly will update the figure and if percentDone = 1.0, % the plot will be removed. % Inputs: percentDone : [0-1] indicating percent of testing done % extraText : text written on the progress bar % Outputs: (none) % Example Function Call: % » [] = progressBar(percentDone); % % Revisions: % 2002-02-27 - Created function % % --------------------------------------------------------------------------------- function [] = progressBar(percentDone, varargin); % ----- Variables ----------------------------------------------------------------- extraText = ''; if nargin > 1, extraText = varargin{1}; end % ----- Begin Procedure ----------------------------------------------------------- % Get the handle for the progress bar progressBar = findobj('Tag','progBar'); if isempty( progressBar ) % Initialize progress bar progressBar = figure(... 'Position', [25 55 400 25],... 'NumberTitle', 'off',... 'Resize', 'off',... 'MenuBar', 'none',... 'Name', 'Progress',... 'Tag', 'progBar',... 'DoubleBuffer', 'on'); barh(1) set(gca,'Position',[0.02 0.16 0.96 0.70],'YLim',[0.8 1.2],... 'Tag','thisAxis','ytick',[],'xtick',[]) end if abs(percentDone-1) < 10^-5 % Close progress bar if percentDone = 1 delete(progressBar) else % Update progress bar a = findobj('Tag','thisAxis'); percentDone = max(percentDone,0.00001); set(a,'XLim',[0 1/percentDone]) set(progressBar,'Name',['Progress - ' num2str(round(100*percentDone)) '% ' extraText]) drawnow end return; % ----- End of File ---------------------------------------------------------------