KiCad PCB EDA Suite
layers_id_colors_and_visibility.h File Reference

Board layer functions and definitions. More...

#include <vector>
#include <bitset>
#include <wx/string.h>
#include <macros.h>

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. More...
 
#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. More...
 
#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   32
 
#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! More...
 
#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. More...
 
typedef std::bitset< PCB_LAYER_ID_COUNTBASE_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, 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
}
 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 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_GRID, LAYER_SCHEMATIC_BACKGROUND, LAYER_SCHEMATIC_CURSOR,
  LAYER_BRIGHTENED, LAYER_HIDDEN, SCH_LAYER_ID_END
}
 Eeschema drawing layers. More...
 
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 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. More...
 
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. More...
 
bool IsBackLayer (PCB_LAYER_ID aLayerId)
 Layer classification: check if it's a back layer. More...
 
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. More...
 
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.

Definition in file layers_id_colors_and_visibility.h.

Macro Definition Documentation

#define GAL_LAYER_INDEX (   x)    ( x - GAL_LAYER_ID_START )
#define GERBER_DRAW_LAYER_INDEX (   x)    ( x - GERBVIEW_LAYER_ID_START )

Definition at line 301 of file layers_id_colors_and_visibility.h.

#define LAYER_ID_COUNT   GERBVIEW_LAYER_ID_END

Must update this if you add any enums after GerbView!

Definition at line 304 of file layers_id_colors_and_visibility.h.

Referenced by BOARD_PRINTOUT::DrawPage(), and KIGFX::RENDER_SETTINGS::update().

#define MIN_VISIBILITY_MASK
Value:
( 1 << GAL_LAYER_INDEX( LAYER_DRC ) ) +\
to draw via holes (pad holes do not use this layer)
#define GAL_LAYER_INDEX(x)
Use this macro to convert a GAL layer to a 0-indexed offset from LAYER_VIAS.
general purpose overlay
currently selected items overlay

Definition at line 311 of file layers_id_colors_and_visibility.h.

Referenced by PCB_PARSER::parseSetup().

#define NETNAMES_LAYER_INDEX (   layer)    ( NETNAMES_LAYER_ID_START + layer )

Macro for obtaining netname layer for a given PCB layer.

Definition at line 163 of file layers_id_colors_and_visibility.h.

Referenced by GetNetnameLayer(), IsNetnameLayer(), and PCB_DRAW_PANEL_GAL::SetTopLayer().

#define SCH_LAYER_ID_COUNT   ( SCH_LAYER_ID_END - SCH_LAYER_ID_START )

Definition at line 267 of file layers_id_colors_and_visibility.h.

Referenced by SCH_LEGACY_PLUGIN::Format().

#define SCH_LAYER_INDEX (   x)    ( x - SCH_LAYER_ID_START )

Definition at line 269 of file layers_id_colors_and_visibility.h.

Typedef Documentation

typedef std::vector<PCB_LAYER_ID> BASE_SEQ

A sequence of layers, a sequence provides a certain order.

Definition at line 319 of file layers_id_colors_and_visibility.h.

typedef std::bitset<PCB_LAYER_ID_COUNT> BASE_SET

Definition at line 369 of file layers_id_colors_and_visibility.h.

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.

Definition at line 39 of file layers_id_colors_and_visibility.h.

Enumeration Type Documentation

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
GAL_LAYER_ID_START 
LAYER_VIAS 
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_FR 
LAYER_MOD_TEXT_BK 
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_RATSNEST 
LAYER_GRID 
LAYER_GRID_AXES 
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_TRACKS 
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.

Definition at line 167 of file layers_id_colors_and_visibility.h.

