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
154 m_Appearance(),
155 m_AutoplaceFields(),
156 m_Drawing(),
157 m_FindReplaceExtra(),
158 m_Input(),
159 m_PageSettings(),
160 m_AnnotatePanel(),
161 m_BomPanel(),
162 m_FieldEditorPanel(),
163 m_LibViewPanel(),
164 m_NetlistPanel(),
165 m_PlotPanel(),
166 m_SymChooserPanel(),
167 m_ImportGraphics(),
168 m_Selection(),
169 m_Simulator(),
170 m_RescueNeverShow( false )
171{
172 m_params.emplace_back( new PARAM<wxString>( "appearance.edit_symbol_visible_columns",
173 &m_Appearance.edit_symbol_visible_columns, "0 1 2 3 4 5 6 7" ) );
174
175 m_params.emplace_back( new PARAM<int>( "appearance.edit_symbol_width",
177
178 m_params.emplace_back( new PARAM<int>( "appearance.edit_symbol_height",
180
181 m_params.emplace_back( new PARAM<wxString>( "appearance.edit_sheet_visible_columns",
182 &m_Appearance.edit_sheet_visible_columns, "0 1 2 3 4 5 6 7" ) );
183
184 m_params.emplace_back( new PARAM<int>( "appearance.edit_sheet_width",
186
187 m_params.emplace_back( new PARAM<int>( "appearance.edit_sheet_height",
189
190 m_params.emplace_back( new PARAM<wxString>( "appearance.edit_label_visible_columns",
191 &m_Appearance.edit_label_visible_columns, "0 1 2 3 4 5 6 7" ) );
192
193 m_params.emplace_back( new PARAM<int>( "appearance.edit_label_width",
195
196 m_params.emplace_back( new PARAM<int>( "appearance.edit_label_height",
198
199 m_params.emplace_back( new PARAM<int>( "appearance.erc_severities",
201
202 m_params.emplace_back( new PARAM<bool>( "appearance.footprint_preview",
204
205 m_params.emplace_back( new PARAM<bool>( "appearance.print_sheet_reference",
207
208 m_params.emplace_back( new PARAM<wxString>( "appearance.default_font",
209 &m_Appearance.default_font, "KiCad Font" ) );
210
211 m_params.emplace_back( new PARAM<bool>( "appearance.show_hidden_pins",
212 &m_Appearance.show_hidden_pins, false ) );
213
214 m_params.emplace_back( new PARAM<bool>( "appearance.show_hidden_fields",
216
217 m_params.emplace_back( new PARAM<bool>( "appearance.show_directive_labels",
219
220 m_params.emplace_back( new PARAM<bool>( "appearance.show_erc_warnings",
222
223 m_params.emplace_back( new PARAM<bool>( "appearance.show_erc_errors",
224 &m_Appearance.show_erc_errors, true ) );
225
226 m_params.emplace_back( new PARAM<bool>( "appearance.show_erc_exclusions",
228
229 m_params.emplace_back( new PARAM<bool>( "appearance.mark_sim_exclusions",
231
232 m_params.emplace_back( new PARAM<bool>( "appearance.show_op_voltages",
234
235 m_params.emplace_back( new PARAM<bool>( "appearance.show_op_currents",
237
238 m_params.emplace_back( new PARAM<bool>( "appearance.show_pin_alt_icons",
240
241 m_params.emplace_back( new PARAM<bool>( "appearance.show_illegal_symbol_lib_dialog",
243
244 m_params.emplace_back( new PARAM<bool>( "appearance.show_page_limits",
246
247 m_params.emplace_back( new PARAM<bool>( "appearance.show_sexpr_file_convert_warning",
249
250 m_params.emplace_back(
251 new PARAM<bool>( "appearance.show_sheet_filename_case_sensitivity_dialog",
253
254 m_params.emplace_back( new PARAM<bool>( "aui.show_schematic_hierarchy",
256
257 m_params.emplace_back( new PARAM<int>( "aui.hierarchy_panel_docked_width",
259
260 m_params.emplace_back( new PARAM<int>( "aui.hierarchy_panel_docked_height",
262
263 m_params.emplace_back( new PARAM<int>( "aui.hierarchy_panel_float_width",
265
266 m_params.emplace_back( new PARAM<int>( "aui.hierarchy_panel_float_height",
268
269 m_params.emplace_back( new PARAM<bool>( "aui.design_blocks_show",
271
272 m_params.emplace_back( new PARAM<int>( "aui.design_blocks_panel_docked_width",
274
275 m_params.emplace_back( new PARAM<int>( "aui.design_blocks_panel_float_width",
277
278 m_params.emplace_back( new PARAM<int>( "aui.design_blocks_panel_float_height",
280
281 m_params.emplace_back( new PARAM<bool>( "aui.schematic_hierarchy_float",
283
284 m_params.emplace_back( new PARAM<int>( "aui.search_panel_height",
286
287 m_params.emplace_back( new PARAM<int>( "aui.search_panel_width",
289
290 m_params.emplace_back( new PARAM<int>( "aui.search_panel_dock_direction",
292
293 m_params.emplace_back( new PARAM<bool>( "aui.show_search",
294 &m_AuiPanels.show_search, false ) );
295
296 m_params.emplace_back( new PARAM<bool>( "aui.show_net_nav_panel",
298
299 m_params.emplace_back( new PARAM<bool>( "aui.float_net_nav_panel",
301
302 m_params.emplace_back( new PARAM<wxSize>( "aui.net_nav_panel_docked_size",
303 &m_AuiPanels.net_nav_panel_docked_size, wxSize( 120, -1 ) ) );
304
305 m_params.emplace_back( new PARAM<wxPoint>( "aui.net_nav_panel_float_pos",
306 &m_AuiPanels.net_nav_panel_float_pos, wxPoint( 50, 200 ), false ) );
307
308 m_params.emplace_back( new PARAM<wxSize>( "aui.net_nav_panel_float_size",
309 &m_AuiPanels.net_nav_panel_float_size, wxSize( 200, 200 ) ) );
310
311 m_params.emplace_back( new PARAM<bool>( "aui.show_properties",
312 &m_AuiPanels.show_properties, true ) );
313
314 m_params.emplace_back( new PARAM<int>( "aui.properties_panel_width",
316
317 m_params.emplace_back( new PARAM<float>( "aui.properties_splitter_proportion",
319
320 m_params.emplace_back( new PARAM<bool>( "autoplace_fields.enable",
321 &m_AutoplaceFields.enable, true ) );
322
323 m_params.emplace_back( new PARAM<bool>( "autoplace_fields.allow_rejustify",
325
326 m_params.emplace_back( new PARAM<bool>( "autoplace_fields.align_to_grid",
328
329 m_params.emplace_back( new PARAM<int>( "drawing.default_bus_thickness",
331
332 m_params.emplace_back( new PARAM<int>( "drawing.default_junction_size",
334
335 m_params.emplace_back( new PARAM<int>( "drawing.pin_symbol_size",
337
338 m_params.emplace_back( new PARAM<double>( "drawing.text_offset_ratio",
339 &m_Drawing.text_offset_ratio, 0.08 ) );
340
341 m_params.emplace_back( new PARAM<int>( "drawing.default_line_thickness",
343
344 m_params.emplace_back( new PARAM<int>( "drawing.default_repeat_offset_x",
346
347 m_params.emplace_back( new PARAM<int>( "drawing.default_repeat_offset_y",
349
350 m_params.emplace_back( new PARAM<int>( "drawing.default_wire_thickness",
352
353 m_params.emplace_back( new PARAM<int>( "drawing.default_text_size",
355
356 m_params.emplace_back( new PARAM<wxString>( "drawing.field_names",
357 &m_Drawing.field_names, "" ) );
358
359 m_params.emplace_back( new PARAM<int>( "drawing.line_mode", &m_Drawing.line_mode,
360 LINE_MODE::LINE_MODE_90 ) );
361
362 m_params.emplace_back( new PARAM<bool>( "drawing.auto_start_wires",
363 &m_Drawing.auto_start_wires, true ) );
364
365 m_params.emplace_back( new PARAM<int>( "drawing.repeat_label_increment",
367
368 m_params.emplace_back( new PARAM<COLOR4D>( "drawing.default_sheet_border_color",
369 &m_Drawing.default_sheet_border_color, COLOR4D::UNSPECIFIED ) );
370
371 m_params.emplace_back( new PARAM<COLOR4D>( "drawing.default_sheet_background_color",
372 &m_Drawing.default_sheet_background_color, COLOR4D::UNSPECIFIED ) );
373
374 m_params.emplace_back( new PARAM_LIST<double>( "drawing.junction_size_mult_list",
375 &m_Drawing.junction_size_mult_list, { 0.0, 1.7, 4.0, 6.0, 9.0, 12.0 } ) );
376
377 m_params.emplace_back(new PARAM <int>( "drawing.junction_size_choice",
379
380 m_params.emplace_back( new PARAM<bool>( "find_replace.search_all_fields",
382
383 m_params.emplace_back( new PARAM<bool>( "find_replace.search_all_pins",
385
386 m_params.emplace_back( new PARAM<bool>( "find_replace.search_current_sheet_only",
388 false ) );
389
390 m_params.emplace_back( new PARAM<bool>( "find_replace.replace_references",
392
393 m_params.emplace_back( new PARAM<bool>( "input.drag_is_move",
394 &m_Input.drag_is_move, false ) );
395
396 m_params.emplace_back( new PARAM<bool>( "input.esc_clears_net_highlight",
398
399 m_params.emplace_back( new PARAM<int>( "selection.thickness",
401
402 m_params.emplace_back( new PARAM<int>( "selection.highlight_thickness",
404
405 m_params.emplace_back( new PARAM<bool>( "selection.draw_selected_children",
407
408 m_params.emplace_back( new PARAM<bool>( "selection.fill_shapes",
409 &m_Selection.fill_shapes, false ) );
410
411 m_params.emplace_back( new PARAM<bool>( "selection.highlight_netclass_colors",
413
414 m_params.emplace_back( new PARAM<int>( "selection.highlight_netclass_colors_thickness",
416
417 m_params.emplace_back( new PARAM<double>( "selection.highlight_netclass_colors_alpha",
419
420 m_params.emplace_back( new PARAM<bool>( "annotation.automatic",
421 &m_AnnotatePanel.automatic, true ) );
422
423 m_params.emplace_back( new PARAM<bool>( "annotation.recursive",
424 &m_AnnotatePanel.recursive, true ) );
425
426 m_params.emplace_back( new PARAM<int>( "annotation.method",
427 &m_AnnotatePanel.method, 0, 0, 2 ) );
428
429 m_params.emplace_back( new PARAM<int>( "annotation.scope",
430 &m_AnnotatePanel.scope, 0, 0, 2 ) );
431
432 m_params.emplace_back( new PARAM<int>( "annotation.options",
433 &m_AnnotatePanel.options, 0, 0, 2 ) );
434
435 m_params.emplace_back( new PARAM<int>( "annotation.messages_filter",
437
438 m_params.emplace_back( new PARAM<int>( "annotation.sort_order",
439 &m_AnnotatePanel.sort_order, 0, 0, 1 ) );
440
441 m_params.emplace_back( new PARAM<wxString>( "bom.selected_plugin",
443
444 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "bom.plugins",
445 std::bind( &EESCHEMA_SETTINGS::bomSettingsToJson, this ),
446 [&]( const nlohmann::json& aObj )
447 {
448 if( !aObj.is_array() )
449 return;
450
451 const nlohmann::json& list = aObj.empty() ? defaultBomPlugins : aObj;
452
454 },
456
457 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "netlist.plugins",
459 [&]( const nlohmann::json& aObj )
460 {
461 if( !aObj.is_array() )
462 return;
463
464 if( aObj.empty() )
465 return;
466
467 const nlohmann::json& list = aObj;
468
470 },
471 nullptr ) );
472
473 m_params.emplace_back( new PARAM<bool>( "page_settings.export_paper",
474 &m_PageSettings.export_paper, false ) );
475
476 m_params.emplace_back( new PARAM<bool>( "page_settings.export_revision",
478
479 m_params.emplace_back( new PARAM<bool>( "page_settings.export_date",
480 &m_PageSettings.export_date, false ) );
481
482 m_params.emplace_back( new PARAM<bool>( "page_settings.export_title",
483 &m_PageSettings.export_title, false ) );
484
485 m_params.emplace_back( new PARAM<bool>( "page_settings.export_company",
486 &m_PageSettings.export_company, false ) );
487
488 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment1",
490
491 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment2",
493
494 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment3",
496
497 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment4",
499
500 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment5",
502
503 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment6",
505
506 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment7",
508
509 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment8",
511
512 m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment9",
514
515 m_params.emplace_back( new PARAM_MAP<int>( "field_editor.field_widths",
517
518 m_params.emplace_back( new PARAM<int>( "field_editor.width", &m_FieldEditorPanel.width, 0 ) );
519
520 m_params.emplace_back( new PARAM<int>( "field_editor.height", &m_FieldEditorPanel.height, 0 ) );
521
522 m_params.emplace_back( new PARAM<int>( "field_editor.page", &m_FieldEditorPanel.page, 0 ) );
523
524 m_params.emplace_back( new PARAM<wxString>( "field_editor.export_filename",
525 &m_FieldEditorPanel.export_filename, wxT( "" ) ) );
526
527 m_params.emplace_back( new PARAM<int>( "field_editor.selection_mode",
529
530 m_params.emplace_back( new PARAM<int>( "field_editor.scope", &m_FieldEditorPanel.scope, 0 ) );
531
532 m_params.emplace_back( new PARAM<bool>( "plot.background_color",
533 &m_PlotPanel.background_color, false ) );
534
535 m_params.emplace_back( new PARAM<bool>( "plot.color",
536 &m_PlotPanel.color, true ) );
537
538 m_params.emplace_back( new PARAM<wxString>( "plot.color_theme",
539 &m_PlotPanel.color_theme, wxT( "user" ) ) );
540
541 m_params.emplace_back( new PARAM<int>( "plot.format",
542 &m_PlotPanel.format, 0 ) );
543
544 m_params.emplace_back( new PARAM<bool>( "plot.frame_reference",
545 &m_PlotPanel.frame_reference, true ) );
546
547 m_params.emplace_back( new PARAM<bool>( "plot.pdf_property_popups",
549
550 m_params.emplace_back( new PARAM<bool>( "plot.pdf_hierarchical_links",
552
553 m_params.emplace_back( new PARAM<bool>( "plot.pdf_metadata",
554 &m_PlotPanel.pdf_metadata, true ) );
555
556 m_params.emplace_back( new PARAM<int>( "plot.hpgl_paper_size",
558
559 m_params.emplace_back( new PARAM<double>( "plot.hpgl_pen_size",
560 &m_PlotPanel.hpgl_pen_size, 0.5 ) );
561
562 m_params.emplace_back( new PARAM<int>( "plot.hpgl_origin",
563 &m_PlotPanel.hpgl_origin, 0 ) );
564
565 m_params.emplace_back( new PARAM<bool>( "plot.other_open_file_after_plot",
567
568 m_params.emplace_back( new PARAM<int>( "simulator.window.pos_x",
570
571 m_params.emplace_back( new PARAM<int>( "simulator.window.pos_y",
573
574 m_params.emplace_back( new PARAM<int>( "simulator.window.size_x",
575 &m_Simulator.window.state.size_x, 500 ) );
576
577 m_params.emplace_back( new PARAM<int>( "simulator.window.size_y",
578 &m_Simulator.window.state.size_y, 400 ) );
579
580 m_params.emplace_back( new PARAM<unsigned int>( "simulator.window.display",
582
583 m_params.emplace_back( new PARAM<bool>( "simulator.window.maximized",
584 &m_Simulator.window.state.maximized, false ) );
585
586 m_params.emplace_back( new PARAM<wxString>( "simulator.window.perspective",
588
589 m_params.emplace_back( new PARAM<int>( "simulator.plot_panel_width",
591
592 m_params.emplace_back( new PARAM<int>( "simulator.plot_panel_height",
594
595 m_params.emplace_back( new PARAM<int>( "simulator.signal_panel_height",
597
598 m_params.emplace_back( new PARAM<int>( "simulator.cursors_panel_height",
600
601 m_params.emplace_back( new PARAM<int>( "simulator.measurements_panel_height",
603
604 m_params.emplace_back( new PARAM<bool>( "simulator.white_background",
606
608 "simulator.mouse_wheel_actions.vertical_unmodified",
610 SIM_MOUSE_WHEEL_ACTION::ZOOM, SIM_MOUSE_WHEEL_ACTION::NONE,
611 SIM_MOUSE_WHEEL_ACTION::ZOOM_VERTICALLY ) );
612
614 "simulator.mouse_wheel_actions.vertical_with_ctrl",
616 SIM_MOUSE_WHEEL_ACTION::PAN_LEFT_RIGHT, SIM_MOUSE_WHEEL_ACTION::NONE,
617 SIM_MOUSE_WHEEL_ACTION::ZOOM_VERTICALLY ) );
618
620 "simulator.mouse_wheel_actions.vertical_with_shift",
622 SIM_MOUSE_WHEEL_ACTION::PAN_UP_DOWN, SIM_MOUSE_WHEEL_ACTION::NONE,
623 SIM_MOUSE_WHEEL_ACTION::ZOOM_VERTICALLY ) );
624
626 "simulator.mouse_wheel_actions.vertical_with_alt",
628 SIM_MOUSE_WHEEL_ACTION::NONE, SIM_MOUSE_WHEEL_ACTION::NONE,
629 SIM_MOUSE_WHEEL_ACTION::ZOOM_VERTICALLY ) );
630
632 "simulator.mouse_wheel_actions.horizontal",
633 &m_Simulator.preferences.mouse_wheel_actions.horizontal, SIM_MOUSE_WHEEL_ACTION::NONE,
634 SIM_MOUSE_WHEEL_ACTION::NONE, SIM_MOUSE_WHEEL_ACTION::ZOOM_VERTICALLY ) );
635
636 m_params.emplace_back( new PARAM<int>( "symbol_chooser.sash_pos_h",
638
639 m_params.emplace_back( new PARAM<int>( "symbol_chooser.sash_pos_v",
641
642 m_params.emplace_back( new PARAM<int>( "symbol_chooser.width",
643 &m_SymChooserPanel.width, -1 ) );
644
645 m_params.emplace_back( new PARAM<int>( "symbol_chooser.height",
646 &m_SymChooserPanel.height, -1 ) );
647
648 m_params.emplace_back( new PARAM<int>( "symbol_chooser.sort_mode",
650
651 m_params.emplace_back( new PARAM<bool>( "symbol_chooser.keep_symbol",
652 &m_SymChooserPanel.keep_symbol, false ) );
653
654 m_params.emplace_back( new PARAM<bool>( "symbol_chooser.place_all_units",
656
657 m_params.emplace_back( new PARAM<int>( "design_block_chooser.sash_pos_h",
659
660 m_params.emplace_back( new PARAM<int>( "design_block_chooser.sash_pos_v",
662
663 m_params.emplace_back( new PARAM<int>( "design_block_chooser.width",
665
666 m_params.emplace_back( new PARAM<int>( "design_block_chooser.height",
668
669 m_params.emplace_back( new PARAM<int>( "design_block_chooser.sort_mode",
671
672 m_params.emplace_back( new PARAM<bool>( "design_block_chooser.repeated_placement",
674
675 m_params.emplace_back( new PARAM<bool>( "design_block_chooser.place_as_sheet",
677
678 m_params.emplace_back( new PARAM<bool>( "design_block_chooser.keep_annotations",
680
681 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>(
682 "design_block_chooser.lib_tree.column_widths",
683 [&]() -> nlohmann::json
684 {
685 nlohmann::json ret = {};
686
687 for( const auto& [name, width] : m_DesignBlockChooserPanel.tree.column_widths )
688 ret[std::string( name.ToUTF8() )] = width;
689
690 return ret;
691 },
692 [&]( const nlohmann::json& aJson )
693 {
694 if( !aJson.is_object() )
695 return;
696
698
699 for( const auto& entry : aJson.items() )
700 {
701 if( !entry.value().is_number_integer() )
702 continue;
703
704 m_DesignBlockChooserPanel.tree.column_widths[ entry.key() ] =
705 entry.value().get<int>();
706 }
707 },
708 {} ) );
709
710 m_params.emplace_back( new PARAM<bool>( "import_graphics.interactive_placement",
712
713 m_params.emplace_back( new PARAM<int>( "import_graphics.line_width_units",
715
716 m_params.emplace_back( new PARAM<double>( "import_graphics.line_width",
718
719 m_params.emplace_back( new PARAM<int>( "import_graphics.origin_units",
721
722 m_params.emplace_back( new PARAM<double>( "import_graphics.origin_x",
724
725 m_params.emplace_back( new PARAM<double>( "import_graphics.origin_y",
727
728 m_params.emplace_back( new PARAM<int>( "import_graphics.dxf_units",
730
731 m_params.emplace_back( new PARAM<bool>( "system.never_show_rescue_dialog",
732 &m_RescueNeverShow, false ) );
733
734 m_params.emplace_back( new PARAM<int>( "lib_view.window.pos_x",
736
737 m_params.emplace_back( new PARAM<int>( "lib_view.window.pos_y",
739
740 m_params.emplace_back( new PARAM<int>( "lib_view.window.size_x",
742
743 m_params.emplace_back( new PARAM<int>( "lib_view.window.size_y",
745
746 m_params.emplace_back( new PARAM<unsigned int>( "lib_view.window.display",
748
749 m_params.emplace_back( new PARAM<bool>( "lib_view.window.maximized",
751
752 m_params.emplace_back( new PARAM<wxString>( "lib_view.window.perspective",
754
755 m_params.emplace_back( new PARAM<int>( "lib_view.lib_list_width",
757
758 m_params.emplace_back( new PARAM<int>( "lib_view.cmp_list_width",
760
761 m_params.emplace_back( new PARAM<bool>( "lib_view.show_pin_electrical_type",
763
764 m_params.emplace_back( new PARAM<wxString>( "system.last_symbol_lib_dir",
765 &m_lastSymbolLibDir, "" ) );
766
767 // Migrations
768 registerMigration( 0, 1,
769 [&]() -> bool
770 {
771 // Version 0 to 1: BOM plugin settings moved from sexpr to JSON
772 return migrateBomSettings();
773 } );
774
775
776 registerMigration( 1, 2,
777 [&]() -> bool
778 {
779 // We used to have a bug on GTK which would set the lib tree column width way
780 // too narrow.
781 if( std::optional<int> optval = Get<int>( "lib_tree.column_width" ) )
782 {
783 if( optval < 150 )
784 Set( "lib_tree.column_width", 300 );
785 }
786
787 return true;
788 } );
789
790 registerMigration( 2, 3,
791 [&]() -> bool
792 {
793 // This is actually a migration for APP_SETTINGS_BASE::m_LibTree
794 return migrateLibTreeWidth();
795 } );
796}
797
798
799bool EESCHEMA_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
800{
801 bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
802
803 // Now modify the loaded grid selection, because in earlier versions the grids index was shared
804 // between all applications and started at 1000 mils. There is a 4-position offset between
805 // this index and the possible eeschema grids list that we have to subtract.
806 std::string gridSizePtr = "window.grid.last_size";
807
808 if( std::optional<int> currentSize = Get<int>( gridSizePtr ) )
809 {
810 Set( gridSizePtr, *currentSize - 4 );
811 }
812 else
813 {
814 // Otherwise, default grid size should be 50 mils; index 1
815 Set( gridSizePtr, 1 );
816 }
817
818 ret &= fromLegacy<bool>( aCfg, "FootprintPreview", "appearance.footprint_preview" );
819 ret &= fromLegacy<bool>( aCfg, "NavigatorStaysOpen", "appearance.navigator_stays_open" );
820 ret &= fromLegacy<bool>( aCfg, "PrintSheetReferenceAndTitleBlock",
821 "appearance.print_sheet_reference" );
822 ret &= fromLegacy<bool>( aCfg, "ShowHiddenPins", "appearance.show_hidden_pins" );
823 ret &= fromLegacy<bool>( aCfg, "ShowIllegalSymbolLibDialog",
824 "appearance.show_illegal_symbol_lib_dialog" );
825 ret &= fromLegacy<bool>( aCfg, "ShowPageLimits", "appearance.show_page_limits" );
826 ret &= fromLegacy<bool>( aCfg, "ShowSheetFileNameCaseSensitivityDlg",
827 "appearance.show_sheet_filename_case_sensitivity_dialog" );
828
829 ret &= fromLegacy<bool>( aCfg, "AutoplaceFields", "autoplace_fields.enable" );
830 ret &= fromLegacy<bool>( aCfg, "AutoplaceJustify", "autoplace_fields.allow_rejustify" );
831 ret &= fromLegacy<bool>( aCfg, "AutoplaceAlign", "autoplace_fields.align_to_grid" );
832
833 ret &= fromLegacy<int>( aCfg, "DefaultBusWidth", "drawing.default_bus_thickness" );
834 ret &= fromLegacy<int>( aCfg, "DefaultJunctionSize", "drawing.default_junction_size" );
835 ret &= fromLegacy<int>( aCfg, "DefaultDrawLineWidth", "drawing.default_line_thickness" );
836 ret &= fromLegacy<int>( aCfg, "RepeatStepX", "drawing.default_repeat_offset_x" );
837 ret &= fromLegacy<int>( aCfg, "RepeatStepY", "drawing.default_repeat_offset_y" );
838 ret &= fromLegacy<int>( aCfg, "DefaultWireWidth", "drawing.default_wire_thickness" );
839 ret &= fromLegacyString( aCfg, "FieldNames", "drawing.field_names" );
840 ret &= fromLegacy<bool>( aCfg, "HorizVertLinesOnly", "drawing.line_mode" );
841 ret &= fromLegacy<int>( aCfg, "RepeatLabelIncrement", "drawing.repeat_label_increment" );
842
843 ret &= fromLegacy<bool>( aCfg, "DragActionIsMove", "input.drag_is_move" );
844
845 ret &= fromLegacy<int>( aCfg, "SelectionThickness", "selection.thickness" );
846 ret &= fromLegacy<bool>( aCfg, "SelectionDrawChildItems", "selection.draw_selected_children" );
847 ret &= fromLegacy<bool>( aCfg, "SelectionFillShapes", "selection.fill_shapes" );
848 ret &= fromLegacy<bool>( aCfg, "SelectPinSelectSymbolOpt",
849 "selection.select_pin_selects_symbol" );
850
851 ret &= fromLegacy<int>( aCfg, "AnnotateAlgoOption", "annotation.method" );
852 ret &= fromLegacy<int>( aCfg, "AnnotateFilterMsg", "annotation.messages_filter" );
853 ret &= fromLegacy<int>( aCfg, "AnnotateSortOption", "annotation.sort_order" );
854
855 ret &= fromLegacyString( aCfg, "bom_plugin_selected", "bom.selected_plugin" );
856 ret &= fromLegacyString( aCfg, "bom_plugins", "bom.plugins" );
857
859
860 ret &= fromLegacyString( aCfg, "SymbolFieldsShownColumns",
861 "edit_sch_component.visible_columns" );
862
863 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportRevision", "page_settings.export_revision" );
864 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportDate", "page_settings.export_date" );
865 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportTitle", "page_settings.export_title" );
866 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportCompany", "page_settings.export_company" );
867 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment1", "page_settings.export_comment1" );
868 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment2", "page_settings.export_comment2" );
869 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment3", "page_settings.export_comment3" );
870 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment4", "page_settings.export_comment4" );
871 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment5", "page_settings.export_comment5" );
872 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment6", "page_settings.export_comment6" );
873 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment7", "page_settings.export_comment7" );
874 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment8", "page_settings.export_comment8" );
875 ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment9", "page_settings.export_comment9" );
876
877 #if 0 // To do: move this code to the new netlist plugin management in settings
878 {
879 constexpr int max_custom_commands = 8; // from DIALOG_NETLIST
880 nlohmann::json js_cmd = nlohmann::json::array();
881 nlohmann::json js_title = nlohmann::json::array();
882 wxString cmd_key, title_key, cmd, title;
883
884 for( int i = 1; i <= max_custom_commands; ++i )
885 {
886 // Only migrate if both title and command are specified
887 cmd_key.Printf( "CustomNetlistCommand%d", i );
888 title_key.Printf( "CustomNetlistTitle%d", i );
889
890 if( aCfg->Read( cmd_key, &cmd ) && aCfg->Read( title_key, &title )
891 && !cmd.IsEmpty() && !title.IsEmpty() )
892 {
893 js_cmd.push_back( cmd.ToUTF8() );
894 js_title.push_back( title.ToUTF8() );
895 }
896 }
897
898 Set( "netlist.custom_command_titles", js_title );
899 Set( "netlist.custom_command_paths", js_cmd );
900 }
901 #endif
902
903 {
904 // NOTE(JE) These parameters should move to project-local storage before V6, but we are
905 // migrating them here in order to preserve data. There is a bug here that is preserved:
906 // keys are taken directly from the (translated) UI and stored in the config, so if the user
907 // changes languages the keys will no longer work.
908 aCfg->SetPath( "SymbolFieldEditor/Show/" );
909
910 nlohmann::json js = nlohmann::json( {} );
911 wxString key;
912 bool value = false;
913 long index = 0;
914
915 while( aCfg->GetNextEntry( key, index ) )
916 {
917 if( aCfg->Read( key, &value ) )
918 {
919 std::string key_utf( key.ToUTF8() );
920
921 try
922 {
923 js[ std::move( key_utf ) ] = value;
924 }
925 catch(...)
926 {
927 continue;
928 }
929 }
930 }
931
932 Set( "field_editor.fields_show", js );
933
934 aCfg->SetPath( "../GroupBy" );
935
936 while( aCfg->GetNextEntry( key, index ) )
937 {
938 if( aCfg->Read( key, &value ) )
939 {
940 std::string key_utf( key.ToUTF8() );
941
942 try
943 {
944 js[ std::move( key_utf ) ] = value;
945 }
946 catch(...)
947 {
948 continue;
949 }
950 }
951 }
952
953 Set( "field_editor.fields_group_by", js );
954
955 aCfg->SetPath( "../.." );
956 }
957
958 ret &= fromLegacy<bool>( aCfg, "PlotModeColor", "plot.color" );
959 ret &= fromLegacy<int>( aCfg, "PlotFormat", "plot.format" );
960 ret &= fromLegacy<bool>( aCfg, "PlotFrameRef", "plot.frame_reference" );
961 ret &= fromLegacy<bool>( aCfg, "PlotHPGLOrg", "plot.hpgl_origin" );
962 ret &= fromLegacy<int>( aCfg, "PlotHPGLPaperSize", "plot.hpgl_paper_size" );
963 ret &= fromLegacy<double>( aCfg, "PlotHPGLPenSize", "plot.hpgl_pen_size" );
964
965 ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMEPos_x", "simulator.window.pos_x" );
966 ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMEPos_y", "simulator.window.pos_y" );
967 ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMESize_x", "simulator.window.size_x" );
968 ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMESize_y", "simulator.window.size_y" );
969 ret &= fromLegacy<bool>( aCfg, "SIM_PLOT_FRAMEMaximized", "simulator.window.maximized" );
970 ret &= fromLegacyString( aCfg, "SIM_PLOT_FRAMEPerspective", "simulator.window.perspective" );
971 ret &= fromLegacyString( aCfg, "SIM_PLOT_FRAMEMostRecentlyUsedPath", "simulator.mru_path" );
972 ret &= fromLegacy<int>( aCfg, "SimPlotPanelWidth", "simulator.plot_panel_width" );
973 ret &= fromLegacy<int>( aCfg, "SimPlotPanelHeight", "simulator.plot_panel_height" );
974 ret &= fromLegacy<int>( aCfg, "SimSignalPanelHeight", "simulator.signal_panel_height" );
975 ret &= fromLegacy<int>( aCfg, "SimCursorsPanelHeight", "simulator.cursors_panel_height" );
976 ret &= fromLegacy<bool>( aCfg, "SimPlotWhiteBg", "simulator.white_background" );
977
978 ret &= fromLegacy<int>( aCfg, "SymbolChooserHSashPosition", "symbol_chooser.sash_pos_h" );
979 ret &= fromLegacy<int>( aCfg, "SymbolChooserVSashPosition", "symbol_chooser.sash_pos_v" );
980 ret &= fromLegacy<int>( aCfg, "SymbolChooserWidth", "symbol_chooser.width" );
981 ret &= fromLegacy<int>( aCfg, "SymbolChooserHeight", "symbol_chooser.height" );
982 ret &= fromLegacy<bool>( aCfg, "SymbolChooserKeepSymbol", "symbol_chooser.keep_symbol" );
983 ret &= fromLegacy<bool>( aCfg, "SymbolChooserUseUnits", "symbol_chooser.place_all_units" );
984
985 const std::string vlf = "ViewlibFrame";
986 ret &= fromLegacy<bool>( aCfg, vlf + "Maximized", "lib_view.window.maximized" );
987 ret &= fromLegacyString( aCfg, vlf + "MostRecentlyUsedPath", "lib_view.window.mru_path" );
988 ret &= fromLegacy<int>( aCfg, vlf + "Size_x", "lib_view.window.size_x" );
989 ret &= fromLegacy<int>( aCfg, vlf + "Size_y", "lib_view.window.size_y" );
990 ret &= fromLegacyString( aCfg, vlf + "Perspective", "lib_view.window.perspective" );
991 ret &= fromLegacy<int>( aCfg, vlf + "Pos_x", "lib_view.window.pos_x" );
992 ret &= fromLegacy<int>( aCfg, vlf + "Pos_y", "lib_view.window.pos_y" );
993 ret &= fromLegacy<int>( aCfg, "ViewLiblistWidth", "lib_view.lib_list_width" );
994 ret &= fromLegacy<int>( aCfg, "ViewCmplistWidth", "lib_view.cmp_list_width" );
995 ret &= fromLegacy<bool>( aCfg,
996 "ViewCmpShowPinElectricalType", "lib_view.show_pin_electrical_type" );
997 ret &= fromLegacy<bool>( aCfg, vlf + "ShowGrid", "lib_view.grid.show" );
998 ret &= fromLegacy<int>( aCfg, vlf + "_LastGridSize", "lib_view.grid.last_size" );
999
1000 ret &= fromLegacy<bool>( aCfg, "RescueNeverShow", "system.never_show_rescue_dialog" );
1001
1002 // Legacy version stored this setting in eeschema, so move it to common if it exists
1003 bool tmp;
1004
1005 if( aCfg->Read( "MoveWarpsCursor", &tmp ) )
1006 Pgm().GetCommonSettings()->m_Input.warp_mouse_on_move = tmp;
1007
1010
1011 auto migrateLegacyColor = [&] ( const std::string& aKey, int aLayerId ) {
1012 wxString str;
1013
1014 if( aCfg->Read( aKey, &str ) )
1015 cs->SetColor( aLayerId, COLOR4D( str ) );
1016 };
1017
1018 migrateLegacyColor( "Color4DBgCanvasEx", LAYER_SCHEMATIC_BACKGROUND );
1019 migrateLegacyColor( "Color4DBodyBgEx", LAYER_DEVICE_BACKGROUND );
1020 migrateLegacyColor( "Color4DBodyEx", LAYER_DEVICE );
1021 migrateLegacyColor( "Color4DBrightenedEx", LAYER_BRIGHTENED );
1022 migrateLegacyColor( "Color4DBusEx", LAYER_BUS );
1023 migrateLegacyColor( "Color4DConnEx", LAYER_JUNCTION );
1024 migrateLegacyColor( "Color4DCursorEx", LAYER_SCHEMATIC_CURSOR );
1025 migrateLegacyColor( "Color4DErcEEx", LAYER_ERC_ERR );
1026 migrateLegacyColor( "Color4DErcWEx", LAYER_ERC_WARN );
1027 migrateLegacyColor( "Color4DFieldEx", LAYER_FIELDS );
1028 migrateLegacyColor( "Color4DGLabelEx", LAYER_GLOBLABEL );
1029 migrateLegacyColor( "Color4DGridEx", LAYER_SCHEMATIC_GRID );
1030 migrateLegacyColor( "Color4DHLabelEx", LAYER_HIERLABEL );
1031 migrateLegacyColor( "Color4DHiddenEx", LAYER_HIDDEN );
1032 migrateLegacyColor( "Color4DLLabelEx", LAYER_LOCLABEL );
1033 migrateLegacyColor( "Color4DNoConnectEx", LAYER_NOCONNECT );
1034 migrateLegacyColor( "Color4DNoteEx", LAYER_NOTES );
1035 migrateLegacyColor( "Color4DPinEx", LAYER_PIN );
1036 migrateLegacyColor( "Color4DPinNameEx", LAYER_PINNAM );
1037 migrateLegacyColor( "Color4DPinNumEx", LAYER_PINNUM );
1038 migrateLegacyColor( "Color4DReferenceEx", LAYER_REFERENCEPART );
1039 migrateLegacyColor( "Color4DShadowEx", LAYER_SELECTION_SHADOWS );
1040 migrateLegacyColor( "Color4DSheetEx", LAYER_SHEET );
1041 migrateLegacyColor( "Color4DSheetFileNameEx", LAYER_SHEETFILENAME );
1042 migrateLegacyColor( "Color4DSheetLabelEx", LAYER_SHEETLABEL );
1043 migrateLegacyColor( "Color4DSheetNameEx", LAYER_SHEETNAME );
1044 migrateLegacyColor( "Color4DValueEx", LAYER_VALUEPART );
1045 migrateLegacyColor( "Color4DWireEx", LAYER_WIRE );
1046 migrateLegacyColor( "Color4DWorksheetEx", LAYER_SCHEMATIC_DRAWINGSHEET );
1047
1048 mgr.SaveColorSettings( cs, "schematic" );
1049
1050 Set( "appearance.color_theme", cs->GetFilename() );
1051
1052 // LibEdit settings were stored with eeschema. If eeschema is the first app to run,
1053 // we need to migrate the LibEdit settings here
1054
1056 libedit->MigrateFromLegacy( aCfg );
1057 libedit->Load();
1058
1059 return ret;
1060}
1061
1062
1067class BOM_CFG_PARSER : public DIALOG_BOM_CFG_LEXER
1068{
1069 std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS>* m_pluginList;
1070
1071public:
1072 BOM_CFG_PARSER( std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS>* aPluginList,
1073 const char* aData, const wxString& aSource );
1074
1075 void Parse();
1076
1077private:
1078 void parseGenerator();
1079};
1080
1081
1082std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS> EESCHEMA_SETTINGS::DefaultBomPlugins()
1083{
1085}
1086
1087
1089{
1090 if( !Contains( "bom.plugins" ) )
1091 return false;
1092
1093 wxString list = *Get<wxString>( "bom.plugins" );
1094
1095 BOM_CFG_PARSER cfg_parser( &m_BomPanel.plugins, TO_UTF8( list ), wxT( "plugins" ) );
1096
1097 try
1098 {
1099 cfg_parser.Parse();
1100 }
1101 catch( const IO_ERROR& )
1102 {
1103 return false;
1104 }
1105
1106 // Parser will have loaded up our array, let's dump it out to JSON
1107 At( "bom.plugins" ) = bomSettingsToJson();
1108
1109 return true;
1110}
1111
1112
1114{
1115 nlohmann::json js = nlohmann::json::array();
1116
1117 for( const BOM_PLUGIN_SETTINGS& plugin : m_BomPanel.plugins )
1118 {
1119 nlohmann::json pluginJson;
1120
1121 pluginJson["name"] = plugin.name.ToUTF8();
1122 pluginJson["path"] = plugin.path.ToUTF8();
1123 pluginJson["command"] = plugin.command.ToUTF8();
1124
1125 js.push_back( pluginJson );
1126 }
1127
1128 return js;
1129}
1130
1131
1132std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS> EESCHEMA_SETTINGS::bomSettingsFromJson(
1133 const nlohmann::json& aObj )
1134{
1135 std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS> ret;
1136
1137 wxASSERT( aObj.is_array() );
1138
1139 for( const nlohmann::json& entry : aObj )
1140 {
1141 if( entry.empty() || !entry.is_object() )
1142 continue;
1143
1144 if( !entry.contains( "name" ) || !entry.contains( "path" ) )
1145 continue;
1146
1147 BOM_PLUGIN_SETTINGS plugin( entry.at( "name" ).get<wxString>(),
1148 entry.at( "path" ).get<wxString>() );
1149
1150 if( entry.contains( "command" ) )
1151 plugin.command = entry.at( "command" ).get<wxString>();
1152
1153 ret.emplace_back( plugin );
1154 }
1155
1156 return ret;
1157}
1158
1159
1161{
1162 nlohmann::json js = nlohmann::json::array();
1163
1164 for( const NETLIST_PLUGIN_SETTINGS& plugin : m_NetlistPanel.plugins )
1165 {
1166 nlohmann::json pluginJson;
1167
1168 pluginJson["name"] = plugin.name.ToUTF8();
1169 pluginJson["path"] = plugin.path.ToUTF8();
1170 pluginJson["command"] = plugin.command.ToUTF8();
1171
1172 js.push_back( pluginJson );
1173 }
1174
1175 return js;
1176}
1177
1178
1179std::vector<EESCHEMA_SETTINGS::NETLIST_PLUGIN_SETTINGS> EESCHEMA_SETTINGS::netlistSettingsFromJson(
1180 const nlohmann::json& aObj )
1181{
1182 std::vector<EESCHEMA_SETTINGS::NETLIST_PLUGIN_SETTINGS> ret;
1183
1184 wxASSERT( aObj.is_array() );
1185
1186 for( const nlohmann::json& entry : aObj )
1187 {
1188 if( entry.empty() || !entry.is_object() )
1189 continue;
1190
1191 if( !entry.contains( "name" ) || !entry.contains( "path" ) )
1192 continue;
1193
1194 NETLIST_PLUGIN_SETTINGS plugin( entry.at( "name" ).get<wxString>(),
1195 entry.at( "path" ).get<wxString>() );
1196
1197 if( entry.contains( "command" ) )
1198 plugin.command = entry.at( "command" ).get<wxString>();
1199
1200 ret.emplace_back( plugin );
1201 }
1202
1203 return ret;
1204}
1205
1206
1207BOM_CFG_PARSER::BOM_CFG_PARSER( std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS>* aPluginList,
1208 const char* aLine, const wxString& aSource ) :
1209 DIALOG_BOM_CFG_LEXER( aLine, aSource )
1210{
1211 wxASSERT( aPluginList );
1212 m_pluginList = aPluginList;
1213}
1214
1215
1217{
1218 T token;
1219
1220 while( ( token = NextTok() ) != T_RIGHT )
1221 {
1222 if( token == T_EOF)
1223 break;
1224
1225 if( token == T_LEFT )
1226 token = NextTok();
1227
1228 if( token == T_plugins )
1229 continue;
1230
1231 switch( token )
1232 {
1233 case T_plugin: // Defines a new plugin
1235 break;
1236
1237 default:
1238// Unexpected( CurText() );
1239 break;
1240 }
1241 }
1242}
1243
1244
1246{
1247 wxString str;
1249
1250 NeedSYMBOLorNUMBER();
1251 settings.path = FromUTF8();
1252
1253 T token;
1254
1255 while( ( token = NextTok() ) != T_RIGHT )
1256 {
1257 if( token == T_EOF)
1258 break;
1259
1260 switch( token )
1261 {
1262 case T_LEFT:
1263 break;
1264
1265 case T_cmd:
1266 NeedSYMBOLorNUMBER();
1267
1268 settings.command = FromUTF8();
1269
1270 NeedRIGHT();
1271 break;
1272
1273 case T_opts:
1274 {
1275 NeedSYMBOLorNUMBER();
1276
1277 wxString option = FromUTF8();
1278
1279 if( option.StartsWith( wxS( "nickname=" ), &str ) )
1280 settings.name = str;
1281
1282 NeedRIGHT();
1283 break;
1284 }
1285
1286 default:
1287 Unexpected( CurText() );
1288 break;
1289 }
1290 }
1291
1292 m_pluginList->emplace_back( settings );
1293}
const char * name
Definition: DXF_plotter.cpp:59
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:92
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
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 DesignBlocksPaneName()
PANEL_DESIGN_BLOCK_CHOOSER m_DesignBlockChooserPanel
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.
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
DIALOG_IMPORT_GRAPHICS m_ImportGraphics
static std::vector< NETLIST_PLUGIN_SETTINGS > netlistSettingsFromJson(const nlohmann::json &aObj)
PANEL_FIELD_EDITOR m_FieldEditorPanel
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:77
bool fromLegacyString(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy wxConfig string 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::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
Definition: json_settings.h:80
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Stores an enum as an integer.
Definition: parameters.h:228
Like a normal param, but with custom getter and setter functions.
Definition: parameters.h:295
Represents a map of <std::string, Value>.
Definition: parameters.h:726
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:689
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:125
void SaveColorSettings(COLOR_SETTINGS *aSettings, const std::string &aNamespace="")
Safely save a COLOR_SETTINGS to disk, preserving any changes outside the given namespace.
T * GetAppSettings(const wxString &aFilename)
Return a handle to the a given settings by type.
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)
@ LAYER_SHEETNAME
Definition: layer_ids.h:461
@ LAYER_ERC_WARN
Definition: layer_ids.h:468
@ LAYER_SHEETLABEL
Definition: layer_ids.h:464
@ LAYER_PINNUM
Definition: layer_ids.h:447
@ LAYER_DEVICE
Definition: layer_ids.h:455
@ LAYER_BRIGHTENED
Definition: layer_ids.h:480
@ LAYER_HIDDEN
Definition: layer_ids.h:481
@ LAYER_HIERLABEL
Definition: layer_ids.h:446
@ LAYER_PINNAM
Definition: layer_ids.h:448
@ LAYER_GLOBLABEL
Definition: layer_ids.h:445
@ LAYER_WIRE
Definition: layer_ids.h:441
@ LAYER_NOTES
Definition: layer_ids.h:456
@ LAYER_ERC_ERR
Definition: layer_ids.h:469
@ LAYER_PIN
Definition: layer_ids.h:459
@ LAYER_VALUEPART
Definition: layer_ids.h:450
@ LAYER_BUS
Definition: layer_ids.h:442
@ LAYER_SCHEMATIC_CURSOR
Definition: layer_ids.h:478
@ LAYER_FIELDS
Definition: layer_ids.h:451
@ LAYER_DEVICE_BACKGROUND
Definition: layer_ids.h:473
@ LAYER_SCHEMATIC_DRAWINGSHEET
Definition: layer_ids.h:484
@ LAYER_LOCLABEL
Definition: layer_ids.h:444
@ LAYER_JUNCTION
Definition: layer_ids.h:443
@ LAYER_REFERENCEPART
Definition: layer_ids.h:449
@ LAYER_SHEET
Definition: layer_ids.h:460
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:483
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:477
@ LAYER_SHEETFILENAME
Definition: layer_ids.h:462
@ LAYER_NOCONNECT
Definition: layer_ids.h:465
@ LAYER_SCHEMATIC_GRID
Definition: layer_ids.h:475
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:1073
see class PGM_BASE
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: string_utils.h:403
std::map< wxString, int > column_widths
Column widths, keyed by header name.
Definition: app_settings.h:134
std::vector< double > junction_size_mult_list
std::vector< BOM_PLUGIN_SETTINGS > plugins
std::map< std::string, int > field_widths
std::vector< NETLIST_PLUGIN_SETTINGS > plugins
SIM_MOUSE_WHEEL_ACTION vertical_unmodified
SIM_MOUSE_WHEEL_ACTION vertical_with_alt
SIM_MOUSE_WHEEL_ACTION horizontal
SIM_MOUSE_WHEEL_ACTION vertical_with_ctrl
SIM_MOUSE_WHEEL_ACTION vertical_with_shift
SIM_MOUSE_WHEEL_ACTION_SET mouse_wheel_actions
WINDOW_STATE state
Definition: app_settings.h:75
wxString perspective
Definition: app_settings.h:77
unsigned int display
Definition: app_settings.h:67
Functions to provide common constants and other functions to assist in making a consistent UI.