Commit b8a2c4e2 authored by Andrey Fedorushkov's avatar Andrey Fedorushkov

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

parent f49c2779
......@@ -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 )
{
......
......@@ -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 );
}
......
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment