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