KiCad PCB EDA Suite
Loading...
Searching...
No Matches
eeschema_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 The 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, see <https://www.gnu.org/licenses/>.
18*/
19
20#include <functional>
21
22#include <dialogs/dialog_bom_cfg_lexer.h>
23#include <eda_draw_frame.h>
24#include <eeschema_settings.h>
25#include <layer_ids.h>
27#include <string_utils.h>
28#include <pgm_base.h>
31#include <settings/parameters.h>
36#include <wx/config.h>
37#include <widgets/ui_common.h>
38#include <default_values.h> // For some default values
39
40using namespace T_BOMCFG_T; // for the BOM_CFG_PARSER parser and its keywords
41
44
45
47const nlohmann::json defaultBomPlugins =
48 {
49 {
50 { "name", "bom_csv_grouped_extra" },
51 { "path", "bom_csv_grouped_extra.py" }
52 },
53 {
54 { "name", "bom_csv_grouped_by_value" },
55 { "path", "bom_csv_grouped_by_value.py" }
56 },
57 {
58 { "name", "bom_csv_grouped_by_value_with_fp" },
59 { "path", "bom_csv_grouped_by_value_with_fp.py" }
60 },
61 };
62
63
64const wxAuiPaneInfo& defaultNetNavigatorPaneInfo()
65{
66 static wxAuiPaneInfo paneInfo;
67
68 paneInfo.Name( wxS( "NetNavigator" ) )
69 .Caption( _( "Net Navigator" ) )
70 .CaptionVisible( true )
71 .PaneBorder( true )
72 .Left().Layer( 3 ).Position( 0 )
73 .TopDockable( false )
74 .BottomDockable( false )
75 .CloseButton( true )
76 .MinSize( 120, 60 )
77 .BestSize( 200, 200 )
78 .FloatingSize( 200, 200 )
79 .FloatingPosition( 50, 200 )
80 .Show( false );
81
82 return paneInfo;
83}
84
85
86const wxAuiPaneInfo& defaultPropertiesPaneInfo( wxWindow* aWindow )
87{
88 static wxAuiPaneInfo paneInfo;
89
90 paneInfo.Name( EDA_DRAW_FRAME::PropertiesPaneName() )
91 .Caption( _( "Properties" ) )
92 .CaptionVisible( true )
93 .PaneBorder( true )
94 .Left().Layer( 3 ).Position( 2 )
95 .TopDockable( false )
96 .BottomDockable( false )
97 .CloseButton( true )
98 .MinSize( aWindow->FromDIP( wxSize( 240, 60 ) ) )
99 .BestSize( aWindow->FromDIP( wxSize( 300, 200 ) ) )
100 .FloatingSize( aWindow->FromDIP( wxSize( 300, 400 ) ) )
101 .FloatingPosition( aWindow->FromDIP( wxPoint( 50, 200 ) ) )
102 .Show( true );
103
104 return paneInfo;
105}
106
107
108const wxAuiPaneInfo& defaultSchSelectionFilterPaneInfo( wxWindow* aWindow )
109{
110 static wxAuiPaneInfo paneInfo;
111
112 paneInfo.Name( wxS( "SelectionFilter" ) )
113 .Caption( _( "Selection Filter" ) )
114 .CaptionVisible( true )
115 .PaneBorder( false )
116 .Left().Layer( 3 ).Position( 4 )
117 .TopDockable( false )
118 .BottomDockable( false )
119 .CloseButton( true )
120 // Fixed-size pane; -1 for MinSize height is required
121 .MinSize( aWindow->FromDIP( wxSize( 180, -1 ) ) )
122 .BestSize( aWindow->FromDIP( wxSize( 180, -1 ) ) )
123 .Show( true );
124
125 return paneInfo;
126}
127
128
129const wxAuiPaneInfo& defaultDesignBlocksPaneInfo( wxWindow* aWindow )
130{
131 static wxAuiPaneInfo paneInfo;
132
133 paneInfo.Name( EDA_DRAW_FRAME::DesignBlocksPaneName() )
134 .Caption( _( "Design Blocks" ) )
135 .CaptionVisible( true )
136 .PaneBorder( true )
137 .Right().Layer( 3 ).Position( 2 )
138 .TopDockable( false )
139 .BottomDockable( false )
140 .CloseButton( true )
141 .MinSize( aWindow->FromDIP( wxSize( 240, 60 ) ) )
142 .BestSize( aWindow->FromDIP( wxSize( 300, 200 ) ) )
143 .FloatingSize( aWindow->FromDIP( wxSize( 800, 600 ) ) )
144 .FloatingPosition( aWindow->FromDIP( wxPoint( 50, 200 ) ) )
145 .Show( true );
146
147 return paneInfo;
148}
149
150
151const wxAuiPaneInfo& defaultRemoteSymbolPaneInfo( wxWindow* aWindow )
152{
153 static wxAuiPaneInfo paneInfo;
154
155 paneInfo.Name( EDA_DRAW_FRAME::RemoteSymbolPaneName() )
156 .Caption( _( "Remote Symbols" ) )
157 .CaptionVisible( true )
158 .PaneBorder( true )
159 .Right().Layer( 3 ).Position( 3 )
160 .TopDockable( false )
161 .BottomDockable( false )
162 .CloseButton( true )
163 .MinSize( aWindow->FromDIP( wxSize( 240, 60 ) ) )
164 .BestSize( aWindow->FromDIP( wxSize( 300, 200 ) ) )
165 .FloatingSize( aWindow->FromDIP( wxSize( 800, 600 ) ) )
166 .FloatingPosition( aWindow->FromDIP( wxPoint( 80, 220 ) ) )
167 .Show( false );
168
169 return paneInfo;
170}
171
172
175 m_Appearance(),
176 m_Drawing(),
177 m_Input(),
179 m_Selection(),
182 m_BomPanel(),
188 m_ERCDialog(),
189 m_Simulator(),
190 m_RescueNeverShow( false )
191{
192 m_params.emplace_back( new PARAM<bool>( "appearance.footprint_preview",
193 &m_Appearance.footprint_preview, true ) );
194
195 m_params.emplace_back( new PARAM<bool>( "appearance.print_sheet_reference",
196 &m_Appearance.print_sheet_reference, true ) );
197
198 m_params.emplace_back( new PARAM<wxString>( "appearance.default_font",
199 &m_Appearance.default_font, "KiCad Font" ) );
200
201 m_params.emplace_back( new PARAM<bool>( "appearance.show_hidden_pins",
202 &m_Appearance.show_hidden_pins, false ) );
203
204 m_params.emplace_back( new PARAM<bool>( "appearance.show_hidden_fields",
205 &m_Appearance.show_hidden_fields, false ) );
206
207 m_params.emplace_back(
208 new PARAM<bool>( "appearance.show_remapped_pin_numbers", &m_Appearance.show_remapped_pin_numbers, true ) );
209
210 m_params.emplace_back( new PARAM<bool>( "appearance.show_directive_labels",
211 &m_Appearance.show_directive_labels, true ) );
212
213 m_params.emplace_back( new PARAM<bool>( "appearance.show_erc_warnings",
214 &m_Appearance.show_erc_warnings, true ) );
215
216 m_params.emplace_back( new PARAM<bool>( "appearance.show_erc_errors",
217 &m_Appearance.show_erc_errors, true ) );
218
219 m_params.emplace_back( new PARAM<bool>( "appearance.show_erc_exclusions",
220 &m_Appearance.show_erc_exclusions, false ) );
221
222 m_params.emplace_back( new PARAM<bool>( "appearance.mark_sim_exclusions",
223 &m_Appearance.mark_sim_exclusions, true ) );
224
225 m_params.emplace_back( new PARAM<bool>( "appearance.show_op_voltages",
226 &m_Appearance.show_op_voltages, true ) );
227
228 m_params.emplace_back( new PARAM<bool>( "appearance.show_op_currents",
229 &m_Appearance.show_op_currents, true ) );
230
231 m_params.emplace_back( new PARAM<bool>( "appearance.show_pin_alt_icons",
232 &m_Appearance.show_pin_alt_icons, true ) );
233
234 m_params.emplace_back( new PARAM<bool>( "appearance.show_illegal_symbol_lib_dialog",
235 &m_Appearance.show_illegal_symbol_lib_dialog, true ) );
236
237 m_params.emplace_back( new PARAM<bool>( "appearance.show_page_limits",
238 &m_Appearance.show_page_limits, true ) );
239
240 m_params.emplace_back( new PARAM<bool>( "appearance.show_sexpr_file_convert_warning",
241 &m_Appearance.show_sexpr_file_convert_warning, true ) );
242
243 m_params.emplace_back( new PARAM<bool>( "appearance.show_sheet_filename_case_sensitivity_dialog",
244 &m_Appearance.show_sheet_filename_case_sensitivity_dialog, true ) );
245
246 m_params.emplace_back( new PARAM<bool>( "aui.show_schematic_hierarchy",
247 &m_AuiPanels.show_schematic_hierarchy, true ) );
248
249 m_params.emplace_back( new PARAM<int>( "aui.hierarchy_panel_docked_width",
250 &m_AuiPanels.hierarchy_panel_docked_width, -1 ) );
251
252 m_params.emplace_back( new PARAM<int>( "aui.hierarchy_panel_docked_height",
253 &m_AuiPanels.hierarchy_panel_docked_height, -1 ) );
254
255 m_params.emplace_back( new PARAM<int>( "aui.hierarchy_panel_float_width",
256 &m_AuiPanels.hierarchy_panel_float_width, -1 ) );
257
258 m_params.emplace_back( new PARAM<int>( "aui.hierarchy_panel_float_height",
259 &m_AuiPanels.hierarchy_panel_float_height, -1 ) );
260
261 m_params.emplace_back( new PARAM<bool>( "aui.design_blocks_show",
262 &m_AuiPanels.design_blocks_show, false ) );
263
264 m_params.emplace_back( new PARAM<int>( "aui.design_blocks_panel_docked_width",
265 &m_AuiPanels.design_blocks_panel_docked_width, -1 ) );
266
267 m_params.emplace_back( new PARAM<int>( "aui.design_blocks_panel_float_width",
268 &m_AuiPanels.design_blocks_panel_float_width, -1 ) );
269
270 m_params.emplace_back( new PARAM<int>( "aui.design_blocks_panel_float_height",
271 &m_AuiPanels.design_blocks_panel_float_height, -1 ) );
272
273 m_params.emplace_back( new PARAM<bool>( "aui.remote_symbol_show",
274 &m_AuiPanels.remote_symbol_show, false ) );
275
276 m_params.emplace_back( new PARAM<int>( "aui.remote_symbol_panel_docked_width",
277 &m_AuiPanels.remote_symbol_panel_docked_width, -1 ) );
278
279 m_params.emplace_back( new PARAM<int>( "aui.remote_symbol_panel_float_width",
280 &m_AuiPanels.remote_symbol_panel_float_width, -1 ) );
281
282 m_params.emplace_back( new PARAM<int>( "aui.remote_symbol_panel_float_height",
283 &m_AuiPanels.remote_symbol_panel_float_height, -1 ) );
284
285 m_params.emplace_back( new PARAM<bool>( "aui.schematic_hierarchy_float",
286 &m_AuiPanels.schematic_hierarchy_float, false ) );
287
288 m_params.emplace_back( new PARAM<int>( "aui.search_panel_height",
289 &m_AuiPanels.search_panel_height, -1 ) );
290
291 m_params.emplace_back( new PARAM<int>( "aui.search_panel_width",
292 &m_AuiPanels.search_panel_width, -1 ) );
293
294 m_params.emplace_back( new PARAM<int>( "aui.search_panel_dock_direction",
295 &m_AuiPanels.search_panel_dock_direction, 3 ) );
296
297 m_params.emplace_back( new PARAM<bool>( "aui.show_search",
298 &m_AuiPanels.show_search, false ) );
299
300 m_params.emplace_back( new PARAM<bool>( "aui.show_net_nav_panel",
301 &m_AuiPanels.show_net_nav_panel, false ) );
302
303 m_params.emplace_back( new PARAM<bool>( "aui.float_net_nav_panel",
304 &m_AuiPanels.float_net_nav_panel, false ) );
305
306 m_params.emplace_back( new PARAM<wxSize>( "aui.net_nav_panel_docked_size",
307 &m_AuiPanels.net_nav_panel_docked_size, wxSize( 120, -1 ) ) );
308
309 m_params.emplace_back( new PARAM<wxPoint>( "aui.net_nav_panel_float_pos",
310 &m_AuiPanels.net_nav_panel_float_pos, wxPoint( 50, 200 ), false ) );
311
312 m_params.emplace_back( new PARAM<wxSize>( "aui.net_nav_panel_float_size",
313 &m_AuiPanels.net_nav_panel_float_size, wxSize( 200, 200 ) ) );
314
315 m_params.emplace_back( new PARAM<bool>( "aui.net_nav_search_mode_wildcard",
316 &m_AuiPanels.net_nav_search_mode_wildcard, true ) );
317
318 m_params.emplace_back( new PARAM<bool>( "aui.show_properties",
319 &m_AuiPanels.show_properties, true ) );
320
321 m_params.emplace_back( new PARAM<bool>( "aui.show_git_commit_pane", &m_AuiPanels.show_git_commit_pane, false ) );
322
323 m_params.emplace_back( new PARAM<int>( "aui.properties_panel_width",
324 &m_AuiPanels.properties_panel_width, -1 ) );
325
326 m_params.emplace_back( new PARAM<float>( "aui.properties_splitter_proportion",
327 &m_AuiPanels.properties_splitter, 0.5f ) );
328
329 m_params.emplace_back( new PARAM<bool>( "autoplace_fields.enable",
330 &m_AutoplaceFields.enable, true ) );
331
332 m_params.emplace_back( new PARAM<bool>( "autoplace_fields.allow_rejustify",
333 &m_AutoplaceFields.allow_rejustify, true ) );
334
335 m_params.emplace_back( new PARAM<bool>( "autoplace_fields.align_to_grid",
336 &m_AutoplaceFields.align_to_grid, true ) );
337
338 m_params.emplace_back( new PARAM<wxString>( "remote_symbols.destination_dir",
339 &m_RemoteSymbol.destination_dir,
341
342 m_params.emplace_back( new PARAM<wxString>( "remote_symbols.library_prefix",
343 &m_RemoteSymbol.library_prefix,
345
346 m_params.emplace_back( new PARAM<bool>( "remote_symbols.add_to_global_table",
347 &m_RemoteSymbol.add_to_global_table, false ) );
348
349 m_params.emplace_back( new PARAM<wxString>( "remote_symbols.last_used_provider_id",
350 &m_RemoteSymbol.last_used_provider_id, wxEmptyString ) );
351
352 m_params.emplace_back( new PARAM_LIST<REMOTE_PROVIDER_ENTRY>( "remote_symbols.providers",
353 &m_RemoteSymbol.providers, {} ) );
354
355 m_params.emplace_back( new PARAM<int>( "drawing.default_bus_thickness",
356 &m_Drawing.default_bus_thickness, DEFAULT_BUS_WIDTH_MILS ) );
357
358 m_params.emplace_back( new PARAM<int>( "drawing.default_junction_size",
359 &m_Drawing.default_junction_size, DEFAULT_JUNCTION_DIAM ) );
360
361 m_params.emplace_back( new PARAM<int>( "drawing.pin_symbol_size",
362 &m_Drawing.pin_symbol_size, DEFAULT_TEXT_SIZE / 2 ) );
363
364 m_params.emplace_back( new PARAM<double>( "drawing.text_offset_ratio",
365 &m_Drawing.text_offset_ratio, 0.08 ) );
366
367 m_params.emplace_back( new PARAM<int>( "drawing.default_line_thickness",
368 &m_Drawing.default_line_thickness, DEFAULT_LINE_WIDTH_MILS ) );
369
370 m_params.emplace_back( new PARAM<int>( "drawing.default_repeat_offset_x",
371 &m_Drawing.default_repeat_offset_x, 0 ) );
372
373 m_params.emplace_back( new PARAM<int>( "drawing.default_repeat_offset_y",
374 &m_Drawing.default_repeat_offset_y, 100 ) );
375
376 m_params.emplace_back( new PARAM<int>( "drawing.default_wire_thickness",
377 &m_Drawing.default_wire_thickness, DEFAULT_WIRE_WIDTH_MILS ) );
378
379 m_params.emplace_back( new PARAM<int>( "drawing.default_text_size",
380 &m_Drawing.default_text_size, DEFAULT_TEXT_SIZE ) );
381
382 m_params.emplace_back( new PARAM<int>( "drawing.line_mode",
383 &m_Drawing.line_mode, LINE_MODE::LINE_MODE_90 ) );
384
385 m_params.emplace_back( new PARAM<int>( "editing.arc_edit_mode",
386 reinterpret_cast<int*>( &m_Drawing.arc_edit_mode ),
388
390
391 m_params.emplace_back( new PARAM<bool>( "drawing.auto_start_wires",
392 &m_Drawing.auto_start_wires, true ) );
393
394 m_params.emplace_back( new PARAM<bool>( "drawing.auto_place_sheet_pins",
395 &m_Drawing.auto_place_sheet_pins, true ) );
396
397 m_params.emplace_back( new PARAM<int>( "drawing.repeat_label_increment",
398 &m_Drawing.repeat_label_increment, 1 ) );
399
400 m_params.emplace_back( new PARAM<COLOR4D>( "drawing.default_sheet_border_color",
401 &m_Drawing.default_sheet_border_color, COLOR4D::UNSPECIFIED ) );
402
403 m_params.emplace_back( new PARAM<COLOR4D>( "drawing.default_sheet_background_color",
404 &m_Drawing.default_sheet_background_color, COLOR4D::UNSPECIFIED ) );
405
406 m_params.emplace_back( new PARAM_ENUM<POWER_SYMBOLS>( "drawing.new_power_symbols",
408
409 m_params.emplace_back( new PARAM<bool>( "find_replace.intersheets_ref_show",
410 &m_Drawing.intersheets_ref_show, false ) );
411
412 m_params.emplace_back( new PARAM<bool>( "find_replace.intersheets_ref_own_page",
413 &m_Drawing.intersheets_ref_own_page, true ) );
414
415 m_params.emplace_back( new PARAM<bool>( "find_replace.intersheets_ref_short",
416 &m_Drawing.intersheets_ref_short, false ) );
417
418 m_params.emplace_back( new PARAM<wxString>( "remote_symbols.intersheets_ref_prefix",
419 &m_Drawing.intersheets_ref_prefix, wxS( DEFAULT_IREF_PREFIX ) ) );
420
421 m_params.emplace_back( new PARAM<wxString>( "remote_symbols.intersheets_ref_suffix",
422 &m_Drawing.intersheets_ref_suffix, wxS( DEFAULT_IREF_SUFFIX ) ) );
423
424 m_params.emplace_back( new PARAM<int>( "drawing.junction_size_choice",
425 &m_Drawing.junction_size_choice, 3, 0, 5 ) );
426
427 m_params.emplace_back( new PARAM<int>( "drawing.hop_over_size_choice",
428 &m_Drawing.hop_over_size_choice, 0, 0, 5 ) );
429
430 m_params.emplace_back( new PARAM<bool>( "find_replace.search_all_fields",
431 &m_FindReplaceExtra.search_all_fields, false ) );
432
433 m_params.emplace_back( new PARAM<bool>( "find_replace.search_all_pins",
434 &m_FindReplaceExtra.search_all_pins, false ) );
435
436 m_params.emplace_back( new PARAM<bool>( "find_replace.search_current_sheet_only",
437 &m_FindReplaceExtra.search_current_sheet_only, false ) );
438
439 m_params.emplace_back( new PARAM<bool>( "find_replace.search_selected_only",
440 &m_FindReplaceExtra.search_selected_only, false ) );
441
442 m_params.emplace_back( new PARAM<bool>( "find_replace.replace_references",
443 &m_FindReplaceExtra.replace_references, false ) );
444
445 m_params.emplace_back( new PARAM<bool>( "input.drag_is_move",
446 &m_Input.drag_is_move, false ) );
447
448 m_params.emplace_back( new PARAM<bool>( "input.allow_unconstrained_pin_swaps",
449 &m_Input.allow_unconstrained_pin_swaps, false ) );
450
451 m_params.emplace_back( new PARAM<bool>( "input.esc_clears_net_highlight",
452 &m_Input.esc_clears_net_highlight, true ) );
453
454 m_params.emplace_back( new PARAM<int>( "selection.thickness",
455 &m_Selection.selection_thickness, 3 ) );
456
457 m_params.emplace_back( new PARAM<int>( "selection.highlight_thickness",
458 &m_Selection.highlight_thickness, 2 ) );
459
460 m_params.emplace_back( new PARAM<bool>( "selection.draw_selected_children",
461 &m_Selection.draw_selected_children, true ) );
462
463 m_params.emplace_back( new PARAM<bool>( "selection.fill_shapes",
464 &m_Selection.fill_shapes, false ) );
465
466 m_params.emplace_back( new PARAM<bool>( "selection.select_pin_selects_symbol",
467 &m_Selection.select_pin_selects_symbol, false ) );
468
469 m_params.emplace_back( new PARAM<bool>( "selection.highlight_netclass_colors",
470 &m_Selection.highlight_netclass_colors, false ) );
471
472 m_params.emplace_back( new PARAM<int>( "selection.highlight_netclass_colors_thickness",
473 &m_Selection.highlight_netclass_colors_thickness, 15, 0, 50 ) );
474
475 m_params.emplace_back( new PARAM<double>( "selection.highlight_netclass_colors_alpha",
476 &m_Selection.highlight_netclass_colors_alpha, 0.6, 0, 1 ) );
477
478 m_params.emplace_back( new PARAM<int>( "selection.drag_net_collision_width",
479 &m_Selection.drag_net_collision_width, 4, 1, 50 ) );
480
481 m_params.emplace_back( new PARAM<bool>( "annotation.automatic",
482 &m_AnnotatePanel.automatic, true ) );
483
484 m_params.emplace_back( new PARAM<bool>( "annotation.recursive",
485 &m_AnnotatePanel.recursive, true ) );
486
487 m_params.emplace_back( new PARAM<bool>( "annotation.regroup_units",
488 &m_AnnotatePanel.regroup_units, false ) );
489
490 m_params.emplace_back( new PARAM<int>( "annotation.scope",
491 &m_AnnotatePanel.scope, 0, 0, 2 ) );
492
493 m_params.emplace_back( new PARAM<int>( "annotation.options",
494 &m_AnnotatePanel.options, 0, 0, 2 ) );
495
496 m_params.emplace_back( new PARAM<int>( "annotation.messages_filter",
497 &m_AnnotatePanel.messages_filter, -1 ) );
498
499
500 m_params.emplace_back( new PARAM<wxString>( "bom.selected_plugin",
501 &m_BomPanel.selected_plugin, "" ) );
502
503 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "bom.plugins",
504 std::bind( &EESCHEMA_SETTINGS::bomSettingsToJson, this ),
505 [&]( const nlohmann::json& aObj )
506 {
507 if( !aObj.is_array() )
508 return;
509
510 const nlohmann::json& list = aObj.empty() ? defaultBomPlugins : aObj;
511
512 m_BomPanel.plugins = bomSettingsFromJson( list );
513 },
515
516 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "netlist.plugins",
518 [&]( const nlohmann::json& aObj )
519 {
520 if( !aObj.is_array() )
521 return;
522
523 if( aObj.empty() )
524 return;
525
526 const nlohmann::json& list = aObj;
527
528 m_NetlistPanel.plugins = netlistSettingsFromJson( list );
529 },
530 nullptr ) );
531
532 m_params.emplace_back( new PARAM<bool>( "page_settings.export_paper",
533 &m_PageSettings.export_paper, false ) );
534
535 m_params.emplace_back( new PARAM<bool>( "page_settings.export_revision",
536 &m_PageSettings.export_revision, false ) );
537
538 m_params.emplace_back( new PARAM<bool>( "page_settings.export_date",
539 &m_PageSettings.export_date, false ) );
540
541 m_params.emplace_back( new PARAM<bool>( "page_settings.export_title",
542 &m_PageSettings.export_title, false ) );
543
544 m_params.emplace_back( new PARAM<bool>( "page_settings.export_company",
545 &m_PageSettings.export_company, false ) );
546
547 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment1",
548 &m_PageSettings.export_comment1, false ) );
549
550 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment2",
551 &m_PageSettings.export_comment2, false ) );
552
553 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment3",
554 &m_PageSettings.export_comment3, false ) );
555
556 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment4",
557 &m_PageSettings.export_comment4, false ) );
558
559 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment5",
560 &m_PageSettings.export_comment5, false ) );
561
562 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment6",
563 &m_PageSettings.export_comment6, false ) );
564
565 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment7",
566 &m_PageSettings.export_comment7, false ) );
567
568 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment8",
569 &m_PageSettings.export_comment8, false ) );
570
571 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment9",
572 &m_PageSettings.export_comment9, false ) );
573
574 m_params.emplace_back( new PARAM_MAP<int>( "field_editor.field_widths",
575 &m_FieldEditorPanel.field_widths, {} ) );
576
577 m_params.emplace_back( new PARAM_MAP<std::vector<std::string>>( "database_library.column_choices",
579
580 m_params.emplace_back( new PARAM<int>( "field_editor.selection_mode",
581 &m_FieldEditorPanel.selection_mode, 0 ) );
582
583 m_params.emplace_back( new PARAM<int>( "field_editor.sash_pos",
584 &m_FieldEditorPanel.sash_pos, 400 ) );
585
586 m_params.emplace_back( new PARAM<int>( "field_editor.variant_sash_pos",
587 &m_FieldEditorPanel.variant_sash_pos, 500 ) );
588
589 m_params.emplace_back( new PARAM<bool>( "field_editor.sidebar_collapsed",
590 &m_FieldEditorPanel.sidebar_collapsed, false ) );
591
592 addParamsForWindow( &m_Simulator.window, "simulator.window", 500, 400 );
593
594 m_params.emplace_back( new PARAM<int>( "simulator.plot_panel_width",
595 &m_Simulator.view.plot_panel_width, 0 ) );
596
597 m_params.emplace_back( new PARAM<int>( "simulator.plot_panel_height",
598 &m_Simulator.view.plot_panel_height, 0 ) );
599
600 m_params.emplace_back( new PARAM<int>( "simulator.signal_panel_height",
601 &m_Simulator.view.signal_panel_height, 0 ) );
602
603 m_params.emplace_back( new PARAM<int>( "simulator.cursors_panel_height",
604 &m_Simulator.view.cursors_panel_height, 0 ) );
605
606 m_params.emplace_back( new PARAM<int>( "simulator.measurements_panel_height",
607 &m_Simulator.view.measurements_panel_height, 0 ) );
608
609 m_params.emplace_back( new PARAM<bool>( "simulator.white_background",
610 &m_Simulator.view.white_background, false ) );
611
612 m_params.emplace_back(
613 new PARAM<wxString>( "simulator.smith_cursor_columns", &m_Simulator.view.smith_cursor_columns, "" ) );
614
615 m_params.emplace_back( new PARAM_ENUM<SIM_MOUSE_WHEEL_ACTION>( "simulator.mouse_wheel_actions.vertical_unmodified",
616 &m_Simulator.preferences.mouse_wheel_actions.vertical_unmodified,
619
620 m_params.emplace_back( new PARAM_ENUM<SIM_MOUSE_WHEEL_ACTION>( "simulator.mouse_wheel_actions.vertical_with_ctrl",
621 &m_Simulator.preferences.mouse_wheel_actions.vertical_with_ctrl,
624
625 m_params.emplace_back( new PARAM_ENUM<SIM_MOUSE_WHEEL_ACTION>( "simulator.mouse_wheel_actions.vertical_with_shift",
626 &m_Simulator.preferences.mouse_wheel_actions.vertical_with_shift,
629
630 m_params.emplace_back( new PARAM_ENUM<SIM_MOUSE_WHEEL_ACTION>( "simulator.mouse_wheel_actions.vertical_with_alt",
631 &m_Simulator.preferences.mouse_wheel_actions.vertical_with_alt,
634
635 m_params.emplace_back( new PARAM_ENUM<SIM_MOUSE_WHEEL_ACTION>( "simulator.mouse_wheel_actions.horizontal",
636 &m_Simulator.preferences.mouse_wheel_actions.horizontal, SIM_MOUSE_WHEEL_ACTION::NONE,
638
639 m_params.emplace_back( new PARAM<int>( "symbol_chooser.sash_pos_h",
640 &m_SymChooserPanel.sash_pos_h, -1 ) );
641
642 m_params.emplace_back( new PARAM<int>( "symbol_chooser.sash_pos_v",
643 &m_SymChooserPanel.sash_pos_v, -1 ) );
644
645 m_params.emplace_back( new PARAM<int>( "symbol_chooser.width",
646 &m_SymChooserPanel.width, -1 ) );
647
648 m_params.emplace_back( new PARAM<int>( "symbol_chooser.height",
649 &m_SymChooserPanel.height, -1 ) );
650
651 m_params.emplace_back( new PARAM<int>( "symbol_chooser.sort_mode",
652 &m_SymChooserPanel.sort_mode, 0 ) );
653
654 m_params.emplace_back( new PARAM<bool>( "ERC.crossprobe",
655 &m_ERCDialog.crossprobe, true ) );
656
657 m_params.emplace_back( new PARAM<bool>( "ERC.scroll_on_crossprobe",
658 &m_ERCDialog.scroll_on_crossprobe, true ) );
659
660 m_params.emplace_back( new PARAM<bool>( "ERC.show_all_errors",
661 &m_ERCDialog.show_all_errors, false ) );
662
663 m_params.emplace_back( new PARAM<bool>( "change_symbols.update_references",
664 &m_ChangeSymbols.updateReferences, false ) );
665
666 m_params.emplace_back( new PARAM<bool>( "change_symbols.update_values",
667 &m_ChangeSymbols.updateValues, false ) );
668
669 m_params.emplace_back( new PARAM<bool>( "system.never_show_rescue_dialog",
670 &m_RescueNeverShow, false ) );
671
672 addParamsForWindow( &m_LibViewPanel.window, "lib_view.window", 500, 400 );
673
674 m_params.emplace_back( new PARAM<int>( "lib_view.lib_list_width",
675 &m_LibViewPanel.lib_list_width, 150 ) );
676
677 m_params.emplace_back( new PARAM<int>( "lib_view.cmp_list_width",
678 &m_LibViewPanel.cmp_list_width, 150 ) );
679
680 m_params.emplace_back( new PARAM<bool>( "lib_view.show_pin_electrical_type",
681 &m_LibViewPanel.show_pin_electrical_type, true ) );
682
683 m_params.emplace_back( new PARAM<bool>( "lib_view.show_pin_numbers",
684 &m_LibViewPanel.show_pin_numbers, true ) );
685
686 m_params.emplace_back( new PARAM<wxString>( "system.last_symbol_lib_dir",
687 &m_lastSymbolLibDir, "" ) );
688
689 // Migrations
690 registerMigration( 0, 1,
691 [&]() -> bool
692 {
693 // Version 0 to 1: BOM plugin settings moved from sexpr to JSON
694 return migrateBomSettings();
695 } );
696
697
698 registerMigration( 1, 2,
699 [&]() -> bool
700 {
701 // We used to have a bug on GTK which would set the lib tree column width way
702 // too narrow.
703 if( std::optional<int> optval = Get<int>( "lib_tree.column_width" ) )
704 {
705 if( optval < 150 )
706 Set( "lib_tree.column_width", 300 );
707 }
708
709 return true;
710 } );
711
712 registerMigration( 2, 3,
713 [&]() -> bool
714 {
715 // This is actually a migration for APP_SETTINGS_BASE::m_LibTree
716 return migrateLibTreeWidth();
717 } );
718
719 registerMigration( 3, 4,
720 [&]() -> bool
721 {
723 } );
724}
725
726
728{
729 if( std::optional<wxString> fieldNames = Get<wxString>( "drawing.field_names" ) )
730 {
731 if( PGM_BASE* pgm = PgmOrNull() )
732 {
733 COMMON_SETTINGS* commonSettings = pgm->GetCommonSettings();
734 TEMPLATES& templates = commonSettings->m_FieldNameTemplates;
735
736 if( templates.GetTemplateFieldNames( TEMPLATES::SCOPE::GLOBAL ).empty()
737 && !fieldNames->IsEmpty() )
738 {
739 templates.AddTemplateFieldNames( *fieldNames, TEMPLATES::SCOPE::GLOBAL );
740 pgm->GetSettingsManager().SyncGlobalFieldNameTemplatesToProjects();
741 pgm->GetSettingsManager().Save( commonSettings );
742 }
743 }
744 }
745
746 if( Contains( "drawing.field_names" ) )
747 At( "drawing" ).erase( "field_names" );
748
749 return true;
750}
751
752
753bool EESCHEMA_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
754{
755 bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
756
757 // Now modify the loaded grid selection, because in earlier versions the grids index was shared
758 // between all applications and started at 1000 mils. There is a 4-position offset between
759 // this index and the possible eeschema grids list that we have to subtract.
760 std::string gridSizePtr = "window.grid.last_size";
761
762 if( std::optional<int> currentSize = Get<int>( gridSizePtr ) )
763 {
764 Set( gridSizePtr, *currentSize - 4 );
765 }
766 else
767 {
768 // Otherwise, default grid size should be 50 mils; index 1
769 Set( gridSizePtr, 1 );
770 }
771
772 ret &= fromLegacy<bool>( aCfg, "FootprintPreview", "appearance.footprint_preview" );
773 ret &= fromLegacy<bool>( aCfg, "NavigatorStaysOpen", "appearance.navigator_stays_open" );
774 ret &= fromLegacy<bool>( aCfg, "PrintSheetReferenceAndTitleBlock", "appearance.print_sheet_reference" );
775 ret &= fromLegacy<bool>( aCfg, "ShowHiddenPins", "appearance.show_hidden_pins" );
776 ret &= fromLegacy<bool>( aCfg, "ShowIllegalSymbolLibDialog", "appearance.show_illegal_symbol_lib_dialog" );
777 ret &= fromLegacy<bool>( aCfg, "ShowPageLimits", "appearance.show_page_limits" );
778 ret &= fromLegacy<bool>( aCfg, "ShowSheetFileNameCaseSensitivityDlg", "appearance.show_sheet_filename_case_sensitivity_dialog" );
779
780 ret &= fromLegacy<bool>( aCfg, "AutoplaceFields", "autoplace_fields.enable" );
781 ret &= fromLegacy<bool>( aCfg, "AutoplaceJustify", "autoplace_fields.allow_rejustify" );
782 ret &= fromLegacy<bool>( aCfg, "AutoplaceAlign", "autoplace_fields.align_to_grid" );
783
784 ret &= fromLegacy<int>( aCfg, "DefaultBusWidth", "drawing.default_bus_thickness" );
785 ret &= fromLegacy<int>( aCfg, "DefaultJunctionSize", "drawing.default_junction_size" );
786 ret &= fromLegacy<int>( aCfg, "DefaultDrawLineWidth", "drawing.default_line_thickness" );
787 ret &= fromLegacy<int>( aCfg, "RepeatStepX", "drawing.default_repeat_offset_x" );
788 ret &= fromLegacy<int>( aCfg, "RepeatStepY", "drawing.default_repeat_offset_y" );
789 ret &= fromLegacy<int>( aCfg, "DefaultWireWidth", "drawing.default_wire_thickness" );
790
791 ret &= fromLegacyString( aCfg, "FieldNames", "drawing.field_names" );
793
794 ret &= fromLegacy<bool>( aCfg, "HorizVertLinesOnly", "drawing.line_mode" );
795 ret &= fromLegacy<int>( aCfg, "RepeatLabelIncrement", "drawing.repeat_label_increment" );
796
797 ret &= fromLegacy<bool>( aCfg, "DragActionIsMove", "input.drag_is_move" );
798
799 ret &= fromLegacy<int>( aCfg, "SelectionThickness", "selection.thickness" );
800 ret &= fromLegacy<bool>( aCfg, "SelectionDrawChildItems", "selection.draw_selected_children" );
801 ret &= fromLegacy<bool>( aCfg, "SelectionFillShapes", "selection.fill_shapes" );
802 ret &= fromLegacy<bool>( aCfg, "SelectPinSelectSymbolOpt", "selection.select_pin_selects_symbol" );
803
804 ret &= fromLegacy<int>( aCfg, "AnnotateFilterMsg", "annotation.messages_filter" );
805
806 ret &= fromLegacyString( aCfg, "bom_plugin_selected", "bom.selected_plugin" );
807 ret &= fromLegacyString( aCfg, "bom_plugins", "bom.plugins" );
808
810
811 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportRevision", "page_settings.export_revision" );
812 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportDate", "page_settings.export_date" );
813 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportTitle", "page_settings.export_title" );
814 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportCompany", "page_settings.export_company" );
815 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment1", "page_settings.export_comment1" );
816 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment2", "page_settings.export_comment2" );
817 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment3", "page_settings.export_comment3" );
818 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment4", "page_settings.export_comment4" );
819 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment5", "page_settings.export_comment5" );
820 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment6", "page_settings.export_comment6" );
821 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment7", "page_settings.export_comment7" );
822 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment8", "page_settings.export_comment8" );
823 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment9", "page_settings.export_comment9" );
824
825 #if 0 // To do: move this code to the new netlist plugin management in settings
826 {
827 constexpr int max_custom_commands = 8; // from DIALOG_NETLIST
828 nlohmann::json js_cmd = nlohmann::json::array();
829 nlohmann::json js_title = nlohmann::json::array();
830 wxString cmd_key, title_key, cmd, title;
831
832 for( int i = 1; i <= max_custom_commands; ++i )
833 {
834 // Only migrate if both title and command are specified
835 cmd_key.Printf( "CustomNetlistCommand%d", i );
836 title_key.Printf( "CustomNetlistTitle%d", i );
837
838 if( aCfg->Read( cmd_key, &cmd ) && aCfg->Read( title_key, &title )
839 && !cmd.IsEmpty() && !title.IsEmpty() )
840 {
841 js_cmd.push_back( cmd.ToUTF8() );
842 js_title.push_back( title.ToUTF8() );
843 }
844 }
845
846 Set( "netlist.custom_command_titles", js_title );
847 Set( "netlist.custom_command_paths", js_cmd );
848 }
849 #endif
850
851 {
852 // NOTE(JE) These parameters should move to project-local storage before V6, but we are
853 // migrating them here in order to preserve data. There is a bug here that is preserved:
854 // keys are taken directly from the (translated) UI and stored in the config, so if the user
855 // changes languages the keys will no longer work.
856 aCfg->SetPath( "SymbolFieldEditor/Show/" );
857
858 nlohmann::json js = nlohmann::json( {} );
859 wxString key;
860 bool value = false;
861 long index = 0;
862
863 while( aCfg->GetNextEntry( key, index ) )
864 {
865 if( aCfg->Read( key, &value ) )
866 {
867 std::string key_utf( key.ToUTF8() );
868
869 try
870 {
871 js[ std::move( key_utf ) ] = value;
872 }
873 catch(...)
874 {
875 continue;
876 }
877 }
878 }
879
880 Set( "field_editor.fields_show", js );
881
882 aCfg->SetPath( "../GroupBy" );
883
884 while( aCfg->GetNextEntry( key, index ) )
885 {
886 if( aCfg->Read( key, &value ) )
887 {
888 std::string key_utf( key.ToUTF8() );
889
890 try
891 {
892 js[ std::move( key_utf ) ] = value;
893 }
894 catch(...)
895 {
896 continue;
897 }
898 }
899 }
900
901 Set( "field_editor.fields_group_by", js );
902
903 aCfg->SetPath( "../.." );
904 }
905
906 ret &= fromLegacy<bool>( aCfg, "PlotModeColor", "plot.color" );
907 ret &= fromLegacy<int>( aCfg, "PlotFormat", "plot.format" );
908 ret &= fromLegacy<bool>( aCfg, "PlotFrameRef", "plot.frame_reference" );
909
910 ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMEPos_x", "simulator.window.pos_x" );
911 ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMEPos_y", "simulator.window.pos_y" );
912 ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMESize_x", "simulator.window.size_x" );
913 ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMESize_y", "simulator.window.size_y" );
914 ret &= fromLegacy<bool>( aCfg, "SIM_PLOT_FRAMEMaximized", "simulator.window.maximized" );
915 ret &= fromLegacyString( aCfg, "SIM_PLOT_FRAMEPerspective", "simulator.window.perspective" );
916 ret &= fromLegacyString( aCfg, "SIM_PLOT_FRAMEMostRecentlyUsedPath", "simulator.mru_path" );
917 ret &= fromLegacy<int>( aCfg, "SimPlotPanelWidth", "simulator.plot_panel_width" );
918 ret &= fromLegacy<int>( aCfg, "SimPlotPanelHeight", "simulator.plot_panel_height" );
919 ret &= fromLegacy<int>( aCfg, "SimSignalPanelHeight", "simulator.signal_panel_height" );
920 ret &= fromLegacy<int>( aCfg, "SimCursorsPanelHeight", "simulator.cursors_panel_height" );
921 ret &= fromLegacy<bool>( aCfg, "SimPlotWhiteBg", "simulator.white_background" );
922
923 ret &= fromLegacy<int>( aCfg, "SymbolChooserHSashPosition", "symbol_chooser.sash_pos_h" );
924 ret &= fromLegacy<int>( aCfg, "SymbolChooserVSashPosition", "symbol_chooser.sash_pos_v" );
925 ret &= fromLegacy<int>( aCfg, "SymbolChooserWidth", "symbol_chooser.width" );
926 ret &= fromLegacy<int>( aCfg, "SymbolChooserHeight", "symbol_chooser.height" );
927
928 const std::string vlf = "ViewlibFrame";
929 ret &= fromLegacy<bool>( aCfg, vlf + "Maximized", "lib_view.window.maximized" );
930 ret &= fromLegacyString( aCfg, vlf + "MostRecentlyUsedPath", "lib_view.window.mru_path" );
931 ret &= fromLegacy<int>( aCfg, vlf + "Size_x", "lib_view.window.size_x" );
932 ret &= fromLegacy<int>( aCfg, vlf + "Size_y", "lib_view.window.size_y" );
933 ret &= fromLegacyString( aCfg, vlf + "Perspective", "lib_view.window.perspective" );
934 ret &= fromLegacy<int>( aCfg, vlf + "Pos_x", "lib_view.window.pos_x" );
935 ret &= fromLegacy<int>( aCfg, vlf + "Pos_y", "lib_view.window.pos_y" );
936 ret &= fromLegacy<int>( aCfg, "ViewLiblistWidth", "lib_view.lib_list_width" );
937 ret &= fromLegacy<int>( aCfg, "ViewCmplistWidth", "lib_view.cmp_list_width" );
938 ret &= fromLegacy<bool>( aCfg,
939 "ViewCmpShowPinElectricalType", "lib_view.show_pin_electrical_type" );
940 ret &= fromLegacy<bool>( aCfg, vlf + "ShowGrid", "lib_view.grid.show" );
941 ret &= fromLegacy<int>( aCfg, vlf + "_LastGridSize", "lib_view.grid.last_size" );
942
943 ret &= fromLegacy<bool>( aCfg, "RescueNeverShow", "system.never_show_rescue_dialog" );
944
945 // Legacy version stored this setting in eeschema, so move it to common if it exists
946 bool tmp;
947
948 if( aCfg->Read( "MoveWarpsCursor", &tmp ) )
949 Pgm().GetCommonSettings()->m_Input.warp_mouse_on_move = tmp;
950
953
954 auto migrateLegacyColor =
955 [&] ( const std::string& aKey, int aLayerId )
956 {
957 wxString str;
958
959 if( aCfg->Read( aKey, &str ) )
960 cs->SetColor( aLayerId, COLOR4D( str ) );
961 };
962
963 migrateLegacyColor( "Color4DBgCanvasEx", LAYER_SCHEMATIC_BACKGROUND );
964 migrateLegacyColor( "Color4DBodyBgEx", LAYER_DEVICE_BACKGROUND );
965 migrateLegacyColor( "Color4DBodyEx", LAYER_DEVICE );
966 migrateLegacyColor( "Color4DBrightenedEx", LAYER_BRIGHTENED );
967 migrateLegacyColor( "Color4DBusEx", LAYER_BUS );
968 migrateLegacyColor( "Color4DConnEx", LAYER_JUNCTION );
969 migrateLegacyColor( "Color4DCursorEx", LAYER_SCHEMATIC_CURSOR );
970 migrateLegacyColor( "Color4DErcEEx", LAYER_ERC_ERR );
971 migrateLegacyColor( "Color4DErcWEx", LAYER_ERC_WARN );
972 migrateLegacyColor( "Color4DFieldEx", LAYER_FIELDS );
973 migrateLegacyColor( "Color4DGLabelEx", LAYER_GLOBLABEL );
974 migrateLegacyColor( "Color4DGridEx", LAYER_SCHEMATIC_GRID );
975 migrateLegacyColor( "Color4DHLabelEx", LAYER_HIERLABEL );
976 migrateLegacyColor( "Color4DHiddenEx", LAYER_HIDDEN );
977 migrateLegacyColor( "Color4DLLabelEx", LAYER_LOCLABEL );
978 migrateLegacyColor( "Color4DNoConnectEx", LAYER_NOCONNECT );
979 migrateLegacyColor( "Color4DNoteEx", LAYER_NOTES );
980 migrateLegacyColor( "Color4DPinEx", LAYER_PIN );
981 migrateLegacyColor( "Color4DPinNameEx", LAYER_PINNAM );
982 migrateLegacyColor( "Color4DPinNumEx", LAYER_PINNUM );
983 migrateLegacyColor( "Color4DReferenceEx", LAYER_REFERENCEPART );
984 migrateLegacyColor( "Color4DShadowEx", LAYER_SELECTION_SHADOWS );
985 migrateLegacyColor( "Color4DSheetEx", LAYER_SHEET );
986 migrateLegacyColor( "Color4DSheetFileNameEx", LAYER_SHEETFILENAME );
987 migrateLegacyColor( "Color4DSheetLabelEx", LAYER_SHEETLABEL );
988 migrateLegacyColor( "Color4DSheetNameEx", LAYER_SHEETNAME );
989 migrateLegacyColor( "Color4DValueEx", LAYER_VALUEPART );
990 migrateLegacyColor( "Color4DWireEx", LAYER_WIRE );
991 migrateLegacyColor( "Color4DWorksheetEx", LAYER_SCHEMATIC_DRAWINGSHEET );
992
993 mgr.SaveColorSettings( cs, "schematic" );
994
995 Set( "appearance.color_theme", cs->GetFilename() );
996
997 // LibEdit settings were stored with eeschema. If eeschema is the first app to run,
998 // we need to migrate the LibEdit settings here
999
1000 if( SYMBOL_EDITOR_SETTINGS* sym_edit_cfg = GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" ) )
1001 {
1002 sym_edit_cfg->MigrateFromLegacy( aCfg );
1003 sym_edit_cfg->Load();
1004 }
1005
1006 return ret;
1007}
1008
1009
1014class BOM_CFG_PARSER : public DIALOG_BOM_CFG_LEXER
1015{
1016 std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS>* m_pluginList;
1017
1018public:
1019 BOM_CFG_PARSER( std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS>* aPluginList,
1020 const char* aData, const wxString& aSource );
1021
1022 void Parse();
1023
1024private:
1025 void parseGenerator();
1026};
1027
1028
1029std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS> EESCHEMA_SETTINGS::DefaultBomPlugins()
1030{
1032}
1033
1034
1036{
1037 if( !Contains( "bom.plugins" ) )
1038 return false;
1039
1040 wxString list = *Get<wxString>( "bom.plugins" );
1041
1042 BOM_CFG_PARSER cfg_parser( &m_BomPanel.plugins, TO_UTF8( list ), wxT( "plugins" ) );
1043
1044 try
1045 {
1046 cfg_parser.Parse();
1047 }
1048 catch( const IO_ERROR& )
1049 {
1050 return false;
1051 }
1052
1053 // Parser will have loaded up our array, let's dump it out to JSON
1054 At( "bom.plugins" ) = bomSettingsToJson();
1055
1056 return true;
1057}
1058
1059
1061{
1062 nlohmann::json js = nlohmann::json::array();
1063
1064 for( const BOM_PLUGIN_SETTINGS& plugin : m_BomPanel.plugins )
1065 {
1066 nlohmann::json pluginJson;
1067
1068 pluginJson["name"] = plugin.name.ToUTF8();
1069 pluginJson["path"] = plugin.path.ToUTF8();
1070 pluginJson["command"] = plugin.command.ToUTF8();
1071
1072 js.push_back( pluginJson );
1073 }
1074
1075 return js;
1076}
1077
1078
1079std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS> EESCHEMA_SETTINGS::bomSettingsFromJson(
1080 const nlohmann::json& aObj )
1081{
1082 std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS> ret;
1083
1084 wxASSERT( aObj.is_array() );
1085
1086 for( const nlohmann::json& entry : aObj )
1087 {
1088 if( entry.empty() || !entry.is_object() )
1089 continue;
1090
1091 if( !entry.contains( "name" ) || !entry.contains( "path" ) )
1092 continue;
1093
1094 BOM_PLUGIN_SETTINGS plugin( entry.at( "name" ).get<wxString>(),
1095 entry.at( "path" ).get<wxString>() );
1096
1097 if( entry.contains( "command" ) )
1098 plugin.command = entry.at( "command" ).get<wxString>();
1099
1100 ret.emplace_back( plugin );
1101 }
1102
1103 return ret;
1104}
1105
1106
1108{
1109 nlohmann::json js = nlohmann::json::array();
1110
1111 for( const NETLIST_PLUGIN_SETTINGS& plugin : m_NetlistPanel.plugins )
1112 {
1113 nlohmann::json pluginJson;
1114
1115 pluginJson["name"] = plugin.name.ToUTF8();
1116 pluginJson["path"] = plugin.path.ToUTF8();
1117 pluginJson["command"] = plugin.command.ToUTF8();
1118
1119 js.push_back( pluginJson );
1120 }
1121
1122 return js;
1123}
1124
1125
1126std::vector<EESCHEMA_SETTINGS::NETLIST_PLUGIN_SETTINGS> EESCHEMA_SETTINGS::netlistSettingsFromJson(
1127 const nlohmann::json& aObj )
1128{
1129 std::vector<EESCHEMA_SETTINGS::NETLIST_PLUGIN_SETTINGS> ret;
1130
1131 wxASSERT( aObj.is_array() );
1132
1133 for( const nlohmann::json& entry : aObj )
1134 {
1135 if( entry.empty() || !entry.is_object() )
1136 continue;
1137
1138 if( !entry.contains( "name" ) || !entry.contains( "path" ) )
1139 continue;
1140
1141 NETLIST_PLUGIN_SETTINGS plugin( entry.at( "name" ).get<wxString>(),
1142 entry.at( "path" ).get<wxString>() );
1143
1144 if( entry.contains( "command" ) )
1145 plugin.command = entry.at( "command" ).get<wxString>();
1146
1147 ret.emplace_back( plugin );
1148 }
1149
1150 return ret;
1151}
1152
1153
1154BOM_CFG_PARSER::BOM_CFG_PARSER( std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS>* aPluginList,
1155 const char* aLine, const wxString& aSource ) :
1156 DIALOG_BOM_CFG_LEXER( aLine, aSource )
1157{
1158 wxASSERT( aPluginList );
1159 m_pluginList = aPluginList;
1160}
1161
1162
1164{
1165 T token;
1166
1167 while( ( token = NextTok() ) != T_RIGHT )
1168 {
1169 if( token == T_EOF)
1170 break;
1171
1172 if( token == T_LEFT )
1173 token = NextTok();
1174
1175 if( token == T_plugins )
1176 continue;
1177
1178 switch( token )
1179 {
1180 case T_plugin: // Defines a new plugin
1182 break;
1183
1184 default:
1185// Unexpected( CurText() );
1186 break;
1187 }
1188 }
1189}
1190
1191
1193{
1194 wxString str;
1196
1197 NeedSYMBOLorNUMBER();
1198 settings.path = FromUTF8();
1199
1200 T token;
1201
1202 while( ( token = NextTok() ) != T_RIGHT )
1203 {
1204 if( token == T_EOF)
1205 break;
1206
1207 switch( token )
1208 {
1209 case T_LEFT:
1210 break;
1211
1212 case T_cmd:
1213 NeedSYMBOLorNUMBER();
1214
1215 settings.command = FromUTF8();
1216
1217 NeedRIGHT();
1218 break;
1219
1220 case T_opts:
1221 {
1222 NeedSYMBOLorNUMBER();
1223
1224 wxString option = FromUTF8();
1225
1226 if( option.StartsWith( wxS( "nickname=" ), &str ) )
1227 settings.name = str;
1228
1229 NeedRIGHT();
1230 break;
1231 }
1232
1233 default:
1234 Unexpected( CurText() );
1235 break;
1236 }
1237 }
1238
1239 m_pluginList->emplace_back( settings );
1240}
int index
@ KEEP_CENTER_ADJUST_ANGLE_RADIUS
When editing endpoints, the angle and radius are adjusted.
APP_SETTINGS_BASE(const std::string &aFilename, int aSchemaVersion)
void addParamsForWindow(WINDOW_SETTINGS *aWindow, const std::string &aJsonPath, int aDefaultWidth=0, int aDefaultHeight=0)
Add parameters for the given window object.
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
bool migrateLibTreeWidth()
Migrate the library tree width setting from a single column (Item) to multi-column.
Used for parsing legacy-format bom plugin configurations.
BOM_CFG_PARSER(std::vector< EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS > *aPluginList, const char *aData, const wxString &aSource)
std::vector< EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS > * m_pluginList
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:400
Color settings are a bit different than most of the settings objects in that there can be more than o...
void SetColor(int aLayer, const COLOR4D &aColor)
TEMPLATES m_FieldNameTemplates
Global field name templates shared by all project editors.
static const wxString PropertiesPaneName()
static const wxString RemoteSymbolPaneName()
static const wxString DesignBlocksPaneName()
PANEL_ANNOTATE m_AnnotatePanel
static std::vector< BOM_PLUGIN_SETTINGS > DefaultBomPlugins()
FIELDS_TABLE_SETTINGS m_FieldEditorPanel
PANEL_NETLIST m_NetlistPanel
nlohmann::json bomSettingsToJson() const
virtual bool MigrateFromLegacy(wxConfigBase *aLegacyConfig) override
Migrates from wxConfig to JSON-based configuration.
DIALOG_CHANGE_SYMBOLS m_ChangeSymbols
SNAP_INFERENCE_SETTINGS m_SnapInference
nlohmann::json netlistSettingsToJson() const
PANEL_SYM_CHOOSER m_SymChooserPanel
PAGE_SETTINGS m_PageSettings
static std::vector< BOM_PLUGIN_SETTINGS > bomSettingsFromJson(const nlohmann::json &aObj)
std::map< std::string, std::vector< std::string > > m_DatabaseColumnChoices
Database columns the user mapped to each library role, most recent first, used to autofill.
REMOTE_PROVIDER_SETTINGS m_RemoteSymbol
FIND_REPLACE_EXTRA m_FindReplaceExtra
PANEL_LIB_VIEW m_LibViewPanel
AUTOPLACE_FIELDS m_AutoplaceFields
static std::vector< NETLIST_PLUGIN_SETTINGS > netlistSettingsFromJson(const nlohmann::json &aObj)
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
bool fromLegacyString(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy wxConfig string value to a given JSON pointer value.
bool fromLegacy(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy wxConfig value to a given JSON pointer value.
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...
bool Contains(const std::string &aPath) const
std::optional< ValueType > Get(const std::string &aPath) const
Fetches a value from within the JSON document.
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.
nlohmann::json & At(const std::string &aPath)
Wrappers for the underlying JSON API so that most consumers don't need json.hpp All of these function...
wxString GetFilename() const
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
Stores an enum as an integer.
Definition parameters.h:232
Like a normal param, but with custom getter and setter functions.
Definition parameters.h:299
Represents a map of <std::string, Value>.
Definition parameters.h:752
Container for data for KiCad programs.
Definition pgm_base.h:101
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:562
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:123
void SaveColorSettings(COLOR_SETTINGS *aSettings, const std::string &aNamespace="")
Safely save a COLOR_SETTINGS to disk, preserving any changes outside the given namespace.
COLOR_SETTINGS * GetMigratedColorSettings()
Return a color theme for storing colors migrated from legacy (5.x and earlier) settings,...
void AddTemplateFieldNames(const wxString &aSerializedFieldNames, SCOPE aScope)
Add a serialized list of template field names.
const std::vector< TEMPLATE_FIELDNAME > & GetTemplateFieldNames(SCOPE aScope)
Return a specific list (global or project) for read only access.
#define DEFAULT_BUS_WIDTH_MILS
The default bus width in mils. (can be changed in preference menu)
#define DEFAULT_IREF_PREFIX
The intersheets references prefix string.
#define DEFAULT_JUNCTION_DIAM
The default junction diameter in mils. (can be changed in preference menu)
#define DEFAULT_WIRE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
#define DEFAULT_LINE_WIDTH_MILS
The default line width in mils. (can be changed in preference menu)
#define DEFAULT_IREF_SUFFIX
The intersheets references suffix string.
#define DEFAULT_TEXT_SIZE
The default text size in mils. (can be changed in preference menu)
#define _(s)
const nlohmann::json defaultBomPlugins
Default value for bom.plugins.
const wxAuiPaneInfo & defaultSchSelectionFilterPaneInfo(wxWindow *aWindow)
const wxAuiPaneInfo & defaultPropertiesPaneInfo(wxWindow *aWindow)
const wxAuiPaneInfo & defaultNetNavigatorPaneInfo()
const int eeschemaSchemaVersion
Update the schema version whenever a migration is required.
const wxAuiPaneInfo & defaultDesignBlocksPaneInfo(wxWindow *aWindow)
const wxAuiPaneInfo & defaultRemoteSymbolPaneInfo(wxWindow *aWindow)
@ LINE_MODE_90
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition idf_helpers.h:37
@ LAYER_SHEETNAME
Definition layer_ids.h:500
@ LAYER_ERC_WARN
Definition layer_ids.h:507
@ LAYER_SHEETLABEL
Definition layer_ids.h:503
@ LAYER_PINNUM
Definition layer_ids.h:486
@ LAYER_DEVICE
Definition layer_ids.h:494
@ LAYER_BRIGHTENED
Definition layer_ids.h:519
@ LAYER_HIDDEN
Definition layer_ids.h:520
@ LAYER_HIERLABEL
Definition layer_ids.h:485
@ LAYER_PINNAM
Definition layer_ids.h:487
@ LAYER_GLOBLABEL
Definition layer_ids.h:484
@ LAYER_WIRE
Definition layer_ids.h:480
@ LAYER_NOTES
Definition layer_ids.h:495
@ LAYER_ERC_ERR
Definition layer_ids.h:508
@ LAYER_PIN
Definition layer_ids.h:498
@ LAYER_VALUEPART
Definition layer_ids.h:489
@ LAYER_BUS
Definition layer_ids.h:481
@ LAYER_SCHEMATIC_CURSOR
Definition layer_ids.h:517
@ LAYER_FIELDS
Definition layer_ids.h:490
@ LAYER_DEVICE_BACKGROUND
Definition layer_ids.h:512
@ LAYER_SCHEMATIC_DRAWINGSHEET
Definition layer_ids.h:524
@ LAYER_LOCLABEL
Definition layer_ids.h:483
@ LAYER_JUNCTION
Definition layer_ids.h:482
@ LAYER_REFERENCEPART
Definition layer_ids.h:488
@ LAYER_SHEET
Definition layer_ids.h:499
@ LAYER_SELECTION_SHADOWS
Definition layer_ids.h:523
@ LAYER_SCHEMATIC_BACKGROUND
Definition layer_ids.h:516
@ LAYER_SHEETFILENAME
Definition layer_ids.h:501
@ LAYER_NOCONNECT
Definition layer_ids.h:504
@ LAYER_SCHEMATIC_GRID
Definition layer_ids.h:514
PGM_BASE & Pgm()
The global program "get" accessor.
PGM_BASE * PgmOrNull()
Return a reference that can be nullptr when running a shared lib from a script, not from a kicad app.
see class PGM_BASE
T * GetAppSettings(const char *aFilename)
void AddSnapInferenceParams(std::vector< PARAM_BASE * > &aParams, SNAP_INFERENCE_SETTINGS &aSettings)
Register the snap inference parameters.
Functions to provide common constants and other functions to assist in making a consistent UI.