KiCad PCB EDA Suite
Loading...
Searching...
No Matches
eeschema_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-2023 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
22#include <common.h>
23#include <pgm_base.h>
24#include <cli/exit_codes.h>
25#include <sch_plotter.h>
31#include <jobs/job_sch_erc.h>
34#include <schematic.h>
35#include <wx/dir.h>
36#include <wx/file.h>
37#include <memory>
38#include <connection_graph.h>
39#include "eeschema_helpers.h"
40#include <kiway.h>
41#include <sch_painter.h>
42#include <locale_io.h>
43#include <erc.h>
44#include <erc_report.h>
48#include <reporter.h>
49#include <string_utils.h>
50
52
53#include <sch_file_versions.h>
55
56#include <netlist.h>
66
67#include <fields_data_model.h>
68
69
71 JOB_DISPATCHER( aKiway )
72{
73 Register( "bom",
74 std::bind( &EESCHEMA_JOBS_HANDLER::JobExportBom, this, std::placeholders::_1 ) );
75 Register( "pythonbom",
77 std::placeholders::_1 ) );
78 Register( "netlist",
79 std::bind( &EESCHEMA_JOBS_HANDLER::JobExportNetlist, this, std::placeholders::_1 ) );
80 Register( "plot",
81 std::bind( &EESCHEMA_JOBS_HANDLER::JobExportPlot, this, std::placeholders::_1 ) );
82 Register( "symupgrade",
83 std::bind( &EESCHEMA_JOBS_HANDLER::JobSymUpgrade, this, std::placeholders::_1 ) );
84 Register( "symsvg",
85 std::bind( &EESCHEMA_JOBS_HANDLER::JobSymExportSvg, this, std::placeholders::_1 ) );
86 Register( "erc",
87 std::bind( &EESCHEMA_JOBS_HANDLER::JobSchErc, this, std::placeholders::_1 ) );
88}
89
90
92 const wxString& aTheme, SCHEMATIC* aSch,
93 const wxString& aDrawingSheetOverride )
94{
96 aRenderSettings->LoadColors( cs );
97
98 aRenderSettings->SetDefaultPenWidth( aSch->Settings().m_DefaultLineWidth );
99 aRenderSettings->m_LabelSizeRatio = aSch->Settings().m_LabelSizeRatio;
100 aRenderSettings->m_TextOffsetRatio = aSch->Settings().m_TextOffsetRatio;
101 aRenderSettings->m_PinSymbolSize = aSch->Settings().m_PinSymbolSize;
102
103 aRenderSettings->SetDashLengthRatio( aSch->Settings().m_DashedLineDashRatio );
104 aRenderSettings->SetGapLengthRatio( aSch->Settings().m_DashedLineGapRatio );
105
106 // Load the drawing sheet from the filename stored in BASE_SCREEN::m_DrawingSheetFileName.
107 // If empty, or not existing, the default drawing sheet is loaded.
108
109 auto loadSheet =
110 [&]( const wxString& path ) -> bool
111 {
112 wxString absolutePath = DS_DATA_MODEL::ResolvePath( path,
113 aSch->Prj().GetProjectPath() );
114
115 if( !DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet( absolutePath ) )
116 {
117 m_reporter->Report( wxString::Format( _( "Error loading drawing sheet '%s'." ),
118 path ),
120 return false;
121 }
122
123 return true;
124 };
125
126 // try to load the override first
127 if( !aDrawingSheetOverride.IsEmpty() && loadSheet( aDrawingSheetOverride ) )
128 return;
129
130 // no override or failed override continues here
131 loadSheet( aSch->Settings().m_SchDrawingSheetFileName );
132}
133
134
136{
137 JOB_EXPORT_SCH_PLOT* aPlotJob = dynamic_cast<JOB_EXPORT_SCH_PLOT*>( aJob );
138
139 if( !aPlotJob )
141
142 SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aPlotJob->m_filename, SCH_IO_MGR::SCH_KICAD, true );
143
144 if( sch == nullptr )
145 {
146 m_reporter->Report( _( "Failed to load schematic file\n" ), RPT_SEVERITY_ERROR );
148 }
149
150 sch->Prj().ApplyTextVars( aJob->GetVarOverrides() );
151
152 std::unique_ptr<KIGFX::SCH_RENDER_SETTINGS> renderSettings =
153 std::make_unique<KIGFX::SCH_RENDER_SETTINGS>();
154 InitRenderSettings( renderSettings.get(), aPlotJob->m_theme, sch, aPlotJob->m_drawingSheet );
155
156 std::unique_ptr<SCH_PLOTTER> schPlotter = std::make_unique<SCH_PLOTTER>( sch );
157
158 PLOT_FORMAT format = PLOT_FORMAT::PDF;
159 switch( aPlotJob->m_plotFormat )
160 {
161 case SCH_PLOT_FORMAT::DXF: format = PLOT_FORMAT::DXF; break;
162 case SCH_PLOT_FORMAT::PDF: format = PLOT_FORMAT::PDF; break;
163 case SCH_PLOT_FORMAT::SVG: format = PLOT_FORMAT::SVG; break;
164 case SCH_PLOT_FORMAT::POST: format = PLOT_FORMAT::POST; break;
165 case SCH_PLOT_FORMAT::HPGL: format = PLOT_FORMAT::HPGL; break;
166 case SCH_PLOT_FORMAT::GERBER: format = PLOT_FORMAT::GERBER; break;
167 }
168
169 HPGL_PAGE_SIZE hpglPageSize = HPGL_PAGE_SIZE::DEFAULT;
170 switch( aPlotJob->m_HPGLPaperSizeSelect )
171 {
172 case JOB_HPGL_PAGE_SIZE::DEFAULT: hpglPageSize = HPGL_PAGE_SIZE::DEFAULT; break;
173 case JOB_HPGL_PAGE_SIZE::SIZE_A: hpglPageSize = HPGL_PAGE_SIZE::SIZE_A; break;
174 case JOB_HPGL_PAGE_SIZE::SIZE_A0: hpglPageSize = HPGL_PAGE_SIZE::SIZE_A0; break;
175 case JOB_HPGL_PAGE_SIZE::SIZE_A1: hpglPageSize = HPGL_PAGE_SIZE::SIZE_A1; break;
176 case JOB_HPGL_PAGE_SIZE::SIZE_A2: hpglPageSize = HPGL_PAGE_SIZE::SIZE_A2; break;
177 case JOB_HPGL_PAGE_SIZE::SIZE_A3: hpglPageSize = HPGL_PAGE_SIZE::SIZE_A3; break;
178 case JOB_HPGL_PAGE_SIZE::SIZE_A4: hpglPageSize = HPGL_PAGE_SIZE::SIZE_A4; break;
179 case JOB_HPGL_PAGE_SIZE::SIZE_A5: hpglPageSize = HPGL_PAGE_SIZE::SIZE_A5; break;
180 case JOB_HPGL_PAGE_SIZE::SIZE_B: hpglPageSize = HPGL_PAGE_SIZE::SIZE_B; break;
181 case JOB_HPGL_PAGE_SIZE::SIZE_C: hpglPageSize = HPGL_PAGE_SIZE::SIZE_C; break;
182 case JOB_HPGL_PAGE_SIZE::SIZE_D: hpglPageSize = HPGL_PAGE_SIZE::SIZE_D; break;
183 case JOB_HPGL_PAGE_SIZE::SIZE_E: hpglPageSize = HPGL_PAGE_SIZE::SIZE_E; break;
184 }
185
186 HPGL_PLOT_ORIGIN_AND_UNITS hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE;
187 switch( aPlotJob->m_HPGLPlotOrigin )
188 {
189 case JOB_HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT:
190 hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT;
191 break;
192 case JOB_HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER:
193 hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER;
194 break;
195 case JOB_HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT:
196 hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT;
197 break;
198 case JOB_HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE:
199 hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE;
200 break;
201 }
202
203 int pageSizeSelect = PageFormatReq::PAGE_SIZE_AUTO;
204
205 switch( aPlotJob->m_pageSizeSelect )
206 {
207 case JOB_PAGE_SIZE::PAGE_SIZE_A: pageSizeSelect = PageFormatReq::PAGE_SIZE_A; break;
208 case JOB_PAGE_SIZE::PAGE_SIZE_A4: pageSizeSelect = PageFormatReq::PAGE_SIZE_A4; break;
209 case JOB_PAGE_SIZE::PAGE_SIZE_AUTO: pageSizeSelect = PageFormatReq::PAGE_SIZE_AUTO; break;
210 }
211
212 SCH_PLOT_SETTINGS settings;
213 settings.m_blackAndWhite = aPlotJob->m_blackAndWhite;
214 settings.m_HPGLPaperSizeSelect = hpglPageSize;
215 settings.m_HPGLPenSize = aPlotJob->m_HPGLPenSize;
216 settings.m_HPGLPlotOrigin = hpglOrigin;
217 settings.m_PDFPropertyPopups = aPlotJob->m_PDFPropertyPopups;
218 settings.m_PDFMetadata = aPlotJob->m_PDFMetadata;
219 settings.m_outputDirectory = aPlotJob->m_outputDirectory;
220 settings.m_outputFile = aPlotJob->m_outputFile;
221 settings.m_pageSizeSelect = pageSizeSelect;
222 settings.m_plotAll = aPlotJob->m_plotAll;
223 settings.m_plotDrawingSheet = aPlotJob->m_plotDrawingSheet;
224 settings.m_plotPages = aPlotJob->m_plotPages;
225 settings.m_theme = aPlotJob->m_theme;
226 settings.m_useBackgroundColor = aPlotJob->m_useBackgroundColor;
227
228 schPlotter->Plot( format, settings, renderSettings.get(), m_reporter );
229
230 return CLI::EXIT_CODES::OK;
231}
232
233
235{
236 JOB_EXPORT_SCH_NETLIST* aNetJob = dynamic_cast<JOB_EXPORT_SCH_NETLIST*>( aJob );
237
238 if( !aNetJob )
240
241 SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aNetJob->m_filename, SCH_IO_MGR::SCH_KICAD, true );
242
243 if( sch == nullptr )
244 {
245 m_reporter->Report( _( "Failed to load schematic file\n" ), RPT_SEVERITY_ERROR );
247 }
248
249 // Annotation warning check
250 SCH_REFERENCE_LIST referenceList;
251 sch->GetSheets().GetSymbols( referenceList );
252
253 if( referenceList.GetCount() > 0 )
254 {
255 if( referenceList.CheckAnnotation(
256 []( ERCE_T, const wxString&, SCH_REFERENCE*, SCH_REFERENCE* )
257 {
258 // We're only interested in the end result -- either errors or not
259 } )
260 > 0 )
261 {
262 m_reporter->Report( _( "Warning: schematic has annotation errors, please use the "
263 "schematic editor to fix them\n" ),
265 }
266 }
267
268 // Test duplicate sheet names:
269 ERC_TESTER erc( sch );
270
271 if( erc.TestDuplicateSheetNames( false ) > 0 )
272 m_reporter->Report( _( "Warning: duplicate sheet names.\n" ), RPT_SEVERITY_WARNING );
273
274 std::unique_ptr<NETLIST_EXPORTER_BASE> helper;
275 unsigned netlistOption = 0;
276
277 wxString fileExt;
278
279 switch( aNetJob->format )
280 {
283 helper = std::make_unique<NETLIST_EXPORTER_KICAD>( sch );
284 break;
285
288 helper = std::make_unique<NETLIST_EXPORTER_ORCADPCB2>( sch );
289 break;
290
293 helper = std::make_unique<NETLIST_EXPORTER_CADSTAR>( sch );
294 break;
295
299 helper = std::make_unique<NETLIST_EXPORTER_SPICE>( sch );
300 break;
301
304 helper = std::make_unique<NETLIST_EXPORTER_SPICE_MODEL>( sch );
305 break;
306
308 fileExt = wxS( "xml" );
309 helper = std::make_unique<NETLIST_EXPORTER_XML>( sch );
310 break;
311
313 fileExt = wxS( "asc" );
314 helper = std::make_unique<NETLIST_EXPORTER_PADS>( sch );
315 break;
316
318 fileExt = wxS( "txt" );
319 helper = std::make_unique<NETLIST_EXPORTER_ALLEGRO>( sch );
320 break;
321
322 default:
323 m_reporter->Report( _( "Unknown netlist format.\n" ), RPT_SEVERITY_ERROR );
325 }
326
327 if( aNetJob->m_outputFile.IsEmpty() )
328 {
329 wxFileName fn = sch->GetFileName();
330 fn.SetName( fn.GetName() );
331 fn.SetExt( fileExt );
332
333 aNetJob->m_outputFile = fn.GetFullName();
334 }
335
336 bool res = helper->WriteNetlist( aNetJob->m_outputFile, netlistOption, *m_reporter );
337
338 if( !res )
340
341 return CLI::EXIT_CODES::OK;
342}
343
344
346{
347 JOB_EXPORT_SCH_BOM* aBomJob = dynamic_cast<JOB_EXPORT_SCH_BOM*>( aJob );
348
349 if( !aBomJob )
351
352 SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aBomJob->m_filename, SCH_IO_MGR::SCH_KICAD, true );
353
354 if( sch == nullptr )
355 {
356 m_reporter->Report( _( "Failed to load schematic file\n" ), RPT_SEVERITY_ERROR );
358 }
359
360 sch->Prj().ApplyTextVars( aJob->GetVarOverrides() );
361
362 // Annotation warning check
363 SCH_REFERENCE_LIST referenceList;
364 sch->GetSheets().GetSymbols( referenceList, false, false );
365
366 if( referenceList.GetCount() > 0 )
367 {
368 SCH_REFERENCE_LIST copy = referenceList;
369
370 // Check annotation splits references...
371 if( copy.CheckAnnotation(
372 []( ERCE_T, const wxString&, SCH_REFERENCE*, SCH_REFERENCE* )
373 {
374 // We're only interested in the end result -- either errors or not
375 } )
376 > 0 )
377 {
379 _( "Warning: schematic has annotation errors, please use the schematic "
380 "editor to fix them\n" ),
382 }
383 }
384
385 // Test duplicate sheet names:
386 ERC_TESTER erc( sch );
387
388 if( erc.TestDuplicateSheetNames( false ) > 0 )
389 m_reporter->Report( _( "Warning: duplicate sheet names.\n" ), RPT_SEVERITY_WARNING );
390
391 // Build our data model
392 FIELDS_EDITOR_GRID_DATA_MODEL dataModel( referenceList );
393
394 // Mandatory fields + quantity virtual field first
395 for( int i = 0; i < MANDATORY_FIELDS; ++i )
397 TEMPLATE_FIELDNAME::GetDefaultFieldName( i, true ), false );
398
399 // User field names in symbols second
400 std::set<wxString> userFieldNames;
401
402 for( size_t i = 0; i < referenceList.GetCount(); ++i )
403 {
404 SCH_SYMBOL* symbol = referenceList[i].GetSymbol();
405
406 for( int j = MANDATORY_FIELDS; j < symbol->GetFieldCount(); ++j )
407 userFieldNames.insert( symbol->GetFields()[j].GetName() );
408 }
409
410 for( const wxString& fieldName : userFieldNames )
411 dataModel.AddColumn( fieldName, GetTextVars( fieldName ), true );
412
413 // Add any templateFieldNames which aren't already present in the userFieldNames
414 for( const TEMPLATE_FIELDNAME& templateFieldname :
416 {
417 if( userFieldNames.count( templateFieldname.m_Name ) == 0 )
418 {
419 dataModel.AddColumn( templateFieldname.m_Name, GetTextVars( templateFieldname.m_Name ),
420 false );
421 }
422 }
423
424 BOM_PRESET preset;
425
426 // Load a preset if one is specified
427 if( !aBomJob->m_bomPresetName.IsEmpty() )
428 {
429 // Make sure the built-in presets are loaded
430 for( const BOM_PRESET& p : BOM_PRESET::BuiltInPresets() )
431 sch->Settings().m_BomPresets.emplace_back( p );
432
433 // Find the preset
434 BOM_PRESET* schPreset = nullptr;
435
436 for( BOM_PRESET& p : sch->Settings().m_BomPresets )
437 {
438 if( p.name == aBomJob->m_bomPresetName )
439 {
440 schPreset = &p;
441 break;
442 }
443 }
444
445 if( !schPreset )
446 {
447 m_reporter->Report( wxString::Format( _( "BOM preset '%s' not found" ) + wxS( "\n" ),
448 aBomJob->m_bomPresetName ),
450
452 }
453
454 preset = *schPreset;
455 }
456 else
457 {
458 size_t i = 0;
459
460 for( wxString fieldName : aBomJob->m_fieldsOrdered )
461 {
462 // Handle wildcard. We allow the wildcard anywhere in the list, but it needs to respect
463 // fields that come before and after the wildcard.
464 if( fieldName == wxS( "*" ) )
465 {
466 for( const BOM_FIELD& modelField : dataModel.GetFieldsOrdered() )
467 {
468 struct BOM_FIELD field;
469
470 field.name = modelField.name;
471 field.show = true;
472 field.groupBy = false;
473 field.label = field.name;
474
475 bool fieldAlreadyPresent = false;
476 for( BOM_FIELD& presetField : preset.fieldsOrdered )
477 {
478 if( presetField.name == field.name )
479 {
480 fieldAlreadyPresent = true;
481 break;
482 }
483 }
484
485 bool fieldLaterInList = false;
486 for( const wxString& fieldInList : aBomJob->m_fieldsOrdered )
487 {
488 if( fieldInList == field.name )
489 {
490 fieldLaterInList = true;
491 break;
492 }
493 }
494
495 if( !fieldAlreadyPresent && !fieldLaterInList )
496 preset.fieldsOrdered.emplace_back( field );
497 }
498
499 continue;
500 }
501
502 struct BOM_FIELD field;
503
504 field.name = fieldName;
505 field.show = true;
506 field.groupBy = std::find( aBomJob->m_fieldsGroupBy.begin(),
507 aBomJob->m_fieldsGroupBy.end(), field.name )
508 != aBomJob->m_fieldsGroupBy.end();
509
510 if( ( aBomJob->m_fieldsLabels.size() > i ) && !aBomJob->m_fieldsLabels[i].IsEmpty() )
511 field.label = aBomJob->m_fieldsLabels[i];
512 else if( IsTextVar( field.name ) )
513 field.label = GetTextVars( field.name );
514 else
515 field.label = field.name;
516
517 preset.fieldsOrdered.emplace_back( field );
518 i++;
519 }
520
521 preset.sortAsc = aBomJob->m_sortAsc;
522 preset.sortField = aBomJob->m_sortField;
523 preset.filterString = aBomJob->m_filterString;
524 preset.groupSymbols = ( aBomJob->m_fieldsGroupBy.size() > 0 );
525 preset.excludeDNP = aBomJob->m_excludeDNP;
526 }
527
528 dataModel.ApplyBomPreset( preset );
529
530 if( aBomJob->m_outputFile.IsEmpty() )
531 {
532 wxFileName fn = sch->GetFileName();
533 fn.SetName( fn.GetName() );
534 fn.SetExt( FILEEXT::CsvFileExtension );
535
536 aBomJob->m_outputFile = fn.GetFullName();
537 }
538
539 wxFile f;
540
541 if( !f.Open( aBomJob->m_outputFile, wxFile::write ) )
542 {
543 m_reporter->Report( wxString::Format( _( "Unable to open destination '%s'" ),
544 aBomJob->m_outputFile ),
546
548 }
549
550 BOM_FMT_PRESET fmt;
551
552 // Load a format preset if one is specified
553 if( !aBomJob->m_bomFmtPresetName.IsEmpty() )
554 {
555 // Make sure the built-in presets are loaded
557 sch->Settings().m_BomFmtPresets.emplace_back( p );
558
559 // Find the preset
560 BOM_FMT_PRESET* schFmtPreset = nullptr;
561
562 for( BOM_FMT_PRESET& p : sch->Settings().m_BomFmtPresets )
563 {
564 if( p.name == aBomJob->m_bomFmtPresetName )
565 {
566 schFmtPreset = &p;
567 break;
568 }
569 }
570
571 if( !schFmtPreset )
572 {
574 wxString::Format( _( "BOM format preset '%s' not found" ) + wxS( "\n" ),
575 aBomJob->m_bomFmtPresetName ),
577
579 }
580
581 fmt = *schFmtPreset;
582 }
583 else
584 {
585 fmt.fieldDelimiter = aBomJob->m_fieldDelimiter;
586 fmt.stringDelimiter = aBomJob->m_stringDelimiter;
587 fmt.refDelimiter = aBomJob->m_refDelimiter;
589 fmt.keepTabs = aBomJob->m_keepTabs;
590 fmt.keepLineBreaks = aBomJob->m_keepLineBreaks;
591 }
592
593 bool res = f.Write( dataModel.Export( fmt ) );
594
595 if( !res )
597
598 return CLI::EXIT_CODES::OK;
599}
600
601
603{
604 JOB_EXPORT_SCH_PYTHONBOM* aNetJob = dynamic_cast<JOB_EXPORT_SCH_PYTHONBOM*>( aJob );
605
606 if( !aNetJob )
608
609 SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aNetJob->m_filename, SCH_IO_MGR::SCH_KICAD, true );
610
611 if( sch == nullptr )
612 {
613 m_reporter->Report( _( "Failed to load schematic file\n" ), RPT_SEVERITY_ERROR );
615 }
616
617 // Annotation warning check
618 SCH_REFERENCE_LIST referenceList;
619 sch->GetSheets().GetSymbols( referenceList );
620
621 if( referenceList.GetCount() > 0 )
622 {
623 if( referenceList.CheckAnnotation(
624 []( ERCE_T, const wxString&, SCH_REFERENCE*, SCH_REFERENCE* )
625 {
626 // We're only interested in the end result -- either errors or not
627 } )
628 > 0 )
629 {
631 _( "Warning: schematic has annotation errors, please use the schematic "
632 "editor to fix them\n" ),
634 }
635 }
636
637 // Test duplicate sheet names:
638 ERC_TESTER erc( sch );
639
640 if( erc.TestDuplicateSheetNames( false ) > 0 )
641 m_reporter->Report( _( "Warning: duplicate sheet names.\n" ), RPT_SEVERITY_WARNING );
642
643 std::unique_ptr<NETLIST_EXPORTER_XML> xmlNetlist =
644 std::make_unique<NETLIST_EXPORTER_XML>( sch );
645
646 if( aNetJob->m_outputFile.IsEmpty() )
647 {
648 wxFileName fn = sch->GetFileName();
649 fn.SetName( fn.GetName() + "-bom" );
650 fn.SetExt( FILEEXT::XmlFileExtension );
651
652 aNetJob->m_outputFile = fn.GetFullName();
653 }
654
655 bool res = xmlNetlist->WriteNetlist( aNetJob->m_outputFile, GNL_OPT_BOM, *m_reporter );
656
657 if( !res )
659
660 return CLI::EXIT_CODES::OK;
661}
662
663
665 KIGFX::SCH_RENDER_SETTINGS* aRenderSettings,
666 LIB_SYMBOL* symbol )
667{
668 wxASSERT( symbol != nullptr );
669
670 if( symbol == nullptr )
672
673 LIB_SYMBOL* symbolToPlot = symbol;
674
675 // if the symbol is an alias, then the draw items are stored in the root symbol
676 if( symbol->IsAlias() )
677 {
678 if( LIB_SYMBOL_SPTR parent = symbol->GetRootSymbol() )
679 {
680 symbolToPlot = parent.get();
681 }
682 else
683 {
684 wxCHECK( false, CLI::EXIT_CODES::ERR_UNKNOWN );
685 }
686 }
687
688 if( aSvgJob->m_includeHiddenPins )
689 {
690 // horrible hack, TODO overhaul the Plot method to handle this
691 for( LIB_ITEM& item : symbolToPlot->GetDrawItems() )
692 {
693 if( item.Type() != LIB_PIN_T )
694 continue;
695
696 LIB_PIN& pin = static_cast<LIB_PIN&>( item );
697 pin.SetVisible( true );
698 }
699 }
700
701 // iterate from unit 1, unit 0 would be "all units" which we don't want
702 for( int unit = 1; unit < symbol->GetUnitCount() + 1; unit++ )
703 {
704 for( int bodyStyle = 1; bodyStyle < ( symbol->HasAlternateBodyStyle() ? 2 : 1 ) + 1; ++bodyStyle )
705 {
706 wxString filename;
707 wxFileName fn;
708 size_t forbidden_char;
709
710 fn.SetPath( aSvgJob->m_outputDirectory );
711 fn.SetExt( FILEEXT::SVGFileExtension );
712
713 filename = symbol->GetName().Lower();
714
715 while( wxString::npos
716 != ( forbidden_char = filename.find_first_of(
717 wxFileName::GetForbiddenChars( wxPATH_DOS ) ) ) )
718 {
719 filename = filename.replace( forbidden_char, 1, wxS( '_' ) );
720 }
721
722 //simplify the name if its single unit
723 if( symbol->GetUnitCount() > 1 )
724 {
725 filename += wxString::Format( "_%d", unit );
726
727 if( bodyStyle == 2 )
728 filename += wxS( "_demorgan" );
729
730 fn.SetName( filename );
731 m_reporter->Report( wxString::Format( _( "Plotting symbol '%s' unit %d to '%s'\n" ),
732 symbol->GetName(), unit, fn.GetFullPath() ),
734 }
735 else
736 {
737 if( bodyStyle == 2 )
738 filename += wxS( "_demorgan" );
739
740 fn.SetName( filename );
741 m_reporter->Report( wxString::Format( _( "Plotting symbol '%s' to '%s'\n" ),
742 symbol->GetName(), fn.GetFullPath() ),
744 }
745
746 // Get the symbol bounding box to fit the plot page to it
747 BOX2I symbolBB = symbol->Flatten()->GetUnitBoundingBox( unit, bodyStyle, false );
748 PAGE_INFO pageInfo( PAGE_INFO::Custom );
749 pageInfo.SetHeightMils( schIUScale.IUToMils( symbolBB.GetHeight() * 1.2 ) );
750 pageInfo.SetWidthMils( schIUScale.IUToMils( symbolBB.GetWidth() * 1.2 ) );
751
752 SVG_PLOTTER* plotter = new SVG_PLOTTER();
753 plotter->SetRenderSettings( aRenderSettings );
754 plotter->SetPageSettings( pageInfo );
755 plotter->SetColorMode( !aSvgJob->m_blackAndWhite );
756
757 VECTOR2I plot_offset;
758 const double scale = 1.0;
759
760 // Currently, plot units are in decimal
761 plotter->SetViewport( plot_offset, schIUScale.IU_PER_MILS / 10, scale, false );
762
763 plotter->SetCreator( wxT( "Eeschema-SVG" ) );
764
765 if( !plotter->OpenFile( fn.GetFullPath() ) )
766 {
768 wxString::Format( _( "Unable to open destination '%s'" ) + wxS( "\n" ),
769 fn.GetFullPath() ),
771
772 delete plotter;
774 }
775
776 LOCALE_IO toggle;
777
778 plotter->StartPlot( wxT( "1" ) );
779
780 bool background = true;
781 TRANSFORM temp; // Uses default transform
782 VECTOR2I plotPos;
783
784 plotPos.x = pageInfo.GetWidthIU( schIUScale.IU_PER_MILS ) / 2;
785 plotPos.y = pageInfo.GetHeightIU( schIUScale.IU_PER_MILS ) / 2;
786
787 // note, we want the fields from the original symbol pointer (in case of non-alias)
788 symbolToPlot->Plot( plotter, unit, bodyStyle, background, plotPos, temp, false );
789 symbol->PlotLibFields( plotter, unit, bodyStyle, background, plotPos, temp, false,
790 aSvgJob->m_includeHiddenFields );
791
792 symbolToPlot->Plot( plotter, unit, bodyStyle, !background, plotPos, temp, false );
793 symbol->PlotLibFields( plotter, unit, bodyStyle, !background, plotPos, temp, false,
794 aSvgJob->m_includeHiddenFields );
795
796 plotter->EndPlot();
797 delete plotter;
798 }
799 }
800
801 return CLI::EXIT_CODES::OK;
802}
803
804
806{
807 JOB_SYM_EXPORT_SVG* svgJob = dynamic_cast<JOB_SYM_EXPORT_SVG*>( aJob );
808
809 if( !svgJob )
811
812 wxFileName fn( svgJob->m_libraryPath );
813 fn.MakeAbsolute();
814
815 SCH_IO_KICAD_SEXPR_LIB_CACHE schLibrary( fn.GetFullPath() );
816
817 try
818 {
819 schLibrary.Load();
820 }
821 catch( ... )
822 {
823 m_reporter->Report( _( "Unable to load library\n" ), RPT_SEVERITY_ERROR );
825 }
826
827 LIB_SYMBOL* symbol = nullptr;
828
829 if( !svgJob->m_symbol.IsEmpty() )
830 {
831 // See if the selected symbol exists
832 symbol = schLibrary.GetSymbol( svgJob->m_symbol );
833
834 if( !symbol )
835 {
836 m_reporter->Report( _( "There is no symbol selected to save." ) + wxS( "\n" ),
839 }
840 }
841
842 if( !svgJob->m_outputDirectory.IsEmpty() && !wxDir::Exists( svgJob->m_outputDirectory ) )
843 {
844 wxFileName::Mkdir( svgJob->m_outputDirectory );
845 }
846
847 KIGFX::SCH_RENDER_SETTINGS renderSettings;
849 renderSettings.LoadColors( cs );
851
852 int exitCode = CLI::EXIT_CODES::OK;
853
854 if( symbol )
855 {
856 exitCode = doSymExportSvg( svgJob, &renderSettings, symbol );
857 }
858 else
859 {
860 // Just plot all the symbols we can
861 const LIB_SYMBOL_MAP& libSymMap = schLibrary.GetSymbolMap();
862
863 for( const std::pair<const wxString, LIB_SYMBOL*>& entry : libSymMap )
864 {
865 exitCode = doSymExportSvg( svgJob, &renderSettings, entry.second );
866
867 if( exitCode != CLI::EXIT_CODES::OK )
868 break;
869 }
870 }
871
872 return exitCode;
873}
874
875
877{
878 JOB_SYM_UPGRADE* upgradeJob = dynamic_cast<JOB_SYM_UPGRADE*>( aJob );
879
880 if( !upgradeJob )
882
883 wxFileName fn( upgradeJob->m_libraryPath );
884 fn.MakeAbsolute();
885
886 SCH_IO_MGR::SCH_FILE_T fileType = SCH_IO_MGR::GuessPluginTypeFromLibPath( fn.GetFullPath() );
887
888 if( !upgradeJob->m_outputLibraryPath.IsEmpty() )
889 {
890 if( wxFile::Exists( upgradeJob->m_outputLibraryPath ) )
891 {
892 m_reporter->Report( _( "Output path must not conflict with existing path\n" ),
894
896 }
897 }
898 else if( fileType != SCH_IO_MGR::SCH_KICAD )
899 {
900 m_reporter->Report( _( "Output path must be specified to convert legacy and non-KiCad libraries\n" ),
902
904 }
905
906 if( fileType == SCH_IO_MGR::SCH_KICAD )
907 {
908 SCH_IO_KICAD_SEXPR_LIB_CACHE schLibrary( fn.GetFullPath() );
909
910 try
911 {
912 schLibrary.Load();
913 }
914 catch( ... )
915 {
916 m_reporter->Report( _( "Unable to load library\n" ), RPT_SEVERITY_ERROR );
918 }
919
920 bool shouldSave =
921 upgradeJob->m_force
923
924 if( shouldSave )
925 {
926 m_reporter->Report( _( "Saving symbol library in updated format\n" ),
928
929 try
930 {
931 if( !upgradeJob->m_outputLibraryPath.IsEmpty() )
932 {
933 schLibrary.SetFileName( upgradeJob->m_outputLibraryPath );
934 }
935
936 schLibrary.SetModified();
937 schLibrary.Save();
938 }
939 catch( ... )
940 {
941 m_reporter->Report( ( "Unable to save library\n" ), RPT_SEVERITY_ERROR );
943 }
944 }
945 else
946 {
947 m_reporter->Report( _( "Symbol library was not updated\n" ), RPT_SEVERITY_INFO );
948 }
949 }
950 else
951 {
952 if( !SCH_IO_MGR::ConvertLibrary( nullptr, fn.GetAbsolutePath(), upgradeJob->m_outputLibraryPath ) )
953 {
954 m_reporter->Report( ( "Unable to convert library\n" ), RPT_SEVERITY_ERROR );
956 }
957 }
958
959 return CLI::EXIT_CODES::OK;
960}
961
962
963
965{
966 JOB_SCH_ERC* ercJob = dynamic_cast<JOB_SCH_ERC*>( aJob );
967
968 if( !ercJob )
970
971 SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( ercJob->m_filename, SCH_IO_MGR::SCH_KICAD, true );
972
973 if( sch == nullptr )
974 {
975 m_reporter->Report( _( "Failed to load schematic file\n" ), RPT_SEVERITY_ERROR );
977 }
978
979 sch->Prj().ApplyTextVars( aJob->GetVarOverrides() );
980
981 if( ercJob->m_outputFile.IsEmpty() )
982 {
983 wxFileName fn = sch->GetFileName();
984 fn.SetName( fn.GetName() );
985
987 fn.SetExt( FILEEXT::JsonFileExtension );
988 else
989 fn.SetExt( FILEEXT::ReportFileExtension );
990
991 ercJob->m_outputFile = fn.GetFullName();
992 }
993
994 EDA_UNITS units;
995
996 switch( ercJob->m_units )
997 {
998 case JOB_SCH_ERC::UNITS::INCHES: units = EDA_UNITS::INCHES; break;
999 case JOB_SCH_ERC::UNITS::MILS: units = EDA_UNITS::MILS; break;
1000 case JOB_SCH_ERC::UNITS::MILLIMETERS: units = EDA_UNITS::MILLIMETRES; break;
1001 default: units = EDA_UNITS::MILLIMETRES; break;
1002 }
1003
1004 std::shared_ptr<SHEETLIST_ERC_ITEMS_PROVIDER> markersProvider =
1005 std::make_shared<SHEETLIST_ERC_ITEMS_PROVIDER>( sch );
1006
1007 ERC_TESTER ercTester( sch );
1008
1009 m_reporter->Report( _( "Running ERC...\n" ), RPT_SEVERITY_INFO );
1010
1011 std::unique_ptr<DS_PROXY_VIEW_ITEM> drawingSheet( getDrawingSheetProxyView( sch ) );
1012 ercTester.RunTests( drawingSheet.get(), nullptr, m_kiway->KiFACE( KIWAY::FACE_CVPCB ),
1013 &sch->Prj(), m_progressReporter );
1014
1015 markersProvider->SetSeverities( ercJob->m_severity );
1016
1017 m_reporter->Report( wxString::Format( _( "Found %d violations\n" ),
1018 markersProvider->GetCount() ),
1020
1021 ERC_REPORT reportWriter( sch, units );
1022
1023 bool wroteReport = false;
1024
1026 wroteReport = reportWriter.WriteJsonReport( ercJob->m_outputFile );
1027 else
1028 wroteReport = reportWriter.WriteTextReport( ercJob->m_outputFile );
1029
1030 if( !wroteReport )
1031 {
1032 m_reporter->Report( wxString::Format( _( "Unable to save ERC report to %s\n" ),
1033 ercJob->m_outputFile ),
1036 }
1037
1038 m_reporter->Report( wxString::Format( _( "Saved ERC Report to %s\n" ), ercJob->m_outputFile ),
1040
1041 if( ercJob->m_exitCodeViolations )
1042 {
1043 if( markersProvider->GetCount() > 0 )
1045 }
1046
1048}
1049
1050
1052{
1053 DS_PROXY_VIEW_ITEM* drawingSheet =
1055 &aSch->Prj(), &aSch->RootScreen()->GetTitleBlock(),
1056 aSch->GetProperties() );
1057
1058 drawingSheet->SetPageNumber( TO_UTF8( aSch->RootScreen()->GetPageNumber() ) );
1059 drawingSheet->SetSheetCount( aSch->RootScreen()->GetPageCount() );
1060 drawingSheet->SetFileName( TO_UTF8( aSch->RootScreen()->GetFileName() ) );
1063 drawingSheet->SetIsFirstPage( aSch->RootScreen()->GetVirtualPageNumber() == 1 );
1064
1065 drawingSheet->SetSheetName( "" );
1066 drawingSheet->SetSheetPath( "" );
1067
1068 return drawingSheet;
1069}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:110
int GetPageCount() const
Definition: base_screen.h:72
int GetVirtualPageNumber() const
Definition: base_screen.h:75
const wxString & GetPageNumber() const
Definition: base_screen.cpp:71
coord_type GetHeight() const
Definition: box2.h:189
coord_type GetWidth() const
Definition: box2.h:188
Color settings are a bit different than most of the settings objects in that there can be more than o...
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 SetSheetCount(int aSheetCount)
Changes the sheet-count number displayed in the title block.
void SetPageNumber(const std::string &aPageNumber)
Changes the page number displayed in the title block.
void SetSheetName(const std::string &aSheetName)
Set the sheet name displayed in the title block.
void SetPageBorderColorLayer(int aLayerId)
Overrides the layer used to pick the color of the page border (normally LAYER_GRID)
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.
void SetColorLayer(int aLayerId)
Can be used to override which layer ID is used for drawing sheet item colors.
static SCHEMATIC * LoadSchematic(wxString &aFileName, bool aSetActive)
void InitRenderSettings(KIGFX::SCH_RENDER_SETTINGS *aRenderSettings, const wxString &aTheme, SCHEMATIC *aSch, const wxString &aDrawingSheetOverride=wxEmptyString)
Configure the SCH_RENDER_SETTINGS object with the correct data to be used with plotting.
DS_PROXY_VIEW_ITEM * getDrawingSheetProxyView(SCHEMATIC *aSch)
int doSymExportSvg(JOB_SYM_EXPORT_SVG *aSvgJob, KIGFX::SCH_RENDER_SETTINGS *aRenderSettings, LIB_SYMBOL *symbol)
EESCHEMA_JOBS_HANDLER(KIWAY *aKiway)
bool WriteJsonReport(const wxString &aFullFileName)
Writes a JSON formatted ERC Report to the given file path.
Definition: erc_report.cpp:109
bool WriteTextReport(const wxString &aFullFileName)
Writes the text report also available via GetTextReport directly to a given file path.
Definition: erc_report.cpp:95
Definition: erc.h:46
void RunTests(DS_PROXY_VIEW_ITEM *aDrawingSheet, SCH_EDIT_FRAME *aEditFrame, KIFACE *aCvPcb, PROJECT *aProject, PROGRESS_REPORTER *aProgressReporter)
Definition: erc.cpp:1238
void ApplyBomPreset(const BOM_PRESET &preset)
wxString Export(const BOM_FMT_PRESET &settings)
void AddColumn(const wxString &aFieldName, const wxString &aLabel, bool aAddedByUser)
const std::vector< BOM_FIELD > GetFieldsOrdered()
PROGRESS_REPORTER * m_progressReporter
void Register(const std::string &aJobTypeName, std::function< int(JOB *job)> aHandler)
REPORTER * m_reporter
std::vector< wxString > m_fieldsLabels
std::vector< wxString > m_fieldsOrdered
std::vector< wxString > m_fieldsGroupBy
JOB_PAGE_SIZE m_pageSizeSelect
SCH_PLOT_FORMAT m_plotFormat
JOB_HPGL_PLOT_ORIGIN_AND_UNITS m_HPGLPlotOrigin
std::vector< wxString > m_plotPages
JOB_HPGL_PAGE_SIZE m_HPGLPaperSizeSelect
wxString m_filename
Definition: job_sch_erc.h:35
int m_severity
Definition: job_sch_erc.h:47
OUTPUT_FORMAT m_format
Definition: job_sch_erc.h:55
UNITS m_units
Definition: job_sch_erc.h:45
bool m_exitCodeViolations
Definition: job_sch_erc.h:57
wxString m_outputFile
Definition: job_sch_erc.h:36
wxString m_outputLibraryPath
wxString m_libraryPath
An simple container class that lets us dispatch output jobs to kifaces.
Definition: job.h:32
const std::map< wxString, wxString > & GetVarOverrides() const
Definition: job.h:41
void SetDefaultPenWidth(int aWidth)
void SetGapLengthRatio(double aRatio)
void SetDashLengthRatio(double aRatio)
Store schematic specific render settings.
Definition: sch_painter.h:72
void LoadColors(const COLOR_SETTINGS *aSettings) override
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_CVPCB
Definition: kiway.h:288
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:68
Define a library symbol object.
Definition: lib_symbol.h:99
bool HasAlternateBodyStyle() const
Test if symbol has more than one body conversion type (DeMorgan).
void PlotLibFields(PLOTTER *aPlotter, int aUnit, int aBodyStyle, bool aBackground, const VECTOR2I &aOffset, const TRANSFORM &aTransform, bool aDimmed, bool aPlotHidden=true)
Plot Lib Fields only of the symbol to plotter.
Definition: lib_symbol.cpp:906
bool IsAlias() const
Definition: lib_symbol.h:215
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition: lib_symbol.h:545
wxString GetName() const override
Definition: lib_symbol.h:160
void Plot(PLOTTER *aPlotter, int aUnit, int aBodyStyle, bool aBackground, const VECTOR2I &aOffset, const TRANSFORM &aTransform, bool aDimmed) const
Plot lib symbol to plotter.
Definition: lib_symbol.cpp:865
int GetUnitCount() const override
For items with units, return the number of units.
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:605
LIB_SYMBOL_SPTR GetRootSymbol() const
Get the parent symbol that does not have another parent.
Definition: lib_symbol.cpp:527
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:49
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:59
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
Definition: page_info.h:162
static const wxChar Custom[]
"User" defined page type
Definition: page_info.h:82
void SetHeightMils(double aHeightInMils)
Definition: page_info.cpp:261
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
Definition: page_info.h:153
void SetWidthMils(double aWidthInMils)
Definition: page_info.cpp:247
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:137
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
Definition: plotter.cpp:74
virtual void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: plotter.h:137
void SetRenderSettings(RENDER_SETTINGS *aSettings)
Definition: plotter.h:134
virtual void SetCreator(const wxString &aCreator)
Definition: plotter.h:153
virtual void SetColorMode(bool aColorMode)
Plot in B/W or color.
Definition: plotter.h:131
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 REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
wxString m_SchDrawingSheetFileName
std::vector< BOM_PRESET > m_BomPresets
std::vector< BOM_FMT_PRESET > m_BomFmtPresets
Holds all the data relating to one schematic.
Definition: schematic.h:75
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:281
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:287
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:100
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:197
const std::map< wxString, wxString > * GetProperties()
Definition: schematic.h:93
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:90
A cache assistant for the KiCad s-expression symbol libraries.
void Save(const std::optional< bool > &aOpt=std::nullopt) override
Save the entire library to file m_libFileName;.
virtual LIB_SYMBOL * GetSymbol(const wxString &aName)
void SetFileName(const wxString &aFileName)
const LIB_SYMBOL_MAP & GetSymbolMap() const
void SetModified(bool aModified=true)
static bool ConvertLibrary(STRING_UTF8_MAP *aOldFileProps, const wxString &aOldFilePath, const wxString &aNewFilepath)
Convert a schematic symbol library to the latest KiCad format.
Definition: sch_io_mgr.cpp:191
static SCH_FILE_T GuessPluginTypeFromLibPath(const wxString &aLibPath, int aCtl=0)
Return a plugin type given a symbol library using the file extension of aLibPath.
Definition: sch_io_mgr.cpp:140
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
size_t GetCount() const
int CheckAnnotation(ANNOTATION_ERROR_HANDLER aErrorHandler)
Check for annotations errors.
A helper to define a symbol's reference designator in a schematic.
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:131
const wxString & GetFileName() const
Definition: sch_screen.h:144
const TITLE_BLOCK & GetTitleBlock() const
Definition: sch_screen.h:155
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
Schematic symbol object.
Definition: sch_symbol.h:109
int GetFieldCount() const
Return the number of fields in this symbol.
Definition: sch_symbol.h:588
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
virtual bool StartPlot(const wxString &aPageNumber) override
Create SVG file header.
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
virtual bool EndPlot() override
const TEMPLATE_FIELDNAMES & GetTemplateFieldNames()
Return a template field name list for read only access.
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:46
bool IsTextVar(const wxString &aSource)
Returns true if the string is a text var, e.g starts with ${.
Definition: common.cpp:127
wxString GetTextVars(const wxString &aSource)
Returns any variables unexpanded, e.g.
Definition: common.cpp:115
The common library.
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
#define _(s)
EDA_UNITS
Definition: eda_units.h:46
ERCE_T
ERC error codes.
Definition: erc_settings.h:37
static const std::string CadstarNetlistFileExtension
static const std::string NetlistFileExtension
static const std::string ReportFileExtension
static const std::string JsonFileExtension
static const std::string XmlFileExtension
static const std::string OrCadPcb2NetlistFileExtension
static const std::string CsvFileExtension
static const std::string SpiceFileExtension
static const std::string SVGFileExtension
@ LAYER_SCHEMATIC_DRAWINGSHEET
Definition: layer_ids.h:394
@ LAYER_SCHEMATIC_PAGE_LIMITS
Definition: layer_ids.h:395
std::shared_ptr< LIB_SYMBOL > LIB_SYMBOL_SPTR
shared pointer to LIB_SYMBOL
Definition: lib_symbol.h:45
static const int ERR_ARGS
Definition: exit_codes.h:31
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
@ GNL_OPT_BOM
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1031
see class PGM_BASE
PLOT_FORMAT
The set of supported output plot formats.
Definition: plotter.h:64
Plotting engines similar to ps (PostScript, Gerber, svg)
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_INFO
@ RPT_SEVERITY_ACTION
#define SEXPR_SYMBOL_LIB_FILE_VERSION
This file contains the file format version information for the s-expression schematic and symbol libr...
HPGL_PAGE_SIZE
Definition: sch_plotter.h:63
HPGL_PLOT_ORIGIN_AND_UNITS
Definition: sch_plotter.h:46
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
wxString label
Definition: bom_settings.h:33
bool groupBy
Definition: bom_settings.h:35
wxString name
Definition: bom_settings.h:32
wxString fieldDelimiter
Definition: bom_settings.h:81
static std::vector< BOM_FMT_PRESET > BuiltInPresets()
wxString stringDelimiter
Definition: bom_settings.h:82
wxString refRangeDelimiter
Definition: bom_settings.h:84
wxString refDelimiter
Definition: bom_settings.h:83
wxString sortField
Definition: bom_settings.h:54
bool groupSymbols
Definition: bom_settings.h:57
std::vector< BOM_FIELD > fieldsOrdered
Definition: bom_settings.h:53
static std::vector< BOM_PRESET > BuiltInPresets()
bool excludeDNP
Definition: bom_settings.h:58
bool sortAsc
Definition: bom_settings.h:55
wxString filterString
Definition: bom_settings.h:56
constexpr int IUToMils(int iu) const
Definition: base_units.h:99
const double IU_PER_MILS
Definition: base_units.h:77
bool m_PDFPropertyPopups
Definition: sch_plotter.h:90
double m_HPGLPenSize
Definition: sch_plotter.h:88
wxString m_theme
Definition: sch_plotter.h:92
HPGL_PAGE_SIZE m_HPGLPaperSizeSelect
Definition: sch_plotter.h:89
HPGL_PLOT_ORIGIN_AND_UNITS m_HPGLPlotOrigin
Definition: sch_plotter.h:97
bool m_useBackgroundColor
Definition: sch_plotter.h:87
std::vector< wxString > m_plotPages
Definition: sch_plotter.h:83
wxString m_outputDirectory
Definition: sch_plotter.h:94
wxString m_outputFile
Definition: sch_plotter.h:95
Hold a name of a symbol's field, field value, and default visibility.
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslateForHI=false)
Return a default symbol field name for field aFieldNdx for all components.
std::map< wxString, LIB_SYMBOL *, LibSymbolMapSort > LIB_SYMBOL_MAP
@ MANDATORY_FIELDS
The first 5 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
VECTOR3I res
@ LIB_PIN_T
Definition: typeinfo.h:206
Definition of file extensions used in Kicad.