167  : int
168 {
170 
179  LAYER_ANCHOR,
180  LAYER_PAD_FR,
181  LAYER_PAD_BK,
183  LAYER_GRID,
186  LAYER_MOD_FR,
187  LAYER_MOD_BK,
190  LAYER_TRACKS,
191  LAYER_PADS_TH,
194  LAYER_DRC,
199  LAYER_CURSOR,
202 
206 
208 
210 };
to draw blind/buried vias
show a marker on pads with no nets
multilayer pads, usually with holes
to handle and draw images bitmaps
handle color for not plated holes (holes, not pads)
anchor of items having an anchor point (texts, footprints)
show modules on back
to draw via holes (pad holes do not use this layer)
show modules values (when texts are visibles)
This is the end of the layers used for visibility bitmasks in Pcbnew There can be at most 32 layers a...
Add new GAL layers here.
smd pads, back layer
show modules on front
Auxiliary items (guides, rule, etc)
to draw usual through hole vias
general purpose overlay
smd pads, front layer
currently selected items overlay
show modules references (when texts are visibles)
enum GERBVIEW_LAYER_ID : int

GerbView draw layers.

Enumerator
GERBVIEW_LAYER_ID_START 
GERBVIEW_LAYER_ID_RESERVED 

GerbView draw layers and d-code layers.

LAYER_DCODES 
LAYER_NEGATIVE_OBJECTS 
LAYER_GERBVIEW_GRID 
LAYER_GERBVIEW_AXES 
LAYER_GERBVIEW_BACKGROUND 
GERBVIEW_LAYER_ID_END 

Definition at line 281 of file layers_id_colors_and_visibility.h.

enum NETNAMES_LAYER_ID : int

Dedicated layers for net names used in Pcbnew.

Enumerator
NETNAMES_LAYER_ID_START 
NETNAMES_LAYER_ID_RESERVED 

Reserved space for board layer netnames.

LAYER_PAD_FR_NETNAMES 

Additional netnames layers (not associated with a PCB layer)

LAYER_PAD_BK_NETNAMES 
LAYER_PADS_NETNAMES 
LAYER_VIAS_NETNAMES 
NETNAMES_LAYER_ID_END 

Definition at line 143 of file layers_id_colors_and_visibility.h.

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.

Enumerator
UNDEFINED_LAYER 
UNSELECTED_LAYER 
PCBNEW_LAYER_ID_START 
F_Cu 
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 
PCB_LAYER_ID_COUNT 

Definition at line 73 of file layers_id_colors_and_visibility.h.

73  : int
74 {
75  UNDEFINED_LAYER = -1,
76  UNSELECTED_LAYER = -2,
77 
80  In1_Cu,
81  In2_Cu,
82  In3_Cu,
83  In4_Cu,
84  In5_Cu,
85  In6_Cu,
86  In7_Cu,
87  In8_Cu,
88  In9_Cu,
89  In10_Cu,
90  In11_Cu,
91  In12_Cu,
92  In13_Cu,
93  In14_Cu,
94  In15_Cu,
95  In16_Cu,
96  In17_Cu,
97  In18_Cu,
98  In19_Cu,
99  In20_Cu,
100  In21_Cu,
101  In22_Cu,
102  In23_Cu,
103  In24_Cu,
104  In25_Cu,
105  In26_Cu,
106  In27_Cu,
107  In28_Cu,
108  In29_Cu,
109  In30_Cu,
110  B_Cu, // 31
111 
112  B_Adhes,
113  F_Adhes,
114 
115  B_Paste,
116  F_Paste,
117 
118  B_SilkS,
119  F_SilkS,
120 
121  B_Mask,
122  F_Mask,
123 
124  Dwgs_User,
125  Cmts_User,
126  Eco1_User,
127  Eco2_User,
128  Edge_Cuts,
129  Margin,
130 
131  B_CrtYd,
132  F_CrtYd,
133 
134  B_Fab,
135  F_Fab,
136 
138 };
enum SCH_LAYER_ID : int

Eeschema drawing layers.

