;pkrmi  interactive
;
; this macro permits to interactively and graphically
; remove peaks from the peak table
;
; see also : PKRM MONOPOINT pkrm_diag pkrmz

if ($dim==3) error "Not implemented yet!"
set ss = $scolor
refmacro 1 
if ($scolor < 6) then
	scolor ($scolor+1)
else
	scolor 2
endif
showpeaks
alert "click on the peak you want to remove"
monopoint
set i = 2  set pic = 1
if ($dim==1) then
  set d = (abs($pk1d_f[1]-$pointx[1]))
  for i = 2 to $npk1d
    set tt = (abs($pk1d_f[$i]-$pointx[1]))
    if ($tt < $d) set pic = $i set d = $tt
    if ($d == 0) goto fin
  endfor
else
  set d = (abs($pk2d_f2f[1]-$pointx[1])+abs($pk2d_f1f[1]-$pointy[1]))
  for i = 2 to $npk2d
    set tt = (abs($pk2d_f2f[$i]-$pointx[1])+abs($pk2d_f1f[$i]-$pointy[1]))
    if ($tt < $d) set pic = $i set d = $tt
    if ($d == 0) goto fin
  endfor
endif
=fin
scolor $ss
showpeak $pic
gm/al_yesno ("Ok to remove peak #"//$pic;"?") 
if ($returned s= "yes") pkrm $pic 0
ref
showpeaks
refmacro 0
exit



