ImagerPrivateImpl.mesa
Michael Plass, October 27, 1983 2:50 pm
DIRECTORY Atom, Imager, ImagerBasic, ImagerPrivate, ImagerTransform, Real;
ImagerPrivateImpl: CEDAR PROGRAM
IMPORTS Atom, Imager, ImagerTransform, Real
EXPORTS ImagerPrivate
~ BEGIN OPEN ImagerPrivate;
imagerRegistrationKey: ATOM ~ $ImagerDeviceClass;
RegisterDevice: PUBLIC PROC [class: ImagerPrivate.Class] ~ {
Atom.PutProp[class.deviceType, imagerRegistrationKey, class];
};
InitState: PUBLIC PROC [context: Context, mediumXSize, mediumYSize, fieldXMin, fieldYMin, fieldXMax, fieldYMax: REAL] ~ {
state: State ← NEW[ImagerPrivate.StateRep ← [
cpx: 0.0,
cpy: 0.0,
correctMX: 0.0,
correctMY: 0.0,
T: ImagerTransform.Create[1,0,0,0,1,0],
priorityImportant: 0,
mediumXSize: mediumXSize,
mediumYSize: mediumYSize,
fieldXMin: fieldXMin,
fieldYMin: fieldYMin,
fieldXMax: fieldXMax,
fieldYMax: fieldYMax,
showVec: NIL,
color: NIL,
noImage: 0,
strokeWidth: 0.0,
strokeEnd: 0,
underlineStart: 0.0,
amplifySpace: 1.0,
correctPass: 0,
correctShrink: 0.5,
correctTX: 0.0,
correctTY: 0.0,
clipper: NIL,
correctMaskCount: 0,
correctMaskX: 0.0,
correctMaskY: 0.0,
correctSumX: 0.0,
correctSumY: 0.0,
correctSpaceX: 0.0,
correctSpaceY: 0.0,
correctcpx: 0.0,
correctcpy: 0.0,
correctTargetX: 0.0,
correctTargetY: 0.0
]];
state.color ← Imager.black;
context.state ← state;
};
IGet: PUBLIC PROC [context: Context, n: Name] RETURNS [REF] ~ {
WITH context.state SELECT FROM
state: State => {
SELECT n FROM
T => RETURN [NEW[ImagerBasic.Transformation ← state.T]];
showVec => RETURN [state.showVec];
color => RETURN [state.color];
clipOutline => RETURN [state.clipper];
ENDCASE => ERROR Imager.Error[$BadSelector];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
ISet: PUBLIC PROC [context: Context, n: Name, x: REF] ~ {
WITH context.state SELECT FROM
state: State => {
SELECT n FROM
T => WITH x SELECT FROM
t: REF ImagerBasic.Transformation => {state.T ← t^};
ENDCASE => ERROR Imager.Error[$WrongType];
showVec => state.showVec ← x;
color => WITH x SELECT FROM
color: ImagerBasic.Color => {state.colorcolor};
ENDCASE => ERROR Imager.Error[$WrongType];
clipOutline => state.clipper ← x;
ENDCASE => ERROR Imager.Error[$BadSelector];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
IGetReal: PUBLIC PROC [context: Context, n: Name] RETURNS [x: REAL] ~ {
WITH context.state SELECT FROM
state: State => {
SELECT n FROM
DCScpx => x ← state.cpx;
DCScpy => x ← state.cpy;
correctMX => x ← state.correctMX;
correctMY => x ← state.correctMY;
mediumXSize => x ← state.mediumXSize;
mediumYSize => x ← state.mediumYSize;
fieldXMin => x ← state.fieldXMin;
fieldYMin => x ← state.fieldYMin;
fieldXMax => x ← state.fieldXMax;
fieldYMax => x ← state.fieldYMax;
strokeWidth => x ← state.strokeWidth;
underlineStart => x ← state.underlineStart;
amplifySpace => x ← state.amplifySpace;
correctShrink => x ← state.correctShrink;
correctTX => x ← state.correctTX;
correctTY => x ← state.correctTY;
ENDCASE => ERROR Imager.Error[$BadSelector];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
ISetReal: PUBLIC PROC [context: Context, n: Name, x: REAL] ~ {
WITH context.state SELECT FROM
state: State => {
SELECT n FROM
DCScpx => state.cpx ← x;
DCScpy => state.cpy ← x;
correctMX => state.correctMX ← x;
correctMY => state.correctMY ← x;
mediumXSize => state.mediumXSize ← x;
mediumYSize => state.mediumYSize ← x;
fieldXMin => state.fieldXMin ← x;
fieldYMin => state.fieldYMin ← x;
fieldXMax => state.fieldXMax ← x;
fieldYMax => state.fieldYMax ← x;
strokeWidth => state.strokeWidth ← x;
underlineStart => state.underlineStart ← x;
amplifySpace => state.amplifySpace ← x;
correctShrink => state.correctShrink ← x;
correctTX => state.correctTX ← x;
correctTY => state.correctTY ← x;
ENDCASE => ERROR Imager.Error[$BadSelector];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
IGetInt: PUBLIC PROC [context: Context, n: Name] RETURNS [x: INT] ~ {
WITH context.state SELECT FROM
state: State => {
SELECT n FROM
priorityImportant => x ← state.priorityImportant;
noImage => x ← state.noImage;
strokeEnd => x ← state.strokeEnd;
correctPass => x ← state.correctPass;
ENDCASE => ERROR Imager.Error[$BadSelector];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
ISetInt: PUBLIC PROC [context: Context, n: Name, x: INT] ~ {
WITH context.state SELECT FROM
state: State => {
SELECT n FROM
priorityImportant => state.priorityImportant ← x;
noImage => state.noImage ← x;
strokeEnd => state.strokeEnd ← x;
correctPass => state.correctPass ← x;
ENDCASE => ERROR Imager.Error[$BadSelector];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
ConcatT: PUBLIC PROC [context: Context, m: Transformation] ~ {
WITH context.state SELECT FROM
state: State => {
state.T ← ImagerTransform.Concat[m, state.T];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
TranslateT: PUBLIC PROC [context: Context, x, y: REAL] ~ {
WITH context.state SELECT FROM
state: State => {
state.T ← ImagerTransform.PreTranslate[x, y, state.T];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
RotateT: PUBLIC PROC [context: Context, degrees: REAL] ~ {
WITH context.state SELECT FROM
state: State => {
state.T ← ImagerTransform.PreRotate[degrees, state.T];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
ScaleT: PUBLIC PROC [context: Context, s: REAL] ~ {
WITH context.state SELECT FROM
state: State => {
state.T ← ImagerTransform.PreScale[s, s, state.T];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
Scale2T: PUBLIC PROC [context: Context, sx, sy: REAL] ~ {
WITH context.state SELECT FROM
state: State => {
state.T ← ImagerTransform.PreScale[sx, sy, state.T];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
Move: PUBLIC PROC [context: Context] ~ {
WITH context.state SELECT FROM
state: State => {
state.T.c ← state.cpx;
state.T.f ← state.cpy;
};
ENDCASE => ERROR Imager.Error[$Bug];
};
Trans: PUBLIC PROC [context: Context] ~ {
WITH context.state SELECT FROM
state: State => {
state.T.c ← Real.RoundLI[state.cpx];
state.T.f ← Real.RoundLI[state.cpy];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
SetXY: PUBLIC PROC [context: Context, p: Pair] ~ {
WITH context.state SELECT FROM
state: State => {
[[state.cpx, state.cpy]] ← ImagerTransform.Transform[p, state.T];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
IntegerSetXY: PUBLIC PROC [context: Context, x, y: INTEGER] ~ {
WITH context.state SELECT FROM
state: State => {
[[state.cpx, state.cpy]] ← ImagerTransform.Transform[[x, y], state.T];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
SetXYRel: PUBLIC PROC [context: Context, v: Pair] ~ {
WITH context.state SELECT FROM
state: State => {
delta: Pair ~ ImagerTransform.TransformVec[v, state.T];
state.cpx ← state.cpx + delta.x;
state.cpy ← state.cpy + delta.y;
};
ENDCASE => ERROR Imager.Error[$Bug];
};
IntegerSetXYRel: PUBLIC PROC [context: Context, x, y: INTEGER] ~ {
WITH context.state SELECT FROM
state: State => {
delta: Pair ~ ImagerTransform.TransformVec[[x, y], state.T];
state.cpx ← state.cpx + delta.x;
state.cpy ← state.cpy + delta.y;
};
ENDCASE => ERROR Imager.Error[$Bug];
};
GetCP: PUBLIC PROC [context: Context] RETURNS [cp: Pair] ~ {
WITH context.state SELECT FROM
state: State => {
cp ← ImagerTransform.InverseTransform[[state.cpx, state.cpy], state.T];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
GetCPRounded: PUBLIC PROC [context: Context] RETURNS [cp: Pair] ~ {
WITH context.state SELECT FROM
state: State => {
cp ← ImagerTransform.InverseTransform[[Real.RoundLI[state.cpx], Real.RoundLI[state.cpy]], state.T];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
StartUnderline: PUBLIC PROC [context: Context] ~ {
WITH context.state SELECT FROM
state: State => {
ERROR Imager.Error[$NotYetImplemented];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
CorrectMask: PUBLIC PROC [context: Context] ~ {
WITH context.state SELECT FROM
state: State => {
ERROR Imager.Error[$NotYetImplemented];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
CorrectSpace: PUBLIC PROC [context: Context, v: Pair] ~ {
WITH context.state SELECT FROM
state: State => {
ERROR Imager.Error[$NotYetImplemented];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
SetCorrectMeasure: PUBLIC PROC [context: Context, v: Pair] ~ {
WITH context.state SELECT FROM
state: State => {
ERROR Imager.Error[$NotYetImplemented];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
SetCorrectTolerance: PUBLIC PROC [context: Context, v: Pair] ~ {
WITH context.state SELECT FROM
state: State => {
ERROR Imager.Error[$NotYetImplemented];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
Space: PUBLIC PROC [context: Context, x: REAL] ~ {
WITH context.state SELECT FROM
state: State => {
ERROR Imager.Error[$NotYetImplemented];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
IntegerSpace: PUBLIC PROC [context: Context, x: INTEGER] ~ {
WITH context.state SELECT FROM
state: State => {
ERROR Imager.Error[$NotYetImplemented];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
Correct: PUBLIC PROC [context: Context, body: PUBLIC PROC] ~ {
WITH context.state SELECT FROM
state: State => {
ERROR Imager.Error[$NotYetImplemented];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
Reset: PUBLIC PROC [context: Context] ~ {
WITH context.state SELECT FROM
state: State => {
ERROR Imager.Error[$NotYetImplemented];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
DrawBitmap: PUBLIC PROC [context: Context, base: LONG POINTER, raster: CARDINAL, area: IntRectangle] ~ {
ERROR Imager.Error[$NotYetImplemented];
};
MaskBits: PUBLIC PROC [context: Context, base: LONG POINTER, raster: CARDINAL, tile: IntRectangle, area: IntRectangle] ~ {
ERROR Imager.Error[$NotYetImplemented];
};
GetSurfaceBounds: PUBLIC PROC [context: Context] RETURNS [IntRectangle] ~ {
WITH context.state SELECT FROM
state: State => {
ERROR Imager.Error[$NotYetImplemented];
};
ENDCASE => ERROR Imager.Error[$Bug];
};
END.