23#include <wx/zipstrm.h>
24#include <wx/filename.h>
25#include <wx/tokenzr.h>
26#include <wx/wfstream.h>
28#include <nlohmann/json.hpp>
134 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
141 wxCHECK( svgJob && editFrame,
false );
148 [](
JOB* job, wxWindow* aParent ) ->
bool
152 wxCHECK( renderJob,
false );
158 [](
JOB* job, wxWindow* aParent ) ->
bool
163 [](
JOB* job, wxWindow* aParent ) ->
bool
168 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
175 wxCHECK( svgJob && editFrame,
false );
182 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
189 wxCHECK( gencadJob && editFrame,
false );
195 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
202 wxCHECK( dxfJob && editFrame,
false );
208 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
215 wxCHECK( pdfJob && editFrame,
false );
221 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
228 wxCHECK( psJob && editFrame,
false );
235 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
242 wxCHECK( statsJob && editFrame,
false );
247 statsJob->
m_filename = boardName.GetFullPath();
250 wxWindow* parent = aParent ? aParent :
static_cast<wxWindow*
>( editFrame );
258 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
265 wxCHECK( gJob && editFrame,
false );
272 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
279 wxCHECK( gJob && editFrame,
false );
287 m_reporter->Report(
_(
"Plotting to HPGL is no longer supported as of KiCad 10.0.\n" ),
291 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
296 wxCHECK( editFrame,
false );
299 _(
"Plotting to HPGL is no longer supported as of KiCad 10.0." ) );
304 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
311 wxCHECK( drillJob && editFrame,
false );
317 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
324 wxCHECK( posJob && editFrame,
false );
331 [](
JOB* job, wxWindow* aParent ) ->
bool
337 [](
JOB* job, wxWindow* aParent ) ->
bool
342 [](
JOB* job, wxWindow* aParent ) ->
bool
346 wxCHECK( drcJob,
false );
353 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
360 wxCHECK( ipcJob && editFrame,
false );
367 [](
JOB* job, wxWindow* aParent ) ->
bool
373 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
380 wxCHECK( odbJob && editFrame,
false );
421 BOARD* brd =
nullptr;
425 wxString pcbPath = aPath;
427 if( pcbPath.IsEmpty() )
432 pcbPath =
path.GetFullPath();
461 std::map<wxString, LSET> layerUserMasks;
462 std::map<wxString, LSET> layerMasks;
463 std::map<wxString, LSET> layerGuiMasks;
498 [&](
const LSET& layerSet )
501 layerMask.push_back( layer );
504 if( !aLayerString.IsEmpty() )
506 wxStringTokenizer layerTokens( aLayerString,
"," );
508 while( layerTokens.HasMoreTokens() )
510 std::string token =
TO_UTF8( layerTokens.GetNextToken().Trim(
true ).Trim(
false ) );
512 if( layerUserMasks.contains( token ) )
513 pushLayers( layerUserMasks.at( token ) );
514 else if( layerMasks.count( token ) )
515 pushLayers( layerMasks.at( token ) );
516 else if( layerGuiMasks.count( token ) )
517 pushLayers( layerGuiMasks.at( token ) );
519 m_reporter->Report( wxString::Format(
_(
"Invalid layer name '%s'\n" ), token ) );
531 if( aStepJob ==
nullptr )
545 fn.SetName( fn.GetName() );
613 m_reporter->Report( wxString::Format(
_(
"Successfully exported VRML to %s" ),
646 if( !stepExporter.
Export() )
658 if( aRenderJob ==
nullptr )
690 fn.SetName( wxString::Format(
"%s-%d", fn.GetName(),
static_cast<int>( aRenderJob->
m_side ) ) );
782 lightColor, lightColor, lightColor, lightColor,
783 lightColor, lightColor, lightColor, lightColor,
789 sideElevation, sideElevation, sideElevation, sideElevation,
790 -sideElevation, -sideElevation, -sideElevation, -sideElevation,
794 45, 135, 225, 315, 45, 135, 225, 315,
799 boardAdapter.
m_Cfg = &cfg;
815 if( preset->name.Lower() ==
_(
"legacy colors" ) )
830 static std::map<JOB_PCB_RENDER::SIDE, VIEW3D_TYPE> s_viewCmdMap = {
878 uint8_t* rgbaBuffer = raytrace.
GetBuffer();
880 bool success = !!rgbaBuffer;
884 const unsigned int wxh = realSize.x * realSize.y;
886 unsigned char* rgbBuffer = (
unsigned char*) malloc( wxh * 3 );
887 unsigned char* alphaBuffer = (
unsigned char*) malloc( wxh );
889 unsigned char* rgbaPtr = rgbaBuffer;
890 unsigned char* rgbPtr = rgbBuffer;
891 unsigned char* alphaPtr = alphaBuffer;
893 for(
int y = 0; y < realSize.y; y++ )
895 for(
int x = 0; x < realSize.x; x++ )
897 rgbPtr[0] = rgbaPtr[0];
898 rgbPtr[1] = rgbaPtr[1];
899 rgbPtr[2] = rgbaPtr[2];
900 alphaPtr[0] = rgbaPtr[3];
908 wxImage
image( realSize );
909 image.SetData( rgbBuffer );
910 image.SetAlpha( alphaBuffer );
913 image.SetOption( wxIMAGE_OPTION_QUALITY, 90 );
915 : wxBITMAP_TYPE_JPEG );
935 if( aSvgJob ==
nullptr )
952 fn.SetName( fn.GetName() );
992 std::optional<wxString> layerName;
993 std::optional<wxString> sheetName;
994 std::optional<wxString> sheetPath;
1010 layerName, sheetName, sheetPath ) )
1023 if( aDxfJob ==
nullptr )
1061 fn.SetName( fn.GetName() );
1081 std::optional<wxString> layerName;
1082 std::optional<wxString> sheetName;
1083 std::optional<wxString> sheetPath;
1099 layerName, sheetName, sheetPath ) )
1110 bool plotAllLayersOneFile =
false;
1113 if( pdfJob ==
nullptr )
1141 plotAllLayersOneFile =
true;
1149 const bool outputIsSingle = plotAllLayersOneFile || pdfJob->
m_pdfSingle;
1154 fn.SetName( fn.GetName() );
1173 std::optional<wxString> layerName;
1174 std::optional<wxString> sheetName;
1175 std::optional<wxString> sheetPath;
1177 if( plotAllLayersOneFile )
1191 layerName, sheetName, sheetPath ) )
1204 if( psJob ==
nullptr )
1244 fn.SetName( fn.GetName() );
1264 std::optional<wxString> layerName;
1265 std::optional<wxString> sheetName;
1266 std::optional<wxString> sheetPath;
1281 layerName, sheetName, sheetPath ) )
1295 if( aGerberJob ==
nullptr )
1324 bool hasLayerListSpecified =
false;
1331 hasLayerListSpecified =
true;
1374 plotSequence.push_back( layer );
1380 if(
find( plotSequence.begin(), plotSequence.end(), layer_all ) != plotSequence.end() )
1383 plotSequence.push_back( layer_all );
1394 plotOpts = boardPlotOptions;
1404 wxString fullname = fn.GetFullName();
1412 jobfile_writer.
AddGbrFile( layer, fullname );
1426 fn.GetFullPath(), sheetName, sheetPath );
1430 m_reporter->Report( wxString::Format(
_(
"Plotted to '%s'.\n" ), fn.GetFullPath() ),
1438 m_reporter->Report( wxString::Format(
_(
"Failed to plot to '%s'.\n" ), fn.GetFullPath() ),
1463 if( aGencadJob ==
nullptr )
1487 fn.SetName( fn.GetName() );
1503 m_reporter->Report( wxString::Format(
_(
"Failed to create file '%s'.\n" ), outPath ),
1519 if( statsJob ==
nullptr )
1537 wxString projectName;
1544 if( boardFile.GetName().IsEmpty() )
1545 boardFile = wxFileName( statsJob->
m_filename );
1568 FILE* outFile = wxFopen( outPath, wxS(
"wt" ) );
1576 if( fprintf( outFile,
"%s",
TO_UTF8( report ) ) < 0 )
1598 if( aGerberJob ==
nullptr )
1626 fn.SetName( fn.GetName() );
1681 m_reporter->Report( wxString::Format(
_(
"Failed to plot to '%s'.\n" ), outPath ),
1699 if( aDrillJob ==
nullptr )
1715 std::unique_ptr<GENDRILL_WRITER_BASE> drillWriter;
1718 drillWriter = std::make_unique<EXCELLON_WRITER>( brd );
1720 drillWriter = std::make_unique<GERBER_WRITER>( brd );
1744 wxFileName fn = outPath;
1746 fn.SetName( fn.GetName() +
"-drill" );
1785 if( excellonWriter ==
nullptr )
1816 if( gerberWriter ==
nullptr )
1851 if( aPosJob ==
nullptr )
1862 fn.SetName( fn.GetName() );
1885 wxFileName fn( outPath );
1886 wxString baseName = fn.GetName();
1888 auto exportPlaceFile =
1889 [&](
bool frontSide,
bool backSide,
const wxString& curr_outPath ) ->
bool
1891 FILE* file = wxFopen( curr_outPath, wxS(
"wt" ) );
1892 wxCHECK( file,
false );
1910 fputs( data.c_str(), file );
1923 if( exportPlaceFile(
true,
false, fn.GetFullPath() ) )
1925 m_reporter->Report( wxString::Format(
_(
"Wrote front position data to '%s'.\n" ),
1941 if( exportPlaceFile(
false,
true, fn.GetFullPath() ) )
1943 m_reporter->Report( wxString::Format(
_(
"Wrote back position data to '%s'.\n" ),
1970 if( exportPlaceFile( front, back, fn.GetFullPath() ) )
1972 m_reporter->Report( wxString::Format(
_(
"Wrote position data to '%s'.\n" ),
1992 wxString outPath_base = outPath;
2003 m_reporter->Report( wxString::Format(
_(
"Wrote front position data to '%s'.\n" ), outPath ),
2019 outPath = outPath_base;
2027 m_reporter->Report( wxString::Format(
_(
"Wrote back position data to '%s'.\n" ), outPath ),
2047 if( upgradeJob ==
nullptr )
2057 m_reporter->Report(
_(
"Output path must not conflict with existing path\n" ),
2064 m_reporter->Report(
_(
"Output path must be specified to convert legacy and non-KiCad libraries\n" ),
2074 m_reporter->Report(
_(
"Footprint library path does not exist or is not accessible\n" ),
2095 bool shouldSave = upgradeJob->
m_force;
2141 if( svgJob ==
nullptr )
2174 bool singleFpPlotted =
false;
2176 for(
const auto& [fpName, fpCacheEntry] : fpLib.
GetFootprints() )
2190 singleFpPlotted =
true;
2193 exitCode =
doFpExportSvg( svgJob, fpCacheEntry->GetFootprint().get() );
2199 if( !svgJob->
m_footprint.IsEmpty() && !singleFpPlotted )
2201 m_reporter->Report(
_(
"The given footprint could not be found to export." ) + wxS(
"\n" ),
2213 std::unique_ptr<BOARD> brd;
2216 brd->SynchronizeProperties();
2229 pad->SetLocalRatsnestVisible(
false );
2230 pad->SetNetCode( 0 );
2238 wxFileName outputFile;
2243 m_reporter->Report( wxString::Format(
_(
"Plotting footprint '%s' to '%s'\n" ),
2245 outputFile.GetFullPath() ),
2264 if( !plotter.
Plot( outputFile.GetFullPath(),
2269 wxEmptyString, wxEmptyString,
2284 if( drcJob ==
nullptr )
2300 fn.SetName( fn.GetName() + wxS(
"-drc" ) );
2329 std::unique_ptr<NETLIST>
netlist = std::make_unique<NETLIST>();
2337 bool checkParity = drcJob->
m_parity;
2338 std::string netlist_str;
2342 wxString annotateMsg =
_(
"Schematic parity tests require a fully annotated schematic." );
2343 netlist_str = annotateMsg;
2355 wxFileName schematicPath( drcJob->
m_filename );
2358 if( !schematicPath.Exists() )
2361 if( !schematicPath.Exists() )
2363 m_reporter->Report(
_(
"Failed to fetch schematic netlist for parity tests.\n" ),
2365 checkParity =
false;
2369 typedef bool ( *NETLIST_FN_PTR )(
const wxString&, std::string& );
2371 NETLIST_FN_PTR netlister =
2373 ( *netlister )( schematicPath.GetFullPath(), netlist_str );
2377 if( netlist_str == annotateMsg )
2380 checkParity =
false;
2389 _(
"Eeschema netlist" ) );
2396 m_reporter->Report(
_(
"Failed to fetch schematic netlist for parity tests.\n" ),
2398 checkParity =
false;
2401 drcEngine->SetSchematicNetlist(
netlist.get() );
2413 drcEngine->SetViolationHandler(
2414 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
2415 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
2418 aPathGenerator( marker );
2419 commit.
Add( marker );
2425 drcEngine->ClearViolationHandler();
2432 std::shared_ptr<DRC_ITEMS_PROVIDER> markersProvider = std::make_shared<DRC_ITEMS_PROVIDER>(
2435 std::shared_ptr<DRC_ITEMS_PROVIDER> ratsnestProvider =
2438 std::shared_ptr<DRC_ITEMS_PROVIDER> fpWarningsProvider =
2441 markersProvider->SetSeverities( drcJob->
m_severity );
2442 ratsnestProvider->SetSeverities( drcJob->
m_severity );
2443 fpWarningsProvider->SetSeverities( drcJob->
m_severity );
2445 m_reporter->Report( wxString::Format(
_(
"Found %d violations\n" ),
2446 markersProvider->GetCount() ),
2448 m_reporter->Report( wxString::Format(
_(
"Found %d unconnected items\n" ),
2449 ratsnestProvider->GetCount() ),
2454 m_reporter->Report( wxString::Format(
_(
"Found %d schematic parity issues\n" ),
2455 fpWarningsProvider->GetCount() ),
2459 DRC_REPORT reportWriter( brd, units, markersProvider, ratsnestProvider, fpWarningsProvider );
2461 bool wroteReport =
false;
2470 m_reporter->Report( wxString::Format(
_(
"Unable to save DRC report to %s\n" ), outPath ),
2475 m_reporter->Report( wxString::Format(
_(
"Saved DRC Report to %s\n" ), outPath ),
2494 if( markersProvider->GetCount() > 0 || ratsnestProvider->GetCount() > 0
2495 || fpWarningsProvider->GetCount() > 0 )
2509 if( job ==
nullptr )
2523 fn.SetName( fn.GetName() );
2537 std::map<std::string, UTF8> props;
2539 props[
"sigfig"] = wxString::Format(
"%d", job->
m_precision );
2552 bomRev = bomSettings.
bomRev;
2554 if( bomRev.IsEmpty() )
2558 if( !bomRev.IsEmpty() )
2559 props[
"bomrev"] = bomRev;
2561 wxString tempFile = wxFileName::CreateTempFileName( wxS(
"pcbnew_ipc" ) );
2566 pi->SaveBoard( tempFile, brd, &props );
2570 m_reporter->Report( wxString::Format(
_(
"Error generating IPC-2581 file '%s'.\n%s" ),
2575 wxRemoveFile( tempFile );
2582 wxFileName tempfn = outPath;
2584 wxFileName zipfn = tempFile;
2585 zipfn.SetExt(
"zip" );
2588 wxFFileOutputStream fnout( zipfn.GetFullPath() );
2592 if( FILE* fp = fnout.GetFile()->fp() )
2595 wxZipOutputStream
zip( fnout );
2596 wxFFileInputStream fnin( tempFile );
2598 zip.PutNextEntry( tempfn.GetFullName() );
2602 wxRemoveFile( tempFile );
2603 tempFile = zipfn.GetFullPath();
2607 if( !wxRenameFile( tempFile, outPath ) )
2609 m_reporter->Report( wxString::Format(
_(
"Error generating IPC-2581 file '%s'.\n"
2610 "Failed to rename temporary file '%s." ),
2624 if( job ==
nullptr )
2635 fn.SetName( fn.GetName() );
2651 bool success = exporter.
Write( outPath );
2670 if( job ==
nullptr )
2691 fn.SetName( fn.GetName() + wxS(
"-odb" ) );
2732 if( job ==
nullptr )
2735 bool shouldSave = job->
m_force;
2757 wxString::Format(
_(
"Error saving board file '%s'.\n%s" ), job->
m_filename, ioe.
What().GetData() );
2771 if( aDrawingSheet && !aDrawingSheet->IsEmpty() )
2799 return drawingSheet;
2806 if( aSheetPath.IsEmpty() )
2810 [&](
const wxString&
path ) ->
bool
2819 { aBrd->GetEmbeddedFiles() } );
2824 m_reporter->Report( wxString::Format(
_(
"Error loading drawing sheet '%s'." ),
2826 + wxS(
"\n" ) + msg + wxS(
"\n" ),
2834 if( loadSheet( aSheetPath ) )
2889 m_reporter->Report( wxString::Format(
_(
"Unable to determine file format for '%s'\n" ),
2898 m_reporter->Report( wxString::Format(
_(
"Input file not found: '%s'\n" ),
2907 if( outputPath.IsEmpty() )
2911 outputPath = fn.GetFullPath();
2914 BOARD* board =
nullptr;
2916 std::vector<wxString> warnings;
2924 m_reporter->Report( wxString::Format(
_(
"No plugin found for file type '%s'\n" ),
2930 m_reporter->Report( wxString::Format(
_(
"Importing '%s' using %s format...\n" ),
2934 board = pi->LoadBoard( job->
m_inputFile,
nullptr,
nullptr,
nullptr );
2944 kicadPlugin->SaveBoard( outputPath, board );
2946 m_reporter->Report( wxString::Format(
_(
"Successfully saved imported board to '%s'\n" ),
2954 wxFileName outputFn( outputPath );
2957 size_t footprintCount = board->
Footprints().size();
2958 size_t trackCount = 0;
2959 size_t viaCount = 0;
2960 size_t zoneCount = board->
Zones().size();
2971 nlohmann::json layerMappings = nlohmann::json::object();
2978 layerMappings[layerName.ToStdString()] = {
2979 {
"kicad_layer",
LSET::Name( layer ).ToStdString() },
2980 {
"method",
"auto" }
2986 nlohmann::json report;
2988 report[
"source_file"] = inputFn.GetFullName().ToStdString();
2989 report[
"source_format"] = formatName.ToStdString();
2990 report[
"output_file"] = outputFn.GetFullName().ToStdString();
2991 report[
"layer_mapping"] = layerMappings;
2992 report[
"statistics"] = {
2993 {
"footprints", footprintCount },
2994 {
"tracks", trackCount },
2995 {
"vias", viaCount },
2996 {
"zones", zoneCount }
2999 nlohmann::json warningsJson = nlohmann::json::array();
3001 for(
const wxString& warning : warnings )
3002 warningsJson.push_back( warning.ToStdString() );
3004 report[
"warnings"] = warningsJson;
3005 report[
"errors"] = nlohmann::json::array();
3007 wxString reportOutput = wxString::FromUTF8( report.dump( 2 ) );
3013 if( file.IsOpened() )
3015 file.Write( reportOutput );
3028 text += wxString::Format( wxS(
"Import Report\n" ) );
3029 text += wxString::Format( wxS(
"=============\n\n" ) );
3030 text += wxString::Format( wxS(
"Source file: %s\n" ), inputFn.GetFullName() );
3031 text += wxString::Format( wxS(
"Source format: %s\n" ), formatName );
3032 text += wxString::Format( wxS(
"Output file: %s\n\n" ), outputFn.GetFullName() );
3033 text += wxS(
"Statistics:\n" );
3034 text += wxString::Format( wxS(
" Footprints: %zu\n" ), footprintCount );
3035 text += wxString::Format( wxS(
" Tracks: %zu\n" ), trackCount );
3036 text += wxString::Format( wxS(
" Vias: %zu\n" ), viaCount );
3037 text += wxString::Format( wxS(
" Zones: %zu\n" ), zoneCount );
3039 if( !warnings.empty() )
3041 text += wxS(
"\nWarnings:\n" );
3043 for(
const wxString& warning : warnings )
3044 text += wxString::Format( wxS(
" - %s\n" ), warning );
3051 if( file.IsOpened() )
3068 m_reporter->Report( wxString::Format(
_(
"Error during import: %s\n" ), ioe.
What() ),
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< DRC_ENGINE > m_DRCEngine
const VECTOR2I & GetAuxOrigin() const
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.
int GetFileFormatVersionAtLoad() const
const PCB_PLOT_PARAMS & GetPlotOptions() const
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
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 void GenerateODBPPFiles(const JOB_EXPORT_PCB_ODB &aJob, BOARD *aBoard, PCB_EDIT_FRAME *aParentFrame=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr, REPORTER *aErrorReporter=nullptr)
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 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.
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
IPC2581_VERSION m_version
ODB_COMPRESSION m_compressionMode
@ 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
bool m_reportAllTrackErrors
Job to import a non-KiCad PCB file to KiCad format.
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
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.
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.
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 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 JobExportDxf(JOB *aJob)
int JobExportPdf(JOB *aJob)
int JobExportDrill(JOB *aJob)
int JobExportSvg(JOB *aJob)
void loadOverrideDrawingSheet(BOARD *brd, const wxString &aSheetPath)
PCBNEW_JOBS_HANDLER(KIWAY *aKiway)
TOOL_MANAGER * getToolManager(BOARD *aBrd)
int JobExportGerbers(JOB *aJob)
int JobExportGencad(JOB *aJob)
BOARD * getBoard(const wxString &aPath=wxEmptyString)
int JobExportIpc2581(JOB *aJob)
virtual ~PCBNEW_JOBS_HANDLER()
std::unique_ptr< TOOL_MANAGER > m_toolManager
LSEQ convertLayerArg(wxString &aLayerString, BOARD *aBoard) const
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.
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 const wxString ShowType(PCB_FILE_T aFileType)
Return a brief name for a plugin given aFileType enum.
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)
static void PlotJobToPlotOpts(PCB_PLOT_PARAMS &aOpts, JOB_EXPORT_PCB_PLOT *aJob, REPORTER &aReporter)
Translate a JOB to PCB_PLOT_PARAMS.
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 DNP filtering.
Base plotter engine class.
wxString m_BoardDrawingSheetFile
PcbNew params.
struct IP2581_BOM m_IP2581Bom
Layer pair list for the board.
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,...
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only 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.
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 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 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 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 VrmlFileExtension
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.
@ KIFACE_NETLIST_SCHEMATIC
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.
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
#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 DRILL_PRECISION precisionListForInches(2, 4)
static DRILL_PRECISION precisionListForMetric(3, 3)
SETTINGS_MANAGER * GetSettingsManager()
BOARD * CreateEmptyBoard()
Construct a default BOARD with a temporary (no filename) project.
bool SaveBoard(wxString &aFileName, BOARD *aBoard, PCB_IO_MGR::PCB_FILE_T aFormat, bool aSkipSettings)
BOARD * LoadBoard(const wxString &aFileName, bool aSetActive)
Loads a board from file This function identifies the file type by extension and determines the correc...
const wxString GetGerberProtelExtension(int aLayer)
void BuildPlotFileName(wxFileName *aFilename, const wxString &aOutputDir, const wxString &aSuffix, const wxString &aExtension)
Complete a plot filename.
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)
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 subtractHolesFromCopperAreas
bool subtractHolesFromBoardArea
bool excludeFootprintsWithoutPads
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
wxString bomRev
Explicit BOM revision override set by user.
wxString schRevision
Auto-propagated schematic title block revision.
Implement a participant in the KIWAY alchemy.
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.