From a6a4973324c6abefc0134d841b916a49cb2488e6 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 31 Oct 2019 19:36:54 +0000 Subject: [PATCH] Handle rotation for N/S/E/W pad cardinal points. Fixes: lp:1844727 * https://bugs.launchpad.net/kicad/+bug/1844727 --- pcbnew/connectivity/connectivity_items.cpp | 39 +++++++++++++++------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/pcbnew/connectivity/connectivity_items.cpp b/pcbnew/connectivity/connectivity_items.cpp index 0f4e5e90a3..ccea48e34e 100644 --- a/pcbnew/connectivity/connectivity_items.cpp +++ b/pcbnew/connectivity/connectivity_items.cpp @@ -63,31 +63,46 @@ const VECTOR2I CN_ITEM::GetAnchor( int n ) const pt0 = pad->ShapePos(); VECTOR2I pt1 = pt0; - switch( n ) - { - case 1: pt1.y = m_bbox.GetTop(); break; // North - case 2: pt1.y = m_bbox.GetBottom(); break; // South - case 3: pt1.x = m_bbox.GetLeft(); break; // East - case 4: pt1.x = m_bbox.GetRight(); break; // West - default: break; // Wicked witch - } - switch( pad->GetShape() ) { case PAD_SHAPE_RECT: + case PAD_SHAPE_CIRCLE: case PAD_SHAPE_OVAL: case PAD_SHAPE_ROUNDRECT: case PAD_SHAPE_CHAMFERED_RECT: - return pt1; + switch( n ) + { + case 1: pt1.y -= pad->GetSize().y / 2; break; // North + case 2: pt1.y += pad->GetSize().y / 2; break; // South + case 3: pt1.x -= pad->GetSize().x / 2; break; // East + case 4: pt1.x += pad->GetSize().x / 2; break; // West + default: break; // Wicked witch + } + + if( pad->GetOrientation() ) + RotatePoint( pt1, pad->ShapePos(), pad->GetOrientation() ); - case PAD_SHAPE_CIRCLE: // Thermal spokes on circular pads form an 'X' instead of a '+' - RotatePoint( pt1, pad->ShapePos(), 450 ); + if( pad->GetShape() == PAD_SHAPE_CIRCLE ) + RotatePoint( pt1, pad->ShapePos(), 450 ); + return pt1; case PAD_SHAPE_TRAPEZOID: case PAD_SHAPE_CUSTOM: { + switch( n ) + { + case 1: pt1.y = m_bbox.GetTop(); break; // North + case 2: pt1.y = m_bbox.GetBottom(); break; // South + case 3: pt1.x = m_bbox.GetLeft(); break; // East + case 4: pt1.x = m_bbox.GetRight(); break; // West + default: break; // Wicked witch + } + + if( pad->GetOrientation() ) + RotatePoint( pt1, pad->ShapePos(), pad->GetOrientation() ); + SHAPE_POLY_SET padPolySet; pad->BuildPadShapePolygon( padPolySet, wxSize( 0, 0 ), ARC_LOW_DEF ); const SHAPE_LINE_CHAIN& padOutline = padPolySet.COutline( 0 );