KiCad PCB EDA Suite
Loading...
Searching...
No Matches
PADS_SCH::PADS_SCH_SYMBOL_BUILDER Class Reference

Builder class to convert PADS symbol definitions to KiCad LIB_SYMBOL objects. More...

#include <pads_sch_symbol_builder.h>

Public Member Functions

 PADS_SCH_SYMBOL_BUILDER (const PARAMETERS &aParams)
 
 ~PADS_SCH_SYMBOL_BUILDER ()
 
LIB_SYMBOLBuildSymbol (const SYMBOL_DEF &aSymbolDef)
 Build a KiCad LIB_SYMBOL from a PADS symbol definition.
 
LIB_SYMBOLGetOrCreateSymbol (const SYMBOL_DEF &aSymbolDef)
 Get or create a symbol for the given definition.
 
bool HasSymbol (const std::string &aName) const
 Check if a symbol with the given name already exists.
 
LIB_SYMBOLGetSymbol (const std::string &aName) const
 Get a cached symbol by name.
 
LIB_SYMBOLBuildKiCadPowerSymbol (const std::string &aKiCadName)
 Build a power symbol using hard-coded KiCad-standard graphics.
 
LIB_SYMBOLBuildMultiUnitSymbol (const PARTTYPE_DEF &aPartType, const std::vector< SYMBOL_DEF > &aSymbolDefs)
 Build a composite multi-unit LIB_SYMBOL from a multi-gate PARTTYPE.
 
LIB_SYMBOLGetOrCreateMultiUnitSymbol (const PARTTYPE_DEF &aPartType, const std::vector< SYMBOL_DEF > &aSymbolDefs)
 Get or create a multi-unit symbol for the given PARTTYPE.
 
LIB_SYMBOLGetOrCreatePartTypeSymbol (const PARTTYPE_DEF &aPartType, const SYMBOL_DEF &aSymbolDef)
 Get or create a single-gate symbol with PARTTYPE-specific pin remapping.
 
LIB_SYMBOLGetOrCreateConnectorPinSymbol (const PARTTYPE_DEF &aPartType, const SYMBOL_DEF &aSymbolDef, const std::string &aPinNumber)
 Get or create a single-pin connector symbol with a specific pin number.
 
LIB_SYMBOLBuildMultiUnitConnectorSymbol (const PARTTYPE_DEF &aPartType, const SYMBOL_DEF &aSymbolDef, const std::vector< std::string > &aPinNumbers)
 Build a multi-unit connector symbol where each unit represents one pin.
 
LIB_SYMBOLGetOrCreateMultiUnitConnectorSymbol (const PARTTYPE_DEF &aPartType, const SYMBOL_DEF &aSymbolDef, const std::vector< std::string > &aPinNumbers, const std::string &aCacheKey)
 Get or create a multi-unit connector symbol, cached by base reference.
 
void AddHiddenPowerPins (LIB_SYMBOL *aSymbol, const std::vector< PARTTYPE_DEF::SIGPIN > &aSigpins)
 Add hidden power pins from PARTTYPE SIGPIN entries to an existing symbol.
 

Static Public Member Functions

static bool IsPowerSymbol (const std::string &aName)
 Check if a symbol name indicates a power symbol.
 
static std::optional< LIB_IDGetKiCadPowerSymbolId (const std::string &aPadsName)
 Get KiCad power library symbol ID for a PADS power symbol.
 
static std::string GetPowerStyleFromVariant (const std::string &aDecalName, const std::string &aPinType)
 Map a PADS special_variant to a power symbol style name.
 

Private Member Functions

int toKiCadUnits (double aPadsValue) const
 Convert PADS coordinate to KiCad internal units.
 
SCH_SHAPEcreateShape (const SYMBOL_GRAPHIC &aGraphic)
 Create a SCH_SHAPE from a PADS graphic element.
 
std::vector< SCH_SHAPE * > createShapes (const SYMBOL_GRAPHIC &aGraphic)
 Create one or more SCH_SHAPEs from a PADS graphic element.
 
