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