KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_io_easyedapro.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
22#include "sch_io_easyedapro.h"
23
24#include <font/fontconfig.h>
25#include <reporter.h>
26#include <schematic.h>
27#include <sch_sheet.h>
28#include <sch_screen.h>
30
31#include <fstream>
32#include <wx/txtstrm.h>
33#include <wx/wfstream.h>
34#include <wx/mstream.h>
35#include <wx/zipstrm.h>
36#include <wx/fs_zip.h>
37#include <wx/log.h>
38
39#include <json_common.h>
40#include <string_utils.h>
43#include <core/map_helpers.h>
44
45
47{
48 std::map<wxString, EASYEDAPRO::SYM_INFO> m_Symbols;
49 std::map<wxString, EASYEDAPRO::BLOB> m_Blobs;
50};
51
52
53SCH_IO_EASYEDAPRO::SCH_IO_EASYEDAPRO() : SCH_IO( wxS( "EasyEDA Pro (JLCEDA) Schematic" ) )
54{
55}
56
57
63
64
65bool SCH_IO_EASYEDAPRO::CanReadSchematicFile( const wxString& aFileName ) const
66{
67 if( aFileName.Lower().EndsWith( wxS( ".epro" ) ) )
68 {
69 return true;
70 }
71 else if( aFileName.Lower().EndsWith( wxS( ".zip" ) ) )
72 {
73 std::shared_ptr<wxZipEntry> entry;
74 wxFFileInputStream in( aFileName );
75 wxZipInputStream zip( in );
76
77 if( !zip.IsOk() )
78 return false;
79
80 while( entry.reset( zip.GetNextEntry() ), entry.get() != NULL )
81 {
82 wxString name = entry->GetName();
83
84 if( name == wxS( "project.json" ) )
85 return true;
86 }
87
88 return false;
89 }
90
91 return false;
92}
93
94
96{
97 return 0;
98}
99
100
101static LIB_SYMBOL* loadSymbol( nlohmann::json project, const wxString& aLibraryPath,
102 const wxString& aAliasName, const std::map<std::string, UTF8>* aProperties )
103{
104 SCH_EASYEDAPRO_PARSER parser( nullptr, nullptr );
105 LIB_SYMBOL* symbol = nullptr;
106 wxFileName libFname( aLibraryPath );
107 wxString symLibName = LIB_ID::FixIllegalChars( libFname.GetName(), true );
108
109 /*if( libFname.GetExt() == wxS( "esym" ) )
110 {
111 wxFFileInputStream ffis( aLibraryPath );
112 wxTextInputStream txt( ffis, wxS( " " ), wxConvUTF8 );
113
114 bool loadThis = false;
115 std::vector<nlohmann::json> lines;
116 while( ffis.CanRead() )
117 {
118 nlohmann::json js = nlohmann::json::parse( txt.ReadLine() );
119 lines.emplace_back( js );
120
121 if( js.at( 0 ) == "ATTR" && js.at( 3 ) == "Symbol" )
122 {
123 if( js.at( 4 ).get<wxString>() == aAliasName )
124 {
125 loadThis = true;
126 }
127 }
128 }
129
130 if( loadThis )
131 {
132 EASYEDAPRO::SYM_INFO symInfo = parser.ParseSymbol( lines );
133 return symInfo.libSymbol.release();
134 }
135 }
136 else */
137 if( libFname.GetExt() == wxS( "elibz" ) || libFname.GetExt() == wxS( "epro" )
138 || libFname.GetExt() == wxS( "zip" ) )
139 {
140 std::map<wxString, EASYEDAPRO::PRJ_SYMBOL> prjSymbols = project.at( "symbols" );
141 std::map<wxString, EASYEDAPRO::PRJ_FOOTPRINT> prjFootprints;
142 std::map<wxString, EASYEDAPRO::PRJ_DEVICE> prjDevices;
143
144 if( project.contains( "footprints" ) )
145 prjFootprints = project.at( "footprints" );
146
147 if( project.contains( "devices" ) )
148 prjDevices = project.at( "devices" );
149
150 auto prjSymIt = std::find_if( prjSymbols.begin(), prjSymbols.end(),
151 [&]( const auto& pair )
152 {
153 return pair.second.title == aAliasName;
154 } );
155
156 if( prjSymIt == prjSymbols.end() )
157 return nullptr;
158
159 wxString prjSymUuid = prjSymIt->first;
160
161 wxString description;
162 wxString customTags;
163 std::map<wxString, wxString> deviceAttributes;
164 wxString fpTitle;
165
166 for( auto& [key, device] : prjDevices )
167 {
168 auto val = get_opt( device.attributes, "Symbol" );
169
170 if( val && *val == prjSymUuid )
171 {
172 description = device.description;
173 deviceAttributes = device.attributes;
174
175 if( device.custom_tags.is_string() )
176 customTags = device.custom_tags.get<wxString>();
177
178 if( auto fpUuid = get_opt( device.attributes, "Footprint" ) )
179 {
180 if( auto prjFp = get_opt( prjFootprints, *fpUuid ) )
181 {
182 fpTitle = prjFp->title;
183 break;
184 }
185 }
186 }
187 }
188
189 auto cb = [&]( const wxString& name, const wxString& symUuid, wxInputStream& zip ) -> bool
190 {
191 if( !name.EndsWith( wxS( ".esym" ) ) )
193
194 if( symUuid != prjSymUuid )
196
197 wxTextInputStream txt( zip, wxS( " " ), wxConvUTF8 );
198
199 std::vector<nlohmann::json> lines;
200 while( zip.CanRead() )
201 {
202 nlohmann::json js = nlohmann::json::parse( txt.ReadLine() );
203 lines.emplace_back( js );
204 }
205
206 EASYEDAPRO::SYM_INFO symInfo = parser.ParseSymbol( lines, deviceAttributes );
207
208 if( !symInfo.libSymbol )
210
211 LIB_ID libID = EASYEDAPRO::ToKiCadLibID( symLibName, aAliasName );
212 symInfo.libSymbol->SetLibId( libID );
213 symInfo.libSymbol->SetName( aAliasName );
214 symInfo.libSymbol->GetFootprintField().SetText( symLibName + wxS( ":" ) + fpTitle );
215
216 wxString keywords = customTags;
217 keywords.Replace( wxS( ":" ), wxS( " " ), true );
218
219 symInfo.libSymbol->SetKeyWords( keywords );
220
222
223 symbol = symInfo.libSymbol.release();
224
226 };
227 EASYEDAPRO::IterateZipFiles( aLibraryPath, cb );
228 }
229
230 return symbol;
231}
232
233
235{
236 std::vector<LIB_SYMBOL*> result;
237
238 result.reserve( m_importedLibSymbols.size() );
239
240 for( const std::unique_ptr<LIB_SYMBOL>& symbol : m_importedLibSymbols )
241 result.push_back( new LIB_SYMBOL( *symbol ) );
242
243 return result;
244}
245
246
247void SCH_IO_EASYEDAPRO::EnumerateSymbolLib( wxArrayString& aSymbolNameList,
248 const wxString& aLibraryPath,
249 const std::map<std::string, UTF8>* aProperties )
250{
251 wxFileName fname( aLibraryPath );
252
253 if( fname.GetExt() == wxS( "esym" ) )
254 {
255 wxFFileInputStream ffis( aLibraryPath );
256 wxTextInputStream txt( ffis, wxS( " " ), wxConvUTF8 );
257
258 while( ffis.CanRead() )
259 {
260 wxString line = txt.ReadLine();
261
262 if( !line.Contains( wxS( "ATTR" ) ) )
263 continue; // Don't bother parsing
264
265 nlohmann::json js = nlohmann::json::parse( line );
266 if( js.at( 0 ) == "ATTR" && js.at( 3 ) == "Symbol" )
267 {
268 aSymbolNameList.Add( js.at( 4 ).get<wxString>() );
269 }
270 }
271 }
272 else if( fname.GetExt() == wxS( "elibz" ) || fname.GetExt() == wxS( "epro" )
273 || fname.GetExt() == wxS( "zip" ) )
274 {
275 nlohmann::json project = EASYEDAPRO::ReadProjectOrDeviceFile( aLibraryPath );
276 std::map<wxString, nlohmann::json> symbolMap = project.at( "symbols" );
277
278 for( auto& [key, value] : symbolMap )
279 {
280 wxString title;
281
282 if( value.contains( "display_title" ) )
283 title = value.at( "display_title" ).get<wxString>();
284 else
285 title = value.at( "title" ).get<wxString>();
286
287 aSymbolNameList.Add( title );
288 }
289 }
290}
291
292
293void SCH_IO_EASYEDAPRO::EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& aSymbolList,
294 const wxString& aLibraryPath,
295 const std::map<std::string, UTF8>* aProperties )
296{
297 wxFileName libFname( aLibraryPath );
298 wxArrayString symbolNameList;
299 nlohmann::json project;
300
301 EnumerateSymbolLib( symbolNameList, aLibraryPath, aProperties );
302
303 if( libFname.GetExt() == wxS( "elibz" ) || libFname.GetExt() == wxS( "epro" )
304 || libFname.GetExt() == wxS( "zip" ) )
305 {
307 }
308
309 for( const wxString& symbolName : symbolNameList )
310 {
311 LIB_SYMBOL* sym = loadSymbol( project, aLibraryPath, symbolName, aProperties );
312
313 if( sym )
314 aSymbolList.push_back( sym );
315 }
316}
317
318
319void SCH_IO_EASYEDAPRO::LoadAllDataFromProject( const wxString& aProjectPath )
320{
321 if( m_projectData )
322 delete m_projectData;
323
325
326 SCH_EASYEDAPRO_PARSER parser( nullptr, nullptr );
327 wxFileName fname( aProjectPath );
328 wxString symLibName = EASYEDAPRO::ShortenLibName( fname.GetName() );
329
330 if( fname.GetExt() != wxS( "epro" ) && fname.GetExt() != wxS( "zip" ) )
331 return;
332
333 nlohmann::json project = EASYEDAPRO::ReadProjectOrDeviceFile( aProjectPath );
334
335 std::map<wxString, EASYEDAPRO::PRJ_SYMBOL> prjSymbols = project.at( "symbols" );
336 std::map<wxString, EASYEDAPRO::PRJ_FOOTPRINT> prjFootprints = project.at( "footprints" );
337 std::map<wxString, EASYEDAPRO::PRJ_DEVICE> prjDevices = project.at( "devices" );
338
339 auto cb = [&]( const wxString& name, const wxString& baseName, wxInputStream& zip ) -> bool
340 {
341 if( !name.EndsWith( wxS( ".esym" ) ) && !name.EndsWith( wxS( ".eblob" ) ) )
343
344 std::vector<nlohmann::json> lines = EASYEDAPRO::ParseJsonLines( zip, name );
345
346 if( name.EndsWith( wxS( ".esym" ) ) )
347 {
348 wxString description;
349 wxString customTags;
350 std::map<wxString, wxString> deviceAttributes;
351 wxString fpTitle;
352
353 for( auto& [key, device] : prjDevices )
354 {
355 auto val = get_opt( device.attributes, "Symbol" );
356
357 if( val && *val == baseName )
358 {
359 description = device.description;
360 deviceAttributes = device.attributes;
361
362 if( device.custom_tags.is_string() )
363 customTags = device.custom_tags.get<wxString>();
364
365 if( auto fpUuid = get_opt( device.attributes, "Footprint" ) )
366 {
367 if( auto prjFp = get_opt( prjFootprints, *fpUuid ) )
368 {
369 fpTitle = prjFp->title;
370 break;
371 }
372 }
373 }
374 }
375
376 EASYEDAPRO::PRJ_SYMBOL symData = prjSymbols.at( baseName );
377 EASYEDAPRO::SYM_INFO symInfo = parser.ParseSymbol( lines, deviceAttributes );
378
379 if( !symInfo.libSymbol )
381
382 LIB_ID libID = EASYEDAPRO::ToKiCadLibID( symLibName, symData.title );
383 symInfo.libSymbol->SetLibId( libID );
384 symInfo.libSymbol->SetName( symData.title );
385 symInfo.libSymbol->GetFootprintField().SetText( symLibName + wxS( ":" ) + fpTitle );
386
387 wxString keywords = customTags;
388 keywords.Replace( wxS( ":" ), wxS( " " ), true );
389
390 symInfo.libSymbol->SetKeyWords( keywords );
391
393
394 m_projectData->m_Symbols.emplace( baseName, std::move( symInfo ) );
395 }
396 else if( name.EndsWith( wxS( ".eblob" ) ) )
397 {
398 for( const nlohmann::json& line : lines )
399 {
400 if( line.at( 0 ) == "BLOB" )
401 {
402 EASYEDAPRO::BLOB blob = line;
403 m_projectData->m_Blobs[blob.objectId] = blob;
404 }
405 }
406 }
407
409 };
410 EASYEDAPRO::IterateZipFiles( aProjectPath, cb );
411}
412
413
414LIB_SYMBOL* SCH_IO_EASYEDAPRO::LoadSymbol( const wxString& aLibraryPath, const wxString& aAliasName,
415 const std::map<std::string, UTF8>* aProperties )
416{
417 wxFileName libFname( aLibraryPath );
418 nlohmann::json project;
419
420 if( libFname.GetExt() == wxS( "elibz" ) || libFname.GetExt() == wxS( "epro" )
421 || libFname.GetExt() == wxS( "zip" ) )
422 {
424 }
425
426 return loadSymbol( project, aLibraryPath, aAliasName, aProperties );
427}
428
429
431 SCHEMATIC* aSchematic, SCH_SHEET* aAppendToMe,
432 const std::map<std::string, UTF8>* aProperties )
433{
434 wxCHECK( !aFileName.IsEmpty() && aSchematic, nullptr );
435
436 // Collect the font substitution warnings (RAII - automatically reset on scope exit)
438
439 SCH_SHEET* rootSheet = nullptr;
440
441 if( aAppendToMe )
442 {
443 wxCHECK_MSG( aSchematic->IsValid(), nullptr,
444 wxS( "Can't append to a schematic with no root!" ) );
445
446 rootSheet = aAppendToMe;
447 }
448 else
449 {
450 rootSheet = new SCH_SHEET( aSchematic );
451 rootSheet->SetFileName( aFileName );
452 aSchematic->SetTopLevelSheets( { rootSheet } );
453 }
454
455 if( !rootSheet->GetScreen() )
456 {
457 SCH_SCREEN* screen = new SCH_SCREEN( aSchematic );
458
459 screen->SetFileName( aFileName );
460 rootSheet->SetScreen( screen );
461
462 // Virtual root sheet UUID must be the same as the schematic file UUID.
463 const_cast<KIID&>( rootSheet->m_Uuid ) = screen->GetUuid();
464 }
465
466 SCH_EASYEDAPRO_PARSER parser( nullptr, nullptr );
467 wxFileName fname( aFileName );
468 wxString libName = EASYEDAPRO::ShortenLibName( fname.GetName() );
469
470 if( fname.GetExt() != wxS( "epro" ) && fname.GetExt() != wxS( "zip" ) )
471 return rootSheet;
472
473 nlohmann::json project = EASYEDAPRO::ReadProjectOrDeviceFile( aFileName );
474
475 std::map<wxString, EASYEDAPRO::PRJ_SCHEMATIC> prjSchematics = project.at( "schematics" );
476
477 wxString schematicToLoad;
478
479 if( aProperties && aProperties->contains( "sch_id" ) )
480 {
481 schematicToLoad = wxString::FromUTF8( aProperties->at( "sch_id" ) );
482 }
483 else
484 {
485 if( prjSchematics.size() == 1 )
486 {
487 schematicToLoad = prjSchematics.begin()->first;
488 }
489 else if( m_choose_project_handler )
490 {
491 std::vector<IMPORT_PROJECT_DESC> chosen = m_choose_project_handler(
493
494 if( chosen.size() > 0 )
495 schematicToLoad = chosen[0].SchematicId;
496 }
497 else if( !prjSchematics.empty() )
498 {
499 // No chooser registered (headless), so take the first rather than throwing
500 schematicToLoad = prjSchematics.begin()->first;
501 }
502 }
503
504 if( schematicToLoad.empty() )
505 return nullptr;
506
507 wxString rootBaseName = EscapeString( prjSchematics[schematicToLoad].name, CTX_FILENAME );
508
509 wxFileName rootFname( aFileName );
510 rootFname.SetFullName( rootBaseName + wxS( "." )
511 + wxString::FromUTF8( FILEEXT::KiCadSchematicFileExtension ) );
512
513 rootSheet->SetName( prjSchematics[schematicToLoad].name );
514 rootSheet->SetFileName( rootFname.GetFullPath() );
515 rootSheet->GetScreen()->SetFileName( rootFname.GetFullPath() );
516
517 const std::vector<EASYEDAPRO::PRJ_SHEET>& prjSchematicSheets =
518 prjSchematics[schematicToLoad].sheets;
519
520 LoadAllDataFromProject( aFileName );
521
522 if( !m_projectData )
523 return nullptr;
524
525 const int schSheetsCount = prjSchematicSheets.size();
526
527 auto cbs = [&]( const wxString& name, const wxString& baseName, wxInputStream& zip ) -> bool
528 {
529 if( !name.EndsWith( wxS( ".esch" ) ) )
531
532 wxArrayString nameParts = wxSplit( name, '\\', '\0' );
533
534 if( nameParts.size() == 1 )
535 nameParts = wxSplit( name, '/', '\0' );
536
537 if( nameParts.size() < 3 )
539
540 wxString schematicUuid = nameParts[1];
541 wxString sheetFileName = nameParts[2];
542 wxString sheetId = sheetFileName.BeforeLast( '.' );
543 int sheetId_i;
544 sheetId.ToInt( &sheetId_i );
545
546 if( schematicUuid != schematicToLoad )
548
549 auto prjSheetIt = std::find_if( prjSchematicSheets.begin(), prjSchematicSheets.end(),
550 [&]( const EASYEDAPRO::PRJ_SHEET& s )
551 {
552 return s.id == sheetId_i;
553 } );
554
555 if( prjSheetIt == prjSchematicSheets.end() )
557
558 std::vector<nlohmann::json> lines = EASYEDAPRO::ParseJsonLines( zip, name );
559
560 if( schSheetsCount > 1 )
561 {
562 wxString sheetBaseName =
563 sheetId + wxS( "_" ) + EscapeString( prjSheetIt->name, CTX_FILENAME );
564
565 wxFileName sheetFname( aFileName );
566 sheetFname.SetFullName( sheetBaseName + wxS( "." )
567 + wxString::FromUTF8( FILEEXT::KiCadSchematicFileExtension ) );
568
569 wxFileName relSheetPath( sheetFname );
570 relSheetPath.MakeRelativeTo( rootFname.GetPath() );
571
572 std::unique_ptr<SCH_SHEET> subSheet = std::make_unique<SCH_SHEET>( aSchematic );
573 subSheet->SetFileName( relSheetPath.GetFullPath() );
574 subSheet->SetName( prjSheetIt->name );
575
576 SCH_SCREEN* screen = new SCH_SCREEN( aSchematic );
577 screen->SetFileName( sheetFname.GetFullPath() );
578 screen->SetPageNumber( sheetId );
579 subSheet->SetScreen( screen );
580
581 VECTOR2I pos;
582 pos.x = schIUScale.MilsToIU( 200 );
583 pos.y = schIUScale.MilsToIU( 200 )
584 + ( subSheet->GetSize().y + schIUScale.MilsToIU( 200 ) ) * ( sheetId_i - 1 );
585
586 subSheet->SetPosition( pos );
587
588 SCH_SHEET_PATH sheetPath;
589 sheetPath.push_back( rootSheet );
590 sheetPath.push_back( subSheet.get() );
591 sheetPath.SetPageNumber( sheetId );
592 aSchematic->SetCurrentSheet( sheetPath );
593
594 parser.ParseSchematic( aSchematic, subSheet.get(), project, m_projectData->m_Symbols,
595 m_projectData->m_Blobs, lines, libName );
596
597 rootSheet->GetScreen()->Append( subSheet.release() );
598 }
599 else
600 {
601 parser.ParseSchematic( aSchematic, rootSheet, project, m_projectData->m_Symbols,
602 m_projectData->m_Blobs, lines, libName );
603 }
604
606 };
607 EASYEDAPRO::IterateZipFiles( aFileName, cbs );
608
609 // Loading a schematic must not write to disk, so the project library is left to the reconciler
610 m_importedLibSymbols.clear();
611
612 for( auto& [symbolUuid, symInfo] : m_projectData->m_Symbols )
613 {
614 if( symInfo.libSymbol )
615 m_importedLibSymbols.emplace_back( std::move( symInfo.libSymbol ) );
616 }
617
619 aSchematic->FixupJunctionsAfterImport();
620
621 return rootSheet;
622}
const char * name
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:123
void SetPageNumber(const wxString &aPageNumber)
Definition base_screen.h:75
const KIID m_Uuid
Definition eda_item.h:531
RAII class to set and restore the fontconfig reporter.
Definition reporter.h:368
Definition kiid.h:46
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
static UTF8 FixIllegalChars(const UTF8 &aLibItemName, bool aLib)
Replace illegal LIB_ID item name characters with underscores '_'.
Definition lib_id.cpp:205
Define a library symbol object.
Definition lib_symbol.h:114
SCH_FIELD & GetFootprintField()
Return reference to the footprint field.
Definition lib_symbol.h:436
void SetDescription(const wxString &aDescription)
Gets the Description field text value *‍/.
void SetKeyWords(const wxString &aKeyWords)
void SetLibId(const LIB_ID &aLibId)
virtual void SetName(const wxString &aName)
static LOAD_INFO_REPORTER & GetInstance()
Definition reporter.cpp:306
CHOOSE_PROJECT_HANDLER m_choose_project_handler
Callback to choose projects to import.
Holds all the data relating to one schematic.
Definition schematic.h:90
void SetCurrentSheet(const SCH_SHEET_PATH &aPath)
Definition schematic.h:194
int FixupJunctionsAfterImport()
Add junctions to this schematic where required.
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
Definition schematic.h:174
void SetTopLevelSheets(const std::vector< SCH_SHEET * > &aSheets)
SCH_SHEET_PATH & CurrentSheet() const
Definition schematic.h:189
EASYEDAPRO::SYM_INFO ParseSymbol(const std::vector< nlohmann::json > &aLines, const std::map< wxString, wxString > &aDeviceAttributes)
void ParseSchematic(SCHEMATIC *aSchematic, SCH_SHEET *aRootSheet, const nlohmann::json &aProject, std::map< wxString, EASYEDAPRO::SYM_INFO > &aSymbolMap, const std::map< wxString, EASYEDAPRO::BLOB > &aBlobMap, const std::vector< nlohmann::json > &aLines, const wxString &aLibName)
void SetText(const wxString &aText) override
std::vector< LIB_SYMBOL * > GetImportedCachedLibrarySymbols() override
Return the canonical symbol definitions produced by the last LoadSchematicFile().
void LoadAllDataFromProject(const wxString &aLibraryPath)
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...
int GetModifyHash() const override
Return the modification hash from the library cache.
std::vector< std::unique_ptr< LIB_SYMBOL > > m_importedLibSymbols
Definitions from the last LoadSchematicFile, cloned out to the import reconciler on request.
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.
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,...
SCH_IO(const wxString &aName)
Definition sch_io.h:384
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
const KIID & GetUuid() const
Definition sch_screen.h:529
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:44
void SetFileName(const wxString &aFilename)
Definition sch_sheet.h:376
void SetName(const wxString &aName)
Definition sch_sheet.h:137
SCH_SCREEN * GetScreen() const
Definition sch_sheet.h:139
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
#define EASY_IT_BREAK
#define EASY_IT_CONTINUE
static const std::string KiCadSchematicFileExtension
std::optional< V > get_opt(const std::map< wxString, V > &aMap, const wxString &aKey)
Definition map_helpers.h:30
LIB_ID ToKiCadLibID(const wxString &aLibName, const wxString &aLibReference)
void IterateZipFiles(const wxString &aFileName, std::function< bool(const wxString &, const wxString &, wxInputStream &)> aCallback)
std::vector< nlohmann::json > ParseJsonLines(wxInputStream &aInput, const wxString &aSource)
wxString NormalizeEasyEDAText(wxString aText)
Replace EasyEDA temperature glyph (℃) with °C.
std::vector< IMPORT_PROJECT_DESC > ProjectToSelectorDialog(const nlohmann::json &aProject, bool aPcbOnly=false, bool aSchOnly=false)
nlohmann::json ReadProjectOrDeviceFile(const wxString &aZipFileName)
wxString ShortenLibName(wxString aProjectName)
LIB_SYMBOL * loadSymbol(const wxString &aLibraryPath, nlohmann::json aFileData, const wxString &aAliasName, const std::map< std::string, UTF8 > *aProperties)
static LIB_SYMBOL * loadSymbol(nlohmann::json project, const wxString &aLibraryPath, const wxString &aAliasName, const std::map< std::string, UTF8 > *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
std::unique_ptr< LIB_SYMBOL > libSymbol
std::map< wxString, EASYEDAPRO::BLOB > m_Blobs
std::map< wxString, EASYEDAPRO::SYM_INFO > m_Symbols
wxString result
Test unit parsing edge cases and error handling.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683
Definition of file extensions used in Kicad.