Harmonize mirroring APIs.

This commit is contained in:
Jeff Young 2024-04-05 00:03:32 +01:00
parent c5ed80af52
commit 5dd8747ecb
14 changed files with 51 additions and 51 deletions

View File

@ -296,25 +296,25 @@ void LIB_FIELD::MoveTo( const VECTOR2I& newPosition )
}
void LIB_FIELD::MirrorHorizontal( const VECTOR2I& center )
void LIB_FIELD::MirrorHorizontally( int aCenter )
{
int x = GetTextPos().x;
x -= center.x;
x -= aCenter;
x *= -1;
x += center.x;
x += aCenter;
SetTextX( x );
}
void LIB_FIELD::MirrorVertical( const VECTOR2I& center )
void LIB_FIELD::MirrorVertically( int aCenter )
{
int y = GetTextPos().y;
y -= center.y;
y -= aCenter;
y *= -1;
y += center.y;
y += aCenter;
SetTextY( y );
}

View File

@ -171,8 +171,8 @@ public:
VECTOR2I GetPosition() const override { return EDA_TEXT::GetTextPos(); }
void MirrorHorizontal( const VECTOR2I& aCenter ) override;
void MirrorVertical( const VECTOR2I& aCenter ) override;
void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( int aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) override;
void Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset,

View File

