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