40 m_ErcSettings( nullptr ),
41 m_SchematicSettings( nullptr ),
89 [&]() -> nlohmann::json
91 nlohmann::json ret = nlohmann::json::array();
94 ret.push_back( libName );
98 [&](
const nlohmann::json& aJson )
100 if( aJson.empty() || !aJson.is_array() )
105 for(
const nlohmann::json& entry : aJson )
109 m_NetSettings = std::make_shared<NET_SETTINGS>(
this,
"net_settings" );
125 std::set<wxString> group_blacklist;
132 auto loadPinnedLibs =
133 [&](
const std::string& aDest )
136 wxString libKey = wxT(
"PinnedItems" );
139 nlohmann::json libs = nlohmann::json::array();
141 while( aCfg->Read( libKey, &str ) )
143 libs.push_back( str );
145 aCfg->DeleteEntry( libKey,
true );
147 libKey = wxT(
"PinnedItems" );
148 libKey << ++libIndex;
154 aCfg->SetPath( wxT(
"/LibeditFrame" ) );
155 loadPinnedLibs(
"libraries.pinned_symbol_libs" );
157 aCfg->SetPath( wxT(
"/ModEditFrame" ) );
158 loadPinnedLibs(
"libraries.pinned_footprint_libs" );
160 aCfg->SetPath( wxT(
"/cvpcb/equfiles" ) );
164 wxString eqKey = wxT(
"EquName" );
167 nlohmann::json eqs = nlohmann::json::array();
169 while( aCfg->Read( eqKey, &str ) )
171 eqs.push_back( str );
173 eqKey = wxT(
"EquName" );
177 Set(
"cvpcb.equivalence_files", eqs );
181 group_blacklist.insert( wxT(
"/cvpcb" ) );
183 aCfg->SetPath( wxT(
"/eeschema" ) );
186 aCfg->SetPath( wxT(
"/eeschema/libraries" ) );
190 wxString libKey = wxT(
"LibName" );
193 nlohmann::json libs = nlohmann::json::array();
195 while( aCfg->Read( libKey, &str ) )
197 libs.push_back( str );
199 libKey = wxT(
"LibName" );
203 Set(
"schematic.legacy_lib_list", libs );
206 group_blacklist.insert( wxT(
"/eeschema" ) );
208 aCfg->SetPath( wxT(
"/text_variables" ) );
215 nlohmann::json vars = nlohmann::json();
217 while( aCfg->Read( txtKey, &str ) )
219 wxArrayString tokens = wxSplit( str,
':' );
221 if( tokens.size() == 2 )
222 vars[ tokens[0].ToStdString() ] = tokens[1];
228 Set(
"text_variables", vars );
231 group_blacklist.insert( wxT(
"/text_variables" ) );
233 aCfg->SetPath( wxT(
"/schematic_editor" ) );
235 fromLegacyString( aCfg,
"PageLayoutDescrFile",
"schematic.page_layout_descr_file" );
238 fromLegacy<bool>( aCfg,
"SpiceAjustPassiveValues",
"schematic.spice_adjust_passive_values" );
239 fromLegacy<int>( aCfg,
"SubpartIdSeparator",
"schematic.subpart_id_separator" );
240 fromLegacy<int>( aCfg,
"SubpartFirstId",
"schematic.subpart_first_id" );
242 fromLegacy<int>( aCfg,
"LineThickness",
"schematic.drawing.default_line_thickness" );
243 fromLegacy<int>( aCfg,
"WireThickness",
"schematic.drawing.default_wire_thickness" );
244 fromLegacy<int>( aCfg,
"BusThickness",
"schematic.drawing.default_bus_thickness" );
245 fromLegacy<int>( aCfg,
"LabSize",
"schematic.drawing.default_text_size" );
247 if( !fromLegacy<int>( aCfg,
"PinSymbolSize",
"schematic.drawing.pin_symbol_size" ) )
250 Set(
"schematic.drawing.pin_symbol_size", 0 );
253 fromLegacy<int>( aCfg,
"JunctionSize",
"schematic.drawing.default_junction_size" );
255 fromLegacyString( aCfg,
"FieldNameTemplates",
"schematic.drawing.field_names" );
257 if( !fromLegacy<double>( aCfg,
"TextOffsetRatio",
"schematic.drawing.text_offset_ratio" ) )
260 Set(
"schematic.drawing.text_offset_ratio", 0.08 );
261 Set(
"schematic.drawing.label_size_ratio", 0.25 );
265 group_blacklist.insert( wxT(
"/schematic_editor" ) );
267 aCfg->SetPath( wxT(
"/pcbnew" ) );
269 fromLegacyString( aCfg,
"PageLayoutDescrFile",
"pcbnew.page_layout_descr_file" );
274 fromLegacyString( aCfg,
"LastSpecctraDSNExportPath",
"pcbnew.last_paths.specctra_dsn" );
275 fromLegacyString( aCfg,
"LastGenCADExportPath",
"pcbnew.last_paths.gencad" );
277 std::string bp =
"board.design_settings.";
281 wxString key = wxT(
"DRCExclusion" );
284 nlohmann::json exclusions = nlohmann::json::array();
286 while( aCfg->Read( key, &str ) )
288 exclusions.push_back( str );
290 key = wxT(
"DRCExclusion" );
294 Set( bp +
"drc_exclusions", exclusions );
297 fromLegacy<bool>( aCfg,
"AllowMicroVias", bp +
"rules.allow_microvias" );
298 fromLegacy<bool>( aCfg,
"AllowBlindVias", bp +
"rules.allow_blind_buried_vias" );
299 fromLegacy<double>( aCfg,
"MinClearance", bp +
"rules.min_clearance" );
300 fromLegacy<double>( aCfg,
"MinTrackWidth", bp +
"rules.min_track_width" );
301 fromLegacy<double>( aCfg,
"MinViaAnnulus", bp +
"rules.min_via_annulus" );
302 fromLegacy<double>( aCfg,
"MinViaDiameter", bp +
"rules.min_via_diameter" );
304 if( !fromLegacy<double>( aCfg,
"MinThroughDrill", bp +
"rules.min_through_hole_diameter" ) )
305 fromLegacy<double>( aCfg,
"MinViaDrill", bp +
"rules.min_through_hole_diameter" );
307 fromLegacy<double>( aCfg,
"MinMicroViaDiameter", bp +
"rules.min_microvia_diameter" );
308 fromLegacy<double>( aCfg,
"MinMicroViaDrill", bp +
"rules.min_microvia_drill" );
309 fromLegacy<double>( aCfg,
"MinHoleToHole", bp +
"rules.min_hole_to_hole" );
310 fromLegacy<double>( aCfg,
"CopperEdgeClearance", bp +
"rules.min_copper_edge_clearance" );
311 fromLegacy<double>( aCfg,
"SolderMaskClearance", bp +
"rules.solder_mask_clearance" );
312 fromLegacy<double>( aCfg,
"SolderMaskMinWidth", bp +
"rules.solder_mask_min_width" );
313 fromLegacy<double>( aCfg,
"SolderPasteClearance", bp +
"rules.solder_paste_clearance" );
314 fromLegacy<double>( aCfg,
"SolderPasteRatio", bp +
"rules.solder_paste_margin_ratio" );
316 if( !fromLegacy<double>( aCfg,
"SilkLineWidth", bp +
"defaults.silk_line_width" ) )
317 fromLegacy<double>( aCfg,
"ModuleOutlineThickness", bp +
"defaults.silk_line_width" );
319 if( !fromLegacy<double>( aCfg,
"SilkTextSizeV", bp +
"defaults.silk_text_size_v" ) )
320 fromLegacy<double>( aCfg,
"ModuleTextSizeV", bp +
"defaults.silk_text_size_v" );
322 if( !fromLegacy<double>( aCfg,
"SilkTextSizeH", bp +
"defaults.silk_text_size_h" ) )
323 fromLegacy<double>( aCfg,
"ModuleTextSizeH", bp +
"defaults.silk_text_size_h" );
325 if( !fromLegacy<double>( aCfg,
"SilkTextSizeThickness", bp +
"defaults.silk_text_thickness" ) )
326 fromLegacy<double>( aCfg,
"ModuleTextSizeThickness", bp +
"defaults.silk_text_thickness" );
328 fromLegacy<bool>( aCfg,
"SilkTextItalic", bp +
"defaults.silk_text_italic" );
329 fromLegacy<bool>( aCfg,
"SilkTextUpright", bp +
"defaults.silk_text_upright" );
331 if( !fromLegacy<double>( aCfg,
"CopperLineWidth", bp +
"defaults.copper_line_width" ) )
332 fromLegacy<double>( aCfg,
"DrawSegmentWidth", bp +
"defaults.copper_line_width" );
334 if( !fromLegacy<double>( aCfg,
"CopperTextSizeV", bp +
"defaults.copper_text_size_v" ) )
335 fromLegacy<double>( aCfg,
"PcbTextSizeV", bp +
"defaults.copper_text_size_v" );
337 if( !fromLegacy<double>( aCfg,
"CopperTextSizeH", bp +
"defaults.copper_text_size_h" ) )
338 fromLegacy<double>( aCfg,
"PcbTextSizeH", bp +
"defaults.copper_text_size_h" );
340 if( !fromLegacy<double>( aCfg,
"CopperTextThickness", bp +
"defaults.copper_text_thickness" ) )
341 fromLegacy<double>( aCfg,
"PcbTextThickness", bp +
"defaults.copper_text_thickness" );
343 fromLegacy<bool>( aCfg,
"CopperTextItalic", bp +
"defaults.copper_text_italic" );
344 fromLegacy<bool>( aCfg,
"CopperTextUpright", bp +
"defaults.copper_text_upright" );
346 if( !fromLegacy<double>( aCfg,
"EdgeCutLineWidth", bp +
"defaults.board_outline_line_width" ) )
347 fromLegacy<double>( aCfg,
"BoardOutlineThickness", bp +
"defaults.board_outline_line_width" );
349 fromLegacy<double>( aCfg,
"CourtyardLineWidth", bp +
"defaults.courtyard_line_width" );
351 fromLegacy<double>( aCfg,
"FabLineWidth", bp +
"defaults.fab_line_width" );
352 fromLegacy<double>( aCfg,
"FabTextSizeV", bp +
"defaults.fab_text_size_v" );
353 fromLegacy<double>( aCfg,
"FabTextSizeH", bp +
"defaults.fab_text_size_h" );
354 fromLegacy<double>( aCfg,
"FabTextSizeThickness", bp +
"defaults.fab_text_thickness" );
355 fromLegacy<bool>( aCfg,
"FabTextItalic", bp +
"defaults.fab_text_italic" );
356 fromLegacy<bool>( aCfg,
"FabTextUpright", bp +
"defaults.fab_text_upright" );
358 if( !fromLegacy<double>( aCfg,
"OthersLineWidth", bp +
"defaults.other_line_width" ) )
359 fromLegacy<double>( aCfg,
"ModuleOutlineThickness", bp +
"defaults.other_line_width" );
361 fromLegacy<double>( aCfg,
"OthersTextSizeV", bp +
"defaults.other_text_size_v" );
362 fromLegacy<double>( aCfg,
"OthersTextSizeH", bp +
"defaults.other_text_size_h" );
363 fromLegacy<double>( aCfg,
"OthersTextSizeThickness", bp +
"defaults.other_text_thickness" );
364 fromLegacy<bool>( aCfg,
"OthersTextItalic", bp +
"defaults.other_text_italic" );
365 fromLegacy<bool>( aCfg,
"OthersTextUpright", bp +
"defaults.other_text_upright" );
367 fromLegacy<int>( aCfg,
"DimensionUnits", bp +
"defaults.dimension_units" );
368 fromLegacy<int>( aCfg,
"DimensionPrecision", bp +
"defaults.dimension_precision" );
370 std::string sev = bp +
"rule_severities";
372 fromLegacy<bool>( aCfg,
"RequireCourtyardDefinitions", sev +
"legacy_no_courtyard_defined" );
374 fromLegacy<bool>( aCfg,
"ProhibitOverlappingCourtyards", sev +
"legacy_courtyards_overlap" );
378 wxString keyBase =
"TrackWidth";
379 wxString key = keyBase;
382 nlohmann::json widths = nlohmann::json::array();
386 while( aCfg->Read( key, &val ) )
388 widths.push_back( val );
393 Set( bp +
"track_widths", widths );
398 wxString keyBase =
"ViaDiameter";
399 wxString key = keyBase;
403 nlohmann::json vias = nlohmann::json::array();
407 while( aCfg->Read( key, &diameter ) )
410 aCfg->Read( key << idx, &drill );
412 nlohmann::json
via = { {
"diameter", diameter }, {
"drill", drill } };
413 vias.push_back(
via );
419 Set( bp +
"via_dimensions", vias );
424 wxString keyBase =
"dPairWidth";
425 wxString key = keyBase;
428 double via_gap = 1.0;
430 nlohmann::json pairs = nlohmann::json::array();
434 while( aCfg->Read( key, &width ) )
437 aCfg->Read( key << idx, &gap );
440 aCfg->Read( key << idx, &via_gap );
442 nlohmann::json pair = { {
"width", width }, {
"gap", gap }, {
"via_gap", via_gap } };
443 pairs.push_back( pair );
449 Set( bp +
"diff_pair_dimensions", pairs );
452 group_blacklist.insert( wxT(
"/pcbnew" ) );
455 group_blacklist.insert( wxT(
"/general" ) );
458 aCfg->SetPath( wxT(
"/" ) );
460 auto loadSheetNames =
465 nlohmann::json arr = nlohmann::json::array();
469 aCfg->SetPath( wxT(
"/sheetnames" ) );
471 while( aCfg->Read( wxString::Format(
"%d", sheet++ ), &entry ) )
473 wxArrayString tokens = wxSplit( entry,
':' );
475 if( tokens.size() == 2 )
477 wxLogTrace(
traceSettings, wxT(
"%d: %s = %s" ), sheet, tokens[0],
479 arr.push_back( nlohmann::json::array( { tokens[0], tokens[1] } ) );
483 Set(
"sheets", arr );
485 aCfg->SetPath(
"/" );
491 std::vector<wxString> groups;
493 groups.emplace_back( wxEmptyString );
495 auto loadLegacyPairs =
496 [&](
const std::string& aGroup ) ->
bool
498 wxLogTrace(
traceSettings, wxT(
"Migrating group %s" ), aGroup );
505 while( aCfg->GetNextEntry( keyStr, index ) )
507 if( !aCfg->Read( keyStr, &val ) )
510 std::string key( keyStr.ToUTF8() );
516 Set(
"legacy." + aGroup +
"." + key, val );
527 for(
size_t i = 0; i < groups.size(); i++ )
529 aCfg->SetPath( groups[i] );
531 if( groups[i] == wxT(
"/sheetnames" ) )
533 ret |= loadSheetNames();
537 aCfg->DeleteEntry( wxT(
"last_client" ),
true );
538 aCfg->DeleteEntry( wxT(
"update" ),
true );
539 aCfg->DeleteEntry( wxT(
"version" ),
true );
541 ret &= loadLegacyPairs( groups[i].ToStdString() );
545 while( aCfg->GetNextGroup( str, index ) )
547 wxString
group = groups[i] +
"/" + str;
549 if( !group_blacklist.count(
group ) )
550 groups.emplace_back(
group );
553 aCfg->SetPath(
"/" );
573 wxString oldProjectName = oldFilename.GetName();
579 [&]( wxString& aPath )
581 if( aPath.StartsWith( oldProjectName + wxS(
"." ) ) )
582 aPath.Replace( oldProjectName, aFile,
false );
613 aJson = nlohmann::json::array( { aPair.first.AsString().ToUTF8(), aPair.second.ToUTF8() } );
619 wxCHECK( aJson.is_array() && aJson.size() == 2, );
620 aPair.first =
KIID( wxString( aJson[0].get<std::string>().c_str(), wxConvUTF8 ) );
621 aPair.second = wxString( aJson[1].get<std::string>().c_str(), wxConvUTF8 );
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 SetReadOnly(bool aReadOnly)
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
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...
bool m_deleteLegacyAfterMigration
Whether or not to delete legacy file after migration.
void SetFilename(const wxString &aFilename)
virtual bool SaveToFile(const wxString &aDirectory="", bool aForce=false)
wxString GetFilename() const
Like a normal param, but with custom getter and setter functions.
Represents a list of strings holding directory paths.
Stores a path as a string with directory separators normalized to unix-style.
A helper for <wxString, wxString> maps.
std::map< wxString, wxString > m_TextVars
wxString getFileExt() const override
wxString m_BoardDrawingSheetFile
PcbNew params.
std::shared_ptr< NET_SETTINGS > m_NetSettings
Net settings for this project (owned here)
wxString m_PcbLastPath[LAST_PATH_SIZE]
MRU path storage.
PROJECT * m_project
A link to the owning PROJECT.
std::vector< VIEWPORT > m_Viewports
List of stored layer presets.
bool SaveAs(const wxString &aDirectory, const wxString &aFile)
std::vector< wxString > m_EquivalenceFiles
CvPcb params.
wxString getLegacyFileExt() const override
std::vector< wxString > m_PinnedFootprintLibs
The list of pinned footprint libraries.
std::vector< FILE_INFO_PAIR > m_sheets
List of stored 3D viewports (view matrixes)
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
std::vector< LAYER_PRESET > m_LayerPresets
std::vector< FILE_INFO_PAIR > m_boards
A list of board files in this project.
wxArrayString m_LegacyLibNames
std::vector< wxString > m_PinnedSymbolLibs
Below are project-level settings that have not been moved to a dedicated file.
std::vector< VIEWPORT3D > m_Viewports3D
List of stored viewports (pos + zoom)
bool SaveToFile(const wxString &aDirectory="", bool aForce=false) override
PROJECT_FILE(const wxString &aFullPath)
Construct the project file for a project.
Container for project specific data.
virtual const wxString GetProjectName() const
Return the short name of the project.
const std::string LegacyProjectFileExtension
const std::string ProjectFileExtension
const wxChar *const traceSettings
Flag to enable debug output of settings operations and management.
void to_json(nlohmann::json &aJson, const FILE_INFO_PAIR &aPair)
void from_json(const nlohmann::json &aJson, FILE_INFO_PAIR &aPair)
const int projectFileSchemaVersion
! Update the schema version whenever a migration is required
std::pair< KIID, wxString > FILE_INFO_PAIR
For files like sheets and boards, a pair of that object KIID and display name Display name is typical...
Definition of file extensions used in Kicad.