24#include <pybind11/pybind11.h>
39#include <wx/tokenzr.h>
105 &
m_AuiPanels.appearance_expand_layer_display,
false ) );
108 &
m_AuiPanels.appearance_expand_net_display,
false ) );
122 &
m_AuiPanels.design_blocks_panel_docked_width, -1 ) );
125 new PARAM<int>(
"aui.design_blocks_panel_float_width", &
m_AuiPanels.design_blocks_panel_float_width, -1 ) );
128 &
m_AuiPanels.design_blocks_panel_float_height, -1 ) );
202 int rot = m_RotationAngle.AsTenthsOfADegree();
210 m_RotationAngle = EDA_ANGLE( aVal, TENTHS_OF_A_DEGREE_T );
215 while( m_RotationAngle > ANGLE_360 )
216 m_RotationAngle = m_RotationAngle / 100;
225 &
m_Display.m_MaxLinksShowed, 3, 0, 15 ) );
239 m_params.emplace_back(
new PARAM<bool>(
"pcb_display.pad_use_via_color_for_normal_th_padstacks",
240 &
m_Display.m_UseViaColorForNormalTHPadstacks,
false ) );
249 &
m_Display.m_ShowGlobalRatsnest,
true ) );
252 &
m_Display.m_ShowModuleRatsnest,
true ) );
255 &
m_Display.m_DisplayRatsnestLinesCurved,
false ) );
264 &
m_Display.m_DisplayPcbTrackFill,
true ) );
270 reinterpret_cast<int*
>( &
m_Display.m_DisplayOrigin ),
274 &
m_Display.m_DisplayInvertXAxis,
false ) );
277 &
m_Display.m_DisplayInvertYAxis,
false ) );
280 &
m_Display.m_ForceShowFieldsWhenFPSelected,
true ) );
292 [&]() -> nlohmann::json
294 nlohmann::json js = nlohmann::json::array();
296 for( const auto& pair : m_VisibleActionPlugins )
297 js.push_back( nlohmann::json( { { pair.first.ToUTF8(), pair.second } } ) );
301 [&](
const nlohmann::json& aObj )
303 m_VisibleActionPlugins.clear();
305 if( !aObj.is_array() )
310 for(
const auto& entry : aObj )
312 if( entry.empty() || !entry.is_object() )
315 for(
const auto& pair : entry.items() )
317 m_VisibleActionPlugins.emplace_back( std::make_pair(
318 wxString( pair.key().c_str(), wxConvUTF8 ), pair.value() ) );
322 nlohmann::json::array() ) );
324 addParamsForWindow( &m_FootprintViewer,
"footprint_viewer" );
326 m_params.emplace_back(
new PARAM<double>(
"footprint_viewer.zoom",
327 &m_FootprintViewerZoom, 1.0 ) );
329 m_params.emplace_back(
new PARAM<bool>(
"footprint_viewer.autozoom",
330 &m_FootprintViewerAutoZoomOnSelect,
true ) );
332 m_params.emplace_back(
new PARAM<int>(
"footprint_viewer.lib_list_width",
333 &m_FootprintViewerLibListWidth, 200 ) );
335 m_params.emplace_back(
new PARAM<int>(
"footprint_viewer.fp_list_width",
336 &m_FootprintViewerFPListWidth, 300 ) );
338 addParamsForWindow( &m_FootprintWizard,
"footprint_wizard" );
340 m_params.emplace_back(
new PARAM<wxString>(
"system.last_footprint_lib_dir",
341 &m_LastFootprintLibDir,
"" ) );
343 m_params.emplace_back(
new PARAM<wxString>(
"system.last_footprint3d_dir",
344 &m_LastFootprint3dDir,
"" ) );
346 m_params.emplace_back(
new PARAM<bool>(
"DRC.report_all_track_errors",
347 &m_DRCDialog.report_all_track_errors,
false ) );
349 m_params.emplace_back(
new PARAM<bool>(
"DRC.crossprobe",
350 &m_DRCDialog.crossprobe,
true ) );
352 m_params.emplace_back(
new PARAM<bool>(
"DRC.scroll_on_crossprobe",
353 &m_DRCDialog.scroll_on_crossprobe,
true ) );
355 registerMigration( 0, 1,
358 if( std::optional<int> optval = Get<int>(
"pcb_display.rotation_angle" ) )
359 Set(
"editing.rotation_angle", *optval );
363 At(
"pcb_display" ).erase(
"rotation_angle" );
371 registerMigration( 1, 2,
376 Set(
"editing.auto_fill_zones",
false );
382 registerMigration( 2, 3,
387 if( std::optional<int> optval = Get<int>(
"lib_tree.column_width" ) )
390 Set(
"lib_tree.column_width", 300 );
396 registerMigration( 3, 4,
400 return migrateLibTreeWidth();
403 registerMigration( 4, 5,
407 Set(
"editing.auto_fill_zones",
false );
425 ret &=
fromLegacy<bool>( aCfg,
"ShowLayerManagerTools",
"aui.show_layer_manager" );
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" );
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" );
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" );
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" );
457 ret &=
fromLegacy<int>( aCfg,
"PcbShowZonesMode",
"pcb_display.zone_mode" );
462 nlohmann::json js = nlohmann::json::array();
468 key.Printf( wxT(
"PlotSVGLayer_%d" ), i );
470 if( aCfg->Read( key, &val ) && val )
474 Set(
"export_svg.layers", js );
478 nlohmann::json js = nlohmann::json::array();
482 if( aCfg->Read(
"ActionPluginButtons", &packed ) )
484 wxStringTokenizer pluginSettingsTokenizer = wxStringTokenizer( packed,
";" );
486 while( pluginSettingsTokenizer.HasMoreTokens() )
489 wxString plugin = pluginSettingsTokenizer.GetNextToken();
490 wxStringTokenizer pluginTokenizer = wxStringTokenizer( plugin,
"=" );
492 if( pluginTokenizer.CountTokens() != 2 )
498 std::string key( pluginTokenizer.GetNextToken().ToUTF8() );
499 bool value( pluginTokenizer.GetNextToken().Cmp( wxT(
"Visible" ) ) == 0 );
501 js.push_back( nlohmann::json( { { key, value } } ) );
505 Set(
"action_plugins", js );
511 ret &=
fromLegacy<int>( aCfg,
"Zone_Ouline_Hatch_Opt",
"zones.hatching_style" );
512 ret &=
fromLegacy<int>( aCfg,
"Zone_NetSort_Opt",
"zones.net_sort_mode" );
516 ret &=
fromLegacy<double>( aCfg,
"Zone_TH_Copper_Width",
"zones.thermal_relief_copper_width" );
518 ret &=
fromLegacy<int>( aCfg,
"PrintSinglePage",
"plot.all_layers_on_one_page" );
519 ret &=
fromLegacy<int>( aCfg,
"PrintPadsDrillOpt",
"plot.pads_drill_mode" );
523 ret &=
fromLegacy<bool>( aCfg,
"CheckZonesBeforePlotting",
"plot.check_zones_before_plotting" );
525 ret &=
fromLegacy<int>( aCfg,
"FpWizardListWidth",
"footprint_wizard_list.width" );
526 ret &=
fromLegacy<int>( aCfg,
"FpWizardListHeight",
"footprint_wizard_list.height" );
530 ret &=
fromLegacy<bool>( aCfg,
"ModViewFrameAutoZoom",
"footprint_viewer.auto_zoom" );
534 ret &=
fromLegacyString( aCfg,
"Fpwizard_auiPerspective",
"footprint_wizard.perspective" );
537 const std::string p =
"pcbnew.InteractiveRouter.";
539 Set(
"tools.pns.meta", nlohmann::json( {
540 {
"filename",
"pns" },
545 ret &=
fromLegacy<int>( aCfg, p +
"OptimizerEffort",
"tools.pns.effort" );
546 ret &=
fromLegacy<bool>( aCfg, p +
"RemoveLoops",
"tools.pns.remove_loops" );
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" );
561 Set(
"tools.pns.fix_all_segments",
false );
568 auto migrateLegacyColor =
569 [&] (
const std::string& aKey,
int aLayerId )
573 if( aCfg->Read( aKey, &str ) )
580 migrateLegacyColor(
"Color4DPCBLayer_" + layer.ToStdString(),
PCB_LAYER_ID( i ) );
585 migrateLegacyColor(
"Color4DGrid",
LAYER_GRID );
603 if( aCfg->Read( f +
"PcbUserGrid_X", &x ) && aCfg->Read( f +
"PcbUserGrid_Y", &y ) )
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
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.
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.
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Like a normal param, but with custom getter and setter functions.
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()
bool m_CtrlClickHighlight
TRACK_DRAG_ACTION m_TrackDragAction
bool m_ESCClearsNetHighlight
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
WINDOW_SETTINGS m_FootprintViewer
bool m_ShowCourtyardCollisions
MAGNETIC_SETTINGS m_MagneticItems
FLIP_DIRECTION m_FlipDirection
int m_FootprintViewerFPListWidth
std::unique_ptr< PNS::ROUTING_SETTINGS > m_PnsSettings
int m_FootprintViewerLibListWidth
PCB_VIEWERS_SETTINGS_BASE(const std::string &aFilename, int aSchemaVersion)
VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay
virtual SETTINGS_MANAGER & GetSettingsManager() const
void SaveColorSettings(COLOR_SETTINGS *aSettings, const std::string &aNamespace="")
Safely save a COLOR_SETTINGS to disk, preserving any changes outside the given namespace.
COLOR_SETTINGS * GetMigratedColorSettings()
Return a color theme for storing colors migrated from legacy (5.x and earlier) settings,...
static constexpr EDA_ANGLE ANGLE_90
LEADER_MODE
The kind of the leader line.
@ DIRECT
Unconstrained point-to-point.
@ LAYER_PAGE_LIMITS
Color for drawing the page extents (visibility stored in PCBNEW_SETTINGS::m_ShowPageLimits)
@ LAYER_NON_PLATEDHOLES
Draw usual through hole vias.
@ LAYER_DRAWINGSHEET
Sheet frame and title block.
@ LAYER_PCB_BACKGROUND
PCB background color.
@ LAYER_CURSOR
PCB cursor.
@ LAYER_AUX_ITEMS
Auxiliary items (guides, rule, etc).
@ LAYER_ANCHOR
Anchor of items having an anchor point (texts, footprints).
@ LAYER_VIA_BURIED
Draw blind vias.
@ LAYER_VIA_BLIND
Draw micro vias.
@ LAYER_VIA_THROUGH
Draw buried vias.
PCB_LAYER_ID
A quick note on layer IDs:
@ LEFT_RIGHT
Flip left to right (around the Y axis)
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
@ CAPTURE_CURSOR_IN_TRACK_TOOL
@ SHOW_WITH_VIA_WHILE_ROUTING
PGM_BASE & Pgm()
The global program "get" accessor.
T * GetAppSettings(const char *aFilename)