%   Name: mctool
%
%   Usage: mctool
%
%   Description: Creates the palette of statistical analysis tools 
%     (Monte Carlo and Bootstrap)
%
     
%
%  Version SWD970709
%
%  Author(s): Scott W. Doebling, doebling@lanl.gov
%
%  Institution: Los Alamos National Laboratory,
%		ESA-EA
%
%  Copyright (c) 1997, The Regents of the University
%     	of California. (See top level of code for
%		full copyright statement.)

%
%  Initialize variables
%

if ~exist('nstatiter'), nstatiter = 1; end   % nstatiter is number of statistical iterations
if ~exist('istat'), istat = 0; end         % istat == 1 means "Do a statistical analysis"
if ~exist('istatmeth'), istatmeth = 1; end % istatmeth == 1 is Monte Carlo
                                           % istatmeth == 2 is Bootstrap

hmctl(1) = figure('units','pixel','position',[40 40 300 150 ],...
			'menubar','none','numbertitle','off','resize','off',...
			'name','Diamond: Statistical Analysis Setup','visible','off');

top=.95;
left=.05;
btnwd=.75;
btnht=.12;
spacing=.01;



%
%  Checkbox to activate statistical analysis
%

btnnum=1;
ypos=top-(btnnum-1)*(btnht+spacing);
btnpos=[left ypos-btnht btnwd btnht];

hmctl(5) = uicontrol(hmctl(1),...
   'style','checkbox',...
	'position',btnpos,...
   'string','Activate Statistical Analysis',...
   'value',istat,...
   'callback',['istat = get(hmctl(5),''value'');',...
      'if istat == 1,',...
      '  set(hmctl(6),''visible'',''on''),',...
      '  eval(get(hmctl(6),''callback'')),',...
      'else,',...
      '  set(hmctl([2 3 6]),''visible'',''off''),',...
      'end,']);

%
%  Popup menu to select the statistical technique
%

btnnum=2;
ypos=top-(btnnum-1)*(btnht+spacing);
btnpos=[left ypos-btnht btnwd btnht];

hmctl(6) = uicontrol(hmctl(1),...
   'style','popup',...
	'position',btnpos,...
   'string','Monte Carlo|Bootstrap',...
   'value',istatmeth,...
   'visible','off',...
   'callback',['istatmeth = get(hmctl(6),''value'');',...
   'set(hmctl(2:3),''visible'',''on''),',...
]);

%
%  Text selector of number of iterations
%

btnnum=4;
ypos=top-(btnnum-1)*(btnht+spacing);
btnpos=[left ypos-btnht btnwd btnht];

hmctl(2) = uicontrol(hmctl(1),...
		'style','text',...
	        'position',btnpos,...
           'string','Number of Analysis Runs:',...
           'visible','off');

btnpos(1) = btnpos(1) + btnpos(3);
btnpos(3) = btnpos(3)/6;

hmctl(3) = uicontrol(hmctl(1),...
		'style','edit',...
	   'position',btnpos,...
      'string',num2str(nstatiter),...
      'visible','off',...
      'callback','nstatiter = str2num(get(hmctl(3),''string''));');


%
%  Close Button
%

btnpos = [0.8 0.2 0.2 0.1];
hmctl(4) = uicontrol(hmctl(1),...
	'style','push',...
	'units','normal',...
	'position',btnpos,...
	'string','Close',...
	'call','set(hmctl(1),''visible'',''off'')');


