diff --git a/src/Renderer/DrawBlock/BusWire.fs b/src/Renderer/DrawBlock/BusWire.fs index 4ed668dfa..d198476b3 100644 --- a/src/Renderer/DrawBlock/BusWire.fs +++ b/src/Renderer/DrawBlock/BusWire.fs @@ -201,11 +201,19 @@ let logSegmentsInModel (model: Model) (wireSegmentIdPairs: (int*ConnectionId) li /// Given the coordinates of two port locations that correspond /// to the endpoints of a wire, as well as the final port orientation -/// this function returns a list of wire vertices +/// this function returns a list of wire vertices. +/// The starting segment will always be from a Right Edge (and so in increasing X direction) let makeInitialWireVerticesList (wireStartPos : XYPos) (wireEndPos : XYPos) (portOrientation : Edge) = let xStart, yStart, xEnd, yEnd = wireStartPos.X, wireStartPos.Y, wireEndPos.X, wireEndPos.Y - let nubLength = Constants.nubLength + let nubLength = + let xDelta = xEnd - xStart + let yDelta = abs (yEnd - yStart) + match portOrientation with + | CommonTypes.Edge.Left when xDelta > 0 -> min nubLength (xDelta / 2.) + | CommonTypes.Edge.Top + | CommonTypes.Edge.Bottom when xDelta > 0 -> min nubLength xDelta + | _ -> nubLength /// This is a fixed-length horizontal stick with a zero-length vertical after it. /// It starts nearly all the wires let rightNub = [ @@ -213,7 +221,7 @@ let makeInitialWireVerticesList (wireStartPos : XYPos) (wireEndPos : XYPos) (por {X = xStart+nubLength; Y = yStart}; //Stick horizontal {X = xStart+nubLength; Y = yStart}; //Length 0 vertical ] - let rightwards = xStart - xEnd + 20. < 0 + let rightwards = xStart - xEnd < 0 let downwards = yStart - yEnd < 0 match rightwards, downwards with //add 20 to prevent issues in the case that the ports are directly on in line with one another | true, true -> @@ -346,7 +354,8 @@ let xyVerticesToSegments connId (xyVerticesList: XYPos list) = /// Given the coordinates of two port locations that correspond /// to the endpoints of a wire, as well as the orientation of the final port -/// this function returns a list of Segment(s). +/// this function returns a list of Segment(s). +/// The starting segment will always be from a Right Edge (and so in increasing X direction) let makeInitialSegmentsList (hostId : ConnectionId) (startPos : XYPos) diff --git a/src/Renderer/DrawBlock/BusWireRoute.fs b/src/Renderer/DrawBlock/BusWireRoute.fs index 3c4d45c30..1c7886c9a 100644 --- a/src/Renderer/DrawBlock/BusWireRoute.fs +++ b/src/Renderer/DrawBlock/BusWireRoute.fs @@ -516,7 +516,7 @@ let snapToNet (model: Model) (wireToRoute: Wire) : Wire = let smartAutoroute (model: Model) (wire: Wire) : Wire = let initialWire = (autoroute model wire) - + // Snapping to Net only if model.SnapToNet toggled to be true let snappedToNetWire = match model.SnapToNet with @@ -533,6 +533,7 @@ let smartAutoroute (model: Model) (wire: Wire) : Wire = tryShiftHorizontalSeg maxCallsToShiftHorizontalSeg model intersectedBoxes snappedToNetWire ) |> Option.defaultValue snappedToNetWire + //-----------------------------------------------------------------------------------------------------------// diff --git a/src/Renderer/DrawBlock/BusWireRoutingHelpers.fs b/src/Renderer/DrawBlock/BusWireRoutingHelpers.fs index 37fa05fe8..96cf71c76 100644 --- a/src/Renderer/DrawBlock/BusWireRoutingHelpers.fs +++ b/src/Renderer/DrawBlock/BusWireRoutingHelpers.fs @@ -117,6 +117,7 @@ module Constants = let overlapTolerance = 2. /// corners with max length edge larger than this are not removed let separateCaptureOverlap = 6. // Larger than as overlapTolerance, smaller than minSegmentSeparation + let minWireLengthToSeparate = 10. // prevents short wires being squiggly let maxCornerSize = 100. /// How close are segment extensions caused by corner removal allowed to /// get to other elements? Maybe needs to be smaller than some otehr things for diff --git a/src/Renderer/DrawBlock/BusWireSeparate.fs b/src/Renderer/DrawBlock/BusWireSeparate.fs index 7b1bf5019..8dc98c2b4 100644 --- a/src/Renderer/DrawBlock/BusWireSeparate.fs +++ b/src/Renderer/DrawBlock/BusWireSeparate.fs @@ -150,7 +150,8 @@ let makeLines (wiresToRoute: ConnectionId list) (ori: Orientation) (model: Model /// Which segments in wires are included as Lines? let selectSegments (wire: Wire) (orient: Orientation) (seg: Segment) = let numSegs = wire.Segments.Length - ori = orient && seg.Index <> 0 && seg.Index <> numSegs - 1 && not (seg.IsZero()) //|| (segN -1).IsZero() || (segN 1).IsZero()) + let wireLength = euclideanDistance wire.StartPos wire.EndPos + ori = orient && seg.Index <> 0 && seg.Index <> numSegs - 1 && not (seg.IsZero()) && wireLength > minWireLengthToSeparate /// Lines coming from wire segments /// Manually routed segments are considered fixed @@ -169,7 +170,6 @@ let makeLines (wiresToRoute: ConnectionId list) (ori: Orientation) (model: Model match wireIsRoutable, seg.Mode, seg.Index=2, seg.Index=segs.Length-3 with | _, Manual , _ , _ | false, _, _, _ -> - //printf $"\n**Wire {pWire wire} is manual**\n" FIXEDMANUALSEG | _, _ , true , _ when segs[ 1 ].IsZero() -> FIXEDSEG @@ -881,7 +881,6 @@ let separateModelSegmentsOneOrientation (wires: ConnectionId list) (ori: Orienta /// Perform complete wire segment separation and ordering for all orientations. /// wiresToRoute: set of wires to have segments separated and ordered let separateAndOrderModelSegments (wiresToRoute: ConnectionId list) (model: Model) : Model = - // Currently: separate all wires - not just those (in wiresToRoute) that // have changed. This prevents unrouted segments from pinning new segments. // TODO: see whetehr something better can be worked out,a nd whetehr routing segments