SCH_PINcreatePin (const SYMBOL_PIN &aPin, LIB_SYMBOL *aParent)
 Create a SCH_PIN from a PADS pin definition.
 
int mapPinType (PIN_TYPE aPadsType)
 Map PADS pin type to KiCad electrical type.
 

Private Attributes

const PARAMETERSm_params
 
std::map< std::string, std::unique_ptr< LIB_SYMBOL > > m_symbolCache
 

Detailed Description

Builder class to convert PADS symbol definitions to KiCad LIB_SYMBOL objects.

This class handles the conversion of parsed PADS symbol definitions (graphics and pins) to KiCad's embedded symbol format for schematic import.

Definition at line 44 of file pads_sch_symbol_builder.h.

Constructor & Destructor Documentation

◆ PADS_SCH_SYMBOL_BUILDER()

PADS_SCH::PADS_SCH_SYMBOL_BUILDER::PADS_SCH_SYMBOL_BUILDER ( const PARAMETERS & aParams)

Definition at line 42 of file pads_sch_symbol_builder.cpp.

References m_params.

◆ ~PADS_SCH_SYMBOL_BUILDER()

PADS_SCH::PADS_SCH_SYMBOL_BUILDER::~PADS_SCH_SYMBOL_BUILDER ( )

Definition at line 48 of file pads_sch_symbol_builder.cpp.

Member Function Documentation

◆ AddHiddenPowerPins()

void PADS_SCH::PADS_SCH_SYMBOL_BUILDER::AddHiddenPowerPins ( LIB_SYMBOL * aSymbol,
const std::vector< PARTTYPE_DEF::SIGPIN > & aSigpins )

Add hidden power pins from PARTTYPE SIGPIN entries to an existing symbol.

Each SIGPIN becomes an invisible PT_POWER_IN pin at position (0,0). Duplicate pin numbers are skipped.

Definition at line 1128 of file pads_sch_symbol_builder.cpp.

References LIB_SYMBOL::AddDrawItem(), LIB_SYMBOL::GetDrawItems(), LINE, pin, PT_POWER_IN, and SCH_PIN_T.

Referenced by SCH_IO_PADS::LoadSchematicFile().

◆ BuildKiCadPowerSymbol()

LIB_SYMBOL * PADS_SCH::PADS_SCH_SYMBOL_BUILDER::BuildKiCadPowerSymbol ( const std::string & aKiCadName)

Build a power symbol using hard-coded KiCad-standard graphics.

Parameters
aKiCadNameKiCad power symbol name (e.g. "GND", "VCC", "VEE").
Returns
A new LIB_SYMBOL with power graphics, or nullptr if the name is unrecognized. Caller takes ownership.

Definition at line 856 of file pads_sch_symbol_builder.cpp.

References LIB_SYMBOL::AddDrawItem(), SCH_SHAPE::AddPoint(), FILLED_SHAPE, LIB_SYMBOL::GetReferenceField(), LAYER_DEVICE, pin, PIN_DOWN, PIN_UP, POLY, PT_POWER_IN, RECTANGLE, schIUScale, EDA_SHAPE::SetEnd(), EDA_SHAPE::SetFillMode(), LIB_SYMBOL::SetGlobalPower(), SYMBOL::SetShowPinNames(), SYMBOL::SetShowPinNumbers(), EDA_SHAPE::SetStart(), SCH_SHAPE::SetStroke(), SCH_FIELD::SetText(), EDA_TEXT::SetVisible(), and SOLID.

Referenced by BOOST_AUTO_TEST_CASE(), and SCH_IO_PADS::LoadSchematicFile().

◆ BuildMultiUnitConnectorSymbol()

LIB_SYMBOL * PADS_SCH::PADS_SCH_SYMBOL_BUILDER::BuildMultiUnitConnectorSymbol ( const PARTTYPE_DEF & aPartType,
const SYMBOL_DEF & aSymbolDef,
const std::vector< std::string > & aPinNumbers )

