42 m_DesignSettings( nullptr,
"fpedit.settings" ),
46 m_PolarCoords( false ),
51 m_LastImportExportPath(),
52 m_FootprintTextShownColumns()
94 static_cast<int>( MAGNETIC_OPTIONS::CAPTURE_ALWAYS ) ) );
123 "design_settings.default_footprint_text_items",
124 [&] () -> nlohmann::json
126 nlohmann::json js = nlohmann::json::array();
130 js.push_back( nlohmann::json( { item.
m_Text.ToUTF8(),
137 [&] (
const nlohmann::json& aObj )
141 if( !aObj.is_array() )
144 for(
const nlohmann::json& entry : aObj )
146 if( entry.empty() || !entry.is_array() )
151 textInfo.
m_Text = entry.at(0).get<wxString>();
152 textInfo.
m_Visible = entry.at(1).get<
bool>();
153 textInfo.
m_Layer = entry.at(2).get<
int>();
158 nlohmann::json::array( {
161 {
"${REFERENCE}",
true,
F_Fab }
258 [&]() -> nlohmann::json
276 [&](
const nlohmann::json& aVal )
278 if( aVal.empty() || !aVal.is_object() )
294 {
"lockedItems",
false },
295 {
"footprints",
true },
300 {
"graphics",
true },
302 {
"keepouts",
true },
303 {
"dimensions",
true },
304 {
"otherItems",
true }
325 ret &= fromLegacy<int>( aCfg,
"ModeditLibWidth",
"window.lib_width" );
326 ret &=
fromLegacyString( aCfg,
"import_last_path",
"system.last_import_export_path" );
327 ret &=
fromLegacyString( aCfg,
"LibFootprintTextShownColumns",
"window.footprint_text_shown_columns" );
329 ret &= fromLegacy<int>( aCfg,
"FpEditorMagneticPads",
"editing.magnetic_pads" );
330 ret &= fromLegacy<bool>( aCfg,
"FpEditorDisplayPolarCoords",
"editing.polar_coords" );
331 ret &= fromLegacy<int>( aCfg,
"FpEditorUse45DegreeGraphicSegments",
"editing.use_45_degree_graphic_segments" );
333 ret &= fromLegacy<bool>( aCfg,
"FpEditorGraphicLinesDisplayMode",
"pcb_display.graphic_items_fill" );
334 ret &= fromLegacy<bool>( aCfg,
"FpEditorPadDisplayMode",
"pcb_display.pad_fill" );
335 ret &= fromLegacy<bool>( aCfg,
"FpEditorTextsDisplayMode",
"pcb_display.footprint_text" );
337 ret &= fromLegacy<double>( aCfg,
"FpEditorSilkLineWidth",
"design_settings.silk_line_width" );
338 ret &= fromLegacy<double>( aCfg,
"FpEditorSilkTextSizeH",
"design_settings.silk_text_size_h" );
339 ret &= fromLegacy<double>( aCfg,
"FpEditorSilkTextSizeV",
"design_settings.silk_text_size_v" );
340 ret &= fromLegacy<double>( aCfg,
"FpEditorSilkTextThickness",
"design_settings.silk_text_thickness" );
341 ret &= fromLegacy<bool>( aCfg,
"FpEditorSilkTextItalic",
"design_settings.silk_text_italic" );
342 ret &= fromLegacy<double>( aCfg,
"FpEditorCopperLineWidth",
"design_settings.copper_line_width" );
343 ret &= fromLegacy<double>( aCfg,
"FpEditorCopperTextSizeH",
"design_settings.copper_text_size_h" );
344 ret &= fromLegacy<double>( aCfg,
"FpEditorCopperTextSizeV",
"design_settings.copper_text_size_v" );
345 ret &= fromLegacy<double>( aCfg,
"FpEditorCopperTextThickness",
"design_settings.copper_text_thickness" );
346 ret &= fromLegacy<bool>( aCfg,
"FpEditorCopperTextItalic",
"design_settings.copper_text_italic" );
347 ret &= fromLegacy<double>( aCfg,
"FpEditorEdgeCutLineWidth",
"design_settings.edge_line_width" );
348 ret &= fromLegacy<double>( aCfg,
"FpEditorCourtyardLineWidth",
"design_settings.courtyard_line_width" );
349 ret &= fromLegacy<double>( aCfg,
"FpEditorOthersLineWidth",
"design_settings.others_line_width" );
350 ret &= fromLegacy<double>( aCfg,
"FpEditorOthersTextSizeH",
"design_settings.others_text_size_h" );
351 ret &= fromLegacy<double>( aCfg,
"FpEditorOthersTextSizeV",
"design_settings.others_text_size_v" );
352 ret &= fromLegacy<double>( aCfg,
"FpEditorOthersTextThickness",
"design_settings.others_text_thickness" );
353 ret &= fromLegacy<bool>( aCfg,
"FpEditorOthersTextItalic",
"design_settings.others_text_italic" );
355 nlohmann::json textItems = nlohmann::json::array( {
360 Set(
"design_settings.default_footprint_text_items", textItems );
362 ret &=
fromLegacyString( aCfg,
"FpEditorRefDefaultText",
"design_settings.default_footprint_text_items.0.0" );
363 ret &= fromLegacy<bool>( aCfg,
"FpEditorRefDefaultVisibility",
"design_settings.default_footprint_text_items.0.1" );
364 ret &= fromLegacy<int>( aCfg,
"FpEditorRefDefaultLayer",
"design_settings.default_footprint_text_items.0.2" );
365 ret &=
fromLegacyString( aCfg,
"FpEditorValueDefaultText",
"design_settings.default_footprint_text_items.1.0" );
366 ret &= fromLegacy<bool>( aCfg,
"FpEditorValueDefaultVisibility",
"design_settings.default_footprint_text_items.1.1" );
367 ret &= fromLegacy<int>( aCfg,
"FpEditorValueDefaultLayer",
"design_settings.default_footprint_text_items.1.2" );
370 std::string f =
"ModEdit";
378 cs->
SetName( wxT(
"User (Footprints)" ) );
381 auto migrateLegacyColor = [&] (
const std::string& aKey,
int aLayerId )
385 if( aCfg->Read( aKey, &str ) )
392 migrateLegacyColor( f +
"Color4DPCBLayer_" + layer.ToStdString(),
PCB_LAYER_ID( i ) );
395 migrateLegacyColor( f +
"Color4DAnchorEx",
LAYER_ANCHOR );
397 migrateLegacyColor( f +
"Color4DGrid",
LAYER_GRID );
399 migrateLegacyColor( f +
"Color4DPadThruHoleEx",
LAYER_PADS_TH );
401 migrateLegacyColor( f +
"Color4DPCBCursor",
LAYER_CURSOR );
411 ( *m_internals )[
m_internals->PointerFromString(
"appearance.color_theme" )] =
"user_footprints";
416 if( aCfg->Read( f +
"PcbUserGrid_X", &x ) && aCfg->Read( f +
"PcbUserGrid_Y", &y ) )
419 static_cast<long>( EDA_UNITS::INCHES ) ) );
445 wxT(
"Error: FOOTPRINT_EDITOR_SETTINGS migration cannot run unmanaged!" ) );
449 std::string theme_ptr(
"appearance.color_theme" );
454 wxString selected =
At( theme_ptr ).get<wxString>();
455 wxString search = selected + wxT(
"_footprints" );
459 if( settings->GetFilename() == search )
461 wxLogTrace(
traceSettings, wxT(
"Updating footprint editor theme from %s to %s" ),
463 Set( theme_ptr, search );
ARC_EDIT_MODE
Settings for arc editing.
@ KEEP_CENTER_ADJUST_ANGLE_RADIUS
constexpr EDA_IU_SCALE pcbIUScale
#define DEFAULT_TEXT_WIDTH
#define DEFAULT_COPPER_TEXT_WIDTH
#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
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
bool migrateLibTreeWidth()
Migrates the library tree width setting from a single column (Item) to multi-column.
std::vector< TEXT_ITEM_INFO > m_DefaultFPTextItems
int m_TextThickness[LAYER_CLASS_COUNT]
int m_LineThickness[LAYER_CLASS_COUNT]
VECTOR2I m_TextSize[LAYER_CLASS_COUNT]
bool m_TextItalic[LAYER_CLASS_COUNT]
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)
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.
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...
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...
std::unique_ptr< JSON_SETTINGS_INTERNALS > m_internals
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.
Represents a parameter that has a scaling factor between the value in the file and the value used int...
void SaveColorSettings(COLOR_SETTINGS *aSettings, const std::string &aNamespace="")
Safely saves a COLOR_SETTINGS to disk, preserving any changes outside the given namespace.
COLOR_SETTINGS * AddNewColorSettings(const wxString &aFilename)
Registers 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
const wxChar *const traceSettings
Flag to enable debug output of settings operations and management.
@ LAYER_MOD_TEXT_INVISIBLE
text marked as invisible
@ 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.
#define TEXTS_MAX_SIZE
Maximum text size in internal units (10 inches)
#define TEXTS_MIN_SIZE
Minimum text size in internal units (1 mil)
#define TEXTS_MAX_WIDTH
Maximum text width in internal units (10 inches)
SETTINGS_MANAGER * GetSettingsManager()
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
constexpr int mmToIU(double mm) const
bool graphics
Graphic lines, shapes, polygons.
bool text
Text (free or attached to a footprint)
bool vias
Vias (all types>
bool lockedItems
Allow selecting locked items.
bool tracks
Copper tracks.
bool footprints
Allow selecting entire footprints.
bool keepouts
Keepout zones.
bool dimensions
Dimension items.
bool otherItems
Anything not fitting one of the above categories.
Functions to provide common constants and other functions to assist in making a consistent UI.