diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index fed42abbfc..58938fbe7d 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -2229,12 +2229,12 @@ void FOOTPRINT::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) SetOrientation( newOrientation ); for( PCB_FIELD* field : m_fields ) - field->KeepUpright( newOrientation ); + field->KeepUpright(); for( BOARD_ITEM* item : m_drawings ) { if( item->Type() == PCB_TEXT_T ) - static_cast( item )->KeepUpright( newOrientation ); + static_cast( item )->KeepUpright(); } m_boundingBoxCacheTimeStamp = 0; diff --git a/pcbnew/pcb_text.cpp b/pcbnew/pcb_text.cpp index 82cb0df92f..b517abca2a 100644 --- a/pcbnew/pcb_text.cpp +++ b/pcbnew/pcb_text.cpp @@ -371,12 +371,12 @@ void PCB_TEXT::StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings ) } -void PCB_TEXT::KeepUpright( const EDA_ANGLE& aNewOrientation ) +void PCB_TEXT::KeepUpright() { if( !IsKeepUpright() ) return; - EDA_ANGLE newAngle = GetTextAngle() + aNewOrientation; + EDA_ANGLE newAngle = GetTextAngle(); newAngle.Normalize(); bool needsFlipped = newAngle >= ANGLE_180; @@ -384,6 +384,7 @@ void PCB_TEXT::KeepUpright( const EDA_ANGLE& aNewOrientation ) if( needsFlipped ) { SetHorizJustify( static_cast( -GetHorizJustify() ) ); + SetVertJustify( static_cast( -GetVertJustify() ) ); SetTextAngle( GetTextAngle() + ANGLE_180 ); } } diff --git a/pcbnew/pcb_text.h b/pcbnew/pcb_text.h index cdd4a80add..d7df044e89 100644 --- a/pcbnew/pcb_text.h +++ b/pcbnew/pcb_text.h @@ -73,7 +73,7 @@ public: /** * Called when rotating the parent footprint. */ - void KeepUpright( const EDA_ANGLE& aNewOrientation ); + void KeepUpright(); wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override; diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 7335638884..ad5ac3e685 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -2956,7 +2956,24 @@ bool EDIT_TOOL::updateModificationPoint( PCB_SELECTION& aSelection ) else { PCB_GRID_HELPER grid( m_toolMgr, frame()->GetMagneticItemsSettings() ); - aSelection.SetReferencePoint( grid.BestSnapAnchor( aSelection.GetCenter(), nullptr ) ); + VECTOR2I refPt = aSelection.GetCenter(); + + // Exclude text in the footprint editor if there's anything else selected + if( m_isFootprintEditor ) + { + BOX2I nonFieldsBBox; + + for( EDA_ITEM* item : aSelection.Items() ) + { + if( !item->IsType( { PCB_TEXT_T, PCB_FIELD_T } ) ) + nonFieldsBBox.Merge( item->GetBoundingBox() ); + } + + if( nonFieldsBBox.IsValid() ) + refPt = nonFieldsBBox.GetCenter(); + } + + aSelection.SetReferencePoint( grid.BestSnapAnchor( refPt, nullptr ) ); } return true;