<> <<>> <> <> DIRECTORY Imager -- USING most everything --, ImagerBasic USING [State], ImagerExtras USING [MakeSampledBlack, MakeSampledColor, MaskTrapezoidX, MaskTrapezoidY, Show, ShowAndXRel], ImagerOps USING [DRound], ImagerTransform USING [Contents, FromRec, TransformationRec], IP USING [Any, AppearanceWarning, Apply, CheckInteger, Color, DoWithMarkProtection, FGet, GetIndex, ImagerVariable, Index, Integer, MasterError, Operator, Outline, Pair, PixelArray, PopBool, PopColor, PopInteger, PopOperator, PopOutline, PopPair, PopPixelArray, PopReal, PopTrajectory, PopTransformation, PopVector, PushColor, PushInteger, PushOutline, PushPair, PushPixelArray, PushReal, PushTrajectory, PushTransformation, PushVector, SetIndex, State, Trajectory, Transformation, Vector, VectorFromAny], IPFont USING [FindFont, FindFontVec, FontFromVector, ModifyFont, VectorFromFont], IPImage USING []; IPImageImpl: CEDAR PROGRAM IMPORTS Imager, ImagerExtras, ImagerOps, ImagerTransform, IP, IPFont EXPORTS IPImage ~ BEGIN OPEN IP; PopImagerVariable: PROC[self: State] RETURNS[ImagerVariable] ~ { IVal: TYPE ~ [0..ImagerVariable.LAST.ORD]; i: Integer ~ PopInteger[self]; IF i IN IVal THEN RETURN[VAL[IVal[i]]] ELSE { MasterError[$boundsFault, "Imager variable index out of bounds."]; ERROR }; }; ApplyIGET: PUBLIC PROC[self: State] ~ { var: ImagerVariable ~ PopImagerVariable[self]; imager: Imager.Context ~ self.imager; SELECT var FROM $DCScpx => PushReal[self, ImagerOps.GetReal[imager, $DCScpx]]; $DCScpy => PushReal[self, ImagerOps.GetReal[imager, $DCScpy]]; $correctMX => PushReal[self, ImagerOps.GetReal[imager, $correctMX]]; $correctMY => PushReal[self, ImagerOps.GetReal[imager, $correctMY]]; $T => WITH ImagerOps.GetRef[imager, $T] SELECT FROM t: Transformation => PushTransformation[self, t]; ENDCASE => MasterError[$bug, "Imager variable $T has wrong type."]; $priorityImportant => PushInteger[self, ImagerOps.GetInt[imager, $priorityImportant]]; $mediumXSize => PushReal[self, ImagerOps.GetReal[imager, $mediumXSize]]; $mediumYSize => PushReal[self, ImagerOps.GetReal[imager, $mediumYSize]]; $fieldXMin => PushReal[self, ImagerOps.GetReal[imager, $fieldXMin]]; $fieldYMin => PushReal[self, ImagerOps.GetReal[imager, $fieldYMin]]; $fieldXMax => PushReal[self, ImagerOps.GetReal[imager, $fieldXMax]]; $fieldYMax => PushReal[self, ImagerOps.GetReal[imager, $fieldYMax]]; $showVec => WITH ImagerOps.GetRef[imager, $showVec] SELECT FROM font: FONT => PushVector[self, IPFont.VectorFromFont[font]]; ENDCASE => MasterError[$bug, "Imager variable $showVec has wrong type."]; $color => WITH ImagerOps.GetRef[imager, $color] SELECT FROM color: Color => PushColor[self, color]; ENDCASE => MasterError[$bug, "Imager variable $color has wrong type."]; $noImage => PushInteger[self, ImagerOps.GetInt[imager, $noImage]]; $strokeWidth => PushReal[self, ImagerOps.GetReal[imager, $strokeWidth]]; $strokeEnd => PushInteger[self, ImagerOps.GetInt[imager, $strokeEnd]]; $underlineStart => PushReal[self, ImagerOps.GetReal[imager, $underlineStart]]; $amplifySpace => PushReal[self, ImagerOps.GetReal[imager, $amplifySpace]]; $correctPass => PushInteger[self, ImagerOps.GetInt[imager, $correctPass]]; $correctShrink => PushReal[self, ImagerOps.GetReal[imager, $correctShrink]]; $correctTX => PushReal[self, ImagerOps.GetReal[imager, $correctTX]]; $correctTY => PushReal[self, ImagerOps.GetReal[imager, $correctTY]]; <<$clipOutline => Push[self, state.clipOutline];>> ENDCASE => ERROR; }; ApplyISET: PUBLIC PROC[self: State] ~ { var: ImagerVariable ~ PopImagerVariable[self]; imager: Imager.Context ~ self.imager; SELECT var FROM $DCScpx => ImagerOps.SetReal[imager, $DCScpx, PopReal[self]]; $DCScpy => ImagerOps.SetReal[imager, $DCScpy, PopReal[self]]; $correctMX => ImagerOps.SetReal[imager, $correctMX, PopReal[self]]; $correctMY => ImagerOps.SetReal[imager, $correctMY, PopReal[self]]; $T => ImagerOps.SetRef[imager, $T, PopTransformation[self]]; $priorityImportant => ImagerOps.SetInt[imager, $priorityImportant, PopInteger[self]]; $mediumXSize => ImagerOps.SetReal[imager, $mediumXSize, PopReal[self]]; $mediumYSize => ImagerOps.SetReal[imager, $mediumYSize, PopReal[self]]; $fieldXMin => ImagerOps.SetReal[imager, $fieldXMin, PopReal[self]]; $fieldYMin => ImagerOps.SetReal[imager, $fieldYMin, PopReal[self]]; $fieldXMax => ImagerOps.SetReal[imager, $fieldXMax, PopReal[self]]; $fieldYMax => ImagerOps.SetReal[imager, $fieldYMax, PopReal[self]]; $showVec => imager.SetFont[IPFont.FontFromVector[PopVector[self]]]; $color => imager.SetColor[PopColor[self]]; $noImage => ImagerOps.SetInt[imager, $noImage, PopInteger[self]]; $strokeWidth => ImagerOps.SetReal[imager, $strokeWidth, PopReal[self]]; $strokeEnd => ImagerOps.SetInt[imager, $strokeEnd, PopInteger[self]]; $underlineStart => ImagerOps.SetReal[imager, $underlineStart, PopReal[self]]; $amplifySpace => ImagerOps.SetReal[imager, $amplifySpace, PopReal[self]]; $correctPass => ImagerOps.SetInt[imager, $correctPass, PopInteger[self]]; $correctShrink => ImagerOps.SetReal[imager, $correctShrink, PopReal[self]]; $correctTX => ImagerOps.SetReal[imager, $correctTX, PopReal[self]]; $correctTY => ImagerOps.SetReal[imager, $correctTY, PopReal[self]]; < ImagerOps.SetRef[imager, $clipOutline, Pop[self]];>> ENDCASE => ERROR; }; ApplyDROUND: PUBLIC PROC[self: State] ~ { p: Pair ~ PopPair[self]; PushPair[self, ImagerOps.DRound[p]]; }; ApplyMAKET: PUBLIC PROC[self: State] ~ { f: REAL ~ PopReal[self]; e: REAL ~ PopReal[self]; d: REAL ~ PopReal[self]; c: REAL ~ PopReal[self]; b: REAL ~ PopReal[self]; a: REAL ~ PopReal[self]; PushTransformation[self, Imager.MakeT[a, b, c, d, e, f]]; }; ApplyOPENT: PUBLIC PROC[self: State] ~ { m: Transformation ~ PopTransformation[self]; PushReal[self, m.a]; PushReal[self, m.b]; PushReal[self, m.c]; PushReal[self, m.d]; PushReal[self, m.e]; PushReal[self, m.f]; }; ApplyTRANSLATE: PUBLIC PROC[self: State] ~ { y: REAL ~ PopReal[self]; x: REAL ~ PopReal[self]; PushTransformation[self, Imager.Translate[x, y]]; }; ApplyROTATE: PUBLIC PROC[self: State] ~ { a: REAL ~ PopReal[self]; PushTransformation[self, Imager.Rotate[a]]; }; ApplySCALE: PUBLIC PROC[self: State] ~ { s: REAL ~ PopReal[self]; PushTransformation[self, Imager.Scale[s]]; }; ApplySCALE2: PUBLIC PROC[self: State] ~ { sy: REAL ~ PopReal[self]; sx: REAL ~ PopReal[self]; PushTransformation[self, Imager.Scale2[sx, sy]]; }; ApplyCONCAT: PUBLIC PROC[self: State] ~ { n: Transformation ~ PopTransformation[self]; m: Transformation ~ PopTransformation[self]; PushTransformation[self, Imager.Concat[m, n]]; }; ApplyINVERT: PUBLIC PROC[self: State] ~ { m: Transformation ~ PopTransformation[self]; PushTransformation[self, Imager.Invert[m]]; }; ApplyTRANSFORM: PUBLIC PROC[self: State] ~ { m: Transformation ~ PopTransformation[self]; p: Pair ~ PopPair[self]; PushPair[self, Imager.Transform[m, p]]; }; ApplyTRANSFORMVEC: PUBLIC PROC[self: State] ~ { m: Transformation ~ PopTransformation[self]; v: Pair ~ PopPair[self]; PushPair[self, Imager.TransformVec[m, v]]; }; ApplyROUNDXY: PUBLIC PROC[self: State] ~ { m: Transformation ~ PopTransformation[self]; p: Pair ~ PopPair[self]; PushPair[self, Imager.RoundXY[m, p]]; }; ApplyROUNDXYVEC: PUBLIC PROC[self: State] ~ { m: Transformation ~ PopTransformation[self]; v: Pair ~ PopPair[self]; PushPair[self, Imager.RoundXYVec[m, v]]; }; ApplyCONCATT: PUBLIC PROC[self: State] ~ { m: Transformation ~ PopTransformation[self]; Imager.ConcatT[self.imager, m]; }; ApplyMOVE: PUBLIC PROC[self: State] ~ { Imager.Move[self.imager]; }; ApplyTRANS: PUBLIC PROC[self: State] ~ { Imager.Trans[self.imager]; }; StringFromVector: PROC[v: Vector] RETURNS[REF TEXT] ~ { IF v.class=$String THEN WITH v.data SELECT FROM text: REF TEXT => RETURN[text]; ENDCASE; RETURN[NIL]; }; ApplySHOW: PUBLIC PROC[self: State] ~ { ImagerExtras.Show[self.imager, StringFromVector[PopVector[self]]]; }; ApplySHOWANDXREL: PUBLIC PROC[self: State] ~ { ImagerExtras.ShowAndXRel[self.imager, StringFromVector[PopVector[self]]]; }; ApplySETXY: PUBLIC PROC[self: State] ~ { Imager.SetXYP[self.imager, PopPair[self]]; }; ApplySETXYREL: PUBLIC PROC[self: State] ~ { Imager.SetXYRelP[self.imager, PopPair[self]]; }; ApplySETXREL: PUBLIC PROC[self: State] ~ { Imager.SetXRel[self.imager, PopReal[self]]; }; ApplySETYREL: PUBLIC PROC[self: State] ~ { Imager.SetYRel[self.imager, PopReal[self]]; }; ApplyGETCP: PUBLIC PROC[self: State] ~ { PushPair[self, Imager.GetCP[self.imager]]; }; ApplyGETCPROUNDED: PUBLIC PROC[self: State] ~ { PushPair[self, Imager.GetCPRounded[self.imager]]; }; ApplyMAKEPIXELARRAY: PUBLIC PROC[self: State] ~ { samples: Vector ~ PopVector[self]; m: Transformation ~ PopTransformation[self]; samplesInterleaved: BOOL ~ PopBool[self]; maxSampleValue: Integer ~ PopInteger[self]; samplesPerPixel: Integer ~ PopInteger[self]; yPixels: Integer ~ PopInteger[self]; xPixels: Integer ~ PopInteger[self]; <> <> <> MasterError[$unimplemented, "MAKEPIXELARRAY is not implemented."]; }; ApplyEXTRACTPIXELARRAY: PUBLIC PROC[self: State] ~ { select: Vector ~ PopVector[self]; pa: PixelArray ~ PopPixelArray[self]; MasterError[$unimplemented, "EXTRACTPIXELARRAY is not implemented."]; PushPixelArray[self, pa]; }; ApplyFINDDECOMPRESSOR: PUBLIC PROC[self: State] ~ { v: Vector ~ PopVector[self]; <> MasterError[$unimplemented, "FINDDECOMPRESSOR is not implemented."]; }; ApplyFINDCOLOR: PUBLIC PROC[self: State] ~ { v: Vector ~ PopVector[self]; <> MasterError[$unimplemented, "FINDCOLOR is not implemented."]; }; ApplyFINDCOLOROPERATOR: PUBLIC PROC[self: State] ~ { v: Vector ~ PopVector[self]; <> MasterError[$unimplemented, "FINDCOLOROPERATOR is not implemented."]; }; ApplyFINDCOLORMODELOPERATOR: PUBLIC PROC[self: State] ~ { v: Vector ~ PopVector[self]; <> MasterError[$unimplemented, "FINDCOLORMODELOPERATOR is not implemented."]; }; ApplyMAKEGRAY: PUBLIC PROC[self: State] ~ { f: REAL ~ PopReal[self]; PushColor[self, Imager.MakeGray[f]]; }; ApplyMAKESAMPLEDCOLOR: PUBLIC PROC[self: State] ~ { colorOperator: Operator ~ PopOperator[self]; um: Transformation ~ PopTransformation[self]; pa: PixelArray ~ PopPixelArray[self]; PushColor[self, ImagerExtras.MakeSampledColor[pa, um, colorOperator]]; }; ApplyMAKESAMPLEDBLACK: PUBLIC PROC[self: State] ~ { clear: BOOL ~ PopBool[self]; um: Transformation ~ PopTransformation[self]; pa: PixelArray ~ PopPixelArray[self]; PushColor[self, ImagerExtras.MakeSampledBlack[pa, um, clear]]; }; ApplySETGRAY: PUBLIC PROC[self: State] ~ { f: REAL ~ PopReal[self]; Imager.SetColor[self.imager, Imager.MakeGray[f]]; }; ApplyMOVETO: PUBLIC PROC[self: State] ~ { p: Pair ~ PopPair[self]; PushTrajectory[self, Imager.MoveTo[p]]; }; ApplyLINETO: PUBLIC PROC[self: State] ~ { p: Pair ~ PopPair[self]; t: Trajectory ~ PopTrajectory[self]; PushTrajectory[self, Imager.LineTo[t, p]]; }; ApplyLINETOX: PUBLIC PROC[self: State] ~ { x: REAL ~ PopReal[self]; t: Trajectory ~ PopTrajectory[self]; PushTrajectory[self, Imager.LineToX[t, x]]; }; ApplyLINETOY: PUBLIC PROC[self: State] ~ { y: REAL ~ PopReal[self]; t: Trajectory ~ PopTrajectory[self]; PushTrajectory[self, Imager.LineToY[t, y]]; }; ApplyCURVETO: PUBLIC PROC[self: State] ~ { p3: Pair ~ PopPair[self]; p2: Pair ~ PopPair[self]; p1: Pair ~ PopPair[self]; t: Trajectory ~ PopTrajectory[self]; PushTrajectory[self, Imager.CurveTo[t, p1, p2, p3]]; }; ApplyARCTO: PUBLIC PROC[self: State] ~ { p2: Pair ~ PopPair[self]; p1: Pair ~ PopPair[self]; t: Trajectory ~ PopTrajectory[self]; PushTrajectory[self, Imager.ArcTo[t, p1, p2]]; }; ApplyCONICTO: PUBLIC PROC[self: State] ~ { e: REAL ~ PopReal[self]; p2: Pair ~ PopPair[self]; p1: Pair ~ PopPair[self]; t: Trajectory ~ PopTrajectory[self]; PushTrajectory[self, Imager.ConicTo[t, p1, p2, e]]; }; ApplyMAKEOUTLINE: PUBLIC PROC[self: State] ~ { n: Integer ~ PopInteger[self]; list: LIST OF Trajectory _ NIL; THROUGH [0..n) DO list _ CONS[PopTrajectory[self], list] ENDLOOP; PushOutline[self, Imager.MakeOutline[list]]; }; ApplyMASKFILL: PUBLIC PROC[self: State] ~ { o: Outline ~ PopOutline[self]; Imager.MaskFill[self.imager, o]; }; ApplyMASKSTROKE: PUBLIC PROC[self: State] ~ { t: Trajectory ~ PopTrajectory[self]; Imager.MaskStroke[self.imager, t]; }; ApplyMASKSTROKECLOSED: PUBLIC PROC[self: State] ~ { t: Trajectory ~ PopTrajectory[self]; Imager.MaskStrokeClosed[self.imager, t]; }; ApplyMASKRECTANGLE: PUBLIC PROC[self: State] ~ { h: REAL ~ PopReal[self]; w: REAL ~ PopReal[self]; y: REAL ~ PopReal[self]; x: REAL ~ PopReal[self]; Imager.MaskRectangle[self.imager, x, y, w, h]; }; ApplyMASKVECTOR: PUBLIC PROC[self: State] ~ { p2: Pair ~ PopPair[self]; p1: Pair ~ PopPair[self]; Imager.MaskVector[self.imager, p1, p2]; }; ApplySTARTUNDERLINE: PUBLIC PROC[self: State] ~ { Imager.StartUnderline[self.imager]; }; ApplyMASKUNDERLINE: PUBLIC PROC[self: State] ~ { h: REAL ~ PopReal[self]; dy: REAL ~ PopReal[self]; Imager.MaskUnderline[self.imager, dy, h]; }; ApplyMASKTRAPEZOIDX: PUBLIC PROC[self: State] ~ { x4: REAL ~ PopReal[self]; y3: REAL ~ PopReal[self]; x3: REAL ~ PopReal[self]; x2: REAL ~ PopReal[self]; y1: REAL ~ PopReal[self]; x1: REAL ~ PopReal[self]; ImagerExtras.MaskTrapezoidX[self.imager, x1, y1, x2, x3, y3, x4]; }; ApplyMASKTRAPEZOIDY: PUBLIC PROC[self: State] ~ { y4: REAL ~ PopReal[self]; y3: REAL ~ PopReal[self]; x3: REAL ~ PopReal[self]; y2: REAL ~ PopReal[self]; y1: REAL ~ PopReal[self]; x1: REAL ~ PopReal[self]; ImagerExtras.MaskTrapezoidY[self.imager, x1, y1, y2, x3, y3, y4]; }; ApplyMASKPIXEL: PUBLIC PROC[self: State] ~ { pa: PixelArray ~ PopPixelArray[self]; Imager.MaskPixel[self.imager, pa]; }; ApplyCLIPOUTLINE: PUBLIC PROC[self: State] ~ { o: Outline ~ PopOutline[self]; Imager.ClipOutline[self.imager, o]; }; ApplyCLIPRECTANGLE: PUBLIC PROC[self: State] ~ { h: REAL ~ PopReal[self]; w: REAL ~ PopReal[self]; y: REAL ~ PopReal[self]; x: REAL ~ PopReal[self]; Imager.ClipRectangle[self.imager, x, y, w, h]; }; ApplyFINDFONT: PUBLIC PROC[self: State] ~ { v: Vector ~ PopVector[self]; PushVector[self, IPFont.FindFont[self, v]]; }; ApplyFINDFONTVEC: PUBLIC PROC[self: State] ~ { v: Vector ~ PopVector[self]; PushVector[self, IPFont.FindFontVec[self, v]]; }; ApplyMODIFYFONT: PUBLIC PROC[self: State] ~ { m: Transformation ~ PopTransformation[self]; v: Vector ~ PopVector[self]; PushVector[self, IPFont.ModifyFont[v, m]]; }; ApplySETFONT: PUBLIC PROC[self: State] ~ { state: ImagerBasic.State ~ self.imager.state; n: Integer ~ PopInteger[self]; state.showVec _ IPFont.FontFromVector[VectorFromAny[FGet[self, n]]]; }; ApplyCORRECTMASK: PUBLIC PROC[self: State] ~ { Imager.CorrectMask[self.imager]; }; ApplyCORRECTSPACE: PUBLIC PROC[self: State] ~ { Imager.CorrectSpace[self.imager, PopPair[self]]; }; ApplyCORRECT: PUBLIC PROC[self: State] ~ { b: Index ~ GetIndex[self]; innerBody: PROC[self: State] ~ { SetIndex[self, b]; Apply[self, $dosavesimplebody] }; body: PROC ~ { [] _ DoWithMarkProtection[self, innerBody] }; Imager.Correct[self.imager, body ! Imager.Error => IF errorCode=$UnableToProperlyAdjustMaskPositions THEN { AppearanceWarning[$correctFailed, "CORRECT failed to achieve target position within tolerance."]; CONTINUE; }; ]; }; ApplySETCORRECTMEASURE: PUBLIC PROC[self: State] ~ { Imager.SetCorrectMeasure[self.imager, PopPair[self]]; }; ApplySETCORRECTTOLERANCE: PUBLIC PROC[self: State] ~ { Imager.SetCorrectTolerance[self.imager, PopPair[self]]; }; ApplySPACE: PUBLIC PROC[self: State] ~ { Imager.Space[self.imager, PopReal[self]]; }; END.