From 37b086837641d7af6332d0d7dd7ef08bd6b0e648 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 12 May 2015 11:05:36 +0200 Subject: [PATCH] Pcbnew: fix minor issues about fast grid switching, and next/previous grid selection from hotkeys. (GAL mode still has an issue) --- common/base_screen.cpp | 38 +++++++++----- common/draw_frame.cpp | 39 +++++++++----- common/zoom.cpp | 4 +- cvpcb/class_DisplayFootprintsFrame.cpp | 7 ++- eeschema/dialogs/dialog_eeschema_options.cpp | 2 +- eeschema/dialogs/dialog_libedit_options.cpp | 2 +- eeschema/eeschema_config.cpp | 4 +- eeschema/schframe.cpp | 12 ++--- include/class_base_screen.h | 23 ++++++--- include/wxBasePcbFrame.h | 12 +++++ pagelayout_editor/pl_editor_frame.cpp | 9 ++-- pcbnew/basepcbframe.cpp | 53 +++++++++++++++++--- pcbnew/dialogs/dialog_set_grid.cpp | 2 +- pcbnew/hotkeys_board_editor.cpp | 1 + pcbnew/tools/grid_menu.cpp | 4 +- 15 files changed, 149 insertions(+), 63 deletions(-) diff --git a/common/base_screen.cpp b/common/base_screen.cpp index c4da616ec3..1297ec95b9 100644 --- a/common/base_screen.cpp +++ b/common/base_screen.cpp @@ -48,7 +48,7 @@ BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : m_NumberOfScreens = 1; // Hierarchy: Root: ScreenNumber = 1 m_Zoom = 32.0; m_Grid.m_Size = wxRealPoint( 50, 50 ); // Default grid size - m_Grid.m_Id = ID_POPUP_GRID_LEVEL_50; + m_Grid.m_CmdId = ID_POPUP_GRID_LEVEL_50; m_Center = true; m_IsPrinting = false; m_ScrollPixelsPerUnitX = 1; @@ -183,7 +183,7 @@ int BASE_SCREEN::BuildGridsChoiceList( wxArrayString& aGridsList, bool aMmFirst) double gridValueMils = To_User_Unit( INCHES, grid.m_Size.x ) * 1000; double gridValue_mm = To_User_Unit( MILLIMETRES, grid.m_Size.x ); - if( grid.m_Id == ID_POPUP_GRID_USER ) + if( grid.m_CmdId == ID_POPUP_GRID_USER ) { msg = _( "User Grid" ); idx_usergrid = i; @@ -232,13 +232,13 @@ int BASE_SCREEN::SetGrid( const wxRealPoint& size ) if( m_grids[i].m_Size == size ) { m_Grid = m_grids[i]; - return m_grids[i].m_Id - ID_POPUP_GRID_LEVEL_1000; + return m_grids[i].m_CmdId - ID_POPUP_GRID_LEVEL_1000; } // keep track of the nearest larger grid size, if the exact size is not found if ( size.x < m_grids[i].m_Size.x ) { - gridIdx = m_grids[i].m_Id - ID_POPUP_GRID_LEVEL_1000; + gridIdx = m_grids[i].m_CmdId - ID_POPUP_GRID_LEVEL_1000; nearest_grid = m_grids[i]; } } @@ -259,10 +259,10 @@ int BASE_SCREEN::SetGrid( int aCommandId ) for( unsigned i = 0; i < m_grids.size(); i++ ) { - if( m_grids[i].m_Id == aCommandId ) + if( m_grids[i].m_CmdId == aCommandId ) { m_Grid = m_grids[i]; - return m_grids[i].m_Id - ID_POPUP_GRID_LEVEL_1000; + return m_grids[i].m_CmdId - ID_POPUP_GRID_LEVEL_1000; } } @@ -272,26 +272,27 @@ int BASE_SCREEN::SetGrid( int aCommandId ) wxT( "grid size( %g, %g )." ), aCommandId, m_Grid.m_Size.x, m_Grid.m_Size.y ); - return m_grids[0].m_Id - ID_POPUP_GRID_LEVEL_1000; + return m_grids[0].m_CmdId - ID_POPUP_GRID_LEVEL_1000; } + void BASE_SCREEN::AddGrid( const GRID_TYPE& grid ) { for( unsigned i = 0; i < m_grids.size(); i++ ) { - if( m_grids[i].m_Size == grid.m_Size && grid.m_Id != ID_POPUP_GRID_USER ) + if( m_grids[i].m_Size == grid.m_Size && grid.m_CmdId != ID_POPUP_GRID_USER ) { wxLogDebug( wxT( "Discarding duplicate grid size( %g, %g )." ), grid.m_Size.x, grid.m_Size.y ); return; } - if( m_grids[i].m_Id == grid.m_Id ) + if( m_grids[i].m_CmdId == grid.m_CmdId ) { wxLogDebug( wxT( "Changing grid ID %d from size( %g, %g ) to " ) \ wxT( "size( %g, %g )." ), - grid.m_Id, m_grids[i].m_Size.x, + grid.m_CmdId, m_grids[i].m_Size.x, m_grids[i].m_Size.y, grid.m_Size.x, grid.m_Size.y ); m_grids[i].m_Size = grid.m_Size; return; @@ -307,7 +308,7 @@ void BASE_SCREEN::AddGrid( const wxRealPoint& size, int id ) GRID_TYPE grid; grid.m_Size = size; - grid.m_Id = id; + grid.m_CmdId = id; AddGrid( grid ); } @@ -319,7 +320,7 @@ void BASE_SCREEN::AddGrid( const wxRealPoint& size, EDA_UNITS_T aUnit, int id ) new_size.x = From_User_Unit( aUnit, size.x ); new_size.y = From_User_Unit( aUnit, size.y ); - new_grid.m_Id = id; + new_grid.m_CmdId = id; new_grid.m_Size = new_size; AddGrid( new_grid ); @@ -335,6 +336,19 @@ GRID_TYPE& BASE_SCREEN::GetGrid( size_t aIndex ) } +bool BASE_SCREEN::GridExists( int aCommandId ) +{ + // tests for grid command ID (not an index in grid list, but a wxID) exists in grid list. + for( unsigned i = 0; i < m_grids.size(); i++ ) + { + if( m_grids[i].m_CmdId == aCommandId ) + return true; + } + + return false; +} + + wxPoint BASE_SCREEN::getNearestGridPosition( const wxPoint& aPosition, const wxPoint& aGridOrigin, wxRealPoint* aGridSize ) const { diff --git a/common/draw_frame.cpp b/common/draw_frame.cpp index 6d993365d8..fe422ee03c 100644 --- a/common/draw_frame.cpp +++ b/common/draw_frame.cpp @@ -378,7 +378,7 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event ) if( event.GetEventType() == wxEVT_COMMAND_COMBOBOX_SELECTED ) { - if( m_gridSelectBox == NULL ) // Should no happen + if( m_gridSelectBox == NULL ) // Should not happen return; /* @@ -404,7 +404,9 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event ) TOOL_MANAGER* mgr = GetToolManager(); if( mgr && IsGalCanvasActive() ) + { mgr->RunAction( "common.Control.gridPreset", true, idx ); + } else SetPresetGrid( idx ); @@ -536,47 +538,58 @@ wxPoint EDA_DRAW_FRAME::GetGridPosition( const wxPoint& aPosition ) const void EDA_DRAW_FRAME::SetNextGrid() { BASE_SCREEN * screen = GetScreen(); - int grid_cnt = screen->GetGridCount(); - int new_grid_idx = screen->GetGridId() - ID_POPUP_GRID_LEVEL_1000 + 1; + int new_grid_cmd = screen->GetGridCmdId(); - if( new_grid_idx >= grid_cnt ) - new_grid_idx = 0; + // if the grid id is the not the last, increment it + if( screen->GridExists( new_grid_cmd + 1 ) ) + new_grid_cmd += 1; - SetPresetGrid( new_grid_idx ); + SetPresetGrid( new_grid_cmd - ID_POPUP_GRID_LEVEL_1000 ); } void EDA_DRAW_FRAME::SetPrevGrid() { BASE_SCREEN * screen = GetScreen(); - int grid_cnt = screen->GetGridCount(); - int new_grid_idx = screen->GetGridId() - ID_POPUP_GRID_LEVEL_1000 - 1; + int new_grid_cmd = screen->GetGridCmdId(); - if( new_grid_idx < 0 ) - new_grid_idx = grid_cnt - 1; + // if the grid id is the not the first, increment it + if( screen->GridExists( new_grid_cmd - 1 ) ) + new_grid_cmd -= 1; - SetPresetGrid( new_grid_idx ); + SetPresetGrid( new_grid_cmd - ID_POPUP_GRID_LEVEL_1000 ); } void EDA_DRAW_FRAME::SetPresetGrid( int aIndex ) { + BASE_SCREEN * screen = GetScreen(); + + if( ! screen->GridExists( aIndex + ID_POPUP_GRID_LEVEL_1000 ) ) + aIndex = screen->GetGrids()[0].m_CmdId; + + // aIndex is a Command Id relative to ID_POPUP_GRID_LEVEL_1000 comand id code. + // we need an index in grid list (the cmd id in list is is screen->GetGrids()[0].m_CmdId): + int glistIdx = aIndex + ID_POPUP_GRID_LEVEL_1000 - screen->GetGrids()[0].m_CmdId; + if( m_gridSelectBox ) { - if( aIndex < 0 || aIndex >= (int) m_gridSelectBox->GetCount() ) + if( glistIdx < 0 || glistIdx >= (int) m_gridSelectBox->GetCount() ) { wxASSERT_MSG( false, "Invalid grid index" ); return; } - m_gridSelectBox->SetSelection( aIndex ); + m_gridSelectBox->SetSelection( glistIdx ); } // Be sure m_LastGridSizeId is up to date. m_LastGridSizeId = aIndex; GetScreen()->SetGrid( aIndex + ID_POPUP_GRID_LEVEL_1000 ); + + // Put cursor on new grid SetCrossHairPosition( RefPos( true ) ); } diff --git a/common/zoom.cpp b/common/zoom.cpp index a44b9b1a80..eb81413360 100644 --- a/common/zoom.cpp +++ b/common/zoom.cpp @@ -289,10 +289,10 @@ void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu ) for( unsigned i = 0; i < gridsList.GetCount(); i++ ) { GRID_TYPE& grid = screen->GetGrid( i ); - gridMenu->Append( grid.m_Id, gridsList[i], wxEmptyString, true ); + gridMenu->Append( grid.m_CmdId, gridsList[i], wxEmptyString, true ); if( (int)i == icurr ) - gridMenu->Check( grid.m_Id, true ); + gridMenu->Check( grid.m_CmdId, true ); } } diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp index 63914e7816..79b7730143 100644 --- a/cvpcb/class_DisplayFootprintsFrame.cpp +++ b/cvpcb/class_DisplayFootprintsFrame.cpp @@ -89,12 +89,11 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, CVPCB_MAINFRA LoadSettings( config() ); - // Initialize grid id to a default value if not found in config or bad: - if( (m_LastGridSizeId <= 0) || - (m_LastGridSizeId > (ID_POPUP_GRID_USER - ID_POPUP_GRID_LEVEL_1000)) ) + // Initialize grid id to a default value if not found in config or incorrect: + if( !( GetScreen()->GridExists( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) ) ) m_LastGridSizeId = ID_POPUP_GRID_LEVEL_500 - ID_POPUP_GRID_LEVEL_1000; - GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); + GetScreen()->SetGrid( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ); // Initialize some display options DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); diff --git a/eeschema/dialogs/dialog_eeschema_options.cpp b/eeschema/dialogs/dialog_eeschema_options.cpp index d07abc529b..6ee6480efa 100644 --- a/eeschema/dialogs/dialog_eeschema_options.cpp +++ b/eeschema/dialogs/dialog_eeschema_options.cpp @@ -153,7 +153,7 @@ void DIALOG_EESCHEMA_OPTIONS::SetGridSizes( const GRIDS& aGridSizes, int aGridId tmp.Printf( wxT( "%0.1f" ), aGridSizes[i].m_Size.x ); m_choiceGridSize->Append( tmp ); - if( aGridSizes[i].m_Id == aGridId ) + if( aGridSizes[i].m_CmdId == aGridId ) select = (int) i; } diff --git a/eeschema/dialogs/dialog_libedit_options.cpp b/eeschema/dialogs/dialog_libedit_options.cpp index db65d6e22c..afd85ecace 100644 --- a/eeschema/dialogs/dialog_libedit_options.cpp +++ b/eeschema/dialogs/dialog_libedit_options.cpp @@ -56,7 +56,7 @@ void DIALOG_LIBEDIT_OPTIONS::SetGridSizes( const GRIDS& grid_sizes, int grid_id tmp.Printf( wxT( "%0.1f" ), grid_sizes[i].m_Size.x ); m_choiceGridSize->Append( tmp ); - if( grid_sizes[i].m_Id == grid_id ) + if( grid_sizes[i].m_CmdId == grid_id ) select = (int) i; } diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 5c6b140b99..81a9838e16 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -316,7 +316,7 @@ void SCH_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event ) units.Add( GetUnitsLabel( MILLIMETRES ) ); dlg.SetUnits( units, g_UserUnit ); - dlg.SetGridSizes( grid_list, GetScreen()->GetGridId() ); + dlg.SetGridSizes( grid_list, GetScreen()->GetGridCmdId() ); dlg.SetBusWidth( GetDefaultBusThickness() ); dlg.SetLineWidth( GetDefaultLineThickness() ); dlg.SetTextSize( GetDefaultTextSize() ); @@ -784,7 +784,7 @@ void LIB_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event ) DIALOG_LIBEDIT_OPTIONS dlg( this ); - dlg.SetGridSizes( grid_list, GetScreen()->GetGridId() ); + dlg.SetGridSizes( grid_list, GetScreen()->GetGridCmdId() ); dlg.SetLineWidth( GetDefaultLineThickness() ); dlg.SetPinLength( GetDefaultPinLength() ); dlg.SetPinNumSize( m_textPinNumDefaultSize ); diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 285518b0cf..636350fc5d 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -337,16 +337,14 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ): SetIcon( icon ); // Initialize grid id to the default value (50 mils): - m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000; + const int default_grid = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000; + m_LastGridSizeId = default_grid; LoadSettings( config() ); - // Ensure m_LastGridSizeId is an offset inside the allowed schematic range - if( m_LastGridSizeId < ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000 ) - m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000; - - if( m_LastGridSizeId > ID_POPUP_GRID_LEVEL_1 - ID_POPUP_GRID_LEVEL_1000 ) - m_LastGridSizeId = ID_POPUP_GRID_LEVEL_1 - ID_POPUP_GRID_LEVEL_1000; + // Ensure m_LastGridSizeId is an offset inside the allowed schematic grid range + if( !GetScreen()->GridExists( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) ) + m_LastGridSizeId = default_grid; SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); diff --git a/include/class_base_screen.h b/include/class_base_screen.h index 0ea8fa9e7b..e83cf4abab 100644 --- a/include/class_base_screen.h +++ b/include/class_base_screen.h @@ -1,9 +1,9 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2011 Wayne Stambaugh - * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -35,6 +35,7 @@ #include #include #include +#include /** @@ -44,14 +45,14 @@ class GRID_TYPE { public: - int m_Id; - wxRealPoint m_Size; + int m_CmdId; // The command id of this grid ( first id is ID_POPUP_GRID_LEVEL_1000 ) + wxRealPoint m_Size; // the size in internal unit of the grid (can differ for X and Y axis) GRID_TYPE& operator=( const GRID_TYPE& item ) { if( this != &item ) { - m_Id = item.m_Id; + m_CmdId = item.m_CmdId; m_Size = item.m_Size; } @@ -60,7 +61,7 @@ public: const bool operator==( const GRID_TYPE& item ) const { - return m_Size == item.m_Size && m_Id == item.m_Id; + return m_Size == item.m_Size && m_CmdId == item.m_CmdId; } }; @@ -386,7 +387,7 @@ public: * * @return int - Currently selected grid command ID. */ - int GetGridId() const { return m_Grid.m_Id; } + int GetGridCmdId() const { return m_Grid.m_CmdId; } /** * Return the grid size of the currently selected grid. @@ -426,6 +427,14 @@ public: void AddGrid( const wxRealPoint& size, int id ); void AddGrid( const wxRealPoint& size, EDA_UNITS_T aUnit, int id ); + /** + * Function GridExists + * tests for grid command ID (not an index in grid list, but a wxID) exists in grid list. + * @param aCommandId = the wxWidgets command ID + * @return true if the grid exists in grid list. + */ + bool GridExists( int aCommandId ); + /** * Function GetGridCount(). * Return the size of the grid list. diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index cd87d1bb21..d06cc00d95 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -655,6 +655,18 @@ public: */ void SetFastGrid2(); + /** + * Virtual function SetNextGrid() + * changes the grid size settings to the next one available. + */ + void SetNextGrid(); + + /** + * Virtual function SetPrevGrid() + * changes the grid size settings to the previous one available. + */ + void SetPrevGrid(); + void ClearSelection(); DECLARE_EVENT_TABLE() diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index 5523092dba..29b746b5cf 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -83,11 +83,10 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : LoadSettings( config() ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); - if( m_LastGridSizeId < ID_POPUP_GRID_LEVEL_1MM-ID_POPUP_GRID_LEVEL_1000 ) - m_LastGridSizeId = ID_POPUP_GRID_LEVEL_1MM-ID_POPUP_GRID_LEVEL_1000; - if( m_LastGridSizeId > ID_POPUP_GRID_LEVEL_0_1MM-ID_POPUP_GRID_LEVEL_1000 ) - m_LastGridSizeId = ID_POPUP_GRID_LEVEL_0_1MM-ID_POPUP_GRID_LEVEL_1000; - GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); + if( ! GetScreen()->GridExists( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) ) + m_LastGridSizeId = ID_POPUP_GRID_LEVEL_1MM - ID_POPUP_GRID_LEVEL_1000; + + GetScreen()->SetGrid( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ); ReCreateMenuBar(); ReCreateHToolbar(); diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index 864a5545b9..6065984952 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -487,7 +487,7 @@ void PCB_BASE_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent ) for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ ) { - if( GetScreen()->GetGridId() == GetScreen()->GetGrid( i ).m_Id ) + if( GetScreen()->GetGridCmdId() == GetScreen()->GetGrid( i ).m_CmdId ) { select = (int) i; break; @@ -815,7 +815,7 @@ void PCB_BASE_FRAME::updateGridSelectBox() for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ ) { GRID_TYPE& grid = GetScreen()->GetGrid( i ); - m_gridSelectBox->Append( gridsList[i], (void*) &grid.m_Id ); + m_gridSelectBox->Append( gridsList[i], (void*) &grid.m_CmdId ); } m_gridSelectBox->SetSelection( icurr ); @@ -850,25 +850,66 @@ void PCB_BASE_FRAME::updateZoomSelectBox() void PCB_BASE_FRAME::SetFastGrid1() { + if( m_FastGrid1 >= GetScreen()->GetGridCount() ) + return; + + int cmdId = GetScreen()->GetGrids()[m_FastGrid1].m_CmdId; + SetPresetGrid( cmdId - ID_POPUP_GRID_LEVEL_1000 ); + if( m_gridSelectBox ) { - m_gridSelectBox->SetSelection( m_FastGrid1 ); - wxCommandEvent cmd( wxEVT_COMMAND_COMBOBOX_SELECTED ); cmd.SetEventObject( this ); OnSelectGrid( cmd ); } + else + GetCanvas()->Refresh(); } void PCB_BASE_FRAME::SetFastGrid2() { + if( m_FastGrid2 >= GetScreen()->GetGridCount() ) + return; + + int cmdId = GetScreen()->GetGrids()[m_FastGrid2].m_CmdId; + SetPresetGrid( cmdId - ID_POPUP_GRID_LEVEL_1000 ); + if( m_gridSelectBox ) { - m_gridSelectBox->SetSelection( m_FastGrid2 ); - wxCommandEvent cmd( wxEVT_COMMAND_COMBOBOX_SELECTED ); cmd.SetEventObject( this ); OnSelectGrid( cmd ); } + else + GetCanvas()->Refresh(); +} + +void PCB_BASE_FRAME::SetNextGrid() +{ + EDA_DRAW_FRAME::SetNextGrid(); + + if( m_gridSelectBox ) + { + wxCommandEvent cmd( wxEVT_COMMAND_COMBOBOX_SELECTED ); + cmd.SetEventObject( this ); + OnSelectGrid( cmd ); + } + else + GetCanvas()->Refresh(); +} + + +void PCB_BASE_FRAME::SetPrevGrid() +{ + EDA_DRAW_FRAME::SetPrevGrid(); + + if( m_gridSelectBox ) + { + wxCommandEvent cmd( wxEVT_COMMAND_COMBOBOX_SELECTED ); + cmd.SetEventObject( this ); + OnSelectGrid( cmd ); + } + else + GetCanvas()->Refresh(); } diff --git a/pcbnew/dialogs/dialog_set_grid.cpp b/pcbnew/dialogs/dialog_set_grid.cpp index a4e575e921..34f87d2b31 100644 --- a/pcbnew/dialogs/dialog_set_grid.cpp +++ b/pcbnew/dialogs/dialog_set_grid.cpp @@ -226,7 +226,7 @@ bool PCB_BASE_FRAME::InvokeDialogGrid() // If the user grid is the current option, recall SetGrid() // to force new values put in list as current grid value - if( screen->GetGridId() == ID_POPUP_GRID_USER ) + if( screen->GetGridCmdId() == ID_POPUP_GRID_USER ) screen->SetGrid( ID_POPUP_GRID_USER ); // Notify GAL diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp index cd68ad3415..9e55a3f638 100644 --- a/pcbnew/hotkeys_board_editor.cpp +++ b/pcbnew/hotkeys_board_editor.cpp @@ -42,6 +42,7 @@ #include #include #include +#include /* How to add a new hotkey: * see hotkeys.cpp diff --git a/pcbnew/tools/grid_menu.cpp b/pcbnew/tools/grid_menu.cpp index 94d29465f1..4d233515d8 100644 --- a/pcbnew/tools/grid_menu.cpp +++ b/pcbnew/tools/grid_menu.cpp @@ -44,7 +44,7 @@ GRID_MENU::GRID_MENU( EDA_DRAW_FRAME* aParent ) : m_parent( aParent ) for( unsigned int i = 0; i < gridsList.GetCount(); ++i ) { GRID_TYPE& grid = screen->GetGrid( i ); - Append( grid.m_Id, gridsList[i], wxEmptyString, true ); + Append( grid.m_CmdId, gridsList[i], wxEmptyString, true ); } } @@ -64,5 +64,5 @@ void GRID_MENU::Update() for( unsigned int i = 0; i < GetMenuItemCount(); ++i ) Check( ID_POPUP_GRID_SELECT + 1 + i, false ); - Check( m_parent->GetScreen()->GetGridId(), true ); + Check( m_parent->GetScreen()->GetGridCmdId(), true ); }