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

Maps PADS layer numbers and names to KiCad layer IDs. More...

#include <pads_layer_mapper.h>

Public Member Functions

 PADS_LAYER_MAPPER ()
 
void SetCopperLayerCount (int aLayerCount)
 Set the total number of copper layers in the PADS design.
 
int GetCopperLayerCount () const
 Get the current copper layer count.
 
PADS_LAYER_TYPE GetLayerType (int aPadsLayer) const
 Parse a PADS layer number and return its type.
 
PADS_LAYER_TYPE ParseLayerName (const std::string &aLayerName) const
 Parse a PADS layer name and return its type.
 
PCB_LAYER_ID GetAutoMapLayer (int aPadsLayer, PADS_LAYER_TYPE aType=PADS_LAYER_TYPE::UNKNOWN) const
 Get the suggested KiCad layer for a PADS layer.
 
LSET GetPermittedLayers (PADS_LAYER_TYPE aType) const
 Get the permitted KiCad layers for a given PADS layer type.
 
std::vector< INPUT_LAYER_DESCBuildInputLayerDescriptions (const std::vector< PADS_LAYER_INFO > &aLayerInfos) const
 Build a vector of INPUT_LAYER_DESC from parsed PADS layer information.
 
void AddLayerNameMapping (const std::string &aName, PADS_LAYER_TYPE aType)
 Add or update a layer name to type mapping.
 

Static Public Member Functions

static std::string LayerTypeToString (PADS_LAYER_TYPE aType)
 Convert a layer type to a human-readable string.
 

Static Public Attributes

static constexpr int LAYER_PAD_STACK_TOP = -2
 Pad stack: Top copper.
 
static constexpr int LAYER_PAD_STACK_BOTTOM = -1
 Pad stack: Bottom copper.
 
static constexpr int LAYER_PAD_STACK_INNER = 0
 Pad stack: Inner copper.
 
static constexpr int LAYER_DRILL_DRAWING = 18
 
static constexpr int LAYER_DIMENSIONS = 19
 
static constexpr int LAYER_PLACEMENT_OUTLINE = 20
 
static constexpr int LAYER_ASSEMBLY_TOP = 21
 
static constexpr int LAYER_ASSEMBLY_BOTTOM = 22
 
static constexpr int LAYER_SOLDERMASK_TOP = 25
 
static constexpr int LAYER_SILKSCREEN_TOP = 26
 
static constexpr int LAYER_SILKSCREEN_BOTTOM = 27
 
static constexpr int LAYER_SOLDERMASK_BOTTOM = 28
 
static constexpr int LAYER_PASTE_TOP = 29
 
static constexpr int LAYER_PASTE_BOTTOM = 30
 
static constexpr int LAYER_BOARD_OUTLINE = 1
 

Private Member Functions

PCB_LAYER_ID mapInnerCopperLayer (int aPadsLayer) const
 
std::string normalizeLayerName (const std::string &aName) const
 

Private Attributes

int m_copperLayerCount
 
std::map< std::string, PADS_LAYER_TYPEm_layerNameMap
 

Detailed Description

Maps PADS layer numbers and names to KiCad layer IDs.

PADS uses a different layer numbering scheme than KiCad:

  • Layer 1 is Top copper
  • Layer N (where N is layer count) is Bottom copper
  • Layers 2 through N-1 are inner copper layers
  • Negative layer numbers (-2, -1) are used in pad stacks for Top/Bottom
  • Higher positive numbers (20+) represent non-copper layers

This class handles the translation between these systems and provides auto-mapping suggestions for the layer mapping dialog.

Definition at line 81 of file pads_layer_mapper.h.

Constructor & Destructor Documentation

◆ PADS_LAYER_MAPPER()

Member Function Documentation

◆ AddLayerNameMapping()

void PADS_LAYER_MAPPER::AddLayerNameMapping ( const std::string & aName,
PADS_LAYER_TYPE aType )

Add or update a layer name to type mapping.

Parameters
aNameThe PADS layer name
aTypeThe layer type it represents

Definition at line 336 of file pads_layer_mapper.cpp.

References m_layerNameMap, and normalizeLayerName().

Referenced by BOOST_AUTO_TEST_CASE().

◆ BuildInputLayerDescriptions()

