<> <> <> DIRECTORY CD, CDCommands, CDOps, CDOrient, CDRects, CDSequencer, TerminalIO, CDInline; CDWireAndSelectCommands: CEDAR PROGRAM IMPORTS CDCommands, CDOps, CDSequencer, TerminalIO, CDRects, CDInline = BEGIN AddARect: PROC[design: CD.Design, r: CD.DesignRect, l: CD.Level] = BEGIN ob: CD.ObPtr; sz: CD.DesignPosition _ CDInline.SizeOfRect[r]; orient: CD.Orientation _ CDOrient.original; IF sz.y> BEGIN InternalAddWire[comm: comm, firstOnly: FALSE] END; ContinueWire: PROC [comm: CDSequencer.Command] = BEGIN InternalAddWire[comm: comm, firstOnly: TRUE] END; InternalAddWire: PROC [comm: CDSequencer.Command, firstOnly: BOOL_FALSE] = <<--this procedure knows EXACTLY the algorithm used for showing>> <<--temporary wires in the cursor part>> BEGIN start: CD.DesignPosition _ comm.sPos; stop: CD.DesignPosition _ comm.pos; wireWidth: CD.DesignNumber _ comm.n; IF wireWidth=0 THEN {AddRect[comm]; RETURN}; TerminalIO.WriteRope["Add wire\n"]; IF --firstHorizontal-- comm.b THEN { IF stop.x<=start.x AND stop.x>=start.x-wireWidth AND (stop.ystart.y+wireWidth) THEN { --crazy vertical wire IF ABS[start.y-stop.y]> IF stop.y>=start.y AND stop.y<=start.y+wireWidth THEN { --horizontal wire stop.y _ start.y+wireWidth; AddARect[comm.design, CDInline.ToRect[start, stop], comm.l] } ELSE { --L shaped (firsthorizontal) IF start.x<=stop.x THEN {stop.x _ stop.x+wireWidth} ELSE {t: CD.Number=stop.x; stop.x _ start.x; start.x _ t}; stop.y _ start.y+wireWidth; AddARect[comm.design, CDInline.ToRect[start, stop], comm.l]; IF firstOnly THEN RETURN; start.x _ comm.pos.x; stop.y _ comm.pos.y; stop.x _ start.x+wireWidth; AddARect[comm.design, CDInline.ToRect[start, stop], comm.l]; } } ELSE { -- NOT firstHorizontalVC -- IF stop.y<=start.y AND stop.y>=start.y-wireWidth AND (stop.xstart.x+wireWidth) THEN { --crazy horizontal wire IF ABS[stop.x-start.x]> IF stop.x>=start.x AND stop.x<=start.x+wireWidth THEN { --vertical wire stop.x _ start.x+wireWidth; AddARect[comm.design, CDInline.ToRect[start, stop], comm.l] } ELSE { --L shaped (firstVertical) IF start.y<=stop.y THEN {stop.y _ stop.y+wireWidth} ELSE {t: CD.Number = stop.y; stop.y _ start.y; start.y _ t}; stop.x _ start.x+wireWidth; AddARect[comm.design, CDInline.ToRect[start, stop], comm.l]; IF firstOnly THEN RETURN; start.y _ comm.pos.y; stop.y _ start.y+wireWidth; stop.x _ comm.pos.x; AddARect[comm.design, CDInline.ToRect[start, stop], comm.l]; } } END; DeselectPointed: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["Remove selection\n"]; CDCommands.DeSelect[comm.design, comm.pos] END; AddSelection: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["Add selection "]; CDCommands.Select[comm.design, comm.pos]; TerminalIO.WriteLn[]; END; DeselectAll: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["Deselect all\n"]; CDCommands.DeselectAll[comm.design] END; DeleteSelected: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["Delete selected\n"]; CDCommands.DeleteSelected[comm.design] END; DeletePointed: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["Delete pointed\n"]; CDCommands.DeletePointed[comm.design, comm.pos] END; Undelete: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["Undelete\n"]; CDCommands.Undelete[comm.design] END; SelectAll: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["Select all\n"]; CDCommands.SelectAll[comm.design] END; AreaAddSelect: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["Inclusive select area\n"]; CDCommands.AreaSelect[comm.design, CDInline.ToRect[comm.pos, comm.sPos]] END; AAddSelect: PROC [comm: CDSequencer.Command] = <<--Auto select area or pointed>> BEGIN IF comm.pos=comm.sPos THEN { TerminalIO.WriteRope["select inclusive "]; CDCommands.Select[comm.design, comm.pos]; TerminalIO.WriteLn[]; } ELSE { TerminalIO.WriteRope["select inclusive\n"]; CDCommands.AreaSelect[comm.design, CDInline.ToRect[comm.pos, comm.sPos]] } END; AreaAddSelectTouching: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["select inclusive touching\n"]; CDCommands.AreaSelect[comm.design, CDInline.ToRect[comm.pos, comm.sPos], TRUE] END; AreaOnlySelect: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["Exclusive select area\n"]; CDCommands.DeselectAll[comm.design]; CDCommands.AreaSelect[comm.design, CDInline.ToRect[comm.pos, comm.sPos]] END; ADeSelect: PROC [comm: CDSequencer.Command] = <<--Auto deselect area or pointed>> BEGIN TerminalIO.WriteRope["deselect\n"]; IF comm.pos=comm.sPos THEN CDCommands.DeSelect[comm.design, comm.pos] ELSE CDCommands.AreaDeSelect[comm.design, CDInline.ToRect[comm.pos, comm.sPos]] END; AreaDeSelect: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["Deselect area\n"]; CDCommands.AreaDeSelect[comm.design, CDInline.ToRect[comm.pos, comm.sPos]] END; AreaDeSelectTouching: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["Deselect touching\n"]; CDCommands.AreaDeSelect[comm.design, CDInline.ToRect[comm.pos, comm.sPos], TRUE] END; Impl: PROC [] = BEGIN CDSequencer.ImplementCommand[$OnlySelectP, SelectExclusive]; CDSequencer.ImplementCommand[$AddSelectP, AddSelection]; CDSequencer.ImplementCommand[$DeSelectP, DeselectPointed]; CDSequencer.ImplementCommand[$DeSelectS, DeselectAll]; CDSequencer.ImplementCommand[$DrawRect, AddRect]; CDSequencer.ImplementCommand[$DrawWire, AddWire]; CDSequencer.ImplementCommand[$ContinueWire, ContinueWire]; CDSequencer.ImplementCommand[$DeleteS, DeleteSelected]; CDSequencer.ImplementCommand[$DeleteP, DeletePointed]; CDSequencer.ImplementCommand[$SelectAll, SelectAll]; CDSequencer.ImplementCommand[$AreaOnlySelect, AreaOnlySelect]; CDSequencer.ImplementCommand[$Undel, Undelete]; CDSequencer.ImplementCommand[$AreaAddSelect, AreaAddSelect]; CDSequencer.ImplementCommand[$AreaAddSelectTouching, AreaAddSelectTouching]; CDSequencer.ImplementCommand[$AAddSelect, AAddSelect]; CDSequencer.ImplementCommand[$AreaDeSelect, AreaDeSelect]; CDSequencer.ImplementCommand[$AreaDeSelectTouching, AreaDeSelectTouching]; CDSequencer.ImplementCommand[$ADeSelect, ADeSelect]; END; Impl[]; END.