DIRECTORY CD USING [Number, DesignNumber, Position, DesignPosition, Rect, DesignRect]; CDVScale: CEDAR DEFINITIONS = BEGIN scaleNum: CARDINAL = 19; ScaleRange: TYPE = [0..scaleNum); ScaleRec: TYPE = RECORD [ off: CD.DesignPosition, xx: PRIVATE INT, useMultiply: PRIVATE BOOL, sA, sB, sC, sD: PRIVATE CARDINAL, grid: INTEGER, --in DesignCoordinates nscale: INTEGER ]; DesignToViewerFactor: PROC [scale: ScaleRec] RETURNS [f: REAL] ~ INLINE { IF scale.useMultiply THEN f _ scale.xx ELSE f _ 1.0/scale.xx; }; DesignToViewerScalar: PROC [scale: ScaleRec, n: CD.DesignNumber] RETURNS [CD.Number] ~ INLINE { RETURN [IF scale.useMultiply THEN n*scale.xx ELSE n/scale.xx]; }; DesignToViewerPosition: PROC[scale: ScaleRec, designPos: CD.DesignPosition] RETURNS [viewerPos: CD.Position] ~ INLINE { RETURN[ IF scale.useMultiply THEN CD.Position[ (designPos.x-scale.off.x)*scale.xx, (designPos.y-scale.off.y)*scale.xx ] ELSE CD.Position[ (designPos.x-scale.off.x)/scale.xx, (designPos.y-scale.off.y)/scale.xx ] ] }; DesignToViewerRect: PROC[scale: ScaleRec, designRect: CD.DesignRect] RETURNS [CD.Rect] ~ INLINE { RETURN[ IF scale.useMultiply THEN CD.Rect[ x1: (designRect.x1-scale.off.x)*scale.xx, y1: (designRect.y1-scale.off.y)*scale.xx, x2: (designRect.x2-scale.off.x)*scale.xx, y2: (designRect.y2-scale.off.y)*scale.xx ] ELSE CD.Rect[ x1: (designRect.x1-scale.off.x)/scale.xx, y1: (designRect.y1-scale.off.y)/scale.xx, x2: (designRect.x2-scale.off.x)/scale.xx, y2: (designRect.y2-scale.off.y)/scale.xx ] ] }; ViewerToDesignScalar: PROC [scale: ScaleRec, v: LONG CARDINAL] RETURNS [CD.DesignNumber] = INLINE { RETURN [LOOPHOLE[(v*scale.sA+scale.sB)/scale.sC*scale.sD, CD.DesignNumber]] }; UngriddedViewerToDesignScalar: PROC [scale: ScaleRec, v: LONG CARDINAL] RETURNS [CD.DesignNumber] = INLINE { IF scale.useMultiply THEN RETURN [LOOPHOLE[(v*scale.sA+scale.xx-1)/scale.xx, CD.DesignNumber]] ELSE RETURN [LOOPHOLE[(v*scale.sA), CD.DesignNumber]] }; ViewerToDesignPosition: PROC[scale: ScaleRec, viewerPos: CD.Position] RETURNS [designPos: CD.DesignPosition] = INLINE { RETURN[CD.DesignPosition[ ViewerToDesignScalar[scale, viewerPos.x]+scale.off.x, ViewerToDesignScalar[scale, viewerPos.y]+scale.off.y] ] }; MakeScale: PROC [off: CD.DesignPosition_[0, 0], nscale: ScaleRange_4, grid: INTEGER_-1] RETURNS [ScaleRec]; GetClipRecord: PROC[scale: ScaleRec, highX, highY: CARDINAL] RETURNS [CD.DesignRect]; --given the index of the (high-most) pixel in the viewer, compute an outside clipping --rectangle in design coordinates; (such that all outside the clipping area is invisible). END. rCDVScale.mesa (Viewer definitions for Chipndale) Copyright c 1983, 1984 by Xerox Corporation. All rights reserved. by Christian Jacobi July 15, 1983 11:16 am complete redesigned by Christian Jacobi August 28, 1984 8:44:31 am PDT last edited by Christian Jacobi August 28, 1984 9:01:55 am PDT -- Non public chipndale interface to scaling of viewers. -- -- Scaling must be real fast, therefore the crazyness. -- Design -> Viewer is the most speed critical operation done, used for drawing every rectangle... -- Viewer -> Design is speed critical for cursor tracking -- This interface is thought as an implementation module and freely recompiled to improve the -- inline procedures. Do never copy code from this module, because this module changes to -- often, but if new need for scaling appears, include it here. -- Analyzing compiler generated code showed that it is feasible to have a full record as -- parameter, since the optimization will get rid of copiing the record. --A type describing scales; increasing a scale number means viewing a bigger part of the --chip in a viewer; (more overview, less detail). --data in this record must be gridded correctly, such that the origin of --the viewer lies on a grid point; otherwise the gridding would --require more complex and slower arithmetic. --without translation --without translation --including translation to viewer origin --including translation to viewer origin --without translation, but gridded to the current grid --without translation, without grid --with offset and grid --given the grid, offset and nscale; makes a correctly gridded and initialized ScaleRec Ê`˜šœ7™7Jšœ Ïmœ7™BJšœ-™-JšœG™GJšœ?™?—J˜šÏk ˜ JšžœžœD˜LJ˜—JšÏnœžœž œ˜Jšž˜J˜Jšœ:™:J™Jšœ6™6J™bJ™9J™]J™ZJ™?J™YJ™HJ˜Jšœ žœ˜šœ žœ˜#JšœX™XJšœ1™1—J˜šœ žœžœ˜JšœI™IJšœ?™?Jšœ-™-Jšœžœ˜Jšœžœžœ˜Jšœ žœžœ˜Jšœžœžœ˜!JšœžœÏc˜%Jšœž˜Jšœ˜J˜—š Ÿœžœžœžœžœ˜IJšœ™Jšžœžœžœ˜=Jšœ˜—J˜šŸœžœžœ˜AJšžœžœ žœ˜Jšœ™Jšžœžœžœ žœ ˜>Jšœ˜—J™šŸœžœžœ˜LJšžœ žœ žœ˜+Jšœ(™(šžœ˜šžœžœžœ ˜&Jšœ#˜#Jšœ"˜"J˜—šžœžœ ˜Jšœ#˜#Jšœ"˜"Jšœ˜—Jšœ˜—Jšœ˜—J˜šŸœžœžœ ˜EJšžœžœ žœ˜Jšœ(™(šžœ˜šžœžœžœ˜"Jšœ)˜)Jšœ)˜)Jšœ)˜)Jšœ(˜(Jšœ˜—šžœžœ˜ Jšœ)˜)Jšœ)˜)Jšœ)˜)Jšœ(˜(Jšœ˜—Jšœ˜—Jšžœ˜—J˜šŸœžœžœžœžœžœžœ˜cJšœ6™6Jšžœžœ*žœ˜KJšœ˜—J˜šŸœžœžœžœžœžœžœ˜lJšœ#™#šžœž˜Jšžœžœ#žœ˜D—šž˜Jšžœžœžœ˜0—Jšœ˜—J˜š Ÿœžœžœ žœ žœžœ˜wJšœ™šžœžœ˜Jšœ5˜5Jšœ5˜5Jšœ˜—JšœŸ˜—J˜š Ÿ œžœžœ4žœžœ ˜kJšœW™W—J˜š Ÿ œžœ žœžœžœ ˜UJ˜VJ˜Z—J˜Jšžœ˜J˜J˜J˜—…— .