KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcbnew_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 <common.h>
23#include <layer_ids.h>
24#include <lset.h>
25#include <pcbnew_settings.h>
26#include <pgm_base.h>
30#include <settings/parameters.h>
34#include <wx/config.h>
35#include <wx/tokenzr.h>
36#include <base_units.h>
37
39
40
42const int pcbnewSchemaVersion = 5;
43
44
50
51
58 m_Display(),
62 m_CtrlClickHighlight( false ),
65 m_AutoConstraints( true ),
67 m_PolarCoords( false ),
69 m_ShowPageLimits( true ),
71 m_AutoRefillZones( false ),
72 m_AllowFreePads( false ),
74 m_PnsSettings( nullptr ),
77{
79
82 m_MagneticItems.graphics = false;
83 m_MagneticItems.allLayers = false;
84
85 m_params.emplace_back( new PARAM<bool>( "aui.show_layer_manager",
86 &m_AuiPanels.show_layer_manager, true ) );
87
88 m_params.emplace_back( new PARAM<int>( "aui.right_panel_width",
89 &m_AuiPanels.right_panel_width, -1 ) );
90
91 m_params.emplace_back( new PARAM<int>( "aui.net_inspector_width",
92 &m_AuiPanels.net_inspector_width, -1 ) );
93
94 m_params.emplace_back( new PARAM<int>( "aui.properties_panel_width",
95 &m_AuiPanels.properties_panel_width, -1 ) );
96
97 m_params.emplace_back( new PARAM<float>( "aui.properties_splitter_proportion",
98 &m_AuiPanels.properties_splitter, 0.5f ) );
99
100 m_params.emplace_back( new PARAM<int>( "aui.search_panel_height",
101 &m_AuiPanels.search_panel_height, -1 ) );
102
103 m_params.emplace_back( new PARAM<int>( "aui.search_panel_width",
104 &m_AuiPanels.search_panel_width, -1 ) );
105
106 m_params.emplace_back( new PARAM<int>( "aui.search_panel_dock_direction",
107 &m_AuiPanels.search_panel_dock_direction, 3 ) );
108
109 m_params.emplace_back( new PARAM<int>( "aui.appearance_panel_tab",
110 &m_AuiPanels.appearance_panel_tab, 0, 0, 2 ) );
111
112 m_params.emplace_back( new PARAM<bool>( "aui.appearance_expand_layer_display",
113 &m_AuiPanels.appearance_expand_layer_display, false ) );
114
115 m_params.emplace_back( new PARAM<bool>( "aui.appearance_expand_net_display",
116 &m_AuiPanels.appearance_expand_net_display, false ) );
117
118 m_params.emplace_back( new PARAM<bool>( "aui.show_properties",
119 &m_AuiPanels.show_properties, true ) );
120
121 m_params.emplace_back( new PARAM<bool>( "aui.show_git_commit_pane", &m_AuiPanels.show_git_commit_pane, false ) );
122
123 m_params.emplace_back( new PARAM<bool>( "aui.show_search",
124 &m_AuiPanels.show_search, false ) );
125
126 m_params.emplace_back( new PARAM<bool>( "aui.show_net_inspector",
127 &m_AuiPanels.show_net_inspector, false ) );
128
129 m_params.emplace_back( new PARAM<bool>( "aui.design_blocks_show",
130 &m_AuiPanels.design_blocks_show, false ) );
131
132 m_params.emplace_back( new PARAM<int>( "aui.design_blocks_panel_docked_width",
133 &m_AuiPanels.design_blocks_panel_docked_width, -1 ) );
134
135 m_params.emplace_back( new PARAM<int>( "aui.design_blocks_panel_float_width",
136 &m_AuiPanels.design_blocks_panel_float_width, -1 ) );
137
138 m_params.emplace_back( new PARAM<int>( "aui.design_blocks_panel_float_height",
139 &m_AuiPanels.design_blocks_panel_float_height, -1 ) );
140
141 m_params.emplace_back( new PARAM<int>( "footprint_chooser.width",
142 &m_FootprintChooser.width, -1 ) );
143
144 m_params.emplace_back( new PARAM<int>( "footprint_chooser.height",
145 &m_FootprintChooser.height, -1 ) );
146
147 m_params.emplace_back( new PARAM<int>( "footprint_chooser.sash_h",
148 &m_FootprintChooser.sash_h, -1 ) );
149
150 m_params.emplace_back( new PARAM<int>( "footprint_chooser.sash_v",
151 &m_FootprintChooser.sash_v, -1 ) );
152
153 m_params.emplace_back( new PARAM<int>( "footprint_chooser.sort_mode",
154 &m_FootprintChooser.sort_mode, 0 ) );
155
156 m_params.emplace_back( new PARAM<bool>( "footprint_chooser.filter_on_pin_count",
157 &m_FootprintChooser.filter_on_pin_count, false ) );
158
159 m_params.emplace_back( new PARAM<bool>( "footprint_chooser.use_fp_filters",
160 &m_FootprintChooser.use_fp_filters, false ) );
161
162 m_params.emplace_back( new PARAM<bool>( "editing.flip_left_right",
163 reinterpret_cast<bool*>( &m_FlipDirection ),
164 static_cast<bool>( FLIP_DIRECTION::LEFT_RIGHT ) ) );
165
166 m_params.emplace_back( new PARAM<bool>( "editing.esc_clears_net_highlight",
167 &m_ESCClearsNetHighlight, true ) );
168
169 m_params.emplace_back( new PARAM<bool>( "editing.show_courtyard_collisions",
170 &m_ShowCourtyardCollisions, true ) );
171
172 m_params.emplace_back( new PARAM<bool>( "editing.magnetic_graphics",
173 &m_MagneticItems.graphics, true ) );
174
175 m_params.emplace_back( new PARAM<int>( "editing.magnetic_pads",
176 reinterpret_cast<int*>( &m_MagneticItems.pads ),
178
179 m_params.emplace_back( new PARAM<int>( "editing.magnetic_tracks",
180 reinterpret_cast<int*>( &m_MagneticItems.tracks ),
182
183 m_params.emplace_back( new PARAM<bool>( "editing.magnetic_all_layers",
184 &m_MagneticItems.allLayers, false ) );
185
187
188 m_params.emplace_back( new PARAM<bool>( "editing.polar_coords",
189 &m_PolarCoords, false ) );
190
191 m_params.emplace_back( new PARAM<int>( "editing.track_drag_action",
192 reinterpret_cast<int*>( &m_TrackDragAction ),
193 static_cast<int>( TRACK_DRAG_ACTION::DRAG ) ) );
194
195 m_params.emplace_back( new PARAM<int>( "editing.arc_edit_mode",
196 reinterpret_cast<int*>( &m_ArcEditMode ),
198
199 m_params.emplace_back( new PARAM<bool>( "editing.ctrl_click_highlight",
200 &m_CtrlClickHighlight, false ) );
201
202 m_params.emplace_back( new PARAM<int>( "editing.pcb_angle_snap_mode",
203 reinterpret_cast<int*>( &m_AngleSnapMode ),
204 static_cast<int>( LEADER_MODE::DIRECT ) ) );
205
206 m_params.emplace_back( new PARAM<bool>( "editing.auto_constraints", &m_AutoConstraints, true ) );
207
208 m_params.emplace_back( new PARAM<bool>( "editing.auto_fill_zones",
209 &m_AutoRefillZones, false ) );
210
211 m_params.emplace_back( new PARAM<bool>( "editing.allow_free_pads",
212 &m_AllowFreePads, false ) );
213
214 m_params.emplace_back( new PARAM<bool>( "import.keep_kicad_layer_names",
215 &m_ImportKeepKiCadLayerNames, false ) );
216
217 m_params.emplace_back( new PARAM_LAMBDA<int>( "editing.rotation_angle",
218 [this] () -> int
219 {
220 int rot = m_RotationAngle.AsTenthsOfADegree();
221
222 // Don't store values larger than 360 degrees
223 return rot % 3600;
224 },
225 [this] ( int aVal )
226 {
227 if( aVal )
229
230 // A misconfiguration allowed some angles to be stored as tenth of a degree but read
231 // as tens of degrees. By disallowing storage of values larger than 360, we can weed out
232 // those invalid values here.
233 while( m_RotationAngle > ANGLE_360 )
235
236 },
237 900 ) );
238
239 m_params.emplace_back( new PARAM<bool>( "pcb_display.graphic_items_fill",
240 &m_ViewersDisplay.m_DisplayGraphicsFill, true ) );
241
242 m_params.emplace_back( new PARAM<int>( "pcb_display.max_links_shown",
243 &m_Display.m_MaxLinksShowed, 3, 0, 15 ) );
244
245 m_params.emplace_back( new PARAM<bool>( "pcb_display.graphics_fill",
246 &m_ViewersDisplay.m_DisplayGraphicsFill, true ) );
247
248 m_params.emplace_back( new PARAM<bool>( "pcb_display.text_fill",
249 &m_ViewersDisplay.m_DisplayTextFill, true ) );
250
251 m_params.emplace_back( new PARAM<int>( "pcb_display.net_names_mode",
252 &m_Display.m_NetNames, 3, 0, 3 ) );
253
254 m_params.emplace_back( new PARAM<bool>( "pcb_display.pad_clearance",
255 &m_Display.m_PadClearance, true ) );
256
257 m_params.emplace_back( new PARAM<bool>( "pcb_display.pad_use_via_color_for_normal_th_padstacks",
258 &m_Display.m_UseViaColorForNormalTHPadstacks, false ) );
259
260 m_params.emplace_back( new PARAM<bool>( "pcb_display.pad_fill",
261 &m_ViewersDisplay.m_DisplayPadFill, true ) );
262
263 m_params.emplace_back( new PARAM<bool>( "pcb_display.pad_numbers",
264 &m_ViewersDisplay.m_DisplayPadNumbers, true ) );
265
266 m_params.emplace_back( new PARAM<bool>( "pcb_display.ratsnest_global",
267 &m_Display.m_ShowGlobalRatsnest, true ) );
268
269 m_params.emplace_back( new PARAM<bool>( "pcb_display.show_constraints",
270 &m_Display.m_ShowConstraints, false ) );
271
272 m_params.emplace_back( new PARAM<bool>( "pcb_display.ratsnest_footprint",
273 &m_Display.m_ShowModuleRatsnest, true ) );
274
275 m_params.emplace_back( new PARAM<bool>( "pcb_display.ratsnest_curved",
276 &m_Display.m_DisplayRatsnestLinesCurved, false ) );
277
278 m_params.emplace_back( new PARAM<double>( "pcb_display.ratsnest_thickness",
279 &m_Display.m_RatsnestThickness, 0.5 ) );
280
281 m_params.emplace_back( new PARAM_ENUM<TRACK_CLEARANCE_MODE>( "pcb_display.track_clearance_mode",
284
285 m_params.emplace_back( new PARAM<bool>( "pcb_display.track_fill",
286 &m_Display.m_DisplayPcbTrackFill, true ) );
287
288 m_params.emplace_back( new PARAM<bool>( "pcb_display.via_fill",
289 &m_Display.m_DisplayViaFill, true ) );
290
291 m_params.emplace_back( new PARAM<int>( "pcb_display.origin_mode",
292 reinterpret_cast<int*>( &m_Display.m_DisplayOrigin ),
294
295 m_params.emplace_back( new PARAM<bool>( "pcb_display.origin_invert_x_axis",
296 &m_Display.m_DisplayInvertXAxis, false ) );
297
298 m_params.emplace_back( new PARAM<bool>( "pcb_display.origin_invert_y_axis",
299 &m_Display.m_DisplayInvertYAxis, false ) );
300
301 m_params.emplace_back( new PARAM<bool>( "pcb_display.force_show_fields_when_fp_selected",
302 &m_Display.m_ForceShowFieldsWhenFPSelected, true ) );
303
304 m_params.emplace_back( new PARAM<bool>( "pcb_display.live_3d_refresh",
305 &m_Display.m_Live3DRefresh, false ) );
306
307 m_params.emplace_back( new PARAM<bool>( "pcb_display.show_page_borders",
308 &m_ShowPageLimits, true ) );
309
310 m_params.emplace_back( new PARAM_MAP<int>( "field_editor.field_widths",
311 &m_FieldEditorPanel.field_widths, {} ) );
312
313 m_params.emplace_back( new PARAM<int>( "field_editor.selection_mode",
314 &m_FieldEditorPanel.selection_mode, 0 ) );
315
316 m_params.emplace_back( new PARAM<int>( "field_editor.sash_pos",
317 &m_FieldEditorPanel.sash_pos, 400 ) );
318
319 m_params.emplace_back( new PARAM<int>( "field_editor.variant_sash_pos",
320 &m_FieldEditorPanel.variant_sash_pos, 500 ) );
321
322 m_params.emplace_back( new PARAM<bool>( "field_editor.sidebar_collapsed",
323 &m_FieldEditorPanel.sidebar_collapsed, false ) );
324
325 m_params.emplace_back( new PARAM<bool>( "export_d356.doNotExportUnconnectedPads",
326 &m_ExportD356.doNotExportUnconnectedPads, false ) );
327
328 addParamsForWindow( &m_FootprintViewer, "footprint_viewer" );
329
330 m_params.emplace_back( new PARAM<double>( "footprint_viewer.zoom",
331 &m_FootprintViewerZoom, 1.0 ) );
332
333 m_params.emplace_back( new PARAM<bool>( "footprint_viewer.autozoom",
335
336 m_params.emplace_back( new PARAM<int>( "footprint_viewer.lib_list_width",
338
339 m_params.emplace_back( new PARAM<int>( "footprint_viewer.fp_list_width",
341
342 addParamsForWindow( &m_FootprintWizard, "footprint_wizard" );
343
344 m_params.emplace_back( new PARAM<wxString>( "system.last_footprint_lib_dir",
345 &m_LastFootprintLibDir, "" ) );
346
347 m_params.emplace_back( new PARAM<wxString>( "system.last_footprint3d_dir",
348 &m_LastFootprint3dDir, "" ) );
349
350 m_params.emplace_back( new PARAM<bool>( "DRC.report_all_track_errors",
351 &m_DRCDialog.report_all_track_errors, false ) );
352
353 m_params.emplace_back( new PARAM<bool>( "DRC.crossprobe",
354 &m_DRCDialog.crossprobe, true ) );
355
356 m_params.emplace_back( new PARAM<bool>( "DRC.scroll_on_crossprobe",
357 &m_DRCDialog.scroll_on_crossprobe, true ) );
358
359 m_params.emplace_back( new PARAM<COLOR4D>( "diff_phase_skew.zero_color",
360 &m_DiffPhaseSkewSettings.m_ZeroSkewColor, COLOR4D( 1.0, 1.0, 1.0, 1.0 ) ) );
361
362 m_params.emplace_back( new PARAM<COLOR4D>( "diff_phase_skew.positive_color",
363 &m_DiffPhaseSkewSettings.m_PositiveSkewColor, COLOR4D( 0.0, 0.0, 1.0, 1.0 ) ) );
364
365 m_params.emplace_back( new PARAM<COLOR4D>( "diff_phase_skew.negative_color",
366 &m_DiffPhaseSkewSettings.m_NegativeSkewColor, COLOR4D( 1.0, 0.0, 0.0, 1.0 ) ) );
367
368 m_params.emplace_back( new PARAM<COLOR4D>( "diff_phase_skew.unknown_color",
369 &m_DiffPhaseSkewSettings.m_UnknownSkewColor, COLOR4D( 0.5, 0.5, 0.5, 1.0 ) ) );
370
371 m_params.emplace_back( new PARAM<bool>( "diff_phase_skew.use_log_scale",
372 &m_DiffPhaseSkewSettings.m_UseLogScale, false ) );
373
374 registerMigration( 0, 1,
375 [&]()
376 {
377 if( std::optional<int> optval = Get<int>( "pcb_display.rotation_angle" ) )
378 Set( "editing.rotation_angle", *optval );
379
380 try
381 {
382 At( "pcb_display" ).erase( "rotation_angle" );
383 }
384 catch( ... )
385 {}
386
387 return true;
388 } );
389
390 registerMigration( 1, 2,
391 [&]()
392 {
393 // In version 1 this meant "after Zone Properties dialog", but it now means
394 // "everywhere" so we knock it off on transition.
395 Set( "editing.auto_fill_zones", false );
396
397 return true;
398 } );
399
400
401 registerMigration( 2, 3,
402 [&]() -> bool
403 {
404 // We used to have a bug on GTK which would set the lib tree column width way
405 // too narrow.
406 if( std::optional<int> optval = Get<int>( "lib_tree.column_width" ) )
407 {
408 if( optval < 150 )
409 Set( "lib_tree.column_width", 300 );
410 }
411
412 return true;
413 } );
414
415 registerMigration( 3, 4,
416 [&]() -> bool
417 {
418 // This is actually a migration for APP_SETTINGS_BASE::m_LibTree
419 return migrateLibTreeWidth();
420 } );
421
422 registerMigration( 4, 5,
423 [&]() -> bool
424 {
425 // This default proved to be unpopular; bump it off for everyone
426 Set( "editing.auto_fill_zones", false );
427 return true;
428 } );
429}
430
431
433
434
435bool PCBNEW_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
436{
437 bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
438
439 const std::string f = getLegacyFrameName();
440
441 //
442 // NOTE: there's no value in line-wrapping these; it just makes the table unreadable.
443 //
444 ret &= fromLegacy<bool>( aCfg, "ShowLayerManagerTools", "aui.show_layer_manager" );
445
446 ret &= fromLegacy<int>( aCfg, "FootprintChooserHSashPosition", "footprint_chooser.sash_h" );
447 ret &= fromLegacy<int>( aCfg, "FootprintChooserVSashPosition", "footprint_chooser.sash_v" );
448 ret &= fromLegacy<int>( aCfg, "FootprintChooserWidth", "footprint_chooser.width" );
449 ret &= fromLegacy<int>( aCfg, "FootprintChooserHeight", "footprint_chooser.height" );
450
451 ret &= fromLegacy<bool>( aCfg, "FlipLeftRight", "editing.flip_left_right" );
452 ret &= fromLegacy<bool>( aCfg, "MagneticGraphics", "editing.magnetic_graphics" );
453 ret &= fromLegacy<int>( aCfg, "MagneticPads", "editing.magnetic_pads" );
454 ret &= fromLegacy<int>( aCfg, "MagneticTracks", "editing.magnetic_tracks" );
455 ret &= fromLegacy<bool>( aCfg, "DisplayPolarCoords", "editing.polar_coords" );
456 ret &= fromLegacy<bool>( aCfg, "Use45DegreeGraphicSegments", "editing.use_45_degree_graphic_segments" );
457
458 ret &= fromLegacy<bool>( aCfg, "PcbAffT", "pcb_display.graphic_items_fill" );
459 ret &= fromLegacy<int>( aCfg, "MaxLnkS", "pcb_display.max_links_shown" );
460 ret &= fromLegacy<bool>( aCfg, "ModAffC", "pcb_display.footprint_edge_fill" );
461 ret &= fromLegacy<bool>( aCfg, "ModAffT", "pcb_display.footprint_text_fill" );
462 ret &= fromLegacy<int>( aCfg, "ShowNetNamesMode", "pcb_display.net_names_mode" );
463 ret &= fromLegacy<int>( aCfg, "PcbDisplayOrigin", "pcb_display.origin_mode" );
464 ret &= fromLegacy<bool>( aCfg, "PcbInvertXAxis", "pcb_display.origin_invert_x_axis" );
465 ret &= fromLegacy<bool>( aCfg, "PcbInvertYAxis", "pcb_display.origin_invert_y_axis" );
466 ret &= fromLegacy<bool>( aCfg, "PadAffG", "pcb_display.pad_clearance" );
467 ret &= fromLegacy<bool>( aCfg, "PadFill", "pcb_display.pad_fill" );
468 ret &= fromLegacy<bool>( aCfg, "PadSNum", "pcb_display.pad_numbers" );
469 ret &= fromLegacy<bool>( aCfg, "ShowRatsnestLines", "pcb_display.ratsnest_global" );
470 ret &= fromLegacy<bool>( aCfg, "ShowRatsnestModuleLines", "pcb_display.ratsnest_footprint" );
471 ret &= fromLegacy<bool>( aCfg, "CurvedRatsnestLines", "pcb_display.ratsnest_curved" );
472 ret &= fromLegacy<int>( aCfg, "RotationAngle", "pcb_display.rotation_angle" );
473 ret &= fromLegacy<int>( aCfg, "TrackDisplayClearance", "pcb_display.track_clearance_mode" );
474 ret &= fromLegacy<bool>( aCfg, "DisplayTrackFilled", "pcb_display.track_fill" );
475 ret &= fromLegacy<bool>( aCfg, "ViaFill", "pcb_display.via_fill" );
476 ret &= fromLegacy<int>( aCfg, "PcbShowZonesMode", "pcb_display.zone_mode" );
477
478 ret &= fromLegacy<double>( aCfg, "PlotLineWidth_mm", "plot.line_width" );
479
480 {
481 nlohmann::json js = nlohmann::json::array();
482 wxString key;
483 bool val = false;
484
485 for( unsigned i = 0; i < PCB_LAYER_ID_COUNT; ++i )
486 {
487 key.Printf( wxT( "PlotSVGLayer_%d" ), i );
488
489 if( aCfg->Read( key, &val ) && val )
490 js.push_back( i );
491 }
492
493 Set( "export_svg.layers", js );
494 }
495
496 {
497 nlohmann::json js = nlohmann::json::array();
498
499 wxString packed;
500
501 if( aCfg->Read( "ActionPluginButtons", &packed ) )
502 {
503 wxStringTokenizer pluginSettingsTokenizer = wxStringTokenizer( packed, ";" );
504
505 while( pluginSettingsTokenizer.HasMoreTokens() )
506 {
507 nlohmann::json row;
508 wxString plugin = pluginSettingsTokenizer.GetNextToken();
509 wxStringTokenizer pluginTokenizer = wxStringTokenizer( plugin, "=" );
510
511 if( pluginTokenizer.CountTokens() != 2 )
512 {
513 // Bad config
514 continue;
515 }
516
517 std::string key( pluginTokenizer.GetNextToken().ToUTF8() );
518 bool value( pluginTokenizer.GetNextToken().Cmp( wxT( "Visible" ) ) == 0 );
519
520 js.push_back( nlohmann::json( { { key, value } } ) );
521 }
522 }
523
524 Set( "action_plugins", js );
525 }
526
527 //
528 // NOTE: there's no value in line-wrapping these; it just makes the table unreadable.
529 //
530 ret &= fromLegacy<int>( aCfg, "Zone_Ouline_Hatch_Opt", "zones.hatching_style" );
531 ret &= fromLegacy<int>( aCfg, "Zone_NetSort_Opt", "zones.net_sort_mode" );
532 ret &= fromLegacy<double>( aCfg, "Zone_Clearance", "zones.clearance" );
533 ret &= fromLegacy<double>( aCfg, "Zone_Thickness", "zones.min_thickness" );
534 ret &= fromLegacy<double>( aCfg, "Zone_TH_Gap", "zones.thermal_relief_gap" );
535 ret &= fromLegacy<double>( aCfg, "Zone_TH_Copper_Width", "zones.thermal_relief_copper_width" );
536
537 ret &= fromLegacy<int>( aCfg, "PrintSinglePage", "plot.all_layers_on_one_page" );
538 ret &= fromLegacy<int>( aCfg, "PrintPadsDrillOpt", "plot.pads_drill_mode" );
539 ret &= fromLegacy<double>( aCfg, "PlotXFineScaleAdj", "plot.fine_scale_x" );
540 ret &= fromLegacy<double>( aCfg, "PlotYFineScaleAdj", "plot.fine_scale_y" );
541 ret &= fromLegacy<double>( aCfg, "PSPlotFineWidthAdj", "plot.ps_fine_width_adjust" );
542 ret &= fromLegacy<bool>( aCfg, "CheckZonesBeforePlotting", "plot.check_zones_before_plotting" );
543
544 ret &= fromLegacy<int>( aCfg, "FpWizardListWidth", "footprint_wizard_list.width" );
545 ret &= fromLegacy<int>( aCfg, "FpWizardListHeight", "footprint_wizard_list.height" );
546
547 migrateWindowConfig( aCfg, "ModViewFrame", "footprint_viewer" );
548
549 ret &= fromLegacy<bool>( aCfg, "ModViewFrameAutoZoom", "footprint_viewer.auto_zoom" );
550 ret &= fromLegacy<double>( aCfg, "ModViewFrameZoom", "footprint_viewer.zoom" );
551
552 migrateWindowConfig( aCfg, "FootprintWizard", "footprint_wizard" );
553 ret &= fromLegacyString( aCfg, "Fpwizard_auiPerspective", "footprint_wizard.perspective" );
554
555
556 const std::string p = "pcbnew.InteractiveRouter.";
557
558 Set( "tools.pns.meta", nlohmann::json( {
559 { "filename", "pns" },
560 { "version", 0 }
561 } ) );
562
563 ret &= fromLegacy<int>( aCfg, p + "Mode", "tools.pns.mode" );
564 ret &= fromLegacy<int>( aCfg, p + "OptimizerEffort", "tools.pns.effort" );
565 ret &= fromLegacy<bool>( aCfg, p + "RemoveLoops", "tools.pns.remove_loops" );
566 ret &= fromLegacy<bool>( aCfg, p + "SmartPads", "tools.pns.smart_pads" );
567 ret &= fromLegacy<bool>( aCfg, p + "ShoveVias", "tools.pns.shove_vias" );
568 ret &= fromLegacy<bool>( aCfg, p + "StartDiagonal", "tools.pns.start_diagonal" );
569 ret &= fromLegacy<int>( aCfg, p + "ShoveTimeLimit", "tools.pns.shove_time_limit" );
570 ret &= fromLegacy<int>( aCfg, p + "ShoveIterationLimit", "tools.pns.shove_iteration_limit" );
571 ret &= fromLegacy<int>( aCfg, p + "WalkaroundIterationLimit", "tools.pns.walkaround_iteration_limit" );
572 ret &= fromLegacy<bool>( aCfg, p + "JumpOverObstacles", "tools.pns.jump_over_obstacles" );
573 ret &= fromLegacy<bool>( aCfg, p + "SmoothDraggedSegments", "tools.pns.smooth_dragged_segments" );
574 ret &= fromLegacy<bool>( aCfg, p + "CanViolateDRC", "tools.pns.can_violate_drc" );
575 ret &= fromLegacy<bool>( aCfg, p + "SuggestFinish", "tools.pns.suggest_finish" );
576 ret &= fromLegacy<bool>( aCfg, p + "FreeAngleMode", "tools.pns.free_angle_mode" );
577 ret &= fromLegacy<bool>( aCfg, p + "InlineDragEnabled", "editing.track_drag_action" );
578
579 // Initialize some new PNS settings to legacy behaviors if coming from legacy
580 Set( "tools.pns.fix_all_segments", false );
581
582 // Migrate color settings that were stored in the pcbnew config file
583
586
587 auto migrateLegacyColor =
588 [&] ( const std::string& aKey, int aLayerId )
589 {
590 wxString str;
591
592 if( aCfg->Read( aKey, &str ) )
593 cs->SetColor( aLayerId, COLOR4D( str ) );
594 };
595
596 for( int i = 0; i < PCB_LAYER_ID_COUNT; ++i )
597 {
598 wxString layer = LSET::Name( PCB_LAYER_ID( i ) );
599 migrateLegacyColor( "Color4DPCBLayer_" + layer.ToStdString(), PCB_LAYER_ID( i ) );
600 }
601
602 migrateLegacyColor( "Color4DAnchorEx", LAYER_ANCHOR );
603 migrateLegacyColor( "Color4DAuxItems", LAYER_AUX_ITEMS );
604 migrateLegacyColor( "Color4DGrid", LAYER_GRID );
605 migrateLegacyColor( "Color4DNonPlatedEx", LAYER_NON_PLATEDHOLES );
606 migrateLegacyColor( "Color4DPCBBackground", LAYER_PCB_BACKGROUND );
607 migrateLegacyColor( "Color4DPCBCursor", LAYER_CURSOR );
608 migrateLegacyColor( "Color4DRatsEx", LAYER_RATSNEST );
609 migrateLegacyColor( "Color4DViaBBlindEx", LAYER_VIA_BLIND );
610 migrateLegacyColor( "Color4DViaBBlindEx", LAYER_VIA_BURIED );
611 migrateLegacyColor( "Color4DViaMicroEx", LAYER_VIA_MICROVIA );
612 migrateLegacyColor( "Color4DViaThruEx", LAYER_VIA_THROUGH );
613 migrateLegacyColor( "Color4DWorksheet", LAYER_DRAWINGSHEET );
614 migrateLegacyColor( "Color4DGrid", LAYER_PAGE_LIMITS );
615
616 mgr.SaveColorSettings( cs, "board" );
617
618 Set( "appearance.color_theme", cs->GetFilename() );
619
620 double x = 0, y = 0;
621
622 if( aCfg->Read( f + "PcbUserGrid_X", &x ) && aCfg->Read( f + "PcbUserGrid_Y", &y ) )
623 {
624 EDA_UNITS u = static_cast<EDA_UNITS>( aCfg->ReadLong( f + "PcbUserGrid_Unit",
625 static_cast<long>( EDA_UNITS::INCH ) ) );
626
627 // Convert to internal units
630
631 Set( "window.grid.user_grid_x", EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, u, x ) );
632 Set( "window.grid.user_grid_y", EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, u, y ) );
633 }
634
635 // Footprint editor settings were stored in pcbnew config file. Migrate them here.
637 fpedit->MigrateFromLegacy( aCfg );
638 fpedit->Load();
639
640 // Same with 3D viewer
642 viewer3d->MigrateFromLegacy( aCfg );
643 viewer3d->Load();
644
645 return ret;
646}
ARC_EDIT_MODE
Settings for arc editing.
@ KEEP_CENTER_ADJUST_ANGLE_RADIUS
When editing endpoints, the angle and radius are adjusted.
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:128
bool migrateWindowConfig(wxConfigBase *aCfg, const std::string &aFrameName, const std::string &aJsonPath)
Migrate legacy window settings into the JSON document.
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.
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)
bool MigrateFromLegacy(wxConfigBase *aLegacyConfig) override
Migrates from wxConfig to JSON-based configuration.
virtual bool MigrateFromLegacy(wxConfigBase *aLegacyConfig) override
Migrates from wxConfig to JSON-based configuration.
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...
virtual void Load()
Updates the parameters of this object based on the current JSON document contents.
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
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition lset.cpp:184
Stores an enum as an integer.
Definition parameters.h:232
Like a normal param, but with custom getter and setter functions.
Definition parameters.h:299
Represents a map of <std::string, Value>.
Definition parameters.h:752
DIALOG_EXPORT_D356 m_ExportD356
DISPLAY_OPTIONS m_Display
wxString m_LastFootprintLibDir
EDA_ANGLE m_RotationAngle
DIALOG_DRC m_DRCDialog
ARC_EDIT_MODE m_ArcEditMode
FOOTPRINT_CHOOSER m_FootprintChooser
virtual ~PCBNEW_SETTINGS()
TRACK_DRAG_ACTION m_TrackDragAction
LEADER_MODE m_AngleSnapMode
virtual std::string getLegacyFrameName() const override
virtual bool MigrateFromLegacy(wxConfigBase *aLegacyConfig) override
Migrates from wxConfig to JSON-based configuration.
WINDOW_SETTINGS m_FootprintWizard
FIELDS_TABLE_SETTINGS m_FieldEditorPanel
DIFF_PHASE_SKEW_SETTINGS m_DiffPhaseSkewSettings
AUI_PANELS m_AuiPanels
WINDOW_SETTINGS m_FootprintViewer
wxString m_LastFootprint3dDir
MAGNETIC_SETTINGS m_MagneticItems
FLIP_DIRECTION m_FlipDirection
SNAP_INFERENCE_SETTINGS m_SnapInference
std::unique_ptr< PNS::ROUTING_SETTINGS > m_PnsSettings
bool m_FootprintViewerAutoZoomOnSelect
true to use automatic zoom on fp selection
std::set< wxString > m_MatchProperties
Keyed as "family/Property Name"; see MATCH_PROPERTIES_CATALOG.
PCB_VIEWERS_SETTINGS_BASE(const std::string &aFilename, int aSchemaVersion)
VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay
void addMatchPropertiesParam()
Opt-in.
double m_FootprintViewerZoom
The last zoom level used (0 for auto)
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:123
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,...
static constexpr EDA_ANGLE ANGLE_90
Definition eda_angle.h:450
@ TENTHS_OF_A_DEGREE_T
Definition eda_angle.h:29
static constexpr EDA_ANGLE ANGLE_360
Definition eda_angle.h:454
EDA_UNITS
Definition eda_units.h:44
LEADER_MODE
The kind of the leader line.
@ DIRECT
Unconstrained point-to-point.
@ LAYER_GRID
Definition layer_ids.h:250
@ LAYER_PAGE_LIMITS
Color for drawing the page extents (visibility stored in PCBNEW_SETTINGS::m_ShowPageLimits)
Definition layer_ids.h:334
@ LAYER_NON_PLATEDHOLES
Draw usual through hole vias.
Definition layer_ids.h:235
@ LAYER_DRAWINGSHEET
Sheet frame and title block.
Definition layer_ids.h:274
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition layer_ids.h:277
@ LAYER_CURSOR
PCB cursor.
Definition layer_ids.h:278
@ LAYER_AUX_ITEMS
Auxiliary items (guides, rule, etc).
Definition layer_ids.h:279
@ LAYER_RATSNEST
Definition layer_ids.h:249
@ LAYER_ANCHOR
Anchor of items having an anchor point (texts, footprints).
Definition layer_ids.h:244
@ LAYER_VIA_BURIED
Draw blind vias.
Definition layer_ids.h:231
@ LAYER_VIA_BLIND
Draw micro vias.
Definition layer_ids.h:230
@ LAYER_VIA_MICROVIA
Definition layer_ids.h:229
@ LAYER_VIA_THROUGH
Draw buried vias.
Definition layer_ids.h:232
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ PCB_LAYER_ID_COUNT
Definition layer_ids.h:167
FLIP_DIRECTION
Definition mirror.h:23
@ LEFT_RIGHT
Flip left to right (around the Y axis)
Definition mirror.h:24
KICOMMON_API double FromUserUnit(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnit, double aValue)
Return in internal units the value aValue given in a real unit such as "in", "mm",...
KICOMMON_API wxString StringFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Return the string from aValue according to aUnits (inch, mm ...) for display.
const std::set< wxString > & DefaultKeys()
The subset enabled until the user says otherwise.
const int pcbnewSchemaVersion
! Update the schema version whenever a migration is required
@ DO_NOT_SHOW_CLEARANCE
@ SHOW_WITH_VIA_ALWAYS
@ SHOW_WITH_VIA_WHILE_ROUTING
@ PCB_ORIGIN_PAGE
TRACK_DRAG_ACTION
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
T * GetAppSettings(const char *aFilename)
void AddSnapInferenceParams(std::vector< PARAM_BASE * > &aParams, SNAP_INFERENCE_SETTINGS &aSettings)
Register the snap inference parameters.