KiCad PCB EDA Suite
Loading...
Searching...
No Matches
PADS_COMMON Namespace Reference

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.
 

Detailed Description

Common utilities and types for parsing PADS file formats, shared by the PCB and schematic importers.

Enumeration Type Documentation

◆ PADS_FILE_TYPE

enum class PADS_COMMON::PADS_FILE_TYPE
strong
Enumerator
UNKNOWN 
PCB_ASCII 
SCHEMATIC_ASCII 

Definition at line 49 of file pads_common.h.

Function Documentation

◆ ConvertInvertedNetName()

◆ ConvertText()

◆ DecodeJustification()

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.

Parameters
aJustificationRaw PADS justification code.
aHJustifyReceives the decoded horizontal alignment.
aVJustifyReceives 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().

◆ DetectPadsFileType()

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().

◆ FindRelatedPadsFiles()

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().

◆ GenerateDeterministicUuid()

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.

Parameters
aIdentifierString 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().

◆ PadsLineStyleToKiCad()

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().

◆ PadsScaleCoord()

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().

◆ ParseDouble()

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().

◆ ParseInt()