QA was built with pin names outside but this was a bug.  For now, we
only want to test outside pin names.  The test can be expanded in the
future
This commit is contained in:
Seth Hillbrand 2025-09-12 12:52:14 -07:00
parent 2c102a62e0
commit 32ee4ebdfa
3 changed files with 69 additions and 42 deletions

View File

@ -1697,16 +1697,35 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR
if( !aReporter ) if( !aReporter )
return retv; return retv;
} }
else if( int tmp = aField->SCH_ITEM::compare( *bField, aCompareFlags ) ) else
{ {
retv = tmp; int tmp = 0;
REPORT( wxString::Format( _( "Field '%s' differs: %s; %s." ),
aField->GetName( false ),
ITEM_DESC( aField ),
ITEM_DESC( bField ) ) );
if( !aReporter ) // For EQUALITY comparison, we need to compare field content directly
return retv; // since SCH_ITEM::compare() returns 0 for EQUALITY flag
if( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::EQUALITY )
{
// Compare field text content
tmp = aField->GetText().CmpNoCase( bField->GetText() );
}
if( tmp == 0 )
{
// Fall back to base class comparison for other properties
tmp = aField->SCH_ITEM::compare( *bField, aCompareFlags );
}
if( tmp != 0 )
{
retv = tmp;
REPORT( wxString::Format( _( "Field '%s' differs: %s; %s." ),
aField->GetName( false ),
ITEM_DESC( aField ),
ITEM_DESC( bField ) ) );
if( !aReporter )
return retv;
}
} }
} }

View File

