Horizon
Classes | Macros | Typedefs | Enumerations | Functions
layers_id_colors_and_visibility.h File Reference

Board layer functions and definitions. More...

#include <vector>
#include <bitset>

Go to the source code of this file.

Classes

class  LSEQ
 Class LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs. More...
 
class  LSET
 Class LSET is a set of PCB_LAYER_IDs. More...
 

Macros

#define MAX_CU_LAYERS   (B_Cu - F_Cu + 1)
 
#define NETNAMES_LAYER_INDEX(layer)   ( NETNAMES_LAYER_ID_START + layer )
 Macro for obtaining netname layer for a given PCB layer.
 
#define GAL_LAYER_INDEX(x)   ( x - GAL_LAYER_ID_START )
 Use this macro to convert a GAL layer to a 0-indexed offset from LAYER_VIAS.
 
#define SCH_LAYER_ID_COUNT   ( SCH_LAYER_ID_END - SCH_LAYER_ID_START )
 
#define SCH_LAYER_INDEX(x)   ( x - SCH_LAYER_ID_START )
 
#define GERBER_DRAWLAYERS_COUNT   PCB_LAYER_ID_COUNT
 
#define GERBER_DRAW_LAYER(x)   ( GERBVIEW_LAYER_ID_START + x )
 
#define GERBER_DCODE_LAYER(x)   ( GERBER_DRAWLAYERS_COUNT + x )
 
#define GERBER_DRAW_LAYER_INDEX(x)   ( x - GERBVIEW_LAYER_ID_START )
 
#define LAYER_ID_COUNT   GERBVIEW_LAYER_ID_END
 Must update this if you add any enums after GerbView!
 
#define MIN_VISIBILITY_MASK
 

Typedefs

typedef int LAYER_NUM
 Type LAYER_NUM can be replaced with int and removed. More...
 
typedef std::vector< PCB_LAYER_IDBASE_SEQ
 A sequence of layers, a sequence provides a certain order.
 
typedef std::bitset< PCB_LAYER_ID_COUNT > BASE_SET
 

Enumerations

enum  PCB_LAYER_ID : int {
  UNDEFINED_LAYER = -1, UNSELECTED_LAYER = -2, PCBNEW_LAYER_ID_START = 0, F_Cu = PCBNEW_LAYER_ID_START,
  In1_Cu, In2_Cu, In3_Cu, In4_Cu,
  In5_Cu, In6_Cu, In7_Cu, In8_Cu,
  In9_Cu, In10_Cu, In11_Cu, In12_Cu,
  In13_Cu, In14_Cu, In15_Cu, In16_Cu,
  In17_Cu, In18_Cu, In19_Cu, In20_Cu,
  In21_Cu, In22_Cu, In23_Cu, In24_Cu,
  In25_Cu, In26_Cu, In27_Cu, In28_Cu,
  In29_Cu, In30_Cu, B_Cu, B_Adhes,
  F_Adhes, B_Paste, F_Paste, B_SilkS,
  F_SilkS, B_Mask, F_Mask, Dwgs_User,
  Cmts_User, Eco1_User, Eco2_User, Edge_Cuts,
  Margin, B_CrtYd, F_CrtYd, B_Fab,
  F_Fab, Rescue, PCB_LAYER_ID_COUNT, UNDEFINED_LAYER = -1,
  UNSELECTED_LAYER = -2, PCBNEW_LAYER_ID_START = 0, F_Cu = PCBNEW_LAYER_ID_START, In1_Cu,
  In2_Cu, In3_Cu, In4_Cu, In5_Cu,
  In6_Cu, In7_Cu, In8_Cu, In9_Cu,
  In10_Cu, In11_Cu, In12_Cu, In13_Cu,
  In14_Cu, In15_Cu, In16_Cu, In17_Cu,
  In18_Cu, In19_Cu, In20_Cu, In21_Cu,
  In22_Cu, In23_Cu, In24_Cu, In25_Cu,
  In26_Cu, In27_Cu, In28_Cu, In29_Cu,
  In30_Cu, B_Cu, B_Adhes, F_Adhes,
  B_Paste, F_Paste, B_SilkS, F_SilkS,
  B_Mask, F_Mask, Dwgs_User, Cmts_User,
  Eco1_User, Eco2_User, Edge_Cuts, Margin,
  B_CrtYd, F_CrtYd, B_Fab, F_Fab,
  Rescue, PCB_LAYER_ID_COUNT
}
 A quick note on layer IDs: More...
 
