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