EasyEDA Std: fix importing footprints from footprint editor.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17264
This commit is contained in:
Alex Shvartzkop 2024-03-04 16:34:51 +03:00
parent c056ef407a
commit 30573beb48
1 changed files with 18 additions and 5 deletions

View File

@ -347,9 +347,16 @@ void PCB_IO_EASYEDA::FootprintEnumerate( wxArrayString& aFootprintNames,
wxString packageName = wxString::Format( wxS( "Unknown_%s" ), wxString packageName = wxString::Format( wxS( "Unknown_%s" ),
pcbDoc.uuid.value_or( wxS( "Unknown" ) ) ); pcbDoc.uuid.value_or( wxS( "Unknown" ) ) );
std::optional<std::map<wxString, wxString>> c_para;
if( pcbDoc.c_para ) if( pcbDoc.c_para )
c_para = pcbDoc.c_para;
else if( doc.head.c_para )
c_para = doc.head.c_para;
if( c_para )
{ {
packageName = get_def( *pcbDoc.c_para, wxS( "package" ), packageName ); packageName = get_def( *c_para, wxS( "package" ), packageName );
} }
aFootprintNames.Add( packageName ); aFootprintNames.Add( packageName );
@ -477,18 +484,24 @@ FOOTPRINT* PCB_IO_EASYEDA::FootprintLoad( const wxString& aLibraryPath,
wxString packageName = wxString::Format( wxS( "Unknown_%s" ), wxString packageName = wxString::Format( wxS( "Unknown_%s" ),
pcbDoc.uuid.value_or( wxS( "Unknown" ) ) ); pcbDoc.uuid.value_or( wxS( "Unknown" ) ) );
std::optional<std::map<wxString, wxString>> c_para;
if( pcbDoc.c_para ) if( pcbDoc.c_para )
c_para = pcbDoc.c_para;
else if( doc.head.c_para )
c_para = doc.head.c_para;
if( c_para )
{ {
packageName = get_def( *pcbDoc.c_para, wxS( "package" ), packageName ); packageName = get_def( *c_para, wxS( "package" ), packageName );
if( packageName != aFootprintName ) if( packageName != aFootprintName )
return nullptr; return nullptr;
VECTOR2D origin( doc.head.x, doc.head.y ); VECTOR2D origin( doc.head.x, doc.head.y );
FOOTPRINT* footprint = FOOTPRINT* footprint = parser.ParseFootprint(
parser.ParseFootprint( origin, ANGLE_0, F_Cu, nullptr, *pcbDoc.c_para, origin, ANGLE_0, F_Cu, nullptr, *c_para, m_loadedFootprints, doc.shape );
m_loadedFootprints, doc.shape );
if( !footprint ) if( !footprint )
return nullptr; return nullptr;