From 3b021d98be7e14de6e2d2520b9f4974da99e0fcc Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 5 Jan 2023 12:23:03 +0000 Subject: [PATCH] Completely remove reading SCH grid sizes from config files. It messes up too many things if you put metric grids in there. Fixes https://gitlab.com/kicad/code/kicad/issues/13345 --- common/dialogs/dialog_grid_settings.cpp | 6 ++- common/dialogs/dialog_grid_settings_base.cpp | 4 +- common/dialogs/dialog_grid_settings_base.fbp | 9 +++- common/dialogs/dialog_grid_settings_base.h | 5 +- common/settings/app_settings.cpp | 22 +++++++-- eeschema/eeschema_config.cpp | 52 ++++++++++---------- 6 files changed, 60 insertions(+), 38 deletions(-) diff --git a/common/dialogs/dialog_grid_settings.cpp b/common/dialogs/dialog_grid_settings.cpp index 4d47a9b6c4..4c23800e6c 100644 --- a/common/dialogs/dialog_grid_settings.cpp +++ b/common/dialogs/dialog_grid_settings.cpp @@ -22,7 +22,6 @@ */ #include -#include #include #include #include @@ -30,6 +29,8 @@ #include #include #include +#include +#include DIALOG_GRID_SETTINGS::DIALOG_GRID_SETTINGS( EDA_DRAW_FRAME* aParent ): DIALOG_GRID_SETTINGS_BASE( aParent ), @@ -114,7 +115,8 @@ bool DIALOG_GRID_SETTINGS::TransferDataFromWindow() return false; // Apply the new settings - GRID_SETTINGS& gridCfg = m_parent->config()->m_Window.grid; + APP_SETTINGS_BASE* cfg = m_parent->config(); + GRID_SETTINGS& gridCfg = cfg->m_Window.grid; gridCfg.last_size_idx = m_currentGridCtrl->GetSelection(); m_parent->SetGridOrigin( wxPoint( m_gridOriginX.GetValue(), m_gridOriginY.GetValue() ) ); diff --git a/common/dialogs/dialog_grid_settings_base.cpp b/common/dialogs/dialog_grid_settings_base.cpp index 8ac86b9992..5ac2f33d51 100644 --- a/common/dialogs/dialog_grid_settings_base.cpp +++ b/common/dialogs/dialog_grid_settings_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -177,7 +177,7 @@ DIALOG_GRID_SETTINGS_BASE::DIALOG_GRID_SETTINGS_BASE( wxWindow* parent, wxWindow m_buttonResetSizes->Hide(); m_buttonResetSizes->SetToolTip( _("Resets the list of grid sizes to default values") ); - bButtonSizer->Add( m_buttonResetSizes, 0, wxALL, 5 ); + bButtonSizer->Add( m_buttonResetSizes, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); bButtonSizer->Add( 0, 0, 1, wxEXPAND, 5 ); diff --git a/common/dialogs/dialog_grid_settings_base.fbp b/common/dialogs/dialog_grid_settings_base.fbp index 1114681e16..8b0ae5bfd2 100644 --- a/common/dialogs/dialog_grid_settings_base.fbp +++ b/common/dialogs/dialog_grid_settings_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -14,6 +14,7 @@ dialog_grid_settings_base 1000 none + 1 dialog_grid_settings @@ -25,6 +26,7 @@ 1 1 UI + 0 0 0 @@ -50,6 +52,7 @@ DIALOG_SHIM; dialog_shim.h Grid Settings + 0 @@ -1599,6 +1602,7 @@ + 0 @@ -1661,7 +1665,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL 0 1 @@ -1672,6 +1676,7 @@ + 0 diff --git a/common/dialogs/dialog_grid_settings_base.h b/common/dialogs/dialog_grid_settings_base.h index f949202eea..058bb1b9af 100644 --- a/common/dialogs/dialog_grid_settings_base.h +++ b/common/dialogs/dialog_grid_settings_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -24,10 +24,10 @@ #include #include #include +#include #include #include #include -#include #include /////////////////////////////////////////////////////////////////////////// @@ -78,6 +78,7 @@ class DIALOG_GRID_SETTINGS_BASE : public DIALOG_SHIM public: DIALOG_GRID_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Grid Settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE ); + ~DIALOG_GRID_SETTINGS_BASE(); }; diff --git a/common/settings/app_settings.cpp b/common/settings/app_settings.cpp index 67b4ba5ae2..e22795f7e3 100644 --- a/common/settings/app_settings.cpp +++ b/common/settings/app_settings.cpp @@ -27,7 +27,6 @@ #include #include #include -#include APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaVersion ) : @@ -316,16 +315,29 @@ void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std: m_params.emplace_back( new PARAM( aJsonPath + ".grid.axes_enabled", &aWindow->grid.axes_enabled, false ) ); - m_params.emplace_back( new PARAM_LIST( aJsonPath + ".grid.sizes", - &aWindow->grid.sizes, DefaultGridSizeList() ) ); - int defaultGridIdx; - if( m_filename == "eeschema" || m_filename == "symbol_editor" || m_filename == "pl_editor" ) + if( m_filename == "pl_editor" ) + { defaultGridIdx = 1; + + m_params.emplace_back( new PARAM_LIST( aJsonPath + ".grid.sizes", + &aWindow->grid.sizes, DefaultGridSizeList() ) ); + } + else if( m_filename == "eeschema" || m_filename == "symbol_editor" ) + { + defaultGridIdx = 1; + + // Eeschema's grids are fixed to keep wires/pins connected + } else + { defaultGridIdx = 4; + m_params.emplace_back( new PARAM_LIST( aJsonPath + ".grid.sizes", + &aWindow->grid.sizes, DefaultGridSizeList() ) ); + } + m_params.emplace_back( new PARAM( aJsonPath + ".grid.last_size", &aWindow->grid.last_size_idx, defaultGridIdx ) ); diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 2e09931c88..bdbb2b7ca1 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -188,32 +188,34 @@ void SCH_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) EDA_DRAW_FRAME::LoadSettings( aCfg ); - // Currently values read from config file are not used because the user cannot - // change this config - // if( aCfg->m_Window.grid.sizes.empty() ) // Will be probably never enabled - { - /* - * Do NOT add others values (mainly grid values in mm), because they can break the - * schematic: Because wires and pins are considered as connected when the are to the - * same coordinate we cannot mix coordinates in mils (internal units) and mm (that - * cannot exactly converted in mils in many cases). In fact schematic must only use - * 50 and 25 mils to place labels, wires and symbols others values are useful only - * for graphic items (mainly in library editor) so use integer values in mils only. - * The 100 mil grid is added to help conform to the KiCad Library Convention which - * states: "Using a 100mil grid, pin ends and origin must lie on grid nodes IEC-60617" - */ - aCfg->m_Window.grid.sizes = { "100 mil", - "50 mil", - "25 mil", - "10 mil", - "5 mil", - "2 mil", - "1 mil" }; - } + /* + * Do NOT add other values (particularly grid values in mm), because they can break the + * schematic: Because wires and pins are considered as connected when the are to the same + * coordinate we cannot mix coordinates in mils (internal units) and mm (that cannot exactly + * converted in mils in many cases). In fact schematic must only use 50 and 25 mils to + * place labels, wires and symbols others values are useful only for graphic items (mainly + * in library editor) so use integer values in mils only. + * The 100 mil grid is added to help conform to the KiCad Library Convention which states: + * "Using a 100mil grid, pin ends and origin must lie on grid nodes IEC-60617" + */ + aCfg->m_Window.grid.sizes = { "100 mil", + "50 mil", + "25 mil", + "10 mil", + "5 mil", + "2 mil", + "1 mil" }; - // Currently values read from config file are not used because the user cannot - // change this config - // if( aCfg->m_Window.zoom_factors.empty() ) + if( aCfg->m_Window.grid.last_size_idx > (int) aCfg->m_Window.grid.sizes.size() ) + aCfg->m_Window.grid.last_size_idx = 1; + + if( aCfg->m_Window.grid.fast_grid_1 > (int) aCfg->m_Window.grid.sizes.size() ) + aCfg->m_Window.grid.fast_grid_1 = 1; + + if( aCfg->m_Window.grid.fast_grid_2 > (int) aCfg->m_Window.grid.sizes.size() ) + aCfg->m_Window.grid.fast_grid_2 = 2; + + if( aCfg->m_Window.zoom_factors.empty() ) { aCfg->m_Window.zoom_factors = { ZOOM_LIST_EESCHEMA }; }