From 891c85a2c1412ae089f3eddf79d2fc16c616d948 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 3 Aug 2013 18:16:57 +0200 Subject: [PATCH] Pcbnew: add hotkey Z to reset grid origin. Save grid origin in .kicad_pcb files only if not 0,0 (to keep compatibility with previous versions of pcbnew, mainly the stable version) Very minor other fixes (set modify flag when grid origin is moved from the dialog grid) --- include/hotkeys_basic.h | 1 + pcbnew/dialogs/dialog_set_grid.cpp | 3 +++ pcbnew/hotkeys.cpp | 6 ++++-- pcbnew/hotkeys.h | 4 +++- pcbnew/hotkeys_board_editor.cpp | 6 ++++++ pcbnew/hotkeys_module_editor.cpp | 5 +++++ pcbnew/kicad_plugin.cpp | 7 ++++--- pcbnew/menubar_pcbframe.cpp | 4 ++-- 8 files changed, 28 insertions(+), 8 deletions(-) diff --git a/include/hotkeys_basic.h b/include/hotkeys_basic.h index 65f53dc483..f070441de4 100644 --- a/include/hotkeys_basic.h +++ b/include/hotkeys_basic.h @@ -218,6 +218,7 @@ enum common_hotkey_id_commnand { HK_NOT_FOUND = 0, HK_RESET_LOCAL_COORD, HK_SET_GRID_ORIGIN, + HK_RESET_GRID_ORIGIN, HK_HELP, HK_ZOOM_IN, HK_ZOOM_OUT, diff --git a/pcbnew/dialogs/dialog_set_grid.cpp b/pcbnew/dialogs/dialog_set_grid.cpp index 154088cd3a..d22890b572 100644 --- a/pcbnew/dialogs/dialog_set_grid.cpp +++ b/pcbnew/dialogs/dialog_set_grid.cpp @@ -211,6 +211,9 @@ bool PCB_BASE_FRAME::InvokeDialogGrid() if( ret == wxID_OK ) { + if( GetGridOrigin() != grid_origin && IsType( PCB_FRAME_TYPE ) ) + OnModify(); // because grid origin is saved in board, show as modified + SetGridOrigin( grid_origin ); GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER ); diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index 8186af3d14..c0a3830388 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -55,6 +55,7 @@ static EDA_HOTKEY HkSwitch2PreviousCopperLayer( wxT( "Switch to Previous Layer" static EDA_HOTKEY HkSaveModule( wxT( "Save Module" ), HK_SAVE_MODULE, 'S' + GR_KB_CTRL ); static EDA_HOTKEY HkSavefile( wxT( "Save board" ), HK_SAVE_BOARD, 'S' + GR_KB_CTRL ); +static EDA_HOTKEY HkSavefileAs( wxT( "Save board as" ), HK_SAVE_BOARD_AS, 'S' + GR_KB_CTRL + GR_KB_SHIFT ); static EDA_HOTKEY HkLoadfile( wxT( "Load board" ), HK_LOAD_BOARD, 'L' + GR_KB_CTRL ); static EDA_HOTKEY HkFindItem( wxT( "Find Item" ), HK_FIND_ITEM, 'F' + GR_KB_CTRL ); static EDA_HOTKEY HkBackspace( wxT( "Delete track segment" ), HK_BACK_SPACE, WXK_BACK ); @@ -78,6 +79,7 @@ static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ), HK_RESET_ static EDA_HOTKEY HkSwitchHighContrastMode( wxT("Switch Highcontrast mode"), HK_SWITCH_HIGHCONTRAST_MODE,'H'); static EDA_HOTKEY HkSetGridOrigin( wxT("Set Grid Origin"), HK_SET_GRID_ORIGIN, 'S' ); +static EDA_HOTKEY HkResetGridOrigin( wxT("Reset Grid Origin"), HK_RESET_GRID_ORIGIN, 'Z' ); /* Fit on Screen */ #if !defined( __WXMAC__ ) @@ -195,7 +197,7 @@ EDA_HOTKEY* common_Hotkey_List[] = { &HkHelp, &HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter, &HkZoomAuto, - &HkSwitchUnits, &HkResetLocalCoord, &HkSetGridOrigin, + &HkSwitchUnits, &HkResetLocalCoord, &HkSetGridOrigin, &HkResetGridOrigin, &HkUndo, &HkRedo, NULL }; @@ -211,7 +213,7 @@ EDA_HOTKEY* board_edit_Hotkey_List[] = &HkPlaceItem, &HkCopyItem, &HkEndTrack, &HkMoveItem, &HkFlipItem, &HkRotateItem, &HkDragFootprint, - &HkGetAndMoveFootprint, &HkLock_Unlock_Footprint, &HkSavefile, + &HkGetAndMoveFootprint, &HkLock_Unlock_Footprint, &HkSavefile, &HkSavefileAs, &HkLoadfile, &HkFindItem, &HkEditBoardItem, &HkSwitch2CopperLayer, &HkSwitch2InnerLayer1, &HkSwitch2InnerLayer2, &HkSwitch2InnerLayer3, &HkSwitch2InnerLayer4, diff --git a/pcbnew/hotkeys.h b/pcbnew/hotkeys.h index 98e18fb565..dca43f3aa0 100644 --- a/pcbnew/hotkeys.h +++ b/pcbnew/hotkeys.h @@ -26,7 +26,9 @@ enum hotkey_id_commnand { HK_SWITCH_TRACK_POSTURE, HK_DRAG_TRACK_KEEP_SLOPE, HK_END_TRACK, - HK_SAVE_BOARD, HK_LOAD_BOARD, + HK_SAVE_BOARD, + HK_SAVE_BOARD_AS, + HK_LOAD_BOARD, HK_SAVE_MODULE, HK_SWITCH_UNITS, HK_SWITCH_TRACK_DISPLAY_MODE, diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp index 2d46178a47..b3cc0893b0 100644 --- a/pcbnew/hotkeys_board_editor.cpp +++ b/pcbnew/hotkeys_board_editor.cpp @@ -351,6 +351,12 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit m_canvas->Refresh(); break; + case HK_RESET_GRID_ORIGIN: + SetGridOrigin( wxPoint(0,0) ); + OnModify(); // because grid origin is saved in board, show as modified + m_canvas->Refresh(); + break; + case HK_SWITCH_UNITS: evt_type = (g_UserUnit == INCHES) ? ID_TB_OPTIONS_SELECT_UNIT_MM : ID_TB_OPTIONS_SELECT_UNIT_INCH; diff --git a/pcbnew/hotkeys_module_editor.cpp b/pcbnew/hotkeys_module_editor.cpp index 978f8a3a3c..0bff61af9e 100644 --- a/pcbnew/hotkeys_module_editor.cpp +++ b/pcbnew/hotkeys_module_editor.cpp @@ -64,6 +64,11 @@ void FOOTPRINT_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPos m_canvas->Refresh(); break; + case HK_RESET_GRID_ORIGIN: + SetGridOrigin( wxPoint(0,0) ); + m_canvas->Refresh(); + break; + case HK_SWITCH_UNITS: cmd.SetId( (g_UserUnit == INCHES) ? ID_TB_OPTIONS_SELECT_UNIT_MM : ID_TB_OPTIONS_SELECT_UNIT_INCH ); diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index d987948d71..d6bc8f87e7 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -560,9 +560,10 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const FMTIU( aBoard->GetAuxOrigin().x ).c_str(), FMTIU( aBoard->GetAuxOrigin().y ).c_str() ); - m_out->Print( aNestLevel+1, "(grid_origin %s %s)\n", - FMTIU( aBoard->GetGridOrigin().x ).c_str(), - FMTIU( aBoard->GetGridOrigin().y ).c_str() ); + if( aBoard->GetGridOrigin().x || aBoard->GetGridOrigin().y ) + m_out->Print( aNestLevel+1, "(grid_origin %s %s)\n", + FMTIU( aBoard->GetGridOrigin().x ).c_str(), + FMTIU( aBoard->GetGridOrigin().y ).c_str() ); m_out->Print( aNestLevel+1, "(visible_elements %X)\n", aBoard->GetDesignSettings().GetVisibleElements() ); diff --git a/pcbnew/menubar_pcbframe.cpp b/pcbnew/menubar_pcbframe.cpp index b3d732d934..a63c652b5a 100644 --- a/pcbnew/menubar_pcbframe.cpp +++ b/pcbnew/menubar_pcbframe.cpp @@ -105,8 +105,8 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() KiBitmap( save_xpm ) ); // Save As - AddMenuItem( filesMenu, ID_SAVE_BOARD_AS, - _( "Sa&ve As...\tCtrl+Shift+S" ), + text = AddHotkeyName( _( "Sa&ve As..." ), g_Board_Editor_Hokeys_Descr, HK_SAVE_BOARD_AS ); + AddMenuItem( filesMenu, ID_SAVE_BOARD_AS, text, _( "Save the current board as..." ), KiBitmap( save_as_xpm ) ); filesMenu->AppendSeparator();