private void SiliconCellCorner(ILayerCell cell, Corner corner, Rectangle cellBounds, bool isVertCornerDetached, bool isHorzCornerDetached) { var(pen, _, _) = SelectSiliconBrush(cell); var(nearToCenter, nearToBounds, nearHorzLink, nearVertLink) = GetCellCornerBounds(cellBounds.X, cellBounds.Y, corner); var horzNeigh = cell.Links[corner.HasFlag(Corner.FarX) ? 2 : 0]; var vertNeigh = cell.Links[corner.HasFlag(Corner.FarY) ? 3 : 1]; var hasHorzLink = !isHorzCornerDetached && (horzNeigh?.SiliconLink ?? SiliconLink.None) != SiliconLink.None; var hasVertLink = !isVertCornerDetached && (vertNeigh?.SiliconLink ?? SiliconLink.None) != SiliconLink.None; GenericCellCorner(hasHorzLink, hasVertLink, pen, nearToCenter, nearToBounds, nearHorzLink, nearVertLink); if (!cell.HasGate()) { return; } var oppositeVertNeigh = cell.Links[corner.HasFlag(Corner.FarY) ? 1 : 3]; var isVerticalGate = (vertNeigh?.SiliconLink ?? SiliconLink.None) == SiliconLink.Slave || (oppositeVertNeigh?.SiliconLink ?? SiliconLink.None) == SiliconLink.Slave; var srcPoint = isVerticalGate ? nearVertLink : nearHorzLink; _graphics.DrawLine(BorderPen, srcPoint, nearToCenter); }
private (bool, SiliconLink, SiliconLayerContent) CheckSiliconLink(ILayerCell fromCell, ILayerCell toCell, Side side) { var fromBase = fromCell.IsBaseN() ? SiliconType.NType : SiliconType.PType; var toBase = toCell.IsBaseN() ? SiliconType.NType : SiliconType.PType; if (fromBase != toBase) { var(p1, p2) = side.GetPerpendicularSides(); return(toCell.Links[p1].SiliconLink == SiliconLink.BiDirectional && toCell.Links[p2].SiliconLink == SiliconLink.BiDirectional && toCell.Links[side].SiliconLink != SiliconLink.BiDirectional && !toCell.HasVia() ? (true, SiliconLink.Master, toCell.HasGate() ? toCell.Silicon : toBase.ConvertToGate(!side.IsVertical())) : (false, SiliconLink.None, SiliconLayerContent.None)); } else { return(fromCell.HasGate() || toCell.HasGate() ? (false, SiliconLink.None, SiliconLayerContent.None) : (true, SiliconLink.BiDirectional, toCell.Silicon)); } }
private void SiliconCellSide(ILayerCell cell, Side side, Rectangle cellBounds, bool isSideDetached) { var(_, brush, gateBrush) = SelectSiliconBrush(cell); var link = cell.Links[side]?.SiliconLink ?? SiliconLink.None; var oppositeLink = cell.Links[GetOppositeSide(side)]?.SiliconLink ?? SiliconLink.None; var hasSlaveLinkInDimension = link == SiliconLink.Slave || oppositeLink == SiliconLink.Slave; var actualBrush = hasSlaveLinkInDimension ? gateBrush : brush; var(rect, nearToBounds, nearToCenter) = GetCellSideBounds(cellBounds.X, cellBounds.Y, side); _graphics.FillRectangle(actualBrush, rect); if (isSideDetached || link == SiliconLink.None || hasSlaveLinkInDimension) { _graphics.FillRectangle(BorderBrush, nearToBounds); } if (!isSideDetached && cell.HasGate() && !hasSlaveLinkInDimension) { _graphics.FillRectangle(BorderBrush, nearToCenter); } }