Support single-field-mirroring in Symbol Editor.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/13395
This commit is contained in:
Jeff Young 2023-11-20 22:55:51 +00:00
parent f3fdfa73e6
commit f9c8f6ab79
1 changed files with 40 additions and 10 deletions

View File

@ -213,21 +213,51 @@ int SYMBOL_EDITOR_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
saveCopyInUndoList( m_frame->GetCurSymbol(), UNDO_REDO::LIBEDIT ); saveCopyInUndoList( m_frame->GetCurSymbol(), UNDO_REDO::LIBEDIT );
if( selection.GetSize() == 1 ) if( selection.GetSize() == 1 )
mirrorPoint = item->GetPosition();
else
mirrorPoint = m_frame->GetNearestHalfGridPosition( mapCoords( selection.GetCenter() ) );
for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
{ {
item = static_cast<LIB_ITEM*>( selection.GetItem( ii ) ); mirrorPoint = item->GetPosition();
switch( item->Type() )
{
case LIB_FIELD_T:
{
LIB_FIELD* field = static_cast<LIB_FIELD*>( item );
if( xAxis )
field->SetVertJustify( TO_VJUSTIFY( -field->GetVertJustify() ) );
else
field->SetHorizJustify( TO_HJUSTIFY( -field->GetHorizJustify() ) );
break;
}
default:
if( xAxis )
item->MirrorVertical( mirrorPoint );
else
item->MirrorHorizontal( mirrorPoint );
break;
}
if( xAxis )
item->MirrorVertical( mirrorPoint );
else
item->MirrorHorizontal( mirrorPoint );
m_frame->UpdateItem( item, false, true ); m_frame->UpdateItem( item, false, true );
} }
else
{
mirrorPoint = m_frame->GetNearestHalfGridPosition( mapCoords( selection.GetCenter() ) );
for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
{
item = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
if( xAxis )
item->MirrorVertical( mirrorPoint );
else
item->MirrorHorizontal( mirrorPoint );
m_frame->UpdateItem( item, false, true );
}
}
if( item->IsMoving() ) if( item->IsMoving() )
{ {