95 std::swap( start,
end );
103 return aCopperLayerCount;
105 return (
end - start ) / 2 - 1;
107 else if ( aEnd ==
B_Cu )
110 return aCopperLayerCount - start / 2 + 1;
113 return (
end - start ) / 2;
119 std::map<wxString, PCB_LAYER_ID> layerMap = {
144 if(
auto it = layerMap.find( aName ); it != layerMap.end() )
145 return static_cast<int>( it->second );
147 if( aName.StartsWith(
"User." ) )
151 if( aName.Mid( 5 ).ToLong( &offset ) && offset > 0 )
152 return static_cast<int>(
User_1 ) + ( offset - 1 ) * 2;
155 if( aName.StartsWith(
"In" ) )
158 wxString str_num = aName.Mid( 2 );
159 str_num.RemoveLast( 3 );
161 if( str_num.ToLong( &offset ) && offset > 0 )
162 return static_cast<int>(
In1_Cu ) + ( offset - 1 ) * 2;
171 if( aLayer == aStart || aLayer == aEnd )
174 int start = std::min( aStart, aEnd );
175 int end = std::max( aStart, aEnd );
181 end = std::numeric_limits<PCB_LAYER_ID>::max() & ~1;
184 return !( layer & 1 ) && ( layer >= start ) && ( layer <=
end );
195 case F_Cu: txt = wxT(
"F.Cu" );
break;
196 case B_Cu: txt = wxT(
"B.Cu" );
break;
199 case B_Adhes: txt = wxT(
"B.Adhes" );
break;
200 case F_Adhes: txt = wxT(
"F.Adhes" );
break;
201 case B_Paste: txt = wxT(
"B.Paste" );
break;
202 case F_Paste: txt = wxT(
"F.Paste" );
break;
203 case B_SilkS: txt = wxT(
"B.SilkS" );
break;
204 case F_SilkS: txt = wxT(
"F.SilkS" );
break;
205 case B_Mask: txt = wxT(
"B.Mask" );
break;
206 case F_Mask: txt = wxT(
"F.Mask" );
break;
209 case Dwgs_User: txt = wxT(
"Dwgs.User" );
break;
210 case Cmts_User: txt = wxT(
"Cmts.User" );
break;
211 case Eco1_User: txt = wxT(
"Eco1.User" );
break;
212 case Eco2_User: txt = wxT(
"Eco2.User" );
break;
213 case Edge_Cuts: txt = wxT(
"Edge.Cuts" );
break;
214 case Margin: txt = wxT(
"Margin" );
break;
217 case F_CrtYd: txt = wxT(
"F.CrtYd" );
break;
218 case B_CrtYd: txt = wxT(
"B.CrtYd" );
break;
219 case F_Fab: txt = wxT(
"F.Fab" );
break;
220 case B_Fab: txt = wxT(
"B.Fab" );
break;
223 case Rescue: txt = wxT(
"Rescue" );
break;
227 if(
static_cast<int>( aLayerId ) & 1 )
229 int offset = ( aLayerId -
Rescue ) / 2;
230 txt = wxString::Format( wxT(
"User.%d" ), offset );
234 int offset = ( aLayerId -
B_Cu ) / 2;
235 txt = wxString::Format( wxT(
"In%d.Cu" ), offset );
252 ret.push_back( *it );
288 ret.push_back( *it );
302 ret.push_back( layer );
313 ret.reserve( size() );
315 for(
unsigned i = 0; i < size(); ++i )
336 LSEQ top_tech_sequence =
Seq( {
345 LSEQ bottom_tech_sequence =
Seq( {
355 LSEQ seq =
Seq( base_sequence );
360 seq.push_back( *it );
363 std::copy( top_tech_sequence.begin(), top_tech_sequence.end(), std::back_inserter( seq ) );
366 seq.push_back( *it );
368 std::copy( bottom_tech_sequence.begin(), bottom_tech_sequence.end(),
369 std::back_inserter( seq ) );
373 auto it = std::find( seq.begin(), seq.end(), aSelectedLayer );
375 if( it != seq.end() )
378 seq.insert( seq.begin(), aSelectedLayer );
391 LSEQ bottom_tech_sequence =
Seq( {
403 LSEQ top_tech_sequence =
Seq( {
428 LSEQ seq =
Seq( bottom_tech_sequence );
430 std::vector<PCB_LAYER_ID> temp_layers;
438 temp_layers.push_back( *it );
441 for(
auto it = temp_layers.rbegin(); it != temp_layers.rend(); ++it )
442 seq.push_back( *it );
444 std::copy( top_tech_sequence.begin(), top_tech_sequence.end(), std::back_inserter( seq ) );
446 std::copy( user_sequence.begin(), user_sequence.end(), std::back_inserter( seq ) );
453 temp_layers.push_back( *it );
456 for(
auto it = temp_layers.rbegin(); it != temp_layers.rend(); ++it )
458 seq.push_back( *it );
461 std::copy( base_sequence.begin(), base_sequence.end(), std::back_inserter( seq ) );
469 LSET oldMask = *
this;
474 const std::map<PCB_LAYER_ID, PCB_LAYER_ID> flip_map =
492 for(
const auto& pair : flip_map )
494 if( oldMask.test( pair.first ) )
498 if( aCopperLayersCount >= 4 )
501 int innerLayerCount = aCopperLayersCount - 2;
503 for(
int ii = 1; ii <= innerLayerCount; ii++ )
505 if( internalMask.test( ( innerLayerCount - ii + 1 ) * 2 +
B_Cu ) )
518 unsigned set_count = count();
522 else if( set_count > 1 )
525 for(
unsigned i=0; i < size(); ++i )
575 static const LSET saved =
LSET().set() & ~AllCuMask();
589 static const LSET saved =
LSET().set();
653 static const LSET saved(
693 order.insert( order.end(), techuser.begin(), techuser.end() );
702 if( aLayer == std::numeric_limits<int>::max() )
712 for(
unsigned i = 0; i < aCount; ++i )
719 std::vector<GAL_LAYER_ID> ret;
721 for(
size_t i = 0; i < size(); ++i )
798 advance_to_next_set_copper_bit();
805 if( m_index ==
F_Cu )
809 else if( m_index ==
B_Cu )
811 m_index = m_baseSet.size();
818 if( m_index >= m_baseSet.size() )
826 while( m_index < m_baseSet.size() && !m_baseSet.test( m_index ) )
847 advance_to_next_set_non_copper_bit();
854 while( m_index < m_baseSet.size() && ( m_index % 2 != 1 || !m_baseSet.test( m_index ) ) )
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
BASE_SET & set(size_t pos)
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.
copper_layers_iterator & operator++()
PCB_LAYER_ID operator*() const
void advance_to_next_set_copper_bit()
copper_layers_iterator(const BASE_SET &set, size_t index)
void advance_to_next_set_non_copper_bit()
PCB_LAYER_ID operator*() const
non_copper_layers_iterator & operator++()
non_copper_layers_iterator(const BASE_SET &set, size_t index)
LSET is a set of PCB_LAYER_IDs.
LSET & Flip(int aCopperLayersCount=0)
Flip the layers in this set.
static LSET ExternalCuMask()
Return a mask holding the Front and Bottom layers.
static bool IsBetween(PCB_LAYER_ID aStart, PCB_LAYER_ID aEnd, PCB_LAYER_ID aLayer)
Return true if aLayer is between aStart and aEnd, inclusive.
copper_layers_iterator copper_layers_end() const
LSEQ UIOrder() const
Return the copper, technical and user layers in the order shown in layer widget.
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 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.
LSEQ SeqStackupForPlotting() const
Return the sequence that is typical for a bottom-to-top stack-up.
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.
static LSET FrontAssembly()
Return a complete set of all top assembly layers which is all F_SilkS and F_Mask.
LSEQ TechAndUserUIOrder() const
Return 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.
all_set_layers_iterator end() const
LSEQ Seq() const
Return a LSEQ from this LSET in ascending PCB_LAYER_ID order.
copper_layers_iterator copper_layers_begin() const
non_copper_layers_iterator non_copper_layers_begin() const
static int NameToLayer(wxString &aName)
Return the layer number from a layer name.
static LSET ForbiddenFootprintLayers()
Layers which are not allowed within footprint definitions.
LSEQ SeqStackupTop2Bottom(PCB_LAYER_ID aSelectedLayer=UNDEFINED_LAYER) const
Generate a sequence of layers that represent a top to bottom stack of this set of layers.
non_copper_layers_iterator non_copper_layers_end() const
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.
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.
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
LSET()
Create an empty (cleared) set.
static int LayerCount(PCB_LAYER_ID aStart, PCB_LAYER_ID aEnd, int aCopperLayerCount)
Return the number of layers between aStart and aEnd, inclusive.
bool IsCopperLayer(int aLayerId)
Test 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 conflicting.
@ LAYER_FOOTPRINTS_FR
Show footprints on front.
@ LAYER_DRC_SHAPE1
Custom shape for DRC marker.
@ LAYER_NON_PLATEDHOLES
Draw usual through hole vias.
@ LAYER_DRAWINGSHEET
Sheet frame and title block.
@ LAYER_DRAW_BITMAPS
Draw images.
@ 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_SHAPES
Copper graphic shape 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_DRC_SHAPE2
Custom shape for DRC marker.
@ LAYER_FOOTPRINTS_BK
Show footprints on back.
@ LAYER_ANCHOR
Anchor of items having an anchor point (texts, footprints).
@ LAYER_VIA_HOLES
Draw via holes (pad holes do not use this layer).
@ LAYER_FP_VALUES
Show footprints values (when texts are visible).
@ LAYER_SELECT_OVERLAY
Selected items overlay.
@ LAYER_VIA_THROUGH
Draw blind/buried vias.
@ LAYER_DRC_ERROR
Layer for DRC markers with #SEVERITY_ERROR.
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
@ LAYER_VIA_BBLIND
Draw micro vias.
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID ToLAYER_ID(int aLayer)
This file contains miscellaneous commonly used macros and functions.