44 for(
size_t i = 0; i < references.
GetCount(); i++ )
46 SCH_SYMBOL* symbol = references[ i ].GetSymbol();
50 curr_full_uuid.push_back( symbol->
m_Uuid );
52 wxString ref = symbol->
GetRef( curr_sheetpath,
true );
55 aMap[ curr_full_uuid.
AsString() ] = ref;
69 auto clearSymbolAnnotation =
73 commit.
Modify( aItem, aScreen );
82 msg.Printf(
_(
"Cleared annotation for %s (unit %s)." ),
83 symbol->
GetValue(
true, aSheet,
false ),
88 msg.Printf(
_(
"Cleared annotation for %s." ),
89 symbol->
GetValue(
true, aSheet,
false ) );
97 auto clearSheetAnnotation =
101 clearSymbolAnnotation( item, aScreen, aSheet, aResetPrefixes );
104 switch( aAnnotateScope )
109 clearSheetAnnotation( sheet.LastScreen(),
nullptr,
false );
115 clearSheetAnnotation( screen, ¤tSheet,
false );
121 std::vector<SCH_ITEM*> tempSubSheets;
124 for(
SCH_ITEM* item : tempSubSheets )
133 clearSheetAnnotation( sheet.LastScreen(), &sheet,
false );
145 for(
EDA_ITEM* item : selection.Items() )
148 clearSymbolAnnotation( item, screen, ¤tSheet,
false );
160 clearSheetAnnotation( sheet.LastScreen(), &sheet,
false );
172 static_cast<DIALOG_ERC*
>( erc_dlg )->UpdateAnnotationWarning();
174 commit.
Push(
_(
"Delete Annotation" ) );
183 std::unordered_set<SCH_SYMBOL*> symbols;
187 switch( item->Type() )
200 symbols.insert(
static_cast<SCH_SYMBOL*
>( item ) );
214 bool aRecursive,
int aStartNumber,
bool aResetAnnotation,
215 bool aRepairTimestamps,
REPORTER& aReporter )
245 std::vector<SCH_ITEM*> tempSubSheets;
248 for(
SCH_ITEM* item : tempSubSheets )
257 std::unordered_set<SCH_SYMBOL*> selectedSymbols;
267 std::map<wxString, wxString> previousAnnotation;
271 if( aRepairTimestamps )
278 msg.Printf(
_(
"%d duplicate time stamps were found and replaced." ), count );
284 switch( aAnnotateScope )
315 switch( aAnnotateScope )
331 currentSheet.
AppendSymbol( references, symbol,
false,
true );
342 if( aResetAnnotation )
355 for(
size_t i = 0; i < allRefs.
GetCount(); i++ )
357 if( !references.
Contains( allRefs[i] ) )
358 additionalRefs.
AddItem( allRefs[i] );
367 references.
AnnotateByOptions( aSortOption, aAlgoOption, aStartNumber, lockedSymbols,
368 additionalRefs,
false );
370 for(
size_t i = 0; i < references.
GetCount(); i++ )
380 full_uuid.push_back( symbol->
m_Uuid );
382 wxString prevRef = previousAnnotation[ full_uuid.
AsString() ];
383 wxString newRef = symbol->
GetRef( sheet );
390 if( prevRef.Length() )
392 if( newRef == prevRef )
397 msg.Printf(
_(
"Updated %s (unit %s) from %s to %s." ),
398 symbol->
GetValue(
true, sheet,
false ),
405 msg.Printf(
_(
"Updated %s from %s to %s." ),
406 symbol->
GetValue(
true, sheet,
false ),
415 msg.Printf(
_(
"Annotated %s (unit %s) as %s." ),
416 symbol->
GetValue(
true, sheet,
false ),
422 msg.Printf(
_(
"Annotated %s as %s." ),
423 symbol->
GetValue(
true, sheet,
false ),
437 aAnnotateScope, aRecursive ) )
449 static_cast<DIALOG_ERC*
>( erc_dlg )->UpdateAnnotationWarning();
465 constexpr bool includePowerSymbols =
false;
470 switch( aAnnotateScope )
483 std::vector<SCH_ITEM*> tempSubSheets;
486 for(
SCH_ITEM* item : tempSubSheets )
495 sheet.GetSymbols( referenceList, includePowerSymbols );
511 for(
EDA_ITEM* item : selection.Items() )
523 sheet.GetSymbols( referenceList, includePowerSymbols );
std::unordered_set< SCH_SYMBOL * > getInferredSymbols(const EE_SELECTION &aSelection)
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
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 & ReportTail(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Places the report at the end of the list, for objects that support report ordering.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
SCH_SHEET_LIST Hierarchy() const override
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
Revert the commit by restoring the modified items state.
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.
void AnnotateSymbols(SCH_COMMIT *aCommit, ANNOTATE_SCOPE_T aAnnotateScope, ANNOTATE_ORDER_T aSortOption, ANNOTATE_ALGO_T aAlgoOption, bool aRecursive, int aStartNumber, bool aResetAnnotation, bool aRepairTimestamps, REPORTER &aReporter)
Annotate the symbols in the schematic that are not currently annotated.
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 UpdateNetHighlightStatus()
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
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, SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap, const SCH_REFERENCE_LIST &aAdditionalRefs, bool aStartAtCurrent)
Annotate the references by the provided options.
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 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
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.
Definition for symbol library class.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".