Fix pad flipping.

This commit is contained in:
Jeff Young 2023-04-03 14:06:35 +01:00
parent b7b7dc6558
commit d9b0577ddd
3 changed files with 14 additions and 17 deletions

View File

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

View File

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

View File

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