KiCad PCB EDA Suite
Loading...
Searching...
No Matches
PADS_UNIT_CONVERTER Class Reference

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_TYPEParseUnitCode (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_TYPEm_unitOverrideStack
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ PADS_UNIT_CONVERTER()

PADS_UNIT_CONVERTER::PADS_UNIT_CONVERTER ( )

Member Function Documentation

◆ GetBasicUnitsScale()

double PADS_UNIT_CONVERTER::GetBasicUnitsScale ( ) const
inline

Definition at line 63 of file pads_unit_converter.h.

References m_basicUnitsScale.

Referenced by BOOST_AUTO_TEST_CASE().

◆ GetOverrideDepth()

size_t PADS_UNIT_CONVERTER::GetOverrideDepth ( ) const
inline

Definition at line 91 of file pads_unit_converter.h.

References m_unitOverrideStack.

Referenced by BOOST_AUTO_TEST_CASE().

◆ GetUnitType()

PADS_UNIT_TYPE PADS_UNIT_CONVERTER::GetUnitType ( ) const
inline

◆ HasUnitOverride()

bool PADS_UNIT_CONVERTER::HasUnitOverride ( ) const
inline

◆ IsBasicUnitsMode()

bool PADS_UNIT_CONVERTER::IsBasicUnitsMode ( ) const
inline

◆ ParseFileHeader()

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

◆ ParseUnitCode()

std::optional< PADS_UNIT_TYPE > PADS_UNIT_CONVERTER::ParseUnitCode ( const std::string & aUnitCode)
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().

◆ PopUnitOverride()

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

◆ PushUnitOverride()

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

◆ SetBaseUnits()

◆ SetBasicUnitsMode()

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

◆ SetBasicUnitsScale()

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

◆ ToNanometers()

int64_t PADS_UNIT_CONVERTER::ToNanometers ( double aValue) const

◆ ToNanometersSize()

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

◆ updateScaleFactor()

Member Data Documentation

◆ BASIC_TO_NM

double PADS_UNIT_CONVERTER::BASIC_TO_NM = MILS_TO_NM / 38100.0
staticconstexpr

◆ INCHES_TO_NM

double PADS_UNIT_CONVERTER::INCHES_TO_NM = 25400000.0
staticconstexpr

◆ m_basicUnitsMode

bool PADS_UNIT_CONVERTER::m_basicUnitsMode
private

◆ m_basicUnitsScale

double PADS_UNIT_CONVERTER::m_basicUnitsScale
private

◆ m_scaleFactor

double PADS_UNIT_CONVERTER::m_scaleFactor
private

◆ m_unitOverrideStack

std::vector<PADS_UNIT_TYPE> PADS_UNIT_CONVERTER::m_unitOverrideStack
private

◆ m_unitType

PADS_UNIT_TYPE PADS_UNIT_CONVERTER::m_unitType
private

◆ MILS_TO_NM

◆ MM_TO_NM


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