-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApplyLayout.m
executable file
·88 lines (85 loc) · 2.33 KB
/
ApplyLayout.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
function DATA = ApplyLayout(DATA, varargin)
%DATA = ApplyLayout(DATA, varargin)
%Reads a layout file and applies to windows
%with tags labelled in DATA.tag
%uses DATA.layoutfile, or file named with
%ApplyLayout(DATA, 'layout', file
% if file is not full pathname, then looks in
% DATA.prefsdir (if exists)
usegui = 0;
verbose = 1;
layoutfile = [];
if isfield(DATA,'layoutfile')
if ~exist(DATA.layoutfile)
if isempty(fileparts(DATA.layoutfile))
DATA.layoutfile = [DATA.gui.prefsdir '/' DATA.layoutfile '.layout.mat'];
end
end
layoutfile = DATA.layoutfile;
end
j = 1;
while j <= length(varargin)
if strncmpi(varargin{j},'choose',5)
usegui = 1;
elseif strncmpi(varargin{j},'layout',6)
j = j+1;
layoutfile = varargin{j};
elseif strncmpi(varargin{j},'silent',6)
verbose = 0;
elseif j == 1 && ischar(varargin{j})
layoutfile = varargin{j};
end
j = j+1;
end
if usegui
if isempty(layoutfile) && isfield(DATA,'prefsdir')
[outname, pathname] = uigetfile(DATA.prefsdir);
else
[outname, pathname] = uigetfile(layoutfile);
end
if ischar(outname)
layoutfile = [pathname outname];
else
return;
end
end
if ~exist(layoutfile)
mycprintf('errors','Cant read Layout %s\n',layoutfile);
return;
end
if ispc && layoutfile(1) == '/'
layoutfile(1) = '\';
end
DATA.layoutfile = layoutfile;
if verbose
fprintf('Loading Layout %s\n',DATA.layoutfile);
end
try
load(DATA.layoutfile);
catch
cprintf('errors','Error loading %s\n',DATA.layoutfile);
return;
end
setappdata(DATA.toplevel,'Figpos',Figpos);
f = fields(Figpos);
for j = 1:length(f)
it = findobj('type','figure','tag',f{j});
if length(it) == 1
set(it,'Position',Figpos.(f{j}));
end
end
if exist('GUI','var')
DATA.gui = CopyFields(DATA.gui, GUI, {'FontSize' 'FontName'});
end
if exist('Showvals','var')
f = fields(Showvals);
for j = 1:length(f)
DATA.show.(f{j}) = Showvals.(f{j});
end
end
if exist('Datavals','var')
f = fields(Datavals);
for j = 1:length(f)
DATA.(f{j}) = Datavals.(f{j});
end
end