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

Utility functions for dealing with layers in the context of a PCB board.s. More...

Functions

wxString AccumulateNames (const LSEQ &aLayers, const BOARD *aBoard)
 Accumulate layer names from a layer set into a comma separated string.
 
wxString AccumulateNames (const LSET &aLayers, const BOARD *aBoard)
 Accumulate layer names from a layer set into a comma separated string, in UI order.
 
LSET GetAllFootprintLayers (const FOOTPRINT &aFootprint)
 Return the union of layers referenced by every item inside the footprint (including graphic items, pads, zones, fields, and nested groups).
 
LSET GetUsedFootprintLayers (const FOOTPRINT &aFootprint)
 Return the layers the footprint's items actually occupy.
 
int MinimalCopperLayerCount (const LSET &aLayers)
 Return the smallest even copper layer count whose stackup contains every copper layer in aLayers.
 
LSET GetOrphanedFootprintLayers (const FOOTPRINT &aFootprint, const LSET &aCustomUserLayers)
 Compute the set of footprint-used layers that would be orphaned if the footprint's allowed layer set is restricted to aCustomUserLayers (plus the tech and user masks).
 

Detailed Description

Utility functions for dealing with layers in the context of a PCB board.s.

This includes functions that need access to the board to get layer names, and other more complex, but reusable operations that either shouldn't be in LSET/LSEQ's interface or need access to Pcbnew types.

Function Documentation

◆ AccumulateNames() [1/2]

wxString LAYER_UTILS::AccumulateNames ( const LSEQ & aLayers,
const BOARD * aBoard )

Accumulate layer names from a layer set into a comma separated string.

Parameters
aLayersis the list of layers to accumulate.
aBoardis the board to get layer names from, if null the default names are used.

Definition at line 27 of file layer_utils.cpp.

References BOARD::GetLayerName(), LayerName(), and result.

Referenced by AccumulateNames(), footprintVsBoardStackup(), and DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::Validate().

◆ AccumulateNames() [2/2]

wxString LAYER_UTILS::AccumulateNames ( const LSET & aLayers,
const BOARD * aBoard )
inline

Accumulate layer names from a layer set into a comma separated string, in UI order.

Definition at line 53 of file layer_utils.h.

References AccumulateNames(), and LSET::UIOrder().

◆ GetAllFootprintLayers()

LSET LAYER_UTILS::GetAllFootprintLayers ( const FOOTPRINT & aFootprint)

Return the union of layers referenced by every item inside the footprint (including graphic items, pads, zones, fields, and nested groups).

Definition at line 43 of file layer_utils.cpp.

References BOARD_ITEM::GetLayerSet(), RECURSE, and FOOTPRINT::RunOnChildren().

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

◆ GetOrphanedFootprintLayers()

LSET LAYER_UTILS::GetOrphanedFootprintLayers ( const FOOTPRINT & aFootprint,
const LSET & aCustomUserLayers )

Compute the set of footprint-used layers that would be orphaned if the footprint's allowed layer set is restricted to aCustomUserLayers (plus the tech and user masks).

A through-hole pad is stored as the "*.Cu" wildcard, naming no individual copper layer, so it can never be orphaned by a copper layer being removed.

The Rescue pseudo-layer is intentionally excluded. It is an internal fallback for items referencing unknown layer names at load time and is not surfaced in any layer-selection UI. Orphans on Rescue must be addressed through the library-parity DRC, not by blocking edits in the Footprint Properties dialog.

Definition at line 108 of file layer_utils.cpp.

References GetUsedFootprintLayers(), Rescue, and BASE_SET::reset().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::Validate().

◆ GetUsedFootprintLayers()

LSET LAYER_UTILS::GetUsedFootprintLayers ( const FOOTPRINT & aFootprint)

Return the layers the footprint's items actually occupy.

Unlike GetAllFootprintLayers(), a through-hole pad stored as the "*.Cu" wildcard contributes only the copper layers its padstack explicitly defines, because it adapts to whatever copper stackup it is placed on.

Definition at line 59 of file layer_utils.cpp.

References LSET::AllCuMask(), LSET::AllCuMask(), BOARD_ITEM::GetLayerSet(), pad, PCB_PAD_T, RECURSE, BASE_SET::reset(), FOOTPRINT::RunOnChildren(), and EDA_ITEM::Type().

Referenced by GetOrphanedFootprintLayers(), and DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataToWindow().

◆ MinimalCopperLayerCount()

int LAYER_UTILS::MinimalCopperLayerCount ( const LSET & aLayers)

Return the smallest even copper layer count whose stackup contains every copper layer in aLayers.

Definition at line 95 of file layer_utils.cpp.

References CopperLayerToOrdinal(), and LSET::InternalCuMask().

Referenced by altiumStackupCopper(), and DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataToWindow().