@ -787,13 +787,6 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode, int aSheetIndex )
translation . x = translation . x - translation . x % 100 ;
translation . y = translation . y - translation . y % 100 ;
// Translate the items.
for ( SCH_ITEM * item = m_currentSheet - > GetScreen ( ) - > GetDrawItems ( ) ; item ; item = item - > Next ( ) )
{
item - > SetPosition ( item - > GetPosition ( ) + translation ) ;
item - > ClearFlags ( ) ;
}
// Add global net labels for the named power input pins in this sheet
for ( SCH_ITEM * item = m_currentSheet - > GetScreen ( ) - > GetDrawItems ( ) ; item ; item = item - > Next ( ) )
{
@ -802,6 +795,15 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode, int aSheetIndex )
addImplicitConnections ( static_cast < SCH_COMPONENT * > ( item ) , m_currentSheet - > GetScreen ( ) , true ) ;
}
m_connPoints . clear ( ) ;
// Translate the items.
for ( SCH_ITEM * item = m_currentSheet - > GetScreen ( ) - > GetDrawItems ( ) ; item ; item = item - > Next ( ) )
{
item - > SetPosition ( item - > GetPosition ( ) + translation ) ;
item - > ClearFlags ( ) ;
}
}
@ -941,6 +943,9 @@ SCH_LINE* SCH_EAGLE_PLUGIN::loadWire( wxXmlNode* aWireNode )
wire - > SetStartPoint ( begin ) ;
wire - > SetEndPoint ( end ) ;
m_connPoints [ begin ] . emplace ( wire . get ( ) ) ;
m_connPoints [ end ] . emplace ( wire . get ( ) ) ;
return wire . release ( ) ;
}
@ -1193,6 +1198,18 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
component - > GetField ( REFERENCE ) - > SetVisible ( false ) ;
}
// Save the pin positions
auto & schLibTable = * m_kiway - > Prj ( ) . SchSymbolLibTable ( ) ;
wxCHECK ( component - > Resolve ( schLibTable ) , /*void*/ ) ;
component - > UpdatePinCache ( ) ;
std : : vector < LIB_PIN * > pins ;
component - > GetPins ( pins ) ;
for ( const auto & pin : pins )
m_connPoints [ component - > GetPinPhysicalPosition ( pin ) ] . emplace ( pin ) ;
component - > ClearFlags ( ) ;
screen - > Append ( component . release ( ) ) ;
@ -2469,11 +2486,24 @@ const SEG* SCH_EAGLE_PLUGIN::SEG_DESC::LabelAttached( const SCH_TEXT* aLabel ) c
}
// TODO could be used to place junctions, instead of IsJunctionNeeded() (see SCH_EDIT_FRAME::importFile())
bool SCH_EAGLE_PLUGIN : : checkConnections ( const SCH_COMPONENT * aComponent , const LIB_PIN * aPin ) const
{
wxPoint pinPosition = aComponent - > GetPinPhysicalPosition ( aPin ) ;
auto pointIt = m_connPoints . find ( pinPosition ) ;
if ( pointIt = = m_connPoints . end ( ) )
return false ;
const auto & items = pointIt - > second ;
wxASSERT ( items . find ( aPin ) ! = items . end ( ) ) ;
return items . size ( ) > 1 ;
}
void SCH_EAGLE_PLUGIN : : addImplicitConnections ( SCH_COMPONENT * aComponent ,
SCH_SCREEN * aScreen , bool aUpdateSet )
{
auto & schLibTable = * m_kiway - > Prj ( ) . SchSymbolLibTable ( ) ;
wxCHECK ( aComponent - > Resolve ( schLibTable ) , /*void*/ ) ;
aComponent - > UpdatePinCache ( ) ;
auto partRef = aComponent - > GetPartRef ( ) . lock ( ) ;
wxCHECK ( partRef , /*void*/ ) ;
@ -2494,7 +2524,10 @@ void SCH_EAGLE_PLUGIN::addImplicitConnections( SCH_COMPONENT* aComponent,
{
if ( pin - > GetType ( ) = = PIN_POWER_IN )
{
if ( ! unit | | pin - > GetUnit ( ) = = unit )
bool pinInUnit = ! unit | | pin - > GetUnit ( ) = = unit ; // pin belongs to the tested unit
// Create a global net label only if there are no other wires/pins attached
if ( pinInUnit & & ! checkConnections ( aComponent , pin ) )
{
// Create a net label to force the net name on the pin
SCH_GLOBALLABEL * netLabel = new SCH_GLOBALLABEL ;
@ -2505,7 +2538,7 @@ void SCH_EAGLE_PLUGIN::addImplicitConnections( SCH_COMPONENT* aComponent,
aScreen - > Append ( netLabel ) ;
}
else if ( aUpdateSet )
else if ( ! pinInUnit & & aUpdateSet )
{
// Found a pin creating implicit connection information in another unit.
// Such units will be instantiated if they do not appear in another sheet and