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