(FILECREATED "11-Feb-84 17:53:57" {PHYLUM}<LISPUSERS>USER.SOURCE;2 15077  

      changes to:  (FNS USER.INIT USER.CREATE.PARAMS USER.CREATE.TRAJS USER.INTERPOLATE 
			USER.INTERPOLATE.PNAME USER.CREATE.WINDOW USER.REPAINTFN USER.BUTTONEVENTFN 
			USER.CREATE.MENU USER.WHENSELECTEDFN USER.EDITTRAJ USER.DRAWLINE 
			USER.ERASELINE USER.DRAWPOINT USER.MIDDLEBUTTONFN USER.LEFTBUTTONFN 
			USER.PROMPT&ADD USER.ADDPOINT USER.GETPARAM USER.SETPARAM))


(PRETTYCOMPRINT USERCOMS)

(RPAQQ USERCOMS ((INITVARS (USER.TRAJS NIL)
			   (USER.WINDOW NIL)
			   (USER.MENU NIL)
			   (USER.TMIN 0)
			   (USER.TMAX 700)
			   (USER.VMIN 0)
			   (USER.VMAX 200)
			   (USER.PNAMES '(AV ASV FGP BGP FGZ BGZ BGS SWITCH AFRIC AASPIR NCF F0 A1 B1 
					     F1 A2 B2 F2 A3 B3 F3 A4 B4 F4 A5 B5 F5 A6 B6 F6 FNZ BNZ 
					     ANP FNP BNP AB GAIN))
			   (USER.DEFAULT.PARAM NIL)
			   (USER.MAX.PARAM NIL)
			   (USER.MIN.PARAM NIL)
			   (USER.COMMAND.MENU (CREATE MENU ITEMS ← '(PROMPT&ADD POINT&ADD 
										PROMPT&DELETE 
										POINT&DELETE 
										POINT&MOVE)))
			   (USER.COMMAND 'ADD))
	(RECORDS POINT)
	(FNS USER.INIT USER.CREATE.PARAMS USER.CREATE.TRAJS USER.INTERPOLATE USER.INTERPOLATE.PNAME 
	     USER.CREATE.WINDOW USER.REPAINTFN USER.BUTTONEVENTFN USER.CREATE.MENU 
	     USER.WHENSELECTEDFN USER.EDITTRAJ USER.DRAWLINE USER.ERASELINE USER.DRAWPOINT 
	     USER.MIDDLEBUTTONFN USER.LEFTBUTTONFN USER.PROMPT&ADD USER.ADDPOINT USER.GETPARAM 
	     USER.SETPARAM)
	(P (LOAD? '{PHYLUM}<LISPCORE>LIBRARY>ATTACHEDWINDOW.DCOM))))

(RPAQ? USER.TRAJS NIL)

(RPAQ? USER.WINDOW NIL)

(RPAQ? USER.MENU NIL)

(RPAQ? USER.TMIN 0)

(RPAQ? USER.TMAX 700)

(RPAQ? USER.VMIN 0)

(RPAQ? USER.VMAX 200)

(RPAQ? USER.PNAMES '(AV ASV FGP BGP FGZ BGZ BGS SWITCH AFRIC AASPIR NCF F0 A1 B1 F1 A2 B2 F2 A3 B3 F3 
			A4 B4 F4 A5 B5 F5 A6 B6 F6 FNZ BNZ ANP FNP BNP AB GAIN))

(RPAQ? USER.DEFAULT.PARAM NIL)

(RPAQ? USER.MAX.PARAM NIL)

(RPAQ? USER.MIN.PARAM NIL)

(RPAQ? USER.COMMAND.MENU (CREATE MENU ITEMS ← '(PROMPT&ADD POINT&ADD PROMPT&DELETE POINT&DELETE 
							   POINT&MOVE)))

(RPAQ? USER.COMMAND 'ADD)
[DECLARE: EVAL@COMPILE 

(RECORD POINT (TIME . VALUE))
]
(DEFINEQ

(USER.INIT
  (LAMBDA NIL                                                (* kbr: "11-Feb-84 17:53")
    (PROG NIL
          (COND
	    ((NULL USER.WINDOW)
	      (SETQ USER.WINDOW (USER.CREATE.WINDOW))))
          (COND
	    ((NULL USER.MENU)
	      (SETQ USER.MENU (USER.CREATE.MENU))))
          (COND
	    ((NULL USER.DEFAULT.PARAM)
	      (USER.CREATE.PARAMS)))
          (COND
	    ((NULL USER.TRAJS)
	      (SETQ USER.TRAJS (USER.CREATE.TRAJS)))))))

(USER.CREATE.PARAMS
  (LAMBDA NIL                                                (* kbr: "11-Feb-84 17:53")
    (PROG NIL
          (SETQ USER.DEFAULT.PARAM
	    (CREATE PARAM
		    AV ← 60
		    ASV ← 0
		    AASPIR ← 0
		    AFRIC ← 0
		    F0 ← 120
		    FGP ← 0
		    BGP ← 100
		    FGZ ← 1500
		    BGZ ← 6000
		    FNP ← 250
		    BNP ← 100
		    FNZ ← 250
		    BNZ ← 100
		    BGS ← 200
		    F1 ← 680
		    B1 ← 90
		    F2 ← 1890
		    B2 ← 200
		    F3 ← 2650
		    B3 ← 170
		    F4 ← 3300
		    B4 ← 250
		    F5 ← 3850
		    B5 ← 200
		    F6 ← 4900
		    B6 ← 1000
		    A1 ← 0
		    ANP ← 0
		    A2 ← 0
		    A3 ← 0
		    A4 ← 0
		    A5 ← 0
		    A6 ← 0
		    AB ← 0
		    SWITCH ← 'CASCADE
		    GAIN ← 36
		    NCF ← 5))
          (SETQ USER.MIN.PARAM
	    (CREATE PARAM
		    AV ← 0
		    ASV ← 0
		    AASPIR ← 0
		    AFRIC ← 0
		    F0 ← 0
		    FGP ← 0
		    BGP ← 50
		    FGZ ← 750
		    BGZ ← 3000
		    FNP ← 125
		    BNP ← 50
		    FNZ ← 250
		    BNZ ← 50
		    BGS ← 100
		    F1 ← 200
		    B1 ← 40
		    F2 ← 600
		    B2 ← 40
		    F3 ← 1300
		    B3 ← 40
		    F4 ← 1650
		    B4 ← 125
		    F5 ← 1925
		    B5 ← 100
		    F6 ← 2450
		    B6 ← 500
		    A1 ← 0
		    ANP ← 0
		    A2 ← 0
		    A3 ← 0
		    A4 ← 0
		    A5 ← 0
		    A6 ← 0
		    AB ← 0
		    SWITCH ← 'CASCADE
		    GAIN ← 0
		    NCF ← 5))
          (SETQ USER.MAX.PARAM
	    (CREATE PARAM
		    AV ← 80
		    ASV ← 80
		    AASPIR ← 80
		    AFRIC ← 80
		    F0 ← 400
		    FGP ← 500
		    BGP ← 200
		    FGZ ← 3000
		    BGZ ← 12000
		    FNP ← 500
		    BNP ← 200
		    FNZ ← 700
		    BNZ ← 200
		    BGS ← 400
		    F1 ← 900
		    B1 ← 500
		    F2 ← 2400
		    B2 ← 500
		    F3 ← 3100
		    B3 ← 500
		    F4 ← 6600
		    B4 ← 500
		    F5 ← 7700
		    B5 ← 400
		    F6 ← 9800
		    B6 ← 2000
		    A1 ← 80
		    ANP ← 80
		    A2 ← 80
		    A3 ← 80
		    A4 ← 80
		    A5 ← 80
		    A6 ← 80
		    AB ← 80
		    SWITCH ← 'CASCADE
		    GAIN ← 100
		    NCF ← 5)))))

(USER.CREATE.TRAJS
  (LAMBDA NIL                                                (* kbr: "11-Feb-84 17:53")
    (PROG (TRAJS VALUE)
          (SETQ TRAJS (CREATE PARAM))
          (FOR PNAME IN USER.PNAMES
	     DO (SETQ VALUE (USER.GETPARAM PNAME USER.DEFAULT.PARAM))
		(USER.SETPARAM PNAME (LIST (CREATE POINT
						   TIME ← USER.TMIN
						   VALUE ← VALUE)
					   (CREATE POINT
						   TIME ← USER.TMAX
						   VALUE ← VALUE))
			       TRAJS))
          (RETURN TRAJS))))

(USER.INTERPOLATE
  (LAMBDA (PARAM TIME TRAJS)                                 (* kbr: "11-Feb-84 17:53")
    (PROG NIL
          (FOR PNAME IN USER.PNAMES WHEN (NOT (MEMB PNAME '(SWITCH NCF)))
	     DO (USER.INTERPOLATE.PNAME PNAME TIME TRAJS)))))

(USER.INTERPOLATE.PNAME
  (LAMBDA (PNAME TIME TRAJS)                                 (* kbr: "11-Feb-84 17:53")
    (PROG (TRAJ LEFTPOINT RIGHTPOINT LTIME RTIME LVALUE RVALUE K VALUE)
          (SETQ TRAJ (USER.GETPARAM PNAME TRAJS))
          (FOR L IN TRAJ AS R IN (CDR TRAJ) WHEN (AND (ILEQ (fetch (POINT TIME) of L)
							    TIME)
						      (IGREATERP (fetch (POINT TIME) of R)
								 TIME))
	     DO (SETQ LEFTPOINT L)
		(SETQ RIGHTPOINT R)
		(RETURN))
          (SETQ LTIME (fetch (POINT TIME) of LEFTPOINT))
          (SETQ RTIME (fetch (POINT TIME) of RIGHTPOINT))
          (SETQ LVALUE (fetch (POINT VALUE) of LEFTPOINT))
          (SETQ RVALUE (fetch (POINT VALUE) of RIGHTPOINT))
          (SETQ K (FQUOTIENT (FDIFFERENCE TIME LTIME)
			     (FDIFFERENCE RTIME LTIME)))
          (SETQ VALUE (FPLUS (FTIMES K RVALUE)
			     (FTIMES (FDIFFERENCE 1.0 K)
				     LVALUE)))
          (USER.SETPARAM PNAME VALUE TRAJS))))

(USER.CREATE.WINDOW
  (LAMBDA NIL                                                (* kbr: "11-Feb-84 17:53")
    (PROG (WINDOW)
          (SETQ WINDOW (CREATEW NIL "USER WINDOW"))
          (WINDOWPROP WINDOW 'REPAINTFN 'USER.REPAINTFN)
          (WINDOWPROP WINDOW 'BUTTONEVENTFN 'USER.BUTTONEVENTFN)
          (RETURN WINDOW))))

(USER.REPAINTFN
  (LAMBDA (WINDOW)                                           (* kbr: "11-Feb-84 17:53")
                                                             (* WINDOW = USER.WINDOW. *)
    (PROG (TRAJ)
          (CLEARW WINDOW)
          (SETQ TRAJ (USER.GETPARAM (WINDOWPROP WINDOW 'PNAME)
				    USER.TRAJS))
          (FOR POINT1 IN TRAJ AS POINT2 IN (CDR TRAJ) WHILE POINT2 DO (USER.DRAWLINE POINT1 POINT2))
          (FOR POINT IN TRAJ DO (USER.DRAWPOINT POINT)))))

(USER.BUTTONEVENTFN
  (LAMBDA (WINDOW)                                           (* kbr: "11-Feb-84 17:53")
    (TOTOPW WINDOW)
    (COND
      ((LASTMOUSESTATE MIDDLE)
	(USER.MIDDLEBUTTONFN))
      ((LASTMOUSESTATE LEFT)
	(USER.LEFTBUTTONFN)))))

(USER.CREATE.MENU
  (LAMBDA NIL                                                (* kbr: "11-Feb-84 17:53")
    (PROG (MENU)
          (SETQ MENU (CREATE MENU
			     TITLE ← "USER MENU"
			     ITEMS ← USER.PNAMES
			     MENUCOLUMNS ← 7
			     WHENSELECTEDFN ← 'USER.WHENSELECTEDFN))
          (ATTACHMENU MENU USER.WINDOW 'TOP 'RIGHT)          (* This causes MENU to open. *)
          (CLOSEW USER.WINDOW)
          (OPENW USER.WINDOW)                                (* Okey Dokey. *)
          (RETURN MENU))))

(USER.WHENSELECTEDFN
  (LAMBDA (ITEM MENU KEY)                                    (* kbr: "11-Feb-84 17:53")
    (PROG NIL
          (SHADEITEM ITEM MENU BLACKSHADE)
          (USER.EDITTRAJ ITEM)
          (SHADEITEM ITEM MENU WHITESHADE))))

(USER.EDITTRAJ
  (LAMBDA (PNAME)                                            (* kbr: "11-Feb-84 17:53")
    (PROG (TRAJ)
          (SETQ USER.VMIN (USER.GETPARAM PNAME USER.MIN.PARAM))
          (SETQ USER.VMAX (USER.GETPARAM PNAME USER.MAX.PARAM))
          (SETQ TRAJ (USER.GETPARAM PNAME USER.TRAJS))
          (WINDOWPROP USER.WINDOW 'PNAME PNAME)
          (WINDOWPROP USER.WINDOW 'TRAJ TRAJ)
          (REDISPLAYW USER.WINDOW)                           (* TBW *)
      )))

(USER.DRAWLINE
  (LAMBDA (POINT1 POINT2)                                    (* kbr: "11-Feb-84 17:53")
    (PROG (T1 V1 T2 V2 X1 Y1 Y2 X2 HEIGHT WIDTH)
          (SETQ T1 (fetch (POINT TIME) of POINT1))
          (SETQ V1 (fetch (POINT VALUE) of POINT1))
          (SETQ T2 (fetch (POINT TIME) of POINT2))
          (SETQ V2 (fetch (POINT VALUE) of POINT2))
          (SETQ HEIGHT (WINDOWPROP USER.WINDOW 'HEIGHT))
          (SETQ WIDTH (WINDOWPROP USER.WINDOW 'WIDTH))
          (SETQ X1 (FIXR (FTIMES WIDTH (FQUOTIENT (FDIFFERENCE T1 USER.TMIN)
						  (FDIFFERENCE USER.TMAX USER.TMIN)))))
          (SETQ Y1 (FIXR (FTIMES HEIGHT (FQUOTIENT (FDIFFERENCE V1 USER.VMIN)
						   (FDIFFERENCE USER.VMAX USER.VMIN)))))
          (SETQ X2 (FIXR (FTIMES WIDTH (FQUOTIENT (FDIFFERENCE T2 USER.TMIN)
						  (FDIFFERENCE USER.TMAX USER.TMIN)))))
          (SETQ Y2 (FIXR (FTIMES HEIGHT (FQUOTIENT (FDIFFERENCE V2 USER.VMIN)
						   (FDIFFERENCE USER.VMAX USER.VMIN)))))
          (DRAWLINE X1 Y1 X2 Y2 1 'PAINT USER.WINDOW))))

(USER.ERASELINE
  (LAMBDA (POINT1 POINT2)                                    (* kbr: "11-Feb-84 17:53")
    (PROG (T1 V1 T2 V2 X1 Y1 Y2 X2 HEIGHT WIDTH)
          (SETQ T1 (fetch (POINT TIME) of POINT1))
          (SETQ V1 (fetch (POINT VALUE) of POINT1))
          (SETQ T2 (fetch (POINT TIME) of POINT2))
          (SETQ V2 (fetch (POINT VALUE) of POINT2))
          (SETQ HEIGHT (WINDOWPROP USER.WINDOW 'HEIGHT))
          (SETQ WIDTH (WINDOWPROP USER.WINDOW 'WIDTH))
          (SETQ X1 (FIXR (FTIMES WIDTH (FQUOTIENT (FDIFFERENCE T1 USER.TMIN)
						  (FDIFFERENCE USER.TMAX USER.TMIN)))))
          (SETQ Y1 (FIXR (FTIMES HEIGHT (FQUOTIENT (FDIFFERENCE V1 USER.VMIN)
						   (FDIFFERENCE USER.VMAX USER.VMIN)))))
          (SETQ X2 (FIXR (FTIMES WIDTH (FQUOTIENT (FDIFFERENCE T2 USER.TMIN)
						  (FDIFFERENCE USER.TMAX USER.TMIN)))))
          (SETQ Y2 (FIXR (FTIMES HEIGHT (FQUOTIENT (FDIFFERENCE V2 USER.VMIN)
						   (FDIFFERENCE USER.VMAX USER.VMIN)))))
          (DRAWLINE X1 Y1 X2 Y2 1 'ERASE USER.WINDOW))))

(USER.DRAWPOINT
  (LAMBDA (POINT)                                            (* kbr: "11-Feb-84 17:53")
    (PROG NIL                                                (* TBW: Draw spot at point. *)
      )))

(USER.MIDDLEBUTTONFN
  (LAMBDA NIL                                                (* kbr: "11-Feb-84 17:53")
    (PROG (COMMAND)
          (SETQ COMMAND (MENU USER.COMMAND.MENU))
          (COND
	    (COMMAND (SETQ USER.COMMAND COMMAND)
		     (SELECTQ USER.COMMAND
			      (PROMPT&ADD (USER.PROMPT&ADD))
			      (PROMPT&DELETE (USER.PROMPT&DELETE))
			                                     (* Wait for point. *)))))))

(USER.LEFTBUTTONFN
  (LAMBDA NIL                                                (* kbr: "11-Feb-84 17:53")
    (SELECTQ USER.COMMAND
	     (POINT&ADD (USER.POINT&ADD))
	     (POINT&DELETE (USER.POINT&DELETE))
	     (POINT&MOVE (USER.PROMPT&MOVE))
	     NIL)))

(USER.PROMPT&ADD
  (LAMBDA NIL                                                (* kbr: "11-Feb-84 17:53")
    (PROG (TIME VALUE POINT)
          (DO (FRESHLINE PROMPTWINDOW)
	      (SETQ TIME (MKATOM (PROMPTFORWORD "TIME = " NIL NIL PROMPTWINDOW)))
	      (COND
		((OR (NOT (NUMBERP TIME))
		     (ILESSP TIME USER.TMIN)
		     (IGREATERP TIME USER.TMAX))
		  (RETURN)))
	      (FRESHLINE PROMPTWINDOW)
	      (SETQ VALUE (MKATOM (PROMPTFORWORD "VALUE = " NIL NIL PROMPTWINDOW)))
	      (COND
		((NOT (NUMBERP VALUE))
		  (RETURN)))
	      (SETQ POINT (CREATE POINT
				  TIME ← TIME
				  VALUE ← VALUE))
	      (USER.ADDPOINT POINT)))))

(USER.ADDPOINT
  (LAMBDA (POINT)                                            (* kbr: "11-Feb-84 17:53")
    (PROG (TIME VALUE TRAJ N OLDPOINT RIGHTPOINT LEFTPOINT)
          (SETQ TIME (fetch (POINT TIME) of POINT))
          (SETQ VALUE (fetch (POINT VALUE) of POINT))
          (SETQ TRAJ (WINDOWPROP USER.WINDOW 'TRAJ))
          (COND
	    ((IEQP TIME USER.TMIN)
	      (USER.ERASELINE (CAR (NTH TRAJ 1))
			      (CAR (NTH TRAJ 2)))
	      (replace (POINT VALUE) of (CAR (NTH TRAJ 1)) with VALUE)
	      (USER.DRAWLINE (CAR (NTH TRAJ 1))
			     (CAR (NTH TRAJ 2))))
	    ((IEQP TIME USER.TMAX)
	      (SETQ N (LENGTH TRAJ))
	      (USER.ERASELINE (CAR (NTH TRAJ (SUB1 N)))
			      (CAR (NTH TRAJ N)))
	      (replace (POINT VALUE) of (CAR (NTH TRAJ N)) with VALUE)
	      (USER.DRAWLINE (CAR (NTH TRAJ (SUB1 N)))
			     (CAR (NTH TRAJ N))))
	    ((SETQ OLDPOINT (FOR P IN TRAJ THEREIS (IEQP TIME (fetch (POINT TIME) of P))))
	      (SETQ N (LENGTH (MEMB OLDPOINT TRAJ)))
	      (USER.ERASELINE (CAR (NTH TRAJ (SUB1 N)))
			      (CAR (NTH TRAJ N)))
	      (USER.ERASELINE (CAR (NTH TRAJ N))
			      (CAR (NTH TRAJ (ADD1 N))))
	      (replace (POINT VALUE) of OLDPOINT with VALUE)
	      (USER.DRAWLINE (CAR (NTH TRAJ (SUB1 N)))
			     (CAR (NTH TRAJ N)))
	      (USER.DRAWLINE (CAR (NTH TRAJ N))
			     (CAR (NTH TRAJ (ADD1 N)))))
	    (T (FOR L IN TRAJ AS R IN (CDR TRAJ) WHEN (AND (ILESSP (fetch (POINT TIME) of L)
								   TIME)
							   (IGREATERP (fetch (POINT TIME)
									 of R)
								      TIME))
		  DO (SETQ LEFTPOINT L)
		     (SETQ RIGHTPOINT R)
		     (RETURN))
	       (USER.ERASELINE LEFTPOINT RIGHTPOINT)
	       (PUSH (CDR (MEMB LEFTPOINT TRAJ))
		     POINT)
	       (USER.DRAWLINE LEFTPOINT POINT)
	       (USER.DRAWLINE POINT RIGHTPOINT))))))

(USER.GETPARAM
  (LAMBDA (PNAME PARAM)                                      (* kbr: "11-Feb-84 17:53")
    (EVAL `(FETCH (PARAM ,PNAME) OF ',PARAM))))

(USER.SETPARAM
  (LAMBDA (PNAME VALUE PARAM)                                (* kbr: "11-Feb-84 17:53")
    (EVAL `(REPLACE (PARAM ,PNAME) OF `,PARAM WITH ',VALUE))))
)
(LOAD? '{PHYLUM}<LISPCORE>LIBRARY>ATTACHEDWINDOW.DCOM)
(DECLARE: DONTCOPY
  (FILEMAP (NIL (2215 15000 (USER.INIT 2225 . 2703) (USER.CREATE.PARAMS 2705 . 4705) (USER.CREATE.TRAJS 
4707 . 5226) (USER.INTERPOLATE 5228 . 5504) (USER.INTERPOLATE.PNAME 5506 . 6530) (USER.CREATE.WINDOW 
6532 . 6869) (USER.REPAINTFN 6871 . 7410) (USER.BUTTONEVENTFN 7412 . 7674) (USER.CREATE.MENU 7676 . 
8210) (USER.WHENSELECTEDFN 8212 . 8466) (USER.EDITTRAJ 8468 . 8969) (USER.DRAWLINE 8971 . 10033) (
USER.ERASELINE 10035 . 11098) (USER.DRAWPOINT 11100 . 11317) (USER.MIDDLEBUTTONFN 11319 . 11754) (
USER.LEFTBUTTONFN 11756 . 12023) (USER.PROMPT&ADD 12025 . 12682) (USER.ADDPOINT 12684 . 14631) (
USER.GETPARAM 14633 . 14803) (USER.SETPARAM 14805 . 14998)))))
STOP