Enumerator
SCH_LAYER_ID_START 
LAYER_WIRE 
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_GRID 
LAYER_SCHEMATIC_BACKGROUND 
LAYER_SCHEMATIC_CURSOR 
LAYER_BRIGHTENED 
LAYER_HIDDEN 
SCH_LAYER_ID_END 

Definition at line 230 of file layers_id_colors_and_visibility.h.

230  : int
231 {
233 
235  LAYER_BUS,
240  LAYER_PINNUM,
241  LAYER_PINNAM,
244  LAYER_FIELDS,
245  LAYER_DEVICE,
246  LAYER_NOTES,
247  LAYER_NETNAM,
248  LAYER_PIN,
249  LAYER_SHEET,
262  LAYER_HIDDEN,
263 
265 };
Add new GAL layers here.

Function Documentation

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

Definition at line 472 of file lset.cpp.

References B_Adhes, B_CrtYd, B_Cu, B_Fab, B_Mask, B_Paste, B_SilkS, F_Adhes, F_CrtYd, F_Cu, F_Fab, F_Mask, F_Paste, F_SilkS, In1_Cu, and IsCopperLayer().

Referenced by PCAD2KICAD::PCB_MODULE::AddToBoard(), PCAD2KICAD::PCB_PAD::Flip(), PCAD2KICAD::PCB_LINE::Flip(), PCAD2KICAD::PCB_ARC::Flip(), PCAD2KICAD::PCB_POLYGON::Flip(), TEXTE_PCB::Flip(), PCB_TARGET::Flip(), EDGE_MODULE::Flip(), TEXTE_MODULE::Flip(), TRACK::Flip(), DIMENSION::Flip(), MODULE::Flip(), DRAWSEGMENT::Flip(), ZONE_CONTAINER::Flip(), VIA::Flip(), and IsBackLayer().

473 {
474  switch( aLayerId )
475  {
476  case B_Cu: return F_Cu;
477  case F_Cu: return B_Cu;
478 
479  case B_SilkS: return F_SilkS;
480  case F_SilkS: return B_SilkS;
481 
482  case B_Adhes: return F_Adhes;
483  case F_Adhes: return B_Adhes;
484 
485  case B_Mask: return F_Mask;
486  case F_Mask: return B_Mask;
487 
488  case B_Paste: return F_Paste;
489  case F_Paste: return B_Paste;
490 
491  case B_CrtYd: return F_CrtYd;
492  case F_CrtYd: return B_CrtYd;
493 
494  case B_Fab: return F_Fab;
495  case F_Fab: return B_Fab;
496 
497  default: // change internal layer if aCopperLayersCount is >= 4
498  if( IsCopperLayer( aLayerId ) && aCopperLayersCount >= 4 )
499  {
500  // internal copper layers count is aCopperLayersCount-2
501  PCB_LAYER_ID fliplayer = PCB_LAYER_ID(aCopperLayersCount - 2 - ( aLayerId - In1_Cu ) );
502  // Ensure fliplayer has a value which does not crash pcbnew:
503  if( fliplayer < F_Cu )
504  fliplayer = F_Cu;
505 
506  if( fliplayer > B_Cu )
507  fliplayer = B_Cu;
508 
509  return fliplayer;
510  }
511 
512  // No change for the other layers
513  return aLayerId;
514  }
515 }
PCB_LAYER_ID
A quick note on layer IDs:
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
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

Definition at line 518 of file lset.cpp.

References B_Adhes, B_CrtYd, B_Cu, B_Fab, B_Mask, B_Paste, B_SilkS, F_Adhes, F_CrtYd, F_Cu, F_Fab, F_Mask, F_Paste, F_SilkS, In1_Cu, and LSET::InternalCuMask().

Referenced by D_PAD::Flip(), ZONE_CONTAINER::Flip(), DIALOG_PAD_PROPERTIES::initValues(), IsBackLayer(), and DIALOG_PAD_PROPERTIES::TransferDataFromWindow().

