46 for(
size_t i = 0; i < references.
GetCount(); i++ )
48 SCH_SYMBOL* symbol = references[ i ].GetSymbol();
52 curr_full_uuid.push_back( symbol->
m_Uuid );
54 wxString ref = symbol->
GetRef( curr_sheetpath,
true );
57 aMap[ curr_full_uuid.
AsString() ] = ref;
71 auto clearSymbolAnnotation =
75 commit.
Modify( aItem, aScreen );
84 msg.Printf(
_(
"Cleared annotation for %s (unit %s)." ),
85 symbol->
GetValue(
true, aSheet,
false ),
90 msg.Printf(
_(
"Cleared annotation for %s." ),
91 symbol->
GetValue(
true, aSheet,
false ) );
99 auto clearSheetAnnotation =
103 clearSymbolAnnotation( item, aScreen, aSheet, aResetPrefixes );
106 switch( aAnnotateScope )
111 clearSheetAnnotation( sheet.LastScreen(), &sheet,
false );
117 clearSheetAnnotation( screen, ¤tSheet,
false );
123 std::vector<SCH_ITEM*> tempSubSheets;
126 for(
SCH_ITEM* item : tempSubSheets )
135 clearSheetAnnotation( sheet.LastScreen(), &sheet,
false );
147 for(
EDA_ITEM* item : selection.Items() )
150 clearSymbolAnnotation( item, screen, ¤tSheet,
false );
162 clearSheetAnnotation( sheet.LastScreen(), &sheet,
false );
174 static_cast<DIALOG_ERC*
>( erc_dlg )->UpdateAnnotationWarning();
176 commit.
Push(
_(
"Delete Annotation" ) );
185 std::unordered_set<SCH_SYMBOL*> symbols;
189 switch( item->Type() )
202 symbols.insert(
static_cast<SCH_SYMBOL*
>( item ) );
209 group->RunOnChildren(
213 symbols.insert(
static_cast<SCH_SYMBOL*
>( aChild ) );
231 bool aRecursive,
int aStartNumber,
bool aResetAnnotation,
232 bool aRegroupUnits,
bool aRepairTimestamps,
263 std::vector<SCH_ITEM*> tempSubSheets;
266 for(
SCH_ITEM* item : tempSubSheets )
275 std::unordered_set<SCH_SYMBOL*> selectedSymbols;
285 std::map<wxString, wxString> previousAnnotation;
289 if( aRepairTimestamps )
296 msg.Printf(
_(
"%d duplicate time stamps were found and replaced." ), count );
306 switch( aAnnotateScope )
332 if( aResetAnnotation )
334 std::vector<wxString> conflictingRefs;
336 for(
auto& [refBase, refList] : lockedSymbols )
338 std::set<int> seenUnits;
339 bool hasConflict =
false;
343 if( seenUnits.count( ref.GetUnit() ) )
349 seenUnits.insert( ref.GetUnit() );
353 conflictingRefs.push_back( refBase );
356 for(
const wxString& ref : conflictingRefs )
357 lockedSymbols.erase( ref );
368 switch( aAnnotateScope )
384 currentSheet.
AppendSymbol( references, symbol,
false,
true );
395 if( aResetAnnotation )
408 for(
size_t i = 0; i < allRefs.
GetCount(); i++ )
410 if( !references.
Contains( allRefs[i] ) )
411 additionalRefs.
AddItem( allRefs[i] );
422 references.
AnnotateByOptions( aSortOption, aAlgoOption, aStartNumber, lockedSymbols,
423 additionalRefs,
false );
425 for(
size_t i = 0; i < references.
GetCount(); i++ )
435 full_uuid.push_back( symbol->
m_Uuid );
437 wxString prevRef = previousAnnotation[ full_uuid.
AsString() ];
438 wxString newRef = symbol->
GetRef( sheet );
445 if( prevRef.Length() )
447 if( newRef == prevRef )
452 msg.Printf(
_(
"Updated %s (unit %s) from %s to %s." ),
453 symbol->
GetValue(
true, sheet,
false ),
460 msg.Printf(
_(
"Updated %s from %s to %s." ),
461 symbol->
GetValue(
true, sheet,
false ),
470 msg.Printf(
_(
"Annotated %s (unit %s) as %s." ),
471 symbol->
GetValue(
true, sheet,
false ),
477 msg.Printf(
_(
"Annotated %s as %s." ),
478 symbol->
GetValue(
true, sheet,
false ),
492 aAnnotateScope, aRecursive ) )
504 static_cast<DIALOG_ERC*
>( erc_dlg )->UpdateAnnotationWarning();
520 constexpr bool includePowerSymbols =
false;
525 switch( aAnnotateScope )
538 std::vector<SCH_ITEM*> tempSubSheets;
541 for(
SCH_ITEM* item : tempSubSheets )
550 sheet.GetSymbols( referenceList, includePowerSymbols );
566 for(
EDA_ITEM* item : selection.Items() )
578 sheet.
GetSymbols( referenceList, includePowerSymbols );
std::unordered_set< SCH_SYMBOL * > getInferredSymbols(const SCH_SELECTION &aSelection)
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
EDA_ITEM * GetParent() const
wxString AsString() const
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
virtual REPORTER & ReportTail(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Places the report at the end of the list, for objects that support report ordering.
SCH_SHEET_LIST Hierarchy() const
Return the full schematic flattened hierarchical sheet list.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SyncView()
Mark all items for refresh.
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
void mapExistingAnnotation(std::map< wxString, wxString > &aMap)
Fill a map of uuid -> reference from the currently loaded schematic.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
void DeleteAnnotation(ANNOTATE_SCOPE_T aAnnotateScope, bool aRecursive, REPORTER &aReporter)
Clear the current symbol annotation.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_SHEET_PATH & GetCurrentSheet() const
SCHEMATIC & Schematic() const
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
int CheckAnnotate(ANNOTATION_ERROR_HANDLER aErrorHandler, ANNOTATE_SCOPE_T aAnnotateScope=ANNOTATE_ALL, bool aRecursive=true)
Check for annotation errors.
void AnnotateSymbols(SCH_COMMIT *aCommit, ANNOTATE_SCOPE_T aAnnotateScope, ANNOTATE_ORDER_T aSortOption, ANNOTATE_ALGO_T aAlgoOption, bool aRecursive, int aStartNumber, bool aResetAnnotation, bool aRegroupUnits, bool aRepairTimestamps, REPORTER &aReporter)
Annotate the symbols in the schematic that are not currently annotated.
void UpdateNetHighlightStatus()
A set of SCH_ITEMs (i.e., without duplicates).
Base class for any item which can be embedded within the SCHEMATIC container class,...
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
bool Contains(const SCH_REFERENCE &aItem) const
Return true if aItem exists in this list.
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)
Annotate the references by the provided options.
void SetRefDesTracker(std::shared_ptr< REFDES_TRACKER > aTracker)
void SplitReferences()
Attempt to split all reference designators into a name (U) and number (1).
void RemoveAnnotation()
Treat all symbols in this list as non-annotated.
void AddItem(const SCH_REFERENCE &aItem)
int CheckAnnotation(ANNOTATION_ERROR_HANDLER aErrorHandler)
Check for annotations errors.
A helper to define a symbol's reference designator in a schematic.
const SCH_SHEET_PATH & GetSheetPath() const
SCH_SYMBOL * GetSymbol() const
void Annotate()
Update the annotation of the symbol according the current object state.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
int ReplaceDuplicateTimeStamps()
Test all sheet and symbol objects in the schematic for duplicate time stamps and replaces them as nec...
void GetSheets(std::vector< SCH_ITEM * > *aItems) const
Similar to Items().OfType( SCH_SHEET_T ), but return the sheets in a deterministic order (L-R,...
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void GetMultiUnitSymbols(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true) const
Add a SCH_REFERENCE_LIST object to aRefList for each same-reference set of multi-unit parts in the li...
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
void GetSheetsWithinPath(std::vector< SCH_SHEET_PATH > &aSheets, const SCH_SHEET_PATH &aSheetPath) const
Add a SCH_SHEET_PATH object to aSheets for each sheet in the list that are contained within aSheetPat...
void GetSymbolsWithinPath(SCH_REFERENCE_LIST &aReferences, const SCH_SHEET_PATH &aSheetPath, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets that are contained wi...
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void AppendMultiUnitSymbol(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, SCH_SYMBOL *aSymbol, bool aIncludePowerSymbols=true) const
Append a SCH_REFERENCE_LIST object to aRefList based on aSymbol, storing same-reference set of multi-...
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Adds SCH_REFERENCE object to aReferences for each symbol in the sheet.
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
SCH_SCREEN * LastScreen()
void GetMultiUnitSymbols(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true) const
Add a SCH_REFERENCE_LIST object to aRefList for each same-reference set of multi-unit parts in the sh...
void AppendSymbol(SCH_REFERENCE_LIST &aReferences, SCH_SYMBOL *aSymbol, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Append a SCH_REFERENCE object to aReferences based on aSymbol.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
wxString SubReference(int aUnit, bool aAddSeparator=true) const
bool IsAnnotated(const SCH_SHEET_PATH *aSheet) const
Check if the symbol has a valid annotation (reference) for the given sheet path.
const wxString GetValue(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText, const wxString &aVariantName=wxEmptyString) const override
void ClearAnnotation(const SCH_SHEET_PATH *aSheetPath, bool aResetPrefix)
Clear exiting symbol annotation.
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
int GetUnitCount() const override
Return the number of units per package of the symbol.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
This file is part of the common library.
#define DIALOG_ERC_WINDOW_NAME
Class to handle a set of SCH_ITEMs.
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.
ANNOTATE_SCOPE_T
Schematic annotation scope options.
@ ANNOTATE_SELECTION
Annotate the selection.
@ ANNOTATE_CURRENT_SHEET
Annotate the current sheet.
@ ANNOTATE_ALL
Annotate the full schematic.
ANNOTATE_ALGO_T
Schematic annotation type options.
std::map< wxString, SCH_REFERENCE_LIST > SCH_MULTI_UNIT_REFERENCE_MAP
Container to map reference designators for multi-unit parts.
@ REFERENCE
Field Reference of part, i.e. "IC21".