![]() |
KiCad PCB EDA Suite
|
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used more than once and its reference designator is dependent on the sheet path for the same symbol. More...
#include <sch_reference_list.h>
Public Member Functions | |
SCH_REFERENCE_LIST () | |
SCH_REFERENCE & | operator[] (int aIndex) |
const SCH_REFERENCE & | operator[] (int aIndex) const |
void | Clear () |
size_t | GetCount () const |
SCH_REFERENCE & | GetItem (int aIdx) |
const SCH_REFERENCE & | GetItem (int aIdx) const |
void | AddItem (const SCH_REFERENCE &aItem) |
void | RemoveItem (unsigned int aIndex) |
Remove an item from the list of references. More... | |
bool | Contains (const SCH_REFERENCE &aItem) |
Return true if aItem exists in this list. More... | |
void | SplitReferences () |
Attempt to split all reference designators into a name (U) and number (1). More... | |
void | UpdateAnnotation () |
Update the symbol references for the schematic project (or the current sheet). More... | |
void | ReannotateDuplicates (const SCH_REFERENCE_LIST &aAdditionalReferences) |
Replace any duplicate reference designators with the next available number after the present number. More... | |
void | Annotate (bool aUseSheetNum, int aSheetIntervalId, int aStartNumber, SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap, const SCH_REFERENCE_LIST &aAdditionalRefs, bool aStartAtCurrent=false) |
Set the reference designators in the list that have not been annotated. More... | |
int | CheckAnnotation (ANNOTATION_ERROR_HANDLER aErrorHandler) |
Check for annotations errors. More... | |
void | SortByXCoordinate () |
Sort the list of references by X position. More... | |
void | SortByYCoordinate () |
Sort the list of references by Y position. More... | |
void | SortByTimeStamp () |
Sort the flat list by Time Stamp (sheet path + timestamp). More... | |
void | SortByRefAndValue () |
Sort the list of references by value. More... | |
void | SortByReferenceOnly () |
Sort the list of references by reference. More... | |
int | FindRef (const wxString &aPath) const |
Search the list for a symbol with a given reference. More... | |
int | FindUnit (size_t aIndex, int aUnit) const |
Search the sorted list of symbols for a another symbol with the same reference and a given part unit. More... | |
int | FindRefByPath (const wxString &aPath) const |
Search the list for a symbol with the given KIID path. More... | |
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 aIndex. More... | |
int | GetLastReference (int aIndex, int aMinValue) const |
Return the last used (greatest) reference number in the reference list for the prefix used by the symbol pointed to by aIndex. More... | |
std::vector< SYMBOL_INSTANCE_REFERENCE > | GetSymbolInstances () const |
Static Public Member Functions | |
static wxString | Shorthand (std::vector< SCH_REFERENCE > aList) |
Return a shorthand string representing all the references in the list. More... | |
Private Member Functions | |
int | CreateFirstFreeRefId (std::vector< int > &aIdList, int aFirstValue) |
Search for the first free reference number in aListId of reference numbers in use. More... | |
Static Private Member Functions | |
static bool | sortByRefAndValue (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) |
static bool | sortByTimeStamp (const SCH_REFERENCE &item1, const SCH_REFERENCE &item2) |
static bool | sortByReferenceOnly (const SCH_REFERENCE &item1, const SCH_REFERENCE &item2) |
Private Attributes | |
std::vector< SCH_REFERENCE > | flatList |
Friends | |
class | BACK_ANNOTATION |
class | BACK_ANNOTATE |
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used more than once and its reference designator is dependent on the sheet path for the same symbol.
This flattened list is used for netlist generation, BOM generation, and schematic annotation.
Definition at line 203 of file sch_reference_list.h.
|
inline |
Definition at line 210 of file sch_reference_list.h.
|
inline |
Definition at line 234 of file sch_reference_list.h.
References flatList.
Referenced by Annotate(), SCH_SHEET_LIST::AnnotatePowerSymbols(), SCH_EDIT_FRAME::AnnotateSymbols(), SCH_SHEET_PATH::AppendSymbol(), and SCH_EDITOR_CONTROL::Paste().
void SCH_REFERENCE_LIST::Annotate | ( | bool | aUseSheetNum, |
int | aSheetIntervalId, | ||
int | aStartNumber, | ||
SCH_MULTI_UNIT_REFERENCE_MAP | aLockedUnitMap, | ||
const SCH_REFERENCE_LIST & | aAdditionalRefs, | ||
bool | aStartAtCurrent = false |
||
) |
Set the reference designators in the list that have not been annotated.
If a the sheet number is 2 and aSheetIntervalId is 100, then the first reference designator would be 201 and the last reference designator would be 299 when no overlap occurs with sheet number 3. If there are 150 items in sheet number 2, then items are referenced U201 to U351, and items in sheet 3 start from U352
aUseSheetNum | Set to true to start annotation for each sheet at the sheet number times aSheetIntervalId. Otherwise annotate incrementally. |
aSheetIntervalId | The per sheet reference designator multiplier. |
aStartNumber | The number to start with if NOT numbering based on sheet number. |
aLockedUnitMap | A SCH_MULTI_UNIT_REFERENCE_MAP of reference designator wxStrings to SCH_REFERENCE_LISTs. May be an empty map. If not empty, any multi-unit parts found in this map will be annotated as a group rather than individually. |
aAdditionalRefs | Additional references to use for checking that there a reference designator doesn't already exist. The caller must ensure that none of the references in aAdditionalRefs exist in this list. |
aStartAtCurrent | Use m_numRef for each reference as the start number (overrides aStartNumber) |
Definition at line 339 of file component_references_lister.cpp.
References AddItem(), buildFullReference(), SCH_REFERENCE::CompareLibName(), SCH_REFERENCE::CompareValue(), CreateFirstFreeRefId(), FindUnit(), flatList, GetCount(), GetRefsInUse(), SCH_REFERENCE::IsSameInstance(), SCH_REFERENCE::m_isNew, SCH_REFERENCE::m_unit, RemoveItem(), and SCH_REFERENCE::Split().
Referenced by SCH_SHEET_LIST::AnnotatePowerSymbols(), SCH_EDIT_FRAME::AnnotateSymbols(), ReannotateDuplicates(), and UpdateAnnotation().
int SCH_REFERENCE_LIST::CheckAnnotation | ( | ANNOTATION_ERROR_HANDLER | aErrorHandler | ) |
Check for annotations errors.
The following annotation error conditions are tested:
aErrorHandler | A handler for errors. |
Definition at line 582 of file component_references_lister.cpp.
References _, ERCE_DIFFERENT_UNIT_VALUE, ERCE_DUPLICATE_REFERENCE, ERCE_EXTRA_UNITS, ERCE_UNANNOTATED, flatList, next(), SortByRefAndValue(), SplitReferences(), and LIB_SYMBOL::SubReference().
Referenced by SCH_EDIT_FRAME::CheckAnnotate().
|
inline |
Definition at line 224 of file sch_reference_list.h.
References flatList.
bool SCH_REFERENCE_LIST::Contains | ( | const SCH_REFERENCE & | aItem | ) |
Return true if aItem exists in this list.
aItem | Reference to check |
Definition at line 51 of file component_references_lister.cpp.
References flatList, and GetCount().
Referenced by SCH_EDIT_FRAME::AnnotateSymbols().
|
private |
Search for the first free reference number in aListId of reference numbers in use.
This function just searches for a hole in a list of incremented numbers, this list must be sorted by increasing values and each value can be stored only once. The new value is added to the list.
aIdList | The buffer that contains the reference numbers in use. |
aFirstValue | The first expected free value |
Definition at line 264 of file component_references_lister.cpp.
Referenced by Annotate().
int SCH_REFERENCE_LIST::FindRef | ( | const wxString & | aPath | ) | const |
Search the list for a symbol with a given reference.
Definition at line 189 of file component_references_lister.cpp.
References flatList.
Referenced by BACK_ANNOTATE::getChangeList().
int SCH_REFERENCE_LIST::FindRefByPath | ( | const wxString & | aPath | ) | const |
Search the list for a symbol with the given KIID path.
aPath | is the path to search. |
Definition at line 177 of file component_references_lister.cpp.
References flatList.
Referenced by BACK_ANNOTATE::getChangeList().
int SCH_REFERENCE_LIST::FindUnit | ( | size_t | aIndex, |
int | aUnit | ||
) | const |
Search the sorted list of symbols for a another symbol with the same reference and a given part unit.
Use this method to manage symbols with multiple parts per package.
aIndex | is the index in aSymbolsList for of given SCH_REFERENCE item to test. |
aUnit | is the given unit number to search. |
Definition at line 157 of file component_references_lister.cpp.
References flatList.
Referenced by Annotate().
|
inline |
Definition at line 229 of file sch_reference_list.h.
References flatList.
Referenced by FIELDS_EDITOR_GRID_DATA_MODEL::AddColumn(), Annotate(), SCH_SHEET_LIST::AnnotatePowerSymbols(), SCH_EDIT_FRAME::AnnotateSymbols(), FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData(), SCH_EDITOR_CONTROL::AssignFootprints(), SCH_EDIT_FRAME::CheckAnnotate(), BACK_ANNOTATE::checkForUnusedSymbols(), CollectOtherUnits(), Contains(), SCHEMATIC::ConvertRefsToKIIDs(), BACK_ANNOTATE::getChangeList(), FIELDS_EDITOR_GRID_DATA_MODEL::GetDataWidth(), DIALOG_EDIT_SYMBOLS_LIBID::initDlg(), DIALOG_SYMBOL_FIELDS_TABLE::LoadFieldNames(), SCH_EDIT_FRAME::mapExistingAnnotation(), DIALOG_TEXT_AND_LABEL_PROPERTIES::onScintillaCharAdded(), DIALOG_SCH_FIELD_PROPERTIES::onScintillaCharAdded(), SCH_EDITOR_CONTROL::processCmpToFootprintLinkFile(), ReannotateDuplicates(), FIELDS_EDITOR_GRID_DATA_MODEL::RebuildRows(), SplitReferences(), ERC_TESTER::TestMultiunitFootprints(), UpdateAnnotation(), and SCH_SHEET_LIST::UpdateSymbolInstances().
|
inline |
Definition at line 231 of file sch_reference_list.h.
References flatList.
Referenced by ERC_TESTER::TestMultiunitFootprints().
|
inline |
Definition at line 232 of file sch_reference_list.h.
References flatList.
int SCH_REFERENCE_LIST::GetLastReference | ( | int | aIndex, |
int | aMinValue | ||
) | const |
Return the last used (greatest) reference number in the reference list for the prefix used by the symbol pointed to by aIndex.
The symbol list must be sorted.
aIndex | The index of the reference item used for the search pattern. |
aMinValue | The minimum value for the current search. |
Definition at line 225 of file component_references_lister.cpp.
References flatList.
void SCH_REFERENCE_LIST::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 aIndex.
aIndex | is the current symbol's index to use for reference prefix filtering. |
aIdList | is the buffer to fill. |
aMinRefId | is the minimum ID value to store. All values < aMinRefId are ignored. |
Definition at line 201 of file component_references_lister.cpp.
References flatList.
Referenced by Annotate().
std::vector< SYMBOL_INSTANCE_REFERENCE > SCH_REFERENCE_LIST::GetSymbolInstances | ( | ) | const |
Definition at line 244 of file component_references_lister.cpp.
References flatList, SYMBOL_INSTANCE_REFERENCE::m_Footprint, SYMBOL_INSTANCE_REFERENCE::m_Path, SYMBOL_INSTANCE_REFERENCE::m_Reference, SYMBOL_INSTANCE_REFERENCE::m_Unit, and SYMBOL_INSTANCE_REFERENCE::m_Value.
Referenced by SCH_SEXPR_PLUGIN::Format().
|
inline |
Definition at line 214 of file sch_reference_list.h.
References flatList.
|
inline |
Definition at line 219 of file sch_reference_list.h.
References flatList.
void SCH_REFERENCE_LIST::ReannotateDuplicates | ( | const SCH_REFERENCE_LIST & | aAdditionalReferences | ) |
Replace any duplicate reference designators with the next available number after the present number.
Multi-unit symbols are reannotated together.
aAdditionalReferences | Additional references to check for duplicates |
Definition at line 314 of file component_references_lister.cpp.
References Annotate(), flatList, GetCount(), SCH_SYMBOL::GetRef(), SCH_REFERENCE::GetSheetPath(), SCH_REFERENCE::GetSymbol(), SCH_REFERENCE::m_isNew, and SplitReferences().
void SCH_REFERENCE_LIST::RemoveItem | ( | unsigned int | aIndex | ) |
Remove an item from the list of references.
aIndex | is the index of the item to be removed. |
Definition at line 44 of file component_references_lister.cpp.
References flatList.
Referenced by Annotate().
|
static |
Return a shorthand string representing all the references in the list.
For instance, "R1, R2, R4 - R7, U1"
Definition at line 827 of file component_references_lister.cpp.
Referenced by FIELDS_EDITOR_GRID_DATA_MODEL::GetValue().
|
inline |
Sort the list of references by value.
Symbols are sorted in the following order:
Definition at line 385 of file sch_reference_list.h.
References flatList, and sortByRefAndValue().
Referenced by CheckAnnotation().
|
staticprivate |
Definition at line 103 of file component_references_lister.cpp.
References SCH_REFERENCE::CompareRef(), SCH_REFERENCE::CompareValue(), SCH_REFERENCE::m_sheetNum, SCH_REFERENCE::m_symbolPos, SCH_REFERENCE::m_symbolUuid, and SCH_REFERENCE::m_unit.
Referenced by SortByRefAndValue().
|
inline |
Sort the list of references by reference.
Symbols are sorted in the following order:
Definition at line 397 of file sch_reference_list.h.
References flatList, and sortByReferenceOnly().
Referenced by SCH_SEXPR_PLUGIN::Format(), and SCH_EDITOR_CONTROL::Paste().
|
staticprivate |
Definition at line 130 of file component_references_lister.cpp.
References SCH_REFERENCE::GetRef(), SCH_REFERENCE::m_symbolUuid, SCH_REFERENCE::m_unit, and StrNumCmp().
Referenced by SortByReferenceOnly().
|
inline |
Sort the flat list by Time Stamp (sheet path + timestamp).
Useful to detect duplicate Time Stamps
Definition at line 369 of file sch_reference_list.h.
References flatList, and sortByTimeStamp().
Referenced by BACK_ANNOTATE::checkForUnusedSymbols().
|
staticprivate |
Definition at line 145 of file component_references_lister.cpp.
References SCH_SHEET_PATH::Cmp(), SCH_REFERENCE::m_sheetPath, and SCH_REFERENCE::m_symbolUuid.
Referenced by BACK_ANNOTATE::checkForUnusedSymbols(), and SortByTimeStamp().
|
inline |
Sort the list of references by X position.
Symbols are sorted as follows:
Definition at line 344 of file sch_reference_list.h.
References flatList, and sortByXPosition().
Referenced by SCH_EDIT_FRAME::AnnotateSymbols().
|
staticprivate |
Definition at line 63 of file component_references_lister.cpp.
References SCH_REFERENCE::CompareRef(), SCH_REFERENCE::m_sheetNum, SCH_REFERENCE::m_symbolPos, and SCH_REFERENCE::m_symbolUuid.
Referenced by SortByXCoordinate().
|
inline |
Sort the list of references by Y position.
Symbols are sorted as follows:
Definition at line 359 of file sch_reference_list.h.
References flatList, and sortByYPosition().
Referenced by SCH_EDIT_FRAME::AnnotateSymbols().
|
staticprivate |
Definition at line 83 of file component_references_lister.cpp.
References SCH_REFERENCE::CompareRef(), SCH_REFERENCE::m_sheetNum, SCH_REFERENCE::m_symbolPos, and SCH_REFERENCE::m_symbolUuid.
Referenced by SortByYCoordinate().
|
inline |
Attempt to split all reference designators into a name (U) and number (1).
If the last character is '?' or not a digit, the reference is tagged as not annotated. For symbols with multiple parts, keeps the unit number intact
Definition at line 266 of file sch_reference_list.h.
References flatList, and GetCount().
Referenced by SCH_SHEET_LIST::AnnotatePowerSymbols(), SCH_EDIT_FRAME::AnnotateSymbols(), CheckAnnotation(), FIELDS_EDITOR_GRID_DATA_MODEL::FIELDS_EDITOR_GRID_DATA_MODEL(), and ReannotateDuplicates().
|
inline |
Update the symbol references for the schematic project (or the current sheet).
Definition at line 280 of file sch_reference_list.h.
References Annotate(), flatList, and GetCount().
Referenced by SCH_SHEET_LIST::AnnotatePowerSymbols().
|
friend |
Definition at line 498 of file sch_reference_list.h.
|
friend |
Definition at line 470 of file sch_reference_list.h.
|
private |
Definition at line 207 of file sch_reference_list.h.
Referenced by AddItem(), Annotate(), CheckAnnotation(), Clear(), Contains(), FindRef(), FindRefByPath(), FindUnit(), GetCount(), GetItem(), GetLastReference(), GetRefsInUse(), GetSymbolInstances(), operator[](), ReannotateDuplicates(), RemoveItem(), SortByRefAndValue(), SortByReferenceOnly(), SortByTimeStamp(), SortByXCoordinate(), SortByYCoordinate(), SplitReferences(), and UpdateAnnotation().