KiCad PCB EDA Suite
Loading...
Searching...
No Matches
variant_symbol_utils.cpp File Reference
#include "variant_symbol_utils.h"
#include <lib_symbol.h>
#include <span>
#include <pin_type.h>
#include <sch_pin.h>
#include <algorithm>

Go to the source code of this file.

Functions

bool VariantSymbolPinsMatch (const SCH_PIN &aBase, const SCH_PIN &aCandidate)
 Check whether two graphical pins occupy the same variant-symbol connection slot.
 
static std::vector< VARIANT_COMPAT_RESULTvalidateCompatibility (int aBaseUnits, int aBaseBodyStyles, std::span< const PIN_COMPARISON_DATA > basePins, int aCandidateUnits, int aCandidateBodyStyles, std::span< const PIN_COMPARISON_DATA > candidatePins)
 
static std::vector< PIN_COMPARISON_DATAvariantPins (const LIB_SYMBOL &aSymbol)
 
std::vector< VARIANT_COMPAT_RESULTValidateVariantSymbolCompatibility (const LIB_SYMBOL &aBase, const LIB_SYMBOL &aCandidate)
 Check whether aCandidate can be used as a variant symbol override for aBase.
 

Function Documentation

◆ validateCompatibility()

static std::vector< VARIANT_COMPAT_RESULT > validateCompatibility ( int aBaseUnits,
int aBaseBodyStyles,
std::span< const PIN_COMPARISON_DATA > basePins,
int aCandidateUnits,
int aCandidateBodyStyles,
std::span< const PIN_COMPARISON_DATA > candidatePins )
static

◆ ValidateVariantSymbolCompatibility()

std::vector< VARIANT_COMPAT_RESULT > ValidateVariantSymbolCompatibility ( const LIB_SYMBOL & aBase,
const LIB_SYMBOL & aCandidate )

Check whether aCandidate can be used as a variant symbol override for aBase.

The returned vector lists every issue found and an empty vector means fully compatible. Every graphical pin occurrence must have a one-to-one match with the same number, unit, body style, position, and electrical type. The candidate must have at least as many units as the base and must provide alternate body styles when the base has them. Pin names, symbol body graphics, field names and counts are not checked.

Parameters
aBasethe base symbol whose pin layout must be preserved.
aCandidatethe proposed alternate symbol.
Returns
a vector of all compatibility issues found; empty if the symbols are compatible.

Definition at line 197 of file variant_symbol_utils.cpp.

References LIB_SYMBOL::GetBodyStyleCount(), LIB_SYMBOL::GetUnitCount(), validateCompatibility(), and variantPins().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), SCH_SYMBOL::GetVariantLibSymbol(), SCH_EDIT_TOOL::SetVariantSymbol(), and ERC_TESTER::TestVariantSymbols().

◆ variantPins()

static std::vector< PIN_COMPARISON_DATA > variantPins ( const LIB_SYMBOL & aSymbol)
static

Definition at line 186 of file variant_symbol_utils.cpp.

References LIB_SYMBOL::GetGraphicalPins(), pin, and result.

Referenced by ValidateVariantSymbolCompatibility().

◆ VariantSymbolPinsMatch()

bool VariantSymbolPinsMatch ( const SCH_PIN & aBase,
const SCH_PIN & aCandidate )

Check whether two graphical pins occupy the same variant-symbol connection slot.

Definition at line 34 of file variant_symbol_utils.cpp.

References SCH_ITEM::GetBodyStyle(), SCH_PIN::GetNumber(), SCH_PIN::GetPosition(), and SCH_ITEM::GetUnit().

Referenced by SCH_SYMBOL::MapLibPins().