519 {
520  // layers on physical outside of a board:
521  const static LSET and_mask( 16, // !! update count
522  B_Cu, F_Cu,
523  B_SilkS, F_SilkS,
524  B_Adhes, F_Adhes,
525  B_Mask, F_Mask,
526  B_Paste, F_Paste,
527  B_Adhes, F_Adhes,
528  B_CrtYd, F_CrtYd,
529  B_Fab, F_Fab
530  );
531 
532  LSET newMask = aMask & ~and_mask;
533 
534  if( aMask[B_Cu] )
535  newMask.set( F_Cu );
536 
537  if( aMask[F_Cu] )
538  newMask.set( B_Cu );
539 
540  if( aMask[B_SilkS] )
541  newMask.set( F_SilkS );
542 
543  if( aMask[F_SilkS] )
544  newMask.set( B_SilkS );
545 
546  if( aMask[B_Adhes] )
547  newMask.set( F_Adhes );
548 
549  if( aMask[F_Adhes] )
550  newMask.set( B_Adhes );
551 
552  if( aMask[B_Mask] )
553  newMask.set( F_Mask );
554 
555  if( aMask[F_Mask] )
556  newMask.set( B_Mask );
557 
558  if( aMask[B_Paste] )
559  newMask.set( F_Paste );
560 
561  if( aMask[F_Paste] )
562  newMask.set( B_Paste );
563 
564  if( aMask[B_Adhes] )
565  newMask.set( F_Adhes );
566 
567  if( aMask[F_Adhes] )
568  newMask.set( B_Adhes );
569 
570  if( aMask[B_CrtYd] )
571  newMask.set( F_CrtYd );
572 
573  if( aMask[F_CrtYd] )
574  newMask.set( B_CrtYd );
575 
576  if( aMask[B_Fab] )
577  newMask.set( F_Fab );
578 
579  if( aMask[F_Fab] )
580  newMask.set( B_Fab );
581 
582  if( aCopperLayersCount >= 4 ) // Internal layers exist
583  {
584  LSET internalMask = aMask & LSET::InternalCuMask();
585 
586  if( internalMask != LSET::InternalCuMask() )
587  {
588  // the mask does not include all internal layers. Therefore
589  // the flipped mask for internal copper layers must be built
590  int innerLayerCnt = aCopperLayersCount -2;
591 
592  // the flipped mask is the innerLayerCnt bits rewritten in reverse order
593  // ( bits innerLayerCnt to 1 rewritten in bits 1 to innerLayerCnt )
594  for( int ii = 0; ii < innerLayerCnt; ii++ )
595  {
596  if( internalMask[innerLayerCnt - ii] )
597  {
598  newMask.set( ii + In1_Cu );
599  }
600  else
601  {
602  newMask.reset( ii + In1_Cu );
603  }
604  }
605  }
606  }
607 
608  return newMask;
609 }
Class LSET is a set of PCB_LAYER_IDs.
static LSET InternalCuMask()
Function InternalCuMask() returns a complete set of internal copper layers, which is all Cu layers ex...
Definition: lset.cpp:633
int GetNetnameLayer ( int  aLayer)
inline

Returns a netname layer corresponding to the given layer.

Definition at line 774 of file layers_id_colors_and_visibility.h.

References Cmts_User, IsCopperLayer(), LAYER_PAD_BK, LAYER_PAD_BK_NETNAMES, LAYER_PAD_FR, LAYER_PAD_FR_NETNAMES, LAYER_PADS_NETNAMES, LAYER_PADS_TH, LAYER_VIA_MICROVIA, LAYER_VIA_THROUGH, LAYER_VIAS_NETNAMES, and NETNAMES_LAYER_INDEX.

Referenced by KIGFX::PCB_RENDER_SETTINGS::ImportLegacyColors(), PCB_LAYER_WIDGET::OnLayerColorChange(), PCB_DRAW_PANEL_GAL::setDefaultLayerDeps(), PCB_DRAW_PANEL_GAL::SetHighContrastLayer(), PCB_DRAW_PANEL_GAL::SetTopLayer(), and TRACK::ViewGetLayers().