Build a multi-unit connector symbol where each unit represents one pin.

PADS connectors place each pin individually on the schematic. This creates a multi-unit KiCad symbol where each unit has the connector decal graphics and one pin with the correct pin number, allowing all placements to share one reference designator.

Parameters
aPartTypeThe connector PARTTYPE definition.
aSymbolDefThe CAEDECAL symbol definition with per-pin graphics.
aPinNumbersOrdered list of pin numbers (one unit per pin).
Returns
A new multi-unit LIB_SYMBOL. Caller takes ownership.

Definition at line 440 of file pads_sch_symbol_builder.cpp.

References LIB_SYMBOL::AddDrawItem(), createPin(), createShapes(), PADS_SCH::PARTTYPE_DEF::gates, ADVANCED_CFG::GetCfg(), PADS_SCH::SYMBOL_DEF::graphics, LAYER_DEVICE, LIB_SYMBOL::LockUnits(), ADVANCED_CFG::m_PadsSchTextHeightScale, ADVANCED_CFG::m_PadsSchTextWidthScale, PADS_SCH::PARTTYPE_DEF::name, PADS_SCH::PADS_SCH_PARSER::ParsePinTypeChar(), pin, PADS_SCH::SYMBOL_DEF::pins, SYMBOL::SetShowPinNames(), SYMBOL::SetShowPinNumbers(), EDA_TEXT::SetTextAngleDegrees(), EDA_TEXT::SetTextSize(), SCH_ITEM::SetUnit(), LIB_SYMBOL::SetUnitCount(), text, PADS_SCH::SYMBOL_DEF::texts, and toKiCadUnits().

Referenced by GetOrCreateMultiUnitConnectorSymbol().

◆ BuildMultiUnitSymbol()

LIB_SYMBOL * PADS_SCH::PADS_SCH_SYMBOL_BUILDER::BuildMultiUnitSymbol ( const PARTTYPE_DEF & aPartType,
const std::vector< SYMBOL_DEF > & aSymbolDefs )

Build a composite multi-unit LIB_SYMBOL from a multi-gate PARTTYPE.

Each gate becomes a separate unit with its own graphics, pins, and text. Pin numbers/names/types are taken from the GATE_DEF pin list rather than from the CAEDECAL SYMBOL_DEF, which only has placeholder pin data.

Parameters
aPartTypeThe multi-gate PARTTYPE definition.
aSymbolDefsAll parsed CAEDECAL definitions for decal lookup.
Returns
A new multi-unit LIB_SYMBOL. Caller takes ownership.

Definition at line 150 of file pads_sch_symbol_builder.cpp.

References LIB_SYMBOL::AddDrawItem(), createPin(), createShapes(), PADS_SCH::GATE_DEF::decal_names, PADS_SCH::PARTTYPE_DEF::gates, ADVANCED_CFG::GetCfg(), PADS_SCH::SYMBOL_DEF::graphics, LAYER_DEVICE, LIB_SYMBOL::LockUnits(), ADVANCED_CFG::m_PadsSchTextHeightScale, ADVANCED_CFG::m_PadsSchTextWidthScale, PADS_SCH::PARTTYPE_DEF::name, PADS_SCH::PADS_SCH_PARSER::ParsePinTypeChar(), pin, PADS_SCH::GATE_DEF::pins, PADS_SCH::SYMBOL_DEF::pins, SYMBOL::SetShowPinNames(), SYMBOL::SetShowPinNumbers(), EDA_TEXT::SetTextAngleDegrees(), EDA_TEXT::SetTextSize(), SCH_ITEM::SetUnit(), LIB_SYMBOL::SetUnitCount(), text, PADS_SCH::SYMBOL_DEF::texts, and toKiCadUnits().

Referenced by BOOST_AUTO_TEST_CASE(), and GetOrCreateMultiUnitSymbol().

◆ BuildSymbol()

◆ createPin()

◆ createShape()

◆ createShapes()

◆ GetKiCadPowerSymbolId()

