Import footprint to symbols. Subsheet is name is prepended to footprint name, which is probably NOT OK when syncing with PCB.
This commit is contained in:
parent
81570e02f3
commit
292aff48fd
|
@ -678,6 +678,27 @@ ASCH_DESIGNATOR::ASCH_DESIGNATOR( const std::map<wxString, wxString>& aPropertie
|
|||
-PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) );
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
|
|
|
@ -646,6 +646,25 @@ struct ASCH_DESIGNATOR
|
|||
explicit ASCH_DESIGNATOR( const std::map<wxString, wxString>& aProperties );
|
||||
};
|
||||
|
||||
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
|
||||
{
|
||||
|
|
|
@ -302,7 +302,9 @@ void SCH_ALTIUM_PLUGIN::Parse( 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();
|
||||
|
@ -409,8 +411,13 @@ void SCH_ALTIUM_PLUGIN::Parse( 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;
|
||||
|
@ -2079,7 +2086,7 @@ void SCH_ALTIUM_PLUGIN::ParseParameter( const std::map<wxString, wxString>& aPro
|
|||
const wxPoint position = elem.location + m_sheetOffset;
|
||||
|
||||
SCH_FIELD* field = nullptr;
|
||||
if( elem.name == "Value" )
|
||||
if( elem.name == "Comment" )
|
||||
{
|
||||
field = component->GetField( VALUE_FIELD );
|
||||
field->SetPosition( position );
|
||||
|
@ -2110,3 +2117,33 @@ 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 );
|
||||
// wxLogWarning( "Current footprint is: %i, %s, %s, %i, last impl list index was: %i\n",
|
||||
// elem.ownerindex, TO_UTF8( elem.name ), TO_UTF8( elem.type ), (int) elem.isCurrent,
|
||||
// ownerindex );
|
||||
// Only get footprint, currently assigned only
|
||||
if( ( elem.type == "PCBLIB" ) && ( elem.isCurrent ) )
|
||||
{
|
||||
const auto& symbol = m_symbols.find( ownerindex );
|
||||
if( symbol == m_symbols.end() )
|
||||
{
|
||||
wxLogWarning(
|
||||
wxString::Format( "Footprint has non-existent ownerindex %d", ownerindex ) );
|
||||
return;
|
||||
}
|
||||
const auto& component = m_components.at( symbol->first );
|
||||
if( elem.libname != "" )
|
||||
{
|
||||
// component->SetFootprint( elem.libname + wxT( ":" ) + elem.name );
|
||||
}
|
||||
else
|
||||
{
|
||||
// component->SetFootprint( elem.name );
|
||||
}
|
||||
|
||||
component->SetFootprint(elem.name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,6 +132,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:
|
||||
SCH_SHEET* m_rootSheet; // The root sheet of the schematic being loaded..
|
||||
|
|
Loading…
Reference in New Issue