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

Builds KiCad schematic elements (wires, junctions, labels, fields, sheets) from parsed PADS data. More...

#include <pads_sch_schematic_builder.h>

Public Member Functions

 PADS_SCH_SCHEMATIC_BUILDER (const PARAMETERS &aParams, SCHEMATIC *aSchematic)
 
 ~PADS_SCH_SCHEMATIC_BUILDER ()
 
int CreateWires (const std::vector< SCH_SIGNAL > &aSignals, SCH_SCREEN *aScreen)
 
SCH_LINECreateWire (const WIRE_SEGMENT &aWire)
 
int CreateJunctions (const std::vector< SCH_SIGNAL > &aSignals, SCH_SCREEN *aScreen)
 
int CreateNetLabels (const std::vector< SCH_SIGNAL > &aSignals, SCH_SCREEN *aScreen, const std::set< std::string > &aSignalOpcIds, const std::set< std::string > &aSkipSignals={}, const std::map< std::string, NETNAME_LABEL > &aNetNameLabels={})
 Create net labels for named signals.
 
SCH_GLOBALLABELCreateNetLabel (const SCH_SIGNAL &aSignal, const VECTOR2I &aPosition, SPIN_STYLE aOrientation=SPIN_STYLE::RIGHT)
 Create a net label.
 
int CreateBusWires (const std::vector< SCH_SIGNAL > &aSignals, SCH_SCREEN *aScreen)
 
SCH_LINECreateBusWire (const WIRE_SEGMENT &aWire)
 
void ApplyPartAttributes (SCH_SYMBOL *aSymbol, const PART_PLACEMENT &aPlacement)
 Set reference, value, footprint and other fields on a symbol from a part placement.
 
void ApplyFieldSettings (SCH_SYMBOL *aSymbol, const PART_PLACEMENT &aPlacement)
 
int CreateCustomFields (SCH_SYMBOL *aSymbol, const PART_PLACEMENT &aPlacement)
 Create KiCad user fields for PADS attributes that have no standard-field mapping.
 