@ -310,14 +310,14 @@ public:
*
* @param aCenter Point to mirror around.
*/
virtual void MirrorHorizontal( const VECTOR2I& aCenter ) = 0;
virtual void MirrorHorizontally( int aCenter ) = 0;
/**
* Mirror the draw object along the MirrorVertical (Y) axis about \a aCenter point.
*
* @param aCenter Point to mirror around.
*/
virtual void MirrorVertical( const VECTOR2I& aCenter ) = 0;
virtual void MirrorVertically( int aCenter ) = 0;
/**
* Rotate the object about \a aCenter point.

View File

@ -1108,11 +1108,11 @@ void LIB_PIN::MoveTo( const VECTOR2I& aNewPosition )
}
void LIB_PIN::MirrorHorizontal( const VECTOR2I& aCenter )
void LIB_PIN::MirrorHorizontally( int aCenter )
{
m_position.x -= aCenter.x;
m_position.x -= aCenter;
m_position.x *= -1;
m_position.x += aCenter.x;
m_position.x += aCenter;
if( m_orientation == PIN_ORIENTATION::PIN_RIGHT )
m_orientation = PIN_ORIENTATION::PIN_LEFT;
@ -1121,11 +1121,11 @@ void LIB_PIN::MirrorHorizontal( const VECTOR2I& aCenter )
}
void LIB_PIN::MirrorVertical( const VECTOR2I& aCenter )
void LIB_PIN::MirrorVertically( int aCenter )
{
m_position.y -= aCenter.y;
m_position.y -= aCenter;
m_position.y *= -1;
m_position.y += aCenter.y;
m_position.y += aCenter;
if( m_orientation == PIN_ORIENTATION::PIN_UP )
m_orientation = PIN_ORIENTATION::PIN_DOWN;

View File

@ -237,8 +237,8 @@ public:
VECTOR2I GetPinRoot() const;
void MirrorHorizontal( const VECTOR2I& aCenter ) override;
void MirrorVertical( const VECTOR2I& aCenter ) override;
void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( int aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) override;
void Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset,

View File

@ -111,15 +111,15 @@ void LIB_SHAPE::Normalize()
}
void LIB_SHAPE::MirrorHorizontal( const VECTOR2I& aCenter )
void LIB_SHAPE::MirrorHorizontally( int aCenter )
{
flip( aCenter, true );
flip( VECTOR2I( aCenter, 0 ), true );
}
void LIB_SHAPE::MirrorVertical( const VECTOR2I& aCenter )
void LIB_SHAPE::MirrorVertically( int aCenter )
{
flip( aCenter, false );
flip( VECTOR2I( 0, aCenter ), false );
}

View File

@ -105,8 +105,8 @@ public:
void Normalize();
void MirrorHorizontal( const VECTOR2I& aCenter ) override;
void MirrorVertical( const VECTOR2I& aCenter ) override;
void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( int aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) override;
void Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset,

View File

@ -161,14 +161,14 @@ void LIB_TEXT::NormalizeJustification( bool inverse )
}
void LIB_TEXT::MirrorHorizontal( const VECTOR2I& center )
void LIB_TEXT::MirrorHorizontally( int aCenter )
{
NormalizeJustification( false );
int x = GetTextPos().x;
x -= center.x;
x -= aCenter;
x *= -1;
x += center.x;
x += aCenter;
if( GetTextAngle().IsHorizontal() )
{
@ -190,14 +190,14 @@ void LIB_TEXT::MirrorHorizontal( const VECTOR2I& center )
}
void LIB_TEXT::MirrorVertical( const VECTOR2I& center )
void LIB_TEXT::MirrorVertically( int aCenter )
{
NormalizeJustification( false );
int y = GetTextPos().y;
y -= center.y;
y -= aCenter;
y *= -1;
y += center.y;
y += aCenter;
if( GetTextAngle().IsHorizontal() )
{

View File

@ -97,8 +97,8 @@ public:
VECTOR2I GetPosition() const override { return EDA_TEXT::GetTextPos(); }
void MirrorHorizontal( const VECTOR2I& aCenter ) override;
void MirrorVertical( const VECTOR2I& aCenter ) override;
void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( int aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) override;
void NormalizeJustification( bool inverse );

View File

@ -75,7 +75,7 @@ int LIB_TEXTBOX::GetLegacyTextMargin() const
}
void LIB_TEXTBOX::MirrorHorizontally( const VECTOR2I& center )
void LIB_TEXTBOX::MirrorHorizontally( int aCenter )
{
// Text is NOT really mirrored; it just has its justification flipped
if( GetTextAngle() == ANGLE_HORIZONTAL )
@ -88,7 +88,7 @@ void LIB_TEXTBOX::MirrorHorizontally( const VECTOR2I& center )
}
void LIB_TEXTBOX::MirrorVertically( const VECTOR2I& center )
void LIB_TEXTBOX::MirrorVertically( int aCenter )
{
// Text is NOT really mirrored; it just has its justification flipped
if( GetTextAngle() == ANGLE_VERTICAL )

View File

@ -70,8 +70,8 @@ public:
wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override;
void MirrorHorizontally( const VECTOR2I& center );
void MirrorVertically( const VECTOR2I& center );
void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( int aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;

View File

@ -2583,10 +2583,10 @@ static void orientSymbol( LIB_SYMBOL* symbol, int orientation )
item.Rotate( VECTOR2I(0, 0 ), true );
if( o.mirror_x )
item.MirrorVertical( VECTOR2I( 0, 0 ) );
item.MirrorVertically( 0 );
if( o.mirror_y )
item.MirrorHorizontal( VECTOR2I( 0, 0 ) );
item.MirrorHorizontally( 0 );
}
}
@ -2766,11 +2766,11 @@ void SCH_PAINTER::draw( const SCH_FIELD* aField, int aLayer, bool aDimmed )
{
if( static_cast<SCH_SYMBOL*>( aField->GetParent() )->GetTransform().y1 )
{
// Rotate symbol 90 degrees.
if( orient.IsHorizontal() )
orient = ANGLE_VERTICAL;
else
orient = ANGLE_HORIZONTAL;
// Rotate symbol 90 degrees.
if( orient.IsHorizontal() )
orient = ANGLE_VERTICAL;
else
orient = ANGLE_HORIZONTAL;
}
}

View File

@ -232,9 +232,9 @@ int SYMBOL_EDITOR_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
default:
if( xAxis )
item->MirrorVertical( mirrorPoint );
item->MirrorVertically( mirrorPoint.y );
else
item->MirrorHorizontal( mirrorPoint );
item->MirrorHorizontally( mirrorPoint.x );
break;
}
@ -251,9 +251,9 @@ int SYMBOL_EDITOR_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
item = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
if( xAxis )
item->MirrorVertical( mirrorPoint );
item->MirrorVertically( mirrorPoint.y );
else
item->MirrorHorizontal( mirrorPoint );
item->MirrorHorizontally( mirrorPoint.x );
m_frame->UpdateItem( item, false, true );
}

View File

@ -315,8 +315,8 @@ BOOST_AUTO_TEST_CASE( MirrorHorizontally )
if( libItem != nullptr )
{
libItem->MirrorHorizontal( aRef );
libItem->MirrorHorizontal( aRef );
libItem->MirrorHorizontally( aRef.x );
libItem->MirrorHorizontally( aRef.x );
}
CompareItems( item.get(), aOriginalItem );
@ -360,8 +360,8 @@ BOOST_AUTO_TEST_CASE( MirrorVertically )
if( libItem != nullptr )
{
libItem->MirrorVertical( aRef );
libItem->MirrorVertical( aRef );
libItem->MirrorVertically( aRef.y );
libItem->MirrorVertically( aRef.y );
}
CompareItems( item.get(), aOriginalItem );