modedit: Mirror custom pads

Fixes mirror command to correctly handle custom pads.

Fixes: lp:1808135
* https://bugs.launchpad.net/kicad/+bug/1808135
This commit is contained in:
Seth Hillbrand 2019-01-16 20:55:40 -08:00
parent 6bea0951a3
commit e270b5d266
3 changed files with 44 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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 );