std::vector< INPUT_LAYER_DESC > PADS_LAYER_MAPPER::BuildInputLayerDescriptions ( const std::vector< PADS_LAYER_INFO > & aLayerInfos) const

Build a vector of INPUT_LAYER_DESC from parsed PADS layer information.

This is used to populate the layer mapping dialog.

Parameters
aLayerInfosVector of parsed layer information
Returns
Vector of INPUT_LAYER_DESC for layer mapping dialog

Definition at line 314 of file pads_layer_mapper.cpp.

References INPUT_LAYER_DESC::AutoMapLayer, GetAutoMapLayer(), GetPermittedLayers(), info, INPUT_LAYER_DESC::Name, INPUT_LAYER_DESC::PermittedLayers, and INPUT_LAYER_DESC::Required.

Referenced by BOOST_AUTO_TEST_CASE().

◆ GetAutoMapLayer()

PCB_LAYER_ID PADS_LAYER_MAPPER::GetAutoMapLayer ( int aPadsLayer,
PADS_LAYER_TYPE aType = PADS_LAYER_TYPE::UNKNOWN ) const

Get the suggested KiCad layer for a PADS layer.

Parameters
aPadsLayerThe PADS layer number
aTypeOptional override for the layer type (if known)
Returns
The suggested KiCad layer ID

Definition at line 216 of file pads_layer_mapper.cpp.

References ASSEMBLY_BOTTOM, ASSEMBLY_TOP, B_Cu, B_Fab, B_Mask, B_Paste, B_SilkS, BOARD_OUTLINE, Cmts_User, COPPER_BOTTOM, COPPER_INNER, COPPER_TOP, DOCUMENTATION, DRILL_DRAWING, Dwgs_User, Edge_Cuts, F_Cu, F_Fab, F_Mask, F_Paste, F_SilkS, GetLayerType(), mapInnerCopperLayer(), PASTE_BOTTOM, PASTE_TOP, SILKSCREEN_BOTTOM, SILKSCREEN_TOP, SOLDERMASK_BOTTOM, SOLDERMASK_TOP, UNDEFINED_LAYER, and UNKNOWN.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BuildInputLayerDescriptions().

◆ GetCopperLayerCount()

int PADS_LAYER_MAPPER::GetCopperLayerCount ( ) const
inline

Get the current copper layer count.

Definition at line 96 of file pads_layer_mapper.h.

References m_copperLayerCount.

◆ GetLayerType()

◆ GetPermittedLayers()

LSET PADS_LAYER_MAPPER::GetPermittedLayers ( PADS_LAYER_TYPE aType) const

◆ LayerTypeToString()

std::string PADS_LAYER_MAPPER::LayerTypeToString ( PADS_LAYER_TYPE aType)
static

◆ mapInnerCopperLayer()

PCB_LAYER_ID PADS_LAYER_MAPPER::mapInnerCopperLayer ( int aPadsLayer) const
private

Definition at line 200 of file pads_layer_mapper.cpp.

References In1_Cu.

Referenced by GetAutoMapLayer().

◆ normalizeLayerName()

std::string PADS_LAYER_MAPPER::normalizeLayerName ( const std::string & aName) const
private

Definition at line 95 of file pads_layer_mapper.cpp.

Referenced by AddLayerNameMapping(), and ParseLayerName().

◆ ParseLayerName()

PADS_LAYER_TYPE PADS_LAYER_MAPPER::ParseLayerName ( const std::string & aLayerName) const

Parse a PADS layer name and return its type.

Recognizes common PADS layer names like "Silkscreen Top", "Solder Mask Top", etc.

Parameters
aLayerNameThe PADS layer name
Returns
The layer type

Definition at line 166 of file pads_layer_mapper.cpp.

References COPPER_BOTTOM, COPPER_INNER, COPPER_TOP, m_layerNameMap, normalizeLayerName(), and UNKNOWN.

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(), and BOOST_AUTO_TEST_CASE().

◆ SetCopperLayerCount()

void PADS_LAYER_MAPPER::SetCopperLayerCount ( int aLayerCount)

Set the total number of copper layers in the PADS design.

Parameters
aLayerCountTotal copper layers (e.g., 2 for a 2-layer board)

Definition at line 86 of file pads_layer_mapper.cpp.

References m_copperLayerCount.

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

Member Data Documentation

◆ LAYER_ASSEMBLY_BOTTOM

