36#include <unordered_set>
55 for(
unsigned ii = 0; ii <
GetCount(); ii++ )
67 for(
unsigned ii = 0; ii <
GetCount(); ii++ )
183 for(
size_t i = 0; i <
m_flatList.size(); ++i )
185 if(
m_flatList[i].GetFullPath() == aFullPath )
195 for(
size_t i = 0; i <
m_flatList.size(); ++i )
206 int aMinRefId )
const
213 if(
m_flatList[aIndex].CompareRef( ref ) == 0 && ref.m_numRef >= aMinRefId && !ref.m_isNew )
214 aIdList.push_back( ref.m_numRef );
217 std::sort( aIdList.begin(), aIdList.end() );
227 std::vector<int> unitsList;
230 unitsList.push_back( aRef.
m_unit );
234 if( ref.CompareValue( aRef ) != 0 )
237 if( ref.CompareLibId( aRef ) != 0 )
240 unitsList.push_back( ref.m_unit );
243 std::sort( unitsList.begin(), unitsList.end() );
269 std::map<const SCH_SCREEN*, const SCH_SHEET_PATH*> firstPath;
272 firstPath.emplace(
path.LastScreen(), &
path );
275 std::unordered_set<SCH_SYMBOL*> seen;
282 representatives.
AddItem( ref );
286 if( !seen.insert( ref.GetSymbol() ).second )
289 auto it = firstPath.find( ref.GetSheetPath().LastScreen() );
291 if( it == firstPath.end() || *it->second == ref.GetSheetPath() )
292 representatives.
AddItem( ref );
294 it->second->AppendSymbol( representatives, ref.GetSymbol(),
SYMBOL_FILTER_ALL,
true );
304 std::map<std::pair<const SCH_SYMBOL*, KIID_PATH>,
size_t> indexOf;
305 std::vector<size_t> parent(
m_flatList.size() );
308 for(
size_t i = 0; i <
m_flatList.size(); i++ )
317 while( parent[aIndex] != aIndex )
318 aIndex = parent[aIndex] = parent[parent[aIndex]];
323 for(
const auto& [key,
group] : aLocked )
325 std::optional<size_t> first;
331 if( it == indexOf.end() )
334 locked.insert( it->second );
337 parent[root( it->second )] = root( *first );
361 std::map<std::pair<const SCH_SYMBOL*, KIID_PATH>, wxString> packageOf;
362 std::map<wxString, std::set<int>> packageUnits;
363 std::set<wxString> renumberedPackages;
365 for(
const auto& [key,
group] : aLocked )
370 packageUnits[key].insert( ref.GetUnit() );
373 if( ref.GetRef() !=
group[0].GetRef() )
374 renumberedPackages.insert( key );
382 return it == packageOf.end() ? nullptr : &it->second;
389 if( aOther.CompareLibId( aRef ) != 0 || aOther.CompareValue( aRef ) != 0 )
392 if(
const wxString* package = packageFor( aRef ) )
393 return !packageUnits[*package].contains( aOther.GetUnit() );
395 return aOther.GetUnit() != aRef.
GetUnit();
401 const wxString* ref = packageFor( aRef );
402 const wxString* other = packageFor( aOther );
405 return *ref == *other;
407 return aOther.GetUnit() != aRef.
GetUnit() && aOther.CompareLibId( aRef ) == 0
408 && aOther.CompareValue( aRef ) == 0;
411 std::multimap<wxString, const SCH_REFERENCE*> othersByBase;
412 std::multimap<wxString, const SCH_REFERENCE*> othersByComposed;
413 std::map<const SCH_SCREEN*, std::vector<const SCH_SHEET_PATH*>> pathsOf;
417 othersByBase.emplace( other.
GetRef(), &other );
422 pathsOf[
path.LastScreen()].push_back( &
path );
431 std::vector<wxString>
result;
455 [&](
const SCH_REFERENCE& aRef,
const std::vector<wxString>& aSuffixes )
458 [&](
const std::multimap<wxString, const SCH_REFERENCE*>& aIndex,
const wxString& aKey )
460 auto [
begin,
end] = aIndex.equal_range( aKey );
463 [&](
const auto& aEntry )
465 return !joins( aRef, *aEntry.second );
469 if( blocks( othersByBase, aRef.
GetRef() ) )
473 for(
const wxString& suffix : aSuffixes )
475 if( blocks( othersByComposed, aRef.
GetRef() + suffix ) )
482 std::set<const SCH_REFERENCE*> renumbered;
483 std::map<wxString, std::vector<const SCH_REFERENCE*>> holders;
484 std::map<wxString, std::vector<const SCH_REFERENCE*>> composedHolders;
488 const std::vector<wxString> suffixes = suffixesFor( ref );
491 [&](
const std::vector<const SCH_REFERENCE*>& aHolders )
493 return !std::all_of( aHolders.begin(), aHolders.end(),
496 return samePackage( ref, *aHolder );
500 bool conflict = collides( ref, suffixes ) || clashes( holders[ref.GetRef()] )
501 || std::any_of( suffixes.begin(), suffixes.end(),
502 [&](
const wxString& aSuffix )
504 return clashes( composedHolders[ref.GetRef() + aSuffix] );
509 holders[ref.GetRef()].push_back( &ref );
511 for(
const wxString& suffix : suffixes )
512 composedHolders[ref.GetRef() + suffix].push_back( &ref );
514 else if(
const wxString* package = packageFor( ref ) )
515 renumberedPackages.insert( *package );
517 renumbered.insert( &ref );
522 const wxString*
package = packageFor( ref );
524 if( renumbered.contains( &ref ) || ( package && renumberedPackages.contains( *package ) ) )
531 const SCH_REFERENCE& aRef,
int aMinValue,
const std::vector<int>& aRequiredUnits,
532 const std::map<
const SCH_REFERENCE*, std::vector<SCH_REFERENCE>>& aDestinations,
537 std::map<int, std::vector<SCH_REFERENCE>> refNumberMap;
540 const bool needUnits = std::ranges::any_of( aRequiredUnits, [](
int aUnit ) {
return aUnit >= 0; } );
545 if( ref.CompareRef( aRef ) != 0 )
551 std::vector<SCH_REFERENCE>& numbered = refNumberMap[ref.m_numRef];
554 numbered.push_back( ref );
557 std::function<bool(
int )> acceptNumber;
559 if( !aDestinations.empty() )
561 std::multimap<wxString, SCH_REFERENCE> occupied;
564 for(
const auto& [ref, destinations] : aDestinations )
567 || ( aLocked && ref->CompareRef( aRef ) == 0 && ref->CompareLibId( aRef ) == 0
568 && ref->CompareValue( aRef ) == 0 && aLocked->
Contains( *ref ) ) )
573 if( ref->m_isNew || ref->m_numRef < 0 )
578 destination.SetUnit( ref->GetUnit() );
581 wxString composed = ref->GetRef() + ref->GetRefNumber() + destination.m_refSuffix;
582 occupied.emplace( composed, std::move( destination ) );
586 acceptNumber = [&aRef, occupied = std::move( occupied ),
candidates = std::move(
candidates )](
int aNumber )
592 auto [
begin,
end] = occupied.equal_range( base + candidate.m_refSuffix );
594 for(
auto it =
begin; it !=
end; ++it )
610 return m_refDesTracker->GetNextRefDesForUnits( aRef, refNumberMap, aRequiredUnits, aMinValue, acceptNumber );
616 std::vector<SCH_SYMBOL_INSTANCE> retval;
621 instance.
m_Path = ref.GetSheetPath().Path();
623 instance.
m_Unit = ref.GetUnit();
625 retval.push_back( instance );
638 if( aUnitNumber < 0 )
639 fullref <<
".." << aItem.
GetUnit();
641 fullref <<
".." << aUnitNumber;
651 bool aStartAtCurrent,
659 for(
size_t i = 0; i <
GetCount(); i++ )
670 wxCHECK2_MSG(
path,
continue,
671 wxS(
"Attempting to annotate item on sheet not part of the "
678 if( refstr[refstr.Len() - 1] ==
'?' )
683 lockedSymbols[refstr].AddItem( ref );
686 AnnotateByOptions( aSortOption, aAlgoOption, aStartNumber, lockedSymbols, aAdditionalRefs,
702 switch( aSortOption )
712 switch( aAlgoOption )
723 aStartAtCurrent =
false;
729 aStartAtCurrent =
false;
733 Annotate( useSheetNum, idStep, aStartNumber, aLockedUnitMap, aAdditionalRefs, aStartAtCurrent, aSharedSheets );
744 wxLogError( wxS(
"No reference tracker set for SCH_REFERENCE_LIST::Annotate()" ) );
762 std::unordered_set<wxString> inUseRefs;
764 for(
size_t i = 0; i < aAdditionalRefs.
GetCount(); i++ )
767 additionalRef.
Split();
779 std::map<const SCH_REFERENCE*, std::vector<SCH_REFERENCE>> destinations;
783 for(
size_t i = 0; i <
m_flatList.size(); ++i )
786 std::vector<SCH_REFERENCE>& instances = destinations[&ref];
798 instances.push_back( ref );
803 int LastReferenceNumber = 0;
817 minRefId =
m_flatList[first].m_sheetNum * aSheetIntervalId + 1;
819 minRefId = aStartNumber + 1;
822 for(
unsigned ii = 0; ii <
m_flatList.size(); ii++ )
826 if( ref_unit.m_flag )
832 for(
const SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair : aLockedUnitMap )
834 unsigned n_refs = pair.second.GetCount();
836 for(
unsigned thisRefI = 0; thisRefI < n_refs; ++thisRefI )
842 lockedList = &pair.second;
847 if( lockedList !=
nullptr )
851 if( (
m_flatList[first].CompareRef( ref_unit ) != 0 )
852 || ( aUseSheetNum && (
m_flatList[first].m_sheetNum != ref_unit.m_sheetNum ) ) )
859 minRefId = ref_unit.m_sheetNum * aSheetIntervalId + 1;
861 minRefId = aStartNumber + 1;
865 if( aStartAtCurrent && ref_unit.m_numRef > 0 )
866 minRefId = ref_unit.m_numRef;
868 wxCHECK( ref_unit.GetLibPart(), );
871 if( ref_unit.GetLibPart()->GetUnitCount() <= 1 )
873 if( ref_unit.m_isNew )
876 ref_unit.m_numRef = LastReferenceNumber;
877 ref_unit.m_numRefStr = ref_unit.formatRefStr( LastReferenceNumber );
881 ref_unit.m_isNew =
false;
887 if( lockedList !=
nullptr )
889 unsigned n_refs = lockedList->
GetCount();
892 if( ref_unit.m_isNew )
895 ref_unit.m_numRef = LastReferenceNumber;
896 ref_unit.m_numRefStr = ref_unit.formatRefStr( LastReferenceNumber );
897 ref_unit.m_isNew =
false;
901 for(
unsigned lockedRefI = 0; lockedRefI < n_refs; ++lockedRefI )
903 const SCH_REFERENCE& lockedRef = ( *lockedList )[lockedRefI];
908 ref_unit.m_unit = lockedRef.
m_unit;
921 for(
unsigned jj = ii + 1; jj <
m_flatList.size(); jj++ )
927 if(
m_flatList[jj].CompareRef( ref_unit ) != 0 )
935 if( inUseRefs.find( ref_candidate ) == inUseRefs.end() )
938 m_flatList[jj].m_numRefStr = ref_unit.m_numRefStr;
943 inUseRefs.insert( ref_candidate );
949 else if( ref_unit.m_isNew )
954 std::vector<int> units = { ref_unit.GetUnit() };
956 ref_unit.m_numRef = LastReferenceNumber;
957 ref_unit.m_numRefStr = ref_unit.formatRefStr( LastReferenceNumber );
958 ref_unit.m_isNew =
false;
966 wxASSERT( originalSize ==
GetCount() );
983 for(
unsigned ii = 0; ii <
m_flatList.size(); ii++ )
1000 msg.Printf(
_(
"Item not annotated: %s%s (unit %d)" ),
1007 msg.Printf(
_(
"Item not annotated: %s%s" ),
m_flatList[ii].GetRef(), tmp );
1025 msg.Printf(
_(
"Error: symbol %s%s%s (unit %d) exceeds units defined (%d)" ),
1051 if( first.
m_unit == second.m_unit )
1058 msg.Printf(
_(
"Duplicate items %s%s%s%s\n" ),
1063 : wxString( wxT(
"" ) ),
1073 if( first.
GetLibPart() && second.GetLibPart()
1081 if( second.m_numRef >= 0 )
1082 tmp2 << second.m_numRefStr;
1086 msg.Printf(
_(
"Differing unit counts for item %s%s%s%s and %s%s%s%s\n" ),
1094 second.GetRefSuffix() );
1104 msg.Printf(
_(
"Different values for %s%d%s (%s) and %s%d%s (%s)" ),
1120 for(
size_t ii = 1; ii <
m_flatList.size(); ++ii )
1127 std::map<wxString, std::map<int, SCH_REFERENCE*>> composed;
1134 auto& units = composed[ref.GetRef() + ref.m_numRefStr + ref.GetRefSuffix()];
1135 auto first = units.find( ref.m_unit );
1137 if( first == units.end() )
1138 first = units.begin();
1141 if( first != units.end() && !sameBaseAndSuffix( *first->second, ref ) )
1142 checkPackage( *first->second, ref );
1144 units.emplace( ref.m_unit, &ref );
1153 wxASSERT( aSymbol !=
nullptr );
1183 if( aSymbol->
GetBaseRef( &aSheetPath ).IsEmpty() )
1184 aSymbol->
SetRef( &aSheetPath, wxT(
"DefRef?" ) );
1186 wxString ref = aSymbol->
GetBaseRef( &aSheetPath );
1191 m_refSuffix = schematic->GetPackageRefSuffix( aSymbol, aSheetPath );
1198 if( value.IsEmpty() )
1258 int ll = refText.length() - 1;
1260 if( refText[ll] ==
'?' )
1264 refText.erase( ll );
1268 else if( isdigit( refText[ll] ) == 0 )
1276 if( (refText[ll] <=
' ' ) || isdigit( refText[ll] ) )
1282 if( isdigit( refText[ll + 1] ) )
1285 const char* cp = refText.c_str() + ll + 1;
1291 refText.erase( ll + 1 );
1303 if(
m_ref.IsEmpty() )
1306 const wxUniChar last =
m_ref.Last();
1308 return last ==
'?' || ( last >=
'0' && last <=
'9' );
1357 return wxString::Format(
"0%d", aNumber );
1359 return wxString::Format(
"%d", aNumber );
1404void SCH_REFERENCE_LIST::Show(
const char* aPrefix )
1406 printf(
"%s\n", aPrefix );
1408 for(
unsigned i = 0; i <
m_flatList.size(); ++i )
1412 printf(
" [%-2d] ref:%-8s num:%-3d lib_part:%s\n", i, schref.
m_ref.ToStdString().c_str(),
1423 std::optional<wxString> sharedBase;
1424 std::vector<wxString> pathSuffixes;
1425 std::multimap<wxString, size_t> composedInUse;
1430 wxString suffix =
path.ComposeRefSuffix();
1433 if( std::ranges::find( pathSuffixes, suffix ) != pathSuffixes.end() )
1436 pathSuffixes.push_back( std::move( suffix ) );
1441 for(
size_t ii = 0; ii < aExistingRefs.
GetCount(); ii++ )
1443 if( aExistingRefs[ii].GetSymbol() != aSymbol )
1444 composedInUse.emplace( aExistingRefs[ii].GetComposedRef(), ii );
1450 auto composesTaken =
1451 [&](
const wxString& aBase,
int aUnit )
1453 for(
size_t ii = 0; ii < aPaths.size(); ii++ )
1459 auto [
begin,
end] = composedInUse.equal_range( aBase + pathSuffixes[ii] );
1461 for(
auto it =
begin; it !=
end; ++it )
1485 std::optional<SCH_REFERENCE_LIST> reserved;
1487 std::set<wxString> tried;
1496 reserved ? *reserved : aExistingRefs,
false, aHierarchy );
1500 if( !share || refs[0].AlwaysAnnotate() )
1506 if( !tried.insert( *sharedBase ).second || !composesTaken( *sharedBase, refs[0].GetUnit() ) )
1511 reserved = aExistingRefs;
1513 reserved->AddItem( refs[0] );
1516 for(
size_t ii = 0; ii < refs.
GetCount(); ii++ )
1517 aExistingRefs.
AddItem( refs[ii] );
1526 return std::nullopt;
1528 std::set<const SCH_SCREEN*> screensInScope;
1531 screensInScope.insert( ref.GetSheetPath().LastScreen() );
1533 for(
const std::pair<SCH_SHEET_PATH, SCH_SHEET_PATH>& collision : aSchematic.
RefSuffixCollisions(
true ) )
1535 if( screensInScope.contains( collision.first.LastScreen() ) )
1539 return std::nullopt;
1545 std::erase_if( aLocked,
1546 [](
const auto& aEntry )
1548 std::set<int> seenUnits;
1552 if( !seenUnits.insert( ref.
GetUnit() ).second )
1564 int aStartNumber,
bool aResetAnnotation,
1565 const std::function<
void(
SCH_REFERENCE& )>& aBeforeAnnotate )
1571 if( aResetAnnotation )
1586 if( aResetAnnotation )
1597 std::unordered_set<SCH_SYMBOL*> annotatedSymbols;
1606 annotatedSymbols.insert( ref.GetSymbol() );
1612 if( !annotatedSymbols.contains( ref.GetSymbol() ) && !aRefs.
Contains( ref ) )
1613 additionalRefs.
AddItem( ref );
1625 aRefs.
AnnotateByOptions( aSortOption, aAlgoOption, aStartNumber, aLocked, additionalRefs,
false,
1626 suffixMode ? &sheets :
nullptr );
1628 std::set<const SCH_SCREEN*> sharedScreens;
1631 const std::set<KIID> splitCopies = suffixMode ? aSchematic.
SplitUnitSymbols() : std::set<KIID>();
1635 if( aBeforeAnnotate )
1636 aBeforeAnnotate( ref );
1640 if( suffixMode && !splitCopies.contains( ref.GetSymbol()->m_Uuid )
1643 sharedScreens.insert( ref.GetSheetPath().LastScreen() );
1647 return sharedScreens;
Define a library symbol object.
wxString GetName() const override
int GetUnitCount() const override
These are loaded from Eeschema settings but then overwritten by the project settings.
std::shared_ptr< REFDES_TRACKER > m_refDesTracker
A list of previously used schematic reference designators.
bool m_AnnotateReusedSheetSuffixes
Holds all the data relating to one schematic.
std::vector< std::pair< SCH_SHEET_PATH, SCH_SHEET_PATH > > RefSuffixCollisions(bool aIncludeEmpty) const
Find instances of one sheet file whose composed reference suffixes collide.
SCHEMATIC_SETTINGS & Settings() const
wxString GetPackageRefSuffix(const SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH &aPath) const
Return the suffix the package of a multi-unit symbol's instance composes with.
SCH_SHEET_LIST Hierarchy() const
Return the full schematic flattened hierarchical sheet list.
std::set< KIID > SplitUnitSymbols() const
Symbols whose copies select different units, for loops that change references as they go.
bool CopiesSelectDifferentUnits(const SCH_SYMBOL *aSymbol) const
virtual const wxString & GetText() const override
Return the string associated with the text object.
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
SCH_REFERENCE * FindItem(const SCH_REFERENCE &aItem)
SCH_MULTI_UNIT_REFERENCE_MAP LockedForRepresentatives(const SCH_MULTI_UNIT_REFERENCE_MAP &aLocked) const
Move locked multi-unit groups onto the representatives in this list.
void ReannotateByOptions(ANNOTATE_ORDER_T aSortOption, ANNOTATE_ALGO_T aAlgoOption, int aStartNumber, const SCH_REFERENCE_LIST &aAdditionalRefs, bool aStartAtCurrent, SCH_SHEET_LIST *aHierarchy)
Forces reannotation of the provided references.
static bool sortByRefAndValue(const SCH_REFERENCE &item1, const SCH_REFERENCE &item2)
static bool sortBySymbolPtr(const SCH_REFERENCE &item1, const SCH_REFERENCE &item2)
void RenumberBasesUsedBy(const SCH_REFERENCE_LIST &aOthers, const SCH_MULTI_UNIT_REFERENCE_MAP &aLocked, const SCH_SHEET_LIST &aSheets)
Mark unsplit references for renumbering where their kept base would collide once suffix mode copies i...
bool Contains(const SCH_REFERENCE &aItem) const
Return true if aItem exists in this list.
void SortByYCoordinate()
Sort the list of references by Y position.
void SetRefDesTracker(std::shared_ptr< REFDES_TRACKER > aTracker)
std::vector< int > GetPackageUnits(const SCH_REFERENCE &aRef) const
Return the units a locked package needs free when aRef is numbered, which are the units of every memb...
static bool sortByTimeStamp(const SCH_REFERENCE &item1, const SCH_REFERENCE &item2)
void SortByXCoordinate()
Sort the list of references by X position.
static bool sortByXPosition(const SCH_REFERENCE &item1, const SCH_REFERENCE &item2)
void AnnotateByOptions(enum ANNOTATE_ORDER_T aSortOption, enum ANNOTATE_ALGO_T aAlgoOption, int aStartNumber, const SCH_MULTI_UNIT_REFERENCE_MAP &aLockedUnitMap, const SCH_REFERENCE_LIST &aAdditionalRefs, bool aStartAtCurrent, const SCH_SHEET_LIST *aSharedSheets=nullptr)
Annotate the references by the provided options.
void UseReusedSheetRepresentatives(const SCH_SHEET_LIST &aSheets)
Replace the references of each reused sheet symbol with one reference on the first instance of its sh...
void SplitReferences()
Attempt to split all reference designators into a name (U) and number (1).
std::shared_ptr< REFDES_TRACKER > m_refDesTracker
A list of previously used reference designators.
void SortByRefAndValue()
Sort the list of references by value.
std::vector< SCH_REFERENCE > m_flatList
static bool sortByReferenceOnly(const SCH_REFERENCE &item1, const SCH_REFERENCE &item2)
void GetRefsInUse(int aIndex, std::vector< int > &aIdList, int aMinRefId) const
Add all the reference designator numbers greater than aMinRefId to aIdList skipping the reference at ...
void Annotate(bool aUseSheetNum, int aSheetIntervalId, int aStartNumber, const SCH_MULTI_UNIT_REFERENCE_MAP &aLockedUnitMap, const SCH_REFERENCE_LIST &aAdditionalRefs, bool aStartAtCurrent=false, const SCH_SHEET_LIST *aSharedSheets=nullptr)
Set the reference designators in the list that have not been annotated.
int FindRef(const wxString &aRef) const
Search the list for a symbol with a given reference, as shown with its sheet suffix.
int FindFirstUnusedReference(const SCH_REFERENCE &aRef, int aMinValue, const std::vector< int > &aRequiredUnits, const std::map< const SCH_REFERENCE *, std::vector< SCH_REFERENCE > > &aDestinations={}, const SCH_REFERENCE_LIST *aLocked=nullptr) const
Return the first unused reference number from the properties given in aRef, ensuring all of the units...
int FindRefByFullPath(const wxString &aFullPath) const
Search the list for a symbol with the given KIID path (as string).
void RemoveAnnotation()
Treat all symbols in this list as non-annotated.
std::vector< SCH_SYMBOL_INSTANCE > GetSymbolInstances() const
void AddItem(const SCH_REFERENCE &aItem)
void RemoveItem(unsigned int aIndex)
Remove an item from the list of references.
void ReannotateDuplicates(const SCH_REFERENCE_LIST &aAdditionalReferences, ANNOTATE_ALGO_T aAlgoOption)
Convenience function for the Paste Unique functionality.
static bool sortByYPosition(const SCH_REFERENCE &item1, const SCH_REFERENCE &item2)
void UpdateAnnotation()
Update the symbol references for the schematic project (or the current sheet).
int CheckAnnotation(ANNOTATION_ERROR_HANDLER aErrorHandler)
Check for annotations errors.
A helper to define a symbol's reference designator in a schematic.
void SetSymbolExcludedFromBoard(bool aEnable)
const SCH_SHEET_PATH & GetSheetPath() const
void SetSymbolExcludedFromBOM(bool aEnable, const wxString &aVariant=wxEmptyString)
wxString GetComposedRef() const
Return the reference as shown on this sheet path, with its sheet suffix.
SCH_SYMBOL * m_rootSymbol
The symbol associated the reference object.
int m_unit
The unit number for symbol with multiple parts per package.
SCH_SHEET_PATH m_sheetPath
The sheet path for this reference.
wxString m_footprint
The footprint assigned.
const wxString & GetRefSuffix() const
Return the sheet suffix this reference composes with, or empty while it is unannotated.
wxString formatRefStr(int aNumber) const
wxString GetFullRef() const
Return reference name with unit and sheet suffix altogether, as in U12A_M4.
int CompareRef(const SCH_REFERENCE &item) const
wxString m_refSuffix
The suffix the board reference composes with.
void SetRef(const wxString &aReference)
bool AlwaysAnnotate() const
Verify the reference should always be automatically annotated.
wxString m_numRefStr
The numeric part in original string form (may have leading zeroes).
bool m_isNew
True if not yet annotated.
bool GetSymbolExcludedFromBOM(const wxString &aVariant=wxEmptyString) const
bool GetSymbolDNP(const wxString &aVariant=wxEmptyString) const
void Split()
Attempt to split the reference designator into a name (U) and number (1).
SCH_SYMBOL * GetSymbol() const
bool GetSymbolExcludedFromPosFiles(const wxString &aVariant=wxEmptyString) const
wxString m_ref
Symbol reference prefix, without number (for IC1, this is IC) )
void SetSymbolExcludedFromSim(bool aEnable, const wxString &aVariant=wxEmptyString)
int m_sheetNum
The sheet number for the reference.
void SetRefStr(const std::string &aReference)
bool IsSplitNeeded() const
Determine if this reference needs to be split or if it likely already has been.
int m_numRef
The numeric part of the reference designator.
bool GetSymbolExcludedFromBoard() const
LIB_SYMBOL * GetLibPart() const
void SetSheetNumber(int aSheetNumber)
const char * GetRefStr() const
bool IsSameInstance(const SCH_REFERENCE &other) const
Return whether this reference refers to the same symbol instance (symbol and sheet) as another.
int CompareLibId(const SCH_REFERENCE &item) const
KIID m_symbolUuid
UUID of the symbol.
bool GetSymbolExcludedFromSim(const wxString &aVariant=wxEmptyString) const
void SetSymbolExcludedFromPosFiles(bool aEnable, const wxString &aVariant=wxEmptyString)
wxString m_value
The symbol value.
VECTOR2I m_symbolPos
The physical position of the symbol in schematic used to annotate by X or Y position.
wxString GetRefNumber() const
int CompareValue(const SCH_REFERENCE &item) const
void Annotate()
Update the annotation of the symbol according the current object state.
void SetSymbolDNP(bool aEnable, const wxString &aVariant=wxEmptyString)
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
int ShareReusedSheetRef(SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH &aSource) const
Give every other instance of aSymbol's sheet the base reference and unit it has on aSource.
SCH_SHEET_PATH * FindSheetForPath(const SCH_SHEET_PATH *aPath)
Return a pointer to the first SCH_SHEET_PATH object (not necessarily the only one) matching the provi...
void GetSymbols(SCH_REFERENCE_LIST &aReferences, SYMBOL_FILTER aSymbolFilter, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
SCH_SCREEN * LastScreen()
int Cmp(const SCH_SHEET_PATH &aSheetPathToTest) const
Compare if this is the same sheet path as aSheetPathToTest.
wxString SubReference(int aUnit, bool aAddSeparator=true) const
const wxString GetFootprintFieldText(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, const wxString &aVariantName=wxEmptyString) const
wxString GetBaseRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the base reference for the given sheet path for this symbol.
void AddHierarchicalReference(const KIID_PATH &aPath, const wxString &aRef, int aUnit)
Add a full hierarchical reference to this symbol.
VECTOR2I GetPosition() const override
bool GetInstance(SCH_SYMBOL_INSTANCE &aInstance, const KIID_PATH &aSheetPath, bool aTestFromEnd=false) const
const wxString GetValue(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, const wxString &aVariantName=wxEmptyString) const override
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
@ ERCE_UNANNOTATED
Symbol has not been annotated.
@ ERCE_DUPLICATE_REFERENCE
More than one symbol with the same reference.
@ ERCE_EXTRA_UNITS
Symbol has more units than are defined.
@ ERCE_DIFFERENT_UNIT_VALUE
Units of same symbol have different values.
void remove_duplicates(_Container &__c)
Deletes all duplicate values from __c.
static std::pair< const SCH_SYMBOL *, KIID_PATH > packageMemberKey(const SCH_REFERENCE &aRef)
wxString buildFullReference(const SCH_REFERENCE &aItem, int aUnitNumber=-1)
static void removeUnitConflicts(SCH_MULTI_UNIT_REFERENCE_MAP &aLocked)
static bool sharesReusedBase(const SCH_REFERENCE &aRef)
std::function< void(ERCE_T aType, const wxString &aMsg, SCH_REFERENCE *aItemA, SCH_REFERENCE *aItemB)> ANNOTATION_ERROR_HANDLER
Define a standard error handler for annotation errors.
ANNOTATE_ORDER_T
Schematic annotation order options.
@ UNSORTED
Annotate by position of symbol in the schematic sheet object list.
@ SORT_BY_X_POSITION
Annotate by X position from left to right.
@ SORT_BY_Y_POSITION
Annotate by Y position from top to bottom.
ANNOTATE_SCOPE_T
Schematic annotation scope options.
@ ANNOTATE_ALL
Annotate the full schematic.
ANNOTATE_ALGO_T
Schematic annotation type options.
@ SHEET_NUMBER_X_1000
Annotate using the first free reference number starting at the sheet number * 1000.
@ INCREMENTAL_BY_REF
Annotate incrementally using the first free reference number.
@ SHEET_NUMBER_X_100
Annotate using the first free reference number starting at the sheet number * 100.
void AnnotateNewSymbol(SCH_SYMBOL *aSymbol, const std::vector< SCH_SHEET_PATH > &aPaths, SCH_REFERENCE_LIST &aExistingRefs, const SCHEMATIC_SETTINGS &aSettings, SCH_SHEET_LIST *aHierarchy)
Annotate a newly placed symbol on each of aPaths in turn, avoiding aExistingRefs and adding the resul...
std::optional< std::pair< SCH_SHEET_PATH, SCH_SHEET_PATH > > FindRefSuffixCollision(const SCH_REFERENCE_LIST &aRefs, const SCHEMATIC &aSchematic)
Find two instances of a reused sheet that aRefs reaches and that compose the same reference suffix.
std::set< const SCH_SCREEN * > AnnotateReferences(SCH_REFERENCE_LIST &aRefs, SCH_MULTI_UNIT_REFERENCE_MAP aLocked, const SCHEMATIC &aSchematic, ANNOTATE_SCOPE_T aScope, ANNOTATE_ORDER_T aSortOption, ANNOTATE_ALGO_T aAlgoOption, int aStartNumber, bool aResetAnnotation, const std::function< void(SCH_REFERENCE &)> &aBeforeAnnotate={})
Annotate aRefs, the references in aScope, around every other symbol of aSchematic.
std::map< wxString, SCH_REFERENCE_LIST > SCH_MULTI_UNIT_REFERENCE_MAP
Container to map reference designators for multi-unit parts.
@ SYMBOL_FILTER_NON_POWER
int StrNumCmp(const wxString &aString1, const wxString &aString2, CMP_T aCaseSensitivity)
Compare two strings with alphanumerical content.
wxString From_UTF8(const char *cstring)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
A simple container for schematic symbol instance information.
@ REFERENCE
Field Reference of part, i.e. "IC21".
static std::vector< int > candidates(const SEGMENT_INDEX &aIndex, const SEG &aQuery, int aPadding)
wxString result
Test unit parsing edge cases and error handling.