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
23#include <confirm.h>
25#include <reporter.h>
26#include <sch_edit_frame.h>
27#include <schematic.h>
28#include <sch_commit.h>
29#include <sch_group.h>
30#include <erc/erc_settings.h>
31#include <sch_reference_list.h>
32#include <tools/sch_selection.h>
34#include <tool/tool_manager.h>
35#include <dialog_erc.h>
36
37void SCH_EDIT_FRAME::mapExistingAnnotation( std::map<wxString, wxString>& aMap )
38{
39 SCH_REFERENCE_LIST references;
41
42 for( size_t i = 0; i < references.GetCount(); i++ )
43 {
44 SCH_SYMBOL* symbol = references[ i ].GetSymbol();
45 SCH_SHEET_PATH* curr_sheetpath = &references[ i ].GetSheetPath();
46 KIID_PATH curr_full_uuid = curr_sheetpath->Path();
47
48 curr_full_uuid.push_back( symbol->m_Uuid );
49
50 wxString ref = symbol->GetRef( curr_sheetpath, true );
51
52 if( symbol->IsAnnotated( curr_sheetpath ) )
53 aMap[ curr_full_uuid.AsString() ] = ref;
54 }
55}
56
57
58void SCH_EDIT_FRAME::DeleteAnnotation( ANNOTATE_SCOPE_T aAnnotateScope, bool aRecursive,
59 REPORTER& aReporter )
60{
61
63 SCH_SCREEN* screen = GetScreen();
64 SCH_SHEET_PATH currentSheet = GetCurrentSheet();
65 SCH_COMMIT commit( this );
66
67 auto clearSymbolAnnotation =
68 [&]( EDA_ITEM* aItem, SCH_SCREEN* aScreen, SCH_SHEET_PATH* aSheet, bool aResetPrefixes )
69 {
70 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( aItem );
71 commit.Modify( aItem, aScreen );
72
73 // aSheet == nullptr means all sheets
74 if( !aSheet || symbol->IsAnnotated( aSheet ) )
75 {
76 wxString msg;
77
78 if( symbol->GetUnitCount() > 1 )
79 {
80 msg.Printf( _( "Cleared annotation for %s (unit %s)." ),
81 symbol->GetValue( true, aSheet, false ),
82 symbol->SubReference( symbol->GetUnit(), false ) );
83 }
84 else
85 {
86 msg.Printf( _( "Cleared annotation for %s." ),
87 symbol->GetValue( true, aSheet, false ) );
88 }
89
90 symbol->ClearAnnotation( aSheet, aResetPrefixes );
91 aReporter.Report( msg, RPT_SEVERITY_ACTION );
92 }
93 };
94
95 auto clearSheetAnnotation =
96 [&]( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aSheet, bool aResetPrefixes )
97 {
98 for( SCH_ITEM* item : aScreen->Items().OfType( SCH_SYMBOL_T ) )
99 clearSymbolAnnotation( item, aScreen, aSheet, aResetPrefixes );
100 };
101
102 switch( aAnnotateScope )
103 {
104 case ANNOTATE_ALL:
105 {
106 for( SCH_SHEET_PATH& sheet : sheets )
107 clearSheetAnnotation( sheet.LastScreen(), &sheet, false );
108
109 break;
110 }
112 {
113 clearSheetAnnotation( screen, &currentSheet, false );
114
115 if( aRecursive )
116 {
117 SCH_SHEET_LIST subSheets;
118
119 std::vector<SCH_ITEM*> tempSubSheets;
120 currentSheet.LastScreen()->GetSheets( &tempSubSheets );
121
122 for( SCH_ITEM* item : tempSubSheets )
123 {
124 SCH_SHEET_PATH subSheetPath = currentSheet;
125 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
126
127 sheets.GetSheetsWithinPath( subSheets, subSheetPath );
128 }
129
130 for( SCH_SHEET_PATH sheet : subSheets )
131 clearSheetAnnotation( sheet.LastScreen(), &sheet, false );
132 }
133
134 break;
135 }
136
138 {
140 SCH_SELECTION& selection = selTool->RequestSelection();
141 SCH_SHEET_LIST selectedSheets;
142
143 for( EDA_ITEM* item : selection.Items() )
144 {
145 if( item->Type() == SCH_SYMBOL_T )
146 clearSymbolAnnotation( item, screen, &currentSheet, false );
147
148 if( item->Type() == SCH_SHEET_T && aRecursive )
149 {
150 SCH_SHEET_PATH subSheetPath = currentSheet;
151 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
152
153 sheets.GetSheetsWithinPath( selectedSheets, subSheetPath );
154 }
155 }
156
157 for( SCH_SHEET_PATH sheet : selectedSheets )
158 clearSheetAnnotation( sheet.LastScreen(), &sheet, false );
159
160 break;
161 }
162 }
163
164 // Update the references for the sheet that is currently being displayed.
166
167 wxWindow* erc_dlg = wxWindow::FindWindowByName( DIALOG_ERC_WINDOW_NAME );
168
169 if( erc_dlg )
170 static_cast<DIALOG_ERC*>( erc_dlg )->UpdateAnnotationWarning();
171
172 commit.Push( _( "Delete Annotation" ) );
173
174 // Must go after OnModify() so the connectivity graph has been updated
176}
177
178
179std::unordered_set<SCH_SYMBOL*> getInferredSymbols( const SCH_SELECTION& aSelection )
180{
181 std::unordered_set<SCH_SYMBOL*> symbols;
182
183 for( EDA_ITEM* item : aSelection )
184 {
185 switch( item->Type() )
186 {
187 case SCH_FIELD_T:
188 {
189 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
190
191 if( field->GetId() == FIELD_T::REFERENCE && field->GetParent()->Type() == SCH_SYMBOL_T )
192 symbols.insert( static_cast<SCH_SYMBOL*>( field->GetParent() ) );
193
194 break;
195 }
196
197 case SCH_SYMBOL_T:
198 symbols.insert( static_cast<SCH_SYMBOL*>( item ) );
199 break;
200
201 case SCH_GROUP_T:
202 {
203 SCH_GROUP* group = static_cast<SCH_GROUP*>( item );
204
205 group->RunOnChildren(
206 [&symbols]( SCH_ITEM* aChild )
207 {
208 if( aChild->Type() == SCH_SYMBOL_T )
209 symbols.insert( static_cast<SCH_SYMBOL*>( aChild ) );
210 },
212
213 break;
214 }
215
216 default:
217 break;
218 }
219 }
220
221 return symbols;
222}
223
224
226 ANNOTATE_ORDER_T aSortOption, ANNOTATE_ALGO_T aAlgoOption, bool aRecursive,
227 int aStartNumber, bool aResetAnnotation, bool aRegroupUnits,
228 bool aRepairTimestamps, REPORTER& aReporter, SYMBOL_FILTER aSymbolFilter )
229{
231 SCH_SELECTION& selection = selTool->GetSelection();
232
233 SCH_REFERENCE_LIST references;
234 SCH_SCREENS screens( Schematic().Root() );
236 SCH_SHEET_PATH currentSheet = GetCurrentSheet();
237
238
239 // Store the selected sheets relative to the full hierarchy so we get the correct sheet numbers
240 SCH_SHEET_LIST selectedSheets;
241
242 for( EDA_ITEM* item : selection )
243 {
244 if( item->Type() == SCH_SHEET_T )
245 {
246 SCH_SHEET_PATH subSheetPath = currentSheet;
247 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
248
249 sheets.GetSheetsWithinPath( selectedSheets, subSheetPath );
250 }
251 }
252
253
254 // Like above, store subsheets relative to full hierarchy for recursive annotation from current
255 // sheet
256 SCH_SHEET_LIST subSheets;
257
258 std::vector<SCH_ITEM*> tempSubSheets;
259 currentSheet.LastScreen()->GetSheets( &tempSubSheets );
260
261 for( SCH_ITEM* item : tempSubSheets )
262 {
263 SCH_SHEET_PATH subSheetPath = currentSheet;
264 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
265
266 sheets.GetSheetsWithinPath( subSheets, subSheetPath );
267 }
268
269
270 std::unordered_set<SCH_SYMBOL*> selectedSymbols;
271
272 if( aAnnotateScope == ANNOTATE_SELECTION )
273 selectedSymbols = getInferredSymbols( selection );
274
275
276 // Map of locked symbols
277 SCH_MULTI_UNIT_REFERENCE_MAP lockedSymbols;
278
279 // Map of previous annotation for building info messages
280 std::map<wxString, wxString> previousAnnotation;
281
282 // Test for and replace duplicate time stamps in symbols and sheets. Duplicate time stamps
283 // can happen with old schematics, schematic conversions, or manual editing of files.
284 if( aRepairTimestamps )
285 {
286 int count = screens.ReplaceDuplicateTimeStamps();
287
288 if( count )
289 {
290 wxString msg;
291 msg.Printf( _( "%d duplicate time stamps were found and replaced." ), count );
292 aReporter.ReportTail( msg, RPT_SEVERITY_WARNING );
293 }
294 }
295
296 // Collect all the sets that must be annotated together. When regrouping, we skip this step
297 // to allow fresh groupings based on symbol placement. When resetting without regrouping, we
298 // collect locked symbols but then check for unit conflicts (duplicate units within a ref).
299 if( !aRegroupUnits )
300 {
301 switch( aAnnotateScope )
302 {
303 case ANNOTATE_ALL:
304 sheets.GetMultiUnitSymbols( lockedSymbols, SYMBOL_FILTER_ALL );
305 break;
306
308 currentSheet.GetMultiUnitSymbols( lockedSymbols, SYMBOL_FILTER_ALL );
309
310 if( aRecursive )
311 subSheets.GetMultiUnitSymbols( lockedSymbols, SYMBOL_FILTER_ALL );
312
313 break;
314
316 for( SCH_SYMBOL* symbol : selectedSymbols )
317 currentSheet.AppendMultiUnitSymbol( lockedSymbols, symbol, aSymbolFilter );
318
319 if( aRecursive )
320 selectedSheets.GetMultiUnitSymbols( lockedSymbols, aSymbolFilter );
321
322 break;
323 }
324
325 // When resetting annotations, check for and remove groups with unit conflicts (duplicate
326 // units within the same reference designator). These will get fresh assignments.
327 if( aResetAnnotation )
328 {
329 std::vector<wxString> conflictingRefs;
330
331 for( auto& [refBase, refList] : lockedSymbols )
332 {
333 std::set<int> seenUnits;
334 bool hasConflict = false;
335
336 for( const SCH_REFERENCE& ref : refList )
337 {
338 if( seenUnits.count( ref.GetUnit() ) )
339 {
340 hasConflict = true;
341 break;
342 }
343
344 seenUnits.insert( ref.GetUnit() );
345 }
346
347 if( hasConflict )
348 conflictingRefs.push_back( refBase );
349 }
350
351 for( const wxString& ref : conflictingRefs )
352 lockedSymbols.erase( ref );
353 }
354 }
355
356 // Store previous annotations for building info messages
357 mapExistingAnnotation( previousAnnotation );
358
359 // Set sheet number and number of sheets.
361
362 // Build symbol list
363 switch( aAnnotateScope )
364 {
365 case ANNOTATE_ALL:
366 sheets.GetSymbols( references, SYMBOL_FILTER_ALL );
367 break;
368
370 currentSheet.GetSymbols( references, SYMBOL_FILTER_ALL );
371
372 if( aRecursive )
373 subSheets.GetSymbolsWithinPath( references, currentSheet, SYMBOL_FILTER_NON_POWER, true );
374
375 break;
376
378 for( SCH_SYMBOL* symbol : selectedSymbols )
379 currentSheet.AppendSymbol( references, symbol, aSymbolFilter, true );
380
381 if( aRecursive )
382 selectedSheets.GetSymbolsWithinPath( references, currentSheet, aSymbolFilter, true );
383
384 break;
385 }
386
387 // Remove annotation only updates the "new" flag to indicate to the algorithm
388 // that these references must be reannotated, but keeps the original reference
389 // so that we can reannotate multi-unit symbols together.
390 if( aResetAnnotation )
391 references.RemoveAnnotation();
392
393 // Build additional list of references to be used during reannotation
394 // to avoid duplicate designators (no additional references when annotating
395 // the full schematic)
396 SCH_REFERENCE_LIST additionalRefs;
397
398 if( aAnnotateScope != ANNOTATE_ALL )
399 {
400 SCH_REFERENCE_LIST allRefs;
401 sheets.GetSymbols( allRefs, SYMBOL_FILTER_ALL );
402
403 for( size_t i = 0; i < allRefs.GetCount(); i++ )
404 {
405 if( !references.Contains( allRefs[i] ) )
406 additionalRefs.AddItem( allRefs[i] );
407 }
408 }
409
410 references.SetRefDesTracker( Schematic().Settings().m_refDesTracker );
411
412 // Break full symbol reference into name (prefix) and number:
413 // example: IC1 become IC, and 1
414 references.SplitReferences();
415
416 // Annotate all of the references we've collected by our options
417 references.AnnotateByOptions( aSortOption, aAlgoOption, aStartNumber, lockedSymbols,
418 additionalRefs, false );
419
420 for( size_t i = 0; i < references.GetCount(); i++ )
421 {
422 SCH_REFERENCE& ref = references[i];
423 SCH_SYMBOL* symbol = ref.GetSymbol();
424 SCH_SHEET_PATH* sheet = &ref.GetSheetPath();
425
426 aCommit->Modify( symbol, sheet->LastScreen() );
427 ref.Annotate();
428
429 KIID_PATH full_uuid = sheet->Path();
430 full_uuid.push_back( symbol->m_Uuid );
431
432 wxString prevRef = previousAnnotation[ full_uuid.AsString() ];
433 wxString newRef = symbol->GetRef( sheet );
434
435 if( symbol->GetUnitCount() > 1 )
436 newRef << symbol->SubReference( symbol->GetUnitSelection( sheet ) );
437
438 wxString msg;
439
440 if( prevRef.Length() )
441 {
442 if( newRef == prevRef )
443 continue;
444
445 if( symbol->GetUnitCount() > 1 )
446 {
447 msg.Printf( _( "Updated %s (unit %s) from %s to %s." ),
448 symbol->GetValue( true, sheet, false ),
449 symbol->SubReference( symbol->GetUnit(), false ),
450 prevRef,
451 newRef );
452 }
453 else
454 {
455 msg.Printf( _( "Updated %s from %s to %s." ),
456 symbol->GetValue( true, sheet, false ),
457 prevRef,
458 newRef );
459 }
460 }
461 else
462 {
463 if( symbol->GetUnitCount() > 1 )
464 {
465 msg.Printf( _( "Annotated %s (unit %s) as %s." ),
466 symbol->GetValue( true, sheet, false ),
467 symbol->SubReference( symbol->GetUnit(), false ),
468 newRef );
469 }
470 else
471 {
472 msg.Printf( _( "Annotated %s as %s." ),
473 symbol->GetValue( true, sheet, false ),
474 newRef );
475 }
476 }
477
478 aReporter.Report( msg, RPT_SEVERITY_ACTION );
479 }
480
481 // Final control (just in case ... ).
482 if( !CheckAnnotate(
483 [&aReporter]( ERCE_T, const wxString& aMsg, SCH_REFERENCE*, SCH_REFERENCE* )
484 {
485 aReporter.Report( aMsg, RPT_SEVERITY_ERROR );
486 },
487 aAnnotateScope, aRecursive, aSymbolFilter ) )
488 {
489 aReporter.ReportTail( _( "Annotation complete." ), RPT_SEVERITY_ACTION );
490 }
491
492 // Update on screen references, that can be modified by previous calculations:
495
496 wxWindow* erc_dlg = wxWindow::FindWindowByName( DIALOG_ERC_WINDOW_NAME );
497
498 if( erc_dlg )
499 static_cast<DIALOG_ERC*>( erc_dlg )->UpdateAnnotationWarning();
500
501 SyncView();
502 GetCanvas()->Refresh();
503 OnModify();
504
505 // Must go after OnModify() so the connectivity graph has been updated
507}
508
509
511 bool aRecursive, SYMBOL_FILTER aSymbolFilter )
512{
513 SCH_REFERENCE_LIST referenceList;
515 SCH_SHEET_PATH currentSheet = GetCurrentSheet();
516
517 // Build the list of symbols
518 switch( aAnnotateScope )
519 {
520 case ANNOTATE_ALL:
521 sheets.GetSymbols( referenceList, SYMBOL_FILTER_ALL );
522 break;
523
526
527 if( aRecursive )
528 {
529 SCH_SHEET_LIST subSheets;
530
531 std::vector<SCH_ITEM*> tempSubSheets;
532 currentSheet.LastScreen()->GetSheets( &tempSubSheets );
533
534 for( SCH_ITEM* item : tempSubSheets )
535 {
536 SCH_SHEET_PATH subSheetPath = currentSheet;
537 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
538
539 sheets.GetSheetsWithinPath( subSheets, subSheetPath );
540 }
541
542 for( SCH_SHEET_PATH sheet : subSheets )
543 sheet.GetSymbols( referenceList, SYMBOL_FILTER_NON_POWER );
544 }
545
546 break;
547
550 SCH_SELECTION& selection = selTool->RequestSelection();
551
552 for( SCH_SYMBOL* symbol : getInferredSymbols( selection ) )
553 GetCurrentSheet().AppendSymbol( referenceList, symbol, aSymbolFilter, true );
554
555 if( aRecursive )
556 {
557 SCH_SHEET_LIST selectedSheets;
558
559 for( EDA_ITEM* item : selection.Items() )
560 {
561 if( item->Type() == SCH_SHEET_T )
562 {
563 SCH_SHEET_PATH subSheetPath = currentSheet;
564 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
565
566 sheets.GetSheetsWithinPath( selectedSheets, subSheetPath );
567 }
568 }
569
570 for( SCH_SHEET_PATH sheet : selectedSheets )
571 sheet.GetSymbols( referenceList, aSymbolFilter );
572 }
573
574 break;
575 }
576
577 // Empty schematic does not need annotation
578 if( referenceList.GetCount() == 0 )
579 return 0;
580
581 return referenceList.CheckAnnotation( aErrorHandler );
582}
std::unordered_set< SCH_SYMBOL * > getInferredSymbols(const SCH_SELECTION &aSelection)
Definition annotate.cpp:179
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:96
const KIID m_Uuid
Definition eda_item.h:531
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
EDA_ITEM * GetParent() const
Definition eda_item.h:110
wxString AsString() const
Definition kiid.cpp:393
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:71
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
Definition reporter.h:100
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:110
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.
Definition annotate.cpp:37
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:58
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, SYMBOL_FILTER aSymbolFilter)
Check for annotation errors.
Definition annotate.cpp:510
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, SYMBOL_FILTER aSymbolFilter)
Annotate the symbols in the schematic that are not currently annotated.
Definition annotate.cpp:225
void UpdateNetHighlightStatus()
FIELD_T GetId() const
Definition sch_field.h:132
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:162
int GetUnit() const
Definition sch_item.h:233
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.
Definition sch_screen.h:746
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:44
Schematic symbol object.
Definition sch_symbol.h:69
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
TOOL_MANAGER * m_toolManager
This file is part of the common library.
#define DIALOG_ERC_WINDOW_NAME
Definition dialog_erc.h:35
#define _(s)
@ RECURSE
Definition eda_item.h:49
ERCE_T
ERC error codes.
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_ACTION
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.
SYMBOL_FILTER
@ SYMBOL_FILTER_NON_POWER
@ SYMBOL_FILTER_ALL
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ SCH_GROUP_T
Definition typeinfo.h:170
@ SCH_SYMBOL_T
Definition typeinfo.h:169
@ SCH_FIELD_T
Definition typeinfo.h:147
@ SCH_SHEET_T
Definition typeinfo.h:172