Don't run keepUpright when not rotating.

For that matter, don't do anything at all for a rotation
of 0 (or a move vector of {0,0}).

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16402
This commit is contained in:
Jeff Young 2023-12-22 21:20:36 +00:00
parent a77ce59487
commit 3f73bbcc4f
4 changed files with 12 additions and 5 deletions

View File

@ -1894,6 +1894,9 @@ const wxChar* FOOTPRINT::StringLibNameInvalidChars( bool aUserReadable )
void FOOTPRINT::Move( const VECTOR2I& aMoveVector )
{
if( aMoveVector.x == 0 && aMoveVector.y == 0 )
return;
VECTOR2I newpos = m_pos + aMoveVector;
SetPosition( newpos );
}
@ -1901,6 +1904,9 @@ void FOOTPRINT::Move( const VECTOR2I& aMoveVector )
void FOOTPRINT::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
{
if( aAngle == ANGLE_0 )
return;
EDA_ANGLE orientation = GetOrientation();
EDA_ANGLE newOrientation = orientation + aAngle;
VECTOR2I newpos = m_pos;
@ -1909,12 +1915,12 @@ void FOOTPRINT::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
SetOrientation( newOrientation );
for( PCB_FIELD* field : m_fields )
field->KeepUpright( orientation, newOrientation );
field->KeepUpright( newOrientation );
for( BOARD_ITEM* item : m_drawings )
{
if( item->Type() == PCB_TEXT_T )
static_cast<PCB_TEXT*>( item )->KeepUpright( orientation, newOrientation );
static_cast<PCB_TEXT*>( item )->KeepUpright( newOrientation );
}
m_boundingBoxCacheTimeStamp = 0;

View File

@ -263,7 +263,7 @@ void PCB_TEXT::StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings )
}
void PCB_TEXT::KeepUpright( const EDA_ANGLE& aOldOrientation, const EDA_ANGLE& aNewOrientation )
void PCB_TEXT::KeepUpright( const EDA_ANGLE& aNewOrientation )
{
if( !IsKeepUpright() )
return;

View File

@ -70,7 +70,7 @@ public:
/**
* Called when rotating the parent footprint.
*/
void KeepUpright( const EDA_ANGLE& aOldOrientation, const EDA_ANGLE& aNewOrientation );
void KeepUpright( const EDA_ANGLE& aNewOrientation );
wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override;

View File

@ -2357,7 +2357,8 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent )
case ROTATE_AROUND_ITEM_ANCHOR:
boardItem->Rotate( boardItem->GetPosition(), angle );
break;
case ROTATE_AROUND_SEL_CENTER: boardItem->Rotate( selCenter, angle );
case ROTATE_AROUND_SEL_CENTER:
boardItem->Rotate( selCenter, angle );
break;
case ROTATE_AROUND_USER_ORIGIN:
boardItem->Rotate( frame()->GetScreen()->m_LocalOrigin, angle );