internal CoordRect CalculatePartRect(PcbPadPart part, bool useAbsolutePosition) { Coord width, height; var offset = OffsetFromHoleCenter; switch (part) { case PcbPadPart.TopLayer: width = SizeTop.X; height = SizeTop.Y; break; case PcbPadPart.BottomLayer: width = SizeBottom.X; height = SizeBottom.Y; break; case PcbPadPart.TopSolder: width = SizeTop.X + Utils.MilsToCoord(5); // TODO: get padding size height = SizeTop.Y + Utils.MilsToCoord(5); break; case PcbPadPart.BottomSolder: width = SizeBottom.X + Utils.MilsToCoord(5); height = SizeBottom.Y + Utils.MilsToCoord(5); break; case PcbPadPart.Hole: width = PcbPadHoleShape.Slot == HoleShape ? HoleSlotLength : HoleSize; height = HoleSize; offset = CoordPoint.Zero; break; default: return(CoordRect.Empty); } Coord x = offset.X - width / 2; Coord y = offset.Y - height / 2; if (useAbsolutePosition) { x += Location.X; y += Location.Y; } return(new CoordRect(x, y, width, height)); }
private void DrawPad(Graphics g, PcbPad pad, PcbPadPart padPart) { PcbPadShape shape; int cornerRadiusPercent; Color color; // setup parameters according to the current padPart switch (padPart) { case PcbPadPart.TopLayer: shape = pad.ShapeTop; cornerRadiusPercent = pad.CornerRadiusTop; color = LayerMetadata.GetColor(pad.Layer); break; case PcbPadPart.BottomLayer: shape = pad.ShapeBottom; cornerRadiusPercent = pad.CornerRadiusBot; color = LayerMetadata.GetColor(pad.Layer); break; case PcbPadPart.TopSolder: shape = pad.ShapeTop; cornerRadiusPercent = pad.CornerRadiusTop; color = LayerMetadata.GetColor("TopSolder"); break; case PcbPadPart.BottomSolder: shape = pad.ShapeBottom; cornerRadiusPercent = pad.CornerRadiusBot; color = LayerMetadata.GetColor("BottomSolder"); break; default: return; } var rect = ScaleRect(pad.CalculatePartRect(padPart, false)); using (var brush = new SolidBrush(color)) { switch (shape) { case PcbPadShape.Round: DrawingUtils.FillRoundedRect(g, brush, rect, 100); break; case PcbPadShape.Rectangular: DrawingUtils.FillRectangle(g, brush, rect); break; case PcbPadShape.Octogonal: DrawingUtils.FillOctagon(g, brush, rect); break; case PcbPadShape.RoundedRectangle: cornerRadiusPercent = cornerRadiusPercent > 0 ? cornerRadiusPercent : 100; DrawingUtils.FillRoundedRect(g, brush, rect, cornerRadiusPercent); break; default: return; } } }
internal CoordRect CalculatePartBounds(PcbPadPart part) => CoordRect.FromRotatedRect(CalculatePartRect(part, true), Location, Rotation + (part == PcbPadPart.Hole ? HoleRotation : 0));