2020-01-12 20:44:19 -05:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2020-01-12 20:44:19 -05: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 2
|
|
|
|
* 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, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2024-03-19 21:53:21 -04:00
|
|
|
#include <json_common.h>
|
2024-02-25 17:39:14 -05:00
|
|
|
|
2020-01-12 20:44:19 -05:00
|
|
|
#include <settings/common_settings.h>
|
|
|
|
#include <settings/parameters.h>
|
|
|
|
#include <settings/settings_manager.h>
|
2020-10-31 01:27:16 +00:00
|
|
|
#include "symbol_editor_settings.h"
|
2020-04-14 20:11:50 +02:00
|
|
|
#include <default_values.h>
|
2020-01-12 20:44:19 -05:00
|
|
|
|
|
|
|
|
|
|
|
///! Update the schema version whenever a migration is required
|
2022-08-28 19:02:12 -04:00
|
|
|
const int libeditSchemaVersion = 1;
|
2020-01-12 20:44:19 -05:00
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
SYMBOL_EDITOR_SETTINGS::SYMBOL_EDITOR_SETTINGS() :
|
|
|
|
APP_SETTINGS_BASE( "symbol_editor", libeditSchemaVersion ),
|
|
|
|
m_Defaults(),
|
|
|
|
m_Repeat(),
|
2023-10-09 03:54:34 +03:00
|
|
|
m_ImportGraphics(),
|
2020-10-31 01:27:16 +00:00
|
|
|
m_ShowPinElectricalType( true ),
|
|
|
|
m_LibWidth(),
|
2021-06-14 14:00:08 -04:00
|
|
|
m_EditSymbolVisibleColumns()
|
2020-01-12 20:44:19 -05:00
|
|
|
{
|
2020-03-30 09:24:56 +02:00
|
|
|
// Make Coverity happy
|
|
|
|
m_UseEeschemaColorSettings = true;;
|
|
|
|
|
|
|
|
// Init settings:
|
2023-01-22 09:41:33 -05:00
|
|
|
SetLegacyFilename( wxS( "eeschema" ) );
|
2020-01-12 20:44:19 -05:00
|
|
|
|
2023-07-26 18:32:06 -04:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "aui.show_properties",
|
|
|
|
&m_AuiPanels.show_properties, true ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<int>( "aui.properties_panel_width",
|
|
|
|
&m_AuiPanels.properties_panel_width, -1 ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<float>( "aui.properties_splitter_proportion",
|
2023-09-25 12:35:31 +01:00
|
|
|
&m_AuiPanels.properties_splitter, 0.5f ) );
|
2023-07-26 18:32:06 -04:00
|
|
|
|
2020-04-14 20:11:50 +02:00
|
|
|
m_params.emplace_back( new PARAM<int>( "defaults.line_width",
|
2021-11-27 11:52:36 +00:00
|
|
|
&m_Defaults.line_width, 0 ) );
|
2020-01-12 20:44:19 -05:00
|
|
|
|
2020-04-14 20:11:50 +02:00
|
|
|
m_params.emplace_back( new PARAM<int>( "defaults.text_size",
|
2021-11-27 11:52:36 +00:00
|
|
|
&m_Defaults.text_size, DEFAULT_TEXT_SIZE ) );
|
2020-04-04 21:32:14 +01:00
|
|
|
|
2020-04-14 20:11:50 +02:00
|
|
|
m_params.emplace_back( new PARAM<int>( "defaults.pin_length",
|
|
|
|
&m_Defaults.pin_length, DEFAULT_PIN_LENGTH ) );
|
2020-01-12 20:44:19 -05:00
|
|
|
|
2020-04-14 20:11:50 +02:00
|
|
|
m_params.emplace_back( new PARAM<int>( "defaults.pin_name_size",
|
2021-11-27 11:52:36 +00:00
|
|
|
&m_Defaults.pin_name_size, DEFAULT_PINNAME_SIZE ) );
|
2020-01-12 20:44:19 -05:00
|
|
|
|
2020-04-14 20:11:50 +02:00
|
|
|
m_params.emplace_back( new PARAM<int>( "defaults.pin_num_size",
|
2021-11-27 11:52:36 +00:00
|
|
|
&m_Defaults.pin_num_size, DEFAULT_PINNUM_SIZE ) );
|
2020-01-12 20:44:19 -05:00
|
|
|
|
2021-10-12 21:05:37 +01:00
|
|
|
m_params.emplace_back( new PARAM<int>( "repeat.label_delta",
|
|
|
|
&m_Repeat.label_delta, 1 ) );
|
2020-01-12 20:44:19 -05:00
|
|
|
|
2021-10-12 21:05:37 +01:00
|
|
|
m_params.emplace_back( new PARAM<int>( "repeat.pin_step",
|
|
|
|
&m_Repeat.pin_step, 100 ) );
|
2020-01-12 20:44:19 -05:00
|
|
|
|
2023-10-09 03:54:34 +03:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "import_graphics.interactive_placement",
|
|
|
|
&m_ImportGraphics.interactive_placement, true ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<int>( "import_graphics.line_width_units",
|
|
|
|
&m_ImportGraphics.dxf_line_width_units, 0 ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<double>( "import_graphics.line_width",
|
|
|
|
&m_ImportGraphics.dxf_line_width, 0.2 ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<int>( "import_graphics.origin_units",
|
|
|
|
&m_ImportGraphics.origin_units, 0 ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<double>( "import_graphics.origin_x",
|
|
|
|
&m_ImportGraphics.origin_x, 0 ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<double>( "import_graphics.origin_y",
|
|
|
|
&m_ImportGraphics.origin_y, 0 ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<int>( "import_graphics.dxf_units",
|
|
|
|
&m_ImportGraphics.dxf_units, 0 ) );
|
|
|
|
|
2020-01-12 20:44:19 -05:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "show_pin_electrical_type",
|
2021-11-27 11:52:36 +00:00
|
|
|
&m_ShowPinElectricalType, true ) );
|
2020-01-12 20:44:19 -05:00
|
|
|
|
2024-10-09 21:27:58 -06:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "show_pin_alt_icons",
|
|
|
|
&m_ShowPinAltIcons, true ) );
|
|
|
|
|
2024-01-21 11:22:27 +01:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "show_hidden_lib_fields",
|
2024-04-08 12:26:56 +01:00
|
|
|
&m_ShowHiddenFields, true ) );
|
2024-01-21 11:22:27 +01:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "show_hidden_lib_pins",
|
2024-04-08 12:26:56 +01:00
|
|
|
&m_ShowHiddenPins, true ) );
|
2024-01-21 11:22:27 +01:00
|
|
|
|
2024-10-01 15:20:30 +01:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "drag_pins_along_with_edges",
|
|
|
|
&m_dragPinsAlongWithEdges, true ) );
|
|
|
|
|
2021-11-27 11:52:36 +00:00
|
|
|
m_params.emplace_back( new PARAM<int>( "lib_table_width",
|
|
|
|
&m_LibWidth, 250 ) );
|
2020-01-12 20:44:19 -05:00
|
|
|
|
2023-05-01 21:26:29 +01:00
|
|
|
m_params.emplace_back( new PARAM<int>( "library.sort_mode",
|
|
|
|
&m_LibrarySortMode, 0 ) );
|
|
|
|
|
2021-10-12 21:05:37 +01:00
|
|
|
m_params.emplace_back( new PARAM<wxString>( "edit_symbol_visible_columns",
|
2021-11-27 11:52:36 +00:00
|
|
|
&m_EditSymbolVisibleColumns, "0 1 2 3 4 5 6 7" ) );
|
2020-03-05 22:57:50 -05:00
|
|
|
|
2020-07-07 20:59:55 -04:00
|
|
|
m_params.emplace_back( new PARAM<wxString>( "pin_table_visible_columns",
|
2021-04-21 22:50:14 -06:00
|
|
|
&m_PinTableVisibleColumns, "0 1 2 3 4 5 9 10" ) );
|
2020-07-07 20:59:55 -04:00
|
|
|
|
2021-11-27 11:52:36 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "use_eeschema_color_settings",
|
|
|
|
&m_UseEeschemaColorSettings, true ) );
|
2022-08-28 19:02:12 -04:00
|
|
|
|
2024-08-30 16:03:06 -07:00
|
|
|
m_params.emplace_back( new PARAM_MAP<int>( "field_editor.field_widths", &m_LibFieldEditor.field_widths, {} ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<int>( "field_editor.width", &m_LibFieldEditor.width, 0 ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<int>( "field_editor.height", &m_LibFieldEditor.height, 0 ) );
|
|
|
|
|
|
|
|
|
2024-02-25 17:39:14 -05:00
|
|
|
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "selection_filter",
|
|
|
|
[&]() -> nlohmann::json
|
|
|
|
{
|
|
|
|
nlohmann::json ret;
|
|
|
|
|
|
|
|
ret["lockedItems"] = m_SelectionFilter.lockedItems;
|
|
|
|
ret["symbols"] = m_SelectionFilter.symbols;
|
|
|
|
ret["text"] = m_SelectionFilter.text;
|
|
|
|
ret["wires"] = m_SelectionFilter.wires;
|
|
|
|
ret["labels"] = m_SelectionFilter.labels;
|
|
|
|
ret["pins"] = m_SelectionFilter.pins;
|
|
|
|
ret["graphics"] = m_SelectionFilter.graphics;
|
|
|
|
ret["images"] = m_SelectionFilter.images;
|
|
|
|
ret["otherItems"] = m_SelectionFilter.otherItems;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
[&]( const nlohmann::json& aVal )
|
|
|
|
{
|
|
|
|
if( aVal.empty() || !aVal.is_object() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
SetIfPresent( aVal, "lockedItems", m_SelectionFilter.lockedItems );
|
|
|
|
SetIfPresent( aVal, "symbols", m_SelectionFilter.symbols );
|
|
|
|
SetIfPresent( aVal, "text", m_SelectionFilter.text );
|
|
|
|
SetIfPresent( aVal, "wires", m_SelectionFilter.wires );
|
|
|
|
SetIfPresent( aVal, "labels", m_SelectionFilter.labels );
|
|
|
|
SetIfPresent( aVal, "pins", m_SelectionFilter.pins );
|
|
|
|
SetIfPresent( aVal, "graphics", m_SelectionFilter.graphics );
|
|
|
|
SetIfPresent( aVal, "images", m_SelectionFilter.images );
|
|
|
|
SetIfPresent( aVal, "otherItems", m_SelectionFilter.otherItems );
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{ "lockedItems", false },
|
|
|
|
{ "symbols", true },
|
|
|
|
{ "text", true },
|
|
|
|
{ "wires", true },
|
|
|
|
{ "labels", true },
|
|
|
|
{ "pins", true },
|
|
|
|
{ "graphics", true },
|
|
|
|
{ "images", true },
|
|
|
|
{ "otherItems", true }
|
|
|
|
} ) );
|
|
|
|
|
2022-08-28 19:02:12 -04:00
|
|
|
registerMigration( 0, 1,
|
|
|
|
[&]() -> bool
|
|
|
|
{
|
|
|
|
// This is actually a migration for APP_SETTINGS_BASE::m_LibTree
|
|
|
|
return migrateLibTreeWidth();
|
|
|
|
} );
|
2020-01-12 20:44:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
bool SYMBOL_EDITOR_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
|
2020-01-12 20:44:19 -05:00
|
|
|
{
|
|
|
|
bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
|
|
|
|
|
2020-12-27 12:12:24 -05:00
|
|
|
// Now modify the loaded grid selection, because in earlier versions the grids index was shared
|
|
|
|
// between all applications and started at 1000 mils. There is a 4-position offset between
|
|
|
|
// this index and the possible eeschema grids list that we have to subtract.
|
2021-06-03 23:52:50 -04:00
|
|
|
std::string gridSizePtr = "window.grid.last_size";
|
2020-12-27 12:12:24 -05:00
|
|
|
|
2022-08-25 15:50:47 -07:00
|
|
|
if( std::optional<int> currentSize = Get<int>( gridSizePtr ) )
|
2020-12-27 12:12:24 -05:00
|
|
|
{
|
2021-06-03 23:52:50 -04:00
|
|
|
Set( gridSizePtr, *currentSize - 4 );
|
2020-12-27 12:12:24 -05:00
|
|
|
}
|
2021-06-03 23:52:50 -04:00
|
|
|
else
|
2020-12-27 12:12:24 -05:00
|
|
|
{
|
|
|
|
// Otherwise, default grid size should be 50 mils; index 1
|
2021-06-03 23:52:50 -04:00
|
|
|
Set( gridSizePtr, 1 );
|
2020-12-27 12:12:24 -05:00
|
|
|
}
|
|
|
|
|
2021-10-12 21:05:37 +01:00
|
|
|
ret &= fromLegacy<int>( aCfg, "DefaultWireWidth", "defaults.line_width" );
|
|
|
|
ret &= fromLegacy<int>( aCfg, "DefaultPinLength", "defaults.pin_length" );
|
|
|
|
ret &= fromLegacy<int>( aCfg, "LibeditPinNameSize", "defaults.pin_name_size" );
|
|
|
|
ret &= fromLegacy<int>( aCfg, "LibeditPinNumSize", "defaults.pin_num_size" );
|
2020-01-12 20:44:19 -05:00
|
|
|
|
2021-10-12 21:05:37 +01:00
|
|
|
ret &= fromLegacy<int>( aCfg, "LibeditRepeatLabelInc", "repeat.label_delta" );
|
|
|
|
ret &= fromLegacy<int>( aCfg, "LibeditPinRepeatStep", "repeat.pin_step" );
|
|
|
|
ret &= fromLegacy<int>( aCfg, "LibeditRepeatStepX", "repeat.x_step" );
|
|
|
|
ret &= fromLegacy<int>( aCfg, "LibeditRepeatStepY", "repeat.y_step" );
|
2020-01-12 20:44:19 -05:00
|
|
|
|
|
|
|
ret &= fromLegacy<int>( aCfg, "LibeditLibWidth", "lib_table_width" );
|
|
|
|
ret &= fromLegacy<bool>( aCfg, "LibeditShowPinElectricalType", "show_pin_electrical_type" );
|
|
|
|
|
2021-10-12 21:05:37 +01:00
|
|
|
ret &= fromLegacyString( aCfg, "LibEditFieldsShownColumns", "edit_symbol_visible_columns" );
|
|
|
|
|
|
|
|
ret &= fromLegacyString( aCfg, "PinTableShownColumns", "pin_table_visible_columns" );
|
2020-07-07 20:59:55 -04:00
|
|
|
|
2020-01-12 20:44:19 -05:00
|
|
|
return ret;
|
|
|
|
}
|