Home > utility > tilefigs.m

tilefigs

PURPOSE ^

tile figure windows usage: tilefigs ([nrows ncols],border_in pixels)

SYNOPSIS ^

function tilefigs(tile,border)

DESCRIPTION ^

 <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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function tilefigs(tile,border)
0002 % <cpp> tile figure windows usage: tilefigs ([nrows ncols],border_in pixels)
0003 % Restriction: maximum of 100 figure windows
0004 % Without arguments, tilefigs will determine the closest N x N grid
0005 
0006 
0007 %Charles Plum                    Nichols Research Corp.
0008 %<cplum@nichols.com>             70 Westview Street
0009 %Tel: (781) 862-9400             Kilnbrook IV
0010 %Fax: (781) 862-9485             Lexington, MA 02173
0011 
0012 
0013 maxpos  = get (0,'screensize'); % determine terminal size in pixels
0014 maxpos(4) = maxpos(4) - 25;
0015 hands   = get (0,'Children');   % locate fall open figure handles
0016 hands   = sort(hands);          % sort figure handles
0017 numfigs = size(hands,1);        % number of open figures
0018 
0019 
0020 maxfigs = 100;
0021 
0022 
0023 if (numfigs>maxfigs)            % figure limit check
0024         disp([' More than ' num2str(maxfigs) ' figures ... get serious pal'])
0025         return
0026 end
0027 
0028 
0029 if nargin == 0
0030   maxfactor = sqrt(maxfigs);       % max number of figures per row or column
0031   sq = [2:maxfactor].^2;           % vector of integer squares
0032   sq = sq(find(sq>=numfigs));      % determine square grid size
0033   gridsize = sq(1);                % best grid size
0034   nrows = sqrt(gridsize);          % figure size screen scale factor
0035   ncols = nrows;                   % figure size screen scale factor
0036 elseif nargin > 0 
0037   nrows = tile(1);
0038   ncols = tile(2);
0039   if numfigs > nrows*ncols
0040     disp ([' requested tile size too small for ' ...
0041         num2str(numfigs) ' open figures '])
0042         return
0043   end
0044 end
0045 if nargin < 2
0046   border = 0;
0047 else
0048   maxpos(3) = maxpos(3) - 2*border;
0049   maxpos(4) = maxpos(4) - 2*border;
0050 end
0051 xlen = fix(maxpos(3)/ncols) - 30; % new tiled figure width
0052 ylen = fix(maxpos(4)/nrows) - 45; % new tiled figure height
0053 
0054 
0055 % tile figures by postiion
0056 % Location (1,1) is at bottom left corner
0057 pnum=0;
0058 for iy = 1:nrows
0059   ypos = maxpos(4) - fix((iy)*maxpos(4)/nrows) + border +25; % figure location (row)
0060   for ix = 1:ncols
0061         xpos = fix((ix-1)*maxpos(3)/ncols + 1) + border+7;     % figure location (column)
0062         pnum = pnum+1;
0063     if (pnum>numfigs)
0064                 break
0065         else
0066           figure(hands(pnum))
0067       set(hands(pnum),'Position',[ xpos ypos xlen ylen ]); % move figure
0068         end
0069   end
0070 end
0071 return
0072 
0073 
0074 % -------------------------------------------------------------------------

Generated on Tue 01-Jun-2010 09:50:34 by m2html © 2003