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