<> <> <> DIRECTORY CD, CDDraw USING [CommandTable], ViewerClasses, Graphics USING [Context], PrincOps USING [BBptr], Rope USING [ROPE]; CDVPrivate: CEDAR DEFINITIONS = BEGIN catchAny: BOOL; --catches low level errors; set to false for debugging catchAnyWhichDeadlock: BOOL; --set to false for debugging <<--xx Scaling xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>> <<--Scaling must be real fast>> scaleNum: CARDINAL = 19; ScaleRange: TYPE = [0..scaleNum); defaultScale: INTEGER = 4; noDivisionScale: INTEGER = 8; ScaleDesignToViewer: PROC [me: MyGraphicRef, d: CD.DesignNumber] RETURNS [CD.Number] = <<--without necessary translation>> INLINE BEGIN IF me.nscale<=noDivisionScale THEN RETURN [d*me.sE] ELSE RETURN [d/me.sF]; END; <<>> DesignToViewerPosition: PROC[me: MyGraphicRef, designPos: CD.DesignPosition] RETURNS [viewerPos: CD.Position] = INLINE BEGIN IF me.nscale<=noDivisionScale THEN RETURN[[ (designPos.x-me.noff.x)*me.sE, (designPos.y-me.noff.y)*me.sE ]] ELSE RETURN[[ (designPos.x-me.noff.x)/me.sF, (designPos.y-me.noff.y)/me.sF ]] END; DesignToViewerRect: PROC[me: MyGraphicRef, designRect: CD.DesignRect] RETURNS [CD.Rect] = INLINE BEGIN IF me.nscale<=noDivisionScale THEN RETURN[CD.Rect[ x1: (designRect.x1-me.noff.x)*me.sE, y1: (designRect.y1-me.noff.y)*me.sE, x2: (designRect.x2-me.noff.x)*me.sE, y2: (designRect.y2-me.noff.y)*me.sE ]] ELSE RETURN[CD.Rect[ x1: (designRect.x1-me.noff.x)/me.sF, y1: (designRect.y1-me.noff.y)/me.sF, x2: (designRect.x2-me.noff.x)/me.sF, y2: (designRect.y2-me.noff.y)/me.sF ]] END; ScaleViewerToDesign: PROC [me: MyGraphicRef, v: LONG CARDINAL] RETURNS [CD.DesignNumber] = <<--without necessary translation, >> <<--this procedure uses grid>> INLINE BEGIN RETURN [LOOPHOLE[(v*me.sA+me.sB)/me.sC*me.sD, CD.DesignNumber]] END; ViewerToDesignPosition: PROC[me: MyGraphicRef, viewerPos: CD.Position] RETURNS [designPos: CD.DesignPosition] = INLINE BEGIN RETURN[[ ScaleViewerToDesign[me, viewerPos.x]+me.noff.x, ScaleViewerToDesign[me, viewerPos.y]+me.noff.y]] END; SetScale: PROC [me: MyGraphicRef, scale: INTEGER, grid: CARDINAL, noff: CD.DesignPosition]; <<--modifyes noff, such that grid conditions are satisfied>> <<--xx Data xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>> SavedRect: TYPE = RECORD [ r: CD.DesignRect, l: CD.Level ]; MyGraphicRef: TYPE = REF MyGraphicRec; -- for NEW use only NewAndLink MyGraphicRec: TYPE = RECORD [ viewer: ViewerClasses.Viewer _ NIL, <<>> <<----------->> xBLT: PrincOps.BBptr, --painting bBLT: PrincOps.BBptr, --outlining screen: LONG POINTER, bpp: CARDINAL, -- bits per pixel (1, 4, 8) logbpp: CARDINAL, colorTable: REF ColorTable, greyTable: REF ColorTable, backGround: REF Brick, scWidth: CARDINAL, -- Screen width in pixels scWidthBits: CARDINAL, -- Screen width in bits scWidthWords: CARDINAL, -- Screen width in words scHeight: CARDINAL, -- Screen height in pixels=lines vx, vy: CARDINAL, -- coordinates of viewer context origin in bitmap vwminus1, vhminus1: CARDINAL, -- size of viewer <<>> <<----------->> bmSize: CD.Position _ [0, 0], viewerContext: Graphics.Context_NIL, ct: CDDraw.CommandTable_NIL, saveList: LIST OF SavedRect_NIL, deviceDrawRef: CD.DrawRef_NIL, entered: BOOL _ FALSE, actualDesign: CD.Design_NIL, stoprequest: REF BOOLEAN, hurryUp: BOOLEAN _ FALSE, running: BOOLEAN _ FALSE, ticks: CARDINAL _ 0, suppressOutsidePushedCell: BOOL _ FALSE, suppressFactorForCells: REAL _ 1.0, <<>> <<--transformation (scaling) and grid>> nscale: INTEGER, ngrid: INTEGER, cellClipp: CD.DesignNumber_-1, noff: CD.DesignPosition _ [0, 0], sA, sB, sC, sD: CARDINAL, sE, sF, sShift: INTEGER, <<>> <<--cursor tracking information (Visible Cursors)>> usedCursor: OutLineProc, startVC, stopVC: CD.DesignPosition, onVC: BOOLEAN _ FALSE, cursorInhibitations: CARDINAL_0, -- MONITORED firstHorizontalVC: BOOLEAN _ TRUE, defaultWidthVC: CD.Number, -- width of cursored wire <<>> <<--book keeping>> link: MyGraphicRef_NIL, designRec: REF PrivatePerDesign, <<>> <<--showing a mark>> arrowRect: CD.DesignRect, -- the arrow's size backtransformed in design arrowIsOn: BOOL_FALSE, <<--debugging new features:>> tempRef: REF ANY_NIL, tempCard: CARDINAL_0, tempBool: BOOL_FALSE, tempRect: CD.Rect_[0,0,0,0], tempPos: CD.DesignPosition_[0,0] ]; PrivatePerDesign: TYPE = RECORD [ arrowOn: BOOL_FALSE, arowAt: CD.DesignPosition, startLCValid: BOOL_FALSE, -- Logical Cursors startLC: CD.DesignPosition_[0,0], stopLC: CD.DesignPosition_[0,0], firstHLC: BOOL_FALSE, widthLC: CD.DesignNumber_0, currentLevel: CD.Level, modeLC: CursorMode, outlineProcLC: OutLineProc, xMode: BOOL _ FALSE, -- usefull for wiringmode, pendingdeletemode, but only one per tip table... mark: CD.DesignPosition_[0,0] -- in future replace completely by startLC? <<--mark is a logical mark, independent of visibility>> <<--owned and changed by the Notify procedure>> ]; NewAndLink: PROC [design: CD.Design] RETURNS [MyGraphicRef]; UnLink: PROC [me: MyGraphicRef]; linkBase: PRIVATE MyGraphicRef; --xx Drawing xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx CreateDrawInformation: PROC [me: MyGraphicRef] RETURNS [CD.DrawRef]; RepaintRectAreaInViewer: PROC[me: MyGraphicRef, rect: CD.DesignRect, eraseFirst: BOOL]; RepaintBackground: PROC[me: MyGraphicRef, r: CD.DesignRect, eraseFirst: BOOL]; PaintTicks: PROC [me: MyGraphicRef, r: CD.DesignRect]; DrawCommentForViewers: PROCEDURE[r: CD.DesignRect, comment: Rope.ROPE, pr: CD.DrawRef]; <<--xx Main xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>> CreateChipndaleViewer: PROC[design: CD.Design]; <<--split or create >> ShowArrow: PROC [design: CD.Design, pos: CD.DesignPosition]; RemoveArrow: PROC[design: CD.Design]; <<--xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>> <<--Cursor>> CursorMode: TYPE = {cLBox, cBox, cArrow, cPos, cDont, cShadow, cOther}; OutLineProc: TYPE = PROC[me: MyGraphicRef]; SetCursorMode: PROC[me: MyGraphicRef, mode: CursorMode]; <<--sets modeLC, outlineProcLC>> <<--do no more export the real cursor procedures if SetCursorMode works>> LCursor: PROC [me: MyGraphicRef]; BoxCursor: PROC [me: MyGraphicRef]; LineCursor: PROC [me: MyGraphicRef]; PosCursor: PROC [me: MyGraphicRef]; DontCursor: PROC [me: MyGraphicRef]; ShadowCursor: PROC [me: MyGraphicRef]; InvertArea: PROC[me: MyGraphicRef, x1, y1, x2, y2: INT]; <> <<--xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>> TeachColor: PROC[lev: CD.Level, bpp: CARDINAL, brick: Brick]; <<--sets value into the default ColorTable >> <<--and resets default greytable>> TeachGrey: PROC[lev: CD.Level, bpp: CARDINAL, brick: Brick]; <<--sets value into the default GreyTable >> TeachColorCode: PROC[lev: CD.Level, bpp: CARDINAL, code: CARDINAL]; <<--sets value into the default Color- and GreyTable >> Brick: TYPE = ARRAY [0..4) OF CARDINAL; ColorTable: TYPE = ARRAY CD.Level OF REF Brick; colorTableBW: REF ColorTable; colorTable4: REF ColorTable; colorTable8: REF ColorTable; greyTableBW: REF ColorTable; greyTable4: REF ColorTable; greyTable8: REF ColorTable; --xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx CreateViewer: PROC [design: CD.Design] RETURNS [ViewerClasses.Viewer]; BackDoor: PROC[REF]; END.