<<>> <> <> <> <> <<>> DIRECTORY Basics USING [BITAND, BITOR], Imager USING [Color, ColorOperator, Context, Font, PathProc, PixelArray, Rectangle, Transformation, VEC], ImagerBackdoor USING [Clipper, IntKey, RealKey], ImagerClipper USING [Clipper], ImagerDeviceVector USING [DVec], Real USING [LargestNumber]; ImagerState: CEDAR DEFINITIONS IMPORTS Basics ~ BEGIN OPEN ImagerBackdoor, Imager; ChangeFlags: TYPE ~ MACHINE DEPENDENT RECORD [ T: BOOL ¬ FALSE, clipper: BOOL ¬ FALSE, font: BOOL ¬ FALSE, color: BOOL ¬ FALSE, priority: BOOL ¬ FALSE, unused: [0..LAST[CARDINAL]/32] ¬ 0 ]; bits: [BITS[WORD]..BITS[WORD]] = BITS[ChangeFlags]; notChanged: ChangeFlags ~ []; OrChangeFlags: PROC[c1, c2: ChangeFlags] RETURNS[ChangeFlags] ~ INLINE { RETURN[LOOPHOLE[Basics.BITOR[LOOPHOLE[c1], LOOPHOLE[c2]]]]; }; AndChangeFlags: PROC[c1, c2: ChangeFlags] RETURNS[ChangeFlags] ~ INLINE { RETURN[LOOPHOLE[Basics.BITAND[LOOPHOLE[c1], LOOPHOLE[c2]]]]; }; PersistentVariables: TYPE ~ RECORD [ correctMeasure: VEC ¬ [0, 0], -- target line measure for Correct, device coords correctMaskCount: INT ¬ 0, -- tally number of CorrectMask calls in pass 1 correctSum: VEC ¬ [0, 0], -- tally adjustable space from CorrectSpace calls in pass 1 correctMask: VEC ¬ [0, 0], -- space inserted by each CorrectMask call in pass 2 correctSpace: VEC ¬ [0, 0] -- adjustment factors for each CorrectSpace call in pass 2 ]; NonPersistentVariables: TYPE ~ RECORD [ changed: ChangeFlags ¬ notChanged, -- changes since np variables were saved priorityImportant: INT ¬ 0, -- if nonzero, priority of masks is important mediumSize: VEC ¬ [0, 0], -- size of medium, in meters fieldMin: VEC ¬ [0, 0], -- minimum x and y of field, in meters fieldMax: VEC ¬ [0, 0], -- maximum x and y of field, in meters noImage: INT ¬ 0, -- if nonzero, don't image masks strokeWidth: REAL ¬ 0, -- stroke width, client coords strokeEnd: INT ¬ 0, -- stroke end treatment strokeJoint: INT ¬ 0, -- stroke joint treatment underlineStart: REAL ¬ 0, -- starting x position for underline, client coords amplifySpace: REAL ¬ 1.0, -- multiplies width of amplified characters correctPass: INT ¬ 0, -- which pass, during Correct correctShrink: REAL ¬ 0.5, -- allowable space shrink correctStretch: REAL ¬ Real.LargestNumber, -- allowable space stretch correctTolerance: VEC ¬ [0, 0], -- tolerable deviation from correctMeasure, device coords miterLimit: REAL ¬ 0.0, -- miter limit on strokes warn: INT ¬ 0 -- Control over Imager.Warning ]; <> <<>> RasterData: TYPE ~ REF RasterDataRep; RasterDataRep: TYPE; State: TYPE ~ REF StateRep; StateRep: TYPE ~ RECORD [ restoreAll: BOOL ¬ FALSE, -- TRUE iff upon Restore, should restore all state variables, or only NonPersistentVariables changed: ChangeFlags ¬ notChanged, p: PersistentVariables ¬ [], -- persistent variables, other than cp np: NonPersistentVariables ¬ [], -- non-persistent variables other than REFs below cp: ImagerDeviceVector.DVec ¬ NIL, -- current position, in device coordinates. clientToDevice: Transformation ¬ NIL, -- current transformation (client to device) (mutable!) viewToDevice: Transformation ¬ NIL, -- current view to device transformation (mutable!) font: Font ¬ NIL, -- current "showVec" color: Color ¬ NIL, -- current color clipper: ImagerClipper.Clipper ¬ NIL, -- current clipping outline previous: State ¬ NIL, -- next lower State on the state stack avail: State ¬ NIL, -- list of available StateReps rasterData: RasterData ¬ NIL -- data for the common raster implementation ]; CreateState: PROC RETURNS [State]; StateSave: PROC[context: Context, all: BOOL] RETURNS [REF]; StateRestore: PROC[context: Context, ref: REF]; StateSetInt: PROC[context: Context, key: IntKey, val: INT]; StateSetReal: PROC[context: Context, key: RealKey, val: REAL]; StateSetT: PROC[context: Context, m: Transformation]; StateSetFont: PROC[context: Context, font: Font]; StateSetColor: PROC[context: Context, color: Color]; StateSetClipper: PROC[context: Context, clipper: Clipper]; StateGetInt: PROC[context: Context, key: IntKey] RETURNS[INT]; StateGetReal: PROC[context: Context, key: RealKey] RETURNS[REAL]; StateGetT: PROC[context: Context] RETURNS[Transformation]; StateGetFont: PROC[context: Context] RETURNS[Font]; StateGetColor: PROC[context: Context] RETURNS[Color]; StateGetClipper: PROC[context: Context] RETURNS[Clipper]; StateConcatT: PROC[context: Context, m: Transformation]; StateScale2T: PROC[context: Context, s: VEC]; StateRotateT: PROC[context: Context, a: REAL]; StateTranslateT: PROC[context: Context, t: VEC]; StateMove: PROC[context: Context, rounded: BOOL]; StateSetXY: PROC[context: Context, p: VEC]; StateSetXYRel: PROC[context: Context, v: VEC]; StateGetCP: PROC[context: Context, rounded: BOOL] RETURNS[VEC]; StateStartUnderline: PROC[context: Context]; StateMaskUnderline: PROC[context: Context, dy, h: REAL]; StateCorrectMask: PROC[context: Context]; StateCorrectSpace: PROC[context: Context, v: VEC]; StateSpace: PROC[context: Context, x: REAL]; StateSetCorrectMeasure: PROC[context: Context, v: VEC]; StateSetCorrectTolerance: PROC[context: Context, v: VEC]; StateCorrect: PROC[context: Context, action: PROC]; StateDontCorrect: PROC[context: Context, action: PROC, saveCP: BOOL]; StateSetGray: PROC[context: Context, f: REAL]; StateSetSampledColor: PROC[context: Context, pa: PixelArray, m: Transformation, colorOperator: ColorOperator]; StateSetSampledBlack: PROC[context: Context, pa: PixelArray, m: Transformation, clear: BOOL]; StateClip: PROC[context: Context, path: PathProc, oddWrap: BOOL, exclude: BOOL]; StateClipRectangle: PROC[context: Context, r: Rectangle, exclude: BOOL]; StateClipRectangleI: PROC[context: Context, x, y, w, h: INTEGER, exclude: BOOL]; END. Michael Plass, October 4, 1988: Added StateSave, StateRestore, removed: StateDoSave: PROC[context: Context, action: PROC, all: BOOL]; Michael Plass, September 1, 1989 9:31:22 am PDT Changed show variables to be in device coordintes rather than view coordinates. Added warn to NonPersistentVariables <<>>