Fix missing user grid in COMMON_TOOLS.

Fixes https://gitlab.com/kicad/code/kicad/issues/4702
This commit is contained in:
Jeff Young 2020-06-23 11:16:34 +01:00
parent 104ff29e5f
commit 18ab3c4714
4 changed files with 14 additions and 5 deletions

View File

@ -29,7 +29,7 @@
#include <tool/tool_manager.h>
#include <tool/actions.h>
#include <tool/grid_menu.h>
#include <tool/common_tools.h>
DIALOG_GRID_SETTINGS::DIALOG_GRID_SETTINGS( EDA_DRAW_FRAME* aParent ):
DIALOG_GRID_SETTINGS_BASE( aParent ),
@ -87,8 +87,11 @@ bool DIALOG_GRID_SETTINGS::TransferDataFromWindow()
gridCfg.fast_grid_1 = m_grid1Ctrl->GetSelection();
gridCfg.fast_grid_2 = m_grid2Ctrl->GetSelection();
// Notify GAL
// Notify TOOLS
TOOL_MANAGER* mgr = m_parent->GetToolManager();
mgr->ResetTools( TOOL_BASE::MODEL_RELOAD );
// Notify GAL
mgr->RunAction( ACTIONS::gridPreset, true, gridCfg.last_size_idx );
mgr->RunAction( ACTIONS::gridSetOrigin, true, new VECTOR2D( m_parent->GetGridOrigin() ) );

View File

@ -45,14 +45,19 @@ void COMMON_TOOLS::Reset( RESET_REASON aReason )
{
m_frame = getEditFrame<EDA_DRAW_FRAME>();
GRID_SETTINGS& settings = m_toolMgr->GetSettings()->m_Window.grid;
m_grids.clear();
for( const wxString& gridDef : m_toolMgr->GetSettings()->m_Window.grid.sizes )
for( const wxString& gridDef : settings.sizes )
{
int gridSize = (int) ValueFromString( EDA_UNITS::MILLIMETRES, gridDef, true );
m_grids.emplace_back( gridSize, gridSize );
}
m_grids.emplace_back( ValueFromString( EDA_UNITS::MILLIMETRES, settings.user_grid_x, true ),
ValueFromString( EDA_UNITS::MILLIMETRES, settings.user_grid_y, true ) );
OnGridChanged();
}

View File

@ -100,6 +100,7 @@ private:
int doZoomToPreset( int idx, bool aCenterOnCursor );
std::vector<VECTOR2I> m_grids; // grids from APP_SETTINGS converted to internal units
// and with the user grid appended
};
#endif

View File

@ -279,8 +279,8 @@ bool PANEL_SETUP_NETCLASSES::TransferDataFromWindow()
m_Pcb->SynchronizeNetsAndNetClasses();
m_BrdSettings->SetCurrentNetClass( NETCLASS::Default );
if( auto toolmgr = m_Frame->GetToolManager() )
toolmgr->ResetTools( TOOL_BASE::MODEL_RELOAD );
if( m_Frame->GetToolManager() )
m_Frame->GetToolManager()->ResetTools( TOOL_BASE::MODEL_RELOAD );
return true;
}