diff --git a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp index dece36542c..9a778e38d4 100644 --- a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp +++ b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp @@ -442,15 +442,14 @@ void SCH_ALTIUM_PLUGIN::Parse( const CFB::CompoundFileReader& aReader ) m_currentSheet->SetModified(); } -bool SCH_ALTIUM_PLUGIN::IsCmpPartVisible( - int aOwnerindex, int aOwnerpartid, int aOwnerpartdisplaymode ) const + +bool SCH_ALTIUM_PLUGIN::IsComponentPartVisible( int aOwnerindex, int aOwnerpartdisplaymode ) const { const auto& component = m_altiumComponents.find( aOwnerindex ); if( component == m_altiumComponents.end() ) return false; - const ASCH_COMPONENT& cmp = component->second; - return ( cmp.currentpartid == aOwnerpartid ) && ( cmp.displaymode == aOwnerpartdisplaymode ); + return component->second.displaymode == aOwnerpartdisplaymode; } @@ -475,6 +474,8 @@ void SCH_ALTIUM_PLUGIN::ParseComponent( int index, const std::mapSetLibId( libId ); //component->SetLibSymbol( kpart ); // this has to be done after parsing the LIB_PART! + component->SetUnit( elem.currentpartid ); + m_currentSheet->GetScreen()->Append( component ); m_components.insert( { index, component } ); @@ -495,7 +496,7 @@ void SCH_ALTIUM_PLUGIN::ParsePin( const std::map& aPropertie return; } - if( !IsCmpPartVisible( elem.ownerindex, elem.ownerpartid, elem.ownerpartdisplaymode ) ) + if( !IsComponentPartVisible( elem.ownerindex, elem.ownerpartdisplaymode ) ) return; const auto& component = m_components.at( symbol->first ); @@ -503,6 +504,8 @@ void SCH_ALTIUM_PLUGIN::ParsePin( const std::map& aPropertie LIB_PIN* pin = new LIB_PIN( symbol->second ); symbol->second->AddDrawItem( pin ); + pin->SetUnit( elem.ownerpartid ); + pin->SetName( elem.name ); pin->SetNumber( elem.designator ); pin->SetLength( elem.pinlength ); @@ -705,6 +708,8 @@ void SCH_ALTIUM_PLUGIN::ParseLabel( const std::map& aPropert LIB_TEXT* text = new LIB_TEXT( symbol->second ); symbol->second->AddDrawItem( text ); + text->SetUnit( elem.ownerpartid ); + text->SetPosition( GetRelativePosition( elem.location + m_sheetOffset, component ) ); text->SetText( elem.text ); @@ -787,7 +792,7 @@ void SCH_ALTIUM_PLUGIN::ParseBezier( const std::map& aProper return; } - if( !IsCmpPartVisible( elem.ownerindex, elem.ownerpartid, elem.ownerpartdisplaymode ) ) + if( !IsComponentPartVisible( elem.ownerindex, elem.ownerpartdisplaymode ) ) return; const auto& component = m_components.at( symbol->first ); @@ -800,6 +805,8 @@ void SCH_ALTIUM_PLUGIN::ParseBezier( const std::map& aProper LIB_POLYLINE* line = new LIB_POLYLINE( symbol->second ); symbol->second->AddDrawItem( line ); + line->SetUnit( elem.ownerpartid ); + for( size_t j = i; j < elem.points.size() && j < i + 2; j++ ) { line->AddPoint( @@ -814,6 +821,8 @@ void SCH_ALTIUM_PLUGIN::ParseBezier( const std::map& aProper LIB_BEZIER* bezier = new LIB_BEZIER( symbol->second ); symbol->second->AddDrawItem( bezier ); + bezier->SetUnit( elem.ownerpartid ); + for( size_t j = i; j < elem.points.size() && j < i + 4; j++ ) { bezier->AddPoint( @@ -875,7 +884,7 @@ void SCH_ALTIUM_PLUGIN::ParsePolyline( const std::map& aProp return; } - if( !IsCmpPartVisible( elem.ownerindex, elem.ownerpartid, elem.ownerpartdisplaymode ) ) + if( !IsComponentPartVisible( elem.ownerindex, elem.ownerpartdisplaymode ) ) return; const auto& component = m_components.at( symbol->first ); @@ -883,6 +892,8 @@ void SCH_ALTIUM_PLUGIN::ParsePolyline( const std::map& aProp LIB_POLYLINE* line = new LIB_POLYLINE( symbol->second ); symbol->second->AddDrawItem( line ); + line->SetUnit( elem.ownerpartid ); + for( wxPoint& point : elem.points ) { line->AddPoint( GetRelativePosition( point + m_sheetOffset, component ) ); @@ -934,7 +945,7 @@ void SCH_ALTIUM_PLUGIN::ParsePolygon( const std::map& aPrope return; } - if( !IsCmpPartVisible( elem.ownerindex, elem.ownerpartid, elem.ownerpartdisplaymode ) ) + if( !IsComponentPartVisible( elem.ownerindex, elem.ownerpartdisplaymode ) ) return; const auto& component = m_components.at( symbol->first ); @@ -942,6 +953,8 @@ void SCH_ALTIUM_PLUGIN::ParsePolygon( const std::map& aPrope LIB_POLYLINE* line = new LIB_POLYLINE( symbol->second ); symbol->second->AddDrawItem( line ); + line->SetUnit( elem.ownerpartid ); + for( wxPoint& point : elem.points ) { line->AddPoint( GetRelativePosition( point + m_sheetOffset, component ) ); @@ -1014,7 +1027,7 @@ void SCH_ALTIUM_PLUGIN::ParseRoundRectangle( const std::map& return; } - if( !IsCmpPartVisible( elem.ownerindex, elem.ownerpartid, elem.ownerpartdisplaymode ) ) + if( !IsComponentPartVisible( elem.ownerindex, elem.ownerpartdisplaymode ) ) return; const auto& component = m_components.at( symbol->first ); @@ -1022,6 +1035,9 @@ void SCH_ALTIUM_PLUGIN::ParseRoundRectangle( const std::map& // TODO: misses rounded edges LIB_RECTANGLE* rect = new LIB_RECTANGLE( symbol->second ); symbol->second->AddDrawItem( rect ); + + rect->SetUnit( elem.ownerpartid ); + rect->SetPosition( GetRelativePosition( elem.topRight + m_sheetOffset, component ) ); rect->SetEnd( GetRelativePosition( elem.bottomLeft + m_sheetOffset, component ) ); rect->SetWidth( elem.lineWidth ); @@ -1056,7 +1072,7 @@ void SCH_ALTIUM_PLUGIN::ParseArc( const std::map& aPropertie return; } - if( !IsCmpPartVisible( elem.ownerindex, elem.ownerpartid, elem.ownerpartdisplaymode ) ) + if( !IsComponentPartVisible( elem.ownerindex, elem.ownerpartdisplaymode ) ) return; const auto& component = m_components.at( symbol->first ); @@ -1066,6 +1082,8 @@ void SCH_ALTIUM_PLUGIN::ParseArc( const std::map& aPropertie LIB_CIRCLE* circle = new LIB_CIRCLE( symbol->second ); symbol->second->AddDrawItem( circle ); + circle->SetUnit( elem.ownerpartid ); + circle->SetPosition( GetRelativePosition( elem.center + m_sheetOffset, component ) ); circle->SetRadius( elem.radius ); circle->SetWidth( elem.lineWidth ); @@ -1075,6 +1093,8 @@ void SCH_ALTIUM_PLUGIN::ParseArc( const std::map& aPropertie LIB_ARC* arc = new LIB_ARC( symbol->second ); symbol->second->AddDrawItem( arc ); + arc->SetUnit( elem.ownerpartid ); + // TODO: correct? arc->SetPosition( GetRelativePosition( elem.center + m_sheetOffset, component ) ); arc->SetRadius( elem.radius ); @@ -1112,7 +1132,7 @@ void SCH_ALTIUM_PLUGIN::ParseLine( const std::map& aProperti return; } - if( !IsCmpPartVisible( elem.ownerindex, elem.ownerpartid, elem.ownerpartdisplaymode ) ) + if( !IsComponentPartVisible( elem.ownerindex, elem.ownerpartdisplaymode ) ) return; const auto& component = m_components.at( symbol->first ); @@ -1120,6 +1140,8 @@ void SCH_ALTIUM_PLUGIN::ParseLine( const std::map& aProperti LIB_POLYLINE* line = new LIB_POLYLINE( symbol->second ); symbol->second->AddDrawItem( line ); + line->SetUnit( elem.ownerpartid ); + line->AddPoint( GetRelativePosition( elem.point1 + m_sheetOffset, component ) ); line->AddPoint( GetRelativePosition( elem.point2 + m_sheetOffset, component ) ); @@ -1181,13 +1203,16 @@ void SCH_ALTIUM_PLUGIN::ParseRectangle( const std::map& aPro return; } - if( !IsCmpPartVisible( elem.ownerindex, elem.ownerpartid, elem.ownerpartdisplaymode ) ) + if( !IsComponentPartVisible( elem.ownerindex, elem.ownerpartdisplaymode ) ) return; const auto& component = m_components.at( symbol->first ); LIB_RECTANGLE* rect = new LIB_RECTANGLE( symbol->second ); symbol->second->AddDrawItem( rect ); + + rect->SetUnit( elem.ownerpartid ); + rect->SetPosition( GetRelativePosition( sheetTopRight, component ) ); rect->SetEnd( GetRelativePosition( sheetBottomLeft, component ) ); rect->SetWidth( elem.lineWidth ); diff --git a/eeschema/sch_plugins/altium/sch_altium_plugin.h b/eeschema/sch_plugins/altium/sch_altium_plugin.h index ab39d171b2..6974c725ef 100644 --- a/eeschema/sch_plugins/altium/sch_altium_plugin.h +++ b/eeschema/sch_plugins/altium/sch_altium_plugin.h @@ -102,7 +102,7 @@ public: void Parse( const CFB::CompoundFileReader& aReader ); private: - bool IsCmpPartVisible( int aOwnerindex, int aOwnerpartid, int aOwnerpartdisplaymode ) const; + bool IsComponentPartVisible( int aOwnerindex, int aOwnerpartdisplaymode ) const; void ParseComponent( int index, const std::map& aProperties ); void ParsePin( const std::map& aProperties );