775 {
776  if( IsCopperLayer( aLayer ) )
777  return NETNAMES_LAYER_INDEX( aLayer );
778  else if( aLayer == LAYER_PADS_TH )
779  return LAYER_PADS_NETNAMES;
780  else if( aLayer == LAYER_PAD_FR )
781  return LAYER_PAD_FR_NETNAMES;
782  else if( aLayer == LAYER_PAD_BK )
783  return LAYER_PAD_BK_NETNAMES;
784  else if( aLayer >= LAYER_VIA_MICROVIA && aLayer <= LAYER_VIA_THROUGH )
785  return LAYER_VIAS_NETNAMES;
786 
787  // Fallback
788  return Cmts_User;
789 }
multilayer pads, usually with holes
smd pads, back layer
to draw usual through hole vias
smd pads, front layer
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
#define NETNAMES_LAYER_INDEX(layer)
Macro for obtaining netname layer for a given PCB layer.
Additional netnames layers (not associated with a PCB layer)
bool IsBackLayer ( PCB_LAYER_ID  aLayerId)
inline
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

Definition at line 665 of file layers_id_colors_and_visibility.h.

References B_Cu, and F_Cu.

Referenced by CN_CONNECTIVITY_ALGO::Add(), PCAD2KICAD::PCB_LINE::AddToBoard(), PCAD2KICAD::PCB_PAD::AddToBoard(), PCB_EDIT_FRAME::Begin_Zone(), BOARD::BOARD(), PCB_ONE_LAYER_SELECTOR::buildList(), SELECT_COPPER_LAYERS_PAIR_DIALOG::buildList(), ZONE_CREATE_HELPER::createNewZone(), PCB_EDIT_FRAME::Delete_Drawings_All_Layer(), EDGE_MODULE::Draw(), KIGFX::PCB_PAINTER::draw(), D_PAD::Draw(), FOOTPRINT_EDIT_FRAME::Edit_Edge_Layer(), PCB_EDIT_FRAME::Edit_Zone_Params(), FlipLayer(), DSN::SPECCTRA_DB::FromBOARD(), GenCADLayerName(), DRAWING_TOOL::getDrawingLayer(), GetGerberFileFunctionAttribute(), GetGerberFilePolarityAttribute(), GetGerberProtelExtension(), BOARD_DESIGN_SETTINGS::GetLayerClass(), BOARD::GetLayerID(), BOARD::GetLayerName(), BOARD::GetLayerType(), GetNetnameLayer(), PANEL_SETUP_LAYERS::getNonRemovableLayers(), DIALOG_EXPORT_SVG::initDialog(), ZONE_CONTAINER::IsOnCopperLayer(), MARKER_PCB::IsOnLayer(), PCBNEW_CONTROL::LayerNext(), PCBNEW_CONTROL::LayerPrev(), EAGLE_PLUGIN::loadPlain(), EAGLE_PLUGIN::loadPolygon(), EAGLE_PLUGIN::loadSignals(), PCB_EDIT_FRAME::OnHotKey(), PCB_EDIT_FRAME::OnHotkeyBeginRoute(), PCB_EDIT_FRAME::OnHotkeyDeleteItem(), PCB_EDIT_FRAME::OnLeftClick(), DIALOG_PLOT::OnPopUpLayers(), PCB_LAYER_WIDGET::onPopupSelection(), PCB_EDIT_FRAME::OnRightClick(), EAGLE_PLUGIN::packageSMD(), PNS::TOOL_BASE::pickSingleItem(), PlotOneBoardLayer(), BRDITEMS_PLOTTER::PlotTextePcb(), ROUTER_TOOL::prepareInteractive(), PCB_DRAW_PANEL_GAL::setDefaultLayerDeps(), PCB_DRAW_PANEL_GAL::SetHighContrastLayer(), BOARD::SetLayerName(), BOARD::SetLayerType(), PCB_DRAW_PANEL_GAL::SetTopLayer(), ShowClearance(), PCB_BASE_FRAME::SwitchLayer(), PCB_EDIT_FRAME::SwitchLayer(), PNS_KICAD_IFACE::syncGraphicalItem(), PNS_KICAD_IFACE::syncTextItem(), DRC::testCopperTextAndGraphics(), and DIALOG_PRINT_PCBNEW::TransferDataToWindow().

