INTERFACEAJunoPt ;
JunoPt.T
represents a point in Juno coordinates. The procedures in this
module perform conversions to/from Juno points.
IMPORT JunoAST, JunoValue, RTVal, Point; EXCEPTION BadPt; TYPE T = RECORD x, y: JunoValue.Real END;A
JunoPt.T
is a point in Juno coordinates. As opposed to Trestle's
Point.T
, Juno points are real-valued, their y
coordinate increases
to the north, and they are measured in units of screen-independent points
instead of screen-dependent pixels.
TYPE Transform = RECORD origin := Point.T{0, 0}; xScale, yScale, widthScale: JunoValue.Real := 1.0; (* in pixels / point *) END;A
JunoPt.Transform
specifies a transformation for converting between Juno
coordinates and Trestle coordinates. The field origin
is the location (in
Trestle coordinates) of the origin of the Juno coordinate system; this is
usually the southwest corner of a drawing's domain. The fields
xScale
and yScale
are the screen-dependent conversion factors for the
orthogonal axes in pixels-per-point: multiply by these factors to convert
from points to pixels, and divide by them to convert from pixels to
points. The field widthScale
is the scale factor to use for line widths;
it is a function of the scale factors in the x and y directions.
PROCEDURE ToHV(READONLY xyPt: T; READONLY xform: Transform): Point.T;
Return the point in Trestle coordinates with the pointorigin
as origin of the locationxyPt
in Juno coordinates.
PROCEDURE FromHV(READONLY hvPt: Point.T; READONLY xform: Transform): T;
Return the location in Juno coordinates of the pointhv
in Trestle coordinates with the pointorigin
as origin.
PROCEDURE ToASTPair(READONLY xyPt: T): JunoAST.Pair;
Return theJunoAST.Pair
representing the point equivalent to the Juno pointxyPt
.
PROCEDURE ToValuePair(READONLY xyPt: T): RTVal.Pair;
Return theRTVal.Pair
representing the point equivalent to the Juno pointxyPt
.
PROCEDURE FromValuePair(pr: RTVal.Pair): T RAISES {BadPt};
Return the Juno point equivalent to the pairpr
. RaisesBadPoint
ifpr
is not a pair ofRTVal.Number
's (this includes the case wherepr = NIL
.
PROCEDURE RelVal( cx,cy, ax,ay, bx,by: JunoValue.Real; VAR (*OUT*) x,y: JunoValue.Real): BOOLEAN;
Solve(cx, cy) = (x, y) REL ((ax, ay), (bx, by))
forx
andy
and return TRUE, or return FALSE if there is no solution (namely, ifax = bx
anday = by
).
END JunoPt.