Eeschema: fix issues related to ERC tests after changes by commit d77eae3e
It also fixes a bug in SCH_FIELD::compare()
This commit is contained in:
parent
b22bc2737e
commit
28f48cbec1
|
@ -1542,7 +1542,13 @@ int SCH_FIELD::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
|
||||||
{
|
{
|
||||||
wxASSERT( aOther.Type() == SCH_FIELD_T );
|
wxASSERT( aOther.Type() == SCH_FIELD_T );
|
||||||
|
|
||||||
int retv = SCH_ITEM::compare( aOther, aCompareFlags );
|
int compareFlags = aCompareFlags;
|
||||||
|
|
||||||
|
// For ERC tests, the field position has no matter, so do not test it
|
||||||
|
if( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::ERC )
|
||||||
|
compareFlags |= SCH_ITEM::COMPARE_FLAGS::SKIP_TST_POS;
|
||||||
|
|
||||||
|
int retv = SCH_ITEM::compare( aOther, compareFlags );
|
||||||
|
|
||||||
if( retv )
|
if( retv )
|
||||||
return retv;
|
return retv;
|
||||||
|
@ -1599,11 +1605,15 @@ int SCH_FIELD::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
|
||||||
return GetTextPos().y - tmp->GetTextPos().y;
|
return GetTextPos().y - tmp->GetTextPos().y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For ERC tests, the field size has no matter, so do not test it
|
||||||
|
if( !( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::ERC ) )
|
||||||
|
{
|
||||||
if( GetTextWidth() != tmp->GetTextWidth() )
|
if( GetTextWidth() != tmp->GetTextWidth() )
|
||||||
return GetTextWidth() - tmp->GetTextWidth();
|
return GetTextWidth() - tmp->GetTextWidth();
|
||||||
|
|
||||||
if( GetTextHeight() != tmp->GetTextHeight() )
|
if( GetTextHeight() != tmp->GetTextHeight() )
|
||||||
return GetTextHeight() - tmp->GetTextHeight();
|
return GetTextHeight() - tmp->GetTextHeight();
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -417,18 +417,30 @@ int SCH_ITEM::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
|
||||||
return m_bodyStyle - aOther.m_bodyStyle;
|
return m_bodyStyle - aOther.m_bodyStyle;
|
||||||
|
|
||||||
if( IsPrivate() != aOther.IsPrivate() )
|
if( IsPrivate() != aOther.IsPrivate() )
|
||||||
return IsPrivate() < aOther.IsPrivate();
|
return IsPrivate() ? 1 : -1;
|
||||||
|
|
||||||
|
if( !( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::SKIP_TST_POS ) )
|
||||||
|
{
|
||||||
if( GetPosition().x != aOther.GetPosition().x )
|
if( GetPosition().x != aOther.GetPosition().x )
|
||||||
return GetPosition().x < aOther.GetPosition().x;
|
return GetPosition().x - aOther.GetPosition().x;
|
||||||
|
|
||||||
if( GetPosition().y != aOther.GetPosition().y )
|
if( GetPosition().y != aOther.GetPosition().y )
|
||||||
return GetPosition().y < aOther.GetPosition().y;
|
return GetPosition().y - aOther.GetPosition().y;
|
||||||
|
}
|
||||||
|
|
||||||
if( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::EQUALITY )
|
if( ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::EQUALITY )
|
||||||
|
|| ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::ERC ) )
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return m_Uuid < aOther.m_Uuid;
|
if( m_Uuid < aOther.m_Uuid )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if( m_Uuid > aOther.m_Uuid )
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -654,17 +654,20 @@ public:
|
||||||
* UNIT This flag relaxes unit, body-style and pin-number constraints. It is used for
|
* UNIT This flag relaxes unit, body-style and pin-number constraints. It is used for
|
||||||
* #SCH_ITEM object unit comparisons.
|
* #SCH_ITEM object unit comparisons.
|
||||||
*
|
*
|
||||||
* EQUALITY This flag relaxes ordering contstraints so that fields, etc. don't have to
|
* EQUALITY This flag relaxes ordering constraints so that fields, etc. don't have to
|
||||||
* appear in the same order to be considered equal.
|
* appear in the same order to be considered equal.
|
||||||
*
|
*
|
||||||
* ERC This flag relaxes constraints on data that is settable in the schematic editor.
|
* ERC This flag relaxes constraints on data that is settable in the schematic editor.
|
||||||
* It compares only symbol-editor-only data.
|
* It compares only symbol-editor-only data.
|
||||||
|
*
|
||||||
|
* SKIP_TST_POS This flag relaxes comparisons on position (mainly for fields) for ERC.
|
||||||
*/
|
*/
|
||||||
enum COMPARE_FLAGS : int
|
enum COMPARE_FLAGS : int
|
||||||
{
|
{
|
||||||
UNIT = 0x01,
|
UNIT = 0x01,
|
||||||
EQUALITY = 0x02,
|
EQUALITY = 0x02,
|
||||||
ERC = 0x04
|
ERC = 0x04,
|
||||||
|
SKIP_TST_POS = 0x08
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual bool operator==( const SCH_ITEM& aOther ) const;
|
virtual bool operator==( const SCH_ITEM& aOther ) const;
|
||||||
|
|
Loading…
Reference in New Issue