function ratpbtns
%
% Function: ratpbtns
% 
% Usage:  ratpbtns
% 
% Description:
%    Initializes the rational polynomial Window
%    Handles and graphics elements.
%    Returns a vector to those elements.
%
% Version SWD970819
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This matlab source code was originally     %
% developed as part of "DIAMOND" at          %
% Los Alamos National Laboratory. It may     %
% be copied, modified, and distributed in    %
% any form, provided:                        %
%  a) This notice accompanies the files and  %
%     appears near the top of all source     %
%     code files.                            %
%  b) No payment or commercial services are  %
%     received in exchange for the code.     %
%                                            %
% Original copyright is reserved by the      %
% Regents of the University of California,   %
% in addition to Scott W. Doebling, Phillip  %
% J. Cornwell, Erik G. Straser, and Charles  %
% R. Farrar.                                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


global HANDLES

%====================================
% Initialize the buttons
%====================================
top=.95;
left=.84;
btnwd=.15;
btnht=.06;
spacing=.01;

%%====================================
%% For the Rational Polynomial window
%%====================================
%====================================
% Set up the console frame
%=====================================
frmborder=0.01;
ypos=.05-frmborder;
frmpos=[left-frmborder ypos btnwd+2*frmborder .9+2*frmborder];
HANDLES.hratpb(1)=uicontrol(HANDLES.hfigdmnd, ...
        'Style','Frame', ...
        'Position',frmpos, ...
        'BackgroundColor',[.5 .5 .5]);


%==================================
% Set up buttons
%==================================
%
% Plot tools button
%
btnnum=1;
ypos=top-(btnnum-1)*(btnht+spacing);
btnpos=[left ypos-btnht btnwd btnht];
HANDLES.hratpb(2)=uicontrol(HANDLES.hfigdmnd, ...
      'style','push', ...
      'position',btnpos, ...
      'string','Plot Tools', ...
      'call','set(HANDLES.hplttl(1),''visible'',''on''),figure(HANDLES.hplttl(1))');

%
%  sliders
%

%
% Lower frequency
%
HANDLES.hratpb(6) = uicontrol(HANDLES.hfigdmnd, ...
   'style','slider', ...
   'pos',[.13 .01 .2 0.04], ...
   'back','w', ...
   'call',['f1_t=get(HANDLES.hratpb(6),''value'');',...
      'if f1_t >= DISPLAY{iaxes}.cursfreq{2},  f1_t = DISPLAY{iaxes}.cursfreq{1}; end,',...
      'updatecursor(f1_t,1,HANDLES.hratpb(6)),',...
      'set(HANDLES.hratpb(8),''string'',num2str(DISPLAY{iaxes}.cursfreq{1})),']);
		
HANDLES.hratpb(7)=uicontrol(HANDLES.hfigdmnd, ...
        'style','text', ...
        'pos',[.13 .05 .1 .04], ...
        'string','Lower');
     
HANDLES.hratpb(8)=uicontrol(HANDLES.hfigdmnd, ...
	'style','edit', ...
	'pos',[.23 .05 .1 .04], ...
	'string','fminm', ...
   'back','w', ...
   'fore','r', ...
	'callback',['f1_t=str2num(get(HANDLES.hratpb(8),''string''));', ...
      'if f1_t >= DISPLAY{iaxes}.cursfreq{2},  f1_t = DISPLAY{iaxes}.cursfreq{1}; end,',...
      'updatecursor(f1_t,1,HANDLES.hratpb(6)),',...
      'set(HANDLES.hratpb(8),''string'',num2str(DISPLAY{iaxes}.cursfreq{1})),']);
 
%
% Upper frequency
%
HANDLES.hratpb(9) = uicontrol(HANDLES.hfigdmnd, ...
   'style','slider', ...
   'pos',[.55 .01 .2 0.04], ...
   'back','w', ...
   'call',...
   ['f2_t=get(HANDLES.hratpb(9),''value'');',...
      'if f2_t <= DISPLAY{iaxes}.cursfreq{1},  f2_t = DISPLAY{iaxes}.cursfreq{2}; end,',...
      'updatecursor(f2_t,2,HANDLES.hratpb(9)),',...
      'set(HANDLES.hratpb(11),''string'',num2str(DISPLAY{iaxes}.cursfreq{2})),']);


HANDLES.hratpb(10)=uicontrol(HANDLES.hfigdmnd, ...
        'style','text', ...
        'pos',[.55 .05 .1 .04], ...
        'string','upper');
