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;
44 Schematic().Hierarchy().GetSymbols( 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,
231 bool aRecursive, int aStartNumber, bool aResetAnnotation,
232 bool aRegroupUnits, bool aRepairTimestamps,
233 REPORTER& aReporter )
234{
236 SCH_SELECTION& selection = selTool->GetSelection();
237
238 SCH_REFERENCE_LIST references;
239 SCH_SCREENS screens( Schematic().Root() );
241 SCH_SHEET_PATH currentSheet = GetCurrentSheet();
242
243
244 // Store the selected sheets relative to the full hierarchy so we get the correct sheet numbers
245 SCH_SHEET_LIST selectedSheets;
246
247 for( EDA_ITEM* item : selection )
248 {
249 if( item->Type() == SCH_SHEET_T )
250 {
251 SCH_SHEET_PATH subSheetPath = currentSheet;
252 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
253
254 sheets.GetSheetsWithinPath( selectedSheets, subSheetPath );
255 }
256 }
257
258
259 // Like above, store subsheets relative to full hierarchy for recursive annotation from current
260 // sheet
261 SCH_SHEET_LIST subSheets;
262
263 std::vector<SCH_ITEM*> tempSubSheets;
264 currentSheet.LastScreen()->GetSheets( &tempSubSheets );
265
266 for( SCH_ITEM* item : tempSubSheets )
267 {
268 SCH_SHEET_PATH subSheetPath = currentSheet;
269 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
270
271 sheets.GetSheetsWithinPath( subSheets, subSheetPath );
272 }
273
274
275 std::unordered_set<SCH_SYMBOL*> selectedSymbols;
276
277 if( aAnnotateScope == ANNOTATE_SELECTION )
278 selectedSymbols = getInferredSymbols( selection );
279
280
281 // Map of locked symbols
282 SCH_MULTI_UNIT_REFERENCE_MAP lockedSymbols;
283
284 // Map of previous annotation for building info messages
285 std::map<wxString, wxString> previousAnnotation;
286
287 // Test for and replace duplicate time stamps in symbols and sheets. Duplicate time stamps
288 // can happen with old schematics, schematic conversions, or manual editing of files.
289 if( aRepairTimestamps )
290 {
291 int count = screens.ReplaceDuplicateTimeStamps();
292
293 if( count )
294 {
295 wxString msg;
296 msg.Printf( _( "%d duplicate time stamps were found and replaced." ), count );
297 aReporter.ReportTail( msg, RPT_SEVERITY_WARNING );
298 }
299 }
300
301 // Collect all the sets that must be annotated together. When regrouping, we skip this step
302 // to allow fresh groupings based on symbol placement. When resetting without regrouping, we
303 // collect locked symbols but then check for unit conflicts (duplicate units within a ref).
304 if( !aRegroupUnits )
305 {
306 switch( aAnnotateScope )
307 {
308 case ANNOTATE_ALL:
309 sheets.GetMultiUnitSymbols( lockedSymbols );
310 break;
311
313 currentSheet.GetMultiUnitSymbols( lockedSymbols );
314
315 if( aRecursive )
316 subSheets.GetMultiUnitSymbols( lockedSymbols );
317
318 break;
319
321 for( SCH_SYMBOL* symbol : selectedSymbols )
322 currentSheet.AppendMultiUnitSymbol( lockedSymbols, symbol );
323
324 if( aRecursive )
325 selectedSheets.GetMultiUnitSymbols( lockedSymbols );
326
327 break;
328 }
329
330 // When resetting annotations, check for and remove groups with unit conflicts (duplicate
331 // units within the same reference designator). These will get fresh assignments.
332 if( aResetAnnotation )
333 {
334 std::vector<wxString> conflictingRefs;
335
336 for( auto& [refBase, refList] : lockedSymbols )
337 {
338 std::set<int> seenUnits;
339 bool hasConflict = false;
340
341 for( const SCH_REFERENCE& ref : refList )
342 {
343 if( seenUnits.count( ref.GetUnit() ) )
344 {
345 hasConflict = true;
346 break;
347 }
348
349 seenUnits.insert( ref.GetUnit() );
350 }
351
352 if( hasConflict )
353 conflictingRefs.push_back( refBase );
354 }
355
356 for( const wxString& ref : conflictingRefs )
357 lockedSymbols.erase( ref );
358 }
359 }
360
361 // Store previous annotations for building info messages
362 mapExistingAnnotation( previousAnnotation );
363
364 // Set sheet number and number of sheets.
366
367 // Build symbol list
368 switch( aAnnotateScope )
369 {
370 case ANNOTATE_ALL:
371 sheets.GetSymbols( references );
372 break;
373
375 currentSheet.GetSymbols( references );
376
377 if( aRecursive )
378 subSheets.GetSymbolsWithinPath( references, currentSheet, false, true );
379
380 break;
381
383 for( SCH_SYMBOL* symbol : selectedSymbols )
384 currentSheet.AppendSymbol( references, symbol, false, true );
385
386 if( aRecursive )
387 selectedSheets.GetSymbolsWithinPath( references, currentSheet, false, true );
388
389 break;
390 }
391
392 // Remove annotation only updates the "new" flag to indicate to the algorithm
393 // that these references must be reannotated, but keeps the original reference
394 // so that we can reannotate multi-unit symbols together.
395 if( aResetAnnotation )
396 references.RemoveAnnotation();
397
398 // Build additional list of references to be used during reannotation
399 // to avoid duplicate designators (no additional references when annotating
400 // the full schematic)
401 SCH_REFERENCE_LIST additionalRefs;
402
403 if( aAnnotateScope != ANNOTATE_ALL )
404 {
405 SCH_REFERENCE_LIST allRefs;
406 sheets.GetSymbols( allRefs );
407
408 for( size_t i = 0; i < allRefs.GetCount(); i++ )
409 {
410 if( !references.Contains( allRefs[i] ) )
411 additionalRefs.AddItem( allRefs[i] );
412 }
413 }
414
415 references.SetRefDesTracker( Schematic().Settings().m_refDesTracker );
416
417 // Break full symbol reference into name (prefix) and number:
418 // example: IC1 become IC, and 1
419 references.SplitReferences();
420
421 // Annotate all of the references we've collected by our options
422 references.AnnotateByOptions( aSortOption, aAlgoOption, aStartNumber, lockedSymbols,
423 additionalRefs, false );
424
425 for( size_t i = 0; i < references.GetCount(); i++ )
426 {
427 SCH_REFERENCE& ref = references[i];
428 SCH_SYMBOL* symbol = ref.GetSymbol();
429 SCH_SHEET_PATH* sheet = &ref.GetSheetPath();
430
431 aCommit->Modify( symbol, sheet->LastScreen() );
432 ref.Annotate();
433
434 KIID_PATH full_uuid = sheet->Path();
435 full_uuid.push_back( symbol->m_Uuid );
436
437 wxString prevRef = previousAnnotation[ full_uuid.AsString() ];
438 wxString newRef = symbol->GetRef( sheet );
439
440 if( symbol->GetUnitCount() > 1 )
441 newRef << symbol->SubReference( symbol->GetUnitSelection( sheet ) );
442
443 wxString msg;
444
445 if( prevRef.Length() )
446 {
447 if( newRef == prevRef )
448 continue;
449
450 if( symbol->GetUnitCount() > 1 )
451 {
452 msg.Printf( _( "Updated %s (unit %s) from %s to %s." ),
453 symbol->GetValue( true, sheet, false ),
454 symbol->SubReference( symbol->GetUnit(), false ),
455 prevRef,
456 newRef );
457 }
458 else
459 {
460 msg.Printf( _( "Updated %s from %s to %s." ),
461 symbol->GetValue( true, sheet, false ),
462 prevRef,
463 newRef );
464 }
465 }
466 else
467 {
468 if( symbol->GetUnitCount() > 1 )
469 {
470 msg.Printf( _( "Annotated %s (unit %s) as %s." ),
471 symbol->GetValue( true, sheet, false ),
472 symbol->SubReference( symbol->GetUnit(), false ),
473 newRef );
474 }
475 else
476 {
477 msg.Printf( _( "Annotated %s as %s." ),
478 symbol->GetValue( true, sheet, false ),
479 newRef );
480 }
481 }
482
483 aReporter.Report( msg, RPT_SEVERITY_ACTION );
484 }
485
486 // Final control (just in case ... ).
487 if( !CheckAnnotate(
488 [ &aReporter ]( ERCE_T , const wxString& aMsg, SCH_REFERENCE* , SCH_REFERENCE* )
489 {
490 aReporter.Report( aMsg, RPT_SEVERITY_ERROR );
491 },
492 aAnnotateScope, aRecursive ) )
493 {
494 aReporter.ReportTail( _( "Annotation complete." ), RPT_SEVERITY_ACTION );
495 }
496
497 // Update on screen references, that can be modified by previous calculations:
500
501 wxWindow* erc_dlg = wxWindow::FindWindowByName( DIALOG_ERC_WINDOW_NAME );
502
503 if( erc_dlg )
504 static_cast<DIALOG_ERC*>( erc_dlg )->UpdateAnnotationWarning();
505
506 SyncView();
507 GetCanvas()->Refresh();
508 OnModify();
509
510 // Must go after OnModify() so the connectivity graph has been updated
512}
513
514
516 ANNOTATE_SCOPE_T aAnnotateScope,
517 bool aRecursive )
518{
519 SCH_REFERENCE_LIST referenceList;
520 constexpr bool includePowerSymbols = false;
522 SCH_SHEET_PATH currentSheet = GetCurrentSheet();
523
524 // Build the list of symbols
525 switch( aAnnotateScope )
526 {
527 case ANNOTATE_ALL:
528 sheets.GetSymbols( referenceList );
529 break;
530
532 GetCurrentSheet().GetSymbols( referenceList, includePowerSymbols );
533
534 if( aRecursive )
535 {
536 SCH_SHEET_LIST subSheets;
537
538 std::vector<SCH_ITEM*> tempSubSheets;
539 currentSheet.LastScreen()->GetSheets( &tempSubSheets );
540
541 for( SCH_ITEM* item : tempSubSheets )
542 {
543 SCH_SHEET_PATH subSheetPath = currentSheet;
544 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
545
546 sheets.GetSheetsWithinPath( subSheets, subSheetPath );
547 }
548
549 for( SCH_SHEET_PATH sheet : subSheets )
550 sheet.GetSymbols( referenceList, includePowerSymbols );
551 }
552
553 break;
554
557 SCH_SELECTION& selection = selTool->RequestSelection();
558
559 for( SCH_SYMBOL* symbol : getInferredSymbols( selection ) )
560 GetCurrentSheet().AppendSymbol( referenceList, symbol, false, true );
561
562 if( aRecursive )
563 {
564 SCH_SHEET_LIST selectedSheets;
565
566 for( EDA_ITEM* item : selection.Items() )
567 {
568 if( item->Type() == SCH_SHEET_T )
569 {
570 SCH_SHEET_PATH subSheetPath = currentSheet;
571 subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
572
573 sheets.GetSheetsWithinPath( selectedSheets, subSheetPath );
574 }
575 }
576
577 for( SCH_SHEET_PATH sheet : selectedSheets )
578 sheet.GetSymbols( referenceList, includePowerSymbols );
579 }
580
581 break;
582 }
583
584 // Empty schematic does not need annotation
585 if( referenceList.GetCount() == 0 )
586 return 0;
587
588 return referenceList.CheckAnnotation( aErrorHandler );
589}
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:98
const KIID m_Uuid
Definition eda_item.h:522
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:356
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:112
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=ANNOTATE_ALL, bool aRecursive=true)
Check for annotation errors.
Definition annotate.cpp:515
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:229
void UpdateNetHighlightStatus()
FIELD_T GetId() const
Definition sch_field.h:122
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:167
int GetUnit() const
Definition sch_item.h:238
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:747
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 GetMultiUnitSymbols(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true) const
Add a SCH_REFERENCE_LIST object to aRefList for each same-reference set of multi-unit parts in the li...
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
void GetSheetsWithinPath(std::vector< SCH_SHEET_PATH > &aSheets, const SCH_SHEET_PATH &aSheetPath) const
Add a SCH_SHEET_PATH object to aSheets for each sheet in the list that are contained within aSheetPat...
void GetSymbolsWithinPath(SCH_REFERENCE_LIST &aReferences, const SCH_SHEET_PATH &aSheetPath, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets that are contained wi...
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void AppendMultiUnitSymbol(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, SCH_SYMBOL *aSymbol, bool aIncludePowerSymbols=true) const
Append a SCH_REFERENCE_LIST object to aRefList based on aSymbol, storing same-reference set of multi-...
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Adds SCH_REFERENCE object to aReferences for each symbol in the sheet.
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
SCH_SCREEN * LastScreen()
void GetMultiUnitSymbols(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true) const
Add a SCH_REFERENCE_LIST object to aRefList for each same-reference set of multi-unit parts in the sh...
void AppendSymbol(SCH_REFERENCE_LIST &aReferences, SCH_SYMBOL *aSymbol, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Append a SCH_REFERENCE object to aReferences based on aSymbol.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
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: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.
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ SCH_GROUP_T
Definition typeinfo.h:177
@ SCH_SYMBOL_T
Definition typeinfo.h:176
@ SCH_FIELD_T
Definition typeinfo.h:154
@ SCH_SHEET_T
Definition typeinfo.h:179