27#include <wx/zipstrm.h>
28#include <wx/filename.h>
29#include <wx/tokenzr.h>
30#include <wx/wfstream.h>
32#include <nlohmann/json.hpp>
149#include <api/board/board.pb.h>
150#include <google/protobuf/util/json_util.h>
175 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
181 wxCHECK( bomJob && editFrame,
false );
191 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
198 wxCHECK( svgJob && editFrame,
false );
204 [](
JOB* job, wxWindow* aParent ) ->
bool
208 wxCHECK( renderJob,
false );
214 [](
JOB* job, wxWindow* aParent ) ->
bool
219 [](
JOB* job, wxWindow* aParent ) ->
bool
224 [](
JOB* job, wxWindow* aParent ) ->
bool
229 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
236 wxCHECK( svgJob && editFrame,
false );
242 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
249 wxCHECK( gencadJob && editFrame,
false );
256 [](
JOB* job, wxWindow* aParent ) ->
bool
261 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
268 wxCHECK( dxfJob && editFrame,
false );
274 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
281 wxCHECK( pdfJob && editFrame,
false );
287 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
294 wxCHECK( pngJob && editFrame,
false );
300 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
307 wxCHECK( psJob && editFrame,
false );
313 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
320 wxCHECK( statsJob && editFrame,
false );
325 statsJob->
m_filename = boardName.GetFullPath();
328 wxWindow* parent = aParent ? aParent :
static_cast<wxWindow*
>( editFrame );
335 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
342 wxCHECK( stackupJob && editFrame,
false );
347 stackupJob->
m_filename = boardName.GetFullPath();
350 wxWindow* parent = aParent ? aParent :
static_cast<wxWindow*
>( editFrame );
357 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
364 wxCHECK( gJob && editFrame,
false );
370 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
377 wxCHECK( gJob && editFrame,
false );
386 m_reporter->Report(
_(
"Plotting to HPGL is no longer supported as of KiCad 10.0.\n" ),
390 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
394 wxCHECK( editFrame,
false );
396 DisplayErrorMessage( editFrame,
_(
"Plotting to HPGL is no longer supported as of KiCad 10.0." ) );
400 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
407 wxCHECK( drillJob && editFrame,
false );
413 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
420 wxCHECK( posJob && editFrame,
false );
426 [](
JOB* job, wxWindow* aParent ) ->
bool
431 [](
JOB* job, wxWindow* aParent ) ->
bool
436 [](
JOB* job, wxWindow* aParent ) ->
bool
441 [](
JOB* job, wxWindow* aParent ) ->
bool
446 [](
JOB* job, wxWindow* aParent ) ->
bool
450 wxCHECK( drcJob,
false );
456 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
463 wxCHECK( ipcJob && editFrame,
false );
469 [](
JOB* job, wxWindow* aParent ) ->
bool
474 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
481 wxCHECK( odbJob && editFrame,
false );
487 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
494 wxCHECK( idfJob && editFrame,
false );
542 BOARD* brd =
nullptr;
546 auto getProjectForBoard = [&](
const wxString& aBoardPath ) ->
PROJECT*
548 wxFileName pro = aBoardPath;
556 settingsManager.
LoadProject( pro.GetFullPath(),
true );
563 auto loadBoardFromPath = [&](
const wxString& aBoardPath ) ->
BOARD*
575 return loadedBoard.release();
579 loadError = ioe.
What();
588 if( !
Pgm().IsGUI() &&
Pgm().GetSettingsManager().IsProjectOpen() )
590 wxString pcbPath = aPath;
592 if( pcbPath.IsEmpty() )
597 pcbPath =
path.GetFullPath();
601 m_cliBoard.reset( loadBoardFromPath( pcbPath ) );
605 else if(
Pgm().IsGUI() &&
Pgm().GetSettingsManager().IsProjectOpen() )
614 m_cliBoard.reset( loadBoardFromPath( aPath ) );
620 wxString msg =
_(
"Failed to load board" );
622 if( !loadError.IsEmpty() )
623 msg += wxString::Format( wxS(
": %s" ), loadError );
634 std::map<wxString, LSET> layerUserMasks;
635 std::map<wxString, LSET> layerMasks;
636 std::map<wxString, LSET> layerGuiMasks;
670 auto pushLayers = [&](
const LSET& layerSet )
673 layerMask.push_back( layer );
676 if( !aLayerString.IsEmpty() )
678 wxStringTokenizer layerTokens( aLayerString,
"," );
680 while( layerTokens.HasMoreTokens() )
682 std::string token =
TO_UTF8( layerTokens.GetNextToken().Trim(
true ).Trim(
false ) );
684 if( layerUserMasks.contains( token ) )
685 pushLayers( layerUserMasks.at( token ) );
686 else if( layerMasks.count( token ) )
687 pushLayers( layerMasks.at( token ) );
688 else if( layerGuiMasks.count( token ) )
689 pushLayers( layerGuiMasks.at( token ) );
691 m_reporter->Report( wxString::Format(
_(
"Invalid layer name '%s'\n" ), token ) );
715 if( !currentVariant.IsEmpty() && currentVariant != wxS(
"all" ) )
721 bool hasWarned =
false;
726 if( !fp->IsAnnotated() && !hasWarned )
728 m_reporter->Report(
_(
"Warning: board has unannotated footprints, please use the PCB "
729 "editor to annotate them\n" ),
762 std::set<wxString> userFieldNames;
764 for(
size_t i = 0; i < referenceList.size(); ++i )
766 FOOTPRINT& footprint = referenceList[i].GetFootprint();
770 if( !field->IsMandatory() && !field->IsPrivate() )
771 userFieldNames.insert( field->GetName() );
775 for(
const wxString& fieldName : userFieldNames )
787 std::optional<BOM_PRESET> boardPreset;
789 for(
const BOM_PRESET& p : BOM_PRESET::BuiltInPresets() )
810 wxString::Format(
_(
"BOM preset '%s' not found" ) + wxS(
"\n" ), aBomJob->
m_bomPresetName ),
816 preset = *boardPreset;
824 auto normalizeFieldName = [&dataModel](
const wxString& aName ) -> wxString
826 if( aName.IsEmpty() )
827 return wxEmptyString;
832 wxString wrapped = wxS(
"${" ) + aName + wxS(
"}" );
844 wxString fieldName = normalizeFieldName( rawFieldName );
846 if( fieldName.IsEmpty() )
854 if( fieldName == wxS(
"*" ) )
860 field.
name = modelField.name;
865 bool fieldAlreadyPresent =
false;
867 for(
BOM_FIELD& presetField : preset.fieldsOrdered )
869 if( presetField.
name == field.
name )
871 fieldAlreadyPresent =
true;
876 bool fieldLaterInList =
false;
880 if( normalizeFieldName( fieldInList ) == field.
name )
882 fieldLaterInList =
true;
887 if( !fieldAlreadyPresent && !fieldLaterInList )
888 preset.fieldsOrdered.emplace_back( field );
896 field.
name = fieldName;
897 field.
show = !fieldName.StartsWith( wxT(
"__" ), &field.
name );
898 field.
name = normalizeFieldName( field.
name );
907 preset.fieldsOrdered.emplace_back( field );
913 wxString fieldName = rawFieldName;
914 fieldName.StartsWith( wxT(
"__" ), &fieldName );
915 fieldName = normalizeFieldName( fieldName );
917 if( fieldName.IsEmpty() )
920 bool fieldAlreadyPresent =
false;
922 for(
BOM_FIELD& field : preset.fieldsOrdered )
924 if( field.
name == fieldName )
927 fieldAlreadyPresent =
true;
932 if( !fieldAlreadyPresent )
937 preset.sortField = normalizeFieldName( aBomJob->
m_sortField );
949 std::optional<BOM_FMT_PRESET> boardFmtPreset;
969 if( !boardFmtPreset )
971 m_reporter->Report( wxString::Format(
_(
"BOM format preset '%s' not found" ) + wxS(
"\n" ),
978 fmt = *boardFmtPreset;
994 fn.SetName( fn.GetName() );
1001 bool hasVariantPlaceholder = configuredPath.Contains( wxS(
"${VARIANT}" ) );
1004 std::vector<wxString> variantsToProcess;
1006 if( aBomJob->
m_variantNames.size() > 1 && hasVariantPlaceholder )
1012 variantsToProcess.push_back( currentVariant );
1015 for(
const wxString& variantName : variantsToProcess )
1017 std::vector<wxString> singleVariant = { variantName };
1025 if( hasVariantPlaceholder )
1045 if( !f.Open( outPath, wxFile::write ) )
1047 m_reporter->Report( wxString::Format(
_(
"Unable to open destination '%s'" ), outPath ),
1053 bool res = f.Write( dataModel.
Export( fmt ) );
1071 if( aStepJob ==
nullptr )
1085 fn.SetName( fn.GetName() );
1145 m_reporter->Report( wxString::Format(
_(
"Successfully exported VRML to %s" ), outPath ),
1177 if( !stepExporter.
Export() )
1189 if( aRenderJob ==
nullptr )
1224 fn.SetName( wxString::Format(
"%s-%d", fn.GetName(),
static_cast<int>( aRenderJob->
m_side ) ) );
1314 lightColor, lightColor, lightColor, lightColor, lightColor, lightColor, lightColor, lightColor,
1320 sideElevation, sideElevation, sideElevation, sideElevation,
1321 -sideElevation, -sideElevation, -sideElevation, -sideElevation,
1325 45, 135, 225, 315, 45, 135, 225, 315,
1330 boardAdapter.
m_Cfg = &cfg;
1346 if( preset->name.Lower() ==
_(
"legacy colors" ) )
1361 static std::map<JOB_PCB_RENDER::SIDE, VIEW3D_TYPE> s_viewCmdMap = {
1384 for(
bool first =
true; raytrace.
Redraw(
false ); first = false )
1411 uint8_t* rgbaBuffer = raytrace.
GetBuffer();
1413 bool success = !!rgbaBuffer;
1417 const unsigned int wxh = realSize.x * realSize.y;
1419 unsigned char* rgbBuffer = (
unsigned char*) malloc( wxh * 3 );
1420 unsigned char* alphaBuffer = (
unsigned char*) malloc( wxh );
1422 unsigned char* rgbaPtr = rgbaBuffer;
1423 unsigned char* rgbPtr = rgbBuffer;
1424 unsigned char* alphaPtr = alphaBuffer;
1426 for(
int y = 0; y < realSize.y; y++ )
1428 for(
int x = 0; x < realSize.x; x++ )
1430 rgbPtr[0] = rgbaPtr[0];
1431 rgbPtr[1] = rgbaPtr[1];
1432 rgbPtr[2] = rgbaPtr[2];
1433 alphaPtr[0] = rgbaPtr[3];
1441 wxImage
image( realSize );
1442 image.SetData( rgbBuffer );
1443 image.SetAlpha( alphaBuffer );
1446 image.SetOption( wxIMAGE_OPTION_QUALITY, 90 );
1447 image.SaveFile( outPath,
1507 bool aSingleOutput,
bool aUseOverrides )
1509 std::optional<wxString> layerName;
1510 std::optional<wxString> sheetName;
1511 std::optional<wxString> sheetPath;
1525 std::vector<wxString> outputPaths;
1528 aSingleOutput, layerName, sheetName, sheetPath, &outputPaths ) )
1533 for(
const wxString& outputPath : outputPaths )
1544 if( aSvgJob ==
nullptr )
1574 return plotJob( aSvgJob, plotter, outPath, isSingle, isSingle );
1582 if( aDxfJob ==
nullptr )
1613 return plotJob( aDxfJob, plotter, outPath, isSingle, isSingle );
1619 bool plotAllLayersOneFile =
false;
1622 if( pdfJob ==
nullptr )
1639 plotAllLayersOneFile =
true;
1641 const bool outputIsSingle = plotAllLayersOneFile || pdfJob->
m_pdfSingle;
1656 return plotJob( pdfJob, pcbPlotter, outPath, outputIsSingle, plotAllLayersOneFile );
1664 if( pngJob ==
nullptr )
1695 return plotJob( pngJob, pcbPlotter, outPath, isSingle,
false );
1703 if( psJob ==
nullptr )
1734 return plotJob( psJob, pcbPlotter, outPath, isSingle, isSingle );
1743 if( aGerberJob ==
nullptr )
1772 bool hasLayerListSpecified =
false;
1779 hasLayerListSpecified =
true;
1819 LSET preflightLayers = layersToPlot;
1822 preflightLayers.
set( commonLayer );
1831 plotSequence.push_back( layer );
1837 if(
find( plotSequence.begin(), plotSequence.end(), layer_all ) != plotSequence.end() )
1840 plotSequence.push_back( layer_all );
1851 plotOpts = boardPlotOptions;
1861 wxString fullname = fn.GetFullName();
1869 jobfile_writer.
AddGbrFile( layer, fullname );
1895 m_reporter->Report( wxString::Format(
_(
"Failed to plot to '%s'.\n" ), fn.GetFullPath() ),
1921 if( aGencadJob ==
nullptr )
1945 fn.SetName( fn.GetName() );
2007 m_reporter->Report( wxString::Format(
_(
"Export failed: %s\n" ), ioe.
What() ),
2023 if( statsJob ==
nullptr )
2041 wxString projectName;
2048 if( boardFile.GetName().IsEmpty() )
2049 boardFile = wxFileName( statsJob->
m_filename );
2072 FILE* outFile = wxFopen( outPath, wxS(
"wt" ) );
2080 if( fprintf( outFile,
"%s",
TO_UTF8( report ) ) < 0 )
2101 if( stackupJob ==
nullptr )
2111 if( boardFile.GetName().IsEmpty() )
2112 boardFile = wxFileName( stackupJob->
m_filename );
2120 kiapi::board::BoardStackup stackupMsg;
2123 google::protobuf::util::JsonPrintOptions jsonOptions;
2124 jsonOptions.add_whitespace =
true;
2128 if( !google::protobuf::util::MessageToJsonString( stackupMsg, &
json, jsonOptions ).ok() )
2134 output = wxString::FromUTF8(
json );
2147 item->SetLayerName( brd->
GetLayerName( item->GetBrdLayerId() ) );
2188 const bool writeOk =
static_cast<bool>( outFile );
2210 if( aGerberJob ==
nullptr )
2238 fn.SetName( fn.GetName() );
2292 PLOTTER* plotter =
StartPlotBoard( brd, &plotOpts, layer, layerName, outPath, sheetName, sheetPath );
2293 bool success =
false;
2320 if( aDrillJob ==
nullptr )
2336 std::unique_ptr<GENDRILL_WRITER_BASE> drillWriter;
2339 drillWriter = std::make_unique<EXCELLON_WRITER>( brd );
2341 drillWriter = std::make_unique<GERBER_WRITER>( brd );
2365 wxFileName fn = outPath;
2367 fn.SetName( fn.GetName() +
"-drill" );
2398 if( excellonWriter ==
nullptr )
2413 for(
const wxString& outputFile : drillWriter->GetCreatedFiles() )
2432 if( gerberWriter ==
nullptr )
2448 for(
const wxString& outputFile : drillWriter->GetCreatedFiles() )
2472 if( aPosJob ==
nullptr )
2483 fn.SetName( fn.GetName() );
2505 wxFileName fn( outPath );
2506 wxString baseName = fn.GetName();
2508 auto exportPlaceFile = [&](
bool frontSide,
bool backSide,
const wxString& curr_outPath ) ->
bool
2510 FILE* file = wxFopen( curr_outPath, wxS(
"wt" ) );
2511 wxCHECK( file,
false );
2523 fputs( data.c_str(), file );
2536 if( exportPlaceFile(
true,
false, fn.GetFullPath() ) )
2538 m_reporter->Report( wxString::Format(
_(
"Wrote front position data to '%s'.\n" ), fn.GetFullPath() ),
2553 if( exportPlaceFile(
false,
true, fn.GetFullPath() ) )
2555 m_reporter->Report( wxString::Format(
_(
"Wrote back position data to '%s'.\n" ), fn.GetFullPath() ),
2581 if( exportPlaceFile( front, back, fn.GetFullPath() ) )
2583 m_reporter->Report( wxString::Format(
_(
"Wrote position data to '%s'.\n" ), fn.GetFullPath() ),
2602 wxString outPath_base = outPath;
2613 m_reporter->Report( wxString::Format(
_(
"Wrote front position data to '%s'.\n" ), outPath ),
2628 outPath = outPath_base;
2637 m_reporter->Report( wxString::Format(
_(
"Wrote back position data to '%s'.\n" ), outPath ),
2657 if( upgradeJob ==
nullptr )
2672 m_reporter->Report(
_(
"Output path must be specified to convert legacy and non-KiCad libraries\n" ),
2682 m_reporter->Report(
_(
"Footprint library path does not exist or is not accessible\n" ),
2703 bool shouldSave = upgradeJob->
m_force;
2749 if( svgJob ==
nullptr )
2782 bool singleFpPlotted =
false;
2784 for(
const auto& [fpName, fpCacheEntry] : fpLib.
GetFootprints() )
2798 singleFpPlotted =
true;
2801 exitCode =
doFpExportSvg( svgJob, fpCacheEntry->GetFootprint().get() );
2807 if( !svgJob->
m_footprint.IsEmpty() && !singleFpPlotted )
2809 m_reporter->Report(
_(
"The given footprint could not be found to export." ) + wxS(
"\n" ),
2819 wxFileName outputFile;
2824 m_reporter->Report( wxString::Format(
_(
"Plotting footprint '%s' to '%s'\n" ),
2839 aSvgJob->
AddOutput( outputFile.GetFullPath() );
2849 if( drcJob ==
nullptr )
2865 fn.SetName( fn.GetName() + wxS(
"-drc" ) );
2894 std::unique_ptr<NETLIST>
netlist = std::make_unique<NETLIST>();
2896 if( !drcEngine->RulesValid() )
2904 m_reporter->Report(
_(
"DRC incomplete: could not compile custom design rules." )
2905 + wxS(
"\n" ) + error.
What() + wxS(
"\n" ),
2918 std::string netlist_str;
2922 wxString annotateMsg =
_(
"Schematic parity tests require a fully annotated schematic." );
2923 netlist_str = annotateMsg;
2935 wxFileName schematicPath( drcJob->
m_filename );
2936 schematicPath.MakeAbsolute();
2939 if( !schematicPath.Exists() )
2942 if( !schematicPath.Exists() )
2949 typedef bool ( *NETLIST_FN_PTR )(
const wxString&, std::string&,
KIWAY* );
2952 ( *netlister )( schematicPath.GetFullPath(), netlist_str,
m_kiway );
2960 else if( netlist_str == annotateMsg )
2982 drcEngine->SetSchematicNetlist(
netlist.get() );
2994 drcEngine->SetViolationHandler(
2995 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
2996 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
2999 aPathGenerator( marker );
3000 commit.
Add( marker );
3006 drcEngine->ClearViolationHandler();
3013 std::shared_ptr<DRC_ITEMS_PROVIDER> markersProvider =
3016 std::shared_ptr<DRC_ITEMS_PROVIDER> ratsnestProvider =
3019 std::shared_ptr<DRC_ITEMS_PROVIDER> fpWarningsProvider =
3022 markersProvider->SetSeverities( drcJob->
m_severity );
3023 ratsnestProvider->SetSeverities( drcJob->
m_severity );
3024 fpWarningsProvider->SetSeverities( drcJob->
m_severity );
3026 m_reporter->Report( wxString::Format(
_(
"Found %d violations\n" ), markersProvider->GetCount() ),
3028 m_reporter->Report( wxString::Format(
_(
"Found %d unconnected items\n" ), ratsnestProvider->GetCount() ),
3034 wxString::Format(
_(
"Found %d schematic parity issues\n" ), fpWarningsProvider->GetCount() ),
3038 DRC_REPORT reportWriter( brd, units, markersProvider, ratsnestProvider, fpWarningsProvider );
3040 bool wroteReport =
false;
3073 if( markersProvider->GetCount() > 0 || ratsnestProvider->GetCount() > 0 || fpWarningsProvider->GetCount() > 0 )
3105 if( job ==
nullptr )
3113 struct VARIANT_RESTORE
3153 if( job ==
nullptr )
3164 fn.SetName( fn.GetName() );
3180 bool success = exporter.
Write( outPath );
3200 if( job ==
nullptr )
3234 if( !exporter.
Export( outPath ) )
3247 if( job ==
nullptr )
3265 fn.SetName( fn.GetName() + wxS(
"-odb" ) );
3290 for(
const wxString&
path :
result.m_outputs )
3304 if( job ==
nullptr )
3307 bool shouldSave = job->
m_force;
3338 wxString::Format(
_(
"Error saving board file '%s'.\n%s" ), job->
m_filename, ioe.
What().GetData() );
3351 wxArrayString files;
3352 wxDir::GetAllFiles( aDir, &files, wxT(
"*.kicad_mod" ) );
3354 for(
const wxString& file : files )
3363 std::unique_ptr<FOOTPRINT> fp = loader.
ImportFootprint( file, nameOut );
3369 scratch.
Add( fp.release() );
3384 bool aDropInsteadOfApproximate,
3386 wxString* aRecoveryError =
nullptr )
3395 [&](
const wxString& aText )
3397 return FindUnsupportedBoardToken( aText, aTarget );
3399 convert, aTransaction, aRecoveryError );
3405 return wxString::Format(
_(
"Cannot export: footprint '%s' uses a feature %s cannot open.\n" ), aFile,
3414 if( job ==
nullptr )
3420 if( target ==
nullptr )
3422 m_reporter->Report( wxString::Format(
_(
"Unknown target version '%s'. Valid targets: %s\n" ), job->
m_target,
3437 m_reporter->Report(
_(
"The target supports variants, so there is nothing to flatten.\n" ),
3443 wxString libraryCopy;
3455 if( !job->
m_outputFile.IsEmpty() && output.MakeAbsolute() )
3489 const std::vector<wxString>& names = brd->GetVariantNames();
3496 m_reporter->Report(
_(
"The board has no variant data. The base board is exported.\n" ),
3499 else if( std::find( names.begin(), names.end(), job->
m_variant ) == names.end() )
3502 wxString::Format(
_(
"The board has no variant named '%s'.\n" ), job->
m_variant ),
3528 m_reporter->Report(
_(
"Cannot export: the board uses features the target cannot represent.\n" ),
3535 m_reporter->Report(
_(
"Export would lose data. Re-run with --force to export anyway.\n" ),
3546 output.MakeAbsolute();
3548 if( !outputDirectories.
Create( output.GetPath() ) )
3554 if( !libraryDir.IsEmpty() )
3562 libraryDir = libraryCopy;
3569 if( stagedBoard.IsEmpty() )
3581 if( !badToken.IsEmpty() )
3582 m_reporter->Report( wxString::Format(
_(
"Cannot export: the result still uses '%s', which %s "
3583 "cannot open. This feature has no downgrade rule yet.\n" ),
3584 badToken, target->
m_name ),
3597 if( !badLib.IsEmpty() )
3604 wxString failedDestination = transaction.
Commit();
3606 if( !failedDestination.IsEmpty() )
3608 m_reporter->Report( wxString::Format(
_(
"Could not replace '%s'.\n" ), failedDestination ),
3617 outputDirectories.
Commit();
3646 m_reporter->Report(
_(
"Cannot export: the libraries use features the target cannot represent.\n" ),
3653 m_reporter->Report(
_(
"Export would lose data. Re-run with --force to export anyway.\n" ),
3658 wxString recoveryError;
3660 nullptr, &recoveryError );
3662 if( !badLib.IsEmpty() )
3666 if( !recoveryError.IsEmpty() )
3679 m_reporter->Report( wxString::Format(
_(
"Error exporting '%s'.\n%s" ), where, ioe.
What().GetData() ),
3694 if( aDrawingSheet && !aDrawingSheet->IsEmpty() )
3724 return drawingSheet;
3731 if( aSheetPath.IsEmpty() )
3734 auto loadSheet = [&](
const wxString&
path ) ->
bool
3747 m_reporter->Report( wxString::Format(
_(
"Error loading drawing sheet '%s'." ),
path ) + wxS(
"\n" ) + msg
3756 if( loadSheet( aSheetPath ) )
3788 m_reporter->Report( wxString::Format(
_(
"Input file not found: '%s'\n" ),
3832 m_reporter->Report( wxString::Format(
_(
"No PCB importer recognizes the file format of "
3845 m_reporter->Report( wxString::Format(
_(
"No plugin found for file type '%s'\n" ),
3857 m_reporter->Report( wxString::Format(
_(
"Failed to inspect board project: %s\n" ), ioe.
What() ),
3869 if( outputPath.IsEmpty() )
3877 PROJECT* projectPtr =
nullptr;
3878 bool createdTransientProject =
false;
3882 projectPtr = &mgr.
Prj();
3886 wxFileName projectFn( outputPath );
3890 projectFn.MakeAbsolute();
3893 projectPtr = mgr.
GetProject( projectFn.GetFullPath() );
3894 createdTransientProject = ( projectPtr != nullptr );
3899 m_reporter->Report(
_(
"Could not establish a project for the import\n" ),
3916 } transientProjectGuard{ mgr, projectPtr, createdTransientProject };
3918 std::unique_ptr<BOARD> board;
3920 struct BOARD_PROJECT_GUARD
3922 std::unique_ptr<BOARD>& board;
3924 ~BOARD_PROJECT_GUARD()
3927 board->ClearProject();
3929 } boardProjectGuard{ board };
3932 std::vector<wxString> warnings;
3936 struct CAPTURED_LAYER
3943 std::vector<CAPTURED_LAYER> capturedLayers;
3944 std::set<wxString> seenSourceLayers;
3945 bool layersCaptured =
false;
3955 m_reporter->Report( wxString::Format(
_(
"No plugin found for file type '%s'\n" ), formatName ),
3961 pi->SetReporter( &importMessages );
3970 mappable->RegisterCallback(
3971 [&](
const std::vector<INPUT_LAYER_DESC>& aDescs )
3972 -> std::map<wxString, PCB_LAYER_ID>
3974 std::map<wxString, PCB_LAYER_ID>
result;
3979 wxString method = wxS(
"auto" );
3981 if(
auto it = job->
m_layerMap.find( desc.Name );
3988 warnings.push_back( wxString::Format(
3989 _(
"Layer map entry '%s' -> '%s' names an unknown "
3990 "KiCad layer; using automatic mapping instead" ),
3991 desc.Name, it->second ) );
3993 else if( !desc.PermittedLayers.Contains( resolved ) )
3995 warnings.push_back( wxString::Format(
3996 _(
"Layer map entry '%s' -> '%s' is not a permitted "
3997 "target for this layer; using automatic mapping "
3999 desc.Name, it->second ) );
4004 method = wxS(
"explicit" );
4010 warnings.push_back( wxString::Format(
4011 _(
"No KiCad layer mapping for required source layer "
4012 "'%s'; its items will not be imported" ),
4016 result.emplace( desc.Name, target );
4017 capturedLayers.push_back( { desc.Name, target, method } );
4018 seenSourceLayers.insert( desc.Name );
4021 layersCaptured =
true;
4028 warnings.push_back(
_(
"A layer map was provided, but this importer does not support "
4029 "layer remapping; it will be ignored" ) );
4033 wxString::Format(
_(
"Importing '%s' using %s format...\n" ), job->
m_inputFile, formatName ),
4042 const std::map<std::string, UTF8>* importProperties =
nullptr;
4043 std::map<std::string, UTF8> easyEdaProProperties;
4048 easyEdaProProperties.emplace(
"pcb_id", std::string( job->
m_importPcbId.ToUTF8() ) );
4049 importProperties = &easyEdaProProperties;
4052 board = pi->LoadBoard( job->
m_inputFile, importProperties, projectPtr );
4059 m_reporter->Report( wxString::Format(
_(
"Unexpected cancellation: %s\n" ), ioce.
What() ),
4080 const wxString reconciliationPath =
4087 if( layersCaptured )
4091 if( !seenSourceLayers.contains(
source ) )
4093 warnings.push_back( wxString::Format(
4094 _(
"Layer map entry '%s' does not match any source layer in the "
4095 "imported file; it will be ignored" ),
4104 kicadPlugin->SaveBoard( outputPath, *board );
4105 wxString importedRules = pi->GetImportedDesignRules();
4107 if( !importedRules.IsEmpty() )
4109 wxFileName rulesPath( outputPath );
4112 wxFile rulesFile( rulesPath.GetFullPath(), wxFile::write );
4114 if( rulesFile.IsOpened() )
4116 rulesFile.Write( importedRules );
4120 m_reporter->Report( wxString::Format(
_(
"Could not write imported design rules to '%s'\n" ),
4121 rulesPath.GetFullPath() ),
4126 m_reporter->Report( wxString::Format(
_(
"Successfully saved imported board to '%s'\n" ), outputPath ),
4130 IMPORT_REPORT_DATA reportData;
4135 reportData.m_sourceFile = wxFileName( job->
m_inputFile ).GetFullName();
4136 reportData.m_sourceFormat = formatName;
4137 reportData.m_outputFile = wxFileName( outputPath ).GetFullName();
4139 size_t trackCount = 0;
4140 size_t viaCount = 0;
4142 for(
PCB_TRACK* track : board->Tracks() )
4150 reportData.m_statistics = {
4151 { wxS(
"footprints" ), board->Footprints().size() },
4152 { wxS(
"tracks" ), trackCount },
4153 { wxS(
"vias" ), viaCount },
4154 { wxS(
"zones" ), board->Zones().size() }
4160 nlohmann::json layerMappings = nlohmann::json::object();
4162 if( layersCaptured )
4164 for(
const CAPTURED_LAYER& mapped : capturedLayers )
4168 :
LSET::Name( mapped.m_target ).ToStdString();
4170 layerMappings[mapped.m_source.ToStdString()] = {
4171 {
"kicad_layer", kicadLayer },
4172 {
"method", mapped.m_method.ToStdString() }
4178 for(
PCB_LAYER_ID layer : board->GetEnabledLayers().Seq() )
4180 wxString layerName = board->GetLayerName( layer );
4182 layerMappings[layerName.ToStdString()] = {
4183 {
"kicad_layer",
LSET::Name( layer ).ToStdString() },
4184 {
"method",
"auto" }
4189 reportData.m_extraJson[
"layer_mapping"] = layerMappings;
4190 reportData.m_warnings.insert( reportData.m_warnings.end(), warnings.begin(), warnings.end() );
4198 for(
const wxString& warning : warnings )
4229 bool aInitializeAfterLoad =
true )
4233 [aPath, aInitializeAfterLoad](
PROJECT* aProject ) -> std::unique_ptr<BOARD>
4256 aBoard->ClearProject();
4277 BOARD* boardA = aScratch.
doc.get();
4278 BOARD* boardB = bScratch.
doc.get();
4298 return diffExitCode;
4327 const wxString& aOurs,
const wxString& aTheirs,
4328 const wxString& aOutput,
bool aInteractive,
bool aSingleFile,
4337 return runFpLibMerge( aAncestor, aOurs, aTheirs, aOutput, aSingleFile );
4339 return runPcbMerge( aAncestor, aOurs, aTheirs, aOutput, aInteractive );
4344 const wxString& aTheirs,
const wxString& aOutput,
4361 BOARD* ancestor = ancestorScratch.
doc.get();
4362 BOARD* ours = oursScratch.
doc.get();
4363 BOARD* theirs = theirsScratch.
doc.get();
4365 if( !ancestor || !ours || !theirs )
4371 const wxString formatNotice =
4375 if( !formatNotice.IsEmpty() )
4389 if( !
Pgm().IsGUI() )
4391 m_reporter->Report(
_(
"--interactive requires a GUI KiCad process; the console "
4392 "kicad-cli cannot open dialogs.\n" ),
4414 return wxEmptyString;
4418 for(
BOARD* board : { ours, theirs, ancestor } )
4423 if(
BOARD_ITEM* item = board->ResolveItem( aId.back(),
true ) )
4424 return item->GetItemDescription( &units,
false );
4427 return wxEmptyString;
4432 const std::optional<KIID_PATH>& )
4434 BOARD* board =
nullptr;
4467 std::unique_ptr<BOARD> merged = applier.
Apply();
4484 m_reporter->Report( wxString::Format(
_(
"Failed to save merged board: %s\n" ), ioe.
What() ),
4517 wxFileName proFn( aOutput );
4540 std::set<wxString> touched;
4558 wxString::Format(
_(
"Failed to save merged project file: %s\n" ), proFn.GetFullPath() ),
4567 auto writeStagedFile = [&](
const wxString& aPath,
const wxString& aContent,
const wxString& aLabel ) ->
bool
4569 if( aContent.IsEmpty() )
4571 if( wxFileExists( aPath ) )
4572 wxRemoveFile( aPath );
4579 if( !out.Open( aPath, wxFile::write ) || !out.Write( aContent ) )
4581 m_reporter->Report( wxString::Format(
_(
"Failed to save merged %s: %s\n" ), aLabel, aPath ),
4593 wxFileName druFn( aOutput );
4606 wxFileName fpFn( aOutput );
4609 if( !writeStagedFile( fpFn.GetFullPath(), applier.
GetReport().
fpLibTable,
_(
"footprint library table" ) ) )
4617 wxFileName symFn( aOutput );
4620 if( !writeStagedFile( symFn.GetFullPath(), applier.
GetReport().
symLibTable,
_(
"symbol library table" ) ) )
4631 m_reporter->Report( wxString::Format( wxS(
"%s: %s\n" ), f.validator, f.message ), f.severity );
4638 m_reporter->Report( wxString::Format(
_(
"Merge completed with %zu unresolved conflict(s) in %s\n" ),
4659 std::vector<std::unique_ptr<FOOTPRINT>>& aOwners,
4663 if( aAllowEmpty && aPath.IsEmpty() )
4669 aOwners = std::move( loaded.first );
4670 aMap = std::move( loaded.second );
4675 aReporter.
Report( wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, ioe.
What() ),
4678 catch(
const std::exception& e )
4681 wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, wxString::FromUTF8( e.what() ) ),
4696 for(
const auto& [
name, footprint] : aMap )
4713 wxFileName dirA( diffJob->
m_inputA );
4714 dirA.MakeAbsolute();
4715 wxFileName dirB( diffJob->
m_inputB );
4716 dirB.MakeAbsolute();
4718 std::vector<std::unique_ptr<FOOTPRINT>> ownersA;
4719 std::vector<std::unique_ptr<FOOTPRINT>> ownersB;
4741 return diffExitCode;
4785 if( !aSides.
a.
doc && !aFileA.IsEmpty() )
4791 if( !aSides.
b.
doc && !aFileB.IsEmpty() )
4822 m_after->SetContextItems( {} );
4843 auto context = std::make_unique<PCB_DIFF_CANVAS_CONTEXT>( aBefore, aAfter );
4857 aDiff = context->m_sides.diff;
4858 return context.release();
4863 const wxString& aFileB,
const wxString& aLabelA,
4864 const wxString& aLabelB, wxWindow* aParent,
4872 wxWindow* parent = aParent ? aParent : ( wxTheApp ? wxTheApp->GetTopWindow() :
nullptr );
4880 auto loadFootprintFile = [&](
const wxString& aPath ) -> std::unique_ptr<FOOTPRINT>
4882 if( aPath.IsEmpty() )
4885 wxFileName fn( aPath );
4916 const wxString labelA = aLabelA.IsEmpty() ? aFileA : aLabelA;
4917 const wxString labelB = aLabelB.IsEmpty() ? aFileB : aLabelB;
4920 parent, labelA, labelB,
result, std::move( refGeometry ), std::move( compGeometry ),
4923 KICAD_DIFF::ConfigurePcbDiffCanvasContext( aCanvas, boardA, boardB, color );
4931 std::vector<std::unique_ptr<FOOTPRINT>> ownersA;
4932 std::vector<std::unique_ptr<FOOTPRINT>> ownersB;
4958 std::unique_ptr<FOOTPRINT> footprintA;
4959 std::unique_ptr<FOOTPRINT> footprintB;
4963 footprintA = loadFootprintFile( aFileA );
4967 m_reporter->Report( wxString::Format(
_(
"Failed to load %s: %s\n" ), aFileA, ioe.
What() ),
4974 footprintB = loadFootprintFile( aFileB );
4978 m_reporter->Report( wxString::Format(
_(
"Failed to load %s: %s\n" ), aFileB, ioe.
What() ),
4985 const wxString nameA = wxFileName( aFileA ).GetName();
4986 const wxString nameB = wxFileName( aFileB ).GetName();
4987 const wxString itemName = !nameB.IsEmpty() ? nameB : nameA;
4990 mapA[itemName] = footprintA.get();
4993 mapB[itemName] = footprintB.get();
5013 const wxString labelA = aLabelA.IsEmpty() ? aFileA : aLabelA;
5014 const wxString labelB = aLabelB.IsEmpty() ? aFileB : aLabelB;
5031 const wxString& aTheirs,
const wxString& aOutput,
5034 if( aOutput.IsEmpty() )
5042 std::vector<std::unique_ptr<FOOTPRINT>> owners;
5046 LIB_SIDE ancestor, ours, theirs;
5053 auto isSingleFile = [&](
const wxString& aPath )
5061 auto loadSide = [&](
const wxString& aPath, LIB_SIDE& aSide ) ->
int
5065 if( isSingleFile( aPath ) )
5077 const UTF8& itemName = fp->GetFPID().GetLibItemName();
5080 aSide.map[key] = fp.get();
5081 aSide.owners.push_back( std::move( fp ) );
5086 aSide.owners = std::move( loaded.first );
5087 aSide.map = std::move( loaded.second );
5092 m_reporter->Report( wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, ioe.
What() ),
5095 catch(
const std::exception& e )
5098 wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, wxString::FromUTF8( e.what() ) ),
5126 std::vector<std::unique_ptr<FOOTPRINT>> merged = applier.
Apply();
5131 const bool hadSilentFallback = applier.
GetReport().mergePropsFallback > 0;
5133 const bool singleFileOutput = isSingleFile( aOutput );
5142 if( singleFileOutput )
5143 outFn = wxFileName( aOutput );
5145 outFn = wxFileName::DirName( aOutput );
5147 outFn.MakeAbsolute();
5153 const wxString outDir = outFn.GetPath();
5155 if( !wxFileName::DirExists( outDir ) && !wxFileName::Mkdir( outDir, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
5157 m_reporter->Report( wxString::Format(
_(
"Cannot create output directory %s\n" ), outDir ),
5166 if( singleFileOutput )
5172 if( merged.size() > 1 )
5174 m_reporter->Report(
_(
"Single-file fp merge produced multiple footprints; refusing to "
5175 "collapse into one .kicad_mod\n" ),
5180 if( merged.empty() )
5185 if( wxFileName::FileExists( outFn.GetFullPath() ) )
5186 wxRemoveFile( outFn.GetFullPath() );
5192 io.
FootprintSave( outFn.GetFullPath(), merged.front().get(),
nullptr );
5203 io.
Format( merged.front().get() );
5215 std::set<wxString> mergedNames;
5217 for(
const auto& fp : merged )
5220 mergedNames.insert( fp->GetFPID().GetLibItemName() );
5223 wxArrayString existing;
5226 for(
const wxString&
name : existing )
5228 if( !mergedNames.count(
name ) )
5232 for(
const auto& fp : merged )
5237 const wxString
name = fp->GetFPID().GetLibItemName();
5248 m_reporter->Report( wxString::Format(
_(
"Failed to save merged footprint library: %s\n" ), ioe.
What() ),
5254 if( !planSnapshot.
Resolved() || hadSilentFallback )
5258 std::set<KIID_PATH> conflicts( planSnapshot.
unresolved.begin(), planSnapshot.
unresolved.end() );
5261 conflicts.insert(
id );
5263 m_reporter->Report( wxString::Format(
_(
"Footprint library merge completed with %zu unresolved "
5264 "conflict(s) in %s\n" ),
5265 conflicts.size(), aOutput ),
PROJECTION_TYPE
Camera projection types.
constexpr EDA_IU_SCALE pcbIUScale
#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()
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
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.
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.
BOARD_DESIGN_SETTINGS & GetDesignSettings()
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).
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.
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()
Keeps the documents drawn on a pair of diff canvases alive.
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)
int JobExportSpecctraDsn(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)
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 boards for a window outside the kiface, drawing the first on aBefore and the second on aAfte...
int JobExportStats(JOB *aJob)
WIDGET_DIFF_CANVAS * m_before
~PCB_DIFF_CANVAS_CONTEXT() override
PCB_DIFF_CANVAS_CONTEXT(WIDGET_DIFF_CANVAS *aBefore, WIDGET_DIFF_CANVAS *aAfter)
WIDGET_DIFF_CANVAS * m_after
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.
@ TARGET3001
TARGET 3001! project.
@ 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)
LSET GetLayerSelection() 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.
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static DRILL_PRECISION precisionListForInches(2, 4)
static DRILL_PRECISION precisionListForMetric(3, 3)
static bool empty(const wxTextEntryBase *aCtrl)
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 SpecctraDsnFileExtension
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_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
void ExportBoardToSpecctraFile(BOARD *aBoard, const wxString &aFullFilename, REPORTER *aReporter=nullptr)
Helper method to export board to DSN file.
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,...
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.
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.
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...
void ConfigurePcbDiffCanvasContext(WIDGET_DIFF_CANVAS &aCanvas, BOARD *aReference, BOARD *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)
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 int loadPcbDiffSides(SETTINGS_MANAGER &aMgr, REPORTER &aReporter, const wxString &aFileA, const wxString &aFileB, PCB_DIFF_SIDES &aSides)
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
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_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
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.
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,...
KICAD_DIFF::DOCUMENT_DIFF diff
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.