-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtptilefigs.m
83 lines (73 loc) · 2.61 KB
/
tptilefigs.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
function tptilefigs(tile,border)
% Tiles all figure windows except main TP analysis windows
% (twophotonbulkload and analyzetpstack).
%
% GS / modified tilefigs script below:
%
% <cpp> tile figure windows usage: tilefigs ([nrows ncols],border_in pixels)
% Restriction: maximum of 100 figure windows
% Without arguments, tilefigs will determine the closest N x N grid
%Charles Plum Nichols Research Corp.
%<[email protected]> 70 Westview Street
%Tel: (781) 862-9400 Kilnbrook IV
%Fax: (781) 862-9485 Lexington, MA 02173
maxpos = get (0,'screensize'); % determine terminal size in pixels
maxpos(4) = maxpos(4) - 25;
hands = get (0,'Children'); % locate fall open figure handles
hands = sort(hands);
% find handles of TP analysis figs, then skip these
skip=ones(length(hands),1);
for i=1:length(hands)
if strcmp(get(hands(i),'Tag'),'twophotonbulkload') | strcmp(get(hands(i),'Tag'),'analyzetpstack')
skip(i)=0;
end
end
hands=hands(logical(skip));
numfigs = size(hands,1); % number of open figures
maxfigs = 100;
if (numfigs>maxfigs) % figure limit check
disp([' More than ' num2str(maxfigs) ' figures ... get serious pal'])
return
end
if nargin == 0
maxfactor = sqrt(maxfigs); % max number of figures per row or column
sq = [2:maxfactor].^2; % vector of integer squares
sq = sq(find(sq>=numfigs)); % determine square grid size
gridsize = sq(1); % best grid size
nrows = sqrt(gridsize); % figure size screen scale factor
ncols = nrows; % figure size screen scale factor
elseif nargin > 0
nrows = tile(1);
ncols = tile(2);
if numfigs > nrows*ncols
disp ([' requested tile size too small for ' ...
num2str(numfigs) ' open figures '])
return
end
end
if nargin < 2
border = 0;
else
maxpos(3) = maxpos(3) - 2*border;
maxpos(4) = maxpos(4) - 2*border;
end
xlen = fix(maxpos(3)/ncols) - 30; % new tiled figure width
ylen = fix(maxpos(4)/nrows) - 45; % new tiled figure height
% tile figures by postiion
% Location (1,1) is at bottom left corner
pnum=0;
for iy = 1:nrows
ypos = maxpos(4) - fix((iy)*maxpos(4)/nrows) + border +25; % figure location (row)
for ix = 1:ncols
xpos = fix((ix-1)*maxpos(3)/ncols + 1) + border+7; % figure location (column)
pnum = pnum+1;
if (pnum>numfigs)
break
else
figure(hands(pnum))
set(hands(pnum),'Position',[ xpos ypos xlen ylen-30 ]); % move figure
end
end
end
return
% -------------------------------------------------------------------------