Symbol editor: Fix usability issues of mirror and rotation commands

Fix also mirrorX and mirrorY command to have the same behavior as the schematic editor

Fixes: lp:1797090
https://bugs.launchpad.net/kicad/+bug/1797090
This commit is contained in:
jean-pierre charras 2018-10-10 15:59:38 +02:00
parent 06dccf715d
commit 9b027628ef
1 changed files with 16 additions and 10 deletions

View File

@ -1166,7 +1166,10 @@ void LIB_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
// Compute the rotation center and put it on grid: // Compute the rotation center and put it on grid:
wxPoint rotationPoint = block.Centre(); wxPoint rotationPoint = block.Centre();
rotationPoint = GetNearestGridPosition( rotationPoint ); rotationPoint = GetNearestGridPosition( rotationPoint );
SetCrossHairPosition( rotationPoint );
// The Y axis orientation is bottom to top for symbol items.
// so change the Y coord value of the rotation center
rotationPoint.y = -rotationPoint.y;
if( block.AppendUndo() ) if( block.AppendUndo() )
; // UR_LIBEDIT saves entire state, so no need to append anything more ; // UR_LIBEDIT saves entire state, so no need to append anything more
@ -1183,12 +1186,11 @@ void LIB_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
} }
GetCanvas()->CallMouseCapture( nullptr, wxDefaultPosition, false ); GetCanvas()->CallMouseCapture( nullptr, wxDefaultPosition, false );
GetGalCanvas()->Refresh();
} }
else if( item ) else if( item )
{ {
wxPoint rotationPoint = item->GetBoundingBox().Centre(); wxPoint rotationPoint = item->GetPosition();
rotationPoint = GetNearestGridPosition( rotationPoint );
SetCrossHairPosition( rotationPoint );
if( !item->InEditMode() ) if( !item->InEditMode() )
SaveCopyInUndoList( part, UR_LIBEDIT ); SaveCopyInUndoList( part, UR_LIBEDIT );
@ -1217,7 +1219,10 @@ void LIB_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
// Compute the mirror center and put it on grid. // Compute the mirror center and put it on grid.
wxPoint mirrorPoint = block.Centre(); wxPoint mirrorPoint = block.Centre();
mirrorPoint = GetNearestGridPosition( mirrorPoint ); mirrorPoint = GetNearestGridPosition( mirrorPoint );
SetCrossHairPosition( mirrorPoint );
// The Y axis orientation is bottom to top for symbol items.
// so change the Y coord value of the rotation center
mirrorPoint.y = -mirrorPoint.y;
if( block.AppendUndo() ) if( block.AppendUndo() )
; // UR_LIBEDIT saves entire state, so no need to append anything more ; // UR_LIBEDIT saves entire state, so no need to append anything more
@ -1231,27 +1236,28 @@ void LIB_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
{ {
item = dynamic_cast<LIB_ITEM*>( block.GetItem( ii ) ); item = dynamic_cast<LIB_ITEM*>( block.GetItem( ii ) );
if( aEvent.GetId() == ID_LIBEDIT_MIRROR_X || aEvent.GetId() == ID_POPUP_MIRROR_X_BLOCK ) if( aEvent.GetId() == ID_LIBEDIT_MIRROR_Y || aEvent.GetId() == ID_POPUP_MIRROR_Y_BLOCK )
item->MirrorHorizontal( mirrorPoint ); item->MirrorHorizontal( mirrorPoint );
else else
item->MirrorVertical( mirrorPoint ); item->MirrorVertical( mirrorPoint );
} }
m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false ); m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
GetGalCanvas()->Refresh();
} }
else if( item ) else if( item )
{ {
wxPoint mirrorPoint = item->GetBoundingBox().Centre(); wxPoint mirrorPoint = item->GetPosition();
mirrorPoint = GetNearestGridPosition( mirrorPoint ); mirrorPoint.y = -mirrorPoint.y;
SetCrossHairPosition( mirrorPoint );
if( !item->InEditMode() ) if( !item->InEditMode() )
SaveCopyInUndoList( part, UR_LIBEDIT ); SaveCopyInUndoList( part, UR_LIBEDIT );
if( aEvent.GetId() == ID_LIBEDIT_MIRROR_X || aEvent.GetId() == ID_POPUP_MIRROR_X_BLOCK ) if( aEvent.GetId() == ID_LIBEDIT_MIRROR_Y || aEvent.GetId() == ID_POPUP_MIRROR_Y_BLOCK )
item->MirrorHorizontal( mirrorPoint ); item->MirrorHorizontal( mirrorPoint );
else else
item->MirrorVertical( mirrorPoint ); item->MirrorVertical( mirrorPoint );
OnModify(); OnModify();
if( !item->InEditMode() ) if( !item->InEditMode() )