function [hanalc] = ancpbtns(figNumber)
% Function: ancpbtns.m
% 
% Usage: hanalc = ancpbtns(figNumber);
% 
% Description:
%    Initializes the Analyze Complex Modes Window
%    Handles and graphics elements.
%    Returns a vector to those elements.
%
% Version SWD970618
%
% 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=.06;
spacing=.01;

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

%
% Set up plot axes
%

hanalc(2) = axes('position',[.1 .20 .7 .7]);

%
%  Input/Output mode shape selector
%

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

%
% Define Text box for Mode Number
%

btnnum=2.75;
ypos=top-(btnnum-1)*(btnht+spacing)+2*spacing;
btnpos=[left+0.5*btnwd ypos-btnht btnwd*0.5 btnht];
hanalc(4) = uicontrol('style','edit',...
	'pos',btnpos,...
        'string',1,...
	'callback','nmod = str2num(get(onHndlVector(4),''string''));');

btnnum=2.75;
ypos=top-(btnnum-1)*(btnht+spacing)+2*spacing;
btnpos=[left ypos-btnht btnwd*0.5 btnht];
hanalc(5)=uicontrol('style','text',...
	'pos',btnpos,...
    	'string','Mode');

%
%  Define Previous and Next Mode Buttons
%
btnnum=3.25;
ypos=top-(btnnum-1)*(btnht+spacing)+2*spacing;
btnpos=[left ypos-btnht btnwd*0.5 btnht*0.5];
hanalc(6) = uicontrol('style','push',...
	'pos',btnpos,...
        'string','prev', ...
  	'callback',['nmod=nmod-1;', ...
		'set(onHndlVector(4),''string'',num2str(nmod));', ...
	  'if nmod<1,', ...
	     'disp(''Mode out of range''),', ...
	     'nmod=1;', ...
	     'set(onHndlVector(4),''string'',num2str(nmod));', ... 
	  'end;']);

btnnum=3.25;
ypos=top-(btnnum-1)*(btnht+spacing)+2*spacing;
btnpos=[left+0.5*btnwd ypos-btnht btnwd*0.5 btnht*0.5];
hanalc(7) = uicontrol('style','push',...
	'pos',btnpos,...
        'string','next', ...
  	'callback',['nmod=nmod+1;', ...
		'set(onHndlVector(4),''string'',num2str(nmod));', ...
	  'if nmod>size(Phiplot,2),', ...
	     'disp(''Mode out of range''),', ...
	     'nmod=size(Phiplot,2);', ...
	     'set(onHndlVector(4),''string'',num2str(nmod));', ...
	  'end;']);


%
% MPC Button
%
btnnum=4.5;
ypos=top-(btnnum-1)*(btnht+spacing)+2*spacing;
btnpos=[left ypos-btnht btnwd btnht];
hanalc(8)=uicontrol(figNumber, ...
      'style','pushbutton', ...
      'position',btnpos, ...
      'string','Plot MPC',...
      'callback',['hideall(onHndlVector(10:12)),',...
		  'showall(onHndlVector(2)),',...
		  'ipltcmplx = 2; iplt_t =0; asphiplt;',...
		  'onHndlVector(2)= mpcplot(onHndlVector(2),Phiplot(:,nmod),Freqplot(nmod));']);


%
% List Magnitudes and phases
%
btnnum=5.5;
ypos=top-(btnnum-1)*(btnht+spacing)+2*spacing;
btnpos=[left ypos-btnht btnwd btnht];
hanalc(9)=uicontrol(figNumber, ...
      'style','pushbutton', ...
      'position',btnpos, ...
      'string','Mag & Phase',...
      'callback',['showall(onHndlVector(10:12)),',...
		  'hideall(onHndlVector(2)),',...
		  'ipltcmplx = 2; iplt_t =0; asphiplt;',...
		  'textin = magphstx(respDOF,Phiplot(:,nmod),Freqplot(nmod));',...
		  '[htext,onHndlVector(11)]=textslid(onHndlVector(12),htext,onHndlVector(11),textin);']);

%
% Text window for listing magnitudes and phases
%
titlestring=sprintf('%-8s   %-8s   %-8s   %-8s','DOF Loc.','DOF Dir','Mag (db)','Phase (deg.)');
hanalc(10)=uicontrol(figNumber, ...
      'style','text', ...
      'position',[.05 .89 .7 .06], ...
	'horizontalalignment','left',...
	'string',titlestring);

% 
% Slider axes
%
hanalc(11)=axes('position',[.05 .05 .7 .84], ...
	  	'color',[.8 .8 .8], ...
		'XtickLabel',[], ...
		'YtickLabel',[]);

%
% Add the vertical slider
%
hanalc(12) = uicontrol('Style','slider', ...
 	'Position',[.72 .05 .03 .84], ...
	'min',-2, ...
	'max',-1, ...
	'UserData',[], ...
	'Value',-1, ...
      	'CallBack',['uu=get(onHndlVector(12),''UserData'');', ...
		 'axes(onHndlVector(11));', ...
		 'rval = get(onHndlVector(12),''Value'');', ...
                 'dy = uu(1);', ...
		 'if (rval-round(rval))>eps,', ...       % Test for +step
                 '  rval = ceil(rval);', ...               
                 'elseif (rval-round(rval)) < -eps,', ... % Test for -step
                 '  rval = floor(rval);', ...
                 'end,', ...
                 'miny = 1-(floor(abs(rval))-1)*abs(dy);', ...
                 'maxy = miny+20*abs(dy);', ...
                 'set(onHndlVector(12),''Value'',rval),', ...    % Set the step
                 'axis([1 56  miny maxy]),']);

%
% Complex-to-Real Conversion Button
%

btnnum=7.5;
ypos=top-(btnnum-1)*(btnht+spacing)+2*spacing;
btnpos=[left ypos-btnht btnwd btnht];
hanalc(13)=uicontrol(figNumber, ...
      'style','pushbutton', ...
      'position',btnpos, ...
      'string','Create Real',...
      'callback','c2rdlg');



%
%  Delete Mode Button
%
btnnum=8.5;
ypos=top-(btnnum-1)*(btnht+spacing)+2*spacing;
btnpos=[left ypos-btnht btnwd*2/3 btnht];
hanalc(14) = uicontrol(	'style','push', ...
	'string','Delete #', ...
	'position',btnpos, ...
	'callback',['numdel=str2num(get(onHndlVector(15),''string''));', ...
	'Freq(numdel)=[];', ...
	'Damp(numdel)=[];', ...
	'phic_resp(:,numdel)=[];', ...
   'phic_ref(:,numdel)=[];',...
   'phir_resp(:,numdel)=[];', ...
   'phir_ref(:,numdel)=[];',...
   'if exist(''Freqall'')==1,',...
   '  Freqall(numdel,:) = [];',...
   '  Dampall(numdel,:) = [];',...
   '  Phicrespall(:,:,numdel) = [];',...
   '  Phicrefall(:,:,numdel) = [];',...
   'end,',...
   'disp([''Mode Number '',num2str(numdel),'' deleted.'']),']);

btnpos=[left+btnwd*2/3 ypos-btnht btnwd/3 btnht];
hanalc(15)=uicontrol('style','edit', ...
	'back','w', ...
	'position',btnpos);

set(hanalc,'visible','off')

return




