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