42 for(
unsigned i=0; i<aCount; ++i )
53 wxASSERT_MSG( aIdCount > 0, wxT(
"aIdCount must be >= 1" ) );
61 va_start( ap, aFirst );
63 for(
unsigned i=0; i<aIdCount; ++i )
89 case F_Cu: txt = wxT(
"F.Cu" );
break;
90 case In1_Cu: txt = wxT(
"In1.Cu" );
break;
91 case In2_Cu: txt = wxT(
"In2.Cu" );
break;
92 case In3_Cu: txt = wxT(
"In3.Cu" );
break;
93 case In4_Cu: txt = wxT(
"In4.Cu" );
break;
94 case In5_Cu: txt = wxT(
"In5.Cu" );
break;
95 case In6_Cu: txt = wxT(
"In6.Cu" );
break;
96 case In7_Cu: txt = wxT(
"In7.Cu" );
break;
97 case In8_Cu: txt = wxT(
"In8.Cu" );
break;
98 case In9_Cu: txt = wxT(
"In9.Cu" );
break;
99 case In10_Cu: txt = wxT(
"In10.Cu" );
break;
100 case In11_Cu: txt = wxT(
"In11.Cu" );
break;
101 case In12_Cu: txt = wxT(
"In12.Cu" );
break;
102 case In13_Cu: txt = wxT(
"In13.Cu" );
break;
103 case In14_Cu: txt = wxT(
"In14.Cu" );
break;
104 case In15_Cu: txt = wxT(
"In15.Cu" );
break;
105 case In16_Cu: txt = wxT(
"In16.Cu" );
break;
106 case In17_Cu: txt = wxT(
"In17.Cu" );
break;
107 case In18_Cu: txt = wxT(
"In18.Cu" );
break;
108 case In19_Cu: txt = wxT(
"In19.Cu" );
break;
109 case In20_Cu: txt = wxT(
"In20.Cu" );
break;
110 case In21_Cu: txt = wxT(
"In21.Cu" );
break;
111 case In22_Cu: txt = wxT(
"In22.Cu" );
break;
112 case In23_Cu: txt = wxT(
"In23.Cu" );
break;
113 case In24_Cu: txt = wxT(
"In24.Cu" );
break;
114 case In25_Cu: txt = wxT(
"In25.Cu" );
break;
115 case In26_Cu: txt = wxT(
"In26.Cu" );
break;
116 case In27_Cu: txt = wxT(
"In27.Cu" );
break;
117 case In28_Cu: txt = wxT(
"In28.Cu" );
break;
118 case In29_Cu: txt = wxT(
"In29.Cu" );
break;
119 case In30_Cu: txt = wxT(
"In30.Cu" );
break;
120 case B_Cu: txt = wxT(
"B.Cu" );
break;
123 case B_Adhes: txt = wxT(
"B.Adhes" );
break;
124 case F_Adhes: txt = wxT(
"F.Adhes" );
break;
125 case B_Paste: txt = wxT(
"B.Paste" );
break;
126 case F_Paste: txt = wxT(
"F.Paste" );
break;
127 case B_SilkS: txt = wxT(
"B.SilkS" );
break;
128 case F_SilkS: txt = wxT(
"F.SilkS" );
break;
129 case B_Mask: txt = wxT(
"B.Mask" );
break;
130 case F_Mask: txt = wxT(
"F.Mask" );
break;
133 case Dwgs_User: txt = wxT(
"Dwgs.User" );
break;
134 case Cmts_User: txt = wxT(
"Cmts.User" );
break;
135 case Eco1_User: txt = wxT(
"Eco1.User" );
break;
136 case Eco2_User: txt = wxT(
"Eco2.User" );
break;
137 case Edge_Cuts: txt = wxT(
"Edge.Cuts" );
break;
138 case Margin: txt = wxT(
"Margin" );
break;
141 case F_CrtYd: txt = wxT(
"F.CrtYd" );
break;
142 case B_CrtYd: txt = wxT(
"B.CrtYd" );
break;
143 case F_Fab: txt = wxT(
"F.Fab" );
break;
144 case B_Fab: txt = wxT(
"B.Fab" );
break;
147 case User_1: txt = wxT(
"User.1" );
break;
148 case User_2: txt = wxT(
"User.2" );
break;
149 case User_3: txt = wxT(
"User.3" );
break;
150 case User_4: txt = wxT(
"User.4" );
break;
151 case User_5: txt = wxT(
"User.5" );
break;
152 case User_6: txt = wxT(
"User.6" );
break;
153 case User_7: txt = wxT(
"User.7" );
break;
154 case User_8: txt = wxT(
"User.8" );
break;
155 case User_9: txt = wxT(
"User.9" );
break;
158 case Rescue: txt = wxT(
"Rescue" );
break;
161 std::cout << aLayerId << std::endl;
162 wxASSERT_MSG( 0, wxT(
"aLayerId out of range" ) );
163 txt = wxT(
"BAD INDEX!" );
break;
230 LSET subset = ~aSetToOmit & *
this;
232 return subset.
Seq( sequence,
arrayDim( sequence ) );
301 int bit_count = size();
303 for(
int bit=0; bit<bit_count; ++bit )
309 else if( !( bit % 4 ) )
313 ret += (*this)[bit] ?
'1' :
'0';
317 return std::string( ret.rbegin(), ret.rend() );
325 static const char hex[] =
"0123456789abcdef";
327 size_t nibble_count = ( size() + 3 ) / 4;
329 for(
size_t nibble = 0; nibble < nibble_count; ++nibble )
331 unsigned int ndx = 0;
334 for(
size_t nibble_bit = 0; nibble_bit < 4; ++nibble_bit )
336 size_t nibble_pos = nibble_bit + ( nibble * 4 );
339 if( nibble_pos >= size() )
342 if( ( *
this )[nibble_pos] )
343 ndx |= ( 1 << nibble_bit );
346 if( nibble && !( nibble % 8 ) )
355 return std::string( ret.rbegin(), ret.rend() );
363 const char* rstart = aStart + aCount - 1;
364 const char* rend = aStart - 1;
366 const int bitcount = size();
370 while( rstart > rend )
379 if( cc >=
'0' && cc <=
'9' )
381 else if( cc >=
'a' && cc <=
'f' )
382 nibble = cc -
'a' + 10;
383 else if( cc >=
'A' && cc <=
'F' )
384 nibble = cc -
'A' + 10;
388 int bit = nibble_ndx * 4;
390 for(
int ndx=0; bit<bitcount && ndx<4; ++bit, ++ndx )
391 if( nibble & (1<<ndx) )
394 if( bit >= bitcount )
400 int byte_count = aStart + aCount - 1 - rstart;
402 assert( byte_count >= 0 );
415#if defined(DEBUG) && 0
418 for(
unsigned i=0; i<aCount; ++i )
424 wxASSERT_MSG( !dup_detector[
id], wxT(
"Duplicate in aWishListSequence" ) );
425 dup_detector[id] =
true;
432 for(
unsigned i=0; i<aCount; ++i )
449 for(
LSEQ seq = aSequence; seq; ++seq )
452 ret.push_back( *seq );
463 ret.reserve( size() );
465 for(
unsigned i = 0; i < size(); ++i )
575 if( fliplayer <
F_Cu )
578 if( fliplayer >
B_Cu )
593 const static LSET and_mask( 16,
604 LSET newMask = aMask & ~and_mask;
649 newMask.set(
F_Fab );
652 newMask.set(
B_Fab );
654 if( aCopperLayersCount >= 4 )
662 int innerLayerCnt = aCopperLayersCount -2;
666 for(
int ii = 0; ii < innerLayerCnt; ii++ )
668 if( internalMask[innerLayerCnt - ii] )
670 newMask.set( ii +
In1_Cu );
674 newMask.reset( ii +
In1_Cu );
686 unsigned set_count = count();
690 else if( set_count > 1 )
693 for(
unsigned i=0; i < size(); ++i )
714 static const LSET saved( front_assembly,
arrayDim( front_assembly ) );
728 static const LSET saved( back_assembly,
arrayDim( back_assembly ) );
768 static const LSET saved( cu_internals,
arrayDim( cu_internals ) );
787 for(
int elem =
In30_Cu; clear_count; --elem, --clear_count )
788 ret.set( elem,
false );
796 static const LSET saved =
LSET().set() & ~AllCuMask();
810 static const LSET saved =
LSET().set();
857 static const LSET saved( 6,
879 static const LSET saved( 9,
926 order.insert( order.end(), techuser.begin(), techuser.end() );
941 for(
unsigned i = 0; i < aCount; ++i )
948 std::vector<GAL_LAYER_ID> ret;
950 for(
size_t i = 0; i < size(); ++i )
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Helper for storing and iterating over GAL_LAYER_IDs.
static GAL_SET DefaultVisible()
std::vector< GAL_LAYER_ID > Seq() const
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
LSET is a set of PCB_LAYER_IDs.
static LSET ExternalCuMask()
Return a mask holding the Front and Bottom layers.
int ParseHex(const char *aStart, int aCount)
Convert the output of FmtHex() and replaces this set's values with those given in the input string.
static LSET AllBoardTechMask()
Return a mask holding board technical layers (no CU layer) on both side.
static LSET AllLayersMask()
static LSET UserDefinedLayers()
Return a mask with all of the allowable user defined layers.
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
LSEQ CuStack() const
Return a sequence of copper layers in starting from the front/top and extending to the back/bottom.
PCB_LAYER_ID ExtractLayer() const
Find the first set PCB_LAYER_ID.
static LSET FrontBoardTechMask()
Return a mask holding technical layers used in a board fabrication (no CU layer) on front side.
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
LSEQ SeqStackupBottom2Top() const
Return the sequence that is typical for a bottom-to-top stack-up.
static LSET FrontAssembly()
Return a complete set of all top assembly layers which is all F_SilkS and F_Mask.
LSEQ TechAndUserUIOrder() const
Returns the technical and user layers in the order shown in layer widget.
static LSET AllTechMask()
Return a mask holding all technical layers (no CU layer) on both side.
static LSET InternalCuMask()
Return a complete set of internal copper layers which is all Cu layers except F_Cu and B_Cu.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static LSET SideSpecificMask()
static LSET PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
LSEQ Seq() const
Return a LSEQ from this LSET in ascending PCB_LAYER_ID order.
std::string FmtHex() const
Return a hex string showing contents of this LSEQ.
static LSET ForbiddenFootprintLayers()
Layers which are not allowed within footprint definitions.
LSEQ Technicals(LSET aSubToOmit=LSET()) const
Return a sequence of technical layers.
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
std::string FmtBin() const
Return a binary string showing contents of this LSEQ.
static LSET FrontTechMask()
Return a mask holding all technical layers (no CU layer) on front side.
static LSET BackBoardTechMask()
Return a mask holding technical layers used in a board fabrication (no CU layer) on Back side.
LSEQ Users() const
*_User layers.
static LSET BackTechMask()
Return a mask holding all technical layers (no CU layer) on back side.
static LSET BackAssembly()
Return a complete set of all bottom assembly layers which is all B_SilkS and B_Mask.
static LSET FrontMask()
Return a mask holding all technical layers and the external CU layer on front side.
static LSET BackMask()
Return a mask holding all technical layers and the external CU layer on back side.
LSET()
Create an empty (cleared) set.
std::bitset< PCB_LAYER_ID_COUNT > BASE_SET
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
@ LAYER_LOCKED_ITEM_SHADOW
shadow layer for locked items
@ LAYER_CONFLICTS_SHADOW
shadow layer for items flagged conficting
@ LAYER_NON_PLATEDHOLES
handle color for not plated holes (holes, not pads)
@ LAYER_PAD_FR
smd pads, front layer
@ LAYER_DRAWINGSHEET
drawingsheet frame and titleblock
@ LAYER_DRAW_BITMAPS
to handle and draw images bitmaps
@ LAYER_PCB_BACKGROUND
PCB background color.
@ LAYER_ZONES
Control for copper zone opacity/visibility (color ignored)
@ LAYER_PADS
Meta control for all pads opacity/visibility (color ignored)
@ LAYER_DRC_WARNING
layer for drc markers with SEVERITY_WARNING
@ LAYER_PAD_PLATEDHOLES
to draw pad holes (plated)
@ LAYER_GP_OVERLAY
general purpose overlay
@ LAYER_CURSOR
PCB cursor.
@ LAYER_AUX_ITEMS
Auxiliary items (guides, rule, etc)
@ LAYER_MOD_FR
show footprints on front
@ LAYER_ANCHOR
anchor of items having an anchor point (texts, footprints)
@ LAYER_PAD_BK
smd pads, back layer
@ LAYER_MOD_VALUES
show footprints values (when texts are visible)
@ LAYER_PADS_TH
multilayer pads, usually with holes
@ LAYER_VIA_HOLES
to draw via holes (pad holes do not use this layer)
@ LAYER_VIA_MICROVIA
to draw micro vias
@ LAYER_SELECT_OVERLAY
currently selected items overlay
@ LAYER_VIA_THROUGH
to draw usual through hole vias
@ LAYER_DRC_ERROR
layer for drc markers with SEVERITY_ERROR
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
@ LAYER_MOD_BK
show footprints on back
@ LAYER_MOD_REFERENCES
show footprints references (when texts are visible)
@ LAYER_VIA_BBLIND
to draw blind/buried vias
PCB_LAYER_ID
A quick note on layer IDs:
LSET FlipLayerMask(LSET aMask, int aCopperLayersCount)
Calculate the mask layer when flipping a footprint.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
This file contains miscellaneous commonly used macros and functions.
constexpr T Clamp(const T &lower, const T &value, const T &upper)
Limit value within the range lower <= value <= upper.