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