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