diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index e9015b6d8d..55b5ee7ccd 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -481,6 +481,40 @@ void D_PAD::FlipPrimitives() } +void D_PAD::MirrorXPrimitives( int aX ) +{ + // Mirror custom shapes + for( unsigned ii = 0; ii < m_basicShapes.size(); ++ii ) + { + PAD_CS_PRIMITIVE& primitive = m_basicShapes[ii]; + + MIRROR( primitive.m_Start.x, aX ); + MIRROR( primitive.m_End.x, aX ); + primitive.m_ArcAngle = -primitive.m_ArcAngle; + + switch( primitive.m_Shape ) + { + case S_POLYGON: // polygon + for( unsigned jj = 0; jj < primitive.m_Poly.size(); jj++ ) + MIRROR( primitive.m_Poly[jj].x, aX ); + break; + + default: + break; + } + } + + // Mirror the local coordinates in merged Polygon + for( int cnt = 0; cnt < m_customShapeAsPolygon.OutlineCount(); ++cnt ) + { + SHAPE_LINE_CHAIN& poly = m_customShapeAsPolygon.Outline( cnt ); + + for( int ii = 0; ii < poly.PointCount(); ++ii ) + MIRROR( poly.Point( ii ).x, aX ); + } +} + + void D_PAD::AppendConfigs( PARAM_CFG_ARRAY* aResult ) { // Parameters stored in config are only significant parameters diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 0f536716a2..1f5f5cae63 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -347,6 +347,13 @@ public: */ void FlipPrimitives(); + /** + * Mirror the primitives about a coordinate + * + * @param aX the x coordinate about which to mirror + */ + void MirrorXPrimitives( int aX ); + /** * Import to the basic shape list * @return true if OK, false if issues diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 1a3b0c4b46..44d3b18a4b 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -731,6 +731,9 @@ static void mirrorPadX( D_PAD& aPad, const wxPoint& aMirrorPoint ) { wxPoint tmpPt = mirrorPointX( aPad.GetPosition(), aMirrorPoint ); + if( aPad.GetShape() == PAD_SHAPE_CUSTOM ) + aPad.MirrorXPrimitives( tmpPt.x ); + aPad.SetPosition( tmpPt ); aPad.SetX0( aPad.GetPosition().x );