From 5d6f8d1edc0e492621fb6ce1afc2d681dfd2b2c4 Mon Sep 17 00:00:00 2001 From: Mikael Arguedas Date: Fri, 22 Apr 2016 10:15:16 -0400 Subject: [PATCH] Eeschema: unify schematic and component library block mirror commands. --- eeschema/eeschema_id.h | 4 ++++ eeschema/hotkeys.cpp | 13 +++++++++++++ eeschema/libedit_onrightclick.cpp | 10 +++++++--- eeschema/libeditframe.cpp | 29 ++++++++++++++++++++++++++++- eeschema/libeditframe.h | 6 ++++++ 5 files changed, 58 insertions(+), 4 deletions(-) diff --git a/eeschema/eeschema_id.h b/eeschema/eeschema_id.h index c030095b7a..683e476290 100644 --- a/eeschema/eeschema_id.h +++ b/eeschema/eeschema_id.h @@ -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, diff --git a/eeschema/hotkeys.cpp b/eeschema/hotkeys.cpp index 245e4c1269..eb4d3feaa0 100644 --- a/eeschema/hotkeys.cpp +++ b/eeschema/hotkeys.cpp @@ -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. diff --git a/eeschema/libedit_onrightclick.cpp b/eeschema/libedit_onrightclick.cpp index 24067ed2d3..30c130b8db 100644 --- a/eeschema/libedit_onrightclick.cpp +++ b/eeschema/libedit_onrightclick.cpp @@ -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 ) ); } diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index 428f539470..fef1f5a6bf 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -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[] ) { diff --git a/eeschema/libeditframe.h b/eeschema/libeditframe.h index dd8caac186..49f569ce5e 100644 --- a/eeschema/libeditframe.h +++ b/eeschema/libeditframe.h @@ -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.