187 [&]() -> nlohmann::json
189 nlohmann::json js = nlohmann::json::array();
193 js.push_back( nlohmann::json( { {
"lib", tab.m_lib.ToUTF8() },
194 {
"fp_name", tab.m_fpName.ToUTF8() },
195 {
"preview", tab.m_preview } } ) );
200 [&](
const nlohmann::json& aObj )
204 if( !aObj.is_array() )
207 for(
const nlohmann::json& entry : aObj )
209 if( !entry.is_object() || !entry.contains(
"lib" ) || !entry.contains(
"fp_name" ) )
213 tab.
m_lib = entry.at(
"lib" ).get<wxString>();
214 tab.
m_fpName = entry.at(
"fp_name" ).get<wxString>();
217 if( entry.contains(
"preview" ) )
218 tab.
m_preview = entry.at(
"preview" ).get<
bool>();
223 nlohmann::json::array() ) );
229 "design_settings.default_footprint_text_items",
230 [&] () -> nlohmann::json
232 nlohmann::json js = nlohmann::json::array();
236 js.push_back( nlohmann::json( { item.
m_Text.ToUTF8(),
243 [&] (
const nlohmann::json& aObj )
247 if( !aObj.is_array() )
250 for(
const nlohmann::json& entry : aObj )
252 if( entry.empty() || !entry.is_array() )
257 textInfo.
m_Text = entry.at(0).get<wxString>();
258 textInfo.
m_Visible = entry.at(1).get<
bool>();
259 wxString layerName = entry.at(2).get<wxString>();
261 textInfo.
m_Layer = candidateLayer >= 0
268 nlohmann::json::array( {
279 [
this](
int aCount ) {
m_DesignSettings.SetUserDefinedLayerCount( aCount ); },
408 [&]() -> nlohmann::json
427 [&](
const nlohmann::json& aVal )
429 if( aVal.empty() || !aVal.is_object() )
446 {
"lockedItems",
false },
447 {
"footprints",
true },
452 {
"graphics",
true },
454 {
"keepouts",
true },
455 {
"dimensions",
true },
457 {
"otherItems",
true }
483 ret &=
fromLegacyString( aCfg,
"import_last_path",
"system.last_import_export_path" );
485 ret &=
fromLegacy<int>( aCfg,
"FpEditorMagneticPads",
"editing.magnetic_pads" );
486 ret &=
fromLegacy<bool>( aCfg,
"FpEditorDisplayPolarCoords",
"editing.polar_coords" );
487 ret &=
fromLegacy<int>( aCfg,
"FpEditorUse45DegreeGraphicSegments",
"editing.use_45_degree_graphic_segments" );
489 ret &=
fromLegacy<bool>( aCfg,
"FpEditorGraphicLinesDisplayMode",
"pcb_display.graphic_items_fill" );
490 ret &=
fromLegacy<bool>( aCfg,
"FpEditorPadDisplayMode",
"pcb_display.pad_fill" );
491 ret &=
fromLegacy<bool>( aCfg,
"FpEditorTextsDisplayMode",
"pcb_display.footprint_text" );
493 ret &=
fromLegacy<double>( aCfg,
"FpEditorSilkLineWidth",
"design_settings.silk_line_width" );
494 ret &=
fromLegacy<double>( aCfg,
"FpEditorSilkTextSizeH",
"design_settings.silk_text_size_h" );
495 ret &=
fromLegacy<double>( aCfg,
"FpEditorSilkTextSizeV",
"design_settings.silk_text_size_v" );
496 ret &=
fromLegacy<double>( aCfg,
"FpEditorSilkTextThickness",
"design_settings.silk_text_thickness" );
497 ret &=
fromLegacy<bool>( aCfg,
"FpEditorSilkTextItalic",
"design_settings.silk_text_italic" );
498 ret &=
fromLegacy<double>( aCfg,
"FpEditorCopperLineWidth",
"design_settings.copper_line_width" );
499 ret &=
fromLegacy<double>( aCfg,
"FpEditorCopperTextSizeH",
"design_settings.copper_text_size_h" );
500 ret &=
fromLegacy<double>( aCfg,
"FpEditorCopperTextSizeV",
"design_settings.copper_text_size_v" );
501 ret &=
fromLegacy<double>( aCfg,
"FpEditorCopperTextThickness",
"design_settings.copper_text_thickness" );
502 ret &=
fromLegacy<bool>( aCfg,
"FpEditorCopperTextItalic",
"design_settings.copper_text_italic" );
503 ret &=
fromLegacy<double>( aCfg,
"FpEditorEdgeCutLineWidth",
"design_settings.edge_line_width" );
504 ret &=
fromLegacy<double>( aCfg,
"FpEditorCourtyardLineWidth",
"design_settings.courtyard_line_width" );
505 ret &=
fromLegacy<double>( aCfg,
"FpEditorOthersLineWidth",
"design_settings.others_line_width" );
506 ret &=
fromLegacy<double>( aCfg,
"FpEditorOthersTextSizeH",
"design_settings.others_text_size_h" );
507 ret &=
fromLegacy<double>( aCfg,
"FpEditorOthersTextSizeV",
"design_settings.others_text_size_v" );
508 ret &=
fromLegacy<double>( aCfg,
"FpEditorOthersTextThickness",
"design_settings.others_text_thickness" );
509 ret &=
fromLegacy<bool>( aCfg,
"FpEditorOthersTextItalic",
"design_settings.others_text_italic" );
511 nlohmann::json textItems = nlohmann::json::array( {
516 Set(
"design_settings.default_footprint_text_items", std::move( textItems ) );
518 ret &=
fromLegacyString( aCfg,
"FpEditorRefDefaultText",
"design_settings.default_footprint_text_items.0.0" );
519 ret &=
fromLegacy<bool>( aCfg,
"FpEditorRefDefaultVisibility",
"design_settings.default_footprint_text_items.0.1" );
520 ret &=
fromLegacy<int>( aCfg,
"FpEditorRefDefaultLayer",
"design_settings.default_footprint_text_items.0.2" );
521 ret &=
fromLegacyString( aCfg,
"FpEditorValueDefaultText",
"design_settings.default_footprint_text_items.1.0" );
522 ret &=
fromLegacy<bool>( aCfg,
"FpEditorValueDefaultVisibility",
"design_settings.default_footprint_text_items.1.1" );
523 ret &=
fromLegacy<int>( aCfg,
"FpEditorValueDefaultLayer",
"design_settings.default_footprint_text_items.1.2" );
526 std::string f =
"ModEdit";
534 cs->
SetName( wxT(
"User (Footprints)" ) );
537 auto migrateLegacyColor = [&] (
const std::string& aKey,
int aLayerId )
541 if( aCfg->Read( aKey, &str ) )
548 migrateLegacyColor( f +
"Color4DPCBLayer_" + layer.ToStdString(),
PCB_LAYER_ID( i ) );
551 migrateLegacyColor( f +
"Color4DAnchorEx",
LAYER_ANCHOR );
553 migrateLegacyColor( f +
"Color4DGrid",
LAYER_GRID );
556 migrateLegacyColor( f +
"Color4DPCBCursor",
LAYER_CURSOR );
566 ( *m_internals )[
m_internals->PointerFromString(
"appearance.color_theme" )] =
"user_footprints";
571 if( aCfg->Read( f +
"PcbUserGrid_X", &x ) && aCfg->Read( f +
"PcbUserGrid_Y", &y ) )
600 wxT(
"Error: FOOTPRINT_EDITOR_SETTINGS migration cannot run unmanaged!" ) );
604 std::string theme_ptr(
"appearance.color_theme" );
609 wxString selected =
At( theme_ptr ).get<wxString>();
610 wxString search = selected + wxT(
"_footprints" );
612 for(
COLOR_SETTINGS* settings :
Pgm().GetSettingsManager().GetColorSettingsList() )
614 if( settings->GetFilename() == search )
616 wxLogTrace(
traceSettings, wxT(
"Updating footprint editor theme from %s to %s" ),
618 Set( theme_ptr, search );
633 auto p(
"/pcb_display/layer_presets"_json_pointer );
640 for( nlohmann::json& entry : presets )
652 auto p(
"/pcb_display/layer_presets"_json_pointer );
659 for( nlohmann::json& entry : presets )
671 auto p(
"/design_settings/default_footprint_text_items"_json_pointer );
680 for( nlohmann::json& entry : defaults )
684 textInfo.
m_Text = entry.at(0).get<wxString>();
685 textInfo.
m_Visible = entry.at(1).get<
bool>();
703 defaults = nlohmann::json::array( {
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
#define DEFAULT_TEXT_WIDTH
#define DEFAULT_COPPER_TEXT_WIDTH
#define DEFAULT_DIMENSION_EXTENSION_OFFSET
#define DEFAULT_DIMENSION_ARROW_LENGTH
#define DEFAULT_SILK_TEXT_SIZE
#define DEFAULT_COPPER_LINE_WIDTH
#define DEFAULT_SILK_LINE_WIDTH
#define DEFAULT_SILK_TEXT_WIDTH
#define DEFAULT_EDGE_WIDTH
#define DEFAULT_COPPER_TEXT_SIZE
#define DEFAULT_LINE_WIDTH
#define DEFAULT_COURTYARD_WIDTH
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 SetName(const wxString &aName)
void SetColor(int aLayer, const COLOR4D &aColor)
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...
SETTINGS_MANAGER * m_manager
A pointer to the settings manager managing this file (may be null)
bool Contains(const std::string &aPath) const
static bool SetIfPresent(const nlohmann::json &aObj, const std::string &aPath, wxString &aTarget)
Sets the given string if the given key/path is present.
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...
std::unique_ptr< JSON_SETTINGS_INTERNALS > m_internals
A color representation with 4 components: red, green, blue, alpha.
static int NameToLayer(wxString &aName)
Return the layer number from a layer name.
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Stores an enum as an integer.
Like a normal param, but with custom getter and setter functions.
static void MigrateToV9Layers(nlohmann::json &aJson)
static void MigrateToNamedRenderLayers(nlohmann::json &aJson)
Represents a map of <std::string, Value>.
Represents a parameter that has a scaling factor between the value in the file and the value used int...
PCB_VIEWERS_SETTINGS_BASE(const std::string &aFilename, int aSchemaVersion)
VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay
void addMatchPropertiesParam()
Opt-in.
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 * AddNewColorSettings(const wxString &aFilename)
Register a new color settings object with the given filename.
#define DEFAULT_TEXT_SIZE
Ratio of the font height to the baseline of the text above the wire.
static constexpr EDA_ANGLE ANGLE_90
#define TEXT_MIN_SIZE_MM
Minimum text size (1 micron).
#define TEXT_MAX_SIZE_MM
Maximum text size in mm (~10 inches)
LEADER_MODE
The kind of the leader line.
@ 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:
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.
@ OUTSIDE
Text appears outside the dimension line (default)
@ INLINE
Text appears in line with the dimension line.
PGM_BASE & Pgm()
The global program "get" accessor.
void AddSnapInferenceParams(std::vector< PARAM_BASE * > &aParams, SNAP_INFERENCE_SETTINGS &aSettings)
Register the snap inference parameters.
static BOM_FMT_PRESET CSV()