Commit 938cb884 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Schematic reference object improvements and doxygen comment warning fixes.

* More schematic reference list object refactoring.
* Initial encapsultation of schematic reference object.
* Improve schematic reference object doxygen comments.
* Remove redundant library component lookup when generating net list.
* Fix doxygen waring in LIB_PIN object.
parent 9618c3a5
This diff is collapsed.
......@@ -43,15 +43,7 @@
/* sort function to annotate items from their position.
* Components are sorted
* by reference
* if same reference: by sheet
* if same sheet, by X pos
* if same X pos, by Y pos
* if same Y pos, by time stamp
*/
bool SCH_REFERENCE_LIST::sortBy_X_Position( const SCH_REFERENCE& item1,
bool SCH_REFERENCE_LIST::sortByXPosition( const SCH_REFERENCE& item1,
const SCH_REFERENCE& item2 )
{
int ii = item1.CompareRef( item2 );
......@@ -69,15 +61,7 @@ bool SCH_REFERENCE_LIST::sortBy_X_Position( const SCH_REFERENCE& item1,
}
/* sort function to annotate items by their position.
* Components are sorted
* by reference
* if same reference: by sheet
* if same sheet, by Y pos
* if same Y pos, by X pos
* if same X pos, by time stamp
*/
bool SCH_REFERENCE_LIST::sortBy_Y_Position( const SCH_REFERENCE& item1,
bool SCH_REFERENCE_LIST::sortByYPosition( const SCH_REFERENCE& item1,
const SCH_REFERENCE& item2 )
{
int ii = item1.CompareRef( item2 );
......@@ -94,16 +78,9 @@ bool SCH_REFERENCE_LIST::sortBy_Y_Position( const SCH_REFERENCE& item1,
return ii < 0;
}
/*
* sort function to annotate items by value
* Components are sorted
* by reference
* if same reference: by value
* if same value: by unit number
* if same unit number, by sheet
* if same sheet, by position X, and Y
*/
bool SCH_REFERENCE_LIST::sortByRefAndValue( const SCH_REFERENCE& item1, const SCH_REFERENCE& item2 )
bool SCH_REFERENCE_LIST::sortByRefAndValue( const SCH_REFERENCE& item1,
const SCH_REFERENCE& item2 )
{
int ii = item1.CompareRef( item2 );
if( ii == 0 )
......@@ -122,13 +99,9 @@ bool SCH_REFERENCE_LIST::sortByRefAndValue( const SCH_REFERENCE& item1, const SC
return ii < 0;
}
/* sort function for for list by values
* components are sorted
* by value
* if same value: by reference
* if same reference: by unit number
*/
bool SCH_REFERENCE_LIST::sortComponentsByValueOnly( const SCH_REFERENCE& item1, const SCH_REFERENCE& item2 )
bool SCH_REFERENCE_LIST::sortByValueOnly( const SCH_REFERENCE& item1,
const SCH_REFERENCE& item2 )
{
int ii;
const wxString* Text1, * Text2;
......@@ -150,15 +123,8 @@ bool SCH_REFERENCE_LIST::sortComponentsByValueOnly( const SCH_REFERENCE& item1,
return ii < 0;
}
/**
* Function sortComponentsByReferenceOnly
* compare function for sorting in BOM creation.
* components are sorted
* by reference
* if same reference: by value
* if same value: by unit number
*/
bool SCH_REFERENCE_LIST::sortComponentsByReferenceOnly( const SCH_REFERENCE& item1,
bool SCH_REFERENCE_LIST::sortByReferenceOnly( const SCH_REFERENCE& item1,
const SCH_REFERENCE& item2 )
{
int ii;
......@@ -182,10 +148,6 @@ bool SCH_REFERENCE_LIST::sortComponentsByReferenceOnly( const SCH_REFERENCE& ite
}
/*****************************************************************************
* qsort function to annotate items by value
* Components are sorted by time stamp
*****************************************************************************/
bool SCH_REFERENCE_LIST::sortByTimeStamp( const SCH_REFERENCE& item1,
const SCH_REFERENCE& item2 )
{
......@@ -198,10 +160,32 @@ bool SCH_REFERENCE_LIST::sortByTimeStamp( const SCH_REFERENCE& item1,
}
int SCH_REFERENCE_LIST::FindUnit( size_t aIndex, int aUnit )
{
int NumRef;
NumRef = componentFlatList[aIndex].m_NumRef;
for( size_t ii = 0; ii < componentFlatList.size(); ii++ )
{
if( ( aIndex == ii )
|| ( componentFlatList[ii].m_IsNew )
|| ( componentFlatList[ii].m_NumRef != NumRef )
|| ( componentFlatList[aIndex].CompareRef( componentFlatList[ii] ) != 0 ) )
continue;
if( componentFlatList[ii].m_Unit == aUnit )
return (int) ii;
}
return -1;
}
/* Remove sub components from the list, when multiples parts per package are
* found in this list
*/
void SCH_REFERENCE_LIST::RemoveSubComponentsFromList( )
void SCH_REFERENCE_LIST::RemoveSubComponentsFromList()
{
SCH_COMPONENT* libItem;
wxString oldName;
......@@ -209,7 +193,8 @@ void SCH_REFERENCE_LIST::RemoveSubComponentsFromList( )
// The component list **MUST** be sorted by reference and by unit number
// in order to find all parts of a component
SortComponentsByReferenceOnly();
SortByReferenceOnly();
for( unsigned ii = 0; ii < componentFlatList.size(); ii++ )
{
libItem = componentFlatList[ii].m_RootCmp;
......@@ -220,18 +205,72 @@ void SCH_REFERENCE_LIST::RemoveSubComponentsFromList( )
if( !oldName.IsEmpty() )
{
if( oldName == currName ) // currName is a subpart of oldName:
// remove it
if( oldName == currName ) // currName is a subpart of oldName: remove it
{
componentFlatList.erase( componentFlatList.begin() + ii );
ii--;
}
}
oldName = currName;
}
}
void SCH_REFERENCE_LIST::ResetHiddenReferences()
{
for( unsigned ii = 0; ii < componentFlatList.size(); ii++ )
{
if( componentFlatList[ii].GetRefStr()[0] == '#' )
{
componentFlatList[ii].m_IsNew = true;
componentFlatList[ii].m_NumRef = 0;
}
}
}
void SCH_REFERENCE_LIST::GetRefsInUse( int aIndex, std::vector< int >& aIdList, int aMinRefId )
{
aIdList.clear();
for( unsigned ii = 0; ii < componentFlatList.size(); ii++ )
{
if( ( componentFlatList[aIndex].CompareRef( componentFlatList[ii] ) == 0 )
&& ( componentFlatList[ii].m_NumRef >= aMinRefId ) )
aIdList.push_back( componentFlatList[ii].m_NumRef );
}
sort( aIdList.begin(), aIdList.end() );
// Ensure each reference number appears only once. If there are components with
// multiple parts per package the same number will be stored for each part.
std::vector< int >::iterator it = unique( aIdList.begin(), aIdList.end() );
// Using the C++ unique algorithm only moves the duplicate entries to the end of
// of the array. This removes the duplicate entries from the array.
aIdList.resize( it - aIdList.begin() );
}
int SCH_REFERENCE_LIST::GetLastReference( int aIndex, int aMinValue )
{
int lastNumber = aMinValue;
for( unsigned ii = 0; ii < componentFlatList.size(); ii++ )
{
// search only for the current reference prefix:
if( componentFlatList[aIndex].CompareRef( componentFlatList[ii] ) != 0 )
continue;
// update max value for the current reference prefix
if( lastNumber < componentFlatList[ii].m_NumRef )
lastNumber = componentFlatList[ii].m_NumRef;
}
return lastNumber;
}
SCH_REFERENCE::SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_COMPONENT* aLibComponent,
SCH_SHEET_PATH& aSheetPath )
......
......@@ -408,7 +408,7 @@ void DIALOG_BUILD_BOM::CreatePartsList( const wxString& aFullFileName, bool aInc
cmplist.RemoveSubComponentsFromList();
// sort component list by value
cmplist.SortComponentsByValueOnly( );
cmplist.SortByValueOnly( );
PrintComponentsListByPart( f, cmplist,aIncludeSubComponents );
fclose( f );
......@@ -440,7 +440,7 @@ void DIALOG_BUILD_BOM::CreateExportList( const wxString& aFullFileName,
sheetList.GetComponents( cmplist, false );
// sort component list
cmplist.SortComponentsByReferenceOnly( );
cmplist.SortByReferenceOnly( );
if( !aIncludeSubComponents )
cmplist.RemoveSubComponentsFromList();
......@@ -489,7 +489,7 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName,
fprintf( f, "%s >> Creation date: %s\n", CONV_TO_UTF8( Title ), Line );
// sort component list
cmplist.SortComponentsByReferenceOnly();
cmplist.SortByReferenceOnly();
if( !aIncludeSubComponents )
cmplist.RemoveSubComponentsFromList();
......@@ -499,7 +499,7 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName,
if( m_ListCmpbyValItems->GetValue() )
{
cmplist.SortComponentsByValueOnly();
cmplist.SortByValueOnly();
PrintComponentsListByVal( f, cmplist, aIncludeSubComponents );
}
}
......@@ -632,7 +632,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( FILE* f,
// Print list of items
for( unsigned ii = 0; ii < aList.GetCount(); ii++ )
{
EDA_ITEM* item = aList[ii].m_RootCmp;
EDA_ITEM* item = aList[ii].GetComponent();
if( item == NULL )
continue;
......@@ -680,7 +680,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( FILE* f,
if( aIncludeSubComponents )
{
msg = aList[ii].m_SheetPath.PathHumanReadable();
msg = aList[ii].GetSheetPath().PathHumanReadable();
BASE_SCREEN * screen = (BASE_SCREEN*) comp->GetParent();
if( screen )
......@@ -747,10 +747,10 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( FILE* f, SCH_REFERENCE_LIST& aL
for( unsigned ii = 0; ii < aList.GetCount(); ii++ )
{
currCmp = (SCH_COMPONENT*) aList[ii].m_RootCmp;
currCmp = aList[ii].GetComponent();
if( ii < aList.GetCount() -1 )
nextCmp = aList[ii+1].m_RootCmp;
nextCmp = aList[ii+1].GetComponent();
else
nextCmp = NULL;
......@@ -882,7 +882,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal( FILE* f,
for( unsigned ii = 0; ii < aList.GetCount(); ii++ )
{
schItem = aList[ii].m_RootCmp;
schItem = aList[ii].GetComponent();
if( schItem == NULL )
continue;
......@@ -918,7 +918,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal( FILE* f,
BASE_SCREEN * screen = (BASE_SCREEN*) DrawLibItem->GetParent();
if( screen )
{
msg = aList[ii].m_SheetPath.PathHumanReadable();
msg = aList[ii].GetSheetPath().PathHumanReadable();
fprintf( f, " (Sheet %s)", CONV_TO_UTF8( msg ) );
msg = m_Parent->GetXYSheetReferences( screen, DrawLibItem->m_Pos );
fprintf( f, " (loc %s)", CONV_TO_UTF8( msg ) );
......
......@@ -1841,34 +1841,18 @@ wxArrayString LIB_PIN::GetElectricalTypeNames( void )
}
/**
* Get a list of pin electrical type icons.
* @return List of valid pin electrical type bitmaps symbols in .xpm format
* for menus and dialogs .
*/
const char*** LIB_PIN::GetElectricalTypeSymbols( void )
{
return s_icons_Pins_Electrical_Type;
}
/**
* Get a list of pin orientation icons.
*
* @return List of valid pin orientation bitmaps symbols in .xpm format
* for menus and dialogs .
*/
const char*** LIB_PIN::GetOrientationSymbols()
{
return s_icons_Pins_Orientations;
}
/**
* Get a list of pin styles bitmaps for menus and dialogs.
*
* @return List of valid pin electrical type bitmaps symbols in .xpm format.
*/
const char*** LIB_PIN::GetStyleSymbols()
{
return s_icons_Pins_Shapes;
......
......@@ -361,7 +361,7 @@ public:
static wxArrayString GetOrientationNames();
/**
* Get a list of pin orientation bitmaps for menus and dialogs..
* Get a list of pin orientation bitmaps for menus and dialogs.
*
* @return List of valid pin orientation bitmaps symbols in .xpm format
*/
......
......@@ -1370,16 +1370,13 @@ bool EXPORT_HELP::WriteNetListPCBNEW( SCH_EDIT_FRAME* frame, FILE* f, bool with_
// Get the Component FootprintFilter and put the component in
// cmpList if filter is present
LIB_COMPONENT* entry =
CMP_LIBRARY::FindLibraryComponent( comp->GetLibName() );
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( comp->GetLibName() );
if( entry )
{
if( entry->GetFootPrints().GetCount() != 0 ) // Put in list
{
cmpList.push_back( SCH_REFERENCE() );
cmpList.back().m_RootCmp = comp;
cmpList.back().SetRef( comp->GetRef( path ) );
cmpList.push_back( SCH_REFERENCE( comp, entry, *path ) );
}
}
......@@ -1442,11 +1439,10 @@ bool EXPORT_HELP::WriteNetListPCBNEW( SCH_EDIT_FRAME* frame, FILE* f, bool with_
wxString ref;
ret |= fprintf( f, "{ Allowed footprints by component:\n" );
for( unsigned ii = 0; ii < cmpList.size(); ii++ )
{
SCH_COMPONENT* comp = cmpList[ii].m_RootCmp;
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( comp->GetLibName() );
LIB_COMPONENT* entry = cmpList[ii].GetLibComponent();
ref = cmpList[ii].GetRef();
......
This diff is collapsed.
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