function hmrpt = mrptbtns(figNumber)
% Function: mrptbtns.m
% 
% Usage: hmrpt = mrptbtns(figNumber);
% 
% Description:
%    Initializes the MRPT matrix update window
%    Handles and graphics elements.
%    Returns a vector to those elements.
%

% Version SWD970405
%
% 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.

%%===========================================%
%% MRPT Model Update Buttons
%%===========================================

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

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

hmrpt(2) = axes('position',[.1 .30 .7 .6]);

%
% Set up legend axes
%

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


%
%  Compute and  plot the damage vector
%
btnnum=3;
ypos=top-(btnnum-1)*(btnht+spacing);
btnpos=[left ypos-btnht btnwd btnht];
hmrpt(3)=uicontrol(figNumber, ...
      'style','pushbutton', ...
      'position',btnpos, ...
      'string','Damage Vector', ...
      'Callback', ...
	[' fprintf(1,''\nComputing Damage Vector...''),',...
	 'dvecs = mrptdvec(K_u,M_u,phir_resp_d(:,mode_anal),Freq_d(mode_anal));',...
	 '[dvecs, dvecsdof] = reducedv(dvecs,matrixDOF_u, nmrptdof);',...
	 'axes(haxes), cla, hold off, bar(dvecs),',...
	 ' fprintf(1,''done\n''),']);

%
%  Compute and plot the stiffness matrix perturbation
%
btnnum=4;
ypos=top-(btnnum-1)*(btnht+spacing);
btnpos=[left ypos-btnht btnwd btnht];
hmrpt(4)=uicontrol(figNumber, ...
      'style','pushbutton', ...
      'position',btnpos, ...
      'string','Stiffness Perturb.', ...
      'Callback', ...
	[' fprintf(1,''\nComputing Stiffness Matrix Perturbation...''),',...
	 ' DI = mrptstmt(K_u,M_u,phir_resp_d(:,mode_anal),Freq_d(mode_anal));',...
	 ' [DI,DIdof] = reduceDI(DI, matrixDOF_u, nmrptdof);',...
	 ' fprintf(1,''done\n Generating 3-D plot of perturbation...''),',...
	 ' [xfp,yfp] = meshgrid([1:size(DIdof,1)],[1:size(DIdof,1)]);',...
	 ' zcont = [-0.9 -0.5 0.5 0.9] * max(max(abs(DI)));',...
	 ' cutoff = 2 * mean(std(DI)); zlab = ''Stiffness Matrix Reduction (%)'';',...
    ' set(onHndlVector([5 8]),''visible'',''on''),',...
    ' if ~isempty(Shells),',...
	 ' plotdam(xfp,yfp,DI,''DOF'',''DOF'',zlab,cutoff,haxes,4,0,Shells,Nodes,0,0);',...
    ' elseif ~isempty(Bars),',...
	 ' plotdam(xfp,yfp,DI,''DOF'',''DOF'',zlab,cutoff,haxes,4,0,Bars,Nodes,0,0);',...
    ' end,',...
    ' axis normal,',...
    ' rotate3d on,',...
    ' fprintf(1,''done\n''),']);

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

hmrpt(5) = uicontrol('position',[0 0 eps eps]);

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

%
% Select the Matrix DOF to display
%

btnnum=2;
ypos=top-(btnnum-1)*(btnht+spacing);
btnpos=[left ypos-btnht btnwd btnht];
hmrpt(7)=uicontrol(figNumber, ...
      'style','popup', ...
      'position',btnpos, ...
      'string','X Trans|Y Trans|Z Trans|X Rot|Y Rot|Z Rot', ...
      'Value',3,...
      'Callback', ...
	['nmrptdof = get(onHndlVector(7),''value'');']);

%
%  Show the selected DOF location on the geometry
%

btnnum=6;
ypos=top-(btnnum-1)*(btnht+spacing);
btnpos=[left ypos-btnht btnwd btnht];
hmrpt(8)=uicontrol(figNumber, ...
      'style','pushbutton', ...
      'position',btnpos, ...
      'string','Locate DOF', ...
      'Callback', ...
	['axes(haxes), [xd,yd]=ginput(1); showloc,']);

%
%  Plot damage indicator on geometry
%

btnnum=7;
ypos=top-(btnnum-1)*(btnht+spacing);
btnpos=[left ypos-btnht btnwd btnht];
hmrpt(9)=uicontrol(figNumber, ...
      'style','pushbutton', ...
      'position',btnpos, ...
      'string','Plot DI on Geom', ...
      'Callback','plotmrpt');
   
%
%  Select Nodal or Elemental Damage indicators
%

btnnum=8;
ypos=top-(btnnum-1)*(btnht+spacing);
btnpos=[left ypos-btnht btnwd btnht];
hmrpt(11)=uicontrol(figNumber, ...
      'style','popupmenu', ...
      'position',btnpos, ...
      'string','Nodal|Elemental');

set(hmrpt,'visible','off');

return