function editgeomsetup
%
%  Name: editgeom.m
% 
%  Usage: editgeom.m
% 
%   Description:
%     Interactive Definition
%     of Nodes, Tracelines, Bars, Shells, SEMBeams, and SEMquads
%
%  Version SWD970707
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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

HANDLES.heditgeom(1) = figure('Name','DIAMOND: EditGeom', ...
   'units','normal',...
	'NumberTitle','off', ...
   'menubar','none',...
   'visible','off',...
	'Position',[0.1 0.1 0.8 0.8]);

%
% Define Frame Around Controls
%

HANDLES.heditgeom(2) = uicontrol('style','frame','pos',[0.00 0.74 1.0 0.26]);

%
%  Define selection switch for geometry editor
%

HANDLES.heditgeom(3) = uicontrol('style','popup',...
   'position',[0.05 0.90 0.2 0.05],...
   'string','Nodes|Bars|SEMbeams|SEMquads|Shells|Tracelines',...
   'callback',['EDITGEOM.nselsw = get(HANDLES.heditgeom(3),''value'');',...
      'set(HANDLES.heditgeom(5),''value'',EDITGEOM.ilab(EDITGEOM.nselsw)),',...
      'listgeom']);
%
%  Define Listbox for current set
%

HANDLES.heditgeom(4) = uicontrol('style','listbox',...
   'pos',[0.26 0.76 0.58 0.25],...
   'String','uninitialized',...
   'fontname','Courier');


%
%  Define Label Switch
%

HANDLES.heditgeom(5) = uicontrol('style','checkbox',...
		'position',[0.05 0.85 0.20 0.05],...
		'string','Show Labels',...
      'callback',...
      ['EDITGEOM.ilab(EDITGEOM.nselsw) = get(HANDLES.heditgeom(5),''value'');',...
         'GEOM.inodelab = EDITGEOM.ilab(1);',...
         'GEOM.ibarlab  = EDITGEOM.ilab(2);',...
         'GEOM.itracelab = EDITGEOM.ilab(6);']);
   
%
%  Define Edit Button
%

HANDLES.heditgeom(6) = uicontrol('style','pushbutton',...
		'position',[0.85 0.95 0.14 0.04],...
		'string','Edit',...
      'callback',...
      ['switch EDITGEOM.nselsw,',...
      'case 1, titlestr = EDITGEOM.titlestr(1,1:end-1); bodystr = num2str(GEOM.Nodes);',...
      'case 2, titlestr = EDITGEOM.titlestr(1,1:end-1); bodystr = num2str(GEOM.Bars);',...
      'case 3, titlestr = EDITGEOM.titlestr(1,1:end-1); bodystr  = ''''; for i = 1:length(GEOM.SEMbeams), bodystr = strvcat(bodystr,num2str(GEOM.SEMbeams{i})); end,',...
      'case 4, titlestr = EDITGEOM.titlestr(1,1:end-1); bodystr  = ''''; for i = 1:length(GEOM.SEMquads), bodystr = strvcat(bodystr,num2str(GEOM.SEMquads{i})); end,',...
      'case 5, titlestr = EDITGEOM.titlestr(1,1:end-1); bodystr = num2str(GEOM.Shells);',...
      'case 6, titlestr = EDITGEOM.titlestr(1,1:end-1); bodystr = num2str(GEOM.Tracelines);',...
      'end,',...
      'set(HANDLES.heditgeom(11),''string'',titlestr),',...
      'set(HANDLES.heditgeom(12),''string'',bodystr),',...
      'set(HANDLES.heditgeom(10),''visible'',''on''),',...
      ]); 
   % 'uiwait(HANDLES.heditgeom(10))']);


%
%  Define Geometry Axes
%

HANDLES.heditgeom(7) =  axes('position',[0.01 0.05 0.8 0.65],'dataaspectratio',[1 1 1]);

%%
%%
%%  Define the Update-Geometry Button
%%
%%

HANDLES.heditgeom(8) = uicontrol('style','push',...
	'units','normal',...
	'pos',[.05 .80 .20 .05],...
   'string','Update Geometry Display',...
   'callback',['updtgeom(HANDLES.heditgeom(7),GEOM.Nodes),',...
      'set(HANDLES.heditgeom(7),''dataaspectratio'',[1 1 1]),',...
      'rotate3d on']);

%%
%%
%%  Define the Exit Button
%%
%%

HANDLES.heditgeom(9) = uicontrol('style','push',...
	'units','normal',...
	'pos',[.775 .01 .2 .04],...
        'string','Exit EditGeom',...
        'callback','set(HANDLES.heditgeom(1),''visible'',''off'')');
     
     
%%
%%  Set up EDIT STRING popup dialog
%%
     
HANDLES.heditgeom(10) = figure('Name','DIAMOND: EditString', ...
   'units','normal',...
	'NumberTitle','off', ...
   'menubar','none',...
   'visible','off',...
   'Position',[0.25 0.4 0.5 0.25]);

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

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

HANDLES.heditgeom(13) = uicontrol('style','pushbutton',...
   'position',[0.80 0.01 0.15 0.14],...
   'string','Close',...
   'callback',[...
      'switch EDITGEOM.nselsw,',...
      '	case 1, GEOM.Nodes = str2num(get(HANDLES.heditgeom(12),''string'')); ',...
      '	case 2, GEOM.Bars  = str2num(get(HANDLES.heditgeom(12),''string'')); ',...
      '  case 3, tempstr = get(HANDLES.heditgeom(12),''string''); GEOM.SEMbeams = {}; for i =1:size(tempstr,1), tempnum = str2num(tempstr(i,:)); if ~isempty(tempnum), GEOM.SEMbeams{i} = tempnum; end, end,',...
      '  case 4, tempstr = get(HANDLES.heditgeom(12),''string''); GEOM.SEMquads = {}; for i =1:size(tempstr,1), tempnum = str2num(tempstr(i,:)); if ~isempty(tempnum), GEOM.SEMquads{i} = tempnum; end, end,',...
      '	case 5, GEOM.Shells  = str2num(get(HANDLES.heditgeom(12),''string'')); ',...
      '	case 6, GEOM.Tracelines  = str2num(get(HANDLES.heditgeom(12),''string'')); ',...
      'end,',...
      'listgeom,',...
      'set(HANDLES.heditgeom(10),''visible'',''off''),',...
      'uiresume,']);

return
