DIRECTORY CD, CDInstances, CDBasics, CDRects, CDSequencer, CDCallSpecific, CDCommandOps, CDOps, CDOrient, CDProperties, CDViewer, TerminalIO, ViewerClasses, ViewerOps; CDCutWireCommands: CEDAR PROGRAM IMPORTS CDInstances, CDBasics, CDCommandOps, CDOps, CDOrient, CDProperties, CDSequencer, CDViewer, TerminalIO, CDRects, ViewerOps = BEGIN CutInstance: PROC [design: CD.Design, inst: CD.Instance, from, to: CD.Position, gridding: CD.Number_1] = { NearlyRoundToLambda: PROC[x: CD.Number] RETURNS[r: CD.Number] = { r _ (x/gridding)*gridding; }; cutPos: CD.Position; L1, L2, W1, W2: CD.Number; wireLeft, wireRight: CD.Object; inter: CD.Position; -- the intersection of the two lines, if any, and the center of the wire oldRect: CD.Rect _ CDInstances.InstRectI[inst]; -- the bounding box oldSize: CD.Position _ CDBasics.SizeOfRect[oldRect]; vertical: BOOL _ oldSize.y > oldSize.x; dx: CD.Number _ to.x-from.x; dy: CD.Number _ to.y-from.y; ctr: CD.Position _ CDBasics.Center[oldRect]; IF vertical AND (dx=0) OR (NOT vertical) AND (dy=0) THEN RETURN; gridding _ MAX[1, gridding]; inter _ IF vertical THEN [ctr.x, (from.y+(dy*(ctr.x-from.x)/dx))/gridding*gridding] ELSE [(dx*(ctr.y-from.y)/dy+from.x)/gridding*gridding, ctr.y]; IF NOT (CDBasics.InsidePos[inter, CDBasics.ToRect[from, to]] AND CDBasics.InsidePos[inter, CDBasics.Extend[oldRect, -1]]) THEN RETURN; cutPos _ IF vertical THEN [oldRect.x1, inter.y] ELSE [inter.x, oldRect.y1]; IF vertical THEN { L1 _ cutPos.y - oldRect.y1; L2 _ oldSize.y - L1; W1 _ W2 _ oldSize.x; } ELSE { L1 _ L2 _ oldSize.y; W1 _ cutPos.x - oldRect.x1; W2 _ oldSize.x - W1; }; wireLeft _ CDRects.CreateRect[CDOrient.OrientedSize[[W1, L1], inst.orientation], inst.ob.layer]; wireRight _ CDRects.CreateRect[CDOrient.OrientedSize[[W2, L2], inst.orientation], inst.ob.layer]; CDOps.IncludeInstance[design, CDInstances.NewInstI[wireLeft, CDBasics.BaseOfRect[oldRect], inst.orientation, TRUE, CDProperties.DCopyProps[inst.properties]], FALSE]; CDOps.IncludeInstance[design, CDInstances.NewInstI[wireRight, cutPos, inst.orientation, TRUE, CDProperties.DCopyProps[inst.properties]], FALSE]; CDOps.RemoveInstance[design, inst]; }; DoAllCuts: PROC [design: CD.Design, from, to: CD.Position, gridding: CD.Number _ 1] = { FOR list: CD.InstanceList _ CDOps.InstList[design], list.rest WHILE list#NIL DO IF list.first.selected AND list.first.ob.class.wireTyped THEN CutInstance[design, list.first, from, to, gridding]; ENDLOOP; }; CutWireComm: PROC [comm: CDSequencer.Command] = { grid: CD.Number _ GetGrid[comm]; TerminalIO.WriteRopes["cut selected with grid ", CDCommandOps.LambdaRope[grid, comm.design.technology.lambda], "\n"]; DoAllCuts[design: comm.design, from: comm.sPos, to: comm.pos, gridding: grid] }; GetGrid: PROC [comm: CDSequencer.Command] RETURNS [g: CD.Number_0] = { v: ViewerClasses.Viewer _ CDViewer.GetViewer[comm]; IF v#NIL THEN { WITH ViewerOps.GetViewer[v, $Grid] SELECT FROM ri: REF INT => g _ ri^; ENDCASE => NULL; }; IF g<=0 THEN g _ comm.design.technology.lambda; }; CDSequencer.ImplementCommand[$SplitWireS, CutWireComm]; CDSequencer.ImplementCommand[$CutWireS, CutWireComm]; END. fCDCutWireCommands.mesa (part of ChipNDale) Copyright c 1984, 1985 by Xerox Corporation. All rights reserved. Last Edited by: Monier, July 24, 1984 11:31:03 am PDT Last Edited by: Jacobi, Jacobi, April 11, 1985 9:18:19 am PST Last Edited by: Bertrand Serlet October 6, 1985 6:44:38 pm PDT Last Edited by: Jacobi, July 23, 1986 3:31:45 pm PDT Last edited by: Christian Jacobi, September 12, 1986 1:43:48 pm PDT --Test if vector parallel to wire --Now we can divide and find the intersection of lines (not yet segments) --Monier-Sindhu theorem: if inter is in cursorBox and in oldRect, then it is the intersection of segments --The mouse track defines the cut vector. Let's define the "spine" of a wire as the centerline, roughly in the middle (lambda) and following the visible length, i.e. the longer edge, not the CD length. Then we cut the wire at the position where the spine meets the cut vector. The cut always reduces the visible length of the wire. (Pff, not easy to describe without drawing!) --A vertical wire freshly drawn has even (0) orientation. --figures out grid used for a particular design or viewer Κ·˜codešœ,™,Kšœ Οmœ7™BK™5K™=K™>K™4K™CK˜—šΟk ˜ Kšžœ˜K˜ Kšœ ˜ K˜K˜ K˜Kšœ ˜ Kšœ˜K˜ K˜ K˜ K˜ K˜K˜ —K˜šΟnœžœž˜ Kšžœ}˜„—Kšž˜K˜š Ÿ œžœ žœžœžœ%˜jK˜š Ÿœžœžœ žœžœ ˜AKšœ˜Kšœ˜—K˜Kšœžœ ˜Kšœžœ˜Kšœžœ˜Kšœžœ ΟcH˜\Kšœ žœ% ˜CKšœ žœ)˜4Kšœ žœ˜'Kšœžœžœ˜9Kšœžœ%˜,Kšœ!™!Kšžœ žœžœžœ žœžœžœ˜@KšœI™IKšœ žœ˜šœžœ ˜Kšžœ;˜?Kšžœ:˜>—Kšœi™iKš žœžœ7žœ:žœžœ˜†Kšœ žœ žœžœ˜Kšžœ žœ˜Kšœ˜Kšœ˜Kšœ˜K˜—šžœ˜Kšœ˜Kšœ˜Kšœ˜K˜—Kšœ`˜`Kšœa˜aKšœmžœ-žœ˜₯KšœXžœ-žœ˜Kšœ#˜#Kšžœ˜—K˜š Ÿ œžœ žœžœžœ˜WKšœψ™ψK™9š žœžœ2žœžœž˜Ošžœžœžœ˜>Kšœ4˜4—Kšžœ˜—Kšžœ˜—K˜šŸ œžœ ˜1Kšœ ˜ Kšœu˜uKšœM˜MKšœ˜—K˜š Ÿœžœžœ žœžœ˜FKšœ9™9Kšœ3˜3šžœžœžœ˜šžœžœž˜.Jšœžœžœ ˜Jšžœžœ˜—Kšœ˜—Kšžœžœ#˜/Kšœ˜—K˜Kšœ7˜7Kšœ5˜5Kšžœ˜K˜K˜K˜—…— @]