void CreateTitleBlock (SCH_SCREEN *aScreen)
 Set the title block from PADS fields, checking custom names too because PADS designs often leave the standard names empty (e.g.
 
SCH_SHEETCreateHierarchicalSheet (int aSheetNumber, int aTotalSheets, SCH_SHEET *aParentSheet, const wxString &aBaseFilename)
 Create a sub-sheet positioned on its parent and backed by its own screen.
 
VECTOR2I GetDefaultSheetSize () const
 
VECTOR2I CalculateSheetPosition (int aSheetIndex, int aTotalSheets) const
 Position a sheet symbol in a roughly square grid on the parent.
 
SCH_SHEET_PINCreateSheetPin (SCH_SHEET *aSheet, const std::string &aSignalName, int aPinIndex)
 Create a sheet pin that connects to a hierarchical label in the sub-schematic.
 
SCH_HIERLABELCreateHierLabel (const std::string &aSignalName, const VECTOR2I &aPosition, SCH_SCREEN *aScreen)
 Create a hierarchical label that connects to a sheet pin on the parent.
 

Static Public Member Functions

static SPIN_STYLE SpinFromNetNameLabel (const NETNAME_LABEL &aLabel)
 Map a PADS NETNAMES label entry to a KiCad global-label spin style.
 
static bool IsBusSignal (const std::string &aName)
 
static bool IsGlobalSignal (const std::string &aSignalName, const std::set< int > &aSheetNumbers)
 A signal is global when it spans multiple sheets or is a common power net.
 
static SPIN_STYLE computeLabelOrientation (const VECTOR2I &aLabelPos, const VECTOR2I &aAdjacentPos)
 Orient a label opposite to the wire direction at its position so it clears the wire.
 

Private Member Functions

int toKiCadUnits (double aPadsValue) const
 
int toKiCadY (double aPadsY) const
 Convert PADS Y coordinate to KiCad Y, accounting for Y-axis inversion and page offset.
 
std::vector< VECTOR2IfindJunctionPoints (const std::vector< SCH_SIGNAL > &aSignals)
 Find points where 3+ wire segments meet.
 
VECTOR2I chooseLabelPosition (const SCH_SIGNAL &aSignal)
 
wxString convertNetName (const std::string &aName) const
 Convert a PADS net name to a KiCad label, mapping a "/" prefix to a "~{}" overbar.
 

Private Attributes

const PARAMETERSm_params
 
SCHEMATICm_schematic
 
int m_pageHeightIU
 

Detailed Description

Builds KiCad schematic elements (wires, junctions, labels, fields, sheets) from parsed PADS data.

Definition at line 51 of file pads_sch_schematic_builder.h.

Constructor & Destructor Documentation

◆ PADS_SCH_SCHEMATIC_BUILDER()

PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::PADS_SCH_SCHEMATIC_BUILDER ( const PARAMETERS & aParams,
SCHEMATIC * aSchematic )

Definition at line 49 of file pads_sch_schematic_builder.cpp.

References m_pageHeightIU, m_params, m_schematic, and schIUScale.

◆ ~PADS_SCH_SCHEMATIC_BUILDER()

PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::~PADS_SCH_SCHEMATIC_BUILDER ( )

Definition at line 58 of file pads_sch_schematic_builder.cpp.

Member Function Documentation

◆ ApplyFieldSettings()

◆ ApplyPartAttributes()

◆ CalculateSheetPosition()

VECTOR2I PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::CalculateSheetPosition ( int aSheetIndex,
int aTotalSheets ) const

Position a sheet symbol in a roughly square grid on the parent.

Definition at line 833 of file pads_sch_schematic_builder.cpp.

References schIUScale.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and CreateHierarchicalSheet().

◆ chooseLabelPosition()

◆ computeLabelOrientation()

SPIN_STYLE PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::computeLabelOrientation ( const VECTOR2I & aLabelPos,
const VECTOR2I & aAdjacentPos )
static

Orient a label opposite to the wire direction at its position so it clears the wire.

Definition at line 266 of file pads_sch_schematic_builder.cpp.

References std::abs(), SPIN_STYLE::BOTTOM, SPIN_STYLE::LEFT, SPIN_STYLE::RIGHT, SPIN_STYLE::UP, VECTOR2< T >::x, and VECTOR2< T >::y.

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

◆ convertNetName()

wxString PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::convertNetName ( const std::string & aName) const
private

Convert a PADS net name to a KiCad label, mapping a "/" prefix to a "~{}" overbar.

Definition at line 77 of file pads_sch_schematic_builder.cpp.

References PADS_COMMON::ConvertInvertedNetName().

Referenced by CreateNetLabel().

◆ CreateBusWire()

◆ CreateBusWires()

int PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::CreateBusWires ( const std::vector< SCH_SIGNAL > & aSignals,
SCH_SCREEN * aScreen )

◆ CreateCustomFields()

◆ CreateHierarchicalSheet()

SCH_SHEET * PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::CreateHierarchicalSheet ( int aSheetNumber,
int aTotalSheets,
SCH_SHEET * aParentSheet,
const wxString & aBaseFilename )

◆ CreateHierLabel()

SCH_HIERLABEL * PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::CreateHierLabel ( const std::string & aSignalName,
const VECTOR2I & aPosition,
SCH_SCREEN * aScreen )

Create a hierarchical label that connects to a sheet pin on the parent.

Caller takes ownership.

Definition at line 884 of file pads_sch_schematic_builder.cpp.

References SCH_SCREEN::Append(), IS_NEW, L_UNSPECIFIED, name, EDA_ITEM::SetFlags(), and SCH_LABEL_BASE::SetShape().

Referenced by BOOST_AUTO_TEST_CASE().

◆ CreateJunctions()

int PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::CreateJunctions ( const std::vector< SCH_SIGNAL > & aSignals,
SCH_SCREEN * aScreen )

◆ CreateNetLabel()

SCH_GLOBALLABEL * PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::CreateNetLabel ( const SCH_SIGNAL & aSignal,
const VECTOR2I & aPosition,
SPIN_STYLE aOrientation = SPIN_STYLE::RIGHT )

Create a net label.

PADS signals are global, so labels are SCH_GLOBALLABEL to avoid sheet-path prefixing. Caller takes ownership.

Definition at line 285 of file pads_sch_schematic_builder.cpp.

References convertNetName(), L_BIDI, PADS_SCH::SCH_SIGNAL::name, schIUScale, SCH_LABEL_BASE::SetShape(), SCH_GLOBALLABEL::SetSpinStyle(), and EDA_TEXT::SetTextSize().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and CreateNetLabels().

◆ CreateNetLabels()

int PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::CreateNetLabels ( const std::vector< SCH_SIGNAL > & aSignals,
SCH_SCREEN * aScreen,
const std::set< std::string > & aSignalOpcIds,
const std::set< std::string > & aSkipSignals = {},
const std::map< std::string, NETNAME_LABEL > & aNetNameLabels = {} )

Create net labels for named signals.

Signals with OPC endpoints get one label per OPC point oriented from the adjacent wire; others get one label at a dangling wire end. aSkipSignals names are ignored (e.g. power nets handled elsewhere).

Definition at line 165 of file pads_sch_schematic_builder.cpp.

References SCH_SCREEN::Append(), computeLabelOrientation(), CreateNetLabel(), PADS_SCH::WIRE_SEGMENT::endpoint_a, PADS_SCH::WIRE_SEGMENT::endpoint_b, IS_NEW, PLACEMENT, EDA_ITEM::SetFlags(), SpinFromNetNameLabel(), toKiCadUnits(), toKiCadY(), and PADS_SCH::WIRE_SEGMENT::vertices.

Referenced by SCH_IO_PADS::LoadSchematicFile().

◆ CreateSheetPin()

SCH_SHEET_PIN * PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::CreateSheetPin ( SCH_SHEET * aSheet,
const std::string & aSignalName,
int aPinIndex )

Create a sheet pin that connects to a hierarchical label in the sub-schematic.

Ownership transfers to the sheet.

Definition at line 857 of file pads_sch_schematic_builder.cpp.

References SCH_SHEET::AddPin(), SCH_SHEET::GetPosition(), L_UNSPECIFIED, LEFT, name, pin, schIUScale, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ CreateTitleBlock()

void PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::CreateTitleBlock ( SCH_SCREEN * aScreen)

Set the title block from PADS fields, checking custom names too because PADS designs often leave the standard names empty (e.g.

"TITLE1" instead of "Title").

Definition at line 702 of file pads_sch_schematic_builder.cpp.

References findField(), m_params, name, TITLE_BLOCK::SetComment(), TITLE_BLOCK::SetCompany(), TITLE_BLOCK::SetDate(), TITLE_BLOCK::SetRevision(), TITLE_BLOCK::SetTitle(), and SCH_SCREEN::SetTitleBlock().

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

◆ CreateWire()

◆ CreateWires()

int PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::CreateWires ( const std::vector< SCH_SIGNAL > & aSignals,
SCH_SCREEN * aScreen )

◆ findJunctionPoints()

std::vector< VECTOR2I > PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::findJunctionPoints ( const std::vector< SCH_SIGNAL > & aSignals)
private

◆ GetDefaultSheetSize()

VECTOR2I PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::GetDefaultSheetSize ( ) const

Definition at line 826 of file pads_sch_schematic_builder.cpp.

References schIUScale.

Referenced by BOOST_AUTO_TEST_CASE(), and CreateHierarchicalSheet().

◆ IsBusSignal()

bool PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::IsBusSignal ( const std::string & aName)
static

◆ IsGlobalSignal()

bool PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::IsGlobalSignal ( const std::string & aSignalName,
const std::set< int > & aSheetNumbers )
static

A signal is global when it spans multiple sheets or is a common power net.

Definition at line 904 of file pads_sch_schematic_builder.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ SpinFromNetNameLabel()

SPIN_STYLE PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::SpinFromNetNameLabel ( const NETNAME_LABEL & aLabel)
static

Map a PADS NETNAMES label entry to a KiCad global-label spin style.

PADS encodes the label side via the offset of the text from the anchor point. The dominant offset axis and its sign tell which way the text reads away from the connection, which is exactly what the spin style controls.

Definition at line 249 of file pads_sch_schematic_builder.cpp.

References std::abs(), SPIN_STYLE::BOTTOM, SPIN_STYLE::LEFT, SPIN_STYLE::RIGHT, SPIN_STYLE::UP, PADS_SCH::NETNAME_LABEL::x_offset, and PADS_SCH::NETNAME_LABEL::y_offset.

Referenced by CreateNetLabels().

◆ toKiCadUnits()

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

◆ toKiCadY()

int PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::toKiCadY ( double aPadsY) const
private

Convert PADS Y coordinate to KiCad Y, accounting for Y-axis inversion and page offset.

Definition at line 71 of file pads_sch_schematic_builder.cpp.

References m_pageHeightIU, and toKiCadUnits().

Referenced by chooseLabelPosition(), CreateBusWire(), CreateNetLabels(), CreateWire(), and findJunctionPoints().

Member Data Documentation

◆ m_pageHeightIU

int PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::m_pageHeightIU
private

Definition at line 177 of file pads_sch_schematic_builder.h.

Referenced by PADS_SCH_SCHEMATIC_BUILDER(), and toKiCadY().

◆ m_params

const PARAMETERS& PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::m_params
private

Definition at line 175 of file pads_sch_schematic_builder.h.

Referenced by CreateTitleBlock(), and PADS_SCH_SCHEMATIC_BUILDER().

◆ m_schematic

SCHEMATIC* PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::m_schematic
private

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