@ -750,7 +750,9 @@ std::optional<PIN_LAYOUT_CACHE::TEXT_INFO> PIN_LAYOUT_CACHE::GetPinNameInfo( int
info->m_Thickness = m_nameThickness; info->m_Thickness = m_nameThickness;
info->m_Angle = ANGLE_HORIZONTAL; info->m_Angle = ANGLE_HORIZONTAL;
if( m_pin.GetParentSymbol()->GetPinNameOffset() > 0 ) bool nameInside = m_pin.GetParentSymbol()->GetPinNameOffset() > 0;
if( nameInside )
{ {
// This means name inside the pin // This means name inside the pin
VECTOR2I pos = { m_pin.GetLength() + m_pin.GetParentSymbol()->GetPinNameOffset(), 0 }; VECTOR2I pos = { m_pin.GetLength() + m_pin.GetParentSymbol()->GetPinNameOffset(), 0 };
@ -760,6 +762,7 @@ std::optional<PIN_LAYOUT_CACHE::TEXT_INFO> PIN_LAYOUT_CACHE::GetPinNameInfo( int
info->m_TextPosition = pos + VECTOR2I{ thickOffset, 0 }; info->m_TextPosition = pos + VECTOR2I{ thickOffset, 0 };
info->m_HAlign = GR_TEXT_H_ALIGN_LEFT; info->m_HAlign = GR_TEXT_H_ALIGN_LEFT;
info->m_VAlign = GR_TEXT_V_ALIGN_CENTER; info->m_VAlign = GR_TEXT_V_ALIGN_CENTER;
transformTextForPin( *info );
} }
else else
{ {
@ -769,42 +772,44 @@ std::optional<PIN_LAYOUT_CACHE::TEXT_INFO> PIN_LAYOUT_CACHE::GetPinNameInfo( int
info->m_TextPosition = pos; info->m_TextPosition = pos;
info->m_HAlign = GR_TEXT_H_ALIGN_CENTER; info->m_HAlign = GR_TEXT_H_ALIGN_CENTER;
info->m_VAlign = GR_TEXT_V_ALIGN_BOTTOM; info->m_VAlign = GR_TEXT_V_ALIGN_BOTTOM;
}
// New policy: names follow same positioning semantics as numbers. // New policy: names follow same positioning semantics as numbers except when
const SYMBOL* parentSym = m_pin.GetParentSymbol(); // specified as inside. When names are inside, they should not overlap with the
if( parentSym ) // number position.
{ const SYMBOL* parentSym = m_pin.GetParentSymbol();
int maxHalfHeight = 0; if( parentSym )
for( const SCH_PIN* p : parentSym->GetPins() )
{ {
wxString n = p->GetShownName(); int maxHalfHeight = 0;
if( n.IsEmpty() ) for( const SCH_PIN* p : parentSym->GetPins() )
continue; {
maxHalfHeight = std::max( maxHalfHeight, p->GetNameTextSize() / 2 ); wxString n = p->GetShownName();
} if( n.IsEmpty() )
int clearance = getPinTextOffset() + schIUScale.MilsToIU( PIN_TEXT_MARGIN ); continue;
VECTOR2I pinPos = m_pin.GetPosition(); maxHalfHeight = std::max( maxHalfHeight, p->GetNameTextSize() / 2 );
PIN_ORIENTATION orient = m_pin.PinDrawOrient( DefaultTransform ); }
bool verticalOrient = ( orient == PIN_ORIENTATION::PIN_UP || orient == PIN_ORIENTATION::PIN_DOWN ); int clearance = getPinTextOffset() + schIUScale.MilsToIU( PIN_TEXT_MARGIN );
VECTOR2I pinPos = m_pin.GetPosition();
PIN_ORIENTATION orient = m_pin.PinDrawOrient( DefaultTransform );
bool verticalOrient = ( orient == PIN_ORIENTATION::PIN_UP || orient == PIN_ORIENTATION::PIN_DOWN );
if( verticalOrient ) if( verticalOrient )
{ {
// Vertical pins: name mirrors number placement (left + rotated) for visual consistency. // Vertical pins: name mirrors number placement (left + rotated) for visual consistency.
int boxWidth = info->m_TextSize * (int) info->m_Text.Length() * 0.6; // heuristic width int boxWidth = info->m_TextSize * (int) info->m_Text.Length() * 0.6; // heuristic width
int centerX = pinPos.x - clearance - boxWidth / 2; int centerX = pinPos.x - clearance - boxWidth / 2;
info->m_TextPosition = { centerX, pinPos.y }; info->m_TextPosition = { centerX, pinPos.y };
info->m_Angle = ANGLE_VERTICAL; info->m_Angle = ANGLE_VERTICAL;
info->m_HAlign = GR_TEXT_H_ALIGN_CENTER; info->m_HAlign = GR_TEXT_H_ALIGN_CENTER;
info->m_VAlign = GR_TEXT_V_ALIGN_CENTER; info->m_VAlign = GR_TEXT_V_ALIGN_CENTER;
} }
else else
{ {
// Horizontal pins: name above (negative Y) aligned to same Y offset logic as numbers. // Horizontal pins: name above (negative Y) aligned to same Y offset logic as numbers.
info->m_TextPosition = { pinPos.x, pinPos.y - ( maxHalfHeight + clearance ) }; info->m_TextPosition = { pinPos.x, pinPos.y - ( maxHalfHeight + clearance ) };
info->m_Angle = ANGLE_HORIZONTAL; info->m_Angle = ANGLE_HORIZONTAL;
info->m_HAlign = GR_TEXT_H_ALIGN_CENTER; info->m_HAlign = GR_TEXT_H_ALIGN_CENTER;
info->m_VAlign = GR_TEXT_V_ALIGN_CENTER; info->m_VAlign = GR_TEXT_V_ALIGN_CENTER;
}
} }
} }
return info; return info;

View File

@ -46,6 +46,9 @@ static std::unique_ptr<LIB_SYMBOL> createTestResistorSymbol()
{ {
auto symbol = std::make_unique<LIB_SYMBOL>( wxT( "TestResistor" ) ); auto symbol = std::make_unique<LIB_SYMBOL>( wxT( "TestResistor" ) );
// Set pin name offset to 0 so names are positioned outside (like numbers)
symbol->SetPinNameOffset( 0 );
// Create first pin with stacked numbers [1-5] // Create first pin with stacked numbers [1-5]
auto pin1 = std::make_unique<SCH_PIN>( symbol.get() ); auto pin1 = std::make_unique<SCH_PIN>( symbol.get() );
pin1->SetPosition( VECTOR2I( 0, schIUScale.MilsToIU( 250 ) ) ); // top pin pin1->SetPosition( VECTOR2I( 0, schIUScale.MilsToIU( 250 ) ) ); // top pin