altium: Improve handling of footprint references
Don't assume the implementation list index is always correct by order.
This commit is contained in:
parent
4207165c26
commit
5e9a8e3488
|
@ -720,10 +720,7 @@ ASCH_IMPLEMENTATION::ASCH_IMPLEMENTATION( const std::map<wxString, wxString>& aP
|
||||||
{
|
{
|
||||||
wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::IMPLEMENTATION );
|
wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::IMPLEMENTATION );
|
||||||
|
|
||||||
// "OWNERINDEX" points to unknown item. Use ASCH_IMPLEMENTATION_LIST -> OWNERINDEX prior
|
ownerindex = ALTIUM_PARSER::PropertiesReadInt( aProperties, "OWNERINDEX", ALTIUM_COMPONENT_NONE );
|
||||||
// in order to get real ownerindex for this particular implementation
|
|
||||||
//ownerindex = ALTIUM_PARSER::PropertiesReadInt( aProperties, "OWNERINDEX",
|
|
||||||
// ALTIUM_COMPONENT_NONE );
|
|
||||||
name = ALTIUM_PARSER::PropertiesReadString( aProperties, "MODELNAME", "" );
|
name = ALTIUM_PARSER::PropertiesReadString( aProperties, "MODELNAME", "" );
|
||||||
type = ALTIUM_PARSER::PropertiesReadString( aProperties, "MODELTYPE", "" );
|
type = ALTIUM_PARSER::PropertiesReadString( aProperties, "MODELTYPE", "" );
|
||||||
libname = ALTIUM_PARSER::PropertiesReadString( aProperties, "MODELDATAFILE0", "" );
|
libname = ALTIUM_PARSER::PropertiesReadString( aProperties, "MODELDATAFILE0", "" );
|
||||||
|
|
|
@ -713,8 +713,7 @@ struct ASCH_DESIGNATOR
|
||||||
|
|
||||||
struct ASCH_IMPLEMENTATION
|
struct ASCH_IMPLEMENTATION
|
||||||
{
|
{
|
||||||
// IMPLEMENTATION_LIST -> ownerindex must be read and used for these IMPLEMENTATIONs
|
int ownerindex;
|
||||||
// int ownerindex;
|
|
||||||
|
|
||||||
wxString name;
|
wxString name;
|
||||||
wxString type;
|
wxString type;
|
||||||
|
|
|
@ -342,9 +342,6 @@ void SCH_ALTIUM_PLUGIN::ParseFileHeader( const CFB::CompoundFileReader& aReader
|
||||||
|
|
||||||
m_currentTitleBlock = std::make_unique<TITLE_BLOCK>();
|
m_currentTitleBlock = std::make_unique<TITLE_BLOCK>();
|
||||||
|
|
||||||
// Track implementation_list ownerindex, because subsequent implementations will depend on it
|
|
||||||
int implementationlistindex = -1;
|
|
||||||
|
|
||||||
// index is required to resolve OWNERINDEX
|
// index is required to resolve OWNERINDEX
|
||||||
for( int index = 0; reader.GetRemainingBytes() > 0; index++ )
|
for( int index = 0; reader.GetRemainingBytes() > 0; index++ )
|
||||||
{
|
{
|
||||||
|
@ -454,13 +451,10 @@ void SCH_ALTIUM_PLUGIN::ParseFileHeader( const CFB::CompoundFileReader& aReader
|
||||||
case ALTIUM_SCH_RECORD::WARNING_SIGN:
|
case ALTIUM_SCH_RECORD::WARNING_SIGN:
|
||||||
break;
|
break;
|
||||||
case ALTIUM_SCH_RECORD::IMPLEMENTATION_LIST:
|
case ALTIUM_SCH_RECORD::IMPLEMENTATION_LIST:
|
||||||
{
|
ParseImplementationList( index, properties );
|
||||||
ASCH_IMPLEMENTATION_LIST elem( properties );
|
|
||||||
implementationlistindex = elem.ownerindex;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case ALTIUM_SCH_RECORD::IMPLEMENTATION:
|
case ALTIUM_SCH_RECORD::IMPLEMENTATION:
|
||||||
ParseImplementation( properties, implementationlistindex );
|
ParseImplementation( properties );
|
||||||
break;
|
break;
|
||||||
case ALTIUM_SCH_RECORD::RECORD_46:
|
case ALTIUM_SCH_RECORD::RECORD_46:
|
||||||
break;
|
break;
|
||||||
|
@ -2350,29 +2344,48 @@ void SCH_ALTIUM_PLUGIN::ParseParameter( const std::map<wxString, wxString>& aPro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCH_ALTIUM_PLUGIN::ParseImplementation( const std::map<wxString, wxString>& aProperties,
|
|
||||||
int ownerindex )
|
void SCH_ALTIUM_PLUGIN::ParseImplementationList( int aIndex, const std::map<wxString, wxString>& aProperties )
|
||||||
|
{
|
||||||
|
ASCH_IMPLEMENTATION_LIST elem( aProperties );
|
||||||
|
|
||||||
|
m_altiumImplementationList.emplace( aIndex, elem.ownerindex );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SCH_ALTIUM_PLUGIN::ParseImplementation( const std::map<wxString, wxString>& aProperties )
|
||||||
{
|
{
|
||||||
ASCH_IMPLEMENTATION elem( aProperties );
|
ASCH_IMPLEMENTATION elem( aProperties );
|
||||||
|
|
||||||
// Only get footprint, currently assigned only
|
// Only get footprint, currently assigned only
|
||||||
if( ( elem.type == "PCBLIB" ) && ( elem.isCurrent ) )
|
if( ( elem.type == "PCBLIB" ) && ( elem.isCurrent ) )
|
||||||
{
|
{
|
||||||
const auto& libSymbolIt = m_libSymbols.find( ownerindex );
|
const auto& implementationOwnerindexIt = m_altiumImplementationList.find( elem.ownerindex );
|
||||||
|
if( implementationOwnerindexIt == m_altiumImplementationList.end() ) {
|
||||||
if( libSymbolIt == m_libSymbols.end() )
|
m_reporter->Report( wxString::Format( _( "Implementation list's owner (%d) not found." ),
|
||||||
{
|
elem.ownerindex ),
|
||||||
m_reporter->Report( wxString::Format( _( "Footprint's owner (%d) not found." ),
|
|
||||||
ownerindex ),
|
|
||||||
RPT_SEVERITY_ERROR );
|
RPT_SEVERITY_ERROR );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto& libSymbolIt = m_libSymbols.find( implementationOwnerindexIt->second );
|
||||||
|
|
||||||
|
if( libSymbolIt == m_libSymbols.end() )
|
||||||
|
{
|
||||||
|
m_reporter->Report( wxString::Format( _( "Footprint's owner (%d) not found." ),
|
||||||
|
implementationOwnerindexIt->second ),
|
||||||
|
RPT_SEVERITY_ERROR );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LIB_ID fpLibId = AltiumToKiCadLibID( elem.libname, elem.name );
|
||||||
|
wxArrayString fpFilters;
|
||||||
|
fpFilters.Add( fpLibId.Format() );
|
||||||
|
|
||||||
|
libSymbolIt->second->SetFPFilters( fpFilters ); // TODO: not ideal as we overwrite it
|
||||||
|
|
||||||
SCH_SYMBOL* symbol = m_symbols.at( libSymbolIt->first );
|
SCH_SYMBOL* symbol = m_symbols.at( libSymbolIt->first );
|
||||||
|
|
||||||
if( elem.libname != "" )
|
symbol->SetFootprint( fpLibId.Format() );
|
||||||
symbol->SetFootprint( elem.libname + wxT( ":" ) + elem.name );
|
|
||||||
else
|
|
||||||
symbol->SetFootprint( elem.name );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,8 @@ private:
|
||||||
void ParseDesignator( const std::map<wxString, wxString>& aProperties );
|
void ParseDesignator( const std::map<wxString, wxString>& aProperties );
|
||||||
void ParseBusEntry( const std::map<wxString, wxString>& aProperties );
|
void ParseBusEntry( const std::map<wxString, wxString>& aProperties );
|
||||||
void ParseParameter( const std::map<wxString, wxString>& aProperties );
|
void ParseParameter( const std::map<wxString, wxString>& aProperties );
|
||||||
void ParseImplementation( const std::map<wxString, wxString>& aProperties, int ownerindex );
|
void ParseImplementationList( int aIndex, const std::map<wxString, wxString>& aProperties );
|
||||||
|
void ParseImplementation( const std::map<wxString, wxString>& aProperties );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
REPORTER* m_reporter; // current reporter for warnings/errors
|
REPORTER* m_reporter; // current reporter for warnings/errors
|
||||||
|
@ -166,6 +167,7 @@ private:
|
||||||
std::vector<ASCH_STORAGE_FILE> m_altiumStorage;
|
std::vector<ASCH_STORAGE_FILE> m_altiumStorage;
|
||||||
|
|
||||||
std::map<int, ASCH_SYMBOL> m_altiumComponents;
|
std::map<int, ASCH_SYMBOL> m_altiumComponents;
|
||||||
|
std::map<int, int> m_altiumImplementationList;
|
||||||
std::vector<ASCH_PORT> m_altiumPortsCurrentSheet; // we require all connections first
|
std::vector<ASCH_PORT> m_altiumPortsCurrentSheet; // we require all connections first
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue