%
%  Name: editgeom.m
% 
%  Usage: editgeom.m
% 
%   Description:
%     Interactive Definition
%     of Nodes as well as Bar and Shell Connectivity
%
%  Version SWD970707
%
%  Author(s): Scott Doebling, doebling@lanl.gov
%	Phillip Cornwell, cornwell@lanl.gov
%
%  Institution: Los Alamos National Laboratory,
%		ESA-EA
%
%  Copyright (c) 1996-1997, The Regents of the University
%     	of California. (See top level of code for
%

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


%%
%% Set default values for variables
%%



if ~exist('ilab'), ilab = [1 0 0 0 0]; end

if ~exist('nselsw'), nselsw = 1; end

if ~exist('Nodes'), Nodes = []; end
if ~exist('Bars'), Bars = []; end
if ~exist('Shells'), Shells = []; end
if ~exist('SEMbeams'), SEMbeams = {}; end
if ~exist('SEMquads'), SEMquads = {}; end

%
% Define Frame Around Controls
%

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

%
%  Define selection switch for geometry editor
%

hselsw = uicontrol('style','popup',...
   'position',[0.05 0.90 0.2 0.05],...
   'string','Nodes|Bars|Shells|SEMbeams|SEMquads',...
   'value',nselsw,...
   'callback',['nselsw = get(hselsw,''value'');',...
      'set(hlab,''value'',ilab(nselsw)),',...
      'switch nselsw,',...
      '	case 1, listnode,',...
      '	case 2, listbars,',...
      '	case 3, listshls,',...
      '	case 4, listSEMbeams,',...
      '	case 5, listSEMquads,',...
      'end,']);

%
%  Define Listbox for current set
%

hlistbox = uicontrol('style','listbox',...
   'pos',[0.26 0.76 0.58 0.29],...
   'String','uninitialized',...
   'fontname','Courier');


%
%  Define Label Switch
%

hlab = uicontrol('style','checkbox',...
		'position',[0.05 0.85 0.20 0.05],...
		'string','Show Labels',...
		'value',ilab(nselsw),...
		'callback','ilab(nselsw) = get(hlab,''value'');');
   
%
%  Define Edit Button
%

hedit = uicontrol('style','pushbutton',...
		'position',[0.85 0.95 0.14 0.04],...
		'string','Edit',...
      'callback','editstr');

%
%  Define Geometry Axes
%

hageom =  axes('position',[0.01 0.05 0.8 0.65]);
rotate3d on

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

higeomupdate = uicontrol('style','push',...
	'units','normal',...
	'pos',[.05 .80 .20 .05],...
   'string','Update Geometry Display',...
   'callback',['axes(hageom), cla,'...
      'updtgeom(''-'',ilab,Nodes,Bars,Shells,hageom,14,[])']);

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

hexit = uicontrol('style','push',...
	'units','normal',...
	'pos',[.775 .01 .2 .04],...
        'string','Exit EditGeom',...
        'callback','delete(fh)');
     
%%
%%  Draw the geometry already in the workspace
%%

set(hageom,'dataaspectratio',[1 1 1]), 

if ~isempty(Nodes),
   updtgeom('-',ilab,Nodes,Bars,Shells,hageom,14,[]);
end

%
%  Initialize the listbox
%

eval(get(hselsw,'callback'))

