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
58std::unordered_set<SCH_SYMBOL*> getInferredSymbols( const SCH_SELECTION& aSelection )
59{
60 std::unordered_set<SCH_SYMBOL*> symbols;
61
62 for( EDA_ITEM* item : aSelection )
63 {
64 switch( item->Type() )
65 {
66 case SCH_FIELD_T:
67 {
68 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
69
70 if( field->GetId() == FIELD_T::REFERENCE && field->GetParent()->Type() == SCH_SYMBOL_T )
71 symbols.insert( static_cast<SCH_SYMBOL*>( field->GetParent() ) );
72
73 break;
74 }
75
76 case SCH_SYMBOL_T:
77 symbols.insert( static_cast<SCH_SYMBOL*>( item ) );
78 break;
79
80 case SCH_GROUP_T:
81 {
82 SCH_GROUP* group = static_cast<SCH_GROUP*>( item );
83
84 group->RunOnChildren(
85 [&symbols]( SCH_ITEM* aChild )
86 {
87 if( aChild->Type() == SCH_SYMBOL_T )
88 symbols.insert( static_cast<SCH_SYMBOL*>( aChild ) );
89 },
91
92 break;
93 }
94
95 default:
96 break;
97 }
98 }
99
100 return symbols;
101}
102
103
104void SCH_EDIT_FRAME::DeleteAnnotation( ANNOTATE_SCOPE_T aAnnotateScope, bool aRecursive,
105 REPORTER& aReporter )
106{
107
109 SCH_SCREEN* screen = GetScreen();
110 SCH_SHEET_PATH currentSheet = GetCurrentSheet();
111 SCH_COMMIT commit( this );
112
113 auto clearSymbolAnnotation =
114 [&]( EDA_ITEM* aItem, SCH_SCREEN* aScreen, SCH_SHEET_PATH* aSheet, bool aResetPrefixes )
115 {
116 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( aItem );
117 commit.Modify( aItem, aScreen );
118
119 // aSheet == nullptr means all sheets
120 if( !aSheet || symbol->IsAnnotated( aSheet ) )
121 {
122 wxString msg;
123
124 if( symbol->GetUnitCount() > 1 )
125 {
126 msg.Printf( _( "Cleared annotation for %s (unit %s)." ),
127 symbol->GetValue( aSheet, FOR_GUI ),
128 symbol->SubReference( symbol->GetUnit(), false ) );
129 }
130 else
131 {
132 msg.Printf( _( "Cleared annotation for %s." ),
133 symbol->GetValue( aSheet, FOR_GUI ) );
134 }
135
136 symbol->ClearAnnotation( aSheet, aResetPrefixes );
137 aReporter.Report( msg, RPT_SEVERITY_ACTION );
138 }
139 };
140
141 auto clearSheetAnnotation =
142 [&]( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aSheet, bool aResetPrefixes )
143 {
144 for( SCH_ITEM* item : aScreen->Items().OfType( SCH_SYMBOL_T ) )
145 clearSymbolAnnotation( item, aScreen, aSheet, aResetPrefixes );
146 };
147
148 switch( aAnnotateScope )
149 {
150 case ANNOTATE_ALL:
151 {
152 for( SCH_SHEET_PATH& sheet : sheets )
153 clearSheetAnnotation( sheet.LastScreen(), &sheet, false );
154
155 break;
156 }
158 {
159 clearSheetAnnotation( screen, &currentSheet, false );
160
161 if( aRecursive )
162 {
163 SCH_SHEET_LIST subSheets;
164
165 std::vector<SCH_ITEM*> tempSubSheets;
166 currentSheet.LastScreen()->GetSheets( &tempSubSheets );
167
168 for( SCH_ITEM* item : tempSubSheets )
169 {
170 SCH_SHEET_PATH subSheetPath = currentSheet;
171 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
172
173 sheets.GetSheetsWithinPath( subSheets, subSheetPath );
174 }
175
176 for( SCH_SHEET_PATH sheet : subSheets )
177 clearSheetAnnotation( sheet.LastScreen(), &sheet, false );
178 }
179
180 break;
181 }
182
184 {
186 SCH_SELECTION& selection = selTool->RequestSelection();
187 SCH_SHEET_LIST selectedSheets;
188
189 for( SCH_SYMBOL* symbol : getInferredSymbols( selection ) )
190 clearSymbolAnnotation( symbol, screen, &currentSheet, false );
191
192 for( EDA_ITEM* item : selection.Items() )
193 {
194 if( item->Type() == SCH_SHEET_T && aRecursive )
195 {
196 SCH_SHEET_PATH subSheetPath = currentSheet;
197 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
198
199 sheets.GetSheetsWithinPath( selectedSheets, subSheetPath );
200 }
201 }
202
203 for( SCH_SHEET_PATH sheet : selectedSheets )
204 clearSheetAnnotation( sheet.LastScreen(), &sheet, false );
205
206 break;
207 }
208 }
209
210 // Update the references for the sheet that is currently being displayed.
212
213 wxWindow* erc_dlg = wxWindow::FindWindowByName( DIALOG_ERC_WINDOW_NAME );
214
215 if( erc_dlg )
216 static_cast<DIALOG_ERC*>( erc_dlg )->UpdateAnnotationWarning();
217
218 commit.Push( _( "Delete Annotation" ) );
219
220 // Must go after OnModify() so the connectivity graph has been updated
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 )
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_NON_POWER );
305 break;
306
308 currentSheet.GetMultiUnitSymbols( lockedSymbols, SYMBOL_FILTER_NON_POWER );
309
310 if( aRecursive )
311 subSheets.GetMultiUnitSymbols( lockedSymbols, SYMBOL_FILTER_NON_POWER );
312
313 break;
314
316 for( SCH_SYMBOL* symbol : selectedSymbols )
317 currentSheet.AppendMultiUnitSymbol( lockedSymbols, symbol, SYMBOL_FILTER_NON_POWER );
318
319 if( aRecursive )
320 selectedSheets.GetMultiUnitSymbols( lockedSymbols, SYMBOL_FILTER_NON_POWER );
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_NON_POWER );
367 break;
368
370 currentSheet.GetSymbols( references, SYMBOL_FILTER_NON_POWER );
371
372 if( aRecursive )
373 subSheets.GetSymbolsWithinPath( references, currentSheet, SYMBOL_FILTER_NON_POWER );
374
375 break;
376
378 for( SCH_SYMBOL* symbol : selectedSymbols )
379 currentSheet.AppendSymbol( references, symbol, SYMBOL_FILTER_NON_POWER );
380
381 if( aRecursive )
382 selectedSheets.GetSymbolsWithinPath( references, currentSheet, SYMBOL_FILTER_NON_POWER );
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_NON_POWER );
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, additionalRefs, false );
418
419 for( size_t i = 0; i < references.GetCount(); i++ )
420 {
421 SCH_REFERENCE& ref = references[i];
422 SCH_SYMBOL* symbol = ref.GetSymbol();
423 SCH_SHEET_PATH* sheet = &ref.GetSheetPath();
424
425 aCommit->Modify( symbol, sheet->LastScreen() );
426 ref.Annotate();
427
428 KIID_PATH full_uuid = sheet->Path();
429 full_uuid.push_back( symbol->m_Uuid );
430
431 wxString prevRef = previousAnnotation[ full_uuid.AsString() ];
432 wxString newRef = symbol->GetRef( sheet );
433
434 if( symbol->GetUnitCount() > 1 )
435 newRef << symbol->SubReference( symbol->GetUnitSelection( sheet ) );
436
437 wxString msg;
438
439 if( prevRef.Length() )
440 {
441 if( newRef == prevRef )
442 continue;
443
444 if( symbol->GetUnitCount() > 1 )
445 {
446 msg.Printf( _( "Updated %s (unit %s) from %s to %s." ),
447 symbol->GetValue( sheet, FOR_GUI ),
448 symbol->SubReference( symbol->GetUnit(), false ),
449 prevRef,
450 newRef );
451 }
452 else
453 {
454 msg.Printf( _( "Updated %s from %s to %s." ),
455 symbol->GetValue( sheet, FOR_GUI ),
456 prevRef,
457 newRef );
458 }
459 }
460 else
461 {
462 if( symbol->GetUnitCount() > 1 )
463 {
464 msg.Printf( _( "Annotated %s (unit %s) as %s." ),
465 symbol->GetValue( sheet, FOR_GUI ),
466 symbol->SubReference( symbol->GetUnit(), false ),
467 newRef );
468 }
469 else
470 {
471 msg.Printf( _( "Annotated %s as %s." ),
472 symbol->GetValue( sheet, FOR_GUI ),
473 newRef );
474 }
475 }
476
477 aReporter.Report( msg, RPT_SEVERITY_ACTION );
478 }
479
480 // Final control (just in case ... ).
481 if( !CheckAnnotate(
482 [&aReporter]( ERCE_T, const wxString& aMsg, SCH_REFERENCE*, SCH_REFERENCE* )
483 {
484 aReporter.Report( aMsg, RPT_SEVERITY_ERROR );
485 },
486 aAnnotateScope, aRecursive ) )
487 {
488 aReporter.ReportTail( _( "Annotation complete." ), RPT_SEVERITY_ACTION );
489 }
490
491 // Update on screen references, that can be modified by previous calculations:
494
495 wxWindow* erc_dlg = wxWindow::FindWindowByName( DIALOG_ERC_WINDOW_NAME );
496
497 if( erc_dlg )
498 static_cast<DIALOG_ERC*>( erc_dlg )->UpdateAnnotationWarning();
499
500 SyncView();
501 GetCanvas()->Refresh();
502 OnModify();
503
504 // Must go after OnModify() so the connectivity graph has been updated
506}
507
508
510 bool aRecursive )
511{
512 SCH_REFERENCE_LIST referenceList;
514 SCH_SHEET_PATH currentSheet = GetCurrentSheet();
515
516 // Build the list of symbols
517 switch( aAnnotateScope )
518 {
519 case ANNOTATE_ALL:
520 sheets.GetSymbols( referenceList, SYMBOL_FILTER_NON_POWER, true );
521 break;
522
524 GetCurrentSheet().GetSymbols( referenceList, SYMBOL_FILTER_NON_POWER, true );
525
526 if( aRecursive )
527 {
528 SCH_SHEET_LIST subSheets;
529
530 std::vector<SCH_ITEM*> tempSubSheets;
531 currentSheet.LastScreen()->GetSheets( &tempSubSheets );
532
533 for( SCH_ITEM* item : tempSubSheets )
534 {
535 SCH_SHEET_PATH subSheetPath = currentSheet;
536 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
537
538 sheets.GetSheetsWithinPath( subSheets, subSheetPath );
539 }
540
541 for( const SCH_SHEET_PATH& sheet : subSheets )
542 sheet.GetSymbols( referenceList, SYMBOL_FILTER_NON_POWER, true );
543 }
544
545 break;
546
549 SCH_SELECTION& selection = selTool->RequestSelection();
550
551 for( SCH_SYMBOL* symbol : getInferredSymbols( selection ) )
552 GetCurrentSheet().AppendSymbol( referenceList, symbol, SYMBOL_FILTER_NON_POWER, true );
553
554 if( aRecursive )
555 {
556 SCH_SHEET_LIST selectedSheets;
557
558 for( EDA_ITEM* item : selection.Items() )
559 {
560 if( item->Type() == SCH_SHEET_T )
561 {
562 SCH_SHEET_PATH subSheetPath = currentSheet;
563 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
564
565 sheets.GetSheetsWithinPath( selectedSheets, subSheetPath );
566 }
567 }
568
569 for( SCH_SHEET_PATH sheet : selectedSheets )
570 sheet.GetSymbols( referenceList, SYMBOL_FILTER_NON_POWER, true );
571 }
572
573 break;
574 }
575
576 // Empty schematic does not need annotation
577 if( referenceList.GetCount() == 0 )
578 return 0;
579
580 return referenceList.CheckAnnotation( aErrorHandler );
581}
std::unordered_set< SCH_SYMBOL * > getInferredSymbols(const SCH_SELECTION &aSelection)
Definition annotate.cpp:58
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: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:104
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:509
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:225
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 ...
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:818
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:48
Schematic symbol object.
Definition sch_symbol.h:73
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 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
@ FOR_GUI
Definition common.h:91
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:51
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_NON_POWER
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ 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