KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_reference_list.cpp File Reference

functions to create a symbol flat list and to annotate schematic. More...

#include <sch_reference_list.h>
#include <core/kicad_algo.h>
#include <wx/regex.h>
#include <algorithm>
#include <map>
#include <optional>
#include <set>
#include <vector>
#include <unordered_set>
#include <string_utils.h>
#include <erc/erc_settings.h>
#include <refdes_tracker.h>
#include <sch_symbol.h>
#include <schematic.h>
#include <sch_edit_frame.h>

Go to the source code of this file.

Functions

static bool sharesReusedBase (const SCH_REFERENCE &aRef)
 
static std::pair< const SCH_SYMBOL *, KIID_PATH > packageMemberKey (const SCH_REFERENCE &aRef)
 
wxString buildFullReference (const SCH_REFERENCE &aItem, int aUnitNumber=-1)
 
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.
 
static void removeUnitConflicts (SCH_MULTI_UNIT_REFERENCE_MAP &aLocked)
 
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.
 

Detailed Description

functions to create a symbol flat list and to annotate schematic.

Definition in file sch_reference_list.cpp.

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().

◆ buildFullReference()

wxString buildFullReference ( const SCH_REFERENCE & aItem,
int aUnitNumber = -1 )

◆ 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().

◆ packageMemberKey()

◆ removeUnitConflicts()

static void removeUnitConflicts ( SCH_MULTI_UNIT_REFERENCE_MAP & aLocked)
static

Definition at line 1543 of file sch_reference_list.cpp.

References SCH_REFERENCE::GetUnit().

Referenced by AnnotateReferences().

◆ sharesReusedBase()