function dummy = deletepz(Editor)
%DELETEPZ  Deletes pole or zero graphically.

%   Author(s): P. Gahinet
%   Copyright 1986-2000 The MathWorks, Inc. 
%   $Revision: 1.6 $  $Date: 2000/06/14 20:21:48 $

% REVISIT
dummy = [];

% Pointers
HG = Editor.HG;
CompData = Editor.LoopData.Compensator;
if isempty(CompData.PZGroup)  
    % Nothing to delete
    return
end

% Acquire pole/zero position 
CP = get(HG.PlotAxes,'CurrentPoint');     % mouse position
Lims = get(HG.PlotAxes,{'Xlim','Ylim'});  % axis extent
Xscale = Lims{1}(2)-Lims{1}(1);
Yscale = Lims{2}(2)-Lims{2}(1);

% Determine nearest match
hPZ = [get(HG.Compensator,{'Zero'}) ; get(HG.Compensator,{'Pole'})];
hPZ = cat(1,hPZ{:});
X = get(hPZ,{'Xdata'});  X = cat(1,X{:});
Y = get(hPZ,{'Ydata'});  Y = cat(1,Y{:});
[distmin,imin] = ...
    min(abs(((CP(1,1)-X)/Xscale).^2 + ((CP(1,2)-Y)/Yscale).^2));

if distmin < 0.03^2,
    % Identify selected group and get its description
    SelectedGroup = get(get(hPZ(imin),'UserData'),'GroupData');
    isel = find(CompData.PZGroup==SelectedGroup);
    Description = describe(CompData.PZGroup(isel),CompData.Ts);
    
    % Start transaction
    T = handle.transaction(get(findpackage('sisodata'),'DefaultDatabase'));
    set(T,'Name',sprintf('Delete %s',Description{1}),...
        'OperationStore','on','InverseOperationStore','on');
    
    % Delete selected group from list of compensator PZ groups
    delete(CompData.PZGroup(isel));
    CompData.PZGroup = CompData.PZGroup([1:isel-1,isel+1:end],:);
    
    % Register transaction
    register(Editor.LoopData,T);
    
    % Notify peers of deletion
    dataevent(Editor.LoopData,'all');
    
    % Notify status and history listeners
    Status = sprintf('Deleted %s',Description{2});
    Editor.up.send('StatusChanged',...
        sisodata.dataevent(Editor.up,'StatusChanged',{Status,Status}));
end
