IPOrientImpl.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Preas, January 13, 1987 4:12:51 pm PST
Implements CD23 CDOrient for Phoenix
DIRECTORY
CD, IPOrient;
IPOrientImpl: CEDAR PROGRAM
EXPORTS IPOrient
~ BEGIN
CDIntToOrien: PUBLIC PROCEDURE[num: INT] RETURNS [orien: IPOrient.Orientation] = {
get the CD orientation for a number like CD23
SELECT num FROM
0 => orien ← original;
1 => orien ← mirrorX;
2 => orien ← rotate270;
3 => orien ← rotate90X;
4 => orien ← rotate180;
5 => orien ← rotate180X;
6 => orien ← rotate270;
7 => orien ← rotate270X;
8 => orien ← rotate90X;
ENDCASE};
CDOrienToInt: PUBLIC PROCEDURE[orien: IPOrient.Orientation] RETURNS [num: INT] = {
get the number for a CD orientation like CD23
SELECT orien FROM
original => num ← 0;
mirrorX => num ← 1;
rotate270 => num ← 2;
rotate90X => num ← 3;
rotate180 => num ← 4;
rotate180X => num ← 5;
rotate270 => num ← 6;
rotate270X => num ← 7;
rotate90X => num ← 8;
ENDCASE};
MapPoint: PUBLIC PROC [pointInCell: CD.Position, cellSize: CD.Position,
cellInstOrient: IPOrient.Orientation, cellInstPos: CD.Position ← [0,0]]
RETURNS [pointInWorld: CD.Position] = BEGIN
-- Given an point in a prototype cell,
-- the size of the prototype cell, both in "cell" co-ordinates, and
-- the position and orientation index of an instance of that cell in "world"
-- co-ordinates, this procedure returns the world
-- co-ordinates of the point.
-- WARNING: a position of a rect can not be mapped with MapPoint
SELECT cellInstOrient FROM
original =>
RETURN[CD.Position[
x: cellInstPos.x+pointInCell.x,
y: cellInstPos.y+pointInCell.y
]];
mirrorX => -- reflection in x
RETURN[CD.Position[
x: cellInstPos.x+cellSize.x-pointInCell.x,
y: cellInstPos.y+pointInCell.y
]];
rotate90 => { -- 90 degrees clockwise
RETURN[CD.Position[
x: cellInstPos.x+cellSize.y-pointInCell.y,
y: cellInstPos.y+pointInCell.x]];
};
rotate90X => { -- 90 degrees clockwise followed by reflection in x
RETURN[CD.Position[
x: cellInstPos.x+pointInCell.y,
y: cellInstPos.y+pointInCell.x]];
};
rotate180 => { -- 180 degrees clockwise
RETURN[CD.Position[
x: cellInstPos.x+cellSize.x-pointInCell.x,
y: cellInstPos.y+cellSize.y-pointInCell.y]];
};
rotate180X => { -- 180 degrees clockwise followed by reflection in x
RETURN[CD.Position[
x: cellInstPos.x+pointInCell.x,
y: cellInstPos.y+cellSize.y-pointInCell.y]];
};
rotate270 => { -- 270 degrees clockwise
RETURN[CD.Position[
x: cellInstPos.x+pointInCell.y,
y: cellInstPos.y+cellSize.x-pointInCell.x]];
};
rotate270X => { -- 270 degrees clockwise followed by reflection in x
RETURN[CD.Position[
x: cellInstPos.x+cellSize.y-pointInCell.y,
y: cellInstPos.y+cellSize.x-pointInCell.x]];
};
ENDCASE;
END;
END.