enum  NETNAMES_LAYER_ID : int {
  NETNAMES_LAYER_ID_START = PCB_LAYER_ID_COUNT, NETNAMES_LAYER_ID_RESERVED = NETNAMES_LAYER_ID_START + PCB_LAYER_ID_COUNT, LAYER_PAD_FR_NETNAMES, LAYER_PAD_BK_NETNAMES,
  LAYER_PADS_NETNAMES, LAYER_VIAS_NETNAMES, NETNAMES_LAYER_ID_END, NETNAMES_LAYER_ID_START = PCB_LAYER_ID_COUNT,
  NETNAMES_LAYER_ID_RESERVED = NETNAMES_LAYER_ID_START + PCB_LAYER_ID_COUNT, LAYER_PAD_FR_NETNAMES, LAYER_PAD_BK_NETNAMES, LAYER_PADS_NETNAMES,
  LAYER_VIAS_NETNAMES, NETNAMES_LAYER_ID_END
}
 Dedicated layers for net names used in Pcbnew. More...
 
enum  GAL_LAYER_ID : int {
  GAL_LAYER_ID_START = NETNAMES_LAYER_ID_END, LAYER_VIAS = GAL_LAYER_ID_START, LAYER_VIA_MICROVIA, LAYER_VIA_BBLIND,
  LAYER_VIA_THROUGH, LAYER_NON_PLATEDHOLES, LAYER_MOD_TEXT_FR, LAYER_MOD_TEXT_BK,
  LAYER_MOD_TEXT_INVISIBLE, LAYER_ANCHOR, LAYER_PAD_FR, LAYER_PAD_BK,
  LAYER_RATSNEST, LAYER_GRID, LAYER_GRID_AXES, LAYER_NO_CONNECTS,
  LAYER_MOD_FR, LAYER_MOD_BK, LAYER_MOD_VALUES, LAYER_MOD_REFERENCES,
  LAYER_TRACKS, LAYER_PADS_TH, LAYER_PADS_PLATEDHOLES, LAYER_VIAS_HOLES,
  LAYER_DRC, LAYER_WORKSHEET, LAYER_GP_OVERLAY, LAYER_SELECT_OVERLAY,
  LAYER_PCB_BACKGROUND, LAYER_CURSOR, LAYER_AUX_ITEMS, LAYER_DRAW_BITMAPS,
  GAL_LAYER_ID_BITMASK_END, GAL_LAYER_ID_END, GAL_LAYER_ID_START = NETNAMES_LAYER_ID_END, LAYER_VIAS = GAL_LAYER_ID_START,
  LAYER_VIA_MICROVIA, LAYER_VIA_BBLIND, LAYER_VIA_THROUGH, LAYER_NON_PLATEDHOLES,
  LAYER_MOD_TEXT_FR, LAYER_MOD_TEXT_BK, LAYER_MOD_TEXT_INVISIBLE, LAYER_ANCHOR,
  LAYER_PAD_FR, LAYER_PAD_BK, LAYER_RATSNEST, LAYER_GRID,
  LAYER_GRID_AXES, LAYER_NO_CONNECTS, LAYER_MOD_FR, LAYER_MOD_BK,
  LAYER_MOD_VALUES, LAYER_MOD_REFERENCES, LAYER_TRACKS, LAYER_PADS_TH,
  LAYER_PADS_PLATEDHOLES, LAYER_VIAS_HOLES, LAYER_DRC, LAYER_WORKSHEET,
  LAYER_GP_OVERLAY, LAYER_SELECT_OVERLAY, LAYER_PCB_BACKGROUND, LAYER_CURSOR,
  LAYER_AUX_ITEMS, LAYER_DRAW_BITMAPS, GAL_LAYER_ID_BITMASK_END, GAL_LAYER_ID_END
}
 GAL layers are "virtual" layers, i.e. More...
 
