From 103dde67f6c6f98dadf166d41677cb71dfc50651 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 26 Feb 2021 11:29:25 -0800 Subject: [PATCH] FABMASTER: Handle rotated/flipped custom pads The rotate mirror actions need to line up with the expectation. FABMASTER keeps elements board-referenced while KiCad has some elements referenced to the board and some referenced to the footprint --- pcbnew/plugins/fabmaster/import_fabmaster.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pcbnew/plugins/fabmaster/import_fabmaster.cpp b/pcbnew/plugins/fabmaster/import_fabmaster.cpp index 18d40cf8fb..f92e91ed86 100644 --- a/pcbnew/plugins/fabmaster/import_fabmaster.cpp +++ b/pcbnew/plugins/fabmaster/import_fabmaster.cpp @@ -2200,12 +2200,28 @@ bool FABMASTER::loadFootprints( BOARD* aBoard ) poly_outline.Move( -newpad->GetPosition() ); if( src->mirror ) + { + poly_outline.Mirror( false, true, VECTOR2I( 0, ( pin->pin_y - src->y ) ) ); poly_outline.Rotate( ( -src->rotate + pin->rotation ) * M_PI / 180.0 ); + } else + { poly_outline.Rotate( ( src->rotate - pin->rotation ) * M_PI / 180.0 ); + } newpad->AddPrimitivePoly( poly_outline, 0, true ); } + + SHAPE_POLY_SET mergedPolygon; + newpad->MergePrimitivesAsPolygon( &mergedPolygon, UNDEFINED_LAYER ); + + if( mergedPolygon.OutlineCount() > 1 ) + { + wxLogError( wxString::Format( + _( "Invalid custom pad named '%s'. Replacing with circular pad." ), + custom_name.c_str() ) ); + newpad->SetShape( PAD_SHAPE_CIRCLE ); + } } else {