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,16 +43,8 @@ ...@@ -43,16 +43,8 @@
/* sort function to annotate items from their position. bool SCH_REFERENCE_LIST::sortByXPosition( const SCH_REFERENCE& item1,
* Components are sorted const SCH_REFERENCE& item2 )
* 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,
const SCH_REFERENCE& item2 )
{ {
int ii = item1.CompareRef( item2 ); int ii = item1.CompareRef( item2 );
...@@ -69,16 +61,8 @@ bool SCH_REFERENCE_LIST::sortBy_X_Position( const SCH_REFERENCE& item1, ...@@ -69,16 +61,8 @@ bool SCH_REFERENCE_LIST::sortBy_X_Position( const SCH_REFERENCE& item1,
} }
/* sort function to annotate items by their position. bool SCH_REFERENCE_LIST::sortByYPosition( const SCH_REFERENCE& item1,
* Components are sorted const SCH_REFERENCE& item2 )
* 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,
const SCH_REFERENCE& item2 )
{ {
int ii = item1.CompareRef( item2 ); int ii = item1.CompareRef( item2 );
...@@ -94,16 +78,9 @@ bool SCH_REFERENCE_LIST::sortBy_Y_Position( const SCH_REFERENCE& item1, ...@@ -94,16 +78,9 @@ bool SCH_REFERENCE_LIST::sortBy_Y_Position( const SCH_REFERENCE& item1,
return ii < 0; return ii < 0;
} }
/*
* sort function to annotate items by value bool SCH_REFERENCE_LIST::sortByRefAndValue( const SCH_REFERENCE& item1,
* Components are sorted const SCH_REFERENCE& item2 )
* 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 )
{ {
int ii = item1.CompareRef( item2 ); int ii = item1.CompareRef( item2 );
if( ii == 0 ) if( ii == 0 )
...@@ -122,13 +99,9 @@ bool SCH_REFERENCE_LIST::sortByRefAndValue( const SCH_REFERENCE& item1, const SC ...@@ -122,13 +99,9 @@ bool SCH_REFERENCE_LIST::sortByRefAndValue( const SCH_REFERENCE& item1, const SC
return ii < 0; return ii < 0;
} }
/* sort function for for list by values
* components are sorted bool SCH_REFERENCE_LIST::sortByValueOnly( const SCH_REFERENCE& item1,
* by value const SCH_REFERENCE& item2 )
* if same value: by reference
* if same reference: by unit number
*/
bool SCH_REFERENCE_LIST::sortComponentsByValueOnly( const SCH_REFERENCE& item1, const SCH_REFERENCE& item2 )
{ {
int ii; int ii;
const wxString* Text1, * Text2; const wxString* Text1, * Text2;
...@@ -150,16 +123,9 @@ bool SCH_REFERENCE_LIST::sortComponentsByValueOnly( const SCH_REFERENCE& item1, ...@@ -150,16 +123,9 @@ bool SCH_REFERENCE_LIST::sortComponentsByValueOnly( const SCH_REFERENCE& item1,
return ii < 0; return ii < 0;
} }
/**
* Function sortComponentsByReferenceOnly bool SCH_REFERENCE_LIST::sortByReferenceOnly( const SCH_REFERENCE& item1,
* compare function for sorting in BOM creation. const SCH_REFERENCE& item2 )
* 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,
const SCH_REFERENCE& item2 )
{ {
int ii; int ii;
const wxString* Text1, * Text2; const wxString* Text1, * Text2;
...@@ -182,12 +148,8 @@ bool SCH_REFERENCE_LIST::sortComponentsByReferenceOnly( const SCH_REFERENCE& ite ...@@ -182,12 +148,8 @@ 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, bool SCH_REFERENCE_LIST::sortByTimeStamp( const SCH_REFERENCE& item1,
const SCH_REFERENCE& item2 ) const SCH_REFERENCE& item2 )
{ {
int ii = item1.m_SheetPath.Cmp( item2.m_SheetPath ); int ii = item1.m_SheetPath.Cmp( item2.m_SheetPath );
...@@ -198,10 +160,32 @@ bool SCH_REFERENCE_LIST::sortByTimeStamp( const SCH_REFERENCE& item1, ...@@ -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 /* Remove sub components from the list, when multiples parts per package are
* found in this list * found in this list
*/ */
void SCH_REFERENCE_LIST::RemoveSubComponentsFromList( ) void SCH_REFERENCE_LIST::RemoveSubComponentsFromList()
{ {
SCH_COMPONENT* libItem; SCH_COMPONENT* libItem;
wxString oldName; wxString oldName;
...@@ -209,7 +193,8 @@ void SCH_REFERENCE_LIST::RemoveSubComponentsFromList( ) ...@@ -209,7 +193,8 @@ void SCH_REFERENCE_LIST::RemoveSubComponentsFromList( )
// The component list **MUST** be sorted by reference and by unit number // The component list **MUST** be sorted by reference and by unit number
// in order to find all parts of a component // in order to find all parts of a component
SortComponentsByReferenceOnly(); SortByReferenceOnly();
for( unsigned ii = 0; ii < componentFlatList.size(); ii++ ) for( unsigned ii = 0; ii < componentFlatList.size(); ii++ )
{ {
libItem = componentFlatList[ii].m_RootCmp; libItem = componentFlatList[ii].m_RootCmp;
...@@ -220,18 +205,72 @@ void SCH_REFERENCE_LIST::RemoveSubComponentsFromList( ) ...@@ -220,18 +205,72 @@ void SCH_REFERENCE_LIST::RemoveSubComponentsFromList( )
if( !oldName.IsEmpty() ) if( !oldName.IsEmpty() )
{ {
if( oldName == currName ) // currName is a subpart of oldName: if( oldName == currName ) // currName is a subpart of oldName: remove it
// remove it
{ {
componentFlatList.erase( componentFlatList.begin() + ii ); componentFlatList.erase( componentFlatList.begin() + ii );
ii--; ii--;
} }
} }
oldName = currName; 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_REFERENCE::SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_COMPONENT* aLibComponent,
SCH_SHEET_PATH& aSheetPath ) SCH_SHEET_PATH& aSheetPath )
......
...@@ -408,7 +408,7 @@ void DIALOG_BUILD_BOM::CreatePartsList( const wxString& aFullFileName, bool aInc ...@@ -408,7 +408,7 @@ void DIALOG_BUILD_BOM::CreatePartsList( const wxString& aFullFileName, bool aInc
cmplist.RemoveSubComponentsFromList(); cmplist.RemoveSubComponentsFromList();
// sort component list by value // sort component list by value
cmplist.SortComponentsByValueOnly( ); cmplist.SortByValueOnly( );
PrintComponentsListByPart( f, cmplist,aIncludeSubComponents ); PrintComponentsListByPart( f, cmplist,aIncludeSubComponents );
fclose( f ); fclose( f );
...@@ -440,7 +440,7 @@ void DIALOG_BUILD_BOM::CreateExportList( const wxString& aFullFileName, ...@@ -440,7 +440,7 @@ void DIALOG_BUILD_BOM::CreateExportList( const wxString& aFullFileName,
sheetList.GetComponents( cmplist, false ); sheetList.GetComponents( cmplist, false );
// sort component list // sort component list
cmplist.SortComponentsByReferenceOnly( ); cmplist.SortByReferenceOnly( );
if( !aIncludeSubComponents ) if( !aIncludeSubComponents )
cmplist.RemoveSubComponentsFromList(); cmplist.RemoveSubComponentsFromList();
...@@ -489,7 +489,7 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName, ...@@ -489,7 +489,7 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName,
fprintf( f, "%s >> Creation date: %s\n", CONV_TO_UTF8( Title ), Line ); fprintf( f, "%s >> Creation date: %s\n", CONV_TO_UTF8( Title ), Line );
// sort component list // sort component list
cmplist.SortComponentsByReferenceOnly(); cmplist.SortByReferenceOnly();
if( !aIncludeSubComponents ) if( !aIncludeSubComponents )
cmplist.RemoveSubComponentsFromList(); cmplist.RemoveSubComponentsFromList();
...@@ -499,7 +499,7 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName, ...@@ -499,7 +499,7 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName,
if( m_ListCmpbyValItems->GetValue() ) if( m_ListCmpbyValItems->GetValue() )
{ {
cmplist.SortComponentsByValueOnly(); cmplist.SortByValueOnly();
PrintComponentsListByVal( f, cmplist, aIncludeSubComponents ); PrintComponentsListByVal( f, cmplist, aIncludeSubComponents );
} }
} }
...@@ -632,7 +632,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( FILE* f, ...@@ -632,7 +632,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( FILE* f,
// Print list of items // Print list of items
for( unsigned ii = 0; ii < aList.GetCount(); ii++ ) for( unsigned ii = 0; ii < aList.GetCount(); ii++ )
{ {
EDA_ITEM* item = aList[ii].m_RootCmp; EDA_ITEM* item = aList[ii].GetComponent();
if( item == NULL ) if( item == NULL )
continue; continue;
...@@ -680,7 +680,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( FILE* f, ...@@ -680,7 +680,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( FILE* f,
if( aIncludeSubComponents ) if( aIncludeSubComponents )
{ {
msg = aList[ii].m_SheetPath.PathHumanReadable(); msg = aList[ii].GetSheetPath().PathHumanReadable();
BASE_SCREEN * screen = (BASE_SCREEN*) comp->GetParent(); BASE_SCREEN * screen = (BASE_SCREEN*) comp->GetParent();
if( screen ) if( screen )
...@@ -747,10 +747,10 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( FILE* f, SCH_REFERENCE_LIST& aL ...@@ -747,10 +747,10 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( FILE* f, SCH_REFERENCE_LIST& aL
for( unsigned ii = 0; ii < aList.GetCount(); ii++ ) for( unsigned ii = 0; ii < aList.GetCount(); ii++ )
{ {
currCmp = (SCH_COMPONENT*) aList[ii].m_RootCmp; currCmp = aList[ii].GetComponent();
if( ii < aList.GetCount() -1 ) if( ii < aList.GetCount() -1 )
nextCmp = aList[ii+1].m_RootCmp; nextCmp = aList[ii+1].GetComponent();
else else
nextCmp = NULL; nextCmp = NULL;
...@@ -882,7 +882,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal( FILE* f, ...@@ -882,7 +882,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal( FILE* f,
for( unsigned ii = 0; ii < aList.GetCount(); ii++ ) for( unsigned ii = 0; ii < aList.GetCount(); ii++ )
{ {
schItem = aList[ii].m_RootCmp; schItem = aList[ii].GetComponent();
if( schItem == NULL ) if( schItem == NULL )
continue; continue;
...@@ -918,7 +918,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal( FILE* f, ...@@ -918,7 +918,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal( FILE* f,
BASE_SCREEN * screen = (BASE_SCREEN*) DrawLibItem->GetParent(); BASE_SCREEN * screen = (BASE_SCREEN*) DrawLibItem->GetParent();
if( screen ) if( screen )
{ {
msg = aList[ii].m_SheetPath.PathHumanReadable(); msg = aList[ii].GetSheetPath().PathHumanReadable();
fprintf( f, " (Sheet %s)", CONV_TO_UTF8( msg ) ); fprintf( f, " (Sheet %s)", CONV_TO_UTF8( msg ) );
msg = m_Parent->GetXYSheetReferences( screen, DrawLibItem->m_Pos ); msg = m_Parent->GetXYSheetReferences( screen, DrawLibItem->m_Pos );
fprintf( f, " (loc %s)", CONV_TO_UTF8( msg ) ); fprintf( f, " (loc %s)", CONV_TO_UTF8( msg ) );
......
...@@ -1841,34 +1841,18 @@ wxArrayString LIB_PIN::GetElectricalTypeNames( void ) ...@@ -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 ) const char*** LIB_PIN::GetElectricalTypeSymbols( void )
{ {
return s_icons_Pins_Electrical_Type; 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() const char*** LIB_PIN::GetOrientationSymbols()
{ {
return s_icons_Pins_Orientations; 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() const char*** LIB_PIN::GetStyleSymbols()
{ {
return s_icons_Pins_Shapes; return s_icons_Pins_Shapes;
......
...@@ -361,7 +361,7 @@ public: ...@@ -361,7 +361,7 @@ public:
static wxArrayString GetOrientationNames(); 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 * @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_ ...@@ -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 // Get the Component FootprintFilter and put the component in
// cmpList if filter is present // cmpList if filter is present
LIB_COMPONENT* entry = LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( comp->GetLibName() );
CMP_LIBRARY::FindLibraryComponent( comp->GetLibName() );
if( entry ) if( entry )
{ {
if( entry->GetFootPrints().GetCount() != 0 ) // Put in list if( entry->GetFootPrints().GetCount() != 0 ) // Put in list
{ {
cmpList.push_back( SCH_REFERENCE() ); cmpList.push_back( SCH_REFERENCE( comp, entry, *path ) );
cmpList.back().m_RootCmp = comp;
cmpList.back().SetRef( comp->GetRef( path ) );
} }
} }
...@@ -1442,11 +1439,10 @@ bool EXPORT_HELP::WriteNetListPCBNEW( SCH_EDIT_FRAME* frame, FILE* f, bool with_ ...@@ -1442,11 +1439,10 @@ bool EXPORT_HELP::WriteNetListPCBNEW( SCH_EDIT_FRAME* frame, FILE* f, bool with_
wxString ref; wxString ref;
ret |= fprintf( f, "{ Allowed footprints by component:\n" ); ret |= fprintf( f, "{ Allowed footprints by component:\n" );
for( unsigned ii = 0; ii < cmpList.size(); ii++ ) for( unsigned ii = 0; ii < cmpList.size(); ii++ )
{ {
SCH_COMPONENT* comp = cmpList[ii].m_RootCmp; LIB_COMPONENT* entry = cmpList[ii].GetLibComponent();
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( comp->GetLibName() );
ref = cmpList[ii].GetRef(); 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