(FILECREATED "29-Apr-87 12:51:42" {QV}<NOTECARDS>1.3K>NEXT>KOTOSKETCHPATCHES.;5 6161   

      changes to:  (VARS KOTOSKETCHPATCHESCOMS)

      previous date: "23-Apr-87 19:48:15" {QV}<NOTECARDS>1.3K>NEXT>KOTOSKETCHPATCHES.;3)


(* Copyright (c) 1987 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT KOTOSKETCHPATCHESCOMS)

(RPAQQ KOTOSKETCHPATCHESCOMS ((DECLARE: EVAL@COMPILE DONTCOPY (FILES (LOADFROM FROM 
										 {CF}<PAPERWORKS>)
								       SKETCH SKETCHOBJ))
				(FNS MAKE.IMAGE.OBJECT.OF.SKETCH SKETCH.VIEWER.GRID 
				     SKETCH.VIEWER.SCALE SKETCH.REGION.VIEWED)))
(DECLARE: EVAL@COMPILE DONTCOPY 
(FILESLOAD (LOADFROM FROM {CF}<PAPERWORKS>)
	   SKETCH SKETCHOBJ)
)
(DEFINEQ

(MAKE.IMAGE.OBJECT.OF.SKETCH
  [LAMBDA (SKETCH REGION SCALE GRIDSIZE)                   (* rrb "21-Apr-87 11:18")

          (* Returns a sketch image object. REGION is the region in sketch coordinates that the image object will show.
	  SCALE is the scale at which it will be shown. GRIDSIZE is the grid size of the sketch. If SKETCH is a viewer, any 
	  of the other arguments that are NIL will be filled in from the values in the viewer. If SKETCH is a sketch, REGION 
	  defaults to the extent of the sketch, SCALE defaults to 1.0 and GRIDSIZE defaults to 8.0.)


    (SKETCH.IMAGEOBJ (INSURE.SKETCH SKETCH)
		       (COND
			 ((REGIONP REGION))
			 (REGION (ERROR REGION " illegal argument."))
			 (T (SKETCH.REGION.VIEWED SKETCH)))
		       (COND
			 ((NUMBERP SCALE))
			 ((WINDOWP SKETCH)
			   (VIEWER.SCALE SKETCH))
			 (T 1.0))
		       (COND
			 ((NUMBERP GRIDSIZE))
			 ((WINDOWP SKETCH)
			   (SK.GRIDFACTOR SKETCH))
			 (T 8.0])

(SKETCH.VIEWER.GRID
  [LAMBDA (VIEWER NEWGRID)                                   (* rrb "21-Apr-87 12:27")
                                                             (* returns and optionally sets the grid size of a 
							     sketch. VIEWER can be a viewer or a sketch image 
							     object.)
    (COND
      [(IMAGEOBJP VIEWER)                                  (* it is a sketch image object)
	(PROG [(SKINFO (LISTP (IMAGEOBJPROP VIEWER (QUOTE OBJECTDATUM]
	        (COND
		  [(type? SKETCH (fetch (SKETCHIMAGEOBJ SKIO.SKETCH) of SKINFO))
		    (RETURN (PROG1 (fetch (SKETCHIMAGEOBJ SKIO.GRID) of SKINFO)
				       (COND
					 (NEWGRID (COND
						    ((NUMBERP NEWGRID)
						      (replace (SKETCHIMAGEOBJ SKIO.GRID)
							 of SKINFO with NEWGRID))
						    (T (\ILLEGAL.ARG NEWGRID]
		  (T (ERROR "not a sketch image object" VIEWER]
      ((WINDOWP VIEWER)
	(SK.GRIDFACTOR VIEWER NEWGRID))
      (T (\ILLEGAL.ARG VIEWER])

(SKETCH.VIEWER.SCALE
  [LAMBDA (VIEWER NEWSCALE)                                  (* rrb "21-Apr-87 12:25")
                                                             (* returns and optionally sets the scale of a viewer.)
    (COND
      [(IMAGEOBJP VIEWER)                                  (* it is a sketch image object)
	(PROG [(SKINFO (LISTP (IMAGEOBJPROP VIEWER (QUOTE OBJECTDATUM]
	        (COND
		  [(type? SKETCH (fetch (SKETCHIMAGEOBJ SKIO.SKETCH) of SKINFO))
		    (RETURN (PROG1 (fetch (SKETCHIMAGEOBJ SKIO.SCALE) of SKINFO)
				       (COND
					 (NEWSCALE (COND
						     ((SK.INSURE.SCALE NEWSCALE)
						       (replace (SKETCHIMAGEOBJ SKIO.SCALE)
							  of SKINFO with NEWSCALE))
						     (T (\ILLEGAL.ARG NEWSCALE]
		  (T (ERROR "not a sketch image object" VIEWER]
      [(WINDOWP VIEWER)
	(PROG1 (WINDOWPROP VIEWER (QUOTE SCALE))
		 (COND
		   (NEWSCALE (COND
			       ((SK.INSURE.SCALE NEWSCALE)
				 (WINDOWPROP VIEWER (QUOTE SCALE)
					       NEWSCALE)
				 (SK.UPDATE.AFTER.SCALE.CHANGE VIEWER]
      (T (\ILLEGAL.ARG VIEWER])

(SKETCH.REGION.VIEWED
  (LAMBDA (VIEWER NEWREGION)                                 (* rht: "22-Apr-87 21:13")
                                                             (* returns the region in sketch coordinates of the 
							     area visible in SKETCHW.)
    (COND
      ((IMAGEOBJP VIEWER)                                  (* it is a sketch image object)
	(PROG ((SKETCHIMAGEOBJ (LISTP (IMAGEOBJPROP VIEWER (QUOTE OBJECTDATUM))))
		 NEWVIEW)
	        (COND
		  ((type? SKETCH (fetch (SKETCHIMAGEOBJ SKIO.SKETCH) of SKETCHIMAGEOBJ))
		    (RETURN (PROG1 (fetch (SKETCHIMAGEOBJ SKIO.REGION) of SKETCHIMAGEOBJ)
				       (COND
					 (NEWREGION (COND
						      ((REGIONP NEWREGION)
							(replace (SKETCHIMAGEOBJ SKIO.REGION)
							   of SKETCHIMAGEOBJ with NEWREGION))
						      ((SETQ NEWVIEW (SKETCH.VIEW.FROM.NAME
							    NEWREGION VIEWER))
							(replace (SKETCHIMAGEOBJ SKIO.REGION)
							   of SKETCHIMAGEOBJ with NEWVIEW))
						      ((EQ NEWREGION (QUOTE HOME))
                                                             (* change scale to 1.0 and set lower left of region 
							     viewed to (0,0).)
							NIL)
						      (T     (* HOME and named views aren't supported for image 
							     object sketches.)
							 (\ILLEGAL.ARG NEWREGION))))))))
		  (T (ERROR "not a sketch image object" VIEWER)))))
      ((WINDOWP VIEWER)
	(PROG1 (WINDOWPROP VIEWER (QUOTE REGION.VIEWED))
		 (COND
		   (NEWREGION (PROG (NEWVIEW)
				      (RETURN (COND
						  ((REGIONP NEWREGION)
						    (SKETCH.GLOBAL.REGION.ZOOM VIEWER NEWREGION))
						  ((EQ NEWREGION (QUOTE HOME))
						    (SKETCH.HOME VIEWER))
						  ((SETQ NEWVIEW (SKETCH.VIEW.FROM.NAME NEWREGION 
											   VIEWER))
						    (SK.MOVE.TO.VIEW VIEWER NEWVIEW))
						  (T (\ILLEGAL.ARG NEWREGION)))))))))
      (T (\ILLEGAL.ARG VIEWER)))))
)
(PUTPROPS KOTOSKETCHPATCHES COPYRIGHT ("Xerox Corporation" 1987))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (705 6073 (MAKE.IMAGE.OBJECT.OF.SKETCH 715 . 1742) (SKETCH.VIEWER.GRID 1744 . 2805) (
SKETCH.VIEWER.SCALE 2807 . 4012) (SKETCH.REGION.VIEWED 4014 . 6071)))))
STOP