Home > FMAToolbox > Plot > Hide.m

Hide

PURPOSE ^

Hide - Hide (or show) existing or future figures, e.g. to speed up batch processing.

SYNOPSIS ^

function status = Hide(parameter1,parameter2)

DESCRIPTION ^

Hide - Hide (or show) existing or future figures, e.g. to speed up batch processing.

  USAGE

    Hide(figures,'on')   % hide these figures
    Hide(figures,'off')  % un-hide this figure
    Hide('all')          % hide all existing figures
    Hide('none')         % un-hide all existing figures
    Hide('on')           % automatically hide all new figures
    Hide('off')          % do not automatically hide new figures

    Hide(figures)        % same as Hide(figures,'on')
    Hide                 % same as Hide(gcf,'on')
    Hide('status')       % returns the current default behavior ('on' or 'off')

  SEE ALSO

    See also sca, scf, StartBatch.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function status = Hide(parameter1,parameter2)
0002 
0003 %Hide - Hide (or show) existing or future figures, e.g. to speed up batch processing.
0004 %
0005 %  USAGE
0006 %
0007 %    Hide(figures,'on')   % hide these figures
0008 %    Hide(figures,'off')  % un-hide this figure
0009 %    Hide('all')          % hide all existing figures
0010 %    Hide('none')         % un-hide all existing figures
0011 %    Hide('on')           % automatically hide all new figures
0012 %    Hide('off')          % do not automatically hide new figures
0013 %
0014 %    Hide(figures)        % same as Hide(figures,'on')
0015 %    Hide                 % same as Hide(gcf,'on')
0016 %    Hide('status')       % returns the current default behavior ('on' or 'off')
0017 %
0018 %  SEE ALSO
0019 %
0020 %    See also sca, scf, StartBatch.
0021 %
0022 
0023 % Copyright (C) 2011-2013 by Michaƫl Zugaro
0024 %
0025 % This program is free software; you can redistribute it and/or modify
0026 % it under the terms of the GNU General Public License as published by
0027 % the Free Software Foundation; either version 3 of the License, or
0028 % (at your option) any later version.
0029 
0030 status = [];
0031 
0032 % Name of this function
0033 name = mfilename;
0034 % Current default figure creation function
0035 default = get(0,'DefaultFigureCreateFcn');
0036 if isa(default,'function_handle'), default = func2str(default); end
0037 
0038 % Special cases: Hide('on'), Hide('off'), Hide('all'), Hide('none')
0039 if nargin == 1 && isastring(lower(parameter1),'on','off','all','none','status'),
0040     switch lower(parameter1),
0041         case 'status',
0042             if isempty(regexp(default,name)),
0043                 status = 'off';
0044             else
0045                 status = 'on';
0046             end
0047         case 'on',
0048             if isempty(regexp(default,name)),
0049                 set(0,'DefaultFigureCreateFcn',[name ';' default]);
0050             end
0051         case 'off',
0052             if ~isempty(regexp(default,name)),
0053                 set(0,'DefaultFigureCreateFcn',regexprep(default,[name ';'],''));
0054             end
0055         case 'all',
0056             children = get(0,'children');
0057             for i = 1:length(children),
0058                 if strcmp(get(children(i),'visible'),'on'),
0059                     % Do not hide if already hidden, because this is *slow*
0060                     set(children(i),'visible','off');
0061                 end
0062             end
0063         case 'none',
0064             children = get(0,'children');
0065             for i = 1:length(children),
0066                 if strcmp(get(children(i),'visible'),'off'),
0067                     % Do not unhide if already visible, because this is *slow*
0068                     set(children(i),'visible','on');
0069                 end
0070             end
0071     end
0072     return
0073 end
0074 
0075 % Special case: call upon figure creation
0076 if ~isempty(gcbo),
0077     % Make invisible
0078     set(gcbo,'visible','off');
0079     warning('FMAToolbox:Hide:FigureHidden','Figure hidden (type ''help <a href="matlab:help Hide">Hide</a>'' for details).');
0080     % Remove from figure creation function
0081     current = get(gcbo,'CreateFcn');
0082     if isa(current,'function_handle'), current = func2str(current); end
0083     set(gcbo,'CreateFcn',regexprep(current,[name ';'],''));
0084 end
0085 
0086 % General case: parameter1 is a list of figure handles
0087 if nargin < 1,
0088     figs = gcf;
0089 else
0090     figs = parameter1;
0091 end
0092 if nargin < 2,
0093     mode = 'on';
0094 else
0095     mode = lower(parameter2);
0096 end
0097 
0098 switch mode,
0099     case 'off',
0100         for fig = figs,
0101             set(fig,'visible','on');
0102         end
0103     case 'on',
0104         for fig = figs,
0105             set(fig,'visible','off');
0106         end
0107 end
0108

Generated on Fri 16-Mar-2018 13:00:20 by m2html © 2005