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 <stddef.h> // for size_t
31
32#include <core/arraydim.h>
33#include <math/util.h> // for Clamp
34#include <layer_ids.h> // for PCB_LAYER_ID
35#include <lseq.h>
36#include <macros.h> // for arrayDim
37#include <wx/debug.h> // for wxASSERT, wxASSERT_MSG
38#include <wx/string.h>
39
40#include <lset.h>
41
42
43LSET::LSET( std::initializer_list<PCB_LAYER_ID> aList ) :
44 BASE_SET()
45{
46 for( PCB_LAYER_ID layer : aList )
47 set( layer );
48}
49
50
51LSET::LSET( const LSEQ& aSeq )
52{
53 for( PCB_LAYER_ID layer : aSeq )
54 set( layer );
55}
56
57
63const wxChar* LSET::Name( PCB_LAYER_ID aLayerId )
64{
65 const wxChar* txt;
66
67 // using a switch to explicitly show the mapping more clearly
68 switch( aLayerId )
69 {
70 case F_Cu: txt = wxT( "F.Cu" ); break;
71 case In1_Cu: txt = wxT( "In1.Cu" ); break;
72 case In2_Cu: txt = wxT( "In2.Cu" ); break;
73 case In3_Cu: txt = wxT( "In3.Cu" ); break;
74 case In4_Cu: txt = wxT( "In4.Cu" ); break;
75 case In5_Cu: txt = wxT( "In5.Cu" ); break;
76 case In6_Cu: txt = wxT( "In6.Cu" ); break;
77 case In7_Cu: txt = wxT( "In7.Cu" ); break;
78 case In8_Cu: txt = wxT( "In8.Cu" ); break;
79 case In9_Cu: txt = wxT( "In9.Cu" ); break;
80 case In10_Cu: txt = wxT( "In10.Cu" ); break;
81 case In11_Cu: txt = wxT( "In11.Cu" ); break;
82 case In12_Cu: txt = wxT( "In12.Cu" ); break;
83 case In13_Cu: txt = wxT( "In13.Cu" ); break;
84 case In14_Cu: txt = wxT( "In14.Cu" ); break;
85 case In15_Cu: txt = wxT( "In15.Cu" ); break;
86 case In16_Cu: txt = wxT( "In16.Cu" ); break;
87 case In17_Cu: txt = wxT( "In17.Cu" ); break;
88 case In18_Cu: txt = wxT( "In18.Cu" ); break;
89 case In19_Cu: txt = wxT( "In19.Cu" ); break;
90 case In20_Cu: txt = wxT( "In20.Cu" ); break;
91 case In21_Cu: txt = wxT( "In21.Cu" ); break;
92 case In22_Cu: txt = wxT( "In22.Cu" ); break;
93 case In23_Cu: txt = wxT( "In23.Cu" ); break;
94 case In24_Cu: txt = wxT( "In24.Cu" ); break;
95 case In25_Cu: txt = wxT( "In25.Cu" ); break;
96 case In26_Cu: txt = wxT( "In26.Cu" ); break;
97 case In27_Cu: txt = wxT( "In27.Cu" ); break;
98 case In28_Cu: txt = wxT( "In28.Cu" ); break;
99 case In29_Cu: txt = wxT( "In29.Cu" ); break;
100 case In30_Cu: txt = wxT( "In30.Cu" ); break;
101 case B_Cu: txt = wxT( "B.Cu" ); break;
102
103 // Technicals
104 case B_Adhes: txt = wxT( "B.Adhes" ); break;
105 case F_Adhes: txt = wxT( "F.Adhes" ); break;
106 case B_Paste: txt = wxT( "B.Paste" ); break;
107 case F_Paste: txt = wxT( "F.Paste" ); break;
108 case B_SilkS: txt = wxT( "B.SilkS" ); break;
109 case F_SilkS: txt = wxT( "F.SilkS" ); break;
110 case B_Mask: txt = wxT( "B.Mask" ); break;
111 case F_Mask: txt = wxT( "F.Mask" ); break;
112
113 // Users
114 case Dwgs_User: txt = wxT( "Dwgs.User" ); break;
115 case Cmts_User: txt = wxT( "Cmts.User" ); break;
116 case Eco1_User: txt = wxT( "Eco1.User" ); break;
117 case Eco2_User: txt = wxT( "Eco2.User" ); break;
118 case Edge_Cuts: txt = wxT( "Edge.Cuts" ); break;
119 case Margin: txt = wxT( "Margin" ); break;
120
121 // Footprint
122 case F_CrtYd: txt = wxT( "F.CrtYd" ); break;
123 case B_CrtYd: txt = wxT( "B.CrtYd" ); break;
124 case F_Fab: txt = wxT( "F.Fab" ); break;
125 case B_Fab: txt = wxT( "B.Fab" ); break;
126
127 // User definable layers.
128 case User_1: txt = wxT( "User.1" ); break;
129 case User_2: txt = wxT( "User.2" ); break;
130 case User_3: txt = wxT( "User.3" ); break;
131 case User_4: txt = wxT( "User.4" ); break;
132 case User_5: txt = wxT( "User.5" ); break;
133 case User_6: txt = wxT( "User.6" ); break;
134 case User_7: txt = wxT( "User.7" ); break;
135 case User_8: txt = wxT( "User.8" ); break;
136 case User_9: txt = wxT( "User.9" ); break;
137
138 // Rescue
139 case Rescue: txt = wxT( "Rescue" ); break;
140
141 default:
142 std::cout << aLayerId << std::endl;
143 wxASSERT_MSG( 0, wxT( "aLayerId out of range" ) );
144 txt = wxT( "BAD INDEX!" ); break;
145 }
146
147 return txt;
148}
149
150
152{
153 // desired sequence
154 static const PCB_LAYER_ID sequence[] = {
155 F_Cu,
156 In1_Cu,
157 In2_Cu,
158 In3_Cu,
159 In4_Cu,
160 In5_Cu,
161 In6_Cu,
162 In7_Cu,
163 In8_Cu,
164 In9_Cu,
165 In10_Cu,
166 In11_Cu,
167 In12_Cu,
168 In13_Cu,
169 In14_Cu,
170 In15_Cu,
171 In16_Cu,
172 In17_Cu,
173 In18_Cu,
174 In19_Cu,
175 In20_Cu,
176 In21_Cu,
177 In22_Cu,
178 In23_Cu,
179 In24_Cu,
180 In25_Cu,
181 In26_Cu,
182 In27_Cu,
183 In28_Cu,
184 In29_Cu,
185 In30_Cu,
186 B_Cu, // 31
187 };
188
189 return Seq( sequence, arrayDim( sequence ) );
190}
191
192
193LSEQ LSET::Technicals( LSET aSetToOmit ) const
194{
195 // desired sequence
196 static const PCB_LAYER_ID sequence[] = {
197 F_Adhes,
198 B_Adhes,
199 F_Paste,
200 B_Paste,
201 F_SilkS,
202 B_SilkS,
203 F_Mask,
204 B_Mask,
205 F_CrtYd,
206 B_CrtYd,
207 F_Fab,
208 B_Fab,
209 };
210
211 LSET subset = ~aSetToOmit & *this;
212
213 return subset.Seq( sequence, arrayDim( sequence ) );
214}
215
216
218{
219 // desired
220 static const PCB_LAYER_ID sequence[] = {
221 Dwgs_User,
222 Cmts_User,
223 Eco1_User,
224 Eco2_User,
225 Edge_Cuts,
226 Margin,
227 User_1,
228 User_2,
229 User_3,
230 User_4,
231 User_5,
232 User_6,
233 User_7,
234 User_8,
235 User_9
236 };
237
238 return Seq( sequence, arrayDim( sequence ) );
239}
240
241
243{
244 static const PCB_LAYER_ID sequence[] = {
245 F_Adhes,
246 B_Adhes,
247 F_Paste,
248 B_Paste,
249 F_SilkS,
250 B_SilkS,
251 F_Mask,
252 B_Mask,
253 Dwgs_User,
254 Cmts_User,
255 Eco1_User,
256 Eco2_User,
257 Edge_Cuts,
258 Margin,
259 F_CrtYd,
260 B_CrtYd,
261 F_Fab,
262 B_Fab,
263 User_1,
264 User_2,
265 User_3,
266 User_4,
267 User_5,
268 User_6,
269 User_7,
270 User_8,
271 User_9
272 };
273
274 return Seq( sequence, arrayDim( sequence ) );
275}
276
277
278std::string LSET::FmtBin() const
279{
280 std::string ret;
281
282 int bit_count = size();
283
284 for( int bit=0; bit<bit_count; ++bit )
285 {
286 if( bit )
287 {
288 if( !( bit % 8 ) )
289 ret += '|';
290 else if( !( bit % 4 ) )
291 ret += '_';
292 }
293
294 ret += (*this)[bit] ? '1' : '0';
295 }
296
297 // reverse of string
298 return std::string( ret.rbegin(), ret.rend() );
299}
300
301
302std::string LSET::FmtHex() const
303{
304 std::string ret;
305
306 static const char hex[] = "0123456789abcdef";
307
308 size_t nibble_count = ( size() + 3 ) / 4;
309
310 for( size_t nibble = 0; nibble < nibble_count; ++nibble )
311 {
312 unsigned int ndx = 0;
313
314 // test 4 consecutive bits and set ndx to 0-15
315 for( size_t nibble_bit = 0; nibble_bit < 4; ++nibble_bit )
316 {
317 size_t nibble_pos = nibble_bit + ( nibble * 4 );
318 // make sure it's not extra bits that don't exist in the bitset but need to in the
319 // hex format
320 if( nibble_pos >= size() )
321 break;
322
323 if( ( *this )[nibble_pos] )
324 ndx |= ( 1 << nibble_bit );
325 }
326
327 if( nibble && !( nibble % 8 ) )
328 ret += '_';
329
330 assert( ndx < arrayDim( hex ) );
331
332 ret += hex[ndx];
333 }
334
335 // reverse of string
336 return std::string( ret.rbegin(), ret.rend() );
337}
338
339
340int LSET::ParseHex( const char* aStart, int aCount )
341{
342 LSET tmp;
343
344 const char* rstart = aStart + aCount - 1;
345 const char* rend = aStart - 1;
346
347 const int bitcount = size();
348
349 int nibble_ndx = 0;
350
351 while( rstart > rend )
352 {
353 int cc = *rstart--;
354
355 if( cc == '_' )
356 continue;
357
358 int nibble;
359
360 if( cc >= '0' && cc <= '9' )
361 nibble = cc - '0';
362 else if( cc >= 'a' && cc <= 'f' )
363 nibble = cc - 'a' + 10;
364 else if( cc >= 'A' && cc <= 'F' )
365 nibble = cc - 'A' + 10;
366 else
367 break;
368
369 int bit = nibble_ndx * 4;
370
371 for( int ndx=0; bit<bitcount && ndx<4; ++bit, ++ndx )
372 if( nibble & (1<<ndx) )
373 tmp.set( bit );
374
375 if( bit >= bitcount )
376 break;
377
378 ++nibble_ndx;
379 }
380
381 int byte_count = aStart + aCount - 1 - rstart;
382
383 assert( byte_count >= 0 );
384
385 if( byte_count > 0 )
386 *this = tmp;
387
388 return byte_count;
389}
390
391
392LSEQ LSET::Seq( const PCB_LAYER_ID* aWishListSequence, unsigned aCount ) const
393{
394 LSEQ ret;
395
396#if defined(DEBUG) && 0
397 LSET dup_detector;
398
399 for( unsigned i=0; i<aCount; ++i )
400 {
401 PCB_LAYER_ID id = aWishListSequence[i];
402
403 if( test( id ) )
404 {
405 wxASSERT_MSG( !dup_detector[id], wxT( "Duplicate in aWishListSequence" ) );
406 dup_detector[id] = true;
407
408 ret.push_back( id );
409 }
410 }
411#else
412
413 for( unsigned i=0; i<aCount; ++i )
414 {
415 PCB_LAYER_ID id = aWishListSequence[i];
416
417 if( test( id ) )
418 ret.push_back( id );
419 }
420#endif
421
422 return ret;
423}
424
425
426LSEQ LSET::Seq( const LSEQ& aSequence ) const
427{
428 LSEQ ret;
429
430 for( PCB_LAYER_ID layer : aSequence )
431 {
432 if( test( layer ) )
433 ret.push_back( layer );
434 }
435
436 return ret;
437}
438
439
441{
442 LSEQ ret;
443
444 ret.reserve( size() );
445
446 for( unsigned i = 0; i < size(); ++i )
447 {
448 if( test( i ) )
449 ret.push_back( PCB_LAYER_ID( i ) );
450 }
451
452 return ret;
453}
454
455
457{
458 static const PCB_LAYER_ID sequence[] = {
459 Edge_Cuts,
460 Margin,
461 Dwgs_User,
462 Cmts_User,
463 Eco1_User,
464 Eco2_User,
465 User_1,
466 User_2,
467 User_3,
468 User_4,
469 User_5,
470 User_6,
471 User_7,
472 User_8,
473 User_9,
474 F_Fab,
475 F_SilkS,
476 F_Paste,
477 F_Adhes,
478 F_Mask,
479 F_CrtYd,
480 F_Cu,
481 In1_Cu,
482 In2_Cu,
483 In3_Cu,
484 In4_Cu,
485 In5_Cu,
486 In6_Cu,
487 In7_Cu,
488 In8_Cu,
489 In9_Cu,
490 In10_Cu,
491 In11_Cu,
492 In12_Cu,
493 In13_Cu,
494 In14_Cu,
495 In15_Cu,
496 In16_Cu,
497 In17_Cu,
498 In18_Cu,
499 In19_Cu,
500 In20_Cu,
501 In21_Cu,
502 In22_Cu,
503 In23_Cu,
504 In24_Cu,
505 In25_Cu,
506 In26_Cu,
507 In27_Cu,
508 In28_Cu,
509 In29_Cu,
510 In30_Cu,
511 B_Cu,
512 B_CrtYd,
513 B_Mask,
514 B_Adhes,
515 B_Paste,
516 B_SilkS,
517 B_Fab,
518 };
519
520 LSEQ seq = Seq( sequence, arrayDim( sequence ) );
521
522 if( aSelectedLayer != UNDEFINED_LAYER )
523 {
524 auto it = std::find( seq.begin(), seq.end(), aSelectedLayer );
525
526 if( it != seq.end() )
527 {
528 seq.erase( it );
529 seq.insert( seq.begin(), aSelectedLayer );
530 }
531 }
532
533 return seq;
534}
535
536
538{
539 // bottom-to-top stack-up layers
540 // Note that the bottom technical layers are flipped so that when plotting a bottom-side view,
541 // they appear in the correct sequence.
542 static const PCB_LAYER_ID sequence[] = {
543 B_Cu,
544 B_Mask,
545 B_Paste,
546 B_SilkS,
547 B_Adhes,
548 B_CrtYd,
549 B_Fab,
550 In30_Cu,
551 In29_Cu,
552 In28_Cu,
553 In27_Cu,
554 In26_Cu,
555 In25_Cu,
556 In24_Cu,
557 In23_Cu,
558 In22_Cu,
559 In21_Cu,
560 In20_Cu,
561 In19_Cu,
562 In18_Cu,
563 In17_Cu,
564 In16_Cu,
565 In15_Cu,
566 In14_Cu,
567 In13_Cu,
568 In12_Cu,
569 In11_Cu,
570 In10_Cu,
571 In9_Cu,
572 In8_Cu,
573 In7_Cu,
574 In6_Cu,
575 In5_Cu,
576 In4_Cu,
577 In3_Cu,
578 In2_Cu,
579 In1_Cu,
580 F_Cu,
581 F_Mask,
582 F_Paste,
583 F_SilkS,
584 F_Adhes,
585 F_CrtYd,
586 F_Fab,
587 Dwgs_User,
588 Cmts_User,
589 Eco1_User,
590 Eco2_User,
591 User_1,
592 User_2,
593 User_3,
594 User_4,
595 User_5,
596 User_6,
597 User_7,
598 User_8,
599 User_9,
600 Margin,
601 Edge_Cuts,
602 };
603
604 return Seq( sequence, arrayDim( sequence ) );
605}
606
607
608LSET& LSET::Flip( int aCopperLayersCount )
609{
610 LSET oldMask = *this;
611
612 reset();
613
614 if( oldMask.test( B_Cu ) )
615 set( F_Cu );
616
617 if( oldMask.test( F_Cu ) )
618 set( B_Cu );
619
620 if( oldMask.test( B_SilkS ) )
621 set( F_SilkS );
622
623 if( oldMask.test( F_SilkS ) )
624 set( B_SilkS );
625
626 if( oldMask.test( B_Adhes ) )
627 set( F_Adhes );
628
629 if( oldMask.test( F_Adhes ) )
630 set( B_Adhes );
631
632 if( oldMask.test( B_Mask ) )
633 set( F_Mask );
634
635 if( oldMask.test( F_Mask ) )
636 set( B_Mask );
637
638 if( oldMask.test( B_Paste ) )
639 set( F_Paste );
640
641 if( oldMask.test( F_Paste ) )
642 set( B_Paste );
643
644 if( oldMask.test( B_Adhes ) )
645 set( F_Adhes );
646
647 if( oldMask.test( F_Adhes ) )
648 set( B_Adhes );
649
650 if( oldMask.test( B_CrtYd ) )
651 set( F_CrtYd );
652
653 if( oldMask.test( F_CrtYd ) )
654 set( B_CrtYd );
655
656 if( oldMask.test( B_Fab ) )
657 set( F_Fab );
658
659 if( oldMask.test( F_Fab ) )
660 set( B_Fab );
661
662 if( aCopperLayersCount >= 4 ) // Internal layers exist
663 {
664 LSET internalMask = oldMask & InternalCuMask();
665 int innerLayerCnt = aCopperLayersCount - 2;
666
667 // the flipped mask is the innerLayerCnt bits rewritten in reverse order
668 // ( bits innerLayerCnt to 1 rewritten in bits 1 to innerLayerCnt )
669 for( int ii = 0; ii < innerLayerCnt; ii++ )
670 {
671 if( internalMask[innerLayerCnt - ii] )
672 {
673 set( ii + In1_Cu );
674 }
675 else
676 {
677 reset( ii + In1_Cu );
678 }
679 }
680 }
681
682 return *this;
683}
684
685
687{
688 unsigned set_count = count();
689
690 if( !set_count )
691 return UNSELECTED_LAYER;
692 else if( set_count > 1 )
693 return UNDEFINED_LAYER;
694
695 for( unsigned i=0; i < size(); ++i )
696 {
697 if( test( i ) )
698 return PCB_LAYER_ID( i );
699 }
700
701 wxASSERT( 0 ); // set_count was verified as 1 above, what did you break?
702
703 return UNDEFINED_LAYER;
704}
705
706
708{
709 static const LSET saved( { F_SilkS, F_Mask, F_Fab, F_CrtYd } );
710 return saved;
711}
712
713
715{
716 static const LSET saved( { B_SilkS, B_Mask, B_Fab, B_CrtYd } );
717 return saved;
718}
719
720
722{
723 static const LSET saved( { In1_Cu, In2_Cu, In3_Cu, In4_Cu, In5_Cu, In6_Cu,
728 return saved;
729}
730
731
732LSET LSET::AllCuMask( int aCuLayerCount )
733{
734 // retain all in static as the full set, which is a common case.
735 static const LSET all = InternalCuMask().set( F_Cu ).set( B_Cu );
736
737 if( aCuLayerCount == MAX_CU_LAYERS )
738 return all;
739
740 // subtract out some Cu layers not wanted in the mask.
741 LSET ret = all;
742 int clear_count = MAX_CU_LAYERS - aCuLayerCount;
743
744 clear_count = Clamp( 0, clear_count, MAX_CU_LAYERS - 2 );
745
746 for( int elem = In30_Cu; clear_count; --elem, --clear_count )
747 ret.set( elem, false );
748
749 return ret;
750}
751
752
754{
755 static const LSET saved = LSET().set() & ~AllCuMask();
756 return saved;
757}
758
759
761{
762 static const LSET saved( { F_Cu, B_Cu } );
763 return saved;
764}
765
766
768{
769 static const LSET saved = LSET().set();
770 return saved;
771}
772
773
775{
776 static const LSET saved( { B_SilkS, B_Mask, B_Adhes, B_Paste, B_CrtYd, B_Fab } );
777 return saved;
778}
779
781{
782 static const LSET saved( { B_SilkS, B_Mask, B_Adhes, B_Paste } );
783 return saved;
784}
785
787{
788 static const LSET saved( { F_SilkS, F_Mask, F_Adhes, F_Paste, F_CrtYd, F_Fab } );
789 return saved;
790}
791
792
794{
795 static const LSET saved( { F_SilkS, F_Mask, F_Adhes, F_Paste } );
796 return saved;
797}
798
799
801{
802 static const LSET saved = BackTechMask() | FrontTechMask();
803 return saved;
804}
805
806
808{
809 static const LSET saved = BackBoardTechMask() | FrontBoardTechMask();
810 return saved;
811}
812
813
815{
816 static const LSET saved( { Dwgs_User, Cmts_User, Eco1_User, Eco2_User, Edge_Cuts, Margin } );
817
818 return saved;
819}
820
821
823{
824 static const LSET saved = AllBoardTechMask() | AllCuMask();
825 return saved;
826}
827
828
830{
831 static const LSET saved(
833
834 return saved;
835}
836
837
839{
840 static const LSET saved = FrontTechMask().set( F_Cu );
841 return saved;
842}
843
844
846{
847 static const LSET saved = BackTechMask().set( B_Cu );
848 return saved;
849}
850
852{
853 static const LSET saved = BackTechMask() | FrontTechMask() | AllCuMask();
854 return saved;
855}
856
857
859{
860 static const LSET saved = InternalCuMask();
861 return saved;
862}
863
864
866{
867 LSEQ order = CuStack();
868 LSEQ techuser = TechAndUserUIOrder();
869 order.insert( order.end(), techuser.begin(), techuser.end() );
870
871 return order;
872}
873
874
876{
877 wxASSERT( aLayer < GAL_LAYER_ID_END );
878 return PCB_LAYER_ID( aLayer );
879}
880
881
882GAL_SET::GAL_SET( const GAL_LAYER_ID* aArray, unsigned aCount ) : GAL_SET()
883{
884 for( unsigned i = 0; i < aCount; ++i )
885 set( aArray[i] );
886}
887
888
889std::vector<GAL_LAYER_ID> GAL_SET::Seq() const
890{
891 std::vector<GAL_LAYER_ID> ret;
892
893 for( size_t i = 0; i < size(); ++i )
894 {
895 if( test( i ) )
896 ret.push_back( static_cast<GAL_LAYER_ID>( i + GAL_LAYER_ID_START ) );
897 }
898
899 return ret;
900}
901
902
904{
905 static const GAL_LAYER_ID visible[] = {
910 // LAYER_HIDDEN_TEXT, // Invisible text hidden by default
931 // LAYER_DRC_EXCLUSION, // DRC exclusions hidden by default
944 };
945
946 static const GAL_SET saved( visible, arrayDim( visible ) );
947 return saved;
948}
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
BASE_SET & set(size_t pos=std::numeric_limits< size_t >::max(), bool value=true)
Definition: base_set.h:61
bool test(size_t pos) const
Definition: base_set.h:47
BASE_SET & reset(size_t pos=std::numeric_limits< size_t >::max())
Definition: base_set.h:76
size_t size() const
Definition: base_set.h:108
size_t count() const
Definition: base_set.h:106
bool all() const
Definition: base_set.h:57
Helper for storing and iterating over GAL_LAYER_IDs.
Definition: layer_ids.h:308
GAL_SET()
Definition: layer_ids.h:314
GAL_SET & set()
Definition: layer_ids.h:324
static GAL_SET DefaultVisible()
Definition: lset.cpp:903
std::vector< GAL_LAYER_ID > Seq() const
Definition: lset.cpp:889
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: lseq.h:47
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:35
LSET & Flip(int aCopperLayersCount=0)
Flip the layers in this set.
Definition: lset.cpp:608
static LSET ExternalCuMask()
Return a mask holding the Front and Bottom layers.
Definition: lset.cpp:760
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:340
LSEQ UIOrder() const
Definition: lset.cpp:865
static LSET AllBoardTechMask()
Return a mask holding board technical layers (no CU layer) on both side.
Definition: lset.cpp:807
static LSET AllLayersMask()
Definition: lset.cpp:767
static LSET UserDefinedLayers()
Return a mask with all of the allowable user defined layers.
Definition: lset.cpp:829
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:392
LSEQ CuStack() const
Return a sequence of copper layers in starting from the front/top and extending to the back/bottom.
Definition: lset.cpp:151
PCB_LAYER_ID ExtractLayer() const
Find the first set PCB_LAYER_ID.
Definition: lset.cpp:686
LSEQ SeqStackupForPlotting() const
Return the sequence that is typical for a bottom-to-top stack-up.
Definition: lset.cpp:537
static LSET FrontBoardTechMask()
Return a mask holding technical layers used in a board fabrication (no CU layer) on front side.
Definition: lset.cpp:793
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
Definition: lset.cpp:753
static LSET FrontAssembly()
Return a complete set of all top assembly layers which is all F_SilkS and F_Mask.
Definition: lset.cpp:707
LSEQ TechAndUserUIOrder() const
Returns the technical and user layers in the order shown in layer widget.
Definition: lset.cpp:242
static LSET UserMask()
Definition: lset.cpp:814
static LSET AllTechMask()
Return a mask holding all technical layers (no CU layer) on both side.
Definition: lset.cpp:800
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:721
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:732
static LSET SideSpecificMask()
Definition: lset.cpp:851
static LSET PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
Definition: lset.cpp:822
LSEQ Seq() const
Return a LSEQ from this LSET in ascending PCB_LAYER_ID order.
Definition: lset.cpp:440
std::string FmtHex() const
Return a hex string showing contents of this LSEQ.
Definition: lset.cpp:302
static LSET ForbiddenFootprintLayers()
Layers which are not allowed within footprint definitions.
Definition: lset.cpp:858
LSEQ Technicals(LSET aSubToOmit=LSET()) const
Return a sequence of technical layers.
Definition: lset.cpp:193
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:456
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition: lset.cpp:63
std::string FmtBin() const
Return a binary string showing contents of this LSEQ.
Definition: lset.cpp:278
static LSET FrontTechMask()
Return a mask holding all technical layers (no CU layer) on front side.
Definition: lset.cpp:786
static LSET BackBoardTechMask()
Return a mask holding technical layers used in a board fabrication (no CU layer) on Back side.
Definition: lset.cpp:780
LSEQ Users() const
*_User layers.
Definition: lset.cpp:217
static LSET BackTechMask()
Return a mask holding all technical layers (no CU layer) on back side.
Definition: lset.cpp:774
static LSET BackAssembly()
Return a complete set of all bottom assembly layers which is all B_SilkS and B_Mask.
Definition: lset.cpp:714
static LSET FrontMask()
Return a mask holding all technical layers and the external CU layer on front side.
Definition: lset.cpp:838
static LSET BackMask()
Return a mask holding all technical layers and the external CU layer on back side.
Definition: lset.cpp:845
LSET()
Create an empty (cleared) set.
Definition: lset.h:51
#define MAX_CU_LAYERS
Definition: layer_ids.h:142
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
Definition: layer_ids.h:194
@ LAYER_GRID
Definition: layer_ids.h:209
@ GAL_LAYER_ID_START
Definition: layer_ids.h:195
@ LAYER_LOCKED_ITEM_SHADOW
shadow layer for locked items
Definition: layer_ids.h:243
@ LAYER_VIA_HOLEWALLS
Definition: layer_ids.h:238
@ LAYER_GRID_AXES
Definition: layer_ids.h:210
@ LAYER_CONFLICTS_SHADOW
shadow layer for items flagged conficting
Definition: layer_ids.h:245
@ LAYER_FOOTPRINTS_FR
show footprints on front
Definition: layer_ids.h:212
@ LAYER_NON_PLATEDHOLES
handle color for not plated holes (holes, not pads)
Definition: layer_ids.h:201
@ LAYER_DRAWINGSHEET
drawingsheet frame and titleblock
Definition: layer_ids.h:221
@ LAYER_DRAW_BITMAPS
to handle and draw images bitmaps
Definition: layer_ids.h:227
@ LAYER_FP_REFERENCES
show footprints references (when texts are visible)
Definition: layer_ids.h:215
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition: layer_ids.h:224
@ LAYER_ZONES
Control for copper zone opacity/visibility (color ignored)
Definition: layer_ids.h:235
@ LAYER_SHAPES
Copper graphic shape opacity/visibility (color ignored)
Definition: layer_ids.h:246
@ LAYER_PADS
Meta control for all pads opacity/visibility (color ignored)
Definition: layer_ids.h:234
@ LAYER_DRC_WARNING
layer for drc markers with SEVERITY_WARNING
Definition: layer_ids.h:239
@ LAYER_PAD_PLATEDHOLES
to draw pad holes (plated)
Definition: layer_ids.h:218
@ GAL_LAYER_ID_END
Definition: layer_ids.h:269
@ LAYER_GP_OVERLAY
general purpose overlay
Definition: layer_ids.h:222
@ LAYER_TRACKS
Definition: layer_ids.h:216
@ LAYER_CURSOR
PCB cursor.
Definition: layer_ids.h:225
@ LAYER_AUX_ITEMS
Auxiliary items (guides, rule, etc)
Definition: layer_ids.h:226
@ LAYER_RATSNEST
Definition: layer_ids.h:208
@ LAYER_FP_TEXT
Definition: layer_ids.h:202
@ LAYER_FOOTPRINTS_BK
show footprints on back
Definition: layer_ids.h:213
@ LAYER_ANCHOR
anchor of items having an anchor point (texts, footprints)
Definition: layer_ids.h:205
@ LAYER_PADS_SMD_BK
smd pads, back layer
Definition: layer_ids.h:207
@ LAYER_PADS_TH
multilayer pads, usually with holes
Definition: layer_ids.h:217
@ LAYER_PADS_SMD_FR
smd pads, front layer
Definition: layer_ids.h:206
@ LAYER_VIA_HOLES
to draw via holes (pad holes do not use this layer)
Definition: layer_ids.h:219
@ LAYER_FP_VALUES
show footprints values (when texts are visible)
Definition: layer_ids.h:214
@ LAYER_VIA_MICROVIA
to draw micro vias
Definition: layer_ids.h:198
@ LAYER_SELECT_OVERLAY
currently selected items overlay
Definition: layer_ids.h:223
@ LAYER_VIA_THROUGH
to draw usual through hole vias
Definition: layer_ids.h:200
@ LAYER_DRC_ERROR
layer for drc markers with SEVERITY_ERROR
Definition: layer_ids.h:220
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
Definition: layer_ids.h:197
@ LAYER_VIA_BBLIND
to draw blind/buried vias
Definition: layer_ids.h:199
@ LAYER_PAD_HOLEWALLS
Definition: layer_ids.h:237
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ In22_Cu
Definition: layer_ids.h:86
@ In11_Cu
Definition: layer_ids.h:75
@ In29_Cu
Definition: layer_ids.h:93
@ In30_Cu
Definition: layer_ids.h:94
@ User_8
Definition: layer_ids.h:130
@ F_CrtYd
Definition: layer_ids.h:117
@ In17_Cu
Definition: layer_ids.h:81
@ B_Adhes
Definition: layer_ids.h:97
@ Edge_Cuts
Definition: layer_ids.h:113
@ Dwgs_User
Definition: layer_ids.h:109
@ F_Paste
Definition: layer_ids.h:101
@ In9_Cu
Definition: layer_ids.h:73
@ Cmts_User
Definition: layer_ids.h:110
@ User_6
Definition: layer_ids.h:128
@ User_7
Definition: layer_ids.h:129
@ In19_Cu
Definition: layer_ids.h:83
@ In7_Cu
Definition: layer_ids.h:71
@ In28_Cu
Definition: layer_ids.h:92
@ In26_Cu
Definition: layer_ids.h:90
@ F_Adhes
Definition: layer_ids.h:98
@ B_Mask
Definition: layer_ids.h:106
@ B_Cu
Definition: layer_ids.h:95
@ User_5
Definition: layer_ids.h:127
@ Eco1_User
Definition: layer_ids.h:111
@ F_Mask
Definition: layer_ids.h:107
@ In21_Cu
Definition: layer_ids.h:85
@ In23_Cu
Definition: layer_ids.h:87
@ B_Paste
Definition: layer_ids.h:100
@ In15_Cu
Definition: layer_ids.h:79
@ In2_Cu
Definition: layer_ids.h:66
@ User_9
Definition: layer_ids.h:131
@ UNSELECTED_LAYER
Definition: layer_ids.h:62
@ F_Fab
Definition: layer_ids.h:120
@ In10_Cu
Definition: layer_ids.h:74
@ Margin
Definition: layer_ids.h:114
@ F_SilkS
Definition: layer_ids.h:104
@ In4_Cu
Definition: layer_ids.h:68
@ B_CrtYd
Definition: layer_ids.h:116
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
@ Eco2_User
Definition: layer_ids.h:112
@ In16_Cu
Definition: layer_ids.h:80
@ In24_Cu
Definition: layer_ids.h:88
@ In1_Cu
Definition: layer_ids.h:65
@ Rescue
Definition: layer_ids.h:133
@ User_3
Definition: layer_ids.h:125
@ User_1
Definition: layer_ids.h:123
@ B_SilkS
Definition: layer_ids.h:103
@ In13_Cu
Definition: layer_ids.h:77
@ User_4
Definition: layer_ids.h:126
@ In8_Cu
Definition: layer_ids.h:72
@ In14_Cu
Definition: layer_ids.h:78
@ User_2
Definition: layer_ids.h:124
@ In12_Cu
Definition: layer_ids.h:76
@ In27_Cu
Definition: layer_ids.h:91
@ In6_Cu
Definition: layer_ids.h:70
@ In5_Cu
Definition: layer_ids.h:69
@ In3_Cu
Definition: layer_ids.h:67
@ In20_Cu
Definition: layer_ids.h:84
@ F_Cu
Definition: layer_ids.h:64
@ In18_Cu
Definition: layer_ids.h:82
@ In25_Cu
Definition: layer_ids.h:89
@ B_Fab
Definition: layer_ids.h:119
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:875
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.
Definition: util.h:65