-
Notifications
You must be signed in to change notification settings - Fork 5
/
smart_figure.m
50 lines (41 loc) · 1007 Bytes
/
smart_figure.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function [h] = smart_figure(name,show_now)
% SMART_FIGURE
%
% [H] = SMART_FIGURE(NAME,SHOW_NOW)
%
% Returns the handler for the figure with a given name or creates
% it if it does not exist
%
% Created by Alexandre Gramfort on 2008-06-25.
% Copyright (c) 2007-2009 Alexandre Gramfort. All rights reserved.
% % $Id: smart_figure.m 139 2009-07-31 17:06:50Z gramfort $
% $LastChangedBy: gramfort $
% $LastChangedDate: 2009-07-31 19:06:50 +0200 (Ven, 31 jul 2009) $
% $Revision: 139 $
me = 'SMART_FIGURE';
if nargin == 1
show_now = true;
end
VISIBLE = true;
% VISIBLE = false;
hw = get(0,'children');
hw = sort(hw);
for i = 1:length(hw),
s = get(hw(i),'Name');
if(strcmp(deblank(s),deblank(name))),
h = hw(i);
if show_now
% figure(h);
set(0,'CurrentFigure',h);
end
return;
end
end
% we exited out without a match, make the window
if VISIBLE
h = figure;
else
h = figure('Visible','off');
end
set(h,'Name',name);
end % function