NewImagerIPImpl.mesa
Edited by:
Doug Wyatt, June 22, 1984 5:23:22 pm PDT
DIRECTORY
Font USING [FONT, Name, RequestedTransformation],
NewImager USING [Class, ClassRep, Context, Error],
ImagerBasic USING [Color, ConstantColor, IntPair, IntRectangle, Pair, PathMapType, PixelArray, StrokeEnd, Transformation, Visibility],
ImagerTransform USING [Contents, TransformationRec],
IPOutput,
RefText USING [TrustTextAsRope],
Rope USING [FromChar, ROPE, Substr];
ImagerIPImpl: CEDAR PROGRAM
IMPORTS Font, Imager: NewImager, ImagerTransform, IPOutput, RefText, Rope
~ BEGIN OPEN ImagerBasic;
ROPE: TYPE ~ Rope.ROPE;
Context: TYPE ~ Imager.Context;
FONT: TYPE ~ Font.FONT;
Name: TYPE ~ ImagerPrivate.Name;
TransformationRec: TYPE ~ ImagerTransform.TransformationRec;
Master:
TYPE ~ IPOutput.Master;
Init:
PROC[context: Context, info:
REF] ~ {
master: Master ~ IPOutput.Narrow[info];
context.data ← master;
};
GetMaster:
PROC[context: Context]
RETURNS[Master] ~
INLINE {
RETURN[IPOutput.Narrow[context.data]];
};
Get:
PROC[context: Context, key: Variable]
RETURNS[
REF] ~ {
ERROR Imager.Error[$Unimplemented];
};
GetReal:
PROC[context: Context, key: Variable]
RETURNS[
REAL] ~ {
ERROR Imager.Error[$Unimplemented];
};
GetInt:
PROC[context: Context, key: Variable]
RETURNS[
INT] ~ {
ERROR Imager.Error[$Unimplemented];
};
Set:
PROC[context: Context, key: Variable, value:
REF] ~ {
master: Master ~ GetMaster[context];
SELECT key
FROM
$T => ERROR Imager.Error[$Unimplemented];
$showVec =>
SELECT value
FROM
font: FONT => SetFont[master, font];
ENDCASE => ERROR Imager.Error[$WrongType];
$color =>
SELECT value
FROM
color: Color => SetColor[master, color];
ENDCASE => ERROR Imager.Error[$WrongType];
$clipper => ERROR Imager.Error[$Unimplemented];
ENDCASE => ERROR Imager.Error[$WrongType];
};
SetFont:
PROC[master: Master, font:
FONT] ~ {
name: ROPE ~ font.Name[];
m: TransformationRec ~ font.RequestedTransformation[].Contents[];
master.FindFont[name];
master.MakeT[m.a, m.b, m.c, m.d, m.e, m.f];
master.ModifyFont[];
master.ISet[$showVec];
};
SetColor:
PROC[master: Master, color: Color] ~ {
WITH color
SELECT
FROM
c: ConstantColor =>
WITH c
SELECT
FROM
c: GrayConstantColor => master.SetGray[c.f];
c: CIEConstantColor => {
master.SetGray[1.0-(REAL[c.Y]/REAL[CARDINAL.LAST])];
};
ENDCASE => ERROR Imager.Error[$Unimplemented];
c: SampledColor => ERROR Imager.Error[$Unimplemented];
ENDCASE => ERROR Imager.Error[$Bug];
};
SetReal:
PROC[context: Context, key: Variable, value:
REAL] ~ {
master: Master ~ GetMaster[context];
SELECT key
FROM
$DCScpx => ERROR Imager.Error[$Unimplemented];
$DCScpy => ERROR Imager.Error[$Unimplemented];
$correctMX => ERROR Imager.Error[$Unimplemented];
$correctMY => ERROR Imager.Error[$Unimplemented];
$mediumXSize => ERROR Imager.Error[$Unimplemented];
$mediumYSize => ERROR Imager.Error[$Unimplemented];
$fieldXMin => ERROR Imager.Error[$Unimplemented];
$fieldYMin => ERROR Imager.Error[$Unimplemented];
$fieldXMax => ERROR Imager.Error[$Unimplemented];
$fieldYMax => ERROR Imager.Error[$Unimplemented];
$strokeWidth => { master.PutReal[value]; master.ISet[$strokeWidth] };
$underlineStart => ERROR Imager.Error[$Unimplemented];
$amplifySpace => { master.PutReal[value]; master.ISet[$amplifySpace] };
$correctShrink => { master.PutReal[value]; master.ISet[$correctShrink] };
$correctTX => ERROR Imager.Error[$Unimplemented];
$correctTY => ERROR Imager.Error[$Unimplemented];
ENDCASE => ERROR Imager.Error[$WrongType];
};
SetInt:
PROC[context: Context, key: Variable, value:
INT] ~ {
master: Master ~ GetMaster[context];
SELECT key
FROM
$priorityImportant => { master.PutInt[value]; master.ISet[$priorityImportant] };
$noImage => { master.PutInt[value]; master.ISet[$noImage] };
$strokeEnd => { master.PutInt[value]; master.ISet[$strokeEnd] };
$correctPass => ERROR Imager.Error[$Unimplemented];
ENDCASE => ERROR Imager.Error[$WrongType];
};
SetSampledColor:
PROC[context: Context, pa: PixelArray, pixelT: Transformation, colorOperator:
ATOM] ~ {
ERROR Imager.Error[$Unimplemented];
};
SetSampledBlack:
PROC[context: Context, pa: PixelArray, pixelT: Transformation, transparent:
BOOLEAN] ~ {
ERROR Imager.Error[$Unimplemented];
};
DoSave:
PROC[context: Context, body:
PROC] ~ {
master: Master ~ GetMaster[context];
master.BeginDoSaveSimpleBody[];
body[];
master.EndDoSaveSimpleBody[];
};
DoSaveAll:
PROC[context: Context, body:
PROC] ~ {
master: Master ~ GetMaster[context];
master.BeginMakeSimpleCO[];
body[];
master.EndMakeSimpleCO[];
master.DoSaveAll[];
};
ConcatT:
PROC[context: Context, m: Transformation] ~ {
master: Master ~ GetMaster[context];
master.MakeT[m.a, m.b, m.c, m.d, m.e, m.f];
master.ConcatT[];
};
ScaleT:
PROC[context: Context, s:
REAL] ~ {
master: Master ~ GetMaster[context];
master.Scale[s]; master.ConcatT[];
};
Scale2T:
PROC[context: Context, sx, sy:
REAL] ~ {
master: Master ~ GetMaster[context];
master.Scale2[sx, sy]; master.ConcatT[];
};
RotateT:
PROC[context: Context, a:
REAL] ~ {
master: Master ~ GetMaster[context];
master.Rotate[a]; master.ConcatT[];
};
TranslateT:
PROC[context: Context, x, y:
REAL] ~ {
master: Master ~ GetMaster[context];
master.Translate[x, y]; master.ConcatT[];
};
Move:
PROC[context: Context] ~ {
master: Master ~ GetMaster[context];
master.Move[];
};
Trans:
PROC[context: Context] ~ {
master: Master ~ GetMaster[context];
master.Trans[];
};
SetXY:
PROC[context: Context, x, y:
REAL] ~ {
master: Master ~ GetMaster[context];
master.SetXY[x, y];
};
SetXYI:
PROC[context: Context, x, y:
INTEGER] ~ {
master: Master ~ GetMaster[context];
master.SetXY[x, y];
};
SetXYRel:
PROC[context: Context, x, y:
REAL] ~ {
master: Master ~ GetMaster[context];
IF y=0 THEN master.SetXRel[x]
ELSE IF x=0 THEN master.SetYRel[y]
ELSE master.SetXYRel[x, y];
};
SetXYRelI:
PROC[context: Context, x, y:
INTEGER] ~ {
master: Master ~ GetMaster[context];
IF y=0 THEN master.SetXRel[x]
ELSE IF x=0 THEN master.SetYRel[y]
ELSE master.SetXYRel[x, y];
};
DoTrajectories:
PROC[master: Master, pathProc: PathProc, pathData:
REF,
action: PROC[Master]] ~ {
started: BOOL ← FALSE;
lx, ly: REAL ← 0;
moveTo:
PROC[x, y:
REAL] ~ {
IF started THEN action[master] ELSE started ← TRUE;
master.MoveTo[lx ← x, ly ← y];
};
lineTo:
PROC[x, y:
REAL] ~ {
IF y=ly THEN master.LineToX[lx ← x]
ELSE IF x=lx THEN master.LineToY[ly ← y]
ELSE master.LineTo[lx ← x, ly ← y];
};
curveTo:
PROC[x1, y1, x2, y2, x3, y3:
REAL] ~ {
master.CurveTo[x1, y1, x2, y2, lx ← x3, ly ← y3];
};
conicTo:
PROC[x1, y1, x2, y2:
REAL, r:
REAL] ~ {
master.ConicTo[x1, y1, lx ← x2, ly ← y2, r];
};
arcTo:
PROC[x1, y1, x2, y2:
REAL] ~ {
master.ArcTo[x1, y1, lx ← x2, ly ← y2];
};
pathProc[pathData, moveTo, lineTo, curveTo, conicTo, arcTo];
IF started THEN action[master];
};
MaskFill:
PROC[context: Context, pathProc: PathProc, pathData:
REF] ~ {
master: Master ~ GetMaster[context];
n: INT ← 0;
action: PROC[master: Master] ~ { n ← n+1 };
DoTrajectories[master, pathProc, pathData, action];
master.MakeOutline[n];
master.MaskFill[];
};
MaskStroke:
PROC[context: Context, pathProc: PathProc, pathData:
REF] ~ {
master: Master ~ GetMaster[context];
action: PROC[master: Master] ~ { master.MaskStroke[] };
DoTrajectories[master, pathProc, pathData, action];
};
MaskStrokeClosed:
PROC[context: Context, pathProc: PathProc, pathData:
REF] ~ {
master: Master ~ GetMaster[context];
action: PROC[master: Master] ~ { master.MaskStrokeClosed[] };
DoTrajectories[master, pathProc, pathData, action];
};
MaskVector:
PROC [context: Context, x1, y1, x2, y2:
REAL] ~ {
master: Master ~ GetMaster[context];
master.MaskVector[x1, y1, x2, y2];
};
MaskVectorI:
PROC[context: Context, x1, y1, x2, y2:
INTEGER] ~ {
master: Master ~ GetMaster[context];
master.MaskVector[x1, y1, x2, y2];
};
MaskRectangle:
PROC[context: Context, x, y, w, h:
REAL] ~ {
master: Master ~ GetMaster[context];
master.MaskRectangle[x, y, w, h];
};
MaskRectangleI:
PROC[context: Context, x, y, w, h:
INTEGER] ~ {
master: Master ~ GetMaster[context];
master.MaskRectangle[x, y, w, h];
};
StartUnderline:
PROC[context: Context] ~ {
master: Master ~ GetMaster[context];
master.StartUnderline[];
};
MaskUnderline:
PROC[context: Context, dy, h:
REAL] ~ {
master: Master ~ GetMaster[context];
master.MaskUnderline[dy, h];
};
MaskUnderlineI:
PROC[context: Context, dy, h:
INTEGER] ~ {
master: Master ~ GetMaster[context];
master.MaskUnderline[dy, h];
};
MaskPixel:
PROC[context: Context, pa: PixelArray] ~ {
ERROR Imager.Error[$Unimplemented];
};
ClipOutline:
PROC[context: Context, pathProc: PathProc, pathData:
REF] ~ {
ERROR Imager.Error[$Unimplemented];
};
ExcludeOutline:
PROC[context: Context, pathProc: PathProc, pathData:
REF] ~ {
ERROR Imager.Error[$Unimplemented];
};
ClipRectangle:
PROC[context: Context, x, y, w, h:
REAL] ~ {
ERROR Imager.Error[$Unimplemented];
};
ExcludeRectangle:
PROC[context: Context, x, y, w, h:
REAL] ~ {
ERROR Imager.Error[$Unimplemented];
};
ClipRectangleI:
PROC[context: Context, x, y, w, h:
INTEGER] ~ {
ERROR Imager.Error[$Unimplemented];
};
ExcludeRectangleI:
PROC[context: Context, x, y, w, h:
INTEGER] ~ {
ERROR Imager.Error[$Unimplemented];
};
ShowChar:
PROC[context: Context, char:
CHAR] ~ {
master: Master ~ GetMaster[context];
master.Show[Rope.FromChar[char]];
};
ShowCharacters:
PROC[context: Context, characters:
REF, start:
INT, length:
INT] ~ {
master: Master ~ GetMaster[context];
rope:
ROPE ~
WITH characters
SELECT
FROM
text: REF TEXT => RefText.TrustTextAsRope[text],
ENDCASE => NARROW[characters];
master.Show[rope.Substr[start, length]];
};
CorrectMask:
PROC[context: Context] ~ {
master: Master ~ GetMaster[context];
master.CorrectMask[];
};
CorrectSpace:
PROC[context: Context, v: Pair] ~ {
master: Master ~ GetMaster[context];
master.CorrectSpace[v.x, v.y];
};
SetCorrectMeasure:
PROC[context: Context, v: Pair] ~ {
master: Master ~ GetMaster[context];
master.SetCorrectMeasure[v.x, v.y];
};
SetCorrectTolerance:
PROC [context: Context, v: Pair] ~ {
master: Master ~ GetMaster[context];
master.SetCorrectTolerance[v.x, v.y];
};
Space:
PROC [context: Context, x:
REAL] ~ {
master: Master ~ GetMaster[context];
master.Space[x];
};
SpaceI:
PROC [context: Context, x:
INTEGER] ~ {
master: Master ~ GetMaster[context];
master.Space[x];
};
Correct:
PROC[context: Context, body:
PROC] ~ {
master: Master ~ GetMaster[context];
master.BeginCorrect[];
body[];
master.EndCorrect[];
};
interpressClass: Imager.Class ~
NEW[Imager.ClassRep ← [
type: $Interpress,
DoSave: DoSave,
DoSaveAll: DoSaveAll,
Set: Set,
SetReal: SetReal,
SetInt: SetInt,
Get: Get,
GetReal: GetReal,
GetInt: GetInt,
ConcatT: ConcatT,
ScaleT: ScaleT,
Scale2T: Scale2T,
RotateT: RotateT,
TranslateT: TranslateT,
Move: Move,
Trans: Trans,
SetSampledColor: SetSampledColor,
SetSampledBlack: SetSampledBlack,
SetXY: SetXY,
SetXYI: SetXYI,
SetXYRel: SetXYRel,
SetXYRelI: SetXYRelI,
MaskFill: MaskFill,
MaskStroke: MaskStroke,
MaskStrokeClosed: MaskStrokeClosed,
MaskVector: MaskVector,
MaskVectorI: MaskVectorI,
MaskRectangle: MaskRectangle,
MaskRectangleI: MaskRectangleI,
StartUnderline: StartUnderline,
MaskUnderline: MaskUnderline,
MaskUnderlineI: MaskUnderlineI,
MaskPixel: MaskPixel,
ClipOutline: ClipOutline,
ExcludeOutline: ExcludeOutline,
ClipRectangle: ClipRectangle,
ExcludeRectangle: ExcludeRectangle,
ClipRectangleI: ClipRectangleI,
ExcludeRectangleI: ExcludeRectangleI,
ShowChar: ShowChar,
ShowCharacters: ShowCharacters,
CorrectMask: CorrectMask,
CorrectSpace: CorrectSpace,
SetCorrectMeasure: SetCorrectMeasure,
SetCorrectTolerance: SetCorrectTolerance,
Space: Space,
SpaceI: SpaceI,
Correct: Correct
]];
ImagerPrivate.RegisterDevice[interpressClass];
END.