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 <pgm_base.h>
23#include <cli/exit_codes.h>
24#include <sch_plotter.h>
31#include <schematic.h>
32#include <wx/crt.h>
33#include <wx/dir.h>
34#include <wx/file.h>
35#include <memory>
36#include <connection_graph.h>
37#include "eeschema_helpers.h"
38#include <sch_painter.h>
39#include <locale_io.h>
40#include <erc.h>
44
46
47#include <sch_file_versions.h>
49
50#include <netlist.h>
58
59#include <fields_data_model.h>
60
61
63{
64 Register( "bom",
65 std::bind( &EESCHEMA_JOBS_HANDLER::JobExportBom, this, std::placeholders::_1 ) );
66 Register( "pythonbom",
67 std::bind( &EESCHEMA_JOBS_HANDLER::JobExportPythonBom, this, std::placeholders::_1 ) );
68 Register( "netlist",
69 std::bind( &EESCHEMA_JOBS_HANDLER::JobExportNetlist, this, std::placeholders::_1 ) );
70 Register( "plot",
71 std::bind( &EESCHEMA_JOBS_HANDLER::JobExportPlot, this, std::placeholders::_1 ) );
72 Register( "symupgrade",
73 std::bind( &EESCHEMA_JOBS_HANDLER::JobSymUpgrade, this, std::placeholders::_1 ) );
74 Register( "symsvg",
75 std::bind( &EESCHEMA_JOBS_HANDLER::JobSymExportSvg, this, std::placeholders::_1 ) );
76}
77
78
80 const wxString& aTheme, SCHEMATIC* aSch )
81{
82 COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetColorSettings( aTheme );
83 aRenderSettings->LoadColors( cs );
84
85 aRenderSettings->SetDefaultPenWidth( aSch->Settings().m_DefaultLineWidth );
86 aRenderSettings->m_LabelSizeRatio = aSch->Settings().m_LabelSizeRatio;
87 aRenderSettings->m_TextOffsetRatio = aSch->Settings().m_TextOffsetRatio;
88 aRenderSettings->m_PinSymbolSize = aSch->Settings().m_PinSymbolSize;
89
90 aRenderSettings->SetDashLengthRatio( aSch->Settings().m_DashedLineDashRatio );
91 aRenderSettings->SetGapLengthRatio( aSch->Settings().m_DashedLineGapRatio );
92
93 // Load the drawing sheet from the filename stored in BASE_SCREEN::m_DrawingSheetFileName.
94 // If empty, or not existing, the default drawing sheet is loaded.
96 aSch->Prj().GetProjectPath() );
97
98 if( !DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet( filename ) )
99 wxFprintf( stderr, _( "Error loading drawing sheet." ) );
100}
101
102
103REPORTER& EESCHEMA_JOBS_HANDLER::Report( const wxString& aText, SEVERITY aSeverity )
104{
105 if( aSeverity == RPT_SEVERITY_ERROR )
106 wxFprintf( stderr, wxS( "%s\n" ), aText );
107 else
108 wxPrintf( wxS( "%s\n" ), aText );
109
110 return *this;
111}
112
113
115{
116 JOB_EXPORT_SCH_PLOT* aPlotJob = dynamic_cast<JOB_EXPORT_SCH_PLOT*>( aJob );
117
118 if( !aPlotJob )
120
121 SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aPlotJob->m_filename, SCH_IO_MGR::SCH_KICAD );
122
123 if( sch == nullptr )
124 {
125 wxFprintf( stderr, _( "Failed to load schematic file\n" ) );
127 }
128
129 std::unique_ptr<KIGFX::SCH_RENDER_SETTINGS> renderSettings =
130 std::make_unique<KIGFX::SCH_RENDER_SETTINGS>();
131 InitRenderSettings( renderSettings.get(), aPlotJob->settings.m_theme, sch );
132
133 std::unique_ptr<SCH_PLOTTER> schPlotter = std::make_unique<SCH_PLOTTER>( sch );
134 schPlotter->Plot( aPlotJob->m_plotFormat, aPlotJob->settings, renderSettings.get(), this );
135
136 return CLI::EXIT_CODES::OK;
137}
138
139
141{
142 JOB_EXPORT_SCH_NETLIST* aNetJob = dynamic_cast<JOB_EXPORT_SCH_NETLIST*>( aJob );
143
144 if( !aNetJob )
146
147 SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aNetJob->m_filename, SCH_IO_MGR::SCH_KICAD );
148
149 if( sch == nullptr )
150 {
151 wxFprintf( stderr, _( "Failed to load schematic file\n" ) );
153 }
154
155 // Annotation warning check
156 SCH_REFERENCE_LIST referenceList;
157 sch->GetSheets().GetSymbols( referenceList );
158
159 if( referenceList.GetCount() > 0 )
160 {
161 if( referenceList.CheckAnnotation(
162 []( ERCE_T, const wxString&, SCH_REFERENCE*, SCH_REFERENCE* )
163 {
164 // We're only interested in the end result -- either errors or not
165 } )
166 > 0 )
167 {
168 wxPrintf( _( "Warning: schematic has annotation errors, please use the schematic editor to fix them\n" ) );
169 }
170 }
171
172 // Test duplicate sheet names:
173 ERC_TESTER erc( sch );
174
175 if( erc.TestDuplicateSheetNames( false ) > 0 )
176 {
177 wxPrintf( _( "Warning: duplicate sheet names.\n" ) );
178 }
179
180
181 std::unique_ptr<NETLIST_EXPORTER_BASE> helper;
182 unsigned netlistOption = 0;
183
184 wxString fileExt;
185
186 switch( aNetJob->format )
187 {
189 fileExt = NetlistFileExtension;
190 helper = std::make_unique<NETLIST_EXPORTER_KICAD>( sch );
191 break;
192
195 helper = std::make_unique<NETLIST_EXPORTER_ORCADPCB2>( sch );
196 break;
197
200 helper = std::make_unique<NETLIST_EXPORTER_CADSTAR>( sch );
201 break;
202
204 fileExt = SpiceFileExtension;
206 helper = std::make_unique<NETLIST_EXPORTER_SPICE>( sch );
207 break;
208
210 fileExt = SpiceFileExtension;
211 helper = std::make_unique<NETLIST_EXPORTER_SPICE_MODEL>( sch );
212 break;
213
215 fileExt = wxS( "xml" );
216 helper = std::make_unique<NETLIST_EXPORTER_XML>( sch );
217 break;
218 default:
219 wxFprintf( stderr, _( "Unknown netlist format.\n" ) );
221 }
222
223
224 if( aNetJob->m_outputFile.IsEmpty() )
225 {
226 wxFileName fn = sch->GetFileName();
227 fn.SetName( fn.GetName() );
228 fn.SetExt( fileExt );
229
230 aNetJob->m_outputFile = fn.GetFullName();
231 }
232
233 bool res = helper->WriteNetlist( aNetJob->m_outputFile, netlistOption, *this );
234
235 if(!res)
236 {
238 }
239
240 return CLI::EXIT_CODES::OK;
241}
242
243
245{
246 JOB_EXPORT_SCH_BOM* aBomJob = dynamic_cast<JOB_EXPORT_SCH_BOM*>( aJob );
247
248 if( !aBomJob )
250
251 SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aBomJob->m_filename, SCH_IO_MGR::SCH_KICAD );
252
253 if( sch == nullptr )
254 {
255 wxFprintf( stderr, _( "Failed to load schematic file\n" ) );
257 }
258
259 // Annotation warning check
260 SCH_REFERENCE_LIST referenceList;
261 sch->GetSheets().GetSymbols( referenceList, false, false );
262
263 if( referenceList.GetCount() > 0 )
264 {
265 SCH_REFERENCE_LIST copy = referenceList;
266
267 // Check annotation splits references...
268 if( copy.CheckAnnotation(
269 []( ERCE_T, const wxString&, SCH_REFERENCE*, SCH_REFERENCE* )
270 {
271 // We're only interested in the end result -- either errors or not
272 } )
273 > 0 )
274 {
275 wxPrintf( _( "Warning: schematic has annotation errors, please use the schematic "
276 "editor to fix them\n" ) );
277 }
278 }
279
280 // Test duplicate sheet names:
281 ERC_TESTER erc( sch );
282
283 if( erc.TestDuplicateSheetNames( false ) > 0 )
284 {
285 wxPrintf( _( "Warning: duplicate sheet names.\n" ) );
286 }
287
288
289 // Build our data model
290 FIELDS_EDITOR_GRID_DATA_MODEL dataModel( referenceList );
291
292 // Mandatory fields + quantity virtual field first
293 for( int i = 0; i < MANDATORY_FIELDS; ++i )
295 TEMPLATE_FIELDNAME::GetDefaultFieldName( i, true ), false );
296
297 dataModel.AddColumn( wxS( "Quantity" ), _( "Qty" ), false );
298
299 // User field names in symbols second
300 std::set<wxString> userFieldNames;
301
302 for( size_t i = 0; i < referenceList.GetCount(); ++i )
303 {
304 SCH_SYMBOL* symbol = referenceList[i].GetSymbol();
305
306 for( int j = MANDATORY_FIELDS; j < symbol->GetFieldCount(); ++j )
307 userFieldNames.insert( symbol->GetFields()[j].GetName() );
308 }
309
310 for( const wxString& fieldName : userFieldNames )
311 dataModel.AddColumn( fieldName, fieldName, true );
312
313 // Add any templateFieldNames which aren't already present in the userFieldNames
314 for( const TEMPLATE_FIELDNAME& templateFieldname :
316 {
317 if( userFieldNames.count( templateFieldname.m_Name ) == 0 )
318 dataModel.AddColumn( templateFieldname.m_Name, templateFieldname.m_Name, false );
319 }
320
321 BOM_PRESET preset;
322
323 size_t i = 0;
324 for( wxString fieldName : aBomJob->m_fieldsOrdered )
325 {
326 struct BOM_FIELD field;
327
328 field.name = fieldName;
329 field.show = true;
330 field.groupBy = std::find( aBomJob->m_fieldsGroupBy.begin(), aBomJob->m_fieldsGroupBy.end(),
331 field.name )
332 != aBomJob->m_fieldsGroupBy.end();
333 field.label =
334 ( ( aBomJob->m_fieldsLabels.size() < i ) && !aBomJob->m_fieldsLabels[i].IsEmpty() )
335 ? aBomJob->m_fieldsLabels[i]
336 : field.name;
337
338 preset.fieldsOrdered.emplace_back( field );
339 i++;
340 }
341
342 preset.sortAsc = aBomJob->m_sortAsc;
343 preset.sortField = aBomJob->m_sortField;
344 preset.groupSymbols = aBomJob->m_groupSymbols;
345 preset.filterString = aBomJob->m_filterString;
346
347 dataModel.ApplyBomPreset( preset );
348
349 if( aBomJob->m_outputFile.IsEmpty() )
350 {
351 wxFileName fn = sch->GetFileName();
352 fn.SetName( fn.GetName() );
353 fn.SetExt( CsvFileExtension );
354
355 aBomJob->m_outputFile = fn.GetFullName();
356 }
357
358 wxFile f;
359 if( !f.Open( aBomJob->m_outputFile, wxFile::write ) )
360 {
361 wxFprintf( stderr, _( "Unable to open destination '%s'" ), aBomJob->m_outputFile );
363 }
364
365 BOM_FMT_PRESET fmt;
366 fmt.fieldDelimiter = aBomJob->m_fieldDelimiter;
367 fmt.stringDelimiter = aBomJob->m_stringDelimiter;
368 fmt.refDelimiter = aBomJob->m_refDelimiter;
370 fmt.keepTabs = aBomJob->m_keepTabs;
371 fmt.keepLineBreaks = aBomJob->m_keepLineBreaks;
372
373 bool res = f.Write( dataModel.Export( fmt ) );
374
375 if( !res )
376 {
378 }
379
380 return CLI::EXIT_CODES::OK;
381}
382
383
385{
386 JOB_EXPORT_SCH_PYTHONBOM* aNetJob = dynamic_cast<JOB_EXPORT_SCH_PYTHONBOM*>( aJob );
387
388 if( !aNetJob )
390
391 SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aNetJob->m_filename, SCH_IO_MGR::SCH_KICAD );
392
393 if( sch == nullptr )
394 {
395 wxFprintf( stderr, _( "Failed to load schematic file\n" ) );
397 }
398
399 // Annotation warning check
400 SCH_REFERENCE_LIST referenceList;
401 sch->GetSheets().GetSymbols( referenceList );
402
403 if( referenceList.GetCount() > 0 )
404 {
405 if( referenceList.CheckAnnotation(
406 []( ERCE_T, const wxString&, SCH_REFERENCE*, SCH_REFERENCE* )
407 {
408 // We're only interested in the end result -- either errors or not
409 } )
410 > 0 )
411 {
412 wxPrintf( _( "Warning: schematic has annotation errors, please use the schematic "
413 "editor to fix them\n" ) );
414 }
415 }
416
417 // Test duplicate sheet names:
418 ERC_TESTER erc( sch );
419
420 if( erc.TestDuplicateSheetNames( false ) > 0 )
421 wxPrintf( _( "Warning: duplicate sheet names.\n" ) );
422
423 std::unique_ptr<NETLIST_EXPORTER_XML> xmlNetlist =
424 std::make_unique<NETLIST_EXPORTER_XML>( sch );
425
426 if( aNetJob->m_outputFile.IsEmpty() )
427 {
428 wxFileName fn = sch->GetFileName();
429 fn.SetName( fn.GetName() + "-bom" );
430 fn.SetExt( XmlFileExtension );
431
432 aNetJob->m_outputFile = fn.GetFullName();
433 }
434
435 bool res = xmlNetlist->WriteNetlist( aNetJob->m_outputFile, GNL_OPT_BOM, *this );
436
437 if( !res )
439
440 return CLI::EXIT_CODES::OK;
441}
442
443
445 KIGFX::SCH_RENDER_SETTINGS* aRenderSettings,
446 LIB_SYMBOL* symbol )
447{
448 wxASSERT( symbol != nullptr );
449
450 if( symbol == nullptr )
452
453 LIB_SYMBOL* symbolToPlot = symbol;
454
455 // if the symbol is an alias, then the draw items are stored in the parent
456 if( symbol->IsAlias() )
457 {
458 LIB_SYMBOL_SPTR parent = symbol->GetParent().lock();
459 symbolToPlot = parent.get();
460 }
461
462 if( aSvgJob->m_includeHiddenPins )
463 {
464 // horrible hack, TODO overhaul the Plot method to handle this
465 for( LIB_ITEM& item : symbolToPlot->GetDrawItems() )
466 {
467 if( item.Type() != LIB_PIN_T )
468 continue;
469
470 LIB_PIN& pin = static_cast<LIB_PIN&>( item );
471 pin.SetVisible( true );
472 }
473 }
474
475 // iterate from unit 1, unit 0 would be "all units" which we don't want
476 for( int unit = 1; unit < symbol->GetUnitCount() + 1; unit++ )
477 {
478 for( int convert = 1; convert < ( symbol->HasConversion() ? 2 : 1 ) + 1; ++convert )
479 {
480 wxString filename;
481 wxFileName fn;
482
483 fn.SetPath( aSvgJob->m_outputDirectory );
484 fn.SetExt( SVGFileExtension );
485
486 //simplify the name if its single unit
487 if( symbol->IsMulti() )
488 {
489 filename = wxString::Format( "%s_%d", symbol->GetName().Lower(), unit );
490
491 if( convert == 2 )
492 filename += wxS( "_demorgan" );
493
494 fn.SetName( filename );
495 wxPrintf( _( "Plotting symbol '%s' unit %d to '%s'\n" ), symbol->GetName(), unit,
496 fn.GetFullPath() );
497 }
498 else
499 {
500 filename = symbol->GetName().Lower();
501
502 if( convert == 2 )
503 filename += wxS( "_demorgan" );
504
505 wxPrintf( _( "Plotting symbol '%s' to '%s'\n" ), symbol->GetName(), fn.GetFullPath() );
506 }
507
508 // Get the symbol bounding box to fit the plot page to it
509 BOX2I symbolBB = symbol->Flatten()->GetUnitBoundingBox( unit, convert, false );
510 PAGE_INFO pageInfo( PAGE_INFO::Custom );
511 pageInfo.SetHeightMils( schIUScale.IUToMils( symbolBB.GetHeight() * 1.2 ) );
512 pageInfo.SetWidthMils( schIUScale.IUToMils( symbolBB.GetWidth() * 1.2 ) );
513
514 SVG_PLOTTER* plotter = new SVG_PLOTTER();
515 plotter->SetRenderSettings( aRenderSettings );
516 plotter->SetPageSettings( pageInfo );
517 plotter->SetColorMode( !aSvgJob->m_blackAndWhite );
518
519 VECTOR2I plot_offset;
520 const double scale = 1.0;
521
522 // Currently, plot units are in decimil
523 plotter->SetViewport( plot_offset, schIUScale.IU_PER_MILS / 10, scale, false );
524
525 plotter->SetCreator( wxT( "Eeschema-SVG" ) );
526
527 if( !plotter->OpenFile( fn.GetFullPath() ) )
528 {
529 wxFprintf( stderr, _( "Unable to open destination '%s'" ), fn.GetFullPath() );
530
531 delete plotter;
533 }
534
535 LOCALE_IO toggle;
536
537 plotter->StartPlot( wxT( "1" ) );
538
539 bool background = true;
540 TRANSFORM temp; // Uses default transform
541 VECTOR2I plotPos;
542
543 plotPos.x = pageInfo.GetWidthIU( schIUScale.IU_PER_MILS ) / 2;
544 plotPos.y = pageInfo.GetHeightIU( schIUScale.IU_PER_MILS ) / 2;
545
546 // note, we want the fields from the original symbol pointer (in case of non-alias)
547 symbolToPlot->Plot( plotter, unit, convert, background, plotPos, temp, false );
548 symbol->PlotLibFields( plotter, unit, convert, background, plotPos, temp, false,
549 aSvgJob->m_includeHiddenFields );
550
551 symbolToPlot->Plot( plotter, unit, convert, !background, plotPos, temp, false );
552 symbol->PlotLibFields( plotter, unit, convert, !background, plotPos, temp, false,
553 aSvgJob->m_includeHiddenFields );
554
555 plotter->EndPlot();
556 delete plotter;
557 }
558 }
559
560 return CLI::EXIT_CODES::OK;
561}
562
563
565{
566 JOB_SYM_EXPORT_SVG* svgJob = dynamic_cast<JOB_SYM_EXPORT_SVG*>( aJob );
567
568 if( !svgJob )
570
571 wxFileName fn( svgJob->m_libraryPath );
572 fn.MakeAbsolute();
573
574 SCH_SEXPR_PLUGIN_CACHE schLibrary( fn.GetFullPath() );
575
576 try
577 {
578 schLibrary.Load();
579 }
580 catch( ... )
581 {
582 wxFprintf( stderr, _( "Unable to load library\n" ) );
584 }
585
586 LIB_SYMBOL* symbol = nullptr;
587
588 if( !svgJob->m_symbol.IsEmpty() )
589 {
590 // See if the selected symbol exists
591 symbol = schLibrary.GetSymbol( svgJob->m_symbol );
592
593 if( !symbol )
594 {
595 wxFprintf( stderr, _( "There is no symbol selected to save." ) );
597 }
598 }
599
600 if( !svgJob->m_outputDirectory.IsEmpty() && !wxDir::Exists( svgJob->m_outputDirectory ) )
601 {
602 wxFileName::Mkdir( svgJob->m_outputDirectory );
603 }
604
605 KIGFX::SCH_RENDER_SETTINGS renderSettings;
606 COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetColorSettings( svgJob->m_colorTheme );
607 renderSettings.LoadColors( cs );
609
610 int exitCode = CLI::EXIT_CODES::OK;
611
612 if( symbol )
613 {
614 exitCode = doSymExportSvg( svgJob, &renderSettings, symbol );
615 }
616 else
617 {
618 // Just plot all the symbols we can
619 const LIB_SYMBOL_MAP& libSymMap = schLibrary.GetSymbolMap();
620
621 for( const std::pair<const wxString, LIB_SYMBOL*>& entry : libSymMap )
622 {
623 exitCode = doSymExportSvg( svgJob, &renderSettings, entry.second );
624
625 if( exitCode != CLI::EXIT_CODES::OK )
626 break;
627 }
628 }
629
630 return exitCode;
631}
632
633
635{
636 JOB_SYM_UPGRADE* upgradeJob = dynamic_cast<JOB_SYM_UPGRADE*>( aJob );
637
638 if( !upgradeJob )
640
641 wxFileName fn( upgradeJob->m_libraryPath );
642 fn.MakeAbsolute();
643
644 SCH_SEXPR_PLUGIN_CACHE schLibrary( fn.GetFullPath() );
645
646 try
647 {
648 schLibrary.Load();
649 }
650 catch( ... )
651 {
652 wxFprintf( stderr, _( "Unable to load library\n" ) );
654 }
655
656 if( !upgradeJob->m_outputLibraryPath.IsEmpty() )
657 {
658 if( wxFile::Exists( upgradeJob->m_outputLibraryPath ) )
659 {
660 wxFprintf( stderr, _( "Output path must not conflict with existing path\n" ) );
662 }
663 }
664
665 bool shouldSave = upgradeJob->m_force
667
668 if( shouldSave )
669 {
670 wxPrintf( _( "Saving symbol library in updated format\n" ) );
671
672 try
673 {
674 if( !upgradeJob->m_outputLibraryPath.IsEmpty() )
675 {
676 schLibrary.SetFileName( upgradeJob->m_outputLibraryPath );
677 }
678
679 schLibrary.SetModified();
680 schLibrary.Save();
681 }
682 catch( ... )
683 {
684 wxFprintf( stderr, _( "Unable to save library\n" ) );
686 }
687 }
688 else
689 {
690 wxPrintf( _( "Symbol library was not updated\n" ) );
691 }
692
693 return CLI::EXIT_CODES::OK;
694}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetWidth() const
Definition: box2.h:187
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.
static SCHEMATIC * LoadSchematic(wxString &aFileName)
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
int doSymExportSvg(JOB_SYM_EXPORT_SVG *aSvgJob, KIGFX::SCH_RENDER_SETTINGS *aRenderSettings, LIB_SYMBOL *symbol)
void InitRenderSettings(KIGFX::SCH_RENDER_SETTINGS *aRenderSettings, const wxString &aTheme, SCHEMATIC *aSch)
Configures the SCH_RENDER_SETTINGS object with the correct data to be used with plotting.
Definition: erc.h:48
void ApplyBomPreset(const BOM_PRESET &preset)
wxString Export(const BOM_FMT_PRESET &settings)
void AddColumn(const wxString &aFieldName, const wxString &aLabel, bool aAddedByUser)
void Register(const std::string &aJobTypeName, std::function< int(JOB *job)> aHandler)
std::vector< wxString > m_fieldsLabels
std::vector< wxString > m_fieldsOrdered
std::vector< wxString > m_fieldsGroupBy
SCH_PLOT_SETTINGS settings
wxString m_outputLibraryPath
wxString m_libraryPath
An simple container class that lets us dispatch output jobs to kifaces.
Definition: job.h:28
void SetDefaultPenWidth(int aWidth)
void SetGapLengthRatio(double aRatio)
void SetDashLengthRatio(double aRatio)
Store schematic specific render settings.
Definition: sch_painter.h:71
void LoadColors(const COLOR_SETTINGS *aSettings) override
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
Define a library symbol object.
Definition: lib_symbol.h:99
void Plot(PLOTTER *aPlotter, int aUnit, int aConvert, bool aBackground, const VECTOR2I &aOffset, const TRANSFORM &aTransform, bool aDimmed) const
Plot lib symbol to plotter.
Definition: lib_symbol.cpp:841
bool IsMulti() const
Definition: lib_symbol.h:564
bool IsAlias() const
Definition: lib_symbol.h:193
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition: lib_symbol.h:515
wxString GetName() const override
Definition: lib_symbol.h:143
void PlotLibFields(PLOTTER *aPlotter, int aUnit, int aConvert, 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:882
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:588
bool HasConversion() const
Test if symbol has more than one body conversion type (DeMorgan).
LIB_SYMBOL_REF & GetParent()
Definition: lib_symbol.h:127
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:41
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
void SetWidthMils(int aWidthInMils)
Definition: page_info.cpp:245
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
Definition: page_info.h:153
static const wxChar Custom[]
"User" defined page type
Definition: page_info.h:77
void SetHeightMils(int aHeightInMils)
Definition: page_info.cpp:259
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
Definition: page_info.h:144
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:143
void SetRenderSettings(RENDER_SETTINGS *aSettings)
Definition: plotter.h:140
virtual void SetCreator(const wxString &aCreator)
Definition: plotter.h:159
virtual void SetColorMode(bool aColorMode)
Plot in B/W or color.
Definition: plotter.h:137
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:126
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:71
wxString m_SchDrawingSheetFileName
TEMPLATES m_TemplateFieldNames
Holds all the data relating to one schematic.
Definition: schematic.h:72
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:199
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:205
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:97
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:87
virtual LIB_SYMBOL * GetSymbol(const wxString &aName)
const LIB_SYMBOL_MAP & GetSymbolMap() const
void SetFileName(const wxString &aFileName)
void SetModified(bool aModified=true)
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.
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;.
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:81
int GetFieldCount() const
Return the number of fields in this symbol.
Definition: sch_symbol.h:500
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:939
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
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
#define _(s)
ERCE_T
ERC error codes.
Definition: erc_settings.h:37
const std::string SpiceFileExtension
const std::string CadstarNetlistFileExtension
const std::string SVGFileExtension
const std::string CsvFileExtension
const std::string NetlistFileExtension
const std::string OrCadPcb2NetlistFileExtension
const std::string XmlFileExtension
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_INVALID_INPUT_FILE
Definition: exit_codes.h:33
static const int ERR_INVALID_OUTPUT_CONFLICT
Definition: exit_codes.h:34
static const int ERR_UNKNOWN
Definition: exit_codes.h:32
@ GNL_OPT_BOM
see class PGM_BASE
Plotting engines similar to ps (PostScript, Gerber, svg)
SEVERITY
@ RPT_SEVERITY_ERROR
#define SEXPR_SYMBOL_LIB_FILE_VERSION
This file contains the file format version information for the s-expression schematic and symbol libr...
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:115
const int scale
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:78
wxString stringDelimiter
Definition: bom_settings.h:79
wxString refRangeDelimiter
Definition: bom_settings.h:81
wxString refDelimiter
Definition: bom_settings.h:80
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 sortAsc
Definition: bom_settings.h:55
wxString filterString
Definition: bom_settings.h:56
constexpr int IUToMils(int iu) const
Definition: base_units.h:100
const double IU_PER_MILS
Definition: base_units.h:78
wxString m_theme
Definition: sch_plotter.h:88
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 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
VECTOR3I res
@ LIB_PIN_T
Definition: typeinfo.h:192
Definition of file extensions used in Kicad.