function delresp(ResponseLine);
%DELRESP Delete Response Objects from the command line
%
%  DELRESP(ResponseLine) deletes all axes associated with 
%  the Response Object for the response line with handle 
%  ResponseLine except for the axes containing the line.

%   Authors: Karen Gondoly, 7-8-98
%   Revised: Adam DiVergilio
%   Copyright 1986-2000 The MathWorks, Inc. 
%   $Revision: 1.8 $  $Date: 2000/06/14 19:59:09 $

if ishandle(ResponseLine),
   CallBackAx=get(ResponseLine,'Parent');
   if ishandle(CallBackAx),
      
      if isequal(get(ResponseLine,'Tag'),'BackgroundResponseObjectLine'),
         %---Invoked from a BackgroundAxes
         BackAx = CallBackAx;
         ContextMenu = get(ResponseLine,'UserData');
         if ishandle(ContextMenu),
            RespObj = get(ContextMenu,'UserData');
            PlotAxes = get(RespObj,'PlotAxes');
            udAx = get(PlotAxes(1),'UserData');
         else
            return
         end
      else
         % Invoked from a Plot axes
         udAx = get(CallBackAx,'UserData');
         BackAx = udAx.Parent;
         if ishandle(BackAx)
            ResponseLine = findobj(udAx.Parent,'Tag','BackgroundResponseObjectLine');
            ContextMenu = get(ResponseLine,'UserData');
            if ishandle(ContextMenu)
               RespObj = get(ContextMenu,'UserData');
            else
               return
            end
         else
            return
         end % if/else ishandle(BackAx)
      end
      
      set(BackAx,'Unit','Norm');
      BackPos = get(BackAx,'Position');
      
      %---Close any I/O selector
      RespMenu = get(RespObj,'UIcontextMenu');
      SelectorHandle = get(RespMenu.ChannelMenu,'UserData');
      if ishandle(SelectorHandle),
         close(SelectorHandle)
      end % if ishandle(SelectorHandle)
      
      %---Close any array selector
      ArrayHandle = get(RespMenu.ArrayMenu,'UserData');
      if ishandle(ArrayHandle),
         %---Must delete the Array Selector since its CloseRequest
         %      function has been reset
         delete(ArrayHandle)
      end % if ishandle(SelectorHandle)
      
      %---Delete all other axes except the callback axes
      set(ResponseLine,'DeleteFcn','');
      DispAx = [udAx.Siblings(:);BackAx];
      DispAx = DispAx(ishandle(DispAx));
      if ~isempty(DispAx)
         LTIlines = findobj(DispAx,'Tag','LTIresponseLines');
         set(LTIlines,'DeleteFcn','');
         DispAx = setdiff(DispAx,CallBackAx);
         delete(DispAx)
      end
          
      if isequal(CallBackAx,gca),
         %---Reset the axes if it is still around. If the figure was destroyed
         %    the current axes is no longer the CallBackAx
         cla reset; % Remove all other PlotAxes settings and lines
         set(CallBackAx,'Unit','Norm','Position',BackPos, ...
            'FontSize',get(0,'DefaultAxesFontSize'), ...
            'UIcontextMenu',[])
      end

      %---Delete the uicontextmenu
      delete(RespMenu.Main);

   end
end
