Import Altium footprint references into symbols.
Fixes https://gitlab.com/kicad/code/kicad/issues/7751
This commit is contained in:
parent
3288971a7c
commit
0be91c5b7d
|
@ -742,6 +742,28 @@ ASCH_DESIGNATOR::ASCH_DESIGNATOR( const std::map<wxString, wxString>& aPropertie
|
|||
}
|
||||
|
||||
|
||||
ASCH_IMPLEMENTATION::ASCH_IMPLEMENTATION( const std::map<wxString, wxString>& aProperties )
|
||||
{
|
||||
wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::IMPLEMENTATION );
|
||||
|
||||
// "OWNERINDEX" points to unknown item. Use ASCH_IMPLEMENTATION_LIST -> OWNERINDEX prior 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", "" );
|
||||
type = ALTIUM_PARSER::PropertiesReadString( aProperties, "MODELTYPE", "" );
|
||||
libname = ALTIUM_PARSER::PropertiesReadString( aProperties, "MODELDATAFILE0", "" );
|
||||
isCurrent = ALTIUM_PARSER::PropertiesReadBool( aProperties, "ISCURRENT", false );
|
||||
}
|
||||
|
||||
|
||||
ASCH_IMPLEMENTATION_LIST::ASCH_IMPLEMENTATION_LIST( const std::map<wxString, wxString>& aProperties )
|
||||
{
|
||||
wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::IMPLEMENTATION_LIST );
|
||||
|
||||
ownerindex =
|
||||
ALTIUM_PARSER::PropertiesReadInt( aProperties, "OWNERINDEX", ALTIUM_COMPONENT_NONE );
|
||||
}
|
||||
|
||||
ASCH_BUS_ENTRY::ASCH_BUS_ENTRY( const std::map<wxString, wxString>& aProperties )
|
||||
{
|
||||
wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::BUS_ENTRY );
|
||||
|
|
|
@ -703,6 +703,28 @@ struct ASCH_DESIGNATOR
|
|||
};
|
||||
|
||||
|
||||
struct ASCH_IMPLEMENTATION
|
||||
{
|
||||
// IMPLEMENTATION_LIST -> ownerindex must be read and used for these IMPLEMENTATIONs
|
||||
// int ownerindex;
|
||||
|
||||
wxString name;
|
||||
wxString type;
|
||||
wxString libname;
|
||||
|
||||
bool isCurrent;
|
||||
|
||||
explicit ASCH_IMPLEMENTATION( const std::map<wxString, wxString>& aProperties );
|
||||
};
|
||||
|
||||
|
||||
struct ASCH_IMPLEMENTATION_LIST
|
||||
{
|
||||
int ownerindex;
|
||||
explicit ASCH_IMPLEMENTATION_LIST( const std::map<wxString, wxString>& aProperties );
|
||||
};
|
||||
|
||||
|
||||
struct ASCH_BUS_ENTRY
|
||||
{
|
||||
wxPoint location;
|
||||
|
|
|
@ -347,7 +347,10 @@ void SCH_ALTIUM_PLUGIN::ParseFileHeader( const CFB::CompoundFileReader& aReader
|
|||
|
||||
m_currentTitleBlock = std::make_unique<TITLE_BLOCK>();
|
||||
|
||||
// index is required required to resolve OWNERINDEX
|
||||
// Track implementation_list ownerindex, because subsequent implementations will depend on it
|
||||
int implementationlistindex = -1;
|
||||
|
||||
// index is required to resolve OWNERINDEX
|
||||
for( int index = 0; reader.GetRemainingBytes() > 0; index++ )
|
||||
{
|
||||
std::map<wxString, wxString> properties = reader.ReadProperties();
|
||||
|
@ -429,7 +432,9 @@ void SCH_ALTIUM_PLUGIN::ParseFileHeader( const CFB::CompoundFileReader& aReader
|
|||
case ALTIUM_SCH_RECORD::JUNCTION:
|
||||
ParseJunction( properties );
|
||||
break;
|
||||
case ALTIUM_SCH_RECORD::IMAGE: ParseImage( properties ); break;
|
||||
case ALTIUM_SCH_RECORD::IMAGE:
|
||||
ParseImage( properties );
|
||||
break;
|
||||
case ALTIUM_SCH_RECORD::SHEET:
|
||||
ParseSheet( properties );
|
||||
break;
|
||||
|
@ -453,8 +458,13 @@ void SCH_ALTIUM_PLUGIN::ParseFileHeader( const CFB::CompoundFileReader& aReader
|
|||
case ALTIUM_SCH_RECORD::WARNING_SIGN:
|
||||
break;
|
||||
case ALTIUM_SCH_RECORD::IMPLEMENTATION_LIST:
|
||||
{
|
||||
ASCH_IMPLEMENTATION_LIST elem( properties );
|
||||
implementationlistindex = elem.ownerindex;
|
||||
}
|
||||
break;
|
||||
case ALTIUM_SCH_RECORD::IMPLEMENTATION:
|
||||
ParseImplementation( properties, implementationlistindex );
|
||||
break;
|
||||
case ALTIUM_SCH_RECORD::RECORD_46:
|
||||
break;
|
||||
|
@ -1058,9 +1068,7 @@ void SCH_ALTIUM_PLUGIN::ParsePolyline( const std::map<wxString, wxString>& aProp
|
|||
line->SetUnit( elem.ownerpartid );
|
||||
|
||||
for( wxPoint& point : elem.points )
|
||||
{
|
||||
line->AddPoint( GetRelativePosition( point + m_sheetOffset, symbol ) );
|
||||
}
|
||||
|
||||
line->SetWidth( elem.lineWidth );
|
||||
}
|
||||
|
@ -1227,6 +1235,7 @@ void SCH_ALTIUM_PLUGIN::ParseArc( const std::map<wxString, wxString>& aPropertie
|
|||
else
|
||||
{
|
||||
const auto& libSymbolIt = m_libSymbols.find( elem.ownerindex );
|
||||
|
||||
if( libSymbolIt == m_libSymbols.end() )
|
||||
{
|
||||
// TODO: e.g. can depend on Template (RECORD=39
|
||||
|
@ -2051,7 +2060,6 @@ void SCH_ALTIUM_PLUGIN::ParseSheet( const std::map<wxString, wxString>& aPropert
|
|||
PAGE_INFO pageInfo;
|
||||
|
||||
bool isPortrait = m_altiumSheet->sheetOrientation == ASCH_SHEET_WORKSPACEORIENTATION::PORTRAIT;
|
||||
|
||||
switch( m_altiumSheet->sheetSize )
|
||||
{
|
||||
default:
|
||||
|
@ -2276,3 +2284,30 @@ void SCH_ALTIUM_PLUGIN::ParseParameter( const std::map<wxString, wxString>& aPro
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SCH_ALTIUM_PLUGIN::ParseImplementation( const std::map<wxString, wxString>& aProperties,
|
||||
int ownerindex )
|
||||
{
|
||||
ASCH_IMPLEMENTATION elem( aProperties );
|
||||
|
||||
// Only get footprint, currently assigned only
|
||||
if( ( elem.type == "PCBLIB" ) && ( elem.isCurrent ) )
|
||||
{
|
||||
const auto& libSymbolIt = m_libSymbols.find( ownerindex );
|
||||
|
||||
if( libSymbolIt == m_libSymbols.end() )
|
||||
{
|
||||
m_reporter->Report( wxString::Format( _( "Footprint has non-existent ownerindex %d." ),
|
||||
ownerindex ),
|
||||
RPT_SEVERITY_WARNING );
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& component = m_symbols.at( libSymbolIt->first );
|
||||
|
||||
if( elem.libname != "" )
|
||||
component->SetFootprint( elem.libname + wxT( ":" ) + elem.name );
|
||||
else
|
||||
component->SetFootprint( elem.name );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,6 +139,7 @@ private:
|
|||
void ParseDesignator( const std::map<wxString, wxString>& aProperties );
|
||||
void ParseBusEntry( const std::map<wxString, wxString>& aProperties );
|
||||
void ParseParameter( const std::map<wxString, wxString>& aProperties );
|
||||
void ParseImplementation( const std::map<wxString, wxString>& aProperties, int ownerindex );
|
||||
|
||||
private:
|
||||
REPORTER* m_reporter; // current reporter for warnings/errors
|
||||
|
|
Loading…
Reference in New Issue