enum  SCH_LAYER_ID : int {
  SCH_LAYER_ID_START = GAL_LAYER_ID_END, LAYER_WIRE = SCH_LAYER_ID_START, LAYER_BUS, LAYER_JUNCTION,
  LAYER_LOCLABEL, LAYER_GLOBLABEL, LAYER_HIERLABEL, LAYER_PINNUM,
  LAYER_PINNAM, LAYER_REFERENCEPART, LAYER_VALUEPART, LAYER_FIELDS,
  LAYER_DEVICE, LAYER_NOTES, LAYER_NETNAM, LAYER_PIN,
  LAYER_SHEET, LAYER_SHEETNAME, LAYER_SHEETFILENAME, LAYER_SHEETLABEL,
  LAYER_NOCONNECT, LAYER_ERC_WARN, LAYER_ERC_ERR, LAYER_DEVICE_BACKGROUND,
  LAYER_SHEET_BACKGROUND, LAYER_SCHEMATIC_BITMAPS, LAYER_SCHEMATIC_GRID, LAYER_SCHEMATIC_BACKGROUND,
  LAYER_SCHEMATIC_CURSOR, LAYER_BRIGHTENED, LAYER_HIDDEN, SCH_LAYER_ID_END,
  SCH_LAYER_ID_START = GAL_LAYER_ID_END, LAYER_WIRE = SCH_LAYER_ID_START, LAYER_BUS, LAYER_JUNCTION,
  LAYER_LOCLABEL, LAYER_GLOBLABEL, LAYER_HIERLABEL, LAYER_PINNUM,
  LAYER_PINNAM, LAYER_REFERENCEPART, LAYER_VALUEPART, LAYER_FIELDS,
  LAYER_DEVICE, LAYER_NOTES, LAYER_NETNAM, LAYER_PIN,
  LAYER_SHEET, LAYER_SHEETNAME, LAYER_SHEETFILENAME, LAYER_SHEETLABEL,
  LAYER_NOCONNECT, LAYER_ERC_WARN, LAYER_ERC_ERR, LAYER_DEVICE_BACKGROUND,
  LAYER_SHEET_BACKGROUND, LAYER_SCHEMATIC_BITMAPS, LAYER_SCHEMATIC_GRID, LAYER_SCHEMATIC_BACKGROUND,
  LAYER_SCHEMATIC_CURSOR, LAYER_BRIGHTENED, LAYER_HIDDEN, SCH_LAYER_ID_END
}
 Eeschema drawing layers.
 
enum  GERBVIEW_LAYER_ID : int {
  GERBVIEW_LAYER_ID_START = SCH_LAYER_ID_END, GERBVIEW_LAYER_ID_RESERVED = GERBVIEW_LAYER_ID_START + ( 2 * GERBER_DRAWLAYERS_COUNT ), LAYER_DCODES, LAYER_NEGATIVE_OBJECTS,
  LAYER_GERBVIEW_GRID, LAYER_GERBVIEW_AXES, LAYER_GERBVIEW_BACKGROUND, GERBVIEW_LAYER_ID_END,
  GERBVIEW_LAYER_ID_START = SCH_LAYER_ID_END, GERBVIEW_LAYER_ID_RESERVED = GERBVIEW_LAYER_ID_START + ( 2 * GERBER_DRAWLAYERS_COUNT ), LAYER_DCODES, LAYER_NEGATIVE_OBJECTS,
  LAYER_GERBVIEW_GRID, LAYER_GERBVIEW_AXES, LAYER_GERBVIEW_BACKGROUND, GERBVIEW_LAYER_ID_END
}
 GerbView draw layers. More...
 

