24#include <wx/zipstrm.h>
25#include <wx/filename.h>
26#include <wx/tokenzr.h>
27#include <wx/wfstream.h>
29#include <nlohmann/json.hpp>
146 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
153 wxCHECK( svgJob && editFrame,
false );
159 [](
JOB* job, wxWindow* aParent ) ->
bool
163 wxCHECK( renderJob,
false );
169 [](
JOB* job, wxWindow* aParent ) ->
bool
174 [](
JOB* job, wxWindow* aParent ) ->
bool
179 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
186 wxCHECK( svgJob && editFrame,
false );
192 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
199 wxCHECK( gencadJob && editFrame,
false );
205 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
212 wxCHECK( dxfJob && editFrame,
false );
218 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
225 wxCHECK( pdfJob && editFrame,
false );
231 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
238 wxCHECK( pngJob && editFrame,
false );
244 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
251 wxCHECK( psJob && editFrame,
false );
257 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
264 wxCHECK( statsJob && editFrame,
false );
269 statsJob->
m_filename = boardName.GetFullPath();
272 wxWindow* parent = aParent ? aParent :
static_cast<wxWindow*
>( editFrame );
279 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
286 wxCHECK( gJob && editFrame,
false );
292 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
299 wxCHECK( gJob && editFrame,
false );
308 m_reporter->Report(
_(
"Plotting to HPGL is no longer supported as of KiCad 10.0.\n" ),
312 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
316 wxCHECK( editFrame,
false );
318 DisplayErrorMessage( editFrame,
_(
"Plotting to HPGL is no longer supported as of KiCad 10.0." ) );
322 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
329 wxCHECK( drillJob && editFrame,
false );
335 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
342 wxCHECK( posJob && editFrame,
false );
348 [](
JOB* job, wxWindow* aParent ) ->
bool
353 [](
JOB* job, wxWindow* aParent ) ->
bool
358 [](
JOB* job, wxWindow* aParent ) ->
bool
363 [](
JOB* job, wxWindow* aParent ) ->
bool
368 [](
JOB* job, wxWindow* aParent ) ->
bool
372 wxCHECK( drcJob,
false );
378 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
385 wxCHECK( ipcJob && editFrame,
false );
391 [](
JOB* job, wxWindow* aParent ) ->
bool
396 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
403 wxCHECK( odbJob && editFrame,
false );
451 BOARD* brd =
nullptr;
455 auto getProjectForBoard = [&](
const wxString& aBoardPath ) ->
PROJECT*
457 wxFileName pro = aBoardPath;
465 settingsManager.
LoadProject( pro.GetFullPath(),
true );
472 auto loadBoardFromPath = [&](
const wxString& aBoardPath ) ->
BOARD*
484 return loadedBoard.release();
488 loadError = ioe.
What();
497 if( !
Pgm().IsGUI() &&
Pgm().GetSettingsManager().IsProjectOpen() )
499 wxString pcbPath = aPath;
501 if( pcbPath.IsEmpty() )
506 pcbPath =
path.GetFullPath();
510 m_cliBoard.reset( loadBoardFromPath( pcbPath ) );
514 else if(
Pgm().IsGUI() &&
Pgm().GetSettingsManager().IsProjectOpen() )
523 m_cliBoard.reset( loadBoardFromPath( aPath ) );
529 wxString msg =
_(
"Failed to load board" );
531 if( !loadError.IsEmpty() )
532 msg += wxString::Format( wxS(
": %s" ), loadError );
543 std::map<wxString, LSET> layerUserMasks;
544 std::map<wxString, LSET> layerMasks;
545 std::map<wxString, LSET> layerGuiMasks;
579 auto pushLayers = [&](
const LSET& layerSet )
582 layerMask.push_back( layer );
585 if( !aLayerString.IsEmpty() )
587 wxStringTokenizer layerTokens( aLayerString,
"," );
589 while( layerTokens.HasMoreTokens() )
591 std::string token =
TO_UTF8( layerTokens.GetNextToken().Trim(
true ).Trim(
false ) );
593 if( layerUserMasks.contains( token ) )
594 pushLayers( layerUserMasks.at( token ) );
595 else if( layerMasks.count( token ) )
596 pushLayers( layerMasks.at( token ) );
597 else if( layerGuiMasks.count( token ) )
598 pushLayers( layerGuiMasks.at( token ) );
600 m_reporter->Report( wxString::Format(
_(
"Invalid layer name '%s'\n" ), token ) );
612 if( aStepJob ==
nullptr )
626 fn.SetName( fn.GetName() );
686 m_reporter->Report( wxString::Format(
_(
"Successfully exported VRML to %s" ), outPath ),
718 if( !stepExporter.
Export() )
730 if( aRenderJob ==
nullptr )
765 fn.SetName( wxString::Format(
"%s-%d", fn.GetName(),
static_cast<int>( aRenderJob->
m_side ) ) );
855 lightColor, lightColor, lightColor, lightColor, lightColor, lightColor, lightColor, lightColor,
861 sideElevation, sideElevation, sideElevation, sideElevation,
862 -sideElevation, -sideElevation, -sideElevation, -sideElevation,
866 45, 135, 225, 315, 45, 135, 225, 315,
871 boardAdapter.
m_Cfg = &cfg;
887 if( preset->name.Lower() ==
_(
"legacy colors" ) )
902 static std::map<JOB_PCB_RENDER::SIDE, VIEW3D_TYPE> s_viewCmdMap = {
949 uint8_t* rgbaBuffer = raytrace.
GetBuffer();
951 bool success = !!rgbaBuffer;
955 const unsigned int wxh = realSize.x * realSize.y;
957 unsigned char* rgbBuffer = (
unsigned char*) malloc( wxh * 3 );
958 unsigned char* alphaBuffer = (
unsigned char*) malloc( wxh );
960 unsigned char* rgbaPtr = rgbaBuffer;
961 unsigned char* rgbPtr = rgbBuffer;
962 unsigned char* alphaPtr = alphaBuffer;
964 for(
int y = 0; y < realSize.y; y++ )
966 for(
int x = 0; x < realSize.x; x++ )
968 rgbPtr[0] = rgbaPtr[0];
969 rgbPtr[1] = rgbaPtr[1];
970 rgbPtr[2] = rgbaPtr[2];
971 alphaPtr[0] = rgbaPtr[3];
979 wxImage
image( realSize );
980 image.SetData( rgbBuffer );
981 image.SetAlpha( alphaBuffer );
984 image.SetOption( wxIMAGE_OPTION_QUALITY, 90 );
985 image.SaveFile( outPath,
1006 if( aSvgJob ==
nullptr )
1023 fn.SetName( fn.GetName() );
1063 std::optional<wxString> layerName;
1064 std::optional<wxString> sheetName;
1065 std::optional<wxString> sheetPath;
1066 std::vector<wxString> outputPaths;
1087 for(
const wxString& outputPath : outputPaths )
1098 if( aDxfJob ==
nullptr )
1136 fn.SetName( fn.GetName() );
1156 std::optional<wxString> layerName;
1157 std::optional<wxString> sheetName;
1158 std::optional<wxString> sheetPath;
1172 std::vector<wxString> outputPaths;
1181 for(
const wxString& outputPath : outputPaths )
1190 bool plotAllLayersOneFile =
false;
1193 if( pdfJob ==
nullptr )
1221 plotAllLayersOneFile =
true;
1229 const bool outputIsSingle = plotAllLayersOneFile || pdfJob->
m_pdfSingle;
1234 fn.SetName( fn.GetName() );
1253 std::optional<wxString> layerName;
1254 std::optional<wxString> sheetName;
1255 std::optional<wxString> sheetPath;
1257 if( plotAllLayersOneFile )
1269 std::vector<wxString> outputPaths;
1272 outputIsSingle, layerName, sheetName, sheetPath, &outputPaths ) )
1277 for(
const wxString& outputPath : outputPaths )
1288 if( pngJob ==
nullptr )
1324 fn.SetName( fn.GetName() );
1343 std::vector<wxString> outputPaths;
1346 std::nullopt, std::nullopt, std::nullopt, &outputPaths ) )
1351 for(
const wxString& outputPath : outputPaths )
1362 if( psJob ==
nullptr )
1402 fn.SetName( fn.GetName() );
1422 std::optional<wxString> layerName;
1423 std::optional<wxString> sheetName;
1424 std::optional<wxString> sheetPath;
1438 std::vector<wxString> outputPaths;
1441 layerName, sheetName, sheetPath, &outputPaths ) )
1446 for(
const wxString& outputPath : outputPaths )
1458 if( aGerberJob ==
nullptr )
1487 bool hasLayerListSpecified =
false;
1494 hasLayerListSpecified =
true;
1537 plotSequence.push_back( layer );
1543 if(
find( plotSequence.begin(), plotSequence.end(), layer_all ) != plotSequence.end() )
1546 plotSequence.push_back( layer_all );
1557 plotOpts = boardPlotOptions;
1567 wxString fullname = fn.GetFullName();
1575 jobfile_writer.
AddGbrFile( layer, fullname );
1601 m_reporter->Report( wxString::Format(
_(
"Failed to plot to '%s'.\n" ), fn.GetFullPath() ),
1627 if( aGencadJob ==
nullptr )
1651 fn.SetName( fn.GetName() );
1683 if( statsJob ==
nullptr )
1701 wxString projectName;
1708 if( boardFile.GetName().IsEmpty() )
1709 boardFile = wxFileName( statsJob->
m_filename );
1732 FILE* outFile = wxFopen( outPath, wxS(
"wt" ) );
1740 if( fprintf( outFile,
"%s",
TO_UTF8( report ) ) < 0 )
1762 if( aGerberJob ==
nullptr )
1790 fn.SetName( fn.GetName() );
1835 PLOTTER* plotter =
StartPlotBoard( brd, &plotOpts, layer, layerName, outPath, sheetName, sheetPath );
1861 if( aDrillJob ==
nullptr )
1877 std::unique_ptr<GENDRILL_WRITER_BASE> drillWriter;
1880 drillWriter = std::make_unique<EXCELLON_WRITER>( brd );
1882 drillWriter = std::make_unique<GERBER_WRITER>( brd );
1906 wxFileName fn = outPath;
1908 fn.SetName( fn.GetName() +
"-drill" );
1939 if( excellonWriter ==
nullptr )
1972 if( gerberWriter ==
nullptr )
2011 if( aPosJob ==
nullptr )
2022 fn.SetName( fn.GetName() );
2044 wxFileName fn( outPath );
2045 wxString baseName = fn.GetName();
2047 auto exportPlaceFile = [&](
bool frontSide,
bool backSide,
const wxString& curr_outPath ) ->
bool
2049 FILE* file = wxFopen( curr_outPath, wxS(
"wt" ) );
2050 wxCHECK( file,
false );
2062 fputs( data.c_str(), file );
2075 if( exportPlaceFile(
true,
false, fn.GetFullPath() ) )
2077 m_reporter->Report( wxString::Format(
_(
"Wrote front position data to '%s'.\n" ), fn.GetFullPath() ),
2092 if( exportPlaceFile(
false,
true, fn.GetFullPath() ) )
2094 m_reporter->Report( wxString::Format(
_(
"Wrote back position data to '%s'.\n" ), fn.GetFullPath() ),
2120 if( exportPlaceFile( front, back, fn.GetFullPath() ) )
2122 m_reporter->Report( wxString::Format(
_(
"Wrote position data to '%s'.\n" ), fn.GetFullPath() ),
2141 wxString outPath_base = outPath;
2152 m_reporter->Report( wxString::Format(
_(
"Wrote front position data to '%s'.\n" ), outPath ),
2167 outPath = outPath_base;
2176 m_reporter->Report( wxString::Format(
_(
"Wrote back position data to '%s'.\n" ), outPath ),
2196 if( upgradeJob ==
nullptr )
2211 m_reporter->Report(
_(
"Output path must be specified to convert legacy and non-KiCad libraries\n" ),
2221 m_reporter->Report(
_(
"Footprint library path does not exist or is not accessible\n" ),
2242 bool shouldSave = upgradeJob->
m_force;
2288 if( svgJob ==
nullptr )
2321 bool singleFpPlotted =
false;
2323 for(
const auto& [fpName, fpCacheEntry] : fpLib.
GetFootprints() )
2337 singleFpPlotted =
true;
2340 exitCode =
doFpExportSvg( svgJob, fpCacheEntry->GetFootprint().get() );
2346 if( !svgJob->
m_footprint.IsEmpty() && !singleFpPlotted )
2348 m_reporter->Report(
_(
"The given footprint could not be found to export." ) + wxS(
"\n" ),
2362 brd->SynchronizeProperties();
2375 pad->SetLocalRatsnestVisible(
false );
2376 pad->SetNetCode( 0 );
2384 wxFileName outputFile;
2389 m_reporter->Report( wxString::Format(
_(
"Plotting footprint '%s' to '%s'\n" ),
2410 false,
true, wxEmptyString, wxEmptyString, wxEmptyString ) )
2416 aSvgJob->
AddOutput( outputFile.GetFullPath() );
2426 if( drcJob ==
nullptr )
2442 fn.SetName( fn.GetName() + wxS(
"-drc" ) );
2471 std::unique_ptr<NETLIST>
netlist = std::make_unique<NETLIST>();
2480 std::string netlist_str;
2484 wxString annotateMsg =
_(
"Schematic parity tests require a fully annotated schematic." );
2485 netlist_str = annotateMsg;
2497 wxFileName schematicPath( drcJob->
m_filename );
2498 schematicPath.MakeAbsolute();
2501 if( !schematicPath.Exists() )
2504 if( !schematicPath.Exists() )
2511 typedef bool ( *NETLIST_FN_PTR )(
const wxString&, std::string& );
2514 ( *netlister )( schematicPath.GetFullPath(), netlist_str );
2522 else if( netlist_str == annotateMsg )
2544 drcEngine->SetSchematicNetlist(
netlist.get() );
2556 drcEngine->SetViolationHandler(
2557 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
2558 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
2561 aPathGenerator( marker );
2562 commit.
Add( marker );
2568 drcEngine->ClearViolationHandler();
2575 std::shared_ptr<DRC_ITEMS_PROVIDER> markersProvider =
2578 std::shared_ptr<DRC_ITEMS_PROVIDER> ratsnestProvider =
2581 std::shared_ptr<DRC_ITEMS_PROVIDER> fpWarningsProvider =
2584 markersProvider->SetSeverities( drcJob->
m_severity );
2585 ratsnestProvider->SetSeverities( drcJob->
m_severity );
2586 fpWarningsProvider->SetSeverities( drcJob->
m_severity );
2588 m_reporter->Report( wxString::Format(
_(
"Found %d violations\n" ), markersProvider->GetCount() ),
2590 m_reporter->Report( wxString::Format(
_(
"Found %d unconnected items\n" ), ratsnestProvider->GetCount() ),
2596 wxString::Format(
_(
"Found %d schematic parity issues\n" ), fpWarningsProvider->GetCount() ),
2600 DRC_REPORT reportWriter( brd, units, markersProvider, ratsnestProvider, fpWarningsProvider );
2602 bool wroteReport =
false;
2635 if( markersProvider->GetCount() > 0 || ratsnestProvider->GetCount() > 0 || fpWarningsProvider->GetCount() > 0 )
2649 if( job ==
nullptr )
2687 if( job ==
nullptr )
2698 fn.SetName( fn.GetName() );
2714 bool success = exporter.
Write( outPath );
2734 if( job ==
nullptr )
2755 fn.SetName( fn.GetName() + wxS(
"-odb" ) );
2802 if( job ==
nullptr )
2805 bool shouldSave = job->
m_force;
2827 wxString::Format(
_(
"Error saving board file '%s'.\n%s" ), job->
m_filename, ioe.
What().GetData() );
2841 if( aDrawingSheet && !aDrawingSheet->IsEmpty() )
2871 return drawingSheet;
2878 if( aSheetPath.IsEmpty() )
2881 auto loadSheet = [&](
const wxString&
path ) ->
bool
2894 m_reporter->Report( wxString::Format(
_(
"Error loading drawing sheet '%s'." ),
path ) + wxS(
"\n" ) + msg
2903 if( loadSheet( aSheetPath ) )
2935 m_reporter->Report( wxString::Format(
_(
"Input file not found: '%s'\n" ),
2967 m_reporter->Report( wxString::Format(
_(
"No PCB importer recognizes the file format of "
2977 if( outputPath.IsEmpty() )
2985 PROJECT* projectPtr =
nullptr;
2986 bool createdTransientProject =
false;
2990 projectPtr = &mgr.
Prj();
2994 wxFileName projectFn( outputPath );
2998 projectPtr = mgr.
GetProject( projectFn.GetFullPath() );
2999 createdTransientProject = ( projectPtr != nullptr );
3004 m_reporter->Report(
_(
"Could not establish a project for the import\n" ),
3010 struct TRANSIENT_PROJECT_GUARD
3016 ~TRANSIENT_PROJECT_GUARD()
3021 } transientProjectGuard{ mgr, projectPtr, createdTransientProject };
3023 BOARD* board =
nullptr;
3025 std::vector<wxString> warnings;
3029 struct CAPTURED_LAYER
3036 std::vector<CAPTURED_LAYER> capturedLayers;
3037 std::set<wxString> seenSourceLayers;
3038 bool layersCaptured =
false;
3046 m_reporter->Report( wxString::Format(
_(
"No plugin found for file type '%s'\n" ), formatName ),
3058 mappable->RegisterCallback(
3059 [&](
const std::vector<INPUT_LAYER_DESC>& aDescs )
3060 -> std::map<wxString, PCB_LAYER_ID>
3062 std::map<wxString, PCB_LAYER_ID>
result;
3067 wxString method = wxS(
"auto" );
3069 if(
auto it = job->
m_layerMap.find( desc.Name );
3076 warnings.push_back( wxString::Format(
3077 _(
"Layer map entry '%s' -> '%s' names an unknown "
3078 "KiCad layer; using automatic mapping instead" ),
3079 desc.Name, it->second ) );
3081 else if( !desc.PermittedLayers.Contains( resolved ) )
3083 warnings.push_back( wxString::Format(
3084 _(
"Layer map entry '%s' -> '%s' is not a permitted "
3085 "target for this layer; using automatic mapping "
3087 desc.Name, it->second ) );
3092 method = wxS(
"explicit" );
3098 warnings.push_back( wxString::Format(
3099 _(
"No KiCad layer mapping for required source layer "
3100 "'%s'; its items will not be imported" ),
3104 result.emplace( desc.Name, target );
3105 capturedLayers.push_back( { desc.Name, target, method } );
3106 seenSourceLayers.insert( desc.Name );
3109 layersCaptured =
true;
3116 warnings.push_back(
_(
"A layer map was provided, but this importer does not support "
3117 "layer remapping; it will be ignored" ) );
3121 wxString::Format(
_(
"Importing '%s' using %s format...\n" ), job->
m_inputFile, formatName ),
3124 board = pi->LoadBoard( job->
m_inputFile,
nullptr,
nullptr,
nullptr );
3141 if( layersCaptured )
3143 for(
const auto& [source, target] : job->
m_layerMap )
3145 if( !seenSourceLayers.contains( source ) )
3147 warnings.push_back( wxString::Format(
3148 _(
"Layer map entry '%s' does not match any source layer in the "
3149 "imported file; it will be ignored" ),
3157 kicadPlugin->SaveBoard( outputPath, board );
3159 m_reporter->Report( wxString::Format(
_(
"Successfully saved imported board to '%s'\n" ), outputPath ),
3165 IMPORT_REPORT_DATA reportData;
3167 reportData.m_sourceFile = wxFileName( job->
m_inputFile ).GetFullName();
3168 reportData.m_sourceFormat = formatName;
3169 reportData.m_outputFile = wxFileName( outputPath ).GetFullName();
3171 size_t trackCount = 0;
3172 size_t viaCount = 0;
3182 reportData.m_statistics = {
3183 { wxS(
"footprints" ), board->
Footprints().size() },
3184 { wxS(
"tracks" ), trackCount },
3185 { wxS(
"vias" ), viaCount },
3186 { wxS(
"zones" ), board->
Zones().size() }
3192 nlohmann::json layerMappings = nlohmann::json::object();
3194 if( layersCaptured )
3196 for(
const CAPTURED_LAYER& mapped : capturedLayers )
3200 :
LSET::Name( mapped.m_target ).ToStdString();
3202 layerMappings[mapped.m_source.ToStdString()] = {
3203 {
"kicad_layer", kicadLayer },
3204 {
"method", mapped.m_method.ToStdString() }
3214 layerMappings[layerName.ToStdString()] = {
3215 {
"kicad_layer",
LSET::Name( layer ).ToStdString() },
3216 {
"method",
"auto" }
3221 reportData.m_extraJson[
"layer_mapping"] = layerMappings;
3222 reportData.m_warnings = warnings;
3229 for(
const wxString& warning : warnings )
3263 bool aInitializeAfterLoad =
true )
3267 [aPath, aInitializeAfterLoad](
PROJECT* aProject ) -> std::unique_ptr<BOARD>
3290 aBoard->ClearProject();
3311 BOARD* boardA = aScratch.
doc.get();
3312 BOARD* boardB = bScratch.
doc.get();
3332 return diffExitCode;
3358 const wxString& aOurs,
const wxString& aTheirs,
3359 const wxString& aOutput,
bool aInteractive,
bool aSingleFile,
3368 return runFpLibMerge( aAncestor, aOurs, aTheirs, aOutput, aSingleFile );
3370 return runPcbMerge( aAncestor, aOurs, aTheirs, aOutput, aInteractive );
3375 const wxString& aTheirs,
const wxString& aOutput,
3392 BOARD* ancestor = ancestorScratch.
doc.get();
3393 BOARD* ours = oursScratch.
doc.get();
3394 BOARD* theirs = theirsScratch.
doc.get();
3396 if( !ancestor || !ours || !theirs )
3413 if( aInteractive && !plan.
Resolved() )
3415 if( !
Pgm().IsGUI() )
3417 m_reporter->Report(
_(
"--interactive requires a GUI KiCad process; the console "
3418 "kicad-cli cannot open dialogs.\n" ),
3447 std::unique_ptr<BOARD> merged = applier.
Apply();
3460 pcbIO.
SaveBoard( aOutput, merged.get() );
3464 m_reporter->Report( wxString::Format(
_(
"Failed to save merged board: %s\n" ), ioe.
What() ),
3497 wxFileName proFn( aOutput );
3520 std::set<wxString> touched;
3538 wxString::Format(
_(
"Failed to save merged project file: %s\n" ), proFn.GetFullPath() ),
3547 auto writeStagedFile = [&](
const wxString& aPath,
const wxString& aContent,
const wxString& aLabel ) ->
bool
3549 if( aContent.IsEmpty() )
3551 if( wxFileExists( aPath ) )
3552 wxRemoveFile( aPath );
3559 if( !out.Open( aPath, wxFile::write ) || !out.Write( aContent ) )
3561 m_reporter->Report( wxString::Format(
_(
"Failed to save merged %s: %s\n" ), aLabel, aPath ),
3573 wxFileName druFn( aOutput );
3586 wxFileName fpFn( aOutput );
3589 if( !writeStagedFile( fpFn.GetFullPath(), applier.
GetReport().
fpLibTable,
_(
"footprint library table" ) ) )
3597 wxFileName symFn( aOutput );
3600 if( !writeStagedFile( symFn.GetFullPath(), applier.
GetReport().
symLibTable,
_(
"symbol library table" ) ) )
3611 m_reporter->Report( wxString::Format( wxS(
"%s: %s\n" ), f.validator, f.message ), f.severity );
3618 m_reporter->Report( wxString::Format(
_(
"Merge completed with %zu unresolved conflict(s) in %s\n" ),
3639 std::vector<std::unique_ptr<FOOTPRINT>>& aOwners,
3643 if( aAllowEmpty && aPath.IsEmpty() )
3649 aOwners = std::move( loaded.first );
3650 aMap = std::move( loaded.second );
3655 aReporter.
Report( wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, ioe.
What() ),
3658 catch(
const std::exception& e )
3661 wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, wxString::FromUTF8( e.what() ) ),
3676 for(
const auto& [
name, footprint] : aMap )
3693 wxFileName dirA( diffJob->
m_inputA );
3694 dirA.MakeAbsolute();
3695 wxFileName dirB( diffJob->
m_inputB );
3696 dirB.MakeAbsolute();
3698 std::vector<std::unique_ptr<FOOTPRINT>> ownersA;
3699 std::vector<std::unique_ptr<FOOTPRINT>> ownersB;
3721 return diffExitCode;
3746 const wxString& aFileB,
const wxString& aLabelA,
3747 const wxString& aLabelB, wxWindow* aParent,
3755 wxWindow* parent = aParent ? aParent : ( wxTheApp ? wxTheApp->GetTopWindow() :
nullptr );
3759 auto loadBoardScratch = [&](
const wxString& aPath )
3768 auto loadFootprintFile = [&](
const wxString& aPath ) -> std::unique_ptr<FOOTPRINT>
3770 if( aPath.IsEmpty() )
3773 wxFileName fn( aPath );
3798 if( !a.
doc && !aFileA.IsEmpty() )
3804 if( !b.
doc && !aFileB.IsEmpty() )
3823 const wxString labelA = aLabelA.IsEmpty() ? aFileA : aLabelA;
3824 const wxString labelB = aLabelB.IsEmpty() ? aFileB : aLabelB;
3827 parent, labelA, labelB,
result, std::move( refGeometry ), std::move( compGeometry ),
3830 KICAD_DIFF::ConfigurePcbDiffCanvasContext( aCanvas, boardA, boardB, color );
3838 std::vector<std::unique_ptr<FOOTPRINT>> ownersA;
3839 std::vector<std::unique_ptr<FOOTPRINT>> ownersB;
3865 std::unique_ptr<FOOTPRINT> footprintA;
3866 std::unique_ptr<FOOTPRINT> footprintB;
3870 footprintA = loadFootprintFile( aFileA );
3874 m_reporter->Report( wxString::Format(
_(
"Failed to load %s: %s\n" ), aFileA, ioe.
What() ),
3881 footprintB = loadFootprintFile( aFileB );
3885 m_reporter->Report( wxString::Format(
_(
"Failed to load %s: %s\n" ), aFileB, ioe.
What() ),
3892 const wxString nameA = wxFileName( aFileA ).GetName();
3893 const wxString nameB = wxFileName( aFileB ).GetName();
3894 const wxString itemName = !nameB.IsEmpty() ? nameB : nameA;
3897 mapA[itemName] = footprintA.get();
3900 mapB[itemName] = footprintB.get();
3920 const wxString labelA = aLabelA.IsEmpty() ? aFileA : aLabelA;
3921 const wxString labelB = aLabelB.IsEmpty() ? aFileB : aLabelB;
3938 const wxString& aTheirs,
const wxString& aOutput,
3941 if( aOutput.IsEmpty() )
3949 std::vector<std::unique_ptr<FOOTPRINT>> owners;
3953 LIB_SIDE ancestor, ours, theirs;
3960 auto isSingleFile = [&](
const wxString& aPath )
3968 auto loadSide = [&](
const wxString& aPath, LIB_SIDE& aSide ) ->
int
3972 if( isSingleFile( aPath ) )
3984 const UTF8& itemName = fp->GetFPID().GetLibItemName();
3987 aSide.map[key] = fp.get();
3988 aSide.owners.push_back( std::move( fp ) );
3993 aSide.owners = std::move( loaded.first );
3994 aSide.map = std::move( loaded.second );
3999 m_reporter->Report( wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, ioe.
What() ),
4002 catch(
const std::exception& e )
4005 wxString::Format(
_(
"Failed to load %s: %s\n" ), aPath, wxString::FromUTF8( e.what() ) ),
4033 std::vector<std::unique_ptr<FOOTPRINT>> merged = applier.
Apply();
4038 const bool hadSilentFallback = applier.
GetReport().mergePropsFallback > 0;
4040 const bool singleFileOutput = isSingleFile( aOutput );
4049 if( singleFileOutput )
4050 outFn = wxFileName( aOutput );
4052 outFn = wxFileName::DirName( aOutput );
4054 outFn.MakeAbsolute();
4060 const wxString outDir = outFn.GetPath();
4062 if( !wxFileName::DirExists( outDir ) && !wxFileName::Mkdir( outDir, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
4064 m_reporter->Report( wxString::Format(
_(
"Cannot create output directory %s\n" ), outDir ),
4073 if( singleFileOutput )
4079 if( merged.size() > 1 )
4081 m_reporter->Report(
_(
"Single-file fp merge produced multiple footprints; refusing to "
4082 "collapse into one .kicad_mod\n" ),
4087 if( merged.empty() )
4092 if( wxFileName::FileExists( outFn.GetFullPath() ) )
4093 wxRemoveFile( outFn.GetFullPath() );
4099 io.
FootprintSave( outFn.GetFullPath(), merged.front().get(),
nullptr );
4110 io.
Format( merged.front().get() );
4122 std::set<wxString> mergedNames;
4124 for(
const auto& fp : merged )
4127 mergedNames.insert( fp->GetFPID().GetLibItemName() );
4130 wxArrayString existing;
4133 for(
const wxString&
name : existing )
4135 if( !mergedNames.count(
name ) )
4139 for(
const auto& fp : merged )
4144 const wxString
name = fp->GetFPID().GetLibItemName();
4155 m_reporter->Report( wxString::Format(
_(
"Failed to save merged footprint library: %s\n" ), ioe.
What() ),
4161 if( !planSnapshot.
Resolved() || hadSilentFallback )
4165 std::set<KIID_PATH> conflicts( planSnapshot.
unresolved.begin(), planSnapshot.
unresolved.end() );
4168 conflicts.insert(
id );
4170 m_reporter->Report( wxString::Format(
_(
"Footprint library merge completed with %zu unresolved "
4171 "conflict(s) in %s\n" ),
4172 conflicts.size(), aOutput ),
constexpr EDA_IU_SCALE pcbIUScale
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
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.
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
std::shared_ptr< NET_SETTINGS > m_NetSettings
std::map< int, SEVERITY > m_DRCSeverities
std::shared_ptr< DRC_ENGINE > m_DRCEngine
const VECTOR2I & GetAuxOrigin() const
static std::unique_ptr< BOARD > CreateEmptyBoard(PROJECT *aProject)
static std::unique_ptr< BOARD > Load(const wxString &aFileName, PCB_IO_MGR::PCB_FILE_T aFormat, PROJECT *aProject, const OPTIONS &aOptions)
static bool SaveBoard(wxString &aFileName, BOARD *aBoard, PCB_IO_MGR::PCB_FILE_T aFormat)
Information pertinent to a Pcbnew printed circuit board.
void SetCurrentVariant(const wxString &aVariant)
const PAGE_INFO & GetPageSettings() const
const ZONES & Zones() 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 TRACKS & Tracks() 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
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
void SynchronizeProperties()
Copy the current project's text variables into the boards property cache.
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false, bool aPhysicalLayersOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
void DeleteMARKERs()
Delete all MARKERS from the board.
constexpr const Vec GetCenter() const
void SetProjection(PROJECTION_TYPE aProjection)
void RotateY_T1(float aAngleInRadians)
bool Zoom_T1(float aFactor)
bool SetCurWindowSize(const wxSize &aSize)
Update the windows size of the camera.
bool ViewCommand_T1(VIEW3D_TYPE aRequestedView)
void RotateX_T1(float aAngleInRadians)
void SetLookAtPos_T1(const SFVEC3F &aLookAtPos)
const SFVEC3F & GetLookAtPos_T1() const
void RotateZ_T1(float aAngleInRadians)
Reporter forwarding messages to stdout or stderr as appropriate.
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
static bool GenerateFile(JOB_EXPORT_PCB_IPC2581 &aJob, BOARD *aBoard, PROGRESS_REPORTER *aProgressReporter, REPORTER *aReporter)
static void GenerateODBPPFiles(const JOB_EXPORT_PCB_ODB &aJob, BOARD *aBoard, PCB_EDIT_FRAME *aParentFrame=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr, REPORTER *aErrorReporter=nullptr)
File-compare dialog (Phase 7).
3-way merge resolution dialog (Phase 8).
const KICAD_DIFF::MERGE_PLAN & GetResolvedPlan() const
Returns the plan with the user's resolutions applied.
A dialog to set the plot options and create plot files in various formats.
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
void SetFlags(EDA_ITEM_FLAGS aMask)
virtual void SetParent(EDA_ITEM *aParent)
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.
Provide an extensible class to resolve 3D model paths.
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.
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
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
wxString GetSettingsDialogTitle() const override
bool m_useIndividualShapes
bool m_useBoardPlotParams
ODB_COMPRESSION m_compressionMode
bool m_checkZonesBeforeExport
@ ALL_LAYERS_ONE_FILE
DEPRECATED MODE.
bool m_pdfSingle
This is a hack to deal with cli having the wrong behavior We will deprecate out the wrong behavior,...
GEN_MODE m_pdfGenMode
The background color specified in a hex string.
LSEQ m_plotOnAllLayersSequence
Used by SVG & PDF.
bool m_checkZonesBeforePlot
std::optional< wxString > m_argLayers
std::optional< wxString > m_argCommonLayers
LSEQ m_plotLayerSequence
Layers to include on all individual layer prints.
wxString m_variant
Variant name for variant-aware filtering.
bool m_useDrillPlaceFileOrigin
bool m_excludeFootprintsWithTh
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.
bool m_reportAllTrackErrors
Job to import a non-KiCad PCB file to KiCad format.
std::map< wxString, wxString > m_layerMap
Explicit overrides from source layer name to KiCad layer name (canonical board-file name,...
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.
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()
virtual bool Store()
Stores the current parameters into the JSON document represented by this object Note: this doesn't do...
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.
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
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)
int JobExportFpSvg(JOB *aJob)
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)
std::unique_ptr< BOARD > m_cliBoard
int JobExportGencad(JOB *aJob)
BOARD * getBoard(const wxString &aPath=wxEmptyString)
int JobExportIpc2581(JOB *aJob)
virtual ~PCBNEW_JOBS_HANDLER()
int runFpLibMerge(const wxString &aAncestor, const wxString &aOurs, const wxString &aTheirs, const wxString &aOutput, bool aSingleFile)
std::unique_ptr< TOOL_MANAGER > m_toolManager
int OpenDiffDialog(KICAD_DIFF::DOC_KIND aKind, const wxString &aFileA, const wxString &aFileB, const wxString &aLabelA, const wxString &aLabelB, wxWindow *aParent, REPORTER *aReporter)
LSEQ convertLayerArg(wxString &aLayerString, BOARD *aBoard) const
void ClearCachedBoard()
Clear the cached CLI board so the next job reloads from the current project.
int JobExportRender(JOB *aJob)
int JobExportIpcD356(JOB *aJob)
int doFpExportSvg(JOB_FP_EXPORT_SVG *aSvgJob, const FOOTPRINT *aFootprint)
int JobExportStats(JOB *aJob)
The main frame for Pcbnew.
A #PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
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.
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.
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.
@ PCB_FILE_UNKNOWN
0 is not a legal menu id on Mac
static PCB_IO * FindPlugin(PCB_FILE_T aFileType)
Return a #PLUGIN 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.
static void PlotJobToPlotOpts(PCB_PLOT_PARAMS &aOpts, JOB_EXPORT_PCB_PLOT *aJob, REPORTER &aReporter)
Translate a JOB to PCB_PLOT_PARAMS.
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 SetSkipPlotNPTH_Pads(bool aSkip)
void SetLayerSelection(const LSET &aSelection)
void SetPlotOnAllLayersSequence(LSEQ aSeq)
void SetPlotFrameRef(bool aFlag)
void SetPlotPadNumbers(bool aFlag)
LSET GetLayerSelection() const
void SetMirror(bool aFlag)
bool GetSketchPadsOnFabLayers() const
void SetSvgFitPageToBoard(int aSvgFitPageToBoard)
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.
static S3D_CACHE * Get3DCacheManager(PROJECT *aProject, bool updateProjDir=false)
Return a pointer to an instance of the 3D cache manager.
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 PROJECT_FILE & GetProjectFile() const
bool Redraw(bool aIsMoving, REPORTER *aStatusReporter, REPORTER *aWarningReporter) override
Redraw the view.
wxSize GetRealBufferSize()
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 GetDefaultPlotExtension(PLOT_FORMAT aFormat)
Return the default plot extension for a format.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
static DRILL_PRECISION precisionListForInches(2, 4)
static DRILL_PRECISION precisionListForMetric(3, 3)
#define FOLLOW_PLOT_SETTINGS
static constexpr EDA_ANGLE ANGLE_0
#define IS_NEW
New item, just created.
static FILENAME_RESOLVER * resolver
Classes used in drill files, map files and report files generation.
Classes used in drill files, map files and report files generation.
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 KiCadSchematicFileExtension
static const std::string CsvFileExtension
static const std::string U3DFileExtension
static const std::string PdfFileExtension
static const std::string Ipc2581FileExtension
static const std::string FootprintLibraryTableFileName
static const std::string GencadFileExtension
static const std::string StlFileExtension
static const std::string IpcD356FileExtension
static const std::string PlyFileExtension
static const std::string StepFileExtension
static const std::string SVGFileExtension
static const std::string DesignRulesFileExtension
static const std::string VrmlFileExtension
static const std::string KiCadFootprintFileExtension
static const std::string ArchiveFileExtension
static const std::string KiCadPcbFileExtension
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
void 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...
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...
@ 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 const int ERR_ARGS
static const int ERR_RC_VIOLATIONS
Rules check violation count was greater than 0.
static const int ERR_INVALID_INPUT_FILE
static const int ERR_INVALID_OUTPUT_CONFLICT
static const int ERR_UNKNOWN_FILE_FORMAT
No plugin for the requested face recognized the input file format.
static const int ERR_UNKNOWN
void CollectChangeBBoxes(const DOCUMENT_DIFF &aDiff, std::map< KIID_PATH, BOX2I > &aOut)
Walk a DOCUMENT_DIFF and populate a (KIID_PATH → BOX2I) map with each changed item's bbox,...
const wxString DOC_PROP_NET_CLASSES
LIB_MERGE_APPLIER< FOOTPRINT > FP_LIB_MERGE_APPLIER
Footprint-library 3-way merge applier. See LIB_MERGE_APPLIER for behavior.
void AppendGeometry(DOCUMENT_GEOMETRY &aDst, DOCUMENT_GEOMETRY &&aSrc)
Move all primitives from aSrc into aDst.
DOCUMENT_GEOMETRY ExtractFootprintGeometry(const FOOTPRINT &aFootprint, const KIGFX::COLOR4D &aColor)
Extract drawable context geometry from a single FOOTPRINT.
DIFF_EMIT_OPTIONS MakeEmitOptions(const JOB_DIFF_BASE &aJob, const wxString &aLabelA, const wxString &aLabelB)
Build a DIFF_EMIT_OPTIONS pre-filled from the job's format, resolved output path and the supplied per...
const wxString DOC_PROP_DRAWING_SHEET
DOC_KIND
Document type a diff/merge entry point should route to, derived from a file path's extension.
int EmitDiffResult(const DOCUMENT_DIFF &aResult, const DIFF_EMIT_OPTIONS &aOptions, int aDiffExitCode, REPORTER &aReporter)
Emit a computed DOCUMENT_DIFF in the requested format.
const wxString DOC_PROP_DRC_SEVERITIES
DOCUMENT_GEOMETRY ExtractBoardGeometry(const BOARD &aBoard, const KIGFX::COLOR4D &aColor)
Extract a coarse outline of a BOARD into a DOCUMENT_GEOMETRY for use as background context in DIFF_SC...
bool ApplyProjectFilePatches(const wxString &aOutputProPath, const nlohmann::json &aSource, const std::set< wxString > &aDocProps, DOC_KIND aKind)
Higher-level orchestrator: load the existing aOutputProPath as JSON (or start from aSource if the fil...
int DiffExitCode(const DOCUMENT_DIFF &aResult)
Map a computed diff onto its CLI exit code – SUCCESS when empty, otherwise ERR_RC_VIOLATIONS.
#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.
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 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 KICAD_DIFF::DOCUMENT_GEOMETRY footprintLibraryGeometry(const KICAD_DIFF::FP_LIB_DIFFER::FOOTPRINT_MAP &aMap, const KIGFX::COLOR4D &aColor)
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 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
Phase 8 context for the conflict canvas.
KICAD_DIFF::DOCUMENT_GEOMETRY ancestorGeometry
std::map< KIID_PATH, BOX2I > theirsBBoxes
KICAD_DIFF::DOCUMENT_GEOMETRY oursGeometry
std::map< KIID_PATH, BOX2I > oursBBoxes
KICAD_DIFF::DOCUMENT_GEOMETRY theirsGeometry
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
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.
Move-only RAII wrapper for "load a KiCad document into a non-active scratch PROJECT and clean up afte...
std::unique_ptr< DOC > doc
static void checkParity(CREEPAGE_PARITY_FIXTURE &aFixture, const std::string &aBoard)
IbisParser parser & reporter
wxString result
Test unit parsing edge cases and error handling.
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.