Refactor AppendSymbol and AppendMultiUnitSymbol
This commit is contained in:
parent
0f85f61e5f
commit
9b35757e18
|
@ -267,23 +267,30 @@ void SCH_SHEET_PATH::GetSymbols( SCH_REFERENCE_LIST& aReferences, bool aIncludeP
|
|||
for( SCH_ITEM* item : LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
|
||||
{
|
||||
SCH_COMPONENT* symbol = static_cast<SCH_COMPONENT*>( item );
|
||||
AppendSymbol( aReferences, symbol, aIncludePowerSymbols, aForceIncludeOrphanSymbols );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SCH_SHEET_PATH::AppendSymbol( SCH_REFERENCE_LIST& aReferences, SCH_COMPONENT* aSymbol,
|
||||
bool aIncludePowerSymbols,
|
||||
bool aForceIncludeOrphanSymbols ) const
|
||||
{
|
||||
// Skip pseudo-symbols, which have a reference starting with #. This mainly
|
||||
// affects power symbols.
|
||||
if( aIncludePowerSymbols || symbol->GetRef( this )[0] != wxT( '#' ) )
|
||||
if( aIncludePowerSymbols || aSymbol->GetRef( this )[0] != wxT( '#' ) )
|
||||
{
|
||||
LIB_PART* part = symbol->GetPartRef().get();
|
||||
LIB_PART* part = aSymbol->GetPartRef().get();
|
||||
|
||||
if( part || aForceIncludeOrphanSymbols )
|
||||
{
|
||||
SCH_REFERENCE schReference( symbol, part, *this );
|
||||
SCH_REFERENCE schReference( aSymbol, part, *this );
|
||||
|
||||
schReference.SetSheetNumber( m_virtualPageNumber );
|
||||
aReferences.AddItem( schReference );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SCH_SHEET_PATH::GetMultiUnitSymbols( SCH_MULTI_UNIT_REFERENCE_MAP& aRefList,
|
||||
|
@ -292,28 +299,35 @@ void SCH_SHEET_PATH::GetMultiUnitSymbols( SCH_MULTI_UNIT_REFERENCE_MAP& aRefList
|
|||
for( SCH_ITEM* item : LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
|
||||
{
|
||||
SCH_COMPONENT* symbol = static_cast<SCH_COMPONENT*>( item );
|
||||
AppendMultiUnitSymbol( aRefList, symbol, aIncludePowerSymbols );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SCH_SHEET_PATH::AppendMultiUnitSymbol( SCH_MULTI_UNIT_REFERENCE_MAP& aRefList,
|
||||
SCH_COMPONENT* aSymbol,
|
||||
bool aIncludePowerSymbols ) const
|
||||
{
|
||||
// Skip pseudo-symbols, which have a reference starting with #. This mainly
|
||||
// affects power symbols.
|
||||
if( !aIncludePowerSymbols && symbol->GetRef( this )[0] == wxT( '#' ) )
|
||||
continue;
|
||||
if( !aIncludePowerSymbols && aSymbol->GetRef( this )[0] == wxT( '#' ) )
|
||||
return;
|
||||
|
||||
LIB_PART* part = symbol->GetPartRef().get();
|
||||
LIB_PART* part = aSymbol->GetPartRef().get();
|
||||
|
||||
if( part && part->GetUnitCount() > 1 )
|
||||
{
|
||||
SCH_REFERENCE schReference = SCH_REFERENCE( symbol, part, *this );
|
||||
SCH_REFERENCE schReference = SCH_REFERENCE( aSymbol, part, *this );
|
||||
schReference.SetSheetNumber( m_virtualPageNumber );
|
||||
wxString reference_str = schReference.GetRef();
|
||||
|
||||
// Never lock unassigned references
|
||||
if( reference_str[reference_str.Len() - 1] == '?' )
|
||||
continue;
|
||||
return;
|
||||
|
||||
aRefList[reference_str].AddItem( schReference );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool SCH_SHEET_PATH::operator==( const SCH_SHEET_PATH& d1 ) const
|
||||
|
|
|
@ -108,6 +108,7 @@ class SCH_SHEET;
|
|||
class SCH_SCREEN;
|
||||
class SCH_MARKER;
|
||||
class SCH_ITEM;
|
||||
class SCH_COMPONENT;
|
||||
class SCH_REFERENCE_LIST;
|
||||
|
||||
|
||||
|
@ -265,6 +266,20 @@ public:
|
|||
*/
|
||||
void UpdateAllScreenReferences();
|
||||
|
||||
/**
|
||||
* Append a #SCH_REFERENCE object to \a aReferences based on \a aSymbol
|
||||
*
|
||||
* @param aReferences List of references to populate.
|
||||
* @param aSymbol A symbol to add to aReferences
|
||||
* @param aIncludePowerSymbols set to false to only get normal symbols.
|
||||
* @param aForceIncludeOrphanSymbols set to true to include symbols having no symbol found
|
||||
* in lib. The normal option is false, and set to true
|
||||
* only to build the full list of symbols.
|
||||
*/
|
||||
void AppendSymbol( SCH_REFERENCE_LIST& aReferences, SCH_COMPONENT* aSymbol,
|
||||
bool aIncludePowerSymbols = true,
|
||||
bool aForceIncludeOrphanSymbols = false ) const;
|
||||
|
||||
/**
|
||||
* Adds #SCH_REFERENCE object to \a aReferences for each symbol in the sheet.
|
||||
*
|
||||
|
@ -277,6 +292,19 @@ public:
|
|||
void GetSymbols( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols = true,
|
||||
bool aForceIncludeOrphanSymbols = false ) const;
|
||||
|
||||
/**
|
||||
* Append a #SCH_REFERENCE_LIST object to \a aRefList based on \a aSymbol,
|
||||
* storing same-reference set of multi-unit parts together.
|
||||
*
|
||||
* The map key for each element will be the reference designator.
|
||||
*
|
||||
* @param aRefList Map of reference designators to reference lists
|
||||
* @param aSymbol A symbol to add to aRefList
|
||||
* @param aIncludePowerSymbols Set to false to only get normal symbols.
|
||||
*/
|
||||
void AppendMultiUnitSymbol( SCH_MULTI_UNIT_REFERENCE_MAP& aRefList, SCH_COMPONENT* aSymbol,
|
||||
bool aIncludePowerSymbols = true ) const;
|
||||
|
||||
/**
|
||||
* Add a #SCH_REFERENCE_LIST object to \a aRefList for each same-reference set of
|
||||
* multi-unit parts in the sheet.
|
||||
|
|
|
@ -90,20 +90,8 @@ void EE_SELECTION::GetSymbols( SCH_REFERENCE_LIST& aReferences,
|
|||
continue;
|
||||
|
||||
SCH_COMPONENT* symbol = static_cast<SCH_COMPONENT*>( item );
|
||||
|
||||
// Skip pseudo-symbols, which have a reference starting with #. This mainly
|
||||
// affects power symbols.
|
||||
if( aIncludePowerSymbols || symbol->GetRef( &aSelectionPath )[0] != wxT( '#' ) )
|
||||
{
|
||||
LIB_PART* part = symbol->GetPartRef().get();
|
||||
|
||||
if( part || aForceIncludeOrphanSymbols )
|
||||
{
|
||||
SCH_REFERENCE schReference( symbol, part, aSelectionPath );
|
||||
schReference.SetSheetNumber( aSelectionPath.GetVirtualPageNumber() );
|
||||
aReferences.AddItem( schReference );
|
||||
}
|
||||
}
|
||||
aSelectionPath.AppendSymbol( aReferences, symbol, aIncludePowerSymbols,
|
||||
aForceIncludeOrphanSymbols );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,26 +106,7 @@ void EE_SELECTION::GetMultiUnitSymbols( SCH_MULTI_UNIT_REFERENCE_MAP& aRefList,
|
|||
continue;
|
||||
|
||||
SCH_COMPONENT* symbol = static_cast<SCH_COMPONENT*>( item );
|
||||
|
||||
// Skip pseudo-symbols, which have a reference starting with #. This mainly
|
||||
// affects power symbols.
|
||||
if( !aIncludePowerSymbols && symbol->GetRef( &aSelectionPath )[0] == wxT( '#' ) )
|
||||
continue;
|
||||
|
||||
LIB_PART* part = symbol->GetPartRef().get();
|
||||
|
||||
if( part && part->GetUnitCount() > 1 )
|
||||
{
|
||||
SCH_REFERENCE schReference = SCH_REFERENCE( symbol, part, aSelectionPath );
|
||||
schReference.SetSheetNumber( aSelectionPath.GetVirtualPageNumber() );
|
||||
wxString reference_str = schReference.GetRef();
|
||||
|
||||
// Never lock unassigned references
|
||||
if( reference_str[reference_str.Len() - 1] == '?' )
|
||||
continue;
|
||||
|
||||
aRefList[reference_str].AddItem( schReference );
|
||||
}
|
||||
aSelectionPath.AppendMultiUnitSymbol( aRefList, symbol, aIncludePowerSymbols );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue