mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
ADDED: extra info for shape, pin and field differences.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/21647
This commit is contained in:
parent
8d8bd7253f
commit
976278e5a6
@ -1542,7 +1542,7 @@ std::vector<LIB_SYMBOL_UNIT> LIB_SYMBOL::GetUnitDrawItems()
|
|||||||
|
|
||||||
|
|
||||||
#define REPORT( msg ) { if( aReporter ) aReporter->Report( msg ); }
|
#define REPORT( msg ) { if( aReporter ) aReporter->Report( msg ); }
|
||||||
#define ITEM_DESC( item ) ( item )->GetItemDescription( &unitsProvider, true )
|
#define ITEM_DESC( item ) ( item )->GetItemDescription( &unitsProvider, false )
|
||||||
|
|
||||||
int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aReporter ) const
|
int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aReporter ) const
|
||||||
{
|
{
|
||||||
@ -1586,35 +1586,34 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR
|
|||||||
return retv;
|
return retv;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure shapes and pins are sorted. No need with fields as those are
|
// Make sure shapes are sorted. No need with fields or pins as those are matched by id/name and number.
|
||||||
// matched by id/name.
|
|
||||||
|
|
||||||
std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> aShapes;
|
std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> aShapes;
|
||||||
std::set<const SCH_ITEM*> aFields;
|
std::set<const SCH_FIELD*> aFields;
|
||||||
std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> aPins;
|
std::set<const SCH_PIN*> aPins;
|
||||||
|
|
||||||
for( auto it = m_drawings.begin(); it != m_drawings.end(); ++it )
|
for( auto it = m_drawings.begin(); it != m_drawings.end(); ++it )
|
||||||
{
|
{
|
||||||
if( it->Type() == SCH_SHAPE_T )
|
if( it->Type() == SCH_SHAPE_T )
|
||||||
aShapes.insert( &(*it) );
|
aShapes.insert( &(*it) );
|
||||||
else if( it->Type() == SCH_FIELD_T )
|
else if( it->Type() == SCH_FIELD_T )
|
||||||
aFields.insert( &(*it) );
|
aFields.insert( static_cast<const SCH_FIELD*>( &(*it) ) );
|
||||||
else if( it->Type() == SCH_PIN_T )
|
else if( it->Type() == SCH_PIN_T )
|
||||||
aPins.insert( &(*it) );
|
aPins.insert( static_cast<const SCH_PIN*>( &(*it) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> bShapes;
|
std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> bShapes;
|
||||||
std::set<const SCH_ITEM*> bFields;
|
std::set<const SCH_FIELD*> bFields;
|
||||||
std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> bPins;
|
std::set<const SCH_PIN*> bPins;
|
||||||
|
|
||||||
for( auto it = aRhs.m_drawings.begin(); it != aRhs.m_drawings.end(); ++it )
|
for( auto it = aRhs.m_drawings.begin(); it != aRhs.m_drawings.end(); ++it )
|
||||||
{
|
{
|
||||||
if( it->Type() == SCH_SHAPE_T )
|
if( it->Type() == SCH_SHAPE_T )
|
||||||
bShapes.insert( &(*it) );
|
bShapes.insert( &(*it) );
|
||||||
else if( it->Type() == SCH_FIELD_T )
|
else if( it->Type() == SCH_FIELD_T )
|
||||||
bFields.insert( &(*it) );
|
bFields.insert( static_cast<const SCH_FIELD*>( &(*it) ) );
|
||||||
else if( it->Type() == SCH_PIN_T )
|
else if( it->Type() == SCH_PIN_T )
|
||||||
bPins.insert( &(*it) );
|
bPins.insert( static_cast<const SCH_PIN*>( &(*it) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( int tmp = static_cast<int>( aShapes.size() - bShapes.size() ) )
|
if( int tmp = static_cast<int>( aShapes.size() - bShapes.size() ) )
|
||||||
@ -1632,7 +1631,9 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR
|
|||||||
if( int tmp2 = (*aIt)->compare( *(*bIt), aCompareFlags ) )
|
if( int tmp2 = (*aIt)->compare( *(*bIt), aCompareFlags ) )
|
||||||
{
|
{
|
||||||
retv = tmp2;
|
retv = tmp2;
|
||||||
REPORT( wxString::Format( _( "%s differs." ), ITEM_DESC( *aIt ) ) );
|
REPORT( wxString::Format( _( "Graphic item differs: %s; %s." ),
|
||||||
|
ITEM_DESC( *aIt ),
|
||||||
|
ITEM_DESC( *bIt ) ) );
|
||||||
|
|
||||||
if( !aReporter )
|
if( !aReporter )
|
||||||
return retv;
|
return retv;
|
||||||
@ -1640,46 +1641,48 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( int tmp = static_cast<int>( aPins.size() - bPins.size() ) )
|
for( const SCH_PIN* aPin : aPins )
|
||||||
{
|
{
|
||||||
retv = tmp;
|
const SCH_PIN* bPin = aRhs.GetPin( aPin->GetNumber(), aPin->GetUnit(), aPin->GetBodyStyle() );
|
||||||
REPORT( _( "Pin count differs." ) );
|
|
||||||
|
|
||||||
if( !aReporter )
|
|
||||||
return retv;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for( const SCH_ITEM* aPinItem : aPins )
|
|
||||||
{
|
|
||||||
const SCH_PIN* aPin = static_cast<const SCH_PIN*>( aPinItem );
|
|
||||||
const SCH_PIN* bPin = aRhs.GetPin( aPin->GetNumber(), aPin->GetUnit(),
|
|
||||||
aPin->GetBodyStyle() );
|
|
||||||
|
|
||||||
if( !bPin )
|
if( !bPin )
|
||||||
{
|
{
|
||||||
retv = 1;
|
retv = 1;
|
||||||
REPORT( wxString::Format( _( "Pin %s not found." ), aPin->GetNumber() ) );
|
REPORT( wxString::Format( _( "Extra pin in schematic symbol: %s." ), ITEM_DESC( aPin ) ) );
|
||||||
|
|
||||||
if( !aReporter )
|
if( !aReporter )
|
||||||
return retv;
|
return retv;
|
||||||
}
|
}
|
||||||
else if( int tmp2 = aPinItem->compare( *bPin, aCompareFlags ) )
|
else if( int tmp = aPin->SCH_ITEM::compare( *bPin, aCompareFlags ) )
|
||||||
{
|
{
|
||||||
retv = tmp2;
|
retv = tmp;
|
||||||
REPORT( wxString::Format( _( "Pin %s differs." ), aPin->GetNumber() ) );
|
REPORT( wxString::Format( _( "Pin %s differs: %s; %s" ),
|
||||||
|
aPin->GetNumber(),
|
||||||
|
ITEM_DESC( aPin ),
|
||||||
|
ITEM_DESC( bPin ) ) );
|
||||||
|
|
||||||
if( !aReporter )
|
if( !aReporter )
|
||||||
return retv;
|
return retv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for( const SCH_PIN* bPin : bPins )
|
||||||
|
{
|
||||||
|
const SCH_PIN* aPin = aRhs.GetPin( bPin->GetNumber(), bPin->GetUnit(), bPin->GetBodyStyle() );
|
||||||
|
|
||||||
|
if( !aPin )
|
||||||
|
{
|
||||||
|
retv = 1;
|
||||||
|
REPORT( wxString::Format( _( "Missing pin in schematic symbol: %s." ), ITEM_DESC( bPin ) ) );
|
||||||
|
|
||||||
|
if( !aReporter )
|
||||||
|
return retv;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for( const SCH_ITEM* aFieldItem : aFields )
|
for( const SCH_FIELD* aField : aFields )
|
||||||
{
|
{
|
||||||
const SCH_FIELD* aField = static_cast<const SCH_FIELD*>( aFieldItem );
|
|
||||||
const SCH_FIELD* bField = nullptr;
|
const SCH_FIELD* bField = nullptr;
|
||||||
int tmp = 0;
|
|
||||||
|
|
||||||
if( aField->IsMandatory() )
|
if( aField->IsMandatory() )
|
||||||
bField = aRhs.GetField( aField->GetId() );
|
bField = aRhs.GetField( aField->GetId() );
|
||||||
@ -1687,33 +1690,49 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR
|
|||||||
bField = aRhs.GetField( aField->GetName() );
|
bField = aRhs.GetField( aField->GetName() );
|
||||||
|
|
||||||
if( !bField )
|
if( !bField )
|
||||||
tmp = 1;
|
{
|
||||||
|
retv = 1;
|
||||||
|
REPORT( wxString::Format( _( "Extra field in schematic symbol: %s." ), ITEM_DESC( aField ) ) );
|
||||||
|
|
||||||
|
if( !aReporter )
|
||||||
|
return retv;
|
||||||
|
}
|
||||||
|
else if( int tmp = aField->SCH_ITEM::compare( *bField, aCompareFlags ) )
|
||||||
|
{
|
||||||
|
retv = tmp;
|
||||||
|
REPORT( wxString::Format( _( "Field '%s' differs: %s; %s." ),
|
||||||
|
aField->GetName( false ),
|
||||||
|
ITEM_DESC( aField ),
|
||||||
|
ITEM_DESC( bField ) ) );
|
||||||
|
|
||||||
|
if( !aReporter )
|
||||||
|
return retv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for( const SCH_FIELD* bField : bFields )
|
||||||
|
{
|
||||||
|
const SCH_FIELD* aField = nullptr;
|
||||||
|
|
||||||
|
if( bField->IsMandatory() )
|
||||||
|
aField = aRhs.GetField( bField->GetId() );
|
||||||
else
|
else
|
||||||
tmp = aFieldItem->compare( *bField, aCompareFlags );
|
aField = aRhs.GetField( bField->GetName() );
|
||||||
|
|
||||||
if( tmp )
|
if( !aField )
|
||||||
{
|
{
|
||||||
retv = tmp;
|
retv = 1;
|
||||||
REPORT( wxString::Format( _( "%s field differs." ), aField->GetName( false ) ) );
|
REPORT( wxString::Format( _( "Missing field in schematic symbol: %s." ), ITEM_DESC( bField ) ) );
|
||||||
|
|
||||||
if( !aReporter )
|
if( !aReporter )
|
||||||
return retv;
|
return retv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( int tmp = static_cast<int>( aFields.size() - bFields.size() ) )
|
|
||||||
{
|
|
||||||
retv = tmp;
|
|
||||||
REPORT( _( "Field count differs." ) );
|
|
||||||
|
|
||||||
if( !aReporter )
|
|
||||||
return retv;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( int tmp = static_cast<int>( m_fpFilters.GetCount() - aRhs.m_fpFilters.GetCount() ) )
|
if( int tmp = static_cast<int>( m_fpFilters.GetCount() - aRhs.m_fpFilters.GetCount() ) )
|
||||||
{
|
{
|
||||||
retv = tmp;
|
retv = tmp;
|
||||||
REPORT( _( "Footprint filters differs." ) );
|
REPORT( _( "Footprint filter count differs." ) );
|
||||||
|
|
||||||
if( !aReporter )
|
if( !aReporter )
|
||||||
return retv;
|
return retv;
|
||||||
|
@ -974,9 +974,19 @@ void SCH_FIELD::CalcEdit( const VECTOR2I& aPosition )
|
|||||||
|
|
||||||
wxString SCH_FIELD::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
|
wxString SCH_FIELD::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
|
||||||
{
|
{
|
||||||
|
wxString content = aFull ? GetShownText( false ) : KIUI::EllipsizeMenuText( GetText() );
|
||||||
|
|
||||||
|
if( content.IsEmpty() )
|
||||||
|
{
|
||||||
|
return wxString::Format( _( "Field %s (empty)" ),
|
||||||
|
UnescapeString( GetName() ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return wxString::Format( _( "Field %s '%s'" ),
|
return wxString::Format( _( "Field %s '%s'" ),
|
||||||
UnescapeString( GetName() ),
|
UnescapeString( GetName() ),
|
||||||
aFull ? GetShownText( false ) : KIUI::EllipsizeMenuText( GetText() ) );
|
content );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1936,11 +1936,21 @@ wxString SCH_DIRECTIVE_LABEL::GetItemDescription( UNITS_PROVIDER* aUnitsProvider
|
|||||||
return _( "Directive Label" );
|
return _( "Directive Label" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
const SCH_FIELD& firstField = m_fields[0];
|
||||||
|
wxString content = aFull ? firstField.GetShownText( false ) : KIUI::EllipsizeMenuText( firstField.GetText() );
|
||||||
|
|
||||||
|
if( content.IsEmpty() )
|
||||||
|
{
|
||||||
|
return wxString::Format( _( "Directive Label [%s (empty)]" ),
|
||||||
|
UnescapeString( m_fields[0].GetName() ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return wxString::Format( _( "Directive Label [%s %s]" ),
|
return wxString::Format( _( "Directive Label [%s %s]" ),
|
||||||
UnescapeString( m_fields[0].GetName() ),
|
UnescapeString( m_fields[0].GetName() ),
|
||||||
aFull ? m_fields[0].GetShownText( false )
|
content );
|
||||||
: KIUI::EllipsizeMenuText( m_fields[0].GetText() ) );
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1169,7 +1169,7 @@ wxString SCH_SHEET::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFu
|
|||||||
{
|
{
|
||||||
const SCH_FIELD* sheetnameField = GetField( FIELD_T::SHEET_NAME );
|
const SCH_FIELD* sheetnameField = GetField( FIELD_T::SHEET_NAME );
|
||||||
|
|
||||||
return wxString::Format( _( "Hierarchical Sheet %s" ),
|
return wxString::Format( _( "Hierarchical Sheet '%s'" ),
|
||||||
aFull ? sheetnameField->GetShownText( false )
|
aFull ? sheetnameField->GetShownText( false )
|
||||||
: KIUI::EllipsizeMenuText( sheetnameField->GetText() ) );
|
: KIUI::EllipsizeMenuText( sheetnameField->GetText() ) );
|
||||||
}
|
}
|
||||||
|
@ -328,7 +328,7 @@ void SCH_SHEET_PIN::GetEndPoints( std::vector<DANGLING_END_ITEM>& aItemList )
|
|||||||
|
|
||||||
wxString SCH_SHEET_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
|
wxString SCH_SHEET_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
|
||||||
{
|
{
|
||||||
return wxString::Format( _( "Hierarchical Sheet Pin %s" ),
|
return wxString::Format( _( "Hierarchical Sheet Pin '%s'" ),
|
||||||
aFull ? GetShownText( false ) : KIUI::EllipsizeMenuText( GetText() ) );
|
aFull ? GetShownText( false ) : KIUI::EllipsizeMenuText( GetText() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user