diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 2f52a74332..ed0ffee6a5 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -110,6 +110,12 @@ public: wxPoint GetCenter() { return m_Start; } /// returns the center of a circle or arc wxPoint GetArcStart() { return m_End; } /// returns the start point of an arc + // Geometric transform + /** Move the primitive + * @param aMoveVector is the deplacement vector + */ + void Move( wxPoint aMoveVector ); + /** Export the PAD_CS_PRIMITIVE parameters to a DRAWSEGMENT * useful to draw a primitive shape * @param aTarget is the DRAWSEGMENT to initialize diff --git a/pcbnew/class_pad_custom_shape_functions.cpp b/pcbnew/class_pad_custom_shape_functions.cpp index 6de30f9d42..83fe7689b4 100644 --- a/pcbnew/class_pad_custom_shape_functions.cpp +++ b/pcbnew/class_pad_custom_shape_functions.cpp @@ -71,6 +71,18 @@ void PAD_CS_PRIMITIVE::ExportTo( EDGE_MODULE* aTarget ) } +void PAD_CS_PRIMITIVE::Move( wxPoint aMoveVector ) +{ + m_Start += aMoveVector; + m_End += aMoveVector; + + for( auto& corner : m_Poly ) + { + corner += aMoveVector; + } +} + + /* * Has meaning only for free shape pads. * add a free shape to the shape list. @@ -369,7 +381,8 @@ bool D_PAD::GetBestAnchorPosition( VECTOR2I& aPos ) minDistEdge = std::max( GetSize().x, GetSize().y ); } - auto bestAnchor( []()->boost::optional{ return boost::none; }() ); + boost::optional bestAnchor( []()-> + boost::optional{ return boost::none; }() ); for ( int y = 0; y < stepsY ; y++ ) { diff --git a/pcbnew/tools/module_editor_tools.cpp b/pcbnew/tools/module_editor_tools.cpp index 57878da50a..d6afbde0c4 100644 --- a/pcbnew/tools/module_editor_tools.cpp +++ b/pcbnew/tools/module_editor_tools.cpp @@ -494,16 +494,7 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent ) // relocate the shapes, they are relative to the anchor pad position for( auto& shape : shapes ) { - shape.m_Start.x -= anchor->x; - shape.m_Start.y -= anchor->y; - shape.m_End.x -= anchor->x; - shape.m_End.y -= anchor->y; - - for( auto&p : shape.m_Poly ) - { - p.x -= anchor->x; - p.y -= anchor->y; - } + shape.Move( wxPoint( -anchor->x, -anchor->y ) ); } @@ -514,7 +505,9 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent ) if( !result ) { - DisplayErrorMessage( frame(), _("Cannot convert items to a custom-shaped pad: selected items do not form a single solid shape.") ); + DisplayErrorMessage( frame(), + _( "Cannot convert items to a custom-shaped pad:\n" + "selected items do not form a single solid shape.") ); return 0; } @@ -529,7 +522,7 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, padPtr ); - commit.Push(_("Create Pad From Selected Shapes") ); + commit.Push(_("Create Pad from Selected Shapes") ); return 0; }