120 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
126 wxCHECK( bomJob && editFrame,
false );
136 [](
JOB* job, wxWindow* aParent ) ->
bool
141 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
147 wxCHECK( netJob && editFrame,
false );
153 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
159 wxCHECK(
plotJob && editFrame,
false );
164 _(
"Plotting to HPGL is no longer supported as of KiCad 10.0." ) );
172 [](
JOB* job, wxWindow* aParent ) ->
bool
177 [](
JOB* job, wxWindow* aParent ) ->
bool
182 [](
JOB* job, wxWindow* aParent ) ->
bool
187 [](
JOB* job, wxWindow* aParent ) ->
bool
192 [](
JOB* job, wxWindow* aParent ) ->
bool
197 [](
JOB* job, wxWindow* aParent ) ->
bool
201 wxCHECK( ercJob,
false );
207 [](
JOB* job, wxWindow* aParent ) ->
bool
212 [](
JOB* job, wxWindow* aParent ) ->
bool
217 [](
JOB* job, wxWindow* aParent ) ->
bool
239 if( !
Pgm().IsGUI() &&
Pgm().GetSettingsManager().IsProjectOpenNotDummy() )
242 wxString schPath = aPath;
244 if( schPath.IsEmpty() )
249 schPath =
path.GetFullPath();
264 else if(
Pgm().IsGUI() &&
Pgm().GetSettingsManager().IsProjectOpen() )
271 else if( !aPath.IsEmpty() )
274 aPath,
true,
false,
nullptr,
true, aRequireRoot ?
m_reporter :
nullptr );
284 SCHEMATIC* aSch,
const wxString& aDrawingSheetOverride )
304 auto loadSheet = [&](
const wxString&
path ) ->
bool
309 { aSch->GetEmbeddedFiles() }, &msg ) )
311 m_reporter->Report( wxString::Format(
_(
"Error loading drawing sheet '%s'." ),
path ) + wxS(
"\n" ) + msg
321 if( !aDrawingSheetOverride.IsEmpty() && loadSheet( aDrawingSheetOverride ) )
358 wxString variantName;
365 if( !variantName.IsEmpty() && variantName != wxS(
"all" ) )
368 std::unique_ptr<SCH_RENDER_SETTINGS> renderSettings = std::make_unique<SCH_RENDER_SETTINGS>();
379 renderSettings->SetDefaultFont( font );
389 for(
SCH_ITEM* item : screen->Items() )
392 for(
const auto& [libItemName, libSymbol] : screen->GetLibSymbols() )
393 libSymbol->ClearCaches();
396 std::unique_ptr<SCH_PLOTTER> schPlotter = std::make_unique<SCH_PLOTTER>( sch );
466 if( !variantName.IsEmpty() )
479 schPlotter->Plot( format, plotOpts, renderSettings.get(),
m_reporter );
484 for(
const wxString& outputPath : schPlotter->GetOutputFilePaths() )
511 if( variantName != wxS(
"all" ) )
528 m_reporter->Report(
_(
"Warning: schematic has annotation errors, please use the "
529 "schematic editor to fix them\n" ),
537 if(
erc.TestDuplicateSheetNames(
false ) > 0 )
540 std::unique_ptr<NETLIST_EXPORTER_BASE> helper;
541 unsigned netlistOption = 0;
549 helper = std::make_unique<NETLIST_EXPORTER_KICAD>( sch,
m_kiway );
554 helper = std::make_unique<NETLIST_EXPORTER_ORCADPCB2>( sch,
m_kiway );
559 helper = std::make_unique<NETLIST_EXPORTER_CADSTAR>( sch,
m_kiway );
565 helper = std::make_unique<NETLIST_EXPORTER_SPICE>( sch,
m_kiway );
570 helper = std::make_unique<NETLIST_EXPORTER_SPICE_MODEL>( sch,
m_kiway );
574 fileExt = wxS(
"xml" );
575 helper = std::make_unique<NETLIST_EXPORTER_XML>( sch,
m_kiway );
579 fileExt = wxS(
"asc" );
580 helper = std::make_unique<NETLIST_EXPORTER_PADS>( sch,
m_kiway );
584 fileExt = wxS(
"txt" );
585 helper = std::make_unique<NETLIST_EXPORTER_ALLEGRO>( sch,
m_kiway );
594 defaultFn.SetExt( fileExt );
600 defaultFn.GetFullName() );
608 bool res = helper->WriteNetlist( outPath, netlistOption, *
m_reporter );
635 if( !currentVariant.IsEmpty() && currentVariant != wxS(
"all" ) )
647 if(
copy.CheckAnnotation(
654 m_reporter->Report(
_(
"Warning: schematic has annotation errors, please use the schematic "
655 "editor to fix them\n" ),
663 if(
erc.TestDuplicateSheetNames(
false ) > 0 )
693 std::set<wxString> userFieldNames;
695 for(
size_t i = 0; i < referenceList.
GetCount(); ++i )
697 SCH_SYMBOL* symbol = referenceList[i].GetSymbol();
701 if( !field.IsMandatory() && !field.IsPrivate() )
702 userFieldNames.insert( field.GetName() );
706 for(
const wxString& fieldName : userFieldNames )
713 if( userFieldNames.count( templateFieldname.m_Name ) == 0 )
726 std::optional<BOM_PRESET> schPreset;
728 for(
const BOM_PRESET& p : BOM_PRESET::BuiltInPresets() )
749 wxString::Format(
_(
"BOM preset '%s' not found" ) + wxS(
"\n" ), aBomJob->
m_bomPresetName ),
763 auto normalizeFieldName = [&dataModel](
const wxString& aName ) -> wxString
765 if( aName.IsEmpty() )
766 return wxEmptyString;
771 wxString wrapped = wxS(
"${" ) + aName + wxS(
"}" );
783 wxString fieldName = normalizeFieldName( rawFieldName );
785 if( fieldName.IsEmpty() )
793 if( fieldName == wxS(
"*" ) )
799 field.
name = modelField.name;
804 bool fieldAlreadyPresent =
false;
806 for(
BOM_FIELD& presetField : preset.fieldsOrdered )
808 if( presetField.
name == field.
name )
810 fieldAlreadyPresent =
true;
815 bool fieldLaterInList =
false;
819 if( normalizeFieldName( fieldInList ) == field.
name )
821 fieldLaterInList =
true;
826 if( !fieldAlreadyPresent && !fieldLaterInList )
827 preset.fieldsOrdered.emplace_back( field );
835 field.
name = fieldName;
836 field.
show = !fieldName.StartsWith( wxT(
"__" ), &field.
name );
837 field.
name = normalizeFieldName( field.
name );
846 preset.fieldsOrdered.emplace_back( field );
852 wxString fieldName = rawFieldName;
853 fieldName.StartsWith( wxT(
"__" ), &fieldName );
854 fieldName = normalizeFieldName( fieldName );
856 if( fieldName.IsEmpty() )
859 bool fieldAlreadyPresent =
false;
861 for(
BOM_FIELD& field : preset.fieldsOrdered )
863 if( field.
name == fieldName )
866 fieldAlreadyPresent =
true;
871 if( !fieldAlreadyPresent )
876 preset.sortField = normalizeFieldName( aBomJob->
m_sortField );
888 std::optional<BOM_FMT_PRESET> schFmtPreset;
910 m_reporter->Report( wxString::Format(
_(
"BOM format preset '%s' not found" ) + wxS(
"\n" ),
937 bool hasVariantPlaceholder = configuredPath.Contains( wxS(
"${VARIANT}" ) );
940 std::vector<wxString> variantsToProcess;
948 variantsToProcess.push_back( currentVariant );
951 for(
const wxString& variantName : variantsToProcess )
953 std::vector<wxString> singleVariant = { variantName };
961 if( hasVariantPlaceholder )
963 wxString variantPath = configuredPath;
964 variantPath.Replace( wxS(
"${VARIANT}" ), variantName );
984 if( !f.Open( outPath, wxFile::write ) )
986 m_reporter->Report( wxString::Format(
_(
"Unable to open destination '%s'" ), outPath ),
992 bool res = f.Write( dataModel.
Export( fmt ) );
1033 m_reporter->Report(
_(
"Warning: schematic has annotation errors, please use the "
1034 "schematic editor to fix them\n" ),
1042 if(
erc.TestDuplicateSheetNames(
false ) > 0 )
1045 std::unique_ptr<NETLIST_EXPORTER_XML> xmlNetlist = std::make_unique<NETLIST_EXPORTER_XML>( sch,
m_kiway );
1048 defaultFn.SetName( defaultFn.GetName() +
"-bom" );
1055 defaultFn.GetFullName() );
1081 std::shared_ptr<LIB_SYMBOL> parent;
1091 symbolToPlot = parent.get();
1095 for(
int unit = 1; unit < symbol->
GetUnitCount() + 1; unit++ )
1107 for( wxChar c : wxFileName::GetForbiddenChars( wxPATH_DOS ) )
1108 filename.Replace( c,
' ' );
1113 filename += wxString::Format(
"_unit%d", unit );
1117 if( bodyStyle == 2 )
1118 filename += wxS(
"_demorgan" );
1125 fn.SetName( filename );
1126 m_reporter->Report( wxString::Format(
_(
"Plotting symbol '%s' unit %d to '%s'\n" ), symbol->
GetName(),
1127 unit, fn.GetFullPath() ),
1132 if( !
PlotSymbolToSVG( *symbolToPlot, *symbol, unit, bodyStyle, symbolBB, *aRenderSettings,
1158 wxString singleFileFilter;
1160 auto schLibrary = std::make_unique<SCH_IO_KICAD_SEXPR_LIB_CACHE>( fn.GetFullPath() );
1170 bool recovered =
false;
1172 if( !fn.IsDir() && wxDir::Exists( fn.GetPath() ) )
1176 schLibrary = std::make_unique<SCH_IO_KICAD_SEXPR_LIB_CACHE>( fn.GetPath() );
1178 singleFileFilter = fn.GetFullPath();
1202 symbol = schLibrary->GetSymbol( svgJob->
m_symbol );
1215 m_reporter->Report( wxString::Format(
_(
"Unable to create output directory '%s'." ) + wxS(
"\n" ),
1239 const std::map<wxString, wxString>& sourceFiles = schLibrary->GetSymbolSourceFiles();
1240 const wxFileName filterFile( singleFileFilter );
1242 for(
const auto& [
name, libSymbol] : libSymMap )
1245 if( !singleFileFilter.IsEmpty() )
1247 auto srcIt = sourceFiles.find(
name );
1249 if( srcIt == sourceFiles.end() || !wxFileName( srcIt->second ).SameAs( filterFile ) )
1281 m_reporter->Report( wxString::Format(
_(
"Unknown target version '%s'. Valid targets: %s\n" ), job->
m_target,
1289 std::vector<LIB_SYMBOL*> symbols;
1298 ioe.
What().GetData() ),
1316 m_reporter->Report(
_(
"Cannot export: the library uses features the target cannot represent.\n" ),
1323 m_reporter->Report(
_(
"Export would lose data. Re-run with --force to export anyway.\n" ),
1339 if( !outputDirectories.
Create( output.GetPath() ) )
1349 if( staged.IsEmpty() )
1365 wxString::Format(
_(
"Error exporting '%s'.\n%s" ), job->
m_libraryPath, ioe.
What().GetData() ),
1370 wxString failedDestination = transaction.
Commit();
1372 if( !failedDestination.IsEmpty() )
1374 m_reporter->Report( wxString::Format(
_(
"Could not replace '%s'.\n" ), failedDestination ),
1379 outputDirectories.
Commit();
1406 else if(
fileType != SCH_IO_MGR::SCH_KICAD )
1408 m_reporter->Report(
_(
"Output path must be specified to convert legacy and non-KiCad libraries\n" ),
1414 if(
fileType == SCH_IO_MGR::SCH_KICAD )
1485 defaultFn.SetName( defaultFn.GetName() + wxS(
"-erc" ) );
1498 defaultFn.GetFullName() );
1516 std::shared_ptr<SHEETLIST_ERC_ITEMS_PROVIDER> markersProvider =
1517 std::make_shared<SHEETLIST_ERC_ITEMS_PROVIDER>( sch );
1533 if( editFrame && &editFrame->
Schematic() != sch )
1534 editFrame =
nullptr;
1546 markersProvider->SetSeverities( ercJob->
m_severity );
1548 m_reporter->Report( wxString::Format(
_(
"Found %d violations\n" ), markersProvider->GetCount() ),
1551 ERC_REPORT reportWriter( sch, units, markersProvider );
1553 bool wroteReport =
false;
1570 if( markersProvider->GetCount() > 0 )
1582 if( aUpgradeJob ==
nullptr )
1590 bool shouldSave = aUpgradeJob->
m_force;
1602 wxFileName schPath( aUpgradeJob->
m_filename );
1603 schPath.MakeAbsolute();
1604 const wxString schFullPath = schPath.GetFullPath();
1609 SCH_SHEET* loadedSheet = pi->LoadSchematicFile( schFullPath, sch );
1610 pi->SaveSchematicFile( schFullPath, loadedSheet, sch );
1615 wxString::Format(
_(
"Error saving schematic file '%s'.\n%s" ), schFullPath, ioe.
What().GetData() );
1645 wxArrayString files;
1646 wxDir::GetAllFiles( aDir, &files, wxT(
"*.kicad_sym" ) );
1648 for(
const wxString& file : files )
1656 std::vector<LIB_SYMBOL*> symbols;
1675 bool aDropInsteadOfApproximate,
1677 wxString* aRecoveryError =
nullptr )
1682 std::vector<LIB_SYMBOL*> symbols;
1686 std::stable_sort( symbols.begin(), symbols.end(),
1689 return a->GetInheritanceDepth() < b->GetInheritanceDepth();
1701 [&](
const wxString& aText )
1703 return FindUnsupportedSchToken( aText, aTarget );
1705 convert, aTransaction, aRecoveryError );
1713 if( job ==
nullptr )
1719 if( target ==
nullptr )
1721 m_reporter->Report( wxString::Format(
_(
"Unknown target version '%s'. Valid targets: %s\n" ), job->
m_target,
1736 wxString libraryCopyDir;
1737 wxString outputError;
1741 wxFileName output = wxFileName::DirName( job->
m_outputDir );
1743 if( job->
m_outputDir.IsEmpty() || !output.MakeAbsolute()
1746 if( outputError.IsEmpty() )
1747 outputError =
_(
"An output folder is required. Use --output." );
1776 auto prepareOutput = [&]() ->
bool
1787 if( !libraryCopyDir.IsEmpty() )
1795 libraryWorkDir = libraryCopyDir;
1808 wxString recoveryError;
1810 aTransaction, &recoveryError );
1812 if( !badLib.IsEmpty() )
1814 m_reporter->Report( wxString::Format(
_(
"Cannot export: symbol library '%s' uses a feature %s "
1816 badLib, target->
m_name ),
1819 if( !recoveryError.IsEmpty() )
1828 wxString::Format(
_(
"Error downgrading symbol libraries.\n%s" ), ioe.
What().GetData() ),
1854 m_reporter->Report(
_(
"Cannot export: the libraries use features the target cannot represent.\n" ),
1861 m_reporter->Report(
_(
"Export would lose data. Re-run with --force to export anyway.\n" ),
1870 if( !prepareOutput() )
1873 int result = downgradeLibraries();
1876 outputDirectories.
Commit();
1883 schInputFn.MakeAbsolute();
1894 bool createdTransientProject =
false;
1898 mgr.
LoadProject( projectFn.GetFullPath(),
false );
1899 projectPtr = mgr.
GetProject( projectFn.GetFullPath() );
1900 createdTransientProject = ( projectPtr != nullptr );
1921 if(
auto storedRoots = projectFile.
GetJson(
"schematic.top_level_sheets" ); storedRoots && storedRoots->is_array() )
1923 for(
const auto&
info : *storedRoots )
1925 if( !
info.contains(
"filename" ) || !
info[
"filename"].is_string() )
1928 const wxString filename = wxString::FromUTF8(
info[
"filename"].get<std::string>() );
1929 wxFileName rootFile( filename );
1932 if( filename.IsEmpty() || !rootFile.FileExists() )
1934 m_reporter->Report( wxString::Format(
_(
"Cannot export: top-level schematic '%s' is missing.\n" ),
1935 rootFile.GetFullPath() ),
1945 std::unique_ptr<SCHEMATIC> owned = std::make_unique<SCHEMATIC>( projectPtr );
1946 owned->CreateDefaultScreens();
1949 struct SCH_PROJECT_GUARD
1957 ~SCH_PROJECT_GUARD()
1973 } schProjectGuard{ sch, projectPtr, createdTransientProject, savedErc, savedSch };
1988 if( !pi->GetError().IsEmpty() )
1990 m_reporter->Report( wxString::Format(
_(
"Cannot export: the schematic did not load "
1991 "completely.\n%s" ),
2000 bool rootIsTopLevel = std::find( topLevelSheets.begin(), topLevelSheets.end(), root ) != topLevelSheets.end();
2002 bool changed =
false;
2004 if( !rootIsTopLevel && !rootIsVirtualRoot )
2006 topLevelSheets = { root };
2012 if( !rootIsVirtualRoot )
2022 SCH_SHEET* sibling = pi->LoadSchematicFile( fn.GetFullPath(), sch );
2024 if( !sibling || !pi->GetError().IsEmpty() )
2026 m_reporter->Report( wxString::Format(
_(
"Cannot export: the schematic did not load "
2027 "completely.\n%s" ),
2037 topLevelSheets.push_back( sibling );
2054 std::set<SCH_SCREEN*> seen;
2055 std::vector<std::pair<SCH_SHEET*, SCH_SCREEN*>> screens;
2062 if( screen && seen.insert( screen ).second )
2063 screens.emplace_back( sheet, screen );
2080 m_reporter->Report(
_(
"The target supports variants, so there is nothing to flatten.\n" ),
2087 m_reporter->Report( wxString::Format(
_(
"The schematic has no variant named '%s'.\n" ), job->
m_variant ),
2097 wxString::Format(
_(
"Cannot export selected variant '%s': %s" ), job->
m_variant, conflict )
2104 for(
const auto& [sheet, screen] : screens )
2121 wxString rootContent;
2122 wxFFile rootFile( job->
m_filename, wxT(
"rb" ) );
2124 if( rootFile.IsOpened() && rootFile.ReadAll( &rootContent ) && rootContent.Contains( wxT(
"(net_chain" ) ) )
2127 _(
"No equivalent in the target. Net chain grouping is removed." ), 1 );
2144 m_reporter->Report(
_(
"Cannot export: the schematic uses features the target cannot represent.\n" ),
2151 m_reporter->Report(
_(
"Export would lose data. Re-run with --force to export anyway.\n" ),
2156 if( !libraryCopyDir.IsEmpty() )
2159 base.MakeAbsolute();
2160 const wxString rootPrefix = wxFileName::DirName( base.GetPath() ).GetPathWithSep();
2161 std::vector<wxString> destinations;
2163 for(
const auto& [sheet, screen] : screens )
2165 wxFileName
source( screen->GetFileName() );
2167 if( !
source.IsAbsolute() )
2168 source.MakeAbsolute( base.GetPath() );
2170 source.Normalize( wxPATH_NORM_DOTS );
2171 const wxString sourcePath =
source.GetFullPath();
2172 const bool contained = wxFileName::IsCaseSensitive() ? sourcePath.StartsWith( rootPrefix )
2173 : sourcePath.Lower().StartsWith( rootPrefix.Lower() );
2178 wxString::Format(
_(
"Cannot export: sheet '%s' lies outside the project folder.\n" ),
2184 destinations.push_back( job->
m_outputDir + wxFileName::GetPathSeparator()
2185 + sourcePath.Mid( rootPrefix.length() ) );
2188 wxFileName projectOutput = projectFn;
2190 destinations.push_back( projectOutput.GetFullPath() );
2191 std::error_code error;
2201 for(
const wxString& destination : destinations )
2212 wxString libraryPath =
library;
2214 if( !wxFileName::IsCaseSensitive() )
2217 libraryPath.MakeLower();
2220 const wxString separator( wxFileName::GetPathSeparator() );
2222 if(
path == libraryPath ||
path.StartsWith( libraryPath + separator )
2223 || libraryPath.StartsWith(
path + separator ) )
2225 m_reporter->Report(
_(
"The copied library folder overlaps a schematic or project output path. "
2226 "Choose a different library folder.\n" ),
2233 if( !prepareOutput() )
2240 for(
const wxString&
name : variants )
2246 wxString currentTemp;
2251 base.MakeAbsolute();
2253 for(
const auto& [sheet, screen] : screens )
2257 wxFileName screenFn( screen->GetFileName() );
2259 if( !screenFn.IsAbsolute() )
2260 screenFn.MakeAbsolute( base.GetPath() );
2263 screenFn.Normalize( wxPATH_NORM_DOTS );
2267 wxFileName rootDir( base.GetPath(), wxEmptyString );
2269 wxString screenPath = screenFn.GetFullPath();
2270 wxString rootPrefix = rootDir.GetPathWithSep();
2273 bool contained = wxFileName::IsCaseSensitive() ? screenPath.StartsWith( rootPrefix )
2274 : screenPath.Lower().StartsWith( rootPrefix.Lower() );
2278 m_reporter->Report( wxString::Format(
_(
"Cannot export: sheet '%s' lies outside the project "
2280 screenFn.GetFullPath() ),
2285 wxString finalPath = screenFn.GetFullPath();
2291 wxFileName destFn( job->
m_outputDir + wxFileName::GetPathSeparator()
2292 + screenPath.Mid( rootPrefix.length() ) );
2294 if( !wxDirExists( destFn.GetPath() )
2295 && !wxFileName::Mkdir( destFn.GetPath(), wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
2298 wxString::Format(
_(
"Could not create the output folder '%s'.\n" ), destFn.GetPath() ),
2303 finalPath = destFn.GetFullPath();
2309 currentTemp = transaction.
Stage( finalPath );
2311 if( currentTemp.IsEmpty() )
2316 wxString unsupported;
2320 [&](
const wxString& aText )
2322 return FindUnsupportedSchToken( aText, *target );
2328 if( !unsupported.IsEmpty() )
2329 m_reporter->Report( wxString::Format(
_(
"Cannot export: the result still uses '%s', which %s "
2330 "cannot open. This feature has no downgrade rule "
2332 unsupported, target->
m_name ),
2336 wxString::Format(
_(
"Cannot export: could not verify '%s'.\n" ), screenFn.GetFullPath() ),
2342 currentTemp.Clear();
2347 nlohmann::json document = nlohmann::json::object();
2350 if( projectFn.FileExists() )
2352 wxFFile sourceProject( projectFn.GetFullPath(), wxT(
"rb" ) );
2354 if( !sourceProject.IsOpened() || !sourceProject.ReadAll( &content ) )
2355 THROW_IO_ERROR(
_(
"Could not read the schematic project settings." ) );
2359 document = nlohmann::json::parse( content.ToStdString( wxConvUTF8 ) );
2361 catch(
const nlohmann::json::exception& )
2363 THROW_IO_ERROR(
_(
"Could not read the schematic project settings." ) );
2367 if( !document.is_object() )
2370 nlohmann::json aliases = nlohmann::json::object();
2374 nlohmann::json members = nlohmann::json::array();
2376 for(
const wxString& member : alias->Members() )
2377 members.push_back( member.ToStdString( wxConvUTF8 ) );
2379 aliases[alias->GetName().ToStdString( wxConvUTF8 )] = std::move( members );
2382 if( !document.contains(
"schematic" ) || !document[
"schematic"].is_object() )
2383 document[
"schematic"] = nlohmann::json::object();
2385 nlohmann::json& schematicSettings = document[
"schematic"];
2387 || schematicSettings.value(
"bus_aliases", nlohmann::json::object() ) != aliases;
2391 schematicSettings[
"bus_aliases"] = std::move( aliases );
2392 nlohmann::json roots = nlohmann::json::array();
2396 wxFileName filename( root.filename );
2398 filename.MakeRelativeTo( base.GetPath() );
2399 roots.push_back( { {
"uuid", root.uuid.AsString().ToStdString( wxConvUTF8 ) },
2400 {
"name", root.name.ToStdString( wxConvUTF8 ) },
2401 {
"filename", filename.GetFullPath().ToStdString( wxConvUTF8 ) } } );
2404 schematicSettings[
"top_level_sheets"] = roots;
2406 if( !document.contains(
"meta" ) )
2407 document[
"meta"] = { {
"version", 3 } };
2409 wxFileName destination = projectFn;
2414 wxString finalPath = destination.GetFullPath();
2418 currentTemp = transaction.
Stage( finalPath );
2420 if( currentTemp.IsEmpty() )
2421 THROW_IO_ERROR(
_(
"Could not stage the schematic project settings." ) );
2423 wxFFile outputProject( currentTemp, wxT(
"wb" ) );
2425 if( !outputProject.IsOpened()
2426 || !outputProject.Write( wxString::FromUTF8( ( document.dump( 2 ) +
"\n" ).c_str() ) )
2427 || !outputProject.Close() )
2429 THROW_IO_ERROR(
_(
"Could not save the schematic project settings." ) );
2432 currentTemp.Clear();
2439 wxString::Format(
_(
"Error saving schematic file '%s'.\n%s" ), job->
m_filename, ioe.
What().GetData() ),
2447 wxString failedDestination = transaction.
Commit();
2449 if( !failedDestination.IsEmpty() )
2451 m_reporter->Report( wxString::Format(
_(
"Could not replace '%s'.\n" ), failedDestination ),
2460 outputDirectories.
Commit();
2484 SCH_IO_MGR::SCH_FILE_T
fileType = SCH_IO_MGR::SCH_FILE_UNKNOWN;
2505 if(
fileType == SCH_IO_MGR::SCH_FILE_UNKNOWN )
2508 m_reporter->Report( wxString::Format(
_(
"No schematic importer recognizes the file format "
2517 if( outputPath.IsEmpty() )
2521 inputFn.MakeAbsolute();
2523 wxFileName outputFn( outputPath );
2524 outputFn.MakeAbsolute();
2530 PROJECT* projectPtr =
nullptr;
2531 bool createdTransientProject =
false;
2535 projectPtr = &mgr.
Prj();
2539 wxFileName projectFn( outputFn );
2543 projectPtr = mgr.
GetProject( projectFn.GetFullPath() );
2544 createdTransientProject = ( projectPtr != nullptr );
2549 m_reporter->Report(
_(
"Could not establish a project for the import\n" ),
2562 std::unique_ptr<SCHEMATIC> schematic = std::make_unique<SCHEMATIC>( &
project );
2575 m_reporter->Report( wxString::Format(
_(
"No plugin found for file type '%s'\n" ),
2582 pi->SetReporter( &importMessages );
2586 m_reporter->Report( wxString::Format(
_(
"Importing '%s' using %s format...\n" ),
2587 inputFn.GetFullPath(), formatName ),
2590 loadedSheet = pi->LoadSchematicFile( inputFn.GetFullPath(), schematic.get() );
2600 m_reporter->Report( wxString::Format(
_(
"Error during import: %s\n" ), ioe.
What() ),
2605 size_t symbolCount = 0;
2606 size_t sheetCount = 0;
2612 std::vector<SCH_SHEET*> topLevelSheets = schematic->GetTopLevelSheets();
2613 bool loadedIsTopLevel = std::find( topLevelSheets.begin(), topLevelSheets.end(),
2614 loadedSheet ) != topLevelSheets.end();
2615 bool loadedIsVirtualRoot = loadedSheet == &schematic->Root()
2618 if( !loadedIsTopLevel && !loadedIsVirtualRoot )
2619 schematic->SetTopLevelSheets( { loadedSheet } );
2627 std::unique_ptr<TOOL_MANAGER> toolManager = std::make_unique<TOOL_MANAGER>();
2628 toolManager->SetEnvironment( schematic.get(),
nullptr,
nullptr,
Kiface().KifaceSettings(),
2633 schematic->RecalculateConnections( &dummyCommit,
GLOBAL_CLEANUP, toolManager.get() );
2637 schematic->SetSheetNumberAndCount();
2641 schematic->Settings().m_SchDrawingSheetFileName = wxS(
"empty.kicad_wks" );
2644 if(
SCH_SHEET* topSheet = schematic->GetTopLevelSheet() )
2645 topSheet->SetFileName( outputFn.GetFullName() );
2647 schematic->RootScreen()->SetFileName( outputFn.GetFullPath() );
2651 std::unordered_map<SCH_SCREEN*, wxString> filenameMap;
2652 filenameMap[schematic->RootScreen()] = outputFn.GetFullPath();
2658 filenameMap, errorMsg ) )
2668 for(
size_t i = 0; i < screens.
GetCount(); i++ )
2671 wxString
path = filenameMap[screen];
2673 if(
path.IsEmpty() )
2676 wxFileName fn(
path );
2679 kicadPi->SaveSchematicFile( fn.GetFullPath(), screens.
GetSheet( i ), schematic.get() );
2683 symbolCount += std::distance( symbols.begin(), symbols.end() );
2688 m_reporter->Report( wxString::Format(
_(
"Error saving imported schematic: %s\n" ),
2693 catch(
const std::exception& exc )
2695 m_reporter->Report( wxString::Format(
_(
"Error saving imported schematic: %s\n" ),
2705 m_reporter->Report( wxString::Format(
_(
"Successfully saved imported schematic to '%s'\n" ),
2706 outputFn.GetFullPath() ),
2710 if(
Pgm().GetSettingsManager().IsProjectOpenNotDummy() )
2712 std::vector<FILE_INFO_PAIR>& projectSheets =
project.GetProjectFile().GetSheets();
2713 projectSheets.clear();
2720 projectSheets.emplace_back( std::make_pair( sheet->
m_Uuid, sheet->
GetName() ) );
2724 std::vector<TOP_LEVEL_SHEET_INFO> topLevelSheets = schematic->TopLevelSheetInfos();
2726 if( !topLevelSheets.empty() )
2727 project.GetProjectFile().GetTopLevelSheets() = std::move( topLevelSheets );
2731 if( createdTransientProject && schematic->GetTopLevelSheets().size() > 1 )
2733 m_reporter->Report( wxString::Format(
_(
"%zu sheets were written, but only '%s' is "
2734 "reachable: top-level sheets are recorded in a "
2735 "project file. Use 'kicad-cli import' to create "
2737 sheetCount, outputFn.GetFullName() ),
2741 IMPORT_REPORT_DATA reportData;
2746 reportData.m_sourceFile = inputFn.GetFullName();
2747 reportData.m_sourceFormat = formatName;
2748 reportData.m_outputFile = outputFn.GetFullName();
2749 reportData.m_statistics = {
2750 { wxS(
"symbols" ), symbolCount },
2751 { wxS(
"sheets" ), sheetCount }
2754 reportData.m_statistics.emplace_back( wxS(
"renamed_board_nets" ), job->
m_netNameMap.size() );
2785 return drawingSheet;
2817 return std::unique_ptr<SCHEMATIC>(
2825 aSch->SetProject(
nullptr );
2836 wxFileName synthetic( wxFileName::GetTempDir(),
2837 wxString::Format( wxS(
"%s_%ld_%p" ), aTag,
static_cast<long>( wxGetProcessId() ), &aMgr ) );
2840 aMgr, synthetic.GetFullPath(),
2843 auto sch = std::make_unique<SCHEMATIC>( aProject );
2844 sch->CreateDefaultScreens();
2849 aSch->SetProject( nullptr );
2892 return diffExitCode;
2921 std::vector<std::unique_ptr<LIB_SYMBOL>>& aOwners,
2925 if( aAllowEmpty && aPath.IsEmpty() )
2931 aOwners = std::move( loaded.first );
2932 aMap = std::move( loaded.second );
2937 aReporter.
Report( wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, ioe.
What() ),
2940 catch(
const std::exception& e )
2943 wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, wxString::FromUTF8( e.what() ) ),
2958 for(
const auto& [
name, symbol] : aMap )
2975 std::vector<std::unique_ptr<LIB_SYMBOL>> ownersA;
2976 std::vector<std::unique_ptr<LIB_SYMBOL>> ownersB;
2998 return diffExitCode;
3043 if( !aSides.
a.
doc && !aFileA.IsEmpty() )
3049 if( !aSides.
b.
doc && !aFileB.IsEmpty() )
3091 canvas->SetContextItems( {} );
3092 canvas->SetContextPainter(
3115 auto context = std::make_unique<SCH_DIFF_CANVAS_CONTEXT>( aBefore, aAfter );
3124 SCHEMATIC* schA = context->m_sides.schA;
3125 SCHEMATIC* schB = context->m_sides.schB;
3132 aDiff = context->m_sides.diff;
3133 return context.release();
3138 const wxString& aFileB,
const wxString& aLabelA,
3139 const wxString& aLabelB, wxWindow* aParent,
3147 wxWindow* parent = aParent ? aParent : ( wxTheApp ? wxTheApp->GetTopWindow() :
nullptr );
3148 const wxString labelA = aLabelA.IsEmpty() ? aFileA : aLabelA;
3149 const wxString labelB = aLabelB.IsEmpty() ? aFileB : aLabelB;
3170 std::map<KIID_PATH, std::set<KIID>> removedBySheet;
3177 sheetPath.pop_back();
3178 removedBySheet[sheetPath].insert( change.
id.back() );
3188 SCH_SCREEN* compScreen = schB ? schB->RootScreen() : nullptr;
3190 if( !aSheetPath.empty() && schB )
3192 if( auto sp = schB->Hierarchy().GetSheetPathByKIIDPath( aSheetPath, true ) )
3193 compScreen = sp->LastScreen();
3198 if( !aSheetPath.empty() && schA )
3200 if( auto sp = schA->Hierarchy().GetSheetPathByKIIDPath( aSheetPath, true ) )
3201 refScreen = sp->LastScreen();
3204 std::vector<KIGFX::VIEW_ITEM*> deletedItems;
3205 auto removedHere = removedBySheet.find( aSheetPath );
3209 if( removedHere == removedBySheet.end() && aSheetPath.empty() && schA )
3212 rootPath.push_back( schA->Root().m_Uuid );
3213 removedHere = removedBySheet.find( rootPath );
3216 if( refScreen && removedHere != removedBySheet.end() )
3218 for( SCH_ITEM* item : refScreen->Items() )
3220 if( removedHere->second.count( item->m_Uuid ) )
3221 deletedItems.push_back( item );
3228 deletedItems, {},
nullptr, compScreen );
3236 std::vector<std::unique_ptr<LIB_SYMBOL>> ownersA;
3237 std::vector<std::unique_ptr<LIB_SYMBOL>> ownersB;
3258 dlg.DrawChosenLibraryItem(
3268 m_reporter->Report(
_(
"Unsupported document kind for this dispatcher.\n" ),
RPT_SEVERITY_ERROR );
3284 const wxString& aOurs,
const wxString& aTheirs,
3285 const wxString& aOutput,
bool aInteractive,
bool aSingleFile,
3294 return runSymLibMerge( aAncestor, aOurs, aTheirs, aOutput, aInteractive );
3296 return runSchMerge( aAncestor, aOurs, aTheirs, aOutput, aInteractive );
3301 const wxString& aTheirs,
const wxString& aOutput,
3310 if( !ancestor.
doc || !ours.
doc || !theirs.
doc )
3320 auto hasSingleRoot = [](
const SCHEMATIC* aSch )
3322 return aSch->GetTopLevelSheets().size() == 1;
3325 if( !hasSingleRoot( ancestor.
doc.get() ) || !hasSingleRoot( ours.
doc.get() ) || !hasSingleRoot( theirs.
doc.get() ) )
3327 m_reporter->Report(
_(
"sch merge requires each input to have a single top-level sheet\n" ),
3332 auto loadedVersion = [](
const SCHEMATIC* aSch )
3334 return aSch->RootScreen() ? aSch->RootScreen()->GetFileFormatVersionAtLoad() : 0;
3337 const wxString formatNotice =
3341 if( !formatNotice.IsEmpty() )
3377 return wxEmptyString;
3381 for(
SCHEMATIC* doc : { ours.
doc.get(), theirs.doc.get(), ancestor.
doc.get() } )
3386 if(
SCH_ITEM* item = doc->ResolveItem( aId.back(),
nullptr,
true ) )
3387 return item->GetItemDescription( &units,
false );
3390 return wxEmptyString;
3395 auto screenForConflict = [](
SCHEMATIC* aDoc,
const std::optional<KIID_PATH>& aId ) ->
SCH_SCREEN*
3397 if( !aId.has_value() || aId->size() < 2 )
3401 sheetPath.pop_back();
3416 const std::optional<KIID_PATH>& aId )
3426 doc = theirs.doc.get();
3436 screenForConflict( doc, aId ) );
3455 if( !applier.
Apply() )
3466 m_reporter->Report(
_(
"Merge contains hierarchical sheet structure changes that sch merge "
3473 SCH_SHEET* rootSheet = ancestor.
doc->GetTopLevelSheet( 0 );
3475 wxFileName outFn( aOutput );
3476 outFn.MakeAbsolute();
3482 const wxString outDir = outFn.GetPath();
3490 std::map<wxString, SCH_SCREEN*> basenameOwner;
3492 for(
size_t i = 0; i < screens.
GetCount(); ++i )
3496 if( !screen || screen == rootScreen )
3499 const wxString basename = wxFileName( screen->
GetFileName() ).GetFullName();
3501 if( basename.IsEmpty() )
3504 auto [it, inserted] = basenameOwner.emplace( basename, screen );
3506 if( !inserted && it->second != screen )
3508 m_reporter->Report( wxString::Format(
_(
"Cannot flatten sub-sheets with duplicate "
3509 "basename '%s'\n" ),
3519 for(
size_t i = 0; i < screens.
GetCount(); ++i )
3531 if( !childScreen || childScreen == rootScreen )
3534 const wxString basename = wxFileName( childScreen->
GetFileName() ).GetFullName();
3536 if( !basename.IsEmpty() )
3544 pi->SaveSchematicFile( outFn.GetFullPath(), rootSheet, ancestor.
doc.get() );
3546 for(
size_t i = 0; i < screens.
GetCount(); ++i )
3551 if( !screen || !sheet || screen == rootScreen )
3554 const wxString basename = wxFileName( screen->
GetFileName() ).GetFullName();
3556 if( basename.IsEmpty() )
3559 wxFileName outSubFn( outDir, basename );
3560 pi->SaveSchematicFile( outSubFn.GetFullPath(), sheet, ancestor.
doc.get() );
3565 m_reporter->Report( wxString::Format(
_(
"Failed to save merged schematic: %s\n" ), ioe.
What() ),
3577 wxFileName proFn = outFn;
3594 ancestor.
doc->ErcSettings().SaveToFile( wxEmptyString,
true );
3597 ancestor.
doc->Settings().SaveToFile( wxEmptyString,
true );
3599 std::set<wxString> touched;
3609 if( !
Pgm().GetSettingsManager().SaveProjectCopy( proFn.GetFullPath(), ancestor.
project ) )
3612 wxString::Format(
_(
"Failed to save merged project file: %s\n" ), proFn.GetFullPath() ),
3623 m_reporter->Report( wxString::Format( wxS(
"%s: %s\n" ), f.validator, f.message ), f.severity );
3630 m_reporter->Report( wxString::Format(
_(
"Merge completed with %zu unresolved conflict(s) in %s\n" ),
3645#include <wx/ffile.h>
3649 const wxString& aTheirs,
const wxString& aOutput,
bool aInteractive )
3651 if( aOutput.IsEmpty() )
3660 std::vector<std::unique_ptr<LIB_SYMBOL>> owners;
3664 LIB_SIDE ancestor, ours, theirs;
3666 auto loadSide = [&](
const wxString& aPath, LIB_SIDE& aSide ) ->
int
3671 aSide.owners = std::move( loaded.first );
3672 aSide.map = std::move( loaded.second );
3677 m_reporter->Report( wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, ioe.
What() ),
3680 catch(
const std::exception& e )
3683 wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, wxString::FromUTF8( e.what() ) ),
3711 auto changeFor = [](
const std::map<KIID_PATH, const KICAD_DIFF::ITEM_CHANGE*>& aChanges,
3714 auto it = aChanges.find( aId );
3715 return it != aChanges.end() ? it->second :
nullptr;
3718 auto combine = [&](
const KIID_PATH& aId ) -> std::unique_ptr<LIB_SYMBOL>
3723 if( !ourChange || !theirChange || !ourChange->
refdes )
3727 auto ancestorSymbol = ancestor.map.find(
name );
3728 auto ourSymbol = ours.map.find(
name );
3729 auto theirSymbol = theirs.map.find(
name );
3731 if( ancestorSymbol == ancestor.map.end() || ourSymbol == ours.map.end() || theirSymbol == theirs.map.end() )
3735 *ourChange, *theirChange );
3738 std::function<std::set<wxString>(
const KIID_PATH& )> editedNames;
3748 return combine( aId ) !=
nullptr;
3752 bool userDecided =
false;
3759 std::set<wxString> names;
3763 for(
const auto& [
name, symbol] : *side )
3764 names.insert(
name );
3777 side = &ancestor.map;
3785 if( dlg.ShowModal() != wxID_APPLY )
3788 plan = dlg.GetResolvedPlan();
3795 std::vector<std::unique_ptr<LIB_SYMBOL>> merged = applier.
Apply();
3799 const bool hadSilentFallback = applier.
GetReport().mergePropsFallback > 0;
3803 wxFileName outFn( aOutput );
3804 outFn.MakeAbsolute();
3812 for(
auto& sym : merged )
3823 m_reporter->Report( wxString::Format(
_(
"Failed to save merged symbol library: %s\n" ), ioe.
What() ),
3835 if( userDecided && planSnapshot.
Resolved() && !hadSilentFallback )
3844 m_reporter->Report( wxString::Format(
_(
"Failed to load %s: %s\n" ), aOutput, ioe.
What() ),
3848 if( !planSnapshot.
Resolved() || hadSilentFallback )
3852 std::set<KIID_PATH> conflicts( planSnapshot.
unresolved.begin(), planSnapshot.
unresolved.end() );
3855 conflicts.insert(
id );
3857 m_reporter->Report( wxString::Format(
_(
"Symbol library merge completed with %zu unresolved "
3858 "conflict(s) in %s\n" ),
3859 conflicts.size(), aOutput ),
3864 m_reporter->Report( wxString::Format(
_(
"Symbol library merge in %s dropped an edit from one side\n" ), aOutput ),
constexpr EDA_IU_SCALE schIUScale
int GetVirtualPageNumber() const
const wxString & GetPageNumber() const
Color settings are a bit different than most of the settings objects in that there can be more than o...
What an export to a given target will keep, approximate, drop, or block.
void Add(DOWNGRADE_BUCKET aBucket, const wxString &aFeature, const wxString &aDetail=wxEmptyString, int aCount=1)
void Print(REPORTER *aReporter) const
void Merge(const COMPATIBILITY_REPORT &aOther)
bool IsLossy() const
True if anything is approximated or dropped. This is what triggers the lossy warning.
bool IsBlocked() const
True if some feature makes the target impossible. The user cannot export anyway.
File-compare dialog (Phase 7).
Resolve a three-way merge by choosing a version for each conflicting item.
const KICAD_DIFF::MERGE_PLAN & GetResolvedPlan() const
Returns the plan with the user's resolutions applied.
static CONFLICT_CONTEXT LibraryContext(const std::set< wxString > &aNames, LIBRARY_ITEM_DRAWER aDraw)
Context for merging a library, whose items are known by the names in aNames.
static bool CanOpen(REPORTER &aReporter)
Report to aReporter and return false when this process cannot open a dialog.
SIDE
Which side's version the canvas should currently display.
Stage related design and library files together, retaining originals until every write is ready.
const wxString & GetRecoveryError() const
Recovery details are nonempty only if restoring an original or removing a new output failed.
wxString Commit()
Replace all destinations, rolling back earlier replacements if a rename fails.
wxString Stage(const wxString &aDestination)
Return an exclusively-created sibling staging file, or empty if it cannot be created.
bool Create(const wxString &aDirectory, bool aOwnContents=false)
static DS_DATA_MODEL & GetTheInstance()
Return the instance of DS_DATA_MODEL used in the application.
void SetSheetPath(const std::string &aSheetPath)
Set the sheet path displayed in the title block.
void SetSheetCount(int aSheetCount)
Change the sheet-count number displayed in the title block.
void SetVariantName(const std::string &aVariant)
Set the current variant name and description to be shown on the drawing sheet.
void SetVariantDesc(const std::string &aVariantDesc)
void SetPageNumber(const std::string &aPageNumber)
Change the page number displayed in the title block.
void SetSheetName(const std::string &aSheetName)
Set the sheet name displayed in the title block.
void SetPageBorderColorLayer(int aLayerId)
Override the layer used to pick the color of the page border (normally LAYER_GRID)
void SetIsFirstPage(bool aIsFirstPage)
Change if this is first page.
void SetFileName(const std::string &aFileName)
Set the file name displayed in the title block.
void SetColorLayer(int aLayerId)
Can be used to override which layer ID is used for drawing sheet item colors.
static SCHEMATIC * LoadSchematic(const wxString &aFileName, bool aSetActive, bool aForceDefaultProject, PROJECT *aProject=nullptr, bool aCalculateConnectivity=true, REPORTER *aRootReporter=nullptr)
int JobExportNetlist(JOB *aJob)
int runSchMerge(const wxString &aAncestor, const wxString &aOurs, const wxString &aTheirs, const wxString &aOutput, bool aInteractive)
void InitRenderSettings(SCH_RENDER_SETTINGS *aRenderSettings, const wxString &aTheme, SCHEMATIC *aSch, const wxString &aDrawingSheetOverride=wxEmptyString)
Configure the SCH_RENDER_SETTINGS object with the correct data to be used with plotting.
int JobSymUpgrade(JOB *aJob)
int JobExportBom(JOB *aJob)
int JobUpgrade(JOB *aJob)
bool m_cliSchematicRootValidated
int JobSymDowngrade(JOB *aJob)
int RunMerge(KICAD_DIFF::DOC_KIND aKind, const wxString &aAncestor, const wxString &aOurs, const wxString &aTheirs, const wxString &aOutput, bool aInteractive, bool aSingleFile, REPORTER *aReporter)
Non-job entry points (reached via the kiface KIFACE_MERGE_DOCUMENT / KIFACE_OPEN_DIFF_DIALOG function...
int JobSymExportSvg(JOB *aJob)
DS_PROXY_VIEW_ITEM * getDrawingSheetProxyView(SCHEMATIC *aSch)
KICAD_DIFF::DIFF_CANVAS_CONTEXT * AttachDiffCanvases(KICAD_DIFF::DOC_KIND aKind, const wxString &aFileA, const wxString &aFileB, WIDGET_DIFF_CANVAS *aBefore, WIDGET_DIFF_CANVAS *aAfter, KICAD_DIFF::DOCUMENT_DIFF &aDiff, REPORTER *aReporter)
Diff two schematics for a window outside the kiface, drawing the first on aBefore and the second on a...
int JobSymDiff(JOB *aJob)
int JobExportPythonBom(JOB *aJob)
int JobDowngrade(JOB *aJob)
int runSymLibMerge(const wxString &aAncestor, const wxString &aOurs, const wxString &aTheirs, const wxString &aOutput, bool aInteractive)
SCHEMATIC * getSchematic(const wxString &aPath, bool aRequireRoot=true)
int OpenDiffDialog(KICAD_DIFF::DOC_KIND aKind, const wxString &aFileA, const wxString &aFileB, const wxString &aLabelA, const wxString &aLabelB, wxWindow *aParent, REPORTER *aReporter)
void ClearCachedSchematic()
Clear the cached CLI schematic so the next job reloads from the current project.
EESCHEMA_JOBS_HANDLER(KIWAY *aKiway)
int JobExportPlot(JOB *aJob)
SCHEMATIC * m_cliSchematic
int doSymExportSvg(JOB_SYM_EXPORT_SVG *aSvgJob, SCH_RENDER_SETTINGS *aRenderSettings, LIB_SYMBOL *symbol)
int JobSchDiff(JOB *aJob)
EE_TYPE OfType(KICAD_T aType) const
bool WriteJsonReport(const wxString &aFullFileName)
Writes a JSON formatted ERC Report to the given file path in the c-locale.
bool WriteTextReport(const wxString &aFullFileName)
Writes the text report also available via GetTextReport directly to a given file path.
Container for ERC settings.
Runs the electrical rules checks and adds a SCH_MARKER for each violation.
void RunTests(DS_PROXY_VIEW_ITEM *aDrawingSheet, SCH_EDIT_FRAME *aEditFrame, KIFACE *aCvPcb, PROJECT *aProject, PROGRESS_REPORTER *aProgressReporter)
void SetVariantNames(const std::vector< wxString > &aVariantNames)
std::vector< BOM_FIELD > GetFieldsOrdered()
static const wxString QUANTITY_VARIABLE
static const wxString ITEM_NUMBER_VARIABLE
wxString Export(const BOM_FMT_PRESET &aSettings)
int GetFieldNameCol(const wxString &aFieldName) const
void ApplyBomPreset(const BOM_PRESET &aPreset)
void AddColumn(const wxString &aFieldName, const wxString &aLabel, bool aAddedByUser) override
void SetCurrentVariant(const wxString &aVariantName) override
Select the displayed variant, retaining un-applied edits in every variant.
Reporter handed to an importer during an import job.
void Flush(IMPORT_REPORT_FORMAT aFormat, IMPORT_REPORT_DATA &aData)
Move the collected messages into aData when a report will be written, otherwise forward them to the j...
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
wxString m_inputB
Comparison document (file or directory)
wxString m_inputA
Reference document (file or directory)
void Register(const std::string &aJobTypeName, std::function< int(JOB *job)> aHandler, std::function< bool(JOB *job, wxWindow *aParent)> aConfigHandler)
JOB_DISPATCHER(KIWAY *aKiway)
PROGRESS_REPORTER * m_progressReporter
wxString GetSelectedVariant() const
std::vector< wxString > m_variantNames
wxString m_stringDelimiter
wxString m_fieldDelimiter
bool m_includeByteOrderMark
std::vector< wxString > m_fieldsOrdered
wxString m_refRangeDelimiter
std::vector< wxString > m_fieldsLabels
std::vector< wxString > m_fieldsGroupBy
wxString m_bomFmtPresetName
BOM_FILTER_SCOPE m_filterScope
std::vector< wxString > m_variantNames
JOB_PAGE_SIZE m_pageSizeSelect
SCH_PLOT_FORMAT m_plotFormat
bool m_useBackgroundColor
std::vector< wxString > m_variantNames
bool m_PDFHierarchicalLinks
std::vector< wxString > m_plotPages
bool m_exitCodeViolations
std::vector< wxString > m_foundVariants
Variant names found in the schematic when the target drops variants.
wxString m_outputDir
Write downgraded sheets under this fresh folder.
wxString m_variant
Flatten this variant into the export. Empty means the base design.
wxString m_libraryDir
If set, downgrade every .kicad_sym symbol library under this folder too.
bool m_inPlace
Internal only: convert the coordinator's already-copied export files.
bool m_dryRun
Only classify and fill m_report, do not write anything.
wxString m_filename
Root schematic file (may be empty to downgrade only libraries)
COMPATIBILITY_REPORT m_report
Filled by the handler so the caller can show it.
wxString m_target
Target release name or id, e.g. "KiCad 10.0" or "10.0". Empty means the newest.
bool m_dropInsteadOfApproximate
Omit features that would otherwise be approximated.
bool m_force
Export even when features must be dropped or approximated.
Job to import a non-KiCad schematic file to KiCad format.
IMPORT_REPORT_FORMAT m_reportFormat
std::map< wxString, wxString > m_netNameMap
COMPATIBILITY_REPORT m_report
Filled by the handler so the caller can show it.
wxString m_libraryPath
The .kicad_sym library to convert.
wxString m_target
Target release name or id, e.g. "KiCad 9.0". Empty means the newest.
bool m_force
Convert even when features must be dropped or approximated.
bool m_dryRun
Only classify and fill m_report, do not write anything.
wxString m_outputLibraryPath
Where to write the converted copy.
bool m_dropInsteadOfApproximate
Omit features that would otherwise be approximated.
wxString m_outputDirectory
bool m_includeHiddenFields
wxString m_outputLibraryPath
An simple container class that lets us dispatch output jobs to kifaces.
void SetConfiguredOutputPath(const wxString &aPath)
Sets the configured output path for the job, this path is always saved to file.
void AddOutput(wxString aOutputPath)
wxString GetFullOutputPath(PROJECT *aProject) const
Returns the full output path for the job, taking into account the configured output path,...
static wxString AppendDefaultFileName(const wxString &aPath, const wxString &aDefaultName)
Complete a resolved file output path that names a folder, either by a trailing separator or by being ...
bool GetOutputPathIsDirectory() const
wxString GetConfiguredOutputPath() const
Returns the configured output path for the job.
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
void SetWorkingOutputPath(const wxString &aPath)
Sets a transient output path for the job, it takes priority over the configured output path when GetF...
const std::map< wxString, wxString > & GetVarOverrides() const
std::optional< nlohmann::json > GetJson(const std::string &aPath) const
Fetches a JSON object that is a subset of this JSON_SETTINGS object, using a path of the form "key1....
JSON_SETTINGS_INTERNALS * Internals()
Keeps the documents drawn on a pair of diff canvases alive.
Three-way merge plan generator.
MERGE_PLAN Plan(const DOCUMENT_DIFF &aAncestorOurs, const DOCUMENT_DIFF &aAncestorTheirs) const
Plan the merge given the canonical pair of diffs.
const REPORT & GetReport() const
std::vector< std::unique_ptr< ITEM > > Apply()
Diff two already-parsed SCHEMATICs and produce a DOCUMENT_DIFF.
DOCUMENT_DIFF Diff() override
Produce a DOCUMENT_DIFF of the inputs the concrete differ was constructed with.
Materialize a MERGE_PLAN into a merged SCHEMATIC by mutating the ancestor in place.
bool Apply()
Apply the plan to the ancestor.
const REPORT & GetReport() const
Diff two .kicad_sym symbol libraries.
static bool MergeKeepsBothSides(const SYMBOL_MAP &aAncestor, const SYMBOL_MAP &aOurs, const SYMBOL_MAP &aTheirs, const SYMBOL_MAP &aMerged)
True when aMerged differs from each side of a three-way merge exactly as the other side differs from ...
DOCUMENT_DIFF Diff() override
Produce a DOCUMENT_DIFF of the inputs the concrete differ was constructed with.
static std::pair< std::vector< std::unique_ptr< LIB_SYMBOL > >, SYMBOL_MAP > LoadLibrary(const wxString &aPath)
Convenience: load a .kicad_sym path into a SYMBOL_MAP using SCH_IO_KICAD_SEXPR::EnumerateSymbolLib.
std::map< wxString, const LIB_SYMBOL * > SYMBOL_MAP
Library content is a map of (canonical_name -> LIB_SYMBOL*).
A color representation with 4 components: red, green, blue, alpha.
void SetDefaultPenWidth(int aWidth)
void SetGapLengthRatio(double aRatio)
void SetDashLengthRatio(double aRatio)
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
void AsyncLoad()
Loads all available libraries for this adapter type in the background.
Define a library symbol object.
std::shared_ptr< LIB_SYMBOL > GetRootSymbol() const
Get the parent symbol that does not have another parent.
wxString GetName() const override
const std::vector< wxString > & GetBodyStyleNames() const
bool HasDeMorganBodyStyles() const override
int GetBodyStyleCount() const override
The body styles are a property of the drawings, which a derived symbol inherits from its root symbol ...
int GetUnitCount() const override
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
static bool EnsurePathExists(const wxString &aPath, bool aPathToFile=false)
Attempts to create a given path if it does not exist.
virtual SETTINGS_MANAGER & GetSettingsManager() const
The backing store for a PROJECT, in JSON format.
ERC_SETTINGS * m_ErcSettings
Eeschema params.
SCHEMATIC_SETTINGS * m_SchematicSettings
TEMPLATES m_TemplateFieldNames
Project and global field name templates shared by project editors.
bool Store() override
Stores the current parameters into the JSON document represented by this object Note: this doesn't do...
std::vector< TOP_LEVEL_SHEET_INFO > & GetTopLevelSheets()
static SYMBOL_LIBRARY_ADAPTER * SymbolLibAdapter(PROJECT *aProject)
Accessor for project symbol library manager adapter.
Container for project specific data.
virtual const wxString GetProjectPath() const
Return the full path of the project.
virtual void ApplyTextVars(const std::map< wxString, wxString > &aVarsMap)
Applies the given var map, it will create or update existing vars.
virtual PROJECT_FILE & GetProjectFile() const
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
These are loaded from Eeschema settings but then overwritten by the project settings.
wxString m_SchDrawingSheetFileName
double m_DashedLineGapRatio
double m_DashedLineDashRatio
Holds all the data relating to one schematic.
void SetCurrentVariant(const wxString &aVariantName)
wxString GetVariantDescription(const wxString &aVariantName) const
Return the description for a variant.
void LoadVariants()
This is a throw away method for variant testing.
SCH_SHEET_LIST BuildSheetListSortedByPageNumbers() const
const std::vector< std::shared_ptr< BUS_ALIAS > > & GetAllBusAliases() const
wxString GetFileName() const
Helper to retrieve the filename from the root sheet screen.
SCHEMATIC_SETTINGS & Settings() const
SCH_SHEET_LIST Hierarchy() const
Return the full schematic flattened hierarchical sheet list.
SCH_SHEET_LIST BuildUnorderedSheetList() const
PROJECT & Project() const
Return a reference to the project this schematic is part of.
void SetProject(PROJECT *aPrj)
void DeleteVariant(const wxString &aVariantName, SCH_COMMIT *aCommit)
Delete all information for aVariantName.
wxString GetCurrentVariant() const
Return the current variant being edited.
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
void SetTopLevelSheets(const std::vector< SCH_SHEET * > &aSheets)
Replace the top level sheets, rebuilding the hierarchy and connectivity around them.
const std::set< wxString > & GetVariantNames() const
Return the set of variant names (without the default placeholder).
const std::map< wxString, wxString > * GetProperties()
std::vector< SCH_SHEET * > GetTopLevelSheets() const
Get the list of top-level sheets.
Commit for the schematic and symbol editors.
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
SCH_DIFF_CANVAS_CONTEXT(WIDGET_DIFF_CANVAS *aBefore, WIDGET_DIFF_CANVAS *aAfter)
~SCH_DIFF_CANVAS_CONTEXT() override
WIDGET_DIFF_CANVAS * m_before
WIDGET_DIFF_CANVAS * m_after
Schematic editor (Eeschema) main window.
SCHEMATIC & Schematic() const
A cache assistant for the KiCad s-expression symbol libraries.
int GetFileFormatVersionAtLoad() const
void Save(const std::optional< bool > &aOpt=std::nullopt) override
Save the entire library to file m_libFileName;.
A SCH_IO derivation for loading schematic files using the new s-expression file format.
void EnumerateSymbolLib(wxArrayString &aSymbolNameList, const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Populate a list of LIB_SYMBOL alias names contained within the library aLibraryPath.
void SetFileName(const wxString &aFileName)
void SetModified(bool aModified=true)
virtual void AddSymbol(std::unique_ptr< LIB_SYMBOL > aSymbol)
static bool ConvertLibrary(std::map< std::string, UTF8 > *aOldFileProps, const wxString &aOldFilePath, const wxString &aNewFilepath, REPORTER *aReporter=nullptr)
Convert a schematic symbol library to the latest KiCad format.
static const wxString ShowType(SCH_FILE_T aFileType)
Return a brief name for a plugin, given aFileType enum.
static SCH_FILE_T GuessPluginTypeFromSchPath(const wxString &aSchematicPath, int aCtl=0)
Return a plugin type given a schematic using the file extension of aSchematicPath.
static SCH_FILE_T GuessPluginTypeFromLibPath(const wxString &aLibPath, int aCtl=0)
Return a plugin type given a symbol library using the file extension of aLibPath.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
int CheckAnnotation(ANNOTATION_ERROR_HANDLER aErrorHandler)
Check for annotations errors.
A helper to define a symbol's reference designator in a schematic.
void LoadColors(const COLOR_SETTINGS *aSettings) override
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
SCH_SCREEN * GetScreen(unsigned int aIndex) const
SCH_SHEET * GetSheet(unsigned int aIndex) const
const PAGE_INFO & GetPageSettings() const
EE_RTREE & Items()
Get the full RTree, usually for iterating.
const wxString & GetFileName() const
int GetFileFormatVersionAtLoad() const
TITLE_BLOCK & GetTitleBlock()
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
std::optional< SCH_SHEET_PATH > GetSheetPathByKIIDPath(const KIID_PATH &aPath, bool aIncludeLastSheet=true) const
Finds a SCH_SHEET_PATH that matches the provided KIID_PATH.
void GetSymbols(SCH_REFERENCE_LIST &aReferences, SYMBOL_FILTER aSymbolFilter, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
void SetFileName(const wxString &aFilename)
void SetName(const wxString &aName)
SCH_SCREEN * GetScreen() const
bool IsVirtualRootSheet() const
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
RAII class that sets an value at construction and resets it to the original value at destruction.
PROJECT * GetProject(const wxString &aFullPath) const
Retrieve a loaded project by name.
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
bool IsProjectOpenNotDummy() const
Helper for checking if we have a project open that is not a dummy project.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true, bool aOverrideLock=false)
Load a project or sets up a new project with a specified path.
void UpdateReferences(const SCH_REFERENCE_LIST &aRefs)
const SCH_REFERENCE_LIST & GetReferenceList() const
An interface to the global shared library manager that is schematic-specific and linked to one projec...
const std::vector< TEMPLATE_FIELDNAME > & GetResolvedTemplateFieldNames()
Return the resolved project and global template field name list for read only access.
wxString GetGeneratedFieldDisplayName(const wxString &aSource)
Returns any variables unexpanded, e.g.
bool IsGeneratedField(const wxString &aFieldName)
Returns true if the entire string is generated, e.g is a single text var reference.
wxString GetDefaultPlotExtension(PLOT_FORMAT aFormat)
Return the default plot extension for a format.
@ DROP
No equivalent, left out.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
#define DEFAULT_LINE_WIDTH_MILS
The default line width in mils. (can be changed in preference menu)
static bool empty(const wxTextEntryBase *aCtrl)
wxString DowngradeWxPath(const std::filesystem::path &aPath)
wxString DowngradeLibraryCopyPath(const wxString &aLibrary, const wxString &aOutputDirectory)
bool ValidateDowngradeLibrarySource(const wxString &aSource, wxString &aError)
bool ValidateDowngradeLibraryCopy(const wxString &aSource, const wxString &aDestination, wxString &aError)
bool ValidateFreshDowngradeOutput(const wxString &aOutput, wxString &aError)
bool CopyDowngradeLibraryDirectory(const wxString &aSource, const wxString &aDestination, DOWNGRADE_OUTPUT_DIRECTORIES &aDirectories, wxString &aError)
std::filesystem::path DowngradeNativePath(const wxString &aPath)
wxString DowngradeLibraryFilesInPlace(const wxString &aDir, const wxString &aGlob, int aStampVersion, const std::function< wxString(const wxString &)> &aFindForbidden, const std::function< DOWNGRADE_FILE_RESULT(const wxString &, const wxString &)> &aConvert, DOWNGRADE_FILE_TRANSACTION *aTransaction=nullptr, wxString *aRecoveryError=nullptr)
Downgrade every library file matching aGlob under aDir in place.
bool IsDowngradeWorkingArtifact(const wxString &aPath)
Editor working state (autosaves, local history, backups) holds current-format copies nothing downgrad...
DOWNGRADE_FILE_RESULT
What a per-file converter did with one library file.
@ CONVERTED
The temp file holds the downgraded copy.
bool VerifyDowngradedFile(const wxString &aPath, int aStampVersion, const std::function< wxString(const wxString &)> &aFindForbidden, wxString *aForbidden=nullptr)
Read back a downgraded output and require the target stamp plus a clean token scan.
const std::vector< DOWNGRADE_TARGET > & GetDowngradeTargets()
Supported downgrade targets, newest first.
const DOWNGRADE_TARGET * FindDowngradeTarget(const wxString &aNameOrId)
Match a user-supplied target string against name or stable id, case-insensitively.
wxString DowngradeTargetNames()
The valid target choices as one user-facing list, for error messages.
bool PrepareSaveAsFiles(SCHEMATIC &aSchematic, SCH_SCREENS &aScreens, const wxFileName &aOldRoot, const wxFileName &aNewRoot, bool aSaveCopy, bool aCopySubsheets, bool aIncludeExternSheets, std::unordered_map< SCH_SCREEN *, wxString > &aFilenameMap, wxString &aErrorMsg)
static int loadSchDiffSides(SETTINGS_MANAGER &aMgr, REPORTER &aReporter, const wxString &aFileA, const wxString &aFileB, SCH_DIFF_SIDES &aSides)
static wxString downgradeSymbolLibraries(const wxString &aDir, const DOWNGRADE_TARGET &aTarget, bool aDropInsteadOfApproximate, DOWNGRADE_FILE_TRANSACTION *aTransaction=nullptr, wxString *aRecoveryError=nullptr)
static SCRATCH_DOC< SCHEMATIC > emptyScratchSchematic(SETTINGS_MANAGER &aMgr, const wxString &aTag)
static int loadSymbolLibrarySide(const wxString &aPath, std::vector< std::unique_ptr< LIB_SYMBOL > > &aOwners, KICAD_DIFF::SYM_LIB_DIFFER::SYMBOL_MAP &aMap, bool aAllowEmpty, REPORTER &aReporter)
static SCRATCH_DOC< SCHEMATIC > loadScratchSchematic(SETTINGS_MANAGER &aMgr, const wxString &aPath)
static void classifySymbolLibraries(const wxString &aDir, const DOWNGRADE_TARGET &aTarget, COMPATIBILITY_REPORT &aReport, bool aDropInsteadOfApproximate)
static KICAD_DIFF::DOCUMENT_GEOMETRY symbolLibraryGeometry(const KICAD_DIFF::SYM_LIB_DIFFER::SYMBOL_MAP &aMap, const KIGFX::COLOR4D &aColor)
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
static const std::string CadstarNetlistFileExtension
static const std::string NetlistFileExtension
static const std::string ReportFileExtension
static const std::string ProjectFileExtension
static const std::string JsonFileExtension
static const std::string XmlFileExtension
static const std::string KiCadSchematicFileExtension
static const std::string OrCadPcb2NetlistFileExtension
static const std::string CsvFileExtension
static const std::string SpiceFileExtension
static const std::string SVGFileExtension
std::map< wxString, wxString > GetBoardNetNameMap(const IMPORT_NET_MAP &aMap, REPORTER &aReporter)
Reduce the map to the board net renames it justifies.
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
wxString DefaultImportOutputPath(const wxString &aInputFile, const wxString &aKiCadExt)
Build the default output path for an import by swapping the input file's extension for the given KiCa...
bool WriteImportReport(REPORTER *aReporter, IMPORT_REPORT_FORMAT aFormat, const wxString &aReportFile, const IMPORT_REPORT_DATA &aData)
Emit an import report in the requested format to aReportFile, or to aReporter (at INFO severity) when...
#define KICTL_NONKICAD_ONLY
chosen file is non-KiCad according to user
@ LAYER_SCHEMATIC_DRAWINGSHEET
@ LAYER_SCHEMATIC_PAGE_LIMITS
static std::vector< PENDING_PROPERTY > plan(const EDA_ITEM &aSource, const EDA_ITEM &aTarget, const std::set< wxString > &aEnabledKeys)
Target properties to write, paired with values read off the source.
static const int ERR_ARGS
static const int ERR_RC_VIOLATIONS
Rules check violation count was greater than 0.
static const int ERR_CANCELLED
The user cancelled the operation.
static const int ERR_INVALID_INPUT_FILE
static const int ERR_INVALID_OUTPUT_CONFLICT
static const int ERR_UNKNOWN_FILE_FORMAT
No plugin for the requested face recognized the input file format.
static const int ERR_UNKNOWN
const wxString DOC_PROP_ERC_SEVERITIES
void SettleLibraryMerges(MERGE_PLAN &aPlan, const std::function< bool(const KIID_PATH &)> &aCanCombine, const std::function< std::set< wxString >(const KIID_PATH &)> &aEditedNames)
Settle the MERGE_PROPS of a library merge, where an item is combined whole or not at all.
std::vector< CONFLICT_LIST_ENTRY > BuildConflictList(const MERGE_PLAN &aPlan)
void CollectChangeBBoxes(const DOCUMENT_DIFF &aDiff, std::map< KIID_PATH, BOX2I > &aOut)
Walk a DOCUMENT_DIFF and populate a (KIID_PATH → BOX2I) map with each changed item's bbox,...
DOCUMENT_GEOMETRY ExtractSymbolGeometry(const LIB_SYMBOL &aSymbol, const KIGFX::COLOR4D &aColor, int aUnit, int aBodyStyle)
Extract coarse drawable context from a library symbol for visual symbol diffs.
void ConfigureSchDiffCanvasContext(WIDGET_DIFF_CANVAS &aCanvas, SCHEMATIC *aReference, SCHEMATIC *aComparison, const KIGFX::COLOR4D &aColor, const std::map< KIID, KIGFX::COLOR4D > &aOverrides, const std::vector< KIGFX::VIEW_ITEM * > &aExtraItems, const std::map< KIID, KICAD_DIFF::CATEGORY > &aCategories, SCH_SCREEN *aReferenceScreen, SCH_SCREEN *aComparisonScreen, std::shared_ptr< const void > aOwner)
DOCUMENT_GEOMETRY ExtractSchematicGeometry(const SCHEMATIC &aSchematic, const KIGFX::COLOR4D &aColor, const std::map< KIID, KIGFX::COLOR4D > &aOverrides, bool aOnlyOverrides)
Extract a coarse outline of a SCHEMATIC into a DOCUMENT_GEOMETRY for use as background context in DIF...
wxString OlderFormatNotice(int aAncestorVersion, int aOursVersion, int aTheirsVersion, int aCurrentVersion)
Empty when every side is already in the current file format.
void AppendGeometry(DOCUMENT_GEOMETRY &aDst, DOCUMENT_GEOMETRY &&aSrc)
Move all primitives from aSrc into aDst.
DIFF_EMIT_OPTIONS MakeEmitOptions(const JOB_DIFF_BASE &aJob, const wxString &aLabelA, const wxString &aLabelB)
Build a DIFF_EMIT_OPTIONS pre-filled from the job's format, resolved output path and the supplied per...
const wxString DOC_PROP_DRAWING_SHEET
DOC_KIND
Document type a diff/merge entry point should route to, derived from a file path's extension.
int EmitDiffResult(const DOCUMENT_DIFF &aResult, const DIFF_EMIT_OPTIONS &aOptions, int aDiffExitCode, REPORTER &aReporter)
Emit a computed DOCUMENT_DIFF in the requested format.
std::unique_ptr< KIGFX::PAINTER > MakeSchDiffContextPainter(KIGFX::GAL *aGal, SCHEMATIC *aSchematic, const KIGFX::COLOR4D &aColor, std::map< KIID, KIGFX::COLOR4D > aOverrides)
std::unique_ptr< LIB_SYMBOL > CombineSymbolEdits(const LIB_SYMBOL &aAncestor, const LIB_SYMBOL &aOurs, const LIB_SYMBOL &aTheirs, const ITEM_CHANGE &aOurChange, const ITEM_CHANGE &aTheirChange)
Combine two edits of one library symbol when neither can lose anything.
void ShowSymbolPair(WIDGET_DIFF_CANVAS &aCanvas, const SYM_LIB_DIFFER::SYMBOL_MAP &aBefore, const SYM_LIB_DIFFER::SYMBOL_MAP &aAfter, const wxString &aName)
Draw the symbol aName as it is in aBefore and aAfter.
std::map< KIID_PATH, const ITEM_CHANGE * > IndexChangesByKiid(const DOCUMENT_DIFF &aDiff)
Flatten a DOCUMENT_DIFF's ITEM_CHANGE tree into a KIID_PATH -> ITEM_CHANGE* map, recursing into child...
std::function< std::set< wxString >(const KIID_PATH &)> EditedNamesIn(const DOCUMENT_DIFF &aOurs, const DOCUMENT_DIFF &aTheirs)
What either side edits in an item, for SettleLibraryMerges. Both diffs must outlive the result.
LIB_MERGE_APPLIER< LIB_SYMBOL > SYM_LIB_MERGE_APPLIER
Symbol-library 3-way merge applier. See LIB_MERGE_APPLIER for behavior.
bool ApplyProjectFilePatches(const wxString &aOutputProPath, const nlohmann::json &aSource, const std::set< wxString > &aDocProps, DOC_KIND aKind)
Higher-level orchestrator: load the existing aOutputProPath as JSON (or start from aSource if the fil...
int DiffExitCode(const DOCUMENT_DIFF &aResult)
Map a computed diff onto its CLI exit code – SUCCESS when empty, otherwise ERR_RC_VIOLATIONS.
static int plotJob(JOB_EXPORT_PCB_PLOT *aJob, PCB_PLOTTER &aPlotter, const LSEQ &aLayersToPlot, const wxString &aOutPath, bool aSingleOutput, bool aUseVarOverrides, bool aForceAllLayersToOnePage=false)
PGM_BASE & Pgm()
The global program "get" accessor.
PLOT_FORMAT
The set of supported output plot formats.
Plotting engines similar to ps (PostScript, Gerber, svg)
#define SKIP_CONNECTIVITY
#define DELETE_REMOVED_ITEMS
COMPATIBILITY_REPORT ClassifySchematicStructureForDowngrade(const SCHEMATIC &aSchematic, const DOWNGRADE_TARGET &aTarget)
Schematic-wide structure the per-screen rules cannot see. Does not modify it.
void DowngradeScreenInPlace(SCH_SCREEN *aScreen, const DOWNGRADE_TARGET &aTarget, bool aDropInsteadOfApproximate)
Approximate or remove, in place, what the target cannot represent.
bool FlattenSchematicVariant(SCHEMATIC &aSchematic, const wxString &aVariantName, wxString *aConflict)
Bake a variant into the base attributes of every symbol and sheet.
void SaveSymbolLibraryForTarget(const std::vector< LIB_SYMBOL * > &aSymbols, const wxString &aPath, const DOWNGRADE_TARGET &aTarget)
Save a .kicad_sym library stamped for the target.
COMPATIBILITY_REPORT ClassifyLibSymbolForDowngrade(const LIB_SYMBOL *aSymbol, const DOWNGRADE_TARGET &aTarget, bool aDropInsteadOfApproximate)
Report what a library symbol would lose if exported to an older KiCad. Does not modify it.
void DowngradeLibSymbolInPlace(LIB_SYMBOL *aSymbol, const DOWNGRADE_TARGET &aTarget, bool aDropInsteadOfApproximate)
Symbol-scoped downgrade for standalone .kicad_sym files the screen pass never sees.
void SaveSchematicForTarget(SCH_SHEET *aSheet, SCHEMATIC *aSchematic, const wxString &aPath, const DOWNGRADE_TARGET &aTarget)
Save a schematic sheet file stamped for the target, using the writer for that version.
COMPATIBILITY_REPORT ClassifyScreenForDowngrade(const SCH_SCREEN *aScreen, const DOWNGRADE_TARGET &aTarget, bool aDropInsteadOfApproximate)
Report what a schematic screen would lose if exported to an older KiCad.
constexpr int SCH_VER_VARIANTS
Format dates for rules the jobs handler applies at schematic scope.
constexpr int SCH_VER_NET_CHAINS
#define SEXPR_SYMBOL_LIB_FILE_VERSION
This file contains the file format version information for the s-expression schematic and symbol libr...
#define SEXPR_SCHEMATIC_FILE_VERSION
Schematic file version.
bool PlotSymbolToSVG(LIB_SYMBOL &aDrawSymbol, LIB_SYMBOL &aFieldsSymbol, int aUnit, int aBodyStyle, const BOX2I &aBBox, SCH_RENDER_SETTINGS &aRenderSettings, bool aBlackAndWhite, const wxString &aFileName, REPORTER *aReporter)
Plot a single symbol variant (unit and body style) to an SVG file.
BOX2I GetSymbolPlotBBox(const LIB_SYMBOL &aSymbol, int aUnit, int aBodyStyle, bool aIncludeHiddenFields)
Compute the bounding box used to size a symbol SVG plot.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
@ SYMBOL_FILTER_NON_POWER
SCRATCH_DOC< DOC > LoadScratchDoc(SETTINGS_MANAGER &aMgr, const wxString &aDocPath, Loader aLoader, ClearFn aClearFn)
Construct a SCRATCH_DOC by loading a project non-active and then handing it to the caller's document ...
COLOR_SETTINGS * GetColorSettings(const wxString &aName)
T * GetAppSettings(const char *aFilename)
std::vector< FAB_LAYER_COLOR > dummy
MODEL3D_FORMAT_TYPE fileType(const char *aFileName)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
bool includeByteOrderMark
static std::vector< BOM_FMT_PRESET > BuiltInPresets()
wxString refRangeDelimiter
Phase 8 context for the conflict canvas.
KICAD_DIFF::DOCUMENT_GEOMETRY ancestorGeometry
wxString formatNotice
Shown with the instructions when the merge cannot keep a side's file format.
std::map< KIID_PATH, BOX2I > theirsBBoxes
KICAD_DIFF::DOCUMENT_GEOMETRY oursGeometry
std::map< KIID_PATH, BOX2I > oursBBoxes
std::function< void(WIDGET_DIFF_CANVAS &, SIDE, const std::optional< KIID_PATH > &)> drawSide
Draw a side on the canvas with the editor's own painter.
KICAD_DIFF::DOCUMENT_GEOMETRY theirsGeometry
std::function< wxString(const KIID_PATH &)> describeItem
Name an item the way the editor would, so a conflict can be told from its neighbours.
An older KiCad release we can export a project back to.
int m_schVersion
SEXPR_SCHEMATIC_FILE_VERSION for the target.
int m_symLibVersion
SEXPR_SYMBOL_LIB_FILE_VERSION for the target.
wxString m_name
User-facing name, e.g. "KiCad 10.0".
std::vector< BOM_PRESET > m_BomPresets
std::vector< BOM_FMT_PRESET > m_BomFmtPresets
Import provenance, held only for the lifetime of the importing SCHEMATIC.
Diff colors with defaults for light backgrounds.
KIGFX::COLOR4D reference
Default color for source-document context geometry.
KIGFX::COLOR4D comparison
Describes how a computed DOCUMENT_DIFF should be emitted by a diff job.
std::function< DOCUMENT_GEOMETRY(const KIGFX::COLOR4D &)> comparisonGeometry
DOC_KIND docKind
Source document type, propagated onto the scene so the PNG/SVG renderer sizes its viewport with the m...
std::function< DOCUMENT_GEOMETRY(const KIGFX::COLOR4D &)> referenceGeometry
The full set of changes between two parsed documents of one type.
Aggregate of background geometry extracted from one source document.
One change record on a single item.
std::optional< wxString > refdes
Result of planning a 3-way merge.
std::size_t ConflictCount() const
std::vector< KIID_PATH > unresolved
bool drawingSheetFileTouched
bool projectFileTouched
True iff the applier resolved state that lives in the .kicad_pro.
bool ercSeveritiesTouched
std::size_t sheetActionsSkipped
Number of actions skipped because they targeted a SCH_SHEET.
VALIDATION_REPORT validation
Post-apply validator pipeline result.
Outcome of a single validator run.
std::vector< VALIDATION_FAILURE > failures
SCRATCH_DOC< SCHEMATIC > emptyA
KICAD_DIFF::DOCUMENT_DIFF diff
SCRATCH_DOC< SCHEMATIC > b
SCRATCH_DOC< SCHEMATIC > a
SCRATCH_DOC< SCHEMATIC > emptyB
std::vector< wxString > m_plotPages
DXF_UNITS m_DXF_File_Unit
wxString m_outputDirectory
std::optional< SCH_SHEET_PATH > m_sheetPath
bool m_PDFHierarchicalLinks
bool m_useBackgroundColor
Move-only RAII wrapper for "load a KiCad document into a non-active scratch PROJECT and clean up afte...
std::unique_ptr< DOC > doc
Hold a name of a symbol's field, field value, and default visibility.
Information about a top-level schematic sheet.
~TRANSIENT_PROJECT_GUARD()
SYMBOL_IMPORT_RECONCILE_RESULT ReconcileImportedSymbols(SCH_IO &aPlugin, SCHEMATIC &aSchematic, PROJECT &aProject, const wxString &aSchematicPath, const std::map< std::string, UTF8 > *aProperties, REPORTER &aReporter)
Reconcile aSchematic against the definitions aPlugin retained while loading it.
std::map< wxString, LIB_SYMBOL *, LibSymbolMapSort > LIB_SYMBOL_MAP
Symbol library map sorted by the symbol name.
wxString GetDefaultFieldName(FIELD_T aFieldId, TRANSLATION aTranslation)
Return a default symbol field name for a mandatory field type.
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
wxString result
Test unit parsing edge cases and error handling.
Definition of file extensions used in Kicad.