std::optional< LIB_ID > PADS_SCH::PADS_SCH_SYMBOL_BUILDER::GetKiCadPowerSymbolId ( const std::string & aPadsName)
static

Get KiCad power library symbol ID for a PADS power symbol.

Parameters
aPadsNamePADS symbol name.
Returns
LIB_ID for the KiCad power library symbol, or nullopt if no mapping.

Definition at line 1212 of file pads_sch_symbol_builder.cpp.

References LIB_ID::SetLibItemName(), and LIB_ID::SetLibNickname().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and SCH_IO_PADS::LoadSchematicFile().

◆ GetOrCreateConnectorPinSymbol()

LIB_SYMBOL * PADS_SCH::PADS_SCH_SYMBOL_BUILDER::GetOrCreateConnectorPinSymbol ( const PARTTYPE_DEF & aPartType,
const SYMBOL_DEF & aSymbolDef,
const std::string & aPinNumber )

Get or create a single-pin connector symbol with a specific pin number.

PADS connectors use one CAEDECAL symbol for all pin placements, but each placement represents a different pin number. This creates a variant with the correct pin number for each connector pin placement.

Parameters
aPartTypeThe connector PARTTYPE definition.
aSymbolDefThe CAEDECAL symbol definition with graphics.
aPinNumberThe pin number string for this connector pin (e.g. "15").
Returns
Pointer to the symbol (owned by this builder).

Definition at line 365 of file pads_sch_symbol_builder.cpp.

References LIB_SYMBOL::AddDrawItem(), createPin(), createShapes(), PADS_SCH::PARTTYPE_DEF::gates, ADVANCED_CFG::GetCfg(), PADS_SCH::SYMBOL_DEF::graphics, LAYER_DEVICE, ADVANCED_CFG::m_PadsSchTextHeightScale, ADVANCED_CFG::m_PadsSchTextWidthScale, m_symbolCache, PADS_SCH::PARTTYPE_DEF::name, PADS_SCH::SYMBOL_DEF::name, PADS_SCH::PADS_SCH_PARSER::ParsePinTypeChar(), pin, PADS_SCH::SYMBOL_DEF::pins, SYMBOL::SetShowPinNames(), SYMBOL::SetShowPinNumbers(), EDA_TEXT::SetTextAngleDegrees(), EDA_TEXT::SetTextSize(), text, PADS_SCH::SYMBOL_DEF::texts, and toKiCadUnits().

Referenced by BOOST_AUTO_TEST_CASE().

◆ GetOrCreateMultiUnitConnectorSymbol()

LIB_SYMBOL * PADS_SCH::PADS_SCH_SYMBOL_BUILDER::GetOrCreateMultiUnitConnectorSymbol ( const PARTTYPE_DEF & aPartType,
const SYMBOL_DEF & aSymbolDef,
const std::vector< std::string > & aPinNumbers,
const std::string & aCacheKey )

Get or create a multi-unit connector symbol, cached by base reference.

Parameters
aPartTypeThe connector PARTTYPE definition.
aSymbolDefThe CAEDECAL symbol definition with per-pin graphics.
aPinNumbersOrdered list of pin numbers.
aCacheKeyUnique key for caching (e.g. PARTTYPE name + base ref).
Returns
Pointer to the symbol (owned by this builder).

Definition at line 534 of file pads_sch_symbol_builder.cpp.

References BuildMultiUnitConnectorSymbol(), and m_symbolCache.

Referenced by BOOST_AUTO_TEST_CASE(), and SCH_IO_PADS::LoadSchematicFile().

◆ GetOrCreateMultiUnitSymbol()

LIB_SYMBOL * PADS_SCH::PADS_SCH_SYMBOL_BUILDER::GetOrCreateMultiUnitSymbol ( const PARTTYPE_DEF & aPartType,
const std::vector< SYMBOL_DEF > & aSymbolDefs )

Get or create a multi-unit symbol for the given PARTTYPE.

Cached by PARTTYPE name so that all instances of the same multi-gate part share one composite LIB_SYMBOL.

