From d2d7e630bd02b2767a305d412a3b62053d0a5bd3 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 28 Aug 2023 18:05:58 +0100 Subject: [PATCH] Allow for offset custom-shaped pads with no holes. (cherry picked from commit 0d39cd5e6350098609e9c9a96f26768cfac4835e) --- pcbnew/tools/pad_tool.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/pcbnew/tools/pad_tool.cpp b/pcbnew/tools/pad_tool.cpp index 8f2263860e..59148d69e1 100644 --- a/pcbnew/tools/pad_tool.cpp +++ b/pcbnew/tools/pad_tool.cpp @@ -829,9 +829,24 @@ std::vector PAD_TOOL::RecombinePad( PAD* aPad, bool aIsDryRun, BOARD_ aPad->TransformShapeToPolygon( existingOutline, layer, 0, maxError, ERROR_INSIDE ); aPad->SetAnchorPadShape( PAD_SHAPE::CIRCLE ); - // We're going to remove the offset, so shrink the anchor pad so that it's - // entirely inside the hole (since it won't be offset anymore) - aPad->SetSize( aPad->GetDrillSize() ); + // The actual pad shape may be offset from the pad anchor, so we don't want the anchor + // shape to be overly large (and stick out from under the actual pad shape). Normally + // this means we want the anchor pad to be entirely inside the hole, but offsets are + // also used with SMD pads to control the anchor point for track routing. + if( aPad->GetDrillSizeX() > 0 ) + { + // For a pad with a hole, just make sure the anchor shape is entirely inside the + // hole. + aPad->SetSize( aPad->GetDrillSize() / 2 ); + } + else + { + // For a SMD pad, an offset is usually used to control the anchor point for routing. + // In this case it will usually be at least 1/2 the minimum track width inside the + // pad. We halve that value again just to be safe. + aPad->SetSize( VECTOR2I( board()->GetDesignSettings().m_TrackMinWidth / 2, + board()->GetDesignSettings().m_TrackMinWidth / 2 ) ); + } PCB_SHAPE* shape = new PCB_SHAPE( nullptr, SHAPE_T::POLY ); shape->SetFilled( true );