KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_io_kicad_sexpr.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) 2020 CERN
5 * Copyright (C) 2021-2024 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Wayne Stambaugh <[email protected]>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23#include <algorithm>
24
25// For some reason wxWidgets is built with wxUSE_BASE64 unset so expose the wxWidgets
26// base64 code.
27#define wxUSE_BASE64 1
28#include <wx/base64.h>
29#include <wx/log.h>
30#include <wx/mstream.h>
31#include <boost/algorithm/string/join.hpp>
32
33#include <advanced_config.h>
34#include <base_units.h>
35#include <bitmap_base.h>
36#include <build_version.h>
37#include <ee_selection.h>
38#include <font/fontconfig.h>
40#include <locale_io.h>
41#include <progress_reporter.h>
42#include <schematic.h>
43#include <schematic_lexer.h>
44#include <sch_bitmap.h>
45#include <sch_bus_entry.h>
46#include <sch_edit_frame.h> // SYMBOL_ORIENTATION_T
51#include <sch_junction.h>
52#include <sch_line.h>
53#include <sch_no_connect.h>
54#include <sch_pin.h>
55#include <sch_rule_area.h>
56#include <sch_screen.h>
57#include <sch_shape.h>
58#include <sch_sheet.h>
59#include <sch_sheet_pin.h>
60#include <sch_symbol.h>
61#include <sch_table.h>
62#include <sch_tablecell.h>
63#include <sch_text.h>
64#include <sch_textbox.h>
65#include <string_utils.h>
66#include <symbol_lib_table.h> // for PropPowerSymsOnly definition.
67#include <trace_helpers.h>
68#include <wx_filename.h> // for ::ResolvePossibleSymlinks()
69
70using namespace TSCHEMATIC_T;
71
72
73#define SCH_PARSE_ERROR( text, reader, pos ) \
74 THROW_PARSE_ERROR( text, reader.GetSource(), reader.Line(), \
75 reader.LineNumber(), pos - reader.Line() )
76
77
78SCH_IO_KICAD_SEXPR::SCH_IO_KICAD_SEXPR() : SCH_IO( wxS( "Eeschema s-expression" ) )
79{
80 init( nullptr );
81}
82
83
85{
86 delete m_cache;
87}
88
89
90void SCH_IO_KICAD_SEXPR::init( SCHEMATIC* aSchematic, const std::map<std::string, UTF8>* aProperties )
91{
92 m_version = 0;
93 m_appending = false;
94 m_rootSheet = nullptr;
95 m_schematic = aSchematic;
96 m_cache = nullptr;
97 m_out = nullptr;
98 m_nextFreeFieldId = 100; // number arbitrarily > MANDATORY_FIELDS or SHEET_MANDATORY_FIELDS
99}
100
101
102SCH_SHEET* SCH_IO_KICAD_SEXPR::LoadSchematicFile( const wxString& aFileName, SCHEMATIC* aSchematic,
103 SCH_SHEET* aAppendToMe,
104 const std::map<std::string, UTF8>* aProperties )
105{
106 wxASSERT( !aFileName || aSchematic != nullptr );
107
108 LOCALE_IO toggle; // toggles on, then off, the C locale.
109 SCH_SHEET* sheet;
110
111 wxFileName fn = aFileName;
112
113 // Show the font substitution warnings
115
116 // Unfortunately child sheet file names the legacy schematic file format are not fully
117 // qualified and are always appended to the project path. The aFileName attribute must
118 // always be an absolute path so the project path can be used for load child sheet files.
119 wxASSERT( fn.IsAbsolute() );
120
121 if( aAppendToMe )
122 {
123 m_appending = true;
124 wxLogTrace( traceSchPlugin, "Append \"%s\" to sheet \"%s\".",
125 aFileName, aAppendToMe->GetFileName() );
126
127 wxFileName normedFn = aAppendToMe->GetFileName();
128
129 if( !normedFn.IsAbsolute() )
130 {
131 if( aFileName.Right( normedFn.GetFullPath().Length() ) == normedFn.GetFullPath() )
132 m_path = aFileName.Left( aFileName.Length() - normedFn.GetFullPath().Length() );
133 }
134
135 if( m_path.IsEmpty() )
136 m_path = aSchematic->Prj().GetProjectPath();
137
138 wxLogTrace( traceSchPlugin, "Normalized append path \"%s\".", m_path );
139 }
140 else
141 {
142 m_path = aSchematic->Prj().GetProjectPath();
143 }
144
145 m_currentPath.push( m_path );
146 init( aSchematic, aProperties );
147
148 if( aAppendToMe == nullptr )
149 {
150 // Clean up any allocated memory if an exception occurs loading the schematic.
151 std::unique_ptr<SCH_SHEET> newSheet = std::make_unique<SCH_SHEET>( aSchematic );
152
153 wxFileName relPath( aFileName );
154
155 // Do not use wxPATH_UNIX as option in MakeRelativeTo(). It can create incorrect
156 // relative paths on Windows, because paths have a disk identifier (C:, D: ...)
157 relPath.MakeRelativeTo( aSchematic->Prj().GetProjectPath() );
158
159 newSheet->SetFileName( relPath.GetFullPath() );
160 m_rootSheet = newSheet.get();
161 loadHierarchy( SCH_SHEET_PATH(), newSheet.get() );
162
163 // If we got here, the schematic loaded successfully.
164 sheet = newSheet.release();
165 m_rootSheet = nullptr; // Quiet Coverity warning.
166 }
167 else
168 {
169 wxCHECK_MSG( aSchematic->IsValid(), nullptr, "Can't append to a schematic with no root!" );
170 m_rootSheet = &aSchematic->Root();
171 sheet = aAppendToMe;
172 loadHierarchy( SCH_SHEET_PATH(), sheet );
173 }
174
175 wxASSERT( m_currentPath.size() == 1 ); // only the project path should remain
176
177 m_currentPath.pop(); // Clear the path stack for next call to Load
178
179 return sheet;
180}
181
182
183// Everything below this comment is recursive. Modify with care.
184
185void SCH_IO_KICAD_SEXPR::loadHierarchy( const SCH_SHEET_PATH& aParentSheetPath, SCH_SHEET* aSheet )
186{
188
189 SCH_SCREEN* screen = nullptr;
190
191 if( !aSheet->GetScreen() )
192 {
193 // SCH_SCREEN objects store the full path and file name where the SCH_SHEET object only
194 // stores the file name and extension. Add the project path to the file name and
195 // extension to compare when calling SCH_SHEET::SearchHierarchy().
196 wxFileName fileName = aSheet->GetFileName();
197
198 if( !fileName.IsAbsolute() )
199 fileName.MakeAbsolute( m_currentPath.top() );
200
201 // Save the current path so that it gets restored when descending and ascending the
202 // sheet hierarchy which allows for sheet schematic files to be nested in folders
203 // relative to the last path a schematic was loaded from.
204 wxLogTrace( traceSchPlugin, "Saving path '%s'", m_currentPath.top() );
205 m_currentPath.push( fileName.GetPath() );
206 wxLogTrace( traceSchPlugin, "Current path '%s'", m_currentPath.top() );
207 wxLogTrace( traceSchPlugin, "Loading '%s'", fileName.GetFullPath() );
208
209 SCH_SHEET_PATH ancestorSheetPath = aParentSheetPath;
210
211 while( !ancestorSheetPath.empty() )
212 {
213 if( ancestorSheetPath.LastScreen()->GetFileName() == fileName.GetFullPath() )
214 {
215 if( !m_error.IsEmpty() )
216 m_error += "\n";
217
218 m_error += wxString::Format( _( "Could not load sheet '%s' because it already "
219 "appears as a direct ancestor in the schematic "
220 "hierarchy." ),
221 fileName.GetFullPath() );
222
223 fileName = wxEmptyString;
224
225 break;
226 }
227
228 ancestorSheetPath.pop_back();
229 }
230
231 if( ancestorSheetPath.empty() )
232 {
233 // Existing schematics could be either in the root sheet path or the current sheet
234 // load path so we have to check both.
235 if( !m_rootSheet->SearchHierarchy( fileName.GetFullPath(), &screen ) )
236 m_currentSheetPath.at( 0 )->SearchHierarchy( fileName.GetFullPath(), &screen );
237 }
238
239 if( screen )
240 {
241 aSheet->SetScreen( screen );
242 aSheet->GetScreen()->SetParent( m_schematic );
243 // Do not need to load the sub-sheets - this has already been done.
244 }
245 else
246 {
247 aSheet->SetScreen( new SCH_SCREEN( m_schematic ) );
248 aSheet->GetScreen()->SetFileName( fileName.GetFullPath() );
249
250 try
251 {
252 loadFile( fileName.GetFullPath(), aSheet );
253 }
254 catch( const IO_ERROR& ioe )
255 {
256 // If there is a problem loading the root sheet, there is no recovery.
257 if( aSheet == m_rootSheet )
258 throw;
259
260 // For all subsheets, queue up the error message for the caller.
261 if( !m_error.IsEmpty() )
262 m_error += "\n";
263
264 m_error += ioe.What();
265 }
266
267 if( fileName.FileExists() )
268 {
269 aSheet->GetScreen()->SetFileReadOnly( !fileName.IsFileWritable() );
270 aSheet->GetScreen()->SetFileExists( true );
271 }
272 else
273 {
274 aSheet->GetScreen()->SetFileReadOnly( !fileName.IsDirWritable() );
275 aSheet->GetScreen()->SetFileExists( false );
276 }
277
278 SCH_SHEET_PATH currentSheetPath = aParentSheetPath;
279 currentSheetPath.push_back( aSheet );
280
281 // This was moved out of the try{} block so that any sheet definitions that
282 // the plugin fully parsed before the exception was raised will be loaded.
283 for( SCH_ITEM* aItem : aSheet->GetScreen()->Items().OfType( SCH_SHEET_T ) )
284 {
285 wxCHECK2( aItem->Type() == SCH_SHEET_T, /* do nothing */ );
286 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( aItem );
287
288 // Recursion starts here.
289 loadHierarchy( currentSheetPath, sheet );
290 }
291 }
292
293 m_currentPath.pop();
294 wxLogTrace( traceSchPlugin, "Restoring path \"%s\"", m_currentPath.top() );
295 }
296
298}
299
300
301void SCH_IO_KICAD_SEXPR::loadFile( const wxString& aFileName, SCH_SHEET* aSheet )
302{
303 FILE_LINE_READER reader( aFileName );
304
305 size_t lineCount = 0;
306
308 {
309 m_progressReporter->Report( wxString::Format( _( "Loading %s..." ), aFileName ) );
310
312 THROW_IO_ERROR( _( "Open cancelled by user." ) );
313
314 while( reader.ReadLine() )
315 lineCount++;
316
317 reader.Rewind();
318 }
319
320 SCH_IO_KICAD_SEXPR_PARSER parser( &reader, m_progressReporter, lineCount, m_rootSheet,
321 m_appending );
322
323 parser.ParseSchematic( aSheet );
324}
325
326
327void SCH_IO_KICAD_SEXPR::LoadContent( LINE_READER& aReader, SCH_SHEET* aSheet, int aFileVersion )
328{
329 wxCHECK( aSheet, /* void */ );
330
331 LOCALE_IO toggle;
332 SCH_IO_KICAD_SEXPR_PARSER parser( &aReader );
333
334 parser.ParseSchematic( aSheet, true, aFileVersion );
335}
336
337
338void SCH_IO_KICAD_SEXPR::SaveSchematicFile( const wxString& aFileName, SCH_SHEET* aSheet,
339 SCHEMATIC* aSchematic,
340 const std::map<std::string, UTF8>* aProperties )
341{
342 wxCHECK_RET( aSheet != nullptr, "NULL SCH_SHEET object." );
343 wxCHECK_RET( !aFileName.IsEmpty(), "No schematic file name defined." );
344
345 LOCALE_IO toggle; // toggles on, then off, the C locale, to write floating point values.
346
347 init( aSchematic, aProperties );
348
349 wxFileName fn = aFileName;
350
351 // File names should be absolute. Don't assume everything relative to the project path
352 // works properly.
353 wxASSERT( fn.IsAbsolute() );
354
355 PRETTIFIED_FILE_OUTPUTFORMATTER formatter( fn.GetFullPath() );
356
357 m_out = &formatter; // no ownership
358
359 Format( aSheet );
360
361 if( aSheet->GetScreen() )
362 aSheet->GetScreen()->SetFileExists( true );
363}
364
365
367{
368 wxCHECK_RET( aSheet != nullptr, "NULL SCH_SHEET* object." );
369 wxCHECK_RET( m_schematic != nullptr, "NULL SCHEMATIC* object." );
370
372 SCH_SCREEN* screen = aSheet->GetScreen();
373
374 wxCHECK( screen, /* void */ );
375
376 // If we've requested to embed the fonts in the schematic, do so.
377 // Otherwise, clear the embedded fonts from the schematic. Embedded
378 // fonts will be used if available
381 else
383
384 m_out->Print( 0, "(kicad_sch (version %d) (generator \"eeschema\") (generator_version \"%s\")\n\n",
386
388
389 screen->GetPageSettings().Format( m_out, 1, 0 );
390 m_out->Print( 0, "\n" );
391 screen->GetTitleBlock().Format( m_out, 1, 0 );
392
393 // Save cache library.
394 m_out->Print( 1, "(lib_symbols\n" );
395
396 for( const auto& [ libItemName, libSymbol ] : screen->GetLibSymbols() )
397 SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol( libSymbol, *m_out, 2, libItemName );
398
399 m_out->Print( 1, ")\n\n" );
400
401 for( const std::shared_ptr<BUS_ALIAS>& alias : screen->GetBusAliases() )
402 saveBusAlias( alias, 1 );
403
404 // Enforce item ordering
405 auto cmp =
406 []( const SCH_ITEM* a, const SCH_ITEM* b )
407 {
408 if( a->Type() != b->Type() )
409 return a->Type() < b->Type();
410
411 return a->m_Uuid < b->m_Uuid;
412 };
413
414 std::multiset<SCH_ITEM*, decltype( cmp )> save_map( cmp );
415
416 for( SCH_ITEM* item : screen->Items() )
417 {
418 // Markers are not saved, so keep them from being considered below
419 if( item->Type() != SCH_MARKER_T )
420 save_map.insert( item );
421 }
422
423 KICAD_T itemType = TYPE_NOT_INIT;
425
426 for( SCH_ITEM* item : save_map )
427 {
428 if( itemType != item->Type() )
429 {
430 itemType = item->Type();
431
432 if( itemType != SCH_SYMBOL_T
433 && itemType != SCH_JUNCTION_T
434 && itemType != SCH_SHEET_T )
435 {
436 m_out->Print( 0, "\n" );
437 }
438 }
439
440 switch( item->Type() )
441 {
442 case SCH_SYMBOL_T:
443 m_out->Print( 0, "\n" );
444 saveSymbol( static_cast<SCH_SYMBOL*>( item ), *m_schematic, sheets, 1, false );
445 break;
446
447 case SCH_BITMAP_T:
448 saveBitmap( static_cast<SCH_BITMAP&>( *item ), 1 );
449 break;
450
451 case SCH_SHEET_T:
452 m_out->Print( 0, "\n" );
453 saveSheet( static_cast<SCH_SHEET*>( item ), sheets, 1 );
454 break;
455
456 case SCH_JUNCTION_T:
457 saveJunction( static_cast<SCH_JUNCTION*>( item ), 1 );
458 break;
459
460 case SCH_NO_CONNECT_T:
461 saveNoConnect( static_cast<SCH_NO_CONNECT*>( item ), 1 );
462 break;
463
466 saveBusEntry( static_cast<SCH_BUS_ENTRY_BASE*>( item ), 1 );
467 break;
468
469 case SCH_LINE_T:
470 if( layer != item->GetLayer() )
471 {
472 if( layer == SCH_LAYER_ID_START )
473 {
474 layer = item->GetLayer();
475 }
476 else
477 {
478 layer = item->GetLayer();
479 m_out->Print( 0, "\n" );
480 }
481 }
482
483 saveLine( static_cast<SCH_LINE*>( item ), 1 );
484 break;
485
486 case SCH_SHAPE_T:
487 saveShape( static_cast<SCH_SHAPE*>( item ), 1 );
488 break;
489
490 case SCH_RULE_AREA_T:
491 saveRuleArea( static_cast<SCH_RULE_AREA*>( item ), 1 );
492 break;
493
494 case SCH_TEXT_T:
495 case SCH_LABEL_T:
497 case SCH_HIER_LABEL_T:
499 saveText( static_cast<SCH_TEXT*>( item ), 1 );
500 break;
501
502 case SCH_TEXTBOX_T:
503 saveTextBox( static_cast<SCH_TEXTBOX*>( item ), 1 );
504 break;
505
506 case SCH_TABLE_T:
507 saveTable( static_cast<SCH_TABLE*>( item ), 1 );
508 break;
509
510 default:
511 wxASSERT( "Unexpected schematic object type in SCH_IO_KICAD_SEXPR::Format()" );
512 }
513 }
514
515 if( aSheet->HasRootInstance() )
516 {
517 std::vector< SCH_SHEET_INSTANCE> instances;
518
519 instances.emplace_back( aSheet->GetRootInstance() );
520 saveInstances( instances, 1 );
521
522 m_out->Print( 1, "(embedded_fonts %s)\n",
523 m_schematic->GetAreFontsEmbedded() ? "yes" : "no" );
524
525 // Save any embedded files
528 }
529
530 m_out->Print( 0, ")\n" );
531}
532
533
534void SCH_IO_KICAD_SEXPR::Format( EE_SELECTION* aSelection, SCH_SHEET_PATH* aSelectionPath,
535 SCHEMATIC& aSchematic, OUTPUTFORMATTER* aFormatter,
536 bool aForClipboard )
537{
538 wxCHECK( aSelection && aSelectionPath && aFormatter, /* void */ );
539
540 LOCALE_IO toggle;
541 SCH_SHEET_LIST sheets = aSchematic.Hierarchy();
542
543 m_schematic = &aSchematic;
544 m_out = aFormatter;
545
546 size_t i;
547 SCH_ITEM* item;
548 std::map<wxString, LIB_SYMBOL*> libSymbols;
549 SCH_SCREEN* screen = aSelection->GetScreen();
550 std::set<SCH_TABLE*> promotedTables;
551
552 for( i = 0; i < aSelection->GetSize(); ++i )
553 {
554 item = dynamic_cast<SCH_ITEM*>( aSelection->GetItem( i ) );
555
556 wxCHECK2( item, continue );
557
558 if( item->Type() != SCH_SYMBOL_T )
559 continue;
560
561 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item );
562
563 wxCHECK2( symbol, continue );
564
565 wxString libSymbolLookup = symbol->GetLibId().Format().wx_str();
566
567 if( !symbol->UseLibIdLookup() )
568 libSymbolLookup = symbol->GetSchSymbolLibraryName();
569
570 auto it = screen->GetLibSymbols().find( libSymbolLookup );
571
572 if( it != screen->GetLibSymbols().end() )
573 libSymbols[ libSymbolLookup ] = it->second;
574 }
575
576 if( !libSymbols.empty() )
577 {
578 m_out->Print( 0, "(lib_symbols\n" );
579
580 for( const std::pair<const wxString, LIB_SYMBOL*>& libSymbol : libSymbols )
581 {
582 SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol( libSymbol.second, *m_out, 1,
583 libSymbol.first, false );
584 }
585
586 m_out->Print( 0, ")\n\n" );
587 }
588
589 for( i = 0; i < aSelection->GetSize(); ++i )
590 {
591 item = (SCH_ITEM*) aSelection->GetItem( i );
592
593 switch( item->Type() )
594 {
595 case SCH_SYMBOL_T:
596 saveSymbol( static_cast<SCH_SYMBOL*>( item ), aSchematic, 0, aForClipboard,
597 aSelectionPath );
598 break;
599
600 case SCH_BITMAP_T:
601 saveBitmap( static_cast< SCH_BITMAP& >( *item ), 0 );
602 break;
603
604 case SCH_SHEET_T:
605 saveSheet( static_cast< SCH_SHEET* >( item ), sheets, 0 );
606 break;
607
608 case SCH_JUNCTION_T:
609 saveJunction( static_cast< SCH_JUNCTION* >( item ), 0 );
610 break;
611
612 case SCH_NO_CONNECT_T:
613 saveNoConnect( static_cast< SCH_NO_CONNECT* >( item ), 0 );
614 break;
615
618 saveBusEntry( static_cast< SCH_BUS_ENTRY_BASE* >( item ), 0 );
619 break;
620
621 case SCH_LINE_T:
622 saveLine( static_cast< SCH_LINE* >( item ), 0 );
623 break;
624
625 case SCH_SHAPE_T:
626 saveShape( static_cast<SCH_SHAPE*>( item ), 0 );
627 break;
628
629 case SCH_RULE_AREA_T:
630 saveRuleArea( static_cast<SCH_RULE_AREA*>( item ), 0 );
631 break;
632
633 case SCH_TEXT_T:
634 case SCH_LABEL_T:
636 case SCH_HIER_LABEL_T:
638 saveText( static_cast<SCH_TEXT*>( item ), 0 );
639 break;
640
641 case SCH_TEXTBOX_T:
642 saveTextBox( static_cast<SCH_TEXTBOX*>( item ), 0 );
643 break;
644
645 case SCH_TABLECELL_T:
646 {
647 SCH_TABLE* table = static_cast<SCH_TABLE*>( item->GetParent() );
648
649 if( promotedTables.count( table ) )
650 break;
651
652 table->SetFlags( SKIP_STRUCT );
653 saveTable( table, 0 );
654 table->ClearFlags( SKIP_STRUCT );
655 promotedTables.insert( table );
656 break;
657 }
658
659 case SCH_TABLE_T:
660 item->ClearFlags( SKIP_STRUCT );
661 saveTable( static_cast<SCH_TABLE*>( item ), 0 );
662 break;
663
664 default:
665 wxASSERT( "Unexpected schematic object type in SCH_IO_KICAD_SEXPR::Format()" );
666 }
667 }
668}
669
670
671void SCH_IO_KICAD_SEXPR::saveSymbol( SCH_SYMBOL* aSymbol, const SCHEMATIC& aSchematic,
672 const SCH_SHEET_LIST& aSheetList,
673 int aNestLevel, bool aForClipboard,
674 const SCH_SHEET_PATH* aRelativePath )
675{
676 wxCHECK_RET( aSymbol != nullptr && m_out != nullptr, "" );
677
678 std::string libName;
679
680 wxString symbol_name = aSymbol->GetLibId().Format();
681
682 if( symbol_name.size() )
683 {
684 libName = toUTFTildaText( symbol_name );
685 }
686 else
687 {
688 libName = "_NONAME_";
689 }
690
691 EDA_ANGLE angle;
692 int orientation = aSymbol->GetOrientation() & ~( SYM_MIRROR_X | SYM_MIRROR_Y );
693
694 if( orientation == SYM_ORIENT_90 )
695 angle = ANGLE_90;
696 else if( orientation == SYM_ORIENT_180 )
697 angle = ANGLE_180;
698 else if( orientation == SYM_ORIENT_270 )
699 angle = ANGLE_270;
700 else
701 angle = ANGLE_0;
702
703 m_out->Print( aNestLevel, "(symbol" );
704
705 if( !aSymbol->UseLibIdLookup() )
706 {
707 m_out->Print( 0, " (lib_name %s)",
708 m_out->Quotew( aSymbol->GetSchSymbolLibraryName() ).c_str() );
709 }
710
711 m_out->Print( 0, " (lib_id %s) (at %s %s %s)",
712 m_out->Quotew( aSymbol->GetLibId().Format().wx_str() ).c_str(),
714 aSymbol->GetPosition().x ).c_str(),
716 aSymbol->GetPosition().y ).c_str(),
717 EDA_UNIT_UTILS::FormatAngle( angle ).c_str() );
718
719 bool mirrorX = aSymbol->GetOrientation() & SYM_MIRROR_X;
720 bool mirrorY = aSymbol->GetOrientation() & SYM_MIRROR_Y;
721
722 if( mirrorX || mirrorY )
723 {
724 m_out->Print( 0, " (mirror" );
725
726 if( mirrorX )
727 m_out->Print( 0, " x" );
728
729 if( mirrorY )
730 m_out->Print( 0, " y" );
731
732 m_out->Print( 0, ")" );
733 }
734
735 // The symbol unit is always set to the first instance regardless of the current sheet
736 // instance to prevent file churn.
737 int unit = ( aSymbol->GetInstances().size() == 0 ) ? aSymbol->GetUnit()
738 : aSymbol->GetInstances()[0].m_Unit;
739
740 if( aForClipboard && aRelativePath )
741 {
742 SCH_SYMBOL_INSTANCE unitInstance;
743
744 if( aSymbol->GetInstance( unitInstance, aRelativePath->Path() ) )
745 unit = unitInstance.m_Unit;
746 }
747
748 m_out->Print( 0, " (unit %d)", unit );
749
750 if( aSymbol->GetBodyStyle() == BODY_STYLE::DEMORGAN )
751 m_out->Print( 0, " (convert %d)", aSymbol->GetBodyStyle() );
752
753 m_out->Print( 0, "\n" );
754
755 m_out->Print( aNestLevel + 1, "(exclude_from_sim %s)",
756 ( aSymbol->GetExcludedFromSim() ) ? "yes" : "no" );
757 m_out->Print( 0, " (in_bom %s)", ( aSymbol->GetExcludedFromBOM() ) ? "no" : "yes" );
758 m_out->Print( 0, " (on_board %s)", ( aSymbol->GetExcludedFromBoard() ) ? "no" : "yes" );
759 m_out->Print( 0, " (dnp %s)", ( aSymbol->GetDNP() ) ? "yes" : "no" );
760
761 if( aSymbol->GetFieldsAutoplaced() != FIELDS_AUTOPLACED_NO )
762 m_out->Print( 0, " (fields_autoplaced yes)" );
763
764 m_out->Print( 0, "\n" );
765
767
769
770 for( SCH_FIELD& field : aSymbol->GetFields() )
771 {
772 int id = field.GetId();
773 wxString value = field.GetText();
774
775 if( !aForClipboard && aSymbol->GetInstances().size() )
776 {
777 // The instance fields are always set to the default instance regardless of the
778 // sheet instance to prevent file churn.
779 if( id == REFERENCE_FIELD )
780 {
781 field.SetText( aSymbol->GetInstances()[0].m_Reference );
782 }
783 else if( id == VALUE_FIELD )
784 {
785 field.SetText( aSymbol->GetField( VALUE_FIELD )->GetText() );
786 }
787 else if( id == FOOTPRINT_FIELD )
788 {
789 field.SetText( aSymbol->GetField( FOOTPRINT_FIELD )->GetText() );
790 }
791 }
792 else if( aForClipboard && aSymbol->GetInstances().size() && aRelativePath
793 && ( id == REFERENCE_FIELD ) )
794 {
795 SCH_SYMBOL_INSTANCE instance;
796
797 if( aSymbol->GetInstance( instance, aRelativePath->Path() ) )
798 field.SetText( instance.m_Reference );
799 }
800
801 try
802 {
803 saveField( &field, aNestLevel + 1 );
804 }
805 catch( ... )
806 {
807 // Restore the changed field text on write error.
808 if( id == REFERENCE_FIELD || id == VALUE_FIELD || id == FOOTPRINT_FIELD )
809 field.SetText( value );
810
811 throw;
812 }
813
814 if( id == REFERENCE_FIELD || id == VALUE_FIELD || id == FOOTPRINT_FIELD )
815 field.SetText( value );
816 }
817
818 for( const std::unique_ptr<SCH_PIN>& pin : aSymbol->GetRawPins() )
819 {
820 if( pin->GetAlt().IsEmpty() )
821 {
822 m_out->Print( aNestLevel + 1, "(pin %s ", m_out->Quotew( pin->GetNumber() ).c_str() );
824 m_out->Print( aNestLevel + 1, ")\n" );
825 }
826 else
827 {
828 m_out->Print( aNestLevel + 1, "(pin %s ", m_out->Quotew( pin->GetNumber() ).c_str() );
830 m_out->Print( aNestLevel + 1, " (alternate %s))\n",
831 m_out->Quotew( pin->GetAlt() ).c_str() );
832 }
833 }
834
835 if( !aSymbol->GetInstances().empty() )
836 {
837 std::map<KIID, std::vector<SCH_SYMBOL_INSTANCE>> projectInstances;
838
839 m_out->Print( aNestLevel + 1, "(instances\n" );
840
841 wxString projectName;
842 KIID lastProjectUuid;
843 KIID rootSheetUuid = aSchematic.Root().m_Uuid;
844
845 for( const SCH_SYMBOL_INSTANCE& inst : aSymbol->GetInstances() )
846 {
847 // Zero length KIID_PATH objects are not valid and will cause a crash below.
848 wxCHECK2( inst.m_Path.size(), continue );
849
850 // If the instance data is part of this design but no longer has an associated sheet
851 // path, don't save it. This prevents large amounts of orphaned instance data for the
852 // current project from accumulating in the schematic files.
853 bool isOrphaned = ( inst.m_Path[0] == rootSheetUuid )
854 && !aSheetList.GetSheetPathByKIIDPath( inst.m_Path );
855
856 // Keep all instance data when copying to the clipboard. They may be needed on paste.
857 if( !aForClipboard && isOrphaned )
858 continue;
859
860 auto it = projectInstances.find( inst.m_Path[0] );
861
862 if( it == projectInstances.end() )
863 {
864 projectInstances[ inst.m_Path[0] ] = { inst };
865 }
866 else
867 {
868 it->second.emplace_back( inst );
869 }
870 }
871
872 for( auto& [uuid, instances] : projectInstances )
873 {
874 wxCHECK2( instances.size(), continue );
875
876 // Sort project instances by KIID_PATH.
877 std::sort( instances.begin(), instances.end(),
879 {
880 return aLhs.m_Path < aRhs.m_Path;
881 } );
882
883 projectName = instances[0].m_ProjectName;
884
885 m_out->Print( aNestLevel + 2, "(project %s\n",
886 m_out->Quotew( projectName ).c_str() );
887
888 for( const SCH_SYMBOL_INSTANCE& instance : instances )
889 {
890 wxString path;
891 KIID_PATH tmp = instance.m_Path;
892
893 if( aForClipboard && aRelativePath )
894 tmp.MakeRelativeTo( aRelativePath->Path() );
895
896 path = tmp.AsString();
897
898 m_out->Print( aNestLevel + 3, "(path %s\n",
899 m_out->Quotew( path ).c_str() );
900 m_out->Print( aNestLevel + 4, "(reference %s) (unit %d)\n",
901 m_out->Quotew( instance.m_Reference ).c_str(),
902 instance.m_Unit );
903 m_out->Print( aNestLevel + 3, ")\n" );
904 }
905
906 m_out->Print( aNestLevel + 2, ")\n" ); // Closes `project`.
907 }
908
909 m_out->Print( aNestLevel + 1, ")\n" ); // Closes `instances`.
910 }
911
912 m_out->Print( aNestLevel, ")\n" ); // Closes `symbol`.
913}
914
915
916void SCH_IO_KICAD_SEXPR::saveField( SCH_FIELD* aField, int aNestLevel )
917{
918 wxCHECK_RET( aField != nullptr && m_out != nullptr, "" );
919
920 wxString fieldName = aField->GetCanonicalName();
921 // For some reason (bug in legacy parser?) the field ID for non-mandatory fields is -1 so
922 // check for this in order to correctly use the field name.
923
924 if( aField->GetId() == -1 /* undefined ID */ )
925 {
926 // Replace the default name built by GetCanonicalName() by
927 // the field name if exists
928 if( !aField->GetName().IsEmpty() )
929 fieldName = aField->GetName();
930
931 aField->SetId( m_nextFreeFieldId );
933 }
934 else if( aField->GetId() >= m_nextFreeFieldId )
935 {
936 m_nextFreeFieldId = aField->GetId() + 1;
937 }
938
939 m_out->Print( aNestLevel, "(property %s %s (at %s %s %s)",
940 m_out->Quotew( fieldName ).c_str(),
941 m_out->Quotew( aField->GetText() ).c_str(),
943 aField->GetPosition().x ).c_str(),
945 aField->GetPosition().y ).c_str(),
946 EDA_UNIT_UTILS::FormatAngle( aField->GetTextAngle() ).c_str() );
947
948 if( aField->IsNameShown() )
949 m_out->Print( 0, " (show_name yes)" );
950
951 if( !aField->CanAutoplace() )
952 m_out->Print( 0, " (do_not_autoplace yes)" );
953
954 if( !aField->IsDefaultFormatting()
955 || ( aField->GetTextHeight() != schIUScale.MilsToIU( DEFAULT_SIZE_TEXT ) ) )
956 {
957 m_out->Print( 0, "\n" );
958 aField->Format( m_out, aNestLevel, 0 );
959 m_out->Print( aNestLevel, ")\n" ); // Closes property token with font effects.
960 }
961 else
962 {
963 m_out->Print( 0, ")\n" ); // Closes property token without font effects.
964 }
965}
966
967
968void SCH_IO_KICAD_SEXPR::saveBitmap( const SCH_BITMAP& aBitmap, int aNestLevel )
969{
970 wxCHECK_RET( m_out != nullptr, "" );
971
972 const REFERENCE_IMAGE& refImage = aBitmap.GetReferenceImage();
973 const BITMAP_BASE& bitmapBase = refImage.GetImage();
974
975 const wxImage* image = bitmapBase.GetImageData();
976
977 wxCHECK_RET( image != nullptr, "wxImage* is NULL" );
978
979 m_out->Print( aNestLevel, "(image (at %s %s)",
981 refImage.GetPosition().x ).c_str(),
983 refImage.GetPosition().y ).c_str() );
984
985 double scale = refImage.GetImageScale();
986
987 // 20230121 or older file format versions assumed 300 image PPI at load/save.
988 // Let's keep compatibility by changing image scale.
989 if( SEXPR_SCHEMATIC_FILE_VERSION <= 20230121 )
990 {
991 scale = scale * 300.0 / bitmapBase.GetPPI();
992 }
993
994 if( scale != 1.0 )
995 m_out->Print( 0, " (scale %g)", scale );
996
997 m_out->Print( 0, "\n" );
998
1000
1001 m_out->Print( aNestLevel + 1, "(data" );
1002
1003 wxString out = wxBase64Encode( bitmapBase.GetImageDataBuffer() );
1004
1005 // Apparently the MIME standard character width for base64 encoding is 76 (unconfirmed)
1006 // so use it in a vein attempt to be standard like.
1007#define MIME_BASE64_LENGTH 76
1008
1009 size_t first = 0;
1010
1011 while( first < out.Length() )
1012 {
1013 m_out->Print( 0, "\n" );
1014 m_out->Print( aNestLevel + 2, "\"%s\"", TO_UTF8( out( first, MIME_BASE64_LENGTH ) ) );
1015 first += MIME_BASE64_LENGTH;
1016 }
1017
1018 m_out->Print( 0, "\n" );
1019 m_out->Print( aNestLevel + 1, ")\n" ); // Closes data token.
1020 m_out->Print( aNestLevel, ")\n" ); // Closes image token.
1021}
1022
1023
1025 int aNestLevel )
1026{
1027 wxCHECK_RET( aSheet != nullptr && m_out != nullptr, "" );
1028
1029 m_out->Print( aNestLevel, "(sheet (at %s %s) (size %s %s)",
1031 aSheet->GetPosition().x ).c_str(),
1033 aSheet->GetPosition().y ).c_str(),
1035 aSheet->GetSize().x ).c_str(),
1037 aSheet->GetSize().y ).c_str() );
1038
1039 m_out->Print( 0, " (exclude_from_sim %s)", ( aSheet->GetExcludedFromSim() ) ? "yes" : "no" );
1040 m_out->Print( 0, " (in_bom %s)", ( aSheet->GetExcludedFromBOM() ) ? "no" : "yes" );
1041 m_out->Print( 0, " (on_board %s)", ( aSheet->GetExcludedFromBoard() ) ? "no" : "yes" );
1042 m_out->Print( 0, " (dnp %s)", ( aSheet->GetDNP() ) ? "yes" : "no" );
1043
1044 if( aSheet->GetFieldsAutoplaced() != FIELDS_AUTOPLACED_NO )
1045 m_out->Print( 0, " (fields_autoplaced yes)" );
1046
1047 m_out->Print( 0, "\n" );
1048
1049 STROKE_PARAMS stroke( aSheet->GetBorderWidth(), LINE_STYLE::SOLID, aSheet->GetBorderColor() );
1050
1051 stroke.SetWidth( aSheet->GetBorderWidth() );
1052 stroke.Format( m_out, schIUScale, aNestLevel + 1 );
1053
1054 m_out->Print( 0, "\n" );
1055
1056 m_out->Print( aNestLevel + 1, "(fill (color %d %d %d %0.4f))\n",
1057 KiROUND( aSheet->GetBackgroundColor().r * 255.0 ),
1058 KiROUND( aSheet->GetBackgroundColor().g * 255.0 ),
1059 KiROUND( aSheet->GetBackgroundColor().b * 255.0 ),
1060 aSheet->GetBackgroundColor().a );
1061
1063
1065
1066 for( SCH_FIELD& field : aSheet->GetFields() )
1067 {
1068 saveField( &field, aNestLevel + 1 );
1069 }
1070
1071 for( const SCH_SHEET_PIN* pin : aSheet->GetPins() )
1072 {
1073 m_out->Print( aNestLevel + 1, "(pin %s %s (at %s %s %s)\n",
1074 EscapedUTF8( pin->GetText() ).c_str(),
1075 getSheetPinShapeToken( pin->GetShape() ),
1077 pin->GetPosition().x ).c_str(),
1079 pin->GetPosition().y ).c_str(),
1080 EDA_UNIT_UTILS::FormatAngle( getSheetPinAngle( pin->GetSide() ) ).c_str() );
1081
1082 pin->Format( m_out, aNestLevel + 1, 0 );
1083
1085
1086 m_out->Print( aNestLevel + 1, ")\n" ); // Closes pin token.
1087 }
1088
1089 // Save all sheet instances here except the root sheet instance.
1090 std::vector< SCH_SHEET_INSTANCE > sheetInstances = aSheet->GetInstances();
1091
1092 auto it = sheetInstances.begin();
1093
1094 while( it != sheetInstances.end() )
1095 {
1096 if( it->m_Path.size() == 0 )
1097 it = sheetInstances.erase( it );
1098 else
1099 it++;
1100 }
1101
1102 if( !sheetInstances.empty() )
1103 {
1104 m_out->Print( aNestLevel + 1, "(instances\n" );
1105
1106 KIID lastProjectUuid;
1107 KIID rootSheetUuid = m_schematic->Root().m_Uuid;
1108 bool project_open = false;
1109
1110 for( size_t i = 0; i < sheetInstances.size(); i++ )
1111 {
1112 // If the instance data is part of this design but no longer has an associated sheet
1113 // path, don't save it. This prevents large amounts of orphaned instance data for the
1114 // current project from accumulating in the schematic files.
1115 //
1116 // Keep all instance data when copying to the clipboard. It may be needed on paste.
1117 if( ( sheetInstances[i].m_Path[0] == rootSheetUuid )
1118 && !aSheetList.GetSheetPathByKIIDPath( sheetInstances[i].m_Path, false ) )
1119 {
1120 if( project_open && ( ( i + 1 == sheetInstances.size() )
1121 || lastProjectUuid != sheetInstances[i+1].m_Path[0] ) )
1122 {
1123 m_out->Print( aNestLevel + 2, ")\n" ); // Closes `project` token.
1124 project_open = false;
1125 }
1126
1127 continue;
1128 }
1129
1130 if( lastProjectUuid != sheetInstances[i].m_Path[0] )
1131 {
1132 wxString projectName;
1133
1134 if( sheetInstances[i].m_Path[0] == rootSheetUuid )
1135 projectName = m_schematic->Prj().GetProjectName();
1136 else
1137 projectName = sheetInstances[i].m_ProjectName;
1138
1139 lastProjectUuid = sheetInstances[i].m_Path[0];
1140 m_out->Print( aNestLevel + 2, "(project %s\n",
1141 m_out->Quotew( projectName ).c_str() );
1142 project_open = true;
1143 }
1144
1145 wxString path = sheetInstances[i].m_Path.AsString();
1146
1147 m_out->Print( aNestLevel + 3, "(path %s (page %s))\n",
1148 m_out->Quotew( path ).c_str(),
1149 m_out->Quotew( sheetInstances[i].m_PageNumber ).c_str() );
1150
1151 if( project_open && ( ( i + 1 == sheetInstances.size() )
1152 || lastProjectUuid != sheetInstances[i+1].m_Path[0] ) )
1153 {
1154 m_out->Print( aNestLevel + 2, ")\n" ); // Closes `project` token.
1155 project_open = false;
1156 }
1157 }
1158
1159 m_out->Print( aNestLevel + 1, ")\n" ); // Closes `instances` token.
1160 }
1161
1162 m_out->Print( aNestLevel, ")\n" ); // Closes sheet token.
1163}
1164
1165
1166void SCH_IO_KICAD_SEXPR::saveJunction( SCH_JUNCTION* aJunction, int aNestLevel )
1167{
1168 wxCHECK_RET( aJunction != nullptr && m_out != nullptr, "" );
1169
1170 m_out->Print( aNestLevel, "(junction (at %s %s) (diameter %s) (color %d %d %d %s)\n",
1172 aJunction->GetPosition().x ).c_str(),
1174 aJunction->GetPosition().y ).c_str(),
1176 aJunction->GetDiameter() ).c_str(),
1177 KiROUND( aJunction->GetColor().r * 255.0 ),
1178 KiROUND( aJunction->GetColor().g * 255.0 ),
1179 KiROUND( aJunction->GetColor().b * 255.0 ),
1180 FormatDouble2Str( aJunction->GetColor().a ).c_str() );
1181
1182 KICAD_FORMAT::FormatUuid( m_out, aJunction->m_Uuid );
1183
1184 m_out->Print( aNestLevel, ")\n" );
1185}
1186
1187
1188void SCH_IO_KICAD_SEXPR::saveNoConnect( SCH_NO_CONNECT* aNoConnect, int aNestLevel )
1189{
1190 wxCHECK_RET( aNoConnect != nullptr && m_out != nullptr, "" );
1191
1192 m_out->Print( aNestLevel, "(no_connect (at %s %s)",
1194 aNoConnect->GetPosition().x ).c_str(),
1196 aNoConnect->GetPosition().y ).c_str() );
1197 KICAD_FORMAT::FormatUuid( m_out, aNoConnect->m_Uuid );
1198 m_out->Print( aNestLevel, ")\n" );
1199}
1200
1201
1203{
1204 wxCHECK_RET( aBusEntry != nullptr && m_out != nullptr, "" );
1205
1206 // Bus to bus entries are converted to bus line segments.
1207 if( aBusEntry->GetClass() == "SCH_BUS_BUS_ENTRY" )
1208 {
1209 SCH_LINE busEntryLine( aBusEntry->GetPosition(), LAYER_BUS );
1210
1211 busEntryLine.SetEndPoint( aBusEntry->GetEnd() );
1212 saveLine( &busEntryLine, aNestLevel );
1213 }
1214 else
1215 {
1216 m_out->Print( aNestLevel, "(bus_entry (at %s %s) (size %s %s)\n",
1218 aBusEntry->GetPosition().x ).c_str(),
1220 aBusEntry->GetPosition().y ).c_str(),
1222 aBusEntry->GetSize().x ).c_str(),
1224 aBusEntry->GetSize().y ).c_str() );
1225
1226 aBusEntry->GetStroke().Format( m_out, schIUScale, aNestLevel + 1 );
1227
1228 m_out->Print( 0, "\n" );
1229
1230 KICAD_FORMAT::FormatUuid( m_out, aBusEntry->m_Uuid );
1231
1232 m_out->Print( aNestLevel, ")\n" );
1233 }
1234}
1235
1236
1237void SCH_IO_KICAD_SEXPR::saveShape( SCH_SHAPE* aShape, int aNestLevel )
1238{
1239 wxCHECK_RET( aShape != nullptr && m_out != nullptr, "" );
1240
1241 switch( aShape->GetShape() )
1242 {
1243 case SHAPE_T::ARC:
1244 formatArc( m_out, aNestLevel, aShape, false, aShape->GetStroke(), aShape->GetFillMode(),
1245 aShape->GetFillColor(), false, aShape->m_Uuid );
1246 break;
1247
1248 case SHAPE_T::CIRCLE:
1249 formatCircle( m_out, aNestLevel, aShape, false, aShape->GetStroke(), aShape->GetFillMode(),
1250 aShape->GetFillColor(), false, aShape->m_Uuid );
1251 break;
1252
1253 case SHAPE_T::RECTANGLE:
1254 formatRect( m_out, aNestLevel, aShape, false, aShape->GetStroke(), aShape->GetFillMode(),
1255 aShape->GetFillColor(), false, aShape->m_Uuid );
1256 break;
1257
1258 case SHAPE_T::BEZIER:
1259 formatBezier( m_out, aNestLevel, aShape, false, aShape->GetStroke(), aShape->GetFillMode(),
1260 aShape->GetFillColor(), false, aShape->m_Uuid );
1261 break;
1262
1263 case SHAPE_T::POLY:
1264 formatPoly( m_out, aNestLevel, aShape, false, aShape->GetStroke(), aShape->GetFillMode(),
1265 aShape->GetFillColor(), false, aShape->m_Uuid );
1266 break;
1267
1268 default:
1270 }
1271}
1272
1273
1274void SCH_IO_KICAD_SEXPR::saveRuleArea( SCH_RULE_AREA* aRuleArea, int aNestLevel )
1275{
1276 wxCHECK_RET( aRuleArea != nullptr && m_out != nullptr, "" );
1277
1278 m_out->Print( aNestLevel, "(rule_area " );
1279 saveShape( aRuleArea, aNestLevel + 1 );
1280 m_out->Print( aNestLevel, ")\n" );
1281}
1282
1283
1284void SCH_IO_KICAD_SEXPR::saveLine( SCH_LINE* aLine, int aNestLevel )
1285{
1286 wxCHECK_RET( aLine != nullptr && m_out != nullptr, "" );
1287
1288 wxString lineType;
1289
1290 STROKE_PARAMS line_stroke = aLine->GetStroke();
1291
1292 switch( aLine->GetLayer() )
1293 {
1294 case LAYER_BUS: lineType = "bus"; break;
1295 case LAYER_WIRE: lineType = "wire"; break;
1296 case LAYER_NOTES: lineType = "polyline"; break;
1297 default:
1298 UNIMPLEMENTED_FOR( LayerName( aLine->GetLayer() ) );
1299 }
1300
1301 m_out->Print( aNestLevel, "(%s (pts (xy %s %s) (xy %s %s))\n",
1302 TO_UTF8( lineType ),
1304 aLine->GetStartPoint().x ).c_str(),
1306 aLine->GetStartPoint().y ).c_str(),
1308 aLine->GetEndPoint().x ).c_str(),
1310 aLine->GetEndPoint().y ).c_str() );
1311
1312 line_stroke.Format( m_out, schIUScale, aNestLevel + 1 );
1313 m_out->Print( 0, "\n" );
1314
1316
1317 m_out->Print( aNestLevel, ")\n" );
1318}
1319
1320
1321void SCH_IO_KICAD_SEXPR::saveText( SCH_TEXT* aText, int aNestLevel )
1322{
1323 wxCHECK_RET( aText != nullptr && m_out != nullptr, "" );
1324
1325 // Note: label is nullptr SCH_TEXT, but not for SCH_LABEL_XXX,
1326 SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( aText );
1327
1328 m_out->Print( aNestLevel, "(%s %s",
1329 getTextTypeToken( aText->Type() ),
1330 m_out->Quotew( aText->GetText() ).c_str() );
1331
1332 if( aText->Type() == SCH_TEXT_T )
1333 {
1334 m_out->Print( 0, " (exclude_from_sim %s)\n", aText->GetExcludedFromSim() ? "yes" : "no" );
1335 }
1336 else if( aText->Type() == SCH_DIRECTIVE_LABEL_T )
1337 {
1338 SCH_DIRECTIVE_LABEL* flag = static_cast<SCH_DIRECTIVE_LABEL*>( aText );
1339
1340 m_out->Print( 0, " (length %s)",
1342 flag->GetPinLength() ).c_str() );
1343 }
1344
1345 EDA_ANGLE angle = aText->GetTextAngle();
1346
1347 if( label )
1348 {
1349 if( label->Type() == SCH_GLOBAL_LABEL_T
1350 || label->Type() == SCH_HIER_LABEL_T
1351 || label->Type() == SCH_DIRECTIVE_LABEL_T )
1352 {
1353 m_out->Print( 0, " (shape %s)", getSheetPinShapeToken( label->GetShape() ) );
1354 }
1355
1356 // The angle of the text is always 0 or 90 degrees for readibility reasons,
1357 // but the item itself can have more rotation (-90 and 180 deg)
1358 switch( label->GetSpinStyle() )
1359 {
1360 default:
1361 case SPIN_STYLE::LEFT: angle += ANGLE_180; break;
1362 case SPIN_STYLE::UP: break;
1363 case SPIN_STYLE::RIGHT: break;
1364 case SPIN_STYLE::BOTTOM: angle += ANGLE_180; break;
1365 }
1366 }
1367
1368 if( aText->GetText().Length() < 50 )
1369 {
1370 m_out->Print( 0, " (at %s %s %s)",
1372 aText->GetPosition().x ).c_str(),
1374 aText->GetPosition().y ).c_str(),
1375 EDA_UNIT_UTILS::FormatAngle( angle ).c_str() );
1376 }
1377 else
1378 {
1379 m_out->Print( 0, "\n" );
1380 m_out->Print( aNestLevel + 1, "(at %s %s %s)",
1382 aText->GetPosition().x ).c_str(),
1384 aText->GetPosition().y ).c_str(),
1385 EDA_UNIT_UTILS::FormatAngle( angle ).c_str() );
1386 }
1387
1389 m_out->Print( 0, " (fields_autoplaced yes)" );
1390
1391 m_out->Print( 0, "\n" );
1392 aText->EDA_TEXT::Format( m_out, aNestLevel, 0 );
1393
1395
1396 if( label )
1397 {
1398 for( SCH_FIELD& field : label->GetFields() )
1399 saveField( &field, aNestLevel + 1 );
1400 }
1401
1402 m_out->Print( aNestLevel, ")\n" ); // Closes text token.
1403}
1404
1405
1406void SCH_IO_KICAD_SEXPR::saveTextBox( SCH_TEXTBOX* aTextBox, int aNestLevel )
1407{
1408 wxCHECK_RET( aTextBox != nullptr && m_out != nullptr, "" );
1409
1410 m_out->Print( aNestLevel, "(%s %s\n",
1411 aTextBox->Type() == SCH_TABLECELL_T ? "table_cell" : "text_box",
1412 m_out->Quotew( aTextBox->GetText() ).c_str() );
1413
1414 VECTOR2I pos = aTextBox->GetStart();
1415 VECTOR2I size = aTextBox->GetEnd() - pos;
1416
1417 m_out->Print( aNestLevel + 1, "(exclude_from_sim %s) (at %s %s %s) (size %s %s) (margins %s %s %s %s)",
1418 aTextBox->GetExcludedFromSim() ? "yes" : "no",
1421 EDA_UNIT_UTILS::FormatAngle( aTextBox->GetTextAngle() ).c_str(),
1428
1429 if( SCH_TABLECELL* cell = dynamic_cast<SCH_TABLECELL*>( aTextBox ) )
1430 m_out->Print( 0, " (span %d %d)", cell->GetColSpan(), cell->GetRowSpan() );
1431
1432 m_out->Print( 0, "\n" );
1433
1434 if( aTextBox->Type() != SCH_TABLECELL_T )
1435 {
1436 aTextBox->GetStroke().Format( m_out, schIUScale, aNestLevel + 1 );
1437 m_out->Print( 0, "\n" );
1438 }
1439
1440 formatFill( m_out, aNestLevel + 1, aTextBox->GetFillMode(), aTextBox->GetFillColor() );
1441 m_out->Print( 0, "\n" );
1442
1443 aTextBox->EDA_TEXT::Format( m_out, aNestLevel, 0 );
1444
1445 if( aTextBox->m_Uuid != niluuid )
1447
1448 m_out->Print( aNestLevel, ")\n" );
1449}
1450
1451
1452void SCH_IO_KICAD_SEXPR::saveTable( SCH_TABLE* aTable, int aNestLevel )
1453{
1454 if( aTable->GetFlags() & SKIP_STRUCT )
1455 {
1456 aTable = static_cast<SCH_TABLE*>( aTable->Clone() );
1457
1458 int minCol = aTable->GetColCount();
1459 int maxCol = -1;
1460 int minRow = aTable->GetRowCount();
1461 int maxRow = -1;
1462
1463 for( int row = 0; row < aTable->GetRowCount(); ++row )
1464 {
1465 for( int col = 0; col < aTable->GetColCount(); ++col )
1466 {
1467 SCH_TABLECELL* cell = aTable->GetCell( row, col );
1468
1469 if( cell->IsSelected() )
1470 {
1471 minRow = std::min( minRow, row );
1472 maxRow = std::max( maxRow, row );
1473 minCol = std::min( minCol, col );
1474 maxCol = std::max( maxCol, col );
1475 }
1476 else
1477 {
1478 cell->SetFlags( STRUCT_DELETED );
1479 }
1480 }
1481 }
1482
1483 wxCHECK_MSG( maxCol >= minCol && maxRow >= minRow, /*void*/, wxT( "No selected cells!" ) );
1484
1485 int destRow = 0;
1486
1487 for( int row = minRow; row <= maxRow; row++ )
1488 aTable->SetRowHeight( destRow++, aTable->GetRowHeight( row ) );
1489
1490 int destCol = 0;
1491
1492 for( int col = minCol; col <= maxCol; col++ )
1493 aTable->SetColWidth( destCol++, aTable->GetColWidth( col ) );
1494
1495 aTable->DeleteMarkedCells();
1496 aTable->SetColCount( ( maxCol - minCol ) + 1 );
1497 }
1498
1499 wxCHECK_RET( aTable != nullptr && m_out != nullptr, "" );
1500
1501 m_out->Print( aNestLevel, "(table (column_count %d)\n",
1502 aTable->GetColCount() );
1503
1504 m_out->Print( aNestLevel + 1, "(border (external %s) (header %s)",
1505 aTable->StrokeExternal() ? "yes" : "no",
1506 aTable->StrokeHeader() ? "yes" : "no" );
1507
1508 if( aTable->StrokeExternal() || aTable->StrokeHeader() )
1509 {
1510 m_out->Print( 0, " " );
1511 aTable->GetBorderStroke().Format( m_out, schIUScale, 0 );
1512 }
1513
1514 m_out->Print( 0, ")\n" );
1515
1516 m_out->Print( aNestLevel + 1, "(separators (rows %s) (cols %s)",
1517 aTable->StrokeRows() ? "yes" : "no",
1518 aTable->StrokeColumns() ? "yes" : "no" );
1519
1520 if( aTable->StrokeRows() || aTable->StrokeColumns() )
1521 {
1522 m_out->Print( 0, " " );
1523 aTable->GetSeparatorsStroke().Format( m_out, schIUScale, 0 );
1524 }
1525
1526 m_out->Print( 0, ")\n" ); // Close `separators` token.
1527
1528 m_out->Print( aNestLevel + 1, "(column_widths" );
1529
1530 for( int col = 0; col < aTable->GetColCount(); ++col )
1531 {
1532 m_out->Print( 0, " %s",
1534 aTable->GetColWidth( col ) ).c_str() );
1535 }
1536
1537 m_out->Print( 0, ")\n" );
1538
1539 m_out->Print( aNestLevel + 1, "(row_heights" );
1540
1541 for( int row = 0; row < aTable->GetRowCount(); ++row )
1542 {
1543 m_out->Print( 0, " %s",
1545 aTable->GetRowHeight( row ) ).c_str() );
1546 }
1547
1548 m_out->Print( 0, ")\n" );
1549
1550 m_out->Print( aNestLevel + 1, "(cells\n" );
1551
1552 for( SCH_TABLECELL* cell : aTable->GetCells() )
1553 saveTextBox( cell, aNestLevel + 2 );
1554
1555 m_out->Print( aNestLevel + 1, ")\n" ); // Close `cells` token.
1556 m_out->Print( aNestLevel, ")\n" ); // Close `table` token.
1557
1558 if( aTable->GetFlags() & SKIP_STRUCT )
1559 delete aTable;
1560}
1561
1562
1563void SCH_IO_KICAD_SEXPR::saveBusAlias( std::shared_ptr<BUS_ALIAS> aAlias, int aNestLevel )
1564{
1565 wxCHECK_RET( aAlias != nullptr, "BUS_ALIAS* is NULL" );
1566
1567 wxString members;
1568
1569 for( const wxString& member : aAlias->Members() )
1570 {
1571 if( !members.IsEmpty() )
1572 members += wxS( " " );
1573
1574 members += m_out->Quotew( member );
1575 }
1576
1577 m_out->Print( aNestLevel, "(bus_alias %s (members %s))\n",
1578 m_out->Quotew( aAlias->GetName() ).c_str(),
1579 TO_UTF8( members ) );
1580}
1581
1582
1583void SCH_IO_KICAD_SEXPR::saveInstances( const std::vector<SCH_SHEET_INSTANCE>& aInstances,
1584 int aNestLevel )
1585{
1586 if( aInstances.size() )
1587 {
1588 m_out->Print( 0, "\n" );
1589 m_out->Print( aNestLevel, "(sheet_instances\n" );
1590
1591 for( const SCH_SHEET_INSTANCE& instance : aInstances )
1592 {
1593 wxString path = instance.m_Path.AsString();
1594
1595 if( path.IsEmpty() )
1596 path = wxT( "/" ); // Root path
1597
1598 m_out->Print( aNestLevel + 1, "(path %s (page %s))\n",
1599 m_out->Quotew( path ).c_str(),
1600 m_out->Quotew( instance.m_PageNumber ).c_str() );
1601 }
1602
1603 m_out->Print( aNestLevel, ")\n" ); // Close sheet instances token.
1604 }
1605}
1606
1607
1608void SCH_IO_KICAD_SEXPR::cacheLib( const wxString& aLibraryFileName,
1609 const std::map<std::string, UTF8>* aProperties )
1610{
1611 // Suppress font substitution warnings
1613
1614 if( !m_cache || !m_cache->IsFile( aLibraryFileName ) || m_cache->IsFileChanged() )
1615 {
1616 // a spectacular episode in memory management:
1617 delete m_cache;
1618 m_cache = new SCH_IO_KICAD_SEXPR_LIB_CACHE( aLibraryFileName );
1619
1620 if( !isBuffering( aProperties ) )
1621 m_cache->Load();
1622 }
1623}
1624
1625
1626bool SCH_IO_KICAD_SEXPR::isBuffering( const std::map<std::string, UTF8>* aProperties )
1627{
1628 return ( aProperties && aProperties->contains( SCH_IO_KICAD_SEXPR::PropBuffering ) );
1629}
1630
1631
1633{
1634 if( m_cache )
1635 return m_cache->GetModifyHash();
1636
1637 // If the cache hasn't been loaded, it hasn't been modified.
1638 return 0;
1639}
1640
1641
1642void SCH_IO_KICAD_SEXPR::EnumerateSymbolLib( wxArrayString& aSymbolNameList,
1643 const wxString& aLibraryPath,
1644 const std::map<std::string, UTF8>* aProperties )
1645{
1646 LOCALE_IO toggle; // toggles on, then off, the C locale.
1647
1648 bool powerSymbolsOnly = ( aProperties &&
1649 aProperties->find( SYMBOL_LIB_TABLE::PropPowerSymsOnly ) != aProperties->end() );
1650
1651 cacheLib( aLibraryPath, aProperties );
1652
1653 const LIB_SYMBOL_MAP& symbols = m_cache->m_symbols;
1654
1655 for( LIB_SYMBOL_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it )
1656 {
1657 if( !powerSymbolsOnly || it->second->IsPower() )
1658 aSymbolNameList.Add( it->first );
1659 }
1660}
1661
1662
1663void SCH_IO_KICAD_SEXPR::EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& aSymbolList,
1664 const wxString& aLibraryPath,
1665 const std::map<std::string, UTF8>* aProperties )
1666{
1667 LOCALE_IO toggle; // toggles on, then off, the C locale.
1668
1669 bool powerSymbolsOnly = ( aProperties &&
1670 aProperties->find( SYMBOL_LIB_TABLE::PropPowerSymsOnly ) != aProperties->end() );
1671
1672 cacheLib( aLibraryPath, aProperties );
1673
1674 const LIB_SYMBOL_MAP& symbols = m_cache->m_symbols;
1675
1676 for( LIB_SYMBOL_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it )
1677 {
1678 if( !powerSymbolsOnly || it->second->IsPower() )
1679 aSymbolList.push_back( it->second );
1680 }
1681}
1682
1683
1684LIB_SYMBOL* SCH_IO_KICAD_SEXPR::LoadSymbol( const wxString& aLibraryPath,
1685 const wxString& aSymbolName,
1686 const std::map<std::string, UTF8>* aProperties )
1687{
1688 LOCALE_IO toggle; // toggles on, then off, the C locale.
1689
1690 cacheLib( aLibraryPath, aProperties );
1691
1692 LIB_SYMBOL_MAP::const_iterator it = m_cache->m_symbols.find( aSymbolName );
1693
1694 // We no longer escape '/' in symbol names, but we used to.
1695 if( it == m_cache->m_symbols.end() && aSymbolName.Contains( '/' ) )
1696 it = m_cache->m_symbols.find( EscapeString( aSymbolName, CTX_LEGACY_LIBID ) );
1697
1698 if( it == m_cache->m_symbols.end() && aSymbolName.Contains( wxT( "{slash}" ) ) )
1699 {
1700 wxString unescaped = aSymbolName;
1701 unescaped.Replace( wxT( "{slash}" ), wxT( "/" ) );
1702 it = m_cache->m_symbols.find( unescaped );
1703 }
1704
1705 if( it == m_cache->m_symbols.end() )
1706 return nullptr;
1707
1708 return it->second;
1709}
1710
1711
1712void SCH_IO_KICAD_SEXPR::SaveSymbol( const wxString& aLibraryPath, const LIB_SYMBOL* aSymbol,
1713 const std::map<std::string, UTF8>* aProperties )
1714{
1715 LOCALE_IO toggle; // toggles on, then off, the C locale.
1716
1717 cacheLib( aLibraryPath, aProperties );
1718
1719 m_cache->AddSymbol( aSymbol );
1720
1721 if( !isBuffering( aProperties ) )
1722 m_cache->Save();
1723}
1724
1725
1726void SCH_IO_KICAD_SEXPR::DeleteSymbol( const wxString& aLibraryPath, const wxString& aSymbolName,
1727 const std::map<std::string, UTF8>* aProperties )
1728{
1729 LOCALE_IO toggle; // toggles on, then off, the C locale.
1730
1731 cacheLib( aLibraryPath, aProperties );
1732
1733 m_cache->DeleteSymbol( aSymbolName );
1734
1735 if( !isBuffering( aProperties ) )
1736 m_cache->Save();
1737}
1738
1739
1740void SCH_IO_KICAD_SEXPR::CreateLibrary( const wxString& aLibraryPath,
1741 const std::map<std::string, UTF8>* aProperties )
1742{
1743 if( wxFileExists( aLibraryPath ) )
1744 {
1745 THROW_IO_ERROR( wxString::Format( _( "Symbol library '%s' already exists." ),
1746 aLibraryPath.GetData() ) );
1747 }
1748
1749 LOCALE_IO toggle;
1750
1751 delete m_cache;
1752 m_cache = new SCH_IO_KICAD_SEXPR_LIB_CACHE( aLibraryPath );
1754 m_cache->Save();
1755 m_cache->Load(); // update m_writable and m_mod_time
1756}
1757
1758
1759bool SCH_IO_KICAD_SEXPR::DeleteLibrary( const wxString& aLibraryPath,
1760 const std::map<std::string, UTF8>* aProperties )
1761{
1762 wxFileName fn = aLibraryPath;
1763
1764 if( !fn.FileExists() )
1765 return false;
1766
1767 // Some of the more elaborate wxRemoveFile() crap puts up its own wxLog dialog
1768 // we don't want that. we want bare metal portability with no UI here.
1769 if( wxRemove( aLibraryPath ) )
1770 {
1771 THROW_IO_ERROR( wxString::Format( _( "Symbol library '%s' cannot be deleted." ),
1772 aLibraryPath.GetData() ) );
1773 }
1774
1775 if( m_cache && m_cache->IsFile( aLibraryPath ) )
1776 {
1777 delete m_cache;
1778 m_cache = nullptr;
1779 }
1780
1781 return true;
1782}
1783
1784
1785void SCH_IO_KICAD_SEXPR::SaveLibrary( const wxString& aLibraryPath,
1786 const std::map<std::string, UTF8>* aProperties )
1787{
1788 if( !m_cache )
1789 m_cache = new SCH_IO_KICAD_SEXPR_LIB_CACHE( aLibraryPath );
1790
1791 wxString oldFileName = m_cache->GetFileName();
1792
1793 if( !m_cache->IsFile( aLibraryPath ) )
1794 {
1795 m_cache->SetFileName( aLibraryPath );
1796 }
1797
1798 // This is a forced save.
1800 m_cache->Save();
1801 m_cache->SetFileName( oldFileName );
1802}
1803
1804
1805bool SCH_IO_KICAD_SEXPR::IsLibraryWritable( const wxString& aLibraryPath )
1806{
1807 wxFileName fn( aLibraryPath );
1808
1809 if( fn.FileExists() )
1810 return fn.IsFileWritable();
1811
1812 return fn.IsDirWritable();
1813}
1814
1815
1816void SCH_IO_KICAD_SEXPR::GetAvailableSymbolFields( std::vector<wxString>& aNames )
1817{
1818 if( !m_cache )
1819 return;
1820
1821 const LIB_SYMBOL_MAP& symbols = m_cache->m_symbols;
1822
1823 std::set<wxString> fieldNames;
1824
1825 for( LIB_SYMBOL_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it )
1826 {
1827 std::vector<SCH_FIELD*> fields;
1828 it->second->GetFields( fields );
1829
1830 for( SCH_FIELD* field : fields )
1831 {
1832 if( field->IsMandatory() )
1833 continue;
1834
1835 // TODO(JE): enable configurability of this outside database libraries?
1836 // if( field->ShowInChooser() )
1837 fieldNames.insert( field->GetName() );
1838 }
1839 }
1840
1841 std::copy( fieldNames.begin(), fieldNames.end(), std::back_inserter( aNames ) );
1842}
1843
1844
1845void SCH_IO_KICAD_SEXPR::GetDefaultSymbolFields( std::vector<wxString>& aNames )
1846{
1847 GetAvailableSymbolFields( aNames );
1848}
1849
1850
1851std::vector<LIB_SYMBOL*> SCH_IO_KICAD_SEXPR::ParseLibSymbols( std::string& aSymbolText,
1852 std::string aSource,
1853 int aFileVersion )
1854{
1855 LOCALE_IO toggle; // toggles on, then off, the C locale.
1856 LIB_SYMBOL* newSymbol = nullptr;
1857 LIB_SYMBOL_MAP map;
1858
1859 std::vector<LIB_SYMBOL*> newSymbols;
1860 std::unique_ptr<STRING_LINE_READER> reader = std::make_unique<STRING_LINE_READER>( aSymbolText,
1861 aSource );
1862
1863 do
1864 {
1865 SCH_IO_KICAD_SEXPR_PARSER parser( reader.get() );
1866
1867 newSymbol = parser.ParseSymbol( map, aFileVersion );
1868
1869 if( newSymbol )
1870 newSymbols.emplace_back( newSymbol );
1871
1872 reader.reset( new STRING_LINE_READER( *reader ) );
1873 }
1874 while( newSymbol );
1875
1876 return newSymbols;
1877}
1878
1879
1881{
1882
1883 LOCALE_IO toggle; // toggles on, then off, the C locale.
1884 SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol( symbol, formatter );
1885}
1886
1887
1888const char* SCH_IO_KICAD_SEXPR::PropBuffering = "buffering";
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:110
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition: box2.h:990
wxString GetMajorMinorVersion()
Get only the major and minor version in a string major.minor.
This class handle bitmap images in KiCad.
Definition: bitmap_base.h:49
const wxMemoryBuffer & GetImageDataBuffer() const
Definition: bitmap_base.h:246
int GetPPI() const
Definition: bitmap_base.h:118
wxImage * GetImageData()
Definition: bitmap_base.h:68
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:127
const KIID m_Uuid
Definition: eda_item.h:489
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:129
bool IsSelected() const
Definition: eda_item.h:110
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:104
EDA_ITEM * GetParent() const
Definition: eda_item.h:103
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:130
FILL_T GetFillMode() const
Definition: eda_shape.h:107
SHAPE_T GetShape() const
Definition: eda_shape.h:125
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:167
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:130
COLOR4D GetFillColor() const
Definition: eda_shape.h:111
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:89
int GetTextHeight() const
Definition: eda_text.h:247
bool IsDefaultFormatting() const
Definition: eda_text.cpp:936
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:130
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:94
virtual void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the object to aFormatter in s-expression form.
Definition: eda_text.cpp:951
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:238
SCH_SCREEN * GetScreen()
Definition: ee_selection.h:52
bool IsEmpty() const
void WriteEmbeddedFiles(OUTPUTFORMATTER &aOut, int aNestLevel, bool aWriteData) const
Output formatter for the embedded files.
void ClearEmbeddedFonts()
Removes all embedded fonts from the collection.
bool GetAreFontsEmbedded() const
A LINE_READER that reads from an open file.
Definition: richio.h:185
void Rewind()
Rewind the file and resets the line number back to zero.
Definition: richio.h:234
char * ReadLine() override
Read a line of text into the buffer and increments the line number counter.
Definition: richio.cpp:244
PROGRESS_REPORTER * m_progressReporter
Progress reporter to track the progress of the operation, may be nullptr.
Definition: io_base.h:221
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:77
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
double r
Red component.
Definition: color4d.h:392
double g
Green component.
Definition: color4d.h:393
double a
Alpha component.
Definition: color4d.h:395
double b
Blue component.
Definition: color4d.h:394
bool MakeRelativeTo(const KIID_PATH &aPath)
Definition: kiid.cpp:303
wxString AsString() const
Definition: kiid.cpp:348
Definition: kiid.h:49
UTF8 Format() const
Definition: lib_id.cpp:118
Define a library symbol object.
Definition: lib_symbol.h:78
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:93
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:49
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:322
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:526
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:458
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the page class to aFormatter in s-expression form.
Definition: page_info.cpp:275
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
virtual void Report(const wxString &aMessage)=0
Display aMessage in the progress bar dialog.
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:135
virtual const wxString GetProjectName() const
Return the short name of the project.
Definition: project.cpp:147
A REFERENCE_IMAGE is a wrapper around a BITMAP_IMAGE that is displayed in an editor as a reference fo...
VECTOR2I GetPosition() const
const BITMAP_BASE & GetImage() const
Get the underlying image.
double GetImageScale() const
Holds all the data relating to one schematic.
Definition: schematic.h:77
void EmbedFonts() override
Embed fonts in the schematic.
Definition: schematic.cpp:872
SCH_SHEET_LIST Hierarchy() const override
Return the full schematic flattened hierarchical sheet list.
Definition: schematic.cpp:214
EMBEDDED_FILES * GetEmbeddedFiles() override
Definition: schematic.cpp:860
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
Definition: schematic.h:137
SCH_SHEET & Root() const
Definition: schematic.h:121
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:92
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:40
REFERENCE_IMAGE & GetReferenceImage()
Definition: sch_bitmap.h:51
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:38
VECTOR2I GetSize() const
Definition: sch_bus_entry.h:73
VECTOR2I GetPosition() const override
virtual STROKE_PARAMS GetStroke() const override
Definition: sch_bus_entry.h:81
VECTOR2I GetEnd() const
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
VECTOR2I GetPosition() const override
Definition: sch_field.cpp:1485
bool IsNameShown() const
Definition: sch_field.h:208
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
Definition: sch_field.cpp:1252
int GetId() const
Definition: sch_field.h:133
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:1227
bool CanAutoplace() const
Definition: sch_field.h:219
void SetId(int aId)
Definition: sch_field.cpp:159
A cache assistant for the KiCad s-expression symbol libraries.
static void SaveSymbol(LIB_SYMBOL *aSymbol, OUTPUTFORMATTER &aFormatter, int aNestLevel=0, const wxString &aLibName=wxEmptyString, bool aIncludeData=true)
void DeleteSymbol(const wxString &aName) override
void Save(const std::optional< bool > &aOpt=std::nullopt) override
Save the entire library to file m_libFileName;.
Object to parser s-expression symbol library and schematic file formats.
void ParseSchematic(SCH_SHEET *aSheet, bool aIsCopyablyOnly=false, int aFileVersion=SEXPR_SCHEMATIC_FILE_VERSION)
Parse the internal LINE_READER object into aSheet.
LIB_SYMBOL * ParseSymbol(LIB_SYMBOL_MAP &aSymbolLibMap, int aFileVersion=SEXPR_SYMBOL_LIB_FILE_VERSION)
Parse internal LINE_READER object into symbols and return all found.
wxString m_path
Root project path for loading child sheets.
void GetDefaultSymbolFields(std::vector< wxString > &aNames) override
Retrieves a list of (custom) field names that should be shown by default for this library in the symb...
void saveBusEntry(SCH_BUS_ENTRY_BASE *aBusEntry, int aNestLevel)
void SaveSchematicFile(const wxString &aFileName, SCH_SHEET *aSheet, SCHEMATIC *aSchematic, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aSchematic to a storage file in a format that this SCH_IO implementation knows about,...
void SaveLibrary(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
SCH_SHEET_PATH m_currentSheetPath
void saveRuleArea(SCH_RULE_AREA *aRuleArea, int aNestLevel)
void LoadContent(LINE_READER &aReader, SCH_SHEET *aSheet, int aVersion=SEXPR_SCHEMATIC_FILE_VERSION)
void EnumerateSymbolLib(wxArrayString &aSymbolNameList, const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Populate a list of LIB_SYMBOL alias names contained within the library aLibraryPath.
void saveText(SCH_TEXT *aText, int aNestLevel)
bool m_appending
Schematic load append status.
int m_version
Version of file being loaded.
void loadFile(const wxString &aFileName, SCH_SHEET *aSheet)
static void FormatLibSymbol(LIB_SYMBOL *aPart, OUTPUTFORMATTER &aFormatter)
void DeleteSymbol(const wxString &aLibraryPath, const wxString &aSymbolName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Delete the entire LIB_SYMBOL associated with aAliasName from the library aLibraryPath.
void loadHierarchy(const SCH_SHEET_PATH &aParentSheetPath, SCH_SHEET *aSheet)
void SaveSymbol(const wxString &aLibraryPath, const LIB_SYMBOL *aSymbol, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aSymbol to an existing library located at aLibraryPath.
static std::vector< LIB_SYMBOL * > ParseLibSymbols(std::string &aSymbolText, std::string aSource, int aFileVersion=SEXPR_SCHEMATIC_FILE_VERSION)
void saveField(SCH_FIELD *aField, int aNestLevel)
OUTPUTFORMATTER * m_out
The formatter for saving SCH_SCREEN objects.
SCH_SHEET * LoadSchematicFile(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load information from some input file format that this SCH_IO implementation knows about,...
void saveBusAlias(std::shared_ptr< BUS_ALIAS > aAlias, int aNestLevel)
LIB_SYMBOL * LoadSymbol(const wxString &aLibraryPath, const wxString &aAliasName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load a LIB_SYMBOL object having aPartName from the aLibraryPath containing a library format that this...
wxString m_error
For throwing exceptions or errors on partial loads.
bool isBuffering(const std::map< std::string, UTF8 > *aProperties)
static const char * PropBuffering
The property used internally by the plugin to enable cache buffering which prevents the library file ...
void saveBitmap(const SCH_BITMAP &aBitmap, int aNestLevel)
SCH_SHEET * m_rootSheet
The root sheet of the schematic being loaded.
void cacheLib(const wxString &aLibraryFileName, const std::map< std::string, UTF8 > *aProperties)
SCH_IO_KICAD_SEXPR_LIB_CACHE * m_cache
void Format(SCH_SHEET *aSheet)
bool IsLibraryWritable(const wxString &aLibraryPath) override
Return true if the library at aLibraryPath is writable.
void saveSymbol(SCH_SYMBOL *aSymbol, const SCHEMATIC &aSchematic, const SCH_SHEET_LIST &aSheetList, int aNestLevel, bool aForClipboard, const SCH_SHEET_PATH *aRelativePath=nullptr)
void init(SCHEMATIC *aSchematic, const std::map< std::string, UTF8 > *aProperties=nullptr)
initialize PLUGIN like a constructor would.
bool DeleteLibrary(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Delete an existing library and returns true, or if library does not exist returns false,...
void saveNoConnect(SCH_NO_CONNECT *aNoConnect, int aNestLevel)
void saveShape(SCH_SHAPE *aShape, int aNestLevel)
int GetModifyHash() const override
Return the modification hash from the library cache.
void saveJunction(SCH_JUNCTION *aJunction, int aNestLevel)
void saveTextBox(SCH_TEXTBOX *aText, int aNestLevel)
void saveInstances(const std::vector< SCH_SHEET_INSTANCE > &aSheets, int aNestLevel)
void saveSheet(SCH_SHEET *aSheet, const SCH_SHEET_LIST &aSheetList, int aNestLevel)
void saveLine(SCH_LINE *aLine, int aNestLevel)
std::stack< wxString > m_currentPath
Stack to maintain nested sheet paths.
void CreateLibrary(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Create a new empty library at aLibraryPath empty.
void saveTable(SCH_TABLE *aTable, int aNestLevel)
void GetAvailableSymbolFields(std::vector< wxString > &aNames) override
Retrieves a list of (custom) field names that are present on symbols in this library.
bool IsFile(const wxString &aFullPathAndFileName) const
void SetFileName(const wxString &aFileName)
virtual void AddSymbol(const LIB_SYMBOL *aSymbol)
LIB_SYMBOL_MAP m_symbols
bool IsFileChanged() const
wxString GetFileName() const
void SetModified(bool aModified=true)
Base class that schematic file and library loading and saving plugins should derive from.
Definition: sch_io.h:57
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:166
int GetBodyStyle() const
Definition: sch_item.h:232
int GetUnit() const
Definition: sch_item.h:229
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:281
FIELDS_AUTOPLACED GetFieldsAutoplaced() const
Return whether the fields have been automatically placed.
Definition: sch_item.h:548
wxString GetClass() const override
Return the class name.
Definition: sch_item.h:176
COLOR4D GetColor() const
Definition: sch_junction.h:119
int GetDiameter() const
Definition: sch_junction.h:114
VECTOR2I GetPosition() const override
Definition: sch_junction.h:107
SPIN_STYLE GetSpinStyle() const
Definition: sch_label.cpp:332
LABEL_FLAG_SHAPE GetShape() const
Definition: sch_label.h:177
std::vector< SCH_FIELD > & GetFields()
Definition: sch_label.h:201
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:41
virtual STROKE_PARAMS GetStroke() const override
Definition: sch_line.h:184
VECTOR2I GetEndPoint() const
Definition: sch_line.h:141
VECTOR2I GetStartPoint() const
Definition: sch_line.h:136
void SetEndPoint(const VECTOR2I &aPosition)
Definition: sch_line.h:142
VECTOR2I GetPosition() const override
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:130
auto & GetBusAliases() const
Return a set of bus aliases defined in this screen.
Definition: sch_screen.h:516
const std::map< wxString, LIB_SYMBOL * > & GetLibSymbols() const
Fetch a list of unique LIB_SYMBOL object pointers required to properly render each SCH_SYMBOL in this...
Definition: sch_screen.h:480
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:108
const wxString & GetFileName() const
Definition: sch_screen.h:143
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
Definition: sch_screen.cpp:118
const TITLE_BLOCK & GetTitleBlock() const
Definition: sch_screen.h:154
KIID m_uuid
A unique identifier for each schematic file.
Definition: sch_screen.h:698
void SetFileReadOnly(bool aIsReadOnly)
Definition: sch_screen.h:145
void SetFileExists(bool aFileExists)
Definition: sch_screen.h:148
STROKE_PARAMS GetStroke() const override
Definition: sch_shape.h:55
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
std::optional< SCH_SHEET_PATH > GetSheetPathByKIIDPath(const KIID_PATH &aPath, bool aIncludeLastSheet=true) const
Finds a SCH_SHEET_PATH that matches the provided KIID_PATH.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
bool empty() const
Forwarded method from std::vector.
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
SCH_SCREEN * LastScreen()
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
void pop_back()
Forwarded method from std::vector.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:66
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
bool GetExcludedFromBOM() const
Definition: sch_sheet.h:376
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:306
bool HasRootInstance() const
Check to see if this sheet has a root sheet instance.
Definition: sch_sheet.cpp:1487
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:93
bool GetExcludedFromBoard() const
Definition: sch_sheet.h:382
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:785
VECTOR2I GetSize() const
Definition: sch_sheet.h:112
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:110
VECTOR2I GetPosition() const override
Definition: sch_sheet.h:400
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:173
const SCH_SHEET_INSTANCE & GetRootInstance() const
Return the root sheet instance data.
Definition: sch_sheet.cpp:1499
KIGFX::COLOR4D GetBorderColor() const
Definition: sch_sheet.h:118
bool GetExcludedFromSim() const override
Definition: sch_sheet.h:370
int GetBorderWidth() const
Definition: sch_sheet.h:115
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:181
const std::vector< SCH_SHEET_INSTANCE > & GetInstances() const
Definition: sch_sheet.h:417
bool GetDNP() const
Set or clear the 'Do Not Populate' flaga.
Definition: sch_sheet.h:387
KIGFX::COLOR4D GetBackgroundColor() const
Definition: sch_sheet.h:121
Schematic symbol object.
Definition: sch_symbol.h:104
std::vector< std::unique_ptr< SCH_PIN > > & GetRawPins()
Definition: sch_symbol.h:677
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstances() const
Definition: sch_symbol.h:163
bool UseLibIdLookup() const
Definition: sch_symbol.h:210
wxString GetSchSymbolLibraryName() const
Definition: sch_symbol.cpp:270
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:939
VECTOR2I GetPosition() const override
Definition: sch_symbol.h:807
const LIB_ID & GetLibId() const override
Definition: sch_symbol.h:193
bool GetInstance(SCH_SYMBOL_INSTANCE &aInstance, const KIID_PATH &aSheetPath, bool aTestFromEnd=false) const
Definition: sch_symbol.cpp:585
int GetOrientation() const
Get the display symbol orientation.
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:987
void SetRowHeight(int aRow, int aHeight)
Definition: sch_table.h:121
const STROKE_PARAMS & GetSeparatorsStroke() const
Definition: sch_table.h:72
void SetColCount(int aCount)
Definition: sch_table.h:103
bool StrokeExternal() const
Definition: sch_table.h:54
int GetRowHeight(int aRow) const
Definition: sch_table.h:123
void SetColWidth(int aCol, int aWidth)
Definition: sch_table.h:111
std::vector< SCH_TABLECELL * > GetCells() const
Definition: sch_table.h:141
int GetColWidth(int aCol) const
Definition: sch_table.h:113
const STROKE_PARAMS & GetBorderStroke() const
Definition: sch_table.h:60
int GetColCount() const
Definition: sch_table.h:104
void DeleteMarkedCells()
Definition: sch_table.h:166
SCH_TABLECELL * GetCell(int aRow, int aCol) const
Definition: sch_table.h:131
bool StrokeColumns() const
Definition: sch_table.h:84
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_table.h:210
bool StrokeRows() const
Definition: sch_table.h:87
int GetRowCount() const
Definition: sch_table.h:106
bool StrokeHeader() const
Definition: sch_table.h:57
int GetMarginBottom() const
Definition: sch_textbox.h:66
int GetMarginLeft() const
Definition: sch_textbox.h:63
bool GetExcludedFromSim() const override
Definition: sch_textbox.h:94
int GetMarginRight() const
Definition: sch_textbox.h:65
int GetMarginTop() const
Definition: sch_textbox.h:64
VECTOR2I GetPosition() const override
Definition: sch_text.h:141
bool GetExcludedFromSim() const override
Definition: sch_text.h:86
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.cpp:75
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:100
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:253
Simple container to manage line stroke parameters.
Definition: stroke_params.h:79
void SetWidth(int aWidth)
Definition: stroke_params.h:90
void Format(OUTPUTFORMATTER *out, const EDA_IU_SCALE &aIuScale, int nestLevel) const
static const char * PropPowerSymsOnly
bool GetExcludedFromBoard() const
Definition: symbol.h:148
bool GetExcludedFromBOM() const
Definition: symbol.h:142
bool GetDNP() const
Set or clear the 'Do Not Populate' flaga.
Definition: symbol.h:153
bool GetExcludedFromSim() const override
Definition: symbol.h:136
virtual void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the object to aFormatter in s-expression form.
Definition: title_block.cpp:30
wxString wx_str() const
Definition: utf8.cpp:45
static REPORTER & GetInstance()
Definition: reporter.cpp:199
static void SetReporter(REPORTER *aReporter)
Set the reporter to use for reporting font substitution warnings.
Definition: fontconfig.cpp:64
#define MIME_BASE64_LENGTH
#define _(s)
static constexpr EDA_ANGLE ANGLE_0
Definition: eda_angle.h:401
static constexpr EDA_ANGLE ANGLE_90
Definition: eda_angle.h:403
static constexpr EDA_ANGLE ANGLE_270
Definition: eda_angle.h:406
static constexpr EDA_ANGLE ANGLE_180
Definition: eda_angle.h:405
#define STRUCT_DELETED
flag indication structures to be erased
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define DEFAULT_SIZE_TEXT
This is the "default-of-the-default" hardcoded text size; individual application define their own def...
Definition: eda_text.h:69
const wxChar *const traceSchPlugin
Flag to enable legacy schematic plugin debug output.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:39
KIID niluuid(0)
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
Definition: layer_id.cpp:31
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:353
@ LAYER_WIRE
Definition: layer_ids.h:356
@ LAYER_NOTES
Definition: layer_ids.h:371
@ LAYER_BUS
Definition: layer_ids.h:357
@ SCH_LAYER_ID_START
Definition: layer_ids.h:354
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:96
KICOMMON_API std::string FormatInternalUnits(const EDA_IU_SCALE &aIuScale, int aValue)
Converts aValue from internal units to a string appropriate for writing to file.
Definition: eda_units.cpp:169
KICOMMON_API std::string FormatAngle(const EDA_ANGLE &aAngle)
Converts aAngle from board units to a string appropriate for writing to file.
Definition: eda_units.cpp:161
void FormatUuid(OUTPUTFORMATTER *aOut, const KIID &aUuid, char aSuffix)
#define SEXPR_SCHEMATIC_FILE_VERSION
Schematic file version.
const char * getSheetPinShapeToken(LABEL_FLAG_SHAPE aShape)
void formatArc(OUTPUTFORMATTER *aFormatter, int aNestLevel, EDA_SHAPE *aArc, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid)
void formatFill(OUTPUTFORMATTER *aFormatter, int aNestLevel, FILL_T aFillMode, const COLOR4D &aFillColor)
Fill token formatting helper.
const char * getTextTypeToken(KICAD_T aType)
void formatCircle(OUTPUTFORMATTER *aFormatter, int aNestLevel, EDA_SHAPE *aCircle, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid)
void formatBezier(OUTPUTFORMATTER *aFormatter, int aNestLevel, EDA_SHAPE *aBezier, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid)
void formatRect(OUTPUTFORMATTER *aFormatter, int aNestLevel, EDA_SHAPE *aRect, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid)
void formatPoly(OUTPUTFORMATTER *aFormatter, int aNestLevel, EDA_SHAPE *aPolyLine, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid)
EDA_ANGLE getSheetPinAngle(SHEET_SIDE aSide)
@ FIELDS_AUTOPLACED_NO
Definition: sch_item.h:69
@ SHEET_MANDATORY_FIELDS
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
Definition: sch_sheet.h:49
std::string toUTFTildaText(const wxString &txt)
Convert a wxString to UTF8 and replace any control characters with a ~, where a control character is ...
Definition: sch_symbol.cpp:56
@ SYM_ORIENT_270
Definition: sch_symbol.h:83
@ SYM_MIRROR_Y
Definition: sch_symbol.h:85
@ SYM_ORIENT_180
Definition: sch_symbol.h:82
@ SYM_MIRROR_X
Definition: sch_symbol.h:84
@ SYM_ORIENT_90
Definition: sch_symbol.h:81
const int scale
std::string FormatDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 This function is intended in...
std::string EscapedUTF8(const wxString &aString)
Return an 8 bit UTF8 string given aString in Unicode form.
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: string_utils.h:398
@ CTX_LEGACY_LIBID
Definition: string_utils.h:55
constexpr int MilsToIU(int mils) const
Definition: base_units.h:93
A simple container for sheet instance information.
A simple container for schematic symbol instance information.
std::map< wxString, LIB_SYMBOL *, LibSymbolMapSort > LIB_SYMBOL_MAP
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 5 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
wxLogTrace helper definitions.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_TABLE_T
Definition: typeinfo.h:165
@ SCH_LINE_T
Definition: typeinfo.h:163
@ SCH_NO_CONNECT_T
Definition: typeinfo.h:160
@ TYPE_NOT_INIT
Definition: typeinfo.h:81
@ SCH_SYMBOL_T
Definition: typeinfo.h:172
@ SCH_TABLECELL_T
Definition: typeinfo.h:166
@ SCH_DIRECTIVE_LABEL_T
Definition: typeinfo.h:171
@ SCH_LABEL_T
Definition: typeinfo.h:167
@ SCH_SHEET_T
Definition: typeinfo.h:174
@ SCH_MARKER_T
Definition: typeinfo.h:158
@ SCH_SHAPE_T
Definition: typeinfo.h:149
@ SCH_RULE_AREA_T
Definition: typeinfo.h:170
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:169
@ SCH_BUS_BUS_ENTRY_T
Definition: typeinfo.h:162
@ SCH_TEXT_T
Definition: typeinfo.h:151
@ SCH_BUS_WIRE_ENTRY_T
Definition: typeinfo.h:161
@ SCH_BITMAP_T
Definition: typeinfo.h:164
@ SCH_TEXTBOX_T
Definition: typeinfo.h:152
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:168
@ SCH_JUNCTION_T
Definition: typeinfo.h:159