function pdffbtns
%
%  Function: pdffbtns
% 
%  Usage: pdffbtns
% 
%  Description:
%    Initializes the Probability Density Function Fit Window
%

%
%  Version SWD970807
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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 

%====================================
% General buttons parameters
%====================================
top=.95;
left=.84;
btnwd=.15;
btnht=.06;
spacing=.01;

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

%
% Set up plot axes
%

%Upper Twin Axes
HANDLES.hpdff(2) = axes('position',[.1 .62 .7 .3]);

%Lower Twin Axes
HANDLES.hpdff(3) = axes('position',[.1 .12 .7 .3]);

%
%  To choose which Response DOF to plot
%
btnnum=2;
ypos=top-(btnnum)*(btnht+spacing);
btnpos=[left ypos-btnht btnwd*0.6 btnht];
HANDLES.hpdff(4)= uicontrol(HANDLES.hfigdmnd, ...
      'style','text', ...
      'unit','normalized', ...
      'position',btnpos, ...
      'string','Resp');
btnpos=[left+btnwd*0.6 ypos-btnht btnwd*0.6 btnht];
HANDLES.hpdff(5)=uicontrol(HANDLES.hfigdmnd, ...
      'style','edit', ...
      'unit','normalized', ...
      'position',btnpos, ...
      'string','1', ...
      'back','white', ...
      'callback',...
      ['iresp_t=str2num(get(HANDLES.hpdff(5),''string''));',...
         'if isempty(iresp_t),',...
         '   disp(''Resp # out of Range''),',...
         'elseif DISPLAY{iaxes}.iresp{1}> size(DATA{DISPLAY{iaxes}.idatafile{inds}}.respDOF,1),',...
         '   disp('' Resp # out of Range''),',...
         'elseif DISPLAY{iaxes}.iresp{1}< 1,',...
         '   disp(''Resp # out of Range''),',...
         'else,',...
         '    DISPLAY{iaxes}.iresp{1} = iresp_t;',...
         'end,',...
         'set(HANDLES.hpdff(5),''string'',num2str(DISPLAY{iaxes}.iresp{1})),',...
         'pdffplot']);


%
%  To choose which Reference DOF to plot
%
btnnum=3;
ypos=top-(btnnum)*(btnht+spacing);
btnpos=[left ypos-btnht btnwd*0.6 btnht];
HANDLES.hpdff(6)=uicontrol(HANDLES.hfigdmnd, ...
      'style','text', ...
      'unit','normalized', ...
      'position',btnpos, ...
      'string','Ref');
btnpos=[left+btnwd*0.6 ypos-btnht btnwd*0.6 btnht];
HANDLES.hpdff(7)=uicontrol(HANDLES.hfigdmnd, ...
      'style','edit', ...
      'unit','normalized', ...
      'position',btnpos, ...
      'string','1', ...
      'back','white', ...
      'callback',...
      ['iref_t=str2num(get(HANDLES.hpdff(7),''string''));',...
         'if isempty(iref_t),',...
         '   disp(''Ref # out of Range''),',...
         'elseif iref_t > size(DATA{DISPLAY{iaxes}.idatafile{inds}}.refDOF,1),',...
         '   disp(''Ref # out of Range''),',...
         'elseif iref_t < 1,',...
         '   disp(''Ref # out of Range''),',...
         'else,',...
         '    DISPLAY{iaxes}.iref{1} = iref_t;',...
         'end,',...
         'set(HANDLES.hpdff(7),''string'',num2str(DISPLAY{iaxes}.iref{1})),',...
         'pdffplot']);

   
%
%  Y axis log scaling
%

btnnum=5;
ypos=top-(btnnum)*(btnht+spacing);
btnpos=[left ypos-btnht btnwd*1.2 btnht*0.5];
HANDLES.hpdff(8) = uicontrol(HANDLES.hfigdmnd, ...
	'style','check',...
	'units','normal',...
	'position',btnpos,...
	'string','Log Scale',...
	'value',1,...
	'callback',[' DISPLAY{2}.iylog = get(HANDLES.hpdff(8),''value'');',...
      ' switch  DISPLAY{2}.iylog,',...
      '  case 0, set(DISPLAY{2}.haxes,''yscale'',''linear''),',...
      '  case 1, set(DISPLAY{2}.haxes,''yscale'',''log''),',...
      ' end,']);

%   Ensemble number selector

btnnum=4;
ypos=top-(btnnum)*(btnht+spacing);
btnpos=[left ypos-btnht btnwd*0.75 btnht*0.7];
HANDLES.hpdff(9)= uicontrol(HANDLES.hfigdmnd, ...
      'style','text', ...
      'unit','normalized', ...
      'position',btnpos, ...
      'string','Ensemble #');
btnpos=[left+btnwd*0.75 ypos-btnht btnwd*0.45 btnht*0.7];
HANDLES.hpdff(10)=uicontrol(HANDLES.hfigdmnd, ...
      'style','edit', ...
      'unit','normalized', ...
      'position',btnpos, ...
      'string','1', ...
      'back','white', ...
      'callback',...
      ['iavg_t=str2num(get(HANDLES.hpdff(10),''string''));',...
         'if isempty(iavg_t),',...
         '   disp(''Ensemble # out of Range''),',...
         'elseif iavg_t > size(DATA{DISPLAY{iaxes}.idatafile{inds}}.thist,4),',...
         '   disp(''Ensemble # out of Range''),',...
         'elseif iavg_t < 1,',...
         '   disp(''Ensemble # out of Range''),',...
         'else,',...
         '    DISPLAY{iaxes}.iavg{1} = iavg_t;',...
         'end,',...
         'set(HANDLES.hpdff(10),''string'',num2str(DISPLAY{iaxes}.iavg{1})),',...
         'pdffplot']);

set(HANDLES.hpdff,'visible','off')

return
