24#include <pybind11/pybind11.h>
38#include <wx/tokenzr.h>
43#include "../3d-viewer/3d_viewer/eda_3d_viewer_settings.h"
60 m_CtrlClickHighlight( false ),
61 m_Use45DegreeLimit( false ),
63 m_ESCClearsNetHighlight( true ),
64 m_PolarCoords( false ),
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 )
157 static_cast<bool>( FLIP_DIRECTION::LEFT_RIGHT ) ) );
170 static_cast<int>( MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL ) ) );
174 static_cast<int>( MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL ) ) );
184 static_cast<int>( TRACK_DRAG_ACTION::DRAG ) ) );
188 static_cast<int>( ARC_EDIT_MODE::KEEP_CENTER_ADJUST_ANGLE_RADIUS ) ) );
271 PCB_DISPLAY_ORIGIN::PCB_ORIGIN_PAGE ) );
298 [&]() -> nlohmann::json
300 nlohmann::json js = nlohmann::json::array();
303 js.push_back( nlohmann::json( { { pair.first.ToUTF8(), pair.second } } ) );
307 [&](
const nlohmann::json& aObj )
311 if( !aObj.is_array() )
316 for(
const auto& entry : aObj )
318 if( entry.empty() || !entry.is_object() )
321 for(
const auto& pair : entry.items() )
324 wxString( pair.key().c_str(), wxConvUTF8 ), pair.value() ) );
328 nlohmann::json::array() ) );
355 if( std::optional<int> optval = Get<int>(
"pcb_display.rotation_angle" ) )
356 Set(
"editing.rotation_angle", *optval );
360 At(
"pcb_display" ).erase(
"rotation_angle" );
373 Set(
"editing.auto_fill_zones",
false );
384 if( std::optional<int> optval = Get<int>(
"lib_tree.column_width" ) )
387 Set(
"lib_tree.column_width", 300 );
404 Set(
"editing.auto_fill_zones",
false );
422 ret &= fromLegacy<bool>( aCfg,
"ShowLayerManagerTools",
"aui.show_layer_manager" );
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" );
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" );
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" );
456 ret &= fromLegacy<double>( aCfg,
"PlotLineWidth_mm",
"plot.line_width" );
459 nlohmann::json js = nlohmann::json::array();
465 key.Printf( wxT(
"PlotSVGLayer_%d" ), i );
467 if( aCfg->Read( key, &val ) && val )
471 Set(
"export_svg.layers", js );
475 nlohmann::json js = nlohmann::json::array();
479 if( aCfg->Read(
"ActionPluginButtons", &packed ) )
481 wxStringTokenizer pluginSettingsTokenizer = wxStringTokenizer( packed,
";" );
483 while( pluginSettingsTokenizer.HasMoreTokens() )
486 wxString plugin = pluginSettingsTokenizer.GetNextToken();
487 wxStringTokenizer pluginTokenizer = wxStringTokenizer( plugin,
"=" );
489 if( pluginTokenizer.CountTokens() != 2 )
495 std::string key( pluginTokenizer.GetNextToken().ToUTF8() );
496 bool value( pluginTokenizer.GetNextToken().Cmp( wxT(
"Visible" ) ) == 0 );
498 js.push_back( nlohmann::json( { { key, value } } ) );
502 Set(
"action_plugins", js );
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" );
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" );
522 ret &=
fromLegacyString( aCfg,
"FootprintTextShownColumns",
"window.footprint_text_shown_columns" );
524 ret &= fromLegacy<int>( aCfg,
"FpWizardListWidth",
"footprint_wizard_list.width" );
525 ret &= fromLegacy<int>( aCfg,
"FpWizardListHeight",
"footprint_wizard_list.height" );
529 ret &= fromLegacy<bool>( aCfg,
"ModViewFrameAutoZoom",
"footprint_viewer.auto_zoom" );
530 ret &= fromLegacy<double>( aCfg,
"ModViewFrameZoom",
"footprint_viewer.zoom" );
533 ret &=
fromLegacyString( aCfg,
"Fpwizard_auiPerspective",
"footprint_wizard.perspective" );
536 const std::string p =
"pcbnew.InteractiveRouter.";
538 Set(
"tools.pns.meta", nlohmann::json( {
539 {
"filename",
"pns" },
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" );
560 Set(
"tools.pns.fix_all_segments",
false );
567 auto migrateLegacyColor =
568 [&] (
const std::string& aKey,
int aLayerId )
572 if( aCfg->Read( aKey, &str ) )
579 migrateLegacyColor(
"Color4DPCBLayer_" + layer.ToStdString(),
PCB_LAYER_ID( i ) );
584 migrateLegacyColor(
"Color4DGrid",
LAYER_GRID );
601 if( aCfg->Read( f +
"PcbUserGrid_X", &x ) && aCfg->Read( f +
"PcbUserGrid_Y", &y ) )
604 static_cast<long>( EDA_UNITS::INCH ) ) );
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.
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
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
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
wxString m_LastFootprintLibDir
EDA_ANGLE m_RotationAngle
ARC_EDIT_MODE m_ArcEditMode
FOOTPRINT_CHOOSER m_FootprintChooser
virtual ~PCBNEW_SETTINGS()
bool m_CtrlClickHighlight
TRACK_DRAG_ACTION m_TrackDragAction
LOCKING_OPTIONS m_LockingOptions
bool m_ESCClearsNetHighlight
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
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
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
static constexpr EDA_ANGLE ANGLE_360
@ 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_THROUGH
Draw blind/buried vias.
@ LAYER_VIA_BBLIND
Draw micro vias.
PCB_LAYER_ID
A quick note on layer IDs:
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
PGM_BASE & Pgm()
The global program "get" accessor.
float properties_splitter
int properties_panel_width
int design_blocks_panel_float_height
bool appearance_expand_layer_display
bool appearance_expand_net_display
int design_blocks_panel_docked_width
int search_panel_dock_direction
int design_blocks_panel_float_width
bool doNotExportUnconnectedPads
bool m_DisplayPcbTrackFill
TRACK_CLEARANCE_MODE m_TrackClearance
bool m_DisplayInvertYAxis
bool m_DisplayRatsnestLinesCurved
bool m_ShowModuleRatsnest
bool m_DisplayInvertXAxis
bool m_ForceShowFieldsWhenFPSelected
bool m_ShowGlobalRatsnest
PCB_DISPLAY_ORIGIN m_DisplayOrigin
double m_RatsnestThickness
bool m_sessionSkipPrompts
bool m_DisplayGraphicsFill
Functions to provide common constants and other functions to assist in making a consistent UI.