KiCad PCB EDA Suite
Loading...
Searching...
No Matches
symbol_editor_settings.cpp
Go to the documentation of this file.
1/*
2* This program source code file is part of KiCad, a free EDA CAD application.
3*
4* Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors.
5*
6* This program is free software; you can redistribute it and/or
7* modify it under the terms of the GNU General Public License
8* as published by the Free Software Foundation; either version 2
9* of the License, or (at your option) any later version.
10*
11* This program is distributed in the hope that it will be useful,
12* but WITHOUT ANY WARRANTY; without even the implied warranty of
13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14* GNU General Public License for more details.
15*
16* You should have received a copy of the GNU General Public License
17* along with this program; if not, you may find one here:
18* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19* or you may search the http://www.gnu.org website for the version 2 license,
20* or you may write to the Free Software Foundation, Inc.,
21* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22*/
23
25#include <settings/parameters.h>
28#include <default_values.h>
29
30
33
34
36 APP_SETTINGS_BASE( "symbol_editor", libeditSchemaVersion ),
37 m_Defaults(),
38 m_Repeat(),
39 m_ImportGraphics(),
40 m_ShowPinElectricalType( true ),
41 m_LibWidth(),
42 m_EditSymbolVisibleColumns()
43{
44 // Make Coverity happy
46
47 // Init settings:
48 SetLegacyFilename( wxS( "eeschema" ) );
49
50 m_params.emplace_back( new PARAM<bool>( "aui.show_properties",
52
53 m_params.emplace_back( new PARAM<int>( "aui.properties_panel_width",
55
56 m_params.emplace_back( new PARAM<float>( "aui.properties_splitter_proportion",
58
59 m_params.emplace_back( new PARAM<int>( "defaults.line_width",
60 &m_Defaults.line_width, 0 ) );
61
62 m_params.emplace_back( new PARAM<int>( "defaults.text_size",
64
65 m_params.emplace_back( new PARAM<int>( "defaults.pin_length",
67
68 m_params.emplace_back( new PARAM<int>( "defaults.pin_name_size",
70
71 m_params.emplace_back( new PARAM<int>( "defaults.pin_num_size",
73
74 m_params.emplace_back( new PARAM<int>( "repeat.label_delta",
75 &m_Repeat.label_delta, 1 ) );
76
77 m_params.emplace_back( new PARAM<int>( "repeat.pin_step",
78 &m_Repeat.pin_step, 100 ) );
79
80 m_params.emplace_back( new PARAM<bool>( "import_graphics.interactive_placement",
82
83 m_params.emplace_back( new PARAM<int>( "import_graphics.line_width_units",
85
86 m_params.emplace_back( new PARAM<double>( "import_graphics.line_width",
88
89 m_params.emplace_back( new PARAM<int>( "import_graphics.origin_units",
91
92 m_params.emplace_back( new PARAM<double>( "import_graphics.origin_x",
94
95 m_params.emplace_back( new PARAM<double>( "import_graphics.origin_y",
97
98 m_params.emplace_back( new PARAM<int>( "import_graphics.dxf_units",
100
101 m_params.emplace_back( new PARAM<bool>( "show_pin_electrical_type",
102 &m_ShowPinElectricalType, true ) );
103
104 m_params.emplace_back( new PARAM<int>( "lib_table_width",
105 &m_LibWidth, 250 ) );
106
107 m_params.emplace_back( new PARAM<int>( "library.sort_mode",
108 &m_LibrarySortMode, 0 ) );
109
110 m_params.emplace_back( new PARAM<wxString>( "edit_symbol_visible_columns",
111 &m_EditSymbolVisibleColumns, "0 1 2 3 4 5 6 7" ) );
112
113 m_params.emplace_back( new PARAM<wxString>( "pin_table_visible_columns",
114 &m_PinTableVisibleColumns, "0 1 2 3 4 5 9 10" ) );
115
116 m_params.emplace_back( new PARAM<bool>( "use_eeschema_color_settings",
118
119 registerMigration( 0, 1,
120 [&]() -> bool
121 {
122 // This is actually a migration for APP_SETTINGS_BASE::m_LibTree
123 return migrateLibTreeWidth();
124 } );
125}
126
127
129{
130 bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
131
132 // Now modify the loaded grid selection, because in earlier versions the grids index was shared
133 // between all applications and started at 1000 mils. There is a 4-position offset between
134 // this index and the possible eeschema grids list that we have to subtract.
135 std::string gridSizePtr = "window.grid.last_size";
136
137 if( std::optional<int> currentSize = Get<int>( gridSizePtr ) )
138 {
139 Set( gridSizePtr, *currentSize - 4 );
140 }
141 else
142 {
143 // Otherwise, default grid size should be 50 mils; index 1
144 Set( gridSizePtr, 1 );
145 }
146
147 ret &= fromLegacy<int>( aCfg, "DefaultWireWidth", "defaults.line_width" );
148 ret &= fromLegacy<int>( aCfg, "DefaultPinLength", "defaults.pin_length" );
149 ret &= fromLegacy<int>( aCfg, "LibeditPinNameSize", "defaults.pin_name_size" );
150 ret &= fromLegacy<int>( aCfg, "LibeditPinNumSize", "defaults.pin_num_size" );
151
152 ret &= fromLegacy<int>( aCfg, "LibeditRepeatLabelInc", "repeat.label_delta" );
153 ret &= fromLegacy<int>( aCfg, "LibeditPinRepeatStep", "repeat.pin_step" );
154 ret &= fromLegacy<int>( aCfg, "LibeditRepeatStepX", "repeat.x_step" );
155 ret &= fromLegacy<int>( aCfg, "LibeditRepeatStepY", "repeat.y_step" );
156
157 ret &= fromLegacy<int>( aCfg, "LibeditLibWidth", "lib_table_width" );
158 ret &= fromLegacy<bool>( aCfg, "LibeditShowPinElectricalType", "show_pin_electrical_type" );
159
160 ret &= fromLegacyString( aCfg, "LibEditFieldsShownColumns", "edit_symbol_visible_columns" );
161
162 ret &= fromLegacyString( aCfg, "PinTableShownColumns", "pin_table_visible_columns" );
163
164 return ret;
165}
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:92
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
bool migrateLibTreeWidth()
Migrates the library tree width setting from a single column (Item) to multi-column.
bool fromLegacyString(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy wxConfig string value to a given JSON pointer value.
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
void registerMigration(int aOldSchemaVersion, int aNewSchemaVersion, std::function< bool(void)> aMigrator)
Registers a migration from one schema version to another.
void Set(const std::string &aPath, ValueType aVal)
Stores a value into the JSON document Will throw an exception if ValueType isn't something that the l...
void SetLegacyFilename(const wxString &aFilename)
Definition: json_settings.h:82
virtual bool MigrateFromLegacy(wxConfigBase *aLegacyConfig) override
Migrates from wxConfig to JSON-based configuration.
DIALOG_IMPORT_GRAPHICS m_ImportGraphics
#define DEFAULT_PINNUM_SIZE
The default pin name size when creating pins(can be changed in preference menu)
#define DEFAULT_PINNAME_SIZE
The default selection highlight thickness (can be changed in preference menu)
#define DEFAULT_PIN_LENGTH
The default pin number size when creating pins(can be changed in preference menu)
#define DEFAULT_TEXT_SIZE
Ratio of the font height to the baseline of the text above the wire.
const int libeditSchemaVersion
! Update the schema version whenever a migration is required