From d9b0577dddd2ecaff03305bd9f7cd7e7c8b26223 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 3 Apr 2023 14:06:35 +0100 Subject: [PATCH] Fix pad flipping. --- pcbnew/dialogs/dialog_pad_properties.cpp | 27 ++++++++++++------------ pcbnew/dialogs/dialog_pad_properties.h | 2 -- pcbnew/pad.cpp | 2 +- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index 278b78a7bf..208e5cec1c 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -184,6 +184,8 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, PAD* aPad m_padNetSelector->Show( false ); } + m_FlippedWarningSizer->Show( false ); + // Pad needs to have a parent for painting; use the parent board for its design settings if( !m_dummyPad->GetParent() ) m_dummyPad->SetParent( m_board ); @@ -479,39 +481,36 @@ void DIALOG_PAD_PROPERTIES::initValues() m_PadLayerECO2->SetLabel( m_board->GetLayerName( Eco2_User ) ); m_PadLayerDraft->SetLabel( m_board->GetLayerName( Dwgs_User ) ); - m_isFlipped = false; - if( m_currentPad ) { - m_dummyPad->SetOrientation( m_currentPad->GetFPRelativeOrientation() ); - m_dummyPad->SetPosition( m_currentPad->GetFPRelativePosition() ); - if( FOOTPRINT* footprint = m_currentPad->GetParent() ) { - m_isFlipped = footprint->IsFlipped(); + VECTOR2I relPos = m_currentPad->GetFPRelativePosition(); - if( m_isFlipped ) + if( footprint->IsFlipped() ) { // flip pad (up/down) around its position m_dummyPad->Flip( m_dummyPad->GetPosition(), false ); - m_dummyPad->SetY( -m_dummyPad->GetY() ); + relPos.y = - relPos.y; } + m_dummyPad->SetPosition( relPos ); + m_dummyPad->SetOrientation( m_currentPad->GetFPRelativeOrientation() ); + // Display parent footprint info msg.Printf( _("Footprint %s (%s), %s, rotated %g deg"), footprint->Reference().GetShownText(), footprint->Value().GetShownText(), footprint->IsFlipped() ? _( "back side (mirrored)" ) : _( "front side" ), footprint->GetOrientation().AsDegrees() ); - } - m_parentInfo->SetLabel( msg ); + m_FlippedWarningSizer->Show( footprint->IsFlipped() ); + m_parentInfo->SetLabel( msg ); + } } m_primitives = m_dummyPad->GetPrimitives(); - m_FlippedWarningSizer->Show( m_isFlipped ); - if( m_currentPad ) { m_padNumCtrl->SetValue( m_dummyPad->GetNumber() ); @@ -1578,6 +1577,7 @@ bool DIALOG_PAD_PROPERTIES::TransferDataFromWindow() // Update values m_currentPad->SetShape( m_padMaster->GetShape() ); m_currentPad->SetAttribute( m_padMaster->GetAttribute() ); + m_currentPad->SetFPRelativeOrientation( m_padMaster->GetOrientation() ); m_currentPad->SetSize( m_padMaster->GetSize() ); @@ -1639,7 +1639,7 @@ bool DIALOG_PAD_PROPERTIES::TransferDataFromWindow() VECTOR2I relPos = m_padMaster->GetPosition(); - if( m_isFlipped ) + if( m_currentPad->GetParentFootprint() && m_currentPad->GetParentFootprint()->IsFlipped() ) { // flip pad (up/down) around its position m_currentPad->Flip( m_currentPad->GetPosition(), false ); @@ -1647,7 +1647,6 @@ bool DIALOG_PAD_PROPERTIES::TransferDataFromWindow() } // Must be done after flipping - m_currentPad->SetFPRelativeOrientation( m_padMaster->GetOrientation() ); m_currentPad->SetFPRelativePosition( relPos ); m_parent->SetMsgPanel( m_currentPad ); diff --git a/pcbnew/dialogs/dialog_pad_properties.h b/pcbnew/dialogs/dialog_pad_properties.h index def4a4a688..b27737f6c9 100644 --- a/pcbnew/dialogs/dialog_pad_properties.h +++ b/pcbnew/dialogs/dialog_pad_properties.h @@ -130,8 +130,6 @@ private: PAD* m_padMaster; // pad used to create new pads in board or footprint editor BOARD* m_board; // the main board: this is the board handled by the PCB // editor or the dummy board used by the footprint editor - bool m_isFlipped; // indicates the parent footprint is flipped (mirrored) in - // which case some Y coordinates values must be negated bool m_canUpdate; bool m_canEditNetName; // true only if the caller is the board editor bool m_isFpEditor; // true if the caller is the footprint editor diff --git a/pcbnew/pad.cpp b/pcbnew/pad.cpp index c5d16a1867..907cee5cf0 100644 --- a/pcbnew/pad.cpp +++ b/pcbnew/pad.cpp @@ -701,7 +701,7 @@ void PAD::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) MIRROR( m_deltaSize.y, 0 ); } - SetOrientation( -GetOrientation() ); + SetFPRelativeOrientation( -GetFPRelativeOrientation() ); auto mirrorBitFlags = []( int& aBitfield, int a, int b ) {