startmacro fn:infile fn:outfile
!
! MORPHDEMO - Demo the MORPH primitive
! @author Jeff Schoen
! @version $Id: morphdemo.mm,v 1.2 2007/05/02 19:54:21 jph Exp $
!
res outfile outfile
noop infile outfile
invoke operList nxm.dsp.prim.morph.operList
res operList "^{operList},POLY"

pipe/panel/setup/controls=gc on

plot infile|outfile

gcontrol button "ACTION" "Action  " "Refresh,Exit" 
gcontrol choice "OPER" "Operator  " operList "NOOP"
gcontrol lval "WIDTH1" "Width 1   " 31 1 128 1
gcontrol lval "WIDTH2" "Width 2   " 31 1 128 1
gcontrol lval "ITER"   "Iterations" 1 1 8 1
gcontrol fval "ALPHA"  "Alpha     " 1 0 2 0.1
gcontrol lval "ORDER"  "Poly Order" 4 0 32 1

pipe off

endmacro

procedure processMessage
if msg.name eqs "ACTION" then
  if msg.data eqs "EXIT" then
    stop
    return
  endif
endif
if gc.OPER.value eqs "NOOP" then
  noop infile outfile
elseif gc.OPER.value eqs "POLY" then
  polyfit infile gc.order.value fit=outfile
else
  morph infile outfile gc.OPER.value gc.WIDTH1.value gc.WIDTH2.value IN gc.ITER.value gc.ALPHA.value
endif
message send "PLOT" ,, "FILE" ,, "REREAD" 

return

