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 aRenderSettings->m_ShowHiddenPins = false;
98 aRenderSettings->m_ShowHiddenFields = false;
99
100 aRenderSettings->SetDefaultPenWidth( aSch->Settings().m_DefaultLineWidth );
101 aRenderSettings->m_LabelSizeRatio = aSch->Settings().m_LabelSizeRatio;
102 aRenderSettings->m_TextOffsetRatio = aSch->Settings().m_TextOffsetRatio;
103 aRenderSettings->m_PinSymbolSize = aSch->Settings().m_PinSymbolSize;
104
105 aRenderSettings->SetDashLengthRatio( aSch->Settings().m_DashedLineDashRatio );
106 aRenderSettings->SetGapLengthRatio( aSch->Settings().m_DashedLineGapRatio );
107
108 // Load the drawing sheet from the filename stored in BASE_SCREEN::m_DrawingSheetFileName.
109 // If empty, or not existing, the default drawing sheet is loaded.
110
111 auto loadSheet =
112 [&]( const wxString& path ) -> bool
113 {
114 wxString absolutePath = DS_DATA_MODEL::ResolvePath( path,
115 aSch->Prj().GetProjectPath() );
116
117 if( !DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet( absolutePath ) )
118 {
119 m_reporter->Report( wxString::Format( _( "Error loading drawing sheet '%s'." ),
120 path ),
122 return false;
123 }
124
125 return true;
126 };
127
128 // try to load the override first
129 if( !aDrawingSheetOverride.IsEmpty() && loadSheet( aDrawingSheetOverride ) )
130 return;
131
132 // no override or failed override continues here
133 loadSheet( aSch->Settings().m_SchDrawingSheetFileName );
134}
135
136
138{
139 JOB_EXPORT_SCH_PLOT* aPlotJob = dynamic_cast<JOB_EXPORT_SCH_PLOT*>( aJob );
140
141 if( !aPlotJob )
143
144 SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aPlotJob->m_filename, SCH_IO_MGR::SCH_KICAD, true );
145
146 if( sch == nullptr )
147 {
148 m_reporter->Report( _( "Failed to load schematic file\n" ), RPT_SEVERITY_ERROR );
150 }
151
152 sch->Prj().ApplyTextVars( aJob->GetVarOverrides() );
153
154 std::unique_ptr<SCH_RENDER_SETTINGS> renderSettings = std::make_unique<SCH_RENDER_SETTINGS>();
155 InitRenderSettings( renderSettings.get(), aPlotJob->m_theme, sch, aPlotJob->m_drawingSheet );
156
157 std::unique_ptr<SCH_PLOTTER> schPlotter = std::make_unique<SCH_PLOTTER>( sch );
158
159 PLOT_FORMAT format = PLOT_FORMAT::PDF;
160 switch( aPlotJob->m_plotFormat )
161 {
162 case SCH_PLOT_FORMAT::DXF: format = PLOT_FORMAT::DXF; break;
163 case SCH_PLOT_FORMAT::PDF: format = PLOT_FORMAT::PDF; break;
164 case SCH_PLOT_FORMAT::SVG: format = PLOT_FORMAT::SVG; break;
165 case SCH_PLOT_FORMAT::POST: format = PLOT_FORMAT::POST; break;
166 case SCH_PLOT_FORMAT::HPGL: format = PLOT_FORMAT::HPGL; break;
167 case SCH_PLOT_FORMAT::GERBER: format = PLOT_FORMAT::GERBER; break;
168 }
169
170 HPGL_PAGE_SIZE hpglPageSize = HPGL_PAGE_SIZE::DEFAULT;
171 switch( aPlotJob->m_HPGLPaperSizeSelect )
172 {
173 case JOB_HPGL_PAGE_SIZE::DEFAULT: hpglPageSize = HPGL_PAGE_SIZE::DEFAULT; break;
174 case JOB_HPGL_PAGE_SIZE::SIZE_A: hpglPageSize = HPGL_PAGE_SIZE::SIZE_A; break;
175 case JOB_HPGL_PAGE_SIZE::SIZE_A0: hpglPageSize = HPGL_PAGE_SIZE::SIZE_A0; break;
176 case JOB_HPGL_PAGE_SIZE::SIZE_A1: hpglPageSize = HPGL_PAGE_SIZE::SIZE_A1; break;
177 case JOB_HPGL_PAGE_SIZE::SIZE_A2: hpglPageSize = HPGL_PAGE_SIZE::SIZE_A2; break;
178 case JOB_HPGL_PAGE_SIZE::SIZE_A3: hpglPageSize = HPGL_PAGE_SIZE::SIZE_A3; break;
179 case JOB_HPGL_PAGE_SIZE::SIZE_A4: hpglPageSize = HPGL_PAGE_SIZE::SIZE_A4; break;
180 case JOB_HPGL_PAGE_SIZE::SIZE_A5: hpglPageSize = HPGL_PAGE_SIZE::SIZE_A5; break;
181 case JOB_HPGL_PAGE_SIZE::SIZE_B: hpglPageSize = HPGL_PAGE_SIZE::SIZE_B; break;
182 case JOB_HPGL_PAGE_SIZE::SIZE_C: hpglPageSize = HPGL_PAGE_SIZE::SIZE_C; break;
183 case JOB_HPGL_PAGE_SIZE::SIZE_D: hpglPageSize = HPGL_PAGE_SIZE::SIZE_D; break;
184 case JOB_HPGL_PAGE_SIZE::SIZE_E: hpglPageSize = HPGL_PAGE_SIZE::SIZE_E; break;
185 }
186
187 HPGL_PLOT_ORIGIN_AND_UNITS hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE;
188 switch( aPlotJob->m_HPGLPlotOrigin )
189 {
190 case JOB_HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT:
191 hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT;
192 break;
193 case JOB_HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER:
194 hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER;
195 break;
196 case JOB_HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT:
197 hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT;
198 break;
199 case JOB_HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE:
200 hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE;
201 break;
202 }
203
204 int pageSizeSelect = PageFormatReq::PAGE_SIZE_AUTO;
205
206 switch( aPlotJob->m_pageSizeSelect )
207 {
208 case JOB_PAGE_SIZE::PAGE_SIZE_A: pageSizeSelect = PageFormatReq::PAGE_SIZE_A; break;
209 case JOB_PAGE_SIZE::PAGE_SIZE_A4: pageSizeSelect = PageFormatReq::PAGE_SIZE_A4; break;
210 case JOB_PAGE_SIZE::PAGE_SIZE_AUTO: pageSizeSelect = PageFormatReq::PAGE_SIZE_AUTO; break;
211 }
212
213 SCH_PLOT_OPTS plotOpts;
214 plotOpts.m_blackAndWhite = aPlotJob->m_blackAndWhite;
215 plotOpts.m_HPGLPaperSizeSelect = hpglPageSize;
216 plotOpts.m_HPGLPenSize = aPlotJob->m_HPGLPenSize;
217 plotOpts.m_HPGLPlotOrigin = hpglOrigin;
218 plotOpts.m_PDFPropertyPopups = aPlotJob->m_PDFPropertyPopups;
219 plotOpts.m_PDFMetadata = aPlotJob->m_PDFMetadata;
220 plotOpts.m_outputDirectory = aPlotJob->m_outputDirectory;
221 plotOpts.m_outputFile = aPlotJob->m_outputFile;
222 plotOpts.m_pageSizeSelect = pageSizeSelect;
223 plotOpts.m_plotAll = aPlotJob->m_plotAll;
224 plotOpts.m_plotDrawingSheet = aPlotJob->m_plotDrawingSheet;
225 plotOpts.m_plotPages = aPlotJob->m_plotPages;
226 plotOpts.m_theme = aPlotJob->m_theme;
227 plotOpts.m_useBackgroundColor = aPlotJob->m_useBackgroundColor;
228
229 schPlotter->Plot( format, plotOpts, renderSettings.get(), m_reporter );
230
231 return CLI::EXIT_CODES::OK;
232}
233
234
236{
237 JOB_EXPORT_SCH_NETLIST* aNetJob = dynamic_cast<JOB_EXPORT_SCH_NETLIST*>( aJob );
238
239 if( !aNetJob )
241
242 SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aNetJob->m_filename, SCH_IO_MGR::SCH_KICAD, true );
243
244 if( sch == nullptr )
245 {
246 m_reporter->Report( _( "Failed to load schematic file\n" ), RPT_SEVERITY_ERROR );
248 }
249
250 // Annotation warning check
251 SCH_REFERENCE_LIST referenceList;
252 sch->GetSheets().GetSymbols( referenceList );
253
254 if( referenceList.GetCount() > 0 )
255 {
256 if( referenceList.CheckAnnotation(
257 []( ERCE_T, const wxString&, SCH_REFERENCE*, SCH_REFERENCE* )
258 {
259 // We're only interested in the end result -- either errors or not
260 } )
261 > 0 )
262 {
263 m_reporter->Report( _( "Warning: schematic has annotation errors, please use the "
264 "schematic editor to fix them\n" ),
266 }
267 }
268
269 // Test duplicate sheet names:
270 ERC_TESTER erc( sch );
271
272 if( erc.TestDuplicateSheetNames( false ) > 0 )
273 m_reporter->Report( _( "Warning: duplicate sheet names.\n" ), RPT_SEVERITY_WARNING );
274
275 std::unique_ptr<NETLIST_EXPORTER_BASE> helper;
276 unsigned netlistOption = 0;
277
278 wxString fileExt;
279
280 switch( aNetJob->format )
281 {
284 helper = std::make_unique<NETLIST_EXPORTER_KICAD>( sch );
285 break;
286
289 helper = std::make_unique<NETLIST_EXPORTER_ORCADPCB2>( sch );
290 break;
291
294 helper = std::make_unique<NETLIST_EXPORTER_CADSTAR>( sch );
295 break;
296
300 helper = std::make_unique<NETLIST_EXPORTER_SPICE>( sch );
301 break;
302
305 helper = std::make_unique<NETLIST_EXPORTER_SPICE_MODEL>( sch );
306 break;
307
309 fileExt = wxS( "xml" );
310 helper = std::make_unique<NETLIST_EXPORTER_XML>( sch );
311 break;
312
314 fileExt = wxS( "asc" );
315 helper = std::make_unique<NETLIST_EXPORTER_PADS>( sch );
316 break;
317
319 fileExt = wxS( "txt" );
320 helper = std::make_unique<NETLIST_EXPORTER_ALLEGRO>( sch );
321 break;
322
323 default:
324 m_reporter->Report( _( "Unknown netlist format.\n" ), RPT_SEVERITY_ERROR );
326 }
327
328 if( aNetJob->m_outputFile.IsEmpty() )
329 {
330 wxFileName fn = sch->GetFileName();
331 fn.SetName( fn.GetName() );
332 fn.SetExt( fileExt );
333
334 aNetJob->m_outputFile = fn.GetFullName();
335 }
336
337 bool res = helper->WriteNetlist( aNetJob->m_outputFile, netlistOption, *m_reporter );
338
339 if( !res )
341
342 return CLI::EXIT_CODES::OK;
343}
344
345
347{
348 JOB_EXPORT_SCH_BOM* aBomJob = dynamic_cast<JOB_EXPORT_SCH_BOM*>( aJob );
349
350 if( !aBomJob )
352
353 SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aBomJob->m_filename, SCH_IO_MGR::SCH_KICAD, true );
354
355 if( sch == nullptr )
356 {
357 m_reporter->Report( _( "Failed to load schematic file\n" ), RPT_SEVERITY_ERROR );
359 }
360
361 sch->Prj().ApplyTextVars( aJob->GetVarOverrides() );
362
363 // Annotation warning check
364 SCH_REFERENCE_LIST referenceList;
365 sch->GetSheets().GetSymbols( referenceList, false, false );
366
367 if( referenceList.GetCount() > 0 )
368 {
369 SCH_REFERENCE_LIST copy = referenceList;
370
371 // Check annotation splits references...
372 if( copy.CheckAnnotation(
373 []( ERCE_T, const wxString&, SCH_REFERENCE*, SCH_REFERENCE* )
374 {
375 // We're only interested in the end result -- either errors or not
376 } )
377 > 0 )
378 {
380 _( "Warning: schematic has annotation errors, please use the schematic "
381 "editor to fix them\n" ),
383 }
384 }
385
386 // Test duplicate sheet names:
387 ERC_TESTER erc( sch );
388
389 if( erc.TestDuplicateSheetNames( false ) > 0 )
390 m_reporter->Report( _( "Warning: duplicate sheet names.\n" ), RPT_SEVERITY_WARNING );
391
392 // Build our data model
393 FIELDS_EDITOR_GRID_DATA_MODEL dataModel( referenceList );
394
395 // Mandatory fields + quantity virtual field first
396 for( int i = 0; i < MANDATORY_FIELDS; ++i )
398 TEMPLATE_FIELDNAME::GetDefaultFieldName( i, true ), false );
399
400 // User field names in symbols second
401 std::set<wxString> userFieldNames;
402
403 for( size_t i = 0; i < referenceList.GetCount(); ++i )
404 {
405 SCH_SYMBOL* symbol = referenceList[i].GetSymbol();
406
407 for( int j = MANDATORY_FIELDS; j < symbol->GetFieldCount(); ++j )
408 userFieldNames.insert( symbol->GetFields()[j].GetName() );
409 }
410
411 for( const wxString& fieldName : userFieldNames )
412 dataModel.AddColumn( fieldName, GetTextVars( fieldName ), true );
413
414 // Add any templateFieldNames which aren't already present in the userFieldNames
415 for( const TEMPLATE_FIELDNAME& templateFieldname :
417 {
418 if( userFieldNames.count( templateFieldname.m_Name ) == 0 )
419 {
420 dataModel.AddColumn( templateFieldname.m_Name, GetTextVars( templateFieldname.m_Name ),
421 false );
422 }
423 }
424
425 BOM_PRESET preset;
426
427 // Load a preset if one is specified
428 if( !aBomJob->m_bomPresetName.IsEmpty() )
429 {
430 // Make sure the built-in presets are loaded
431 for( const BOM_PRESET& p : BOM_PRESET::BuiltInPresets() )
432 sch->Settings().m_BomPresets.emplace_back( p );
433
434 // Find the preset
435 BOM_PRESET* schPreset = nullptr;
436
437 for( BOM_PRESET& p : sch->Settings().m_BomPresets )
438 {
439 if( p.name == aBomJob->m_bomPresetName )
440 {
441 schPreset = &p;
442 break;
443 }
444 }
445
446 if( !schPreset )
447 {
448 m_reporter->Report( wxString::Format( _( "BOM preset '%s' not found" ) + wxS( "\n" ),
449 aBomJob->m_bomPresetName ),
451
453 }
454
455 preset = *schPreset;
456 }
457 else
458 {
459 size_t i = 0;
460
461 for( wxString fieldName : aBomJob->m_fieldsOrdered )
462 {
463 // Handle wildcard. We allow the wildcard anywhere in the list, but it needs to respect
464 // fields that come before and after the wildcard.
465 if( fieldName == wxS( "*" ) )
466 {
467 for( const BOM_FIELD& modelField : dataModel.GetFieldsOrdered() )
468 {
469 struct BOM_FIELD field;
470
471 field.name = modelField.name;
472 field.show = true;
473 field.groupBy = false;
474 field.label = field.name;
475
476 bool fieldAlreadyPresent = false;
477 for( BOM_FIELD& presetField : preset.fieldsOrdered )
478 {
479 if( presetField.name == field.name )
480 {
481 fieldAlreadyPresent = true;
482 break;
483 }
484 }
485
486 bool fieldLaterInList = false;
487 for( const wxString& fieldInList : aBomJob->m_fieldsOrdered )
488 {
489 if( fieldInList == field.name )
490 {
491 fieldLaterInList = true;
492 break;
493 }
494 }
495
496 if( !fieldAlreadyPresent && !fieldLaterInList )
497 preset.fieldsOrdered.emplace_back( field );
498 }
499
500 continue;
501 }
502
503 struct BOM_FIELD field;
504
505 field.name = fieldName;
506 field.show = true;
507 field.groupBy = std::find( aBomJob->m_fieldsGroupBy.begin(),
508 aBomJob->m_fieldsGroupBy.end(), field.name )
509 != aBomJob->m_fieldsGroupBy.end();
510
511 if( ( aBomJob->m_fieldsLabels.size() > i ) && !aBomJob->m_fieldsLabels[i].IsEmpty() )
512 field.label = aBomJob->m_fieldsLabels[i];
513 else if( IsTextVar( field.name ) )
514 field.label = GetTextVars( field.name );
515 else
516 field.label = field.name;
517
518 preset.fieldsOrdered.emplace_back( field );
519 i++;
520 }
521
522 preset.sortAsc = aBomJob->m_sortAsc;
523 preset.sortField = aBomJob->m_sortField;
524 preset.filterString = aBomJob->m_filterString;
525 preset.groupSymbols = ( aBomJob->m_fieldsGroupBy.size() > 0 );
526 preset.excludeDNP = aBomJob->m_excludeDNP;
528 }
529
530 dataModel.ApplyBomPreset( preset );
531
532 if( aBomJob->m_outputFile.IsEmpty() )
533 {
534 wxFileName fn = sch->GetFileName();
535 fn.SetName( fn.GetName() );
536 fn.SetExt( FILEEXT::CsvFileExtension );
537
538 aBomJob->m_outputFile = fn.GetFullName();
539 }
540
541 wxFile f;
542
543 if( !f.Open( aBomJob->m_outputFile, wxFile::write ) )
544 {
545 m_reporter->Report( wxString::Format( _( "Unable to open destination '%s'" ),
546 aBomJob->m_outputFile ),
548
550 }
551
552 BOM_FMT_PRESET fmt;
553
554 // Load a format preset if one is specified
555 if( !aBomJob->m_bomFmtPresetName.IsEmpty() )
556 {
557 // Make sure the built-in presets are loaded
559 sch->Settings().m_BomFmtPresets.emplace_back( p );
560
561 // Find the preset
562 BOM_FMT_PRESET* schFmtPreset = nullptr;
563
564 for( BOM_FMT_PRESET& p : sch->Settings().m_BomFmtPresets )
565 {
566 if( p.name == aBomJob->m_bomFmtPresetName )
567 {
568 schFmtPreset = &p;
569 break;
570 }
571 }
572
573 if( !schFmtPreset )
574 {
576 wxString::Format( _( "BOM format preset '%s' not found" ) + wxS( "\n" ),
577 aBomJob->m_bomFmtPresetName ),
579
581 }
582
583 fmt = *schFmtPreset;
584 }
585 else
586 {
587 fmt.fieldDelimiter = aBomJob->m_fieldDelimiter;
588 fmt.stringDelimiter = aBomJob->m_stringDelimiter;
589 fmt.refDelimiter = aBomJob->m_refDelimiter;
591 fmt.keepTabs = aBomJob->m_keepTabs;
592 fmt.keepLineBreaks = aBomJob->m_keepLineBreaks;
593 }
594
595 bool res = f.Write( dataModel.Export( fmt ) );
596
597 if( !res )
599
600 return CLI::EXIT_CODES::OK;
601}
602
603
605{
606 JOB_EXPORT_SCH_PYTHONBOM* aNetJob = dynamic_cast<JOB_EXPORT_SCH_PYTHONBOM*>( aJob );
607
608 if( !aNetJob )
610
611 SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aNetJob->m_filename, SCH_IO_MGR::SCH_KICAD, true );
612
613 if( sch == nullptr )
614 {
615 m_reporter->Report( _( "Failed to load schematic file\n" ), RPT_SEVERITY_ERROR );
617 }
618
619 // Annotation warning check
620 SCH_REFERENCE_LIST referenceList;
621 sch->GetSheets().GetSymbols( referenceList );
622
623 if( referenceList.GetCount() > 0 )
624 {
625 if( referenceList.CheckAnnotation(
626 []( ERCE_T, const wxString&, SCH_REFERENCE*, SCH_REFERENCE* )
627 {
628 // We're only interested in the end result -- either errors or not
629 } )
630 > 0 )
631 {
633 _( "Warning: schematic has annotation errors, please use the schematic "
634 "editor to fix them\n" ),
636 }
637 }
638
639 // Test duplicate sheet names:
640 ERC_TESTER erc( sch );
641
642 if( erc.TestDuplicateSheetNames( false ) > 0 )
643 m_reporter->Report( _( "Warning: duplicate sheet names.\n" ), RPT_SEVERITY_WARNING );
644
645 std::unique_ptr<NETLIST_EXPORTER_XML> xmlNetlist =
646 std::make_unique<NETLIST_EXPORTER_XML>( sch );
647
648 if( aNetJob->m_outputFile.IsEmpty() )
649 {
650 wxFileName fn = sch->GetFileName();
651 fn.SetName( fn.GetName() + "-bom" );
652 fn.SetExt( FILEEXT::XmlFileExtension );
653
654 aNetJob->m_outputFile = fn.GetFullName();
655 }
656
657 bool res = xmlNetlist->WriteNetlist( aNetJob->m_outputFile, GNL_OPT_BOM, *m_reporter );
658
659 if( !res )
661
662 return CLI::EXIT_CODES::OK;
663}
664
665
667 SCH_RENDER_SETTINGS* aRenderSettings,
668 LIB_SYMBOL* symbol )
669{
670 wxASSERT( symbol != nullptr );
671
672 if( symbol == nullptr )
674
675 LIB_SYMBOL* symbolToPlot = symbol;
676
677 // if the symbol is an alias, then the draw items are stored in the root symbol
678 if( symbol->IsAlias() )
679 {
680 if( LIB_SYMBOL_SPTR parent = symbol->GetRootSymbol() )
681 {
682 symbolToPlot = parent.get();
683 }
684 else
685 {
686 wxCHECK( false, CLI::EXIT_CODES::ERR_UNKNOWN );
687 }
688 }
689
690 // iterate from unit 1, unit 0 would be "all units" which we don't want
691 for( int unit = 1; unit < symbol->GetUnitCount() + 1; unit++ )
692 {
693 for( int bodyStyle = 1; bodyStyle < ( symbol->HasAlternateBodyStyle() ? 2 : 1 ) + 1; ++bodyStyle )
694 {
695 wxString filename;
696 wxFileName fn;
697 size_t forbidden_char;
698
699 fn.SetPath( aSvgJob->m_outputDirectory );
700 fn.SetExt( FILEEXT::SVGFileExtension );
701
702 filename = symbol->GetName().Lower();
703
704 while( wxString::npos
705 != ( forbidden_char = filename.find_first_of(
706 wxFileName::GetForbiddenChars( wxPATH_DOS ) ) ) )
707 {
708 filename = filename.replace( forbidden_char, 1, wxS( '_' ) );
709 }
710
711 //simplify the name if its single unit
712 if( symbol->GetUnitCount() > 1 )
713 {
714 filename += wxString::Format( "_%d", unit );
715
716 if( bodyStyle == 2 )
717 filename += wxS( "_demorgan" );
718
719 fn.SetName( filename );
720 m_reporter->Report( wxString::Format( _( "Plotting symbol '%s' unit %d to '%s'\n" ),
721 symbol->GetName(), unit, fn.GetFullPath() ),
723 }
724 else
725 {
726 if( bodyStyle == 2 )
727 filename += wxS( "_demorgan" );
728
729 fn.SetName( filename );
730 m_reporter->Report( wxString::Format( _( "Plotting symbol '%s' to '%s'\n" ),
731 symbol->GetName(), fn.GetFullPath() ),
733 }
734
735 // Get the symbol bounding box to fit the plot page to it
736 BOX2I symbolBB = symbol->Flatten()->GetUnitBoundingBox( unit, bodyStyle, false );
737 PAGE_INFO pageInfo( PAGE_INFO::Custom );
738 pageInfo.SetHeightMils( schIUScale.IUToMils( symbolBB.GetHeight() * 1.2 ) );
739 pageInfo.SetWidthMils( schIUScale.IUToMils( symbolBB.GetWidth() * 1.2 ) );
740
741 SVG_PLOTTER* plotter = new SVG_PLOTTER();
742 plotter->SetRenderSettings( aRenderSettings );
743 plotter->SetPageSettings( pageInfo );
744 plotter->SetColorMode( !aSvgJob->m_blackAndWhite );
745
746 VECTOR2I plot_offset;
747 const double scale = 1.0;
748
749 // Currently, plot units are in decimal
750 plotter->SetViewport( plot_offset, schIUScale.IU_PER_MILS / 10, scale, false );
751
752 plotter->SetCreator( wxT( "Eeschema-SVG" ) );
753
754 if( !plotter->OpenFile( fn.GetFullPath() ) )
755 {
757 wxString::Format( _( "Unable to open destination '%s'" ) + wxS( "\n" ),
758 fn.GetFullPath() ),
760
761 delete plotter;
763 }
764
765 LOCALE_IO toggle;
766 SCH_PLOT_OPTS plotOpts;
767
768 plotter->StartPlot( wxT( "1" ) );
769
770 bool background = true;
771 VECTOR2I offset( pageInfo.GetWidthIU( schIUScale.IU_PER_MILS ) / 2,
772 pageInfo.GetHeightIU( schIUScale.IU_PER_MILS ) / 2 );
773
774 // note, we want the fields from the original symbol pointer (in case of non-alias)
775 symbolToPlot->Plot( plotter, background, plotOpts, unit, bodyStyle, offset, false );
776 symbol->PlotFields( plotter, background, plotOpts, unit, bodyStyle, offset, false );
777
778 symbolToPlot->Plot( plotter, !background, plotOpts, unit, bodyStyle, offset, false );
779 symbol->PlotFields( plotter, !background, plotOpts, unit, bodyStyle, offset, false );
780
781 plotter->EndPlot();
782 delete plotter;
783 }
784 }
785
786 return CLI::EXIT_CODES::OK;
787}
788
789
791{
792 JOB_SYM_EXPORT_SVG* svgJob = dynamic_cast<JOB_SYM_EXPORT_SVG*>( aJob );
793
794 if( !svgJob )
796
797 wxFileName fn( svgJob->m_libraryPath );
798 fn.MakeAbsolute();
799
800 SCH_IO_KICAD_SEXPR_LIB_CACHE schLibrary( fn.GetFullPath() );
801
802 try
803 {
804 schLibrary.Load();
805 }
806 catch( ... )
807 {
808 m_reporter->Report( _( "Unable to load library\n" ), RPT_SEVERITY_ERROR );
810 }
811
812 LIB_SYMBOL* symbol = nullptr;
813
814 if( !svgJob->m_symbol.IsEmpty() )
815 {
816 // See if the selected symbol exists
817 symbol = schLibrary.GetSymbol( svgJob->m_symbol );
818
819 if( !symbol )
820 {
821 m_reporter->Report( _( "There is no symbol selected to save." ) + wxS( "\n" ),
824 }
825 }
826
827 if( !svgJob->m_outputDirectory.IsEmpty() && !wxDir::Exists( svgJob->m_outputDirectory ) )
828 {
829 wxFileName::Mkdir( svgJob->m_outputDirectory );
830 }
831
832 SCH_RENDER_SETTINGS renderSettings;
834 renderSettings.LoadColors( cs );
836 renderSettings.m_ShowHiddenPins = svgJob->m_includeHiddenPins;
837 renderSettings.m_ShowHiddenFields = svgJob->m_includeHiddenFields;
838
839 int exitCode = CLI::EXIT_CODES::OK;
840
841 if( symbol )
842 {
843 exitCode = doSymExportSvg( svgJob, &renderSettings, symbol );
844 }
845 else
846 {
847 // Just plot all the symbols we can
848 const LIB_SYMBOL_MAP& libSymMap = schLibrary.GetSymbolMap();
849
850 for( const std::pair<const wxString, LIB_SYMBOL*>& entry : libSymMap )
851 {
852 exitCode = doSymExportSvg( svgJob, &renderSettings, entry.second );
853
854 if( exitCode != CLI::EXIT_CODES::OK )
855 break;
856 }
857 }
858
859 return exitCode;
860}
861
862
864{
865 JOB_SYM_UPGRADE* upgradeJob = dynamic_cast<JOB_SYM_UPGRADE*>( aJob );
866
867 if( !upgradeJob )
869
870 wxFileName fn( upgradeJob->m_libraryPath );
871 fn.MakeAbsolute();
872
873 SCH_IO_MGR::SCH_FILE_T fileType = SCH_IO_MGR::GuessPluginTypeFromLibPath( fn.GetFullPath() );
874
875 if( !upgradeJob->m_outputLibraryPath.IsEmpty() )
876 {
877 if( wxFile::Exists( upgradeJob->m_outputLibraryPath ) )
878 {
879 m_reporter->Report( _( "Output path must not conflict with existing path\n" ),
881
883 }
884 }
885 else if( fileType != SCH_IO_MGR::SCH_KICAD )
886 {
887 m_reporter->Report( _( "Output path must be specified to convert legacy and non-KiCad libraries\n" ),
889
891 }
892
893 if( fileType == SCH_IO_MGR::SCH_KICAD )
894 {
895 SCH_IO_KICAD_SEXPR_LIB_CACHE schLibrary( fn.GetFullPath() );
896
897 try
898 {
899 schLibrary.Load();
900 }
901 catch( ... )
902 {
903 m_reporter->Report( _( "Unable to load library\n" ), RPT_SEVERITY_ERROR );
905 }
906
907 bool shouldSave =
908 upgradeJob->m_force
910
911 if( shouldSave )
912 {
913 m_reporter->Report( _( "Saving symbol library in updated format\n" ),
915
916 try
917 {
918 if( !upgradeJob->m_outputLibraryPath.IsEmpty() )
919 {
920 schLibrary.SetFileName( upgradeJob->m_outputLibraryPath );
921 }
922
923 schLibrary.SetModified();
924 schLibrary.Save();
925 }
926 catch( ... )
927 {
928 m_reporter->Report( ( "Unable to save library\n" ), RPT_SEVERITY_ERROR );
930 }
931 }
932 else
933 {
934 m_reporter->Report( _( "Symbol library was not updated\n" ), RPT_SEVERITY_INFO );
935 }
936 }
937 else
938 {
939 if( !SCH_IO_MGR::ConvertLibrary( nullptr, fn.GetAbsolutePath(), upgradeJob->m_outputLibraryPath ) )
940 {
941 m_reporter->Report( ( "Unable to convert library\n" ), RPT_SEVERITY_ERROR );
943 }
944 }
945
946 return CLI::EXIT_CODES::OK;
947}
948
949
950
952{
953 JOB_SCH_ERC* ercJob = dynamic_cast<JOB_SCH_ERC*>( aJob );
954
955 if( !ercJob )
957
958 SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( ercJob->m_filename, SCH_IO_MGR::SCH_KICAD, true );
959
960 if( sch == nullptr )
961 {
962 m_reporter->Report( _( "Failed to load schematic file\n" ), RPT_SEVERITY_ERROR );
964 }
965
966 sch->Prj().ApplyTextVars( aJob->GetVarOverrides() );
967
968 if( ercJob->m_outputFile.IsEmpty() )
969 {
970 wxFileName fn = sch->GetFileName();
971 fn.SetName( fn.GetName() );
972
974 fn.SetExt( FILEEXT::JsonFileExtension );
975 else
976 fn.SetExt( FILEEXT::ReportFileExtension );
977
978 ercJob->m_outputFile = fn.GetFullName();
979 }
980
981 EDA_UNITS units;
982
983 switch( ercJob->m_units )
984 {
985 case JOB_SCH_ERC::UNITS::INCHES: units = EDA_UNITS::INCHES; break;
986 case JOB_SCH_ERC::UNITS::MILS: units = EDA_UNITS::MILS; break;
987 case JOB_SCH_ERC::UNITS::MILLIMETERS: units = EDA_UNITS::MILLIMETRES; break;
988 default: units = EDA_UNITS::MILLIMETRES; break;
989 }
990
991 std::shared_ptr<SHEETLIST_ERC_ITEMS_PROVIDER> markersProvider =
992 std::make_shared<SHEETLIST_ERC_ITEMS_PROVIDER>( sch );
993
994 ERC_TESTER ercTester( sch );
995
996 m_reporter->Report( _( "Running ERC...\n" ), RPT_SEVERITY_INFO );
997
998 std::unique_ptr<DS_PROXY_VIEW_ITEM> drawingSheet( getDrawingSheetProxyView( sch ) );
999 ercTester.RunTests( drawingSheet.get(), nullptr, m_kiway->KiFACE( KIWAY::FACE_CVPCB ),
1000 &sch->Prj(), m_progressReporter );
1001
1002 markersProvider->SetSeverities( ercJob->m_severity );
1003
1004 m_reporter->Report( wxString::Format( _( "Found %d violations\n" ),
1005 markersProvider->GetCount() ),
1007
1008 ERC_REPORT reportWriter( sch, units );
1009
1010 bool wroteReport = false;
1011
1013 wroteReport = reportWriter.WriteJsonReport( ercJob->m_outputFile );
1014 else
1015 wroteReport = reportWriter.WriteTextReport( ercJob->m_outputFile );
1016
1017 if( !wroteReport )
1018 {
1019 m_reporter->Report( wxString::Format( _( "Unable to save ERC report to %s\n" ),
1020 ercJob->m_outputFile ),
1023 }
1024
1025 m_reporter->Report( wxString::Format( _( "Saved ERC Report to %s\n" ), ercJob->m_outputFile ),
1027
1028 if( ercJob->m_exitCodeViolations )
1029 {
1030 if( markersProvider->GetCount() > 0 )
1032 }
1033
1035}
1036
1037
1039{
1040 DS_PROXY_VIEW_ITEM* drawingSheet =
1042 &aSch->Prj(), &aSch->RootScreen()->GetTitleBlock(),
1043 aSch->GetProperties() );
1044
1045 drawingSheet->SetPageNumber( TO_UTF8( aSch->RootScreen()->GetPageNumber() ) );
1046 drawingSheet->SetSheetCount( aSch->RootScreen()->GetPageCount() );
1047 drawingSheet->SetFileName( TO_UTF8( aSch->RootScreen()->GetFileName() ) );
1050 drawingSheet->SetIsFirstPage( aSch->RootScreen()->GetVirtualPageNumber() == 1 );
1051
1052 drawingSheet->SetSheetName( "" );
1053 drawingSheet->SetSheetPath( "" );
1054
1055 return drawingSheet;
1056}
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
size_type GetHeight() const
Definition: box2.h:205
size_type GetWidth() const
Definition: box2.h:204
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(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)
EESCHEMA_JOBS_HANDLER(KIWAY *aKiway)
int doSymExportSvg(JOB_SYM_EXPORT_SVG *aSvgJob, SCH_RENDER_SETTINGS *aRenderSettings, LIB_SYMBOL *symbol)
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:1232
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)
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
Define a library symbol object.
Definition: lib_symbol.h:77
bool IsAlias() const
Definition: lib_symbol.h:194
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
Definition: lib_symbol.cpp:821
bool HasAlternateBodyStyle() const override
Test if symbol has more than one body conversion type (DeMorgan).
void PlotFields(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed)
Plot symbol fields.
Definition: lib_symbol.cpp:863
wxString GetName() const override
Definition: lib_symbol.h:136
int GetUnitCount() const override
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:579
LIB_SYMBOL_SPTR GetRootSymbol() const
Get the parent symbol that does not have another parent.
Definition: lib_symbol.cpp:511
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:142
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.
void LoadColors(const COLOR_SETTINGS *aSettings) override
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:108
int GetFieldCount() const
Return the number of fields in this symbol.
Definition: sch_symbol.h:571
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:958
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.
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:395
@ LAYER_SCHEMATIC_PAGE_LIMITS
Definition: layer_ids.h:396
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:1059
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:83
static std::vector< BOM_FMT_PRESET > BuiltInPresets()
wxString stringDelimiter
Definition: bom_settings.h:84
wxString refRangeDelimiter
Definition: bom_settings.h:86
wxString refDelimiter
Definition: bom_settings.h:85
wxString sortField
Definition: bom_settings.h:54
bool groupSymbols
Definition: bom_settings.h:57
std::vector< BOM_FIELD > fieldsOrdered
Definition: bom_settings.h:53
bool includeExcludedFromBOM
Definition: bom_settings.h:59
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
std::vector< wxString > m_plotPages
Definition: sch_plotter.h:83
wxString m_theme
Definition: sch_plotter.h:92
bool m_PDFPropertyPopups
Definition: sch_plotter.h:90
wxString m_outputDirectory
Definition: sch_plotter.h:94
HPGL_PLOT_ORIGIN_AND_UNITS m_HPGLPlotOrigin
Definition: sch_plotter.h:97
wxString m_outputFile
Definition: sch_plotter.h:95
int m_pageSizeSelect
Definition: sch_plotter.h:86
bool m_PDFMetadata
Definition: sch_plotter.h:91
bool m_blackAndWhite
Definition: sch_plotter.h:85
HPGL_PAGE_SIZE m_HPGLPaperSizeSelect
Definition: sch_plotter.h:89
double m_HPGLPenSize
Definition: sch_plotter.h:88
bool m_useBackgroundColor
Definition: sch_plotter.h:87
bool m_plotDrawingSheet
Definition: sch_plotter.h:82
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
Definition of file extensions used in Kicad.