28 #include <wx/config.h> 41 m_ErcSettings( nullptr ),
42 m_SchematicSettings( nullptr ),
92 ret.push_back( libName );
98 if( aJson.empty() || !aJson.is_array() )
107 m_NetSettings = std::make_shared<NET_SETTINGS>(
this,
"net_settings" );
119 std::set<wxString> group_blacklist;
126 auto loadPinnedLibs =
127 [&](
const std::string& aDest )
130 wxString libKey = wxT(
"PinnedItems" );
135 while( aCfg->Read( libKey, &str ) )
137 libs.push_back( str );
139 aCfg->DeleteEntry( libKey,
true );
141 libKey = wxT(
"PinnedItems" );
142 libKey << ++libIndex;
148 aCfg->SetPath( wxT(
"/LibeditFrame" ) );
149 loadPinnedLibs(
"libraries.pinned_symbol_libs" );
151 aCfg->SetPath( wxT(
"/ModEditFrame" ) );
152 loadPinnedLibs(
"libraries.pinned_footprint_libs" );
154 aCfg->SetPath( wxT(
"/cvpcb/equfiles" ) );
158 wxString eqKey = wxT(
"EquName" );
163 while( aCfg->Read( eqKey, &str ) )
165 eqs.push_back( str );
167 eqKey = wxT(
"EquName" );
175 group_blacklist.insert( wxT(
"/cvpcb" ) );
177 aCfg->SetPath( wxT(
"/eeschema" ) );
180 aCfg->SetPath( wxT(
"/eeschema/libraries" ) );
184 wxString libKey = wxT(
"LibName" );
189 while( aCfg->Read( libKey, &str ) )
191 libs.push_back( str );
193 libKey = wxT(
"LibName" );
200 group_blacklist.insert( wxT(
"/eeschema" ) );
202 aCfg->SetPath( wxT(
"/text_variables" ) );
211 while( aCfg->Read( txtKey, &str ) )
213 wxArrayString tokens = wxSplit( str,
':' );
215 if( tokens.size() == 2 )
216 vars[ tokens[0].ToStdString() ] = tokens[1];
225 group_blacklist.insert( wxT(
"/text_variables" ) );
227 aCfg->SetPath( wxT(
"/schematic_editor" ) );
229 fromLegacyString( aCfg,
"PageLayoutDescrFile",
"schematic.page_layout_descr_file" );
232 fromLegacy<bool>( aCfg,
"SpiceAjustPassiveValues",
"schematic.spice_adjust_passive_values" );
233 fromLegacy<int>( aCfg,
"SubpartIdSeparator",
"schematic.subpart_id_separator" );
234 fromLegacy<int>( aCfg,
"SubpartFirstId",
"schematic.subpart_first_id" );
236 fromLegacy<int>( aCfg,
"LineThickness",
"schematic.drawing.default_line_thickness" );
237 fromLegacy<int>( aCfg,
"WireThickness",
"schematic.drawing.default_wire_thickness" );
238 fromLegacy<int>( aCfg,
"BusThickness",
"schematic.drawing.default_bus_thickness" );
239 fromLegacy<int>( aCfg,
"LabSize",
"schematic.drawing.default_text_size" );
240 fromLegacy<int>( aCfg,
"PinSymbolSize",
"schematic.drawing.pin_symbol_size" );
241 fromLegacy<int>( aCfg,
"JunctionSize",
"schematic.drawing.default_junction_size" );
243 fromLegacyString( aCfg,
"FieldNameTemplates",
"schematic.drawing.field_names" );
244 fromLegacy<double>( aCfg,
"TextOffsetRatio",
"schematic.drawing.text_offset_ratio" );
247 group_blacklist.insert( wxT(
"/schematic_editor" ) );
249 aCfg->SetPath( wxT(
"/pcbnew" ) );
251 fromLegacyString( aCfg,
"PageLayoutDescrFile",
"pcbnew.page_layout_descr_file" );
256 fromLegacyString( aCfg,
"LastSpecctraDSNExportPath",
"pcbnew.last_paths.specctra_dsn" );
257 fromLegacyString( aCfg,
"LastGenCADExportPath",
"pcbnew.last_paths.gencad" );
259 std::string bp =
"board.design_settings.";
263 wxString key = wxT(
"DRCExclusion" );
268 while( aCfg->Read( key, &str ) )
270 exclusions.push_back( str );
272 key = wxT(
"DRCExclusion" );
279 fromLegacy<bool>( aCfg,
"AllowMicroVias", bp +
"rules.allow_microvias" );
280 fromLegacy<bool>( aCfg,
"AllowBlindVias", bp +
"rules.allow_blind_buried_vias" );
281 fromLegacy<double>( aCfg,
"MinClearance", bp +
"rules.min_clearance" );
282 fromLegacy<double>( aCfg,
"MinTrackWidth", bp +
"rules.min_track_width" );
283 fromLegacy<double>( aCfg,
"MinViaAnnulus", bp +
"rules.min_via_annulus" );
284 fromLegacy<double>( aCfg,
"MinViaDiameter", bp +
"rules.min_via_diameter" );
286 if( !fromLegacy<double>( aCfg,
"MinThroughDrill", bp +
"rules.min_through_hole_diameter" ) )
287 fromLegacy<double>( aCfg,
"MinViaDrill", bp +
"rules.min_through_hole_diameter" );
289 fromLegacy<double>( aCfg,
"MinMicroViaDiameter", bp +
"rules.min_microvia_diameter" );
290 fromLegacy<double>( aCfg,
"MinMicroViaDrill", bp +
"rules.min_microvia_drill" );
291 fromLegacy<double>( aCfg,
"MinHoleToHole", bp +
"rules.min_hole_to_hole" );
292 fromLegacy<double>( aCfg,
"CopperEdgeClearance", bp +
"rules.min_copper_edge_clearance" );
293 fromLegacy<double>( aCfg,
"SolderMaskClearance", bp +
"rules.solder_mask_clearance" );
294 fromLegacy<double>( aCfg,
"SolderMaskMinWidth", bp +
"rules.solder_mask_min_width" );
295 fromLegacy<double>( aCfg,
"SolderPasteClearance", bp +
"rules.solder_paste_clearance" );
296 fromLegacy<double>( aCfg,
"SolderPasteRatio", bp +
"rules.solder_paste_margin_ratio" );
298 if( !fromLegacy<double>( aCfg,
"SilkLineWidth", bp +
"defaults.silk_line_width" ) )
299 fromLegacy<double>( aCfg,
"ModuleOutlineThickness", bp +
"defaults.silk_line_width" );
301 if( !fromLegacy<double>( aCfg,
"SilkTextSizeV", bp +
"defaults.silk_text_size_v" ) )
302 fromLegacy<double>( aCfg,
"ModuleTextSizeV", bp +
"defaults.silk_text_size_v" );
304 if( !fromLegacy<double>( aCfg,
"SilkTextSizeH", bp +
"defaults.silk_text_size_h" ) )
305 fromLegacy<double>( aCfg,
"ModuleTextSizeH", bp +
"defaults.silk_text_size_h" );
307 if( !fromLegacy<double>( aCfg,
"SilkTextSizeThickness", bp +
"defaults.silk_text_thickness" ) )
308 fromLegacy<double>( aCfg,
"ModuleTextSizeThickness", bp +
"defaults.silk_text_thickness" );
310 fromLegacy<bool>( aCfg,
"SilkTextItalic", bp +
"defaults.silk_text_italic" );
311 fromLegacy<bool>( aCfg,
"SilkTextUpright", bp +
"defaults.silk_text_upright" );
313 if( !fromLegacy<double>( aCfg,
"CopperLineWidth", bp +
"defaults.copper_line_width" ) )
314 fromLegacy<double>( aCfg,
"DrawSegmentWidth", bp +
"defaults.copper_line_width" );
316 if( !fromLegacy<double>( aCfg,
"CopperTextSizeV", bp +
"defaults.copper_text_size_v" ) )
317 fromLegacy<double>( aCfg,
"PcbTextSizeV", bp +
"defaults.copper_text_size_v" );
319 if( !fromLegacy<double>( aCfg,
"CopperTextSizeH", bp +
"defaults.copper_text_size_h" ) )
320 fromLegacy<double>( aCfg,
"PcbTextSizeH", bp +
"defaults.copper_text_size_h" );
322 if( !fromLegacy<double>( aCfg,
"CopperTextThickness", bp +
"defaults.copper_text_thickness" ) )
323 fromLegacy<double>( aCfg,
"PcbTextThickness", bp +
"defaults.copper_text_thickness" );
325 fromLegacy<bool>( aCfg,
"CopperTextItalic", bp +
"defaults.copper_text_italic" );
326 fromLegacy<bool>( aCfg,
"CopperTextUpright", bp +
"defaults.copper_text_upright" );
328 if( !fromLegacy<double>( aCfg,
"EdgeCutLineWidth", bp +
"defaults.board_outline_line_width" ) )
329 fromLegacy<double>( aCfg,
"BoardOutlineThickness", bp +
"defaults.board_outline_line_width" );
331 fromLegacy<double>( aCfg,
"CourtyardLineWidth", bp +
"defaults.courtyard_line_width" );
333 fromLegacy<double>( aCfg,
"FabLineWidth", bp +
"defaults.fab_line_width" );
334 fromLegacy<double>( aCfg,
"FabTextSizeV", bp +
"defaults.fab_text_size_v" );
335 fromLegacy<double>( aCfg,
"FabTextSizeH", bp +
"defaults.fab_text_size_h" );
336 fromLegacy<double>( aCfg,
"FabTextSizeThickness", bp +
"defaults.fab_text_thickness" );
337 fromLegacy<bool>( aCfg,
"FabTextItalic", bp +
"defaults.fab_text_italic" );
338 fromLegacy<bool>( aCfg,
"FabTextUpright", bp +
"defaults.fab_text_upright" );
340 if( !fromLegacy<double>( aCfg,
"OthersLineWidth", bp +
"defaults.other_line_width" ) )
341 fromLegacy<double>( aCfg,
"ModuleOutlineThickness", bp +
"defaults.other_line_width" );
343 fromLegacy<double>( aCfg,
"OthersTextSizeV", bp +
"defaults.other_text_size_v" );
344 fromLegacy<double>( aCfg,
"OthersTextSizeH", bp +
"defaults.other_text_size_h" );
345 fromLegacy<double>( aCfg,
"OthersTextSizeThickness", bp +
"defaults.other_text_thickness" );
346 fromLegacy<bool>( aCfg,
"OthersTextItalic", bp +
"defaults.other_text_italic" );
347 fromLegacy<bool>( aCfg,
"OthersTextUpright", bp +
"defaults.other_text_upright" );
349 fromLegacy<int>( aCfg,
"DimensionUnits", bp +
"defaults.dimension_units" );
350 fromLegacy<int>( aCfg,
"DimensionPrecision", bp +
"defaults.dimension_precision" );
352 std::string sev = bp +
"rule_severities";
354 fromLegacy<bool>( aCfg,
"RequireCourtyardDefinitions", sev +
"legacy_no_courtyard_defined" );
356 fromLegacy<bool>( aCfg,
"ProhibitOverlappingCourtyards", sev +
"legacy_courtyards_overlap" );
360 wxString keyBase =
"TrackWidth";
361 wxString key = keyBase;
368 while( aCfg->Read( key, &val ) )
370 widths.push_back( val );
380 wxString keyBase =
"ViaDiameter";
381 wxString key = keyBase;
389 while( aCfg->Read( key, &diameter ) )
392 aCfg->Read( key << idx, &drill );
394 nlohmann::json via = { {
"diameter", diameter }, {
"drill", drill } };
395 vias.push_back( via );
406 wxString keyBase =
"dPairWidth";
407 wxString key = keyBase;
410 double via_gap = 1.0;
416 while( aCfg->Read( key, &width ) )
419 aCfg->Read( key << idx, &gap );
422 aCfg->Read( key << idx, &via_gap );
424 nlohmann::json pair = { {
"width", width }, {
"gap", gap }, {
"via_gap", via_gap } };
425 pairs.push_back( pair );
434 group_blacklist.insert( wxT(
"/pcbnew" ) );
437 group_blacklist.insert( wxT(
"/general" ) );
440 aCfg->SetPath( wxT(
"/" ) );
442 auto loadSheetNames =
451 aCfg->SetPath( wxT(
"/sheetnames" ) );
455 wxArrayString tokens = wxSplit( entry,
':' );
457 if( tokens.size() == 2 )
459 wxLogTrace(
traceSettings,
"%d: %s = %s", sheet, tokens[0], tokens[1] );
460 arr.push_back( nlohmann::json::array( { tokens[0], tokens[1] } ) );
466 aCfg->SetPath(
"/" );
472 std::vector<wxString> groups;
474 groups.emplace_back(
"" );
476 auto loadLegacyPairs =
477 [&](
const std::string& aGroup ) ->
bool 486 while( aCfg->GetNextEntry( keyStr, index ) )
488 if( !aCfg->Read( keyStr, &val ) )
491 std::string key( keyStr.ToUTF8() );
497 nlohmann::json::json_pointer ptr(
"/legacy" + aGroup +
"/" + key );
498 ( *this )[ptr] = val;
509 for(
size_t i = 0; i < groups.size(); i++ )
511 aCfg->SetPath( groups[i] );
513 if( groups[i] == wxT(
"/sheetnames" ) )
515 ret |= loadSheetNames();
519 aCfg->DeleteEntry( wxT(
"last_client" ),
true );
520 aCfg->DeleteEntry( wxT(
"update" ),
true );
521 aCfg->DeleteEntry( wxT(
"version" ),
true );
523 ret &= loadLegacyPairs( groups[i].ToStdString() );
527 while( aCfg->GetNextGroup( str, index ) )
529 wxString group = groups[i] +
"/" + str;
531 if( !group_blacklist.count( group ) )
532 groups.emplace_back( group );
535 aCfg->SetPath(
"/" );
567 aJson = nlohmann::json::array( { aPair.first.AsString().ToUTF8(), aPair.second.ToUTF8() } );
573 wxCHECK( aJson.is_array() && aJson.size() == 2, );
574 aPair.first =
KIID( wxString( aJson[0].get<std::string>().c_str(), wxConvUTF8 ) );
575 aPair.second = wxString( aJson[1].get<std::string>().c_str(), wxConvUTF8 );
PROJECT * m_project
A link to the owning PROJECT.
std::map< wxString, wxString > m_TextVars
std::vector< wxString > m_PinnedSymbolLibs
Below are project-level settings that have not been moved to a dedicated file.
std::vector< wxString > m_PinnedFootprintLibs
The list of pinned footprint libraries.
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
Container for project specific data.
const std::string ProjectFileExtension
wxArrayString m_LegacyLibNames
std::vector< FILE_INFO_PAIR > m_sheets
An list of schematic sheets in this project.
const int projectFileSchemaVersion
! Update the schema version whenever a migration is required
wxString getLegacyFileExt() const override
bool SaveToFile(const wxString &aDirectory="", bool aForce=false) override
wxString m_PcbLastPath[LAST_PATH_SIZE]
MRU path storage.
bool m_deleteLegacyAfterMigration
Whether or not to delete legacy file after migration.
Stores a path as a string with directory separators normalized to unix-style.
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...
std::shared_ptr< NET_SETTINGS > m_NetSettings
Net settings for this project (owned here) NOTE: If we go multi-board in the future,...
virtual bool SaveToFile(const wxString &aDirectory="", bool aForce=false)
wxString m_BoardPageLayoutDescrFile
PcbNew params.
std::vector< wxString > m_EquivalenceFiles
CvPcb params.
Definition of file extensions used in Kicad.
wxString getFileExt() const override
const std::string LegacyProjectFileExtension
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
bool fromLegacyString(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy wxConfig string value to a given JSON pointer value.
A helper for <wxString, wxString> maps.
void to_json(nlohmann::json &aJson, const FILE_INFO_PAIR &aPair)
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
void from_json(const nlohmann::json &aJson, FILE_INFO_PAIR &aPair)
virtual const wxString GetProjectName() const
Return the short name of the project.
const wxChar *const traceSettings
Flag to enable debug output of settings operations and management.
std::vector< LAYER_PRESET > m_LayerPresets
List of stored layer presets.
Represents a list of strings holding directory paths.
static nlohmann::json::json_pointer PointerFromString(std::string aPath)
Builds a JSON pointer based on a given string.
PROJECT_FILE(const wxString &aFullPath)
Constructs the project file for a project.
std::vector< FILE_INFO_PAIR > m_boards
A list of board files in this project.