2020-01-13 01:44:19 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
|
2023-08-24 15:41:08 +00:00
|
|
|
* Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2020-01-13 01:44:19 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <class_draw_panel_gal.h>
|
|
|
|
#include <common.h>
|
2022-09-17 01:07:36 +00:00
|
|
|
#include <eda_units.h>
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <settings/app_settings.h>
|
2021-06-04 03:52:50 +00:00
|
|
|
#include <settings/json_settings_internals.h>
|
2023-02-18 22:42:36 +00:00
|
|
|
#include <settings/color_settings.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/common_settings.h>
|
2023-08-30 15:21:56 +00:00
|
|
|
#include <settings/grid_settings.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/parameters.h>
|
|
|
|
|
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaVersion ) :
|
|
|
|
JSON_SETTINGS( aFilename, SETTINGS_LOC::USER, aSchemaVersion ),
|
2020-07-18 22:56:39 +00:00
|
|
|
m_CrossProbing(),
|
|
|
|
m_FindReplace(),
|
|
|
|
m_Graphics(),
|
2020-08-17 12:55:56 +00:00
|
|
|
m_ColorPicker(),
|
2020-07-18 22:56:39 +00:00
|
|
|
m_LibTree(),
|
|
|
|
m_Printing(),
|
|
|
|
m_System(),
|
|
|
|
m_Window(),
|
|
|
|
m_appSettingsSchemaVersion( aSchemaVersion )
|
2020-01-13 01:44:19 +00:00
|
|
|
{
|
2020-04-03 07:54:47 +00:00
|
|
|
// Make Coverity happy:
|
2023-01-04 01:30:02 +00:00
|
|
|
m_Graphics.canvas_type = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL;
|
2020-04-03 07:54:47 +00:00
|
|
|
|
|
|
|
// Build parameters list:
|
2022-08-05 02:40:38 +00:00
|
|
|
m_params.emplace_back(
|
|
|
|
new PARAM<int>( "find_replace.match_mode", &m_FindReplace.match_mode, 0 ) );
|
|
|
|
|
|
|
|
m_params.emplace_back(
|
|
|
|
new PARAM<bool>( "find_replace.match_case", &m_FindReplace.match_case, false ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "find_replace.search_and_replace",
|
|
|
|
&m_FindReplace.search_and_replace, false ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<wxString>( "find_replace.find_string",
|
2023-01-22 14:41:33 +00:00
|
|
|
&m_FindReplace.find_string, wxS( "" ) ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM_LIST<wxString>( "find_replace.find_history",
|
|
|
|
&m_FindReplace.find_history, {} ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<wxString>( "find_replace.replace_string",
|
|
|
|
&m_FindReplace.replace_string, "" ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM_LIST<wxString>( "find_replace.replace_history",
|
|
|
|
&m_FindReplace.replace_history, {} ) );
|
|
|
|
|
2020-08-17 12:55:56 +00:00
|
|
|
m_params.emplace_back( new PARAM<int>( "graphics.canvas_type",
|
2023-01-04 01:30:02 +00:00
|
|
|
&m_Graphics.canvas_type, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2021-11-05 23:35:10 +00:00
|
|
|
m_params.emplace_back( new PARAM<float>( "graphics.highlight_factor",
|
|
|
|
&m_Graphics.highlight_factor, 0.5f, 0.0, 1.0f ) );
|
2020-08-19 00:44:01 +00:00
|
|
|
|
2021-11-05 23:35:10 +00:00
|
|
|
m_params.emplace_back( new PARAM<float>( "graphics.select_factor",
|
|
|
|
&m_Graphics.select_factor, 0.75f, 0.0, 1.0f ) );
|
2020-08-19 00:44:01 +00:00
|
|
|
|
2020-08-17 12:55:56 +00:00
|
|
|
m_params.emplace_back( new PARAM<int>( "color_picker.default_tab",
|
|
|
|
&m_ColorPicker.default_tab, 0 ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2022-09-24 03:45:00 +00:00
|
|
|
m_params.emplace_back( new PARAM_LIST<wxString>( "lib_tree.columns", &m_LibTree.columns, {} ) );
|
|
|
|
|
2022-08-28 23:02:12 +00:00
|
|
|
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "lib_tree.column_widths",
|
|
|
|
[&]() -> nlohmann::json
|
|
|
|
{
|
|
|
|
nlohmann::json ret = {};
|
|
|
|
|
|
|
|
for( const std::pair<const wxString, int>& pair : m_LibTree.column_widths )
|
|
|
|
ret[std::string( pair.first.ToUTF8() )] = pair.second;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
[&]( const nlohmann::json& aJson )
|
|
|
|
{
|
|
|
|
if( !aJson.is_object() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_LibTree.column_widths.clear();
|
|
|
|
|
|
|
|
for( const auto& entry : aJson.items() )
|
|
|
|
{
|
|
|
|
if( !entry.value().is_number_integer() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
m_LibTree.column_widths[ entry.key() ] = entry.value().get<int>();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{} ) );
|
2021-03-30 19:58:35 +00:00
|
|
|
|
2020-08-17 12:55:56 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "printing.background",
|
|
|
|
&m_Printing.background, false ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-08-17 12:55:56 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "printing.monochrome",
|
|
|
|
&m_Printing.monochrome, true ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-08-17 12:55:56 +00:00
|
|
|
m_params.emplace_back( new PARAM<double>( "printing.scale",
|
|
|
|
&m_Printing.scale, 1.0 ) );
|
2020-05-16 14:47:43 +00:00
|
|
|
|
2020-08-17 12:55:56 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "printing.use_theme",
|
|
|
|
&m_Printing.use_theme, false ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<wxString>( "printing.color_theme",
|
2023-01-22 14:41:33 +00:00
|
|
|
&m_Printing.color_theme, wxS( "" ) ) );
|
2020-05-16 14:47:43 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "printing.title_block",
|
|
|
|
&m_Printing.title_block, false ) );
|
|
|
|
|
2020-08-17 12:55:56 +00:00
|
|
|
m_params.emplace_back( new PARAM_LIST<int>( "printing.layers",
|
|
|
|
&m_Printing.layers, {} ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "system.first_run_shown",
|
2023-01-04 01:30:02 +00:00
|
|
|
&m_System.first_run_shown, false ) ); //@todo RFB remove? - not used
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-08-17 12:55:56 +00:00
|
|
|
m_params.emplace_back( new PARAM<int>( "system.max_undo_items",
|
|
|
|
&m_System.max_undo_items, 0 ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM_LIST<wxString>( "system.file_history",
|
|
|
|
&m_System.file_history, {} ) );
|
|
|
|
|
2023-08-29 16:23:33 +00:00
|
|
|
if( m_filename == wxS( "pl_editor" )
|
|
|
|
|| ( m_filename == wxS( "eeschema" ) || m_filename == wxS( "symbol_editor" ) ) )
|
|
|
|
{
|
|
|
|
m_params.emplace_back( new PARAM<int>( "system.units",
|
|
|
|
&m_System.units, static_cast<int>( EDA_UNITS::MILS ) ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_params.emplace_back( new PARAM<int>( "system.units",
|
|
|
|
&m_System.units, static_cast<int>( EDA_UNITS::MILLIMETRES ) ) );
|
|
|
|
}
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-10-05 19:26:33 +00:00
|
|
|
m_params.emplace_back( new PARAM<int>( "system.last_metric_units",
|
|
|
|
&m_System.last_metric_units, static_cast<int>( EDA_UNITS::MILLIMETRES ) ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<int>( "system.last_imperial_units",
|
2023-08-29 16:23:33 +00:00
|
|
|
&m_System.last_imperial_units, static_cast<int>( EDA_UNITS::MILS ) ) );
|
2020-10-05 19:26:33 +00:00
|
|
|
|
2020-08-17 12:55:56 +00:00
|
|
|
m_params.emplace_back( new PARAM<wxString>( "appearance.color_theme",
|
2023-02-18 22:42:36 +00:00
|
|
|
&m_ColorTheme, COLOR_SETTINGS::COLOR_BUILTIN_DEFAULT ) );
|
2020-02-03 16:46:58 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
addParamsForWindow( &m_Window, "window" );
|
2020-06-28 02:48:48 +00:00
|
|
|
|
2022-01-16 20:29:03 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "cross_probing.on_selection",
|
|
|
|
&m_CrossProbing.on_selection, true ) );
|
|
|
|
|
2020-08-17 12:55:56 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "cross_probing.center_on_items",
|
|
|
|
&m_CrossProbing.center_on_items, true ) );
|
2020-06-28 02:48:48 +00:00
|
|
|
|
2020-08-17 12:55:56 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "cross_probing.zoom_to_fit",
|
|
|
|
&m_CrossProbing.zoom_to_fit, true ) );
|
2020-06-28 02:48:48 +00:00
|
|
|
|
2020-08-17 12:55:56 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "cross_probing.auto_highlight",
|
|
|
|
&m_CrossProbing.auto_highlight, true ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool APP_SETTINGS_BASE::MigrateFromLegacy( wxConfigBase* aCfg )
|
|
|
|
{
|
|
|
|
bool ret = true;
|
|
|
|
|
|
|
|
const std::string f = getLegacyFrameName();
|
|
|
|
|
|
|
|
ret &= fromLegacyString( aCfg, "LastFindString", "find_replace.find_string" );
|
|
|
|
ret &= fromLegacyString( aCfg, "LastReplaceString", "find_replace.replace_string" );
|
|
|
|
|
|
|
|
migrateFindReplace( aCfg );
|
|
|
|
|
2020-06-14 15:08:47 +00:00
|
|
|
ret &= fromLegacy<int>( aCfg, "canvas_type", "graphics.canvas_type" );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-06-14 15:08:47 +00:00
|
|
|
ret &= fromLegacy<int>( aCfg, "P22LIB_TREE_MODEL_ADAPTERSelectorColumnWidth",
|
|
|
|
"lib_tree.column_width" );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-06-14 15:08:47 +00:00
|
|
|
ret &= fromLegacy<bool>( aCfg, "PrintMonochrome", "printing.monochrome" );
|
|
|
|
ret &= fromLegacy<double>( aCfg, "PrintScale", "printing.scale" );
|
|
|
|
ret &= fromLegacy<bool>( aCfg, "PrintPageFrame", "printing.title_block" );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
nlohmann::json js = nlohmann::json::array();
|
|
|
|
wxString key;
|
|
|
|
bool val = false;
|
|
|
|
|
|
|
|
for( unsigned i = 0; i < PCB_LAYER_ID_COUNT; ++i )
|
|
|
|
{
|
|
|
|
key.Printf( wxT( "PlotLayer_%d" ), i );
|
|
|
|
|
|
|
|
if( aCfg->Read( key, &val ) && val )
|
|
|
|
js.push_back( i );
|
|
|
|
}
|
|
|
|
|
2021-06-04 03:52:50 +00:00
|
|
|
Set( "printing.layers", js );
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret &= fromLegacy<bool>( aCfg, f + "FirstRunShown", "system.first_run_shown" );
|
|
|
|
ret &= fromLegacy<int>( aCfg, f + "DevelMaxUndoItems", "system.max_undo_items" );
|
|
|
|
ret &= fromLegacy<int>( aCfg, f + "Units", "system.units" );
|
|
|
|
|
|
|
|
{
|
|
|
|
int max_history_size = Pgm().GetCommonSettings()->m_System.file_history_size;
|
|
|
|
wxString file, key;
|
|
|
|
nlohmann::json js = nlohmann::json::array();
|
|
|
|
|
|
|
|
for( int i = 1; i <= max_history_size; i++ )
|
|
|
|
{
|
|
|
|
key.Printf( "file%d", i );
|
|
|
|
file = aCfg->Read( key, wxEmptyString );
|
|
|
|
|
|
|
|
if( !file.IsEmpty() )
|
|
|
|
js.push_back( file.ToStdString() );
|
|
|
|
}
|
|
|
|
|
2021-06-04 03:52:50 +00:00
|
|
|
Set( "system.file_history", js );
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret &= migrateWindowConfig( aCfg, f, "window" );
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void APP_SETTINGS_BASE::migrateFindReplace( wxConfigBase* aCfg )
|
|
|
|
{
|
|
|
|
const int find_replace_history_size = 10;
|
|
|
|
nlohmann::json find_history = nlohmann::json::array();
|
|
|
|
nlohmann::json replace_history = nlohmann::json::array();
|
|
|
|
wxString tmp, find_key, replace_key;
|
|
|
|
|
|
|
|
for( int i = 0; i < find_replace_history_size; ++i )
|
|
|
|
{
|
|
|
|
find_key.Printf( "FindStringHistoryList%d", i );
|
|
|
|
replace_key.Printf( "ReplaceStringHistoryList%d", i );
|
|
|
|
|
|
|
|
if( aCfg->Read( find_key, &tmp ) )
|
|
|
|
find_history.push_back( tmp.ToStdString() );
|
|
|
|
|
|
|
|
if( aCfg->Read( replace_key, &tmp ) )
|
|
|
|
replace_history.push_back( tmp.ToStdString() );
|
|
|
|
}
|
|
|
|
|
2021-06-04 03:52:50 +00:00
|
|
|
Set( "find_replace.find_history", find_history );
|
|
|
|
Set( "find_replace.replace_history", replace_history );
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool APP_SETTINGS_BASE::migrateWindowConfig( wxConfigBase* aCfg, const std::string& aFrame,
|
|
|
|
const std::string& aJsonPath )
|
|
|
|
{
|
|
|
|
bool ret = true;
|
|
|
|
|
2020-06-14 15:08:47 +00:00
|
|
|
const std::string frameGDO = aFrame + "GalDisplayOptions";
|
|
|
|
const std::string cursorPath = aJsonPath + ".cursor";
|
|
|
|
const std::string gridPath = aJsonPath + ".grid";
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
ret &= fromLegacy<bool>( aCfg, aFrame + "Maximized", aJsonPath + ".maximized" );
|
|
|
|
ret &= fromLegacyString( aCfg, aFrame + "MostRecentlyUsedPath", aJsonPath + ".mru_path" );
|
|
|
|
ret &= fromLegacy<int>( aCfg, aFrame + "Size_x", aJsonPath + ".size_x" );
|
|
|
|
ret &= fromLegacy<int>( aCfg, aFrame + "Size_y", aJsonPath + ".size_y" );
|
|
|
|
ret &= fromLegacyString( aCfg, aFrame + "Perspective", aJsonPath + ".perspective" );
|
|
|
|
ret &= fromLegacy<int>( aCfg, aFrame + "Pos_x", aJsonPath + ".pos_x" );
|
|
|
|
ret &= fromLegacy<int>( aCfg, aFrame + "Pos_y", aJsonPath + ".pos_y" );
|
|
|
|
|
2020-06-14 15:08:47 +00:00
|
|
|
ret &= fromLegacy<bool>( aCfg, frameGDO + "ForceDisplayCursor", cursorPath + ".always_show_cursor" );
|
|
|
|
ret &= fromLegacy<bool>( aCfg, frameGDO + "CursorFullscreen", cursorPath + ".fullscreen_cursor" );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-06-14 15:08:47 +00:00
|
|
|
ret &= fromLegacy<int>( aCfg, aFrame + "_LastGridSize", gridPath + ".last_size" );
|
2020-06-12 10:58:56 +00:00
|
|
|
|
2020-06-14 15:08:47 +00:00
|
|
|
ret &= fromLegacy<int>( aCfg, aFrame + "FastGrid1", gridPath + ".fast_grid_1" );
|
|
|
|
ret &= fromLegacy<int>( aCfg, aFrame + "FastGrid2", gridPath + ".fast_grid_2" );
|
2020-06-12 10:58:56 +00:00
|
|
|
|
2020-06-14 15:08:47 +00:00
|
|
|
ret &= fromLegacy<bool>( aCfg, frameGDO + "GridAxesEnabled", gridPath + ".axes_enabled" );
|
|
|
|
ret &= fromLegacy<double>( aCfg, frameGDO + "GridLineWidth", gridPath + ".line_width" );
|
|
|
|
ret &= fromLegacy<double>( aCfg, frameGDO + "GridMaxDensity", gridPath + ".min_spacing" );
|
|
|
|
ret &= fromLegacy<bool>( aCfg, frameGDO + "ShowGrid", gridPath + ".show" );
|
|
|
|
ret &= fromLegacy<int>( aCfg, frameGDO + "GridStyle", gridPath + ".style" );
|
|
|
|
ret &= fromLegacyColor( aCfg, frameGDO + "GridColor", gridPath + ".color" );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std::string& aJsonPath )
|
|
|
|
{
|
2020-06-12 10:58:56 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".maximized",
|
2020-08-24 02:01:14 +00:00
|
|
|
&aWindow->state.maximized, false ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".mru_path",
|
2023-01-22 14:41:33 +00:00
|
|
|
&aWindow->mru_path, wxS( "" ) ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
m_params.emplace_back( new PARAM<int>( aJsonPath + ".size_x", &aWindow->state.size_x, 0 ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
m_params.emplace_back( new PARAM<int>( aJsonPath + ".size_y", &aWindow->state.size_y, 0 ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".perspective",
|
2023-01-22 14:41:33 +00:00
|
|
|
&aWindow->perspective, wxS( "" ) ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
m_params.emplace_back( new PARAM<int>( aJsonPath + ".pos_x", &aWindow->state.pos_x, 0 ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
m_params.emplace_back( new PARAM<int>( aJsonPath + ".pos_y", &aWindow->state.pos_y, 0 ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
m_params.emplace_back( new PARAM<unsigned int>( aJsonPath + ".display", &aWindow->state.display, 0 ) );
|
2020-07-27 02:53:56 +00:00
|
|
|
|
2020-06-13 21:09:02 +00:00
|
|
|
m_params.emplace_back( new PARAM_LIST<double>( aJsonPath + ".zoom_factors",
|
|
|
|
&aWindow->zoom_factors, {} ) );
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.axes_enabled",
|
|
|
|
&aWindow->grid.axes_enabled, false ) );
|
|
|
|
|
2021-10-28 21:15:57 +00:00
|
|
|
int defaultGridIdx;
|
|
|
|
|
2023-08-21 19:06:50 +00:00
|
|
|
if( m_filename == wxS( "pl_editor" )
|
|
|
|
|| ( m_filename == wxS( "eeschema" ) || m_filename == wxS( "symbol_editor" ) ) )
|
2023-01-05 12:23:03 +00:00
|
|
|
{
|
|
|
|
defaultGridIdx = 1;
|
|
|
|
}
|
2021-10-28 21:15:57 +00:00
|
|
|
else
|
2023-08-24 15:41:08 +00:00
|
|
|
{
|
2021-10-28 21:15:57 +00:00
|
|
|
defaultGridIdx = 4;
|
2023-08-24 15:41:08 +00:00
|
|
|
}
|
2021-10-28 21:15:57 +00:00
|
|
|
|
2023-08-30 15:21:56 +00:00
|
|
|
m_params.emplace_back( new PARAM_LIST<GRID>( aJsonPath + ".grid.sizes", &aWindow->grid.grids,
|
|
|
|
DefaultGridSizeList() ) );
|
2023-01-05 12:23:03 +00:00
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.last_size",
|
2021-10-28 21:15:57 +00:00
|
|
|
&aWindow->grid.last_size_idx, defaultGridIdx ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-06-14 15:08:47 +00:00
|
|
|
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.fast_grid_1",
|
2021-10-28 21:15:57 +00:00
|
|
|
&aWindow->grid.fast_grid_1, defaultGridIdx ) );
|
2020-06-14 15:08:47 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.fast_grid_2",
|
2021-10-28 21:15:57 +00:00
|
|
|
&aWindow->grid.fast_grid_2, defaultGridIdx + 1 ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2023-08-30 15:21:56 +00:00
|
|
|
// legacy values, leave blank by default so we don't convert them
|
2020-06-12 10:58:56 +00:00
|
|
|
m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".grid.user_grid_x",
|
2023-08-24 15:41:08 +00:00
|
|
|
&aWindow->grid.user_grid_x, wxEmptyString ) );
|
2020-06-14 15:08:47 +00:00
|
|
|
m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".grid.user_grid_y",
|
2023-08-24 15:41:08 +00:00
|
|
|
&aWindow->grid.user_grid_y, wxEmptyString ) );
|
2020-06-12 10:58:56 +00:00
|
|
|
|
2023-07-23 17:51:42 +00:00
|
|
|
// for grid overrides, give just the schematic and symbol editors sane values
|
|
|
|
if( m_filename == wxS( "eeschema" ) || m_filename == wxS( "symbol_editor" ) )
|
|
|
|
{
|
|
|
|
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.overrides_enabled",
|
|
|
|
&aWindow->grid.overrides_enabled, true ) );
|
2023-08-26 12:29:24 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_connected",
|
|
|
|
&aWindow->grid.override_connected, true ) );
|
2023-07-23 17:51:42 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_wires",
|
|
|
|
&aWindow->grid.override_wires, true ) );
|
2023-08-24 16:38:20 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_vias",
|
|
|
|
&aWindow->grid.override_vias, false ) );
|
2023-07-23 17:51:42 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_text",
|
2023-08-30 17:33:04 +00:00
|
|
|
&aWindow->grid.override_text, true ) );
|
2023-07-23 17:51:42 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_graphics",
|
|
|
|
&aWindow->grid.override_graphics, false ) );
|
|
|
|
|
2023-08-30 17:33:04 +00:00
|
|
|
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_connected_idx",
|
|
|
|
&aWindow->grid.override_connected_idx, 1 ) );
|
|
|
|
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_wires_idx",
|
|
|
|
&aWindow->grid.override_wires_idx, 1 ) );
|
|
|
|
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_vias_idx",
|
|
|
|
&aWindow->grid.override_vias_idx, 0 ) );
|
|
|
|
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_text_idx",
|
|
|
|
&aWindow->grid.override_text_idx, 3 ) );
|
|
|
|
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_graphics_idx",
|
|
|
|
&aWindow->grid.override_graphics_idx, 2 ) );
|
2023-07-23 17:51:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.overrides_enabled",
|
|
|
|
&aWindow->grid.overrides_enabled, false ) );
|
2023-08-26 12:29:24 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_connected",
|
|
|
|
&aWindow->grid.override_connected, false ) );
|
2023-07-23 17:51:42 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_wires",
|
|
|
|
&aWindow->grid.override_wires, false ) );
|
2023-08-24 16:38:20 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_vias",
|
2023-08-24 17:57:22 +00:00
|
|
|
&aWindow->grid.override_vias, false ) );
|
2023-07-23 17:51:42 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_text",
|
|
|
|
&aWindow->grid.override_text, false ) );
|
|
|
|
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_graphics",
|
|
|
|
&aWindow->grid.override_graphics, false ) );
|
|
|
|
|
2023-08-30 17:33:04 +00:00
|
|
|
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_connected_idx",
|
|
|
|
&aWindow->grid.override_connected_idx, 16 ) );
|
|
|
|
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_text_idx",
|
|
|
|
&aWindow->grid.override_text_idx, 18 ) );
|
|
|
|
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_wires_idx",
|
|
|
|
&aWindow->grid.override_wires_idx, 19 ) );
|
|
|
|
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_vias_idx",
|
|
|
|
&aWindow->grid.override_vias_idx, 18 ) );
|
|
|
|
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_graphics_idx",
|
|
|
|
&aWindow->grid.override_graphics_idx, 15 ) );
|
2023-07-23 17:51:42 +00:00
|
|
|
}
|
|
|
|
|
2023-11-19 23:43:42 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
#define DEFAULT_GRID_THICKNESS 2.0
|
|
|
|
#else
|
|
|
|
#define DEFAULT_GRID_THICKNESS 1.0
|
|
|
|
#endif
|
2023-07-23 17:51:42 +00:00
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
m_params.emplace_back( new PARAM<double>( aJsonPath + ".grid.line_width",
|
2023-11-19 23:43:42 +00:00
|
|
|
&aWindow->grid.line_width, DEFAULT_GRID_THICKNESS ) );
|
2020-06-12 10:58:56 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<double>( aJsonPath + ".grid.min_spacing",
|
|
|
|
&aWindow->grid.min_spacing, 10 ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.show",
|
|
|
|
&aWindow->grid.show, true ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.style",
|
|
|
|
&aWindow->grid.style, 0 ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-09-11 03:07:56 +00:00
|
|
|
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.snap",
|
|
|
|
&aWindow->grid.snap, 0 ) );
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".cursor.always_show_cursor",
|
|
|
|
&aWindow->cursor.always_show_cursor, true ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".cursor.fullscreen_cursor",
|
|
|
|
&aWindow->cursor.fullscreen_cursor, false ) );
|
|
|
|
}
|
2021-02-24 01:02:48 +00:00
|
|
|
|
|
|
|
|
2023-08-30 15:21:56 +00:00
|
|
|
const std::vector<GRID> APP_SETTINGS_BASE::DefaultGridSizeList() const
|
2021-02-24 01:02:48 +00:00
|
|
|
{
|
2023-01-22 14:41:33 +00:00
|
|
|
if( m_filename == wxS( "eeschema" ) || m_filename == wxS( "symbol_editor" ) )
|
2023-01-05 16:30:55 +00:00
|
|
|
{
|
2023-08-30 15:21:56 +00:00
|
|
|
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( "10 mil" ), wxS( "10 mil" ) } };
|
2023-01-05 16:30:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-30 15:21:56 +00:00
|
|
|
return { GRID{ wxEmptyString, wxS( "1000 mil" ), wxS( "1000 mil" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "500 mil" ), wxS( "500 mil" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "250 mil" ), wxS( "250 mil" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "200 mil" ), wxS( "200 mil" ) },
|
|
|
|
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 mil" ), wxS( "2 mil" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "1 mil" ), wxS( "1 mil" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "5.0 mm" ), wxS( "5.0 mm" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "2.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.05 mm" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "0.025 mm" ), wxS( "0.025 mm" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "0.01 mm" ), wxS( "0.01 mm" ) } };
|
2023-01-05 16:30:55 +00:00
|
|
|
}
|
2021-02-24 01:02:48 +00:00
|
|
|
}
|
2022-08-28 23:02:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool APP_SETTINGS_BASE::migrateLibTreeWidth()
|
|
|
|
{
|
|
|
|
// We used to store only the width of the first column, because there were only
|
|
|
|
// two possible columns.
|
|
|
|
if( std::optional<int> optWidth = Get<int>( "lib_tree.column_width" ) )
|
|
|
|
{
|
|
|
|
Set<nlohmann::json>( "lib_tree.column_widths", { { "Item", *optWidth } } );
|
|
|
|
At( "lib_tree" ).erase( "column_width" );
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|