diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 08fd95d45c..2f52a74332 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -50,6 +50,7 @@ class LINE_READER; class EDA_3D_CANVAS; class EDA_DRAW_PANEL; class MODULE; +class EDGE_MODULE; class TRACK; class MSG_PANEL_INFO; @@ -114,6 +115,13 @@ public: * @param aTarget is the DRAWSEGMENT to initialize */ void ExportTo( DRAWSEGMENT* aTarget ); + + /** Export the PAD_CS_PRIMITIVE parameters to a EDGE_MODULE + * useful to convert a primitive shape to a EDGE_MODULE shape for edition + * in footprint editor + * @param aTarget is the EDGE_MODULE to initialize + */ + void ExportTo( EDGE_MODULE* aTarget ); }; diff --git a/pcbnew/class_pad_custom_shape_functions.cpp b/pcbnew/class_pad_custom_shape_functions.cpp index 779538e38d..3e0c84d264 100644 --- a/pcbnew/class_pad_custom_shape_functions.cpp +++ b/pcbnew/class_pad_custom_shape_functions.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -61,6 +62,15 @@ void PAD_CS_PRIMITIVE::ExportTo( DRAWSEGMENT* aTarget ) aTarget->SetPolyPoints( m_Poly ); } + +void PAD_CS_PRIMITIVE::ExportTo( EDGE_MODULE* aTarget ) +{ + ExportTo( static_cast( aTarget ) ); + // Initialize coordinates specific to the EDGE_MODULE (m_Start0 and m_End0) + aTarget->SetLocalCoord(); +} + + /* * Has meaning only for free shape pads. * add a free shape to the shape list. diff --git a/pcbnew/tools/module_editor_tools.cpp b/pcbnew/tools/module_editor_tools.cpp index d992234ca9..57878da50a 100644 --- a/pcbnew/tools/module_editor_tools.cpp +++ b/pcbnew/tools/module_editor_tools.cpp @@ -357,17 +357,10 @@ int MODULE_EDITOR_TOOLS::ExplodePadToShapes( const TOOL_EVENT& aEvent ) { auto ds = new EDGE_MODULE( board()->m_Modules ); - ds->SetLayer( pad->GetLayer() ); - ds->SetShape( prim.m_Shape ); - ds->SetStart( prim.m_Start + anchor ); - ds->SetEnd( prim.m_End + anchor ); - ds->SetWidth( prim.m_Thickness ); - - for( auto&p : prim.m_Poly ) - p += anchor; - - ds->SetPolyPoints( prim.m_Poly ); - ds->SetAngle( prim.m_ArcAngle ); + prim.ExportTo( ds ); // ExportTo exports to a DRAWSEGMENT + // Fix an arbitray draw layer for this EDGE_MODULE + ds->SetLayer( Dwgs_User ); //pad->GetLayer() ); + ds->Move( anchor ); commit.Add( ds ); } @@ -442,13 +435,18 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent ) if( multipleRefPadsFound ) { - DisplayErrorMessage( frame(), _("Cannot convert items to a custom-shaped pad: selection contains more than one reference pad. ") ); + DisplayErrorMessage( frame(), + _( "Cannot convert items to a custom-shaped pad:\n" + "selection contains more than one reference pad." ) ); return 0; } if( illegalItemsFound ) { - DisplayErrorMessage( frame(), _("Cannot convert items to a custom-shaped pad: selection contains unsupported items. Only graphical lines, circles, arcs and polygons are allowed.") ); + DisplayErrorMessage( frame(), + _( "Cannot convert items to a custom-shaped pad:\n" + "selection contains unsupported items.\n" + "Only graphical lines, circles, arcs and polygons are allowed." ) ); return 0; } @@ -458,10 +456,12 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent ) } else { + // Create a default pad anchor: pad->SetAnchorPadShape( PAD_SHAPE_CIRCLE ); pad->SetAttribute( PAD_ATTRIB_SMD ); pad->SetLayerSet( D_PAD::SMDMask() ); - pad->SetSize ( wxSize( 10000, 10000 ) ); + int radius = Millimeter2iu( 0.2 ); + pad->SetSize ( wxSize( radius, radius ) ); pad->IncrementPadName( true, true ); } @@ -483,7 +483,10 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent ) if( !anchor ) { - DisplayErrorMessage( frame(), _("Cannot convert items to a custom-shaped pad: unable to determine the anchor point position. Consider adding a small anchor pad to the selection and try again.") ); + DisplayErrorMessage( frame(), + _( "Cannot convert items to a custom-shaped pad:\n" + "unable to determine the anchor point position.\n" + "Consider adding a small anchor pad to the selection and try again.") ); return 0; }