int PADS_LAYER_MAPPER::LAYER_ASSEMBLY_BOTTOM = 22
staticconstexpr

Definition at line 169 of file pads_layer_mapper.h.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and GetLayerType().

◆ LAYER_ASSEMBLY_TOP

int PADS_LAYER_MAPPER::LAYER_ASSEMBLY_TOP = 21
staticconstexpr

Definition at line 168 of file pads_layer_mapper.h.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and GetLayerType().

◆ LAYER_BOARD_OUTLINE

int PADS_LAYER_MAPPER::LAYER_BOARD_OUTLINE = 1
staticconstexpr

Definition at line 176 of file pads_layer_mapper.h.

◆ LAYER_DIMENSIONS

int PADS_LAYER_MAPPER::LAYER_DIMENSIONS = 19
staticconstexpr

Definition at line 166 of file pads_layer_mapper.h.

Referenced by GetLayerType().

◆ LAYER_DRILL_DRAWING

int PADS_LAYER_MAPPER::LAYER_DRILL_DRAWING = 18
staticconstexpr

Definition at line 165 of file pads_layer_mapper.h.

Referenced by GetLayerType().

◆ LAYER_PAD_STACK_BOTTOM

int PADS_LAYER_MAPPER::LAYER_PAD_STACK_BOTTOM = -1
staticconstexpr

Pad stack: Bottom copper.

Definition at line 161 of file pads_layer_mapper.h.

Referenced by BOOST_AUTO_TEST_CASE(), and GetLayerType().

◆ LAYER_PAD_STACK_INNER

int PADS_LAYER_MAPPER::LAYER_PAD_STACK_INNER = 0
staticconstexpr

Pad stack: Inner copper.

Definition at line 162 of file pads_layer_mapper.h.

Referenced by BOOST_AUTO_TEST_CASE(), and GetLayerType().

◆ LAYER_PAD_STACK_TOP

int PADS_LAYER_MAPPER::LAYER_PAD_STACK_TOP = -2
staticconstexpr

Pad stack: Top copper.

Definition at line 160 of file pads_layer_mapper.h.

Referenced by BOOST_AUTO_TEST_CASE(), and GetLayerType().

◆ LAYER_PASTE_BOTTOM

int PADS_LAYER_MAPPER::LAYER_PASTE_BOTTOM = 30
staticconstexpr

Definition at line 175 of file pads_layer_mapper.h.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and GetLayerType().

◆ LAYER_PASTE_TOP

int PADS_LAYER_MAPPER::LAYER_PASTE_TOP = 29
staticconstexpr

Definition at line 174 of file pads_layer_mapper.h.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and GetLayerType().

◆ LAYER_PLACEMENT_OUTLINE

int PADS_LAYER_MAPPER::LAYER_PLACEMENT_OUTLINE = 20
staticconstexpr

Definition at line 167 of file pads_layer_mapper.h.

Referenced by GetLayerType().

◆ LAYER_SILKSCREEN_BOTTOM

int PADS_LAYER_MAPPER::LAYER_SILKSCREEN_BOTTOM = 27
staticconstexpr

Definition at line 172 of file pads_layer_mapper.h.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and GetLayerType().

◆ LAYER_SILKSCREEN_TOP

int PADS_LAYER_MAPPER::LAYER_SILKSCREEN_TOP = 26
staticconstexpr

Definition at line 171 of file pads_layer_mapper.h.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and GetLayerType().

◆ LAYER_SOLDERMASK_BOTTOM

int PADS_LAYER_MAPPER::LAYER_SOLDERMASK_BOTTOM = 28
staticconstexpr

Definition at line 173 of file pads_layer_mapper.h.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and GetLayerType().

◆ LAYER_SOLDERMASK_TOP

int PADS_LAYER_MAPPER::LAYER_SOLDERMASK_TOP = 25
staticconstexpr

Definition at line 170 of file pads_layer_mapper.h.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and GetLayerType().

◆ m_copperLayerCount

int PADS_LAYER_MAPPER::m_copperLayerCount
private

◆ m_layerNameMap

std::map<std::string, PADS_LAYER_TYPE> PADS_LAYER_MAPPER::m_layerNameMap
private

Definition at line 180 of file pads_layer_mapper.h.

Referenced by AddLayerNameMapping(), PADS_LAYER_MAPPER(), and ParseLayerName().


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