Functions

GAL_LAYER_ID operator++ (GAL_LAYER_ID &a)
 
GAL_LAYER_ID operator+ (const GAL_LAYER_ID &a, int b)
 Used for via types.
 
SCH_LAYER_ID operator++ (SCH_LAYER_ID &a)
 
bool IsValidLayer (LAYER_NUM aLayerId)
 Function IsValidLayer tests whether a given integer is a valid layer index, i.e. More...
 
bool IsPcbLayer (LAYER_NUM aLayer)
 Function IsPcbLayer tests whether a layer is a valid layer for pcbnew. More...
 
bool IsCopperLayer (LAYER_NUM aLayerId)
 Function IsCopperLayer tests whether a layer is a copper layer. More...
 
bool IsNonCopperLayer (LAYER_NUM aLayerId)
 Function IsNonCopperLayer tests whether a layer is a non copper layer. More...
 
bool IsUserLayer (PCB_LAYER_ID aLayerId)
 Function IsUserLayer tests whether a layer is a non copper and a non tech layer. More...
 
bool IsFrontLayer (PCB_LAYER_ID aLayerId)
 Layer classification: check if it's a front layer.
 
bool IsBackLayer (PCB_LAYER_ID aLayerId)
 Layer classification: check if it's a back layer.
 
PCB_LAYER_ID FlipLayer (PCB_LAYER_ID aLayerId, int aCopperLayersCount=0)
 Function FlippedLayerNumber. More...
 
LSET FlipLayerMask (LSET aMask, int aCopperLayersCount=0)
 Calculate the mask layer when flipping a footprint BACK and FRONT copper layers, mask, paste, solder layers are swapped internal layers are flipped only if the copper layers count is known. More...
 
int GetNetnameLayer (int aLayer)
 Returns a netname layer corresponding to the given layer.
 
bool IsNetnameLayer (LAYER_NUM aLayer)
 Function IsNetnameLayer tests whether a layer is a netname layer. More...
 
bool IsDCodeLayer (int aLayer)
 
PCB_LAYER_ID ToLAYER_ID (int aLayer)
 

Detailed Description

Board layer functions and definitions.

Macro Definition Documentation

◆ MIN_VISIBILITY_MASK

#define MIN_VISIBILITY_MASK

Typedef Documentation

◆ LAYER_NUM

typedef int LAYER_NUM

Type LAYER_NUM can be replaced with int and removed.

Until then, it is something you can increment, and its meaning is only advisory but can extend beyond PCB layers into view layers and gerber layers.

Enumeration Type Documentation

◆ GAL_LAYER_ID

enum GAL_LAYER_ID : int

GAL layers are "virtual" layers, i.e.

not tied into design data. Some layers here are shared between applications.

Enumerator
LAYER_VIA_MICROVIA 

to draw micro vias

LAYER_VIA_BBLIND 

to draw blind/buried vias

LAYER_VIA_THROUGH 

to draw usual through hole vias

LAYER_NON_PLATEDHOLES 

handle color for not plated holes (holes, not pads)

LAYER_MOD_TEXT_INVISIBLE 

text marked as invisible

LAYER_ANCHOR 

anchor of items having an anchor point (texts, footprints)

LAYER_PAD_FR 

smd pads, front layer

LAYER_PAD_BK 

smd pads, back layer

LAYER_NO_CONNECTS 

show a marker on pads with no nets

LAYER_MOD_FR 

show modules on front

LAYER_MOD_BK 

show modules on back

LAYER_MOD_VALUES 

show modules values (when texts are visibles)

LAYER_MOD_REFERENCES 

show modules references (when texts are visibles)

LAYER_PADS_TH 

multilayer pads, usually with holes

LAYER_PADS_PLATEDHOLES 

to draw pad holes (plated)

LAYER_VIAS_HOLES 

to draw via holes (pad holes do not use this layer)

LAYER_DRC 

drc markers

LAYER_WORKSHEET 

