Eeschema: unify schematic and component library block mirror commands.

This commit is contained in:
Mikael Arguedas 2016-04-22 10:15:16 -04:00 committed by Wayne Stambaugh
parent ce593f9784
commit 5d6f8d1edc
5 changed files with 58 additions and 4 deletions

View File

@ -209,7 +209,11 @@ enum id_eeschema_frm
ID_LIBEDIT_EXPORT_BODY_BUTT,
ID_LIBEDIT_DELETE_ITEM_BUTT,
/* Change orientation command ID */
ID_LIBEDIT_ROTATE_ITEM,
ID_LIBEDIT_MIRROR_X,
ID_LIBEDIT_MIRROR_Y,
ID_LIBEDIT_ORIENT_NORMAL,
/* Library editor context menu IDs */
ID_LIBEDIT_EDIT_PIN,

View File

@ -311,6 +311,8 @@ static EDA_HOTKEY* libEdit_Hotkey_List[] =
&HkCreatePin,
&HkInsertPin,
&HkMoveLibItem,
&HkMirrorX,
&HkMirrorY,
NULL
};
@ -782,6 +784,17 @@ bool LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
}
}
break;
case HK_MIRROR_Y: // Mirror Y
m_drawItem = LocateItemUsingCursor( aPosition );
cmd.SetId( ID_LIBEDIT_MIRROR_Y );
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_MIRROR_X: // Mirror X
m_drawItem = LocateItemUsingCursor( aPosition );
cmd.SetId( ID_LIBEDIT_MIRROR_X );
GetEventHandler()->ProcessEvent( cmd );
break;
}
// Hot key handled.

View File

@ -320,6 +320,7 @@ void AddMenusForPin( wxMenu* PopMenu, LIB_PIN* Pin, LIB_EDIT_FRAME* frame )
void AddMenusForBlock( wxMenu* PopMenu, LIB_EDIT_FRAME* frame )
{
wxString msg;
AddMenuItem( PopMenu, ID_POPUP_LIBEDIT_CANCEL_EDITING, _( "Cancel Block" ),
KiBitmap( cancel_xpm ) );
@ -337,11 +338,14 @@ void AddMenusForBlock( wxMenu* PopMenu, LIB_EDIT_FRAME* frame )
AddMenuItem( PopMenu, ID_POPUP_SELECT_ITEMS_BLOCK, _( "Select Items" ),
KiBitmap( green_xpm ) );
AddMenuItem( PopMenu, ID_POPUP_COPY_BLOCK, _( "Copy Block" ), KiBitmap( copyblock_xpm ) );
AddMenuItem( PopMenu, ID_POPUP_MIRROR_Y_BLOCK, _( "Mirror Block ||" ),
msg = AddHotkeyName( _( "Mirror Block ||" ), g_Libedit_Hokeys_Descr, HK_MIRROR_Y );
AddMenuItem( PopMenu, ID_POPUP_MIRROR_Y_BLOCK, msg,
KiBitmap( mirror_h_xpm ) );
AddMenuItem( PopMenu, ID_POPUP_MIRROR_X_BLOCK, _( "Mirror Block --" ),
msg = AddHotkeyName( _( "Mirror Block --" ), g_Libedit_Hokeys_Descr, HK_MIRROR_X );
AddMenuItem( PopMenu, ID_POPUP_MIRROR_X_BLOCK, msg,
KiBitmap( mirror_v_xpm ) );
AddMenuItem( PopMenu, ID_POPUP_ROTATE_BLOCK, _( "Rotate Block ccw" ),
msg = AddHotkeyName( _( "Rotate Block CCW" ), g_Libedit_Hokeys_Descr, HK_ROTATE );
AddMenuItem( PopMenu, ID_POPUP_ROTATE_BLOCK, msg,
KiBitmap( rotate_ccw_xpm ) );
AddMenuItem( PopMenu, ID_POPUP_DELETE_BLOCK, _( "Delete Block" ), KiBitmap( delete_xpm ) );
}

View File

@ -150,6 +150,8 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
LIB_EDIT_FRAME::Process_Special_Functions )
EVT_MENU_RANGE( ID_LIBEDIT_MIRROR_X, ID_LIBEDIT_ORIENT_NORMAL,
LIB_EDIT_FRAME::OnOrient )
// Update user interface elements.
EVT_UPDATE_UI( ExportPartId, LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( CreateNewLibAndSavePartId, LIB_EDIT_FRAME::OnUpdateEditingPart )
@ -871,7 +873,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_canvas->SetAutoPanRequest( false );
GetScreen()->m_BlockLocate.SetCommand( BLOCK_COPY );
m_canvas->MoveCursorToCrossHair();
HandleBlockPlace( &dc );
HandleBlockEnd( &dc );
break;
case ID_POPUP_SELECT_ITEMS_BLOCK:
@ -1197,6 +1199,31 @@ void LIB_EDIT_FRAME::OnRotateItem( wxCommandEvent& aEvent )
}
void LIB_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
{
INSTALL_UNBUFFERED_DC( dc, m_canvas );
SCH_SCREEN* screen = GetScreen();
// Allows block rotate operation on hot key.
if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
{
if( aEvent.GetId() == ID_LIBEDIT_MIRROR_X )
{
m_canvas->MoveCursorToCrossHair();
screen->m_BlockLocate.SetMessageBlock( this );
screen->m_BlockLocate.SetCommand( BLOCK_MIRROR_X );
HandleBlockEnd( &dc );
}
else if( aEvent.GetId() == ID_LIBEDIT_MIRROR_Y )
{
m_canvas->MoveCursorToCrossHair();
screen->m_BlockLocate.SetMessageBlock( this );
screen->m_BlockLocate.SetCommand( BLOCK_MIRROR_Y );
HandleBlockEnd( &dc );
}
}
}
LIB_ITEM* LIB_EDIT_FRAME::LocateItemUsingCursor( const wxPoint& aPosition,
const KICAD_T aFilterList[] )
{

View File

@ -506,6 +506,12 @@ private:
*/
void OnRotateItem( wxCommandEvent& aEvent );
/**
* Function OnOrient
* Handles the ID_LIBEDIT_MIRROR_X and ID_LIBEDIT_MIRROR_Y events.
*/
void OnOrient( wxCommandEvent& aEvent );
/**
* Function deleteItem
* deletes the currently selected draw item.