|
KiCad PCB EDA Suite
|
Common utilities and types for parsing PADS file formats, shared by the PCB and schematic importers. More...
Classes | |
| struct | RELATED_FILES |
Enumerations | |
| enum class | PADS_FILE_TYPE { UNKNOWN , PCB_ASCII , SCHEMATIC_ASCII } |
Functions | |
| KIID | GenerateDeterministicUuid (const std::string &aIdentifier) |
| Generate a deterministic KIID from a PADS component identifier. | |
| PADS_FILE_TYPE | DetectPadsFileType (const wxString &aFilePath) |
| Detect the type of a PADS file by examining its header. | |
| RELATED_FILES | FindRelatedPadsFiles (const wxString &aFilePath) |
| Find the related PADS project file (schematic for a PCB source, or vice versa) in the same directory, preferring a matching base filename. | |
| int | ParseInt (const std::string &aStr, int aDefault=0, const std::string &aContext={}) |
| Parse integer from string with error context. | |
| double | ParseDouble (const std::string &aStr, double aDefault=0.0, const std::string &aContext={}) |
| Parse double from string with error context. | |
| wxString | ConvertInvertedNetName (const std::string &aNetName) |
| Convert a PADS net name to KiCad notation. | |
| wxString | ConvertText (const std::string &aText) |
| Decode text from a PADS file, which uses an 8-bit codepage rather than UTF-8. | |
| LINE_STYLE | PadsLineStyleToKiCad (int aPadsStyle) |
| Convert a PADS line style integer to a KiCad LINE_STYLE enum value. | |
| void | DecodeJustification (int aJustification, GR_TEXT_H_ALIGN_T &aHJustify, GR_TEXT_V_ALIGN_T &aVJustify) |
| Decode a PADS text justification code into KiCad horizontal and vertical alignment. | |
| int | PadsScaleCoord (double aVal, bool aIsX, double aOriginX, double aOriginY, double aScaleFactor) |
| Map a PADS board coordinate to a KiCad internal coordinate. | |
Common utilities and types for parsing PADS file formats, shared by the PCB and schematic importers.
|
strong |
| Enumerator | |
|---|---|
| UNKNOWN | |
| PCB_ASCII | |
| SCHEMATIC_ASCII | |
Definition at line 49 of file pads_common.h.
| wxString PADS_COMMON::ConvertInvertedNetName | ( | const std::string & | aNetName | ) |
Convert a PADS net name to KiCad notation.
PADS marks inverted signals with a leading "/" (e.g. "/RESET"); KiCad uses overbar "~{name}". Non-inverted names pass through unchanged.
Definition at line 266 of file pads_common.cpp.
References ConvertText().
Referenced by PADS_PCB_CONVERTER::ApplyPourSettings(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), PCB_IO_PADS_BINARY::buildPad(), PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::convertNetName(), PADS_PCB_CONVERTER::EnsureNet(), PCB_IO_PADS::loadBoardSetup(), PCB_IO_PADS::loadClusterGroups(), PCB_IO_PADS::loadCopperShapes(), PCB_IO_PADS::loadFootprints(), PCB_IO_PADS_BINARY::loadNets(), PCB_IO_PADS::loadTestPoints(), PCB_IO_PADS::loadTracksAndVias(), PCB_IO_PADS_BINARY::loadTracksAndVias(), and PADS_PCB_CONVERTER::WriteDiffPairRules().
| wxString PADS_COMMON::ConvertText | ( | const std::string & | aText | ) |
Decode text from a PADS file, which uses an 8-bit codepage rather than UTF-8.
A direct UTF-8 conversion discards the whole string on the first high byte, so decode UTF-8 when valid and otherwise fall back to Windows-1252 / ISO-8859-1.
| aText | Raw text bytes from the PADS file. |
Definition at line 278 of file pads_common.cpp.
References result.
Referenced by PADS_PCB_CONVERTER::ApplyPourSettings(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), PADS_LAYER_MAPPER::BuildInputLayerDescriptions(), PCB_IO_PADS_BINARY::buildPad(), ConvertInvertedNetName(), PADS_PCB_CONVERTER::GetMappedLayer(), PCB_IO_PADS::loadBoardSetup(), PCB_IO_PADS::loadClusterGroups(), PCB_IO_PADS_BINARY::loadClusterGroups(), PADS_PCB_CONVERTER::LoadDimensions(), PCB_IO_PADS::loadFootprints(), PCB_IO_PADS_BINARY::loadFootprints(), PCB_IO_PADS_BINARY::loadNets(), PCB_IO_PADS::loadReuseBlockGroups(), PCB_IO_PADS::loadTestPoints(), PADS_PCB_CONVERTER::LoadTexts(), PCB_IO_PADS_BINARY::loadTracksAndVias(), and PADS_PCB_CONVERTER::WriteDiffPairRules().
| void PADS_COMMON::DecodeJustification | ( | int | aJustification, |
| GR_TEXT_H_ALIGN_T & | aHJustify, | ||
| GR_TEXT_V_ALIGN_T & | aVJustify ) |
Decode a PADS text justification code into KiCad horizontal and vertical alignment.
PADS encodes the anchor of a text string as a single integer combining a vertical band and a horizontal code: value = vertical_band + horizontal_code vertical bands bottom (0..1), top (2..7), middle (8..) horizontal codes left=0, right=1, center=4
The same encoding is used for free text, part field labels and net name labels, so both the PCB and schematic importers share this decode to stay consistent.
| aJustification | Raw PADS justification code. |
| aHJustify | Receives the decoded horizontal alignment. |
| aVJustify | Receives the decoded vertical alignment. |
Definition at line 319 of file pads_common.cpp.
References GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_CENTER, and GR_TEXT_V_ALIGN_TOP.
Referenced by PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::ApplyFieldSettings(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), createSchText(), and SCH_IO_PADS::LoadSchematicFile().
| PADS_FILE_TYPE PADS_COMMON::DetectPadsFileType | ( | const wxString & | aFilePath | ) |
Detect the type of a PADS file by examining its header.
Definition at line 91 of file pads_common.cpp.
References PCB_ASCII, SCHEMATIC_ASCII, and UNKNOWN.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), FindRelatedPadsFiles(), and KICAD_MANAGER_FRAME::ImportNonKiCadProject().
| RELATED_FILES PADS_COMMON::FindRelatedPadsFiles | ( | const wxString & | aFilePath | ) |
Find the related PADS project file (schematic for a PCB source, or vice versa) in the same directory, preferring a matching base filename.
Definition at line 125 of file pads_common.cpp.
References DetectPadsFileType(), PCB_ASCII, result, SCHEMATIC_ASCII, and UNKNOWN.
Referenced by BOOST_AUTO_TEST_CASE(), and IMPORT_PROJ_HELPER::ImportPadsFiles().
| KIID PADS_COMMON::GenerateDeterministicUuid | ( | const std::string & | aIdentifier | ) |
Generate a deterministic KIID from a PADS component identifier.
The same input always produces the same UUID, so a schematic symbol and its PCB footprint can cross-probe link when both are imported from the same PADS project.
| aIdentifier | String identifying the component (typically refdes or combination of part type and refdes). |
Definition at line 39 of file pads_common.cpp.
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(), PCB_IO_PADS::loadFootprints(), PCB_IO_PADS_BINARY::loadFootprints(), and SCH_IO_PADS::LoadSchematicFile().
| LINE_STYLE PADS_COMMON::PadsLineStyleToKiCad | ( | int | aPadsStyle | ) |
Convert a PADS line style integer to a KiCad LINE_STYLE enum value.
PADS stores line style as an unsigned int that should be interpreted as a signed int8_t for mapping.
Definition at line 301 of file pads_common.cpp.
References DASH, DASHDOT, DASHDOTDOT, DOT, and SOLID.
Referenced by appendGraphicPrimitive(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), PADS_SCH::PADS_SCH_SYMBOL_BUILDER::createShape(), and PADS_SCH::PADS_SCH_SYMBOL_BUILDER::createShapes().
| int PADS_COMMON::PadsScaleCoord | ( | double | aVal, |
| bool | aIsX, | ||
| double | aOriginX, | ||
| double | aOriginY, | ||
| double | aScaleFactor ) |
Map a PADS board coordinate to a KiCad internal coordinate.
Subtracts the per-axis design origin (scaled by aScaleFactor), applies the PADS-Y-up to KiCad-Y-down flip on the Y axis (aIsX false), and clamps to the int range. Both PADS PCB importers share this mapping.
Definition at line 359 of file pads_common.cpp.
References result.
Referenced by PADS_PCB_CONVERTER::ScaleCoord().
| double PADS_COMMON::ParseDouble | ( | const std::string & | aStr, |
| double | aDefault = 0.0, | ||
| const std::string & | aContext = {} ) |
Parse double from string with error context.
Returns aDefault on failure and logs a trace warning.
Definition at line 247 of file pads_common.cpp.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), PADS_SCH::PADS_SCH_PARSER::parseGraphicPrimitive(), PADS_IO::PARSER::parseSectionPARTDECAL(), and PADS_IO::PARSER::parseSectionTEXT().
| int PADS_COMMON::ParseInt | ( | const std::string & | aStr, |
| int | aDefault = 0, | ||
| const std::string & | aContext = {} ) |
Parse integer from string with error context.
Returns aDefault on failure and logs a trace warning.
Definition at line 228 of file pads_common.cpp.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), PADS_IO::expandShortcutPattern(), PADS_IO::PARSER::parseSectionCLUSTER(), PADS_IO::PARSER::parseSectionNETS(), PADS_SCH::PADS_SCH_PARSER::parseSectionOFFPAGEREFS(), PADS_IO::PARSER::parseSectionPARTS(), PADS_IO::PARSER::parseSectionPARTTYPE(), PADS_SCH::PADS_SCH_PARSER::parseSectionPARTTYPE(), PADS_IO::PARSER::parseSectionTEXT(), PADS_SCH::PADS_SCH_PARSER::parseSectionTIEDOTS(), and PADS_SCH::PADS_SCH_PARSER::parseSymbolDef().