666 {
667  return aLayerId >= F_Cu && aLayerId <= B_Cu;
668 }
bool IsFrontLayer ( PCB_LAYER_ID  aLayerId)
inline

Layer classification: check if it's a front layer.

Definition at line 705 of file layers_id_colors_and_visibility.h.

References F_Adhes, F_CrtYd, F_Cu, F_Fab, F_Mask, F_Paste, and F_SilkS.

Referenced by TEXTE_MODULE::Draw(), GENERAL_COLLECTOR::Inspect(), PCB_DRAW_PANEL_GAL::SetTopLayer(), TEXTE_MODULE::ViewGetLOD(), and D_PAD::ViewGetLOD().

706 {
707  switch( aLayerId )
708  {
709  case F_Cu:
710  case F_Adhes:
711  case F_Paste:
712  case F_SilkS:
713  case F_Mask:
714  case F_CrtYd:
715  case F_Fab:
716  return true;
717  default:
718  ;
719  }
720 
721  return false;
722 }
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

Definition at line 797 of file layers_id_colors_and_visibility.h.

References F_Cu, NETNAMES_LAYER_ID_END, and NETNAMES_LAYER_INDEX.

Referenced by KIGFX::PCB_PAINTER::draw(), PCB_DRAW_PANEL_GAL::setDefaultLayerDeps(), TRACK::ViewGetLOD(), VIA::ViewGetLOD(), and D_PAD::ViewGetLOD().

798 {
799  return aLayer >= NETNAMES_LAYER_INDEX( F_Cu ) &&
800  aLayer < NETNAMES_LAYER_ID_END;
801 }
#define NETNAMES_LAYER_INDEX(layer)
Macro for obtaining netname layer for a given PCB layer.
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

Definition at line 676 of file layers_id_colors_and_visibility.h.

References B_Cu, and PCB_LAYER_ID_COUNT.

Referenced by PCAD2KICAD::PCB_LINE::AddToModule(), PCAD2KICAD::PCB_ARC::AddToModule(), and PCAD2KICAD::PCB_POLYGON::AddToModule().

677 {
678  return aLayerId > B_Cu && aLayerId <= PCB_LAYER_ID_COUNT;
679 }
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

Definition at line 654 of file layers_id_colors_and_visibility.h.

References F_Cu, and PCB_LAYER_ID_COUNT.

Referenced by GBR_TO_PCB_EXPORTER::ExportPcb().

655 {
656  return aLayer >= F_Cu && aLayer < PCB_LAYER_ID_COUNT;
657 }
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

Definition at line 687 of file layers_id_colors_and_visibility.h.

References Dwgs_User, and Eco2_User.

688 {
689  return aLayerId >= Dwgs_User && aLayerId <= Eco2_User;
690 }
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

Definition at line 643 of file layers_id_colors_and_visibility.h.

References PCB_LAYER_ID_COUNT.

Referenced by LAYERS_MAP_DIALOG::OnSelectLayer().

644 {
645  return unsigned( aLayerId ) < PCB_LAYER_ID_COUNT;
646 }
GAL_LAYER_ID operator+ ( const GAL_LAYER_ID a,
int  b 
)
inline

Used for via types.

Definition at line 222 of file layers_id_colors_and_visibility.h.

References GAL_LAYER_ID_END.

Referenced by VECTOR2< unsigned int >::operator wxPoint().

