26#include <wx/zipstrm.h>
27#include <wx/filename.h>
28#include <wx/tokenzr.h>
29#include <wx/wfstream.h>
31#include <nlohmann/json.hpp>
147#include <api/board/board.pb.h>
148#include <google/protobuf/util/json_util.h>
171 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
177 wxCHECK( bomJob && editFrame,
false );
187 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
194 wxCHECK( svgJob && editFrame,
false );
200 [](
JOB* job, wxWindow* aParent ) ->
bool
204 wxCHECK( renderJob,
false );
210 [](
JOB* job, wxWindow* aParent ) ->
bool
215 [](
JOB* job, wxWindow* aParent ) ->
bool
220 [](
JOB* job, wxWindow* aParent ) ->
bool
225 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
232 wxCHECK( svgJob && editFrame,
false );
238 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
245 wxCHECK( gencadJob && editFrame,
false );
251 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
258 wxCHECK( dxfJob && editFrame,
false );
264 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
271 wxCHECK( pdfJob && editFrame,
false );
277 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
284 wxCHECK( pngJob && editFrame,
false );
290 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
297 wxCHECK( psJob && editFrame,
false );
303 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
310 wxCHECK( statsJob && editFrame,
false );
315 statsJob->
m_filename = boardName.GetFullPath();
318 wxWindow* parent = aParent ? aParent :
static_cast<wxWindow*
>( editFrame );
325 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
332 wxCHECK( stackupJob && editFrame,
false );
337 stackupJob->
m_filename = boardName.GetFullPath();
340 wxWindow* parent = aParent ? aParent :
static_cast<wxWindow*
>( editFrame );
347 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
354 wxCHECK( gJob && editFrame,
false );
360 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
367 wxCHECK( gJob && editFrame,
false );
376 m_reporter->Report(
_(
"Plotting to HPGL is no longer supported as of KiCad 10.0.\n" ),
380 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
384 wxCHECK( editFrame,
false );
386 DisplayErrorMessage( editFrame,
_(
"Plotting to HPGL is no longer supported as of KiCad 10.0." ) );
390 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
397 wxCHECK( drillJob && editFrame,
false );
403 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
410 wxCHECK( posJob && editFrame,
false );
416 [](
JOB* job, wxWindow* aParent ) ->
bool
421 [](
JOB* job, wxWindow* aParent ) ->
bool
426 [](
JOB* job, wxWindow* aParent ) ->
bool
431 [](
JOB* job, wxWindow* aParent ) ->
bool
436 [](
JOB* job, wxWindow* aParent ) ->
bool
440 wxCHECK( drcJob,
false );
446 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
453 wxCHECK( ipcJob && editFrame,
false );
459 [](
JOB* job, wxWindow* aParent ) ->
bool
464 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
471 wxCHECK( odbJob && editFrame,
false );
477 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
484 wxCHECK( idfJob && editFrame,
false );
532 BOARD* brd =
nullptr;
536 auto getProjectForBoard = [&](
const wxString& aBoardPath ) ->
PROJECT*
538 wxFileName pro = aBoardPath;
546 settingsManager.
LoadProject( pro.GetFullPath(),
true );
553 auto loadBoardFromPath = [&](
const wxString& aBoardPath ) ->
BOARD*
565 return loadedBoard.release();
569 loadError = ioe.
What();
578 if( !
Pgm().IsGUI() &&
Pgm().GetSettingsManager().IsProjectOpen() )
580 wxString pcbPath = aPath;
582 if( pcbPath.IsEmpty() )
587 pcbPath =
path.GetFullPath();
591 m_cliBoard.reset( loadBoardFromPath( pcbPath ) );
595 else if(
Pgm().IsGUI() &&
Pgm().GetSettingsManager().IsProjectOpen() )
604 m_cliBoard.reset( loadBoardFromPath( aPath ) );
610 wxString msg =
_(
"Failed to load board" );
612 if( !loadError.IsEmpty() )
613 msg += wxString::Format( wxS(
": %s" ), loadError );
624 std::map<wxString, LSET> layerUserMasks;
625 std::map<wxString, LSET> layerMasks;
626 std::map<wxString, LSET> layerGuiMasks;
660 auto pushLayers = [&](
const LSET& layerSet )
663 layerMask.push_back( layer );
666 if( !aLayerString.IsEmpty() )
668 wxStringTokenizer layerTokens( aLayerString,
"," );
670 while( layerTokens.HasMoreTokens() )
672 std::string token =
TO_UTF8( layerTokens.GetNextToken().Trim(
true ).Trim(
false ) );
674 if( layerUserMasks.contains( token ) )
675 pushLayers( layerUserMasks.at( token ) );
676 else if( layerMasks.count( token ) )
677 pushLayers( layerMasks.at( token ) );
678 else if( layerGuiMasks.count( token ) )
679 pushLayers( layerGuiMasks.at( token ) );
681 m_reporter->Report( wxString::Format(
_(
"Invalid layer name '%s'\n" ), token ) );
705 if( !currentVariant.IsEmpty() && currentVariant != wxS(
"all" ) )
711 bool hasWarned =
false;
716 if( !fp->IsAnnotated() && !hasWarned )
718 m_reporter->Report(
_(
"Warning: board has unannotated footprints, please use the PCB "
719 "editor to annotate them\n" ),
752 std::set<wxString> userFieldNames;
754 for(
size_t i = 0; i < referenceList.size(); ++i )
756 FOOTPRINT& footprint = referenceList[i].GetFootprint();
760 if( !field->IsMandatory() && !field->IsPrivate() )
761 userFieldNames.insert( field->GetName() );
765 for(
const wxString& fieldName : userFieldNames )
777 std::optional<BOM_PRESET> boardPreset;
779 for(
const BOM_PRESET& p : BOM_PRESET::BuiltInPresets() )
800 wxString::Format(
_(
"BOM preset '%s' not found" ) + wxS(
"\n" ), aBomJob->
m_bomPresetName ),
806 preset = *boardPreset;
814 auto normalizeFieldName = [&dataModel](
const wxString& aName ) -> wxString
816 if( aName.IsEmpty() )
817 return wxEmptyString;
822 wxString wrapped = wxS(
"${" ) + aName + wxS(
"}" );
834 wxString fieldName = normalizeFieldName( rawFieldName );
836 if( fieldName.IsEmpty() )
844 if( fieldName == wxS(
"*" ) )
850 field.
name = modelField.name;
855 bool fieldAlreadyPresent =
false;
857 for(
BOM_FIELD& presetField : preset.fieldsOrdered )
859 if( presetField.
name == field.
name )
861 fieldAlreadyPresent =
true;
866 bool fieldLaterInList =
false;
870 if( normalizeFieldName( fieldInList ) == field.
name )
872 fieldLaterInList =
true;
877 if( !fieldAlreadyPresent && !fieldLaterInList )
878 preset.fieldsOrdered.emplace_back( field );
886 field.
name = fieldName;
887 field.
show = !fieldName.StartsWith( wxT(
"__" ), &field.
name );
888 field.
name = normalizeFieldName( field.
name );
897 preset.fieldsOrdered.emplace_back( field );
903 wxString fieldName = rawFieldName;
904 fieldName.StartsWith( wxT(
"__" ), &fieldName );
905 fieldName = normalizeFieldName( fieldName );
907 if( fieldName.IsEmpty() )
910 bool fieldAlreadyPresent =
false;
912 for(
BOM_FIELD& field : preset.fieldsOrdered )
914 if( field.
name == fieldName )
917 fieldAlreadyPresent =
true;
922 if( !fieldAlreadyPresent )
927 preset.sortField = normalizeFieldName( aBomJob->
m_sortField );
939 std::optional<BOM_FMT_PRESET> boardFmtPreset;
959 if( !boardFmtPreset )
961 m_reporter->Report( wxString::Format(
_(
"BOM format preset '%s' not found" ) + wxS(
"\n" ),
968 fmt = *boardFmtPreset;
984 fn.SetName( fn.GetName() );
991 bool hasVariantPlaceholder = configuredPath.Contains( wxS(
"${VARIANT}" ) );
994 std::vector<wxString> variantsToProcess;
1002 variantsToProcess.push_back( currentVariant );
1005 for(
const wxString& variantName : variantsToProcess )
1007 std::vector<wxString> singleVariant = { variantName };
1015 if( hasVariantPlaceholder )
1035 if( !f.Open( outPath, wxFile::write ) )
1037 m_reporter->Report( wxString::Format(
_(
"Unable to open destination '%s'" ), outPath ),
1043 bool res = f.Write( dataModel.
Export( fmt ) );
1061 if( aStepJob ==
nullptr )
1075 fn.SetName( fn.GetName() );
1135 m_reporter->Report( wxString::Format(
_(
"Successfully exported VRML to %s" ), outPath ),
1167 if( !stepExporter.
Export() )
1179 if( aRenderJob ==
nullptr )
1214 fn.SetName( wxString::Format(
"%s-%d", fn.GetName(),
static_cast<int>( aRenderJob->
m_side ) ) );
1304 lightColor, lightColor, lightColor, lightColor, lightColor, lightColor, lightColor, lightColor,
1310 sideElevation, sideElevation, sideElevation, sideElevation,
1311 -sideElevation, -sideElevation, -sideElevation, -sideElevation,
1315 45, 135, 225, 315, 45, 135, 225, 315,
1320 boardAdapter.
m_Cfg = &cfg;
1336 if( preset->name.Lower() ==
_(
"legacy colors" ) )
1351 static std::map<JOB_PCB_RENDER::SIDE, VIEW3D_TYPE> s_viewCmdMap = {
1374 for(
bool first =
true; raytrace.
Redraw(
false ); first = false )
1401 uint8_t* rgbaBuffer = raytrace.
GetBuffer();
1403 bool success = !!rgbaBuffer;
1407 const unsigned int wxh = realSize.x * realSize.y;
1409 unsigned char* rgbBuffer = (
unsigned char*) malloc( wxh * 3 );
1410 unsigned char* alphaBuffer = (
unsigned char*) malloc( wxh );
1412 unsigned char* rgbaPtr = rgbaBuffer;
1413 unsigned char* rgbPtr = rgbBuffer;
1414 unsigned char* alphaPtr = alphaBuffer;
1416 for(
int y = 0; y < realSize.y; y++ )
1418 for(
int x = 0; x < realSize.x; x++ )
1420 rgbPtr[0] = rgbaPtr[0];
1421 rgbPtr[1] = rgbaPtr[1];
1422 rgbPtr[2] = rgbaPtr[2];
1423 alphaPtr[0] = rgbaPtr[3];
1431 wxImage
image( realSize );
1432 image.SetData( rgbBuffer );
1433 image.SetAlpha( alphaBuffer );
1436 image.SetOption( wxIMAGE_OPTION_QUALITY, 90 );
1437 image.SaveFile( outPath,
1497 bool aSingleOutput,
bool aUseOverrides )
1499 std::optional<wxString> layerName;
1500 std::optional<wxString> sheetName;
1501 std::optional<wxString> sheetPath;
1515 std::vector<wxString> outputPaths;
1518 aSingleOutput, layerName, sheetName, sheetPath, &outputPaths ) )
1523 for(
const wxString& outputPath : outputPaths )
1534 if( aSvgJob ==
nullptr )
1564 return plotJob( aSvgJob, plotter, outPath, isSingle, isSingle );
1572 if( aDxfJob ==
nullptr )
1603 return plotJob( aDxfJob, plotter, outPath, isSingle, isSingle );
1609 bool plotAllLayersOneFile =
false;
1612 if( pdfJob ==
nullptr )
1629 plotAllLayersOneFile =
true;
1631 const bool outputIsSingle = plotAllLayersOneFile || pdfJob->
m_pdfSingle;
1646 return plotJob( pdfJob, pcbPlotter, outPath, outputIsSingle, plotAllLayersOneFile );
1654 if( pngJob ==
nullptr )
1685 return plotJob( pngJob, pcbPlotter, outPath, isSingle,
false );
1693 if( psJob ==
nullptr )
1724 return plotJob( psJob, pcbPlotter, outPath, isSingle, isSingle );
1733 if( aGerberJob ==
nullptr )
1762 bool hasLayerListSpecified =
false;
1769 hasLayerListSpecified =
true;
1809 LSET preflightLayers = layersToPlot;
1812 preflightLayers.
set( commonLayer );
1821 plotSequence.push_back( layer );
1827 if(
find( plotSequence.begin(), plotSequence.end(), layer_all ) != plotSequence.end() )
1830 plotSequence.push_back( layer_all );
1841 plotOpts = boardPlotOptions;
1851 wxString fullname = fn.GetFullName();
1859 jobfile_writer.
AddGbrFile( layer, fullname );
1885 m_reporter->Report( wxString::Format(
_(
"Failed to plot to '%s'.\n" ), fn.GetFullPath() ),
1911 if( aGencadJob ==
nullptr )
1935 fn.SetName( fn.GetName() );
1967 if( statsJob ==
nullptr )
1985 wxString projectName;
1992 if( boardFile.GetName().IsEmpty() )
1993 boardFile = wxFileName( statsJob->
m_filename );
2016 FILE* outFile = wxFopen( outPath, wxS(
"wt" ) );
2024 if( fprintf( outFile,
"%s",
TO_UTF8( report ) ) < 0 )
2045 if( stackupJob ==
nullptr )
2055 if( boardFile.GetName().IsEmpty() )
2056 boardFile = wxFileName( stackupJob->
m_filename );
2064 kiapi::board::BoardStackup stackupMsg;
2067 google::protobuf::util::JsonPrintOptions jsonOptions;
2068 jsonOptions.add_whitespace =
true;
2072 if( !google::protobuf::util::MessageToJsonString( stackupMsg, &
json, jsonOptions ).ok() )
2078 output = wxString::FromUTF8(
json );
2091 item->SetLayerName( brd->
GetLayerName( item->GetBrdLayerId() ) );
2132 const bool writeOk =
static_cast<bool>( outFile );
2154 if( aGerberJob ==
nullptr )
2182 fn.SetName( fn.GetName() );
2236 PLOTTER* plotter =
StartPlotBoard( brd, &plotOpts, layer, layerName, outPath, sheetName, sheetPath );
2262 if( aDrillJob ==
nullptr )
2278 std::unique_ptr<GENDRILL_WRITER_BASE> drillWriter;
2281 drillWriter = std::make_unique<EXCELLON_WRITER>( brd );
2283 drillWriter = std::make_unique<GERBER_WRITER>( brd );
2307 wxFileName fn = outPath;
2309 fn.SetName( fn.GetName() +
"-drill" );
2340 if( excellonWriter ==
nullptr )
2355 for(
const wxString& outputFile : drillWriter->GetCreatedFiles() )
2374 if( gerberWriter ==
nullptr )
2390 for(
const wxString& outputFile : drillWriter->GetCreatedFiles() )
2414 if( aPosJob ==
nullptr )
2425 fn.SetName( fn.GetName() );
2447 wxFileName fn( outPath );
2448 wxString baseName = fn.GetName();
2450 auto exportPlaceFile = [&](
bool frontSide,
bool backSide,
const wxString& curr_outPath ) ->
bool
2452 FILE* file = wxFopen( curr_outPath, wxS(
"wt" ) );
2453 wxCHECK( file,
false );
2465 fputs( data.c_str(), file );
2478 if( exportPlaceFile(
true,
false, fn.GetFullPath() ) )
2480 m_reporter->Report( wxString::Format(
_(
"Wrote front position data to '%s'.\n" ), fn.GetFullPath() ),
2495 if( exportPlaceFile(
false,
true, fn.GetFullPath() ) )
2497 m_reporter->Report( wxString::Format(
_(
"Wrote back position data to '%s'.\n" ), fn.GetFullPath() ),
2523 if( exportPlaceFile( front, back, fn.GetFullPath() ) )
2525 m_reporter->Report( wxString::Format(
_(
"Wrote position data to '%s'.\n" ), fn.GetFullPath() ),
2544 wxString outPath_base = outPath;
2555 m_reporter->Report( wxString::Format(
_(
"Wrote front position data to '%s'.\n" ), outPath ),
2570 outPath = outPath_base;
2579 m_reporter->Report( wxString::Format(
_(
"Wrote back position data to '%s'.\n" ), outPath ),
2599 if( upgradeJob ==
nullptr )
2614 m_reporter->Report(
_(
"Output path must be specified to convert legacy and non-KiCad libraries\n" ),
2624 m_reporter->Report(
_(
"Footprint library path does not exist or is not accessible\n" ),
2645 bool shouldSave = upgradeJob->
m_force;
2691 if( svgJob ==
nullptr )
2724 bool singleFpPlotted =
false;
2726 for(
const auto& [fpName, fpCacheEntry] : fpLib.
GetFootprints() )
2740 singleFpPlotted =
true;
2743 exitCode =
doFpExportSvg( svgJob, fpCacheEntry->GetFootprint().get() );
2749 if( !svgJob->
m_footprint.IsEmpty() && !singleFpPlotted )
2751 m_reporter->Report(
_(
"The given footprint could not be found to export." ) + wxS(
"\n" ),
2761 wxFileName outputFile;
2766 m_reporter->Report( wxString::Format(
_(
"Plotting footprint '%s' to '%s'\n" ),
2786 aSvgJob->
AddOutput( outputFile.GetFullPath() );
2796 if( drcJob ==
nullptr )
2812 fn.SetName( fn.GetName() + wxS(
"-drc" ) );
2841 std::unique_ptr<NETLIST>
netlist = std::make_unique<NETLIST>();
2843 if( !drcEngine->RulesValid() )
2851 m_reporter->Report(
_(
"DRC incomplete: could not compile custom design rules." )
2852 + wxS(
"\n" ) + error.
What() + wxS(
"\n" ),
2865 std::string netlist_str;
2869 wxString annotateMsg =
_(
"Schematic parity tests require a fully annotated schematic." );
2870 netlist_str = annotateMsg;
2882 wxFileName schematicPath( drcJob->
m_filename );
2883 schematicPath.MakeAbsolute();
2886 if( !schematicPath.Exists() )
2889 if( !schematicPath.Exists() )
2896 typedef bool ( *NETLIST_FN_PTR )(
const wxString&, std::string&,
KIWAY* );
2899 ( *netlister )( schematicPath.GetFullPath(), netlist_str,
m_kiway );
2907 else if( netlist_str == annotateMsg )
2929 drcEngine->SetSchematicNetlist(
netlist.get() );
2941 drcEngine->SetViolationHandler(
2942 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
2943 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
2946 aPathGenerator( marker );
2947 commit.
Add( marker );
2953 drcEngine->ClearViolationHandler();
2960 std::shared_ptr<DRC_ITEMS_PROVIDER> markersProvider =
2963 std::shared_ptr<DRC_ITEMS_PROVIDER> ratsnestProvider =
2966 std::shared_ptr<DRC_ITEMS_PROVIDER> fpWarningsProvider =
2969 markersProvider->SetSeverities( drcJob->
m_severity );
2970 ratsnestProvider->SetSeverities( drcJob->
m_severity );
2971 fpWarningsProvider->SetSeverities( drcJob->
m_severity );
2973 m_reporter->Report( wxString::Format(
_(
"Found %d violations\n" ), markersProvider->GetCount() ),
2975 m_reporter->Report( wxString::Format(
_(
"Found %d unconnected items\n" ), ratsnestProvider->GetCount() ),
2981 wxString::Format(
_(
"Found %d schematic parity issues\n" ), fpWarningsProvider->GetCount() ),
2985 DRC_REPORT reportWriter( brd, units, markersProvider, ratsnestProvider, fpWarningsProvider );
2987 bool wroteReport =
false;
3020 if( markersProvider->GetCount() > 0 || ratsnestProvider->GetCount() > 0 || fpWarningsProvider->GetCount() > 0 )
3052 if( job ==
nullptr )
3060 struct VARIANT_RESTORE
3100 if( job ==
nullptr )
3111 fn.SetName( fn.GetName() );
3127 bool success = exporter.
Write( outPath );
3147 if( job ==
nullptr )
3181 if( !exporter.
Export( outPath ) )
3194 if( job ==
nullptr )
3212 fn.SetName( fn.GetName() + wxS(
"-odb" ) );
3237 for(
const wxString&
path :
result.m_outputs )
3251 if( job ==
nullptr )
3254 bool shouldSave = job->
m_force;
3285 wxString::Format(
_(
"Error saving board file '%s'.\n%s" ), job->
m_filename, ioe.
What().GetData() );
3298 wxArrayString files;
3299 wxDir::GetAllFiles( aDir, &files, wxT(
"*.kicad_mod" ) );
3301 for(
const wxString& file : files )
3310 std::unique_ptr<FOOTPRINT> fp = loader.
ImportFootprint( file, nameOut );
3316 scratch.
Add( fp.release() );
3331 bool aDropInsteadOfApproximate,
3333 wxString* aRecoveryError =
nullptr )
3342 [&](
const wxString& aText )
3344 return FindUnsupportedBoardToken( aText, aTarget );
3346 convert, aTransaction, aRecoveryError );
3352 return wxString::Format(
_(
"Cannot export: footprint '%s' uses a feature %s cannot open.\n" ), aFile,
3361 if( job ==
nullptr )
3367 if( target ==
nullptr )
3369 m_reporter->Report( wxString::Format(
_(
"Unknown target version '%s'. Valid targets: %s\n" ), job->
m_target,
3384 m_reporter->Report(
_(
"The target supports variants, so there is nothing to flatten.\n" ),
3390 wxString libraryCopy;
3402 if( !job->
m_outputFile.IsEmpty() && output.MakeAbsolute() )
3436 const std::vector<wxString>& names = brd->GetVariantNames();
3443 m_reporter->Report(
_(
"The board has no variant data. The base board is exported.\n" ),
3446 else if( std::find( names.begin(), names.end(), job->
m_variant ) == names.end() )
3449 wxString::Format(
_(
"The board has no variant named '%s'.\n" ), job->
m_variant ),
3475 m_reporter->Report(
_(
"Cannot export: the board uses features the target cannot represent.\n" ),
3482 m_reporter->Report(
_(
"Export would lose data. Re-run with --force to export anyway.\n" ),
3493 output.MakeAbsolute();
3495 if( !outputDirectories.
Create( output.GetPath() ) )
3501 if( !libraryDir.IsEmpty() )
3509 libraryDir = libraryCopy;
3516 if( stagedBoard.IsEmpty() )
3528 if( !badToken.IsEmpty() )
3529 m_reporter->Report( wxString::Format(
_(
"Cannot export: the result still uses '%s', which %s "
3530 "cannot open. This feature has no downgrade rule yet.\n" ),
3531 badToken, target->
m_name ),
3544 if( !badLib.IsEmpty() )
3551 wxString failedDestination = transaction.
Commit();
3553 if( !failedDestination.IsEmpty() )
3555 m_reporter->Report( wxString::Format(
_(
"Could not replace '%s'.\n" ), failedDestination ),
3564 outputDirectories.
Commit();
3593 m_reporter->Report(
_(
"Cannot export: the libraries use features the target cannot represent.\n" ),
3600 m_reporter->Report(
_(
"Export would lose data. Re-run with --force to export anyway.\n" ),
3605 wxString recoveryError;
3607 nullptr, &recoveryError );
3609 if( !badLib.IsEmpty() )
3613 if( !recoveryError.IsEmpty() )
3626 m_reporter->Report( wxString::Format(
_(
"Error exporting '%s'.\n%s" ), where, ioe.
What().GetData() ),
3641 if( aDrawingSheet && !aDrawingSheet->IsEmpty() )
3671 return drawingSheet;
3678 if( aSheetPath.IsEmpty() )
3681 auto loadSheet = [&](
const wxString&
path ) ->
bool
3694 m_reporter->Report( wxString::Format(
_(
"Error loading drawing sheet '%s'." ),
path ) + wxS(
"\n" ) + msg
3703 if( loadSheet( aSheetPath ) )
3735 m_reporter->Report( wxString::Format(
_(
"Input file not found: '%s'\n" ),
3777 m_reporter->Report( wxString::Format(
_(
"No PCB importer recognizes the file format of "
3790 m_reporter->Report( wxString::Format(
_(
"No plugin found for file type '%s'\n" ),
3802 m_reporter->Report( wxString::Format(
_(
"Failed to inspect board project: %s\n" ), ioe.
What() ),
3814 if( outputPath.IsEmpty() )
3822 PROJECT* projectPtr =
nullptr;
3823 bool createdTransientProject =
false;
3827 projectPtr = &mgr.
Prj();
3831 wxFileName projectFn( outputPath );
3835 projectFn.MakeAbsolute();
3838 projectPtr = mgr.
GetProject( projectFn.GetFullPath() );
3839 createdTransientProject = ( projectPtr != nullptr );
3844 m_reporter->Report(
_(
"Could not establish a project for the import\n" ),
3861 } transientProjectGuard{ mgr, projectPtr, createdTransientProject };
3863 std::unique_ptr<BOARD> board;
3865 struct BOARD_PROJECT_GUARD
3867 std::unique_ptr<BOARD>& board;
3869 ~BOARD_PROJECT_GUARD()
3872 board->ClearProject();
3874 } boardProjectGuard{ board };
3877 std::vector<wxString> warnings;
3881 struct CAPTURED_LAYER
3888 std::vector<CAPTURED_LAYER> capturedLayers;
3889 std::set<wxString> seenSourceLayers;
3890 bool layersCaptured =
false;
3900 m_reporter->Report( wxString::Format(
_(
"No plugin found for file type '%s'\n" ), formatName ),
3906 pi->SetReporter( &importMessages );
3915 mappable->RegisterCallback(
3916 [&](
const std::vector<INPUT_LAYER_DESC>& aDescs )
3917 -> std::map<wxString, PCB_LAYER_ID>
3919 std::map<wxString, PCB_LAYER_ID>
result;
3924 wxString method = wxS(
"auto" );
3926 if(
auto it = job->
m_layerMap.find( desc.Name );
3933 warnings.push_back( wxString::Format(
3934 _(
"Layer map entry '%s' -> '%s' names an unknown "
3935 "KiCad layer; using automatic mapping instead" ),
3936 desc.Name, it->second ) );
3938 else if( !desc.PermittedLayers.Contains( resolved ) )
3940 warnings.push_back( wxString::Format(
3941 _(
"Layer map entry '%s' -> '%s' is not a permitted "
3942 "target for this layer; using automatic mapping "
3944 desc.Name, it->second ) );
3949 method = wxS(
"explicit" );
3955 warnings.push_back( wxString::Format(
3956 _(
"No KiCad layer mapping for required source layer "
3957 "'%s'; its items will not be imported" ),
3961 result.emplace( desc.Name, target );
3962 capturedLayers.push_back( { desc.Name, target, method } );
3963 seenSourceLayers.insert( desc.Name );
3966 layersCaptured =
true;
3973 warnings.push_back(
_(
"A layer map was provided, but this importer does not support "
3974 "layer remapping; it will be ignored" ) );
3978 wxString::Format(
_(
"Importing '%s' using %s format...\n" ), job->
m_inputFile, formatName ),
3987 const std::map<std::string, UTF8>* importProperties =
nullptr;
3988 std::map<std::string, UTF8> easyEdaProProperties;
3993 easyEdaProProperties.emplace(
"pcb_id", std::string( job->
m_importPcbId.ToUTF8() ) );
3994 importProperties = &easyEdaProProperties;
3997 board = pi->LoadBoard( job->
m_inputFile, importProperties, projectPtr );
4004 m_reporter->Report( wxString::Format(
_(
"Unexpected cancellation: %s\n" ), ioce.
What() ),
4025 const wxString reconciliationPath =
4032 if( layersCaptured )
4036 if( !seenSourceLayers.contains(
source ) )
4038 warnings.push_back( wxString::Format(
4039 _(
"Layer map entry '%s' does not match any source layer in the "
4040 "imported file; it will be ignored" ),
4049 kicadPlugin->SaveBoard( outputPath, *board );
4050 wxString importedRules = pi->GetImportedDesignRules();
4052 if( !importedRules.IsEmpty() )
4054 wxFileName rulesPath( outputPath );
4057 wxFile rulesFile( rulesPath.GetFullPath(), wxFile::write );
4059 if( rulesFile.IsOpened() )
4061 rulesFile.Write( importedRules );
4065 m_reporter->Report( wxString::Format(
_(
"Could not write imported design rules to '%s'\n" ),
4066 rulesPath.GetFullPath() ),
4071 m_reporter->Report( wxString::Format(
_(
"Successfully saved imported board to '%s'\n" ), outputPath ),
4075 IMPORT_REPORT_DATA reportData;
4080 reportData.m_sourceFile = wxFileName( job->
m_inputFile ).GetFullName();
4081 reportData.m_sourceFormat = formatName;
4082 reportData.m_outputFile = wxFileName( outputPath ).GetFullName();
4084 size_t trackCount = 0;
4085 size_t viaCount = 0;
4087 for(
PCB_TRACK* track : board->Tracks() )
4095 reportData.m_statistics = {
4096 { wxS(
"footprints" ), board->Footprints().size() },
4097 { wxS(
"tracks" ), trackCount },
4098 { wxS(
"vias" ), viaCount },
4099 { wxS(
"zones" ), board->Zones().size() }
4105 nlohmann::json layerMappings = nlohmann::json::object();
4107 if( layersCaptured )
4109 for(
const CAPTURED_LAYER& mapped : capturedLayers )
4113 :
LSET::Name( mapped.m_target ).ToStdString();
4115 layerMappings[mapped.m_source.ToStdString()] = {
4116 {
"kicad_layer", kicadLayer },
4117 {
"method", mapped.m_method.ToStdString() }
4123 for(
PCB_LAYER_ID layer : board->GetEnabledLayers().Seq() )
4125 wxString layerName = board->GetLayerName( layer );
4127 layerMappings[layerName.ToStdString()] = {
4128 {
"kicad_layer",
LSET::Name( layer ).ToStdString() },
4129 {
"method",
"auto" }
4134 reportData.m_extraJson[
"layer_mapping"] = layerMappings;
4135 reportData.m_warnings.insert( reportData.m_warnings.end(), warnings.begin(), warnings.end() );
4143 for(
const wxString& warning : warnings )
4174 bool aInitializeAfterLoad =
true )
4178 [aPath, aInitializeAfterLoad](
PROJECT* aProject ) -> std::unique_ptr<BOARD>
4201 aBoard->ClearProject();
4222 BOARD* boardA = aScratch.
doc.get();
4223 BOARD* boardB = bScratch.
doc.get();
4243 return diffExitCode;
4269 const wxString& aOurs,
const wxString& aTheirs,
4270 const wxString& aOutput,
bool aInteractive,
bool aSingleFile,
4279 return runFpLibMerge( aAncestor, aOurs, aTheirs, aOutput, aSingleFile );
4281 return runPcbMerge( aAncestor, aOurs, aTheirs, aOutput, aInteractive );
4286 const wxString& aTheirs,
const wxString& aOutput,
4303 BOARD* ancestor = ancestorScratch.
doc.get();
4304 BOARD* ours = oursScratch.
doc.get();
4305 BOARD* theirs = theirsScratch.
doc.get();
4307 if( !ancestor || !ours || !theirs )
4324 if( aInteractive && !
plan.Resolved() )
4326 if( !
Pgm().IsGUI() )
4328 m_reporter->Report(
_(
"--interactive requires a GUI KiCad process; the console "
4329 "kicad-cli cannot open dialogs.\n" ),
4358 std::unique_ptr<BOARD> merged = applier.
Apply();
4375 m_reporter->Report( wxString::Format(
_(
"Failed to save merged board: %s\n" ), ioe.
What() ),
4408 wxFileName proFn( aOutput );
4431 std::set<wxString> touched;
4449 wxString::Format(
_(
"Failed to save merged project file: %s\n" ), proFn.GetFullPath() ),
4458 auto writeStagedFile = [&](
const wxString& aPath,
const wxString& aContent,
const wxString& aLabel ) ->
bool
4460 if( aContent.IsEmpty() )
4462 if( wxFileExists( aPath ) )
4463 wxRemoveFile( aPath );
4470 if( !out.Open( aPath, wxFile::write ) || !out.Write( aContent ) )
4472 m_reporter->Report( wxString::Format(
_(
"Failed to save merged %s: %s\n" ), aLabel, aPath ),
4484 wxFileName druFn( aOutput );
4497 wxFileName fpFn( aOutput );
4500 if( !writeStagedFile( fpFn.GetFullPath(), applier.
GetReport().
fpLibTable,
_(
"footprint library table" ) ) )
4508 wxFileName symFn( aOutput );
4511 if( !writeStagedFile( symFn.GetFullPath(), applier.
GetReport().
symLibTable,
_(
"symbol library table" ) ) )
4522 m_reporter->Report( wxString::Format( wxS(
"%s: %s\n" ), f.validator, f.message ), f.severity );
4529 m_reporter->Report( wxString::Format(
_(
"Merge completed with %zu unresolved conflict(s) in %s\n" ),
4550 std::vector<std::unique_ptr<FOOTPRINT>>& aOwners,
4554 if( aAllowEmpty && aPath.IsEmpty() )
4560 aOwners = std::move( loaded.first );
4561 aMap = std::move( loaded.second );
4566 aReporter.
Report( wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, ioe.
What() ),
4569 catch(
const std::exception& e )
4572 wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, wxString::FromUTF8( e.what() ) ),
4587 for(
const auto& [
name, footprint] : aMap )
4604 wxFileName dirA( diffJob->
m_inputA );
4605 dirA.MakeAbsolute();
4606 wxFileName dirB( diffJob->
m_inputB );
4607 dirB.MakeAbsolute();
4609 std::vector<std::unique_ptr<FOOTPRINT>> ownersA;
4610 std::vector<std::unique_ptr<FOOTPRINT>> ownersB;
4632 return diffExitCode;
4657 const wxString& aFileB,
const wxString& aLabelA,
4658 const wxString& aLabelB, wxWindow* aParent,
4666 wxWindow* parent = aParent ? aParent : ( wxTheApp ? wxTheApp->GetTopWindow() :
nullptr );
4670 auto loadBoardScratch = [&](
const wxString& aPath )
4679 auto loadFootprintFile = [&](
const wxString& aPath ) -> std::unique_ptr<FOOTPRINT>
4681 if( aPath.IsEmpty() )
4684 wxFileName fn( aPath );
4709 if( !a.
doc && !aFileA.IsEmpty() )
4715 if( !b.
doc && !aFileB.IsEmpty() )
4734 const wxString labelA = aLabelA.IsEmpty() ? aFileA : aLabelA;
4735 const wxString labelB = aLabelB.IsEmpty() ? aFileB : aLabelB;
4738 parent, labelA, labelB,
result, std::move( refGeometry ), std::move( compGeometry ),
4741 KICAD_DIFF::ConfigurePcbDiffCanvasContext( aCanvas, boardA, boardB, color );
4749 std::vector<std::unique_ptr<FOOTPRINT>> ownersA;
4750 std::vector<std::unique_ptr<FOOTPRINT>> ownersB;
4776 std::unique_ptr<FOOTPRINT> footprintA;
4777 std::unique_ptr<FOOTPRINT> footprintB;
4781 footprintA = loadFootprintFile( aFileA );
4785 m_reporter->Report( wxString::Format(
_(
"Failed to load %s: %s\n" ), aFileA, ioe.
What() ),
4792 footprintB = loadFootprintFile( aFileB );
4796 m_reporter->Report( wxString::Format(
_(
"Failed to load %s: %s\n" ), aFileB, ioe.
What() ),
4803 const wxString nameA = wxFileName( aFileA ).GetName();
4804 const wxString nameB = wxFileName( aFileB ).GetName();
4805 const wxString itemName = !nameB.IsEmpty() ? nameB : nameA;
4808 mapA[itemName] = footprintA.get();
4811 mapB[itemName] = footprintB.get();
4831 const wxString labelA = aLabelA.IsEmpty() ? aFileA : aLabelA;
4832 const wxString labelB = aLabelB.IsEmpty() ? aFileB : aLabelB;
4849 const wxString& aTheirs,
const wxString& aOutput,
4852 if( aOutput.IsEmpty() )
4860 std::vector<std::unique_ptr<FOOTPRINT>> owners;
4864 LIB_SIDE ancestor, ours, theirs;
4871 auto isSingleFile = [&](
const wxString& aPath )
4879 auto loadSide = [&](
const wxString& aPath, LIB_SIDE& aSide ) ->
int
4883 if( isSingleFile( aPath ) )
4895 const UTF8& itemName = fp->GetFPID().GetLibItemName();
4898 aSide.map[key] = fp.get();
4899 aSide.owners.push_back( std::move( fp ) );
4904 aSide.owners = std::move( loaded.first );
4905 aSide.map = std::move( loaded.second );
4910 m_reporter->Report( wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, ioe.
What() ),
4913 catch(
const std::exception& e )
4916 wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, wxString::FromUTF8( e.what() ) ),
4944 std::vector<std::unique_ptr<FOOTPRINT>> merged = applier.
Apply();
4949 const bool hadSilentFallback = applier.
GetReport().mergePropsFallback > 0;
4951 const bool singleFileOutput = isSingleFile( aOutput );
4960 if( singleFileOutput )
4961 outFn = wxFileName( aOutput );
4963 outFn = wxFileName::DirName( aOutput );
4965 outFn.MakeAbsolute();
4971 const wxString outDir = outFn.GetPath();
4973 if( !wxFileName::DirExists( outDir ) && !wxFileName::Mkdir( outDir, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
4975 m_reporter->Report( wxString::Format(
_(
"Cannot create output directory %s\n" ), outDir ),
4984 if( singleFileOutput )
4990 if( merged.size() > 1 )
4992 m_reporter->Report(
_(
"Single-file fp merge produced multiple footprints; refusing to "
4993 "collapse into one .kicad_mod\n" ),
4998 if( merged.empty() )
5003 if( wxFileName::FileExists( outFn.GetFullPath() ) )
5004 wxRemoveFile( outFn.GetFullPath() );
5010 io.
FootprintSave( outFn.GetFullPath(), merged.front().get(),
nullptr );
5021 io.
Format( merged.front().get() );
5033 std::set<wxString> mergedNames;
5035 for(
const auto& fp : merged )
5038 mergedNames.insert( fp->GetFPID().GetLibItemName() );
5041 wxArrayString existing;
5044 for(
const wxString&
name : existing )
5046 if( !mergedNames.count(
name ) )
5050 for(
const auto& fp : merged )
5055 const wxString
name = fp->GetFPID().GetLibItemName();
5066 m_reporter->Report( wxString::Format(
_(
"Failed to save merged footprint library: %s\n" ), ioe.
What() ),
5072 if( !planSnapshot.
Resolved() || hadSilentFallback )
5076 std::set<KIID_PATH> conflicts( planSnapshot.
unresolved.begin(), planSnapshot.
unresolved.end() );
5079 conflicts.insert(
id );
5081 m_reporter->Report( wxString::Format(
_(
"Footprint library merge completed with %zu unresolved "
5082 "conflict(s) in %s\n" ),
5083 conflicts.size(), aOutput ),
constexpr EDA_IU_SCALE pcbIUScale
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
COMPATIBILITY_REPORT ClassifyBoardForDowngrade(const BOARD *aBoard, const DOWNGRADE_TARGET &aTarget, bool aDropInsteadOfApproximate)
Report what a board would lose if exported to an older KiCad.
void FlattenBoardVariant(BOARD *aBoard, const wxString &aVariantName)
Bake a variant's overrides into the base footprint attributes.
bool ExportBoardToOlderVersion(const wxString &aSrcFile, const wxString &aDestFile, const DOWNGRADE_TARGET &aTarget, COMPATIBILITY_REPORT &aReport, wxString *aUnsupportedToken, const wxString &aVariant, bool aDropInsteadOfApproximate)
Load a board, downgrade the copy, and write it stamped for the target.
DOWNGRADE_FILE_RESULT DowngradeFootprintFileToTemp(const wxString &aSrcFile, const wxString &aTmpFile, const DOWNGRADE_TARGET &aTarget, bool aDropInsteadOfApproximate)
Load one .kicad_mod, classify it against the rule table, and write the downgraded copy to aTmpFile.
constexpr int FIRST_PCB_VARIANTS
First board format that stores variants.
wxString BuildStackupCsv(BOARD_STACKUP &aStackup, EDA_UNITS aUnits, const STACKUP_CSV_OPTIONS &aOptions)
wxString FormatBoardStatisticsJson(const BOARD_STATISTICS_DATA &aData, BOARD *aBoard, const UNITS_PROVIDER &aUnitsProvider, const wxString &aProjectName, const wxString &aBoardName)
void ComputeBoardStatistics(BOARD *aBoard, const BOARD_STATISTICS_OPTIONS &aOptions, BOARD_STATISTICS_DATA &aData)
wxString FormatBoardStatisticsReport(const BOARD_STATISTICS_DATA &aData, BOARD *aBoard, const UNITS_PROVIDER &aUnitsProvider, const wxString &aProjectName, const wxString &aBoardName)
void InitializeBoardStatisticsData(BOARD_STATISTICS_DATA &aData)
static wxString m_DrawingSheetFileName
the name of the drawing sheet file, or empty to use the default drawing sheet
BASE_SET & set(size_t pos)
Helper class to handle information needed to display 3D board.
double BiuTo3dUnits() const noexcept
Board integer units To 3D units.
void SetVisibleLayers(const std::bitset< LAYER_3D_END > &aLayers)
std::bitset< LAYER_3D_END > GetVisibleLayers() const
void SetBoard(BOARD *aBoard) noexcept
Set current board to be rendered.
void SetLayerColors(const std::map< int, COLOR4D > &aColors)
EDA_3D_VIEWER_SETTINGS * m_Cfg
std::map< int, COLOR4D > m_ColorOverrides
allows to override color scheme colors
void Set3dCacheManager(S3D_CACHE *aCacheMgr) noexcept
Update the cache manager pointer.
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
Container for design settings for a BOARD object.
std::shared_ptr< NET_SETTINGS > m_NetSettings
std::map< int, SEVERITY > m_DRCSeverities
std::shared_ptr< DRC_ENGINE > m_DRCEngine
const VECTOR2I & GetAuxOrigin() const
BOARD_STACKUP & GetStackupDescriptor()
static bool SaveBoard(wxString &aFileName, BOARD &aBoard, PCB_IO_MGR::PCB_FILE_T aFormat)
static std::unique_ptr< BOARD > Load(const wxString &aFileName, PCB_IO_MGR::PCB_FILE_T aFormat, PROJECT *aProject, const OPTIONS &aOptions)
Manage one layer needed to make a physical board.
Manage layers needed to make a physical board.
const std::vector< BOARD_STACKUP_ITEM * > & GetList() const
bool SynchronizeWithBoard(const BOARD_DESIGN_SETTINGS *aSettings)
Synchronize the BOARD_STACKUP_ITEM* list with the board.
Information pertinent to a Pcbnew printed circuit board.
void SetCurrentVariant(const wxString &aVariant)
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
const PAGE_INFO & GetPageSettings() const
void RecordDRCExclusions()
Scan existing markers and record data from any that are Excluded.
TITLE_BLOCK & GetTitleBlock()
const std::map< wxString, wxString > & GetProperties() const
const FOOTPRINTS & Footprints() const
const wxString & GetFileName() const
std::vector< PCB_MARKER * > ResolveDRCExclusions(bool aCreateMarkers)
Rebuild DRC markers from the serialized data in BOARD_DESIGN_SETTINGS.
wxString GetVariantDescription(const wxString &aVariantName) const
int GetFileFormatVersionAtLoad() const
const PCB_PLOT_PARAMS & GetPlotOptions() const
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
wxString GetCurrentVariant() const
PROJECT * GetProject() const
wxString GetDesignRulesPath() const
Return the absolute path to the design rules file for this board.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
void SynchronizeProperties()
Copy the current project's text variables into the boards property cache.
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false, bool aPhysicalLayersOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
void DeleteMARKERs()
Delete all MARKERS from the board.
constexpr const Vec GetCenter() const
void SetProjection(PROJECTION_TYPE aProjection)
void RotateY_T1(float aAngleInRadians)
bool Zoom_T1(float aFactor)
bool SetCurWindowSize(const wxSize &aSize)
Update the windows size of the camera.
bool ViewCommand_T1(VIEW3D_TYPE aRequestedView)
void RotateX_T1(float aAngleInRadians)
void SetLookAtPos_T1(const SFVEC3F &aLookAtPos)
const SFVEC3F & GetLookAtPos_T1() const
void RotateZ_T1(float aAngleInRadians)
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
What an export to a given target will keep, approximate, drop, or block.
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).
3-way merge resolution dialog (Phase 8).
const KICAD_DIFF::MERGE_PLAN & GetResolvedPlan() const
Returns the plan with the user's resolutions applied.
A dialog to set the plot options and create plot files in various formats.
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)
bool WriteJsonReport(const wxString &aFullFileName)
bool WriteTextReport(const wxString &aFullFileName)
Helper to handle drill precision format in excellon files.
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 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 SetSheetName(const std::string &aSheetName)
Set the sheet name displayed in the title block.
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.
LAYER_PRESET_3D * FindPreset(const wxString &aName)
std::vector< LAYER_PRESET_3D > m_LayerPresets
Create Excellon drill, drill map, and drill report files.
void SetFormat(bool aMetric, ZEROS_FMT aZerosFmt=DECIMAL_FORMAT, int aLeftDigits=0, int aRightDigits=0)
Initialize internal parameters to match the given format.
bool CreateDrillandMapFilesSet(const wxString &aPlotDirectory, bool aGenDrill, bool aGenMap, REPORTER *aReporter=nullptr)
Create the full set of Excellon drill file for the board.
void SetOptions(bool aMirror, bool aMinimalHeader, const VECTOR2I &aOffset, bool aMerge_PTH_NPTH)
Initialize internal parameters to match drill options.
void SetRouteModeForOvalHoles(bool aUseRouteModeForOvalHoles)
bool m_IncludeUnspecified
Wrapper to expose an API for writing VRML files, without exposing all the many structures used in the...
bool ExportVRML_File(PROJECT *aProject, wxString *aMessages, const wxString &aFullFileName, double aMMtoWRMLunit, bool aIncludeUnspecified, bool aIncludeDNP, bool aExport3DFiles, bool aUseRelativePaths, const wxString &a3D_Subdir, double aXRef, double aYRef)
Exports the board and its footprint shapes 3D (vrml files only) as a vrml file.
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.
Provide an extensible class to resolve 3D model paths.
wxString ResolvePath(const wxString &aFileName, const wxString &aWorkingPath, std::vector< const EMBEDDED_FILES * > aEmbeddedFilesStack)
Determine the full path of the given file name.
void SetProgramBase(PGM_BASE *aBase)
Set a pointer to the application's PGM_BASE instance used to extract the local env vars.
bool SetProject(const PROJECT *aProject, bool *flgChanged=nullptr)
Set the current KiCad project directory as the first entry in the model path list.
void SetPath(const wxString &aPath)
void Save(FOOTPRINT *aFootprintFilter=nullptr)
Save the footprint cache or a single footprint from it to disk.
boost::ptr_map< wxString, FP_CACHE_ENTRY > & GetFootprints()
Export board to GenCAD file format.
void UseIndividualShapes(bool aUnique)
Make pad shapes unique.
void UsePinNamesUnique(bool aUnique)
Make pin names unique.
void StoreOriginCoordsInFile(bool aStore)
Store origin coordinate in GenCAD file.
void FlipBottomPads(bool aFlip)
Flip pad shapes on the bottom side.
void SetPlotOffet(VECTOR2I aOffset)
Set the coordinates offset when exporting items.
bool WriteFile(const wxString &aFullFileName)
Export a GenCAD file.
void SetMapFileFormat(PLOT_FORMAT aMapFmt)
Initialize the format for the drill map file.
bool GenDrillReportFile(const wxString &aFullFileName, REPORTER *aReporter=nullptr)
Create a plain text report file giving a list of drill values and drill count for through holes,...
GERBER_JOBFILE_WRITER is a class used to create Gerber job file a Gerber job file stores info to make...
bool CreateJobFile(const wxString &aFullFilename)
Creates a Gerber job file.
void AddGbrFile(PCB_LAYER_ID aLayer, wxString &aFilename)
add a gerber file name and type in job file list
virtual bool EndPlot() override
Used to create Gerber drill files.
bool CreateDrillandMapFilesSet(const wxString &aPlotDirectory, bool aGenDrill, bool aGenMap, bool aGenTenting, REPORTER *aReporter=nullptr)
Create the full set of Excellon drill file for the board filenames are computed from the board name,...
void SetOptions(const VECTOR2I &aOffset)
Initialize internal parameters to match drill options.
void SetFormat(int aRightDigits=6)
Initialize internal parameters to match the given format.
bool Export(const wxString &aFullFileName) const
Generate IDFv3 compliant board (*.emn) and library (*.emp) files for aPcb.
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...
An exception saying that the user cancelled an interactive part of a load, import,...
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()
Wrapper to expose an API for writing IPC-D356 files.
bool Write(const wxString &aFilename)
Generates and writes the netlist to a given path.
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
JOB_EXPORT_PCB_3D::FORMAT m_format
EXPORTER_STEP_PARAMS m_3dparams
Despite the name; also used for other formats.
ZEROS_FORMAT m_zeroFormat
bool m_excellonOvalDrillRoute
DRILL_ORIGIN m_drillOrigin
bool m_excellonCombinePTHNPTH
bool m_excellonMinimalHeader
std::vector< wxString > m_variantNames
bool m_checkZonesBeforeExport
wxString GetSettingsDialogTitle() const override
bool m_useIndividualShapes
bool m_useBoardPlotParams
ODB_COMPRESSION m_compressionMode
@ ALL_LAYERS_ONE_FILE
DEPRECATED MODE.
GEN_MODE m_pdfGenMode
uused by the cli, will be removed when the other behavior is deprecated
LSEQ m_plotOnAllLayersSequence
Layers to include on all individual layer prints.
bool m_checkZonesBeforePlot
std::optional< wxString > m_argLayers
std::optional< wxString > m_argCommonLayers
wxString m_variant
Variant name for variant-aware filtering.
bool m_useDrillPlaceFileOrigin
bool m_excludeFootprintsWithTh
bool m_includeBoardOptions
bool m_includeLossTangent
void SetDefaultOutputPath(const wxString &aReferenceName)
bool m_subtractHolesFromBoardArea
void SetDefaultOutputPath(const wxString &aReferenceName)
bool m_excludeFootprintsWithoutPads
bool m_subtractHolesFromCopperAreas
wxString m_outputLibraryPath
Job: diff two PCB files end-to-end via PCB_DIFFER.
wxString m_outputFile
Where to write the downgraded copy.
bool m_dropInsteadOfApproximate
Omit features that would otherwise be approximated.
wxString m_filename
Input board file (may be empty to downgrade only libraries)
wxString m_libraryDir
If set, downgrade every .kicad_mod footprint under this folder too.
COMPATIBILITY_REPORT m_report
Filled by the handler so the caller can show it.
wxString m_variant
Flatten this variant into the export. Empty means the base design.
bool m_inPlace
Internal project export operating only on its prepared copy.
wxString m_target
Target release name, e.g. "KiCad 10.0". Empty means the newest.
bool m_dryRun
Only classify and fill m_report, do not write anything.
bool m_force
Export even when features must be dropped or approximated.
bool m_reportAllTrackErrors
Job to import a non-KiCad PCB file to KiCad format.
wxString m_importPcbId
EasyEDA Pro PCB document identifier selected by project-level import.
std::map< wxString, wxString > m_layerMap
Explicit overrides from source layer name to KiCad layer name (canonical board-file name,...
std::map< wxString, wxString > m_netNameMap
bool m_isPartOfMultiBoardProject
Avoid promoting an individual board's source settings into shared project settings.
std::vector< std::pair< wxString, wxString > > m_projectBoards
PCB document identifier and source name pairs found during a probe.
IMPORT_REPORT_FORMAT m_reportFormat
VECTOR3D m_lightBottomIntensity
VECTOR3D m_lightTopIntensity
VECTOR3D m_lightCameraIntensity
bool m_proceduralTextures
bool m_useBoardStackupColors
VECTOR3D m_lightSideIntensity
std::string m_appearancePreset
bool m_exitCodeViolations
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.
wxString ResolveOutputPath(const wxString &aPath, bool aPathIsDirectory, PROJECT *aProject) const
void AddOutput(wxString aOutputPath)
wxString GetFullOutputPath(PROJECT *aProject) const
Returns the full output path for the job, taking into account the configured output path,...
wxString GetWorkingOutputPath() const
Returns the working output path for the job, if one has been set.
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
JSON_SETTINGS_INTERNALS * Internals()
Diff two .pretty footprint library directories.
static std::pair< std::vector< std::unique_ptr< FOOTPRINT > >, FOOTPRINT_MAP > LoadLibrary(const wxString &aPrettyPath)
Load a .pretty directory into a FOOTPRINT_MAP.
DOCUMENT_DIFF Diff() override
Produce a DOCUMENT_DIFF of the inputs the concrete differ was constructed with.
std::map< wxString, const FOOTPRINT * > FOOTPRINT_MAP
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 BOARDs 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 real merged BOARD.
std::unique_ptr< BOARD > Apply()
Produce the merged board.
const REPORT & GetReport() const
Read the new s-expression based KiCad netlist format.
virtual void LoadNetlist() override
Load the contents of the netlist file into aNetlist.
A color representation with 4 components: red, green, blue, alpha.
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.
Plugin class for import plugins that support remappable layers.
void AsyncLoad()
Loads all available libraries for this adapter type in the background.
const UTF8 & GetLibItemName() const
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
LSET is a set of PCB_LAYER_IDs.
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
LSEQ UIOrder() const
Return the copper, technical and user layers in the order shown in layer widget.
LSEQ SeqStackupForPlotting() const
Return the sequence that is typical for a bottom-to-top stack-up.
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static const LSET & AllLayersMask()
static const LSET & InternalCuMask()
Return a complete set of internal copper layers which is all Cu layers except F_Cu and B_Cu.
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
bool SaveToFile(const wxString &aDirectory="", bool aForce=false) override
Calls Store() and then saves the JSON document contents into the parent JSON_SETTINGS.
void CopyFrom(NET_SETTINGS &aOther)
Deep-copy the persisted contents of aOther into this instance.
static bool EnsurePathExists(const wxString &aPath, bool aPathToFile=false)
Attempts to create a given path if it does not exist.
int JobExportStep(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 JobExportPs(JOB *aJob)
int JobExportPos(JOB *aJob)
bool preparePlotLayers(JOB_EXPORT_PCB_PLOT *aJob, BOARD *aBoard, TOOL_MANAGER *aToolManager)
int JobDowngrade(JOB *aJob)
int JobExportFpSvg(JOB *aJob)
int JobExportStackup(JOB *aJob)
void refillFabZones(const JOB_EXPORT_PCB_FAB &aJob, BOARD *aBoard)
int JobExportOdb(JOB *aJob)
int JobExportDrc(JOB *aJob)
int JobUpgrade(JOB *aJob)
int JobExportFpUpgrade(JOB *aJob)
int JobExportGerber(JOB *aJob)
DS_PROXY_VIEW_ITEM * getDrawingSheetProxyView(BOARD *aBrd)
wxString resolveJobOutputPath(JOB *aJob, BOARD *aBoard, const wxString *aDrawingSheet=nullptr)
int JobExportPng(JOB *aJob)
int JobExportDxf(JOB *aJob)
int JobExportPdf(JOB *aJob)
int runPcbMerge(const wxString &aAncestor, const wxString &aOurs, const wxString &aTheirs, const wxString &aOutput, bool aInteractive)
int JobExportDrill(JOB *aJob)
int JobExportSvg(JOB *aJob)
void loadOverrideDrawingSheet(BOARD *brd, const wxString &aSheetPath)
PCBNEW_JOBS_HANDLER(KIWAY *aKiway)
TOOL_MANAGER * getToolManager(BOARD *aBrd)
int JobExportGerbers(JOB *aJob)
int JobExportBom(JOB *aJob)
int JobExportIdf(JOB *aJob)
std::unique_ptr< BOARD > m_cliBoard
int JobExportGencad(JOB *aJob)
BOARD * getBoard(const wxString &aPath=wxEmptyString)
wxString resolvePlotOutputPath(JOB_EXPORT_PCB_PLOT *aJob, BOARD *aBoard, PLOT_FORMAT aFormat, bool aSingleOutput)
int JobExportIpc2581(JOB *aJob)
virtual ~PCBNEW_JOBS_HANDLER()
int runFpLibMerge(const wxString &aAncestor, const wxString &aOurs, const wxString &aTheirs, const wxString &aOutput, bool aSingleFile)
std::unique_ptr< TOOL_MANAGER > m_toolManager
int OpenDiffDialog(KICAD_DIFF::DOC_KIND aKind, const wxString &aFileA, const wxString &aFileB, const wxString &aLabelA, const wxString &aLabelB, wxWindow *aParent, REPORTER *aReporter)
LSEQ convertLayerArg(wxString &aLayerString, BOARD *aBoard) const
void ClearCachedBoard()
Clear the cached CLI board so the next job reloads from the current project.
int JobExportRender(JOB *aJob)
int JobExportIpcD356(JOB *aJob)
int doFpExportSvg(JOB_FP_EXPORT_SVG *aSvgJob, const FOOTPRINT *aFootprint)
int JobExportStats(JOB *aJob)
The main frame for Pcbnew.
A PCB_IO derivation for saving and loading Pcbnew s-expression formatted files.
void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Delete aFootprintName from the library at aLibraryPath.
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Return a list of footprint names contained within the library at aLibraryPath.
std::unique_ptr< FOOTPRINT > ImportFootprint(const wxString &aFootprintPath, wxString &aFootprintNameOut, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load a single footprint from aFootprintPath and put its name in aFootprintNameOut.
bool FootprintExists(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Check for the existence of a footprint.
void FootprintSave(const wxString &aLibraryPath, const FOOTPRINT *aFootprint, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aFootprint to an existing library located at aLibraryPath.
void SaveBoard(const wxString &aFileName, BOARD &aBoard, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aBoard to a storage file in a format that this PCB_IO implementation knows about or it can be u...
void Format(const BOARD_ITEM *aItem) const
Output aItem to aFormatter in s-expression format.
void SetOutputFormatter(OUTPUTFORMATTER *aFormatter)
static bool ConvertLibrary(const std::map< std::string, UTF8 > &aOldFileProps, const wxString &aOldFilePath, const wxString &aNewFilePath, REPORTER *aReporter)
Convert a schematic symbol library to the latest KiCad format.
PCB_FILE_T
The set of file types that the PCB_IO_MGR knows about, and for which there has been a plugin written,...
@ KICAD_SEXP
S-expression Pcbnew file format.
@ EASYPC
Easy-PC / DesignSpark PCB.
@ PCB_FILE_UNKNOWN
0 is not a legal menu id on Mac
static PCB_IO * FindPlugin(PCB_FILE_T aFileType)
Return a PCB_IO which the caller can use to import, export, save, or load design documents.
static PCB_FILE_T FindPluginTypeFromBoardPath(const wxString &aFileName, int aCtl=0)
Return a plugin type given a path for a board file.
static PCB_FILE_T GuessPluginTypeFromLibPath(const wxString &aLibPath, int aCtl=0)
Return a plugin type given a footprint library's libPath.
static bool ImportGeneratesProjectLibrary(PCB_FILE_T aFileType)
Return true when importing aFileType should materialize a project footprint library.
static const wxString ShowType(PCB_FILE_T aFileType)
Return a brief name for a plugin given aFileType enum.
std::unique_ptr< BOARD > LoadBoard(const wxString &aFileName, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr)
Load information from some input file format that this PCB_IO implementation knows about into new BOA...
static void PlotJobToPlotOpts(PCB_PLOT_PARAMS &aOpts, JOB_EXPORT_PCB_PLOT *aJob, REPORTER &aReporter)
True when the board's out-of-date-chart policy regenerated charts during the last Plot().
bool Plot(const wxString &aOutputPath, const LSEQ &aLayersToPlot, const LSEQ &aCommonLayers, bool aUseGerberFileExtensions, bool aOutputPathIsSingle=false, std::optional< wxString > aLayerName=std::nullopt, std::optional< wxString > aSheetName=std::nullopt, std::optional< wxString > aSheetPath=std::nullopt, std::vector< wxString > *aOutputFiles=nullptr)
static void BuildPlotFileName(wxFileName *aFilename, const wxString &aOutputDir, const wxString &aSuffix, const wxString &aExtension)
Complete a plot filename.
Parameters and options when plotting/printing a board.
LSEQ GetPlotOnAllLayersSequence() const
void SetLayerSelection(const LSET &aSelection)
void SetPlotOnAllLayersSequence(LSEQ aSeq)
void SetPlotPadNumbers(bool aFlag)
LSET GetLayerSelection() const
bool GetSketchPadsOnFabLayers() const
bool GetUseGerberProtelExtensions() const
virtual SETTINGS_MANAGER & GetSettingsManager() const
Used to create Gerber drill files.
const wxString GetPlaceFileName(const wxString &aFullBaseFilename, PCB_LAYER_ID aLayer) const
void SetVariant(const wxString &aVariant)
Set the variant name for variant-aware filtering.
int CreatePlaceFile(const wxString &aFullFilename, PCB_LAYER_ID aLayer, bool aIncludeBrdEdges, bool aExcludeDNP, bool aExcludeBOM)
Create an pnp gerber file.
The ASCII format of the kicad place file is:
static wxString DecorateFilename(const wxString &aBaseName, bool aFront, bool aBack)
std::string GenPositionData()
build a string filled with the position data
void SetVariant(const wxString &aVariant)
Set the variant name for variant-aware export.
Base plotter engine class.
The backing store for a PROJECT, in JSON format.
wxString m_BoardDrawingSheetFile
PcbNew params.
bool Store() override
Stores the current parameters into the JSON document represented by this object Note: this doesn't do...
static S3D_CACHE * Get3DCacheManager(PROJECT *aProject, bool updateProjDir=false)
Return a pointer to an instance of the 3D cache manager.
static FILENAME_RESOLVER * Get3DFilenameResolver(PROJECT *aProject)
Accessor for 3D path resolver.
static FOOTPRINT_LIBRARY_ADAPTER * FootprintLibAdapter(PROJECT *aProject)
Container for project specific data.
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
virtual const wxString GetProjectPath() const
Return the full path of the project.
virtual const wxString GetProjectName() const
Return the short name 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
void SetReporters(std::shared_ptr< REPORTER > aActivityReporter, std::shared_ptr< REPORTER > aWarningReporter)
Set the reporters for activity and warning messages.
wxSize GetRealBufferSize()
bool Redraw(bool aIsMoving) override
Redraw the view.
void SetCurWindowSize(const wxSize &aSize) override
Before each render, the canvas will tell the render what is the size of its windows,...
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.
RAII class that sets an value at construction and resets it to the original value at destruction.
bool SaveProjectCopy(const wxString &aFullPath, PROJECT *aProject=nullptr)
Save a copy of the current project under the given path.
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.
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Save, unload and unregister the given PROJECT.
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.
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
void Pan_T1(const SFVEC3F &aDeltaOffsetInc) override
void SetT0_and_T1_current_T() override
This will set T0 and T1 with the current values.
void Interpolate(float t) override
It will update the matrix to interpolate between T0 and T1 values.
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
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.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
static DRILL_PRECISION precisionListForInches(2, 4)
static DRILL_PRECISION precisionListForMetric(3, 3)
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)
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.
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.
#define FOLLOW_PLOT_SETTINGS
Classes used in drill files, map files and report files generation.
Classes used in drill files, map files and report files generation.
int RefreshGeneratedTables(BOARD &aBoard)
Bring every generated table on the board up to date and return how many were rebuilt.
Classes used to generate a Gerber job file in JSON.
Classes used in place file generation.
static const std::string LegacySchematicFileExtension
static const std::string BrepFileExtension
static const std::string SymbolLibraryTableFileName
static const std::string JpegFileExtension
static const std::string GerberJobFileExtension
static const std::string GerberFileExtension
static const std::string XaoFileExtension
static const std::string ReportFileExtension
static const std::string GltfBinaryFileExtension
static const std::string ProjectFileExtension
static const std::string PngFileExtension
static const std::string FootprintPlaceFileExtension
static const std::string JsonFileExtension
static const std::string IdfV3BoardFileExtension
static const std::string KiCadSchematicFileExtension
static const std::string CsvFileExtension
static const std::string U3DFileExtension
static const std::string PdfFileExtension
static const std::string Ipc2581FileExtension
static const std::string FootprintLibraryTableFileName
static const std::string GencadFileExtension
static const std::string StlFileExtension
static const std::string IpcD356FileExtension
static const std::string PlyFileExtension
static const std::string StepFileExtension
static const std::string SVGFileExtension
static const std::string DesignRulesFileExtension
static const std::string VrmlFileExtension
static const std::string KiCadFootprintFileExtension
static const std::string ArchiveFileExtension
static const std::string KiCadPcbFileExtension
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
bool ApplyImportedNetNameMap(BOARD &aBoard, const std::map< wxString, wxString > &aNames, REPORTER &aReporter)
Apply caller-selected imported net names without changing net identity or connectivity.
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
bool GenerateIpc2581File(JOB_EXPORT_PCB_IPC2581 &aJob, BOARD *aBoard, PROGRESS_REPORTER *aProgressReporter, REPORTER *aReporter)
Write the IPC-2581 file or archive of aJob and record it as a job output.
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...
@ KIFACE_NETLIST_SCHEMATIC
#define KICTL_KICAD_ONLY
chosen file is from KiCad according to user
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
@ LAYER_3D_BACKGROUND_TOP
@ LAYER_3D_BACKGROUND_BOTTOM
PCB_LAYER_ID
A quick note on layer IDs:
This file contains miscellaneous commonly used macros and functions.
#define MAIL_SCH_GET_NETLIST_CANCELLED
Reply payload for MAIL_SCH_GET_NETLIST when the user deliberately aborts netlist generation (for exam...
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_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
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,...
const wxString DOC_PROP_NET_CLASSES
LIB_MERGE_APPLIER< FOOTPRINT > FP_LIB_MERGE_APPLIER
Footprint-library 3-way merge applier. See LIB_MERGE_APPLIER for behavior.
void AppendGeometry(DOCUMENT_GEOMETRY &aDst, DOCUMENT_GEOMETRY &&aSrc)
Move all primitives from aSrc into aDst.
DOCUMENT_GEOMETRY ExtractFootprintGeometry(const FOOTPRINT &aFootprint, const KIGFX::COLOR4D &aColor)
Extract drawable context geometry from a single FOOTPRINT.
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.
const wxString DOC_PROP_DRC_SEVERITIES
DOCUMENT_GEOMETRY ExtractBoardGeometry(const BOARD &aBoard, const KIGFX::COLOR4D &aColor)
Extract a coarse outline of a BOARD into a DOCUMENT_GEOMETRY for use as background context in DIFF_SC...
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.
void PackBoardStackup(const BOARD &aBoard, BoardStackup &aOut)
ODB_EXPORT_RESULT GenerateODBPPFiles(const JOB_EXPORT_PCB_ODB &aJob, BOARD *aBoard, PCB_EDIT_FRAME *aParentFrame, PROGRESS_REPORTER *aProgressReporter, REPORTER *aReporter)
Generate the ODB++ tree or archive and return the write status and the paths written.
#define SEXPR_BOARD_FILE_VERSION
Current s-expression file format version. 2 was the last legacy format version.
#define CTL_FOR_LIBRARY
Format output for a footprint library instead of clipboard or BOARD.
bool PlotFootprintToSVG(const FOOTPRINT &aFootprint, PROJECT &aProject, const std::map< wxString, wxString > *aVarOverrides, PCB_PLOT_PARAMS &aPlotOpts, const LSEQ &aLayersToPlot, const LSEQ &aLayersOnAll, const wxString &aFileName, REPORTER *aReporter)
Plot a footprint to an SVG file, with the footprint origin at the SVG origin and the page/viewBox siz...
static PCB_LAYER_ID resolveKiCadLayerName(const wxString &aName)
static int loadFootprintLibrarySide(const wxString &aPath, std::vector< std::unique_ptr< FOOTPRINT > > &aOwners, KICAD_DIFF::FP_LIB_DIFFER::FOOTPRINT_MAP &aMap, bool aAllowEmpty, REPORTER &aReporter)
static wxString footprintRefusedMessage(const wxString &aFile, const DOWNGRADE_TARGET &aTarget)
static DRILL_PRECISION precisionListForInches(2, 4)
static int plotJob(JOB_EXPORT_PCB_PLOT *aJob, PCB_PLOTTER &aPlotter, const wxString &aOutPath, bool aSingleOutput, bool aUseOverrides)
static DRILL_PRECISION precisionListForMetric(3, 3)
static SCRATCH_DOC< BOARD > loadScratchBoard(SETTINGS_MANAGER &aMgr, const wxString &aPath, bool aInitializeAfterLoad=true)
static KICAD_DIFF::DOCUMENT_GEOMETRY footprintLibraryGeometry(const KICAD_DIFF::FP_LIB_DIFFER::FOOTPRINT_MAP &aMap, const KIGFX::COLOR4D &aColor)
static wxString downgradeFootprintLibraries(const wxString &aDir, const DOWNGRADE_TARGET &aTarget, bool aDropInsteadOfApproximate, DOWNGRADE_FILE_TRANSACTION *aTransaction=nullptr, wxString *aRecoveryError=nullptr)
static void classifyFootprintLibraries(const wxString &aDir, const DOWNGRADE_TARGET &aTarget, COMPATIBILITY_REPORT &aReport, bool aDropInsteadOfApproximate)
const wxString GetGerberProtelExtension(int aLayer)
PLOTTER * StartPlotBoard(BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aLayer, const wxString &aLayerName, const wxString &aFullFileName, const wxString &aSheetName, const wxString &aSheetPath, const wxString &aPageName=wxT("1"), const wxString &aPageNumber=wxEmptyString, const int aPageCount=1)
Open a new plotfile using the options (and especially the format) specified in the options and prepar...
void PlotBoardLayers(BOARD *aBoard, PLOTTER *aPlotter, const LSEQ &aLayerSequence, const PCB_PLOT_PARAMS &aPlotOptions)
Plot a sequence of board layer IDs.
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)
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 ...
T * GetAppSettings(const char *aFilename)
MODEL3D_FORMAT_TYPE fileType(const char *aFileName)
#define OPEN_OSTREAM(var, name)
#define CLOSE_STREAM(var)
wxString ExpandVariantOutputPath(const wxString &aPath, const wxString &aVariantToken)
bool initialize_after_load
bool subtractHolesFromCopperAreas
bool subtractHolesFromBoardArea
bool excludeFootprintsWithoutPads
bool includeByteOrderMark
static std::vector< BOM_FMT_PRESET > BuiltInPresets()
wxString refRangeDelimiter
Phase 8 context for the conflict canvas.
KICAD_DIFF::DOCUMENT_GEOMETRY ancestorGeometry
std::map< KIID_PATH, BOX2I > theirsBBoxes
KICAD_DIFF::DOCUMENT_GEOMETRY oursGeometry
std::map< KIID_PATH, BOX2I > oursBBoxes
KICAD_DIFF::DOCUMENT_GEOMETRY theirsGeometry
An older KiCad release we can export a project back to.
int m_boardVersion
SEXPR_BOARD_FILE_VERSION for the target.
wxString m_name
User-facing name, e.g. "KiCad 10.0".
std::vector< int > raytrace_lightElevation
bool show_footprints_normal
KIGFX::COLOR4D raytrace_lightColorCamera
bool raytrace_post_processing
std::vector< KIGFX::COLOR4D > raytrace_lightColor
KIGFX::COLOR4D raytrace_lightColorBottom
bool raytrace_reflections
bool show_footprints_virtual
bool differentiate_plated_copper
std::vector< int > raytrace_lightAzimuth
bool raytrace_refractions
bool show_footprints_not_in_posfile
bool raytrace_procedural_textures
bool show_footprints_insert
int raytrace_recursivelevel_refractions
KIGFX::COLOR4D raytrace_lightColorTop
bool raytrace_anti_aliasing
std::vector< BOM_PRESET > m_BomPresets
std::vector< BOM_FMT_PRESET > m_BomFmtPresets
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.
Result of planning a 3-way merge.
std::size_t ConflictCount() const
std::vector< KIID_PATH > unresolved
Report on the application after Apply() runs.
wxString fpLibTable
fp-lib-table content the applier resolved.
VALIDATION_REPORT validation
Post-apply validator pipeline result (refdes uniqueness, connectivity-rebuild-ack,...
bool drcSeveritiesTouched
bool projectFileTouched
True iff the applier resolved state that lives in the .kicad_pro or a project sibling file.
wxString customDrcRules
Custom DRC rules (.kicad_dru) content the applier resolved.
wxString symLibTable
sym-lib-table content the applier resolved.
wxString drawingSheetFile
Drawing sheet path the applier resolved (from a doc-level resolution).
Outcome of a single validator run.
std::vector< VALIDATION_FAILURE > failures
Implement a participant in the KIWAY alchemy.
A filename or source description, a problem input line, a line number, a byte offset,...
Move-only RAII wrapper for "load a KiCad document into a non-active scratch PROJECT and clean up afte...
std::unique_ptr< DOC > doc
Options controlling which stackup fields are included in CSV exports.
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...
static void checkParity(CREEPAGE_PARITY_FIXTURE &aFixture, const std::string &aBoard)
IbisParser parser & reporter
wxString result
Test unit parsing edge cases and error handling.
wxLogTrace helper definitions.
Declaration for a track ball camera.
double DEG2RAD(double deg)
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
VECTOR2< int32_t > VECTOR2I
Definition of file extensions used in Kicad.