% routine to set four corner box by slider or edit box
function [minx,maxx,miny,maxy]=boxit(minx,maxx,miny,maxy);
%
disp('Change box limits if desired');
type=2;
% routine to change the box coordinates via sliders
if type==1;
%
milo=uicontrol('style','slider','string','minx','min',minx-minx,'max',maxx,'Value',minx,'units','normalized','position',[.1 .1 .3 .1]);
mxlo=uicontrol('style','slider','min',minx,'max',maxx+maxx,'Value',maxx,'units','normalized','position',[.6 .1 .3 .1]);
mila=uicontrol('style','slider','min',miny-miny,'max',maxy,'Value',miny,'units','normalized','position',[.05 .25  .3 .1]);
mxla=uicontrol('style','slider','min',miny,'max',maxy+maxy,'Value',minx,'units','normalized','position',[.05 .8 .3 .1]);
pause
minx=get(milo,'Value');
maxx=get(mxlo,'Value');
miny=get(mila,'Value');
maxy=get(mxla,'Value');
get(milo)


% edit box stlye
elseif type==2;

% genreate boxes
  milo=uicontrol('style','edit','string',num2str(minx),'units','normalized','position',[.1 .1 .1 .1]);
  mxlo=uicontrol('style','edit','string',num2str(maxx),'units','normalized','position',[.6 .1 .1 .1]);
  mila=uicontrol('style','edit','string',num2str(miny),'units','normalized','position',[.05 .25  .1 .1]);
  mxla=uicontrol('style','edit','string',num2str(maxy),'units','normalized','position',[.05 .8 .1 .1]);

% label boxes
  h1=text(.1,.05,'Min x','units','normalized');
  h2=text(.6,.05,'Max x','units','normalized');
  h3=text(.05,.2,'Min y','units','normalized');
  h4=text(.05,.75,'Max y','units','normalized');
  h5=text(.1,.5,'Set Box Limits Now and then press return in Matlab window.','units','normalized','color','g');

% wait for user
  pause;

  minx=str2num(get(milo,'string'));
  maxx=str2num(get(mxlo,'string'));
  miny=str2num(get(mila,'string'));
  maxy=str2num(get(mxla,'string'));
     

% remove boxes & text
  set(milo,'Visible','off');
  set(mxlo,'Visible','off');
  set(mila,'Visible','off');
  set(mxla,'Visible','off');
  set(h1,'Visible','off');
  set(h2,'Visible','off');
  set(h3,'Visible','off');
  set(h4,'Visible','off');
  set(h5,'Visible','off');

end;