CDVPrivate.mesa (Viewer definitions for Chipndale)
by Christian Jacobi July 15, 1983 11:16 am
last edited by Christian Jacobi November 23, 1983 3:52 pm
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: BOOLFALSE,
actualDesign: CD.Design←NIL,
stoprequest: REF BOOLEAN,
hurryUp: BOOLEANFALSE,
running: BOOLEANFALSE,
ticks: CARDINAL ← 0,
suppressOutsidePushedCell: BOOLFALSE,
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: BOOLEANFALSE,
cursorInhibitations: CARDINAL𡤀, -- MONITORED
firstHorizontalVC: BOOLEANTRUE,
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: BOOLFALSE,
--debugging new features:
tempRef: REF ANYNIL,
tempCard: CARDINAL𡤀,
tempBool: BOOLFALSE,
tempRect: CD.Rect←[0,0,0,0],
tempPos: CD.DesignPosition←[0,0]
];
PrivatePerDesign: TYPE = RECORD [
arrowOn: BOOLFALSE,
arowAt: CD.DesignPosition,
startLCValid: BOOLFALSE, -- Logical Cursors
startLC: CD.DesignPosition←[0,0],
stopLC: CD.DesignPosition←[0,0],
firstHLC: BOOLFALSE,
widthLC: CD.DesignNumber𡤀,
currentLevel: CD.Level,
modeLC: CursorMode,
outlineProcLC: OutLineProc,
xMode: BOOLFALSE, -- 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];
x1, y1, x2, y2 in viewers coordinates
--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.