KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_io_easyeda.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) 2023 Alex Shvartzkop <[email protected]>
5 * Copyright (C) 2023-2024 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include "sch_easyeda_parser.h"
26#include "sch_io_easyeda.h"
27
28#include <schematic.h>
29#include <sch_sheet.h>
30#include <sch_screen.h>
32#include <project_sch.h>
34#include <string_utils.h>
35
36#include <wx/log.h>
37#include <wx/stdstream.h>
38#include <wx/zipstrm.h>
39
40#include <nlohmann/json.hpp>
41#include <core/map_helpers.h>
42#include <wx/wfstream.h>
43
44
45static bool FindSchFileInStream( const wxString& aName, wxInputStream& aStream,
46 nlohmann::json& aOut, EASYEDA::DOCUMENT& aDoc,
47 EASYEDA::DOC_TYPE& aDocType )
48{
49 if( aName.Lower().EndsWith( wxS( ".json" ) ) )
50 {
51 wxStdInputStream sin( aStream );
52 nlohmann::json js = nlohmann::json::parse( sin, nullptr, false );
53
54 if( js.is_discarded() )
55 return false;
56
59
60 if( doc.docType )
61 type = *doc.docType;
62 else
63 type = doc.head.docType;
64
66 || type == EASYEDA::DOC_TYPE::SYMBOL )
67 {
68 aOut = js;
69 aDoc = doc;
70 aDocType = type;
71 return true;
72 }
73 }
74 else if( aName.Lower().EndsWith( wxS( ".zip" ) ) )
75 {
76 std::shared_ptr<wxZipEntry> entry;
77 wxZipInputStream zip( aStream );
78
79 if( !zip.IsOk() )
80 return false;
81
82 while( entry.reset( zip.GetNextEntry() ), entry.get() != NULL )
83 {
84 wxString name = entry->GetName();
85
86 if( FindSchFileInStream( name, zip, aOut, aDoc, aDocType ) )
87 return true;
88 }
89 }
90
91 return false;
92}
93
94
95bool SCH_IO_EASYEDA::CanReadSchematicFile( const wxString& aFileName ) const
96{
97 if( !SCH_IO::CanReadSchematicFile( aFileName ) )
98 return false;
99
100 try
101 {
102 wxFFileInputStream in( aFileName );
103 nlohmann::json js;
105 EASYEDA::DOC_TYPE docType;
106
107 return FindSchFileInStream( aFileName, in, js, doc, docType );
108 }
109 catch( nlohmann::json::exception& )
110 {
111 }
112 catch( std::exception& )
113 {
114 }
115
116 return false;
117}
118
119
120bool SCH_IO_EASYEDA::CanReadLibrary( const wxString& aFileName ) const
121{
122 return CanReadSchematicFile( aFileName );
123}
124
125
127{
128 return 0;
129}
130
131
132LIB_SYMBOL* loadSymbol( const wxString& aLibraryPath, nlohmann::json aFileData,
133 const wxString& aAliasName, const STRING_UTF8_MAP* aProperties )
134{
135 SCH_EASYEDA_PARSER parser( nullptr, nullptr );
136 std::map<wxString, int> namesCounter;
137
138 try
139 {
140 wxFFileInputStream in( aLibraryPath );
141 nlohmann::json js;
142 EASYEDA::DOCUMENT topDoc;
143 EASYEDA::DOC_TYPE topDocType;
144
145 if( !FindSchFileInStream( aLibraryPath, in, js, topDoc, topDocType ) )
146 {
147 THROW_IO_ERROR( wxString::Format( _( "Unable to find a valid schematic file in '%s'" ),
148 aLibraryPath ) );
149 }
150
151 if( topDocType == EASYEDA::DOC_TYPE::SCHEMATIC_SHEET
152 || topDocType == EASYEDA::DOC_TYPE::SCHEMATIC_LIST )
153 {
155
156 for( const EASYEDA::DOCUMENT& subDoc : *schDoc.schematics )
157 {
158 if( subDoc.docType )
159 {
161 continue;
162 }
163 else
164 {
166 continue;
167 }
168
169 EASYEDA::DOCUMENT dataStrDoc = subDoc.dataStr->get<EASYEDA::DOCUMENT>();
170
171 for( wxString shap : dataStrDoc.shape )
172 {
173 if( !shap.Contains( wxS( "LIB" ) ) )
174 continue;
175
176 shap.Replace( wxS( "#@$" ), wxS( "\n" ) );
177 wxArrayString parts = wxSplit( shap, '\n', '\0' );
178
179 if( parts.size() < 1 )
180 continue;
181
182 wxArrayString paramsRoot = wxSplit( parts[0], '~', '\0' );
183
184 if( paramsRoot.size() < 1 )
185 continue;
186
187 wxString rootType = paramsRoot[0];
188
189 if( rootType == wxS( "LIB" ) )
190 {
191 if( paramsRoot.size() < 4 )
192 continue;
193
194 VECTOR2D origin( parser.Convert( paramsRoot[1] ),
195 parser.Convert( paramsRoot[2] ) );
196
197 wxString symbolName = wxString::Format( wxS( "Unknown_%s_%s" ),
198 paramsRoot[1], paramsRoot[2] );
199
200 wxArrayString paramParts = wxSplit( paramsRoot[3], '`', '\0' );
201
202 std::map<wxString, wxString> paramMap;
203
204 for( size_t i = 1; i < paramParts.size(); i += 2 )
205 {
206 wxString key = paramParts[i - 1];
207 wxString value = paramParts[i];
208
209 if( key == wxS( "spiceSymbolName" ) && !value.IsEmpty() )
210 symbolName = value;
211
212 paramMap[key] = value;
213 }
214
215 int& serial = namesCounter[symbolName];
216
217 if( serial > 0 )
218 symbolName << wxS( "_" ) << serial;
219
220 serial++;
221
222 paramMap[wxS( "spiceSymbolName" )] = symbolName;
223
224 if( symbolName == aAliasName )
225 {
226 parts.RemoveAt( 0 );
227
228 LIB_SYMBOL* ksymbol = parser.ParseSymbol( origin, paramMap, parts );
229
230 // Clear reference numbers
231 SCH_FIELD& refField = ksymbol->GetReferenceField();
232 wxString origRef = refField.GetText();
233 wxString reference;
234
235 for( size_t i = 0; i < origRef.size() && !wxIsdigit( origRef[i] ); i++ )
236 reference << origRef[i];
237
238 refField.SetText( reference );
239
240 return ksymbol;
241 }
242 }
243 }
244 }
245 }
246 else if( topDocType == EASYEDA::DOC_TYPE::SYMBOL )
247 {
249
250 wxString symbolName = wxS( "Unknown" );
251
252 std::optional<std::map<wxString, wxString>> c_para;
253
254 if( symDoc.c_para )
255 c_para = symDoc.c_para;
256 else if( topDoc.head.c_para )
257 c_para = topDoc.head.c_para;
258
259 if( !c_para )
260 return nullptr;
261
262 symbolName = get_def( *c_para, wxS( "name" ), symbolName );
263
264 int& serial = namesCounter[symbolName];
265
266 if( serial > 0 )
267 symbolName << wxS( "_" ) << serial;
268
269 serial++;
270
271 if( symbolName != aAliasName )
272 return nullptr;
273
274 VECTOR2D origin( topDoc.head.x, topDoc.head.y );
275
276 LIB_SYMBOL* ksymbol = parser.ParseSymbol( origin, *c_para, topDoc.shape );
277
278 // Clear reference numbers
279 SCH_FIELD& refField = ksymbol->GetReferenceField();
280 wxString origRef = refField.GetText();
281 wxString reference;
282
283 for( size_t i = 0; i < origRef.size() && !wxIsdigit( origRef[i] ); i++ )
284 reference << origRef[i];
285
286 refField.SetText( reference );
287
288 return ksymbol;
289 }
290 }
291 catch( nlohmann::json::exception& e )
292 {
293 THROW_IO_ERROR( wxString::Format( _( "Error loading symbol '%s' from library '%s': %s" ),
294 aAliasName, aLibraryPath, e.what() ) );
295 }
296 catch( std::exception& e )
297 {
298 THROW_IO_ERROR( wxString::Format( _( "Error loading symbol '%s' from library '%s': %s" ),
299 aAliasName, aLibraryPath, e.what() ) );
300 }
301
302 return nullptr;
303}
304
305
306void SCH_IO_EASYEDA::EnumerateSymbolLib( wxArrayString& aSymbolNameList,
307 const wxString& aLibraryPath,
308 const STRING_UTF8_MAP* aProperties )
309{
310 std::map<wxString, int> namesCounter;
311
312 try
313 {
314 wxFFileInputStream in( aLibraryPath );
315 nlohmann::json js;
316 EASYEDA::DOCUMENT topDoc;
317 EASYEDA::DOC_TYPE topDocType;
318
319 if( !FindSchFileInStream( aLibraryPath, in, js, topDoc, topDocType ) )
320 {
321 THROW_IO_ERROR( wxString::Format( _( "Unable to find a valid schematic file in '%s'" ),
322 aLibraryPath ) );
323 }
324
325 if( topDocType == EASYEDA::DOC_TYPE::SCHEMATIC_SHEET
326 || topDocType == EASYEDA::DOC_TYPE::SCHEMATIC_LIST )
327 {
329
330 for( const EASYEDA::DOCUMENT& subDoc : *schDoc.schematics )
331 {
332 if( subDoc.docType )
333 {
335 continue;
336 }
337 else
338 {
340 continue;
341 }
342
343 EASYEDA::DOCUMENT dataStrDoc = subDoc.dataStr->get<EASYEDA::DOCUMENT>();
344
345 for( wxString shap : dataStrDoc.shape )
346 {
347 if( !shap.Contains( wxS( "LIB" ) ) )
348 continue;
349
350 shap.Replace( wxS( "#@$" ), wxS( "\n" ) );
351 wxArrayString parts = wxSplit( shap, '\n', '\0' );
352
353 if( parts.size() < 1 )
354 continue;
355
356 wxArrayString paramsRoot = wxSplit( parts[0], '~', '\0' );
357
358 if( paramsRoot.size() < 1 )
359 continue;
360
361 wxString rootType = paramsRoot[0];
362
363 if( rootType == wxS( "LIB" ) )
364 {
365 if( paramsRoot.size() < 4 )
366 continue;
367
368 wxString symbolName = wxString::Format( wxS( "Unknown_%s_%s" ),
369 paramsRoot[1], paramsRoot[2] );
370
371 wxArrayString paramParts = wxSplit( paramsRoot[3], '`', '\0' );
372
373 std::map<wxString, wxString> paramMap;
374
375 for( size_t i = 1; i < paramParts.size(); i += 2 )
376 {
377 wxString key = paramParts[i - 1];
378 wxString value = paramParts[i];
379
380 if( key == wxS( "spiceSymbolName" ) && !value.IsEmpty() )
381 symbolName = value;
382
383 paramMap[key] = value;
384 }
385
386 int& serial = namesCounter[symbolName];
387
388 if( serial > 0 )
389 symbolName << wxS( "_" ) << serial;
390
391 serial++;
392
393 aSymbolNameList.Add( symbolName );
394 }
395 }
396 }
397 }
398 else if( topDocType == EASYEDA::DOC_TYPE::SYMBOL )
399 {
401
402 wxString packageName = wxS( "Unknown" );
403
404 if( symDoc.c_para )
405 {
406 packageName = get_def( *symDoc.c_para, wxS( "name" ), packageName );
407 }
408 else if( topDoc.head.c_para )
409 {
410 packageName = get_def( *topDoc.head.c_para, wxS( "name" ), packageName );
411 }
412
413 aSymbolNameList.Add( packageName );
414 }
415 }
416 catch( nlohmann::json::exception& e )
417 {
418 THROW_IO_ERROR( wxString::Format( _( "Error enumerating symbol library '%s': %s" ),
419 aLibraryPath, e.what() ) );
420 }
421 catch( std::exception& e )
422 {
423 THROW_IO_ERROR( wxString::Format( _( "Error enumerating symbol library '%s': %s" ),
424 aLibraryPath, e.what() ) );
425 }
426}
427
428
429void SCH_IO_EASYEDA::EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& aSymbolList,
430 const wxString& aLibraryPath,
431 const STRING_UTF8_MAP* aProperties )
432{
433 wxFFileInputStream in( aLibraryPath );
434 nlohmann::json js;
435 EASYEDA::DOCUMENT topDoc;
436 EASYEDA::DOC_TYPE topDocType;
437
438 if( !FindSchFileInStream( aLibraryPath, in, js, topDoc, topDocType ) )
439 {
440 THROW_IO_ERROR( wxString::Format( _( "Unable to find a valid schematic file in '%s'" ),
441 aLibraryPath ) );
442 }
443
444 try
445 {
446 wxArrayString symbolNameList;
447
448 EnumerateSymbolLib( symbolNameList, aLibraryPath, aProperties );
449
450 for( const wxString& symbolName : symbolNameList )
451 {
452 LIB_SYMBOL* sym = loadSymbol( aLibraryPath, js, symbolName, aProperties );
453
454 if( sym )
455 aSymbolList.push_back( sym );
456 }
457 }
458 catch( nlohmann::json::exception& e )
459 {
460 THROW_IO_ERROR( wxString::Format( _( "Error enumerating symbol library '%s': %s" ),
461 aLibraryPath, e.what() ) );
462 }
463 catch( std::exception& e )
464 {
465 THROW_IO_ERROR( wxString::Format( _( "Error enumerating symbol library '%s': %s" ),
466 aLibraryPath, e.what() ) );
467 }
468}
469
470
471LIB_SYMBOL* SCH_IO_EASYEDA::LoadSymbol( const wxString& aLibraryPath,
472 const wxString& aAliasName,
473 const STRING_UTF8_MAP* aProperties )
474{
475 try
476 {
477 wxFFileInputStream in( aLibraryPath );
478 nlohmann::json js;
479 EASYEDA::DOCUMENT topDoc;
480 EASYEDA::DOC_TYPE topDocType;
481
482 if( !FindSchFileInStream( aLibraryPath, in, js, topDoc, topDocType ) )
483 {
484 THROW_IO_ERROR( wxString::Format( _( "Unable to find a valid schematic file in '%s'" ),
485 aLibraryPath ) );
486 }
487
488 return loadSymbol( aLibraryPath, js, aAliasName, aProperties );
489 }
490 catch( nlohmann::json::exception& e )
491 {
492 THROW_IO_ERROR( wxString::Format( _( "Error loading symbol '%s' from library '%s': %s" ),
493 aAliasName, aLibraryPath, e.what() ) );
494 }
495 catch( std::exception& e )
496 {
497 THROW_IO_ERROR( wxString::Format( _( "Error loading symbol '%s' from library '%s': %s" ),
498 aAliasName, aLibraryPath, e.what() ) );
499 }
500
501 return nullptr;
502}
503
504
505static void LoadSchematic( SCHEMATIC* aSchematic, SCH_SHEET* aRootSheet, const wxString& aFileName )
506{
507 SCH_EASYEDA_PARSER parser( nullptr, nullptr );
508
509 try
510 {
511 wxFFileInputStream in( aFileName );
512 nlohmann::json js;
513 EASYEDA::DOCUMENT topDoc;
514 EASYEDA::DOC_TYPE topDocType;
515
516 if( !FindSchFileInStream( aFileName, in, js, topDoc, topDocType ) )
517 {
518 THROW_IO_ERROR( wxString::Format( _( "Unable to find a valid schematic file in '%s'" ),
519 aFileName ) );
520 }
521
522 if( topDocType == EASYEDA::DOC_TYPE::SCHEMATIC_SHEET
523 || topDocType == EASYEDA::DOC_TYPE::SCHEMATIC_LIST )
524 {
525 int pageNum = 1;
527
528 for( const EASYEDA::DOCUMENT& subDoc : *schDoc.schematics )
529 {
530 if( subDoc.docType )
531 {
533 continue;
534 }
535 else
536 {
538 continue;
539 }
540
541 EASYEDA::DOCUMENT dataStrDoc = subDoc.dataStr->get<EASYEDA::DOCUMENT>();
542
543 if( schDoc.schematics->size() > 1 )
544 {
545 wxString sheetTitle =
546 !subDoc.title.empty() ? subDoc.title : ( wxString() << pageNum );
547
548 wxString sheetBaseName = EscapeString( sheetTitle, CTX_FILENAME );
549
550 wxFileName sheetFname( aFileName );
551 sheetFname.SetFullName(
552 sheetBaseName + wxS( "." )
553 + wxString::FromUTF8( FILEEXT::KiCadSchematicFileExtension ) );
554
555 wxFileName relSheetPath( sheetFname );
556 relSheetPath.MakeRelativeTo(
557 wxFileName( aRootSheet->GetFileName() ).GetPath() );
558
559 std::unique_ptr<SCH_SHEET> subSheet = std::make_unique<SCH_SHEET>( aSchematic );
560 subSheet->SetFileName( relSheetPath.GetFullPath() );
561 subSheet->SetName( sheetTitle );
562
563 SCH_SCREEN* screen = new SCH_SCREEN( aSchematic );
564 screen->SetFileName( sheetFname.GetFullPath() );
565 screen->SetPageNumber( wxString() << pageNum );
566 subSheet->SetScreen( screen );
567
568 VECTOR2I pos;
569 pos.x = schIUScale.MilsToIU( 200 );
570 pos.y = schIUScale.MilsToIU( 200 )
571 + ( subSheet->GetSize().y + schIUScale.MilsToIU( 200 ) )
572 * ( pageNum - 1 );
573
574 subSheet->SetPosition( pos );
575
576 SCH_SHEET_PATH sheetPath;
577 sheetPath.push_back( aRootSheet );
578 sheetPath.push_back( subSheet.get() );
579 sheetPath.SetPageNumber( wxString() << pageNum );
580 aSchematic->SetCurrentSheet( sheetPath );
581
582 parser.ParseSchematic( aSchematic, subSheet.get(), aFileName,
583 dataStrDoc.shape );
584
585 aRootSheet->GetScreen()->Append( subSheet.release() );
586 }
587 else
588 {
589 parser.ParseSchematic( aSchematic, aRootSheet, aFileName, dataStrDoc.shape );
590 }
591
592 pageNum++;
593 }
594 }
595 }
596 catch( nlohmann::json::exception& e )
597 {
599 wxString::Format( _( "Error loading schematic '%s': %s" ), aFileName, e.what() ) );
600 }
601 catch( std::exception& e )
602 {
604 wxString::Format( _( "Error loading schematic '%s': %s" ), aFileName, e.what() ) );
605 }
606}
607
608
609SCH_SHEET* SCH_IO_EASYEDA::LoadSchematicFile( const wxString& aFileName, SCHEMATIC* aSchematic,
610 SCH_SHEET* aAppendToMe,
611 const STRING_UTF8_MAP* aProperties )
612{
613 wxCHECK( !aFileName.IsEmpty() && aSchematic, nullptr );
614
615 SCH_SHEET* rootSheet = nullptr;
616
617 if( aAppendToMe )
618 {
619 wxCHECK_MSG( aSchematic->IsValid(), nullptr,
620 wxS( "Can't append to a schematic with no root!" ) );
621
622 rootSheet = &aSchematic->Root();
623 }
624 else
625 {
626 rootSheet = new SCH_SHEET( aSchematic );
627 rootSheet->SetFileName( aFileName );
628 aSchematic->SetRoot( rootSheet );
629 }
630
631 if( !rootSheet->GetScreen() )
632 {
633 SCH_SCREEN* screen = new SCH_SCREEN( aSchematic );
634
635 screen->SetFileName( aFileName );
636 rootSheet->SetScreen( screen );
637 }
638
639 SYMBOL_LIB_TABLE* libTable = PROJECT_SCH::SchSymbolLibTable( &aSchematic->Prj() );
640
641 wxCHECK_MSG( libTable, nullptr, wxS( "Could not load symbol lib table." ) );
642 LoadSchematic( aSchematic, rootSheet, aFileName );
644
645 return rootSheet;
646}
const char * name
Definition: DXF_plotter.cpp:57
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:110
void SetPageNumber(const wxString &aPageNumber)
Definition: base_screen.h:79
static double Convert(const wxString &aValue)
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:98
Define a library symbol object.
Definition: lib_symbol.h:77
SCH_FIELD & GetReferenceField() const
Return reference to the reference designator field.
static SYMBOL_LIB_TABLE * SchSymbolLibTable(PROJECT *aProject)
Accessor for project symbol library table.
Holds all the data relating to one schematic.
Definition: schematic.h:75
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:136
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
Definition: schematic.h:141
void SetRoot(SCH_SHEET *aRootSheet)
Initialize the schematic with a new root sheet.
Definition: schematic.cpp:186
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
Definition: schematic.h:121
SCH_SHEET & Root() const
Definition: schematic.h:105
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:90
void ParseSchematic(SCHEMATIC *aSchematic, SCH_SHEET *aRootSheet, const wxString &aFileName, wxArrayString aShapes)
LIB_SYMBOL * ParseSymbol(const VECTOR2D &aOrigin, std::map< wxString, wxString > aParams, wxArrayString aShapes)
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
void SetText(const wxString &aText) override
Definition: sch_field.cpp:1138
LIB_SYMBOL * LoadSymbol(const wxString &aLibraryPath, const wxString &aAliasName, const STRING_UTF8_MAP *aProperties=nullptr) override
Load a LIB_SYMBOL object having aPartName from the aLibraryPath containing a library format that this...
bool CanReadLibrary(const wxString &aFileName) const override
Checks if this IO object can read the specified library file/directory.
int GetModifyHash() const override
Return the modification hash from the library cache.
void EnumerateSymbolLib(wxArrayString &aSymbolNameList, const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr) override
Populate a list of LIB_SYMBOL alias names contained within the library aLibraryPath.
SCH_SHEET * LoadSchematicFile(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const STRING_UTF8_MAP *aProperties=nullptr) override
Load information from some input file format that this SCH_IO implementation knows about,...
bool CanReadSchematicFile(const wxString &aFileName) const override
Checks if this SCH_IO can read the specified schematic file.
virtual bool CanReadSchematicFile(const wxString &aFileName) const
Checks if this SCH_IO can read the specified schematic file.
Definition: sch_io.cpp:46
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Definition: sch_screen.cpp:151
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
Definition: sch_screen.cpp:116
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
void SetFileName(const wxString &aFilename)
Definition: sch_sheet.h:312
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:306
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:110
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:162
A name/value tuple with unique names and optional values.
#define _(s)
static const std::string KiCadSchematicFileExtension
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:39
wxString get_def(const std::map< wxString, wxString > &aMap, const char *aKey, const char *aDefval="")
Definition: map_helpers.h:64
static void LoadSchematic(SCHEMATIC *aSchematic, SCH_SHEET *aRootSheet, const wxString &aFileName)
static bool FindSchFileInStream(const wxString &aName, wxInputStream &aStream, nlohmann::json &aOut, EASYEDA::DOCUMENT &aDoc, EASYEDA::DOC_TYPE &aDocType)
LIB_SYMBOL * loadSymbol(const wxString &aLibraryPath, nlohmann::json aFileData, const wxString &aAliasName, const STRING_UTF8_MAP *aProperties)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
@ CTX_FILENAME
Definition: string_utils.h:61
std::optional< std::vector< DOCUMENT > > schematics
std::optional< std::map< wxString, wxString > > c_para
std::optional< nlohmann::json > dataStr
std::optional< DOC_TYPE > docType
std::optional< std::map< wxString, wxString > > c_para
constexpr int MilsToIU(int mils) const
Definition: base_units.h:93
Definition of file extensions used in Kicad.