KiCad PCB EDA Suite
Loading...
Searching...
No Matches
lset.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
5 * Copyright (C) 2014-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <algorithm>
26#include <bitset> // for bitset, __bitset<>::ref...
27#include <cassert>
28#include <cstdarg>
29#include <iostream> // for string, endl, basic_ost...
30#include <cstddef> // for size_t
31#include <map>
32
33#include <core/arraydim.h>
34#include <layer_ids.h> // for PCB_LAYER_ID
35#include <layer_range.h>
36#include <lseq.h>
37#include <macros.h> // for arrayDim
38#include <wx/debug.h> // for wxASSERT, wxASSERT_MSG
39#include <wx/string.h>
40
41#include <lset.h>
42
43
44LSET::LSET( std::initializer_list<PCB_LAYER_ID> aList ) :
45 LSET()
46{
47 for( PCB_LAYER_ID layer : aList )
48 {
49 if( layer >= 0 )
50 set( layer );
51 }
52}
53
54LSET::LSET( const std::vector<PCB_LAYER_ID>& aList ) :
55 LSET()
56{
57 for( PCB_LAYER_ID layer : aList )
58 {
59 if( layer >= 0 )
60 set( layer );
61 }
62}
63
64
65LSET::LSET( const LSEQ& aSeq ) :
66 LSET()
67{
68 for( PCB_LAYER_ID layer : aSeq )
69 {
70 if( layer >= 0 )
71 set( layer );
72 }
73}
74
75
76LSET::LSET( const LAYER_RANGE& aRange )
77{
78 for( PCB_LAYER_ID layer : aRange )
79 {
80 if( layer >= 0 )
81 set( layer );
82 }
83}
84
85
86int LSET::LayerCount( PCB_LAYER_ID aStart, PCB_LAYER_ID aEnd, int aCopperLayerCount )
87{
88 int start = aStart;
89 int end = aEnd;
90
91 // Both layers need to be copper
92 wxCHECK( IsCopperLayer( aStart ) && IsCopperLayer( aEnd ), aCopperLayerCount );
93
94 if( aStart == B_Cu )
95 std::swap( start, end );
96
97 if( aStart == aEnd )
98 return 1;
99
100 if( aStart == F_Cu )
101 {
102 if ( aEnd == B_Cu )
103 return aCopperLayerCount;
104 else
105 return ( end - start ) / 2 - 1;
106 }
107 else if ( aEnd == B_Cu )
108 {
109 // Add 1 for the B_Cu layer
110 return aCopperLayerCount - start / 2 + 1;
111 }
112
113 return ( end - start ) / 2;
114}
115
116
117int LSET::NameToLayer( wxString& aName )
118{
119 std::map<wxString, PCB_LAYER_ID> layerMap = {
120 { "F.Cu", F_Cu },
121 { "B.Cu", B_Cu },
122 { "F.Adhes", F_Adhes },
123 { "B.Adhes", B_Adhes },
124 { "F.Paste", F_Paste },
125 { "B.Paste", B_Paste },
126 { "F.SilkS", F_SilkS },
127 { "B.SilkS", B_SilkS },
128 { "F.Mask", F_Mask },
129 { "B.Mask", B_Mask },
130 { "Dwgs.User", Dwgs_User },
131 { "Cmts.User", Cmts_User },
132 { "Eco1.User", Eco1_User },
133 { "Eco2.User", Eco2_User },
134 { "Edge.Cuts", Edge_Cuts },
135 { "Margin", Margin },
136 { "F.CrtYd", F_CrtYd },
137 { "B.CrtYd", B_CrtYd },
138 { "F.Fab", F_Fab },
139 { "B.Fab", B_Fab },
140 { "Rescue", Rescue },
141 { "B.Cu", B_Cu },
142 };
143
144 if( auto it = layerMap.find( aName ); it != layerMap.end() )
145 return static_cast<int>( it->second );
146
147 if( aName.StartsWith( "User." ) )
148 {
149 long offset;
150
151 if( aName.Mid( 5 ).ToLong( &offset ) && offset > 0 )
152 return static_cast<int>( User_1 ) + ( offset - 1 ) * 2;
153 }
154
155 if( aName.StartsWith( "In" ) )
156 {
157 long offset;
158 wxString str_num = aName.Mid( 2 );
159 str_num.RemoveLast( 3 ); // Removes .Cu
160
161 if( str_num.ToLong( &offset ) && offset > 0 )
162 return static_cast<int>( In1_Cu ) + ( offset - 1 ) * 2;
163 }
164
165 return -1;
166}
167
168
170{
171 if( aLayer == aStart || aLayer == aEnd )
172 return true;
173
174 int start = std::min( aStart, aEnd );
175 int end = std::max( aStart, aEnd );
176 int layer = aLayer;
177
178 if( end == B_Cu )
179 {
180 //Reassign the end layer to the largest possible positive even number
181 end = std::numeric_limits<PCB_LAYER_ID>::max() & ~1;
182 }
183
184 return !( layer & 1 ) && ( layer >= start ) && ( layer <= end );
185}
186
187
193wxString LSET::Name( PCB_LAYER_ID aLayerId )
194{
195 wxString txt;
196
197 // using a switch to explicitly show the mapping more clearly
198 switch( aLayerId )
199 {
200 case F_Cu: txt = wxT( "F.Cu" ); break;
201 case B_Cu: txt = wxT( "B.Cu" ); break;
202
203 // Technicals
204 case B_Adhes: txt = wxT( "B.Adhes" ); break;
205 case F_Adhes: txt = wxT( "F.Adhes" ); break;
206 case B_Paste: txt = wxT( "B.Paste" ); break;
207 case F_Paste: txt = wxT( "F.Paste" ); break;
208 case B_SilkS: txt = wxT( "B.SilkS" ); break;
209 case F_SilkS: txt = wxT( "F.SilkS" ); break;
210 case B_Mask: txt = wxT( "B.Mask" ); break;
211 case F_Mask: txt = wxT( "F.Mask" ); break;
212
213 // Users
214 case Dwgs_User: txt = wxT( "Dwgs.User" ); break;
215 case Cmts_User: txt = wxT( "Cmts.User" ); break;
216 case Eco1_User: txt = wxT( "Eco1.User" ); break;
217 case Eco2_User: txt = wxT( "Eco2.User" ); break;
218 case Edge_Cuts: txt = wxT( "Edge.Cuts" ); break;
219 case Margin: txt = wxT( "Margin" ); break;
220
221 // Footprint
222 case F_CrtYd: txt = wxT( "F.CrtYd" ); break;
223 case B_CrtYd: txt = wxT( "B.CrtYd" ); break;
224 case F_Fab: txt = wxT( "F.Fab" ); break;
225 case B_Fab: txt = wxT( "B.Fab" ); break;
226
227 // Rescue
228 case Rescue: txt = wxT( "Rescue" ); break;
229
230 default:
231
232 if( static_cast<int>( aLayerId ) & 1 )
233 {
234 int offset = ( aLayerId - Rescue ) / 2;
235 txt = wxString::Format( wxT( "User.%d" ), offset );
236 }
237 else
238 {
239 int offset = ( aLayerId - B_Cu ) / 2;
240 txt = wxString::Format( wxT( "In%d.Cu" ), offset );
241 }
242
243
244 }
245
246 return txt;
247}
248
249
251{
252 LSEQ ret;
253
254 ret.reserve( 32 );
255
256 for( auto it = copper_layers_begin(); it != copper_layers_end(); ++it )
257 ret.push_back( *it );
258
259 return ret;
260}
261
262
264{
265 LSEQ ret;
266
267 ret.reserve( 32 );
268
269 ret = Seq( {
270 F_Adhes,
271 B_Adhes,
272 F_Paste,
273 B_Paste,
274 F_SilkS,
275 B_SilkS,
276 F_Mask,
277 B_Mask,
278 Dwgs_User,
279 Cmts_User,
280 Eco1_User,
281 Eco2_User,
282 Edge_Cuts,
283 Margin,
284 F_CrtYd,
285 B_CrtYd,
286 F_Fab,
287 B_Fab
288 } );
289
290 for( auto it = non_copper_layers_begin(); it != non_copper_layers_end(); ++it )
291 {
292 if( *it >= User_1 )
293 ret.push_back( *it );
294 }
295
296 return ret;
297}
298
299
300std::string LSET::FmtBin() const
301{
302 std::string ret;
303
304 int bit_count = size();
305
306 for( int bit=0; bit<bit_count; ++bit )
307 {
308 if( bit )
309 {
310 if( !( bit % 8 ) )
311 ret += '|';
312 else if( !( bit % 4 ) )
313 ret += '_';
314 }
315
316 ret += (*this)[bit] ? '1' : '0';
317 }
318
319 // reverse of string
320 return std::string( ret.rbegin(), ret.rend() );
321}
322
323
324std::string LSET::FmtHex() const
325{
326 std::string ret;
327
328 static const char hex[] = "0123456789abcdef";
329
330 size_t nibble_count = ( size() + 3 ) / 4;
331
332 for( size_t nibble = 0; nibble < nibble_count; ++nibble )
333 {
334 unsigned int ndx = 0;
335
336 // test 4 consecutive bits and set ndx to 0-15
337 for( size_t nibble_bit = 0; nibble_bit < 4; ++nibble_bit )
338 {
339 size_t nibble_pos = nibble_bit + ( nibble * 4 );
340 // make sure it's not extra bits that don't exist in the bitset but need to in the
341 // hex format
342 if( nibble_pos >= size() )
343 break;
344
345 if( ( *this )[nibble_pos] )
346 ndx |= ( 1 << nibble_bit );
347 }
348
349 if( nibble && !( nibble % 8 ) )
350 ret += '_';
351
352 assert( ndx < arrayDim( hex ) );
353
354 ret += hex[ndx];
355 }
356
357 // reverse of string
358 return std::string( ret.rbegin(), ret.rend() );
359}
360
361
362int LSET::ParseHex( const std::string& str )
363{
364 return ParseHex( str.c_str(), str.length() );
365}
366
367
368int LSET::ParseHex( const char* aStart, int aCount )
369{
370 LSET tmp;
371
372 const char* rstart = aStart + aCount - 1;
373 const char* rend = aStart - 1;
374
375 const int bitcount = size();
376
377 int nibble_ndx = 0;
378
379 while( rstart > rend )
380 {
381 int cc = *rstart--;
382
383 if( cc == '_' )
384 continue;
385
386 int nibble;
387
388 if( cc >= '0' && cc <= '9' )
389 nibble = cc - '0';
390 else if( cc >= 'a' && cc <= 'f' )
391 nibble = cc - 'a' + 10;
392 else if( cc >= 'A' && cc <= 'F' )
393 nibble = cc - 'A' + 10;
394 else
395 break;
396
397 int bit = nibble_ndx * 4;
398
399 for( int ndx=0; bit<bitcount && ndx<4; ++bit, ++ndx )
400 if( nibble & (1<<ndx) )
401 tmp.set( bit );
402
403 if( bit >= bitcount )
404 break;
405
406 ++nibble_ndx;
407 }
408
409 int byte_count = aStart + aCount - 1 - rstart;
410
411 assert( byte_count >= 0 );
412
413 if( byte_count > 0 )
414 *this = tmp;
415
416 return byte_count;
417}
418
419
420LSEQ LSET::Seq( const LSEQ& aSequence ) const
421{
422 LSEQ ret;
423
424 for( PCB_LAYER_ID layer : aSequence )
425 {
426 if( test( layer ) )
427 ret.push_back( layer );
428 }
429
430 return ret;
431}
432
433
435{
436 LSEQ ret;
437
438 ret.reserve( size() );
439
440 for( unsigned i = 0; i < size(); ++i )
441 {
442 if( test( i ) )
443 ret.push_back( PCB_LAYER_ID( i ) );
444 }
445
446 return ret;
447}
448
449
451{
452 LSEQ base_sequence = Seq( {
453 Edge_Cuts,
454 Margin,
455 Dwgs_User,
456 Cmts_User,
457 Eco1_User,
459 } );
460
461 LSEQ top_tech_sequence = Seq( {
462 F_Fab,
463 F_SilkS,
464 F_Paste,
465 F_Adhes,
466 F_Mask,
467 F_CrtYd,
468 } );
469
470 LSEQ bottom_tech_sequence = Seq( {
471 B_CrtYd,
472 B_Mask,
473 B_Adhes,
474 B_Paste,
475 B_SilkS,
476 B_Fab,
477 } );
478
479
480 LSEQ seq = Seq( base_sequence );
481
482 for( auto it = non_copper_layers_begin(); it != non_copper_layers_end(); ++it )
483 {
484 if( *it >= User_1 )
485 seq.push_back( *it );
486 }
487
488 std::copy( top_tech_sequence.begin(), top_tech_sequence.end(), std::back_inserter( seq ) );
489
490 for( auto it = copper_layers_begin(); it != copper_layers_end(); ++it )
491 seq.push_back( *it );
492
493 std::copy( bottom_tech_sequence.begin(), bottom_tech_sequence.end(), std::back_inserter( seq ) );
494
495 if( aSelectedLayer != UNDEFINED_LAYER )
496 {
497 auto it = std::find( seq.begin(), seq.end(), aSelectedLayer );
498
499 if( it != seq.end() )
500 {
501 seq.erase( it );
502 seq.insert( seq.begin(), aSelectedLayer );
503 }
504 }
505
506 return seq;
507}
508
509
511{
512 // bottom-to-top stack-up layers
513 // Note that the bottom technical layers are flipped so that when plotting a bottom-side view,
514 // they appear in the correct sequence.
515 LSEQ bottom_tech_sequence = Seq( {
516 B_Cu,
517 B_Mask,
518 B_Paste,
519 B_SilkS,
520 B_Adhes,
521 B_CrtYd,
522 B_Fab,
523 } );
524
525 // Copper layers go here
526
527 LSEQ top_tech_sequence = Seq( {
528 F_Mask,
529 F_Paste,
530 F_SilkS,
531 F_Adhes,
532 F_CrtYd,
533 F_Fab,
534 } );
535
536 LSEQ user_sequence = Seq( {
537 Dwgs_User,
538 Cmts_User,
539 Eco1_User,
540 Eco2_User,
541 } );
542
543 // User layers go here
544
545 LSEQ base_sequence = Seq( {
546 Margin,
547 Edge_Cuts,
548 } );
549
550
551
552 LSEQ seq = Seq( bottom_tech_sequence );
553
554 std::vector<PCB_LAYER_ID> temp_layers;
555
556 // We are going to reverse the copper layers and then add them to the sequence
557 // because the plotting order is bottom-to-top
558 for( auto it = copper_layers_begin(); it != copper_layers_end(); ++it )
559 {
560 // Skip B_Cu because it is already in the sequence (if it exists)
561 if( *it != B_Cu )
562 temp_layers.push_back( *it );
563 }
564
565 for( auto it = temp_layers.rbegin(); it != temp_layers.rend(); ++it )
566 seq.push_back( *it );
567
568 std::copy( top_tech_sequence.begin(), top_tech_sequence.end(), std::back_inserter( seq ) );
569
570 std::copy( user_sequence.begin(), user_sequence.end(), std::back_inserter( seq ) );
571
572 temp_layers.clear();
573
574 for( auto it = non_copper_layers_begin(); it != non_copper_layers_end(); ++it )
575 {
576 if( *it >= User_1 )
577 temp_layers.push_back( *it );
578 }
579
580 for( auto it = temp_layers.rbegin(); it != temp_layers.rend(); ++it )
581 {
582 seq.push_back( *it );
583 }
584
585 std::copy( base_sequence.begin(), base_sequence.end(), std::back_inserter( seq ) );
586
587 return seq;
588}
589
590
591LSET& LSET::Flip( int aCopperLayersCount )
592{
593 LSET oldMask = *this;
594
595 reset();
596
597 // Mapping for Copper and Non-Copper layers
598 const std::map<PCB_LAYER_ID, PCB_LAYER_ID> flip_map =
599 {
600 {F_Cu, B_Cu},
601 {B_Cu, F_Cu},
602 {F_SilkS, B_SilkS},
603 {B_SilkS, F_SilkS},
604 {F_Adhes, B_Adhes},
605 {B_Adhes, F_Adhes},
606 {F_Mask, B_Mask},
607 {B_Mask, F_Mask},
608 {F_Paste, B_Paste},
609 {B_Paste, F_Paste},
610 {F_CrtYd, B_CrtYd},
611 {B_CrtYd, F_CrtYd},
612 {F_Fab, B_Fab},
613 {B_Fab, F_Fab}
614 };
615
616 for( const auto& pair : flip_map )
617 {
618 if( oldMask.test( pair.first ) )
619 set( pair.second );
620 }
621
622 if( aCopperLayersCount >= 4 )
623 {
624 LSET internalMask = oldMask & InternalCuMask();
625 int innerLayerCount = aCopperLayersCount - 2;
626
627 for( int ii = 1; ii <= innerLayerCount; ii++ )
628 {
629 if( internalMask.test( ( innerLayerCount - ii + 1 ) * 2 + B_Cu ) )
630 {
631 set( ii * 2 + B_Cu );
632 }
633 }
634 }
635
636 return *this;
637}
638
639
641{
642 unsigned set_count = count();
643
644 if( !set_count )
645 return UNSELECTED_LAYER;
646 else if( set_count > 1 )
647 return UNDEFINED_LAYER;
648
649 for( unsigned i=0; i < size(); ++i )
650 {
651 if( test( i ) )
652 return PCB_LAYER_ID( i );
653 }
654
655 wxASSERT( 0 ); // set_count was verified as 1 above, what did you break?
656
657 return UNDEFINED_LAYER;
658}
659
660
662{
663 static const LSET saved( { F_SilkS, F_Mask, F_Fab, F_CrtYd } );
664 return saved;
665}
666
667
669{
670 static const LSET saved( { B_SilkS, B_Mask, B_Fab, B_CrtYd } );
671 return saved;
672}
673
674
676{
677 static const LSET saved( { In1_Cu, In2_Cu, In3_Cu, In4_Cu, In5_Cu, In6_Cu,
682 return saved;
683}
684
685
686LSET LSET::AllCuMask( int aCuLayerCount )
687{
688 LSET ret;
689
690 for( PCB_LAYER_ID layer : LAYER_RANGE( F_Cu, B_Cu, aCuLayerCount ) )
691 ret.set( layer );
692
693 return ret;
694}
695
696
698{
699 static const LSET saved = LSET().set() & ~AllCuMask();
700 return saved;
701}
702
703
705{
706 static const LSET saved( { F_Cu, B_Cu } );
707 return saved;
708}
709
710
712{
713 static const LSET saved = LSET().set();
714 return saved;
715}
716
717
719{
720 static const LSET saved( { B_SilkS, B_Mask, B_Adhes, B_Paste, B_CrtYd, B_Fab } );
721 return saved;
722}
723
725{
726 static const LSET saved( { B_SilkS, B_Mask, B_Adhes, B_Paste } );
727 return saved;
728}
729
731{
732 static const LSET saved( { F_SilkS, F_Mask, F_Adhes, F_Paste, F_CrtYd, F_Fab } );
733 return saved;
734}
735
736
738{
739 static const LSET saved( { F_SilkS, F_Mask, F_Adhes, F_Paste } );
740 return saved;
741}
742
743
745{
746 static const LSET saved = BackTechMask() | FrontTechMask();
747 return saved;
748}
749
750
752{
753 static const LSET saved = BackBoardTechMask() | FrontBoardTechMask();
754 return saved;
755}
756
757
759{
760 static const LSET saved( { Dwgs_User, Cmts_User, Eco1_User, Eco2_User, Edge_Cuts, Margin } );
761
762 return saved;
763}
764
765
767{
768 static const LSET saved = AllBoardTechMask() | AllCuMask();
769 return saved;
770}
771
772
774{
775 static const LSET saved(
777
778 return saved;
779}
780
781
783{
784 static const LSET saved = FrontTechMask().set( F_Cu );
785 return saved;
786}
787
788
790{
791 static const LSET saved = BackTechMask().set( B_Cu );
792 return saved;
793}
794
796{
797 static const LSET saved = BackTechMask() | FrontTechMask() | AllCuMask();
798 return saved;
799}
800
801
803{
804 static const LSET saved = InternalCuMask();
805 return saved;
806}
807
808
810{
811 LSEQ order = CuStack();
812 LSEQ techuser = TechAndUserUIOrder();
813
814 order.insert( order.end(), techuser.begin(), techuser.end() );
815
816 return order;
817}
818
819
821{
822 // We use std::numeric_limits<int>::max() to represent B_Cu for the connectivity_rtree
823 if( aLayer == std::numeric_limits<int>::max() )
824 return B_Cu;
825
826 wxASSERT( aLayer < GAL_LAYER_ID_END );
827 return PCB_LAYER_ID( aLayer );
828}
829
830
831GAL_SET::GAL_SET( const GAL_LAYER_ID* aArray, unsigned aCount ) : GAL_SET()
832{
833 for( unsigned i = 0; i < aCount; ++i )
834 set( aArray[i] );
835}
836
837
838std::vector<GAL_LAYER_ID> GAL_SET::Seq() const
839{
840 std::vector<GAL_LAYER_ID> ret;
841
842 for( size_t i = 0; i < size(); ++i )
843 {
844 if( test( i ) )
845 ret.push_back( static_cast<GAL_LAYER_ID>( i + GAL_LAYER_ID_START ) );
846 }
847
848 return ret;
849}
850
851
853{
854 static const GAL_LAYER_ID visible[] = {
859 // LAYER_HIDDEN_TEXT, // DEPCREATED SINCE 9.0. Invisible text hidden by default
879 // LAYER_DRC_EXCLUSION, // DRC exclusions hidden by default
892 };
893
894 static const GAL_SET saved( visible, arrayDim( visible ) );
895 return saved;
896}
897
898#ifndef SWIG // Skip SWIG generators for the iterators because it requires a default constructor
899// Custom iterators for Copper and Non-Copper layers
900
902 BASE_SET::set_bits_iterator( set, index )
903{
904 m_index = ( index + 1 ) & ~1;
906}
907
909{
910 return static_cast<PCB_LAYER_ID>( m_index );
911}
912
914{
915 next_copper_layer();
916 advance_to_next_set_copper_bit();
917 return *this;
918}
919
921{
922 if( m_index == F_Cu )
923 {
924 m_index += 4;
925 }
926 else if( m_index == B_Cu )
927 {
928 m_index = m_baseSet.size();
929 return;
930 }
931 else
932 {
933 m_index += 2;
934
935 if( m_index >= m_baseSet.size() )
936 m_index = B_Cu;
937 }
938}
939
941{
942 while( m_index < m_baseSet.size() && !m_baseSet.test( m_index ) )
943 next_copper_layer();
944}
945
948{
950}
951
953{
954 return static_cast<PCB_LAYER_ID>( m_index );
955}
956
958{
959 ++m_index;
960 advance_to_next_set_non_copper_bit();
961 return *this;
962}
963
965{
966 while( m_index < m_baseSet.size() && ( m_index % 2 != 1 || !m_baseSet.test( m_index ) ) )
967 {
968 ++m_index;
969 }
970}
971
973{
974 return copper_layers_iterator( *this, 0 );
975}
976
978{
979 return copper_layers_iterator( *this, size() );
980}
981
983{
984 return non_copper_layers_iterator( *this, 0 );
985}
986
988{
989 return non_copper_layers_iterator( *this, size() );
990}
991
992
993#endif
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
BASE_SET & set()
Definition: base_set.h:135
BASE_SET & reset()
Definition: base_set.h:152
BASE_SET & set(size_t pos)
Definition: base_set.h:115
Helper for storing and iterating over GAL_LAYER_IDs.
Definition: layer_ids.h:307
GAL_SET()
Definition: layer_ids.h:313
GAL_SET & set()
Definition: layer_ids.h:323
static GAL_SET DefaultVisible()
Definition: lset.cpp:852
std::vector< GAL_LAYER_ID > Seq() const
Definition: lset.cpp:838
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: lseq.h:47
copper_layers_iterator & operator++()
Definition: lset.cpp:913
PCB_LAYER_ID operator*() const
Definition: lset.cpp:908
void advance_to_next_set_copper_bit()
Definition: lset.cpp:940
copper_layers_iterator(const BASE_SET &set, size_t index)
Definition: lset.cpp:901
PCB_LAYER_ID operator*() const
Definition: lset.cpp:952
non_copper_layers_iterator & operator++()
Definition: lset.cpp:957
non_copper_layers_iterator(const BASE_SET &set, size_t index)
Definition: lset.cpp:946
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:36
LSET & Flip(int aCopperLayersCount=0)
Flip the layers in this set.
Definition: lset.cpp:591
static LSET ExternalCuMask()
Return a mask holding the Front and Bottom layers.
Definition: lset.cpp:704
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.
Definition: lset.cpp:368
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.
Definition: lset.cpp:169
copper_layers_iterator copper_layers_end() const
Definition: lset.cpp:977
LSEQ UIOrder() const
Returns the copper, technical and user layers in the order shown in layer widget.
Definition: lset.cpp:809
static LSET AllBoardTechMask()
Return a mask holding board technical layers (no CU layer) on both side.
Definition: lset.cpp:751
static LSET AllLayersMask()
Definition: lset.cpp:711
static LSET UserDefinedLayers()
Return a mask with all of the allowable user defined layers.
Definition: lset.cpp:773
LSEQ CuStack() const
Return a sequence of copper layers in starting from the front/top and extending to the back/bottom.
Definition: lset.cpp:250
PCB_LAYER_ID ExtractLayer() const
Find the first set PCB_LAYER_ID.
Definition: lset.cpp:640
LSEQ SeqStackupForPlotting() const
Return the sequence that is typical for a bottom-to-top stack-up.
Definition: lset.cpp:510
static LSET FrontBoardTechMask()
Return a mask holding technical layers used in a board fabrication (no CU layer) on front side.
Definition: lset.cpp:737
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
Definition: lset.cpp:697
static LSET FrontAssembly()
Return a complete set of all top assembly layers which is all F_SilkS and F_Mask.
Definition: lset.cpp:661
LSEQ TechAndUserUIOrder() const
Returns the technical and user layers in the order shown in layer widget.
Definition: lset.cpp:263
static LSET UserMask()
Definition: lset.cpp:758
static LSET AllTechMask()
Return a mask holding all technical layers (no CU layer) on both side.
Definition: lset.cpp:744
static LSET InternalCuMask()
Return a complete set of internal copper layers which is all Cu layers except F_Cu and B_Cu.
Definition: lset.cpp:675
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:686
static LSET SideSpecificMask()
Definition: lset.cpp:795
static LSET PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
Definition: lset.cpp:766
all_set_layers_iterator end() const
Definition: lset.h:315
LSEQ Seq() const
Return a LSEQ from this LSET in ascending PCB_LAYER_ID order.
Definition: lset.cpp:434
std::string FmtHex() const
Return a hex string showing contents of this LSEQ.
Definition: lset.cpp:324
copper_layers_iterator copper_layers_begin() const
Definition: lset.cpp:972
non_copper_layers_iterator non_copper_layers_begin() const
Definition: lset.cpp:982
static int NameToLayer(wxString &aName)
Return the layer number from a layer name.
Definition: lset.cpp:117
static LSET ForbiddenFootprintLayers()
Layers which are not allowed within footprint definitions.
Definition: lset.cpp:802
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.
Definition: lset.cpp:450
non_copper_layers_iterator non_copper_layers_end() const
Definition: lset.cpp:987
std::string FmtBin() const
Return a binary string showing contents of this LSEQ.
Definition: lset.cpp:300
static LSET FrontTechMask()
Return a mask holding all technical layers (no CU layer) on front side.
Definition: lset.cpp:730
static LSET BackBoardTechMask()
Return a mask holding technical layers used in a board fabrication (no CU layer) on Back side.
Definition: lset.cpp:724
static LSET BackTechMask()
Return a mask holding all technical layers (no CU layer) on back side.
Definition: lset.cpp:718
static LSET BackAssembly()
Return a complete set of all bottom assembly layers which is all B_SilkS and B_Mask.
Definition: lset.cpp:668
static LSET FrontMask()
Return a mask holding all technical layers and the external CU layer on front side.
Definition: lset.cpp:782
static LSET BackMask()
Return a mask holding all technical layers and the external CU layer on back side.
Definition: lset.cpp:789
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition: lset.cpp:193
LSET()
Create an empty (cleared) set.
Definition: lset.h:42
static int LayerCount(PCB_LAYER_ID aStart, PCB_LAYER_ID aEnd, int aCopperLayerCount)
Return the number of layers between aStart and aEnd, inclusive.
Definition: lset.cpp:86
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:531
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
Definition: layer_ids.h:191
@ LAYER_GRID
Definition: layer_ids.h:206
@ GAL_LAYER_ID_START
Definition: layer_ids.h:192
@ LAYER_LOCKED_ITEM_SHADOW
shadow layer for locked items
Definition: layer_ids.h:240
@ LAYER_VIA_HOLEWALLS
Definition: layer_ids.h:235
@ LAYER_GRID_AXES
Definition: layer_ids.h:207
@ LAYER_CONFLICTS_SHADOW
shadow layer for items flagged conficting
Definition: layer_ids.h:242
@ LAYER_FOOTPRINTS_FR
show footprints on front
Definition: layer_ids.h:209
@ LAYER_DRC_SHAPE1
Custom shape for DRC marker.
Definition: layer_ids.h:245
@ LAYER_NON_PLATEDHOLES
handle color for not plated holes (holes, not pads)
Definition: layer_ids.h:198
@ LAYER_DRAWINGSHEET
drawingsheet frame and titleblock
Definition: layer_ids.h:218
@ LAYER_DRAW_BITMAPS
to handle and draw images bitmaps
Definition: layer_ids.h:224
@ LAYER_FP_REFERENCES
show footprints references (when texts are visible)
Definition: layer_ids.h:212
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition: layer_ids.h:221
@ LAYER_ZONES
Control for copper zone opacity/visibility (color ignored)
Definition: layer_ids.h:232
@ LAYER_SHAPES
Copper graphic shape opacity/visibility (color ignored)
Definition: layer_ids.h:243
@ LAYER_PADS
Meta control for all pads opacity/visibility (color ignored)
Definition: layer_ids.h:231
@ LAYER_DRC_WARNING
layer for drc markers with SEVERITY_WARNING
Definition: layer_ids.h:236
@ LAYER_PAD_PLATEDHOLES
to draw pad holes (plated)
Definition: layer_ids.h:215
@ GAL_LAYER_ID_END
Definition: layer_ids.h:268
@ LAYER_GP_OVERLAY
general purpose overlay
Definition: layer_ids.h:219
@ LAYER_TRACKS
Definition: layer_ids.h:213
@ LAYER_CURSOR
PCB cursor.
Definition: layer_ids.h:222
@ LAYER_AUX_ITEMS
Auxiliary items (guides, rule, etc)
Definition: layer_ids.h:223
@ LAYER_RATSNEST
Definition: layer_ids.h:205
@ LAYER_DRC_SHAPE2
Custom shape for DRC marker.
Definition: layer_ids.h:246
@ LAYER_FP_TEXT
Definition: layer_ids.h:199
@ LAYER_FOOTPRINTS_BK
show footprints on back
Definition: layer_ids.h:210
@ LAYER_ANCHOR
anchor of items having an anchor point (texts, footprints)
Definition: layer_ids.h:202
@ LAYER_VIA_HOLES
to draw via holes (pad holes do not use this layer)
Definition: layer_ids.h:216
@ LAYER_FP_VALUES
show footprints values (when texts are visible)
Definition: layer_ids.h:211
@ LAYER_VIA_MICROVIA
to draw micro vias
Definition: layer_ids.h:195
@ LAYER_SELECT_OVERLAY
currently selected items overlay
Definition: layer_ids.h:220
@ LAYER_VIA_THROUGH
to draw usual through hole vias
Definition: layer_ids.h:197
@ LAYER_DRC_ERROR
layer for drc markers with SEVERITY_ERROR
Definition: layer_ids.h:217
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
Definition: layer_ids.h:194
@ LAYER_VIA_BBLIND
to draw blind/buried vias
Definition: layer_ids.h:196
@ LAYER_PAD_HOLEWALLS
Definition: layer_ids.h:234
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ In22_Cu
Definition: layer_ids.h:87
@ In11_Cu
Definition: layer_ids.h:76
@ In29_Cu
Definition: layer_ids.h:94
@ In30_Cu
Definition: layer_ids.h:95
@ User_8
Definition: layer_ids.h:131
@ F_CrtYd
Definition: layer_ids.h:116
@ In17_Cu
Definition: layer_ids.h:82
@ B_Adhes
Definition: layer_ids.h:103
@ Edge_Cuts
Definition: layer_ids.h:112
@ Dwgs_User
Definition: layer_ids.h:107
@ F_Paste
Definition: layer_ids.h:104
@ In9_Cu
Definition: layer_ids.h:74
@ Cmts_User
Definition: layer_ids.h:108
@ User_6
Definition: layer_ids.h:129
@ User_7
Definition: layer_ids.h:130
@ In19_Cu
Definition: layer_ids.h:84
@ In7_Cu
Definition: layer_ids.h:72
@ In28_Cu
Definition: layer_ids.h:93
@ In26_Cu
Definition: layer_ids.h:91
@ F_Adhes
Definition: layer_ids.h:102
@ B_Mask
Definition: layer_ids.h:98
@ B_Cu
Definition: layer_ids.h:65
@ User_5
Definition: layer_ids.h:128
@ Eco1_User
Definition: layer_ids.h:109
@ F_Mask
Definition: layer_ids.h:97
@ In21_Cu
Definition: layer_ids.h:86
@ In23_Cu
Definition: layer_ids.h:88
@ B_Paste
Definition: layer_ids.h:105
@ In15_Cu
Definition: layer_ids.h:80
@ In2_Cu
Definition: layer_ids.h:67
@ User_9
Definition: layer_ids.h:132
@ UNSELECTED_LAYER
Definition: layer_ids.h:62
@ F_Fab
Definition: layer_ids.h:119
@ In10_Cu
Definition: layer_ids.h:75
@ Margin
Definition: layer_ids.h:113
@ F_SilkS
Definition: layer_ids.h:100
@ In4_Cu
Definition: layer_ids.h:69
@ B_CrtYd
Definition: layer_ids.h:115
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
@ Eco2_User
Definition: layer_ids.h:110
@ In16_Cu
Definition: layer_ids.h:81
@ In24_Cu
Definition: layer_ids.h:89
@ In1_Cu
Definition: layer_ids.h:66
@ Rescue
Definition: layer_ids.h:121
@ User_3
Definition: layer_ids.h:126
@ User_1
Definition: layer_ids.h:124
@ B_SilkS
Definition: layer_ids.h:101
@ In13_Cu
Definition: layer_ids.h:78
@ User_4
Definition: layer_ids.h:127
@ In8_Cu
Definition: layer_ids.h:73
@ In14_Cu
Definition: layer_ids.h:79
@ User_2
Definition: layer_ids.h:125
@ In12_Cu
Definition: layer_ids.h:77
@ In27_Cu
Definition: layer_ids.h:92
@ In6_Cu
Definition: layer_ids.h:71
@ In5_Cu
Definition: layer_ids.h:70
@ In3_Cu
Definition: layer_ids.h:68
@ In20_Cu
Definition: layer_ids.h:85
@ F_Cu
Definition: layer_ids.h:64
@ In18_Cu
Definition: layer_ids.h:83
@ In25_Cu
Definition: layer_ids.h:90
@ B_Fab
Definition: layer_ids.h:118
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:820
This file contains miscellaneous commonly used macros and functions.