45 m_DesignSettings( nullptr,
"fpedit.settings" ),
49 m_PolarCoords( false ),
50 m_DisplayInvertXAxis( false ),
51 m_DisplayInvertYAxis( false ),
57 m_FootprintTextShownColumns()
112 static_cast<int>( MAGNETIC_OPTIONS::CAPTURE_ALWAYS ) ) );
150 "design_settings.default_footprint_text_items",
151 [&] () -> nlohmann::json
153 nlohmann::json js = nlohmann::json::array();
157 js.push_back( nlohmann::json( { item.
m_Text.ToUTF8(),
164 [&] (
const nlohmann::json& aObj )
168 if( !aObj.is_array() )
171 for(
const nlohmann::json& entry : aObj )
173 if( entry.empty() || !entry.is_array() )
178 textInfo.
m_Text = entry.at(0).get<wxString>();
179 textInfo.
m_Visible = entry.at(1).get<
bool>();
180 wxString layerName = entry.at(2).get<wxString>();
182 textInfo.
m_Layer = candidateLayer >= 0
189 nlohmann::json::array( {
207 m_params.emplace_back(
new PARAM_SCALED<int>(
"design_settings.silk_text_size_h",
211 m_params.emplace_back(
new PARAM_SCALED<int>(
"design_settings.silk_text_size_v",
215 m_params.emplace_back(
new PARAM_SCALED<int>(
"design_settings.silk_text_thickness",
219 m_params.emplace_back(
new PARAM<bool>(
"design_settings.silk_text_italic",
222 m_params.emplace_back(
new PARAM_SCALED<int>(
"design_settings.copper_line_width",
226 m_params.emplace_back(
new PARAM_SCALED<int>(
"design_settings.copper_text_size_h",
230 m_params.emplace_back(
new PARAM_SCALED<int>(
"design_settings.copper_text_size_v",
234 m_params.emplace_back(
new PARAM_SCALED<int>(
"design_settings.copper_text_thickness",
238 m_params.emplace_back(
new PARAM<bool>(
"design_settings.copper_text_italic",
245 m_params.emplace_back(
new PARAM_SCALED<int>(
"design_settings.courtyard_line_width",
261 m_params.emplace_back(
new PARAM_SCALED<int>(
"design_settings.fab_text_thickness",
265 m_params.emplace_back(
new PARAM<bool>(
"design_settings.fab_text_italic",
268 m_params.emplace_back(
new PARAM_SCALED<int>(
"design_settings.others_line_width",
272 m_params.emplace_back(
new PARAM_SCALED<int>(
"design_settings.others_text_size_h",
276 m_params.emplace_back(
new PARAM_SCALED<int>(
"design_settings.others_text_size_v",
280 m_params.emplace_back(
new PARAM_SCALED<int>(
"design_settings.others_text_thickness",
284 m_params.emplace_back(
new PARAM<bool>(
"design_settings.others_text_italic",
302 m_params.emplace_back(
new PARAM<bool>(
"design_settings.dimensions.suppress_zeroes",
303 &m_DesignSettings.m_DimensionSuppressZeroes,
true ) );
310 m_params.emplace_back(
new PARAM<bool>(
"design_settings.dimensions.keep_text_aligned",
311 &m_DesignSettings.m_DimensionKeepTextAligned,
true ) );
313 m_params.emplace_back(
new PARAM<int>(
"design_settings.dimensions.arrow_length",
314 &m_DesignSettings.m_DimensionArrowLength,
317 m_params.emplace_back(
new PARAM<int>(
"design_settings.dimensions.extension_offset",
318 &m_DesignSettings.m_DimensionExtensionOffset,
324 [&]() -> nlohmann::json
328 ret[
"lockedItems"] = m_SelectionFilter.lockedItems;
329 ret[
"footprints"] = m_SelectionFilter.footprints;
330 ret[
"text"] = m_SelectionFilter.text;
331 ret[
"tracks"] = m_SelectionFilter.tracks;
332 ret[
"vias"] = m_SelectionFilter.vias;
333 ret[
"pads"] = m_SelectionFilter.pads;
334 ret[
"graphics"] = m_SelectionFilter.graphics;
335 ret[
"zones"] = m_SelectionFilter.zones;
336 ret[
"keepouts"] = m_SelectionFilter.keepouts;
337 ret[
"dimensions"] = m_SelectionFilter.dimensions;
338 ret[
"otherItems"] = m_SelectionFilter.otherItems;
342 [&](
const nlohmann::json& aVal )
344 if( aVal.empty() || !aVal.is_object() )
347 SetIfPresent( aVal,
"lockedItems", m_SelectionFilter.lockedItems );
348 SetIfPresent( aVal,
"footprints", m_SelectionFilter.footprints );
349 SetIfPresent( aVal,
"text", m_SelectionFilter.text );
350 SetIfPresent( aVal,
"tracks", m_SelectionFilter.tracks );
351 SetIfPresent( aVal,
"vias", m_SelectionFilter.vias );
352 SetIfPresent( aVal,
"pads", m_SelectionFilter.pads );
353 SetIfPresent( aVal,
"graphics", m_SelectionFilter.graphics );
354 SetIfPresent( aVal,
"zones", m_SelectionFilter.zones );
355 SetIfPresent( aVal,
"keepouts", m_SelectionFilter.keepouts );
356 SetIfPresent( aVal,
"dimensions", m_SelectionFilter.dimensions );
357 SetIfPresent( aVal,
"otherItems", m_SelectionFilter.otherItems );
360 {
"lockedItems",
false },
361 {
"footprints",
true },
366 {
"graphics",
true },
368 {
"keepouts",
true },
369 {
"dimensions",
true },
370 {
"otherItems",
true }
375 registerMigration( 1, 2,
379 return migrateLibTreeWidth();
395 ret &= fromLegacy<int>( aCfg,
"ModeditLibWidth",
"window.lib_width" );
396 ret &=
fromLegacyString( aCfg,
"import_last_path",
"system.last_import_export_path" );
397 ret &=
fromLegacyString( aCfg,
"LibFootprintTextShownColumns",
"window.footprint_text_shown_columns" );
399 ret &= fromLegacy<int>( aCfg,
"FpEditorMagneticPads",
"editing.magnetic_pads" );
400 ret &= fromLegacy<bool>( aCfg,
"FpEditorDisplayPolarCoords",
"editing.polar_coords" );
401 ret &= fromLegacy<int>( aCfg,
"FpEditorUse45DegreeGraphicSegments",
"editing.use_45_degree_graphic_segments" );
403 ret &= fromLegacy<bool>( aCfg,
"FpEditorGraphicLinesDisplayMode",
"pcb_display.graphic_items_fill" );
404 ret &= fromLegacy<bool>( aCfg,
"FpEditorPadDisplayMode",
"pcb_display.pad_fill" );
405 ret &= fromLegacy<bool>( aCfg,
"FpEditorTextsDisplayMode",
"pcb_display.footprint_text" );
407 ret &= fromLegacy<double>( aCfg,
"FpEditorSilkLineWidth",
"design_settings.silk_line_width" );
408 ret &= fromLegacy<double>( aCfg,
"FpEditorSilkTextSizeH",
"design_settings.silk_text_size_h" );
409 ret &= fromLegacy<double>( aCfg,
"FpEditorSilkTextSizeV",
"design_settings.silk_text_size_v" );
410 ret &= fromLegacy<double>( aCfg,
"FpEditorSilkTextThickness",
"design_settings.silk_text_thickness" );
411 ret &= fromLegacy<bool>( aCfg,
"FpEditorSilkTextItalic",
"design_settings.silk_text_italic" );
412 ret &= fromLegacy<double>( aCfg,
"FpEditorCopperLineWidth",
"design_settings.copper_line_width" );
413 ret &= fromLegacy<double>( aCfg,
"FpEditorCopperTextSizeH",
"design_settings.copper_text_size_h" );
414 ret &= fromLegacy<double>( aCfg,
"FpEditorCopperTextSizeV",
"design_settings.copper_text_size_v" );
415 ret &= fromLegacy<double>( aCfg,
"FpEditorCopperTextThickness",
"design_settings.copper_text_thickness" );
416 ret &= fromLegacy<bool>( aCfg,
"FpEditorCopperTextItalic",
"design_settings.copper_text_italic" );
417 ret &= fromLegacy<double>( aCfg,
"FpEditorEdgeCutLineWidth",
"design_settings.edge_line_width" );
418 ret &= fromLegacy<double>( aCfg,
"FpEditorCourtyardLineWidth",
"design_settings.courtyard_line_width" );
419 ret &= fromLegacy<double>( aCfg,
"FpEditorOthersLineWidth",
"design_settings.others_line_width" );
420 ret &= fromLegacy<double>( aCfg,
"FpEditorOthersTextSizeH",
"design_settings.others_text_size_h" );
421 ret &= fromLegacy<double>( aCfg,
"FpEditorOthersTextSizeV",
"design_settings.others_text_size_v" );
422 ret &= fromLegacy<double>( aCfg,
"FpEditorOthersTextThickness",
"design_settings.others_text_thickness" );
423 ret &= fromLegacy<bool>( aCfg,
"FpEditorOthersTextItalic",
"design_settings.others_text_italic" );
425 nlohmann::json textItems = nlohmann::json::array( {
430 Set(
"design_settings.default_footprint_text_items", std::move( textItems ) );
432 ret &=
fromLegacyString( aCfg,
"FpEditorRefDefaultText",
"design_settings.default_footprint_text_items.0.0" );
433 ret &= fromLegacy<bool>( aCfg,
"FpEditorRefDefaultVisibility",
"design_settings.default_footprint_text_items.0.1" );
434 ret &= fromLegacy<int>( aCfg,
"FpEditorRefDefaultLayer",
"design_settings.default_footprint_text_items.0.2" );
435 ret &=
fromLegacyString( aCfg,
"FpEditorValueDefaultText",
"design_settings.default_footprint_text_items.1.0" );
436 ret &= fromLegacy<bool>( aCfg,
"FpEditorValueDefaultVisibility",
"design_settings.default_footprint_text_items.1.1" );
437 ret &= fromLegacy<int>( aCfg,
"FpEditorValueDefaultLayer",
"design_settings.default_footprint_text_items.1.2" );
440 std::string f =
"ModEdit";
448 cs->
SetName( wxT(
"User (Footprints)" ) );
451 auto migrateLegacyColor = [&] (
const std::string& aKey,
int aLayerId )
455 if( aCfg->Read( aKey, &str ) )
462 migrateLegacyColor( f +
"Color4DPCBLayer_" + layer.ToStdString(),
PCB_LAYER_ID( i ) );
465 migrateLegacyColor( f +
"Color4DAnchorEx",
LAYER_ANCHOR );
467 migrateLegacyColor( f +
"Color4DGrid",
LAYER_GRID );
470 migrateLegacyColor( f +
"Color4DPCBCursor",
LAYER_CURSOR );
479 ( *m_internals )[
m_internals->PointerFromString(
"appearance.color_theme" )] =
"user_footprints";
484 if( aCfg->Read( f +
"PcbUserGrid_X", &x ) && aCfg->Read( f +
"PcbUserGrid_Y", &y ) )
487 static_cast<long>( EDA_UNITS::INCHES ) ) );
513 wxT(
"Error: FOOTPRINT_EDITOR_SETTINGS migration cannot run unmanaged!" ) );
517 std::string theme_ptr(
"appearance.color_theme" );
522 wxString selected =
At( theme_ptr ).get<wxString>();
523 wxString search = selected + wxT(
"_footprints" );
527 if( settings->GetFilename() == search )
529 wxLogTrace(
traceSettings, wxT(
"Updating footprint editor theme from %s to %s" ),
531 Set( theme_ptr, search );
546 auto p(
"/pcb_display/layer_presets"_json_pointer );
553 for( nlohmann::json& entry : presets )
565 auto p(
"/pcb_display/layer_presets"_json_pointer );
572 for( nlohmann::json& entry : presets )
584 auto p(
"/design_settings/default_footprint_text_items"_json_pointer );
593 for( nlohmann::json& entry : defaults )
597 textInfo.
m_Text = entry.at(0).get<wxString>();
598 textInfo.
m_Visible = entry.at(1).get<
bool>();
616 defaults = nlohmann::json::array( {
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_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.
std::vector< TEXT_ITEM_INFO > m_DefaultFPTextItems
std::map< std::string, wxString > m_UserLayerNames
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.
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
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
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...
VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay
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)
@ 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.
@ OUTSIDE
Text appears outside the dimension line (default)
@ INLINE
Text appears in line with the dimension line.
SETTINGS_MANAGER * GetSettingsManager()
PGM_BASE & Pgm()
The global program "get" accessor.
constexpr int MilsToIU(int mils) const
constexpr int mmToIU(double mm) const
bool m_DisplayGraphicsFill