(FILECREATED " 5-MAY-83 18:16:24" {PHYLUM}<LISPUSERS>POLYGONS.;26 21365  

      changes to:  (FNS POLYGONS DOPOLYGON RANDOMPT LABELPTS READPOLYGONPTS DRAWCROSSAT READSPLINEPTS 
			DOMENU CONNECTPOLYS)

      previous date: " 5-DEC-82 20:43:37" {PHYLUM}<LISPUSERS>POLYGONS.;25)


(* Copyright (c) 1982, 1983 by Xerox Corporation)

(PRETTYCOMPRINT POLYGONSCOMS)

(RPAQQ POLYGONSCOMS [(FNS ADDPOSITIONS CHANGE/POLYGONS/BACKGROUND CONNECTPOLYS DOPOLYGON DRAWCROSSAT 
			  DRAWPOLY1 DRAWPOLYS FLASHPOLY1 INITPOLYMENU LABELPTS POLYGONS POLYGON 
			  RANDOMPT READPOLYGONPTS READPOLYNUMBER READSPLINEPTS RETRIEVEPOLYGONS 
			  RUNPOLYGONS POLYGONSDEMO SAVECURRENTPOLYGONS WUPPERLEFTCORNER)
	(VARS (SAVEDPOLYGONS)
	      (POLYGONSWINDOW)
	      POLYGONSFLASHWAIT)
	(GLOBALVARS POLYGONSTEPS POLYGONWAIT POLYGONMINPTS POLYGONMAXPTS WHITEBACKGROUNDFLG 
		    POLYGONCONNECTEDFLG LASTPOLYGONTOS LASTPOLYGONFROMS POINTSINPUT SAVEDPOLYGONS 
		    SHOWMOVEMENTFLG POLYGONSFLASHWAIT)
	(COMS (* active menu functions)
	      (FNS DOMENU UPDATEACTIVEMENU)
	      (RECORDS ACTIVEMENU ACTIVEMENUITEM))
	(P (MOVD? (QUOTE \BACKGROUND)
		  (QUOTE BLOCK])
(DEFINEQ

(ADDPOSITIONS
  [LAMBDA (POS1 POS2)
    (create POSITION
	    XCOORD ←(IPLUS (fetch XCOORD of POS1)
			   (fetch XCOORD of POS2))
	    YCOORD ←(IPLUS (fetch YCOORD of POS1)
			   (fetch YCOORD of POS2])

(CHANGE/POLYGONS/BACKGROUND
  [LAMBDA (WINDOW)                                           (* rrb "29-MAY-82 20:04")
                                                             (* switches the background color of the polygon window.)
    (COND
      (WHITEBACKGROUNDFLG (DSPTEXTURE BLACKSHADE WINDOW)
			  (DSPOPERATION (QUOTE ERASE)
					WINDOW)
			  (SETQ WHITEBACKGROUNDFLG NIL)
			  "White back")
      (T (DSPTEXTURE WHITESHADE WINDOW)
	 (DSPOPERATION (QUOTE REPLACE)
		       WINDOW)
	 (SETQ WHITEBACKGROUNDFLG T)
	 "Black back"])

(CONNECTPOLYS
  [LAMBDA (FROMS TOS NSTEPS CONNECTEDFLG DS)                 (* rrb " 5-MAY-83 18:15")
    (SETQ LASTPOLYGONFROMS FROMS)
    (SETQ LASTPOLYGONTOS TOS)
    (PROG (DIFFS (XFROMS (COPY FROMS)))
          (CLEARW DS)
          (DRAWPOLY1 XFROMS 3 CONNECTEDFLG (COND
		       (WHITEBACKGROUNDFLG (QUOTE REPLACE))
		       (T (QUOTE ERASE)))
		     DS)
          (DRAWPOLY1 TOS 6 CONNECTEDFLG (COND
		       (WHITEBACKGROUNDFLG (QUOTE REPLACE))
		       (T (QUOTE ERASE)))
		     DS)
          [SETQ DIFFS (for FPT in XFROMS as TPT in TOS
			 collect (DRAWBETWEEN FPT TPT 1 (COND
						(WHITEBACKGROUNDFLG (QUOTE REPLACE))
						(T (QUOTE ERASE)))
					      DS)
				 (create POSITION
					 XCOORD ←(IDIFFERENCE (fetch XCOORD of TPT)
							      (fetch XCOORD of FPT))
					 YCOORD ←(IDIFFERENCE (fetch YCOORD of TPT)
							      (fetch YCOORD of FPT]
          [COND
	    (SHOWMOVEMENTFLG (for I from 1 to POLYGONSTEPS
				do (FLASHPOLY1 XFROMS 1 CONNECTEDFLG DS)
				   [for PT in XFROMS as DIF in DIFFS as FROMPT in FROMS
				      do (replace XCOORD of PT
					    with (IPLUS (fetch XCOORD of FROMPT)
							(IQUOTIENT (ITIMES (fetch XCOORD
									      of DIF)
									   I)
								   POLYGONSTEPS)))
					 (replace YCOORD of PT
					    with (IPLUS (fetch YCOORD of FROMPT)
							(IQUOTIENT (ITIMES (fetch YCOORD
									      of DIF)
									   I)
								   POLYGONSTEPS]
				finally (FLASHPOLY1 XFROMS 1 CONNECTEDFLG DS))
			     (SETQ XFROMS (COPY FROMS]
          (DISMISS 1500)
          (CLEARW DS)
          (for I from 1 to POLYGONSTEPS
	     do (DRAWPOLY1 XFROMS 1 CONNECTEDFLG NIL DS)
		[for PT in XFROMS as DIF in DIFFS as FROMPT in FROMS
		   do (replace XCOORD of PT with (IPLUS (fetch XCOORD of FROMPT)
							(IQUOTIENT (ITIMES (fetch XCOORD
									      of DIF)
									   I)
								   POLYGONSTEPS)))
		      (replace YCOORD of PT with (IPLUS (fetch YCOORD of FROMPT)
							(IQUOTIENT (ITIMES (fetch YCOORD
									      of DIF)
									   I)
								   POLYGONSTEPS]
	     finally (DRAWPOLY1 XFROMS 1 CONNECTEDFLG NIL DS))
          (RETURN T])

(DOPOLYGON
  [LAMBDA (WINDOW)                                           (* rrb " 5-MAY-83 17:48")
                                                             (* runs the current settings of polygon until a key is 
							     hit.)
    (ERSETQ (PROG (NPOINTS (WINDOW (OR WINDOW POLYWINDOW)))
	          (SETQ NPOINTS (RAND POLYGONMINPTS POLYGONMAXPTS))
	          (CONNECTPOLYS (for I from 1 to NPOINTS collect (RANDOMPT WINDOW))
				(for I from 1 to NPOINTS collect (RANDOMPT WINDOW))
				POLYGONSTEPS POLYGONCONNECTEDFLG WINDOW)))
    NIL])

(DRAWCROSSAT
  [LAMBDA (PT LENGTH WIN)                                    (* rrb " 5-MAY-83 17:56")

          (* * draws a cross at a point)


    (PROG ((X (fetch XCOORD of PT))
	   (Y (fetch YCOORD of PT))
	   (DIFFLEN (IQUOTIENT LENGTH 2)))
          (DRAWLINE (IDIFFERENCE X DIFFLEN)
		    Y
		    (IPLUS X DIFFLEN)
		    Y 1 NIL WIN)
          (DRAWLINE X (IDIFFERENCE Y DIFFLEN)
		    X
		    (IPLUS Y DIFFLEN)
		    1 NIL WIN])

(DRAWPOLY1
  [LAMBDA (PTLIST WIDTH CONNECT? OPERATION DS)               (* rrb "29-MAY-82 20:10")
                                                             (* draws a closed polygon of the points given If 
							     OPERATION is not given, use the one from the default 
							     DS.)
    [COND
      (PTLIST (for PTA in PTLIST as PTB in (CDR PTLIST) do (DRAWBETWEEN PTA PTB WIDTH
									(OR OPERATION
									    (DSPOPERATION NIL DS))
									DS)
		 finally (AND CONNECT? (DRAWBETWEEN (CAR (LAST PTLIST))
						    (CAR PTLIST)
						    WIDTH
						    (OR OPERATION (DSPOPERATION NIL DS))
						    DS)
			      DS]
    (BLOCK])

(DRAWPOLYS
  [LAMBDA (FROMS TOS NSTEPS CONNECTEDFLG WINDOW)             (* rrb " 5-DEC-82 20:40")
                                                             (* set up to draw polygons with CONNECTPOLYS and return 
							     NIL.)
    (CONNECTPOLYS FROMS TOS NSTEPS CONNECTEDFLG (OR WINDOW POLYWINDOW))
    NIL])

(FLASHPOLY1
  [LAMBDA (PTS WIDTH CONNECTEDFLG DS)                        (* rrb "29-MAY-82 19:48")
    (DRAWPOLY1 XFROMS WIDTH CONNECTEDFLG (QUOTE INVERT)
	       DS)
    (DISMISS POLYGONSFLASHWAIT)
    (DRAWPOLY1 XFROMS WIDTH CONNECTEDFLG (QUOTE INVERT)
	       DS])

(INITPOLYMENU
  [LAMBDA (WINDOW)                                           (* rrb "29-MAY-82 20:14")
                                                             (* creates the initial polygon menu list.)
    (SETQ POLYGONACTIVEMENU (create ACTIVEMENU
				    ACTIVEMENUITEMS ←[LIST
				      (create ACTIVEMENUITEM
					      ACTIVEITEMLABEL ← "AUTO-MODE"
					      MENUFORM ←(LIST (QUOTE RUNPOLYGONS)
							      (KWOTE WINDOW)))
				      (create ACTIVEMENUITEM
					      ACTIVEITEMLABEL ← "Do One"
					      MENUFORM ←(LIST (QUOTE DOPOLYGON)
							      (KWOTE WINDOW)))
				      (create ACTIVEMENUITEM
					      ACTIVEITEMLABEL ← "Pause Time"
					      MENUFORM ←(QUOTE (READPOLYNUMBER (QUOTE WAIT)))
					      MENUINITFORM ←(QUOTE (SETQ POLYGONWAIT 5000)))
				      (create ACTIVEMENUITEM
					      ACTIVEITEMLABEL ← "Number Of Steps"
					      MENUFORM ←(QUOTE (READPOLYNUMBER (QUOTE STEPS)))
					      MENUINITFORM ←(QUOTE (SETQ POLYGONSTEPS 35)))
				      (create ACTIVEMENUITEM
					      ACTIVEITEMLABEL ← "Max Points"
					      MENUFORM ←(QUOTE (READPOLYNUMBER (QUOTE MAX)))
					      MENUINITFORM ←(QUOTE (SETQ POLYGONMAXPTS 9)))
				      (create ACTIVEMENUITEM
					      ACTIVEITEMLABEL ← "Min Points"
					      MENUFORM ←(QUOTE (READPOLYNUMBER (QUOTE MIN)))
					      MENUINITFORM ←(QUOTE (SETQ POLYGONMINPTS 3)))
				      (create ACTIVEMENUITEM
					      ACTIVEITEMLABEL ← "Movement"
					      MENUFORM ←(QUOTE (COND (SHOWMOVEMENTFLG (SETQ 
										  SHOWMOVEMENTFLG NIL)
										      "Movement")
								     ((SETQ SHOWMOVEMENTFLG T)
								       "Don't Movement")))
					      MENUINITFORM ←(QUOTE (SETQ SHOWMOVEMENTFLG NIL)))
				      [create ACTIVEMENUITEM
					      ACTIVEITEMLABEL ← "REDRAW"
					      MENUFORM ←(LIST (QUOTE DRAWPOLYS)
							      (QUOTE LASTPOLYGONFROMS)
							      (QUOTE LASTPOLYGONTOS)
							      (QUOTE POLYGONSTEPS)
							      (QUOTE POLYGONCONNECTEDFLG)
							      (KWOTE WINDOW))
					      MENUINITFORM ←(QUOTE (PROGN [SETQ LASTPOLYGONFROMS
									    (QUOTE ((210 . 637)
										     (471 . 493)
										     (72 . 319)
										     (470 . 146)
										     (225 . 46]
									  (SETQ LASTPOLYGONTOS
									    (QUOTE ((431 . 635)
										     (96 . 491)
										     (419 . 370)
										     (125 . 172)
										     (527 . 61]
				      (create ACTIVEMENUITEM
					      ACTIVEITEMLABEL ← "Not Connected"
					      MENUFORM ←(QUOTE (COND (POLYGONCONNECTEDFLG
								       (SETQ POLYGONCONNECTEDFLG NIL)
								       "Connected")
								     (T (SETQ POLYGONCONNECTEDFLG T)
									"Not Connected")))
					      MENUINITFORM ←(QUOTE (SETQ POLYGONCONNECTEDFLG T)))
				      (create ACTIVEMENUITEM
					      ACTIVEITEMLABEL ← "FROM pts"
					      MENUFORM ←(LIST (QUOTE READPOLYGONPTS)
							      (QUOTE (QUOTE FROM))
							      WINDOW))
				      (create ACTIVEMENUITEM
					      ACTIVEITEMLABEL ← "TO pts"
					      MENUFORM ←(LIST (QUOTE READPOLYGONPTS)
							      (QUOTE (QUOTE TO))
							      WINDOW))
				      [create ACTIVEMENUITEM
					      ACTIVEITEMLABEL ← "White back"
					      MENUFORM ←(LIST (QUOTE CHANGE/POLYGONS/BACKGROUND)
							      WINDOW)
					      MENUINITFORM ←(QUOTE (PROGN (SETQ WHITEBACKGROUNDFLG 
									    NIL)
									  (DSPTEXTURE BLACKSHADE 
										      WINDOW)
									  (DSPOPERATION (QUOTE ERASE)
											WINDOW]
				      (create ACTIVEMENUITEM
					      ACTIVEITEMLABEL ← "Save Figure"
					      MENUFORM ←(QUOTE (SAVECURRENTPOLYGONS)))
				      (create ACTIVEMENUITEM
					      ACTIVEITEMLABEL ← "Retrieve Figure"
					      MENUFORM ←(QUOTE (RETRIEVEPOLYGONS)))
				      (create ACTIVEMENUITEM
					      ACTIVEITEMLABEL ← "Hardcopy"
					      MENUFORM ←(LIST (QUOTE HARDCOPYW)
							      WINDOW))
				      (create ACTIVEMENUITEM
					      ACTIVEITEMLABEL ← "Stop"
					      MENUFORM ←(QUOTE (QUOTE STOP]
				    MENU ←(create MENU
						  CENTERFLG ← T
						  MENUFONT ←(FONTCREATE (QUOTE HELVETICA)
									10)
						  MENUCOLUMNS ← 4)))
    (UPDATEACTIVEMENU POLYGONACTIVEMENU)
    (for AMITEM in (fetch ACTIVEMENUITEMS of POLYGONACTIVEMENU) do (EVAL (fetch MENUINITFORM
									    of AMITEM])

(LABELPTS
  [LAMBDA (PTS PREFIX WINDOW)                                (* rrb " 5-MAY-83 17:55")
    (for PT in PTS as I from 1
       do (DRAWCROSSAT PT 15 WINDOW)
	  (MOVETO (IPLUS (fetch XCOORD of PT)
			 1)
		  (IPLUS (fetch YCOORD of PT)
			 3)
		  WINDOW)
	  (AND PREFIX (PRIN1 PREFIX WINDOW)
	       (PRIN1 I WINDOW])

(POLYGONS
  [LAMBDA (DONTGOFLG WHERE)                                  (* rrb " 5-MAY-83 17:36")
    (PROG [(POLYWINDOW (DECODE/WINDOW/OR/DISPLAYSTREAM WHERE (QUOTE POLYWINDOW]
          (INITPOLYMENU POLYWINDOW)
          (OR DONTGOFLG (RUNPOLYGONS POLYWINDOW))
          (DOMENU POLYGONACTIVEMENU (ADDPOSITIONS (WUPPERLEFTCORNER POLYWINDOW)
						  (CONSTANT (create POSITION
								    XCOORD ← 0
								    YCOORD ← 4])

(POLYGON
  [LAMBDA NIL                                                (* bas: " 5-JUN-82 18:59")
                                                             (* draws one polygon in either POLYGONSWINDOW or a 
							     window from the user.)
    (PROG ([POLYWINDOW (COND
			 ((TYPENAMEP POLYGONSWINDOW (QUOTE WINDOW))
			   POLYGONSWINDOW)
			 (T (SETQ POLYGONSWINDOW (CREATEW]
	   NPOINTS)                                          (* INITPOLYMENU does some initialization)
          (INITPOLYMENU POLYWINDOW)
          (SETQ NPOINTS (RAND POLYGONMINPTS POLYGONMAXPTS))
          (CONNECTPOLYS (for I from 1 to NPOINTS collect (RANDOMPT POLYWINDOW))
			(for I from 1 to NPOINTS collect (RANDOMPT POLYWINDOW))
			POLYGONSTEPS POLYGONCONNECTEDFLG POLYWINDOW])

(RANDOMPT
  [LAMBDA (DS)                                               (* rrb " 5-MAY-83 17:48")
    (PROG ((REG (DSPCLIPPINGREGION NIL DS)))
          (RETURN (create POSITION
			  XCOORD ←(RAND (fetch LEFT of REG)
					(fetch RIGHT of REG))
			  YCOORD ←(RAND (fetch BOTTOM of REG)
					(fetch TOP of REG])

(READPOLYGONPTS
  [LAMBDA (WHAT DS)                                          (* rrb " 5-MAY-83 17:52")
                                                             (* reads a polygon)
    (LABELPTS LASTPOLYGONFROMS (COND
		((EQ WHAT (QUOTE TO))
		  (QUOTE F))
		(T (QUOTE OF)))
	      DS)
    (LABELPTS LASTPOLYGONTOS (COND
		((EQ WHAT (QUOTE FROM))
		  T)
		(T (QUOTE OT)))
	      DS)
    (PRIN1 "

" T DS)
    (ERSETQ (SELECTQ WHAT
		     (FROM (SETQ LASTPOLYGONFROMS (READSPLINEPTS DS)))
		     (TO (SETQ LASTPOLYGONTOS (READSPLINEPTS DS)))
		     (SHOULDNT)))
    NIL])

(READPOLYNUMBER
  [LAMBDA (WHAT)                                            (* rrb "12-JAN-81 18:34")

          (* reads a number and sets the MIN or MAX number of points to that. Also checks to make sure min leq max.
	  Returns NIL so menu won't be updates.)


    (PROG (NEWVALUE)
      LP  (CLEARBUF T T)
          (PRIN1 "Current value is: " T)
          (PRIN1 (SELECTQ WHAT
			  (MIN POLYGONMINPTS)
			  (MAX POLYGONMAXPTS)
			  (STEPS POLYGONSTEPS)
			  (WAIT (PACK* (IQUOTIENT POLYGONWAIT 1000)
				       " seconds"))
			  (SHOULDNT))
		 T)
          (TERPRI T)
          (PRIN1 "What should the new value be: " T)
          (COND
	    ((NOT (AND [NUMBERP (SETQ NEWVALUE (PROGN (CLEARBUF T T)
						      (READ]
		       (IGEQ NEWVALUE 0)))
	      (PRIN1 "Please enter a number greater than 0." T)
	      (TERPRI T)
	      (GO LP)))
          (SELECTQ WHAT
		   [MIN (SETQ POLYGONMINPTS NEWVALUE)
			(COND
			  ((IGREATERP POLYGONMINPTS POLYGONMAXPTS)
			    (SETQ POLYGONMAXPTS POLYGONMINPTS]
		   [MAX (SETQ POLYGONMAXPTS NEWVALUE)
			(COND
			  ((IGREATERP POLYGONMINPTS POLYGONMINPTS)
			    (SETQ POLYGONMINPTS NEWVALUE]
		   (STEPS (SETQ POLYGONSTEPS NEWVALUE))
		   (WAIT (SETQ POLYGONWAIT (ITIMES NEWVALUE 1000)))
		   (SHOULDNT))
          (RETURN NIL])

(READSPLINEPTS
  [LAMBDA (DS)                                               (* rrb " 5-MAY-83 17:58")
                                                             (* reads red button mouse up clicks and returns their 
							     positions until a character is pressed.)
    (CLEARBUF T)
    (PRIN1 "Use red button to indicate points.  End by typing a character.
" PROMPTWINDOW)
    (PROG (PTS)
      LP  (COND
	    ((READP T)
	      (RETURN (DREVERSE PTS)))
	    ((NOT (MOUSESTATE LEFT))
	      (GO LP)))
      LEFTDOWN
          (COND
	    ((READP T)
	      (RETURN (DREVERSE PTS)))
	    ((NOT (MOUSESTATE (NOT LEFT)))
	      (GO LEFTDOWN)))
          (SETQ PTS (CONS (create POSITION
				  XCOORD ←(LASTMOUSEX DS)
				  YCOORD ←(LASTMOUSEY DS))
			  PTS))
          (DRAWCROSSAT (CAR PTS)
		       10 DS)
          (GO LP])

(RETRIEVEPOLYGONS
  [LAMBDA NIL                                               (* rrb " 7-DEC-80 13:00")
                                                            (* lets the user select a saved figure and installs it)
    (COND
      ((NULL SAVEDPOLYGONS)
	(PRIN1 "No figures have been saved yet.
" T))
      ((SETQ FIGURE (MENUASSOC SAVEDPOLYGONS 4 500))
	(CONNECTPOLYS (CADR FIGURE)
		      (CADDR FIGURE)
		      POLYGONSTEPS POLYGONCONNECTEDFLG))
      (T (PRIN1 "Old figure not retrieved.
" T)))
    NIL])

(RUNPOLYGONS
  [LAMBDA (DS)                                               (* rrb "29-MAY-82 19:57")
                                                             (* runs the current settings of polygon until a key is 
							     hit.)
    [ERSETQ (PROG (NPOINTS)
	          (CLEARBUF T)
	      LP  (SETQ NPOINTS (RAND POLYGONMINPTS POLYGONMAXPTS))
                                                             (* if ↑E during CONNECTPOLYS propagate it.)
	          (OR (CONNECTPOLYS (for I from 1 to NPOINTS collect (RANDOMPT DS))
				    (for I from 1 to NPOINTS collect (RANDOMPT DS))
				    POLYGONSTEPS POLYGONCONNECTEDFLG DS)
		      (ERROR!))
	          (AND (READP T)
		       (RETURN))
	          (DISMISS POLYGONWAIT)
	          (OR (READP T)
		      (GO LP]
    NIL])

(POLYGONSDEMO
  [LAMBDA NIL                                                (* edited: "18-NOV-82 09:03")
    (PROG ([POLYWINDOW (COND
			 ((TYPENAMEP POLYGONSWINDOW (QUOTE WINDOW))
			   POLYGONSWINDOW)
			 (T (SETQ POLYGONSWINDOW
			      (CREATEW (create REGION
					       LEFT ← 200
					       BOTTOM ← 150
					       WIDTH ← 600
					       HEIGHT ← 500]
	   NPOINTS)                                          (* INITPOLYMENU does some initialization)
          (INITPOLYMENU POLYWINDOW)
          (SETQ NPOINTS (RAND POLYGONMINPTS POLYGONMAXPTS))
          (RPTQ (COND
		  ((EQ (MACHINETYPE)
		       (QUOTE DORADO))
		    3)
		  (T 1))
		(CONNECTPOLYS (for I from 1 to NPOINTS collect (RANDOMPT POLYWINDOW))
			      (for I from 1 to NPOINTS collect (RANDOMPT POLYWINDOW))
			      POLYGONSTEPS POLYGONCONNECTEDFLG POLYWINDOW)
		(COND
		  ((IGREATERP RPTN 1)
		    (DISMISS 1500])

(SAVECURRENTPOLYGONS
  [LAMBDA NIL                                               (* rrb " 7-DEC-80 11:32")
                                                            (* asks for a figure name and saves the current polygons
							    with that name.)
    (PRIN1 "Type in the name of this figure (end with a RETURN): " T)
    (SETQ SAVEDPOLYGONS (CONS (LIST (READ T)
				    LASTPOLYGONFROMS LASTPOLYGONTOS)
			      SAVEDPOLYGONS))
    NIL])

(WUPPERLEFTCORNER
  [LAMBDA (WINDOW)                                           (* rrb " 4-AUG-81 15:04")
                                                             (* returns the position of the upper left corner of the 
							     window.)
    (create POSITION
	    XCOORD ←(DSPXOFFSET NIL (WINDOWPROP WINDOW (QUOTE DSP)))
	    YCOORD ←(IPLUS (DSPYOFFSET NIL (WINDOWPROP WINDOW (QUOTE DSP)))
			   (WINDOWPROP WINDOW (QUOTE HEIGHT])
)

(RPAQQ SAVEDPOLYGONS NIL)

(RPAQQ POLYGONSWINDOW NIL)

(RPAQQ POLYGONSFLASHWAIT 60)
(DECLARE: DOEVAL@COMPILE DONTCOPY

(ADDTOVAR GLOBALVARS POLYGONSTEPS POLYGONWAIT POLYGONMINPTS POLYGONMAXPTS WHITEBACKGROUNDFLG 
	  POLYGONCONNECTEDFLG LASTPOLYGONTOS LASTPOLYGONFROMS POINTSINPUT SAVEDPOLYGONS 
	  SHOWMOVEMENTFLG POLYGONSFLASHWAIT)
)



(* active menu functions)

(DEFINEQ

(DOMENU
  [LAMBDA (ACTIVEMENU POS)                                   (* rrb " 5-MAY-83 18:15")

          (* repeatedly reads menu hits from ACTIVEMENU and executing the associated forms. If the form returns 
	  (QUOTE STOP) DOMENU returns. If the form returns any other non-NIL value it is taken as the new menu label for the
	  selected item.)


    (PROG (HITITEM FORMVALUE)
      LP  (SETQ HITITEM (MENU (fetch MENU of ACTIVEMENU)
			      POS))
          (for AMITEM in (fetch ACTIVEMENUITEMS of ACTIVEMENU) when (EQ HITITEM
									(fetch ACTIVEITEMLABEL
									   of AMITEM))
	     do (COND
		  ((EQ (SETQ FORMVALUE (EVAL (fetch MENUFORM of AMITEM)))
		       (QUOTE STOP))
		    (GO OUT))
		  (FORMVALUE (replace ACTIVEITEMLABEL of AMITEM with FORMVALUE)
			     (UPDATEACTIVEMENU ACTIVEMENU))
		  (T))
		(GO LP))
          (GO LP)
      OUT (RETURN])

(UPDATEACTIVEMENU
  [LAMBDA (ACTIVEMENU)                                       (* rrb "27-JAN-81 09:20")
                                                             (* updates the MENU part of an active menu by 
							     recollecting the labels.)
    (replace ITEMS of (fetch MENU of ACTIVEMENU) with (for ITEM in (fetch ACTIVEMENUITEMS
								      of ACTIVEMENU)
							 collect (fetch ACTIVEITEMLABEL of ITEM)))
                                                             (* clobber image so that it will be recalculated.)
    (replace IMAGE of (fetch MENU of ACTIVEMENU) with NIL])
)
[DECLARE: EVAL@COMPILE 

(RECORD ACTIVEMENU (ACTIVEMENUITEMS MENU))

(RECORD ACTIVEMENUITEM (ACTIVEITEMLABEL MENUFORM MENUINITFORM))
]
(MOVD? (QUOTE \BACKGROUND)
       (QUOTE BLOCK))
(PUTPROPS POLYGONS COPYRIGHT ("Xerox Corporation" 1982 1983))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1143 19067 (ADDPOSITIONS 1153 . 1395) (CHANGE/POLYGONS/BACKGROUND 1397 . 1944) (
CONNECTPOLYS 1946 . 4336) (DOPOLYGON 4338 . 4941) (DRAWCROSSAT 4943 . 5406) (DRAWPOLY1 5408 . 6095) (
DRAWPOLYS 6097 . 6432) (FLASHPOLY1 6434 . 6717) (INITPOLYMENU 6719 . 11058) (LABELPTS 11060 . 11432) (
POLYGONS 11434 . 11891) (POLYGON 11893 . 12721) (RANDOMPT 12723 . 13075) (READPOLYGONPTS 13077 . 13678
) (READPOLYNUMBER 13680 . 14968) (READSPLINEPTS 14970 . 15820) (RETRIEVEPOLYGONS 15822 . 16350) (
RUNPOLYGONS 16352 . 17193) (POLYGONSDEMO 17195 . 18147) (SAVECURRENTPOLYGONS 18149 . 18607) (
WUPPERLEFTCORNER 18609 . 19065)) (19450 21089 (DOMENU 19460 . 20406) (UPDATEACTIVEMENU 20408 . 21087))
)))
STOP