worksheet frame

LAYER_GP_OVERLAY 

general purpose overlay

LAYER_SELECT_OVERLAY 

currently selected items overlay

LAYER_PCB_BACKGROUND 

PCB background color.

LAYER_CURSOR 

PCB cursor.

LAYER_AUX_ITEMS 

Auxiliary items (guides, rule, etc)

LAYER_DRAW_BITMAPS 

to handle and draw images bitmaps

GAL_LAYER_ID_BITMASK_END 

This is the end of the layers used for visibility bitmasks in Pcbnew There can be at most 32 layers above here.

GAL_LAYER_ID_END 

Add new GAL layers here.

LAYER_VIA_MICROVIA 

to draw micro vias

LAYER_VIA_BBLIND 

to draw blind/buried vias

LAYER_VIA_THROUGH 

to draw usual through hole vias

LAYER_NON_PLATEDHOLES 

handle color for not plated holes (holes, not pads)

LAYER_MOD_TEXT_INVISIBLE 

text marked as invisible

LAYER_ANCHOR 

anchor of items having an anchor point (texts, footprints)

LAYER_PAD_FR 

smd pads, front layer

LAYER_PAD_BK 

smd pads, back layer

LAYER_NO_CONNECTS 

show a marker on pads with no nets

LAYER_MOD_FR 

show modules on front

LAYER_MOD_BK 

show modules on back

LAYER_MOD_VALUES 

show modules values (when texts are visibles)

LAYER_MOD_REFERENCES 

show modules references (when texts are visibles)

LAYER_PADS_TH 

multilayer pads, usually with holes

LAYER_PADS_PLATEDHOLES 

to draw pad holes (plated)

LAYER_VIAS_HOLES 

to draw via holes (pad holes do not use this layer)

LAYER_DRC 

drc markers

LAYER_WORKSHEET 

worksheet frame

LAYER_GP_OVERLAY 

general purpose overlay

LAYER_SELECT_OVERLAY 

currently selected items overlay

LAYER_PCB_BACKGROUND 

PCB background color.

LAYER_CURSOR 

PCB cursor.

LAYER_AUX_ITEMS 

Auxiliary items (guides, rule, etc)

LAYER_DRAW_BITMAPS 

to handle and draw images bitmaps

GAL_LAYER_ID_BITMASK_END 

This is the end of the layers used for visibility bitmasks in Pcbnew There can be at most 32 layers above here.

GAL_LAYER_ID_END 

Add new GAL layers here.

◆ GERBVIEW_LAYER_ID

enum GERBVIEW_LAYER_ID : int

GerbView draw layers.

Enumerator
GERBVIEW_LAYER_ID_RESERVED 

GerbView draw layers and d-code layers.

GERBVIEW_LAYER_ID_RESERVED 

GerbView draw layers and d-code layers.

◆ NETNAMES_LAYER_ID

enum NETNAMES_LAYER_ID : int

Dedicated layers for net names used in Pcbnew.

Enumerator
NETNAMES_LAYER_ID_RESERVED 

Reserved space for board layer netnames.

LAYER_PAD_FR_NETNAMES 

Additional netnames layers (not associated with a PCB layer)

NETNAMES_LAYER_ID_RESERVED 

Reserved space for board layer netnames.

LAYER_PAD_FR_NETNAMES 

Additional netnames layers (not associated with a PCB layer)

◆ PCB_LAYER_ID

enum PCB_LAYER_ID : int

A quick note on layer IDs:

The layers are stored in separate enums so that certain functions can take in the enums as datatypes and don't have to know about layers from other applications.

Layers that are shared between applications should be in the GAL_LAYER_ID enum.

The PCB_LAYER_ID struct must start at zero for compatibility with legacy board files.

Some functions accept any layer ID, so they start at zero (i.e. F_Cu) and go up to the LAYER_ID_COUNT, which needs to be kept up-to-date if new enums are added. Enum PCB_LAYER_ID This is the definition of all layers used in Pcbnew The PCB layer types are fixed at value 0 through LAYER_ID_COUNT, to ensure compatibility with legacy board files.

