24 #include <pybind11/pybind11.h> 36 #include <wx/config.h> 37 #include <wx/tokenzr.h> 42 #include "../3d-viewer/3d_viewer/eda_3d_viewer_settings.h" 58 m_FootprintWizardList(),
70 m_PcbUse45DegreeLimit( false ),
71 m_FpeditUse45DegreeLimit( false ),
72 m_FlipLeftRight( false ),
73 m_PolarCoords( false ),
74 m_RotationAngle( 900 ),
75 m_ShowPageLimits( true ),
76 m_AutoRefillZones( true ),
77 m_AllowFreePads( false ),
78 m_PnsSettings( nullptr ),
79 m_FootprintViewerZoom( 1.0 )
482 js.push_back(
nlohmann::json( { { pair.first.ToUTF8(), pair.second } } ) );
490 if( !aObj.is_array() )
495 for(
const auto& entry : aObj )
497 if( entry.empty() || !entry.is_object() )
500 for(
const auto& pair : entry.items() )
503 wxString( pair.key().c_str(), wxConvUTF8 ), pair.value() ) );
507 nlohmann::json::array() ) );
525 if(
OPT<int> optval = Get<int>(
"pcb_display.rotation_angle" ) )
526 Set(
"editing.rotation_angle", optval.get() );
530 At(
"pcb_display" ).erase(
"rotation_angle" );
553 ret &= fromLegacy<bool>( aCfg,
"ShowLayerManagerTools",
"aui.show_layer_manager" );
555 ret &= fromLegacy<int>( aCfg,
"FootprintChooserHSashPosition",
"footprint_chooser.sash_h" );
556 ret &= fromLegacy<int>( aCfg,
"FootprintChooserVSashPosition",
"footprint_chooser.sash_v" );
557 ret &= fromLegacy<int>( aCfg,
"FootprintChooserWidth",
"footprint_chooser.width" );
558 ret &= fromLegacy<int>( aCfg,
"FootprintChooserHeight",
"footprint_chooser.height" );
560 ret &= fromLegacy<bool>( aCfg,
"FlipLeftRight",
"editing.flip_left_right" );
561 ret &= fromLegacy<bool>( aCfg,
"MagneticGraphics",
"editing.magnetic_graphics" );
562 ret &= fromLegacy<int>( aCfg,
"MagneticPads",
"editing.magnetic_pads" );
563 ret &= fromLegacy<int>( aCfg,
"MagneticTracks",
"editing.magnetic_tracks" );
564 ret &= fromLegacy<bool>( aCfg,
"DisplayPolarCoords",
"editing.polar_coords" );
565 ret &= fromLegacy<bool>( aCfg,
"Use45DegreeGraphicSegments",
"editing.use_45_degree_graphic_segments" );
567 ret &= fromLegacy<bool>( aCfg,
"PcbAffT",
"pcb_display.graphic_items_fill" );
568 ret &= fromLegacy<int>( aCfg,
"MaxLnkS",
"pcb_display.max_links_shown" );
569 ret &= fromLegacy<bool>( aCfg,
"ModAffC",
"pcb_display.footprint_edge_fill" );
570 ret &= fromLegacy<bool>( aCfg,
"ModAffT",
"pcb_display.footprint_text_fill" );
571 ret &= fromLegacy<int>( aCfg,
"ShowNetNamesMode",
"pcb_display.net_names_mode" );
572 ret &= fromLegacy<int>( aCfg,
"PcbDisplayOrigin",
"pcb_display.origin_mode" );
573 ret &= fromLegacy<bool>( aCfg,
"PcbInvertXAxis",
"pcb_display.origin_invert_x_axis" );
574 ret &= fromLegacy<bool>( aCfg,
"PcbInvertYAxis",
"pcb_display.origin_invert_y_axis" );
575 ret &= fromLegacy<bool>( aCfg,
"PadAffG",
"pcb_display.pad_clearance" );
576 ret &= fromLegacy<bool>( aCfg,
"PadFill",
"pcb_display.pad_fill" );
577 ret &= fromLegacy<bool>( aCfg,
"PadSNum",
"pcb_display.pad_numbers" );
578 ret &= fromLegacy<bool>( aCfg,
"ShowRatsnestLines",
"pcb_display.ratsnest_global" );
579 ret &= fromLegacy<bool>( aCfg,
"ShowRatsnestModuleLines",
"pcb_display.ratsnest_footprint" );
580 ret &= fromLegacy<bool>( aCfg,
"CurvedRatsnestLines",
"pcb_display.ratsnest_curved" );
581 ret &= fromLegacy<int>( aCfg,
"RotationAngle",
"pcb_display.rotation_angle" );
582 ret &= fromLegacy<int>( aCfg,
"TrackDisplayClearance",
"pcb_display.track_clearance_mode" );
583 ret &= fromLegacy<bool>( aCfg,
"DisplayTrackFilled",
"pcb_display.track_fill" );
584 ret &= fromLegacy<bool>( aCfg,
"ViaFill",
"pcb_display.via_fill" );
585 ret &= fromLegacy<int>( aCfg,
"PcbShowZonesMode",
"pcb_display.zone_mode" );
587 ret &= fromLegacy<double>( aCfg,
"PlotLineWidth_mm",
"plot.line_width" );
589 aCfg->SetPath(
"/dialogs/cleanup_tracks" );
590 ret &= fromLegacy<bool>( aCfg,
"DialogCleanupVias",
"cleanup.cleanup_vias" );
591 ret &= fromLegacy<bool>( aCfg,
"DialogCleanupMergeSegments",
"cleanup.merge_segments" );
592 ret &= fromLegacy<bool>( aCfg,
"DialogCleanupUnconnected",
"cleanup.cleanup_unconnected" );
593 ret &= fromLegacy<bool>( aCfg,
"DialogCleanupShortCircuit",
"cleanup.cleanup_short_circuits" );
594 ret &= fromLegacy<bool>( aCfg,
"DialogCleanupTracksInPads",
"cleanup.cleanup_tracks_in_pad" );
595 aCfg->SetPath(
"../.." );
597 ret &= fromLegacy<bool>( aCfg,
"RefillZonesBeforeDrc",
"drc_dialog.refill_zones" );
598 ret &= fromLegacy<bool>( aCfg,
"DrcTestFootprints",
"drc_dialog.test_footprints" );
600 ret &= fromLegacy<bool>( aCfg,
"DrillMergePTHNPTH",
"gen_drill.merge_pth_npth" );
601 ret &= fromLegacy<bool>( aCfg,
"DrillMinHeader",
"gen_drill.minimal_header" );
602 ret &= fromLegacy<bool>( aCfg,
"DrillMirrorYOpt",
"gen_drill.mirror" );
603 ret &= fromLegacy<bool>( aCfg,
"DrillUnit",
"gen_drill.unit_drill_is_inch" );
604 ret &= fromLegacy<bool>( aCfg,
"OvalHolesRouteMode",
"gen_drill.use_route_for_oval_holes" );
605 ret &= fromLegacy<int>( aCfg,
"DrillFileType",
"gen_drill.drill_file_type" );
606 ret &= fromLegacy<int>( aCfg,
"DrillMapFileType",
"gen_drill.map_file_type" );
607 ret &= fromLegacy<int>( aCfg,
"DrillZerosFormat",
"gen_drill.zeros_format" );
609 ret &= fromLegacy<bool>( aCfg,
"IDFRefAutoAdj",
"export_idf.auto_adjust" );
610 ret &= fromLegacy<int>( aCfg,
"IDFRefUnits",
"export_idf.ref_units" );
611 ret &= fromLegacy<double>( aCfg,
"IDFRefX",
"export_idf.ref_x" );
612 ret &= fromLegacy<double>( aCfg,
"IDFRefY",
"export_idf.ref_y" );
613 ret &= fromLegacy<bool>( aCfg,
"IDFExportThou",
"export_idf.units_mils" );
615 ret &= fromLegacy<int>( aCfg,
"STEP_Origin_Opt",
"export_step.origin_mode" );
616 ret &= fromLegacy<int>( aCfg,
"STEP_UserOriginUnits",
"export_step.origin_units" );
617 ret &= fromLegacy<double>( aCfg,
"STEP_UserOriginX",
"export_step.origin_x" );
618 ret &= fromLegacy<double>( aCfg,
"STEP_UserOriginY",
"export_step.origin_y" );
619 ret &= fromLegacy<bool>( aCfg,
"STEP_NoVirtual",
"export_step.no_virtual" );
621 ret &= fromLegacy<bool>( aCfg,
"PlotSVGModeColor",
"export_svg.black_and_white" );
622 ret &= fromLegacy<bool>( aCfg,
"PlotSVGModeMirror",
"export_svg.mirror" );
623 ret &= fromLegacy<bool>( aCfg,
"PlotSVGModeOneFile",
"export_svg.one_file" );
624 ret &= fromLegacy<bool>( aCfg,
"PlotSVGBrdEdge",
"export_svg.plot_board_edges" );
625 ret &= fromLegacy<int>( aCfg,
"PlotSVGPageOpt",
"export_svg.page_size" );
626 ret &=
fromLegacyString( aCfg,
"PlotSVGDirectory",
"export_svg.output_dir" );
635 key.Printf( wxT(
"PlotSVGLayer_%d" ), i );
637 if( aCfg->Read( key, &val ) && val )
641 Set(
"export_svg.layers", js );
649 if( aCfg->Read(
"ActionPluginButtons", &packed ) )
651 wxStringTokenizer pluginSettingsTokenizer = wxStringTokenizer( packed,
";" );
653 while( pluginSettingsTokenizer.HasMoreTokens() )
656 wxString plugin = pluginSettingsTokenizer.GetNextToken();
657 wxStringTokenizer pluginTokenizer = wxStringTokenizer( plugin,
"=" );
659 if( pluginTokenizer.CountTokens() != 2 )
665 std::string key( pluginTokenizer.GetNextToken().ToUTF8() );
666 bool value( pluginTokenizer.GetNextToken().Cmp( wxT(
"Visible" ) ) == 0 );
672 Set(
"action_plugins", js );
678 ret &= fromLegacy<int>( aCfg,
"VrmlExportUnit",
"export_vrml.units" );
679 ret &= fromLegacy<bool>( aCfg,
"VrmlExportCopyFiles",
"export_vrml.copy_3d_models" );
680 ret &= fromLegacy<bool>( aCfg,
"VrmlUseRelativePaths",
"export_vrml.use_relative_paths" );
681 ret &= fromLegacy<int>( aCfg,
"VrmlRefUnits",
"export_vrml.ref_units" );
682 ret &= fromLegacy<double>( aCfg,
"VrmlRefX",
"export_vrml.ref_x" );
683 ret &= fromLegacy<double>( aCfg,
"VrmlRefY",
"export_vrml.ref_y" );
684 ret &= fromLegacy<int> ( aCfg,
"VrmlOriginMode",
"export_vrml.origin_mode" );
686 ret &= fromLegacy<int>( aCfg,
"Zone_Ouline_Hatch_Opt",
"zones.hatching_style" );
687 ret &= fromLegacy<int>( aCfg,
"Zone_NetSort_Opt",
"zones.net_sort_mode" );
688 ret &= fromLegacy<double>( aCfg,
"Zone_Clearance",
"zones.clearance" );
689 ret &= fromLegacy<double>( aCfg,
"Zone_Thickness",
"zones.min_thickness" );
690 ret &= fromLegacy<double>( aCfg,
"Zone_TH_Gap",
"zones.thermal_relief_gap" );
691 ret &= fromLegacy<double>( aCfg,
"Zone_TH_Copper_Width",
"zones.thermal_relief_copper_width" );
693 aCfg->SetPath(
"ImportGraphics" );
694 ret &= fromLegacy<int>( aCfg,
"BoardLayer",
"import_graphics.layer" );
695 ret &= fromLegacy<bool>( aCfg,
"InteractivePlacement",
"import_graphics.interactive_placement" );
697 ret &= fromLegacy<double>( aCfg,
"LineWidth",
"import_graphics.line_width" );
698 ret &= fromLegacy<int>( aCfg,
"LineWidthUnits",
"import_graphics.line_width_units" );
699 ret &= fromLegacy<int>( aCfg,
"PositionUnits",
"import_graphics.origin_units" );
700 ret &= fromLegacy<double>( aCfg,
"PositionX",
"import_graphics.origin_x" );
701 ret &= fromLegacy<double>( aCfg,
"PositionY",
"import_graphics.origin_y" );
702 aCfg->SetPath(
".." );
704 ret &= fromLegacy<int>( aCfg,
"NetlistReportFilterMsg",
"netlist.report_filter" );
705 ret &= fromLegacy<bool>( aCfg,
"NetlistUpdateFootprints",
"netlist.update_footprints" );
706 ret &= fromLegacy<bool>( aCfg,
"NetlistDeleteShortingTracks",
"netlist.delete_shorting_tracks" );
707 ret &= fromLegacy<bool>( aCfg,
"NetlistDeleteExtraFootprints",
"netlist.delete_extra_footprints" );
709 ret &= fromLegacy<int>( aCfg,
"PlaceFileUnits",
"place_file.units" );
710 ret &= fromLegacy<int>( aCfg,
"PlaceFileOpts",
"place_file.file_options" );
711 ret &= fromLegacy<int>( aCfg,
"PlaceFileFormat",
"place_file.file_format" );
712 ret &= fromLegacy<bool>( aCfg,
"PlaceFileIncludeBrdEdge",
"place_file.include_board_edge" );
714 ret &= fromLegacy<int>( aCfg,
"PrintSinglePage",
"plot.all_layers_on_one_page" );
715 ret &= fromLegacy<int>( aCfg,
"PrintPadsDrillOpt",
"plot.pads_drill_mode" );
716 ret &= fromLegacy<double>( aCfg,
"PlotXFineScaleAdj",
"plot.fine_scale_x" );
717 ret &= fromLegacy<double>( aCfg,
"PlotYFineScaleAdj",
"plot.fine_scale_y" );
718 ret &= fromLegacy<double>( aCfg,
"PSPlotFineWidthAdj",
"plot.ps_fine_width_adjust" );
719 ret &= fromLegacy<bool>( aCfg,
"CheckZonesBeforePlotting",
"plot.check_zones_before_plotting" );
721 ret &=
fromLegacyString( aCfg,
"FootprintTextShownColumns",
"window.footprint_text_shown_columns" );
723 ret &= fromLegacy<int>( aCfg,
"FpWizardListWidth",
"footprint_wizard_list.width" );
724 ret &= fromLegacy<int>( aCfg,
"FpWizardListHeight",
"footprint_wizard_list.height" );
728 ret &= fromLegacy<bool>( aCfg,
"ModViewFrameAutoZoom",
"footprint_viewer.auto_zoom" );
729 ret &= fromLegacy<double>( aCfg,
"ModViewFrameZoom",
"footprint_viewer.zoom" );
732 ret &=
fromLegacyString( aCfg,
"Fpwizard_auiPerspective",
"footprint_wizard.perspective" );
735 const std::string p =
"pcbnew.InteractiveRouter.";
738 {
"filename",
"pns" },
742 ret &= fromLegacy<int>( aCfg, p +
"Mode",
"tools.pns.mode" );
743 ret &= fromLegacy<int>( aCfg, p +
"OptimizerEffort",
"tools.pns.effort" );
744 ret &= fromLegacy<bool>( aCfg, p +
"RemoveLoops",
"tools.pns.remove_loops" );
745 ret &= fromLegacy<bool>( aCfg, p +
"SmartPads",
"tools.pns.smart_pads" );
746 ret &= fromLegacy<bool>( aCfg, p +
"ShoveVias",
"tools.pns.shove_vias" );
747 ret &= fromLegacy<bool>( aCfg, p +
"StartDiagonal",
"tools.pns.start_diagonal" );
748 ret &= fromLegacy<int>( aCfg, p +
"ShoveTimeLimit",
"tools.pns.shove_time_limit" );
749 ret &= fromLegacy<int>( aCfg, p +
"ShoveIterationLimit",
"tools.pns.shove_iteration_limit" );
750 ret &= fromLegacy<int>( aCfg, p +
"WalkaroundIterationLimit",
"tools.pns.walkaround_iteration_limit" );
751 ret &= fromLegacy<bool>( aCfg, p +
"JumpOverObstacles",
"tools.pns.jump_over_obstacles" );
752 ret &= fromLegacy<bool>( aCfg, p +
"SmoothDraggedSegments",
"tools.pns.smooth_dragged_segments" );
753 ret &= fromLegacy<bool>( aCfg, p +
"CanViolateDRC",
"tools.pns.can_violate_drc" );
754 ret &= fromLegacy<bool>( aCfg, p +
"SuggestFinish",
"tools.pns.suggest_finish" );
755 ret &= fromLegacy<bool>( aCfg, p +
"FreeAngleMode",
"tools.pns.free_angle_mode" );
756 ret &= fromLegacy<bool>( aCfg, p +
"InlineDragEnabled",
"editing.track_drag_action" );
759 Set(
"tools.pns.fix_all_segments",
false );
765 auto migrateLegacyColor =
766 [&] (
const std::string& aKey,
int aLayerId )
770 if( aCfg->Read( aKey, &str ) )
777 migrateLegacyColor(
"Color4DPCBLayer_" + layer.ToStdString(),
PCB_LAYER_ID( i ) );
782 migrateLegacyColor(
"Color4DGrid",
LAYER_GRID );
795 Pgm().GetSettingsManager().SaveColorSettings( cs,
"board" );
801 if( aCfg->Read( f +
"PcbUserGrid_X", &x ) && aCfg->Read( f +
"PcbUserGrid_Y", &y ) )
803 EDA_UNITS u = static_cast<EDA_UNITS>( aCfg->ReadLong( f +
"PcbUserGrid_Unit",
DIALOG_GENERATE_DRILL m_GenDrill
bool m_DisplayPadNoConnects
void addParamsForWindow(WINDOW_SETTINGS *aWindow, const std::string &aJsonPath)
Adds parameters for the given window object.
bool use_route_for_oval_holes
Auxiliary items (guides, rule, etc)
DIALOG_EXPORT_STEP m_ExportStep
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...
bool m_DisplayInvertXAxis
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
wxString report_file_name
Implementation of conversion functions that require both schematic and board internal units.
int all_layers_on_one_page
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
DIALOG_EXPORT_IDF m_ExportIdf
wxString GetFilename() const
int m_DisplayNetNamesMode
double ps_fine_width_adjust
bool associate_by_ref_sch
anchor of items having an anchor point (texts, footprints)
void SetColor(int aLayer, const COLOR4D &aColor)
bool m_ShowModuleRatsnest
Stores an enum as an integer.
const int pcbnewSchemaVersion
! Update the schema version whenever a migration is required
#define ZONE_THERMAL_RELIEF_COPPER_WIDTH_MIL
double m_FootprintViewerZoom
The last zoom level used (0 for auto)
bool delete_extra_footprints
wxString m_FootprintTextShownColumns
DIALOG_EXPORT_VRML m_ExportVrml
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
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...
FOOTPRINT_CHOOSER m_FootprintChooser
bool check_zones_before_plotting
TRACE_CLEARANCE_DISPLAY_MODE_T m_ShowTrackClearanceMode
How trace clearances are displayed.
wxString front_refdes_start
to draw usual through hole vias
bool cleanup_tracks_in_pad
DIALOG_FOOTPRINT_WIZARD_LIST m_FootprintWizardList
double thermal_relief_gap
wxString m_lastFootprint3dDir
WINDOW_SETTINGS m_FootprintWizard
DIALOG_EXPORT_SVG m_ExportSvg
handle color for not plated holes (holes, not pads)
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
PCB_DISPLAY_ORIGIN_OPTIONS_T m_DisplayOrigin
Which origin is used for display transforms.
TRACK_DRAG_ACTION m_TrackDragAction
virtual bool MigrateFromLegacy(wxConfigBase *aLegacyConfig) override
Migrates from wxConfig to JSON-based configuration.
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
DIALOG_NETLIST m_NetlistDialog
bool m_DisplayInvertYAxis
virtual bool MigrateFromLegacy(wxConfigBase *aLegacyConfig) override
Migrates from wxConfig to JSON-based configuration.
bool m_PcbUse45DegreeLimit
Functions to provide common constants and other functions to assist in making a consistent UI.
#define ZONE_CLEARANCE_MIL
bool m_FpeditUse45DegreeLimit
drawingsheet frame and titleblock
bool m_DisplayPcbTrackFill
WINDOW_SETTINGS m_FootprintViewer
bool m_DisplayGraphicsFill
wxString back_refdes_start
double thermal_relief_copper_width
#define ZONE_THICKNESS_MIL
bool interactive_placement
bool m_ShowGlobalRatsnest
virtual std::string getLegacyFrameName() const override
show a marker on pads with no nets
bool delete_dangling_vias
DIALOG_PLACE_FILE m_PlaceFile
bool fromLegacyString(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy wxConfig string value to a given JSON pointer value.
ACTION_PLUGIN_SETTINGS_LIST m_VisibleActionPlugins
virtual ~PCBNEW_SETTINGS()
multilayer pads, usually with holes
to draw blind/buried vias
void registerMigration(int aOldSchemaVersion, int aNewSchemaVersion, std::function< bool(void)> aMigrator)
Registers a migration from one schema version to another.
bool delete_shorting_tracks
PCB_LAYER_ID
A quick note on layer IDs:
bool cleanup_short_circuits
bool m_Live3DRefresh
If true, 3D viewer will redraw on every modification operation.
ZONE_DISPLAY_MODE m_ZoneDisplayMode
bool test_all_track_errors
DIALOG_REANNOTATE m_Reannotate
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
DIALOG_IMPORT_GRAPHICS m_ImportGraphics
Color settings are a bit different than most of the settings objects in that there can be more than o...
bool edgecut_on_all_layers
#define ZONE_THERMAL_RELIEF_GAP_MIL
std::vector< int > layers
MAGNETIC_SETTINGS m_MagneticItems
wxString m_lastFootprintLibDir
bool m_DisplayRatsnestLinesCurved
PCB_DISPLAY_OPTIONS m_Display
double From_User_Unit(EDA_UNITS aUnits, double aValue)
Return in internal units the value "val" given in a real unit such as "in", "mm" or "deg".
bool m_DisplayPadClearance
bool migrateWindowConfig(wxConfigBase *aCfg, const std::string &aFrameName, const std::string &aJsonPath)
Migrates legacy window settings into the JSON document.
A color representation with 4 components: red, green, blue, alpha.