From 6541202d427401ef9ffff87c2d7c1840dd6ac337 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 15 Jul 2025 15:22:18 +0100 Subject: [PATCH] Repair COMMON_TOOLS to know about frame-specific WINDOW_SETTINGS Remove the older architectures for ensuring non-empty grids and zooms Move new architecture to PARAM_LIST::Load, and add zoom support Fixes https://gitlab.com/kicad/code/kicad/-/issues/21318 --- common/settings/app_settings.cpp | 69 ++++++++++++++++++++++++--- common/tool/common_tools.cpp | 47 ++++++++---------- eeschema/eeschema_config.cpp | 7 --- gerbview/gerbview_frame.cpp | 38 +-------------- include/settings/app_settings.h | 2 + include/settings/parameters.h | 30 +++++++----- pagelayout_editor/pl_editor_frame.cpp | 20 -------- pcbnew/footprint_chooser_frame.cpp | 10 ++-- pcbnew/footprint_preview_panel.cpp | 14 ------ pcbnew/pcb_base_frame.cpp | 14 ------ 10 files changed, 112 insertions(+), 139 deletions(-) diff --git a/common/settings/app_settings.cpp b/common/settings/app_settings.cpp index e3a13936ce..6051f77500 100644 --- a/common/settings/app_settings.cpp +++ b/common/settings/app_settings.cpp @@ -29,6 +29,7 @@ #include #include #include +#include APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaVersion ) : @@ -432,7 +433,7 @@ void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std: &aWindow->state.display, 0 ) ); m_params.emplace_back( new PARAM_LIST( aJsonPath + ".zoom_factors", - &aWindow->zoom_factors, {} ) ); + &aWindow->zoom_factors, DefaultZoomList(), true /* resetIfEmpty */ ) ); m_params.emplace_back( new PARAM( aJsonPath + ".grid.axes_enabled", &aWindow->grid.axes_enabled, false ) ); @@ -453,11 +454,7 @@ void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std: } m_params.emplace_back( new PARAM_LIST( aJsonPath + ".grid.sizes", &aWindow->grid.grids, - DefaultGridSizeList() ) ); - - // Force grids to have at least 1 entry. If not, reset to default. - if( aWindow->grid.grids.empty() ) - aWindow->grid.grids = DefaultGridSizeList(); + DefaultGridSizeList(), true /* resetIfEmpty */ ) ); m_params.emplace_back( new PARAM( aJsonPath + ".grid.last_size", &aWindow->grid.last_size_idx, defaultGridIdx ) ); @@ -551,6 +548,30 @@ void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std: } +const std::vector APP_SETTINGS_BASE::DefaultZoomList() const +{ + if( m_filename == wxS( "eeschema" ) || m_filename == wxS( "symbol_editor" ) ) + { + return { ZOOM_LIST_EESCHEMA }; + } + else if( m_filename == wxS( "pl_editor" ) ) + { + return { ZOOM_LIST_PL_EDITOR }; + } + else if( m_filename == wxS( "gerbview" ) ) + { + return { ZOOM_LIST_GERBVIEW }; + } + else + { + if( ADVANCED_CFG::GetCfg().m_HyperZoom ) + return { ZOOM_LIST_PCBNEW_HYPER }; + else + return { ZOOM_LIST_PCBNEW }; + } +} + + const std::vector APP_SETTINGS_BASE::DefaultGridSizeList() const { if( m_filename == wxS( "eeschema" ) || m_filename == wxS( "symbol_editor" ) ) @@ -560,6 +581,42 @@ const std::vector APP_SETTINGS_BASE::DefaultGridSizeList() const GRID{ wxEmptyString, wxS( "25 mil" ), wxS( "25 mil" ) }, GRID{ wxEmptyString, wxS( "10 mil" ), wxS( "10 mil" ) } }; } + else if( m_filename == wxS( "pl_editor" ) ) + { + return { GRID{ wxEmptyString, wxS( "5.00 mm" ), wxS( "5.00 mm" ) }, + GRID{ wxEmptyString, wxS( "2.50 mm" ), wxS( "2.50 mm" ) }, + GRID{ wxEmptyString, wxS( "2.00 mm" ), wxS( "2.00 mm" ) }, + GRID{ wxEmptyString, wxS( "1.00 mm" ), wxS( "1.00 mm" ) }, + GRID{ wxEmptyString, wxS( "0.50 mm" ), wxS( "0.50 mm" ) }, + GRID{ wxEmptyString, wxS( "0.25 mm" ), wxS( "0.25 mm" ) }, + GRID{ wxEmptyString, wxS( "0.20 mm" ), wxS( "0.20 mm" ) }, + GRID{ wxEmptyString, wxS( "0.10 mm" ), wxS( "0.10 mm" ) } }; + } + else if( m_filename == wxS( "gerbview" ) ) + { + return { GRID{ wxEmptyString, wxS( "100 mil" ), wxS( "100 mil" ) }, + GRID{ wxEmptyString, wxS( "50 mil" ), wxS( "50 mil" ) }, + GRID{ wxEmptyString, wxS( "25 mil" ), wxS( "25 mil" ) }, + GRID{ wxEmptyString, wxS( "20 mil" ), wxS( "20 mil" ) }, + GRID{ wxEmptyString, wxS( "10 mil" ), wxS( "10 mil" ) }, + GRID{ wxEmptyString, wxS( "5 mil" ), wxS( "5 mil" ) }, + GRID{ wxEmptyString, wxS( "2.5 mil" ), wxS( "2.5 mil" ) }, + GRID{ wxEmptyString, wxS( "2 mil" ), wxS( "2 mil" ) }, + GRID{ wxEmptyString, wxS( "1 mil" ), wxS( "1 mil" ) }, + GRID{ wxEmptyString, wxS( "0.5 mil" ), wxS( "0.5 mil" ) }, + GRID{ wxEmptyString, wxS( "0.2 mil" ), wxS( "0.2 mil" ) }, + GRID{ wxEmptyString, wxS( "0.1 mil" ), wxS( "0.1 mil" ) }, + GRID{ wxEmptyString, wxS( "5.0 mm" ), wxS( "5.0 mm" ) }, + GRID{ wxEmptyString, wxS( "1.5 mm" ), wxS( "2.5 mm" ) }, + GRID{ wxEmptyString, wxS( "1.0 mm" ), wxS( "1.0 mm" ) }, + GRID{ wxEmptyString, wxS( "0.5 mm" ), wxS( "0.5 mm" ) }, + GRID{ wxEmptyString, wxS( "0.25 mm" ), wxS( "0.25 mm" ) }, + GRID{ wxEmptyString, wxS( "0.2 mm" ), wxS( "0.2 mm" ) }, + GRID{ wxEmptyString, wxS( "0.1 mm" ), wxS( "0.1 mm" ) }, + GRID{ wxEmptyString, wxS( "0.05 mm" ), wxS( "0.0 mm" ) }, + GRID{ wxEmptyString, wxS( "0.025 mm" ), wxS( "0.0 mm" ) }, + GRID{ wxEmptyString, wxS( "0.01 mm" ), wxS( "0.0 mm" ) } }; + } else { return { GRID{ wxEmptyString, wxS( "1000 mil" ), wxS( "1000 mil" ) }, diff --git a/common/tool/common_tools.cpp b/common/tool/common_tools.cpp index 179e88a3a9..a6531a72c8 100644 --- a/common/tool/common_tools.cpp +++ b/common/tool/common_tools.cpp @@ -64,18 +64,15 @@ void COMMON_TOOLS::Reset( RESET_REASON aReason ) if( aReason == RESET_REASON::SHUTDOWN ) return; - GRID_SETTINGS& settings = m_toolMgr->GetSettings()->m_Window.grid; + GRID_SETTINGS& settings = m_frame->GetWindowSettings( m_toolMgr->GetSettings() )->grid; EDA_IU_SCALE scale = m_frame->GetIuScale(); for( GRID& gridDef : settings.grids ) { - double gridSizeX = EDA_UNIT_UTILS::UI::DoubleValueFromString( scale, EDA_UNITS::MM, - gridDef.x ); - double gridSizeY = EDA_UNIT_UTILS::UI::DoubleValueFromString( scale, EDA_UNITS::MM, - gridDef.y ); + double gridSizeX = EDA_UNIT_UTILS::UI::DoubleValueFromString( scale, EDA_UNITS::MM, gridDef.x ); + double gridSizeY = EDA_UNIT_UTILS::UI::DoubleValueFromString( scale, EDA_UNITS::MM, gridDef.y ); - m_grids.emplace_back( KiROUND( gridSizeX ), - KiROUND( gridSizeY ) ); + m_grids.emplace_back( KiROUND( gridSizeX ), KiROUND( gridSizeY ) ); } OnGridChanged( false ); @@ -251,7 +248,7 @@ int COMMON_TOOLS::doZoomInOut( bool aDirection, bool aCenterOnCursor ) zoom /= 1.3; // Now look for the next closest menu step - std::vector& zoomList = m_toolMgr->GetSettings()->m_Window.zoom_factors; + std::vector& zoomList = m_frame->GetWindowSettings( m_toolMgr->GetSettings() )->zoom_factors; int idx; if( aDirection ) @@ -458,13 +455,7 @@ int COMMON_TOOLS::ZoomPreset( const TOOL_EVENT& aEvent ) // Note: idx == 0 is Auto; idx == 1 is first entry in zoomList int COMMON_TOOLS::doZoomToPreset( int idx, bool aCenterOnCursor ) { - std::vector& zoomList = m_toolMgr->GetSettings()->m_Window.zoom_factors; - - if( zoomList.empty() ) // When called from footprint chooser, zoomList is empty for some reason - zoomList = m_frame->config()->m_Window.zoom_factors; - // or: zoomList = Kiface().KifaceSettings()->m_Window.zoom_factors; - - wxCHECK( !zoomList.empty(), 0 ); // To avoid a crash lower on scale from Fp Chooser panel + std::vector& zoomList = m_frame->GetWindowSettings( m_toolMgr->GetSettings() )->zoom_factors; if( idx == 0 ) // Zoom Auto { @@ -498,7 +489,7 @@ int COMMON_TOOLS::doZoomToPreset( int idx, bool aCenterOnCursor ) int COMMON_TOOLS::GridNext( const TOOL_EVENT& aEvent ) { - int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx; + int& currentGrid = m_frame->GetWindowSettings( m_toolMgr->GetSettings() )->grid.last_size_idx; currentGrid++; @@ -511,7 +502,7 @@ int COMMON_TOOLS::GridNext( const TOOL_EVENT& aEvent ) int COMMON_TOOLS::GridPrev( const TOOL_EVENT& aEvent ) { - int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx; + int& currentGrid = m_frame->GetWindowSettings( m_toolMgr->GetSettings() )->grid.last_size_idx; currentGrid--; @@ -530,7 +521,7 @@ int COMMON_TOOLS::GridPreset( const TOOL_EVENT& aEvent ) int COMMON_TOOLS::GridPreset( int idx, bool aFromHotkey ) { - int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx; + int& currentGrid = m_frame->GetWindowSettings( m_toolMgr->GetSettings() )->grid.last_size_idx; currentGrid = std::clamp( idx, 0, (int) m_grids.size() - 1 ); @@ -540,7 +531,7 @@ int COMMON_TOOLS::GridPreset( int idx, bool aFromHotkey ) int COMMON_TOOLS::OnGridChanged( bool aFromHotkey ) { - int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx; + int& currentGrid = m_frame->GetWindowSettings( m_toolMgr->GetSettings() )->grid.last_size_idx; currentGrid = std::max( 0, std::min( currentGrid, static_cast( m_grids.size() ) - 1 ) ); @@ -550,7 +541,7 @@ int COMMON_TOOLS::OnGridChanged( bool aFromHotkey ) // Update GAL canvas from screen getView()->GetGAL()->SetGridSize( m_grids[ currentGrid ] ); - getView()->GetGAL()->SetGridVisibility( m_toolMgr->GetSettings()->m_Window.grid.show ); + getView()->GetGAL()->SetGridVisibility( m_frame->GetWindowSettings( m_toolMgr->GetSettings() )->grid.show ); getView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); // Put cursor on new grid @@ -567,25 +558,25 @@ int COMMON_TOOLS::OnGridChanged( bool aFromHotkey ) int COMMON_TOOLS::GridFast1( const TOOL_EVENT& aEvent ) { - return GridPreset( m_frame->config()->m_Window.grid.fast_grid_1, true ); + return GridPreset( m_frame->GetWindowSettings( m_toolMgr->GetSettings() )->grid.fast_grid_1, true ); } int COMMON_TOOLS::GridFast2( const TOOL_EVENT& aEvent ) { - return GridPreset( m_frame->config()->m_Window.grid.fast_grid_2, true ); + return GridPreset( m_frame->GetWindowSettings( m_toolMgr->GetSettings() )->grid.fast_grid_2, true ); } int COMMON_TOOLS::GridFastCycle( const TOOL_EVENT& aEvent ) { - if( m_toolMgr->GetSettings()->m_Window.grid.last_size_idx - == m_frame->config()->m_Window.grid.fast_grid_1 ) + if( m_frame->GetWindowSettings( m_toolMgr->GetSettings() )->grid.last_size_idx + == m_frame->GetWindowSettings( m_toolMgr->GetSettings() )->grid.fast_grid_1 ) { - return GridPreset( m_frame->config()->m_Window.grid.fast_grid_2, true ); + return GridPreset( m_frame->GetWindowSettings( m_toolMgr->GetSettings() )->grid.fast_grid_2, true ); } - return GridPreset( m_frame->config()->m_Window.grid.fast_grid_1, true ); + return GridPreset( m_frame->GetWindowSettings( m_toolMgr->GetSettings() )->grid.fast_grid_1, true ); } @@ -707,7 +698,7 @@ int COMMON_TOOLS::ToggleCursor( const TOOL_EVENT& aEvent ) auto& galOpts = m_frame->GetGalDisplayOptions(); galOpts.m_forceDisplayCursor = !galOpts.m_forceDisplayCursor; - galOpts.WriteConfig( m_toolMgr->GetSettings()->m_Window ); + galOpts.WriteConfig( *m_frame->GetWindowSettings( m_toolMgr->GetSettings() ) ); galOpts.NotifyChanged(); return 0; @@ -719,7 +710,7 @@ int COMMON_TOOLS::ToggleCursorStyle( const TOOL_EVENT& aEvent ) GAL_DISPLAY_OPTIONS_IMPL& galOpts = m_frame->GetGalDisplayOptions(); galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor; - galOpts.WriteConfig( m_toolMgr->GetSettings()->m_Window ); + galOpts.WriteConfig( *m_frame->GetWindowSettings( m_toolMgr->GetSettings() ) ); galOpts.NotifyChanged(); return 0; diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 762b4403b6..8963c6db46 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include @@ -357,9 +356,6 @@ void SCH_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) EDA_DRAW_FRAME::LoadSettings( aCfg ); - if( aCfg->m_Window.grid.grids.empty() ) - aCfg->m_Window.grid.grids = aCfg->DefaultGridSizeList(); - // Move legacy user grids to grid list if( !aCfg->m_Window.grid.user_grid_x.empty() ) { @@ -378,9 +374,6 @@ void SCH_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) if( aCfg->m_Window.grid.fast_grid_2 > (int) aCfg->m_Window.grid.grids.size() ) aCfg->m_Window.grid.fast_grid_2 = 2; - - if( aCfg->m_Window.zoom_factors.empty() ) - aCfg->m_Window.zoom_factors = { ZOOM_LIST_EESCHEMA }; } diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 7db3aba93b..0a4ea36e10 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -58,7 +58,6 @@ #include "widgets/gerbview_layer_widget.h" #include "widgets/dcode_selection_box.h" #include -#include #include #include @@ -317,44 +316,11 @@ void GERBVIEW_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) { EDA_DRAW_FRAME::LoadSettings( aCfg ); - if( aCfg->m_Window.grid.grids.empty() ) - { - aCfg->m_Window.grid.grids = { GRID{ wxEmptyString, wxS( "100 mil" ), wxS( "100 mil" ) }, - GRID{ wxEmptyString, wxS( "50 mil" ), wxS( "50 mil" ) }, - GRID{ wxEmptyString, wxS( "25 mil" ), wxS( "25 mil" ) }, - GRID{ wxEmptyString, wxS( "20 mil" ), wxS( "20 mil" ) }, - GRID{ wxEmptyString, wxS( "10 mil" ), wxS( "10 mil" ) }, - GRID{ wxEmptyString, wxS( "5 mil" ), wxS( "5 mil" ) }, - GRID{ wxEmptyString, wxS( "2.5 mil" ), wxS( "2.5 mil" ) }, - GRID{ wxEmptyString, wxS( "2 mil" ), wxS( "2 mil" ) }, - GRID{ wxEmptyString, wxS( "1 mil" ), wxS( "1 mil" ) }, - GRID{ wxEmptyString, wxS( "0.5 mil" ), wxS( "0.5 mil" ) }, - GRID{ wxEmptyString, wxS( "0.2 mil" ), wxS( "0.2 mil" ) }, - GRID{ wxEmptyString, wxS( "0.1 mil" ), wxS( "0.1 mil" ) }, - GRID{ wxEmptyString, wxS( "5.0 mm" ), wxS( "5.0 mm" ) }, - GRID{ wxEmptyString, wxS( "1.5 mm" ), wxS( "2.5 mm" ) }, - GRID{ wxEmptyString, wxS( "1.0 mm" ), wxS( "1.0 mm" ) }, - GRID{ wxEmptyString, wxS( "0.5 mm" ), wxS( "0.5 mm" ) }, - GRID{ wxEmptyString, wxS( "0.25 mm" ), wxS( "0.25 mm" ) }, - GRID{ wxEmptyString, wxS( "0.2 mm" ), wxS( "0.2 mm" ) }, - GRID{ wxEmptyString, wxS( "0.1 mm" ), wxS( "0.1 mm" ) }, - GRID{ wxEmptyString, wxS( "0.05 mm" ), wxS( "0.0 mm" ) }, - GRID{ wxEmptyString, wxS( "0.025 mm" ), wxS( "0.0 mm" ) }, - GRID{ wxEmptyString, wxS( "0.01 mm" ), wxS( "0.0 mm" ) } }; - } - - if( aCfg->m_Window.zoom_factors.empty() ) - { - aCfg->m_Window.zoom_factors = { ZOOM_LIST_GERBVIEW }; - } - GERBVIEW_SETTINGS* cfg = dynamic_cast( aCfg ); wxCHECK( cfg, /*void*/ ); - SetElementVisibility( LAYER_GERBVIEW_DRAWINGSHEET, - cfg->m_Appearance.show_border_and_titleblock ); - SetElementVisibility( LAYER_GERBVIEW_PAGE_LIMITS, - cfg->m_Display.m_DisplayPageLimits ); + SetElementVisibility( LAYER_GERBVIEW_DRAWINGSHEET, cfg->m_Appearance.show_border_and_titleblock ); + SetElementVisibility( LAYER_GERBVIEW_PAGE_LIMITS, cfg->m_Display.m_DisplayPageLimits ); PAGE_INFO pageInfo( wxT( "GERBER" ) ); pageInfo.SetType( cfg->m_Appearance.page_type ); diff --git a/include/settings/app_settings.h b/include/settings/app_settings.h index 54698093d9..464d81980f 100644 --- a/include/settings/app_settings.h +++ b/include/settings/app_settings.h @@ -208,6 +208,8 @@ public: const std::vector DefaultGridSizeList() const; + const std::vector DefaultZoomList() const; + public: CROSS_PROBING_SETTINGS m_CrossProbing; diff --git a/include/settings/parameters.h b/include/settings/parameters.h index 2129e5b9f1..fdffdb3cce 100644 --- a/include/settings/parameters.h +++ b/include/settings/parameters.h @@ -476,17 +476,19 @@ class PARAM_LIST : public PARAM_BASE { public: PARAM_LIST( const std::string& aJsonPath, std::vector* aPtr, - std::initializer_list aDefault, bool aReadOnly = false ) : - PARAM_BASE( aJsonPath, aReadOnly ), + std::initializer_list aDefault, bool aResetIfEmpty = false ) : + PARAM_BASE( aJsonPath, false ), m_ptr( aPtr ), - m_default( aDefault ) + m_default( aDefault ), + m_resetIfEmpty( aResetIfEmpty ) { } PARAM_LIST( const std::string& aJsonPath, std::vector* aPtr, - std::vector aDefault, bool aReadOnly = false ) : - PARAM_BASE( aJsonPath, aReadOnly ), + std::vector aDefault, bool aResetIfEmpty = false ) : + PARAM_BASE( aJsonPath, false ), m_ptr( aPtr ), - m_default( std::move( aDefault ) ) + m_default( std::move( aDefault ) ), + m_resetIfEmpty( aResetIfEmpty ) { } void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override @@ -504,10 +506,15 @@ public: val.push_back( el.value().get() ); } - *m_ptr = val; + if( val.empty() && m_resetIfEmpty ) + *m_ptr = m_default; + else + *m_ptr = val; } else if( aResetIfMissing ) + { *m_ptr = m_default; + } } void Store( JSON_SETTINGS* aSettings ) const override @@ -555,6 +562,7 @@ public: protected: std::vector* m_ptr; std::vector m_default; + bool m_resetIfEmpty; }; @@ -667,13 +675,13 @@ class KICOMMON_API PARAM_PATH_LIST : public PARAM_LIST { public: PARAM_PATH_LIST( const std::string& aJsonPath, std::vector* aPtr, - std::initializer_list aDefault, bool aReadOnly = false ) : - PARAM_LIST( aJsonPath, aPtr, aDefault, aReadOnly ) + std::initializer_list aDefault ) : + PARAM_LIST( aJsonPath, aPtr, aDefault ) { } PARAM_PATH_LIST( const std::string& aJsonPath, std::vector* aPtr, - std::vector aDefault, bool aReadOnly = false ) : - PARAM_LIST( aJsonPath, aPtr, aDefault, aReadOnly ) + std::vector aDefault ) : + PARAM_LIST( aJsonPath, aPtr, aDefault ) { } void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index 829d0c087c..3ec5844bbc 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -58,7 +58,6 @@ #include "invoke_pl_editor_dialog.h" #include "tools/pl_editor_control.h" #include -#include #include #include @@ -518,25 +517,6 @@ void PL_EDITOR_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) { EDA_DRAW_FRAME::LoadSettings( aCfg ); - if( aCfg->m_Window.grid.grids.empty() ) - { - aCfg->m_Window.grid.grids = { GRID{ wxEmptyString, wxS( "5.00 mm" ), wxS( "5.00 mm" ) }, - GRID{ wxEmptyString, wxS( "2.50 mm" ), wxS( "2.50 mm" ) }, - GRID{ wxEmptyString, wxS( "2.00 mm" ), wxS( "2.00 mm" ) }, - GRID{ wxEmptyString, wxS( "1.00 mm" ), wxS( "1.00 mm" ) }, - GRID{ wxEmptyString, wxS( "0.50 mm" ), wxS( "0.50 mm" ) }, - GRID{ wxEmptyString, wxS( "0.25 mm" ), wxS( "0.25 mm" ) }, - GRID{ wxEmptyString, wxS( "0.20 mm" ), wxS( "0.20 mm" ) }, - GRID{ wxEmptyString, wxS( "0.10 mm" ), wxS( "0.10 mm" ) } }; - } - - // Currently values read from config file are not used because the user cannot - // change this config - // if( aCfg->m_Window.zoom_factors.empty() ) - { - aCfg->m_Window.zoom_factors = { ZOOM_LIST_PL_EDITOR }; - } - PL_EDITOR_SETTINGS* cfg = dynamic_cast( aCfg ); wxCHECK( cfg, /*void*/ ); diff --git a/pcbnew/footprint_chooser_frame.cpp b/pcbnew/footprint_chooser_frame.cpp index 75b25a446b..e576b64d41 100644 --- a/pcbnew/footprint_chooser_frame.cpp +++ b/pcbnew/footprint_chooser_frame.cpp @@ -44,6 +44,7 @@ #include #include #include +#include "settings/cvpcb_settings.h" #include "wx/display.h" #include #include <3d_canvas/eda_3d_canvas.h> @@ -437,10 +438,13 @@ void FOOTPRINT_CHOOSER_FRAME::doCloseWindow() WINDOW_SETTINGS* FOOTPRINT_CHOOSER_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg ) { - PCBNEW_SETTINGS* cfg = dynamic_cast( aCfg ); - wxCHECK_MSG( cfg, nullptr, wxT( "config not existing" ) ); + if( PCBNEW_SETTINGS* pcb_cfg = dynamic_cast( aCfg ) ) + return &pcb_cfg->m_FootprintViewer; + else if( CVPCB_SETTINGS* cvpcb_cfg = dynamic_cast( aCfg ) ) + return &cvpcb_cfg->m_FootprintViewer; - return &cfg->m_FootprintViewer; + wxFAIL_MSG( wxT( "FOOTPRINT_CHOOSER not running with PCBNEW_SETTINGS or CVPCB_SETTINGS" ) ); + return &aCfg->m_Window; // non-null fail-safe } diff --git a/pcbnew/footprint_preview_panel.cpp b/pcbnew/footprint_preview_panel.cpp index 0e58e337a1..f4db7553ec 100644 --- a/pcbnew/footprint_preview_panel.cpp +++ b/pcbnew/footprint_preview_panel.cpp @@ -43,7 +43,6 @@ #include #include #include -#include #include #include @@ -243,19 +242,6 @@ FOOTPRINT_PREVIEW_PANEL* FOOTPRINT_PREVIEW_PANEL::New( KIWAY* aKiway, wxWindow* { PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings( "pcbnew" ); - if( cfg->m_Window.grid.grids.empty() ) - cfg->m_Window.grid.grids = cfg->DefaultGridSizeList(); - - // Currently values read from config file are not used because the user cannot - // change this config - //if( cfg->m_Window.zoom_factors.empty() ) - { - if( ADVANCED_CFG::GetCfg().m_HyperZoom ) - cfg->m_Window.zoom_factors = { ZOOM_LIST_PCBNEW_HYPER }; - else - cfg->m_Window.zoom_factors = { ZOOM_LIST_PCBNEW }; - } - std::unique_ptr gal_opts; gal_opts = std::make_unique(); diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index 5d2f45bac4..d38fbe3234 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -53,7 +53,6 @@ #include #include #include -#include #include #include @@ -814,9 +813,6 @@ void PCB_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) { EDA_DRAW_FRAME::LoadSettings( aCfg ); - if( aCfg->m_Window.grid.grids.empty() ) - aCfg->m_Window.grid.grids = aCfg->DefaultGridSizeList(); - // Move legacy user grids to grid list if( !aCfg->m_Window.grid.user_grid_x.empty() ) { @@ -826,16 +822,6 @@ void PCB_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) aCfg->m_Window.grid.user_grid_y = wxEmptyString; } - // Currently values read from config file are not used because the user cannot - // change this config - // if( aCfg->m_Window.zoom_factors.empty() ) - { - if( ADVANCED_CFG::GetCfg().m_HyperZoom ) - aCfg->m_Window.zoom_factors = { ZOOM_LIST_PCBNEW_HYPER }; - else - aCfg->m_Window.zoom_factors = { ZOOM_LIST_PCBNEW }; - } - // Some, but not all, derived classes have a PCBNEW_SETTINGS. if( PCBNEW_SETTINGS* pcbnew_cfg = dynamic_cast( aCfg ) ) m_polarCoords = pcbnew_cfg->m_PolarCoords;