223 {
224  GAL_LAYER_ID t = GAL_LAYER_ID( int( a ) + b );
225  wxASSERT( t <= GAL_LAYER_ID_END );
226  return t;
227 }
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
Add new GAL layers here.
GAL_LAYER_ID operator++ ( GAL_LAYER_ID a)
inline

Definition at line 215 of file layers_id_colors_and_visibility.h.

216 {
217  a = GAL_LAYER_ID( int( a ) + 1 );
218  return a;
219 }
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
SCH_LAYER_ID operator++ ( SCH_LAYER_ID a)
inline

Definition at line 271 of file layers_id_colors_and_visibility.h.

272 {
273  a = SCH_LAYER_ID( int( a ) + 1 );
274  return a;
275 }
SCH_LAYER_ID
Eeschema drawing layers.
PCB_LAYER_ID ToLAYER_ID ( int  aLayer)

Definition at line 810 of file lset.cpp.

References GAL_LAYER_ID_END.

Referenced by DIALOG_GLOBAL_DELETION::AcceptPcbDelete(), DXF2BRD_CONVERTER::addArc(), DXF2BRD_CONVERTER::addCircle(), PNS_KICAD_IFACE::AddItem(), DXF2BRD_CONVERTER::addLine(), DXF2BRD_CONVERTER::addMText(), DXF2BRD_CONVERTER::addText(), GRID_CELL_LAYER_SELECTOR::BeginEdit(), BOARD::BOARD(), DSN::SPECCTRA_DB::buildLayerMaps(), CINFO3D_VISU::createLayers(), PCB_BASE_FRAME::CreateNewModule(), GRID_CELL_LAYER_RENDERER::Draw(), DRAWING_TOOL::DrawVia(), GENDRILL_WRITER_BASE::GenDrillReportFile(), GetGerberFileFunctionAttribute(), BOARD::GetLayerID(), PCB_LAYER_SELECTOR::GetLayerName(), PCB_LAYER_BOX_SELECTOR::GetLayerName(), GRID_CELL_LAYER_SELECTOR::GetValue(), DXF2BRD_CONVERTER::insertArc(), DXF2BRD_CONVERTER::insertLine(), DXF2BRD_CONVERTER::insertSpline(), IsDCodeLayer(), PCB_LAYER_BOX_SELECTOR::IsLayerEnabled(), PCBNEW_CONTROL::LayerNext(), PCBNEW_CONTROL::LayerPrev(), PCAD2KICAD::PCB::MapLayer(), PCB_EDIT_FRAME::OnHotKey(), PCB_LAYER_WIDGET::OnLayerSelect(), DIALOG_KEEPOUT_AREA_PROPERTIES::OnLayerSelection(), DIALOG_NON_COPPER_ZONES_EDITOR::OnLayerSelection(), DIALOG_COPPER_ZONE::OnLayerSelection(), PCB_LAYER_WIDGET::onPopupSelection(), PLOT_CONTROLLER::OpenPlotfile(), PCB_EDIT_FRAME::Other_Layer_Route(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), PLOT_CONTROLLER::PlotLayer(), ROUTER_TOOL::prepareInteractive(), PCB_EDIT_FRAME::Process_Special_Functions(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), PCB_BASE_FRAME::SelectLayer(), DIALOG_GLOBAL_DELETION::SetCurrentLayer(), TEXT_MOD_GRID_TABLE::SetValueAsLong(), ROUTER_TOOL::switchLayerOnViaPlacement(), PCB_LAYER_WIDGET::SyncLayerAlphaIndicators(), PCB_LAYER_WIDGET::SyncLayerVisibilities(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), and DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow().

811 {
812  wxASSERT( aLayer < GAL_LAYER_ID_END );
813  return PCB_LAYER_ID( aLayer );
814 }
Add new GAL layers here.
PCB_LAYER_ID
A quick note on layer IDs: