function [hflex] = flexbtns(figNumber)
% Function: flexbtns.m
% 
% Usage: hflex = flexbtns(figNumber);
% 
% Description:
%    Initializes the Flexibility Analysis Window
%    Handles and graphics elements.
%    Returns a vector to those elements.
%

% Version SWD970521
%
% Author(s): Erik Straser, estraser@lanl.gov
%	modified by Scott W. Doebling, doebling@lanl.gov
%
% Institution: Los Alamos National Laboratory, ESA-EA
%
% Copyright (c) 1996-1997, The Regents of the University
%     	of California.

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

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

%
% Set up plot axes
%

hflex(2) = axes('position',[.1 .22 .7 .7]);

%
% Set up legend axes
%

hflex(15) = axes('position',[.1 .1 .7 .10]);

%
%  Input/Output mode shape selector
%

btnnum=1;
ypos=top-(btnnum-1)*(btnht+spacing)+2*spacing;
btnpos=[left ypos-btnht btnwd btnht];
hflex(3)  = uicontrol(figNumber, ...
      'style','popup', ...
      'position',btnpos, ...
      'Value',1,...
      'string','Resp DOF|Ref DOF', ...
       'callback','iopDOF=get(onHndlVector(3),''value'');');


%
% Loading DOF Textbox
%
btnnum=2;
ypos=top-(btnnum-1)*(btnht+spacing)+2*spacing;
btnpos=[left ypos-btnht btnwd btnht/2];
hflex(4)=uicontrol(figNumber, ...
      'style','text', ...
      'position',btnpos, ...
      'string','Loaded DOF');

btnpos=[left ypos-btnht*3/2 btnwd btnht/2];
hflex(5)=uicontrol(figNumber, ...
      'style','edit', ...
      'position',btnpos, ...
      'string','1',...
	'callback',['iflexdof = str2num(get(onHndlVector(5),''string''));',...
			' if iopDOF == 1, ndof = size(respDOF_u,1);',...
			' else, ndof = size(refDOF_u,1); end,',...
			' if iflexdof < 1,',...
			'   iflexdof = 1; set(onHndlVector(5),''string'',num2str(iflexdof)),',...
			' elseif iflexdof > ndof,',...
			'   iflexdof = ndof; set(onHndlVector(5),''string'',num2str(iflexdof)),',...
			' end,']);
%
%  Positive/Negative Loading
%

btnnum=3.0;
ypos=top-(btnnum-1)*(btnht+spacing)+2*spacing;
btnpos=[left ypos-btnht btnwd btnht/2];
hflex(13)  = uicontrol(figNumber, ...
      'style','text', ...
      'position',btnpos, ...
      'string','Loading Sign');

btnpos(2) = btnpos(2) - btnht/2;
hflex(6)  = uicontrol(figNumber, ...
      'style','popup', ...
      'position',btnpos, ...
      'Value',1,...
      'string','Positive|Negative',...
      'callback',['  if get(onHndlVector(6),''value'') == 1,',...
		'	iflexsgn = 1;',...
		'    else,',...
		'	iflexsgn = -1;',...
		'    end,']);

%
%  Flexibility Loading Type
%

btnnum=4;
ypos=top-(btnnum-1)*(btnht+spacing)+2*spacing;
btnpos=[left ypos-btnht btnwd btnht/2];
hflex(7)  = uicontrol(figNumber, ...
      'style','text', ...
      'position',btnpos, ...
      'string','Loading Type');

btnpos(2) = btnpos(2) - btnht/2;
hflex(8)  = uicontrol(figNumber, ...
      'style','popup', ...
      'position',btnpos, ...
      'Value',1,...
      'string','Uniform|Multi-Point|Single Point',...
	'callback',['   nflexload = get(onHndlVector(8),''value'');',...
		' 	if nflexload == 3,',...
		'	  set(onHndlVector(4:5),''visible'',''on''),',...
		'  	  iflexdof = str2num(get(onHndlVector(5),''string''));',...
		'	else,',...
		'	  set(onHndlVector(4:5),''visible'',''off''),',...
		'	end']);



%
%  Plot Type
%

btnnum=5;
ypos=top-(btnnum-1)*(btnht+spacing)+2*spacing;
btnpos=[left ypos-btnht btnwd btnht/2];
hflex(14)  = uicontrol(figNumber, ...
      'style','text', ...
      'position',btnpos, ...
      'string','Plot Type');

btnpos(2) = btnpos(2) - btnht/2;
hflex(9)  = uicontrol(figNumber, ...
      'style','popup', ...
      'position',btnpos, ...
      'Value',1,...
      'string','Flex Change|Undam Flex|Dam Flex',...
	'callback','iflextype = get(onHndlVector(9),''value'');');
	

%
% Plot Flexibility Shape
%

btnnum=7;
ypos=top-(btnnum-1)*(btnht+spacing)+2*spacing;
btnpos=[left ypos-btnht btnwd btnht];
hflex(10)=uicontrol(figNumber, ...
      'style','pushbutton', ...
      'position',btnpos, ...
      'string','Plot Flex',...
      'callback',['if iopDOF == 1,',...
 		'   Flex_u = phir_resp_u(:,mode_anal)/diag(2*pi*Freq_u(mode_anal))^2 * phir_resp_u(:,mode_anal)'';',...
		'   Flex_d = phir_resp_d(:,mode_anal)/diag(2*pi*Freq_d(mode_anal))^2 * phir_resp_d(:,mode_anal)'';',...
		'elseif iopDOF == 2,',...
		'   Flex_u = phir_ref_u(:,mode_anal)/diag(2*pi*Freq_u(mode_anal))^2 * phir_ref_u(:,mode_anal)'';',...
		'   Flex_d = phir_ref_d(:,mode_anal)/diag(2*pi*Freq_d(mode_anal))^2 * phir_ref_d(:,mode_anal)'';',...	
		'end,',...
		'plotflex, set(onHndlVector(11),''visible'',''on'')']);

%
%  Display tools button
%

%btnnum=8;
%ypos=top-(btnnum-1)*(btnht+spacing);
%btnpos=[left ypos-btnht btnwd btnht];
%hflex(11)=uicontrol(figNumber, ...
%      'style','pushbutton', ...
%      'position',btnpos, ...
%      'string','Display Tools', ...
%      'Callback', ...
%	'set(hdamtl(1),''visible'',''on''), figure(hdamtl(1))');

hflex(11) = uicontrol('position',[0 0 eps eps]);

%
% Select the modes to use in the analysis
%
btnnum=9;
ypos=top-(btnnum-1)*(btnht+spacing);
btnpos=[left ypos-btnht btnwd btnht];
hflex(12)=uicontrol(figNumber, ...
      'style','pushbutton', ...
      'position',btnpos, ...
      'string','Select Modes', ...
      'Callback', ...
	['set(hmdsel(1),''visible'',''on''), figure(hmdsel(1)),']);

set(hflex,'visible','off')

return

