Fix keep-upright algo for footprint text.
Also removes PCB_FIELDs from rotation centre calc in footprint editor if there is other stuff selected. Fixes https://gitlab.com/kicad/code/kicad/-/issues/16896
This commit is contained in:
parent
0772739cf1
commit
25bb3f77fa
|
@ -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<PCB_TEXT*>( item )->KeepUpright( newOrientation );
|
||||
static_cast<PCB_TEXT*>( item )->KeepUpright();
|
||||
}
|
||||
|
||||
m_boundingBoxCacheTimeStamp = 0;
|
||||
|
|
|
@ -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<GR_TEXT_H_ALIGN_T>( -GetHorizJustify() ) );
|
||||
SetVertJustify( static_cast<GR_TEXT_V_ALIGN_T>( -GetVertJustify() ) );
|
||||
SetTextAngle( GetTextAngle() + ANGLE_180 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue