KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_easyedapro_plugin.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 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
27
28#include <schematic.h>
29#include <sch_sheet.h>
30#include <sch_screen.h>
32
33#include <fstream>
34#include <wx/txtstrm.h>
35#include <wx/wfstream.h>
36#include <wx/mstream.h>
37#include <wx/zipstrm.h>
38#include <wx/fs_zip.h>
39#include <wx/log.h>
40
41#include <nlohmann/json.hpp>
42#include <string_utils.h>
46#include <core/map_helpers.h>
47#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
58{
60 m_progressReporter = nullptr;
61}
62
63
65{
66 if( m_projectData )
67 delete m_projectData;
68}
69
70
71const wxString SCH_EASYEDAPRO_PLUGIN::GetName() const
72{
73 return wxT( "EasyEDA (JLCEDA) Schematic Importer" );
74}
75
76
77bool SCH_EASYEDAPRO_PLUGIN::CanReadSchematicFile( const wxString& aFileName ) const
78{
79 if( aFileName.Lower().EndsWith( wxS( ".epro" ) ) )
80 {
81 return true;
82 }
83 else if( aFileName.Lower().EndsWith( wxS( ".zip" ) ) )
84 {
85 std::shared_ptr<wxZipEntry> entry;
86 wxFFileInputStream in( aFileName );
87 wxZipInputStream zip( in );
88
89 if( !zip.IsOk() )
90 return false;
91
92 while( entry.reset( zip.GetNextEntry() ), entry.get() != NULL )
93 {
94 wxString name = entry->GetName();
95
96 if( name == wxS( "project.json" ) )
97 return true;
98 }
99
100 return false;
101 }
102
103 return false;
104}
105
106
108{
109 return 0;
110}
111
112
113static LIB_SYMBOL* loadSymbol( nlohmann::json project, const wxString& aLibraryPath,
114 const wxString& aAliasName, const STRING_UTF8_MAP* aProperties )
115{
116 SCH_EASYEDAPRO_PARSER parser( nullptr, nullptr );
117 LIB_SYMBOL* symbol = nullptr;
118 wxFileName libFname( aLibraryPath );
119 wxString symLibName = EASYEDAPRO::ShortenLibName( libFname.GetName() );
120
121 /*if( libFname.GetExt() == wxS( "esym" ) )
122 {
123 wxFFileInputStream ffis( aLibraryPath );
124 wxTextInputStream txt( ffis, wxS( " " ), wxConvUTF8 );
125
126 bool loadThis = false;
127 std::vector<nlohmann::json> lines;
128 while( ffis.CanRead() )
129 {
130 nlohmann::json js = nlohmann::json::parse( txt.ReadLine() );
131 lines.emplace_back( js );
132
133 if( js.at( 0 ) == "ATTR" && js.at( 3 ) == "Symbol" )
134 {
135 if( js.at( 4 ).get<wxString>() == aAliasName )
136 {
137 loadThis = true;
138 }
139 }
140 }
141
142 if( loadThis )
143 {
144 EASYEDAPRO::SYM_INFO symInfo = parser.ParseSymbol( lines );
145 return symInfo.libSymbol.release();
146 }
147 }
148 else */
149 if( libFname.GetExt() == wxS( "epro" ) || libFname.GetExt() == wxS( "zip" ) )
150 {
151 std::map<wxString, EASYEDAPRO::PRJ_SYMBOL> prjSymbols = project.at( "symbols" );
152 std::map<wxString, EASYEDAPRO::PRJ_FOOTPRINT> prjFootprints = project.at( "footprints" );
153 std::map<wxString, EASYEDAPRO::PRJ_DEVICE> 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 wxString fpTitle;
166
167 for( auto& [key, device] : prjDevices )
168 {
169 auto val = get_opt( device.attributes, "Symbol" );
170
171 if( val && *val == prjSymUuid )
172 {
173 if( auto fpUuid = get_opt( device.attributes, "Footprint" ) )
174 {
175 if( auto prjFp = get_opt( prjFootprints, *fpUuid ) )
176 {
177 fpTitle = prjFp->title;
178 break;
179 }
180 }
181 }
182 }
183
184 auto cb = [&]( const wxString& name, const wxString& symUuid, wxInputStream& zip ) -> bool
185 {
186 if( !name.EndsWith( wxS( ".esym" ) ) )
188
189 if( symUuid != prjSymUuid )
191
192 wxTextInputStream txt( zip, wxS( " " ), wxConvUTF8 );
193
194 std::vector<nlohmann::json> lines;
195 while( zip.CanRead() )
196 {
197 nlohmann::json js = nlohmann::json::parse( txt.ReadLine() );
198 lines.emplace_back( js );
199 }
200
201 EASYEDAPRO::SYM_INFO symInfo = parser.ParseSymbol( lines );
202
203 if( !symInfo.libSymbol )
205
206 LIB_ID libID = EASYEDAPRO::ToKiCadLibID( symLibName, aAliasName );
207 symInfo.libSymbol->SetLibId( libID );
208 symInfo.libSymbol->SetName( aAliasName );
209 symInfo.libSymbol->GetFootprintField().SetText( symLibName + wxS( "/" ) + fpTitle );
210
211 symbol = symInfo.libSymbol.release();
212
214 };
215 EASYEDAPRO::IterateZipFiles( aLibraryPath, cb );
216 }
217
218 return symbol;
219}
220
221
222void SCH_EASYEDAPRO_PLUGIN::EnumerateSymbolLib( wxArrayString& aSymbolNameList,
223 const wxString& aLibraryPath,
224 const STRING_UTF8_MAP* aProperties )
225{
226 wxFileName fname( aLibraryPath );
227
228 if( fname.GetExt() == wxS( "esym" ) )
229 {
230 wxFFileInputStream ffis( aLibraryPath );
231 wxTextInputStream txt( ffis, wxS( " " ), wxConvUTF8 );
232
233 while( ffis.CanRead() )
234 {
235 wxString line = txt.ReadLine();
236
237 if( !line.Contains( wxS( "ATTR" ) ) )
238 continue; // Don't bother parsing
239
240 nlohmann::json js = nlohmann::json::parse( line );
241 if( js.at( 0 ) == "ATTR" && js.at( 3 ) == "Symbol" )
242 {
243 aSymbolNameList.Add( js.at( 4 ).get<wxString>() );
244 }
245 }
246 }
247 else if( fname.GetExt() == wxS( "epro" ) || fname.GetExt() == wxS( "zip" ) )
248 {
249 nlohmann::json project = EASYEDAPRO::ReadProjectFile( aLibraryPath );
250 std::map<wxString, nlohmann::json> symbolMap = project.at( "symbols" );
251
252 for( auto& [key, value] : symbolMap )
253 aSymbolNameList.Add( value.at( "title" ) );
254 }
255}
256
257
258void SCH_EASYEDAPRO_PLUGIN::EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& aSymbolList,
259 const wxString& aLibraryPath,
260 const STRING_UTF8_MAP* aProperties )
261{
262 wxFileName libFname( aLibraryPath );
263 wxArrayString symbolNameList;
264 nlohmann::json project;
265
266 EnumerateSymbolLib( symbolNameList, aLibraryPath, aProperties );
267
268 if( libFname.GetExt() == wxS( "epro" ) || libFname.GetExt() == wxS( "zip" ) )
269 project = EASYEDAPRO::ReadProjectFile( aLibraryPath );
270
271 for( const wxString& symbolName : symbolNameList )
272 {
273 LIB_SYMBOL* sym = loadSymbol( project, aLibraryPath, symbolName, aProperties );
274
275 if( sym )
276 aSymbolList.push_back( sym );
277 }
278}
279
280
281void SCH_EASYEDAPRO_PLUGIN::LoadAllDataFromProject( const wxString& aProjectPath )
282{
283 if( m_projectData )
284 delete m_projectData;
285
287
288 SCH_EASYEDAPRO_PARSER parser( nullptr, nullptr );
289 wxFileName fname( aProjectPath );
290 wxString symLibName = EASYEDAPRO::ShortenLibName( fname.GetName() );
291
292 if( fname.GetExt() != wxS( "epro" ) && fname.GetExt() != wxS( "zip" ) )
293 return;
294
295 nlohmann::json project = EASYEDAPRO::ReadProjectFile( aProjectPath );
296
297 std::map<wxString, EASYEDAPRO::PRJ_SYMBOL> prjSymbols = project.at( "symbols" );
298 std::map<wxString, EASYEDAPRO::PRJ_FOOTPRINT> prjFootprints = project.at( "footprints" );
299 std::map<wxString, EASYEDAPRO::PRJ_DEVICE> prjDevices = project.at( "devices" );
300
301 auto cb = [&]( const wxString& name, const wxString& baseName, wxInputStream& zip ) -> bool
302 {
303 if( !name.EndsWith( wxS( ".esym" ) ) && !name.EndsWith( wxS( ".eblob" ) ) )
305
306 std::vector<nlohmann::json> lines = EASYEDAPRO::ParseJsonLines( zip, name );
307
308 if( name.EndsWith( wxS( ".esym" ) ) )
309 {
310 EASYEDAPRO::PRJ_SYMBOL symData = prjSymbols.at( baseName );
311 EASYEDAPRO::SYM_INFO symInfo = parser.ParseSymbol( lines );
312
313 if( !symInfo.libSymbol )
315
316 wxString fpTitle;
317
318 for( auto& [key, device] : prjDevices )
319 {
320 auto val = get_opt( device.attributes, "Symbol" );
321
322 if( val && *val == baseName )
323 {
324 if( auto fpUuid = get_opt( device.attributes, "Footprint" ) )
325 {
326 if( auto prjFp = get_opt( prjFootprints, *fpUuid ) )
327 {
328 fpTitle = prjFp->title;
329 break;
330 }
331 }
332 }
333 }
334
335 LIB_ID libID = EASYEDAPRO::ToKiCadLibID( symLibName, symData.title );
336 symInfo.libSymbol->SetLibId( libID );
337 symInfo.libSymbol->SetName( symData.title );
338 symInfo.libSymbol->GetFootprintField().SetText( symLibName + wxS( "/" ) + fpTitle );
339
340 m_projectData->m_Symbols.emplace( baseName, std::move( symInfo ) );
341 }
342 else if( name.EndsWith( wxS( ".eblob" ) ) )
343 {
344 for( const nlohmann::json& line : lines )
345 {
346 if( line.at( 0 ) == "BLOB" )
347 {
348 EASYEDAPRO::BLOB blob = line;
349 m_projectData->m_Blobs[blob.objectId] = blob;
350 }
351 }
352 }
353
355 };
356 EASYEDAPRO::IterateZipFiles( aProjectPath, cb );
357}
358
359
360LIB_SYMBOL* SCH_EASYEDAPRO_PLUGIN::LoadSymbol( const wxString& aLibraryPath,
361 const wxString& aAliasName,
362 const STRING_UTF8_MAP* aProperties )
363{
364 wxFileName libFname( aLibraryPath );
365 nlohmann::json project;
366
367 if( libFname.GetExt() == wxS( "epro" ) || libFname.GetExt() == wxS( "zip" ) )
368 project = EASYEDAPRO::ReadProjectFile( aLibraryPath );
369
370 return loadSymbol( project, aLibraryPath, aAliasName, aProperties );
371}
372
373
375 SCHEMATIC* aSchematic, SCH_SHEET* aAppendToMe,
376 const STRING_UTF8_MAP* aProperties )
377{
378 wxCHECK( !aFileName.IsEmpty() && aSchematic, nullptr );
379
380 SCH_SHEET* rootSheet = nullptr;
381
382 if( aAppendToMe )
383 {
384 wxCHECK_MSG( aSchematic->IsValid(), nullptr,
385 wxS( "Can't append to a schematic with no root!" ) );
386
387 rootSheet = &aSchematic->Root();
388 }
389 else
390 {
391 rootSheet = new SCH_SHEET( aSchematic );
392 rootSheet->SetFileName( aFileName );
393 aSchematic->SetRoot( rootSheet );
394 }
395
396 if( !rootSheet->GetScreen() )
397 {
398 SCH_SCREEN* screen = new SCH_SCREEN( aSchematic );
399
400 screen->SetFileName( aFileName );
401 rootSheet->SetScreen( screen );
402 }
403
404 SYMBOL_LIB_TABLE* libTable = PROJECT_SCH::SchSymbolLibTable( &aSchematic->Prj() );
405 wxCHECK_MSG( libTable, nullptr, wxS( "Could not load symbol lib table." ) );
406
407 SCH_EASYEDAPRO_PARSER parser( nullptr, nullptr );
408 wxFileName fname( aFileName );
409 wxString libName = EASYEDAPRO::ShortenLibName( fname.GetName() );
410
411 wxFileName libFileName( fname.GetPath(), libName, KiCadSymbolLibFileExtension );
412
413 if( fname.GetExt() != wxS( "epro" ) && fname.GetExt() != wxS( "zip" ) )
414 return rootSheet;
415
416 nlohmann::json project = EASYEDAPRO::ReadProjectFile( aFileName );
417
418 std::map<wxString, EASYEDAPRO::PRJ_SCHEMATIC> prjSchematics = project.at( "schematics" );
419
420 wxString schematicToLoad;
421
422 if( aProperties && aProperties->Exists( "sch_id" ) )
423 {
424 schematicToLoad = wxString::FromUTF8( aProperties->at( "sch_id" ) );
425 }
426 else
427 {
428 if( prjSchematics.size() == 1 )
429 {
430 schematicToLoad = prjSchematics.begin()->first;
431 }
432 else
433 {
434 std::vector<IMPORT_PROJECT_DESC> chosen = m_choose_project_handler(
436
437 if( chosen.size() > 0 )
438 schematicToLoad = chosen[0].SchematicId;
439 }
440 }
441
442 if( schematicToLoad.empty() )
443 return nullptr;
444
445 wxString rootBaseName = EscapeString( prjSchematics[schematicToLoad].name, CTX_FILENAME );
446
447 wxFileName rootFname( aFileName );
448 rootFname.SetFullName( rootBaseName + wxS( "." )
449 + wxString::FromUTF8( KiCadSchematicFileExtension ) );
450
451 rootSheet->SetName( prjSchematics[schematicToLoad].name );
452 rootSheet->SetFileName( rootFname.GetFullPath() );
453 rootSheet->GetScreen()->SetFileName( rootFname.GetFullPath() );
454
455 const std::vector<EASYEDAPRO::PRJ_SHEET>& prjSchematicSheets =
456 prjSchematics[schematicToLoad].sheets;
457
458 LoadAllDataFromProject( aFileName );
459
460 if( !m_projectData )
461 return nullptr;
462
463 auto cbs = [&]( const wxString& name, const wxString& symUuid, wxInputStream& zip ) -> bool
464 {
465 if( !name.EndsWith( wxS( ".esch" ) ) )
467
468 wxArrayString nameParts = wxSplit( name, '\\', '\0' );
469
470 if( nameParts.size() == 1 )
471 nameParts = wxSplit( name, '/', '\0' );
472
473 if( nameParts.size() < 3 )
475
476 wxString schematicUuid = nameParts[1];
477 wxString sheetFileName = nameParts[2];
478 wxString sheetId = sheetFileName.BeforeLast( '.' );
479 int sheetId_i;
480 sheetId.ToInt( &sheetId_i );
481
482 if( schematicUuid != schematicToLoad )
484
485 auto prjSheetIt = std::find_if( prjSchematicSheets.begin(), prjSchematicSheets.end(),
486 [&]( const EASYEDAPRO::PRJ_SHEET& s )
487 {
488 return s.id == sheetId_i;
489 } );
490
491 if( prjSheetIt == prjSchematicSheets.end() )
493
494 wxString sheetBaseName =
495 sheetId + wxS( "_" ) + EscapeString( prjSheetIt->name, CTX_FILENAME );
496
497 wxFileName sheetFname( aFileName );
498 sheetFname.SetFullName( sheetBaseName + wxS( "." )
499 + wxString::FromUTF8( KiCadSchematicFileExtension ) );
500
501 std::unique_ptr<SCH_SHEET> subSheet = std::make_unique<SCH_SHEET>( aSchematic );
502 subSheet->SetFileName( sheetFname.GetFullPath() );
503 subSheet->SetName( prjSheetIt->name );
504
505 SCH_SCREEN* screen = new SCH_SCREEN( aSchematic );
506 screen->SetFileName( sheetFname.GetFullPath() );
507 screen->SetPageNumber( sheetId );
508 subSheet->SetScreen( screen );
509
510 VECTOR2I pos;
511 pos.x = schIUScale.MilsToIU( 200 );
512 pos.y = schIUScale.MilsToIU( 200 )
513 + ( subSheet->GetSize().y + schIUScale.MilsToIU( 200 ) ) * ( sheetId_i - 1 );
514
515 subSheet->SetPosition( pos );
516
517 std::vector<nlohmann::json> lines = EASYEDAPRO::ParseJsonLines( zip, name );
518
519 SCH_SHEET_PATH sheetPath;
520 sheetPath.push_back( rootSheet );
521 sheetPath.push_back( subSheet.get() );
522 sheetPath.SetPageNumber( sheetId );
523 aSchematic->SetCurrentSheet( sheetPath );
524
525 parser.ParseSchematic( aSchematic, subSheet.get(), project, m_projectData->m_Symbols,
526 m_projectData->m_Blobs, lines, libName );
527
528 rootSheet->GetScreen()->Append( subSheet.release() );
529
531 };
532 EASYEDAPRO::IterateZipFiles( aFileName, cbs );
533
535 sch_plugin.set( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
536
537 if( !libTable->HasLibrary( libName ) )
538 {
539 // Create a new empty symbol library.
540 sch_plugin->CreateSymbolLib( libFileName.GetFullPath() );
541 wxString libTableUri = wxS( "${KIPRJMOD}/" ) + libFileName.GetFullName();
542
543 // Add the new library to the project symbol library table.
544 libTable->InsertRow( new SYMBOL_LIB_TABLE_ROW( libName, libTableUri, wxS( "KiCad" ) ) );
545
546 // Save project symbol library table.
547 wxFileName fn( aSchematic->Prj().GetProjectPath(),
549
550 // So output formatter goes out of scope and closes the file before reloading.
551 {
552 FILE_OUTPUTFORMATTER formatter( fn.GetFullPath() );
553 libTable->Format( &formatter, 0 );
554 }
555
556 // Relaod the symbol library table.
557 aSchematic->Prj().SetElem( PROJECT::ELEM_SYMBOL_LIB_TABLE, NULL );
558 PROJECT_SCH::SchSymbolLibTable( &aSchematic->Prj() );
559 }
560
561 // set properties to prevent save file on every symbol save
562 STRING_UTF8_MAP properties;
563 properties.emplace( SCH_SEXPR_PLUGIN::PropBuffering, wxEmptyString );
564
565 for( auto& [symbolUuid, symInfo] : m_projectData->m_Symbols )
566 sch_plugin->SaveSymbol( libFileName.GetFullPath(), symInfo.libSymbol.release(),
567 &properties );
568
569 sch_plugin->SaveLibrary( libFileName.GetFullPath() );
570
572 aSchematic->FixupJunctions();
573
574 return rootSheet;
575}
const char * name
Definition: DXF_plotter.cpp:57
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
void SetPageNumber(const wxString &aPageNumber)
Definition: base_screen.h:79
Used for text file output.
Definition: richio.h:469
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
Define a library symbol object.
Definition: lib_symbol.h:99
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
bool InsertRow(LIB_TABLE_ROW *aRow, bool doReplace=false)
Adds aRow if it does not already exist or if doReplace is true.
CHOOSE_PROJECT_HANDLER m_choose_project_handler
Callback to choose projects to import.
static SYMBOL_LIB_TABLE * SchSymbolLibTable(PROJECT *aProject)
Accessor for project symbol library table.
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:143
virtual void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:317
@ ELEM_SYMBOL_LIB_TABLE
Definition: project.h:228
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 FixupJunctions()
Add junctions to this schematic where required.
Definition: schematic.cpp:656
void SetRoot(SCH_SHEET *aRootSheet)
Initialize the schematic with a new root sheet.
Definition: schematic.cpp:113
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
EASYEDAPRO::SYM_INFO ParseSymbol(const std::vector< nlohmann::json > &aLines)
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)
PROGRESS_REPORTER * m_progressReporter
int GetModifyHash() const override
Return the modification hash from the library cache.
const wxString GetName() const override
Return a brief hard coded name for this SCH_PLUGIN.
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...
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_PLUGIN implementation knows about,...
void LoadAllDataFromProject(const wxString &aLibraryPath)
bool CanReadSchematicFile(const wxString &aFileName) const override
Checks if this SCH_PLUGIN can read the specified schematic file.
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.
Helper object to release a SCH_PLUGIN in the context of a potential thrown exception through its dest...
Definition: sch_io_mgr.h:530
void set(SCH_PLUGIN *aPlugin)
Definition: sch_io_mgr.h:557
virtual void SaveSymbol(const wxString &aLibraryPath, const LIB_SYMBOL *aSymbol, const STRING_UTF8_MAP *aProperties=nullptr)
Write aSymbol to an existing library located at aLibraryPath.
Definition: sch_plugin.cpp:165
virtual void SaveLibrary(const wxString &aFileName, const STRING_UTF8_MAP *aProperties=nullptr)
Definition: sch_plugin.cpp:118
virtual void CreateSymbolLib(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr)
Create a new empty symbol library at aLibraryPath.
Definition: sch_plugin.cpp:181
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Definition: sch_screen.cpp:149
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
Definition: sch_screen.cpp:114
static const char * PropBuffering
The property used internally by the plugin to enable cache buffering which prevents the library file ...
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:314
void SetName(const wxString &aName)
Definition: sch_sheet.h:108
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.
bool Exists(const std::string &aProperty) const
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
static const wxString & GetSymbolLibTableFileName()
virtual void Format(OUTPUTFORMATTER *aOutput, int aIndentLevel) const override
Generate the table in s-expression format to aOutput with an indentation level of aIndentLevel.
static REPORTER & GetInstance()
Definition: reporter.cpp:203
#define EASY_IT_BREAK
#define EASY_IT_CONTINUE
const std::string KiCadSymbolLibFileExtension
const std::string KiCadSchematicFileExtension
std::optional< V > get_opt(const std::map< wxString, V > &aMap, const wxString &aKey)
Definition: map_helpers.h:34
LIB_ID ToKiCadLibID(const wxString &aLibName, const wxString &aLibReference)
nlohmann::json ReadProjectFile(const wxString &aZipFileName)
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)
wxString ShortenLibName(wxString aProjectName)
LIB_SYMBOL * loadSymbol(const wxString &aLibraryPath, nlohmann::json aFileData, const wxString &aAliasName, const STRING_UTF8_MAP *aProperties)
static LIB_SYMBOL * loadSymbol(nlohmann::json project, const wxString &aLibraryPath, 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::unique_ptr< LIB_SYMBOL > libSymbol
constexpr int MilsToIU(int mils) const
Definition: base_units.h:94
std::map< wxString, EASYEDAPRO::SYM_INFO > m_Symbols
std::map< wxString, EASYEDAPRO::BLOB > m_Blobs
Definition of file extensions used in Kicad.