-- File: DJExtGraphics.mesa -- Routines for generating graphical output for Disjoint -- Written by Martin Newell/Dan Fitzpatrick February 1981 -- Last edited (Pilot): 12-Aug-81 14:27:56 DIRECTORY CIFUtilitiesDefs: FROM "CIFUtilitiesDefs" USING [DrawRectangleOutline, GetClipRectangle, Rectangle], DisjointTypes: FROM "DisjointTypes" USING [Instance, Symbol, Rectangle, Geometry], DisjointAllocDefs: FROM "DisjointAllocDefs" USING [EnumerateSymbols], DJExtractDefs: FROM "DJExtractDefs" USING [Interrupt, GetSegmentList], DJExtGraphicsDefs: FROM "DJExtGraphicsDefs", DJExtTypes: FROM "DJExtTypes" USING [Segment], IODefs: FROM "IODefs" USING [WriteLine], JaMFnsDefs: FROM "JaMFnsDefs" USING [GetJaMBreak], MoreCIFUtilitiesDefs: FROM "MoreCIFUtilitiesDefs" USING [DrawStringAt, SetStipple, DrawRectangleArea], String: FROM "String" USING [AppendLongDecimal]; DJExtGraphics: PROGRAM IMPORTS CIFUtilitiesDefs, DisjointAllocDefs, DJExtractDefs, IODefs, JaMFnsDefs, MoreCIFUtilitiesDefs, String EXPORTS DJExtGraphicsDefs = BEGIN OPEN CIFUtilitiesDefs, DisjointTypes, DisjointAllocDefs, DJExtractDefs, DJExtTypes, IODefs, JaMFnsDefs, MoreCIFUtilitiesDefs, String; DontDraw: PUBLIC PROCEDURE = BEGIN Draw _ FALSE; END; DrawLongDecimal: PUBLIC PROCEDURE[n:LONG INTEGER,x,y:REAL] = BEGIN str:STRING _ [50]; IF NOT Draw THEN RETURN; x _ sx[x]; y _ sy[y]; AppendLongDecimal[str,n]; DrawStringAt[str, x,y]; END; DrawSegment: PUBLIC PROCEDURE[x0,y0,x1,y1:REAL] = BEGIN IF NOT Draw THEN RETURN; IF x0 = x1 THEN { -- vertical line IF y1 < y0 THEN {t:REAL_y1;y1_y0;y0_t;}; DrawRectangle[x0-w,y0,x0+w,y1,177777B]; RETURN; }; IF y0 = y1 THEN { -- horizontal line IF x1 < x0 THEN {t:REAL_x1;x1_x0;x0_t;}; DrawRectangle[x0,y0-w,x1,y0+w,177777B]; RETURN; }; DrawRectangle[x0-w,y0-w,x0+w,y0+w,177777B]; END; DrawSymbol: PUBLIC PROCEDURE[s: Symbol, callOnce: BOOLEAN, level: INTEGER] = --draw all instances of s at given level of hierarchy --level=0 is top level --level=-1 will draw all geometry --callOnce=TRUE will allow only the first call to each symbol BEGIN Mark: PROC[s: Symbol] RETURNS[BOOLEAN] = BEGIN --here .mark means symbol can still be called s.mark _ TRUE; RETURN[FALSE]; END; r: CIFUtilitiesDefs.Rectangle; count _ 0; drawSegs _ TRUE; IF NOT Draw THEN RETURN; -- mark all the symbols [] _ EnumerateSymbols[Mark]; r _ GetClipRectangle[]; [ClipL,ClipB,ClipR,ClipT] _ r; InitMap[s]; DrawSymbolR[s, callOnce, 0,0, level]; END; DrawSymbolR: PROCEDURE[s: Symbol, callOnce: BOOLEAN, x,y: REAL, level: INTEGER] = -- draw all instances of s at given level of hierarchy -- level=0 is top level BEGIN IF level=0 THEN DrawCellOffset[s, x,y, s.data] ELSE { -- IF level=1 OR level<0 THEN DrawGeomOffset[s, x,y]; FOR i:Instance _ s.insts, i.next UNTIL i=NIL DO IF GetJaMBreak[] THEN SIGNAL Interrupt; IF i.symbol.mark THEN DrawSymbolR[i.symbol, callOnce, x+i.xOffset,y+i.yOffset, level-1]; IF callOnce THEN i.symbol.mark _ FALSE; ENDLOOP; }; END; DrawCellOffset: PUBLIC PROCEDURE[us: Symbol, x,y: REAL, stipple: CARDINAL] = BEGIN r: DisjointTypes.Rectangle; IF NOT Draw THEN RETURN; FOR r _ us.windows, r.next UNTIL r=NIL DO DrawRectangle[r.l+x,r.b+y,r.r+x,r.t+y, stipple]; ENDLOOP; IF NOT drawSegs THEN RETURN; FOR s: Segment _ GetSegmentList[us],s.next UNTIL s = NIL DO IF count = 300 THEN { WriteLine["Punt on internal segments"]; drawSegs _ FALSE; EXIT; }; count _ count + 1; DrawSegment[s.bx+x,s.by+y,s.tx+x,s.ty+y]; ENDLOOP; END; DrawGeomOffset: PUBLIC PROCEDURE[us: Symbol, x,y: REAL] = BEGIN w: DisjointTypes.Rectangle; IF NOT Draw THEN RETURN; FOR w _ us.windows, w.next UNTIL w=NIL DO DrawRectangleOutline[[sx[w.l+x],sy[w.b+y],sx[w.r+x],sy[w.t+y]]]; ENDLOOP; FOR g:Geometry _ us.geom, g.next UNTIL g=NIL DO DrawRectangle[g.l+x,g.b+y,g.r+x,g.t+y, Stipple[g.layer]]; ENDLOOP; END; DrawRectangle: PUBLIC PROCEDURE[l,b,r,t: REAL, stipple: CARDINAL] = BEGIN IF NOT Draw THEN RETURN; SetStipple[stipple]; l _ sx[l]; r _ sx[r]; b _ sy[b]; t _ sy[t]; DrawRectangleArea[[l,b,r,t]]; END; ClipL,ClipB,ClipR,ClipT: REAL; BoundBox: PUBLIC PROCEDURE[s: Symbol] RETURNS[l,b,r,t: REAL] = BEGIN rec: DisjointTypes.Rectangle; l _ s.windows.l; b _ s.windows.b; r _ s.windows.r; t _ s.windows.t; --always at least one window FOR rec _ s.windows.next, rec.next UNTIL rec=NIL DO l _ MIN[l,rec.l]; b _ MIN[b,rec.b]; r _ MAX[r,rec.r]; t _ MAX[t,rec.t]; ENDLOOP; END; scale,cx,cy,w: REAL; InitMap: PUBLIC PROCEDURE[s: Symbol] = BEGIN l,b,r,t: REAL; [l,b,r,t] _ BoundBox[s]; scale _ MIN[((ClipR-ClipL)/(r-l)),((ClipT-ClipB)/(t-b))]; cx _ (ClipL+ClipR)/2 - scale*(l+r)/2; cy _ (ClipT+ClipB)/2 - scale*(t+b)/2; w _ MAX[(r-l),(t-b)]/200; END; sx: PUBLIC PROCEDURE[x: REAL] RETURNS[REAL] = BEGIN RETURN[scale*x+cx]; END; sy: PUBLIC PROCEDURE[y: REAL] RETURNS[REAL] = BEGIN RETURN[scale*y+cy]; END; count: CARDINAL; drawSegs: BOOLEAN; Draw: BOOLEAN _ TRUE; Stipple: ARRAY [0..16) OF CARDINAL _ ALL[177777B]; --undef --Set up default stipples Stipple[0] _ 000020B; --implant Stipple[1] _ 040501B; --diffusion Stipple[2] _ 014102B; --poly Stipple[3] _ 165627B; --contact Stipple[4] _ 000050B; --metal Stipple[5] _ 001110B; --buried Stipple[6] _ 001122B; --glass Stipple[7] _ 177777B; --undef END. e6(635)\183b10B721b13B272b8B49b15B268b11B397b10B250b4B47i43I135i20I147b11B76i51I4i20I363b14B506b14B353b13B383b8B367b7B251b2B78b2B