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