G2dZoom.mesa
Copyright Ó 1984, 1992 by Xerox Corporation. All rights reserved.
Bloomenthal, July 1, 1992 7:08 pm PDT
DIRECTORY Imager, IO, Rope, Vector2, ViewerClasses;
Types
ROPE: TYPE ~ Rope.ROPE;
STREAM: TYPE ~ IO.STREAM;
Transformation: TYPE ~ Imager.Transformation;
VEC: TYPE ~ Vector2.VEC;
Viewer: TYPE ~ ViewerClasses.Viewer;
Pan/Zoom a Viewer
Hijack:
PROC [viewer: Viewer];
Override a viewer's paint and notify procs to accomodate subsequent scale, translate, or rotate.
The following procedures have no effect unless the viewer has first been commandeered:
Release:
PROC [viewer: Viewer];
Release the viewer that was commandeered.
SetTransform:
PROC [viewer: Viewer, m: Transformation, repaint:
BOOL ¬
TRUE];
Set the transformation for the given viewer.
Transform:
PROC [viewer: Viewer, translate:
VEC, scale, rotate:
REAL, repaint:
BOOL ¬
TRUE];
Set the given transformation parameters for the viewer, first resetting the viewer's transform.
The translation is in inches; the rotation in degrees.
Scale:
PROC [viewer: Viewer, s:
REAL, repaint:
BOOL ¬
TRUE];
Add the given scale factor to the viewer's transformation.
Translate:
PROC [viewer: Viewer, v:
VEC, repaint:
BOOL ¬
TRUE];
Add the given translation to the viewer's transformation. The translation is in inches.
Rotate:
PROC [viewer: Viewer, degrees:
REAL, repaint:
BOOL ¬
TRUE];
Add the given rotation to the viewer's transformation.
Reset:
PROC [viewer: Viewer, repaint:
BOOL ¬
TRUE];
Reset the viewer's viewer's transformation to identity.
IO
A transformation is stored to or read from a stream according to the following format:
Rotate: <degrees: REAL>
Scale: <scale: REAL>
Translate: <[x, y: REAL]>
WriteTransform:
PROC [viewer: Viewer, out:
STREAM];
Write the transformation associated with viewer to the output stream.
ReadTransform:
PROC [in:
STREAM]
RETURNS [Transformation];
Read an input stream, given in the above format, and return the transformation.
IPOut:
PROC [viewer: Viewer, fileName:
ROPE];
Write the viewer to the named file, using the associated context transformation.