function makedofsetup
%
%  Name:   makedof
%
%  Usage:  makedof
%
%   Create the variables respDOF and refDOF
%

%
%  Version SWD980301
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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 EDITDOF

%
% buttons for the respDOF window
%

HANDLES.hmakedof(1)=figure( ...
	'Name','measDOF', ...
	'NumberTitle','off', ...
	'Units','normal', ...
	'Position',[0.1 0.1 0.5 0.5],...
   'menubar','none',...
   'visible','off',...
	'resize','off');

%
%  List box for number of measurement channels
%

top = 0.13;
left = 0.30;
btnwd = 0.4;
btnht = 0.05;
spacing = 0.01;

btnnum=0;
ypos=top-(btnnum)*(btnht+spacing);
btnpos=[left ypos-btnht 3*btnwd/4 btnht];
HANDLES.hmakedof(2) = uicontrol(HANDLES.hmakedof(1),...
      'style','text', ...
      'unit','normalized', ...
      'position',btnpos, ...
      'string','# Meas. Chan:');
         
btnnum=0;
ypos=top-(btnnum)*(btnht+spacing);
btnpos=[left+3*btnwd/4 ypos-btnht btnwd/4 btnht];
HANDLES.hmakedof(3)=uicontrol(HANDLES.hmakedof(1),...
      'style','edit', ...
      'unit','normalized', ...
      'position',btnpos, ...
      'backgroundcolor','w', ...
       'callback',['EDITDOF.nmeaschan = str2num(get(HANDLES.hmakedof(3),''string''));']);

btnnum=1;
ypos=top-(btnnum)*(btnht+spacing);
btnpos=[left ypos-btnht 3*btnwd/4 btnht];
HANDLES.hmakedof(4) =uicontrol(HANDLES.hmakedof(1),...
      'style','text', ...
      'unit','normalized', ...
      'position',btnpos, ...
      'backgroundcolor',[1 1 1], ...
      'string','Ref. Chan:');
         
btnnum=1;
ypos=top-(btnnum)*(btnht+spacing);
btnpos=[left+3*btnwd/4 ypos-btnht btnwd/4 btnht];
HANDLES.hmakedof(5)=uicontrol(HANDLES.hmakedof(1),...
      'style','edit', ...
      'unit','normalized', ...
      'position',btnpos, ...
      'backgroundcolor',[1 1 1], ...
       'callback',['EDITDOF.nrefchan = str2num(get(HANDLES.hmakedof(5),''string''));',...
			 'disp([''Ref. Channel set to '',num2str(EDITDOF.nrefchan)]),']);

%
% Display listbox
%    
    
HANDLES.hmakedof(6)=uicontrol(HANDLES.hmakedof(1), ...
	'style','listbox', ...
	'units','normal', ...
	'pos',[0 .15 .95 .8], ...
	'back','white',...
   'String','uninitialized',...
   'fontname','Courier');


%
%  automatic generation button for nodes
%
HANDLES.hmakedof(7)= uicontrol(HANDLES.hmakedof(1), ...
	'style','push', ...
	'units','normal', ...
	'pos',[.71 .08 .28 .05], ...
	'string','Auto number', ...
   'callback',['EDITDOF.nodenum=(1:EDITDOF.nmeaschan)''; ', ...
      'EDITDOF.respDOF = [ [1:EDITDOF.nmeaschan]'' EDITDOF.dofdiropt*ones(EDITDOF.nmeaschan,1)];',...
		'listdof']);
%
%  automatic generation directions
%
HANDLES.hmakedof(8)=uicontrol(HANDLES.hmakedof(1), ...
	'style','popup', ...
	'units','normal', ...
	'pos',[.71 .01 .25 .05], ...
	'string',' x  |  y  |  z', ...
   'callback','EDITDOF.dofdiropt=get(HANDLES.hmakedof(8),''value'');');
   
%   
% Edit button
%
HANDLES.hmakedof(9) = uicontrol(HANDLES.hmakedof(1),...
   'style','push', ...
	'units','normal', ...
	'pos',[.04 .08 .25 .05], ...
	'string','Edit', ...
   'callback',...
   ['titlestr = EDITDOF.titlestr(1,1:end-1);',... 
   'bodystr = num2str([[1:size(EDITDOF.respDOF,1)]'' EDITDOF.respDOF]);',...
   'set(HANDLES.hmakedof(12),''string'',titlestr),',...
   'set(HANDLES.hmakedof(13),''string'',bodystr),'...
   'set(HANDLES.hmakedof(11),''visible'',''on''),']);

%
% Close button
%
HANDLES.hmakedof(10) = uicontrol(HANDLES.hmakedof(1),...
   'style','push', ...
	'units','normal', ...
	'pos',[.04 .015 .25 .05], ...
	'string','Save & Close', ...
   'callback',['if ~isempty(EDITDOF.respDOF), EDITDOF.refDOF = EDITDOF.respDOF(EDITDOF.nrefchan,:); end,',...
      'DATA{1}.respDOF = [EDITDOF.respDOF(1:EDITDOF.nrefchan-1,:);EDITDOF.respDOF((EDITDOF.nrefchan+1):end,:)];',...
      'DATA{1}.refDOF = EDITDOF.refDOF;',...
      'MODES.respDOF = EDITDOF.respDOF;',...
      'set(HANDLES.hmakedof(1),''visible'',''off''),']);

HANDLES.hmakedof(11) = figure('Name','DIAMOND: EditDOF', ...
   'units','normal',...
	'NumberTitle','off', ...
   'menubar','none',...
   'visible','off',...
   'Position',[0.25 0.4 0.5 0.25]);

HANDLES.hmakedof(12) = uicontrol(HANDLES.hmakedof(11),...
   'style','text',...
   'position',[0.02 0.90 0.96 0.10],...
   'horizontalalignment','left');

HANDLES.hmakedof(13) = uicontrol(HANDLES.hmakedof(11),...
   'style','edit',...
   'position',[0.02 0.15 0.96 0.75],...
   'horizontalalignment','left',...
   'max',2);

HANDLES.hmakedof(14) = uicontrol(HANDLES.hmakedof(11),...
   'style','pushbutton',...
   'position',[0.80 0.01 0.15 0.14],...
   'string','Close',...
   'callback',[...
      'temp = str2num(get(HANDLES.hmakedof(13),''string'')); EDITDOF.respDOF = temp(:,2:3);',...
      'listdof, set(HANDLES.hmakedof(11),''visible'',''off'')']);

return