Definition at line 253 of file pads_sch_symbol_builder.cpp.

References BuildMultiUnitSymbol(), m_symbolCache, and PADS_SCH::PARTTYPE_DEF::name.

Referenced by SCH_IO_PADS::LoadSchematicFile().

◆ GetOrCreatePartTypeSymbol()

LIB_SYMBOL * PADS_SCH::PADS_SCH_SYMBOL_BUILDER::GetOrCreatePartTypeSymbol ( const PARTTYPE_DEF & aPartType,
const SYMBOL_DEF & aSymbolDef )

◆ GetOrCreateSymbol()

LIB_SYMBOL * PADS_SCH::PADS_SCH_SYMBOL_BUILDER::GetOrCreateSymbol ( const SYMBOL_DEF & aSymbolDef)

Get or create a symbol for the given definition.

If the symbol has already been created, returns a pointer to the existing symbol. Otherwise creates a new symbol and caches it.

Parameters
aSymbolDefThe parsed PADS symbol definition.
Returns
Pointer to the symbol (owned by this builder).

Definition at line 136 of file pads_sch_symbol_builder.cpp.

References BuildSymbol(), m_symbolCache, and PADS_SCH::SYMBOL_DEF::name.

Referenced by BOOST_AUTO_TEST_CASE(), and SCH_IO_PADS::LoadSchematicFile().

◆ GetPowerStyleFromVariant()

std::string PADS_SCH::PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant ( const std::string & aDecalName,
const std::string & aPinType )
static

Map a PADS special_variant to a power symbol style name.

Uses the variant's decal_name pattern (RAIL, ARROW, BUBBLE) and pin_type to determine the appropriate KiCad power symbol style.

Parameters
aDecalNameVariant decal name (e.g. "+RAIL", "AGND", "+BUBBLE").
aPinTypeVariant pin type ("G" for ground, "P" for power).
Returns
Internal style name for BuildKiCadPowerSymbol(), or empty if unrecognized.

Definition at line 1094 of file pads_sch_symbol_builder.cpp.

Referenced by SCH_IO_PADS::LoadSchematicFile().

◆ GetSymbol()

LIB_SYMBOL * PADS_SCH::PADS_SCH_SYMBOL_BUILDER::GetSymbol ( const std::string & aName) const

Get a cached symbol by name.

Parameters
aNameSymbol name.
Returns
Pointer to the symbol, or nullptr if not found.

Definition at line 556 of file pads_sch_symbol_builder.cpp.

References m_symbolCache.

◆ HasSymbol()

bool PADS_SCH::PADS_SCH_SYMBOL_BUILDER::HasSymbol ( const std::string & aName) const

Check if a symbol with the given name already exists.

Definition at line 550 of file pads_sch_symbol_builder.cpp.

References m_symbolCache.

Referenced by BOOST_AUTO_TEST_CASE().

◆ IsPowerSymbol()

bool PADS_SCH::PADS_SCH_SYMBOL_BUILDER::IsPowerSymbol ( const std::string & aName)
static

Check if a symbol name indicates a power symbol.

Parameters
aNameSymbol name to check.
Returns
True if the name matches common power symbol patterns.

Definition at line 1183 of file pads_sch_symbol_builder.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and SCH_IO_PADS::LoadSchematicFile().

◆ mapPinType()

int PADS_SCH::PADS_SCH_SYMBOL_BUILDER::mapPinType ( PIN_TYPE aPadsType)
private

◆ toKiCadUnits()

int PADS_SCH::PADS_SCH_SYMBOL_BUILDER::toKiCadUnits ( double aPadsValue) const
private

Member Data Documentation

◆ m_params

const PARAMETERS& PADS_SCH::PADS_SCH_SYMBOL_BUILDER::m_params
private

◆ m_symbolCache

std::map<std::string, std::unique_ptr<LIB_SYMBOL> > PADS_SCH::PADS_SCH_SYMBOL_BUILDER::m_symbolCache
private

The documentation for this class was generated from the following files: