|
KiCad PCB EDA Suite
|
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_LINE * | CreateWire (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_GLOBALLABEL * | CreateNetLabel (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_LINE * | CreateBusWire (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_SHEET * | CreateHierarchicalSheet (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_PIN * | CreateSheetPin (SCH_SHEET *aSheet, const std::string &aSignalName, int aPinIndex) |
| Create a sheet pin that connects to a hierarchical label in the sub-schematic. | |
| SCH_HIERLABEL * | CreateHierLabel (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< VECTOR2I > | findJunctionPoints (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 PARAMETERS & | m_params |
| SCHEMATIC * | m_schematic |
| int | m_pageHeightIU |
Builds KiCad schematic elements (wires, junctions, labels, fields, sheets) from parsed PADS data.
Definition at line 51 of file pads_sch_schematic_builder.h.
| 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::PADS_SCH_SCHEMATIC_BUILDER::~PADS_SCH_SCHEMATIC_BUILDER | ( | ) |
Definition at line 58 of file pads_sch_schematic_builder.cpp.
| void PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::ApplyFieldSettings | ( | SCH_SYMBOL * | aSymbol, |
| const PART_PLACEMENT & | aPlacement ) |
Definition at line 520 of file pads_sch_schematic_builder.cpp.
References PADS_SCH::PART_PLACEMENT::attributes, PADS_COMMON::DecodeJustification(), FOOTPRINT, ADVANCED_CFG::GetCfg(), SCH_SYMBOL::GetField(), GetFlippedAlignment(), SCH_SYMBOL::GetPosition(), GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_BOTTOM, PADS_SCH::PART_ATTRIBUTE::height, PADS_ATTRIBUTE_MAPPER::IsFootprintField(), PADS_ATTRIBUTE_MAPPER::IsReferenceField(), PADS_ATTRIBUTE_MAPPER::IsValueField(), PADS_SCH::PART_ATTRIBUTE::justification, KiROUND(), PADS_SCH::PART_PLACEMENT::mirror_flags, PADS_SCH::PART_ATTRIBUTE::name, PADS_SCH::PART_ATTRIBUTE::position, REFERENCE, PADS_SCH::PART_ATTRIBUTE::rotation, schIUScale, EDA_TEXT::SetHorizJustify(), SCH_FIELD::SetPosition(), EDA_TEXT::SetTextAngleDegrees(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetTextThickness(), EDA_TEXT::SetVertJustify(), EDA_TEXT::SetVisible(), toKiCadUnits(), VALUE, PADS_SCH::PART_ATTRIBUTE::visible, PADS_SCH::PART_ATTRIBUTE::width, PADS_SCH::POINT::x, and PADS_SCH::POINT::y.
Referenced by ApplyPartAttributes().
| void PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::ApplyPartAttributes | ( | SCH_SYMBOL * | aSymbol, |
| const PART_PLACEMENT & | aPlacement ) |
Set reference, value, footprint and other fields on a symbol from a part placement.
Definition at line 473 of file pads_sch_schematic_builder.cpp.
References ApplyFieldSettings(), PADS_SCH::PART_PLACEMENT::attributes, m_schematic, PADS_SCH::PART_ATTRIBUTE::name, PADS_SCH::PART_PLACEMENT::part_type, PADS_SCH::PART_PLACEMENT::reference, SCH_SYMBOL::SetFootprintFieldText(), SCH_SYMBOL::SetRef(), SCH_SYMBOL::SetValueFieldText(), and PADS_SCH::PART_ATTRIBUTE::value.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and SCH_IO_PADS::LoadSchematicFile().
| 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().
|
private |
Definition at line 302 of file pads_sch_schematic_builder.cpp.
References PADS_SCH::WIRE_SEGMENT::endpoint_a, PADS_SCH::WIRE_SEGMENT::endpoint_b, toKiCadUnits(), toKiCadY(), PADS_SCH::WIRE_SEGMENT::vertices, PADS_SCH::SCH_SIGNAL::wires, PADS_SCH::POINT::x, and PADS_SCH::POINT::y.
|
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().
|
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().
| SCH_LINE * PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::CreateBusWire | ( | const WIRE_SEGMENT & | aWire | ) |
Definition at line 419 of file pads_sch_schematic_builder.cpp.
References end, PADS_SCH::WIRE_SEGMENT::end, LAYER_BUS, SCH_LINE::SetEndPoint(), PADS_SCH::WIRE_SEGMENT::start, toKiCadUnits(), toKiCadY(), PADS_SCH::POINT::x, and PADS_SCH::POINT::y.
Referenced by BOOST_AUTO_TEST_CASE(), and CreateBusWires().
| int PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::CreateBusWires | ( | const std::vector< SCH_SIGNAL > & | aSignals, |
| SCH_SCREEN * | aScreen ) |
Definition at line 392 of file pads_sch_schematic_builder.cpp.
References SCH_SCREEN::Append(), CreateBusWire(), IS_NEW, IsBusSignal(), and EDA_ITEM::SetFlags().
| int PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::CreateCustomFields | ( | SCH_SYMBOL * | aSymbol, |
| const PART_PLACEMENT & | aPlacement ) |
Create KiCad user fields for PADS attributes that have no standard-field mapping.
Definition at line 607 of file pads_sch_schematic_builder.cpp.
References PADS_SCH::PART_PLACEMENT::attr_overrides, PADS_SCH::PART_PLACEMENT::attributes, SCH_SYMBOL::GetField(), SCH_SYMBOL::GetFields(), PADS_ATTRIBUTE_MAPPER::GetKiCadFieldName(), SCH_SYMBOL::GetPosition(), PADS_ATTRIBUTE_MAPPER::IsStandardField(), name, PADS_SCH::PART_ATTRIBUTE::name, PADS_SCH::PART_ATTRIBUTE::position, PADS_SCH::PART_ATTRIBUTE::rotation, SCH_FIELD::SetPosition(), SCH_FIELD::SetText(), EDA_TEXT::SetTextAngleDegrees(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetVisible(), PADS_SCH::PART_ATTRIBUTE::size, toKiCadUnits(), USER, PADS_SCH::PART_ATTRIBUTE::value, PADS_SCH::POINT::x, and PADS_SCH::POINT::y.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and SCH_IO_PADS::LoadSchematicFile().
| SCH_SHEET * PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::CreateHierarchicalSheet | ( | int | aSheetNumber, |
| int | aTotalSheets, | ||
| SCH_SHEET * | aParentSheet, | ||
| const wxString & | aBaseFilename ) |
Create a sub-sheet positioned on its parent and backed by its own screen.
Caller takes ownership.
Definition at line 771 of file pads_sch_schematic_builder.cpp.
References SCH_SCREEN::Append(), CalculateSheetPosition(), GetDefaultSheetSize(), SCH_SHEET::GetField(), SCH_SHEET::GetScreen(), IS_NEW, FILEEXT::KiCadSchematicFileExtension, m_schematic, SCH_SCREEN::SetFileName(), EDA_ITEM::SetFlags(), SCH_SHEET::SetScreen(), SCH_FIELD::SetText(), SHEET_FILENAME, and SHEET_NAME.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and SCH_IO_PADS::LoadSchematicFile().
| 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().
| int PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::CreateJunctions | ( | const std::vector< SCH_SIGNAL > & | aSignals, |
| SCH_SCREEN * | aScreen ) |
Definition at line 119 of file pads_sch_schematic_builder.cpp.
References SCH_SCREEN::Append(), findJunctionPoints(), IS_NEW, and EDA_ITEM::SetFlags().
| 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().
| 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().
| 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().
| 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().
| SCH_LINE * PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::CreateWire | ( | const WIRE_SEGMENT & | aWire | ) |
Definition at line 107 of file pads_sch_schematic_builder.cpp.
References end, PADS_SCH::WIRE_SEGMENT::end, LAYER_WIRE, SCH_LINE::SetEndPoint(), PADS_SCH::WIRE_SEGMENT::start, toKiCadUnits(), toKiCadY(), PADS_SCH::POINT::x, and PADS_SCH::POINT::y.
Referenced by BOOST_AUTO_TEST_CASE(), and CreateWires().
| int PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::CreateWires | ( | const std::vector< SCH_SIGNAL > & | aSignals, |
| SCH_SCREEN * | aScreen ) |
Definition at line 83 of file pads_sch_schematic_builder.cpp.
References SCH_SCREEN::Append(), CreateWire(), IS_NEW, and EDA_ITEM::SetFlags().
|
private |
Find points where 3+ wire segments meet.
Definition at line 135 of file pads_sch_schematic_builder.cpp.
References end, PADS_SCH::WIRE_SEGMENT::end, PADS_SCH::WIRE_SEGMENT::start, toKiCadUnits(), toKiCadY(), PADS_SCH::POINT::x, VECTOR2< T >::x, PADS_SCH::POINT::y, and VECTOR2< T >::y.
Referenced by CreateJunctions().
| 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().
|
static |
Definition at line 431 of file pads_sch_schematic_builder.cpp.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and CreateBusWires().
|
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().
|
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().
|
private |
Definition at line 63 of file pads_sch_schematic_builder.cpp.
References schIUScale.
Referenced by ApplyFieldSettings(), chooseLabelPosition(), CreateBusWire(), CreateCustomFields(), CreateNetLabels(), CreateWire(), findJunctionPoints(), and toKiCadY().
|
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().
|
private |
Definition at line 177 of file pads_sch_schematic_builder.h.
Referenced by PADS_SCH_SCHEMATIC_BUILDER(), and toKiCadY().
|
private |
Definition at line 175 of file pads_sch_schematic_builder.h.
Referenced by CreateTitleBlock(), and PADS_SCH_SCHEMATIC_BUILDER().
|
private |
Definition at line 176 of file pads_sch_schematic_builder.h.
Referenced by ApplyPartAttributes(), CreateHierarchicalSheet(), and PADS_SCH_SCHEMATIC_BUILDER().