24#include <pybind11/pybind11.h>
37#include <wx/tokenzr.h>
42#include "../3d-viewer/3d_viewer/eda_3d_viewer_settings.h"
58 m_FootprintWizardList(),
71 m_CtrlClickHighlight( false ),
72 m_Use45DegreeLimit( false ),
73 m_FlipLeftRight( false ),
74 m_ESCClearsNetHighlight( true ),
75 m_PolarCoords( false ),
77 m_ShowPageLimits( true ),
78 m_ShowCourtyardCollisions( true ),
79 m_AutoRefillZones( false ),
80 m_AllowFreePads( false ),
81 m_PnsSettings( nullptr ),
82 m_FootprintViewerZoom( 1.0 ),
83 m_FootprintViewerAutoZoomOnSelect( true ),
84 m_FootprintViewerLibListWidth( 200 ),
85 m_FootprintViewerFPListWidth( 300 )
527 js.push_back(
nlohmann::json( { { pair.first.ToUTF8(), pair.second } } ) );
535 if( !aObj.is_array() )
540 for(
const auto& entry : aObj )
542 if( entry.empty() || !entry.is_object() )
545 for(
const auto& pair : entry.items() )
548 wxString( pair.key().c_str(), wxConvUTF8 ), pair.value() ) );
552 nlohmann::json::array() ) );
579 if( std::optional<int> optval = Get<int>(
"pcb_display.rotation_angle" ) )
580 Set(
"editing.rotation_angle", *optval );
584 At(
"pcb_display" ).erase(
"rotation_angle" );
597 Set(
"editing.auto_fill_zones",
false );
608 if( std::optional<int> optval = Get<int>(
"lib_tree.column_width" ) )
611 Set(
"lib_tree.column_width", 300 );
638 ret &= fromLegacy<bool>( aCfg,
"ShowLayerManagerTools",
"aui.show_layer_manager" );
640 ret &= fromLegacy<int>( aCfg,
"FootprintChooserHSashPosition",
"footprint_chooser.sash_h" );
641 ret &= fromLegacy<int>( aCfg,
"FootprintChooserVSashPosition",
"footprint_chooser.sash_v" );
642 ret &= fromLegacy<int>( aCfg,
"FootprintChooserWidth",
"footprint_chooser.width" );
643 ret &= fromLegacy<int>( aCfg,
"FootprintChooserHeight",
"footprint_chooser.height" );
645 ret &= fromLegacy<bool>( aCfg,
"FlipLeftRight",
"editing.flip_left_right" );
646 ret &= fromLegacy<bool>( aCfg,
"MagneticGraphics",
"editing.magnetic_graphics" );
647 ret &= fromLegacy<int>( aCfg,
"MagneticPads",
"editing.magnetic_pads" );
648 ret &= fromLegacy<int>( aCfg,
"MagneticTracks",
"editing.magnetic_tracks" );
649 ret &= fromLegacy<bool>( aCfg,
"DisplayPolarCoords",
"editing.polar_coords" );
650 ret &= fromLegacy<bool>( aCfg,
"Use45DegreeGraphicSegments",
"editing.use_45_degree_graphic_segments" );
652 ret &= fromLegacy<bool>( aCfg,
"PcbAffT",
"pcb_display.graphic_items_fill" );
653 ret &= fromLegacy<int>( aCfg,
"MaxLnkS",
"pcb_display.max_links_shown" );
654 ret &= fromLegacy<bool>( aCfg,
"ModAffC",
"pcb_display.footprint_edge_fill" );
655 ret &= fromLegacy<bool>( aCfg,
"ModAffT",
"pcb_display.footprint_text_fill" );
656 ret &= fromLegacy<int>( aCfg,
"ShowNetNamesMode",
"pcb_display.net_names_mode" );
657 ret &= fromLegacy<int>( aCfg,
"PcbDisplayOrigin",
"pcb_display.origin_mode" );
658 ret &= fromLegacy<bool>( aCfg,
"PcbInvertXAxis",
"pcb_display.origin_invert_x_axis" );
659 ret &= fromLegacy<bool>( aCfg,
"PcbInvertYAxis",
"pcb_display.origin_invert_y_axis" );
660 ret &= fromLegacy<bool>( aCfg,
"PadAffG",
"pcb_display.pad_clearance" );
661 ret &= fromLegacy<bool>( aCfg,
"PadFill",
"pcb_display.pad_fill" );
662 ret &= fromLegacy<bool>( aCfg,
"PadSNum",
"pcb_display.pad_numbers" );
663 ret &= fromLegacy<bool>( aCfg,
"ShowRatsnestLines",
"pcb_display.ratsnest_global" );
664 ret &= fromLegacy<bool>( aCfg,
"ShowRatsnestModuleLines",
"pcb_display.ratsnest_footprint" );
665 ret &= fromLegacy<bool>( aCfg,
"CurvedRatsnestLines",
"pcb_display.ratsnest_curved" );
666 ret &= fromLegacy<int>( aCfg,
"RotationAngle",
"pcb_display.rotation_angle" );
667 ret &= fromLegacy<int>( aCfg,
"TrackDisplayClearance",
"pcb_display.track_clearance_mode" );
668 ret &= fromLegacy<bool>( aCfg,
"DisplayTrackFilled",
"pcb_display.track_fill" );
669 ret &= fromLegacy<bool>( aCfg,
"ViaFill",
"pcb_display.via_fill" );
670 ret &= fromLegacy<int>( aCfg,
"PcbShowZonesMode",
"pcb_display.zone_mode" );
672 ret &= fromLegacy<double>( aCfg,
"PlotLineWidth_mm",
"plot.line_width" );
674 aCfg->SetPath(
"/dialogs/cleanup_tracks" );
675 ret &= fromLegacy<bool>( aCfg,
"DialogCleanupVias",
"cleanup.cleanup_vias" );
676 ret &= fromLegacy<bool>( aCfg,
"DialogCleanupMergeSegments",
"cleanup.merge_segments" );
677 ret &= fromLegacy<bool>( aCfg,
"DialogCleanupUnconnected",
"cleanup.cleanup_unconnected" );
678 ret &= fromLegacy<bool>( aCfg,
"DialogCleanupShortCircuit",
"cleanup.cleanup_short_circuits" );
679 ret &= fromLegacy<bool>( aCfg,
"DialogCleanupTracksInPads",
"cleanup.cleanup_tracks_in_pad" );
680 aCfg->SetPath(
"../.." );
682 ret &= fromLegacy<bool>( aCfg,
"RefillZonesBeforeDrc",
"drc_dialog.refill_zones" );
683 ret &= fromLegacy<bool>( aCfg,
"DrcTestFootprints",
"drc_dialog.test_footprints" );
685 ret &= fromLegacy<bool>( aCfg,
"DrillMergePTHNPTH",
"gen_drill.merge_pth_npth" );
686 ret &= fromLegacy<bool>( aCfg,
"DrillMinHeader",
"gen_drill.minimal_header" );
687 ret &= fromLegacy<bool>( aCfg,
"DrillMirrorYOpt",
"gen_drill.mirror" );
688 ret &= fromLegacy<bool>( aCfg,
"DrillUnit",
"gen_drill.unit_drill_is_inch" );
689 ret &= fromLegacy<bool>( aCfg,
"OvalHolesRouteMode",
"gen_drill.use_route_for_oval_holes" );
690 ret &= fromLegacy<int>( aCfg,
"DrillFileType",
"gen_drill.drill_file_type" );
691 ret &= fromLegacy<int>( aCfg,
"DrillMapFileType",
"gen_drill.map_file_type" );
692 ret &= fromLegacy<int>( aCfg,
"DrillZerosFormat",
"gen_drill.zeros_format" );
694 ret &= fromLegacy<bool>( aCfg,
"IDFRefAutoAdj",
"export_idf.auto_adjust" );
695 ret &= fromLegacy<int>( aCfg,
"IDFRefUnits",
"export_idf.ref_units" );
696 ret &= fromLegacy<double>( aCfg,
"IDFRefX",
"export_idf.ref_x" );
697 ret &= fromLegacy<double>( aCfg,
"IDFRefY",
"export_idf.ref_y" );
698 ret &= fromLegacy<bool>( aCfg,
"IDFExportThou",
"export_idf.units_mils" );
700 ret &= fromLegacy<int>( aCfg,
"STEP_Origin_Opt",
"export_step.origin_mode" );
701 ret &= fromLegacy<int>( aCfg,
"STEP_UserOriginUnits",
"export_step.origin_units" );
702 ret &= fromLegacy<double>( aCfg,
"STEP_UserOriginX",
"export_step.origin_x" );
703 ret &= fromLegacy<double>( aCfg,
"STEP_UserOriginY",
"export_step.origin_y" );
704 ret &= fromLegacy<bool>( aCfg,
"STEP_NoVirtual",
"export_step.no_virtual" );
706 ret &= fromLegacy<bool>( aCfg,
"PlotSVGModeColor",
"export_svg.black_and_white" );
707 ret &= fromLegacy<bool>( aCfg,
"PlotSVGModeMirror",
"export_svg.mirror" );
708 ret &= fromLegacy<bool>( aCfg,
"PlotSVGModeOneFile",
"export_svg.one_file" );
709 ret &= fromLegacy<bool>( aCfg,
"PlotSVGBrdEdge",
"export_svg.plot_board_edges" );
710 ret &= fromLegacy<int>( aCfg,
"PlotSVGPageOpt",
"export_svg.page_size" );
711 ret &=
fromLegacyString( aCfg,
"PlotSVGDirectory",
"export_svg.output_dir" );
720 key.Printf( wxT(
"PlotSVGLayer_%d" ), i );
722 if( aCfg->Read( key, &val ) && val )
726 Set(
"export_svg.layers", js );
734 if( aCfg->Read(
"ActionPluginButtons", &packed ) )
736 wxStringTokenizer pluginSettingsTokenizer = wxStringTokenizer( packed,
";" );
738 while( pluginSettingsTokenizer.HasMoreTokens() )
741 wxString plugin = pluginSettingsTokenizer.GetNextToken();
742 wxStringTokenizer pluginTokenizer = wxStringTokenizer( plugin,
"=" );
744 if( pluginTokenizer.CountTokens() != 2 )
750 std::string key( pluginTokenizer.GetNextToken().ToUTF8() );
751 bool value( pluginTokenizer.GetNextToken().Cmp( wxT(
"Visible" ) ) == 0 );
757 Set(
"action_plugins", js );
763 ret &= fromLegacy<int>( aCfg,
"VrmlExportUnit",
"export_vrml.units" );
764 ret &= fromLegacy<bool>( aCfg,
"VrmlExportCopyFiles",
"export_vrml.copy_3d_models" );
765 ret &= fromLegacy<bool>( aCfg,
"VrmlUseRelativePaths",
"export_vrml.use_relative_paths" );
766 ret &= fromLegacy<int>( aCfg,
"VrmlRefUnits",
"export_vrml.ref_units" );
767 ret &= fromLegacy<double>( aCfg,
"VrmlRefX",
"export_vrml.ref_x" );
768 ret &= fromLegacy<double>( aCfg,
"VrmlRefY",
"export_vrml.ref_y" );
769 ret &= fromLegacy<int> ( aCfg,
"VrmlOriginMode",
"export_vrml.origin_mode" );
771 ret &= fromLegacy<int>( aCfg,
"Zone_Ouline_Hatch_Opt",
"zones.hatching_style" );
772 ret &= fromLegacy<int>( aCfg,
"Zone_NetSort_Opt",
"zones.net_sort_mode" );
773 ret &= fromLegacy<double>( aCfg,
"Zone_Clearance",
"zones.clearance" );
774 ret &= fromLegacy<double>( aCfg,
"Zone_Thickness",
"zones.min_thickness" );
775 ret &= fromLegacy<double>( aCfg,
"Zone_TH_Gap",
"zones.thermal_relief_gap" );
776 ret &= fromLegacy<double>( aCfg,
"Zone_TH_Copper_Width",
"zones.thermal_relief_copper_width" );
778 aCfg->SetPath(
"ImportGraphics" );
779 ret &= fromLegacy<int>( aCfg,
"BoardLayer",
"import_graphics.layer" );
780 ret &= fromLegacy<bool>( aCfg,
"InteractivePlacement",
"import_graphics.interactive_placement" );
782 ret &= fromLegacy<double>( aCfg,
"LineWidth",
"import_graphics.line_width" );
783 ret &= fromLegacy<int>( aCfg,
"LineWidthUnits",
"import_graphics.line_width_units" );
784 ret &= fromLegacy<int>( aCfg,
"PositionUnits",
"import_graphics.origin_units" );
785 ret &= fromLegacy<double>( aCfg,
"PositionX",
"import_graphics.origin_x" );
786 ret &= fromLegacy<double>( aCfg,
"PositionY",
"import_graphics.origin_y" );
787 aCfg->SetPath(
".." );
789 ret &= fromLegacy<int>( aCfg,
"NetlistReportFilterMsg",
"netlist.report_filter" );
790 ret &= fromLegacy<bool>( aCfg,
"NetlistUpdateFootprints",
"netlist.update_footprints" );
791 ret &= fromLegacy<bool>( aCfg,
"NetlistDeleteShortingTracks",
"netlist.delete_shorting_tracks" );
792 ret &= fromLegacy<bool>( aCfg,
"NetlistDeleteExtraFootprints",
"netlist.delete_extra_footprints" );
794 ret &= fromLegacy<int>( aCfg,
"PlaceFileUnits",
"place_file.units" );
795 ret &= fromLegacy<int>( aCfg,
"PlaceFileOpts",
"place_file.file_options" );
796 ret &= fromLegacy<int>( aCfg,
"PlaceFileFormat",
"place_file.file_format" );
797 ret &= fromLegacy<bool>( aCfg,
"PlaceFileIncludeBrdEdge",
"place_file.include_board_edge" );
799 ret &= fromLegacy<int>( aCfg,
"PrintSinglePage",
"plot.all_layers_on_one_page" );
800 ret &= fromLegacy<int>( aCfg,
"PrintPadsDrillOpt",
"plot.pads_drill_mode" );
801 ret &= fromLegacy<double>( aCfg,
"PlotXFineScaleAdj",
"plot.fine_scale_x" );
802 ret &= fromLegacy<double>( aCfg,
"PlotYFineScaleAdj",
"plot.fine_scale_y" );
803 ret &= fromLegacy<double>( aCfg,
"PSPlotFineWidthAdj",
"plot.ps_fine_width_adjust" );
804 ret &= fromLegacy<bool>( aCfg,
"CheckZonesBeforePlotting",
"plot.check_zones_before_plotting" );
806 ret &=
fromLegacyString( aCfg,
"FootprintTextShownColumns",
"window.footprint_text_shown_columns" );
808 ret &= fromLegacy<int>( aCfg,
"FpWizardListWidth",
"footprint_wizard_list.width" );
809 ret &= fromLegacy<int>( aCfg,
"FpWizardListHeight",
"footprint_wizard_list.height" );
813 ret &= fromLegacy<bool>( aCfg,
"ModViewFrameAutoZoom",
"footprint_viewer.auto_zoom" );
814 ret &= fromLegacy<double>( aCfg,
"ModViewFrameZoom",
"footprint_viewer.zoom" );
817 ret &=
fromLegacyString( aCfg,
"Fpwizard_auiPerspective",
"footprint_wizard.perspective" );
820 const std::string p =
"pcbnew.InteractiveRouter.";
823 {
"filename",
"pns" },
827 ret &= fromLegacy<int>( aCfg, p +
"Mode",
"tools.pns.mode" );
828 ret &= fromLegacy<int>( aCfg, p +
"OptimizerEffort",
"tools.pns.effort" );
829 ret &= fromLegacy<bool>( aCfg, p +
"RemoveLoops",
"tools.pns.remove_loops" );
830 ret &= fromLegacy<bool>( aCfg, p +
"SmartPads",
"tools.pns.smart_pads" );
831 ret &= fromLegacy<bool>( aCfg, p +
"ShoveVias",
"tools.pns.shove_vias" );
832 ret &= fromLegacy<bool>( aCfg, p +
"StartDiagonal",
"tools.pns.start_diagonal" );
833 ret &= fromLegacy<int>( aCfg, p +
"ShoveTimeLimit",
"tools.pns.shove_time_limit" );
834 ret &= fromLegacy<int>( aCfg, p +
"ShoveIterationLimit",
"tools.pns.shove_iteration_limit" );
835 ret &= fromLegacy<int>( aCfg, p +
"WalkaroundIterationLimit",
"tools.pns.walkaround_iteration_limit" );
836 ret &= fromLegacy<bool>( aCfg, p +
"JumpOverObstacles",
"tools.pns.jump_over_obstacles" );
837 ret &= fromLegacy<bool>( aCfg, p +
"SmoothDraggedSegments",
"tools.pns.smooth_dragged_segments" );
838 ret &= fromLegacy<bool>( aCfg, p +
"CanViolateDRC",
"tools.pns.can_violate_drc" );
839 ret &= fromLegacy<bool>( aCfg, p +
"SuggestFinish",
"tools.pns.suggest_finish" );
840 ret &= fromLegacy<bool>( aCfg, p +
"FreeAngleMode",
"tools.pns.free_angle_mode" );
841 ret &= fromLegacy<bool>( aCfg, p +
"InlineDragEnabled",
"editing.track_drag_action" );
844 Set(
"tools.pns.fix_all_segments",
false );
850 auto migrateLegacyColor =
851 [&] (
const std::string& aKey,
int aLayerId )
855 if( aCfg->Read( aKey, &str ) )
862 migrateLegacyColor(
"Color4DPCBLayer_" + layer.ToStdString(),
PCB_LAYER_ID( i ) );
867 migrateLegacyColor(
"Color4DGrid",
LAYER_GRID );
880 Pgm().GetSettingsManager().SaveColorSettings( cs,
"board" );
886 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
constexpr EDA_IU_SCALE pcbIUScale
bool migrateWindowConfig(wxConfigBase *aCfg, const std::string &aFrameName, const std::string &aJsonPath)
Migrates legacy window settings into the JSON document.
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
void addParamsForWindow(WINDOW_SETTINGS *aWindow, const std::string &aJsonPath)
Adds parameters for the given window object.
bool migrateLibTreeWidth()
Migrates 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
bool fromLegacyString(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy wxConfig string value to a given JSON pointer value.
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...
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...
wxString GetFilename() const
A color representation with 4 components: red, green, blue, alpha.
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Like a normal param, but with custom getter and setter functions.
double m_FootprintViewerZoom
The last zoom level used (0 for auto)
DISPLAY_OPTIONS m_Display
DIALOG_NETLIST m_NetlistDialog
EDA_ANGLE m_RotationAngle
DIALOG_PLACE_FILE m_PlaceFile
bool m_FootprintViewerAutoZoomOnSelect
true to use automatic zoom on fp selection
DIALOG_FOOTPRINT_WIZARD_LIST m_FootprintWizardList
ARC_EDIT_MODE m_ArcEditMode
FOOTPRINT_CHOOSER m_FootprintChooser
virtual ~PCBNEW_SETTINGS()
bool m_CtrlClickHighlight
DIALOG_EXPORT_VRML m_ExportVrml
DIALOG_EXPORT_IDF m_ExportIdf
TRACK_DRAG_ACTION m_TrackDragAction
bool m_ESCClearsNetHighlight
wxString m_lastFootprintLibDir
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
DIALOG_IMPORT_GRAPHICS m_ImportGraphics
DIALOG_EXPORT_STEP m_ExportStep
WINDOW_SETTINGS m_FootprintViewer
wxString m_lastFootprint3dDir
bool m_ShowCourtyardCollisions
DIALOG_GENERATE_DRILL m_GenDrill
MAGNETIC_SETTINGS m_MagneticItems
DIALOG_REANNOTATE m_Reannotate
int m_FootprintViewerFPListWidth
DIALOG_EXPORT_SVG m_ExportSvg
wxString m_FootprintTextShownColumns
int m_FootprintViewerLibListWidth
VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay
static constexpr EDA_ANGLE & ANGLE_360
static constexpr EDA_ANGLE & ANGLE_90
@ LAYER_MOD_TEXT_INVISIBLE
text marked as invisible
@ LAYER_PAGE_LIMITS
color for drawing the page extents (visibility stored in PCBNEW_SETTINGS::m_ShowPageLimits)
@ LAYER_NON_PLATEDHOLES
handle color for not plated holes (holes, not pads)
@ LAYER_DRAWINGSHEET
drawingsheet frame and titleblock
@ 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_PADS_TH
multilayer pads, usually with holes
@ LAYER_VIA_MICROVIA
to draw micro vias
@ LAYER_VIA_THROUGH
to draw usual through hole vias
@ LAYER_VIA_BBLIND
to draw blind/buried vias
PCB_LAYER_ID
A quick note on layer IDs:
double FromUserUnit(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnit, double aValue)
Return in internal units the value "val" given in a real unit such as "in", "mm" or "deg".
wxString StringFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Returns 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
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
int properties_panel_width
float properties_splitter_proportion
bool appearance_expand_layer_display
bool appearance_expand_net_display
bool cleanup_tracks_in_pad
bool delete_dangling_vias
bool cleanup_short_circuits
bool test_all_track_errors
std::vector< int > layers
bool use_route_for_oval_holes
bool interactive_placement
bool associate_by_ref_sch
bool delete_extra_footprints
bool delete_shorting_tracks
wxString output_directory
int all_layers_on_one_page
double ps_fine_width_adjust
bool check_zones_before_plotting
bool edgecut_on_all_layers
wxString front_refdes_start
wxString back_refdes_start
wxString report_file_name
bool m_DisplayPcbTrackFill
TRACK_CLEARANCE_MODE m_TrackClearance
bool m_DisplayInvertYAxis
bool m_DisplayRatsnestLinesCurved
bool m_ShowModuleRatsnest
bool m_DisplayInvertXAxis
bool m_ShowGlobalRatsnest
PCB_DISPLAY_ORIGIN m_DisplayOrigin
bool m_DisplayGraphicsFill
Functions to provide common constants and other functions to assist in making a consistent UI.