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<int>( "aui.properties_panel_width",
322 &m_AuiPanels.properties_panel_width, -1 ) );
323
324 m_params.emplace_back( new PARAM<float>( "aui.properties_splitter_proportion",
325 &m_AuiPanels.properties_splitter, 0.5f ) );
326
327 m_params.emplace_back( new PARAM<bool>( "autoplace_fields.enable",
328 &m_AutoplaceFields.enable, true ) );
329
330 m_params.emplace_back( new PARAM<bool>( "autoplace_fields.allow_rejustify",
331 &m_AutoplaceFields.allow_rejustify, true ) );
332
333 m_params.emplace_back( new PARAM<bool>( "autoplace_fields.align_to_grid",
334 &m_AutoplaceFields.align_to_grid, true ) );
335
336 m_params.emplace_back( new PARAM<wxString>( "remote_symbols.destination_dir",
337 &m_RemoteSymbol.destination_dir,
339
340 m_params.emplace_back( new PARAM<wxString>( "remote_symbols.library_prefix",
341 &m_RemoteSymbol.library_prefix,
343
344 m_params.emplace_back( new PARAM<bool>( "remote_symbols.add_to_global_table",
345 &m_RemoteSymbol.add_to_global_table, false ) );
346
347 m_params.emplace_back( new PARAM<wxString>( "remote_symbols.last_used_provider_id",
348 &m_RemoteSymbol.last_used_provider_id, wxEmptyString ) );
349
350 m_params.emplace_back( new PARAM_LIST<REMOTE_PROVIDER_ENTRY>( "remote_symbols.providers",
351 &m_RemoteSymbol.providers, {} ) );
352
353 m_params.emplace_back( new PARAM<int>( "drawing.default_bus_thickness",
354 &m_Drawing.default_bus_thickness, DEFAULT_BUS_WIDTH_MILS ) );
355
356 m_params.emplace_back( new PARAM<int>( "drawing.default_junction_size",
357 &m_Drawing.default_junction_size, DEFAULT_JUNCTION_DIAM ) );
358
359 m_params.emplace_back( new PARAM<int>( "drawing.pin_symbol_size",
360 &m_Drawing.pin_symbol_size, DEFAULT_TEXT_SIZE / 2 ) );
361
362 m_params.emplace_back( new PARAM<double>( "drawing.text_offset_ratio",
363 &m_Drawing.text_offset_ratio, 0.08 ) );
364
365 m_params.emplace_back( new PARAM<int>( "drawing.default_line_thickness",
366 &m_Drawing.default_line_thickness, DEFAULT_LINE_WIDTH_MILS ) );
367
368 m_params.emplace_back( new PARAM<int>( "drawing.default_repeat_offset_x",
369 &m_Drawing.default_repeat_offset_x, 0 ) );
370
371 m_params.emplace_back( new PARAM<int>( "drawing.default_repeat_offset_y",
372 &m_Drawing.default_repeat_offset_y, 100 ) );
373
374 m_params.emplace_back( new PARAM<int>( "drawing.default_wire_thickness",
375 &m_Drawing.default_wire_thickness, DEFAULT_WIRE_WIDTH_MILS ) );
376
377 m_params.emplace_back( new PARAM<int>( "drawing.default_text_size",
378 &m_Drawing.default_text_size, DEFAULT_TEXT_SIZE ) );
379
380 m_params.emplace_back( new PARAM<int>( "drawing.line_mode",
381 &m_Drawing.line_mode, LINE_MODE::LINE_MODE_90 ) );
382
383 m_params.emplace_back( new PARAM<int>( "editing.arc_edit_mode",
384 reinterpret_cast<int*>( &m_Drawing.arc_edit_mode ),
386
388
389 m_params.emplace_back( new PARAM<bool>( "drawing.auto_start_wires",
390 &m_Drawing.auto_start_wires, true ) );
391
392 m_params.emplace_back( new PARAM<bool>( "drawing.auto_place_sheet_pins",
393 &m_Drawing.auto_place_sheet_pins, true ) );
394
395 m_params.emplace_back( new PARAM<int>( "drawing.repeat_label_increment",
396 &m_Drawing.repeat_label_increment, 1 ) );
397
398 m_params.emplace_back( new PARAM<COLOR4D>( "drawing.default_sheet_border_color",
399 &m_Drawing.default_sheet_border_color, COLOR4D::UNSPECIFIED ) );
400
401 m_params.emplace_back( new PARAM<COLOR4D>( "drawing.default_sheet_background_color",
402 &m_Drawing.default_sheet_background_color, COLOR4D::UNSPECIFIED ) );
403
404 m_params.emplace_back( new PARAM_ENUM<POWER_SYMBOLS>( "drawing.new_power_symbols",
406
407 m_params.emplace_back( new PARAM<bool>( "find_replace.intersheets_ref_show",
408 &m_Drawing.intersheets_ref_show, false ) );
409
410 m_params.emplace_back( new PARAM<bool>( "find_replace.intersheets_ref_own_page",
411 &m_Drawing.intersheets_ref_own_page, true ) );
412
413 m_params.emplace_back( new PARAM<bool>( "find_replace.intersheets_ref_short",
414 &m_Drawing.intersheets_ref_short, false ) );
415
416 m_params.emplace_back( new PARAM<wxString>( "remote_symbols.intersheets_ref_prefix",
417 &m_Drawing.intersheets_ref_prefix, wxS( DEFAULT_IREF_PREFIX ) ) );
418
419 m_params.emplace_back( new PARAM<wxString>( "remote_symbols.intersheets_ref_suffix",
420 &m_Drawing.intersheets_ref_suffix, wxS( DEFAULT_IREF_SUFFIX ) ) );
421
422 m_params.emplace_back( new PARAM<int>( "drawing.junction_size_choice",
423 &m_Drawing.junction_size_choice, 3, 0, 5 ) );
424
425 m_params.emplace_back( new PARAM<int>( "drawing.hop_over_size_choice",
426 &m_Drawing.hop_over_size_choice, 0, 0, 5 ) );
427
428 m_params.emplace_back( new PARAM<bool>( "find_replace.search_all_fields",
429 &m_FindReplaceExtra.search_all_fields, false ) );
430
431 m_params.emplace_back( new PARAM<bool>( "find_replace.search_all_pins",
432 &m_FindReplaceExtra.search_all_pins, false ) );
433
434 m_params.emplace_back( new PARAM<bool>( "find_replace.search_current_sheet_only",
435 &m_FindReplaceExtra.search_current_sheet_only, false ) );
436
437 m_params.emplace_back( new PARAM<bool>( "find_replace.search_selected_only",
438 &m_FindReplaceExtra.search_selected_only, false ) );
439
440 m_params.emplace_back( new PARAM<bool>( "find_replace.replace_references",
441 &m_FindReplaceExtra.replace_references, false ) );
442
443 m_params.emplace_back( new PARAM<bool>( "input.drag_is_move",
444 &m_Input.drag_is_move, false ) );
445
446 m_params.emplace_back( new PARAM<bool>( "input.allow_unconstrained_pin_swaps",
447 &m_Input.allow_unconstrained_pin_swaps, false ) );
448
449 m_params.emplace_back( new PARAM<bool>( "input.esc_clears_net_highlight",
450 &m_Input.esc_clears_net_highlight, true ) );
451
452 m_params.emplace_back( new PARAM<int>( "selection.thickness",
453 &m_Selection.selection_thickness, 3 ) );
454
455 m_params.emplace_back( new PARAM<int>( "selection.highlight_thickness",
456 &m_Selection.highlight_thickness, 2 ) );
457
458 m_params.emplace_back( new PARAM<bool>( "selection.draw_selected_children",
459 &m_Selection.draw_selected_children, true ) );
460
461 m_params.emplace_back( new PARAM<bool>( "selection.fill_shapes",
462 &m_Selection.fill_shapes, false ) );
463
464 m_params.emplace_back( new PARAM<bool>( "selection.select_pin_selects_symbol",
465 &m_Selection.select_pin_selects_symbol, false ) );
466
467 m_params.emplace_back( new PARAM<bool>( "selection.highlight_netclass_colors",
468 &m_Selection.highlight_netclass_colors, false ) );
469
470 m_params.emplace_back( new PARAM<int>( "selection.highlight_netclass_colors_thickness",
471 &m_Selection.highlight_netclass_colors_thickness, 15, 0, 50 ) );
472
473 m_params.emplace_back( new PARAM<double>( "selection.highlight_netclass_colors_alpha",
474 &m_Selection.highlight_netclass_colors_alpha, 0.6, 0, 1 ) );
475
476 m_params.emplace_back( new PARAM<int>( "selection.drag_net_collision_width",
477 &m_Selection.drag_net_collision_width, 4, 1, 50 ) );
478
479 m_params.emplace_back( new PARAM<bool>( "annotation.automatic",
480 &m_AnnotatePanel.automatic, true ) );
481
482 m_params.emplace_back( new PARAM<bool>( "annotation.recursive",
483 &m_AnnotatePanel.recursive, true ) );
484
485 m_params.emplace_back( new PARAM<bool>( "annotation.regroup_units",
486 &m_AnnotatePanel.regroup_units, false ) );
487
488 m_params.emplace_back( new PARAM<int>( "annotation.scope",
489 &m_AnnotatePanel.scope, 0, 0, 2 ) );
490
491 m_params.emplace_back( new PARAM<int>( "annotation.options",
492 &m_AnnotatePanel.options, 0, 0, 2 ) );
493
494 m_params.emplace_back( new PARAM<int>( "annotation.messages_filter",
495 &m_AnnotatePanel.messages_filter, -1 ) );
496
497
498 m_params.emplace_back( new PARAM<wxString>( "bom.selected_plugin",
499 &m_BomPanel.selected_plugin, "" ) );
500
501 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "bom.plugins",
502 std::bind( &EESCHEMA_SETTINGS::bomSettingsToJson, this ),
503 [&]( const nlohmann::json& aObj )
504 {
505 if( !aObj.is_array() )
506 return;
507
508 const nlohmann::json& list = aObj.empty() ? defaultBomPlugins : aObj;
509
510 m_BomPanel.plugins = bomSettingsFromJson( list );
511 },
513
514 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "netlist.plugins",
516 [&]( const nlohmann::json& aObj )
517 {
518 if( !aObj.is_array() )
519 return;
520
521 if( aObj.empty() )
522 return;
523
524 const nlohmann::json& list = aObj;
525
526 m_NetlistPanel.plugins = netlistSettingsFromJson( list );
527 },
528 nullptr ) );
529
530 m_params.emplace_back( new PARAM<bool>( "page_settings.export_paper",
531 &m_PageSettings.export_paper, false ) );
532
533 m_params.emplace_back( new PARAM<bool>( "page_settings.export_revision",
534 &m_PageSettings.export_revision, false ) );
535
536 m_params.emplace_back( new PARAM<bool>( "page_settings.export_date",
537 &m_PageSettings.export_date, false ) );
538
539 m_params.emplace_back( new PARAM<bool>( "page_settings.export_title",
540 &m_PageSettings.export_title, false ) );
541
542 m_params.emplace_back( new PARAM<bool>( "page_settings.export_company",
543 &m_PageSettings.export_company, false ) );
544
545 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment1",
546 &m_PageSettings.export_comment1, false ) );
547
548 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment2",
549 &m_PageSettings.export_comment2, false ) );
550
551 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment3",
552 &m_PageSettings.export_comment3, false ) );
553
554 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment4",
555 &m_PageSettings.export_comment4, false ) );
556
557 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment5",
558 &m_PageSettings.export_comment5, false ) );
559
560 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment6",
561 &m_PageSettings.export_comment6, false ) );
562
563 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment7",
564 &m_PageSettings.export_comment7, false ) );
565
566 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment8",
567 &m_PageSettings.export_comment8, false ) );
568
569 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment9",
570 &m_PageSettings.export_comment9, false ) );
571
572 m_params.emplace_back( new PARAM_MAP<int>( "field_editor.field_widths",
573 &m_FieldEditorPanel.field_widths, {} ) );
574
575 m_params.emplace_back( new PARAM<int>( "field_editor.selection_mode",
576 &m_FieldEditorPanel.selection_mode, 0 ) );
577
578 m_params.emplace_back( new PARAM<int>( "field_editor.sash_pos",
579 &m_FieldEditorPanel.sash_pos, 400 ) );
580
581 m_params.emplace_back( new PARAM<int>( "field_editor.variant_sash_pos",
582 &m_FieldEditorPanel.variant_sash_pos, 500 ) );
583
584 m_params.emplace_back( new PARAM<bool>( "field_editor.sidebar_collapsed",
585 &m_FieldEditorPanel.sidebar_collapsed, false ) );
586
587 addParamsForWindow( &m_Simulator.window, "simulator.window", 500, 400 );
588
589 m_params.emplace_back( new PARAM<int>( "simulator.plot_panel_width",
590 &m_Simulator.view.plot_panel_width, 0 ) );
591
592 m_params.emplace_back( new PARAM<int>( "simulator.plot_panel_height",
593 &m_Simulator.view.plot_panel_height, 0 ) );
594
595 m_params.emplace_back( new PARAM<int>( "simulator.signal_panel_height",
596 &m_Simulator.view.signal_panel_height, 0 ) );
597
598 m_params.emplace_back( new PARAM<int>( "simulator.cursors_panel_height",
599 &m_Simulator.view.cursors_panel_height, 0 ) );
600
601 m_params.emplace_back( new PARAM<int>( "simulator.measurements_panel_height",
602 &m_Simulator.view.measurements_panel_height, 0 ) );
603
604 m_params.emplace_back( new PARAM<bool>( "simulator.white_background",
605 &m_Simulator.view.white_background, false ) );
606
607 m_params.emplace_back(
608 new PARAM<wxString>( "simulator.smith_cursor_columns", &m_Simulator.view.smith_cursor_columns, "" ) );
609
610 m_params.emplace_back( new PARAM_ENUM<SIM_MOUSE_WHEEL_ACTION>( "simulator.mouse_wheel_actions.vertical_unmodified",
611 &m_Simulator.preferences.mouse_wheel_actions.vertical_unmodified,
614
615 m_params.emplace_back( new PARAM_ENUM<SIM_MOUSE_WHEEL_ACTION>( "simulator.mouse_wheel_actions.vertical_with_ctrl",
616 &m_Simulator.preferences.mouse_wheel_actions.vertical_with_ctrl,
619
620 m_params.emplace_back( new PARAM_ENUM<SIM_MOUSE_WHEEL_ACTION>( "simulator.mouse_wheel_actions.vertical_with_shift",
621 &m_Simulator.preferences.mouse_wheel_actions.vertical_with_shift,
624
625 m_params.emplace_back( new PARAM_ENUM<SIM_MOUSE_WHEEL_ACTION>( "simulator.mouse_wheel_actions.vertical_with_alt",
626 &m_Simulator.preferences.mouse_wheel_actions.vertical_with_alt,
629
630 m_params.emplace_back( new PARAM_ENUM<SIM_MOUSE_WHEEL_ACTION>( "simulator.mouse_wheel_actions.horizontal",
631 &m_Simulator.preferences.mouse_wheel_actions.horizontal, SIM_MOUSE_WHEEL_ACTION::NONE,
633
634 m_params.emplace_back( new PARAM<int>( "symbol_chooser.sash_pos_h",
635 &m_SymChooserPanel.sash_pos_h, -1 ) );
636
637 m_params.emplace_back( new PARAM<int>( "symbol_chooser.sash_pos_v",
638 &m_SymChooserPanel.sash_pos_v, -1 ) );
639
640 m_params.emplace_back( new PARAM<int>( "symbol_chooser.width",
641 &m_SymChooserPanel.width, -1 ) );
642
643 m_params.emplace_back( new PARAM<int>( "symbol_chooser.height",
644 &m_SymChooserPanel.height, -1 ) );
645
646 m_params.emplace_back( new PARAM<int>( "symbol_chooser.sort_mode",
647 &m_SymChooserPanel.sort_mode, 0 ) );
648
649 m_params.emplace_back( new PARAM<bool>( "ERC.crossprobe",
650 &m_ERCDialog.crossprobe, true ) );
651
652 m_params.emplace_back( new PARAM<bool>( "ERC.scroll_on_crossprobe",
653 &m_ERCDialog.scroll_on_crossprobe, true ) );
654
655 m_params.emplace_back( new PARAM<bool>( "ERC.show_all_errors",
656 &m_ERCDialog.show_all_errors, false ) );
657
658 m_params.emplace_back( new PARAM<bool>( "change_symbols.update_references",
659 &m_ChangeSymbols.updateReferences, false ) );
660
661 m_params.emplace_back( new PARAM<bool>( "change_symbols.update_values",
662 &m_ChangeSymbols.updateValues, false ) );
663
664 m_params.emplace_back( new PARAM<bool>( "system.never_show_rescue_dialog",
665 &m_RescueNeverShow, false ) );
666
667 addParamsForWindow( &m_LibViewPanel.window, "lib_view.window", 500, 400 );
668
669 m_params.emplace_back( new PARAM<int>( "lib_view.lib_list_width",
670 &m_LibViewPanel.lib_list_width, 150 ) );
671
672 m_params.emplace_back( new PARAM<int>( "lib_view.cmp_list_width",
673 &m_LibViewPanel.cmp_list_width, 150 ) );
674
675 m_params.emplace_back( new PARAM<bool>( "lib_view.show_pin_electrical_type",
676 &m_LibViewPanel.show_pin_electrical_type, true ) );
677
678 m_params.emplace_back( new PARAM<bool>( "lib_view.show_pin_numbers",
679 &m_LibViewPanel.show_pin_numbers, true ) );
680
681 m_params.emplace_back( new PARAM<wxString>( "system.last_symbol_lib_dir",
682 &m_lastSymbolLibDir, "" ) );
683
684 // Migrations
685 registerMigration( 0, 1,
686 [&]() -> bool
687 {
688 // Version 0 to 1: BOM plugin settings moved from sexpr to JSON
689 return migrateBomSettings();
690 } );
691
692
693 registerMigration( 1, 2,
694 [&]() -> bool
695 {
696 // We used to have a bug on GTK which would set the lib tree column width way
697 // too narrow.
698 if( std::optional<int> optval = Get<int>( "lib_tree.column_width" ) )
699 {
700 if( optval < 150 )
701 Set( "lib_tree.column_width", 300 );
702 }
703
704 return true;
705 } );
706
707 registerMigration( 2, 3,
708 [&]() -> bool
709 {
710 // This is actually a migration for APP_SETTINGS_BASE::m_LibTree
711 return migrateLibTreeWidth();
712 } );
713
714 registerMigration( 3, 4,
715 [&]() -> bool
716 {
718 } );
719}
720
721
723{
724 if( std::optional<wxString> fieldNames = Get<wxString>( "drawing.field_names" ) )
725 {
726 if( PGM_BASE* pgm = PgmOrNull() )
727 {
728 COMMON_SETTINGS* commonSettings = pgm->GetCommonSettings();
729 TEMPLATES& templates = commonSettings->m_FieldNameTemplates;
730
731 if( templates.GetTemplateFieldNames( TEMPLATES::SCOPE::GLOBAL ).empty()
732 && !fieldNames->IsEmpty() )
733 {
734 templates.AddTemplateFieldNames( *fieldNames, TEMPLATES::SCOPE::GLOBAL );
735 pgm->GetSettingsManager().SyncGlobalFieldNameTemplatesToProjects();
736 pgm->GetSettingsManager().Save( commonSettings );
737 }
738 }
739 }
740
741 if( Contains( "drawing.field_names" ) )
742 At( "drawing" ).erase( "field_names" );
743
744 return true;
745}
746
747
748bool EESCHEMA_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
749{
750 bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
751
752 // Now modify the loaded grid selection, because in earlier versions the grids index was shared
753 // between all applications and started at 1000 mils. There is a 4-position offset between
754 // this index and the possible eeschema grids list that we have to subtract.
755 std::string gridSizePtr = "window.grid.last_size";
756
757 if( std::optional<int> currentSize = Get<int>( gridSizePtr ) )
758 {
759 Set( gridSizePtr, *currentSize - 4 );
760 }
761 else
762 {
763 // Otherwise, default grid size should be 50 mils; index 1
764 Set( gridSizePtr, 1 );
765 }
766
767 ret &= fromLegacy<bool>( aCfg, "FootprintPreview", "appearance.footprint_preview" );
768 ret &= fromLegacy<bool>( aCfg, "NavigatorStaysOpen", "appearance.navigator_stays_open" );
769 ret &= fromLegacy<bool>( aCfg, "PrintSheetReferenceAndTitleBlock", "appearance.print_sheet_reference" );
770 ret &= fromLegacy<bool>( aCfg, "ShowHiddenPins", "appearance.show_hidden_pins" );
771 ret &= fromLegacy<bool>( aCfg, "ShowIllegalSymbolLibDialog", "appearance.show_illegal_symbol_lib_dialog" );
772 ret &= fromLegacy<bool>( aCfg, "ShowPageLimits", "appearance.show_page_limits" );
773 ret &= fromLegacy<bool>( aCfg, "ShowSheetFileNameCaseSensitivityDlg", "appearance.show_sheet_filename_case_sensitivity_dialog" );
774
775 ret &= fromLegacy<bool>( aCfg, "AutoplaceFields", "autoplace_fields.enable" );
776 ret &= fromLegacy<bool>( aCfg, "AutoplaceJustify", "autoplace_fields.allow_rejustify" );
777 ret &= fromLegacy<bool>( aCfg, "AutoplaceAlign", "autoplace_fields.align_to_grid" );
778
779 ret &= fromLegacy<int>( aCfg, "DefaultBusWidth", "drawing.default_bus_thickness" );
780 ret &= fromLegacy<int>( aCfg, "DefaultJunctionSize", "drawing.default_junction_size" );
781 ret &= fromLegacy<int>( aCfg, "DefaultDrawLineWidth", "drawing.default_line_thickness" );
782 ret &= fromLegacy<int>( aCfg, "RepeatStepX", "drawing.default_repeat_offset_x" );
783 ret &= fromLegacy<int>( aCfg, "RepeatStepY", "drawing.default_repeat_offset_y" );
784 ret &= fromLegacy<int>( aCfg, "DefaultWireWidth", "drawing.default_wire_thickness" );
785
786 ret &= fromLegacyString( aCfg, "FieldNames", "drawing.field_names" );
788
789 ret &= fromLegacy<bool>( aCfg, "HorizVertLinesOnly", "drawing.line_mode" );
790 ret &= fromLegacy<int>( aCfg, "RepeatLabelIncrement", "drawing.repeat_label_increment" );
791
792 ret &= fromLegacy<bool>( aCfg, "DragActionIsMove", "input.drag_is_move" );
793
794 ret &= fromLegacy<int>( aCfg, "SelectionThickness", "selection.thickness" );
795 ret &= fromLegacy<bool>( aCfg, "SelectionDrawChildItems", "selection.draw_selected_children" );
796 ret &= fromLegacy<bool>( aCfg, "SelectionFillShapes", "selection.fill_shapes" );
797 ret &= fromLegacy<bool>( aCfg, "SelectPinSelectSymbolOpt", "selection.select_pin_selects_symbol" );
798
799 ret &= fromLegacy<int>( aCfg, "AnnotateFilterMsg", "annotation.messages_filter" );
800
801 ret &= fromLegacyString( aCfg, "bom_plugin_selected", "bom.selected_plugin" );
802 ret &= fromLegacyString( aCfg, "bom_plugins", "bom.plugins" );
803
805
806 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportRevision", "page_settings.export_revision" );
807 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportDate", "page_settings.export_date" );
808 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportTitle", "page_settings.export_title" );
809 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportCompany", "page_settings.export_company" );
810 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment1", "page_settings.export_comment1" );
811 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment2", "page_settings.export_comment2" );
812 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment3", "page_settings.export_comment3" );
813 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment4", "page_settings.export_comment4" );
814 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment5", "page_settings.export_comment5" );
815 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment6", "page_settings.export_comment6" );
816 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment7", "page_settings.export_comment7" );
817 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment8", "page_settings.export_comment8" );
818 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment9", "page_settings.export_comment9" );
819
820 #if 0 // To do: move this code to the new netlist plugin management in settings
821 {
822 constexpr int max_custom_commands = 8; // from DIALOG_NETLIST
823 nlohmann::json js_cmd = nlohmann::json::array();
824 nlohmann::json js_title = nlohmann::json::array();
825 wxString cmd_key, title_key, cmd, title;
826
827 for( int i = 1; i <= max_custom_commands; ++i )
828 {
829 // Only migrate if both title and command are specified
830 cmd_key.Printf( "CustomNetlistCommand%d", i );
831 title_key.Printf( "CustomNetlistTitle%d", i );
832
833 if( aCfg->Read( cmd_key, &cmd ) && aCfg->Read( title_key, &title )
834 && !cmd.IsEmpty() && !title.IsEmpty() )
835 {
836 js_cmd.push_back( cmd.ToUTF8() );
837 js_title.push_back( title.ToUTF8() );
838 }
839 }
840
841 Set( "netlist.custom_command_titles", js_title );
842 Set( "netlist.custom_command_paths", js_cmd );
843 }
844 #endif
845
846 {
847 // NOTE(JE) These parameters should move to project-local storage before V6, but we are
848 // migrating them here in order to preserve data. There is a bug here that is preserved:
849 // keys are taken directly from the (translated) UI and stored in the config, so if the user
850 // changes languages the keys will no longer work.
851 aCfg->SetPath( "SymbolFieldEditor/Show/" );
852
853 nlohmann::json js = nlohmann::json( {} );
854 wxString key;
855 bool value = false;
856 long index = 0;
857
858 while( aCfg->GetNextEntry( key, index ) )
859 {
860 if( aCfg->Read( key, &value ) )
861 {
862 std::string key_utf( key.ToUTF8() );
863
864 try
865 {
866 js[ std::move( key_utf ) ] = value;
867 }
868 catch(...)
869 {
870 continue;
871 }
872 }
873 }
874
875 Set( "field_editor.fields_show", js );
876
877 aCfg->SetPath( "../GroupBy" );
878
879 while( aCfg->GetNextEntry( key, index ) )
880 {
881 if( aCfg->Read( key, &value ) )
882 {
883 std::string key_utf( key.ToUTF8() );
884
885 try
886 {
887 js[ std::move( key_utf ) ] = value;
888 }
889 catch(...)
890 {
891 continue;
892 }
893 }
894 }
895
896 Set( "field_editor.fields_group_by", js );
897
898 aCfg->SetPath( "../.." );
899 }
900
901 ret &= fromLegacy<bool>( aCfg, "PlotModeColor", "plot.color" );
902 ret &= fromLegacy<int>( aCfg, "PlotFormat", "plot.format" );
903 ret &= fromLegacy<bool>( aCfg, "PlotFrameRef", "plot.frame_reference" );
904
905 ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMEPos_x", "simulator.window.pos_x" );
906 ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMEPos_y", "simulator.window.pos_y" );
907 ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMESize_x", "simulator.window.size_x" );
908 ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMESize_y", "simulator.window.size_y" );
909 ret &= fromLegacy<bool>( aCfg, "SIM_PLOT_FRAMEMaximized", "simulator.window.maximized" );
910 ret &= fromLegacyString( aCfg, "SIM_PLOT_FRAMEPerspective", "simulator.window.perspective" );
911 ret &= fromLegacyString( aCfg, "SIM_PLOT_FRAMEMostRecentlyUsedPath", "simulator.mru_path" );
912 ret &= fromLegacy<int>( aCfg, "SimPlotPanelWidth", "simulator.plot_panel_width" );
913 ret &= fromLegacy<int>( aCfg, "SimPlotPanelHeight", "simulator.plot_panel_height" );
914 ret &= fromLegacy<int>( aCfg, "SimSignalPanelHeight", "simulator.signal_panel_height" );
915 ret &= fromLegacy<int>( aCfg, "SimCursorsPanelHeight", "simulator.cursors_panel_height" );
916 ret &= fromLegacy<bool>( aCfg, "SimPlotWhiteBg", "simulator.white_background" );
917
918 ret &= fromLegacy<int>( aCfg, "SymbolChooserHSashPosition", "symbol_chooser.sash_pos_h" );
919 ret &= fromLegacy<int>( aCfg, "SymbolChooserVSashPosition", "symbol_chooser.sash_pos_v" );
920 ret &= fromLegacy<int>( aCfg, "SymbolChooserWidth", "symbol_chooser.width" );
921 ret &= fromLegacy<int>( aCfg, "SymbolChooserHeight", "symbol_chooser.height" );
922
923 const std::string vlf = "ViewlibFrame";
924 ret &= fromLegacy<bool>( aCfg, vlf + "Maximized", "lib_view.window.maximized" );
925 ret &= fromLegacyString( aCfg, vlf + "MostRecentlyUsedPath", "lib_view.window.mru_path" );
926 ret &= fromLegacy<int>( aCfg, vlf + "Size_x", "lib_view.window.size_x" );
927 ret &= fromLegacy<int>( aCfg, vlf + "Size_y", "lib_view.window.size_y" );
928 ret &= fromLegacyString( aCfg, vlf + "Perspective", "lib_view.window.perspective" );
929 ret &= fromLegacy<int>( aCfg, vlf + "Pos_x", "lib_view.window.pos_x" );
930 ret &= fromLegacy<int>( aCfg, vlf + "Pos_y", "lib_view.window.pos_y" );
931 ret &= fromLegacy<int>( aCfg, "ViewLiblistWidth", "lib_view.lib_list_width" );
932 ret &= fromLegacy<int>( aCfg, "ViewCmplistWidth", "lib_view.cmp_list_width" );
933 ret &= fromLegacy<bool>( aCfg,
934 "ViewCmpShowPinElectricalType", "lib_view.show_pin_electrical_type" );
935 ret &= fromLegacy<bool>( aCfg, vlf + "ShowGrid", "lib_view.grid.show" );
936 ret &= fromLegacy<int>( aCfg, vlf + "_LastGridSize", "lib_view.grid.last_size" );
937
938 ret &= fromLegacy<bool>( aCfg, "RescueNeverShow", "system.never_show_rescue_dialog" );
939
940 // Legacy version stored this setting in eeschema, so move it to common if it exists
941 bool tmp;
942
943 if( aCfg->Read( "MoveWarpsCursor", &tmp ) )
944 Pgm().GetCommonSettings()->m_Input.warp_mouse_on_move = tmp;
945
948
949 auto migrateLegacyColor =
950 [&] ( const std::string& aKey, int aLayerId )
951 {
952 wxString str;
953
954 if( aCfg->Read( aKey, &str ) )
955 cs->SetColor( aLayerId, COLOR4D( str ) );
956 };
957
958 migrateLegacyColor( "Color4DBgCanvasEx", LAYER_SCHEMATIC_BACKGROUND );
959 migrateLegacyColor( "Color4DBodyBgEx", LAYER_DEVICE_BACKGROUND );
960 migrateLegacyColor( "Color4DBodyEx", LAYER_DEVICE );
961 migrateLegacyColor( "Color4DBrightenedEx", LAYER_BRIGHTENED );
962 migrateLegacyColor( "Color4DBusEx", LAYER_BUS );
963 migrateLegacyColor( "Color4DConnEx", LAYER_JUNCTION );
964 migrateLegacyColor( "Color4DCursorEx", LAYER_SCHEMATIC_CURSOR );
965 migrateLegacyColor( "Color4DErcEEx", LAYER_ERC_ERR );
966 migrateLegacyColor( "Color4DErcWEx", LAYER_ERC_WARN );
967 migrateLegacyColor( "Color4DFieldEx", LAYER_FIELDS );
968 migrateLegacyColor( "Color4DGLabelEx", LAYER_GLOBLABEL );
969 migrateLegacyColor( "Color4DGridEx", LAYER_SCHEMATIC_GRID );
970 migrateLegacyColor( "Color4DHLabelEx", LAYER_HIERLABEL );
971 migrateLegacyColor( "Color4DHiddenEx", LAYER_HIDDEN );
972 migrateLegacyColor( "Color4DLLabelEx", LAYER_LOCLABEL );
973 migrateLegacyColor( "Color4DNoConnectEx", LAYER_NOCONNECT );
974 migrateLegacyColor( "Color4DNoteEx", LAYER_NOTES );
975 migrateLegacyColor( "Color4DPinEx", LAYER_PIN );
976 migrateLegacyColor( "Color4DPinNameEx", LAYER_PINNAM );
977 migrateLegacyColor( "Color4DPinNumEx", LAYER_PINNUM );
978 migrateLegacyColor( "Color4DReferenceEx", LAYER_REFERENCEPART );
979 migrateLegacyColor( "Color4DShadowEx", LAYER_SELECTION_SHADOWS );
980 migrateLegacyColor( "Color4DSheetEx", LAYER_SHEET );
981 migrateLegacyColor( "Color4DSheetFileNameEx", LAYER_SHEETFILENAME );
982 migrateLegacyColor( "Color4DSheetLabelEx", LAYER_SHEETLABEL );
983 migrateLegacyColor( "Color4DSheetNameEx", LAYER_SHEETNAME );
984 migrateLegacyColor( "Color4DValueEx", LAYER_VALUEPART );
985 migrateLegacyColor( "Color4DWireEx", LAYER_WIRE );
986 migrateLegacyColor( "Color4DWorksheetEx", LAYER_SCHEMATIC_DRAWINGSHEET );
987
988 mgr.SaveColorSettings( cs, "schematic" );
989
990 Set( "appearance.color_theme", cs->GetFilename() );
991
992 // LibEdit settings were stored with eeschema. If eeschema is the first app to run,
993 // we need to migrate the LibEdit settings here
994
995 if( SYMBOL_EDITOR_SETTINGS* sym_edit_cfg = GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" ) )
996 {
997 sym_edit_cfg->MigrateFromLegacy( aCfg );
998 sym_edit_cfg->Load();
999 }
1000
1001 return ret;
1002}
1003
1004
1009class BOM_CFG_PARSER : public DIALOG_BOM_CFG_LEXER
1010{
1011 std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS>* m_pluginList;
1012
1013public:
1014 BOM_CFG_PARSER( std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS>* aPluginList,
1015 const char* aData, const wxString& aSource );
1016
1017 void Parse();
1018
1019private:
1020 void parseGenerator();
1021};
1022
1023
1024std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS> EESCHEMA_SETTINGS::DefaultBomPlugins()
1025{
1027}
1028
1029
1031{
1032 if( !Contains( "bom.plugins" ) )
1033 return false;
1034
1035 wxString list = *Get<wxString>( "bom.plugins" );
1036
1037 BOM_CFG_PARSER cfg_parser( &m_BomPanel.plugins, TO_UTF8( list ), wxT( "plugins" ) );
1038
1039 try
1040 {
1041 cfg_parser.Parse();
1042 }
1043 catch( const IO_ERROR& )
1044 {
1045 return false;
1046 }
1047
1048 // Parser will have loaded up our array, let's dump it out to JSON
1049 At( "bom.plugins" ) = bomSettingsToJson();
1050
1051 return true;
1052}
1053
1054
1056{
1057 nlohmann::json js = nlohmann::json::array();
1058
1059 for( const BOM_PLUGIN_SETTINGS& plugin : m_BomPanel.plugins )
1060 {
1061 nlohmann::json pluginJson;
1062
1063 pluginJson["name"] = plugin.name.ToUTF8();
1064 pluginJson["path"] = plugin.path.ToUTF8();
1065 pluginJson["command"] = plugin.command.ToUTF8();
1066
1067 js.push_back( pluginJson );
1068 }
1069
1070 return js;
1071}
1072
1073
1074std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS> EESCHEMA_SETTINGS::bomSettingsFromJson(
1075 const nlohmann::json& aObj )
1076{
1077 std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS> ret;
1078
1079 wxASSERT( aObj.is_array() );
1080
1081 for( const nlohmann::json& entry : aObj )
1082 {
1083 if( entry.empty() || !entry.is_object() )
1084 continue;
1085
1086 if( !entry.contains( "name" ) || !entry.contains( "path" ) )
1087 continue;
1088
1089 BOM_PLUGIN_SETTINGS plugin( entry.at( "name" ).get<wxString>(),
1090 entry.at( "path" ).get<wxString>() );
1091
1092 if( entry.contains( "command" ) )
1093 plugin.command = entry.at( "command" ).get<wxString>();
1094
1095 ret.emplace_back( plugin );
1096 }
1097
1098 return ret;
1099}
1100
1101
1103{
1104 nlohmann::json js = nlohmann::json::array();
1105
1106 for( const NETLIST_PLUGIN_SETTINGS& plugin : m_NetlistPanel.plugins )
1107 {
1108 nlohmann::json pluginJson;
1109
1110 pluginJson["name"] = plugin.name.ToUTF8();
1111 pluginJson["path"] = plugin.path.ToUTF8();
1112 pluginJson["command"] = plugin.command.ToUTF8();
1113
1114 js.push_back( pluginJson );
1115 }
1116
1117 return js;
1118}
1119
1120
1121std::vector<EESCHEMA_SETTINGS::NETLIST_PLUGIN_SETTINGS> EESCHEMA_SETTINGS::netlistSettingsFromJson(
1122 const nlohmann::json& aObj )
1123{
1124 std::vector<EESCHEMA_SETTINGS::NETLIST_PLUGIN_SETTINGS> ret;
1125
1126 wxASSERT( aObj.is_array() );
1127
1128 for( const nlohmann::json& entry : aObj )
1129 {
1130 if( entry.empty() || !entry.is_object() )
1131 continue;
1132
1133 if( !entry.contains( "name" ) || !entry.contains( "path" ) )
1134 continue;
1135
1136 NETLIST_PLUGIN_SETTINGS plugin( entry.at( "name" ).get<wxString>(),
1137 entry.at( "path" ).get<wxString>() );
1138
1139 if( entry.contains( "command" ) )
1140 plugin.command = entry.at( "command" ).get<wxString>();
1141
1142 ret.emplace_back( plugin );
1143 }
1144
1145 return ret;
1146}
1147
1148
1149BOM_CFG_PARSER::BOM_CFG_PARSER( std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS>* aPluginList,
1150 const char* aLine, const wxString& aSource ) :
1151 DIALOG_BOM_CFG_LEXER( aLine, aSource )
1152{
1153 wxASSERT( aPluginList );
1154 m_pluginList = aPluginList;
1155}
1156
1157
1159{
1160 T token;
1161
1162 while( ( token = NextTok() ) != T_RIGHT )
1163 {
1164 if( token == T_EOF)
1165 break;
1166
1167 if( token == T_LEFT )
1168 token = NextTok();
1169
1170 if( token == T_plugins )
1171 continue;
1172
1173 switch( token )
1174 {
1175 case T_plugin: // Defines a new plugin
1177 break;
1178
1179 default:
1180// Unexpected( CurText() );
1181 break;
1182 }
1183 }
1184}
1185
1186
1188{
1189 wxString str;
1191
1192 NeedSYMBOLorNUMBER();
1193 settings.path = FromUTF8();
1194
1195 T token;
1196
1197 while( ( token = NextTok() ) != T_RIGHT )
1198 {
1199 if( token == T_EOF)
1200 break;
1201
1202 switch( token )
1203 {
1204 case T_LEFT:
1205 break;
1206
1207 case T_cmd:
1208 NeedSYMBOLorNUMBER();
1209
1210 settings.command = FromUTF8();
1211
1212 NeedRIGHT();
1213 break;
1214
1215 case T_opts:
1216 {
1217 NeedSYMBOLorNUMBER();
1218
1219 wxString option = FromUTF8();
1220
1221 if( option.StartsWith( wxS( "nickname=" ), &str ) )
1222 settings.name = str;
1223
1224 NeedRIGHT();
1225 break;
1226 }
1227
1228 default:
1229 Unexpected( CurText() );
1230 break;
1231 }
1232 }
1233
1234 m_pluginList->emplace_back( settings );
1235}
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)
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:546
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:494
@ LAYER_ERC_WARN
Definition layer_ids.h:501
@ LAYER_SHEETLABEL
Definition layer_ids.h:497
@ LAYER_PINNUM
Definition layer_ids.h:480
@ LAYER_DEVICE
Definition layer_ids.h:488
@ LAYER_BRIGHTENED
Definition layer_ids.h:513
@ LAYER_HIDDEN
Definition layer_ids.h:514
@ LAYER_HIERLABEL
Definition layer_ids.h:479
@ LAYER_PINNAM
Definition layer_ids.h:481
@ LAYER_GLOBLABEL
Definition layer_ids.h:478
@ LAYER_WIRE
Definition layer_ids.h:474
@ LAYER_NOTES
Definition layer_ids.h:489
@ LAYER_ERC_ERR
Definition layer_ids.h:502
@ LAYER_PIN
Definition layer_ids.h:492
@ LAYER_VALUEPART
Definition layer_ids.h:483
@ LAYER_BUS
Definition layer_ids.h:475
@ LAYER_SCHEMATIC_CURSOR
Definition layer_ids.h:511
@ LAYER_FIELDS
Definition layer_ids.h:484
@ LAYER_DEVICE_BACKGROUND
Definition layer_ids.h:506
@ LAYER_SCHEMATIC_DRAWINGSHEET
Definition layer_ids.h:518
@ LAYER_LOCLABEL
Definition layer_ids.h:477
@ LAYER_JUNCTION
Definition layer_ids.h:476
@ LAYER_REFERENCEPART
Definition layer_ids.h:482
@ LAYER_SHEET
Definition layer_ids.h:493
@ LAYER_SELECTION_SHADOWS
Definition layer_ids.h:517
@ LAYER_SCHEMATIC_BACKGROUND
Definition layer_ids.h:510
@ LAYER_SHEETFILENAME
Definition layer_ids.h:495
@ LAYER_NOCONNECT
Definition layer_ids.h:498
@ LAYER_SCHEMATIC_GRID
Definition layer_ids.h:508
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.