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 <cli/exit_codes.h>
48#include <tool/tool_manager.h>
49#include <tools/drc_tool.h>
54#include <kiface_base.h>
55#include <macros.h>
56#include <pad.h>
57#include <pcb_marker.h>
60#include <kiface_ids.h>
63#include <pcbnew_settings.h>
64#include <pcbplot.h>
65#include <pgm_base.h>
68#include <project_pcb.h>
70#include <reporter.h>
71#include <string_utf8_map.h>
73#include <export_vrml.h>
74#include <wx/wfstream.h>
75#include <wx/zipstrm.h>
76
78
79
80#ifdef _WIN32
81#ifdef TRANSPARENT
82#undef TRANSPARENT
83#endif
84#endif
85
86
88 JOB_DISPATCHER( aKiway )
89{
90 Register( "3d", std::bind( &PCBNEW_JOBS_HANDLER::JobExportStep, this, std::placeholders::_1 ) );
91 Register( "render", std::bind( &PCBNEW_JOBS_HANDLER::JobExportRender, this, std::placeholders::_1 ) );
92 Register( "svg", std::bind( &PCBNEW_JOBS_HANDLER::JobExportSvg, this, std::placeholders::_1 ) );
93 Register( "dxf", std::bind( &PCBNEW_JOBS_HANDLER::JobExportDxf, this, std::placeholders::_1 ) );
94 Register( "pdf", std::bind( &PCBNEW_JOBS_HANDLER::JobExportPdf, this, std::placeholders::_1 ) );
95 Register( "gerber",
96 std::bind( &PCBNEW_JOBS_HANDLER::JobExportGerber, this, std::placeholders::_1 ) );
97 Register( "gerbers",
98 std::bind( &PCBNEW_JOBS_HANDLER::JobExportGerbers, this, std::placeholders::_1 ) );
99 Register( "drill",
100 std::bind( &PCBNEW_JOBS_HANDLER::JobExportDrill, this, std::placeholders::_1 ) );
101 Register( "pos", std::bind( &PCBNEW_JOBS_HANDLER::JobExportPos, this, std::placeholders::_1 ) );
102 Register( "fpupgrade",
103 std::bind( &PCBNEW_JOBS_HANDLER::JobExportFpUpgrade, this, std::placeholders::_1 ) );
104 Register( "fpsvg",
105 std::bind( &PCBNEW_JOBS_HANDLER::JobExportFpSvg, this, std::placeholders::_1 ) );
106 Register( "drc", std::bind( &PCBNEW_JOBS_HANDLER::JobExportDrc, this, std::placeholders::_1 ) );
107 Register( "ipc2581",
108 std::bind( &PCBNEW_JOBS_HANDLER::JobExportIpc2581, this, std::placeholders::_1 ) );
109}
110
111
113{
114 JOB_EXPORT_PCB_3D* aStepJob = dynamic_cast<JOB_EXPORT_PCB_3D*>( aJob );
115
116 if( aStepJob == nullptr )
118
119 if( aJob->IsCli() )
120 m_reporter->Report( _( "Loading board\n" ), RPT_SEVERITY_INFO );
121
122 BOARD* brd = LoadBoard( aStepJob->m_filename, true );
123 brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
125
126 if( aStepJob->m_outputFile.IsEmpty() )
127 {
128 wxFileName fn = brd->GetFileName();
129 fn.SetName( fn.GetName() );
130
131 switch( aStepJob->m_format )
132 {
134 break;
136 break;
138 break;
140 break;
142 break;
143 default:
144 return CLI::EXIT_CODES::ERR_UNKNOWN; // shouldnt have gotten here
145 }
146
147 aStepJob->m_outputFile = fn.GetFullName();
148 }
149
151 {
152
153 double scale = 0.0;
154 switch ( aStepJob->m_vrmlUnits )
155 {
157 case JOB_EXPORT_PCB_3D::VRML_UNITS::METERS: scale = 0.001; break;
158 case JOB_EXPORT_PCB_3D::VRML_UNITS::TENTHS: scale = 10.0 / 25.4; break;
159 case JOB_EXPORT_PCB_3D::VRML_UNITS::INCHES: scale = 1.0 / 25.4; break;
160 }
161
162 EXPORTER_VRML vrmlExporter( brd );
163 wxString messages;
164
165 double originX = pcbIUScale.IUTomm( aStepJob->m_xOrigin );
166 double originY = pcbIUScale.IUTomm( aStepJob->m_yOrigin );
167
168 if( !aStepJob->m_hasUserOrigin )
169 {
170 BOX2I bbox = brd->ComputeBoundingBox( true, false );
171 originX = pcbIUScale.IUTomm( bbox.GetCenter().x );
172 originY = pcbIUScale.IUTomm( bbox.GetCenter().y );
173 }
174
175 bool success = vrmlExporter.ExportVRML_File(
176 brd->GetProject(), &messages, aStepJob->m_outputFile, scale,
177 aStepJob->m_includeUnspecified, aStepJob->m_includeDNP,
178 !aStepJob->m_vrmlModelDir.IsEmpty(), aStepJob->m_vrmlRelativePaths,
179 aStepJob->m_vrmlModelDir, originX, originY );
180
181 if ( success )
182 {
183 m_reporter->Report( wxString::Format( _( "Successfully exported VRML to %s" ),
184 aStepJob->m_outputFile ),
186 }
187 else
188 {
189 m_reporter->Report( _( "Error exporting VRML" ), RPT_SEVERITY_ERROR );
191 }
192 }
193 else
194 {
196 params.m_exportBoardBody = aStepJob->m_exportBoardBody;
197 params.m_exportComponents = aStepJob->m_exportComponents;
198 params.m_exportTracksVias = aStepJob->m_exportTracks;
199 params.m_exportPads = aStepJob->m_exportPads;
200 params.m_exportZones = aStepJob->m_exportZones;
201 params.m_exportInnerCopper = aStepJob->m_exportInnerCopper;
202 params.m_exportSilkscreen = aStepJob->m_exportSilkscreen;
203 params.m_exportSoldermask = aStepJob->m_exportSoldermask;
204 params.m_fuseShapes = aStepJob->m_fuseShapes;
206 params.m_includeDNP = aStepJob->m_includeDNP;
208 params.m_overwrite = aStepJob->m_overwrite;
209 params.m_substModels = aStepJob->m_substModels;
210 params.m_origin = VECTOR2D( aStepJob->m_xOrigin, aStepJob->m_yOrigin );
211 params.m_useDrillOrigin = aStepJob->m_useDrillOrigin;
212 params.m_useGridOrigin = aStepJob->m_useGridOrigin;
213 params.m_boardOnly = aStepJob->m_boardOnly;
214 params.m_optimizeStep = aStepJob->m_optimizeStep;
215 params.m_netFilter = aStepJob->m_netFilter;
216
217 switch( aStepJob->m_format )
218 {
221 break;
224 break;
227 break;
230 break;
231 default:
232 return CLI::EXIT_CODES::ERR_UNKNOWN; // shouldnt have gotten here
233 }
234
235 EXPORTER_STEP stepExporter( brd, params );
236 stepExporter.m_outputFile = aStepJob->m_outputFile;
237
238 if( !stepExporter.Export() )
240 }
241
242 return CLI::EXIT_CODES::OK;
243}
244
245
247{
248 JOB_PCB_RENDER* aRenderJob = dynamic_cast<JOB_PCB_RENDER*>( aJob );
249
250 if( aRenderJob == nullptr )
252
253 if( aJob->IsCli() )
254 m_reporter->Report( _( "Loading board\n" ), RPT_SEVERITY_INFO );
255
256 BOARD* brd = LoadBoard( aRenderJob->m_filename, true );
257 brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
259
260 BOARD_ADAPTER boardAdapter;
261
262 boardAdapter.SetBoard( brd );
263 boardAdapter.m_IsBoardView = false;
264 boardAdapter.m_IsPreviewer =
265 true; // Force display 3D models, regardless the 3D viewer options
266
269
270 if( aRenderJob->m_quality == JOB_PCB_RENDER::QUALITY::BASIC )
271 {
272 // Silkscreen is pixelated without antialiasing
274
275 cfg->m_Render.raytrace_backfloor = false;
277
279 cfg->m_Render.raytrace_reflections = false;
280 cfg->m_Render.raytrace_shadows = false;
281
282 // Better colors
284
285 // Tracks below soldermask are not visible without refractions
286 cfg->m_Render.raytrace_refractions = true;
288 }
289 else if( aRenderJob->m_quality == JOB_PCB_RENDER::QUALITY::HIGH )
290 {
292 cfg->m_Render.raytrace_backfloor = true;
295 cfg->m_Render.raytrace_reflections = true;
296 cfg->m_Render.raytrace_shadows = true;
297 cfg->m_Render.raytrace_refractions = true;
299 }
300
301 if( aRenderJob->m_floor )
302 {
303 cfg->m_Render.raytrace_backfloor = true;
304 cfg->m_Render.raytrace_shadows = true;
306 }
307
308 cfg->m_CurrentPreset = aRenderJob->m_colorPreset;
309 boardAdapter.m_Cfg = cfg;
310
313 && aRenderJob->m_format == JOB_PCB_RENDER::FORMAT::PNG ) )
314 {
315 boardAdapter.m_ColorOverrides[LAYER_3D_BACKGROUND_TOP] = COLOR4D( 1.0, 1.0, 1.0, 0.0 );
316 boardAdapter.m_ColorOverrides[LAYER_3D_BACKGROUND_BOTTOM] = COLOR4D( 1.0, 1.0, 1.0, 0.0 );
317 }
318
320
321 static std::map<JOB_PCB_RENDER::SIDE, VIEW3D_TYPE> s_viewCmdMap = {
322 { JOB_PCB_RENDER::SIDE::TOP, VIEW3D_TYPE::VIEW3D_TOP },
323 { JOB_PCB_RENDER::SIDE::BOTTOM, VIEW3D_TYPE::VIEW3D_BOTTOM },
324 { JOB_PCB_RENDER::SIDE::LEFT, VIEW3D_TYPE::VIEW3D_LEFT },
325 { JOB_PCB_RENDER::SIDE::RIGHT, VIEW3D_TYPE::VIEW3D_RIGHT },
326 { JOB_PCB_RENDER::SIDE::FRONT, VIEW3D_TYPE::VIEW3D_FRONT },
327 { JOB_PCB_RENDER::SIDE::BACK, VIEW3D_TYPE::VIEW3D_BACK },
328 };
329
330 PROJECTION_TYPE projection =
331 aRenderJob->m_perspective ? PROJECTION_TYPE::PERSPECTIVE : PROJECTION_TYPE::ORTHO;
332
333 wxSize windowSize( aRenderJob->m_width, aRenderJob->m_height );
334 TRACK_BALL camera( 2 * RANGE_SCALE_3D );
335
336 camera.SetProjection( projection );
337 camera.SetCurWindowSize( windowSize );
338
339 RENDER_3D_RAYTRACE_RAM raytrace( boardAdapter, camera );
340 raytrace.SetCurWindowSize( windowSize );
341
342 for( bool first = true; raytrace.Redraw( false, m_reporter, m_reporter ); first = false )
343 {
344 if( first )
345 {
346 const float cmTo3D = boardAdapter.BiuTo3dUnits() * pcbIUScale.mmToIU( 10.0 );
347
348 // First redraw resets lookat point to the board center, so set up the camera here
349 camera.ViewCommand_T1( s_viewCmdMap[aRenderJob->m_side] );
350
351 camera.SetLookAtPos_T1(
352 camera.GetLookAtPos_T1()
353 + SFVEC3F( aRenderJob->m_pivot.x, aRenderJob->m_pivot.y, aRenderJob->m_pivot.z )
354 * cmTo3D );
355
356 camera.Pan_T1(
357 SFVEC3F( aRenderJob->m_pan.x, aRenderJob->m_pan.y, aRenderJob->m_pan.z ) );
358
359 camera.Zoom_T1( aRenderJob->m_zoom );
360
361 camera.RotateX_T1( DEG2RAD( aRenderJob->m_rotation.x ) );
362 camera.RotateY_T1( DEG2RAD( aRenderJob->m_rotation.y ) );
363 camera.RotateZ_T1( DEG2RAD( aRenderJob->m_rotation.z ) );
364
365 camera.Interpolate( 1.0f );
366 camera.SetT0_and_T1_current_T();
367 camera.ParametersChanged();
368 }
369 }
370
371 GLubyte* rgbaBuffer = raytrace.GetBuffer();
372 wxSize realSize = raytrace.GetRealBufferSize();
373 bool success = !!rgbaBuffer;
374
375 if( rgbaBuffer )
376 {
377 const unsigned int wxh = realSize.x * realSize.y;
378
379 unsigned char* rgbBuffer = (unsigned char*) malloc( wxh * 3 );
380 unsigned char* alphaBuffer = (unsigned char*) malloc( wxh );
381
382 unsigned char* rgbaPtr = rgbaBuffer;
383 unsigned char* rgbPtr = rgbBuffer;
384 unsigned char* alphaPtr = alphaBuffer;
385
386 for( int y = 0; y < realSize.y; y++ )
387 {
388 for( int x = 0; x < realSize.x; x++ )
389 {
390 rgbPtr[0] = rgbaPtr[0];
391 rgbPtr[1] = rgbaPtr[1];
392 rgbPtr[2] = rgbaPtr[2];
393 alphaPtr[0] = rgbaPtr[3];
394
395 rgbaPtr += 4;
396 rgbPtr += 3;
397 alphaPtr += 1;
398 }
399 }
400
401 wxImage image( realSize );
402 image.SetData( rgbBuffer );
403 image.SetAlpha( alphaBuffer );
404 image = image.Mirror( false );
405
406 image.SetOption( wxIMAGE_OPTION_QUALITY, 90 );
407 image.SaveFile( aRenderJob->m_outputFile,
408 aRenderJob->m_format == JOB_PCB_RENDER::FORMAT::PNG ? wxBITMAP_TYPE_PNG
409 : wxBITMAP_TYPE_JPEG );
410 }
411
412 m_reporter->Report( wxString::Format( _( "Actual image size: %dx%d" ), realSize.x, realSize.y )
413 + wxS( "\n" ),
415
416 if( success )
417 m_reporter->Report( _( "Successfully created 3D render image" ) + wxS( "\n" ),
419 else
420 m_reporter->Report( _( "Error creating 3D render image" ) + wxS( "\n" ),
422
423 return CLI::EXIT_CODES::OK;
424}
425
426
428{
429 JOB_EXPORT_PCB_SVG* aSvgJob = dynamic_cast<JOB_EXPORT_PCB_SVG*>( aJob );
430
431 if( aSvgJob == nullptr )
433
434 PCB_PLOT_SVG_OPTIONS svgPlotOptions;
435 svgPlotOptions.m_blackAndWhite = aSvgJob->m_blackAndWhite;
436 svgPlotOptions.m_colorTheme = aSvgJob->m_colorTheme;
437 svgPlotOptions.m_outputFile = aSvgJob->m_outputFile;
438 svgPlotOptions.m_mirror = aSvgJob->m_mirror;
439 svgPlotOptions.m_negative = aSvgJob->m_negative;
440 svgPlotOptions.m_pageSizeMode = aSvgJob->m_pageSizeMode;
441 svgPlotOptions.m_printMaskLayer = aSvgJob->m_printMaskLayer;
442 svgPlotOptions.m_plotFrame = aSvgJob->m_plotDrawingSheet;
443 svgPlotOptions.m_sketchPadsOnFabLayers = aSvgJob->m_sketchPadsOnFabLayers;
444 svgPlotOptions.m_drillShapeOption = aSvgJob->m_drillShapeOption;
445
446 if( aJob->IsCli() )
447 m_reporter->Report( _( "Loading board\n" ), RPT_SEVERITY_INFO );
448
449 BOARD* brd = LoadBoard( aSvgJob->m_filename, true );
451 brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
453
454 if( aJob->IsCli() )
455 {
456 if( EXPORT_SVG::Plot( brd, svgPlotOptions ) )
457 m_reporter->Report( _( "Successfully created svg file" ) + wxS( "\n" ), RPT_SEVERITY_INFO );
458 else
459 m_reporter->Report( _( "Error creating svg file" ) + wxS( "\n" ), RPT_SEVERITY_ERROR );
460 }
461
462 return CLI::EXIT_CODES::OK;
463}
464
465
467{
468 JOB_EXPORT_PCB_DXF* aDxfJob = dynamic_cast<JOB_EXPORT_PCB_DXF*>( aJob );
469
470 if( aDxfJob == nullptr )
472
473 if( aJob->IsCli() )
474 m_reporter->Report( _( "Loading board\n" ), RPT_SEVERITY_INFO );
475
476 BOARD* brd = LoadBoard( aDxfJob->m_filename, true );
478 brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
480
481 if( aDxfJob->m_outputFile.IsEmpty() )
482 {
483 wxFileName fn = brd->GetFileName();
484 fn.SetName( fn.GetName() );
485 fn.SetExt( GetDefaultPlotExtension( PLOT_FORMAT::DXF ) );
486
487 aDxfJob->m_outputFile = fn.GetFullName();
488 }
489
490 PCB_PLOT_PARAMS plotOpts;
491 plotOpts.SetFormat( PLOT_FORMAT::DXF );
492
494
496 plotOpts.SetDXFPlotUnits( DXF_UNITS::MILLIMETERS );
497 else
498 plotOpts.SetDXFPlotUnits( DXF_UNITS::INCHES );
499
500 plotOpts.SetPlotFrameRef( aDxfJob->m_plotBorderTitleBlocks );
501 plotOpts.SetPlotValue( aDxfJob->m_plotFootprintValues );
502 plotOpts.SetPlotReference( aDxfJob->m_plotRefDes );
503 plotOpts.SetLayerSelection( aDxfJob->m_printMaskLayer );
504
506 wxString layerName;
507 wxString sheetName;
508 wxString sheetPath;
509
510 if( aDxfJob->m_printMaskLayer.size() == 1 )
511 {
512 layer = aDxfJob->m_printMaskLayer.front();
513 layerName = brd->GetLayerName( layer );
514 }
515
516 if( aJob->GetVarOverrides().contains( wxT( "LAYER" ) ) )
517 layerName = aJob->GetVarOverrides().at( wxT( "LAYER" ) );
518
519 if( aJob->GetVarOverrides().contains( wxT( "SHEETNAME" ) ) )
520 sheetName = aJob->GetVarOverrides().at( wxT( "SHEETNAME" ) );
521
522 if( aJob->GetVarOverrides().contains( wxT( "SHEETPATH" ) ) )
523 sheetPath = aJob->GetVarOverrides().at( wxT( "SHEETPATH" ) );
524
525 DXF_PLOTTER* plotter = (DXF_PLOTTER*) StartPlotBoard( brd, &plotOpts, layer, layerName,
526 aDxfJob->m_outputFile, sheetName,
527 sheetPath );
528
529 if( plotter )
530 {
531 PlotBoardLayers( brd, plotter, aDxfJob->m_printMaskLayer, plotOpts );
532 plotter->EndPlot();
533 }
534
535 delete plotter;
536
537 return CLI::EXIT_CODES::OK;
538}
539
540
542{
543 JOB_EXPORT_PCB_PDF* aPdfJob = dynamic_cast<JOB_EXPORT_PCB_PDF*>( aJob );
544
545 if( aPdfJob == nullptr )
547
548 if( aJob->IsCli() )
549 m_reporter->Report( _( "Loading board\n" ), RPT_SEVERITY_INFO );
550
551 BOARD* brd = LoadBoard( aPdfJob->m_filename, true );
553 brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
555
556 if( aPdfJob->m_outputFile.IsEmpty() )
557 {
558 wxFileName fn = brd->GetFileName();
559 fn.SetName( fn.GetName() );
560 fn.SetExt( GetDefaultPlotExtension( PLOT_FORMAT::PDF ) );
561
562 aPdfJob->m_outputFile = fn.GetFullName();
563 }
564
565 PCB_PLOT_PARAMS plotOpts;
566 plotOpts.SetFormat( PLOT_FORMAT::PDF );
567
568 plotOpts.SetPlotFrameRef( aPdfJob->m_plotBorderTitleBlocks );
569 plotOpts.SetPlotValue( aPdfJob->m_plotFootprintValues );
570 plotOpts.SetPlotReference( aPdfJob->m_plotRefDes );
571
572 plotOpts.SetLayerSelection( aPdfJob->m_printMaskLayer );
573
575 plotOpts.SetColorSettings( mgr.GetColorSettings( aPdfJob->m_colorTheme ) );
576 plotOpts.SetMirror( aPdfJob->m_mirror );
577 plotOpts.SetBlackAndWhite( aPdfJob->m_blackAndWhite );
578 plotOpts.SetNegative( aPdfJob->m_negative );
579
580 if( aPdfJob->m_sketchPadsOnFabLayers )
581 {
582 plotOpts.SetSketchPadsOnFabLayers( true );
583 plotOpts.SetPlotPadNumbers( true );
584 }
585
586 switch( aPdfJob->m_drillShapeOption )
587 {
588 default:
589 case 0: plotOpts.SetDrillMarksType( DRILL_MARKS::NO_DRILL_SHAPE ); break;
590 case 1: plotOpts.SetDrillMarksType( DRILL_MARKS::SMALL_DRILL_SHAPE ); break;
591 case 2: plotOpts.SetDrillMarksType( DRILL_MARKS::FULL_DRILL_SHAPE ); break;
592 }
593
595 wxString layerName;
596 wxString sheetName;
597 wxString sheetPath;
598
599 if( aPdfJob->m_printMaskLayer.size() == 1 )
600 {
601 layer = aPdfJob->m_printMaskLayer.front();
602 layerName = brd->GetLayerName( layer );
603 }
604
605 if( aPdfJob->GetVarOverrides().contains( wxT( "LAYER" ) ) )
606 layerName = aPdfJob->GetVarOverrides().at( wxT( "LAYER" ) );
607
608 if( aPdfJob->GetVarOverrides().contains( wxT( "SHEETNAME" ) ) )
609 sheetName = aPdfJob->GetVarOverrides().at( wxT( "SHEETNAME" ) );
610
611 if( aPdfJob->GetVarOverrides().contains( wxT( "SHEETPATH" ) ) )
612 sheetPath = aPdfJob->GetVarOverrides().at( wxT( "SHEETPATH" ) );
613
614 PDF_PLOTTER* plotter = (PDF_PLOTTER*) StartPlotBoard( brd, &plotOpts, layer, layerName,
615 aPdfJob->m_outputFile, sheetName,
616 sheetPath );
617
618 if( plotter )
619 {
620 PlotBoardLayers( brd, plotter, aPdfJob->m_printMaskLayer, plotOpts );
621 PlotInteractiveLayer( brd, plotter, plotOpts );
622 plotter->EndPlot();
623 }
624
625 delete plotter;
626
627 return CLI::EXIT_CODES::OK;
628}
629
630
632{
633 int exitCode = CLI::EXIT_CODES::OK;
634 JOB_EXPORT_PCB_GERBERS* aGerberJob = dynamic_cast<JOB_EXPORT_PCB_GERBERS*>( aJob );
635
636 if( aGerberJob == nullptr )
638
639 if( aJob->IsCli() )
640 m_reporter->Report( _( "Loading board\n" ), RPT_SEVERITY_INFO );
641
642 BOARD* brd = LoadBoard( aGerberJob->m_filename, true );
643 loadOverrideDrawingSheet( brd, aGerberJob->m_drawingSheet );
644 brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
646
647 PCB_PLOT_PARAMS boardPlotOptions = brd->GetPlotOptions();
648 LSET plotOnAllLayersSelection = boardPlotOptions.GetPlotOnAllLayersSelection();
649 GERBER_JOBFILE_WRITER jobfile_writer( brd );
650
651 wxString fileExt;
652
653 if( aGerberJob->m_useBoardPlotParams )
654 {
655 // The board plot options are saved with all copper layers enabled, even those that don't
656 // exist in the current stackup. This is done so the layers are automatically enabled in the plot
657 // dialog when the user enables them. We need to filter out these not-enabled layers here so
658 // we don't plot 32 layers when we only have 4, etc.
659 LSET plotLayers = ( boardPlotOptions.GetLayerSelection() & LSET::AllNonCuMask() )
660 | ( brd->GetEnabledLayers() & LSET::AllCuMask() );
661 aGerberJob->m_printMaskLayer = plotLayers.SeqStackupForPlotting();
662 aGerberJob->m_layersIncludeOnAll = boardPlotOptions.GetPlotOnAllLayersSelection();
663 }
664 else
665 {
666 // default to the board enabled layers
667 if( aGerberJob->m_printMaskLayer == 0 )
669
670 if( aGerberJob->m_layersIncludeOnAllSet )
671 aGerberJob->m_layersIncludeOnAll = plotOnAllLayersSelection;
672 }
673
674 for( LSEQ seq = LSET( aGerberJob->m_printMaskLayer ).UIOrder(); seq; ++seq )
675 {
676 LSEQ plotSequence;
677
678 // Base layer always gets plotted first.
679 plotSequence.push_back( *seq );
680
681 // Now all the "include on all" layers
682 for( LSEQ seqAll = aGerberJob->m_layersIncludeOnAll.UIOrder(); seqAll; ++seqAll )
683 {
684 // Don't plot the same layer more than once;
685 if( find( plotSequence.begin(), plotSequence.end(), *seqAll ) != plotSequence.end() )
686 continue;
687
688 plotSequence.push_back( *seqAll );
689 }
690
691 // Pick the basename from the board file
692 wxFileName fn( brd->GetFileName() );
693 PCB_LAYER_ID layer = *seq;
694 wxString layerName = brd->GetLayerName( layer );
695 wxString sheetName;
696 wxString sheetPath;
697 PCB_PLOT_PARAMS plotOpts;
698
699 if( aGerberJob->m_useBoardPlotParams )
700 plotOpts = boardPlotOptions;
701 else
702 populateGerberPlotOptionsFromJob( plotOpts, aGerberJob );
703
704 if( plotOpts.GetUseGerberProtelExtensions() )
705 fileExt = GetGerberProtelExtension( layer );
706 else
708
709 BuildPlotFileName( &fn, aGerberJob->m_outputFile, layerName, fileExt );
710 wxString fullname = fn.GetFullName();
711
712 jobfile_writer.AddGbrFile( layer, fullname );
713
714 if( aJob->GetVarOverrides().contains( wxT( "LAYER" ) ) )
715 layerName = aJob->GetVarOverrides().at( wxT( "LAYER" ) );
716
717 if( aJob->GetVarOverrides().contains( wxT( "SHEETNAME" ) ) )
718 sheetName = aJob->GetVarOverrides().at( wxT( "SHEETNAME" ) );
719
720 if( aJob->GetVarOverrides().contains( wxT( "SHEETPATH" ) ) )
721 sheetPath = aJob->GetVarOverrides().at( wxT( "SHEETPATH" ) );
722
723 // We are feeding it one layer at the start here to silence a logic check
724 GERBER_PLOTTER* plotter = (GERBER_PLOTTER*) StartPlotBoard( brd, &plotOpts, layer,
725 layerName, fn.GetFullPath(),
726 sheetName, sheetPath );
727
728 if( plotter )
729 {
730 m_reporter->Report( wxString::Format( _( "Plotted to '%s'.\n" ), fn.GetFullPath() ),
732 PlotBoardLayers( brd, plotter, plotSequence, plotOpts );
733 plotter->EndPlot();
734 }
735 else
736 {
737 m_reporter->Report( wxString::Format( _( "Failed to plot to '%s'.\n" ),
738 fn.GetFullPath() ),
741 }
742
743 delete plotter;
744 }
745
746 wxFileName fn( aGerberJob->m_filename );
747
748 // Build gerber job file from basename
749 BuildPlotFileName( &fn, aGerberJob->m_outputFile, wxT( "job" ),
751 jobfile_writer.CreateJobFile( fn.GetFullPath() );
752
753 return exitCode;
754}
755
756
759{
760 aPlotOpts.SetFormat( PLOT_FORMAT::GERBER );
761
762 aPlotOpts.SetPlotFrameRef( aJob->m_plotBorderTitleBlocks );
763 aPlotOpts.SetPlotValue( aJob->m_plotFootprintValues );
764 aPlotOpts.SetPlotReference( aJob->m_plotRefDes );
765
767
768 // Always disable plot pad holes
769 aPlotOpts.SetDrillMarksType( DRILL_MARKS::NO_DRILL_SHAPE );
770
772 aPlotOpts.SetUseGerberX2format( aJob->m_useX2Format );
774 aPlotOpts.SetUseAuxOrigin( aJob->m_useAuxOrigin );
776 aPlotOpts.SetGerberPrecision( aJob->m_precision );
777}
778
779
781{
782 int exitCode = CLI::EXIT_CODES::OK;
783 JOB_EXPORT_PCB_GERBER* aGerberJob = dynamic_cast<JOB_EXPORT_PCB_GERBER*>( aJob );
784
785 if( aGerberJob == nullptr )
787
788 if( aJob->IsCli() )
789 m_reporter->Report( _( "Loading board\n" ), RPT_SEVERITY_INFO );
790
791 BOARD* brd = LoadBoard( aGerberJob->m_filename, true );
792 brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
794
795 if( aGerberJob->m_outputFile.IsEmpty() )
796 {
797 wxFileName fn = brd->GetFileName();
798 fn.SetName( fn.GetName() );
799 fn.SetExt( GetDefaultPlotExtension( PLOT_FORMAT::GERBER ) );
800
801 aGerberJob->m_outputFile = fn.GetFullName();
802 }
803
804 PCB_PLOT_PARAMS plotOpts;
805 populateGerberPlotOptionsFromJob( plotOpts, aGerberJob );
806 plotOpts.SetLayerSelection( aGerberJob->m_printMaskLayer );
807
809 wxString layerName;
810 wxString sheetName;
811 wxString sheetPath;
812
813 if( aGerberJob->m_printMaskLayer.size() == 1 )
814 {
815 layer = aGerberJob->m_printMaskLayer.front();
816 layerName = brd->GetLayerName( layer );
817 }
818
819 if( aJob->GetVarOverrides().contains( wxT( "LAYER" ) ) )
820 layerName = aJob->GetVarOverrides().at( wxT( "LAYER" ) );
821
822 if( aJob->GetVarOverrides().contains( wxT( "SHEETNAME" ) ) )
823 sheetName = aJob->GetVarOverrides().at( wxT( "SHEETNAME" ) );
824
825 if( aJob->GetVarOverrides().contains( wxT( "SHEETPATH" ) ) )
826 sheetPath = aJob->GetVarOverrides().at( wxT( "SHEETPATH" ) );
827
828 // We are feeding it one layer at the start here to silence a logic check
829 GERBER_PLOTTER* plotter = (GERBER_PLOTTER*) StartPlotBoard( brd, &plotOpts, layer, layerName,
830 aGerberJob->m_outputFile,
831 sheetName, sheetPath );
832
833 if( plotter )
834 {
835 PlotBoardLayers( brd, plotter, aGerberJob->m_printMaskLayer, plotOpts );
836 plotter->EndPlot();
837 }
838 else
839 {
840 m_reporter->Report( wxString::Format( _( "Failed to plot to '%s'.\n" ),
841 aGerberJob->m_outputFile ),
844 }
845
846 delete plotter;
847
848 return exitCode;
849}
850
853
854
856{
857 JOB_EXPORT_PCB_DRILL* aDrillJob = dynamic_cast<JOB_EXPORT_PCB_DRILL*>( aJob );
858
859 if( aDrillJob == nullptr )
861
862 if( aJob->IsCli() )
863 m_reporter->Report( _( "Loading board\n" ), RPT_SEVERITY_INFO );
864
865 BOARD* brd = LoadBoard( aDrillJob->m_filename, true );
866
867 // ensure output dir exists
868 wxFileName fn( aDrillJob->m_outputDir + wxT( "/" ) );
869
870 if( !fn.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
871 {
872 m_reporter->Report( _( "Failed to create output directory\n" ), RPT_SEVERITY_ERROR );
874 }
875
876 std::unique_ptr<GENDRILL_WRITER_BASE> drillWriter;
877
879 drillWriter = std::make_unique<EXCELLON_WRITER>( brd );
880 else
881 drillWriter = std::make_unique<GERBER_WRITER>( brd );
882
883 VECTOR2I offset;
884
886 offset = VECTOR2I( 0, 0 );
887 else
888 offset = brd->GetDesignSettings().GetAuxOrigin();
889
890 PLOT_FORMAT mapFormat = PLOT_FORMAT::PDF;
891
892 switch( aDrillJob->m_mapFormat )
893 {
894 case JOB_EXPORT_PCB_DRILL::MAP_FORMAT::POSTSCRIPT: mapFormat = PLOT_FORMAT::POST; break;
895 case JOB_EXPORT_PCB_DRILL::MAP_FORMAT::GERBER_X2: mapFormat = PLOT_FORMAT::GERBER; break;
896 case JOB_EXPORT_PCB_DRILL::MAP_FORMAT::DXF: mapFormat = PLOT_FORMAT::DXF; break;
897 case JOB_EXPORT_PCB_DRILL::MAP_FORMAT::SVG: mapFormat = PLOT_FORMAT::SVG; break;
898 default:
899 case JOB_EXPORT_PCB_DRILL::MAP_FORMAT::PDF: mapFormat = PLOT_FORMAT::PDF; break;
900 }
901
903 {
905 switch( aDrillJob->m_zeroFormat )
906 {
909 break;
912 break;
915 break;
917 default:
919 break;
920 }
921
922 DRILL_PRECISION precision;
923
925 precision = precisionListForInches;
926 else
927 precision = precisionListForMetric;
928
929 EXCELLON_WRITER* excellonWriter = dynamic_cast<EXCELLON_WRITER*>( drillWriter.get() );
930
931 if( excellonWriter == nullptr )
933
934 excellonWriter->SetFormat( aDrillJob->m_drillUnits
936 zeroFmt, precision.m_Lhs, precision.m_Rhs );
937 excellonWriter->SetOptions( aDrillJob->m_excellonMirrorY,
938 aDrillJob->m_excellonMinimalHeader,
939 offset, aDrillJob->m_excellonCombinePTHNPTH );
940 excellonWriter->SetRouteModeForOvalHoles( aDrillJob->m_excellonOvalDrillRoute );
941 excellonWriter->SetMapFileFormat( mapFormat );
942
943 if( !excellonWriter->CreateDrillandMapFilesSet( aDrillJob->m_outputDir, true,
944 aDrillJob->m_generateMap, m_reporter ) )
945 {
947 }
948 }
950 {
951 GERBER_WRITER* gerberWriter = dynamic_cast<GERBER_WRITER*>( drillWriter.get() );
952
953 if( gerberWriter == nullptr )
955
956 // Set gerber precision: only 5 or 6 digits for mantissa are allowed
957 // (SetFormat() accept 5 or 6, and any other value set the precision to 5)
958 // the integer part precision is always 4, and units always mm
959 gerberWriter->SetFormat( aDrillJob->m_gerberPrecision );
960 gerberWriter->SetOptions( offset );
961 gerberWriter->SetMapFileFormat( mapFormat );
962
963 if( !gerberWriter->CreateDrillandMapFilesSet( aDrillJob->m_outputDir, true,
964 aDrillJob->m_generateMap, m_reporter ) )
965 {
967 }
968 }
969
970 return CLI::EXIT_CODES::OK;
971}
972
973
975{
976 JOB_EXPORT_PCB_POS* aPosJob = dynamic_cast<JOB_EXPORT_PCB_POS*>( aJob );
977
978 if( aPosJob == nullptr )
980
981 if( aJob->IsCli() )
982 m_reporter->Report( _( "Loading board\n" ), RPT_SEVERITY_INFO );
983
984 BOARD* brd = LoadBoard( aPosJob->m_filename, true );
985
986 if( aPosJob->m_outputFile.IsEmpty() )
987 {
988 wxFileName fn = brd->GetFileName();
989 fn.SetName( fn.GetName() );
990
993 else if( aPosJob->m_format == JOB_EXPORT_PCB_POS::FORMAT::CSV )
994 fn.SetExt( FILEEXT::CsvFileExtension );
995 else if( aPosJob->m_format == JOB_EXPORT_PCB_POS::FORMAT::GERBER )
996 fn.SetExt( FILEEXT::GerberFileExtension );
997
998 aPosJob->m_outputFile = fn.GetFullName();
999 }
1000
1003 {
1004 FILE* file = nullptr;
1005 file = wxFopen( aPosJob->m_outputFile, wxS( "wt" ) );
1006
1007 if( file == nullptr )
1009
1010 std::string data;
1011
1012 bool frontSide = aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::FRONT
1014
1015 bool backSide = aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::BACK
1017
1018 PLACE_FILE_EXPORTER exporter( brd,
1020 aPosJob->m_smdOnly, aPosJob->m_excludeFootprintsWithTh,
1021 aPosJob->m_excludeDNP,
1022 frontSide, backSide,
1025 aPosJob->m_negateBottomX );
1026 data = exporter.GenPositionData();
1027
1028 fputs( data.c_str(), file );
1029 fclose( file );
1030 }
1031 else if( aPosJob->m_format == JOB_EXPORT_PCB_POS::FORMAT::GERBER )
1032 {
1033 PLACEFILE_GERBER_WRITER exporter( brd );
1034
1035 PCB_LAYER_ID gbrLayer = F_Cu;
1036
1037 if( aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::BACK )
1038 gbrLayer = B_Cu;
1039
1040 exporter.CreatePlaceFile( aPosJob->m_outputFile, gbrLayer, aPosJob->m_gerberBoardEdge );
1041 }
1042
1043 return CLI::EXIT_CODES::OK;
1044}
1045
1046extern FOOTPRINT* try_load_footprint( const wxFileName& aFileName, PCB_IO_MGR::PCB_FILE_T aFileType,
1047 const wxString& aName );
1048
1049
1051{
1052 JOB_FP_UPGRADE* upgradeJob = dynamic_cast<JOB_FP_UPGRADE*>( aJob );
1053
1054 if( upgradeJob == nullptr )
1056
1058
1059 if( !upgradeJob->m_outputLibraryPath.IsEmpty() )
1060 {
1061 if( wxFile::Exists( upgradeJob->m_outputLibraryPath ) ||
1062 wxDir::Exists( upgradeJob->m_outputLibraryPath) )
1063 {
1064 m_reporter->Report( _( "Output path must not conflict with existing path\n" ),
1067 }
1068 }
1069 else if( fileType != PCB_IO_MGR::KICAD_SEXP )
1070 {
1071 m_reporter->Report( _( "Output path must be specified to convert legacy and non-KiCad libraries\n" ),
1073
1075 }
1076
1078 {
1079 if( !wxDir::Exists( upgradeJob->m_libraryPath ) )
1080 {
1081 m_reporter->Report( _( "Footprint library path does not exist or is not accessible\n" ),
1084 }
1085
1086
1087 if( aJob->IsCli() )
1088 m_reporter->Report( _( "Loading footprint library\n" ), RPT_SEVERITY_INFO );
1089
1091 FP_CACHE fpLib( &pcb_io, upgradeJob->m_libraryPath );
1092
1093 try
1094 {
1095 fpLib.Load();
1096 }
1097 catch( ... )
1098 {
1099 m_reporter->Report( _( "Unable to load library\n" ), RPT_SEVERITY_ERROR );
1101 }
1102
1103 bool shouldSave = upgradeJob->m_force;
1104
1105 for( const auto& footprint : fpLib.GetFootprints() )
1106 {
1107 if( footprint.second->GetFootprint()->GetFileFormatVersionAtLoad()
1109 {
1110 shouldSave = true;
1111 }
1112 }
1113
1114 if( shouldSave )
1115 {
1116 m_reporter->Report( _( "Saving footprint library\n" ), RPT_SEVERITY_INFO );
1117
1118 try
1119 {
1120 if( !upgradeJob->m_outputLibraryPath.IsEmpty() )
1121 {
1122 fpLib.SetPath( upgradeJob->m_outputLibraryPath );
1123 }
1124
1125 fpLib.Save();
1126 }
1127 catch( ... )
1128 {
1129 m_reporter->Report( _( "Unable to save library\n" ), RPT_SEVERITY_ERROR );
1131 }
1132 }
1133 else
1134 {
1135 m_reporter->Report( _( "Footprint library was not updated\n" ), RPT_SEVERITY_INFO );
1136 }
1137 }
1138 else
1139 {
1140 if( !PCB_IO_MGR::ConvertLibrary( nullptr, upgradeJob->m_libraryPath, upgradeJob->m_outputLibraryPath ) )
1141 {
1142 m_reporter->Report( ( "Unable to convert library\n" ), RPT_SEVERITY_ERROR );
1144 }
1145 }
1146
1147 return CLI::EXIT_CODES::OK;
1148}
1149
1150
1152{
1153 JOB_FP_EXPORT_SVG* svgJob = dynamic_cast<JOB_FP_EXPORT_SVG*>( aJob );
1154
1155 if( svgJob == nullptr )
1157
1158 if( aJob->IsCli() )
1159 m_reporter->Report( _( "Loading footprint library\n" ), RPT_SEVERITY_INFO );
1160
1162 FP_CACHE fpLib( &pcb_io, svgJob->m_libraryPath );
1163
1164 try
1165 {
1166 fpLib.Load();
1167 }
1168 catch( ... )
1169 {
1170 m_reporter->Report( _( "Unable to load library\n" ), RPT_SEVERITY_ERROR );
1172 }
1173
1174 if( !svgJob->m_outputDirectory.IsEmpty() && !wxDir::Exists( svgJob->m_outputDirectory ) )
1175 {
1176 wxFileName::Mkdir( svgJob->m_outputDirectory );
1177 }
1178
1179 int exitCode = CLI::EXIT_CODES::OK;
1180
1181 // Just plot all the symbols we can
1182 FP_CACHE_FOOTPRINT_MAP& footprintMap = fpLib.GetFootprints();
1183
1184 bool singleFpPlotted = false;
1185 for( FP_CACHE_FOOTPRINT_MAP::iterator it = footprintMap.begin(); it != footprintMap.end();
1186 ++it )
1187 {
1188 const FOOTPRINT* fp = it->second->GetFootprint();
1189 if( !svgJob->m_footprint.IsEmpty() )
1190 {
1191 if( fp->GetFPID().GetLibItemName().wx_str() != svgJob->m_footprint )
1192 {
1193 // skip until we find the right footprint
1194 continue;
1195 }
1196 else
1197 {
1198 singleFpPlotted = true;
1199 }
1200 }
1201
1202 exitCode = doFpExportSvg( svgJob, fp );
1203 if( exitCode != CLI::EXIT_CODES::OK )
1204 break;
1205 }
1206
1207 if( !svgJob->m_footprint.IsEmpty() && !singleFpPlotted )
1208 {
1209 m_reporter->Report( _( "The given footprint could not be found to export." ) + wxS( "\n" ),
1211 }
1212
1213 return CLI::EXIT_CODES::OK;
1214}
1215
1216
1218{
1219 // the hack for now is we create fake boards containing the footprint and plot the board
1220 // until we refactor better plot api later
1221 std::unique_ptr<BOARD> brd;
1222 brd.reset( CreateEmptyBoard() );
1223 brd->GetProject()->ApplyTextVars( aSvgJob->GetVarOverrides() );
1224 brd->SynchronizeProperties();
1225
1226 FOOTPRINT* fp = dynamic_cast<FOOTPRINT*>( aFootprint->Clone() );
1227
1228 if( fp == nullptr )
1230
1231 fp->SetLink( niluuid );
1232 fp->SetFlags( IS_NEW );
1233 fp->SetParent( brd.get() );
1234
1235 for( PAD* pad : fp->Pads() )
1236 {
1237 pad->SetLocalRatsnestVisible( false );
1238 pad->SetNetCode( 0 );
1239 }
1240
1241 fp->SetOrientation( ANGLE_0 );
1242 fp->SetPosition( VECTOR2I( 0, 0 ) );
1243
1244 brd->Add( fp, ADD_MODE::INSERT, true );
1245
1246 wxFileName outputFile;
1247 outputFile.SetPath( aSvgJob->m_outputDirectory );
1248 outputFile.SetName( aFootprint->GetFPID().GetLibItemName().wx_str() );
1249 outputFile.SetExt( FILEEXT::SVGFileExtension );
1250
1251 m_reporter->Report( wxString::Format( _( "Plotting footprint '%s' to '%s'\n" ),
1252 aFootprint->GetFPID().GetLibItemName().wx_str(),
1253 outputFile.GetFullPath() ),
1255
1256
1257 PCB_PLOT_SVG_OPTIONS svgPlotOptions;
1258 svgPlotOptions.m_blackAndWhite = aSvgJob->m_blackAndWhite;
1259 svgPlotOptions.m_colorTheme = aSvgJob->m_colorTheme;
1260 svgPlotOptions.m_outputFile = outputFile.GetFullPath();
1261 svgPlotOptions.m_mirror = false;
1262 svgPlotOptions.m_pageSizeMode = 2; // board bounding box
1263 svgPlotOptions.m_printMaskLayer = aSvgJob->m_printMaskLayer;
1264 svgPlotOptions.m_sketchPadsOnFabLayers = aSvgJob->m_sketchPadsOnFabLayers;
1265 svgPlotOptions.m_plotFrame = false;
1266
1267 if( !EXPORT_SVG::Plot( brd.get(), svgPlotOptions ) )
1268 m_reporter->Report( _( "Error creating svg file" ) + wxS( "\n" ), RPT_SEVERITY_ERROR );
1269
1270 return CLI::EXIT_CODES::OK;
1271}
1272
1273
1275{
1276 JOB_PCB_DRC* drcJob = dynamic_cast<JOB_PCB_DRC*>( aJob );
1277
1278 if( drcJob == nullptr )
1280
1281 if( aJob->IsCli() )
1282 m_reporter->Report( _( "Loading board\n" ), RPT_SEVERITY_INFO );
1283
1284 BOARD* brd = LoadBoard( drcJob->m_filename, true );
1285 brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
1286 brd->SynchronizeProperties();
1287
1288 if( drcJob->m_outputFile.IsEmpty() )
1289 {
1290 wxFileName fn = brd->GetFileName();
1291 fn.SetName( fn.GetName() );
1292
1294 fn.SetExt( FILEEXT::JsonFileExtension );
1295 else
1296 fn.SetExt( FILEEXT::ReportFileExtension );
1297
1298 drcJob->m_outputFile = fn.GetFullName();
1299 }
1300
1301 EDA_UNITS units;
1302
1303 switch( drcJob->m_units )
1304 {
1305 case JOB_PCB_DRC::UNITS::INCHES: units = EDA_UNITS::INCHES; break;
1306 case JOB_PCB_DRC::UNITS::MILS: units = EDA_UNITS::MILS; break;
1307 case JOB_PCB_DRC::UNITS::MILLIMETERS: units = EDA_UNITS::MILLIMETRES; break;
1308 default: units = EDA_UNITS::MILLIMETRES; break;
1309 }
1310
1311 std::shared_ptr<DRC_ENGINE> drcEngine = brd->GetDesignSettings().m_DRCEngine;
1312 std::unique_ptr<NETLIST> netlist = std::make_unique<NETLIST>();
1313
1314 drcEngine->SetDrawingSheet( getDrawingSheetProxyView( brd ) );
1315
1316 // BOARD_COMMIT uses TOOL_MANAGER to grab the board internally so we must give it one
1317 TOOL_MANAGER* toolManager = new TOOL_MANAGER;
1318 toolManager->SetEnvironment( brd, nullptr, nullptr, Kiface().KifaceSettings(), nullptr );
1319
1320 BOARD_COMMIT commit( toolManager );
1321
1322 m_reporter->Report( _( "Running DRC...\n" ), RPT_SEVERITY_INFO );
1323
1324 if( drcJob->m_parity )
1325 {
1326 typedef bool (*NETLIST_FN_PTR)( const wxString&, std::string& );
1327
1329 wxFileName schematicPath( drcJob->m_filename );
1330 NETLIST_FN_PTR netlister = (NETLIST_FN_PTR) eeschema->IfaceOrAddress( KIFACE_NETLIST_SCHEMATIC );
1331 std::string netlist_str;
1332
1333 schematicPath.SetExt( FILEEXT::KiCadSchematicFileExtension );
1334
1335 if( !schematicPath.Exists() )
1336 schematicPath.SetExt( FILEEXT::LegacySchematicFileExtension );
1337
1338 if( !schematicPath.Exists() )
1339 {
1340 m_reporter->Report( _( "Failed to find schematic for parity tests.\n" ),
1342 }
1343 else
1344 {
1345 (*netlister)( schematicPath.GetFullPath(), netlist_str );
1346
1347 try
1348 {
1349 auto lineReader = new STRING_LINE_READER( netlist_str, _( "Eeschema netlist" ) );
1350 KICAD_NETLIST_READER netlistReader( lineReader, netlist.get() );
1351 netlistReader.LoadNetlist();
1352 }
1353 catch( const IO_ERROR& )
1354 {
1355 m_reporter->Report( _( "Failed to fetch schematic netlist for parity tests.\n" ),
1357 }
1358
1359 drcEngine->SetSchematicNetlist( netlist.get() );
1360 }
1361 }
1362
1363 drcEngine->SetProgressReporter( nullptr );
1364 drcEngine->SetViolationHandler(
1365 [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer )
1366 {
1367 PCB_MARKER* marker = new PCB_MARKER( aItem, aPos, aLayer );
1368 commit.Add( marker );
1369 } );
1370
1371 brd->RecordDRCExclusions();
1372 brd->DeleteMARKERs( true, true );
1373 drcEngine->RunTests( units, drcJob->m_reportAllTrackErrors, drcJob->m_parity );
1374 drcEngine->ClearViolationHandler();
1375
1376 commit.Push( _( "DRC" ), SKIP_UNDO | SKIP_SET_DIRTY );
1377
1378 // Update the exclusion status on any excluded markers that still exist.
1379 brd->ResolveDRCExclusions( false );
1380
1381 std::shared_ptr<DRC_ITEMS_PROVIDER> markersProvider = std::make_shared<DRC_ITEMS_PROVIDER>(
1383
1384 std::shared_ptr<DRC_ITEMS_PROVIDER> ratsnestProvider =
1385 std::make_shared<DRC_ITEMS_PROVIDER>( brd, MARKER_BASE::MARKER_RATSNEST );
1386
1387 std::shared_ptr<DRC_ITEMS_PROVIDER> fpWarningsProvider =
1388 std::make_shared<DRC_ITEMS_PROVIDER>( brd, MARKER_BASE::MARKER_PARITY );
1389
1390 markersProvider->SetSeverities( drcJob->m_severity );
1391 ratsnestProvider->SetSeverities( drcJob->m_severity );
1392 fpWarningsProvider->SetSeverities( drcJob->m_severity );
1393
1394 m_reporter->Report( wxString::Format( _( "Found %d violations\n" ),
1395 markersProvider->GetCount() ),
1397 m_reporter->Report( wxString::Format( _( "Found %d unconnected items\n" ),
1398 ratsnestProvider->GetCount() ),
1400
1401 if( drcJob->m_parity )
1402 {
1403 m_reporter->Report( wxString::Format( _( "Found %d schematic parity issues\n" ),
1404 fpWarningsProvider->GetCount() ),
1406 }
1407
1408 DRC_REPORT reportWriter( brd, units, markersProvider, ratsnestProvider, fpWarningsProvider );
1409
1410 bool wroteReport = false;
1411
1413 wroteReport = reportWriter.WriteJsonReport( drcJob->m_outputFile );
1414 else
1415 wroteReport = reportWriter.WriteTextReport( drcJob->m_outputFile );
1416
1417 if( !wroteReport )
1418 {
1419 m_reporter->Report( wxString::Format( _( "Unable to save DRC report to %s\n" ),
1420 drcJob->m_outputFile ),
1423 }
1424
1425 m_reporter->Report( wxString::Format( _( "Saved DRC Report to %s\n" ),
1426 drcJob->m_outputFile ),
1428
1429 if( drcJob->m_exitCodeViolations )
1430 {
1431 if( markersProvider->GetCount() > 0 || ratsnestProvider->GetCount() > 0
1432 || fpWarningsProvider->GetCount() > 0 )
1433 {
1435 }
1436 }
1437
1439}
1440
1441
1443{
1444 JOB_EXPORT_PCB_IPC2581* job = dynamic_cast<JOB_EXPORT_PCB_IPC2581*>( aJob );
1445
1446 if( job == nullptr )
1448
1449 if( job->IsCli() )
1450 m_reporter->Report( _( "Loading board\n" ), RPT_SEVERITY_INFO );
1451
1452 BOARD* brd = LoadBoard( job->m_filename, true );
1453
1454 if( job->m_outputFile.IsEmpty() )
1455 {
1456 wxFileName fn = brd->GetFileName();
1457 fn.SetName( fn.GetName() );
1458 fn.SetExt( FILEEXT::Ipc2581FileExtension );
1459
1460 job->m_outputFile = fn.GetFullName();
1461 }
1462
1463 STRING_UTF8_MAP props;
1464 props["units"] = job->m_units == JOB_EXPORT_PCB_IPC2581::IPC2581_UNITS::MILLIMETERS ? "mm"
1465 : "inch";
1466 props["sigfig"] = wxString::Format( "%d", job->m_precision );
1467 props["version"] = job->m_version == JOB_EXPORT_PCB_IPC2581::IPC2581_VERSION::C ? "C" : "B";
1468 props["OEMRef"] = job->m_colInternalId;
1469 props["mpn"] = job->m_colMfgPn;
1470 props["mfg"] = job->m_colMfg;
1471 props["dist"] = job->m_colDist;
1472 props["distpn"] = job->m_colDistPn;
1473
1474 wxString tempFile = wxFileName::CreateTempFileName( wxS( "pcbnew_ipc" ) );
1475 try
1476 {
1478 pi->SetProgressReporter( m_progressReporter );
1479 pi->SaveBoard( tempFile, brd, &props );
1480 }
1481 catch( const IO_ERROR& ioe )
1482 {
1483 m_reporter->Report( wxString::Format( _( "Error generating IPC2581 file '%s'.\n%s" ),
1484 job->m_filename, ioe.What() ),
1486
1487 wxRemoveFile( tempFile );
1488
1490 }
1491
1492 if( job->m_compress )
1493 {
1494 wxFileName tempfn = job->m_outputFile;
1495 tempfn.SetExt( FILEEXT::Ipc2581FileExtension );
1496 wxFileName zipfn = tempFile;
1497 zipfn.SetExt( "zip" );
1498
1499 wxFFileOutputStream fnout( zipfn.GetFullPath() );
1500 wxZipOutputStream zip( fnout );
1501 wxFFileInputStream fnin( tempFile );
1502
1503 zip.PutNextEntry( tempfn.GetFullName() );
1504 fnin.Read( zip );
1505 zip.Close();
1506 fnout.Close();
1507
1508 wxRemoveFile( tempFile );
1509 tempFile = zipfn.GetFullPath();
1510 }
1511
1512 // If save succeeded, replace the original with what we just wrote
1513 if( !wxRenameFile( tempFile, job->m_outputFile ) )
1514 {
1515 m_reporter->Report( wxString::Format( _( "Error generating IPC2581 file '%s'.\n"
1516 "Failed to rename temporary file '%s." )
1517 + wxS( "\n" ),
1518 job->m_outputFile, tempFile ),
1520 }
1521
1523}
1524
1525
1527{
1529 &aBrd->GetPageSettings(),
1530 aBrd->GetProject(),
1531 &aBrd->GetTitleBlock(),
1532 &aBrd->GetProperties() );
1533
1534 drawingSheet->SetSheetName( std::string() );
1535 drawingSheet->SetSheetPath( std::string() );
1536 drawingSheet->SetIsFirstPage( true );
1537
1538 drawingSheet->SetFileName( TO_UTF8( aBrd->GetFileName() ) );
1539
1540 return drawingSheet;
1541}
1542
1543
1544void PCBNEW_JOBS_HANDLER::loadOverrideDrawingSheet( BOARD* aBrd, const wxString& aSheetPath )
1545{
1546 // dont bother attempting to load a empty path, if there was one
1547 if( aSheetPath.IsEmpty() )
1548 return;
1549
1550 auto loadSheet =
1551 [&]( const wxString& path ) -> bool
1552 {
1555 aBrd->GetProject()->GetProjectPath() );
1556
1557 if( !DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet( filename ) )
1558 {
1559 m_reporter->Report( wxString::Format( _( "Error loading drawing sheet '%s'." ) + wxS( "\n" ),
1560 path ),
1562 return false;
1563 }
1564
1565 return true;
1566 };
1567
1568 if( loadSheet( aSheetPath ) )
1569 return;
1570
1571 // failed loading custom path, revert back to default
1572 loadSheet( aBrd->GetProject()->GetProjectFile().m_BoardDrawingSheetFile );
1573}
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:282
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:680
const PAGE_INFO & GetPageSettings() const
Definition: board.h:666
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false, bool aIncludeHiddenText=false) const
Calculate the bounding box containing all board items (or board edge segments).
Definition: board.cpp:1555
void RecordDRCExclusions()
Scan existing markers and record data from any that are Excluded.
Definition: board.cpp:320
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:672
const std::map< wxString, wxString > & GetProperties() const
Definition: board.h:354
const wxString & GetFileName() const
Definition: board.h:319
std::vector< PCB_MARKER * > ResolveDRCExclusions(bool aCreateMarkers)
Rebuild DRC markers from the serialized data in BOARD_DESIGN_SETTINGS.
Definition: board.cpp:337
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: board.h:669
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:567
PROJECT * GetProject() const
Definition: board.h:476
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:797
void SynchronizeProperties()
Copy the current project's text variables into the boards property cache.
Definition: board.cpp:1927
void DeleteMARKERs()
Delete all MARKERS from the board.
Definition: board.cpp:1242
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.
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
static const wxString ResolvePath(const wxString &aPath, const wxString &aProjectPath)
Resolve a path which might be project-relative or contain env variable references.
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:126
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:103
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:90
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
void SetPosition(const VECTOR2I &aPos) override
Definition: footprint.cpp:2332
void SetLink(const KIID &aLink)
Definition: footprint.h:840
void SetOrientation(const EDA_ANGLE &aNewAngle)
Definition: footprint.cpp:2404
EDA_ITEM * Clone() const override
Invoke a function on all children.
Definition: footprint.cpp:2021
PADS & Pads()
Definition: footprint.h:193
const LIB_ID & GetFPID() const
Definition: footprint.h:235
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: layer_ids.h:522
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:576
LSEQ UIOrder() const
Definition: lset.cpp:1012
LSEQ SeqStackupForPlotting() const
Return the sequence that is typical for a bottom-to-top stack-up.
Definition: lset.cpp:563
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
Definition: lset.cpp:884
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:863
@ MARKER_DRAWING_SHEET
Definition: marker_base.h:56
Definition: pad.h:53
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
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:453
@ LAYER_3D_BACKGROUND_BOTTOM
Definition: layer_ids.h:452
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:42
void BuildPlotFileName(wxFileName *aFilename, const wxString &aOutputDir, const wxString &aSuffix, const wxString &aExtension)
Complete a plot filename.
Definition: pcbplot.cpp:361
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