From 6f7d5f5e2bb2ed0ec3dc947c1d5ee437f321d9b7 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 25 Jul 2020 17:41:36 +0200 Subject: [PATCH] Footprint editor: fix some issues in flip and mirror commands. more about fixes #4958 https://gitlab.com/kicad/code/kicad/issues/4958 --- pcbnew/class_pad.cpp | 17 ++++------------- pcbnew/class_pad.h | 10 +++------- pcbnew/dialogs/dialog_pad_properties.cpp | 7 ++++--- pcbnew/tools/edit_tool.cpp | 7 +++---- 4 files changed, 14 insertions(+), 27 deletions(-) diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index ab584eaad2..63b398ae43 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -497,26 +497,17 @@ void D_PAD::Flip( const wxPoint& aCentre, bool aFlipLeftRight ) SetLayerSet( FlipLayerMask( m_layerMask ) ); // Flip the basic shapes, in custom pads - FlipPrimitives(); + FlipPrimitives( aFlipLeftRight ); m_shapesDirty = true; } -// Flip the basic shapes, in custom pads -void D_PAD::FlipPrimitives() +// Flip (mirror) the basic shapes (primitives), in custom pads +void D_PAD::FlipPrimitives( bool aFlipLeftRight ) { for( std::shared_ptr& primitive : m_editPrimitives ) - primitive->Flip( wxPoint( 0, 0 ), false ); - - m_shapesDirty = true; -} - - -void D_PAD::MirrorXPrimitives( int aX ) -{ - for( std::shared_ptr& primitive : m_editPrimitives ) - primitive->Flip( wxPoint( aX, 0 ), true ); + primitive->Flip( wxPoint( 0, 0 ), aFlipLeftRight ); m_shapesDirty = true; } diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index f7a3f21c6a..8bbc43450c 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -277,14 +277,10 @@ public: void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override; /** - * Flip the basic shapes, in custom pads + * Flip (mirror) the primitives left to right or top to bottom, around the anchor position + * in custom pads */ - void FlipPrimitives(); - - /** - * Mirror the primitives about a coordinate - */ - void MirrorXPrimitives( int aX ); + void FlipPrimitives( bool aFlipLeftRight ); /** * Clear the current primitive list and import a basic shape (primitive) list. diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index db9a231dbd..3d7f8f88b7 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -487,8 +487,8 @@ void DIALOG_PAD_PROPERTIES::initValues() // flip pad's layers m_dummyPad->SetLayerSet( FlipLayerMask( m_dummyPad->GetLayerSet() ) ); - // flip custom pad shapes - m_dummyPad->FlipPrimitives(); + // flip custom pad shapes (up/down) + m_dummyPad->FlipPrimitives( false ); } m_primitives = m_dummyPad->GetPrimitives(); @@ -1376,7 +1376,8 @@ bool DIALOG_PAD_PROPERTIES::TransferDataFromWindow() if( m_isFlipped ) { m_currentPad->SetLayerSet( FlipLayerMask( m_currentPad->GetLayerSet() ) ); - m_currentPad->FlipPrimitives(); + // flip custom pad shapes (up/down) + m_dummyPad->FlipPrimitives( false ); } m_currentPad->SetLayerSet( m_padMaster->GetLayerSet() ); diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 83f1f2a176..68e359e338 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -753,15 +753,14 @@ static wxPoint mirrorPointX( const wxPoint& aPoint, const wxPoint& aMirrorPoint /** - * Mirror a pad in the vertical axis passing through a point + * Mirror a pad in the vertical axis passing through a point (mirror left to right) */ 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.FlipPrimitives( true ); // mirror primitives left to right + wxPoint tmpPt = mirrorPointX( aPad.GetPosition(), aMirrorPoint ); aPad.SetPosition( tmpPt ); aPad.SetX0( aPad.GetPosition().x );