eeschema: fix sorting parts generate BOM "Single part per line"

This commit is contained in:
Andrey Fedorushkov 2012-03-20 18:41:57 +04:00
parent f49c27798e
commit b8a2c4e240
3 changed files with 43 additions and 2 deletions

View File

@ -106,6 +106,25 @@ bool SCH_REFERENCE_LIST::sortByRefAndValue( const SCH_REFERENCE& item1,
return ii < 0;
}
bool SCH_REFERENCE_LIST::sortByValueAndRef( const SCH_REFERENCE& item1,
const SCH_REFERENCE& item2 )
{
int ii = item1.CompareValue( item2 );
if( ii == 0 )
ii = RefDesStringCompare( item1.GetRef(), item2.GetRef() );
if( ii == 0 )
ii = item1.m_Unit - item2.m_Unit;
if( ii == 0 )
ii = item1.m_SheetNum - item2.m_SheetNum;
if( ii == 0 )
ii = item1.m_CmpPos.x - item2.m_CmpPos.x;
if( ii == 0 )
ii = item1.m_CmpPos.y - item2.m_CmpPos.y;
if( ii == 0 )
ii = item1.m_TimeStamp - item2.m_TimeStamp;
return ii < 0;
}
static bool engStrToDouble( wxString aStr, double* aDouble )
{

View File

@ -427,8 +427,8 @@ void DIALOG_BUILD_BOM::CreatePartsList( const wxString& aFullFileName, bool aInc
cmplist.RemoveSubComponentsFromList();
// sort component list by value
cmplist.SortByValueOnly( );
PrintComponentsListByPart( f, cmplist,aIncludeSubComponents );
cmplist.SortByRefAndValue( );
PrintComponentsListByPart( f, cmplist, aIncludeSubComponents );
fclose( f );
}

View File

@ -376,6 +376,26 @@ public:
sort( componentFlatList.begin(), componentFlatList.end(), sortByRefAndValue );
}
/**
* Function SortByValueAndRef
* sorts the list of references by value.
* <p>
* Components are sorted in the following order:
* <ul>
* <li>Value of component.</li>
* <li>Numeric value of reference designator.</li>
* <li>Unit number when component has multiple parts.</li>
* <li>Sheet number.</li>
* <li>X coordinate position.</li>
* <li>Y coordinate position.</li>
* </ul>
* </p>
*/
void SortByValueAndRef()
{
sort( componentFlatList.begin(), componentFlatList.end(), sortByValueAndRef );
}
/**
* Function SortByReferenceOnly
* sorts the list of references by reference.
@ -454,6 +474,8 @@ private:
static bool sortByRefAndValue( const SCH_REFERENCE& item1, const SCH_REFERENCE& item2 );
static bool sortByValueAndRef( const SCH_REFERENCE& item1, const SCH_REFERENCE& item2 );
static bool sortByXPosition( const SCH_REFERENCE& item1, const SCH_REFERENCE& item2 );
static bool sortByYPosition( const SCH_REFERENCE& item1, const SCH_REFERENCE& item2 );