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>
44#include <core/map_helpers.h>
45#include <project_sch.h>
48
49
51{
52 std::map<wxString, EASYEDAPRO::SYM_INFO> m_Symbols;
53 std::map<wxString, EASYEDAPRO::BLOB> m_Blobs;
54};
55
56
57SCH_IO_EASYEDAPRO::SCH_IO_EASYEDAPRO() : SCH_IO( wxS( "EasyEDA Pro (JLCEDA) Schematic" ) )
58{
60}
61
62
68
69
70bool SCH_IO_EASYEDAPRO::CanReadSchematicFile( const wxString& aFileName ) const
71{
72 if( aFileName.Lower().EndsWith( wxS( ".epro" ) ) )
73 {
74 return true;
75 }
76 else if( aFileName.Lower().EndsWith( wxS( ".zip" ) ) )
77 {
78 std::shared_ptr<wxZipEntry> entry;
79 wxFFileInputStream in( aFileName );
80 wxZipInputStream zip( in );
81
82 if( !zip.IsOk() )
83 return false;
84
85 while( entry.reset( zip.GetNextEntry() ), entry.get() != NULL )
86 {
87 wxString name = entry->GetName();
88
89 if( name == wxS( "project.json" ) )
90 return true;
91 }
92
93 return false;
94 }
95
96 return false;
97}
98
99
101{
102 return 0;
103}
104
105
106static LIB_SYMBOL* loadSymbol( nlohmann::json project, const wxString& aLibraryPath,
107 const wxString& aAliasName, const std::map<std::string, UTF8>* aProperties )
108{
109 SCH_EASYEDAPRO_PARSER parser( nullptr, nullptr );
110 LIB_SYMBOL* symbol = nullptr;
111 wxFileName libFname( aLibraryPath );
112 wxString symLibName = LIB_ID::FixIllegalChars( libFname.GetName(), true );
113
114 /*if( libFname.GetExt() == wxS( "esym" ) )
115 {
116 wxFFileInputStream ffis( aLibraryPath );
117 wxTextInputStream txt( ffis, wxS( " " ), wxConvUTF8 );
118
119 bool loadThis = false;
120 std::vector<nlohmann::json> lines;
121 while( ffis.CanRead() )
122 {
123 nlohmann::json js = nlohmann::json::parse( txt.ReadLine() );
124 lines.emplace_back( js );
125
126 if( js.at( 0 ) == "ATTR" && js.at( 3 ) == "Symbol" )
127 {
128 if( js.at( 4 ).get<wxString>() == aAliasName )
129 {
130 loadThis = true;
131 }
132 }
133 }
134
135 if( loadThis )
136 {
137 EASYEDAPRO::SYM_INFO symInfo = parser.ParseSymbol( lines );
138 return symInfo.libSymbol.release();
139 }
140 }
141 else */
142 if( libFname.GetExt() == wxS( "elibz" ) || libFname.GetExt() == wxS( "epro" )
143 || libFname.GetExt() == wxS( "zip" ) )
144 {
145 std::map<wxString, EASYEDAPRO::PRJ_SYMBOL> prjSymbols = project.at( "symbols" );
146 std::map<wxString, EASYEDAPRO::PRJ_FOOTPRINT> prjFootprints;
147 std::map<wxString, EASYEDAPRO::PRJ_DEVICE> prjDevices;
148
149 if( project.contains( "footprints" ) )
150 prjFootprints = project.at( "footprints" );
151
152 if( project.contains( "devices" ) )
153 prjDevices = project.at( "devices" );
154
155 auto prjSymIt = std::find_if( prjSymbols.begin(), prjSymbols.end(),
156 [&]( const auto& pair )
157 {
158 return pair.second.title == aAliasName;
159 } );
160
161 if( prjSymIt == prjSymbols.end() )
162 return nullptr;
163
164 wxString prjSymUuid = prjSymIt->first;
165
166 wxString description;
167 wxString customTags;
168 std::map<wxString, wxString> deviceAttributes;
169 wxString fpTitle;
170
171 for( auto& [key, device] : prjDevices )
172 {
173 auto val = get_opt( device.attributes, "Symbol" );
174
175 if( val && *val == prjSymUuid )
176 {
177 description = device.description;
178 deviceAttributes = device.attributes;
179
180 if( device.custom_tags.is_string() )
181 customTags = device.custom_tags.get<wxString>();
182
183 if( auto fpUuid = get_opt( device.attributes, "Footprint" ) )
184 {
185 if( auto prjFp = get_opt( prjFootprints, *fpUuid ) )
186 {
187 fpTitle = prjFp->title;
188 break;
189 }
190 }
191 }
192 }
193
194 auto cb = [&]( const wxString& name, const wxString& symUuid, wxInputStream& zip ) -> bool
195 {
196 if( !name.EndsWith( wxS( ".esym" ) ) )
198
199 if( symUuid != prjSymUuid )
201
202 wxTextInputStream txt( zip, wxS( " " ), wxConvUTF8 );
203
204 std::vector<nlohmann::json> lines;
205 while( zip.CanRead() )
206 {
207 nlohmann::json js = nlohmann::json::parse( txt.ReadLine() );
208 lines.emplace_back( js );
209 }
210
211 EASYEDAPRO::SYM_INFO symInfo = parser.ParseSymbol( lines, deviceAttributes );
212
213 if( !symInfo.libSymbol )
215
216 LIB_ID libID = EASYEDAPRO::ToKiCadLibID( symLibName, aAliasName );
217 symInfo.libSymbol->SetLibId( libID );
218 symInfo.libSymbol->SetName( aAliasName );
219 symInfo.libSymbol->GetFootprintField().SetText( symLibName + wxS( ":" ) + fpTitle );
220
221 wxString keywords = customTags;
222 keywords.Replace( wxS( ":" ), wxS( " " ), true );
223
224 symInfo.libSymbol->SetKeyWords( keywords );
225
226 description.Replace( wxS( "\u2103" ), wxS( "\u00B0C" ), true ); // ℃ -> °C
227
228 symInfo.libSymbol->SetDescription( description );
229
230 symbol = symInfo.libSymbol.release();
231
233 };
234 EASYEDAPRO::IterateZipFiles( aLibraryPath, cb );
235 }
236
237 return symbol;
238}
239
240
241void SCH_IO_EASYEDAPRO::EnumerateSymbolLib( wxArrayString& aSymbolNameList,
242 const wxString& aLibraryPath,
243 const std::map<std::string, UTF8>* aProperties )
244{
245 wxFileName fname( aLibraryPath );
246
247 if( fname.GetExt() == wxS( "esym" ) )
248 {
249 wxFFileInputStream ffis( aLibraryPath );
250 wxTextInputStream txt( ffis, wxS( " " ), wxConvUTF8 );
251
252 while( ffis.CanRead() )
253 {
254 wxString line = txt.ReadLine();
255
256 if( !line.Contains( wxS( "ATTR" ) ) )
257 continue; // Don't bother parsing
258
259 nlohmann::json js = nlohmann::json::parse( line );
260 if( js.at( 0 ) == "ATTR" && js.at( 3 ) == "Symbol" )
261 {
262 aSymbolNameList.Add( js.at( 4 ).get<wxString>() );
263 }
264 }
265 }
266 else if( fname.GetExt() == wxS( "elibz" ) || fname.GetExt() == wxS( "epro" )
267 || fname.GetExt() == wxS( "zip" ) )
268 {
269 nlohmann::json project = EASYEDAPRO::ReadProjectOrDeviceFile( aLibraryPath );
270 std::map<wxString, nlohmann::json> symbolMap = project.at( "symbols" );
271
272 for( auto& [key, value] : symbolMap )
273 {
274 wxString title;
275
276 if( value.contains( "display_title" ) )
277 title = value.at( "display_title" ).get<wxString>();
278 else
279 title = value.at( "title" ).get<wxString>();
280
281 aSymbolNameList.Add( title );
282 }
283 }
284}
285
286
287void SCH_IO_EASYEDAPRO::EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& aSymbolList,
288 const wxString& aLibraryPath,
289 const std::map<std::string, UTF8>* aProperties )
290{
291 wxFileName libFname( aLibraryPath );
292 wxArrayString symbolNameList;
293 nlohmann::json project;
294
295 EnumerateSymbolLib( symbolNameList, aLibraryPath, aProperties );
296
297 if( libFname.GetExt() == wxS( "elibz" ) || libFname.GetExt() == wxS( "epro" )
298 || libFname.GetExt() == wxS( "zip" ) )
299 {
301 }
302
303 for( const wxString& symbolName : symbolNameList )
304 {
305 LIB_SYMBOL* sym = loadSymbol( project, aLibraryPath, symbolName, aProperties );
306
307 if( sym )
308 aSymbolList.push_back( sym );
309 }
310}
311
312
313void SCH_IO_EASYEDAPRO::LoadAllDataFromProject( const wxString& aProjectPath )
314{
315 if( m_projectData )
316 delete m_projectData;
317
319
320 SCH_EASYEDAPRO_PARSER parser( nullptr, nullptr );
321 wxFileName fname( aProjectPath );
322 wxString symLibName = EASYEDAPRO::ShortenLibName( fname.GetName() );
323
324 if( fname.GetExt() != wxS( "epro" ) && fname.GetExt() != wxS( "zip" ) )
325 return;
326
327 nlohmann::json project = EASYEDAPRO::ReadProjectOrDeviceFile( aProjectPath );
328
329 std::map<wxString, EASYEDAPRO::PRJ_SYMBOL> prjSymbols = project.at( "symbols" );
330 std::map<wxString, EASYEDAPRO::PRJ_FOOTPRINT> prjFootprints = project.at( "footprints" );
331 std::map<wxString, EASYEDAPRO::PRJ_DEVICE> prjDevices = project.at( "devices" );
332
333 auto cb = [&]( const wxString& name, const wxString& baseName, wxInputStream& zip ) -> bool
334 {
335 if( !name.EndsWith( wxS( ".esym" ) ) && !name.EndsWith( wxS( ".eblob" ) ) )
337
338 std::vector<nlohmann::json> lines = EASYEDAPRO::ParseJsonLines( zip, name );
339
340 if( name.EndsWith( wxS( ".esym" ) ) )
341 {
342 wxString description;
343 wxString customTags;
344 std::map<wxString, wxString> deviceAttributes;
345 wxString fpTitle;
346
347 for( auto& [key, device] : prjDevices )
348 {
349 auto val = get_opt( device.attributes, "Symbol" );
350
351 if( val && *val == baseName )
352 {
353 description = device.description;
354 deviceAttributes = device.attributes;
355
356 if( device.custom_tags.is_string() )
357 customTags = device.custom_tags.get<wxString>();
358
359 if( auto fpUuid = get_opt( device.attributes, "Footprint" ) )
360 {
361 if( auto prjFp = get_opt( prjFootprints, *fpUuid ) )
362 {
363 fpTitle = prjFp->title;
364 break;
365 }
366 }
367 }
368 }
369
370 EASYEDAPRO::PRJ_SYMBOL symData = prjSymbols.at( baseName );
371 EASYEDAPRO::SYM_INFO symInfo = parser.ParseSymbol( lines, deviceAttributes );
372
373 if( !symInfo.libSymbol )
375
376 LIB_ID libID = EASYEDAPRO::ToKiCadLibID( symLibName, symData.title );
377 symInfo.libSymbol->SetLibId( libID );
378 symInfo.libSymbol->SetName( symData.title );
379 symInfo.libSymbol->GetFootprintField().SetText( symLibName + wxS( ":" ) + fpTitle );
380
381 wxString keywords = customTags;
382 keywords.Replace( wxS( ":" ), wxS( " " ), true );
383
384 symInfo.libSymbol->SetKeyWords( keywords );
385
386 description.Replace( wxS( "\u2103" ), wxS( "\u00B0C" ), true ); // ℃ -> °C
387
388 symInfo.libSymbol->SetDescription( description );
389
390 m_projectData->m_Symbols.emplace( baseName, std::move( symInfo ) );
391 }
392 else if( name.EndsWith( wxS( ".eblob" ) ) )
393 {
394 for( const nlohmann::json& line : lines )
395 {
396 if( line.at( 0 ) == "BLOB" )
397 {
398 EASYEDAPRO::BLOB blob = line;
399 m_projectData->m_Blobs[blob.objectId] = blob;
400 }
401 }
402 }
403
405 };
406 EASYEDAPRO::IterateZipFiles( aProjectPath, cb );
407}
408
409
410LIB_SYMBOL* SCH_IO_EASYEDAPRO::LoadSymbol( const wxString& aLibraryPath, const wxString& aAliasName,
411 const std::map<std::string, UTF8>* aProperties )
412{
413 wxFileName libFname( aLibraryPath );
414 nlohmann::json project;
415
416 if( libFname.GetExt() == wxS( "elibz" ) || libFname.GetExt() == wxS( "epro" )
417 || libFname.GetExt() == wxS( "zip" ) )
418 {
420 }
421
422 return loadSymbol( project, aLibraryPath, aAliasName, aProperties );
423}
424
425
427 SCHEMATIC* aSchematic, SCH_SHEET* aAppendToMe,
428 const std::map<std::string, UTF8>* aProperties )
429{
430 wxCHECK( !aFileName.IsEmpty() && aSchematic, nullptr );
431
432 // Collect the font substitution warnings (RAII - automatically reset on scope exit)
434
435 SCH_SHEET* rootSheet = nullptr;
436
437 if( aAppendToMe )
438 {
439 wxCHECK_MSG( aSchematic->IsValid(), nullptr,
440 wxS( "Can't append to a schematic with no root!" ) );
441
442 rootSheet = aAppendToMe;
443 }
444 else
445 {
446 rootSheet = new SCH_SHEET( aSchematic );
447 rootSheet->SetFileName( aFileName );
448 aSchematic->SetTopLevelSheets( { rootSheet } );
449 }
450
451 if( !rootSheet->GetScreen() )
452 {
453 SCH_SCREEN* screen = new SCH_SCREEN( aSchematic );
454
455 screen->SetFileName( aFileName );
456 rootSheet->SetScreen( screen );
457
458 // Virtual root sheet UUID must be the same as the schematic file UUID.
459 const_cast<KIID&>( rootSheet->m_Uuid ) = screen->GetUuid();
460 }
461
462 SCH_EASYEDAPRO_PARSER parser( nullptr, nullptr );
463 wxFileName fname( aFileName );
464 wxString libName = EASYEDAPRO::ShortenLibName( fname.GetName() );
465
466 wxFileName libFileName( fname.GetPath(), libName, FILEEXT::KiCadSymbolLibFileExtension );
467
468 if( fname.GetExt() != wxS( "epro" ) && fname.GetExt() != wxS( "zip" ) )
469 return rootSheet;
470
471 nlohmann::json project = EASYEDAPRO::ReadProjectOrDeviceFile( aFileName );
472
473 std::map<wxString, EASYEDAPRO::PRJ_SCHEMATIC> prjSchematics = project.at( "schematics" );
474
475 wxString schematicToLoad;
476
477 if( aProperties && aProperties->contains( "sch_id" ) )
478 {
479 schematicToLoad = wxString::FromUTF8( aProperties->at( "sch_id" ) );
480 }
481 else
482 {
483 if( prjSchematics.size() == 1 )
484 {
485 schematicToLoad = prjSchematics.begin()->first;
486 }
487 else
488 {
489 std::vector<IMPORT_PROJECT_DESC> chosen = m_choose_project_handler(
491
492 if( chosen.size() > 0 )
493 schematicToLoad = chosen[0].SchematicId;
494 }
495 }
496
497 if( schematicToLoad.empty() )
498 return nullptr;
499
500 wxString rootBaseName = EscapeString( prjSchematics[schematicToLoad].name, CTX_FILENAME );
501
502 wxFileName rootFname( aFileName );
503 rootFname.SetFullName( rootBaseName + wxS( "." )
504 + wxString::FromUTF8( FILEEXT::KiCadSchematicFileExtension ) );
505
506 rootSheet->SetName( prjSchematics[schematicToLoad].name );
507 rootSheet->SetFileName( rootFname.GetFullPath() );
508 rootSheet->GetScreen()->SetFileName( rootFname.GetFullPath() );
509
510 const std::vector<EASYEDAPRO::PRJ_SHEET>& prjSchematicSheets =
511 prjSchematics[schematicToLoad].sheets;
512
513 LoadAllDataFromProject( aFileName );
514
515 if( !m_projectData )
516 return nullptr;
517
518 const int schSheetsCount = prjSchematicSheets.size();
519
520 auto cbs = [&]( const wxString& name, const wxString& baseName, wxInputStream& zip ) -> bool
521 {
522 if( !name.EndsWith( wxS( ".esch" ) ) )
524
525 wxArrayString nameParts = wxSplit( name, '\\', '\0' );
526
527 if( nameParts.size() == 1 )
528 nameParts = wxSplit( name, '/', '\0' );
529
530 if( nameParts.size() < 3 )
532
533 wxString schematicUuid = nameParts[1];
534 wxString sheetFileName = nameParts[2];
535 wxString sheetId = sheetFileName.BeforeLast( '.' );
536 int sheetId_i;
537 sheetId.ToInt( &sheetId_i );
538
539 if( schematicUuid != schematicToLoad )
541
542 auto prjSheetIt = std::find_if( prjSchematicSheets.begin(), prjSchematicSheets.end(),
543 [&]( const EASYEDAPRO::PRJ_SHEET& s )
544 {
545 return s.id == sheetId_i;
546 } );
547
548 if( prjSheetIt == prjSchematicSheets.end() )
550
551 std::vector<nlohmann::json> lines = EASYEDAPRO::ParseJsonLines( zip, name );
552
553 if( schSheetsCount > 1 )
554 {
555 wxString sheetBaseName =
556 sheetId + wxS( "_" ) + EscapeString( prjSheetIt->name, CTX_FILENAME );
557
558 wxFileName sheetFname( aFileName );
559 sheetFname.SetFullName( sheetBaseName + wxS( "." )
560 + wxString::FromUTF8( FILEEXT::KiCadSchematicFileExtension ) );
561
562 wxFileName relSheetPath( sheetFname );
563 relSheetPath.MakeRelativeTo( rootFname.GetPath() );
564
565 std::unique_ptr<SCH_SHEET> subSheet = std::make_unique<SCH_SHEET>( aSchematic );
566 subSheet->SetFileName( relSheetPath.GetFullPath() );
567 subSheet->SetName( prjSheetIt->name );
568
569 SCH_SCREEN* screen = new SCH_SCREEN( aSchematic );
570 screen->SetFileName( sheetFname.GetFullPath() );
571 screen->SetPageNumber( sheetId );
572 subSheet->SetScreen( screen );
573
574 VECTOR2I pos;
575 pos.x = schIUScale.MilsToIU( 200 );
576 pos.y = schIUScale.MilsToIU( 200 )
577 + ( subSheet->GetSize().y + schIUScale.MilsToIU( 200 ) ) * ( sheetId_i - 1 );
578
579 subSheet->SetPosition( pos );
580
581 SCH_SHEET_PATH sheetPath;
582 sheetPath.push_back( rootSheet );
583 sheetPath.push_back( subSheet.get() );
584 sheetPath.SetPageNumber( sheetId );
585 aSchematic->SetCurrentSheet( sheetPath );
586
587 parser.ParseSchematic( aSchematic, subSheet.get(), project, m_projectData->m_Symbols,
588 m_projectData->m_Blobs, lines, libName );
589
590 rootSheet->GetScreen()->Append( subSheet.release() );
591 }
592 else
593 {
594 parser.ParseSchematic( aSchematic, rootSheet, project, m_projectData->m_Symbols,
595 m_projectData->m_Blobs, lines, libName );
596 }
597
599 };
600 EASYEDAPRO::IterateZipFiles( aFileName, cbs );
601
602 IO_RELEASER<SCH_IO> sch_plugin( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
603
605 LIBRARY_TABLE* table = adapter->ProjectTable().value_or( nullptr );
606 wxCHECK_MSG( table, nullptr, "Could not load symbol lib table." );
607
608 if( !table->HasRow( libName ) )
609 {
610 // Create a new empty symbol library.
611 sch_plugin->CreateLibrary( libFileName.GetFullPath() );
612 wxString libTableUri = wxS( "${KIPRJMOD}/" ) + libFileName.GetFullName();
613
614 // Add the new library to the project symbol library table.
615 LIBRARY_TABLE_ROW& row = table->InsertRow();
616 row.SetNickname( libName );
617 row.SetURI( libTableUri );
618 row.SetType( "KiCad" );
619
620 table->Save();
621
622 adapter->LoadOne( libName );
623 }
624
625 // set properties to prevent save file on every symbol save
626 std::map<std::string, UTF8> properties;
627 properties.emplace( SCH_IO_KICAD_SEXPR::PropBuffering, wxEmptyString );
628
629 for( auto& [symbolUuid, symInfo] : m_projectData->m_Symbols )
630 sch_plugin->SaveSymbol( libFileName.GetFullPath(), symInfo.libSymbol.release(),
631 &properties );
632
633 sch_plugin->SaveLibrary( libFileName.GetFullPath() );
634
636 aSchematic->FixupJunctionsAfterImport();
637
638 return rootSheet;
639}
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:332
REPORTER * m_reporter
Reporter to log errors/warnings to, may be nullptr.
Definition io_base.h:237
Definition kiid.h:44
std::optional< LIBRARY_TABLE * > ProjectTable() const
Retrieves the project library table for this adapter type, or nullopt if one doesn't exist.
void SetNickname(const wxString &aNickname)
void SetType(const wxString &aType)
void SetURI(const wxString &aUri)
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:188
Define a library symbol object.
Definition lib_symbol.h:79
SCH_FIELD & GetFootprintField()
Return reference to the footprint field.
Definition lib_symbol.h:337
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:247
CHOOSE_PROJECT_HANDLER m_choose_project_handler
Callback to choose projects to import.
static SYMBOL_LIBRARY_ADAPTER * SymbolLibAdapter(PROJECT *aProject)
Accessor for project symbol library manager adapter.
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.
PROJECT & Project() const
Return a reference to the project this schematic is part of.
Definition schematic.h:105
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
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.
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,...
static const char * PropBuffering
The property used internally by the plugin to enable cache buffering which prevents the library file ...
SCH_IO(const wxString &aName)
Definition sch_io.h:375
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.
An interface to the global shared library manager that is schematic-specific and linked to one projec...
std::optional< LIB_STATUS > LoadOne(LIB_DATA *aLib) override
Loads or reloads the given library, if it exists.
static REPORTER & GetInstance()
Definition reporter.cpp:220
#define EASY_IT_BREAK
#define EASY_IT_CONTINUE
static const std::string KiCadSchematicFileExtension
static const std::string KiCadSymbolLibFileExtension
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
Definition io_mgr.h:33
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)
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
std::vector< std::vector< std::string > > table
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683
Definition of file extensions used in Kicad.