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>
32#include <wx/config.h>
33#include <wx/tokenzr.h>
34#include <base_units.h>
35
37
38
40const int pcbnewSchemaVersion = 5;
41
42
49 m_Display(),
52 m_CtrlClickHighlight( false ),
56 m_PolarCoords( false ),
58 m_ShowPageLimits( true ),
60 m_AutoRefillZones( false ),
61 m_AllowFreePads( false ),
63 m_PnsSettings( nullptr ),
66{
69 m_MagneticItems.graphics = false;
70 m_MagneticItems.allLayers = false;
71
72 m_params.emplace_back( new PARAM<bool>( "aui.show_layer_manager",
73 &m_AuiPanels.show_layer_manager, true ) );
74
75 m_params.emplace_back( new PARAM<int>( "aui.right_panel_width",
76 &m_AuiPanels.right_panel_width, -1 ) );
77
78 m_params.emplace_back( new PARAM<int>( "aui.net_inspector_width",
79 &m_AuiPanels.net_inspector_width, -1 ) );
80
81 m_params.emplace_back( new PARAM<int>( "aui.properties_panel_width",
82 &m_AuiPanels.properties_panel_width, -1 ) );
83
84 m_params.emplace_back( new PARAM<float>( "aui.properties_splitter_proportion",
85 &m_AuiPanels.properties_splitter, 0.5f ) );
86
87 m_params.emplace_back( new PARAM<int>( "aui.search_panel_height",
88 &m_AuiPanels.search_panel_height, -1 ) );
89
90 m_params.emplace_back( new PARAM<int>( "aui.search_panel_width",
91 &m_AuiPanels.search_panel_width, -1 ) );
92
93 m_params.emplace_back( new PARAM<int>( "aui.search_panel_dock_direction",
94 &m_AuiPanels.search_panel_dock_direction, 3 ) );
95
96 m_params.emplace_back( new PARAM<int>( "aui.appearance_panel_tab",
97 &m_AuiPanels.appearance_panel_tab, 0, 0, 2 ) );
98
99 m_params.emplace_back( new PARAM<bool>( "aui.appearance_expand_layer_display",
100 &m_AuiPanels.appearance_expand_layer_display, false ) );
101
102 m_params.emplace_back( new PARAM<bool>( "aui.appearance_expand_net_display",
103 &m_AuiPanels.appearance_expand_net_display, false ) );
104
105 m_params.emplace_back( new PARAM<bool>( "aui.show_properties",
106 &m_AuiPanels.show_properties, true ) );
107
108 m_params.emplace_back( new PARAM<bool>( "aui.show_search",
109 &m_AuiPanels.show_search, false ) );
110
111 m_params.emplace_back( new PARAM<bool>( "aui.show_net_inspector",
112 &m_AuiPanels.show_net_inspector, false ) );
113
114 m_params.emplace_back( new PARAM<bool>( "aui.design_blocks_show", &m_AuiPanels.design_blocks_show, false ) );
115
116 m_params.emplace_back( new PARAM<int>( "aui.design_blocks_panel_docked_width",
117 &m_AuiPanels.design_blocks_panel_docked_width, -1 ) );
118
119 m_params.emplace_back(
120 new PARAM<int>( "aui.design_blocks_panel_float_width", &m_AuiPanels.design_blocks_panel_float_width, -1 ) );
121
122 m_params.emplace_back( new PARAM<int>( "aui.design_blocks_panel_float_height",
123 &m_AuiPanels.design_blocks_panel_float_height, -1 ) );
124
125 m_params.emplace_back( new PARAM<int>( "footprint_chooser.width",
126 &m_FootprintChooser.width, -1 ) );
127
128 m_params.emplace_back( new PARAM<int>( "footprint_chooser.height",
129 &m_FootprintChooser.height, -1 ) );
130
131 m_params.emplace_back( new PARAM<int>( "footprint_chooser.sash_h",
132 &m_FootprintChooser.sash_h, -1 ) );
133
134 m_params.emplace_back( new PARAM<int>( "footprint_chooser.sash_v",
135 &m_FootprintChooser.sash_v, -1 ) );
136
137 m_params.emplace_back( new PARAM<int>( "footprint_chooser.sort_mode",
138 &m_FootprintChooser.sort_mode, 0 ) );
139
140 m_params.emplace_back( new PARAM<bool>( "footprint_chooser.filter_on_pin_count",
141 &m_FootprintChooser.filter_on_pin_count, false ) );
142
143 m_params.emplace_back( new PARAM<bool>( "footprint_chooser.use_fp_filters",
144 &m_FootprintChooser.use_fp_filters, false ) );
145
146 m_params.emplace_back( new PARAM<bool>( "editing.flip_left_right",
147 reinterpret_cast<bool*>( &m_FlipDirection ),
148 static_cast<bool>( FLIP_DIRECTION::LEFT_RIGHT ) ) );
149
150 m_params.emplace_back( new PARAM<bool>( "editing.esc_clears_net_highlight",
151 &m_ESCClearsNetHighlight, true ) );
152
153 m_params.emplace_back( new PARAM<bool>( "editing.show_courtyard_collisions",
154 &m_ShowCourtyardCollisions, true ) );
155
156 m_params.emplace_back( new PARAM<bool>( "editing.magnetic_graphics",
157 &m_MagneticItems.graphics, true ) );
158
159 m_params.emplace_back( new PARAM<int>( "editing.magnetic_pads",
160 reinterpret_cast<int*>( &m_MagneticItems.pads ),
162
163 m_params.emplace_back( new PARAM<int>( "editing.magnetic_tracks",
164 reinterpret_cast<int*>( &m_MagneticItems.tracks ),
166
167 m_params.emplace_back( new PARAM<bool>( "editing.magnetic_all_layers",
168 &m_MagneticItems.allLayers, false ) );
169
170 m_params.emplace_back( new PARAM<bool>( "editing.polar_coords",
171 &m_PolarCoords, false ) );
172
173 m_params.emplace_back( new PARAM<int>( "editing.track_drag_action",
174 reinterpret_cast<int*>( &m_TrackDragAction ),
175 static_cast<int>( TRACK_DRAG_ACTION::DRAG ) ) );
176
177 m_params.emplace_back( new PARAM<int>( "editing.arc_edit_mode",
178 reinterpret_cast<int*>( &m_ArcEditMode ),
180
181 m_params.emplace_back( new PARAM<bool>( "editing.ctrl_click_highlight",
182 &m_CtrlClickHighlight, false ) );
183
184 m_params.emplace_back( new PARAM<int>( "editing.pcb_angle_snap_mode",
185 reinterpret_cast<int*>( &m_AngleSnapMode ),
186 static_cast<int>( LEADER_MODE::DIRECT ) ) );
187
188 m_params.emplace_back( new PARAM<bool>( "editing.auto_fill_zones",
189 &m_AutoRefillZones, false ) );
190
191 m_params.emplace_back( new PARAM<bool>( "editing.allow_free_pads",
192 &m_AllowFreePads, false ) );
193
194 m_params.emplace_back( new PARAM<bool>( "import.keep_kicad_layer_names",
195 &m_ImportKeepKiCadLayerNames, false ) );
196
197 m_params.emplace_back( new PARAM_LAMBDA<int>( "editing.rotation_angle",
198 [this] () -> int
199 {
200 int rot = m_RotationAngle.AsTenthsOfADegree();
201
202 // Don't store values larger than 360 degrees
203 return rot % 3600;
204 },
205 [this] ( int aVal )
206 {
207 if( aVal )
208 m_RotationAngle = EDA_ANGLE( aVal, TENTHS_OF_A_DEGREE_T );
209
210 // A misconfiguration allowed some angles to be stored as tenth of a degree but read
211 // as tens of degrees. By disallowing storage of values larger than 360, we can weed out
212 // those invalid values here.
213 while( m_RotationAngle > ANGLE_360 )
214 m_RotationAngle = m_RotationAngle / 100;
215
216 },
217 900 ) );
218
219 m_params.emplace_back( new PARAM<bool>( "pcb_display.graphic_items_fill",
220 &m_ViewersDisplay.m_DisplayGraphicsFill, true ) );
221
222 m_params.emplace_back( new PARAM<int>( "pcb_display.max_links_shown",
223 &m_Display.m_MaxLinksShowed, 3, 0, 15 ) );
224
225 m_params.emplace_back( new PARAM<bool>( "pcb_display.graphics_fill",
226 &m_ViewersDisplay.m_DisplayGraphicsFill, true ) );
227
228 m_params.emplace_back( new PARAM<bool>( "pcb_display.text_fill",
229 &m_ViewersDisplay.m_DisplayTextFill, true ) );
230
231 m_params.emplace_back( new PARAM<int>( "pcb_display.net_names_mode",
232 &m_Display.m_NetNames, 3, 0, 3 ) );
233
234 m_params.emplace_back( new PARAM<bool>( "pcb_display.pad_clearance",
235 &m_Display.m_PadClearance, true ) );
236
237 m_params.emplace_back( new PARAM<bool>( "pcb_display.pad_use_via_color_for_normal_th_padstacks",
238 &m_Display.m_UseViaColorForNormalTHPadstacks, false ) );
239
240 m_params.emplace_back( new PARAM<bool>( "pcb_display.pad_fill",
241 &m_ViewersDisplay.m_DisplayPadFill, true ) );
242
243 m_params.emplace_back( new PARAM<bool>( "pcb_display.pad_numbers",
244 &m_ViewersDisplay.m_DisplayPadNumbers, true ) );
245
246 m_params.emplace_back( new PARAM<bool>( "pcb_display.ratsnest_global",
247 &m_Display.m_ShowGlobalRatsnest, true ) );
248
249 m_params.emplace_back( new PARAM<bool>( "pcb_display.ratsnest_footprint",
250 &m_Display.m_ShowModuleRatsnest, true ) );
251
252 m_params.emplace_back( new PARAM<bool>( "pcb_display.ratsnest_curved",
253 &m_Display.m_DisplayRatsnestLinesCurved, false ) );
254
255 m_params.emplace_back( new PARAM<double>( "pcb_display.ratsnest_thickness",
256 &m_Display.m_RatsnestThickness, 0.5 ) );
257
258 m_params.emplace_back( new PARAM<int>( "pcb_display.track_clearance_mode",
259 reinterpret_cast<int*>( &m_Display.m_TrackClearance ), SHOW_WITH_VIA_WHILE_ROUTING ) );
260
261 m_params.emplace_back( new PARAM<bool>( "pcb_display.track_fill",
262 &m_Display.m_DisplayPcbTrackFill, true ) );
263
264 m_params.emplace_back( new PARAM<bool>( "pcb_display.via_fill",
265 &m_Display.m_DisplayViaFill, true ) );
266
267 m_params.emplace_back( new PARAM<int>( "pcb_display.origin_mode",
268 reinterpret_cast<int*>( &m_Display.m_DisplayOrigin ),
270
271 m_params.emplace_back( new PARAM<bool>( "pcb_display.origin_invert_x_axis",
272 &m_Display.m_DisplayInvertXAxis, false ) );
273
274 m_params.emplace_back( new PARAM<bool>( "pcb_display.origin_invert_y_axis",
275 &m_Display.m_DisplayInvertYAxis, false ) );
276
277 m_params.emplace_back( new PARAM<bool>( "pcb_display.force_show_fields_when_fp_selected",
278 &m_Display.m_ForceShowFieldsWhenFPSelected, true ) );
279
280 m_params.emplace_back( new PARAM<bool>( "pcb_display.live_3d_refresh",
281 &m_Display.m_Live3DRefresh, false ) );
282
283 m_params.emplace_back( new PARAM<bool>( "pcb_display.show_page_borders",
284 &m_ShowPageLimits, true ) );
285
286 m_params.emplace_back( new PARAM<bool>( "export_d356.doNotExportUnconnectedPads",
287 &m_ExportD356.doNotExportUnconnectedPads, false ) );
288
289 addParamsForWindow( &m_FootprintViewer, "footprint_viewer" );
290
291 m_params.emplace_back( new PARAM<double>( "footprint_viewer.zoom",
292 &m_FootprintViewerZoom, 1.0 ) );
293
294 m_params.emplace_back( new PARAM<bool>( "footprint_viewer.autozoom",
296
297 m_params.emplace_back( new PARAM<int>( "footprint_viewer.lib_list_width",
299
300 m_params.emplace_back( new PARAM<int>( "footprint_viewer.fp_list_width",
302
303 addParamsForWindow( &m_FootprintWizard, "footprint_wizard" );
304
305 m_params.emplace_back( new PARAM<wxString>( "system.last_footprint_lib_dir",
306 &m_LastFootprintLibDir, "" ) );
307
308 m_params.emplace_back( new PARAM<wxString>( "system.last_footprint3d_dir",
309 &m_LastFootprint3dDir, "" ) );
310
311 m_params.emplace_back( new PARAM<bool>( "DRC.report_all_track_errors",
312 &m_DRCDialog.report_all_track_errors, false ) );
313
314 m_params.emplace_back( new PARAM<bool>( "DRC.crossprobe",
315 &m_DRCDialog.crossprobe, true ) );
316
317 m_params.emplace_back( new PARAM<bool>( "DRC.scroll_on_crossprobe",
318 &m_DRCDialog.scroll_on_crossprobe, true ) );
319
320 m_params.emplace_back( new PARAM<COLOR4D>( "diff_phase_skew.zero_color", &m_DiffPhaseSkewSettings.m_ZeroSkewColor,
321 COLOR4D( 1.0, 1.0, 1.0, 1.0 ) ) );
322
323 m_params.emplace_back( new PARAM<COLOR4D>( "diff_phase_skew.positive_color",
324 &m_DiffPhaseSkewSettings.m_PositiveSkewColor,
325 COLOR4D( 0.0, 0.0, 1.0, 1.0 ) ) );
326
327 m_params.emplace_back( new PARAM<COLOR4D>( "diff_phase_skew.negative_color",
328 &m_DiffPhaseSkewSettings.m_NegativeSkewColor,
329 COLOR4D( 1.0, 0.0, 0.0, 1.0 ) ) );
330
331 m_params.emplace_back( new PARAM<COLOR4D>( "diff_phase_skew.unknown_color",
332 &m_DiffPhaseSkewSettings.m_UnknownSkewColor,
333 COLOR4D( 0.5, 0.5, 0.5, 1.0 ) ) );
334
335 registerMigration( 0, 1,
336 [&]()
337 {
338 if( std::optional<int> optval = Get<int>( "pcb_display.rotation_angle" ) )
339 Set( "editing.rotation_angle", *optval );
340
341 try
342 {
343 At( "pcb_display" ).erase( "rotation_angle" );
344 }
345 catch( ... )
346 {}
347
348 return true;
349 } );
350
351 registerMigration( 1, 2,
352 [&]()
353 {
354 // In version 1 this meant "after Zone Properties dialog", but it now means
355 // "everywhere" so we knock it off on transition.
356 Set( "editing.auto_fill_zones", false );
357
358 return true;
359 } );
360
361
362 registerMigration( 2, 3,
363 [&]() -> bool
364 {
365 // We used to have a bug on GTK which would set the lib tree column width way
366 // too narrow.
367 if( std::optional<int> optval = Get<int>( "lib_tree.column_width" ) )
368 {
369 if( optval < 150 )
370 Set( "lib_tree.column_width", 300 );
371 }
372
373 return true;
374 } );
375
376 registerMigration( 3, 4,
377 [&]() -> bool
378 {
379 // This is actually a migration for APP_SETTINGS_BASE::m_LibTree
380 return migrateLibTreeWidth();
381 } );
382
383 registerMigration( 4, 5,
384 [&]() -> bool
385 {
386 // This default proved to be unpopular; bump it off for everyone
387 Set( "editing.auto_fill_zones", false );
388 return true;
389 } );
390}
391
392
394
395
396bool PCBNEW_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
397{
398 bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
399
400 const std::string f = getLegacyFrameName();
401
402 //
403 // NOTE: there's no value in line-wrapping these; it just makes the table unreadable.
404 //
405 ret &= fromLegacy<bool>( aCfg, "ShowLayerManagerTools", "aui.show_layer_manager" );
406
407 ret &= fromLegacy<int>( aCfg, "FootprintChooserHSashPosition", "footprint_chooser.sash_h" );
408 ret &= fromLegacy<int>( aCfg, "FootprintChooserVSashPosition", "footprint_chooser.sash_v" );
409 ret &= fromLegacy<int>( aCfg, "FootprintChooserWidth", "footprint_chooser.width" );
410 ret &= fromLegacy<int>( aCfg, "FootprintChooserHeight", "footprint_chooser.height" );
411
412 ret &= fromLegacy<bool>( aCfg, "FlipLeftRight", "editing.flip_left_right" );
413 ret &= fromLegacy<bool>( aCfg, "MagneticGraphics", "editing.magnetic_graphics" );
414 ret &= fromLegacy<int>( aCfg, "MagneticPads", "editing.magnetic_pads" );
415 ret &= fromLegacy<int>( aCfg, "MagneticTracks", "editing.magnetic_tracks" );
416 ret &= fromLegacy<bool>( aCfg, "DisplayPolarCoords", "editing.polar_coords" );
417 ret &= fromLegacy<bool>( aCfg, "Use45DegreeGraphicSegments", "editing.use_45_degree_graphic_segments" );
418
419 ret &= fromLegacy<bool>( aCfg, "PcbAffT", "pcb_display.graphic_items_fill" );
420 ret &= fromLegacy<int>( aCfg, "MaxLnkS", "pcb_display.max_links_shown" );
421 ret &= fromLegacy<bool>( aCfg, "ModAffC", "pcb_display.footprint_edge_fill" );
422 ret &= fromLegacy<bool>( aCfg, "ModAffT", "pcb_display.footprint_text_fill" );
423 ret &= fromLegacy<int>( aCfg, "ShowNetNamesMode", "pcb_display.net_names_mode" );
424 ret &= fromLegacy<int>( aCfg, "PcbDisplayOrigin", "pcb_display.origin_mode" );
425 ret &= fromLegacy<bool>( aCfg, "PcbInvertXAxis", "pcb_display.origin_invert_x_axis" );
426 ret &= fromLegacy<bool>( aCfg, "PcbInvertYAxis", "pcb_display.origin_invert_y_axis" );
427 ret &= fromLegacy<bool>( aCfg, "PadAffG", "pcb_display.pad_clearance" );
428 ret &= fromLegacy<bool>( aCfg, "PadFill", "pcb_display.pad_fill" );
429 ret &= fromLegacy<bool>( aCfg, "PadSNum", "pcb_display.pad_numbers" );
430 ret &= fromLegacy<bool>( aCfg, "ShowRatsnestLines", "pcb_display.ratsnest_global" );
431 ret &= fromLegacy<bool>( aCfg, "ShowRatsnestModuleLines", "pcb_display.ratsnest_footprint" );
432 ret &= fromLegacy<bool>( aCfg, "CurvedRatsnestLines", "pcb_display.ratsnest_curved" );
433 ret &= fromLegacy<int>( aCfg, "RotationAngle", "pcb_display.rotation_angle" );
434 ret &= fromLegacy<int>( aCfg, "TrackDisplayClearance", "pcb_display.track_clearance_mode" );
435 ret &= fromLegacy<bool>( aCfg, "DisplayTrackFilled", "pcb_display.track_fill" );
436 ret &= fromLegacy<bool>( aCfg, "ViaFill", "pcb_display.via_fill" );
437 ret &= fromLegacy<int>( aCfg, "PcbShowZonesMode", "pcb_display.zone_mode" );
438
439 ret &= fromLegacy<double>( aCfg, "PlotLineWidth_mm", "plot.line_width" );
440
441 {
442 nlohmann::json js = nlohmann::json::array();
443 wxString key;
444 bool val = false;
445
446 for( unsigned i = 0; i < PCB_LAYER_ID_COUNT; ++i )
447 {
448 key.Printf( wxT( "PlotSVGLayer_%d" ), i );
449
450 if( aCfg->Read( key, &val ) && val )
451 js.push_back( i );
452 }
453
454 Set( "export_svg.layers", js );
455 }
456
457 {
458 nlohmann::json js = nlohmann::json::array();
459
460 wxString packed;
461
462 if( aCfg->Read( "ActionPluginButtons", &packed ) )
463 {
464 wxStringTokenizer pluginSettingsTokenizer = wxStringTokenizer( packed, ";" );
465
466 while( pluginSettingsTokenizer.HasMoreTokens() )
467 {
468 nlohmann::json row;
469 wxString plugin = pluginSettingsTokenizer.GetNextToken();
470 wxStringTokenizer pluginTokenizer = wxStringTokenizer( plugin, "=" );
471
472 if( pluginTokenizer.CountTokens() != 2 )
473 {
474 // Bad config
475 continue;
476 }
477
478 std::string key( pluginTokenizer.GetNextToken().ToUTF8() );
479 bool value( pluginTokenizer.GetNextToken().Cmp( wxT( "Visible" ) ) == 0 );
480
481 js.push_back( nlohmann::json( { { key, value } } ) );
482 }
483 }
484
485 Set( "action_plugins", js );
486 }
487
488 //
489 // NOTE: there's no value in line-wrapping these; it just makes the table unreadable.
490 //
491 ret &= fromLegacy<int>( aCfg, "Zone_Ouline_Hatch_Opt", "zones.hatching_style" );
492 ret &= fromLegacy<int>( aCfg, "Zone_NetSort_Opt", "zones.net_sort_mode" );
493 ret &= fromLegacy<double>( aCfg, "Zone_Clearance", "zones.clearance" );
494 ret &= fromLegacy<double>( aCfg, "Zone_Thickness", "zones.min_thickness" );
495 ret &= fromLegacy<double>( aCfg, "Zone_TH_Gap", "zones.thermal_relief_gap" );
496 ret &= fromLegacy<double>( aCfg, "Zone_TH_Copper_Width", "zones.thermal_relief_copper_width" );
497
498 ret &= fromLegacy<int>( aCfg, "PrintSinglePage", "plot.all_layers_on_one_page" );
499 ret &= fromLegacy<int>( aCfg, "PrintPadsDrillOpt", "plot.pads_drill_mode" );
500 ret &= fromLegacy<double>( aCfg, "PlotXFineScaleAdj", "plot.fine_scale_x" );
501 ret &= fromLegacy<double>( aCfg, "PlotYFineScaleAdj", "plot.fine_scale_y" );
502 ret &= fromLegacy<double>( aCfg, "PSPlotFineWidthAdj", "plot.ps_fine_width_adjust" );
503 ret &= fromLegacy<bool>( aCfg, "CheckZonesBeforePlotting", "plot.check_zones_before_plotting" );
504
505 ret &= fromLegacy<int>( aCfg, "FpWizardListWidth", "footprint_wizard_list.width" );
506 ret &= fromLegacy<int>( aCfg, "FpWizardListHeight", "footprint_wizard_list.height" );
507
508 migrateWindowConfig( aCfg, "ModViewFrame", "footprint_viewer" );
509
510 ret &= fromLegacy<bool>( aCfg, "ModViewFrameAutoZoom", "footprint_viewer.auto_zoom" );
511 ret &= fromLegacy<double>( aCfg, "ModViewFrameZoom", "footprint_viewer.zoom" );
512
513 migrateWindowConfig( aCfg, "FootprintWizard", "footprint_wizard" );
514 ret &= fromLegacyString( aCfg, "Fpwizard_auiPerspective", "footprint_wizard.perspective" );
515
516
517 const std::string p = "pcbnew.InteractiveRouter.";
518
519 Set( "tools.pns.meta", nlohmann::json( {
520 { "filename", "pns" },
521 { "version", 0 }
522 } ) );
523
524 ret &= fromLegacy<int>( aCfg, p + "Mode", "tools.pns.mode" );
525 ret &= fromLegacy<int>( aCfg, p + "OptimizerEffort", "tools.pns.effort" );
526 ret &= fromLegacy<bool>( aCfg, p + "RemoveLoops", "tools.pns.remove_loops" );
527 ret &= fromLegacy<bool>( aCfg, p + "SmartPads", "tools.pns.smart_pads" );
528 ret &= fromLegacy<bool>( aCfg, p + "ShoveVias", "tools.pns.shove_vias" );
529 ret &= fromLegacy<bool>( aCfg, p + "StartDiagonal", "tools.pns.start_diagonal" );
530 ret &= fromLegacy<int>( aCfg, p + "ShoveTimeLimit", "tools.pns.shove_time_limit" );
531 ret &= fromLegacy<int>( aCfg, p + "ShoveIterationLimit", "tools.pns.shove_iteration_limit" );
532 ret &= fromLegacy<int>( aCfg, p + "WalkaroundIterationLimit", "tools.pns.walkaround_iteration_limit" );
533 ret &= fromLegacy<bool>( aCfg, p + "JumpOverObstacles", "tools.pns.jump_over_obstacles" );
534 ret &= fromLegacy<bool>( aCfg, p + "SmoothDraggedSegments", "tools.pns.smooth_dragged_segments" );
535 ret &= fromLegacy<bool>( aCfg, p + "CanViolateDRC", "tools.pns.can_violate_drc" );
536 ret &= fromLegacy<bool>( aCfg, p + "SuggestFinish", "tools.pns.suggest_finish" );
537 ret &= fromLegacy<bool>( aCfg, p + "FreeAngleMode", "tools.pns.free_angle_mode" );
538 ret &= fromLegacy<bool>( aCfg, p + "InlineDragEnabled", "editing.track_drag_action" );
539
540 // Initialize some new PNS settings to legacy behaviors if coming from legacy
541 Set( "tools.pns.fix_all_segments", false );
542
543 // Migrate color settings that were stored in the pcbnew config file
544
547
548 auto migrateLegacyColor =
549 [&] ( const std::string& aKey, int aLayerId )
550 {
551 wxString str;
552
553 if( aCfg->Read( aKey, &str ) )
554 cs->SetColor( aLayerId, COLOR4D( str ) );
555 };
556
557 for( int i = 0; i < PCB_LAYER_ID_COUNT; ++i )
558 {
559 wxString layer = LSET::Name( PCB_LAYER_ID( i ) );
560 migrateLegacyColor( "Color4DPCBLayer_" + layer.ToStdString(), PCB_LAYER_ID( i ) );
561 }
562
563 migrateLegacyColor( "Color4DAnchorEx", LAYER_ANCHOR );
564 migrateLegacyColor( "Color4DAuxItems", LAYER_AUX_ITEMS );
565 migrateLegacyColor( "Color4DGrid", LAYER_GRID );
566 migrateLegacyColor( "Color4DNonPlatedEx", LAYER_NON_PLATEDHOLES );
567 migrateLegacyColor( "Color4DPCBBackground", LAYER_PCB_BACKGROUND );
568 migrateLegacyColor( "Color4DPCBCursor", LAYER_CURSOR );
569 migrateLegacyColor( "Color4DRatsEx", LAYER_RATSNEST );
570 migrateLegacyColor( "Color4DViaBBlindEx", LAYER_VIA_BLIND );
571 migrateLegacyColor( "Color4DViaBBlindEx", LAYER_VIA_BURIED );
572 migrateLegacyColor( "Color4DViaMicroEx", LAYER_VIA_MICROVIA );
573 migrateLegacyColor( "Color4DViaThruEx", LAYER_VIA_THROUGH );
574 migrateLegacyColor( "Color4DWorksheet", LAYER_DRAWINGSHEET );
575 migrateLegacyColor( "Color4DGrid", LAYER_PAGE_LIMITS );
576
577 mgr.SaveColorSettings( cs, "board" );
578
579 Set( "appearance.color_theme", cs->GetFilename() );
580
581 double x = 0, y = 0;
582
583 if( aCfg->Read( f + "PcbUserGrid_X", &x ) && aCfg->Read( f + "PcbUserGrid_Y", &y ) )
584 {
585 EDA_UNITS u = static_cast<EDA_UNITS>( aCfg->ReadLong( f + "PcbUserGrid_Unit",
586 static_cast<long>( EDA_UNITS::INCH ) ) );
587
588 // Convert to internal units
591
592 Set( "window.grid.user_grid_x", EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, u, x ) );
593 Set( "window.grid.user_grid_y", EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, u, y ) );
594 }
595
596 // Footprint editor settings were stored in pcbnew config file. Migrate them here.
598 fpedit->MigrateFromLegacy( aCfg );
599 fpedit->Load();
600
601 // Same with 3D viewer
603 viewer3d->MigrateFromLegacy( aCfg );
604 viewer3d->Load();
605
606 return ret;
607}
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:121
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)
virtual 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
Like a normal param, but with custom getter and setter functions.
Definition parameters.h:297
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
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
std::unique_ptr< PNS::ROUTING_SETTINGS > m_PnsSettings
bool m_FootprintViewerAutoZoomOnSelect
true to use automatic zoom on fp selection
PCB_VIEWERS_SETTINGS_BASE(const std::string &aFilename, int aSchemaVersion)
VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay
double m_FootprintViewerZoom
The last zoom level used (0 for auto)
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,...
The common library.
static constexpr EDA_ANGLE ANGLE_90
Definition eda_angle.h:413
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:325
@ 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 int pcbnewSchemaVersion
! Update the schema version whenever a migration is required
@ 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)