%
% Script: showloc
%
% Usage: showloc
% 
% Description:
%    Displays the location of the point with DOF of 'xd' and 'yd'
%	Following variables must be defined in workspace:
%		DIdof
%		Nodes
%		Bars

% Version SWD970405
%
% Author(s): Scott W. Doebling, doebling@lanl.gov
%
% Institution: Los Alamos National Laboratory, ESA-EA
%
% Copyright (c) 1997, The Regents of the University
%     	of California. (See top level of code for full copyright
%	statement.)

%
% Determine the node numbers and directions from the DOF numbers
%

xd = round(xd);
yd = round(yd);

xloc = DIdof(xd, 1);
xdir = DIdof(xd, 2);

yloc = DIdof(yd, 1);
ydir = DIdof(yd, 2);

%
% Create new figure (with close button)
%

hshowloc(1) = figure('units','pixels','position',[ -2    30   642   433],...
			'menubar','none','numbertitle','off','resize','on',...
			'name','Diamond: Show DOF Location','visible','off');



%
%  Close Button

hshowloc(2) = uicontrol(hshowloc(1),...
	'style','push',...
	'units','normal',...
	'position',[0.0 0.0 0.1 0.05],...
	'string','Close',...
	'call','delete(hshowloc(1))');

%
%  Axes
%

hshowloc(3) = axes('parent',hshowloc(1),'position',[.1 .1 .9 .9]);


%
%
%  Draw undeformed geometry and highlight appropriate node numbers
%

xnrow = find(Nodes(:,1) == xloc);
ynrow = find(Nodes(:,1) == yloc);

updtgeom('-',[1 0 0],Nodes,Bars,Shells,30,30,hshowloc(3),14,[xnrow ynrow])

axis('equal')

view(0,90)

axis(1.15 * [min(Nodes(:,2)) max(Nodes(:,2)) min(Nodes(:,3)) max(Nodes(:,3))])



%
% Draw arrows from selected nodes
%

%  First, find axis limits to determine necessary arrow lengths

%xlim = get(hshowloc(3),'xlim');
%ylim = get(hshowloc(3),'ylim');
%zlim = get(hshowloc(3),'zlim');

%arlen(1) = (max(xlim) - min(xlim)) * 0.2;
%arlen(2) = (max(ylim) - min(ylim)) * 0.2;
%arlen(3) = (max(zlim) - min(zlim)) * 0.2;

%  Draw arrow for xloc, xdir


%if ~isempty(xnrow),

%    xnrow = xnrow(1);

%    xstart = Nodes(xnrow,2:4);

 %   xdirvec = zeros(1,3);
	
  %  if abs(xdir) >= 1 & abs(xdir) <= 3,  xdc=abs(xdir); else  xdc=abs(xdir)-3; end
	
   % xdirvec(xdc) = 1;
	
    %xend = xstart + sign(xdir) * arlen(xdc) * xdirvec; 
	
	
    %axes(hshowloc(3))
	
    %axis(axis)
	  
   % if abs(xdir) >= 1 & abs(xdir) <= 3, cstr = 'r'; else, cstr = 'w'; end
	
    %arrow(xstart,xend,20,60,20,2,'color',cstr)
	
%    text(max(xlim),0,0,'Red = Trans.    White = Rot.')

%end

%if ~isempty(ynrow),

 %   ynrow = ynrow(1);

  %  ystart = Nodes(ynrow,2:4);

   % ydirvec = zeros(1,3);
	
%    if abs(ydir) >= 1 & abs(ydir) <= 3,  ydc=abs(ydir); else ydc=abs(ydir)-3; end
	
%    ydirvec(ydc) = 1;
	
%    yend = ystart + sign(ydir) * arlen(ydc) * ydirvec; 
	
	
%    axes(hshowloc(3))
	
%    axis(axis)
	  
%    if abs(ydir) >= 1 & abs(ydir) <= 3, cstr = 'r'; else, cstr = 'w'; end
	
%    arrow(ystart,yend,20,60,20,2,'color',cstr)
	
%end

%
% DONE
%