KiCad PCB EDA Suite
Loading...
Searching...
No Matches
annotate.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <algorithm>
21#include <set>
22#include <unordered_set>
23
24#include <confirm.h>
26#include <reporter.h>
27#include <sch_edit_frame.h>
28#include <schematic.h>
29#include <sch_commit.h>
30#include <sch_group.h>
31#include <erc/erc_settings.h>
32#include <sch_reference_list.h>
33#include <tools/sch_selection.h>
35#include <tool/tool_manager.h>
36#include <dialog_erc.h>
37
38void SCH_EDIT_FRAME::mapExistingAnnotation( std::map<wxString, wxString>& aMap )
39{
40 SCH_REFERENCE_LIST references;
42
43 for( size_t i = 0; i < references.GetCount(); i++ )
44 {
45 SCH_SYMBOL* symbol = references[ i ].GetSymbol();
46 SCH_SHEET_PATH* curr_sheetpath = &references[ i ].GetSheetPath();
47 KIID_PATH curr_full_uuid = curr_sheetpath->Path();
48
49 curr_full_uuid.push_back( symbol->m_Uuid );
50
51 wxString ref = symbol->GetRef( curr_sheetpath, true );
52
53 if( symbol->IsAnnotated( curr_sheetpath ) )
54 aMap[ curr_full_uuid.AsString() ] = ref;
55 }
56}
57
58
59std::unordered_set<SCH_SYMBOL*> getInferredSymbols( const SCH_SELECTION& aSelection )
60{
61 std::unordered_set<SCH_SYMBOL*> symbols;
62
63 for( EDA_ITEM* item : aSelection )
64 {
65 switch( item->Type() )
66 {
67 case SCH_FIELD_T:
68 {
69 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
70
71 if( field->GetId() == FIELD_T::REFERENCE && field->GetParent()->Type() == SCH_SYMBOL_T )
72 symbols.insert( static_cast<SCH_SYMBOL*>( field->GetParent() ) );
73
74 break;
75 }
76
77 case SCH_SYMBOL_T:
78 symbols.insert( static_cast<SCH_SYMBOL*>( item ) );
79 break;
80
81 case SCH_GROUP_T:
82 {
83 SCH_GROUP* group = static_cast<SCH_GROUP*>( item );
84
85 group->RunOnChildren(
86 [&symbols]( SCH_ITEM* aChild )
87 {
88 if( aChild->Type() == SCH_SYMBOL_T )
89 symbols.insert( static_cast<SCH_SYMBOL*>( aChild ) );
90 },
92
93 break;
94 }
95
96 default:
97 break;
98 }
99 }
100
101 return symbols;
102}
103
104
105void SCH_EDIT_FRAME::DeleteAnnotation( ANNOTATE_SCOPE_T aAnnotateScope, bool aRecursive,
106 REPORTER& aReporter )
107{
108
110 SCH_SCREEN* screen = GetScreen();
111 SCH_SHEET_PATH currentSheet = GetCurrentSheet();
112 SCH_COMMIT commit( this );
113
114 auto clearSymbolAnnotation =
115 [&]( EDA_ITEM* aItem, SCH_SCREEN* aScreen, SCH_SHEET_PATH* aSheet, bool aResetPrefixes )
116 {
117 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( aItem );
118 commit.Modify( aItem, aScreen );
119
120 // aSheet == nullptr means all sheets
121 if( !aSheet || symbol->IsAnnotated( aSheet ) )
122 {
123 wxString msg;
124
125 if( symbol->GetUnitCount() > 1 )
126 {
127 msg.Printf( _( "Cleared annotation for %s (unit %s)." ),
128 symbol->GetValue( aSheet, FOR_GUI ),
129 symbol->SubReference( symbol->GetUnit(), false ) );
130 }
131 else
132 {
133 msg.Printf( _( "Cleared annotation for %s." ),
134 symbol->GetValue( aSheet, FOR_GUI ) );
135 }
136
137 symbol->ClearAnnotation( aSheet, aResetPrefixes );
138 aReporter.Report( msg, RPT_SEVERITY_ACTION );
139 }
140 };
141
142 auto clearSheetAnnotation =
143 [&]( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aSheet, bool aResetPrefixes )
144 {
145 for( SCH_ITEM* item : aScreen->Items().OfType( SCH_SYMBOL_T ) )
146 clearSymbolAnnotation( item, aScreen, aSheet, aResetPrefixes );
147 };
148
149 switch( aAnnotateScope )
150 {
151 case ANNOTATE_ALL:
152 {
153 for( SCH_SHEET_PATH& sheet : sheets )
154 clearSheetAnnotation( sheet.LastScreen(), &sheet, false );
155
156 break;
157 }
159 {
160 clearSheetAnnotation( screen, &currentSheet, false );
161
162 if( aRecursive )
163 {
164 SCH_SHEET_LIST subSheets;
165
166 std::vector<SCH_ITEM*> tempSubSheets;
167 currentSheet.LastScreen()->GetSheets( &tempSubSheets );
168
169 for( SCH_ITEM* item : tempSubSheets )
170 {
171 SCH_SHEET_PATH subSheetPath = currentSheet;
172 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
173
174 sheets.GetSheetsWithinPath( subSheets, subSheetPath );
175 }
176
177 for( SCH_SHEET_PATH sheet : subSheets )
178 clearSheetAnnotation( sheet.LastScreen(), &sheet, false );
179 }
180
181 break;
182 }
183
185 {
187 SCH_SELECTION& selection = selTool->RequestSelection();
188 SCH_SHEET_LIST selectedSheets;
189
190 for( SCH_SYMBOL* symbol : getInferredSymbols( selection ) )
191 clearSymbolAnnotation( symbol, screen, &currentSheet, false );
192
193 for( EDA_ITEM* item : selection.Items() )
194 {
195 if( item->Type() == SCH_SHEET_T && aRecursive )
196 {
197 SCH_SHEET_PATH subSheetPath = currentSheet;
198 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
199
200 sheets.GetSheetsWithinPath( selectedSheets, subSheetPath );
201 }
202 }
203
204 for( SCH_SHEET_PATH sheet : selectedSheets )
205 clearSheetAnnotation( sheet.LastScreen(), &sheet, false );
206
207 break;
208 }
209 }
210
211 // Update the references for the sheet that is currently being displayed.
213
214 wxWindow* erc_dlg = wxWindow::FindWindowByName( DIALOG_ERC_WINDOW_NAME );
215
216 if( erc_dlg )
217 static_cast<DIALOG_ERC*>( erc_dlg )->UpdateAnnotationWarning();
218
219 commit.Push( _( "Delete Annotation" ) );
220
221 // Must go after OnModify() so the connectivity graph has been updated
223}
224
225
227 ANNOTATE_ORDER_T aSortOption, ANNOTATE_ALGO_T aAlgoOption, bool aRecursive,
228 int aStartNumber, bool aResetAnnotation, bool aRegroupUnits,
229 bool aRepairTimestamps, REPORTER& aReporter )
230{
232 SCH_SELECTION& selection = selTool->GetSelection();
233
234 SCH_REFERENCE_LIST references;
235 SCH_SCREENS screens( Schematic().Root() );
237 SCH_SHEET_PATH currentSheet = GetCurrentSheet();
238
239
240 // Store the selected sheets relative to the full hierarchy so we get the correct sheet numbers
241 SCH_SHEET_LIST selectedSheets;
242
243 auto addSelectedSheet =
244 [&]( EDA_ITEM* aItem )
245 {
246 if( aItem->Type() == SCH_SHEET_T )
247 {
248 SCH_SHEET_PATH subSheetPath = currentSheet;
249 subSheetPath.push_back( static_cast<SCH_SHEET*>( aItem ) );
250
251 sheets.GetSheetsWithinPath( selectedSheets, subSheetPath );
252 }
253 };
254
255 for( EDA_ITEM* item : selection )
256 {
257 addSelectedSheet( item );
258
259 // A selected group selects its sheets, as getInferredSymbols does its symbols
260 if( item->Type() == SCH_GROUP_T )
261 static_cast<SCH_GROUP*>( item )->RunOnChildren( addSelectedSheet, RECURSE_MODE::RECURSE );
262 }
263
264
265 // Like above, store subsheets relative to full hierarchy for recursive annotation from current
266 // sheet
267 SCH_SHEET_LIST subSheets;
268
269 std::vector<SCH_ITEM*> tempSubSheets;
270 currentSheet.LastScreen()->GetSheets( &tempSubSheets );
271
272 for( SCH_ITEM* item : tempSubSheets )
273 {
274 SCH_SHEET_PATH subSheetPath = currentSheet;
275 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
276
277 sheets.GetSheetsWithinPath( subSheets, subSheetPath );
278 }
279
280
281 std::unordered_set<SCH_SYMBOL*> selectedSymbols;
282
283 if( aAnnotateScope == ANNOTATE_SELECTION )
284 selectedSymbols = getInferredSymbols( selection );
285
286
287 // Map of locked symbols
288 SCH_MULTI_UNIT_REFERENCE_MAP lockedSymbols;
289
290 // Map of previous annotation for building info messages
291 std::map<wxString, wxString> previousAnnotation;
292
293 // Test for and replace duplicate time stamps in symbols and sheets. Duplicate time stamps
294 // can happen with old schematics, schematic conversions, or manual editing of files.
295 if( aRepairTimestamps )
296 {
297 int count = screens.ReplaceDuplicateTimeStamps();
298
299 if( count )
300 {
301 wxString msg;
302 msg.Printf( _( "%d duplicate time stamps were found and replaced." ), count );
303 aReporter.ReportTail( msg, RPT_SEVERITY_WARNING );
304 }
305 }
306
307 // Collect all the sets that must be annotated together. When regrouping, we skip this step
308 // to allow fresh groupings based on symbol placement. When resetting without regrouping, we
309 // collect locked symbols but then check for unit conflicts (duplicate units within a ref).
310 if( !aRegroupUnits )
311 {
312 switch( aAnnotateScope )
313 {
314 case ANNOTATE_ALL:
315 sheets.GetMultiUnitSymbols( lockedSymbols, SYMBOL_FILTER_NON_POWER );
316 break;
317
319 currentSheet.GetMultiUnitSymbols( lockedSymbols, SYMBOL_FILTER_NON_POWER );
320
321 if( aRecursive )
322 subSheets.GetMultiUnitSymbols( lockedSymbols, SYMBOL_FILTER_NON_POWER );
323
324 break;
325
327 for( SCH_SYMBOL* symbol : selectedSymbols )
328 currentSheet.AppendMultiUnitSymbol( lockedSymbols, symbol, SYMBOL_FILTER_NON_POWER );
329
330 if( aRecursive )
331 selectedSheets.GetMultiUnitSymbols( lockedSymbols, SYMBOL_FILTER_NON_POWER );
332
333 break;
334 }
335 }
336
337 // Store previous annotations for building info messages
338 mapExistingAnnotation( previousAnnotation );
339
340 // Set sheet number and number of sheets.
342
343 // Build symbol list
344 switch( aAnnotateScope )
345 {
346 case ANNOTATE_ALL:
347 sheets.GetSymbols( references, SYMBOL_FILTER_NON_POWER );
348 break;
349
351 currentSheet.GetSymbols( references, SYMBOL_FILTER_NON_POWER );
352
353 if( aRecursive )
354 subSheets.GetSymbolsWithinPath( references, currentSheet, SYMBOL_FILTER_NON_POWER );
355
356 break;
357
359 for( SCH_SYMBOL* symbol : selectedSymbols )
360 currentSheet.AppendSymbol( references, symbol, SYMBOL_FILTER_NON_POWER );
361
362 if( aRecursive )
363 selectedSheets.GetSymbolsWithinPath( references, currentSheet, SYMBOL_FILTER_NON_POWER );
364
365 break;
366 }
367
368 if( std::optional<std::pair<SCH_SHEET_PATH, SCH_SHEET_PATH>> collision =
369 FindRefSuffixCollision( references, Schematic() ) )
370 {
371 const auto& [path, first] = *collision;
372
373 aReporter.ReportTail( wxString::Format( _( "Sheets %s and %s use %s with the same reference suffix. "
374 "Give each sheet a distinct suffix before annotating." ),
375 first.PathHumanReadable( false, true ),
376 path.PathHumanReadable( false, true ),
377 path.LastScreen()->GetFileName() ),
379 return;
380 }
381
382 const std::set<const SCH_SCREEN*> sharedScreens =
383 AnnotateReferences( references, std::move( lockedSymbols ), Schematic(), aAnnotateScope, aSortOption,
384 aAlgoOption, aStartNumber, aResetAnnotation,
385 [&]( SCH_REFERENCE& aRef )
386 {
387 aCommit->Modify( aRef.GetSymbol(), aRef.GetSheetPath().LastScreen() );
388 } );
389
390 for( size_t i = 0; i < references.GetCount(); i++ )
391 {
392 SCH_REFERENCE& ref = references[i];
393 SCH_SYMBOL* symbol = ref.GetSymbol();
394 SCH_SHEET_PATH* sheet = &ref.GetSheetPath();
395
396 KIID_PATH full_uuid = sheet->Path();
397 full_uuid.push_back( symbol->m_Uuid );
398
399 wxString prevRef = previousAnnotation[ full_uuid.AsString() ];
400 wxString newRef = symbol->GetRef( sheet, true );
401
402 wxString msg;
403
404 if( prevRef.Length() )
405 {
406 if( newRef == prevRef )
407 continue;
408
409 if( symbol->GetUnitCount() > 1 )
410 {
411 msg.Printf( _( "Updated %s (unit %s) from %s to %s." ),
412 symbol->GetValue( sheet, FOR_GUI ),
413 symbol->SubReference( symbol->GetUnit(), false ),
414 prevRef,
415 newRef );
416 }
417 else
418 {
419 msg.Printf( _( "Updated %s from %s to %s." ),
420 symbol->GetValue( sheet, FOR_GUI ),
421 prevRef,
422 newRef );
423 }
424 }
425 else
426 {
427 if( symbol->GetUnitCount() > 1 )
428 {
429 msg.Printf( _( "Annotated %s (unit %s) as %s." ),
430 symbol->GetValue( sheet, FOR_GUI ),
431 symbol->SubReference( symbol->GetUnit(), false ),
432 newRef );
433 }
434 else
435 {
436 msg.Printf( _( "Annotated %s as %s." ),
437 symbol->GetValue( sheet, FOR_GUI ),
438 newRef );
439 }
440 }
441
442 aReporter.Report( msg, RPT_SEVERITY_ACTION );
443 }
444
445 for( const SCH_SCREEN* screen : sharedScreens )
446 {
447 aReporter.Report( wxString::Format( _( "References in %s apply to every sheet that uses it." ),
448 screen->GetFileName() ),
450 }
451
452 // Final control (just in case ... ).
453 if( !CheckAnnotate(
454 [&aReporter]( ERCE_T, const wxString& aMsg, SCH_REFERENCE*, SCH_REFERENCE* )
455 {
456 aReporter.Report( aMsg, RPT_SEVERITY_ERROR );
457 },
458 aAnnotateScope, aRecursive ) )
459 {
460 aReporter.ReportTail( _( "Annotation complete." ), RPT_SEVERITY_ACTION );
461 }
462
463 // Update on screen references, that can be modified by previous calculations:
466
467 wxWindow* erc_dlg = wxWindow::FindWindowByName( DIALOG_ERC_WINDOW_NAME );
468
469 if( erc_dlg )
470 static_cast<DIALOG_ERC*>( erc_dlg )->UpdateAnnotationWarning();
471
472 SyncView();
473 GetCanvas()->Refresh();
474 OnModify();
475
476 // Must go after OnModify() so the connectivity graph has been updated
478}
479
480
482 bool aRecursive )
483{
484 SCH_REFERENCE_LIST referenceList;
486 SCH_SHEET_PATH currentSheet = GetCurrentSheet();
487
488 // Build the list of symbols
489 switch( aAnnotateScope )
490 {
491 case ANNOTATE_ALL:
492 sheets.GetSymbols( referenceList, SYMBOL_FILTER_NON_POWER, true );
493 break;
494
496 GetCurrentSheet().GetSymbols( referenceList, SYMBOL_FILTER_NON_POWER, true );
497
498 if( aRecursive )
499 {
500 SCH_SHEET_LIST subSheets;
501
502 std::vector<SCH_ITEM*> tempSubSheets;
503 currentSheet.LastScreen()->GetSheets( &tempSubSheets );
504
505 for( SCH_ITEM* item : tempSubSheets )
506 {
507 SCH_SHEET_PATH subSheetPath = currentSheet;
508 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
509
510 sheets.GetSheetsWithinPath( subSheets, subSheetPath );
511 }
512
513 for( const SCH_SHEET_PATH& sheet : subSheets )
514 sheet.GetSymbols( referenceList, SYMBOL_FILTER_NON_POWER, true );
515 }
516
517 break;
518
521 SCH_SELECTION& selection = selTool->RequestSelection();
522
523 for( SCH_SYMBOL* symbol : getInferredSymbols( selection ) )
524 GetCurrentSheet().AppendSymbol( referenceList, symbol, SYMBOL_FILTER_NON_POWER, true );
525
526 if( aRecursive )
527 {
528 SCH_SHEET_LIST selectedSheets;
529
530 for( EDA_ITEM* item : selection.Items() )
531 {
532 if( item->Type() == SCH_SHEET_T )
533 {
534 SCH_SHEET_PATH subSheetPath = currentSheet;
535 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
536
537 sheets.GetSheetsWithinPath( selectedSheets, subSheetPath );
538 }
539 }
540
541 for( SCH_SHEET_PATH sheet : selectedSheets )
542 sheet.GetSymbols( referenceList, SYMBOL_FILTER_NON_POWER, true );
543 }
544
545 break;
546 }
547
548 // Empty schematic does not need annotation
549 if( referenceList.GetCount() == 0 )
550 return 0;
551
552 return referenceList.CheckAnnotation( aErrorHandler );
553}
std::unordered_set< SCH_SYMBOL * > getInferredSymbols(const SCH_SELECTION &aSelection)
Definition annotate.cpp:59
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Definition commit.h:102
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.
Definition eda_item.h:98
const KIID m_Uuid
Definition eda_item.h:599
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
EDA_ITEM * GetParent() const
Definition eda_item.h:112
wxString AsString() const
Definition kiid.cpp:423
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
Definition reporter.h:102
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.
Definition reporter.h:121
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.
Commit for the schematic and symbol editors.
Definition sch_commit.h:54
void Push(const wxString &aMessage=wxEmptyString, 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.
Definition annotate.cpp:38
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.
Definition annotate.cpp:105
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, bool aRecursive)
Check for annotation errors.
Definition annotate.cpp:481
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.
Definition annotate.cpp:226
void UpdateNetHighlightStatus()
FIELD_T GetId() const
Definition sch_field.h:143
A set of SCH_ITEMs (i.e., without duplicates).
Definition sch_group.h:48
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:170
int GetUnit() const
Definition sch_item.h:243
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
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
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition sch_screen.h:826
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,...
SCH_SELECTION & GetSelection()
SCH_SELECTION & RequestSelection(const std::vector< KICAD_T > &aScanTypes={ SCH_LOCATE_ANY_T }, bool aPromoteCellSelections=false, bool aPromoteGroups=false)
Return either an existing selection (filtered), or the selection at the current cursor position if th...
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void GetSymbolsWithinPath(SCH_REFERENCE_LIST &aReferences, const SCH_SHEET_PATH &aSheetPath, SYMBOL_FILTER aSymbolFilter, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets that are contained wi...
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 GetMultiUnitSymbols(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, SYMBOL_FILTER aSymbolFilter) 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, 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...
void AppendSymbol(SCH_REFERENCE_LIST &aReferences, SCH_SYMBOL *aSymbol, SYMBOL_FILTER aSymbolFilter, bool aForceIncludeOrphanSymbols=false) const
Append a SCH_REFERENCE object to aReferences based on aSymbol.
void GetMultiUnitSymbols(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, SYMBOL_FILTER aSymbolFilter) const
Add a SCH_REFERENCE_LIST object to aRefList for each same-reference set of multi-unit parts in the sh...
void GetSymbols(SCH_REFERENCE_LIST &aReferences, SYMBOL_FILTER aSymbolFilter, 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 AppendMultiUnitSymbol(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, SCH_SYMBOL *aSymbol, SYMBOL_FILTER aSymbolFilter) const
Append a SCH_REFERENCE_LIST object to aRefList based on aSymbol, storing same-reference set of multi-...
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.
Definition sch_sheet.h:50
Schematic symbol object.
Definition sch_symbol.h:76
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.
void ClearAnnotation(const SCH_SHEET_PATH *aSheetPath, bool aResetPrefix)
Clear exiting symbol annotation.
const wxString GetValue(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, const wxString &aVariantName=wxEmptyString) const override
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
TOOL_MANAGER * m_toolManager
@ FOR_GUI
Definition common.h:93
This file is part of the common library.
#define DIALOG_ERC_WINDOW_NAME
Definition dialog_erc.h:37
#define _(s)
@ RECURSE
Definition eda_item.h:51
ERCE_T
ERC error codes.
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_ACTION
Class to handle a set of SCH_ITEMs.
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::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::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.
@ SYMBOL_FILTER_NON_POWER
@ REFERENCE
Field Reference of part, i.e. "IC21".
std::string path
@ SCH_GROUP_T
Definition typeinfo.h:169
@ SCH_SYMBOL_T
Definition typeinfo.h:168
@ SCH_FIELD_T
Definition typeinfo.h:146
@ SCH_SHEET_T
Definition typeinfo.h:171