KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_reference_list.h File Reference
#include <functional>
#include <map>
#include <optional>
#include <set>
#include <utility>
#include <lib_symbol.h>
#include <macros.h>
#include <sch_sheet_path.h>
#include <sch_symbol.h>
#include <sch_text.h>
#include <erc/erc_settings.h>

Go to the source code of this file.

Classes

class  SCH_REFERENCE
 A helper to define a symbol's reference designator in a schematic. More...
 
class  SCH_REFERENCE_LIST
 Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used more than once and its reference designator is dependent on the sheet path for the same symbol. More...
 

Typedefs

typedef 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.
 

Enumerations

enum  ANNOTATE_SCOPE_T { ANNOTATE_ALL , ANNOTATE_CURRENT_SHEET , ANNOTATE_SELECTION }
 Schematic annotation scope options. More...
 
enum  ANNOTATE_ORDER_T { SORT_BY_X_POSITION , SORT_BY_Y_POSITION , UNSORTED }
 Schematic annotation order options. More...
 
enum  ANNOTATE_ALGO_T { INCREMENTAL_BY_REF , SHEET_NUMBER_X_100 , SHEET_NUMBER_X_1000 }
 Schematic annotation type options. More...
 

Functions

void AnnotateNewSymbol (SCH_SYMBOL *aSymbol, const std::vector< SCH_SHEET_PATH > &aPaths, SCH_REFERENCE_LIST &aExistingRefs, const SCHEMATIC_SETTINGS &aSettings, SCH_SHEET_LIST *aHierarchy)
 Annotate a newly placed symbol on each of aPaths in turn, avoiding aExistingRefs and adding the results to it.
 
std::optional< std::pair< SCH_SHEET_PATH, SCH_SHEET_PATH > > FindRefSuffixCollision (const SCH_REFERENCE_LIST &aRefs, const SCHEMATIC &aSchematic)
 Find two instances of a reused sheet that aRefs reaches and that compose the same reference suffix.
 
std::set< const SCH_SCREEN * > AnnotateReferences (SCH_REFERENCE_LIST &aRefs, SCH_MULTI_UNIT_REFERENCE_MAP aLocked, const SCHEMATIC &aSchematic, ANNOTATE_SCOPE_T aScope, ANNOTATE_ORDER_T aSortOption, ANNOTATE_ALGO_T aAlgoOption, int aStartNumber, bool aResetAnnotation, const std::function< void(SCH_REFERENCE &)> &aBeforeAnnotate={})
 Annotate aRefs, the references in aScope, around every other symbol of aSchematic.
 

Typedef Documentation

◆ ANNOTATION_ERROR_HANDLER

typedef 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.

Definition at line 325 of file sch_reference_list.h.

Enumeration Type Documentation

◆ ANNOTATE_ALGO_T

Schematic annotation type options.

Enumerator
INCREMENTAL_BY_REF 

Annotate incrementally using the first free reference number.

SHEET_NUMBER_X_100 

Annotate using the first free reference number starting at the sheet number * 100.

SHEET_NUMBER_X_1000 

Annotate using the first free reference number starting at the sheet number * 1000.

Definition at line 60 of file sch_reference_list.h.

◆ ANNOTATE_ORDER_T

Schematic annotation order options.

Enumerator
SORT_BY_X_POSITION 

Annotate by X position from left to right.

SORT_BY_Y_POSITION 

Annotate by Y position from top to bottom.

UNSORTED 

Annotate by position of symbol in the schematic sheet object list.

Definition at line 50 of file sch_reference_list.h.

◆ ANNOTATE_SCOPE_T

Schematic annotation scope options.

Enumerator
ANNOTATE_ALL 

Annotate the full schematic.

ANNOTATE_CURRENT_SHEET 

Annotate the current sheet.

ANNOTATE_SELECTION 

Annotate the selection.

Definition at line 42 of file sch_reference_list.h.

Function Documentation

◆ AnnotateNewSymbol()

◆ AnnotateReferences()

std::set< const SCH_SCREEN * > AnnotateReferences ( SCH_REFERENCE_LIST & aRefs,
SCH_MULTI_UNIT_REFERENCE_MAP aLocked,
const SCHEMATIC & aSchematic,
ANNOTATE_SCOPE_T aScope,
ANNOTATE_ORDER_T aSortOption,
ANNOTATE_ALGO_T aAlgoOption,
int aStartNumber,
bool aResetAnnotation,
const std::function< void(SCH_REFERENCE &)> & aBeforeAnnotate = {} )

Annotate aRefs, the references in aScope, around every other symbol of aSchematic.

In suffix annotation mode each symbol of a reused sheet annotates on its first instance and every other instance takes that base. Check FindRefSuffixCollision() first, since instances that compose alike cannot share a base.

Parameters
aLockedthe multi-unit groups in scope that stay together, or none to regroup units.
aResetAnnotationrenumber every reference instead of only the unannotated ones.
aBeforeAnnotatecalled with each reference before its symbol changes.
Returns
the screens whose references now apply to every sheet that uses them.

Definition at line 1561 of file sch_reference_list.cpp.

References SCH_REFERENCE_LIST::AddItem(), ANNOTATE_ALL, SCH_REFERENCE_LIST::AnnotateByOptions(), SCH_REFERENCE_LIST::Contains(), SCHEMATIC::CopiesSelectDifferentUnits(), SCH_SHEET_LIST::GetSymbols(), SCHEMATIC::Hierarchy(), SCH_REFERENCE_LIST::LockedForRepresentatives(), SCHEMATIC_SETTINGS::m_AnnotateReusedSheetSuffixes, SCHEMATIC_SETTINGS::m_refDesTracker, SCH_REFERENCE_LIST::RemoveAnnotation(), removeUnitConflicts(), SCH_REFERENCE_LIST::RenumberBasesUsedBy(), SCH_REFERENCE_LIST::SetRefDesTracker(), SCHEMATIC::Settings(), SCH_SHEET_LIST::ShareReusedSheetRef(), SCH_REFERENCE_LIST::SplitReferences(), SCHEMATIC::SplitUnitSymbols(), SYMBOL_FILTER_NON_POWER, and SCH_REFERENCE_LIST::UseReusedSheetRepresentatives().

Referenced by REF_SUFFIX_FIXTURE::Annotate(), SCH_EDIT_FRAME::AnnotateSymbols(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ FindRefSuffixCollision()

std::optional< std::pair< SCH_SHEET_PATH, SCH_SHEET_PATH > > FindRefSuffixCollision ( const SCH_REFERENCE_LIST & aRefs,
const SCHEMATIC & aSchematic )

Find two instances of a reused sheet that aRefs reaches and that compose the same reference suffix.

Suffix annotation mode gives every instance one base, so only their suffixes keep their references apart.

Returns
the colliding instance and the first instance with its suffix, or nothing outside suffix mode.

Definition at line 1522 of file sch_reference_list.cpp.

References SCHEMATIC_SETTINGS::m_AnnotateReusedSheetSuffixes, SCHEMATIC::RefSuffixCollisions(), and SCHEMATIC::Settings().

Referenced by REF_SUFFIX_FIXTURE::Annotate(), and SCH_EDIT_FRAME::AnnotateSymbols().