function mrptbtns
%
% Function: mrptbtns
% 
% Usage: mrptbtns
% 
% Description:
%    Initializes the MRPT matrix update window
%    Handles and graphics elements.
%    Returns a vector to those elements.
%

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

%%===========================================%
%% 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];
HANDLES.hmrptb(1)=uicontrol(HANDLES.hfigdmnd, ...
        'Style','Frame', ...
        'Position',frmpos, ...
        'BackgroundColor',[.5 .5 .5]);
%
% Set up plot axes
%

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

%
% Set up legend axes
%

HANDLES.hmrptb(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];
HANDLES.hmrptb(3)=uicontrol(HANDLES.hfigdmnd, ...
      'style','pushbutton', ...
      'position',btnpos, ...
      'string','Damage Vector', ...
      'Callback', ...
	[' fprintf(1,''\nComputing Damage Vector...''),',...
	 'MODELCOR.dvecs = mrptdvec(MODELCOR.modelK,MODELCOR.modelM,MODELCOR.measmode{MODELCOR.mode_anal},MODELCOR.measFreq{MODELCOR.mode_anal});',...
	 '[MODELCOR.dvecs, MODELCOR.dvecsdof] = reducedv(MODELCOR.dvecs,MODELCOR.modelmatrixDOF, MODELCOR.nmrptdof);',...
	 'axes(MODELCOR.haxes), cla, hold off, bar(MODELCOR.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];
HANDLES.hmrptb(4)=uicontrol(HANDLES.hfigdmnd, ...
      'style','pushbutton', ...
      'position',btnpos, ...
      'string','Stiffness Perturb.', ...
      'Callback', ...
	[' fprintf(1,''\nComputing Stiffness Matrix Perturbation...''),',...
	 ' MODELCOR.DI = mrptstmt(MODELCOR.modelK,MODELCOR.modelM,MODELCOR.measmode{MODELCOR.mode_anal},MODELCOR.measFreq{MODELCOR.mode_anal});',...
	 ' [MODELCOR.DI,MODELCOR.DIdof] = reduceDI(MODELCOR.DI, MODELCOR.modelmatrixDOF, MODELCOR.nmrptdof);',...
	 ' fprintf(1,''done\n Generating 3-D plot of perturbation...''),',...
	 ' [xfp,yfp] = meshgrid([1:size(MODELCOR.DIdof,1)],[1:size(MODELCOR.DIdof,1)]);',...
	 ' zcont = [-0.9 -0.5 0.5 0.9] * max(abs(MODELCOR.DI(:)));',...
	 ' cutoff = 2 * mean(std(MODELCOR.DI)); zlab = ''Stiffness Matrix Reduction (%)'';',...
    ' set(HANDLES.hmrptb([5 8]),''visible'',''on''),',...
    ' if isfield(GEOM,''Shells''),',...
    '  if ~isempty(GEOM.Shells),',...
    '    plotdam(xfp,yfp,MODELCOR.DI,''DOF'',''DOF'',zlab,cutoff,MODELCOR.haxes,4,0,GEOM.Shells,GEOM.Nodes,0,0);',...
    '  end,',...
    ' end,',...
    ' if isfield(GEOM,''Bars''),',...
    '   if ~isempty(GEOM.Bars),',...
	 '      plotdam(xfp,yfp,MODELCOR.DI,''DOF'',''DOF'',zlab,cutoff,MODELCOR.haxes,4,0,GEOM.Bars,GEOM.Nodes,0,0);',...
    '   end,',...
    ' end,',...
    ' axis normal,',...
    ' rotate3d on,',...
    ' fprintf(1,''done\n''),']);


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

%
% Select the Matrix DOF to display
%

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

%
%  Show the selected DOF location on the geometry
%

btnnum=6;
ypos=top-(btnnum-1)*(btnht+spacing);
btnpos=[left ypos-btnht btnwd btnht];
HANDLES.hmrptb(8)=uicontrol(HANDLES.hfigdmnd, ...
      'style','pushbutton', ...
      'position',btnpos, ...
      'string','Locate DOF', ...
      'Callback', ...
	['axes(MODELCOR.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];
HANDLES.hmrptb(9)=uicontrol(HANDLES.hfigdmnd, ...
      '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];
HANDLES.hmrptb(11)=uicontrol(HANDLES.hfigdmnd, ...
      'style','popupmenu', ...
      'position',btnpos, ...
      'string','Nodal|Elemental');

set(HANDLES.hmrptb,'visible','off');

return