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>
150#include <api/board/board.pb.h>
151#include <google/protobuf/util/json_util.h>
176 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
182 wxCHECK( bomJob && editFrame,
false );
192 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
199 wxCHECK( svgJob && editFrame,
false );
205 [](
JOB* job, wxWindow* aParent ) ->
bool
209 wxCHECK( renderJob,
false );
215 [](
JOB* job, wxWindow* aParent ) ->
bool
220 [](
JOB* job, wxWindow* aParent ) ->
bool
225 [](
JOB* job, wxWindow* aParent ) ->
bool
230 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
237 wxCHECK( svgJob && editFrame,
false );
243 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
250 wxCHECK( gencadJob && editFrame,
false );
257 [](
JOB* job, wxWindow* aParent ) ->
bool
262 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
269 wxCHECK( dxfJob && editFrame,
false );
275 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
282 wxCHECK( pdfJob && editFrame,
false );
288 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
295 wxCHECK( pngJob && editFrame,
false );
301 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
308 wxCHECK( psJob && editFrame,
false );
314 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
321 wxCHECK( statsJob && editFrame,
false );
326 statsJob->
m_filename = boardName.GetFullPath();
329 wxWindow* parent = aParent ? aParent :
static_cast<wxWindow*
>( editFrame );
336 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
343 wxCHECK( stackupJob && editFrame,
false );
348 stackupJob->
m_filename = boardName.GetFullPath();
351 wxWindow* parent = aParent ? aParent :
static_cast<wxWindow*
>( editFrame );
358 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
365 wxCHECK( gJob && editFrame,
false );
371 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
378 wxCHECK( gJob && editFrame,
false );
387 m_reporter->Report(
_(
"Plotting to HPGL is no longer supported as of KiCad 10.0.\n" ),
391 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
395 wxCHECK( editFrame,
false );
397 DisplayErrorMessage( editFrame,
_(
"Plotting to HPGL is no longer supported as of KiCad 10.0." ) );
401 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
408 wxCHECK( drillJob && editFrame,
false );
414 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
421 wxCHECK( posJob && editFrame,
false );
427 [](
JOB* job, wxWindow* aParent ) ->
bool
432 [](
JOB* job, wxWindow* aParent ) ->
bool
437 [](
JOB* job, wxWindow* aParent ) ->
bool
442 [](
JOB* job, wxWindow* aParent ) ->
bool
447 [](
JOB* job, wxWindow* aParent ) ->
bool
452 [](
JOB* job, wxWindow* aParent ) ->
bool
456 wxCHECK( drcJob,
false );
462 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
469 wxCHECK( ipcJob && editFrame,
false );
475 [](
JOB* job, wxWindow* aParent ) ->
bool
480 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
487 wxCHECK( odbJob && editFrame,
false );
493 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
500 wxCHECK( idfJob && editFrame,
false );
548 BOARD* brd =
nullptr;
552 auto getProjectForBoard = [&](
const wxString& aBoardPath ) ->
PROJECT*
554 wxFileName pro = aBoardPath;
562 settingsManager.
LoadProject( pro.GetFullPath(),
true );
569 auto loadBoardFromPath = [&](
const wxString& aBoardPath ) ->
BOARD*
581 return loadedBoard.release();
585 loadError = ioe.
What();
594 if( !
Pgm().IsGUI() &&
Pgm().GetSettingsManager().IsProjectOpen() )
596 wxString pcbPath = aPath;
598 if( pcbPath.IsEmpty() )
603 pcbPath =
path.GetFullPath();
607 m_cliBoard.reset( loadBoardFromPath( pcbPath ) );
611 else if(
Pgm().IsGUI() &&
Pgm().GetSettingsManager().IsProjectOpen() )
620 m_cliBoard.reset( loadBoardFromPath( aPath ) );
626 wxString msg =
_(
"Failed to load board" );
628 if( !loadError.IsEmpty() )
629 msg += wxString::Format( wxS(
": %s" ), loadError );
640 std::map<wxString, LSET> layerUserMasks;
641 std::map<wxString, LSET> layerMasks;
642 std::map<wxString, LSET> layerGuiMasks;
676 auto pushLayers = [&](
const LSET& layerSet )
679 layerMask.push_back( layer );
682 if( !aLayerString.IsEmpty() )
684 wxStringTokenizer layerTokens( aLayerString,
"," );
686 while( layerTokens.HasMoreTokens() )
688 std::string token =
TO_UTF8( layerTokens.GetNextToken().Trim(
true ).Trim(
false ) );
690 if( layerUserMasks.contains( token ) )
691 pushLayers( layerUserMasks.at( token ) );
692 else if( layerMasks.count( token ) )
693 pushLayers( layerMasks.at( token ) );
694 else if( layerGuiMasks.count( token ) )
695 pushLayers( layerGuiMasks.at( token ) );
697 m_reporter->Report( wxString::Format(
_(
"Invalid layer name '%s'\n" ), token ) );
721 if( !currentVariant.IsEmpty() && currentVariant != wxS(
"all" ) )
727 bool hasWarned =
false;
732 if( !fp->IsAnnotated() && !hasWarned )
734 m_reporter->Report(
_(
"Warning: board has unannotated footprints, please use the PCB "
735 "editor to annotate them\n" ),
768 std::set<wxString> userFieldNames;
770 for(
size_t i = 0; i < referenceList.size(); ++i )
772 FOOTPRINT& footprint = referenceList[i].GetFootprint();
776 if( !field->IsMandatory() && !field->IsPrivate() )
777 userFieldNames.insert( field->GetName() );
781 for(
const wxString& fieldName : userFieldNames )
793 std::optional<BOM_PRESET> boardPreset;
795 for(
const BOM_PRESET& p : BOM_PRESET::BuiltInPresets() )
816 wxString::Format(
_(
"BOM preset '%s' not found" ) + wxS(
"\n" ), aBomJob->
m_bomPresetName ),
822 preset = *boardPreset;
830 auto normalizeFieldName = [&dataModel](
const wxString& aName ) -> wxString
832 if( aName.IsEmpty() )
833 return wxEmptyString;
838 wxString wrapped = wxS(
"${" ) + aName + wxS(
"}" );
850 wxString fieldName = normalizeFieldName( rawFieldName );
852 if( fieldName.IsEmpty() )
860 if( fieldName == wxS(
"*" ) )
866 field.
name = modelField.name;
871 bool fieldAlreadyPresent =
false;
873 for(
BOM_FIELD& presetField : preset.fieldsOrdered )
875 if( presetField.
name == field.
name )
877 fieldAlreadyPresent =
true;
882 bool fieldLaterInList =
false;
886 if( normalizeFieldName( fieldInList ) == field.
name )
888 fieldLaterInList =
true;
893 if( !fieldAlreadyPresent && !fieldLaterInList )
894 preset.fieldsOrdered.emplace_back( field );
902 field.
name = fieldName;
903 field.
show = !fieldName.StartsWith( wxT(
"__" ), &field.
name );
904 field.
name = normalizeFieldName( field.
name );
913 preset.fieldsOrdered.emplace_back( field );
919 wxString fieldName = rawFieldName;
920 fieldName.StartsWith( wxT(
"__" ), &fieldName );
921 fieldName = normalizeFieldName( fieldName );
923 if( fieldName.IsEmpty() )
926 bool fieldAlreadyPresent =
false;
928 for(
BOM_FIELD& field : preset.fieldsOrdered )
930 if( field.
name == fieldName )
933 fieldAlreadyPresent =
true;
938 if( !fieldAlreadyPresent )
943 preset.sortField = normalizeFieldName( aBomJob->
m_sortField );
955 std::optional<BOM_FMT_PRESET> boardFmtPreset;
975 if( !boardFmtPreset )
977 m_reporter->Report( wxString::Format(
_(
"BOM format preset '%s' not found" ) + wxS(
"\n" ),
984 fmt = *boardFmtPreset;
1000 fn.SetName( fn.GetName() );
1007 bool hasVariantPlaceholder = configuredPath.Contains( wxS(
"${VARIANT}" ) );
1010 std::vector<wxString> variantsToProcess;
1012 if( aBomJob->
m_variantNames.size() > 1 && hasVariantPlaceholder )
1018 variantsToProcess.push_back( currentVariant );
1021 for(
const wxString& variantName : variantsToProcess )
1023 std::vector<wxString> singleVariant = { variantName };
1031 if( hasVariantPlaceholder )
1051 if( !f.Open( outPath, wxFile::write ) )
1053 m_reporter->Report( wxString::Format(
_(
"Unable to open destination '%s'" ), outPath ),
1059 bool res = f.Write( dataModel.
Export( fmt ) );
1077 if( aStepJob ==
nullptr )
1091 fn.SetName( fn.GetName() );
1151 m_reporter->Report( wxString::Format(
_(
"Successfully exported VRML to %s" ), outPath ),
1183 if( !stepExporter.
Export() )
1195 if( aRenderJob ==
nullptr )
1230 fn.SetName( wxString::Format(
"%s-%d", fn.GetName(),
static_cast<int>( aRenderJob->
m_side ) ) );
1320 lightColor, lightColor, lightColor, lightColor, lightColor, lightColor, lightColor, lightColor,
1326 sideElevation, sideElevation, sideElevation, sideElevation,
1327 -sideElevation, -sideElevation, -sideElevation, -sideElevation,
1331 45, 135, 225, 315, 45, 135, 225, 315,
1336 boardAdapter.
m_Cfg = &cfg;
1352 if( preset->name.Lower() ==
_(
"legacy colors" ) )
1367 static std::map<JOB_PCB_RENDER::SIDE, VIEW3D_TYPE> s_viewCmdMap = {
1390 for(
bool first =
true; raytrace.
Redraw(
false ); first = false )
1417 uint8_t* rgbaBuffer = raytrace.
GetBuffer();
1419 bool success = !!rgbaBuffer;
1423 const unsigned int wxh = realSize.x * realSize.y;
1425 unsigned char* rgbBuffer = (
unsigned char*) malloc( wxh * 3 );
1426 unsigned char* alphaBuffer = (
unsigned char*) malloc( wxh );
1428 unsigned char* rgbaPtr = rgbaBuffer;
1429 unsigned char* rgbPtr = rgbBuffer;
1430 unsigned char* alphaPtr = alphaBuffer;
1432 for(
int y = 0; y < realSize.y; y++ )
1434 for(
int x = 0; x < realSize.x; x++ )
1436 rgbPtr[0] = rgbaPtr[0];
1437 rgbPtr[1] = rgbaPtr[1];
1438 rgbPtr[2] = rgbaPtr[2];
1439 alphaPtr[0] = rgbaPtr[3];
1447 wxImage
image( realSize );
1448 image.SetData( rgbBuffer );
1449 image.SetAlpha( alphaBuffer );
1452 image.SetOption( wxIMAGE_OPTION_QUALITY, 90 );
1454 : wxBITMAP_TYPE_JPEG );
1489 if( aLayersToPlot.empty() )
1515 const wxString& aOutPath,
bool aSingleOutput,
bool aUseVarOverrides,
1516 bool aForceAllLayersToOnePage =
false )
1518 std::optional<wxString> layerName;
1519 std::optional<wxString> sheetName;
1520 std::optional<wxString> sheetPath;
1522 if( aUseVarOverrides )
1534 bool useGerberFileExtensions =
false;
1535 std::vector<wxString> outputPaths;
1538 aSingleOutput, aForceAllLayersToOnePage, layerName, sheetName, sheetPath, &outputPaths ) )
1543 for(
const wxString& outputPath : outputPaths )
1554 if( aSvgJob ==
nullptr )
1567 const bool useVarOverrides = isSingle;
1587 return plotJob( aSvgJob, plotter, layersToPlot, outPath, isSingle, useVarOverrides );
1595 if( aDxfJob ==
nullptr )
1614 const bool useVarOverrides = isSingle;
1629 return plotJob( aDxfJob, plotter, layersToPlot, outPath, isSingle, useVarOverrides );
1637 if( pdfJob ==
nullptr )
1656 bool useVarOverrides = outputIsSingle;
1657 bool forceAllLayersToOnePage =
false;
1663 outputIsSingle =
true;
1664 useVarOverrides =
true;
1665 forceAllLayersToOnePage =
true;
1681 return plotJob( pdfJob, pcbPlotter, layersToPlot, outPath, outputIsSingle, useVarOverrides,
1682 forceAllLayersToOnePage );
1690 if( pngJob ==
nullptr )
1709 bool useVarOverrides = isSingle;
1724 return plotJob( pngJob, pcbPlotter, layersToPlot, outPath, isSingle, useVarOverrides );
1732 if( psJob ==
nullptr )
1751 bool useVarOverrides = isSingle;
1766 return plotJob( psJob, pcbPlotter, layersToPlot, outPath, isSingle, useVarOverrides );
1775 if( aGerberJob ==
nullptr )
1804 bool hasLayerListSpecified =
false;
1811 hasLayerListSpecified =
true;
1860 plotSequence.push_back( layer );
1866 if(
find( plotSequence.begin(), plotSequence.end(), layer_all ) != plotSequence.end() )
1869 plotSequence.push_back( layer_all );
1880 plotOpts = boardPlotOptions;
1890 wxString fullname = fn.GetFullName();
1898 jobfile_writer.
AddGbrFile( layer, fullname );
1924 m_reporter->Report( wxString::Format(
_(
"Failed to plot to '%s'.\n" ), fn.GetFullPath() ),
1950 if( aGencadJob ==
nullptr )
1974 fn.SetName( fn.GetName() );
2036 m_reporter->Report( wxString::Format(
_(
"Export failed: %s\n" ), ioe.
What() ),
2052 if( statsJob ==
nullptr )
2070 wxString projectName;
2077 if( boardFile.GetName().IsEmpty() )
2078 boardFile = wxFileName( statsJob->
m_filename );
2101 FILE* outFile = wxFopen( outPath, wxS(
"wt" ) );
2109 if( fprintf( outFile,
"%s",
TO_UTF8( report ) ) < 0 )
2130 if( stackupJob ==
nullptr )
2140 if( boardFile.GetName().IsEmpty() )
2141 boardFile = wxFileName( stackupJob->
m_filename );
2149 kiapi::board::BoardStackup stackupMsg;
2152 google::protobuf::util::JsonPrintOptions jsonOptions;
2153 jsonOptions.add_whitespace =
true;
2157 if( !google::protobuf::util::MessageToJsonString( stackupMsg, &
json, jsonOptions ).ok() )
2163 output = wxString::FromUTF8(
json );
2176 item->SetLayerName( brd->
GetLayerName( item->GetBrdLayerId() ) );
2217 const bool writeOk =
static_cast<bool>( outFile );
2239 if( aGerberJob ==
nullptr )
2267 fn.SetName( fn.GetName() );
2316 PLOTTER* plotter =
StartPlotBoard( brd, &plotOpts, layer, layerName, outPath, sheetName, sheetPath );
2317 bool success =
false;
2344 if( aDrillJob ==
nullptr )
2360 std::unique_ptr<GENDRILL_WRITER_BASE> drillWriter;
2363 drillWriter = std::make_unique<EXCELLON_WRITER>( brd );
2365 drillWriter = std::make_unique<GERBER_WRITER>( brd );
2392 wxFileName fn = wxFileName::DirName( outPath );
2394 fn.SetName( fn.GetName() +
"-drill" );
2397 reportPathSetting = fn.GetFullPath();
2425 if( excellonWriter ==
nullptr )
2440 for(
const wxString& outputFile : drillWriter->GetCreatedFiles() )
2459 if( gerberWriter ==
nullptr )
2475 for(
const wxString& outputFile : drillWriter->GetCreatedFiles() )
2499 if( aPosJob ==
nullptr )
2510 fn.SetName( fn.GetName() );
2532 wxFileName fn( outPath );
2533 wxString baseName = fn.GetName();
2535 auto exportPlaceFile = [&](
bool frontSide,
bool backSide,
const wxString& curr_outPath ) ->
bool
2537 FILE* file = wxFopen( curr_outPath, wxS(
"wt" ) );
2538 wxCHECK( file,
false );
2550 fputs( data.c_str(), file );
2563 if( exportPlaceFile(
true,
false, fn.GetFullPath() ) )
2565 m_reporter->Report( wxString::Format(
_(
"Wrote front position data to '%s'.\n" ), fn.GetFullPath() ),
2580 if( exportPlaceFile(
false,
true, fn.GetFullPath() ) )
2582 m_reporter->Report( wxString::Format(
_(
"Wrote back position data to '%s'.\n" ), fn.GetFullPath() ),
2608 if( exportPlaceFile( front, back, fn.GetFullPath() ) )
2610 m_reporter->Report( wxString::Format(
_(
"Wrote position data to '%s'.\n" ), fn.GetFullPath() ),
2629 wxString outPath_base = outPath;
2640 m_reporter->Report( wxString::Format(
_(
"Wrote front position data to '%s'.\n" ), outPath ),
2655 outPath = outPath_base;
2664 m_reporter->Report( wxString::Format(
_(
"Wrote back position data to '%s'.\n" ), outPath ),
2684 if( upgradeJob ==
nullptr )
2699 m_reporter->Report(
_(
"Output path must be specified to convert legacy and non-KiCad libraries\n" ),
2709 m_reporter->Report(
_(
"Footprint library path does not exist or is not accessible\n" ),
2730 bool shouldSave = upgradeJob->
m_force;
2776 if( svgJob ==
nullptr )
2809 bool singleFpPlotted =
false;
2811 for(
const auto& [fpName, fpCacheEntry] : fpLib.
GetFootprints() )
2825 singleFpPlotted =
true;
2828 exitCode =
doFpExportSvg( svgJob, fpCacheEntry->GetFootprint().get() );
2834 if( !svgJob->
m_footprint.IsEmpty() && !singleFpPlotted )
2836 m_reporter->Report(
_(
"The given footprint could not be found to export." ) + wxS(
"\n" ),
2846 wxFileName outputFile;
2851 m_reporter->Report( wxString::Format(
_(
"Plotting footprint '%s' to '%s'\n" ),
2866 aSvgJob->
AddOutput( outputFile.GetFullPath() );
2876 if( drcJob ==
nullptr )
2892 fn.SetName( fn.GetName() + wxS(
"-drc" ) );
2921 std::unique_ptr<NETLIST>
netlist = std::make_unique<NETLIST>();
2923 if( !drcEngine->RulesValid() )
2931 m_reporter->Report(
_(
"DRC incomplete: could not compile custom design rules." )
2932 + wxS(
"\n" ) + error.
What() + wxS(
"\n" ),
2945 std::string netlist_str;
2949 wxString annotateMsg =
_(
"Schematic parity tests require a fully annotated schematic." );
2950 netlist_str = annotateMsg;
2962 wxFileName schematicPath( drcJob->
m_filename );
2963 schematicPath.MakeAbsolute();
2966 if( !schematicPath.Exists() )
2969 if( !schematicPath.Exists() )
2980 ( *netlister )( schematicPath.GetFullPath(), netlist_str,
m_kiway );
2988 else if( netlist_str == annotateMsg )
3010 drcEngine->SetSchematicNetlist(
netlist.get() );
3022 drcEngine->SetViolationHandler(
3023 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
3024 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
3027 aPathGenerator( marker );
3028 commit.
Add( marker );
3034 drcEngine->ClearViolationHandler();
3041 std::shared_ptr<DRC_ITEMS_PROVIDER> markersProvider =
3044 std::shared_ptr<DRC_ITEMS_PROVIDER> ratsnestProvider =
3047 std::shared_ptr<DRC_ITEMS_PROVIDER> fpWarningsProvider =
3050 markersProvider->SetSeverities( drcJob->
m_severity );
3051 ratsnestProvider->SetSeverities( drcJob->
m_severity );
3052 fpWarningsProvider->SetSeverities( drcJob->
m_severity );
3054 m_reporter->Report( wxString::Format(
_(
"Found %d violations\n" ), markersProvider->GetCount() ),
3056 m_reporter->Report( wxString::Format(
_(
"Found %d unconnected items\n" ), ratsnestProvider->GetCount() ),
3062 wxString::Format(
_(
"Found %d schematic parity issues\n" ), fpWarningsProvider->GetCount() ),
3066 DRC_REPORT reportWriter( brd, units, markersProvider, ratsnestProvider, fpWarningsProvider );
3068 bool wroteReport =
false;
3101 if( markersProvider->GetCount() > 0 || ratsnestProvider->GetCount() > 0 || fpWarningsProvider->GetCount() > 0 )
3133 if( job ==
nullptr )
3141 struct VARIANT_RESTORE
3181 if( job ==
nullptr )
3192 fn.SetName( fn.GetName() );
3208 bool success = exporter.
Write( outPath );
3228 if( job ==
nullptr )
3262 if( !exporter.
Export( outPath ) )
3275 if( job ==
nullptr )
3293 fn.SetName( fn.GetName() + wxS(
"-odb" ) );
3318 for(
const wxString&
path :
result.m_outputs )
3332 if( job ==
nullptr )
3335 bool shouldSave = job->
m_force;
3366 wxString::Format(
_(
"Error saving board file '%s'.\n%s" ), job->
m_filename, ioe.
What().GetData() );
3379 wxArrayString files;
3380 wxDir::GetAllFiles( aDir, &files, wxT(
"*.kicad_mod" ) );
3382 for(
const wxString& file : files )
3391 std::unique_ptr<FOOTPRINT> fp = loader.
ImportFootprint( file, nameOut );
3397 scratch.
Add( fp.release() );
3412 bool aDropInsteadOfApproximate,
3414 wxString* aRecoveryError =
nullptr )
3423 [&](
const wxString& aText )
3425 return FindUnsupportedBoardToken( aText, aTarget );
3427 convert, aTransaction, aRecoveryError );
3433 return wxString::Format(
_(
"Cannot export: footprint '%s' uses a feature %s cannot open.\n" ), aFile,
3442 if( job ==
nullptr )
3448 if( target ==
nullptr )
3450 m_reporter->Report( wxString::Format(
_(
"Unknown target version '%s'. Valid targets: %s\n" ), job->
m_target,
3465 m_reporter->Report(
_(
"The target supports variants, so there is nothing to flatten.\n" ),
3471 wxString libraryCopy;
3483 if( !job->
m_outputFile.IsEmpty() && output.MakeAbsolute() )
3517 const std::vector<wxString>& names = brd->GetVariantNames();
3524 m_reporter->Report(
_(
"The board has no variant data. The base board is exported.\n" ),
3527 else if( std::find( names.begin(), names.end(), job->
m_variant ) == names.end() )
3530 wxString::Format(
_(
"The board has no variant named '%s'.\n" ), job->
m_variant ),
3556 m_reporter->Report(
_(
"Cannot export: the board uses features the target cannot represent.\n" ),
3563 m_reporter->Report(
_(
"Export would lose data. Re-run with --force to export anyway.\n" ),
3574 output.MakeAbsolute();
3576 if( !outputDirectories.
Create( output.GetPath() ) )
3582 if( !libraryDir.IsEmpty() )
3590 libraryDir = libraryCopy;
3597 if( stagedBoard.IsEmpty() )
3609 if( !badToken.IsEmpty() )
3610 m_reporter->Report( wxString::Format(
_(
"Cannot export: the result still uses '%s', which %s "
3611 "cannot open. This feature has no downgrade rule yet.\n" ),
3612 badToken, target->
m_name ),
3625 if( !badLib.IsEmpty() )
3632 wxString failedDestination = transaction.
Commit();
3634 if( !failedDestination.IsEmpty() )
3636 m_reporter->Report( wxString::Format(
_(
"Could not replace '%s'.\n" ), failedDestination ),
3645 outputDirectories.
Commit();
3674 m_reporter->Report(
_(
"Cannot export: the libraries use features the target cannot represent.\n" ),
3681 m_reporter->Report(
_(
"Export would lose data. Re-run with --force to export anyway.\n" ),
3686 wxString recoveryError;
3688 nullptr, &recoveryError );
3690 if( !badLib.IsEmpty() )
3694 if( !recoveryError.IsEmpty() )
3707 m_reporter->Report( wxString::Format(
_(
"Error exporting '%s'.\n%s" ), where, ioe.
What().GetData() ),
3727 m_reporter->Report( wxString::Format(
_(
"Unknown target version '%s'. Valid targets: %s\n" ), job->
m_target,
3750 m_reporter->Report(
_(
"Cannot export: the library uses features the target cannot represent.\n" ),
3757 m_reporter->Report(
_(
"Export would lose data. Re-run with --force to export anyway.\n" ),
3774 wxString recoveryError;
3778 if( !badLib.IsEmpty() )
3782 if( !recoveryError.IsEmpty() )
3791 wxString::Format(
_(
"Error exporting '%s'.\n%s" ), job->
m_libraryPath, ioe.
What().GetData() ),
3796 outputDirectories.
Commit();
3809 if( aDrawingSheet && !aDrawingSheet->IsEmpty() )
3839 return drawingSheet;
3846 if( aSheetPath.IsEmpty() )
3849 auto loadSheet = [&](
const wxString&
path ) ->
bool
3862 m_reporter->Report( wxString::Format(
_(
"Error loading drawing sheet '%s'." ),
path ) + wxS(
"\n" ) + msg
3871 if( loadSheet( aSheetPath ) )
3941 m_reporter->Report( wxString::Format(
_(
"No PCB importer recognizes the file format of '%s'\n" ),
3953 m_reporter->Report( wxString::Format(
_(
"No plugin found for file type '%s'\n" ),
3965 m_reporter->Report( wxString::Format(
_(
"Failed to inspect board project: %s\n" ), ioe.
What() ),
3977 if( outputPath.IsEmpty() )
3985 PROJECT* projectPtr =
nullptr;
3986 bool createdTransientProject =
false;
3990 projectPtr = &mgr.
Prj();
3994 wxFileName projectFn( outputPath );
3998 projectFn.MakeAbsolute();
4001 projectPtr = mgr.
GetProject( projectFn.GetFullPath() );
4002 createdTransientProject = ( projectPtr != nullptr );
4023 } transientProjectGuard{ mgr, projectPtr, createdTransientProject };
4025 std::unique_ptr<BOARD> board;
4027 struct BOARD_PROJECT_GUARD
4029 std::unique_ptr<BOARD>& board;
4031 ~BOARD_PROJECT_GUARD()
4034 board->ClearProject();
4036 } boardProjectGuard{ board };
4039 std::vector<wxString> warnings;
4043 struct CAPTURED_LAYER
4050 std::vector<CAPTURED_LAYER> capturedLayers;
4051 std::set<wxString> seenSourceLayers;
4052 bool layersCaptured =
false;
4062 m_reporter->Report( wxString::Format(
_(
"No plugin found for file type '%s'\n" ), formatName ),
4068 pi->SetReporter( &importMessages );
4077 mappable->RegisterCallback(
4078 [&](
const std::vector<INPUT_LAYER_DESC>& aDescs )
4079 -> std::map<wxString, PCB_LAYER_ID>
4081 std::map<wxString, PCB_LAYER_ID>
result;
4086 wxString method = wxS(
"auto" );
4088 if(
auto it = job->
m_layerMap.find( desc.Name );
4095 warnings.push_back( wxString::Format(
4096 _(
"Layer map entry '%s' -> '%s' names an unknown "
4097 "KiCad layer; using automatic mapping instead" ),
4098 desc.Name, it->second ) );
4100 else if( !desc.PermittedLayers.Contains( resolved ) )
4102 warnings.push_back( wxString::Format(
4103 _(
"Layer map entry '%s' -> '%s' is not a permitted "
4104 "target for this layer; using automatic mapping "
4106 desc.Name, it->second ) );
4111 method = wxS(
"explicit" );
4117 warnings.push_back( wxString::Format(
4118 _(
"No KiCad layer mapping for required source layer "
4119 "'%s'; its items will not be imported" ),
4123 result.emplace( desc.Name, target );
4124 capturedLayers.push_back( { desc.Name, target, method } );
4125 seenSourceLayers.insert( desc.Name );
4128 layersCaptured =
true;
4135 warnings.push_back(
_(
"A layer map was provided, but this importer does not support "
4136 "layer remapping; it will be ignored" ) );
4139 m_reporter->Report( wxString::Format(
_(
"Importing '%s' using %s format...\n" ),
4149 const std::map<std::string, UTF8>* importProperties =
nullptr;
4150 std::map<std::string, UTF8> importPropertyStorage;
4156 importPropertyStorage.emplace(
"pcb_id", std::string( job->
m_importPcbId.ToUTF8() ) );
4157 importProperties = &importPropertyStorage;
4165 importPropertyStorage[
"page_width"] = std::to_string( pageSize.
x );
4166 importPropertyStorage[
"page_height"] = std::to_string( pageSize.
y );
4167 importProperties = &importPropertyStorage;
4171 board = pi->LoadBoard( job->
m_inputFile, importProperties, projectPtr );
4178 m_reporter->Report( wxString::Format(
_(
"Unexpected cancellation: %s\n" ), ioce.
What() ),
4204 if( layersCaptured )
4208 if( !seenSourceLayers.contains(
source ) )
4210 warnings.push_back( wxString::Format(
_(
"Layer map entry '%s' does not match any source layer "
4211 "in the imported file; it will be ignored" ),
4220 kicadPlugin->SaveBoard( outputPath, *board );
4221 wxString importedRules = pi->GetImportedDesignRules();
4223 if( !importedRules.IsEmpty() )
4225 wxFileName rulesPath( outputPath );
4228 wxFile rulesFile( rulesPath.GetFullPath(), wxFile::write );
4230 if( rulesFile.IsOpened() )
4232 rulesFile.Write( importedRules );
4236 m_reporter->Report( wxString::Format(
_(
"Could not write imported design rules to '%s'\n" ),
4237 rulesPath.GetFullPath() ),
4242 m_reporter->Report( wxString::Format(
_(
"Successfully saved imported board to '%s'\n" ), outputPath ),
4246 IMPORT_REPORT_DATA reportData;
4251 reportData.m_sourceFile = wxFileName( job->
m_inputFile ).GetFullName();
4252 reportData.m_sourceFormat = formatName;
4253 reportData.m_outputFile = wxFileName( outputPath ).GetFullName();
4255 size_t trackCount = 0;
4256 size_t viaCount = 0;
4258 for(
PCB_TRACK* track : board->Tracks() )
4266 reportData.m_statistics = {
4267 { wxS(
"footprints" ), board->Footprints().size() },
4268 { wxS(
"tracks" ), trackCount },
4269 { wxS(
"vias" ), viaCount },
4270 { wxS(
"zones" ), board->Zones().size() }
4276 nlohmann::json layerMappings = nlohmann::json::object();
4278 if( layersCaptured )
4280 for(
const CAPTURED_LAYER& mapped : capturedLayers )
4284 :
LSET::Name( mapped.m_target ).ToStdString();
4286 layerMappings[mapped.m_source.ToStdString()] = {
4287 {
"kicad_layer", kicadLayer },
4288 {
"method", mapped.m_method.ToStdString() }
4294 for(
PCB_LAYER_ID layer : board->GetEnabledLayers().Seq() )
4296 wxString layerName = board->GetLayerName( layer );
4298 layerMappings[layerName.ToStdString()] = {
4299 {
"kicad_layer",
LSET::Name( layer ).ToStdString() },
4300 {
"method",
"auto" }
4305 reportData.m_extraJson[
"layer_mapping"] = layerMappings;
4306 reportData.m_warnings.insert( reportData.m_warnings.end(), warnings.begin(), warnings.end() );
4314 for(
const wxString& warning : warnings )
4345 bool aInitializeAfterLoad =
true )
4349 [aPath, aInitializeAfterLoad](
PROJECT* aProject ) -> std::unique_ptr<BOARD>
4372 aBoard->ClearProject();
4393 BOARD* boardA = aScratch.
doc.get();
4394 BOARD* boardB = bScratch.
doc.get();
4414 return diffExitCode;
4443 const wxString& aOurs,
const wxString& aTheirs,
4444 const wxString& aOutput,
bool aInteractive,
bool aSingleFile,
4453 return runFpLibMerge( aAncestor, aOurs, aTheirs, aOutput, aInteractive, aSingleFile );
4455 return runPcbMerge( aAncestor, aOurs, aTheirs, aOutput, aInteractive );
4460 const wxString& aTheirs,
const wxString& aOutput,
4477 BOARD* ancestor = ancestorScratch.
doc.get();
4478 BOARD* ours = oursScratch.
doc.get();
4479 BOARD* theirs = theirsScratch.
doc.get();
4481 if( !ancestor || !ours || !theirs )
4487 const wxString formatNotice =
4491 if( !formatNotice.IsEmpty() )
4525 return wxEmptyString;
4529 for(
BOARD* board : { ours, theirs, ancestor } )
4534 if(
BOARD_ITEM* item = board->ResolveItem( aId.back(),
true ) )
4535 return item->GetItemDescription( &units,
false );
4538 return wxEmptyString;
4543 const std::optional<KIID_PATH>& )
4545 BOARD* board =
nullptr;
4578 std::unique_ptr<BOARD> merged = applier.
Apply();
4595 m_reporter->Report( wxString::Format(
_(
"Failed to save merged board: %s\n" ), ioe.
What() ),
4628 wxFileName proFn( aOutput );
4651 std::set<wxString> touched;
4669 wxString::Format(
_(
"Failed to save merged project file: %s\n" ), proFn.GetFullPath() ),
4678 auto writeStagedFile = [&](
const wxString& aPath,
const wxString& aContent,
const wxString& aLabel ) ->
bool
4680 if( aContent.IsEmpty() )
4682 if( wxFileExists( aPath ) )
4683 wxRemoveFile( aPath );
4690 if( !out.Open( aPath, wxFile::write ) || !out.Write( aContent ) )
4692 m_reporter->Report( wxString::Format(
_(
"Failed to save merged %s: %s\n" ), aLabel, aPath ),
4704 wxFileName druFn( aOutput );
4717 wxFileName fpFn( aOutput );
4720 if( !writeStagedFile( fpFn.GetFullPath(), applier.
GetReport().
fpLibTable,
_(
"footprint library table" ) ) )
4728 wxFileName symFn( aOutput );
4731 if( !writeStagedFile( symFn.GetFullPath(), applier.
GetReport().
symLibTable,
_(
"symbol library table" ) ) )
4742 m_reporter->Report( wxString::Format( wxS(
"%s: %s\n" ), f.validator, f.message ), f.severity );
4749 m_reporter->Report( wxString::Format(
_(
"Merge completed with %zu unresolved conflict(s) in %s\n" ),
4770 std::vector<std::unique_ptr<FOOTPRINT>>& aOwners,
4774 if( aAllowEmpty && aPath.IsEmpty() )
4780 aOwners = std::move( loaded.first );
4781 aMap = std::move( loaded.second );
4786 aReporter.
Report( wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, ioe.
What() ),
4789 catch(
const std::exception& e )
4792 wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, wxString::FromUTF8( e.what() ) ),
4807 wxFileName dirA( diffJob->
m_inputA );
4808 dirA.MakeAbsolute();
4809 wxFileName dirB( diffJob->
m_inputB );
4810 dirB.MakeAbsolute();
4812 std::vector<std::unique_ptr<FOOTPRINT>> ownersA;
4813 std::vector<std::unique_ptr<FOOTPRINT>> ownersB;
4835 return diffExitCode;
4879 if( !aSides.
a.
doc && !aFileA.IsEmpty() )
4885 if( !aSides.
b.
doc && !aFileB.IsEmpty() )
4916 m_after->SetContextItems( {} );
4937 auto context = std::make_unique<PCB_DIFF_CANVAS_CONTEXT>( aBefore, aAfter );
4951 aDiff = context->m_sides.diff;
4952 return context.release();
4957 const wxString& aFileB,
const wxString& aLabelA,
4958 const wxString& aLabelB, wxWindow* aParent,
4966 wxWindow* parent = aParent ? aParent : ( wxTheApp ? wxTheApp->GetTopWindow() :
nullptr );
4970 const wxString labelA = aLabelA.IsEmpty() ? aFileA : aLabelA;
4971 const wxString labelB = aLabelB.IsEmpty() ? aFileB : aLabelB;
4973 std::vector<std::unique_ptr<FOOTPRINT>> ownersA;
4974 std::vector<std::unique_ptr<FOOTPRINT>> ownersB;
4999 KICAD_DIFF::ConfigurePcbDiffCanvasContext( aCanvas, boardA, boardB, color );
5023 const wxString nameA = wxFileName( aFileA ).GetName();
5024 const wxString nameB = wxFileName( aFileB ).GetName();
5025 const wxString itemName = !nameB.IsEmpty() ? nameB : nameA;
5027 auto loadSide = [&](
const wxString& aPath, std::vector<std::unique_ptr<FOOTPRINT>>& aOwners,
5030 if( aPath.IsEmpty() )
5033 wxFileName fn( aPath );
5044 aMap[itemName] = footprint.get();
5045 aOwners.push_back( std::move( footprint ) );
5052 m_reporter->Report( wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, ioe.
What() ),
5058 if( !loadSide( aFileA, ownersA, mapA ) || !loadSide( aFileB, ownersB, mapB ) )
5097 const wxString& aTheirs,
const wxString& aOutput,
5098 bool aInteractive,
bool aSingleFile )
5100 if( aOutput.IsEmpty() )
5108 std::vector<std::unique_ptr<FOOTPRINT>> owners;
5112 LIB_SIDE ancestor, ours, theirs;
5119 auto isSingleFile = [&](
const wxString& aPath )
5127 auto loadSide = [&](
const wxString& aPath, LIB_SIDE& aSide ) ->
int
5131 if( isSingleFile( aPath ) )
5143 const UTF8& itemName = fp->GetFPID().GetLibItemName();
5146 aSide.map[key] = fp.get();
5147 aSide.owners.push_back( std::move( fp ) );
5152 aSide.owners = std::move( loaded.first );
5153 aSide.map = std::move( loaded.second );
5158 m_reporter->Report( wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, ioe.
What() ),
5161 catch(
const std::exception& e )
5164 wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, wxString::FromUTF8( e.what() ) ),
5203 std::set<wxString> names;
5207 for(
const auto& [
name, footprint] : *side )
5208 names.insert(
name );
5221 side = &ancestor.map;
5229 if( dlg.ShowModal() != wxID_APPLY )
5232 plan = dlg.GetResolvedPlan();
5238 std::vector<std::unique_ptr<FOOTPRINT>> merged = applier.
Apply();
5243 const bool hadSilentFallback = applier.
GetReport().mergePropsFallback > 0;
5245 const bool singleFileOutput = isSingleFile( aOutput );
5254 if( singleFileOutput )
5255 outFn = wxFileName( aOutput );
5257 outFn = wxFileName::DirName( aOutput );
5259 outFn.MakeAbsolute();
5265 const wxString outDir = outFn.GetPath();
5267 if( !wxFileName::DirExists( outDir ) && !wxFileName::Mkdir( outDir, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
5269 m_reporter->Report( wxString::Format(
_(
"Cannot create output directory %s\n" ), outDir ),
5278 if( singleFileOutput )
5284 if( merged.size() > 1 )
5286 m_reporter->Report(
_(
"Single-file fp merge produced multiple footprints; refusing to "
5287 "collapse into one .kicad_mod\n" ),
5292 if( merged.empty() )
5297 if( wxFileName::FileExists( outFn.GetFullPath() ) )
5298 wxRemoveFile( outFn.GetFullPath() );
5304 io.
FootprintSave( outFn.GetFullPath(), merged.front().get(),
nullptr );
5315 io.
Format( merged.front().get() );
5327 std::set<wxString> mergedNames;
5329 for(
const auto& fp : merged )
5332 mergedNames.insert( fp->GetFPID().GetLibItemName() );
5335 wxArrayString existing;
5338 for(
const wxString&
name : existing )
5340 if( !mergedNames.count(
name ) )
5344 for(
const auto& fp : merged )
5349 const wxString
name = fp->GetFPID().GetLibItemName();
5360 m_reporter->Report( wxString::Format(
_(
"Failed to save merged footprint library: %s\n" ), ioe.
What() ),
5366 if( !planSnapshot.
Resolved() || hadSilentFallback )
5370 std::set<KIID_PATH> conflicts( planSnapshot.
unresolved.begin(), planSnapshot.
unresolved.end() );
5373 conflicts.insert(
id );
5375 m_reporter->Report( wxString::Format(
_(
"Footprint library merge completed with %zu unresolved "
5376 "conflict(s) in %s\n" ),
5377 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
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).
void DrawChosenLibraryItem(LIBRARY_ITEM_DRAWER aDraw)
Draw only the library item named by the chosen change, since the outlines of a whole library pile up ...
Resolve a three-way merge by choosing a version for each conflicting item.
const KICAD_DIFF::MERGE_PLAN & GetResolvedPlan() const
Returns the plan with the user's resolutions applied.
static CONFLICT_CONTEXT LibraryContext(const std::set< wxString > &aNames, LIBRARY_ITEM_DRAWER aDraw)
Context for merging a library, whose items are known by the names in aNames.
static bool CanOpen(REPORTER &aReporter)
Report to aReporter and return false when this process cannot open a dialog.
SIDE
Which side's version the canvas should currently display.
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 ResolvePlotLayers(const LSET &aEnabledLayers) const
Return the layers to plot on a board with aEnabledLayers.
LSEQ m_plotOnAllLayersSequence
Layers to include on all individual layer prints.
bool m_checkZonesBeforePlot
std::optional< wxString > m_argLayers
std::optional< wxString > m_argCommonLayers
bool m_plotAllCopperLayers
Plot every copper layer of the board in addition to m_plotLayerSequence.
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
Where to write the converted copy.
bool m_dropInsteadOfApproximate
Omit features that would otherwise be approximated.
wxString m_target
Target release name or id, e.g. "KiCad 9.0". Empty means the newest.
bool m_force
Convert even when features must be dropped or approximated.
COMPATIBILITY_REPORT m_report
Filled by the handler so the caller can show it.
bool m_dryRun
Only classify and fill m_report, do not write anything.
wxString m_libraryPath
The .pretty footprint library to convert.
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.
Describe the page size and margins of a paper page on which to eventually print or plot.
const VECTOR2D GetSizeIU(double aIUScale) const
Gets the page size in internal units.
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)
int runFpLibMerge(const wxString &aAncestor, const wxString &aOurs, const wxString &aTheirs, const wxString &aOutput, bool aInteractive, bool aSingleFile)
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)
bool preparePlotLayers(JOB_EXPORT_PCB_PLOT *aJob, BOARD *aBoard, TOOL_MANAGER *aToolManager, LSEQ &aLayersToPlot)
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 JobFpDowngrade(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()
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...
bool Plot(const wxString &aOutputPath, const LSEQ &aLayersToPlot, const LSEQ &aCommonLayers, bool aUseGerberFileExtensions, bool aPlotAllLayersToSingleFile, bool aForceAllLayersToSinglePage, 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 PlotJobToPlotOpts(PCB_PLOT_PARAMS &aOpts, JOB_EXPORT_PCB_PLOT *aJob, REPORTER &aReporter)
Translate a JOB to PCB_PLOT_PARAMS.
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.
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.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true, bool aOverrideLock=false)
Load a project or sets up a new project with a specified path.
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
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...
Service::Type GetKifaceService(KIFACE *aKiface)
Look up a service exported by a KIFACE.
#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.
void SettleLibraryMerges(MERGE_PLAN &aPlan, const std::function< bool(const KIID_PATH &)> &aCanCombine, const std::function< std::set< wxString >(const KIID_PATH &)> &aEditedNames)
Settle the MERGE_PROPS of a library merge, where an item is combined whole or not at all.
std::vector< CONFLICT_LIST_ENTRY > BuildConflictList(const MERGE_PLAN &aPlan)
void CollectChangeBBoxes(const DOCUMENT_DIFF &aDiff, std::map< KIID_PATH, BOX2I > &aOut)
Walk a DOCUMENT_DIFF and populate a (KIID_PATH → BOX2I) map with each changed item's bbox,...
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.
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...
std::function< std::set< wxString >(const KIID_PATH &)> EditedNamesIn(const DOCUMENT_DIFF &aOurs, const DOCUMENT_DIFF &aTheirs)
What either side edits in an item, for SettleLibraryMerges. Both diffs must outlive the result.
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 ShowFootprintPair(WIDGET_DIFF_CANVAS &aCanvas, const FP_LIB_DIFFER::FOOTPRINT_MAP &aBefore, const FP_LIB_DIFFER::FOOTPRINT_MAP &aAfter, const wxString &aName)
Draw the footprint aName as it is in aBefore and aAfter.
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_FOOTPRINT_LIB_FILE_VERSION
#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 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 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)
static int plotJob(JOB_EXPORT_PCB_PLOT *aJob, PCB_PLOTTER &aPlotter, const LSEQ &aLayersToPlot, const wxString &aOutPath, bool aSingleOutput, bool aUseVarOverrides, bool aForceAllLayersToOnePage=false)
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)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
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.
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
bool(*)(const wxString &, std::string &, KIWAY *) Type
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.