function makedof
%
%  Name:   makeDOF
%
%  Usage:  makeDOF
%
%  This m-file allows the user to map the
%  measurement channels to the response DOF and
%  reference DOF

% 
%  Version SWD970806
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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 EDITDOF GEOM DATA HANDLES

%  Configure EDITDOF global fields

if ~isfield(EDITDOF,'respDOF')
   if ~isfield(GEOM,'respDOF')
      if ~isempty(DATA),
         if ~isfield(DATA{1},'respDOF')
            EDITDOF.respDOF = [];
         else
            EDITDOF.respDOF = DATA{1}.respDOF;
            EDITDOF.nmeaschan = size(EDITDOF.respDOF,1);
         end
      else
         EDITDOF.respDOF = [];
      end    
   else
      EDITDOF.respDOF = GEOM.respDOF;
      EDITDOF.nmeaschan = size(EDITDOF.respDOF,1);
   end
end

if ~isfield(EDITDOF,'refDOF')
   if ~isfield(GEOM,'refDOF')
      if ~isempty(DATA),
         if ~isfield(DATA{1},'refDOF')
            EDITDOF.refDOF = [];
         else
            EDITDOF.refDOF = DATA{1}.refDOF;
         end
      else
         EDITDOF.refDOF = [];
      end
   else
      EDITDOF.refDOF = GEOM.refDOF;
   end
end

if ~isfield(EDITDOF,'nmeaschan'),
   if ~isempty(DATA),
      EDITDOF.nmeaschan = size(DATA{1}.G,2);
   elseif ~isempty(EDITDOF.respDOF),
      EDITDOF.nmeaschan = size(EDITDOF.respDOF,1);
   else
      EDITDOF.nmeaschan = 1;   
   end
end

if ~isfield(EDITDOF,'nrefchan'),
   if ~isempty(DATA),
      EDITDOF.nrefchan = size(DATA{1}.G,3);
   elseif ~isempty(EDITDOF.refDOF),
      EDITDOF.nrefchan = size(EDITDOF.refDOF,1);
   else
      EDITDOF.nrefchan = 1;   
   end
end

if ~isfield(EDITDOF,'dofdiropt')
   EDITDOF.dofdiropt = 3;
end

%  Configure controls in makedof to reflect current variables

set(HANDLES.hmakedof(3),'string',num2str(EDITDOF.nmeaschan))
set(HANDLES.hmakedof(5),'string',num2str(EDITDOF.nrefchan))
set(HANDLES.hmakedof(8),'value',EDITDOF.dofdiropt)

%  Initialize the DOF list

listdof

%  Make the window visible

set(HANDLES.hmakedof(1),'visible','on')

return