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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21#include "sch_easyeda_parser.h"
22#include "sch_io_easyeda.h"
23
24#include <font/fontconfig.h>
26#include <project_sch.h>
27#include <sch_screen.h>
28#include <sch_sheet.h>
29#include <schematic.h>
30#include <string_utils.h>
31#include <reporter.h>
33#include <wx/log.h>
34#include <wx/stdstream.h>
35#include <wx/zipstrm.h>
36
37#include <json_common.h>
38#include <core/map_helpers.h>
39#include <wx/wfstream.h>
40
41
42static bool FindSchFileInStream( const wxString& aName, wxInputStream& aStream,
43 nlohmann::json& aOut, EASYEDA::DOCUMENT& aDoc,
44 EASYEDA::DOC_TYPE& aDocType )
45{
46 if( aName.Lower().EndsWith( wxS( ".json" ) ) )
47 {
48 wxStdInputStream sin( aStream );
49 nlohmann::json js = nlohmann::json::parse( sin, nullptr, false );
50
51 if( js.is_discarded() )
52 return false;
53
55
58
59 if( doc.docType )
60 type = *doc.docType;
61 else
62 type = doc.head.docType;
63
65 || type == EASYEDA::DOC_TYPE::SYMBOL )
66 {
67 aOut = js;
68 aDoc = doc;
69 aDocType = type;
70 return true;
71 }
72 }
73 else if( aName.Lower().EndsWith( wxS( ".zip" ) ) )
74 {
75 std::shared_ptr<wxZipEntry> entry;
76 wxZipInputStream zip( aStream );
77
78 if( !zip.IsOk() )
79 return false;
80
81 while( entry.reset( zip.GetNextEntry() ), entry.get() != NULL )
82 {
83 wxString name = entry->GetName();
84
85 if( FindSchFileInStream( name, zip, aOut, aDoc, aDocType ) )
86 return true;
87 }
88 }
89
90 return false;
91}
92
93
94// A document that is a lone sheet carries its shapes itself, so present it as a one sheet list
95static std::vector<EASYEDA::DOCUMENT> SheetsOf( const nlohmann::json& aJson )
96{
98
99 if( schDoc.schematics )
100 return *schDoc.schematics;
101
102 EASYEDA::DOCUMENT sheet;
104 sheet.dataStr = aJson;
105
106 return { sheet };
107}
108
109
110bool SCH_IO_EASYEDA::CanReadSchematicFile( const wxString& aFileName ) const
111{
112 if( !SCH_IO::CanReadSchematicFile( aFileName ) )
113 return false;
114
115 try
116 {
117 wxFFileInputStream in( aFileName );
118 nlohmann::json js;
120 EASYEDA::DOC_TYPE docType;
121
122 return FindSchFileInStream( aFileName, in, js, doc, docType );
123 }
124 catch( nlohmann::json::exception& )
125 {
126 }
127 catch( std::exception& )
128 {
129 }
130
131 return false;
132}
133
134
135bool SCH_IO_EASYEDA::CanReadLibrary( const wxString& aFileName ) const
136{
137 return CanReadSchematicFile( aFileName );
138}
139
140
142{
143 return 0;
144}
145
146
147LIB_SYMBOL* loadSymbol( const wxString& aLibraryPath, nlohmann::json aFileData,
148 const wxString& aAliasName, const std::map<std::string, UTF8>* aProperties,
149 REPORTER* aReporter )
150{
151 SCH_EASYEDA_PARSER parser( nullptr, nullptr, aReporter );
152 std::map<wxString, int> namesCounter;
153
154 try
155 {
156 wxFFileInputStream in( aLibraryPath );
157 nlohmann::json js;
158 EASYEDA::DOCUMENT topDoc;
159 EASYEDA::DOC_TYPE topDocType;
160
161 if( !FindSchFileInStream( aLibraryPath, in, js, topDoc, topDocType ) )
162 THROW_IO_ERRORF( _( "Unable to find a valid schematic file in '%s'" ), aLibraryPath );
163
164 if( topDocType == EASYEDA::DOC_TYPE::SCHEMATIC_SHEET
165 || topDocType == EASYEDA::DOC_TYPE::SCHEMATIC_LIST )
166 {
167 for( const EASYEDA::DOCUMENT& subDoc : SheetsOf( js ) )
168 {
169 if( subDoc.docType )
170 {
171 if( *subDoc.docType != EASYEDA::DOC_TYPE::SCHEMATIC_SHEET )
172 continue;
173 }
174 else
175 {
176 if( subDoc.head.docType != EASYEDA::DOC_TYPE::SCHEMATIC_SHEET )
177 continue;
178 }
179
180 EASYEDA::DOCUMENT dataStrDoc = subDoc.dataStr->get<EASYEDA::DOCUMENT>();
181
182 for( wxString shap : dataStrDoc.shape )
183 {
184 if( !shap.Contains( wxS( "LIB" ) ) )
185 continue;
186
187 shap.Replace( wxS( "#@$" ), wxS( "\n" ) );
188 wxArrayString parts = wxSplit( shap, '\n', '\0' );
189
190 if( parts.size() < 1 )
191 continue;
192
193 wxArrayString paramsRoot = wxSplit( parts[0], '~', '\0' );
194
195 if( paramsRoot.size() < 1 )
196 continue;
197
198 wxString rootType = paramsRoot[0];
199
200 if( rootType == wxS( "LIB" ) )
201 {
202 if( paramsRoot.size() < 4 )
203 continue;
204
205 VECTOR2D origin( parser.Convert( paramsRoot[1] ),
206 parser.Convert( paramsRoot[2] ) );
207
208 wxString symbolName = wxString::Format( wxS( "Unknown_%s_%s" ),
209 paramsRoot[1], paramsRoot[2] );
210
211 wxArrayString paramParts = wxSplit( paramsRoot[3], '`', '\0' );
212
213 std::map<wxString, wxString> paramMap;
214
215 for( size_t i = 1; i < paramParts.size(); i += 2 )
216 {
217 wxString key = paramParts[i - 1];
218 wxString value = paramParts[i];
219
220 if( key == wxS( "spiceSymbolName" ) && !value.IsEmpty() )
221 symbolName = value;
222
223 paramMap[key] = value;
224 }
225
226 int& serial = namesCounter[symbolName];
227
228 if( serial > 0 )
229 symbolName << wxS( "_" ) << serial;
230
231 serial++;
232
233 paramMap[wxS( "spiceSymbolName" )] = symbolName;
234
235 if( symbolName == aAliasName )
236 {
237 parts.RemoveAt( 0 );
238
239 LIB_SYMBOL* ksymbol = parser.ParseSymbol( origin, paramMap, parts );
240
241 // Clear reference numbers
242 SCH_FIELD& refField = ksymbol->GetReferenceField();
243 wxString origRef = refField.GetText();
244 wxString reference;
245
246 for( size_t i = 0; i < origRef.size() && !wxIsdigit( origRef[i] ); i++ )
247 reference << origRef[i];
248
249 refField.SetText( reference );
250
251 return ksymbol;
252 }
253 }
254 }
255 }
256 }
257 else if( topDocType == EASYEDA::DOC_TYPE::SYMBOL )
258 {
260
261 wxString symbolName = wxS( "Unknown" );
262
263 std::optional<std::map<wxString, wxString>> c_para;
264
265 if( symDoc.c_para )
266 c_para = symDoc.c_para;
267 else if( topDoc.head.c_para )
268 c_para = topDoc.head.c_para;
269
270 if( !c_para )
271 return nullptr;
272
273 symbolName = get_def( *c_para, wxS( "name" ), symbolName );
274
275 int& serial = namesCounter[symbolName];
276
277 if( serial > 0 )
278 symbolName << wxS( "_" ) << serial;
279
280 serial++;
281
282 if( symbolName != aAliasName )
283 return nullptr;
284
285 VECTOR2D origin( topDoc.head.x, topDoc.head.y );
286
287 LIB_SYMBOL* ksymbol = parser.ParseSymbol( origin, *c_para, topDoc.shape );
288
289 // Clear reference numbers
290 SCH_FIELD& refField = ksymbol->GetReferenceField();
291 wxString origRef = refField.GetText();
292 wxString reference;
293
294 for( size_t i = 0; i < origRef.size() && !wxIsdigit( origRef[i] ); i++ )
295 reference << origRef[i];
296
297 refField.SetText( reference );
298
299 return ksymbol;
300 }
301 }
302 catch( nlohmann::json::exception& e )
303 {
304 THROW_IO_ERRORF( _( "Error loading symbol '%s' from library '%s': %s" ),
305 aAliasName,
306 aLibraryPath,
307 e.what() );
308 }
309 catch( std::exception& e )
310 {
311 THROW_IO_ERRORF( _( "Error loading symbol '%s' from library '%s': %s" ),
312 aAliasName,
313 aLibraryPath,
314 e.what() );
315 }
316
317 return nullptr;
318}
319
320
321void SCH_IO_EASYEDA::EnumerateSymbolLib( wxArrayString& aSymbolNameList,
322 const wxString& aLibraryPath,
323 const std::map<std::string, UTF8>* aProperties )
324{
325 std::map<wxString, int> namesCounter;
326
327 // Suppress font substitution warnings (RAII - automatically restored on scope exit)
328 FONTCONFIG_REPORTER_SCOPE fontconfigScope( nullptr );
329
330 try
331 {
332 wxFFileInputStream in( aLibraryPath );
333 nlohmann::json js;
334 EASYEDA::DOCUMENT topDoc;
335 EASYEDA::DOC_TYPE topDocType;
336
337 if( !FindSchFileInStream( aLibraryPath, in, js, topDoc, topDocType ) )
338 THROW_IO_ERRORF( _( "Unable to find a valid schematic file in '%s'" ), aLibraryPath );
339
340 if( topDocType == EASYEDA::DOC_TYPE::SCHEMATIC_SHEET
341 || topDocType == EASYEDA::DOC_TYPE::SCHEMATIC_LIST )
342 {
343 for( const EASYEDA::DOCUMENT& subDoc : SheetsOf( js ) )
344 {
345 if( subDoc.docType )
346 {
347 if( *subDoc.docType != EASYEDA::DOC_TYPE::SCHEMATIC_SHEET )
348 continue;
349 }
350 else
351 {
352 if( subDoc.head.docType != EASYEDA::DOC_TYPE::SCHEMATIC_SHEET )
353 continue;
354 }
355
356 EASYEDA::DOCUMENT dataStrDoc = subDoc.dataStr->get<EASYEDA::DOCUMENT>();
357
358 for( wxString shap : dataStrDoc.shape )
359 {
360 if( !shap.Contains( wxS( "LIB" ) ) )
361 continue;
362
363 shap.Replace( wxS( "#@$" ), wxS( "\n" ) );
364 wxArrayString parts = wxSplit( shap, '\n', '\0' );
365
366 if( parts.size() < 1 )
367 continue;
368
369 wxArrayString paramsRoot = wxSplit( parts[0], '~', '\0' );
370
371 if( paramsRoot.size() < 1 )
372 continue;
373
374 wxString rootType = paramsRoot[0];
375
376 if( rootType == wxS( "LIB" ) )
377 {
378 if( paramsRoot.size() < 4 )
379 continue;
380
381 wxString symbolName = wxString::Format( wxS( "Unknown_%s_%s" ),
382 paramsRoot[1], paramsRoot[2] );
383
384 wxArrayString paramParts = wxSplit( paramsRoot[3], '`', '\0' );
385
386 std::map<wxString, wxString> paramMap;
387
388 for( size_t i = 1; i < paramParts.size(); i += 2 )
389 {
390 wxString key = paramParts[i - 1];
391 wxString value = paramParts[i];
392
393 if( key == wxS( "spiceSymbolName" ) && !value.IsEmpty() )
394 symbolName = value;
395
396 paramMap[key] = value;
397 }
398
399 int& serial = namesCounter[symbolName];
400
401 if( serial > 0 )
402 symbolName << wxS( "_" ) << serial;
403
404 serial++;
405
406 aSymbolNameList.Add( symbolName );
407 }
408 }
409 }
410 }
411 else if( topDocType == EASYEDA::DOC_TYPE::SYMBOL )
412 {
414
415 wxString packageName = wxS( "Unknown" );
416
417 if( symDoc.c_para )
418 {
419 packageName = get_def( *symDoc.c_para, wxS( "name" ), packageName );
420 }
421 else if( topDoc.head.c_para )
422 {
423 packageName = get_def( *topDoc.head.c_para, wxS( "name" ), packageName );
424 }
425
426 aSymbolNameList.Add( packageName );
427 }
428 }
429 catch( nlohmann::json::exception& e )
430 {
431 THROW_IO_ERRORF( _( "Error enumerating symbol library '%s': %s" ), aLibraryPath, e.what() );
432 }
433 catch( std::exception& e )
434 {
435 THROW_IO_ERRORF( _( "Error enumerating symbol library '%s': %s" ), aLibraryPath, e.what() );
436 }
437}
438
439
440void SCH_IO_EASYEDA::EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& aSymbolList,
441 const wxString& aLibraryPath,
442 const std::map<std::string, UTF8>* aProperties )
443{
444 wxFFileInputStream in( aLibraryPath );
445 nlohmann::json js;
446 EASYEDA::DOCUMENT topDoc;
447 EASYEDA::DOC_TYPE topDocType;
448
449 if( !FindSchFileInStream( aLibraryPath, in, js, topDoc, topDocType ) )
450 THROW_IO_ERRORF( _( "Unable to find a valid schematic file in '%s'" ), aLibraryPath );
451
452 try
453 {
454 wxArrayString symbolNameList;
455
456 EnumerateSymbolLib( symbolNameList, aLibraryPath, aProperties );
457
458 for( const wxString& symbolName : symbolNameList )
459 {
460 LIB_SYMBOL* sym = loadSymbol( aLibraryPath, js, symbolName, aProperties, m_reporter );
461
462 if( sym )
463 aSymbolList.push_back( sym );
464 }
465 }
466 catch( nlohmann::json::exception& e )
467 {
468 THROW_IO_ERRORF( _( "Error enumerating symbol library '%s': %s" ), aLibraryPath, e.what() );
469 }
470 catch( std::exception& e )
471 {
472 THROW_IO_ERRORF( _( "Error enumerating symbol library '%s': %s" ), aLibraryPath, e.what() );
473 }
474}
475
476
477LIB_SYMBOL* SCH_IO_EASYEDA::LoadSymbol( const wxString& aLibraryPath,
478 const wxString& aAliasName,
479 const std::map<std::string, UTF8>* aProperties )
480{
481 try
482 {
483 wxFFileInputStream in( aLibraryPath );
484 nlohmann::json js;
485 EASYEDA::DOCUMENT topDoc;
486 EASYEDA::DOC_TYPE topDocType;
487
488 if( !FindSchFileInStream( aLibraryPath, in, js, topDoc, topDocType ) )
489 THROW_IO_ERRORF( _( "Unable to find a valid schematic file in '%s'" ), aLibraryPath );
490
491 return loadSymbol( aLibraryPath, js, aAliasName, aProperties, m_reporter );
492 }
493 catch( nlohmann::json::exception& e )
494 {
495 THROW_IO_ERRORF( _( "Error loading symbol '%s' from library '%s': %s" ), aAliasName, aLibraryPath, e.what() );
496 }
497 catch( std::exception& e )
498 {
499 THROW_IO_ERRORF( _( "Error loading symbol '%s' from library '%s': %s" ), aAliasName, aLibraryPath, e.what() );
500 }
501}
502
503
504static void LoadSchematic( SCHEMATIC* aSchematic, SCH_SHEET* aRootSheet, const wxString& aFileName,
505 REPORTER* aReporter )
506{
507 SCH_EASYEDA_PARSER parser( nullptr, nullptr, aReporter );
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 THROW_IO_ERRORF( _( "Unable to find a valid schematic file in '%s'" ), aFileName );
518
520 {
521 int pageNum = 1;
523
524 // a single sheet document carries its shapes itself rather than in a sheet list
525 if( !schDoc.schematics )
526 {
527 parser.ParseSchematic( aSchematic, aRootSheet, aFileName, topDoc.shape );
528 return;
529 }
530
531 for( const EASYEDA::DOCUMENT& subDoc : *schDoc.schematics )
532 {
533 if( subDoc.docType )
534 {
536 continue;
537 }
538 else
539 {
541 continue;
542 }
543
544 EASYEDA::DOCUMENT dataStrDoc = subDoc.dataStr->get<EASYEDA::DOCUMENT>();
545
546 if( schDoc.schematics->size() > 1 )
547 {
548 wxString sheetTitle = !subDoc.title.empty() ? subDoc.title : ( wxString() << pageNum );
549
550 wxString sheetBaseName = EscapeString( sheetTitle, CTX_FILENAME );
551
552 wxFileName sheetFname( aFileName );
553 sheetFname.SetFullName( sheetBaseName + wxS( "." )
554 + wxString::FromUTF8( FILEEXT::KiCadSchematicFileExtension ) );
555
556 wxFileName relSheetPath( sheetFname );
557 relSheetPath.MakeRelativeTo( 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 ) ) * ( pageNum - 1 );
572
573 subSheet->SetPosition( pos );
574
575 SCH_SHEET_PATH sheetPath;
576 sheetPath.push_back( aRootSheet );
577 sheetPath.push_back( subSheet.get() );
578 sheetPath.SetPageNumber( wxString() << pageNum );
579 aSchematic->SetCurrentSheet( sheetPath );
580
581 parser.ParseSchematic( aSchematic, subSheet.get(), aFileName, dataStrDoc.shape );
582
583 aRootSheet->GetScreen()->Append( subSheet.release() );
584 }
585 else
586 {
587 parser.ParseSchematic( aSchematic, aRootSheet, aFileName, dataStrDoc.shape );
588 }
589
590 pageNum++;
591 }
592 }
593 }
594 catch( nlohmann::json::exception& e )
595 {
596 THROW_IO_ERRORF( _( "Error loading schematic '%s': %s" ), aFileName, e.what() );
597 }
598 catch( std::exception& e )
599 {
600 THROW_IO_ERRORF( _( "Error loading schematic '%s': %s" ), aFileName, e.what() );
601 }
602}
603
604
605SCH_SHEET* SCH_IO_EASYEDA::LoadSchematicFile( const wxString& aFileName, SCHEMATIC* aSchematic,
606 SCH_SHEET* aAppendToMe,
607 const std::map<std::string, UTF8>* aProperties )
608{
609 wxCHECK( !aFileName.IsEmpty() && aSchematic, nullptr );
610
611 // Collect the font substitution warnings (RAII - automatically reset on scope exit)
613
614 SCH_SHEET* rootSheet = nullptr;
615
616 if( aAppendToMe )
617 {
618 wxCHECK_MSG( aSchematic->IsValid(), nullptr,
619 wxS( "Can't append to a schematic with no root!" ) );
620
621 rootSheet = aAppendToMe;
622 }
623 else
624 {
625 rootSheet = new SCH_SHEET( aSchematic );
626 rootSheet->SetFileName( aFileName );
627 aSchematic->SetTopLevelSheets( { rootSheet } );
628 }
629
630 if( !rootSheet->GetScreen() )
631 {
632 SCH_SCREEN* screen = new SCH_SCREEN( aSchematic );
633
634 screen->SetFileName( aFileName );
635 rootSheet->SetScreen( screen );
636
637 // Virtual root sheet UUID must be the same as the schematic file UUID.
638 rootSheet->SyncUuidToScreen();
639 }
640
641 LoadSchematic( aSchematic, rootSheet, aFileName, m_reporter );
643
644 return rootSheet;
645}
const char * name
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:130
void SetPageNumber(const wxString &aPageNumber)
Definition base_screen.h:75
static double Convert(const wxString &aValue)
RAII class to set and restore the fontconfig reporter.
Definition reporter.h:385
REPORTER * m_reporter
Reporter to log errors/warnings to, may be nullptr.
Definition io_base.h:264
Define a library symbol object.
Definition lib_symbol.h:114
SCH_FIELD & GetReferenceField()
Definition lib_symbol.h:453
static LOAD_INFO_REPORTER & GetInstance()
Definition reporter.cpp:351
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
Holds all the data relating to one schematic.
Definition schematic.h:155
void SetCurrentSheet(const SCH_SHEET_PATH &aPath)
Definition schematic.h:404
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
Definition schematic.h:384
void SetTopLevelSheets(const std::vector< SCH_SHEET * > &aSheets)
Replace the top level sheets, rebuilding the hierarchy and connectivity around them.
SCH_SHEET_PATH & CurrentSheet() const
Definition schematic.h:399
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)
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:139
void SetText(const wxString &aText) override
bool CanReadLibrary(const wxString &aFileName) const override
Checks if this IO object can read the specified library file/directory.
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,...
int GetModifyHash() const override
Return the modification hash from the library cache.
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 CanReadSchematicFile(const wxString &aFileName) const override
Checks if this SCH_IO can read the specified schematic file.
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...
virtual bool CanReadSchematicFile(const wxString &aFileName) const
Checks if this SCH_IO can read the specified schematic file.
Definition sch_io.cpp:47
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
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:50
void SetFileName(const wxString &aFilename)
Definition sch_sheet.h:434
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition sch_sheet.h:428
void SyncUuidToScreen()
Take the identity of the screen this sheet owns.
SCH_SCREEN * GetScreen() const
Definition sch_sheet.h:187
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
#define _(s)
#define THROW_IO_ERRORF(msg,...)
static const std::string KiCadSchematicFileExtension
wxString get_def(const std::map< wxString, wxString > &aMap, const char *aKey, const char *aDefval="")
Definition map_helpers.h:60
bool UnwrapDataStr(nlohmann::json &aJson)
Replace a document the EasyEDA server wraps in a metadata envelope with the document it carries.
static void LoadSchematic(SCHEMATIC *aSchematic, SCH_SHEET *aRootSheet, const wxString &aFileName, REPORTER *aReporter)
LIB_SYMBOL * loadSymbol(const wxString &aLibraryPath, nlohmann::json aFileData, const wxString &aAliasName, const std::map< std::string, UTF8 > *aProperties, REPORTER *aReporter)
static std::vector< EASYEDA::DOCUMENT > SheetsOf(const nlohmann::json &aJson)
static bool FindSchFileInStream(const wxString &aName, wxInputStream &aStream, nlohmann::json &aOut, EASYEDA::DOCUMENT &aDoc, EASYEDA::DOC_TYPE &aDocType)
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
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
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707
Definition of file extensions used in Kicad.