119 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
125 wxCHECK( bomJob && editFrame,
false );
135 [](
JOB* job, wxWindow* aParent ) ->
bool
140 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
146 wxCHECK( netJob && editFrame,
false );
152 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
158 wxCHECK(
plotJob && editFrame,
false );
163 _(
"Plotting to HPGL is no longer supported as of KiCad 10.0." ) );
171 [](
JOB* job, wxWindow* aParent ) ->
bool
176 [](
JOB* job, wxWindow* aParent ) ->
bool
181 [](
JOB* job, wxWindow* aParent ) ->
bool
186 [](
JOB* job, wxWindow* aParent ) ->
bool
191 [](
JOB* job, wxWindow* aParent ) ->
bool
195 wxCHECK( ercJob,
false );
201 [](
JOB* job, wxWindow* aParent ) ->
bool
206 [](
JOB* job, wxWindow* aParent ) ->
bool
211 [](
JOB* job, wxWindow* aParent ) ->
bool
233 if( !
Pgm().IsGUI() &&
Pgm().GetSettingsManager().IsProjectOpenNotDummy() )
236 wxString schPath = aPath;
238 if( schPath.IsEmpty() )
243 schPath =
path.GetFullPath();
258 else if(
Pgm().IsGUI() &&
Pgm().GetSettingsManager().IsProjectOpen() )
265 else if( !aPath.IsEmpty() )
268 aPath,
true,
false,
nullptr,
true, aRequireRoot ?
m_reporter :
nullptr );
278 SCHEMATIC* aSch,
const wxString& aDrawingSheetOverride )
298 auto loadSheet = [&](
const wxString&
path ) ->
bool
303 { aSch->GetEmbeddedFiles() }, &msg ) )
305 m_reporter->Report( wxString::Format(
_(
"Error loading drawing sheet '%s'." ),
path ) + wxS(
"\n" ) + msg
315 if( !aDrawingSheetOverride.IsEmpty() && loadSheet( aDrawingSheetOverride ) )
352 wxString variantName;
359 if( !variantName.IsEmpty() && variantName != wxS(
"all" ) )
362 std::unique_ptr<SCH_RENDER_SETTINGS> renderSettings = std::make_unique<SCH_RENDER_SETTINGS>();
373 renderSettings->SetDefaultFont( font );
383 for(
SCH_ITEM* item : screen->Items() )
386 for(
const auto& [libItemName, libSymbol] : screen->GetLibSymbols() )
387 libSymbol->ClearCaches();
390 std::unique_ptr<SCH_PLOTTER> schPlotter = std::make_unique<SCH_PLOTTER>( sch );
416 fn.SetName( fn.GetName() );
459 if( !variantName.IsEmpty() )
472 schPlotter->Plot( format, plotOpts, renderSettings.get(),
m_reporter );
477 for(
const wxString& outputPath : schPlotter->GetOutputFilePaths() )
504 if( variantName != wxS(
"all" ) )
521 m_reporter->Report(
_(
"Warning: schematic has annotation errors, please use the "
522 "schematic editor to fix them\n" ),
530 if(
erc.TestDuplicateSheetNames(
false ) > 0 )
533 std::unique_ptr<NETLIST_EXPORTER_BASE> helper;
534 unsigned netlistOption = 0;
542 helper = std::make_unique<NETLIST_EXPORTER_KICAD>( sch,
m_kiway );
547 helper = std::make_unique<NETLIST_EXPORTER_ORCADPCB2>( sch,
m_kiway );
552 helper = std::make_unique<NETLIST_EXPORTER_CADSTAR>( sch,
m_kiway );
558 helper = std::make_unique<NETLIST_EXPORTER_SPICE>( sch,
m_kiway );
563 helper = std::make_unique<NETLIST_EXPORTER_SPICE_MODEL>( sch,
m_kiway );
567 fileExt = wxS(
"xml" );
568 helper = std::make_unique<NETLIST_EXPORTER_XML>( sch,
m_kiway );
572 fileExt = wxS(
"asc" );
573 helper = std::make_unique<NETLIST_EXPORTER_PADS>( sch,
m_kiway );
577 fileExt = wxS(
"txt" );
578 helper = std::make_unique<NETLIST_EXPORTER_ALLEGRO>( sch,
m_kiway );
589 fn.SetName( fn.GetName() );
590 fn.SetExt( fileExt );
603 bool res = helper->WriteNetlist( outPath, netlistOption, *
m_reporter );
630 if( !currentVariant.IsEmpty() && currentVariant != wxS(
"all" ) )
642 if(
copy.CheckAnnotation(
649 m_reporter->Report(
_(
"Warning: schematic has annotation errors, please use the schematic "
650 "editor to fix them\n" ),
658 if(
erc.TestDuplicateSheetNames(
false ) > 0 )
688 std::set<wxString> userFieldNames;
690 for(
size_t i = 0; i < referenceList.
GetCount(); ++i )
692 SCH_SYMBOL* symbol = referenceList[i].GetSymbol();
696 if( !field.IsMandatory() && !field.IsPrivate() )
697 userFieldNames.insert( field.GetName() );
701 for(
const wxString& fieldName : userFieldNames )
708 if( userFieldNames.count( templateFieldname.m_Name ) == 0 )
721 std::optional<BOM_PRESET> schPreset;
723 for(
const BOM_PRESET& p : BOM_PRESET::BuiltInPresets() )
744 wxString::Format(
_(
"BOM preset '%s' not found" ) + wxS(
"\n" ), aBomJob->
m_bomPresetName ),
758 auto normalizeFieldName = [&dataModel](
const wxString& aName ) -> wxString
760 if( aName.IsEmpty() )
761 return wxEmptyString;
766 wxString wrapped = wxS(
"${" ) + aName + wxS(
"}" );
778 wxString fieldName = normalizeFieldName( rawFieldName );
780 if( fieldName.IsEmpty() )
788 if( fieldName == wxS(
"*" ) )
794 field.
name = modelField.name;
799 bool fieldAlreadyPresent =
false;
801 for(
BOM_FIELD& presetField : preset.fieldsOrdered )
803 if( presetField.
name == field.
name )
805 fieldAlreadyPresent =
true;
810 bool fieldLaterInList =
false;
814 if( normalizeFieldName( fieldInList ) == field.
name )
816 fieldLaterInList =
true;
821 if( !fieldAlreadyPresent && !fieldLaterInList )
822 preset.fieldsOrdered.emplace_back( field );
830 field.
name = fieldName;
831 field.
show = !fieldName.StartsWith( wxT(
"__" ), &field.
name );
832 field.
name = normalizeFieldName( field.
name );
841 preset.fieldsOrdered.emplace_back( field );
847 wxString fieldName = rawFieldName;
848 fieldName.StartsWith( wxT(
"__" ), &fieldName );
849 fieldName = normalizeFieldName( fieldName );
851 if( fieldName.IsEmpty() )
854 bool fieldAlreadyPresent =
false;
856 for(
BOM_FIELD& field : preset.fieldsOrdered )
858 if( field.
name == fieldName )
861 fieldAlreadyPresent =
true;
866 if( !fieldAlreadyPresent )
871 preset.sortField = normalizeFieldName( aBomJob->
m_sortField );
883 std::optional<BOM_FMT_PRESET> schFmtPreset;
905 m_reporter->Report( wxString::Format(
_(
"BOM format preset '%s' not found" ) + wxS(
"\n" ),
928 fn.SetName( fn.GetName() );
935 bool hasVariantPlaceholder = configuredPath.Contains( wxS(
"${VARIANT}" ) );
938 std::vector<wxString> variantsToProcess;
946 variantsToProcess.push_back( currentVariant );
949 for(
const wxString& variantName : variantsToProcess )
951 std::vector<wxString> singleVariant = { variantName };
959 if( hasVariantPlaceholder )
961 wxString variantPath = configuredPath;
962 variantPath.Replace( wxS(
"${VARIANT}" ), variantName );
980 if( !f.Open( outPath, wxFile::write ) )
982 m_reporter->Report( wxString::Format(
_(
"Unable to open destination '%s'" ), outPath ),
988 bool res = f.Write( dataModel.
Export( fmt ) );
1029 m_reporter->Report(
_(
"Warning: schematic has annotation errors, please use the "
1030 "schematic editor to fix them\n" ),
1038 if(
erc.TestDuplicateSheetNames(
false ) > 0 )
1041 std::unique_ptr<NETLIST_EXPORTER_XML> xmlNetlist = std::make_unique<NETLIST_EXPORTER_XML>( sch,
m_kiway );
1046 fn.SetName( fn.GetName() +
"-bom" );
1078 std::shared_ptr<LIB_SYMBOL> parent;
1088 symbolToPlot = parent.get();
1092 for(
int unit = 1; unit < symbol->
GetUnitCount() + 1; unit++ )
1104 for( wxChar c : wxFileName::GetForbiddenChars( wxPATH_DOS ) )
1105 filename.Replace( c,
' ' );
1110 filename += wxString::Format(
"_unit%d", unit );
1114 if( bodyStyle == 2 )
1115 filename += wxS(
"_demorgan" );
1122 fn.SetName( filename );
1123 m_reporter->Report( wxString::Format(
_(
"Plotting symbol '%s' unit %d to '%s'\n" ), symbol->
GetName(),
1124 unit, fn.GetFullPath() ),
1129 if( !
PlotSymbolToSVG( *symbolToPlot, *symbol, unit, bodyStyle, symbolBB, *aRenderSettings,
1155 wxString singleFileFilter;
1157 auto schLibrary = std::make_unique<SCH_IO_KICAD_SEXPR_LIB_CACHE>( fn.GetFullPath() );
1167 bool recovered =
false;
1169 if( !fn.IsDir() && wxDir::Exists( fn.GetPath() ) )
1173 schLibrary = std::make_unique<SCH_IO_KICAD_SEXPR_LIB_CACHE>( fn.GetPath() );
1175 singleFileFilter = fn.GetFullPath();
1199 symbol = schLibrary->GetSymbol( svgJob->
m_symbol );
1212 m_reporter->Report( wxString::Format(
_(
"Unable to create output directory '%s'." ) + wxS(
"\n" ),
1236 const std::map<wxString, wxString>& sourceFiles = schLibrary->GetSymbolSourceFiles();
1237 const wxFileName filterFile( singleFileFilter );
1239 for(
const auto& [
name, libSymbol] : libSymMap )
1242 if( !singleFileFilter.IsEmpty() )
1244 auto srcIt = sourceFiles.find(
name );
1246 if( srcIt == sourceFiles.end() || !wxFileName( srcIt->second ).SameAs( filterFile ) )
1287 else if(
fileType != SCH_IO_MGR::SCH_KICAD )
1289 m_reporter->Report(
_(
"Output path must be specified to convert legacy and non-KiCad libraries\n" ),
1295 if(
fileType == SCH_IO_MGR::SCH_KICAD )
1368 fn.SetName( fn.GetName() + wxS(
"-erc" ) );
1398 std::shared_ptr<SHEETLIST_ERC_ITEMS_PROVIDER> markersProvider =
1399 std::make_shared<SHEETLIST_ERC_ITEMS_PROVIDER>( sch );
1415 if( editFrame && &editFrame->
Schematic() != sch )
1416 editFrame =
nullptr;
1428 markersProvider->SetSeverities( ercJob->
m_severity );
1430 m_reporter->Report( wxString::Format(
_(
"Found %d violations\n" ), markersProvider->GetCount() ),
1433 ERC_REPORT reportWriter( sch, units, markersProvider );
1435 bool wroteReport =
false;
1452 if( markersProvider->GetCount() > 0 )
1464 if( aUpgradeJob ==
nullptr )
1472 bool shouldSave = aUpgradeJob->
m_force;
1484 wxFileName schPath( aUpgradeJob->
m_filename );
1485 schPath.MakeAbsolute();
1486 const wxString schFullPath = schPath.GetFullPath();
1491 SCH_SHEET* loadedSheet = pi->LoadSchematicFile( schFullPath, sch );
1492 pi->SaveSchematicFile( schFullPath, loadedSheet, sch );
1497 wxString::Format(
_(
"Error saving schematic file '%s'.\n%s" ), schFullPath, ioe.
What().GetData() );
1527 wxArrayString files;
1528 wxDir::GetAllFiles( aDir, &files, wxT(
"*.kicad_sym" ) );
1530 for(
const wxString& file : files )
1538 std::vector<LIB_SYMBOL*> symbols;
1557 bool aDropInsteadOfApproximate,
1559 wxString* aRecoveryError =
nullptr )
1564 std::vector<LIB_SYMBOL*> symbols;
1568 std::stable_sort( symbols.begin(), symbols.end(),
1571 return a->GetInheritanceDepth() < b->GetInheritanceDepth();
1583 [&](
const wxString& aText )
1585 return FindUnsupportedSchToken( aText, aTarget );
1587 convert, aTransaction, aRecoveryError );
1595 if( job ==
nullptr )
1601 if( target ==
nullptr )
1603 m_reporter->Report( wxString::Format(
_(
"Unknown target version '%s'. Valid targets: %s\n" ), job->
m_target,
1618 wxString libraryCopyDir;
1619 wxString outputError;
1623 wxFileName output = wxFileName::DirName( job->
m_outputDir );
1625 if( job->
m_outputDir.IsEmpty() || !output.MakeAbsolute()
1628 if( outputError.IsEmpty() )
1629 outputError =
_(
"An output folder is required. Use --output." );
1658 auto prepareOutput = [&]() ->
bool
1669 if( !libraryCopyDir.IsEmpty() )
1677 libraryWorkDir = libraryCopyDir;
1690 wxString recoveryError;
1692 aTransaction, &recoveryError );
1694 if( !badLib.IsEmpty() )
1696 m_reporter->Report( wxString::Format(
_(
"Cannot export: symbol library '%s' uses a feature %s "
1698 badLib, target->
m_name ),
1701 if( !recoveryError.IsEmpty() )
1710 wxString::Format(
_(
"Error downgrading symbol libraries.\n%s" ), ioe.
What().GetData() ),
1736 m_reporter->Report(
_(
"Cannot export: the libraries use features the target cannot represent.\n" ),
1743 m_reporter->Report(
_(
"Export would lose data. Re-run with --force to export anyway.\n" ),
1752 if( !prepareOutput() )
1755 int result = downgradeLibraries();
1758 outputDirectories.
Commit();
1765 schInputFn.MakeAbsolute();
1776 bool createdTransientProject =
false;
1780 mgr.
LoadProject( projectFn.GetFullPath(),
false );
1781 projectPtr = mgr.
GetProject( projectFn.GetFullPath() );
1782 createdTransientProject = ( projectPtr != nullptr );
1803 if(
auto storedRoots = projectFile.
GetJson(
"schematic.top_level_sheets" ); storedRoots && storedRoots->is_array() )
1805 for(
const auto&
info : *storedRoots )
1807 if( !
info.contains(
"filename" ) || !
info[
"filename"].is_string() )
1810 const wxString filename = wxString::FromUTF8(
info[
"filename"].get<std::string>() );
1811 wxFileName rootFile( filename );
1814 if( filename.IsEmpty() || !rootFile.FileExists() )
1816 m_reporter->Report( wxString::Format(
_(
"Cannot export: top-level schematic '%s' is missing.\n" ),
1817 rootFile.GetFullPath() ),
1827 std::unique_ptr<SCHEMATIC> owned = std::make_unique<SCHEMATIC>( projectPtr );
1828 owned->CreateDefaultScreens();
1831 struct SCH_PROJECT_GUARD
1839 ~SCH_PROJECT_GUARD()
1855 } schProjectGuard{ sch, projectPtr, createdTransientProject, savedErc, savedSch };
1870 if( !pi->GetError().IsEmpty() )
1872 m_reporter->Report( wxString::Format(
_(
"Cannot export: the schematic did not load "
1873 "completely.\n%s" ),
1882 bool rootIsTopLevel = std::find( topLevelSheets.begin(), topLevelSheets.end(), root ) != topLevelSheets.end();
1884 bool changed =
false;
1886 if( !rootIsTopLevel && !rootIsVirtualRoot )
1888 topLevelSheets = { root };
1894 if( !rootIsVirtualRoot )
1904 SCH_SHEET* sibling = pi->LoadSchematicFile( fn.GetFullPath(), sch );
1906 if( !sibling || !pi->GetError().IsEmpty() )
1908 m_reporter->Report( wxString::Format(
_(
"Cannot export: the schematic did not load "
1909 "completely.\n%s" ),
1919 topLevelSheets.push_back( sibling );
1936 std::set<SCH_SCREEN*> seen;
1937 std::vector<std::pair<SCH_SHEET*, SCH_SCREEN*>> screens;
1944 if( screen && seen.insert( screen ).second )
1945 screens.emplace_back( sheet, screen );
1962 m_reporter->Report(
_(
"The target supports variants, so there is nothing to flatten.\n" ),
1969 m_reporter->Report( wxString::Format(
_(
"The schematic has no variant named '%s'.\n" ), job->
m_variant ),
1979 wxString::Format(
_(
"Cannot export selected variant '%s': %s" ), job->
m_variant, conflict )
1986 for(
const auto& [sheet, screen] : screens )
2003 wxString rootContent;
2004 wxFFile rootFile( job->
m_filename, wxT(
"rb" ) );
2006 if( rootFile.IsOpened() && rootFile.ReadAll( &rootContent ) && rootContent.Contains( wxT(
"(net_chain" ) ) )
2009 _(
"No equivalent in the target. Net chain grouping is removed." ), 1 );
2026 m_reporter->Report(
_(
"Cannot export: the schematic uses features the target cannot represent.\n" ),
2033 m_reporter->Report(
_(
"Export would lose data. Re-run with --force to export anyway.\n" ),
2038 if( !libraryCopyDir.IsEmpty() )
2041 base.MakeAbsolute();
2042 const wxString rootPrefix = wxFileName::DirName( base.GetPath() ).GetPathWithSep();
2043 std::vector<wxString> destinations;
2045 for(
const auto& [sheet, screen] : screens )
2047 wxFileName
source( screen->GetFileName() );
2049 if( !
source.IsAbsolute() )
2050 source.MakeAbsolute( base.GetPath() );
2052 source.Normalize( wxPATH_NORM_DOTS );
2053 const wxString sourcePath =
source.GetFullPath();
2054 const bool contained = wxFileName::IsCaseSensitive() ? sourcePath.StartsWith( rootPrefix )
2055 : sourcePath.Lower().StartsWith( rootPrefix.Lower() );
2060 wxString::Format(
_(
"Cannot export: sheet '%s' lies outside the project folder.\n" ),
2066 destinations.push_back( job->
m_outputDir + wxFileName::GetPathSeparator()
2067 + sourcePath.Mid( rootPrefix.length() ) );
2070 wxFileName projectOutput = projectFn;
2072 destinations.push_back( projectOutput.GetFullPath() );
2073 std::error_code error;
2083 for(
const wxString& destination : destinations )
2094 wxString libraryPath =
library;
2096 if( !wxFileName::IsCaseSensitive() )
2099 libraryPath.MakeLower();
2102 const wxString separator( wxFileName::GetPathSeparator() );
2104 if(
path == libraryPath ||
path.StartsWith( libraryPath + separator )
2105 || libraryPath.StartsWith(
path + separator ) )
2107 m_reporter->Report(
_(
"The copied library folder overlaps a schematic or project output path. "
2108 "Choose a different library folder.\n" ),
2115 if( !prepareOutput() )
2122 for(
const wxString&
name : variants )
2128 wxString currentTemp;
2133 base.MakeAbsolute();
2135 for(
const auto& [sheet, screen] : screens )
2139 wxFileName screenFn( screen->GetFileName() );
2141 if( !screenFn.IsAbsolute() )
2142 screenFn.MakeAbsolute( base.GetPath() );
2145 screenFn.Normalize( wxPATH_NORM_DOTS );
2149 wxFileName rootDir( base.GetPath(), wxEmptyString );
2151 wxString screenPath = screenFn.GetFullPath();
2152 wxString rootPrefix = rootDir.GetPathWithSep();
2155 bool contained = wxFileName::IsCaseSensitive() ? screenPath.StartsWith( rootPrefix )
2156 : screenPath.Lower().StartsWith( rootPrefix.Lower() );
2160 m_reporter->Report( wxString::Format(
_(
"Cannot export: sheet '%s' lies outside the project "
2162 screenFn.GetFullPath() ),
2167 wxString finalPath = screenFn.GetFullPath();
2173 wxFileName destFn( job->
m_outputDir + wxFileName::GetPathSeparator()
2174 + screenPath.Mid( rootPrefix.length() ) );
2176 if( !wxDirExists( destFn.GetPath() )
2177 && !wxFileName::Mkdir( destFn.GetPath(), wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
2180 wxString::Format(
_(
"Could not create the output folder '%s'.\n" ), destFn.GetPath() ),
2185 finalPath = destFn.GetFullPath();
2191 currentTemp = transaction.
Stage( finalPath );
2193 if( currentTemp.IsEmpty() )
2198 wxString unsupported;
2202 [&](
const wxString& aText )
2204 return FindUnsupportedSchToken( aText, *target );
2210 if( !unsupported.IsEmpty() )
2211 m_reporter->Report( wxString::Format(
_(
"Cannot export: the result still uses '%s', which %s "
2212 "cannot open. This feature has no downgrade rule "
2214 unsupported, target->
m_name ),
2218 wxString::Format(
_(
"Cannot export: could not verify '%s'.\n" ), screenFn.GetFullPath() ),
2224 currentTemp.Clear();
2229 nlohmann::json document = nlohmann::json::object();
2232 if( projectFn.FileExists() )
2234 wxFFile sourceProject( projectFn.GetFullPath(), wxT(
"rb" ) );
2236 if( !sourceProject.IsOpened() || !sourceProject.ReadAll( &content ) )
2237 THROW_IO_ERROR(
_(
"Could not read the schematic project settings." ) );
2241 document = nlohmann::json::parse( content.ToStdString( wxConvUTF8 ) );
2243 catch(
const nlohmann::json::exception& )
2245 THROW_IO_ERROR(
_(
"Could not read the schematic project settings." ) );
2249 if( !document.is_object() )
2252 nlohmann::json aliases = nlohmann::json::object();
2256 nlohmann::json members = nlohmann::json::array();
2258 for(
const wxString& member : alias->Members() )
2259 members.push_back( member.ToStdString( wxConvUTF8 ) );
2261 aliases[alias->GetName().ToStdString( wxConvUTF8 )] = std::move( members );
2264 if( !document.contains(
"schematic" ) || !document[
"schematic"].is_object() )
2265 document[
"schematic"] = nlohmann::json::object();
2267 nlohmann::json& schematicSettings = document[
"schematic"];
2269 || schematicSettings.value(
"bus_aliases", nlohmann::json::object() ) != aliases;
2273 schematicSettings[
"bus_aliases"] = std::move( aliases );
2274 nlohmann::json roots = nlohmann::json::array();
2278 wxFileName filename( root.filename );
2280 filename.MakeRelativeTo( base.GetPath() );
2281 roots.push_back( { {
"uuid", root.uuid.AsString().ToStdString( wxConvUTF8 ) },
2282 {
"name", root.name.ToStdString( wxConvUTF8 ) },
2283 {
"filename", filename.GetFullPath().ToStdString( wxConvUTF8 ) } } );
2286 schematicSettings[
"top_level_sheets"] = roots;
2288 if( !document.contains(
"meta" ) )
2289 document[
"meta"] = { {
"version", 3 } };
2291 wxFileName destination = projectFn;
2296 wxString finalPath = destination.GetFullPath();
2300 currentTemp = transaction.
Stage( finalPath );
2302 if( currentTemp.IsEmpty() )
2303 THROW_IO_ERROR(
_(
"Could not stage the schematic project settings." ) );
2305 wxFFile outputProject( currentTemp, wxT(
"wb" ) );
2307 if( !outputProject.IsOpened()
2308 || !outputProject.Write( wxString::FromUTF8( ( document.dump( 2 ) +
"\n" ).c_str() ) )
2309 || !outputProject.Close() )
2311 THROW_IO_ERROR(
_(
"Could not save the schematic project settings." ) );
2314 currentTemp.Clear();
2321 wxString::Format(
_(
"Error saving schematic file '%s'.\n%s" ), job->
m_filename, ioe.
What().GetData() ),
2329 wxString failedDestination = transaction.
Commit();
2331 if( !failedDestination.IsEmpty() )
2333 m_reporter->Report( wxString::Format(
_(
"Could not replace '%s'.\n" ), failedDestination ),
2342 outputDirectories.
Commit();
2366 SCH_IO_MGR::SCH_FILE_T
fileType = SCH_IO_MGR::SCH_FILE_UNKNOWN;
2387 if(
fileType == SCH_IO_MGR::SCH_FILE_UNKNOWN )
2390 m_reporter->Report( wxString::Format(
_(
"No schematic importer recognizes the file format "
2399 if( outputPath.IsEmpty() )
2403 inputFn.MakeAbsolute();
2405 wxFileName outputFn( outputPath );
2406 outputFn.MakeAbsolute();
2412 PROJECT* projectPtr =
nullptr;
2413 bool createdTransientProject =
false;
2417 projectPtr = &mgr.
Prj();
2421 wxFileName projectFn( outputFn );
2425 projectPtr = mgr.
GetProject( projectFn.GetFullPath() );
2426 createdTransientProject = ( projectPtr != nullptr );
2431 m_reporter->Report(
_(
"Could not establish a project for the import\n" ),
2444 std::unique_ptr<SCHEMATIC> schematic = std::make_unique<SCHEMATIC>( &
project );
2457 m_reporter->Report( wxString::Format(
_(
"No plugin found for file type '%s'\n" ),
2464 pi->SetReporter( &importMessages );
2468 m_reporter->Report( wxString::Format(
_(
"Importing '%s' using %s format...\n" ),
2469 inputFn.GetFullPath(), formatName ),
2472 loadedSheet = pi->LoadSchematicFile( inputFn.GetFullPath(), schematic.get() );
2482 m_reporter->Report( wxString::Format(
_(
"Error during import: %s\n" ), ioe.
What() ),
2487 size_t symbolCount = 0;
2488 size_t sheetCount = 0;
2494 std::vector<SCH_SHEET*> topLevelSheets = schematic->GetTopLevelSheets();
2495 bool loadedIsTopLevel = std::find( topLevelSheets.begin(), topLevelSheets.end(),
2496 loadedSheet ) != topLevelSheets.end();
2497 bool loadedIsVirtualRoot = loadedSheet == &schematic->Root()
2500 if( !loadedIsTopLevel && !loadedIsVirtualRoot )
2501 schematic->SetTopLevelSheets( { loadedSheet } );
2509 std::unique_ptr<TOOL_MANAGER> toolManager = std::make_unique<TOOL_MANAGER>();
2510 toolManager->SetEnvironment( schematic.get(),
nullptr,
nullptr,
Kiface().KifaceSettings(),
2515 schematic->RecalculateConnections( &dummyCommit,
GLOBAL_CLEANUP, toolManager.get() );
2519 schematic->SetSheetNumberAndCount();
2523 schematic->Settings().m_SchDrawingSheetFileName = wxS(
"empty.kicad_wks" );
2526 if(
SCH_SHEET* topSheet = schematic->GetTopLevelSheet() )
2527 topSheet->SetFileName( outputFn.GetFullName() );
2529 schematic->RootScreen()->SetFileName( outputFn.GetFullPath() );
2533 std::unordered_map<SCH_SCREEN*, wxString> filenameMap;
2534 filenameMap[schematic->RootScreen()] = outputFn.GetFullPath();
2540 filenameMap, errorMsg ) )
2550 for(
size_t i = 0; i < screens.
GetCount(); i++ )
2553 wxString
path = filenameMap[screen];
2555 if(
path.IsEmpty() )
2558 wxFileName fn(
path );
2561 kicadPi->SaveSchematicFile( fn.GetFullPath(), screens.
GetSheet( i ), schematic.get() );
2565 symbolCount += std::distance( symbols.begin(), symbols.end() );
2570 m_reporter->Report( wxString::Format(
_(
"Error saving imported schematic: %s\n" ),
2575 catch(
const std::exception& exc )
2577 m_reporter->Report( wxString::Format(
_(
"Error saving imported schematic: %s\n" ),
2587 m_reporter->Report( wxString::Format(
_(
"Successfully saved imported schematic to '%s'\n" ),
2588 outputFn.GetFullPath() ),
2592 if(
Pgm().GetSettingsManager().IsProjectOpenNotDummy() )
2594 std::vector<FILE_INFO_PAIR>& projectSheets =
project.GetProjectFile().GetSheets();
2595 projectSheets.clear();
2602 projectSheets.emplace_back( std::make_pair( sheet->
m_Uuid, sheet->
GetName() ) );
2606 const std::vector<SCH_SHEET*>& topLevelSheets = schematic->GetTopLevelSheets();
2608 if( !topLevelSheets.empty() )
2610 std::vector<TOP_LEVEL_SHEET_INFO>& infos =
project.GetProjectFile().GetTopLevelSheets();
2613 wxString projectPath =
project.GetProjectPath();
2615 for(
SCH_SHEET* sheet : topLevelSheets )
2617 if( !sheet || !sheet->GetScreen() )
2620 wxFileName sheetFn( sheet->GetScreen()->GetFileName() );
2622 if( sheetFn.IsAbsolute() )
2623 sheetFn.MakeRelativeTo( projectPath );
2625 infos.emplace_back( sheet->m_Uuid, sheet->GetName(), sheetFn.GetFullPath() );
2631 if( createdTransientProject && schematic->GetTopLevelSheets().size() > 1 )
2633 m_reporter->Report( wxString::Format(
_(
"%zu sheets were written, but only '%s' is "
2634 "reachable: top-level sheets are recorded in a "
2635 "project file. Use 'kicad-cli import' to create "
2637 sheetCount, outputFn.GetFullName() ),
2641 IMPORT_REPORT_DATA reportData;
2646 reportData.m_sourceFile = inputFn.GetFullName();
2647 reportData.m_sourceFormat = formatName;
2648 reportData.m_outputFile = outputFn.GetFullName();
2649 reportData.m_statistics = {
2650 { wxS(
"symbols" ), symbolCount },
2651 { wxS(
"sheets" ), sheetCount }
2654 reportData.m_statistics.emplace_back( wxS(
"renamed_board_nets" ), job->
m_netNameMap.size() );
2685 return drawingSheet;
2717 return std::unique_ptr<SCHEMATIC>(
2725 aSch->SetProject(
nullptr );
2736 wxFileName synthetic( wxFileName::GetTempDir(),
2737 wxString::Format( wxS(
"%s_%ld_%p" ), aTag,
static_cast<long>( wxGetProcessId() ), &aMgr ) );
2740 aMgr, synthetic.GetFullPath(),
2743 auto sch = std::make_unique<SCHEMATIC>( aProject );
2744 sch->CreateDefaultScreens();
2749 aSch->SetProject( nullptr );
2792 return diffExitCode;
2820 std::vector<std::unique_ptr<LIB_SYMBOL>>& aOwners,
2824 if( aAllowEmpty && aPath.IsEmpty() )
2830 aOwners = std::move( loaded.first );
2831 aMap = std::move( loaded.second );
2836 aReporter.
Report( wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, ioe.
What() ),
2839 catch(
const std::exception& e )
2842 wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, wxString::FromUTF8( e.what() ) ),
2857 for(
const auto& [
name, symbol] : aMap )
2874 std::vector<std::unique_ptr<LIB_SYMBOL>> ownersA;
2875 std::vector<std::unique_ptr<LIB_SYMBOL>> ownersB;
2897 return diffExitCode;
2941 if( !aSides.
a.
doc && !aFileA.IsEmpty() )
2947 if( !aSides.
b.
doc && !aFileB.IsEmpty() )
2989 canvas->SetContextItems( {} );
2990 canvas->SetContextPainter(
3013 auto context = std::make_unique<SCH_DIFF_CANVAS_CONTEXT>( aBefore, aAfter );
3022 SCHEMATIC* schA = context->m_sides.schA;
3023 SCHEMATIC* schB = context->m_sides.schB;
3030 aDiff = context->m_sides.diff;
3031 return context.release();
3036 const wxString& aFileB,
const wxString& aLabelA,
3037 const wxString& aLabelB, wxWindow* aParent,
3045 wxWindow* parent = aParent ? aParent : ( wxTheApp ? wxTheApp->GetTopWindow() :
nullptr );
3071 const wxString labelA = aLabelA.IsEmpty() ? aFileA : aLabelA;
3072 const wxString labelB = aLabelB.IsEmpty() ? aFileB : aLabelB;
3076 std::map<KIID_PATH, std::set<KIID>> removedBySheet;
3083 sheetPath.pop_back();
3084 removedBySheet[sheetPath].insert( change.
id.back() );
3092 SCH_SCREEN* compScreen = schB ? schB->RootScreen() : nullptr;
3094 if( !aSheetPath.empty() && schB )
3096 if( auto sp = schB->Hierarchy().GetSheetPathByKIIDPath( aSheetPath, true ) )
3097 compScreen = sp->LastScreen();
3102 if( !aSheetPath.empty() && schA )
3104 if( auto sp = schA->Hierarchy().GetSheetPathByKIIDPath( aSheetPath, true ) )
3105 refScreen = sp->LastScreen();
3108 std::vector<KIGFX::VIEW_ITEM*> deletedItems;
3109 auto removedHere = removedBySheet.find( aSheetPath );
3113 if( removedHere == removedBySheet.end() && aSheetPath.empty() && schA )
3116 rootPath.push_back( schA->Root().m_Uuid );
3117 removedHere = removedBySheet.find( rootPath );
3120 if( refScreen && removedHere != removedBySheet.end() )
3122 for( SCH_ITEM* item : refScreen->Items() )
3124 if( removedHere->second.count( item->m_Uuid ) )
3125 deletedItems.push_back( item );
3132 deletedItems, {},
nullptr, compScreen );
3140 std::vector<std::unique_ptr<LIB_SYMBOL>> ownersA;
3141 std::vector<std::unique_ptr<LIB_SYMBOL>> ownersB;
3166 m_reporter->Report(
_(
"Unsupported document kind for this dispatcher.\n" ),
RPT_SEVERITY_ERROR );
3170 const wxString labelA = aLabelA.IsEmpty() ? aFileA : aLabelA;
3171 const wxString labelB = aLabelB.IsEmpty() ? aFileB : aLabelB;
3190 const wxString& aOurs,
const wxString& aTheirs,
3191 const wxString& aOutput,
bool aInteractive,
bool aSingleFile,
3202 return runSchMerge( aAncestor, aOurs, aTheirs, aOutput, aInteractive );
3207 const wxString& aTheirs,
const wxString& aOutput,
3216 if( !ancestor.
doc || !ours.
doc || !theirs.
doc )
3226 auto hasSingleRoot = [](
const SCHEMATIC* aSch )
3228 return aSch->GetTopLevelSheets().size() == 1;
3231 if( !hasSingleRoot( ancestor.
doc.get() ) || !hasSingleRoot( ours.
doc.get() ) || !hasSingleRoot( theirs.
doc.get() ) )
3233 m_reporter->Report(
_(
"sch merge requires each input to have a single top-level sheet\n" ),
3238 auto loadedVersion = [](
const SCHEMATIC* aSch )
3240 return aSch->RootScreen() ? aSch->RootScreen()->GetFileFormatVersionAtLoad() : 0;
3243 const wxString formatNotice =
3247 if( !formatNotice.IsEmpty() )
3261 if( !
Pgm().IsGUI() )
3263 m_reporter->Report(
_(
"--interactive requires a GUI KiCad process; the console "
3264 "kicad-cli cannot open dialogs.\n" ),
3288 return wxEmptyString;
3292 for(
SCHEMATIC* doc : { ours.
doc.get(), theirs.doc.get(), ancestor.
doc.get() } )
3297 if(
SCH_ITEM* item = doc->ResolveItem( aId.back(),
nullptr,
true ) )
3298 return item->GetItemDescription( &units,
false );
3301 return wxEmptyString;
3306 auto screenForConflict = [](
SCHEMATIC* aDoc,
const std::optional<KIID_PATH>& aId ) ->
SCH_SCREEN*
3308 if( !aId.has_value() || aId->size() < 2 )
3312 sheetPath.pop_back();
3327 const std::optional<KIID_PATH>& aId )
3337 doc = theirs.doc.get();
3347 screenForConflict( doc, aId ) );
3366 if( !applier.
Apply() )
3377 m_reporter->Report(
_(
"Merge contains hierarchical sheet structure changes that sch merge "
3384 SCH_SHEET* rootSheet = ancestor.
doc->GetTopLevelSheet( 0 );
3386 wxFileName outFn( aOutput );
3387 outFn.MakeAbsolute();
3393 const wxString outDir = outFn.GetPath();
3401 std::map<wxString, SCH_SCREEN*> basenameOwner;
3403 for(
size_t i = 0; i < screens.
GetCount(); ++i )
3407 if( !screen || screen == rootScreen )
3410 const wxString basename = wxFileName( screen->
GetFileName() ).GetFullName();
3412 if( basename.IsEmpty() )
3415 auto [it, inserted] = basenameOwner.emplace( basename, screen );
3417 if( !inserted && it->second != screen )
3419 m_reporter->Report( wxString::Format(
_(
"Cannot flatten sub-sheets with duplicate "
3420 "basename '%s'\n" ),
3430 for(
size_t i = 0; i < screens.
GetCount(); ++i )
3442 if( !childScreen || childScreen == rootScreen )
3445 const wxString basename = wxFileName( childScreen->
GetFileName() ).GetFullName();
3447 if( !basename.IsEmpty() )
3455 pi->SaveSchematicFile( outFn.GetFullPath(), rootSheet, ancestor.
doc.get() );
3457 for(
size_t i = 0; i < screens.
GetCount(); ++i )
3462 if( !screen || !sheet || screen == rootScreen )
3465 const wxString basename = wxFileName( screen->
GetFileName() ).GetFullName();
3467 if( basename.IsEmpty() )
3470 wxFileName outSubFn( outDir, basename );
3471 pi->SaveSchematicFile( outSubFn.GetFullPath(), sheet, ancestor.
doc.get() );
3476 m_reporter->Report( wxString::Format(
_(
"Failed to save merged schematic: %s\n" ), ioe.
What() ),
3488 wxFileName proFn = outFn;
3505 ancestor.
doc->ErcSettings().SaveToFile( wxEmptyString,
true );
3508 ancestor.
doc->Settings().SaveToFile( wxEmptyString,
true );
3510 std::set<wxString> touched;
3520 if( !
Pgm().GetSettingsManager().SaveProjectCopy( proFn.GetFullPath(), ancestor.
project ) )
3523 wxString::Format(
_(
"Failed to save merged project file: %s\n" ), proFn.GetFullPath() ),
3534 m_reporter->Report( wxString::Format( wxS(
"%s: %s\n" ), f.validator, f.message ), f.severity );
3541 m_reporter->Report( wxString::Format(
_(
"Merge completed with %zu unresolved conflict(s) in %s\n" ),
3556#include <wx/ffile.h>
3560 const wxString& aTheirs,
const wxString& aOutput )
3562 if( aOutput.IsEmpty() )
3571 std::vector<std::unique_ptr<LIB_SYMBOL>> owners;
3575 LIB_SIDE ancestor, ours, theirs;
3577 auto loadSide = [&](
const wxString& aPath, LIB_SIDE& aSide ) ->
int
3582 aSide.owners = std::move( loaded.first );
3583 aSide.map = std::move( loaded.second );
3588 m_reporter->Report( wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, ioe.
What() ),
3591 catch(
const std::exception& e )
3594 wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, wxString::FromUTF8( e.what() ) ),
3622 std::vector<std::unique_ptr<LIB_SYMBOL>> merged = applier.
Apply();
3627 const bool hadSilentFallback = applier.
GetReport().mergePropsFallback > 0;
3631 wxFileName outFn( aOutput );
3632 outFn.MakeAbsolute();
3640 for(
auto& sym : merged )
3651 m_reporter->Report( wxString::Format(
_(
"Failed to save merged symbol library: %s\n" ), ioe.
What() ),
3657 if( !planSnapshot.
Resolved() || hadSilentFallback )
3661 std::set<KIID_PATH> conflicts( planSnapshot.
unresolved.begin(), planSnapshot.
unresolved.end() );
3664 conflicts.insert(
id );
3666 m_reporter->Report( wxString::Format(
_(
"Symbol library merge completed with %zu unresolved "
3667 "conflict(s) in %s\n" ),
3668 conflicts.size(), 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.
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 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)
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
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,...
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.
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)
void DeleteVariant(const wxString &aVariantName, SCH_COMMIT *aCommit=nullptr)
Delete all information for 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)
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.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Load a project or sets up a new project with a specified path.
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.
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
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
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 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::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.
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)
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 wxString &aOutPath, bool aSingleOutput, bool aUseOverrides)
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)
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.
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.