Function Documentation

◆ FlipLayer()

PCB_LAYER_ID FlipLayer ( PCB_LAYER_ID  aLayerId,
int  aCopperLayersCount = 0 
)

Function FlippedLayerNumber.

Returns
the layer number after flipping an item some (not all) layers: external copper, and paired layers( Mask, Paste, solder ... ) are swapped between front and back sides internal layers are flipped only if the copper layers count is known
Parameters
aLayerId= the PCB_LAYER_ID to flip
aCopperLayersCount= the number of copper layers. if 0 (in fact if < 4 ) internal layers will be not flipped because the layer count is not known

◆ FlipLayerMask()

LSET FlipLayerMask ( LSET  aMask,
int  aCopperLayersCount = 0 
)

Calculate the mask layer when flipping a footprint BACK and FRONT copper layers, mask, paste, solder layers are swapped internal layers are flipped only if the copper layers count is known.

Parameters
aMask= the LSET to flip
aCopperLayersCount= the number of copper layers. if 0 (in fact if < 4 ) internal layers will be not flipped because the layer count is not known

◆ IsCopperLayer()

bool IsCopperLayer ( LAYER_NUM  aLayerId)
inline

Function IsCopperLayer tests whether a layer is a copper layer.

Parameters
aLayerId= Layer to test
Returns
true if aLayer is a valid copper layer

◆ IsNetnameLayer()

bool IsNetnameLayer ( LAYER_NUM  aLayer)
inline

Function IsNetnameLayer tests whether a layer is a netname layer.

Parameters
aLayer= Layer to test
Returns
true if aLayer is a valid netname layer

◆ IsNonCopperLayer()

bool IsNonCopperLayer ( LAYER_NUM  aLayerId)
inline

Function IsNonCopperLayer tests whether a layer is a non copper layer.

Parameters
aLayerId= Layer to test
Returns
true if aLayer is a non copper layer

◆ IsPcbLayer()

bool IsPcbLayer ( LAYER_NUM  aLayer)
inline

Function IsPcbLayer tests whether a layer is a valid layer for pcbnew.

Parameters
aLayer= Layer to test
Returns
true if aLayer is a layer valid in pcbnew

◆ IsUserLayer()

bool IsUserLayer ( PCB_LAYER_ID  aLayerId)
inline

Function IsUserLayer tests whether a layer is a non copper and a non tech layer.

Parameters
aLayerId= Layer to test
Returns
true if aLayer is a user layer

◆ IsValidLayer()

bool IsValidLayer ( LAYER_NUM  aLayerId)
inline

Function IsValidLayer tests whether a given integer is a valid layer index, i.e.

can be safely put in a PCB_LAYER_ID

Parameters
aLayerId= Layer index to test. It can be an int, so its useful during I/O
Returns
true if aLayerIndex is a valid layer index
LAYER_DRC
@ LAYER_DRC
drc markers
Definition: layers_id_colors_and_visibility.h:194
GAL_LAYER_INDEX
#define GAL_LAYER_INDEX(x)
Use this macro to convert a GAL layer to a 0-indexed offset from LAYER_VIAS.
Definition: layers_id_colors_and_visibility.h:213
LAYER_SELECT_OVERLAY
@ LAYER_SELECT_OVERLAY
currently selected items overlay
Definition: layers_id_colors_and_visibility.h:197
LAYER_PADS_PLATEDHOLES
@ LAYER_PADS_PLATEDHOLES
to draw pad holes (plated)
Definition: layers_id_colors_and_visibility.h:192
LAYER_GP_OVERLAY
@ LAYER_GP_OVERLAY
general purpose overlay
Definition: layers_id_colors_and_visibility.h:196
LAYER_VIAS_HOLES
@ LAYER_VIAS_HOLES
to draw via holes (pad holes do not use this layer)
Definition: layers_id_colors_and_visibility.h:193