KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcbnew_jobs_handler.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2022 Mark Roszko <[email protected]>
5 * Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <wx/dir.h>
22#include "pcbnew_jobs_handler.h"
23#include <board_commit.h>
25#include <drc/drc_item.h>
26#include <drc/drc_report.h>
30#include <jobs/job_fp_upgrade.h>
40#include <jobs/job_pcb_render.h>
41#include <jobs/job_pcb_drc.h>
42#include <lset.h>
43#include <cli/exit_codes.h>
49#include <tool/tool_manager.h>
50#include <tools/drc_tool.h>
51#include <filename_resolver.h>
56#include <kiface_base.h>
57#include <macros.h>
58#include <pad.h>
59#include <pcb_marker.h>
62#include <kiface_ids.h>
65#include <pcbnew_settings.h>
66#include <pcbplot.h>
67#include <pgm_base.h>
70#include <project_pcb.h>
72#include <reporter.h>
73#include <string_utf8_map.h>
75#include <export_vrml.h>
76#include <wx/wfstream.h>
77#include <wx/zipstrm.h>
78
80
81
82#ifdef _WIN32
83#ifdef TRANSPARENT
84#undef TRANSPARENT
85#endif
86#endif
87
88
90 JOB_DISPATCHER( aKiway )
91{
92 Register( "3d", std::bind( &PCBNEW_JOBS_HANDLER::JobExportStep, this, std::placeholders::_1 ) );
93 Register( "render", std::bind( &PCBNEW_JOBS_HANDLER::JobExportRender, this, std::placeholders::_1 ) );
94 Register( "svg", std::bind( &PCBNEW_JOBS_HANDLER::JobExportSvg, this, std::placeholders::_1 ) );
95 Register( "dxf", std::bind( &PCBNEW_JOBS_HANDLER::JobExportDxf, this, std::placeholders::_1 ) );
96 Register( "pdf", std::bind( &PCBNEW_JOBS_HANDLER::JobExportPdf, this, std::placeholders::_1 ) );
97 Register( "gerber",
98 std::bind( &PCBNEW_JOBS_HANDLER::JobExportGerber, this, std::placeholders::_1 ) );
99 Register( "gerbers",
100 std::bind( &PCBNEW_JOBS_HANDLER::JobExportGerbers, this, std::placeholders::_1 ) );
101 Register( "drill",
102 std::bind( &PCBNEW_JOBS_HANDLER::JobExportDrill, this, std::placeholders::_1 ) );
103 Register( "pos", std::bind( &PCBNEW_JOBS_HANDLER::JobExportPos, this, std::placeholders::_1 ) );
104 Register( "fpupgrade",
105 std::bind( &PCBNEW_JOBS_HANDLER::JobExportFpUpgrade, this, std::placeholders::_1 ) );
106 Register( "fpsvg",
107 std::bind( &PCBNEW_JOBS_HANDLER::JobExportFpSvg, this, std::placeholders::_1 ) );
108 Register( "drc", std::bind( &PCBNEW_JOBS_HANDLER::JobExportDrc, this, std::placeholders::_1 ) );
109 Register( "ipc2581",
110 std::bind( &PCBNEW_JOBS_HANDLER::JobExportIpc2581, this, std::placeholders::_1 ) );
111}
112
113
115{
116 JOB_EXPORT_PCB_3D* aStepJob = dynamic_cast<JOB_EXPORT_PCB_3D*>( aJob );
117
118 if( aStepJob == nullptr )
120
121 if( aJob->IsCli() )
122 m_reporter->Report( _( "Loading board\n" ), RPT_SEVERITY_INFO );
123
124 BOARD* brd = LoadBoard( aStepJob->m_filename, true );
125 brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
127
128 if( aStepJob->m_outputFile.IsEmpty() )
129 {
130 wxFileName fn = brd->GetFileName();
131 fn.SetName( fn.GetName() );
132
133 switch( aStepJob->m_format )
134 {
136 break;
138 break;
140 break;
142 break;
144 break;
145 default:
146 return CLI::EXIT_CODES::ERR_UNKNOWN; // shouldnt have gotten here
147 }
148
149 aStepJob->m_outputFile = fn.GetFullName();
150 }
151
153 {
154
155 double scale = 0.0;
156 switch ( aStepJob->m_vrmlUnits )
157 {
159 case JOB_EXPORT_PCB_3D::VRML_UNITS::METERS: scale = 0.001; break;
160 case JOB_EXPORT_PCB_3D::VRML_UNITS::TENTHS: scale = 10.0 / 25.4; break;
161 case JOB_EXPORT_PCB_3D::VRML_UNITS::INCHES: scale = 1.0 / 25.4; break;
162 }
163
164 EXPORTER_VRML vrmlExporter( brd );
165 wxString messages;
166
167 double originX = pcbIUScale.IUTomm( aStepJob->m_xOrigin );
168 double originY = pcbIUScale.IUTomm( aStepJob->m_yOrigin );
169
170 if( !aStepJob->m_hasUserOrigin )
171 {
172 BOX2I bbox = brd->ComputeBoundingBox( true, false );
173 originX = pcbIUScale.IUTomm( bbox.GetCenter().x );
174 originY = pcbIUScale.IUTomm( bbox.GetCenter().y );
175 }
176
177 bool success = vrmlExporter.ExportVRML_File(
178 brd->GetProject(), &messages, aStepJob->m_outputFile, scale,
179 aStepJob->m_includeUnspecified, aStepJob->m_includeDNP,
180 !aStepJob->m_vrmlModelDir.IsEmpty(), aStepJob->m_vrmlRelativePaths,
181 aStepJob->m_vrmlModelDir, originX, originY );
182
183 if ( success )
184 {
185 m_reporter->Report( wxString::Format( _( "Successfully exported VRML to %s" ),
186 aStepJob->m_outputFile ),
188 }
189 else
190 {
191 m_reporter->Report( _( "Error exporting VRML" ), RPT_SEVERITY_ERROR );
193 }
194 }
195 else
196 {
198 params.m_exportBoardBody = aStepJob->m_exportBoardBody;
199 params.m_exportComponents = aStepJob->m_exportComponents;
200 params.m_exportTracksVias = aStepJob->m_exportTracks;
201 params.m_exportPads = aStepJob->m_exportPads;
202 params.m_exportZones = aStepJob->m_exportZones;
203 params.m_exportInnerCopper = aStepJob->m_exportInnerCopper;
204 params.m_exportSilkscreen = aStepJob->m_exportSilkscreen;
205 params.m_exportSoldermask = aStepJob->m_exportSoldermask;
206 params.m_fuseShapes = aStepJob->m_fuseShapes;
208 params.m_includeDNP = aStepJob->m_includeDNP;
210 params.m_overwrite = aStepJob->m_overwrite;
211 params.m_substModels = aStepJob->m_substModels;
212 params.m_origin = VECTOR2D( aStepJob->m_xOrigin, aStepJob->m_yOrigin );
213 params.m_useDrillOrigin = aStepJob->m_useDrillOrigin;
214 params.m_useGridOrigin = aStepJob->m_useGridOrigin;
215 params.m_boardOnly = aStepJob->m_boardOnly;
216 params.m_optimizeStep = aStepJob->m_optimizeStep;
217 params.m_netFilter = aStepJob->m_netFilter;
218
219 switch( aStepJob->m_format )
220 {
223 break;
226 break;
229 break;
232 break;
233 default:
234 return CLI::EXIT_CODES::ERR_UNKNOWN; // shouldnt have gotten here
235 }
236
237 EXPORTER_STEP stepExporter( brd, params );
238 stepExporter.m_outputFile = aStepJob->m_outputFile;
239
240 if( !stepExporter.Export() )
242 }
243
244 return CLI::EXIT_CODES::OK;
245}
246
247
249{
250 JOB_PCB_RENDER* aRenderJob = dynamic_cast<JOB_PCB_RENDER*>( aJob );
251
252 if( aRenderJob == nullptr )
254
255 if( aJob->IsCli() )
256 m_reporter->Report( _( "Loading board\n" ), RPT_SEVERITY_INFO );
257
258 BOARD* brd = LoadBoard( aRenderJob->m_filename, true );
259 brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
261
262 BOARD_ADAPTER boardAdapter;
263
264 boardAdapter.SetBoard( brd );
265 boardAdapter.m_IsBoardView = false;
266 boardAdapter.m_IsPreviewer =
267 true; // Force display 3D models, regardless the 3D viewer options
268
271
272 if( aRenderJob->m_quality == JOB_PCB_RENDER::QUALITY::BASIC )
273 {
274 // Silkscreen is pixelated without antialiasing
276
277 cfg->m_Render.raytrace_backfloor = false;
279
281 cfg->m_Render.raytrace_reflections = false;
282 cfg->m_Render.raytrace_shadows = false;
283
284 // Better colors
286
287 // Tracks below soldermask are not visible without refractions
288 cfg->m_Render.raytrace_refractions = true;
290 }
291 else if( aRenderJob->m_quality == JOB_PCB_RENDER::QUALITY::HIGH )
292 {
294 cfg->m_Render.raytrace_backfloor = true;
297 cfg->m_Render.raytrace_reflections = true;
298 cfg->m_Render.raytrace_shadows = true;
299 cfg->m_Render.raytrace_refractions = true;
301 }
302
303 if( aRenderJob->m_floor )
304 {
305 cfg->m_Render.raytrace_backfloor = true;
306 cfg->m_Render.raytrace_shadows = true;
308 }
309
310 cfg->m_CurrentPreset = aRenderJob->m_colorPreset;
311 boardAdapter.m_Cfg = cfg;
312
315 && aRenderJob->m_format == JOB_PCB_RENDER::FORMAT::PNG ) )
316 {
317 boardAdapter.m_ColorOverrides[LAYER_3D_BACKGROUND_TOP] = COLOR4D( 1.0, 1.0, 1.0, 0.0 );
318 boardAdapter.m_ColorOverrides[LAYER_3D_BACKGROUND_BOTTOM] = COLOR4D( 1.0, 1.0, 1.0, 0.0 );
319 }
320
322
323 static std::map<JOB_PCB_RENDER::SIDE, VIEW3D_TYPE> s_viewCmdMap = {
324 { JOB_PCB_RENDER::SIDE::TOP, VIEW3D_TYPE::VIEW3D_TOP },
325 { JOB_PCB_RENDER::SIDE::BOTTOM, VIEW3D_TYPE::VIEW3D_BOTTOM },
326 { JOB_PCB_RENDER::SIDE::LEFT, VIEW3D_TYPE::VIEW3D_LEFT },
327 { JOB_PCB_RENDER::SIDE::RIGHT, VIEW3D_TYPE::VIEW3D_RIGHT },
328 { JOB_PCB_RENDER::SIDE::FRONT, VIEW3D_TYPE::VIEW3D_FRONT },
329 { JOB_PCB_RENDER::SIDE::BACK, VIEW3D_TYPE::VIEW3D_BACK },
330 };
331
332 PROJECTION_TYPE projection =
333 aRenderJob->m_perspective ? PROJECTION_TYPE::PERSPECTIVE : PROJECTION_TYPE::ORTHO;
334
335 wxSize windowSize( aRenderJob->m_width, aRenderJob->m_height );
336 TRACK_BALL camera( 2 * RANGE_SCALE_3D );
337
338 camera.SetProjection( projection );
339 camera.SetCurWindowSize( windowSize );
340
341 RENDER_3D_RAYTRACE_RAM raytrace( boardAdapter, camera );
342 raytrace.SetCurWindowSize( windowSize );
343
344 for( bool first = true; raytrace.Redraw( false, m_reporter, m_reporter ); first = false )
345 {
346 if( first )
347 {
348 const float cmTo3D = boardAdapter.BiuTo3dUnits() * pcbIUScale.mmToIU( 10.0 );
349
350 // First redraw resets lookat point to the board center, so set up the camera here
351 camera.ViewCommand_T1( s_viewCmdMap[aRenderJob->m_side] );
352
353 camera.SetLookAtPos_T1(
354 camera.GetLookAtPos_T1()
355 + SFVEC3F( aRenderJob->m_pivot.x, aRenderJob->m_pivot.y, aRenderJob->m_pivot.z )
356 * cmTo3D );
357
358 camera.Pan_T1(
359 SFVEC3F( aRenderJob->m_pan.x, aRenderJob->m_pan.y, aRenderJob->m_pan.z ) );
360
361 camera.Zoom_T1( aRenderJob->m_zoom );
362
363 camera.RotateX_T1( DEG2RAD( aRenderJob->m_rotation.x ) );
364 camera.RotateY_T1( DEG2RAD( aRenderJob->m_rotation.y ) );
365 camera.RotateZ_T1( DEG2RAD( aRenderJob->m_rotation.z ) );
366
367 camera.Interpolate( 1.0f );
368 camera.SetT0_and_T1_current_T();
369 camera.ParametersChanged();
370 }
371 }
372
373 GLubyte* rgbaBuffer = raytrace.GetBuffer();
374 wxSize realSize = raytrace.GetRealBufferSize();
375 bool success = !!rgbaBuffer;
376
377 if( rgbaBuffer )
378 {
379 const unsigned int wxh = realSize.x * realSize.y;
380
381 unsigned char* rgbBuffer = (unsigned char*) malloc( wxh * 3 );
382 unsigned char* alphaBuffer = (unsigned char*) malloc( wxh );
383
384 unsigned char* rgbaPtr = rgbaBuffer;
385 unsigned char* rgbPtr = rgbBuffer;
386 unsigned char* alphaPtr = alphaBuffer;
387
388 for( int y = 0; y < realSize.y; y++ )
389 {
390 for( int x = 0; x < realSize.x; x++ )
391 {
392 rgbPtr[0] = rgbaPtr[0];
393 rgbPtr[1] = rgbaPtr[1];
394 rgbPtr[2] = rgbaPtr[2];
395 alphaPtr[0] = rgbaPtr[3];
396
397 rgbaPtr += 4;
398 rgbPtr += 3;
399 alphaPtr += 1;
400 }
401 }
402
403 wxImage image( realSize );
404 image.SetData( rgbBuffer );
405 image.SetAlpha( alphaBuffer );
406 image = image.Mirror( false );
407
408 image.SetOption( wxIMAGE_OPTION_QUALITY, 90 );
409 image.SaveFile( aRenderJob->m_outputFile,
410 aRenderJob->m_format == JOB_PCB_RENDER::FORMAT::PNG ? wxBITMAP_TYPE_PNG
411 : wxBITMAP_TYPE_JPEG );
412 }
413
414 m_reporter->Report( wxString::Format( _( "Actual image size: %dx%d" ), realSize.x, realSize.y )
415 + wxS( "\n" ),
417
418 if( success )
419 m_reporter->Report( _( "Successfully created 3D render image" ) + wxS( "\n" ),
421 else
422 m_reporter->Report( _( "Error creating 3D render image" ) + wxS( "\n" ),
424
425 return CLI::EXIT_CODES::OK;
426}
427
428
430{
431 JOB_EXPORT_PCB_SVG* aSvgJob = dynamic_cast<JOB_EXPORT_PCB_SVG*>( aJob );
432
433 if( aSvgJob == nullptr )
435
436 PCB_PLOT_SVG_OPTIONS svgPlotOptions;
437 svgPlotOptions.m_blackAndWhite = aSvgJob->m_blackAndWhite;
438 svgPlotOptions.m_colorTheme = aSvgJob->m_colorTheme;
439 svgPlotOptions.m_outputFile = aSvgJob->m_outputFile;
440 svgPlotOptions.m_mirror = aSvgJob->m_mirror;
441 svgPlotOptions.m_negative = aSvgJob->m_negative;
442 svgPlotOptions.m_pageSizeMode = aSvgJob->m_pageSizeMode;
443 svgPlotOptions.m_printMaskLayer = aSvgJob->m_printMaskLayer;
444 svgPlotOptions.m_plotFrame = aSvgJob->m_plotDrawingSheet;
445 svgPlotOptions.m_sketchPadsOnFabLayers = aSvgJob->m_sketchPadsOnFabLayers;
446 svgPlotOptions.m_drillShapeOption = aSvgJob->m_drillShapeOption;
447
448 if( aJob->IsCli() )
449 m_reporter->Report( _( "Loading board\n" ), RPT_SEVERITY_INFO );
450
451 BOARD* brd = LoadBoard( aSvgJob->m_filename, true );
453 brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
455
456 if( aJob->IsCli() )
457 {
458 if( EXPORT_SVG::Plot( brd, svgPlotOptions ) )
459 m_reporter->Report( _( "Successfully created svg file" ) + wxS( "\n" ), RPT_SEVERITY_INFO );
460 else
461 m_reporter->Report( _( "Error creating svg file" ) + wxS( "\n" ), RPT_SEVERITY_ERROR );
462 }
463
464 return CLI::EXIT_CODES::OK;
465}
466
467
469{
470 JOB_EXPORT_PCB_DXF* aDxfJob = dynamic_cast<JOB_EXPORT_PCB_DXF*>( aJob );
471
472 if( aDxfJob == nullptr )
474
475 if( aJob->IsCli() )
476 m_reporter->Report( _( "Loading board\n" ), RPT_SEVERITY_INFO );
477
478 BOARD* brd = LoadBoard( aDxfJob->m_filename, true );
480 brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
482
483 if( aDxfJob->m_outputFile.IsEmpty() )
484 {
485 wxFileName fn = brd->GetFileName();
486 fn.SetName( fn.GetName() );
487 fn.SetExt( GetDefaultPlotExtension( PLOT_FORMAT::DXF ) );
488
489 aDxfJob->m_outputFile = fn.GetFullName();
490 }
491
492 PCB_PLOT_PARAMS plotOpts;
493 plotOpts.SetFormat( PLOT_FORMAT::DXF );
494
496 plotOpts.SetUseAuxOrigin( aDxfJob->m_useDrillOrigin );
497
499 plotOpts.SetDXFPlotUnits( DXF_UNITS::MILLIMETERS );
500 else
501 plotOpts.SetDXFPlotUnits( DXF_UNITS::INCHES );
502
503 plotOpts.SetPlotFrameRef( aDxfJob->m_plotBorderTitleBlocks );
504 plotOpts.SetPlotValue( aDxfJob->m_plotFootprintValues );
505 plotOpts.SetPlotReference( aDxfJob->m_plotRefDes );
506 plotOpts.SetLayerSelection( aDxfJob->m_printMaskLayer );
507
509 wxString layerName;
510 wxString sheetName;
511 wxString sheetPath;
512
513 if( aDxfJob->m_printMaskLayer.size() == 1 )
514 {
515 layer = aDxfJob->m_printMaskLayer.front();
516 layerName = brd->GetLayerName( layer );
517 }
518
519 if( aJob->GetVarOverrides().contains( wxT( "LAYER" ) ) )
520 layerName = aJob->GetVarOverrides().at( wxT( "LAYER" ) );
521
522 if( aJob->GetVarOverrides().contains( wxT( "SHEETNAME" ) ) )
523 sheetName = aJob->GetVarOverrides().at( wxT( "SHEETNAME" ) );
524
525 if( aJob->GetVarOverrides().contains( wxT( "SHEETPATH" ) ) )
526 sheetPath = aJob->GetVarOverrides().at( wxT( "SHEETPATH" ) );
527
528 DXF_PLOTTER* plotter = (DXF_PLOTTER*) StartPlotBoard( brd, &plotOpts, layer, layerName,
529 aDxfJob->m_outputFile, sheetName,
530 sheetPath );
531
532 if( plotter )
533 {
534 PlotBoardLayers( brd, plotter, aDxfJob->m_printMaskLayer, plotOpts );
535 plotter->EndPlot();
536 }
537
538 delete plotter;
539
540 return CLI::EXIT_CODES::OK;
541}
542
543
545{
546 JOB_EXPORT_PCB_PDF* aPdfJob = dynamic_cast<JOB_EXPORT_PCB_PDF*>( aJob );
547
548 if( aPdfJob == nullptr )
550
551 if( aJob->IsCli() )
552 m_reporter->Report( _( "Loading board\n" ), RPT_SEVERITY_INFO );
553
554 BOARD* brd = LoadBoard( aPdfJob->m_filename, true );
556 brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
558
559 if( aPdfJob->m_outputFile.IsEmpty() )
560 {
561 wxFileName fn = brd->GetFileName();
562 fn.SetName( fn.GetName() );
563 fn.SetExt( GetDefaultPlotExtension( PLOT_FORMAT::PDF ) );
564
565 aPdfJob->m_outputFile = fn.GetFullName();
566 }
567
568 PCB_PLOT_PARAMS plotOpts;
569 plotOpts.SetFormat( PLOT_FORMAT::PDF );
570
571 plotOpts.SetPlotFrameRef( aPdfJob->m_plotBorderTitleBlocks );
572 plotOpts.SetPlotValue( aPdfJob->m_plotFootprintValues );
573 plotOpts.SetPlotReference( aPdfJob->m_plotRefDes );
574
575 plotOpts.SetLayerSelection( aPdfJob->m_printMaskLayer );
576
578 plotOpts.SetColorSettings( mgr.GetColorSettings( aPdfJob->m_colorTheme ) );
579 plotOpts.SetMirror( aPdfJob->m_mirror );
580 plotOpts.SetBlackAndWhite( aPdfJob->m_blackAndWhite );
581 plotOpts.SetNegative( aPdfJob->m_negative );
582
583 if( aPdfJob->m_sketchPadsOnFabLayers )
584 {
585 plotOpts.SetSketchPadsOnFabLayers( true );
586 plotOpts.SetPlotPadNumbers( true );
587 }
588
589 switch( aPdfJob->m_drillShapeOption )
590 {
591 default:
592 case 0: plotOpts.SetDrillMarksType( DRILL_MARKS::NO_DRILL_SHAPE ); break;
593 case 1: plotOpts.SetDrillMarksType( DRILL_MARKS::SMALL_DRILL_SHAPE ); break;
594 case 2: plotOpts.SetDrillMarksType( DRILL_MARKS::FULL_DRILL_SHAPE ); break;
595 }
596
598 wxString layerName;
599 wxString sheetName;
600 wxString sheetPath;
601
602 if( aPdfJob->m_printMaskLayer.size() == 1 )
603 {
604 layer = aPdfJob->m_printMaskLayer.front();
605 layerName = brd->GetLayerName( layer );
606 }
607
608 if( aPdfJob->GetVarOverrides().contains( wxT( "LAYER" ) ) )
609 layerName = aPdfJob->GetVarOverrides().at( wxT( "LAYER" ) );
610
611 if( aPdfJob->GetVarOverrides().contains( wxT( "SHEETNAME" ) ) )
612 sheetName = aPdfJob->GetVarOverrides().at( wxT( "SHEETNAME" ) );
613
614 if( aPdfJob->GetVarOverrides().contains( wxT( "SHEETPATH" ) ) )
615 sheetPath = aPdfJob->GetVarOverrides().at( wxT( "SHEETPATH" ) );
616
617 PDF_PLOTTER* plotter = (PDF_PLOTTER*) StartPlotBoard( brd, &plotOpts, layer, layerName,
618 aPdfJob->m_outputFile, sheetName,
619 sheetPath );
620
621 if( plotter )
622 {
623 PlotBoardLayers( brd, plotter, aPdfJob->m_printMaskLayer, plotOpts );
624 PlotInteractiveLayer( brd, plotter, plotOpts );
625 plotter->EndPlot();
626 }
627
628 delete plotter;
629
630 return CLI::EXIT_CODES::OK;
631}
632
633
635{
636 int exitCode = CLI::EXIT_CODES::OK;
637 JOB_EXPORT_PCB_GERBERS* aGerberJob = dynamic_cast<JOB_EXPORT_PCB_GERBERS*>( aJob );
638
639 if( aGerberJob == nullptr )
641
642 if( aJob->IsCli() )
643 m_reporter->Report( _( "Loading board\n" ), RPT_SEVERITY_INFO );
644
645 BOARD* brd = LoadBoard( aGerberJob->m_filename, true );
646 loadOverrideDrawingSheet( brd, aGerberJob->m_drawingSheet );
647 brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
649
650 PCB_PLOT_PARAMS boardPlotOptions = brd->GetPlotOptions();
651 LSET plotOnAllLayersSelection = boardPlotOptions.GetPlotOnAllLayersSelection();
652 GERBER_JOBFILE_WRITER jobfile_writer( brd );
653
654 wxString fileExt;
655
656 if( aGerberJob->m_useBoardPlotParams )
657 {
658 // The board plot options are saved with all copper layers enabled, even those that don't
659 // exist in the current stackup. This is done so the layers are automatically enabled in the plot
660 // dialog when the user enables them. We need to filter out these not-enabled layers here so
661 // we don't plot 32 layers when we only have 4, etc.
662 LSET plotLayers = ( boardPlotOptions.GetLayerSelection() & LSET::AllNonCuMask() )
663 | ( brd->GetEnabledLayers() & LSET::AllCuMask() );
664 aGerberJob->m_printMaskLayer = plotLayers.SeqStackupForPlotting();
665 aGerberJob->m_layersIncludeOnAll = boardPlotOptions.GetPlotOnAllLayersSelection();
666 }
667 else
668 {
669 // default to the board enabled layers
670 if( aGerberJob->m_printMaskLayer.empty() )
672
673 if( aGerberJob->m_layersIncludeOnAllSet )
674 aGerberJob->m_layersIncludeOnAll = plotOnAllLayersSelection;
675 }
676
677 for( PCB_LAYER_ID layer : LSET( aGerberJob->m_printMaskLayer ).UIOrder() )
678 {
679 LSEQ plotSequence;
680
681 // Base layer always gets plotted first.
682 plotSequence.push_back( layer );
683
684 // Now all the "include on all" layers
685 for( PCB_LAYER_ID layer_all : aGerberJob->m_layersIncludeOnAll.UIOrder() )
686 {
687 // Don't plot the same layer more than once;
688 if( find( plotSequence.begin(), plotSequence.end(), layer_all ) != plotSequence.end() )
689 continue;
690
691 plotSequence.push_back( layer_all );
692 }
693
694 // Pick the basename from the board file
695 wxFileName fn( brd->GetFileName() );
696 wxString layerName = brd->GetLayerName( layer );
697 wxString sheetName;
698 wxString sheetPath;
699 PCB_PLOT_PARAMS plotOpts;
700
701 if( aGerberJob->m_useBoardPlotParams )
702 plotOpts = boardPlotOptions;
703 else
704 populateGerberPlotOptionsFromJob( plotOpts, aGerberJob );
705
706 if( plotOpts.GetUseGerberProtelExtensions() )
707 fileExt = GetGerberProtelExtension( layer );
708 else
710
711 BuildPlotFileName( &fn, aGerberJob->m_outputFile, layerName, fileExt );
712 wxString fullname = fn.GetFullName();
713
714 jobfile_writer.AddGbrFile( layer, fullname );
715
716 if( aJob->GetVarOverrides().contains( wxT( "LAYER" ) ) )
717 layerName = aJob->GetVarOverrides().at( wxT( "LAYER" ) );
718
719 if( aJob->GetVarOverrides().contains( wxT( "SHEETNAME" ) ) )
720 sheetName = aJob->GetVarOverrides().at( wxT( "SHEETNAME" ) );
721
722 if( aJob->GetVarOverrides().contains( wxT( "SHEETPATH" ) ) )
723 sheetPath = aJob->GetVarOverrides().at( wxT( "SHEETPATH" ) );
724
725 // We are feeding it one layer at the start here to silence a logic check
726 GERBER_PLOTTER* plotter = (GERBER_PLOTTER*) StartPlotBoard( brd, &plotOpts, layer,
727 layerName, fn.GetFullPath(),
728 sheetName, sheetPath );
729
730 if( plotter )
731 {
732 m_reporter->Report( wxString::Format( _( "Plotted to '%s'.\n" ), fn.GetFullPath() ),
734 PlotBoardLayers( brd, plotter, plotSequence, plotOpts );
735 plotter->EndPlot();
736 }
737 else
738 {
739 m_reporter->Report( wxString::Format( _( "Failed to plot to '%s'.\n" ),
740 fn.GetFullPath() ),
743 }
744
745 delete plotter;
746 }
747
748 wxFileName fn( aGerberJob->m_filename );
749
750 // Build gerber job file from basename
751 BuildPlotFileName( &fn, aGerberJob->m_outputFile, wxT( "job" ),
753 jobfile_writer.CreateJobFile( fn.GetFullPath() );
754
755 return exitCode;
756}
757
758
761{
762 aPlotOpts.SetFormat( PLOT_FORMAT::GERBER );
763
764 aPlotOpts.SetPlotFrameRef( aJob->m_plotBorderTitleBlocks );
765 aPlotOpts.SetPlotValue( aJob->m_plotFootprintValues );
766 aPlotOpts.SetPlotReference( aJob->m_plotRefDes );
767
769
770 // Always disable plot pad holes
771 aPlotOpts.SetDrillMarksType( DRILL_MARKS::NO_DRILL_SHAPE );
772
774 aPlotOpts.SetUseGerberX2format( aJob->m_useX2Format );
776 aPlotOpts.SetUseAuxOrigin( aJob->m_useAuxOrigin );
778 aPlotOpts.SetGerberPrecision( aJob->m_precision );
779}
780
781
783{
784 int exitCode = CLI::EXIT_CODES::OK;
785 JOB_EXPORT_PCB_GERBER* aGerberJob = dynamic_cast<JOB_EXPORT_PCB_GERBER*>( aJob );
786
787 if( aGerberJob == nullptr )
789
790 if( aJob->IsCli() )
791 m_reporter->Report( _( "Loading board\n" ), RPT_SEVERITY_INFO );
792
793 BOARD* brd = LoadBoard( aGerberJob->m_filename, true );
794 brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
796
797 if( aGerberJob->m_outputFile.IsEmpty() )
798 {
799 wxFileName fn = brd->GetFileName();
800 fn.SetName( fn.GetName() );
801 fn.SetExt( GetDefaultPlotExtension( PLOT_FORMAT::GERBER ) );
802
803 aGerberJob->m_outputFile = fn.GetFullName();
804 }
805
806 PCB_PLOT_PARAMS plotOpts;
807 populateGerberPlotOptionsFromJob( plotOpts, aGerberJob );
808 plotOpts.SetLayerSelection( aGerberJob->m_printMaskLayer );
809
811 wxString layerName;
812 wxString sheetName;
813 wxString sheetPath;
814
815 if( aGerberJob->m_printMaskLayer.size() == 1 )
816 {
817 layer = aGerberJob->m_printMaskLayer.front();
818 layerName = brd->GetLayerName( layer );
819 }
820
821 if( aJob->GetVarOverrides().contains( wxT( "LAYER" ) ) )
822 layerName = aJob->GetVarOverrides().at( wxT( "LAYER" ) );
823
824 if( aJob->GetVarOverrides().contains( wxT( "SHEETNAME" ) ) )
825 sheetName = aJob->GetVarOverrides().at( wxT( "SHEETNAME" ) );
826
827 if( aJob->GetVarOverrides().contains( wxT( "SHEETPATH" ) ) )
828 sheetPath = aJob->GetVarOverrides().at( wxT( "SHEETPATH" ) );
829
830 // We are feeding it one layer at the start here to silence a logic check
831 GERBER_PLOTTER* plotter = (GERBER_PLOTTER*) StartPlotBoard( brd, &plotOpts, layer, layerName,
832 aGerberJob->m_outputFile,
833 sheetName, sheetPath );
834
835 if( plotter )
836 {
837 PlotBoardLayers( brd, plotter, aGerberJob->m_printMaskLayer, plotOpts );
838 plotter->EndPlot();
839 }
840 else
841 {
842 m_reporter->Report( wxString::Format( _( "Failed to plot to '%s'.\n" ),
843 aGerberJob->m_outputFile ),
846 }
847
848 delete plotter;
849
850 return exitCode;
851}
852
855
856
858{
859 JOB_EXPORT_PCB_DRILL* aDrillJob = dynamic_cast<JOB_EXPORT_PCB_DRILL*>( aJob );
860
861 if( aDrillJob == nullptr )
863
864 if( aJob->IsCli() )
865 m_reporter->Report( _( "Loading board\n" ), RPT_SEVERITY_INFO );
866
867 BOARD* brd = LoadBoard( aDrillJob->m_filename, true );
868
869 // ensure output dir exists
870 wxFileName fn( aDrillJob->m_outputDir + wxT( "/" ) );
871
872 if( !fn.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
873 {
874 m_reporter->Report( _( "Failed to create output directory\n" ), RPT_SEVERITY_ERROR );
876 }
877
878 std::unique_ptr<GENDRILL_WRITER_BASE> drillWriter;
879
881 drillWriter = std::make_unique<EXCELLON_WRITER>( brd );
882 else
883 drillWriter = std::make_unique<GERBER_WRITER>( brd );
884
885 VECTOR2I offset;
886
888 offset = VECTOR2I( 0, 0 );
889 else
890 offset = brd->GetDesignSettings().GetAuxOrigin();
891
892 PLOT_FORMAT mapFormat = PLOT_FORMAT::PDF;
893
894 switch( aDrillJob->m_mapFormat )
895 {
896 case JOB_EXPORT_PCB_DRILL::MAP_FORMAT::POSTSCRIPT: mapFormat = PLOT_FORMAT::POST; break;
897 case JOB_EXPORT_PCB_DRILL::MAP_FORMAT::GERBER_X2: mapFormat = PLOT_FORMAT::GERBER; break;
898 case JOB_EXPORT_PCB_DRILL::MAP_FORMAT::DXF: mapFormat = PLOT_FORMAT::DXF; break;
899 case JOB_EXPORT_PCB_DRILL::MAP_FORMAT::SVG: mapFormat = PLOT_FORMAT::SVG; break;
900 default:
901 case JOB_EXPORT_PCB_DRILL::MAP_FORMAT::PDF: mapFormat = PLOT_FORMAT::PDF; break;
902 }
903
905 {
907 switch( aDrillJob->m_zeroFormat )
908 {
911 break;
914 break;
917 break;
919 default:
921 break;
922 }
923
924 DRILL_PRECISION precision;
925
927 precision = precisionListForInches;
928 else
929 precision = precisionListForMetric;
930
931 EXCELLON_WRITER* excellonWriter = dynamic_cast<EXCELLON_WRITER*>( drillWriter.get() );
932
933 if( excellonWriter == nullptr )
935
936 excellonWriter->SetFormat( aDrillJob->m_drillUnits
938 zeroFmt, precision.m_Lhs, precision.m_Rhs );
939 excellonWriter->SetOptions( aDrillJob->m_excellonMirrorY,
940 aDrillJob->m_excellonMinimalHeader,
941 offset, aDrillJob->m_excellonCombinePTHNPTH );
942 excellonWriter->SetRouteModeForOvalHoles( aDrillJob->m_excellonOvalDrillRoute );
943 excellonWriter->SetMapFileFormat( mapFormat );
944
945 if( !excellonWriter->CreateDrillandMapFilesSet( aDrillJob->m_outputDir, true,
946 aDrillJob->m_generateMap, m_reporter ) )
947 {
949 }
950 }
952 {
953 GERBER_WRITER* gerberWriter = dynamic_cast<GERBER_WRITER*>( drillWriter.get() );
954
955 if( gerberWriter == nullptr )
957
958 // Set gerber precision: only 5 or 6 digits for mantissa are allowed
959 // (SetFormat() accept 5 or 6, and any other value set the precision to 5)
960 // the integer part precision is always 4, and units always mm
961 gerberWriter->SetFormat( aDrillJob->m_gerberPrecision );
962 gerberWriter->SetOptions( offset );
963 gerberWriter->SetMapFileFormat( mapFormat );
964
965 if( !gerberWriter->CreateDrillandMapFilesSet( aDrillJob->m_outputDir, true,
966 aDrillJob->m_generateMap, m_reporter ) )
967 {
969 }
970 }
971
972 return CLI::EXIT_CODES::OK;
973}
974
975
977{
978 JOB_EXPORT_PCB_POS* aPosJob = dynamic_cast<JOB_EXPORT_PCB_POS*>( aJob );
979
980 if( aPosJob == nullptr )
982
983 if( aJob->IsCli() )
984 m_reporter->Report( _( "Loading board\n" ), RPT_SEVERITY_INFO );
985
986 BOARD* brd = LoadBoard( aPosJob->m_filename, true );
987
988 if( aPosJob->m_outputFile.IsEmpty() )
989 {
990 wxFileName fn = brd->GetFileName();
991 fn.SetName( fn.GetName() );
992
995 else if( aPosJob->m_format == JOB_EXPORT_PCB_POS::FORMAT::CSV )
996 fn.SetExt( FILEEXT::CsvFileExtension );
997 else if( aPosJob->m_format == JOB_EXPORT_PCB_POS::FORMAT::GERBER )
998 fn.SetExt( FILEEXT::GerberFileExtension );
999
1000 aPosJob->m_outputFile = fn.GetFullName();
1001 }
1002
1005 {
1006 FILE* file = nullptr;
1007 file = wxFopen( aPosJob->m_outputFile, wxS( "wt" ) );
1008
1009 if( file == nullptr )
1011
1012 std::string data;
1013
1014 bool frontSide = aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::FRONT
1016
1017 bool backSide = aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::BACK
1019
1020 PLACE_FILE_EXPORTER exporter( brd,
1022 aPosJob->m_smdOnly, aPosJob->m_excludeFootprintsWithTh,
1023 aPosJob->m_excludeDNP,
1024 frontSide, backSide,
1027 aPosJob->m_negateBottomX );
1028 data = exporter.GenPositionData();
1029
1030 fputs( data.c_str(), file );
1031 fclose( file );
1032 }
1033 else if( aPosJob->m_format == JOB_EXPORT_PCB_POS::FORMAT::GERBER )
1034 {
1035 PLACEFILE_GERBER_WRITER exporter( brd );
1036
1037 PCB_LAYER_ID gbrLayer = F_Cu;
1038
1039 if( aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::BACK )
1040 gbrLayer = B_Cu;
1041
1042 exporter.CreatePlaceFile( aPosJob->m_outputFile, gbrLayer, aPosJob->m_gerberBoardEdge );
1043 }
1044
1045 return CLI::EXIT_CODES::OK;
1046}
1047
1048extern FOOTPRINT* try_load_footprint( const wxFileName& aFileName, PCB_IO_MGR::PCB_FILE_T aFileType,
1049 const wxString& aName );
1050
1051
1053{
1054 JOB_FP_UPGRADE* upgradeJob = dynamic_cast<JOB_FP_UPGRADE*>( aJob );
1055
1056 if( upgradeJob == nullptr )
1058
1060
1061 if( !upgradeJob->m_outputLibraryPath.IsEmpty() )
1062 {
1063 if( wxFile::Exists( upgradeJob->m_outputLibraryPath ) ||
1064 wxDir::Exists( upgradeJob->m_outputLibraryPath) )
1065 {
1066 m_reporter->Report( _( "Output path must not conflict with existing path\n" ),
1069 }
1070 }
1071 else if( fileType != PCB_IO_MGR::KICAD_SEXP )
1072 {
1073 m_reporter->Report( _( "Output path must be specified to convert legacy and non-KiCad libraries\n" ),
1075
1077 }
1078
1080 {
1081 if( !wxDir::Exists( upgradeJob->m_libraryPath ) )
1082 {
1083 m_reporter->Report( _( "Footprint library path does not exist or is not accessible\n" ),
1086 }
1087
1088
1089 if( aJob->IsCli() )
1090 m_reporter->Report( _( "Loading footprint library\n" ), RPT_SEVERITY_INFO );
1091
1093 FP_CACHE fpLib( &pcb_io, upgradeJob->m_libraryPath );
1094
1095 try
1096 {
1097 fpLib.Load();
1098 }
1099 catch( ... )
1100 {
1101 m_reporter->Report( _( "Unable to load library\n" ), RPT_SEVERITY_ERROR );
1103 }
1104
1105 bool shouldSave = upgradeJob->m_force;
1106
1107 for( const auto& footprint : fpLib.GetFootprints() )
1108 {
1109 if( footprint.second->GetFootprint()->GetFileFormatVersionAtLoad()
1111 {
1112 shouldSave = true;
1113 }
1114 }
1115
1116 if( shouldSave )
1117 {
1118 m_reporter->Report( _( "Saving footprint library\n" ), RPT_SEVERITY_INFO );
1119
1120 try
1121 {
1122 if( !upgradeJob->m_outputLibraryPath.IsEmpty() )
1123 {
1124 fpLib.SetPath( upgradeJob->m_outputLibraryPath );
1125 }
1126
1127 fpLib.Save();
1128 }
1129 catch( ... )
1130 {
1131 m_reporter->Report( _( "Unable to save library\n" ), RPT_SEVERITY_ERROR );
1133 }
1134 }
1135 else
1136 {
1137 m_reporter->Report( _( "Footprint library was not updated\n" ), RPT_SEVERITY_INFO );
1138 }
1139 }
1140 else
1141 {
1142 if( !PCB_IO_MGR::ConvertLibrary( nullptr, upgradeJob->m_libraryPath, upgradeJob->m_outputLibraryPath ) )
1143 {
1144 m_reporter->Report( ( "Unable to convert library\n" ), RPT_SEVERITY_ERROR );
1146 }
1147 }
1148
1149 return CLI::EXIT_CODES::OK;
1150}
1151
1152
1154{
1155 JOB_FP_EXPORT_SVG* svgJob = dynamic_cast<JOB_FP_EXPORT_SVG*>( aJob );
1156
1157 if( svgJob == nullptr )
1159
1160 if( aJob->IsCli() )
1161 m_reporter->Report( _( "Loading footprint library\n" ), RPT_SEVERITY_INFO );
1162
1164 FP_CACHE fpLib( &pcb_io, svgJob->m_libraryPath );
1165
1166 try
1167 {
1168 fpLib.Load();
1169 }
1170 catch( ... )
1171 {
1172 m_reporter->Report( _( "Unable to load library\n" ), RPT_SEVERITY_ERROR );
1174 }
1175
1176 if( !svgJob->m_outputDirectory.IsEmpty() && !wxDir::Exists( svgJob->m_outputDirectory ) )
1177 {
1178 wxFileName::Mkdir( svgJob->m_outputDirectory );
1179 }
1180
1181 int exitCode = CLI::EXIT_CODES::OK;
1182
1183 // Just plot all the symbols we can
1184 FP_CACHE_FOOTPRINT_MAP& footprintMap = fpLib.GetFootprints();
1185
1186 bool singleFpPlotted = false;
1187 for( FP_CACHE_FOOTPRINT_MAP::iterator it = footprintMap.begin(); it != footprintMap.end();
1188 ++it )
1189 {
1190 const FOOTPRINT* fp = it->second->GetFootprint();
1191 if( !svgJob->m_footprint.IsEmpty() )
1192 {
1193 if( fp->GetFPID().GetLibItemName().wx_str() != svgJob->m_footprint )
1194 {
1195 // skip until we find the right footprint
1196 continue;
1197 }
1198 else
1199 {
1200 singleFpPlotted = true;
1201 }
1202 }
1203
1204 exitCode = doFpExportSvg( svgJob, fp );
1205 if( exitCode != CLI::EXIT_CODES::OK )
1206 break;
1207 }
1208
1209 if( !svgJob->m_footprint.IsEmpty() && !singleFpPlotted )
1210 {
1211 m_reporter->Report( _( "The given footprint could not be found to export." ) + wxS( "\n" ),
1213 }
1214
1215 return CLI::EXIT_CODES::OK;
1216}
1217
1218
1220{
1221 // the hack for now is we create fake boards containing the footprint and plot the board
1222 // until we refactor better plot api later
1223 std::unique_ptr<BOARD> brd;
1224 brd.reset( CreateEmptyBoard() );
1225 brd->GetProject()->ApplyTextVars( aSvgJob->GetVarOverrides() );
1226 brd->SynchronizeProperties();
1227
1228 FOOTPRINT* fp = dynamic_cast<FOOTPRINT*>( aFootprint->Clone() );
1229
1230 if( fp == nullptr )
1232
1233 fp->SetLink( niluuid );
1234 fp->SetFlags( IS_NEW );
1235 fp->SetParent( brd.get() );
1236
1237 for( PAD* pad : fp->Pads() )
1238 {
1239 pad->SetLocalRatsnestVisible( false );
1240 pad->SetNetCode( 0 );
1241 }
1242
1243 fp->SetOrientation( ANGLE_0 );
1244 fp->SetPosition( VECTOR2I( 0, 0 ) );
1245
1246 brd->Add( fp, ADD_MODE::INSERT, true );
1247
1248 wxFileName outputFile;
1249 outputFile.SetPath( aSvgJob->m_outputDirectory );
1250 outputFile.SetName( aFootprint->GetFPID().GetLibItemName().wx_str() );
1251 outputFile.SetExt( FILEEXT::SVGFileExtension );
1252
1253 m_reporter->Report( wxString::Format( _( "Plotting footprint '%s' to '%s'\n" ),
1254 aFootprint->GetFPID().GetLibItemName().wx_str(),
1255 outputFile.GetFullPath() ),
1257
1258
1259 PCB_PLOT_SVG_OPTIONS svgPlotOptions;
1260 svgPlotOptions.m_blackAndWhite = aSvgJob->m_blackAndWhite;
1261 svgPlotOptions.m_colorTheme = aSvgJob->m_colorTheme;
1262 svgPlotOptions.m_outputFile = outputFile.GetFullPath();
1263 svgPlotOptions.m_mirror = false;
1264 svgPlotOptions.m_pageSizeMode = 2; // board bounding box
1265 svgPlotOptions.m_printMaskLayer = aSvgJob->m_printMaskLayer;
1266 svgPlotOptions.m_sketchPadsOnFabLayers = aSvgJob->m_sketchPadsOnFabLayers;
1267 svgPlotOptions.m_plotFrame = false;
1268
1269 if( !EXPORT_SVG::Plot( brd.get(), svgPlotOptions ) )
1270 m_reporter->Report( _( "Error creating svg file" ) + wxS( "\n" ), RPT_SEVERITY_ERROR );
1271
1272 return CLI::EXIT_CODES::OK;
1273}
1274
1275
1277{
1278 JOB_PCB_DRC* drcJob = dynamic_cast<JOB_PCB_DRC*>( aJob );
1279
1280 if( drcJob == nullptr )
1282
1283 if( aJob->IsCli() )
1284 m_reporter->Report( _( "Loading board\n" ), RPT_SEVERITY_INFO );
1285
1286 BOARD* brd = LoadBoard( drcJob->m_filename, true );
1287 brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
1288 brd->SynchronizeProperties();
1289
1290 if( drcJob->m_outputFile.IsEmpty() )
1291 {
1292 wxFileName fn = brd->GetFileName();
1293 fn.SetName( fn.GetName() );
1294
1296 fn.SetExt( FILEEXT::JsonFileExtension );
1297 else
1298 fn.SetExt( FILEEXT::ReportFileExtension );
1299
1300 drcJob->m_outputFile = fn.GetFullName();
1301 }
1302
1303 EDA_UNITS units;
1304
1305 switch( drcJob->m_units )
1306 {
1307 case JOB_PCB_DRC::UNITS::INCHES: units = EDA_UNITS::INCHES; break;
1308 case JOB_PCB_DRC::UNITS::MILS: units = EDA_UNITS::MILS; break;
1309 case JOB_PCB_DRC::UNITS::MILLIMETERS: units = EDA_UNITS::MILLIMETRES; break;
1310 default: units = EDA_UNITS::MILLIMETRES; break;
1311 }
1312
1313 std::shared_ptr<DRC_ENGINE> drcEngine = brd->GetDesignSettings().m_DRCEngine;
1314 std::unique_ptr<NETLIST> netlist = std::make_unique<NETLIST>();
1315
1316 drcEngine->SetDrawingSheet( getDrawingSheetProxyView( brd ) );
1317
1318 // BOARD_COMMIT uses TOOL_MANAGER to grab the board internally so we must give it one
1319 TOOL_MANAGER* toolManager = new TOOL_MANAGER;
1320 toolManager->SetEnvironment( brd, nullptr, nullptr, Kiface().KifaceSettings(), nullptr );
1321
1322 BOARD_COMMIT commit( toolManager );
1323
1324 m_reporter->Report( _( "Running DRC...\n" ), RPT_SEVERITY_INFO );
1325
1326 if( drcJob->m_parity )
1327 {
1328 typedef bool (*NETLIST_FN_PTR)( const wxString&, std::string& );
1329
1331 wxFileName schematicPath( drcJob->m_filename );
1332 NETLIST_FN_PTR netlister = (NETLIST_FN_PTR) eeschema->IfaceOrAddress( KIFACE_NETLIST_SCHEMATIC );
1333 std::string netlist_str;
1334
1335 schematicPath.SetExt( FILEEXT::KiCadSchematicFileExtension );
1336
1337 if( !schematicPath.Exists() )
1338 schematicPath.SetExt( FILEEXT::LegacySchematicFileExtension );
1339
1340 if( !schematicPath.Exists() )
1341 {
1342 m_reporter->Report( _( "Failed to find schematic for parity tests.\n" ),
1344 }
1345 else
1346 {
1347 (*netlister)( schematicPath.GetFullPath(), netlist_str );
1348
1349 try
1350 {
1351 auto lineReader = new STRING_LINE_READER( netlist_str, _( "Eeschema netlist" ) );
1352 KICAD_NETLIST_READER netlistReader( lineReader, netlist.get() );
1353 netlistReader.LoadNetlist();
1354 }
1355 catch( const IO_ERROR& )
1356 {
1357 m_reporter->Report( _( "Failed to fetch schematic netlist for parity tests.\n" ),
1359 }
1360
1361 drcEngine->SetSchematicNetlist( netlist.get() );
1362 }
1363 }
1364
1365 drcEngine->SetProgressReporter( nullptr );
1366 drcEngine->SetViolationHandler(
1367 [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer )
1368 {
1369 PCB_MARKER* marker = new PCB_MARKER( aItem, aPos, aLayer );
1370 commit.Add( marker );
1371 } );
1372
1373 brd->RecordDRCExclusions();
1374 brd->DeleteMARKERs( true, true );
1375 drcEngine->RunTests( units, drcJob->m_reportAllTrackErrors, drcJob->m_parity );
1376 drcEngine->ClearViolationHandler();
1377
1378 commit.Push( _( "DRC" ), SKIP_UNDO | SKIP_SET_DIRTY );
1379
1380 // Update the exclusion status on any excluded markers that still exist.
1381 brd->ResolveDRCExclusions( false );
1382
1383 std::shared_ptr<DRC_ITEMS_PROVIDER> markersProvider = std::make_shared<DRC_ITEMS_PROVIDER>(
1385
1386 std::shared_ptr<DRC_ITEMS_PROVIDER> ratsnestProvider =
1387 std::make_shared<DRC_ITEMS_PROVIDER>( brd, MARKER_BASE::MARKER_RATSNEST );
1388
1389 std::shared_ptr<DRC_ITEMS_PROVIDER> fpWarningsProvider =
1390 std::make_shared<DRC_ITEMS_PROVIDER>( brd, MARKER_BASE::MARKER_PARITY );
1391
1392 markersProvider->SetSeverities( drcJob->m_severity );
1393 ratsnestProvider->SetSeverities( drcJob->m_severity );
1394 fpWarningsProvider->SetSeverities( drcJob->m_severity );
1395
1396 m_reporter->Report( wxString::Format( _( "Found %d violations\n" ),
1397 markersProvider->GetCount() ),
1399 m_reporter->Report( wxString::Format( _( "Found %d unconnected items\n" ),
1400 ratsnestProvider->GetCount() ),
1402
1403 if( drcJob->m_parity )
1404 {
1405 m_reporter->Report( wxString::Format( _( "Found %d schematic parity issues\n" ),
1406 fpWarningsProvider->GetCount() ),
1408 }
1409
1410 DRC_REPORT reportWriter( brd, units, markersProvider, ratsnestProvider, fpWarningsProvider );
1411
1412 bool wroteReport = false;
1413
1415 wroteReport = reportWriter.WriteJsonReport( drcJob->m_outputFile );
1416 else
1417 wroteReport = reportWriter.WriteTextReport( drcJob->m_outputFile );
1418
1419 if( !wroteReport )
1420 {
1421 m_reporter->Report( wxString::Format( _( "Unable to save DRC report to %s\n" ),
1422 drcJob->m_outputFile ),
1425 }
1426
1427 m_reporter->Report( wxString::Format( _( "Saved DRC Report to %s\n" ),
1428 drcJob->m_outputFile ),
1430
1431 if( drcJob->m_exitCodeViolations )
1432 {
1433 if( markersProvider->GetCount() > 0 || ratsnestProvider->GetCount() > 0
1434 || fpWarningsProvider->GetCount() > 0 )
1435 {
1437 }
1438 }
1439
1441}
1442
1443
1445{
1446 JOB_EXPORT_PCB_IPC2581* job = dynamic_cast<JOB_EXPORT_PCB_IPC2581*>( aJob );
1447
1448 if( job == nullptr )
1450
1451 if( job->IsCli() )
1452 m_reporter->Report( _( "Loading board\n" ), RPT_SEVERITY_INFO );
1453
1454 BOARD* brd = LoadBoard( job->m_filename, true );
1455
1456 if( job->m_outputFile.IsEmpty() )
1457 {
1458 wxFileName fn = brd->GetFileName();
1459 fn.SetName( fn.GetName() );
1460 fn.SetExt( FILEEXT::Ipc2581FileExtension );
1461
1462 job->m_outputFile = fn.GetFullName();
1463 }
1464
1465 STRING_UTF8_MAP props;
1466 props["units"] = job->m_units == JOB_EXPORT_PCB_IPC2581::IPC2581_UNITS::MILLIMETERS ? "mm"
1467 : "inch";
1468 props["sigfig"] = wxString::Format( "%d", job->m_precision );
1469 props["version"] = job->m_version == JOB_EXPORT_PCB_IPC2581::IPC2581_VERSION::C ? "C" : "B";
1470 props["OEMRef"] = job->m_colInternalId;
1471 props["mpn"] = job->m_colMfgPn;
1472 props["mfg"] = job->m_colMfg;
1473 props["dist"] = job->m_colDist;
1474 props["distpn"] = job->m_colDistPn;
1475
1476 wxString tempFile = wxFileName::CreateTempFileName( wxS( "pcbnew_ipc" ) );
1477 try
1478 {
1480 pi->SetProgressReporter( m_progressReporter );
1481 pi->SaveBoard( tempFile, brd, &props );
1482 }
1483 catch( const IO_ERROR& ioe )
1484 {
1485 m_reporter->Report( wxString::Format( _( "Error generating IPC2581 file '%s'.\n%s" ),
1486 job->m_filename, ioe.What() ),
1488
1489 wxRemoveFile( tempFile );
1490
1492 }
1493
1494 if( job->m_compress )
1495 {
1496 wxFileName tempfn = job->m_outputFile;
1497 tempfn.SetExt( FILEEXT::Ipc2581FileExtension );
1498 wxFileName zipfn = tempFile;
1499 zipfn.SetExt( "zip" );
1500
1501 wxFFileOutputStream fnout( zipfn.GetFullPath() );
1502 wxZipOutputStream zip( fnout );
1503 wxFFileInputStream fnin( tempFile );
1504
1505 zip.PutNextEntry( tempfn.GetFullName() );
1506 fnin.Read( zip );
1507 zip.Close();
1508 fnout.Close();
1509
1510 wxRemoveFile( tempFile );
1511 tempFile = zipfn.GetFullPath();
1512 }
1513
1514 // If save succeeded, replace the original with what we just wrote
1515 if( !wxRenameFile( tempFile, job->m_outputFile ) )
1516 {
1517 m_reporter->Report( wxString::Format( _( "Error generating IPC2581 file '%s'.\n"
1518 "Failed to rename temporary file '%s." )
1519 + wxS( "\n" ),
1520 job->m_outputFile, tempFile ),
1522 }
1523
1525}
1526
1527
1529{
1531 &aBrd->GetPageSettings(),
1532 aBrd->GetProject(),
1533 &aBrd->GetTitleBlock(),
1534 &aBrd->GetProperties() );
1535
1536 drawingSheet->SetSheetName( std::string() );
1537 drawingSheet->SetSheetPath( std::string() );
1538 drawingSheet->SetIsFirstPage( true );
1539
1540 drawingSheet->SetFileName( TO_UTF8( aBrd->GetFileName() ) );
1541
1542 return drawingSheet;
1543}
1544
1545
1546void PCBNEW_JOBS_HANDLER::loadOverrideDrawingSheet( BOARD* aBrd, const wxString& aSheetPath )
1547{
1548 // dont bother attempting to load a empty path, if there was one
1549 if( aSheetPath.IsEmpty() )
1550 return;
1551
1552 auto loadSheet =
1553 [&]( const wxString& path ) -> bool
1554 {
1557 resolver.SetProject( aBrd->GetProject() );
1559
1561 aBrd->GetProject()->GetProjectPath(),
1562 aBrd->GetEmbeddedFiles() );
1563 wxString msg;
1564
1565 if( !DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet( filename, &msg ) )
1566 {
1567 m_reporter->Report( wxString::Format( _( "Error loading drawing sheet '%s'." ),
1568 path )
1569 + wxS( "\n" ) + msg + wxS( "\n" ),
1571 return false;
1572 }
1573
1574 return true;
1575 };
1576
1577 if( loadSheet( aSheetPath ) )
1578 return;
1579
1580 // failed loading custom path, revert back to default
1581 loadSheet( aBrd->GetProject()->GetProjectFile().m_BoardDrawingSheetFile );
1582}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
Definition: board_adapter.h:66
PROJECTION_TYPE
Definition: camera.h:40
static wxString m_DrawingSheetFileName
the name of the drawing sheet file, or empty to use the default drawing sheet
Definition: base_screen.h:85
Helper class to handle information needed to display 3D board.
Definition: board_adapter.h:73
double BiuTo3dUnits() const noexcept
Board integer units To 3D units.
bool m_IsPreviewer
true if we're in a 3D preview panel, false for the standard 3D viewer
void SetBoard(BOARD *aBoard) noexcept
Set current board to be rendered.
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.
Definition: board_adapter.h:84
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
std::shared_ptr< DRC_ENGINE > m_DRCEngine
const VECTOR2I & GetAuxOrigin()
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:289
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:757
EMBEDDED_FILES * GetEmbeddedFiles() override
Definition: board.cpp:2523
const PAGE_INFO & GetPageSettings() const
Definition: board.h:682
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false, bool aIncludeHiddenText=false) const
Calculate the bounding box containing all board items (or board edge segments).
Definition: board.cpp:1652
void RecordDRCExclusions()
Scan existing markers and record data from any that are Excluded.
Definition: board.cpp:327
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:688
const std::map< wxString, wxString > & GetProperties() const
Definition: board.h:361
const wxString & GetFileName() const
Definition: board.h:326
std::vector< PCB_MARKER * > ResolveDRCExclusions(bool aCreateMarkers)
Rebuild DRC markers from the serialized data in BOARD_DESIGN_SETTINGS.
Definition: board.cpp:344
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: board.h:685
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:575
PROJECT * GetProject() const
Definition: board.h:490
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:874
void SynchronizeProperties()
Copy the current project's text variables into the boards property cache.
Definition: board.cpp:2024
void DeleteMARKERs()
Delete all MARKERS from the board.
Definition: board.cpp:1339
const Vec GetCenter() const
Definition: box2.h:220
void SetProjection(PROJECTION_TYPE aProjection)
Definition: camera.h:206
void RotateY_T1(float aAngleInRadians)
Definition: camera.cpp:685
bool Zoom_T1(float aFactor)
Definition: camera.cpp:628
bool SetCurWindowSize(const wxSize &aSize)
Update the windows size of the camera.
Definition: camera.cpp:570
bool ViewCommand_T1(VIEW3D_TYPE aRequestedView)
Definition: camera.cpp:110
void RotateX_T1(float aAngleInRadians)
Definition: camera.cpp:679
void SetLookAtPos_T1(const SFVEC3F &aLookAtPos)
Definition: camera.h:162
const SFVEC3F & GetLookAtPos_T1() const
Definition: camera.h:167
void RotateZ_T1(float aAngleInRadians)
Definition: camera.cpp:691
bool ParametersChanged()
Definition: camera.cpp:729
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been added.
Definition: commit.h:80
bool WriteJsonReport(const wxString &aFullFileName)
Definition: drc_report.cpp:114
bool WriteTextReport(const wxString &aFullFileName)
Definition: drc_report.cpp:47
Helper to handle drill precision format in excellon files.
bool LoadDrawingSheet(const wxString &aFullFileName, wxString *aMsg, bool aAppend=false)
Populates the list with a custom layout or the default layout if no custom layout is available.
static DS_DATA_MODEL & GetTheInstance()
static function: returns 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.
virtual bool EndPlot() override
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:127
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:104
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)
double m_BoardOutlinesChainingEpsilon
Definition: exporter_step.h:91
wxString m_outputFile
Wrapper to expose an API for writing VRML files, without exposing all the many structures used in the...
Definition: export_vrml.h:33
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.
static bool Plot(BOARD *aBoard, const PCB_PLOT_SVG_OPTIONS &aSvgPlotOptions)
Definition: export_svg.cpp:29
Provide an extensible class to resolve 3D model paths.
bool SetProject(PROJECT *aProject, bool *flgChanged=nullptr)
Set the current KiCad project directory as the first entry in the model path list.
void SetProgramBase(PGM_BASE *aBase)
Set a pointer to the application's PGM_BASE instance used to extract the local env vars.
wxString ResolvePath(const wxString &aFileName, const wxString &aWorkingPath, const EMBEDDED_FILES *aFiles)
Determines the full path of the given file name.
void SetPosition(const VECTOR2I &aPos) override
Definition: footprint.cpp:2343
void SetLink(const KIID &aLink)
Definition: footprint.h:842
void SetOrientation(const EDA_ANGLE &aNewAngle)
Definition: footprint.cpp:2415
EDA_ITEM * Clone() const override
Invoke a function on all children.
Definition: footprint.cpp:2032
PADS & Pads()
Definition: footprint.h:195
const LIB_ID & GetFPID() const
Definition: footprint.h:237
FP_CACHE_FOOTPRINT_MAP & GetFootprints()
void Save(FOOTPRINT *aFootprint=nullptr)
Save the footprint cache or a single footprint from it to disk.
void SetPath(const wxString &aPath)
void SetMapFileFormat(PLOT_FORMAT aMapFmt)
Initialize the format for the drill map file.
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, 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.
Definition: ki_exception.h:77
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
PROGRESS_REPORTER * m_progressReporter
void Register(const std::string &aJobTypeName, std::function< int(JOB *job)> aHandler)
REPORTER * m_reporter
double m_BoardOutlinesChainingEpsilon
JOB_EXPORT_PCB_3D::FORMAT m_format
wxString m_libraryPath
wxString m_outputLibraryPath
OUTPUT_FORMAT m_format
Definition: job_pcb_drc.h:57
UNITS m_units
Definition: job_pcb_drc.h:47
bool m_parity
Definition: job_pcb_drc.h:60
wxString m_filename
Definition: job_pcb_drc.h:35
int m_severity
Definition: job_pcb_drc.h:49
bool m_reportAllTrackErrors
Definition: job_pcb_drc.h:38
wxString m_outputFile
Definition: job_pcb_drc.h:36
bool m_exitCodeViolations
Definition: job_pcb_drc.h:59
BG_STYLE m_bgStyle
VECTOR3D m_rotation
wxString m_filename
VECTOR3D m_pivot
std::string m_colorPreset
wxString m_outputFile
An simple container class that lets us dispatch output jobs to kifaces.
Definition: job.h:32
bool IsCli() const
Definition: job.h:39
const std::map< wxString, wxString > & GetVarOverrides() const
Definition: job.h:41
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.
Definition: color4d.h:104
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:279
virtual KIFACE * KiFACE(FACE_T aFaceId, bool doLoad=true)
Return the KIFACE* given a FACE_T.
Definition: kiway.cpp:202
@ FACE_SCH
eeschema DSO
Definition: kiway.h:286
const UTF8 & GetLibItemName() const
Definition: lib_id.h:102
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: lseq.h:47
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:35
LSEQ UIOrder() const
Definition: lset.cpp:865
LSEQ SeqStackupForPlotting() const
Return the sequence that is typical for a bottom-to-top stack-up.
Definition: lset.cpp:537
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
Definition: lset.cpp:753
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:732
@ MARKER_DRAWING_SHEET
Definition: marker_base.h:56
Definition: pad.h:54
void populateGerberPlotOptionsFromJob(PCB_PLOT_PARAMS &aPlotOpts, JOB_EXPORT_PCB_GERBER *aJob)
int JobExportFpUpgrade(JOB *aJob)
int JobExportGerber(JOB *aJob)
DS_PROXY_VIEW_ITEM * getDrawingSheetProxyView(BOARD *aBrd)
void loadOverrideDrawingSheet(BOARD *brd, const wxString &aSheetPath)
PCBNEW_JOBS_HANDLER(KIWAY *aKiway)
int JobExportGerbers(JOB *aJob)
int JobExportRender(JOB *aJob)
int doFpExportSvg(JOB_FP_EXPORT_SVG *aSvgJob, const FOOTPRINT *aFootprint)
A #PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
static PCB_IO * PluginFind(PCB_FILE_T aFileType)
Return a #PLUGIN which the caller can use to import, export, save, or load design documents.
Definition: pcb_io_mgr.cpp:65
static bool ConvertLibrary(STRING_UTF8_MAP *aOldFileProps, const wxString &aOldFilePath, const wxString &aNewFilePath)
Convert a schematic symbol library to the latest KiCad format.
Definition: pcb_io_mgr.cpp:187
PCB_FILE_T
The set of file types that the PCB_IO_MGR knows about, and for which there has been a plugin written,...
Definition: pcb_io_mgr.h:56
@ KICAD_SEXP
S-expression Pcbnew file format.
Definition: pcb_io_mgr.h:58
static PCB_FILE_T GuessPluginTypeFromLibPath(const wxString &aLibPath, int aCtl=0)
Return a plugin type given a footprint library's libPath.
Definition: pcb_io_mgr.cpp:132
Parameters and options when plotting/printing a board.
void SetDrillMarksType(DRILL_MARKS aVal)
void SetLayerSelection(LSET aSelection)
void SetPlotReference(bool aFlag)
void SetSketchPadsOnFabLayers(bool aFlag)
void SetUseGerberX2format(bool aUse)
void SetDXFPlotPolygonMode(bool aFlag)
void SetPlotFrameRef(bool aFlag)
void SetPlotPadNumbers(bool aFlag)
LSET GetLayerSelection() const
LSET GetPlotOnAllLayersSelection() const
void SetDisableGerberMacros(bool aDisable)
void SetMirror(bool aFlag)
void SetBlackAndWhite(bool blackAndWhite)
void SetGerberPrecision(int aPrecision)
void SetSubtractMaskFromSilk(bool aSubtract)
void SetPlotValue(bool aFlag)
void SetUseGerberProtelExtensions(bool aUse)
void SetDXFPlotUnits(DXF_UNITS aUnit)
void SetColorSettings(COLOR_SETTINGS *aSettings)
void SetIncludeGerberNetlistInfo(bool aUse)
void SetNegative(bool aFlag)
void SetUseAuxOrigin(bool aAux)
bool GetUseGerberProtelExtensions() const
void SetFormat(PLOT_FORMAT aFormat)
virtual bool EndPlot() override
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
Used to create Gerber drill files.
int CreatePlaceFile(wxString &aFullFilename, PCB_LAYER_ID aLayer, bool aIncludeBrdEdges)
Create an pnp gerber file.
The ASCII format of the kicad place file is:
std::string GenPositionData()
build a string filled with the position data
wxString m_BoardDrawingSheetFile
PcbNew params.
Definition: project_file.h:154
static S3D_CACHE * Get3DCacheManager(PROJECT *aProject, bool updateProjDir=false)
Return a pointer to an instance of the 3D cache manager.
Definition: project_pcb.cpp:77
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:135
virtual void ApplyTextVars(const std::map< wxString, wxString > &aVarsMap)
Applies the given var map, it will create or update existing vars.
Definition: project.cpp:90
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:166
bool Redraw(bool aIsMoving, REPORTER *aStatusReporter, REPORTER *aWarningReporter) override
Redraw the view.
void SetCurWindowSize(const wxSize &aSize) override
Before each render, the canvas will tell the render what is the size of its windows,...
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
T * GetAppSettings()
Returns a handle to the a given settings by type If the settings have already been loaded,...
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:253
A name/value tuple with unique names and optional values.
Master controller class:
Definition: tool_manager.h:62
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void Pan_T1(const SFVEC3F &aDeltaOffsetInc) override
Definition: track_ball.cpp:125
void SetT0_and_T1_current_T() override
This will set T0 and T1 with the current values.
Definition: track_ball.cpp:138
void Interpolate(float t) override
It will update the matrix to interpolate between T0 and T1 values.
Definition: track_ball.cpp:152
wxString wx_str() const
Definition: utf8.cpp:45
T y
Definition: vector3.h:63
T z
Definition: vector3.h:64
T x
Definition: vector3.h:62
wxString GetDefaultPlotExtension(PLOT_FORMAT aFormat)
Returns the default plot extension for a format.
static DRILL_PRECISION precisionListForInches(2, 4)
static DRILL_PRECISION precisionListForMetric(3, 3)
#define _(s)
static constexpr EDA_ANGLE ANGLE_0
Definition: eda_angle.h:401
#define IS_NEW
New item, just created.
EDA_UNITS
Definition: eda_units.h:46
static FILENAME_RESOLVER * resolver
Definition: export_idf.cpp:53
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 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 FootprintPlaceFileExtension
static const std::string JsonFileExtension
static const std::string KiCadSchematicFileExtension
static const std::string CsvFileExtension
static const std::string Ipc2581FileExtension
static const std::string StepFileExtension
static const std::string SVGFileExtension
static const std::string VrmlFileExtension
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
Definition: io_mgr.h:33
@ KIFACE_NETLIST_SCHEMATIC
Definition: kiface_ids.h:56
KIID niluuid(0)
@ LAYER_3D_BACKGROUND_TOP
Definition: layer_ids.h:454
@ LAYER_3D_BACKGROUND_BOTTOM
Definition: layer_ids.h:453
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ B_Cu
Definition: layer_ids.h:95
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
@ F_Cu
Definition: layer_ids.h:64
This file contains miscellaneous commonly used macros and functions.
static const int OK
Definition: exit_codes.h:30
static const int ERR_RC_VIOLATIONS
Definition: exit_codes.h:36
static const int ERR_INVALID_INPUT_FILE
Definition: exit_codes.h:33
static const int SUCCESS
Definition: exit_codes.h:29
static const int ERR_INVALID_OUTPUT_CONFLICT
Rules check violation count was greater than 0.
Definition: exit_codes.h:34
static const int ERR_UNKNOWN
Definition: exit_codes.h:32
#define SEXPR_BOARD_FILE_VERSION
Current s-expression file format version. 2 was the last legacy format version.
boost::ptr_map< wxString, FP_CACHE_ITEM > FP_CACHE_FOOTPRINT_MAP
#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)
FOOTPRINT * try_load_footprint(const wxFileName &aFileName, PCB_IO_MGR::PCB_FILE_T aFileType, const wxString &aName)
BOARD * LoadBoard(wxString &aFileName, bool aSetActive)
Loads a board from file This function identifies the file type by extension and determines the correc...
BOARD * CreateEmptyBoard()
Construct a default BOARD with a temporary (no filename) project.
const wxString GetGerberProtelExtension(int aLayer)
Definition: pcbplot.cpp:43
void BuildPlotFileName(wxFileName *aFilename, const wxString &aOutputDir, const wxString &aSuffix, const wxString &aExtension)
Complete a plot filename.
Definition: pcbplot.cpp:373
void PlotBoardLayers(BOARD *aBoard, PLOTTER *aPlotter, const LSEQ &aLayerSequence, const PCB_PLOT_PARAMS &aPlotOptions)
Plot a sequence of board layer IDs.
void PlotInteractiveLayer(BOARD *aBoard, PLOTTER *aPlotter, const PCB_PLOT_PARAMS &aPlotOpt)
Plot interactive items (hypertext links, properties, etc.).
PLOTTER * StartPlotBoard(BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aLayer, const wxString &aLayerName, const wxString &aFullFileName, const wxString &aSheetName, const wxString &aSheetPath)
Open a new plotfile using the options (and especially the format) specified in the options and prepar...
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1059
see class PGM_BASE
PLOT_FORMAT
The set of supported output plot formats.
Definition: plotter.h:65
Plotting engines similar to ps (PostScript, Gerber, svg)
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_INFO
@ RPT_SEVERITY_ACTION
#define SKIP_SET_DIRTY
Definition: sch_commit.h:43
#define SKIP_UNDO
Definition: sch_commit.h:41
const int scale
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.
Definition: string_utils.h:391
constexpr double IUTomm(int iu) const
Definition: base_units.h:86
constexpr int mmToIU(double mm) const
Definition: base_units.h:88
Implement a participant in the KIWAY alchemy.
Definition: kiway.h:151
bool m_sketchPadsOnFabLayers
Definition: export_svg.h:37
wxString m_colorTheme
Definition: export_svg.h:27
wxString m_outputFile
Definition: export_svg.h:26
Declaration for a track ball camera.
double DEG2RAD(double deg)
Definition: trigo.h:140
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:673
VECTOR2< double > VECTOR2D
Definition: vector2d.h:672
Definition of file extensions used in Kicad.
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44