|
KiCad PCB EDA Suite
|
Converts PADS file units (MILS, METRIC, INCHES, or internal BASIC database units) to KiCad internal units (nanometers). More...
#include <pads_unit_converter.h>
Public Member Functions | |
| PADS_UNIT_CONVERTER () | |
| void | SetBaseUnits (PADS_UNIT_TYPE aUnitType) |
| PADS_UNIT_TYPE | GetUnitType () const |
| void | SetBasicUnitsMode (bool aEnabled) |
| Enable or disable BASIC units mode. | |
| bool | IsBasicUnitsMode () const |
| void | SetBasicUnitsScale (double aScale) |
| Set a custom scale for BASIC units, in nanometers per BASIC unit. | |
| double | GetBasicUnitsScale () const |
| bool | ParseFileHeader (const std::string &aHeader) |
| Parse a PADS file header string and configure units accordingly. | |
| bool | PushUnitOverride (const std::string &aUnitCode) |
| Push a unit override onto the stack, temporarily overriding the base units for subsequent conversions until popped. | |
| void | PopUnitOverride () |
| Pop the most recent unit override, reverting to the previous setting. | |
| bool | HasUnitOverride () const |
| size_t | GetOverrideDepth () const |
| int64_t | ToNanometers (double aValue) const |
| Convert a coordinate value in PADS file units to nanometers. | |
| int64_t | ToNanometersSize (double aValue) const |
| Convert a size value (width, height, radius) in PADS file units to nanometers. | |
Static Public Member Functions | |
| static std::optional< PADS_UNIT_TYPE > | ParseUnitCode (const std::string &aUnitCode) |
| Parse a PADS unit override code ("M"/"D" mils, "MM" metric, "I" inches), returning an empty optional for "N" (no override) or an invalid code. | |
Static Public Attributes | |
| static constexpr double | MILS_TO_NM = 25400.0 |
| static constexpr double | MM_TO_NM = 1000000.0 |
| static constexpr double | INCHES_TO_NM = 25400000.0 |
| static constexpr double | BASIC_TO_NM = MILS_TO_NM / 38100.0 |
Private Member Functions | |
| void | updateScaleFactor () |
Private Attributes | |
| PADS_UNIT_TYPE | m_unitType |
| double | m_scaleFactor |
| bool | m_basicUnitsMode |
| double | m_basicUnitsScale |
| std::vector< PADS_UNIT_TYPE > | m_unitOverrideStack |
Converts PADS file units (MILS, METRIC, INCHES, or internal BASIC database units) to KiCad internal units (nanometers).
Definition at line 39 of file pads_unit_converter.h.
| PADS_UNIT_CONVERTER::PADS_UNIT_CONVERTER | ( | ) |
Definition at line 24 of file pads_unit_converter.cpp.
References BASIC_TO_NM, m_basicUnitsMode, m_basicUnitsScale, m_scaleFactor, m_unitType, MILS, and MILS_TO_NM.
|
inline |
Definition at line 63 of file pads_unit_converter.h.
References m_basicUnitsScale.
Referenced by BOOST_AUTO_TEST_CASE().
|
inline |
Definition at line 91 of file pads_unit_converter.h.
References m_unitOverrideStack.
Referenced by BOOST_AUTO_TEST_CASE().
|
inline |
Definition at line 46 of file pads_unit_converter.h.
References m_unitType.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
|
inline |
Definition at line 89 of file pads_unit_converter.h.
References m_unitOverrideStack.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
|
inline |
Definition at line 55 of file pads_unit_converter.h.
References m_basicUnitsMode.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
| bool PADS_UNIT_CONVERTER::ParseFileHeader | ( | const std::string & | aHeader | ) |
Parse a PADS file header string and configure units accordingly.
Returns true if a unit type or BASIC mode was recognized.
Definition at line 56 of file pads_unit_converter.cpp.
References INCHES, METRIC, MILS, SetBaseUnits(), and SetBasicUnitsMode().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
|
static |
Parse a PADS unit override code ("M"/"D" mils, "MM" metric, "I" inches), returning an empty optional for "N" (no override) or an invalid code.
Definition at line 93 of file pads_unit_converter.cpp.
References INCHES, METRIC, and MILS.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and PushUnitOverride().
| void PADS_UNIT_CONVERTER::PopUnitOverride | ( | ) |
Pop the most recent unit override, reverting to the previous setting.
Definition at line 138 of file pads_unit_converter.cpp.
References m_unitOverrideStack, and updateScaleFactor().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
| bool PADS_UNIT_CONVERTER::PushUnitOverride | ( | const std::string & | aUnitCode | ) |
Push a unit override onto the stack, temporarily overriding the base units for subsequent conversions until popped.
Returns false for an invalid or no-override code.
Definition at line 125 of file pads_unit_converter.cpp.
References m_unitOverrideStack, ParseUnitCode(), and updateScaleFactor().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
| void PADS_UNIT_CONVERTER::SetBaseUnits | ( | PADS_UNIT_TYPE | aUnitType | ) |
Definition at line 33 of file pads_unit_converter.cpp.
References m_unitType, and updateScaleFactor().
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(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and ParseFileHeader().
| void PADS_UNIT_CONVERTER::SetBasicUnitsMode | ( | bool | aEnabled | ) |
Enable or disable BASIC units mode.
BASIC units are PADS internal database units at 1/38100 mil resolution, interpreted regardless of the base unit type.
Definition at line 40 of file pads_unit_converter.cpp.
References m_basicUnitsMode, and updateScaleFactor().
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(), and ParseFileHeader().
| void PADS_UNIT_CONVERTER::SetBasicUnitsScale | ( | double | aScale | ) |
Set a custom scale for BASIC units, in nanometers per BASIC unit.
The default is MILS_TO_NM / 38100.0.
Definition at line 47 of file pads_unit_converter.cpp.
References m_basicUnitsMode, m_basicUnitsScale, and updateScaleFactor().
Referenced by BOOST_AUTO_TEST_CASE().
| int64_t PADS_UNIT_CONVERTER::ToNanometers | ( | double | aValue | ) | const |
Convert a coordinate value in PADS file units to nanometers.
Definition at line 177 of file pads_unit_converter.cpp.
References m_scaleFactor.
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(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
| int64_t PADS_UNIT_CONVERTER::ToNanometersSize | ( | double | aValue | ) | const |
Convert a size value (width, height, radius) in PADS file units to nanometers.
Definition at line 183 of file pads_unit_converter.cpp.
References m_scaleFactor.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
|
private |
Definition at line 148 of file pads_unit_converter.cpp.
References INCHES, INCHES_TO_NM, m_basicUnitsMode, m_basicUnitsScale, m_scaleFactor, m_unitOverrideStack, m_unitType, METRIC, MILS, MILS_TO_NM, and MM_TO_NM.
Referenced by PopUnitOverride(), PushUnitOverride(), SetBaseUnits(), SetBasicUnitsMode(), and SetBasicUnitsScale().
|
staticconstexpr |
Definition at line 107 of file pads_unit_converter.h.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), PCB_IO_PADS::loadBoardSetup(), PCB_IO_PADS_BINARY::loadBoardSetup(), and PADS_UNIT_CONVERTER().
|
staticconstexpr |
Definition at line 106 of file pads_unit_converter.h.
Referenced by BOOST_AUTO_TEST_CASE(), PCB_IO_PADS::decalUnitScale(), PCB_IO_PADS::loadBoardSetup(), PCB_IO_PADS::loadFootprints(), and updateScaleFactor().
|
private |
Definition at line 114 of file pads_unit_converter.h.
Referenced by IsBasicUnitsMode(), PADS_UNIT_CONVERTER(), SetBasicUnitsMode(), SetBasicUnitsScale(), and updateScaleFactor().
|
private |
Definition at line 115 of file pads_unit_converter.h.
Referenced by GetBasicUnitsScale(), PADS_UNIT_CONVERTER(), SetBasicUnitsScale(), and updateScaleFactor().
|
private |
Definition at line 113 of file pads_unit_converter.h.
Referenced by PADS_UNIT_CONVERTER(), ToNanometers(), ToNanometersSize(), and updateScaleFactor().
|
private |
Definition at line 116 of file pads_unit_converter.h.
Referenced by GetOverrideDepth(), HasUnitOverride(), PopUnitOverride(), PushUnitOverride(), and updateScaleFactor().
|
private |
Definition at line 112 of file pads_unit_converter.h.
Referenced by GetUnitType(), PADS_UNIT_CONVERTER(), SetBaseUnits(), and updateScaleFactor().
|
staticconstexpr |
Definition at line 104 of file pads_unit_converter.h.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), PCB_IO_PADS::decalUnitScale(), PCB_IO_PADS::loadBoardSetup(), PCB_IO_PADS::loadFootprints(), PADS_UNIT_CONVERTER(), and updateScaleFactor().
|
staticconstexpr |
Definition at line 105 of file pads_unit_converter.h.
Referenced by BOOST_AUTO_TEST_CASE(), PCB_IO_PADS::decalUnitScale(), PCB_IO_PADS::loadBoardSetup(), PCB_IO_PADS::loadFootprints(), updateScaleFactor(), and PADS_PCB_CONVERTER::WriteDiffPairRules().