HANDLES.hratpb(11)=uicontrol(HANDLES.hfigdmnd, ...
	'style','edit', ...
   'back','w', ...
   'fore','b', ...
	'pos',[.65 .05 .1 .04], ...
   'callback',...
   ['f2_t=str2num(get(HANDLES.hratpb(11),''string''));', ...
      'if f2_t <= DISPLAY{iaxes}.cursfreq{1},  f2_t = DISPLAY{iaxes}.cursfreq{2}; end,',...
      'updatecursor(f2_t,2,HANDLES.hratpb(9)),',...
      'set(HANDLES.hratpb(11),''string'',num2str(DISPLAY{iaxes}.cursfreq{2})),']);

% calculate button
%
btnnum=5;
ypos=top-(btnnum-1)*(btnht+spacing);
btnpos=[left ypos-btnht btnwd btnht];
HANDLES.hratpb(13)=uicontrol(HANDLES.hfigdmnd, ...
      'style','pushbutton', ...
      'position',btnpos, ...
      'string','Calculate', ...
      'callback',...
      ['runrp, imode = MODES.nmodes;',...
         'if isstruct(GEOM),',...
         '   viewmode,',...
         'end,',...
         'set(HANDLES.hmmenu{6}(1),''enable'',''on''),']);
   
%
% Number of modes to use in fit
%
btnnum=6;
ypos=top-(btnnum-1)*(btnht+spacing);
btnpos=[left ypos-btnht-spacing btnwd btnht];
HANDLES.hratpb(14)=uicontrol(HANDLES.hfigdmnd, ...
      'style','text', ...
      'position',btnpos, ...
      'string','Num. Modes');

btnnum=7;
ypos=top-(btnnum-1)*(btnht+spacing)+spacing;
btnpos=[left ypos-btnht-spacing btnwd btnht];
HANDLES.hratpb(15)=uicontrol(HANDLES.hfigdmnd, ...
      'style','edit', ...
      'position',btnpos, ...
      'string','1', ...
      'back','white', ...
      'callback','MODES.nmodfit = str2num(get(HANDLES.hratpb(15),''string''));');

%
% Extra terms
%
btnnum=8;
ypos=top-(btnnum-1)*(btnht+spacing);
btnpos=[left ypos-btnht btnwd btnht];
HANDLES.hratpb(16)=uicontrol(HANDLES.hfigdmnd, ...
      'style','text', ...
      'position',btnpos, ...
      'string','Extra Terms');

btnnum=9;
ypos=top-(btnnum-1)*(btnht+spacing)+spacing;
btnpos=[left ypos-btnht btnwd btnht];
HANDLES.hratpb(17)=uicontrol(HANDLES.hfigdmnd, ...
      'style','edit', ...
      'position',btnpos, ...
      'string','4', ...
      'back','white',...
      'callback','MODES.nkterms = str2num(get(HANDLES.hratpb(17),''string''));');

%====================================
% Set up the axes
%====================================

HANDLES.hratpb(25) = axes('position',[.1 .2 .7 .7]);

%
%  Mouse-based cursor position
%

%  Lower Freq.

HANDLES.hratpb(30)=uicontrol(HANDLES.hfigdmnd, ...
   'style','pushbutton', ...
   'pos',[.13 .10 .2 .04], ...
   'string','Use Mouse', ...
	'callback',['[f1_t,temp] = ginput(1);',...
      'if f1_t >= DISPLAY{iaxes}.cursfreq{2},  f1_t = DISPLAY{iaxes}.cursfreq{1}; end,',...
      'updatecursor(f1_t,1,HANDLES.hratpb(6)),',...
      'set(HANDLES.hratpb(8),''string'',num2str(DISPLAY{iaxes}.cursfreq{1})),']);



%  Upper Freq.

HANDLES.hratpb(31)=uicontrol(HANDLES.hfigdmnd, ...
   'style','pushbutton', ...
   'pos',[.55 .10 .2 .04], ...
   'string','Use Mouse', ...
   'callback',['[f2_t,temp] = ginput(1);',...
      'if f2_t <= DISPLAY{iaxes}.cursfreq{1},  f2_t = DISPLAY{iaxes}.cursfreq{2}; end,',...
      'updatecursor(f2_t,2,HANDLES.hratpb(9)),',...
      'set(HANDLES.hratpb(11),''string'',num2str(DISPLAY{iaxes}.cursfreq{2})),']);

%
%  Statistical Analysis Setup Button
%

btnnum=12;
ypos=top-(btnnum-1)*(btnht+spacing);
btnpos=[left ypos-btnht btnwd btnht];
HANDLES.hratpb(18)=uicontrol(HANDLES.hfigdmnd, ...
      'style','pushbutton', ...
      'position',btnpos, ...
      'string','Statistical Analysis', ...
      'callback',['set(HANDLES.hmctl(1),''visible'',''on''),',...
         'figure(HANDLES.hmctl(1)),']);
	
set(HANDLES.hratpb,'visible','off')

return
