wxString SCH_REFERENCE_LIST::Shorthand( std::vector<SCH_REFERENCE> aList ) { wxString retVal; std::sort( aList.begin(), aList.end(), []( const SCH_REFERENCE& lhs, const SCH_REFERENCE& rhs ) -> bool { wxString lhRef( lhs.GetRef() << lhs.GetRefNumber() ); wxString rhRef( rhs.GetRef() << rhs.GetRefNumber() ); return RefDesStringCompare( lhRef, rhRef ) < 0; } ); size_t i = 0; while( i < aList.size() ) { wxString ref = aList[ i ].GetRef(); size_t j = i; while( j + 1 < aList.size() && aList[ j + 1 ].GetRef() == ref ) j = j + 1; if( !retVal.IsEmpty() ) retVal << wxT( ", " ); if( j == i ) { retVal << ref << aList[ i ].GetRefNumber(); } else if( j == i + 1 ) { retVal << ref << aList[ i ].GetRefNumber(); retVal << wxT( ", " ); retVal << ref << aList[ j ].GetRefNumber(); } else { retVal << ref << aList[ i ].GetRefNumber(); retVal << wxT( " - " ); retVal << ref << aList[ j ].GetRefNumber(); } i = j + 1; } return retVal; }
bool SCH_REFERENCE_LIST::sortByReferenceOnly( const SCH_REFERENCE& item1, const SCH_REFERENCE& item2 ) { int ii; ii = RefDesStringCompare( item1.GetRef(), item2.GetRef() ); if( ii == 0 ) { ii = item1.m_RootCmp->GetField( VALUE )->GetText().CmpNoCase( item2.m_RootCmp->GetField( VALUE )->GetText() ); } if( ii == 0 ) { ii = item1.m_Unit - item2.m_Unit; } return ii < 0; }
static bool sortPinsByNumber( LIB_PIN* aPin1, LIB_PIN* aPin2 ) { // return "lhs < rhs" return RefDesStringCompare( aPin1->GetNumberString(), aPin2->GetNumberString() ) < 0; }
/// Comparison routine for sorting by pin numbers. static bool sortPinsByNum( NETLIST_OBJECT* aPin1, NETLIST_OBJECT* aPin2 ) { // return "lhs < rhs" return RefDesStringCompare( aPin1->GetPinNumText(), aPin2->GetPinNumText() ) < 0; }