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 )
96 case F_Cu: txt = wxT(
"F.Cu" );
break;
97 case In1_Cu: txt = wxT(
"In1.Cu" );
break;
98 case In2_Cu: txt = wxT(
"In2.Cu" );
break;
99 case In3_Cu: txt = wxT(
"In3.Cu" );
break;
100 case In4_Cu: txt = wxT(
"In4.Cu" );
break;
101 case In5_Cu: txt = wxT(
"In5.Cu" );
break;
102 case In6_Cu: txt = wxT(
"In6.Cu" );
break;
103 case In7_Cu: txt = wxT(
"In7.Cu" );
break;
104 case In8_Cu: txt = wxT(
"In8.Cu" );
break;
105 case In9_Cu: txt = wxT(
"In9.Cu" );
break;
106 case In10_Cu: txt = wxT(
"In10.Cu" );
break;
107 case In11_Cu: txt = wxT(
"In11.Cu" );
break;
108 case In12_Cu: txt = wxT(
"In12.Cu" );
break;
109 case In13_Cu: txt = wxT(
"In13.Cu" );
break;
110 case In14_Cu: txt = wxT(
"In14.Cu" );
break;
111 case In15_Cu: txt = wxT(
"In15.Cu" );
break;
112 case In16_Cu: txt = wxT(
"In16.Cu" );
break;
113 case In17_Cu: txt = wxT(
"In17.Cu" );
break;
114 case In18_Cu: txt = wxT(
"In18.Cu" );
break;
115 case In19_Cu: txt = wxT(
"In19.Cu" );
break;
116 case In20_Cu: txt = wxT(
"In20.Cu" );
break;
117 case In21_Cu: txt = wxT(
"In21.Cu" );
break;
118 case In22_Cu: txt = wxT(
"In22.Cu" );
break;
119 case In23_Cu: txt = wxT(
"In23.Cu" );
break;
120 case In24_Cu: txt = wxT(
"In24.Cu" );
break;
121 case In25_Cu: txt = wxT(
"In25.Cu" );
break;
122 case In26_Cu: txt = wxT(
"In26.Cu" );
break;
123 case In27_Cu: txt = wxT(
"In27.Cu" );
break;
124 case In28_Cu: txt = wxT(
"In28.Cu" );
break;
125 case In29_Cu: txt = wxT(
"In29.Cu" );
break;
126 case In30_Cu: txt = wxT(
"In30.Cu" );
break;
127 case B_Cu: txt = wxT(
"B.Cu" );
break;
130 case B_Adhes: txt = wxT(
"B.Adhes" );
break;
131 case F_Adhes: txt = wxT(
"F.Adhes" );
break;
132 case B_Paste: txt = wxT(
"B.Paste" );
break;
133 case F_Paste: txt = wxT(
"F.Paste" );
break;
134 case B_SilkS: txt = wxT(
"B.SilkS" );
break;
135 case F_SilkS: txt = wxT(
"F.SilkS" );
break;
136 case B_Mask: txt = wxT(
"B.Mask" );
break;
137 case F_Mask: txt = wxT(
"F.Mask" );
break;
140 case Dwgs_User: txt = wxT(
"Dwgs.User" );
break;
141 case Cmts_User: txt = wxT(
"Cmts.User" );
break;
142 case Eco1_User: txt = wxT(
"Eco1.User" );
break;
143 case Eco2_User: txt = wxT(
"Eco2.User" );
break;
144 case Edge_Cuts: txt = wxT(
"Edge.Cuts" );
break;
145 case Margin: txt = wxT(
"Margin" );
break;
148 case F_CrtYd: txt = wxT(
"F.CrtYd" );
break;
149 case B_CrtYd: txt = wxT(
"B.CrtYd" );
break;
150 case F_Fab: txt = wxT(
"F.Fab" );
break;
151 case B_Fab: txt = wxT(
"B.Fab" );
break;
154 case User_1: txt = wxT(
"User.1" );
break;
155 case User_2: txt = wxT(
"User.2" );
break;
156 case User_3: txt = wxT(
"User.3" );
break;
157 case User_4: txt = wxT(
"User.4" );
break;
158 case User_5: txt = wxT(
"User.5" );
break;
159 case User_6: txt = wxT(
"User.6" );
break;
160 case User_7: txt = wxT(
"User.7" );
break;
161 case User_8: txt = wxT(
"User.8" );
break;
162 case User_9: txt = wxT(
"User.9" );
break;
165 case Rescue: txt = wxT(
"Rescue" );
break;
168 std::cout << aLayerId << std::endl;
169 wxASSERT_MSG( 0, wxT(
"aLayerId out of range" ) );
170 txt = wxT(
"BAD INDEX!" );
break;
237 LSET subset = ~aSetToOmit & *
this;
239 return subset.
Seq( sequence,
arrayDim( sequence ) );
308 int bit_count = size();
310 for(
int bit=0; bit<bit_count; ++bit )
316 else if( !( bit % 4 ) )
320 ret += (*this)[bit] ?
'1' :
'0';
324 return std::string( ret.rbegin(), ret.rend() );
332 static const char hex[] =
"0123456789abcdef";
334 size_t nibble_count = ( size() + 3 ) / 4;
336 for(
size_t nibble = 0; nibble < nibble_count; ++nibble )
338 unsigned int ndx = 0;
341 for(
size_t nibble_bit = 0; nibble_bit < 4; ++nibble_bit )
343 size_t nibble_pos = nibble_bit + ( nibble * 4 );
346 if( nibble_pos >= size() )
349 if( ( *
this )[nibble_pos] )
350 ndx |= ( 1 << nibble_bit );
353 if( nibble && !( nibble % 8 ) )
362 return std::string( ret.rbegin(), ret.rend() );
370 const char* rstart = aStart + aCount - 1;
371 const char* rend = aStart - 1;
373 const int bitcount = size();
377 while( rstart > rend )
386 if( cc >=
'0' && cc <=
'9' )
388 else if( cc >=
'a' && cc <=
'f' )
389 nibble = cc -
'a' + 10;
390 else if( cc >=
'A' && cc <=
'F' )
391 nibble = cc -
'A' + 10;
395 int bit = nibble_ndx * 4;
397 for(
int ndx=0; bit<bitcount && ndx<4; ++bit, ++ndx )
398 if( nibble & (1<<ndx) )
401 if( bit >= bitcount )
407 int byte_count = aStart + aCount - 1 - rstart;
409 assert( byte_count >= 0 );
422#if defined(DEBUG) && 0
425 for(
unsigned i=0; i<aCount; ++i )
431 wxASSERT_MSG( !dup_detector[
id], wxT(
"Duplicate in aWishListSequence" ) );
432 dup_detector[id] =
true;
439 for(
unsigned i=0; i<aCount; ++i )
456 for(
LSEQ seq = aSequence; seq; ++seq )
459 ret.push_back( *seq );
470 ret.reserve( size() );
472 for(
unsigned i = 0; i < size(); ++i )
584 if( fliplayer <
F_Cu )
587 if( fliplayer >
B_Cu )
602 const static LSET and_mask( 16,
613 LSET newMask = aMask & ~and_mask;
658 newMask.set(
F_Fab );
661 newMask.set(
B_Fab );
663 if( aCopperLayersCount >= 4 )
671 int innerLayerCnt = aCopperLayersCount -2;
675 for(
int ii = 0; ii < innerLayerCnt; ii++ )
677 if( internalMask[innerLayerCnt - ii] )
679 newMask.set( ii +
In1_Cu );
683 newMask.reset( ii +
In1_Cu );
695 unsigned set_count = count();
699 else if( set_count > 1 )
702 for(
unsigned i=0; i < size(); ++i )
723 static const LSET saved( front_assembly,
arrayDim( front_assembly ) );
737 static const LSET saved( back_assembly,
arrayDim( back_assembly ) );
777 static const LSET saved( cu_internals,
arrayDim( cu_internals ) );
796 for(
int elem =
In30_Cu; clear_count; --elem, --clear_count )
797 ret.set( elem,
false );
805 static const LSET saved =
LSET().set() & ~AllCuMask();
819 static const LSET saved =
LSET().set();
866 static const LSET saved( 6,
888 static const LSET saved( 9,
935 order.insert( order.end(), techuser.begin(), techuser.end() );
950 for(
unsigned i = 0; i < aCount; ++i )
957 std::vector<GAL_LAYER_ID> ret;
959 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_FOOTPRINTS_FR
show footprints on front
@ LAYER_NON_PLATEDHOLES
handle color for not plated holes (holes, not pads)
@ LAYER_DRAWINGSHEET
drawingsheet frame and titleblock
@ LAYER_DRAW_BITMAPS
to handle and draw images bitmaps
@ LAYER_FP_REFERENCES
show footprints references (when texts are visible)
@ 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_FOOTPRINTS_BK
show footprints on back
@ LAYER_ANCHOR
anchor of items having an anchor point (texts, footprints)
@ LAYER_PADS_SMD_BK
smd pads, back layer
@ LAYER_PADS_TH
multilayer pads, usually with holes
@ LAYER_PADS_SMD_FR
smd pads, front layer
@ LAYER_VIA_HOLES
to draw via holes (pad holes do not use this layer)
@ LAYER_FP_VALUES
show footprints values (when texts are visible)
@ 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_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.