mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
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
This commit is contained in:
parent
486522e0b4
commit
6541202d42
@ -29,6 +29,7 @@
|
|||||||
#include <settings/common_settings.h>
|
#include <settings/common_settings.h>
|
||||||
#include <settings/grid_settings.h>
|
#include <settings/grid_settings.h>
|
||||||
#include <settings/parameters.h>
|
#include <settings/parameters.h>
|
||||||
|
#include <zoom_defines.h>
|
||||||
|
|
||||||
|
|
||||||
APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaVersion ) :
|
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 ) );
|
&aWindow->state.display, 0 ) );
|
||||||
|
|
||||||
m_params.emplace_back( new PARAM_LIST<double>( aJsonPath + ".zoom_factors",
|
m_params.emplace_back( new PARAM_LIST<double>( aJsonPath + ".zoom_factors",
|
||||||
&aWindow->zoom_factors, {} ) );
|
&aWindow->zoom_factors, DefaultZoomList(), true /* resetIfEmpty */ ) );
|
||||||
|
|
||||||
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.axes_enabled",
|
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.axes_enabled",
|
||||||
&aWindow->grid.axes_enabled, false ) );
|
&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<GRID>( aJsonPath + ".grid.sizes", &aWindow->grid.grids,
|
m_params.emplace_back( new PARAM_LIST<GRID>( aJsonPath + ".grid.sizes", &aWindow->grid.grids,
|
||||||
DefaultGridSizeList() ) );
|
DefaultGridSizeList(), true /* resetIfEmpty */ ) );
|
||||||
|
|
||||||
// Force grids to have at least 1 entry. If not, reset to default.
|
|
||||||
if( aWindow->grid.grids.empty() )
|
|
||||||
aWindow->grid.grids = DefaultGridSizeList();
|
|
||||||
|
|
||||||
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.last_size",
|
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.last_size",
|
||||||
&aWindow->grid.last_size_idx, defaultGridIdx ) );
|
&aWindow->grid.last_size_idx, defaultGridIdx ) );
|
||||||
@ -551,6 +548,30 @@ void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const std::vector<double> 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<GRID> APP_SETTINGS_BASE::DefaultGridSizeList() const
|
const std::vector<GRID> APP_SETTINGS_BASE::DefaultGridSizeList() const
|
||||||
{
|
{
|
||||||
if( m_filename == wxS( "eeschema" ) || m_filename == wxS( "symbol_editor" ) )
|
if( m_filename == wxS( "eeschema" ) || m_filename == wxS( "symbol_editor" ) )
|
||||||
@ -560,6 +581,42 @@ const std::vector<GRID> APP_SETTINGS_BASE::DefaultGridSizeList() const
|
|||||||
GRID{ wxEmptyString, wxS( "25 mil" ), wxS( "25 mil" ) },
|
GRID{ wxEmptyString, wxS( "25 mil" ), wxS( "25 mil" ) },
|
||||||
GRID{ wxEmptyString, wxS( "10 mil" ), wxS( "10 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
|
else
|
||||||
{
|
{
|
||||||
return { GRID{ wxEmptyString, wxS( "1000 mil" ), wxS( "1000 mil" ) },
|
return { GRID{ wxEmptyString, wxS( "1000 mil" ), wxS( "1000 mil" ) },
|
||||||
|
@ -64,18 +64,15 @@ void COMMON_TOOLS::Reset( RESET_REASON aReason )
|
|||||||
if( aReason == RESET_REASON::SHUTDOWN )
|
if( aReason == RESET_REASON::SHUTDOWN )
|
||||||
return;
|
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();
|
EDA_IU_SCALE scale = m_frame->GetIuScale();
|
||||||
|
|
||||||
for( GRID& gridDef : settings.grids )
|
for( GRID& gridDef : settings.grids )
|
||||||
{
|
{
|
||||||
double gridSizeX = EDA_UNIT_UTILS::UI::DoubleValueFromString( scale, EDA_UNITS::MM,
|
double gridSizeX = EDA_UNIT_UTILS::UI::DoubleValueFromString( scale, EDA_UNITS::MM, gridDef.x );
|
||||||
gridDef.x );
|
double gridSizeY = EDA_UNIT_UTILS::UI::DoubleValueFromString( scale, EDA_UNITS::MM, gridDef.y );
|
||||||
double gridSizeY = EDA_UNIT_UTILS::UI::DoubleValueFromString( scale, EDA_UNITS::MM,
|
|
||||||
gridDef.y );
|
|
||||||
|
|
||||||
m_grids.emplace_back( KiROUND<double, int>( gridSizeX ),
|
m_grids.emplace_back( KiROUND<double, int>( gridSizeX ), KiROUND<double, int>( gridSizeY ) );
|
||||||
KiROUND<double, int>( gridSizeY ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OnGridChanged( false );
|
OnGridChanged( false );
|
||||||
@ -251,7 +248,7 @@ int COMMON_TOOLS::doZoomInOut( bool aDirection, bool aCenterOnCursor )
|
|||||||
zoom /= 1.3;
|
zoom /= 1.3;
|
||||||
|
|
||||||
// Now look for the next closest menu step
|
// Now look for the next closest menu step
|
||||||
std::vector<double>& zoomList = m_toolMgr->GetSettings()->m_Window.zoom_factors;
|
std::vector<double>& zoomList = m_frame->GetWindowSettings( m_toolMgr->GetSettings() )->zoom_factors;
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
if( aDirection )
|
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
|
// Note: idx == 0 is Auto; idx == 1 is first entry in zoomList
|
||||||
int COMMON_TOOLS::doZoomToPreset( int idx, bool aCenterOnCursor )
|
int COMMON_TOOLS::doZoomToPreset( int idx, bool aCenterOnCursor )
|
||||||
{
|
{
|
||||||
std::vector<double>& zoomList = m_toolMgr->GetSettings()->m_Window.zoom_factors;
|
std::vector<double>& zoomList = m_frame->GetWindowSettings( m_toolMgr->GetSettings() )->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
|
|
||||||
|
|
||||||
if( idx == 0 ) // Zoom Auto
|
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 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++;
|
currentGrid++;
|
||||||
|
|
||||||
@ -511,7 +502,7 @@ int COMMON_TOOLS::GridNext( const TOOL_EVENT& aEvent )
|
|||||||
|
|
||||||
int COMMON_TOOLS::GridPrev( 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--;
|
currentGrid--;
|
||||||
|
|
||||||
@ -530,7 +521,7 @@ int COMMON_TOOLS::GridPreset( const TOOL_EVENT& aEvent )
|
|||||||
|
|
||||||
int COMMON_TOOLS::GridPreset( int idx, bool aFromHotkey )
|
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 );
|
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 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<int>( m_grids.size() ) - 1 ) );
|
currentGrid = std::max( 0, std::min( currentGrid, static_cast<int>( m_grids.size() ) - 1 ) );
|
||||||
|
|
||||||
@ -550,7 +541,7 @@ int COMMON_TOOLS::OnGridChanged( bool aFromHotkey )
|
|||||||
|
|
||||||
// Update GAL canvas from screen
|
// Update GAL canvas from screen
|
||||||
getView()->GetGAL()->SetGridSize( m_grids[ currentGrid ] );
|
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 );
|
getView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
||||||
|
|
||||||
// Put cursor on new grid
|
// Put cursor on new grid
|
||||||
@ -567,25 +558,25 @@ int COMMON_TOOLS::OnGridChanged( bool aFromHotkey )
|
|||||||
|
|
||||||
int COMMON_TOOLS::GridFast1( const TOOL_EVENT& aEvent )
|
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 )
|
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 )
|
int COMMON_TOOLS::GridFastCycle( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
if( m_toolMgr->GetSettings()->m_Window.grid.last_size_idx
|
if( m_frame->GetWindowSettings( m_toolMgr->GetSettings() )->grid.last_size_idx
|
||||||
== m_frame->config()->m_Window.grid.fast_grid_1 )
|
== 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();
|
auto& galOpts = m_frame->GetGalDisplayOptions();
|
||||||
|
|
||||||
galOpts.m_forceDisplayCursor = !galOpts.m_forceDisplayCursor;
|
galOpts.m_forceDisplayCursor = !galOpts.m_forceDisplayCursor;
|
||||||
galOpts.WriteConfig( m_toolMgr->GetSettings()->m_Window );
|
galOpts.WriteConfig( *m_frame->GetWindowSettings( m_toolMgr->GetSettings() ) );
|
||||||
galOpts.NotifyChanged();
|
galOpts.NotifyChanged();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -719,7 +710,7 @@ int COMMON_TOOLS::ToggleCursorStyle( const TOOL_EVENT& aEvent )
|
|||||||
GAL_DISPLAY_OPTIONS_IMPL& galOpts = m_frame->GetGalDisplayOptions();
|
GAL_DISPLAY_OPTIONS_IMPL& galOpts = m_frame->GetGalDisplayOptions();
|
||||||
|
|
||||||
galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
|
galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
|
||||||
galOpts.WriteConfig( m_toolMgr->GetSettings()->m_Window );
|
galOpts.WriteConfig( *m_frame->GetWindowSettings( m_toolMgr->GetSettings() ) );
|
||||||
galOpts.NotifyChanged();
|
galOpts.NotifyChanged();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -43,7 +43,6 @@
|
|||||||
#include <settings/settings_manager.h>
|
#include <settings/settings_manager.h>
|
||||||
#include <wildcards_and_files_ext.h>
|
#include <wildcards_and_files_ext.h>
|
||||||
#include <drawing_sheet/ds_data_model.h>
|
#include <drawing_sheet/ds_data_model.h>
|
||||||
#include <zoom_defines.h>
|
|
||||||
#include <sim/spice_settings.h>
|
#include <sim/spice_settings.h>
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include <tools/sch_selection_tool.h>
|
#include <tools/sch_selection_tool.h>
|
||||||
@ -357,9 +356,6 @@ void SCH_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
|||||||
|
|
||||||
EDA_DRAW_FRAME::LoadSettings( 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
|
// Move legacy user grids to grid list
|
||||||
if( !aCfg->m_Window.grid.user_grid_x.empty() )
|
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() )
|
if( aCfg->m_Window.grid.fast_grid_2 > (int) aCfg->m_Window.grid.grids.size() )
|
||||||
aCfg->m_Window.grid.fast_grid_2 = 2;
|
aCfg->m_Window.grid.fast_grid_2 = 2;
|
||||||
|
|
||||||
if( aCfg->m_Window.zoom_factors.empty() )
|
|
||||||
aCfg->m_Window.zoom_factors = { ZOOM_LIST_EESCHEMA };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,7 +58,6 @@
|
|||||||
#include "widgets/gerbview_layer_widget.h"
|
#include "widgets/gerbview_layer_widget.h"
|
||||||
#include "widgets/dcode_selection_box.h"
|
#include "widgets/dcode_selection_box.h"
|
||||||
#include <dialog_draw_layers_settings.h>
|
#include <dialog_draw_layers_settings.h>
|
||||||
#include <zoom_defines.h>
|
|
||||||
|
|
||||||
#include <navlib/nl_gerbview_plugin.h>
|
#include <navlib/nl_gerbview_plugin.h>
|
||||||
#include <wx/log.h>
|
#include <wx/log.h>
|
||||||
@ -317,44 +316,11 @@ void GERBVIEW_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
|||||||
{
|
{
|
||||||
EDA_DRAW_FRAME::LoadSettings( 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<GERBVIEW_SETTINGS*>( aCfg );
|
GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
|
||||||
wxCHECK( cfg, /*void*/ );
|
wxCHECK( cfg, /*void*/ );
|
||||||
|
|
||||||
SetElementVisibility( LAYER_GERBVIEW_DRAWINGSHEET,
|
SetElementVisibility( LAYER_GERBVIEW_DRAWINGSHEET, cfg->m_Appearance.show_border_and_titleblock );
|
||||||
cfg->m_Appearance.show_border_and_titleblock );
|
SetElementVisibility( LAYER_GERBVIEW_PAGE_LIMITS, cfg->m_Display.m_DisplayPageLimits );
|
||||||
SetElementVisibility( LAYER_GERBVIEW_PAGE_LIMITS,
|
|
||||||
cfg->m_Display.m_DisplayPageLimits );
|
|
||||||
|
|
||||||
PAGE_INFO pageInfo( wxT( "GERBER" ) );
|
PAGE_INFO pageInfo( wxT( "GERBER" ) );
|
||||||
pageInfo.SetType( cfg->m_Appearance.page_type );
|
pageInfo.SetType( cfg->m_Appearance.page_type );
|
||||||
|
@ -208,6 +208,8 @@ public:
|
|||||||
|
|
||||||
const std::vector<GRID> DefaultGridSizeList() const;
|
const std::vector<GRID> DefaultGridSizeList() const;
|
||||||
|
|
||||||
|
const std::vector<double> DefaultZoomList() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CROSS_PROBING_SETTINGS m_CrossProbing;
|
CROSS_PROBING_SETTINGS m_CrossProbing;
|
||||||
|
|
||||||
|
@ -476,17 +476,19 @@ class PARAM_LIST : public PARAM_BASE
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PARAM_LIST( const std::string& aJsonPath, std::vector<Type>* aPtr,
|
PARAM_LIST( const std::string& aJsonPath, std::vector<Type>* aPtr,
|
||||||
std::initializer_list<Type> aDefault, bool aReadOnly = false ) :
|
std::initializer_list<Type> aDefault, bool aResetIfEmpty = false ) :
|
||||||
PARAM_BASE( aJsonPath, aReadOnly ),
|
PARAM_BASE( aJsonPath, false ),
|
||||||
m_ptr( aPtr ),
|
m_ptr( aPtr ),
|
||||||
m_default( aDefault )
|
m_default( aDefault ),
|
||||||
|
m_resetIfEmpty( aResetIfEmpty )
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
PARAM_LIST( const std::string& aJsonPath, std::vector<Type>* aPtr,
|
PARAM_LIST( const std::string& aJsonPath, std::vector<Type>* aPtr,
|
||||||
std::vector<Type> aDefault, bool aReadOnly = false ) :
|
std::vector<Type> aDefault, bool aResetIfEmpty = false ) :
|
||||||
PARAM_BASE( aJsonPath, aReadOnly ),
|
PARAM_BASE( aJsonPath, false ),
|
||||||
m_ptr( aPtr ),
|
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
|
void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override
|
||||||
@ -504,10 +506,15 @@ public:
|
|||||||
val.push_back( el.value().get<Type>() );
|
val.push_back( el.value().get<Type>() );
|
||||||
}
|
}
|
||||||
|
|
||||||
*m_ptr = val;
|
if( val.empty() && m_resetIfEmpty )
|
||||||
|
*m_ptr = m_default;
|
||||||
|
else
|
||||||
|
*m_ptr = val;
|
||||||
}
|
}
|
||||||
else if( aResetIfMissing )
|
else if( aResetIfMissing )
|
||||||
|
{
|
||||||
*m_ptr = m_default;
|
*m_ptr = m_default;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Store( JSON_SETTINGS* aSettings ) const override
|
void Store( JSON_SETTINGS* aSettings ) const override
|
||||||
@ -555,6 +562,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
std::vector<Type>* m_ptr;
|
std::vector<Type>* m_ptr;
|
||||||
std::vector<Type> m_default;
|
std::vector<Type> m_default;
|
||||||
|
bool m_resetIfEmpty;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -667,13 +675,13 @@ class KICOMMON_API PARAM_PATH_LIST : public PARAM_LIST<wxString>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PARAM_PATH_LIST( const std::string& aJsonPath, std::vector<wxString>* aPtr,
|
PARAM_PATH_LIST( const std::string& aJsonPath, std::vector<wxString>* aPtr,
|
||||||
std::initializer_list<wxString> aDefault, bool aReadOnly = false ) :
|
std::initializer_list<wxString> aDefault ) :
|
||||||
PARAM_LIST( aJsonPath, aPtr, aDefault, aReadOnly )
|
PARAM_LIST( aJsonPath, aPtr, aDefault )
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
PARAM_PATH_LIST( const std::string& aJsonPath, std::vector<wxString>* aPtr,
|
PARAM_PATH_LIST( const std::string& aJsonPath, std::vector<wxString>* aPtr,
|
||||||
std::vector<wxString> aDefault, bool aReadOnly = false ) :
|
std::vector<wxString> aDefault ) :
|
||||||
PARAM_LIST( aJsonPath, aPtr, aDefault, aReadOnly )
|
PARAM_LIST( aJsonPath, aPtr, aDefault )
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override
|
void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override
|
||||||
|
@ -58,7 +58,6 @@
|
|||||||
#include "invoke_pl_editor_dialog.h"
|
#include "invoke_pl_editor_dialog.h"
|
||||||
#include "tools/pl_editor_control.h"
|
#include "tools/pl_editor_control.h"
|
||||||
#include <view/view_controls.h>
|
#include <view/view_controls.h>
|
||||||
#include <zoom_defines.h>
|
|
||||||
|
|
||||||
#include <wx/filedlg.h>
|
#include <wx/filedlg.h>
|
||||||
#include <wx/print.h>
|
#include <wx/print.h>
|
||||||
@ -518,25 +517,6 @@ void PL_EDITOR_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
|||||||
{
|
{
|
||||||
EDA_DRAW_FRAME::LoadSettings( 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<PL_EDITOR_SETTINGS*>( aCfg );
|
PL_EDITOR_SETTINGS* cfg = dynamic_cast<PL_EDITOR_SETTINGS*>( aCfg );
|
||||||
wxCHECK( cfg, /*void*/ );
|
wxCHECK( cfg, /*void*/ );
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
#include <tools/pcb_actions.h>
|
#include <tools/pcb_actions.h>
|
||||||
#include <tools/pcb_picker_tool.h>
|
#include <tools/pcb_picker_tool.h>
|
||||||
#include <tools/pcb_viewer_tools.h>
|
#include <tools/pcb_viewer_tools.h>
|
||||||
|
#include "settings/cvpcb_settings.h"
|
||||||
#include "wx/display.h"
|
#include "wx/display.h"
|
||||||
#include <footprint_preview_panel.h>
|
#include <footprint_preview_panel.h>
|
||||||
#include <3d_canvas/eda_3d_canvas.h>
|
#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 )
|
WINDOW_SETTINGS* FOOTPRINT_CHOOSER_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg )
|
||||||
{
|
{
|
||||||
PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
|
if( PCBNEW_SETTINGS* pcb_cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg ) )
|
||||||
wxCHECK_MSG( cfg, nullptr, wxT( "config not existing" ) );
|
return &pcb_cfg->m_FootprintViewer;
|
||||||
|
else if( CVPCB_SETTINGS* cvpcb_cfg = dynamic_cast<CVPCB_SETTINGS*>( 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,7 +43,6 @@
|
|||||||
#include <settings/settings_manager.h>
|
#include <settings/settings_manager.h>
|
||||||
#include <view/view.h>
|
#include <view/view.h>
|
||||||
#include <wx/stattext.h>
|
#include <wx/stattext.h>
|
||||||
#include <zoom_defines.h>
|
|
||||||
#include <dialog_shim.h>
|
#include <dialog_shim.h>
|
||||||
#include <project_pcb.h>
|
#include <project_pcb.h>
|
||||||
|
|
||||||
@ -243,19 +242,6 @@ FOOTPRINT_PREVIEW_PANEL* FOOTPRINT_PREVIEW_PANEL::New( KIWAY* aKiway, wxWindow*
|
|||||||
{
|
{
|
||||||
PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" );
|
PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>( "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_DISPLAY_OPTIONS_IMPL> gal_opts;
|
std::unique_ptr<GAL_DISPLAY_OPTIONS_IMPL> gal_opts;
|
||||||
|
|
||||||
gal_opts = std::make_unique<GAL_DISPLAY_OPTIONS_IMPL>();
|
gal_opts = std::make_unique<GAL_DISPLAY_OPTIONS_IMPL>();
|
||||||
|
@ -53,7 +53,6 @@
|
|||||||
#include <pgm_base.h>
|
#include <pgm_base.h>
|
||||||
#include <project_pcb.h>
|
#include <project_pcb.h>
|
||||||
#include <wildcards_and_files_ext.h>
|
#include <wildcards_and_files_ext.h>
|
||||||
#include <zoom_defines.h>
|
|
||||||
|
|
||||||
#include <math/vector2d.h>
|
#include <math/vector2d.h>
|
||||||
#include <math/vector2wx.h>
|
#include <math/vector2wx.h>
|
||||||
@ -814,9 +813,6 @@ void PCB_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
|||||||
{
|
{
|
||||||
EDA_DRAW_FRAME::LoadSettings( 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
|
// Move legacy user grids to grid list
|
||||||
if( !aCfg->m_Window.grid.user_grid_x.empty() )
|
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;
|
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.
|
// Some, but not all, derived classes have a PCBNEW_SETTINGS.
|
||||||
if( PCBNEW_SETTINGS* pcbnew_cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg ) )
|
if( PCBNEW_SETTINGS* pcbnew_cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg ) )
|
||||||
m_polarCoords = pcbnew_cfg->m_PolarCoords;
|
m_polarCoords = pcbnew_cfg->m_PolarCoords;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user