You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

854 lines
20 KiB

12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
  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 <dick@softplc.com>
  5. * Copyright (C) 2014-2017 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. #include <bitset> // for bitset, __bitset<>::ref...
  25. #include <cassert>
  26. #include <cstdarg>
  27. #include <iostream> // for string, endl, basic_ost...
  28. #include <stddef.h> // for size_t
  29. #include <math/util.h> // for Clamp
  30. #include <layers_id_colors_and_visibility.h> // for LSET, PCB_LAYER_ID, LSEQ
  31. #include <macros.h> // for arrayDim
  32. #include <wx/debug.h> // for wxASSERT, wxASSERT_MSG
  33. #include <wx/wx.h> // for wxT, wxChar
  34. LSET::LSET( const PCB_LAYER_ID* aArray, unsigned aCount ) :
  35. BASE_SET()
  36. {
  37. for( unsigned i=0; i<aCount; ++i )
  38. set( aArray[i] );
  39. }
  40. LSET::LSET( unsigned aIdCount, int aFirst, ... ) :
  41. BASE_SET()
  42. {
  43. // The constructor, without the mandatory aFirst argument, could have been confused
  44. // by the compiler with the LSET( PCB_LAYER_ID ). With aFirst, that ambiguity is not
  45. // present. Therefore aIdCount must always be >=1.
  46. wxASSERT_MSG( aIdCount > 0, wxT( "aIdCount must be >= 1" ) );
  47. set( aFirst );
  48. if( --aIdCount )
  49. {
  50. va_list ap;
  51. va_start( ap, aFirst );
  52. for( unsigned i=0; i<aIdCount; ++i )
  53. {
  54. PCB_LAYER_ID id = (PCB_LAYER_ID) va_arg( ap, int );
  55. // printf( "%s: id:%d PCB_LAYER_ID_COUNT:%d\n", __func__, id, PCB_LAYER_ID_COUNT );
  56. assert( unsigned( id ) < PCB_LAYER_ID_COUNT );
  57. set( id );
  58. }
  59. va_end( ap );
  60. }
  61. }
  62. const wxChar* LSET::Name( PCB_LAYER_ID aLayerId )
  63. {
  64. const wxChar* txt;
  65. // using a switch to explicitly show the mapping more clearly
  66. switch( aLayerId )
  67. {
  68. case F_Cu: txt = wxT( "F.Cu" ); break;
  69. case In1_Cu: txt = wxT( "In1.Cu" ); break;
  70. case In2_Cu: txt = wxT( "In2.Cu" ); break;
  71. case In3_Cu: txt = wxT( "In3.Cu" ); break;
  72. case In4_Cu: txt = wxT( "In4.Cu" ); break;
  73. case In5_Cu: txt = wxT( "In5.Cu" ); break;
  74. case In6_Cu: txt = wxT( "In6.Cu" ); break;
  75. case In7_Cu: txt = wxT( "In7.Cu" ); break;
  76. case In8_Cu: txt = wxT( "In8.Cu" ); break;
  77. case In9_Cu: txt = wxT( "In9.Cu" ); break;
  78. case In10_Cu: txt = wxT( "In10.Cu" ); break;
  79. case In11_Cu: txt = wxT( "In11.Cu" ); break;
  80. case In12_Cu: txt = wxT( "In12.Cu" ); break;
  81. case In13_Cu: txt = wxT( "In13.Cu" ); break;
  82. case In14_Cu: txt = wxT( "In14.Cu" ); break;
  83. case In15_Cu: txt = wxT( "In15.Cu" ); break;
  84. case In16_Cu: txt = wxT( "In16.Cu" ); break;
  85. case In17_Cu: txt = wxT( "In17.Cu" ); break;
  86. case In18_Cu: txt = wxT( "In18.Cu" ); break;
  87. case In19_Cu: txt = wxT( "In19.Cu" ); break;
  88. case In20_Cu: txt = wxT( "In20.Cu" ); break;
  89. case In21_Cu: txt = wxT( "In21.Cu" ); break;
  90. case In22_Cu: txt = wxT( "In22.Cu" ); break;
  91. case In23_Cu: txt = wxT( "In23.Cu" ); break;
  92. case In24_Cu: txt = wxT( "In24.Cu" ); break;
  93. case In25_Cu: txt = wxT( "In25.Cu" ); break;
  94. case In26_Cu: txt = wxT( "In26.Cu" ); break;
  95. case In27_Cu: txt = wxT( "In27.Cu" ); break;
  96. case In28_Cu: txt = wxT( "In28.Cu" ); break;
  97. case In29_Cu: txt = wxT( "In29.Cu" ); break;
  98. case In30_Cu: txt = wxT( "In30.Cu" ); break;
  99. case B_Cu: txt = wxT( "B.Cu" ); break;
  100. // Technicals
  101. case B_Adhes: txt = wxT( "B.Adhes" ); break;
  102. case F_Adhes: txt = wxT( "F.Adhes" ); break;
  103. case B_Paste: txt = wxT( "B.Paste" ); break;
  104. case F_Paste: txt = wxT( "F.Paste" ); break;
  105. case B_SilkS: txt = wxT( "B.SilkS" ); break;
  106. case F_SilkS: txt = wxT( "F.SilkS" ); break;
  107. case B_Mask: txt = wxT( "B.Mask" ); break;
  108. case F_Mask: txt = wxT( "F.Mask" ); break;
  109. // Users
  110. case Dwgs_User: txt = wxT( "Dwgs.User" ); break;
  111. case Cmts_User: txt = wxT( "Cmts.User" ); break;
  112. case Eco1_User: txt = wxT( "Eco1.User" ); break;
  113. case Eco2_User: txt = wxT( "Eco2.User" ); break;
  114. case Edge_Cuts: txt = wxT( "Edge.Cuts" ); break;
  115. case Margin: txt = wxT( "Margin" ); break;
  116. // Footprint
  117. case F_CrtYd: txt = wxT( "F.CrtYd" ); break;
  118. case B_CrtYd: txt = wxT( "B.CrtYd" ); break;
  119. case F_Fab: txt = wxT( "F.Fab" ); break;
  120. case B_Fab: txt = wxT( "B.Fab" ); break;
  121. // Rescue
  122. case Rescue: txt = wxT( "Rescue" ); break;
  123. default:
  124. std::cout << aLayerId << std::endl;
  125. wxASSERT_MSG( 0, wxT( "aLayerId out of range" ) );
  126. txt = wxT( "BAD INDEX!" ); break;
  127. }
  128. return txt;
  129. }
  130. LSEQ LSET::CuStack() const
  131. {
  132. // desired sequence
  133. static const PCB_LAYER_ID sequence[] = {
  134. F_Cu,
  135. In1_Cu,
  136. In2_Cu,
  137. In3_Cu,
  138. In4_Cu,
  139. In5_Cu,
  140. In6_Cu,
  141. In7_Cu,
  142. In8_Cu,
  143. In9_Cu,
  144. In10_Cu,
  145. In11_Cu,
  146. In12_Cu,
  147. In13_Cu,
  148. In14_Cu,
  149. In15_Cu,
  150. In16_Cu,
  151. In17_Cu,
  152. In18_Cu,
  153. In19_Cu,
  154. In20_Cu,
  155. In21_Cu,
  156. In22_Cu,
  157. In23_Cu,
  158. In24_Cu,
  159. In25_Cu,
  160. In26_Cu,
  161. In27_Cu,
  162. In28_Cu,
  163. In29_Cu,
  164. In30_Cu,
  165. B_Cu, // 31
  166. };
  167. return Seq( sequence, arrayDim( sequence ) );
  168. }
  169. LSEQ LSET::Technicals( LSET aSetToOmit ) const
  170. {
  171. // desired sequence
  172. static const PCB_LAYER_ID sequence[] = {
  173. F_Adhes,
  174. B_Adhes,
  175. F_Paste,
  176. B_Paste,
  177. F_SilkS,
  178. B_SilkS,
  179. F_Mask,
  180. B_Mask,
  181. F_CrtYd,
  182. B_CrtYd,
  183. F_Fab,
  184. B_Fab,
  185. };
  186. LSET subset = ~aSetToOmit & *this;
  187. return subset.Seq( sequence, arrayDim( sequence ) );
  188. }
  189. LSEQ LSET::Users() const
  190. {
  191. // desired
  192. static const PCB_LAYER_ID sequence[] = {
  193. Dwgs_User,
  194. Cmts_User,
  195. Eco1_User,
  196. Eco2_User,
  197. Edge_Cuts,
  198. Margin,
  199. };
  200. return Seq( sequence, arrayDim( sequence ) );
  201. }
  202. LSEQ LSET::TechAndUserUIOrder() const
  203. {
  204. static const PCB_LAYER_ID sequence[] = {
  205. F_Adhes,
  206. B_Adhes,
  207. F_Paste,
  208. B_Paste,
  209. F_SilkS,
  210. B_SilkS,
  211. F_Mask,
  212. B_Mask,
  213. Dwgs_User,
  214. Cmts_User,
  215. Eco1_User,
  216. Eco2_User,
  217. Edge_Cuts,
  218. Margin,
  219. F_CrtYd,
  220. B_CrtYd,
  221. F_Fab,
  222. B_Fab,
  223. };
  224. return Seq( sequence, arrayDim( sequence ) );
  225. }
  226. std::string LSET::FmtBin() const
  227. {
  228. std::string ret;
  229. int bit_count = size();
  230. for( int bit=0; bit<bit_count; ++bit )
  231. {
  232. if( bit )
  233. {
  234. if( !( bit % 8 ) )
  235. ret += '|';
  236. else if( !( bit % 4 ) )
  237. ret += '_';
  238. }
  239. ret += (*this)[bit] ? '1' : '0';
  240. }
  241. // reverse of string
  242. return std::string( ret.rbegin(), ret.rend() );
  243. }
  244. std::string LSET::FmtHex() const
  245. {
  246. std::string ret;
  247. static const char hex[] = "0123456789abcdef";
  248. size_t nibble_count = ( size() + 3 ) / 4;
  249. for( size_t nibble = 0; nibble < nibble_count; ++nibble )
  250. {
  251. unsigned int ndx = 0;
  252. // test 4 consecutive bits and set ndx to 0-15
  253. for( size_t nibble_bit = 0; nibble_bit < 4; ++nibble_bit )
  254. {
  255. size_t nibble_pos = nibble_bit + ( nibble * 4 );
  256. // make sure it's not extra bits that dont exist in the bitset but need to in the hex format
  257. if( nibble_pos >= size() )
  258. break;
  259. if( ( *this )[nibble_pos] )
  260. ndx |= ( 1 << nibble_bit );
  261. }
  262. if( nibble && !( nibble % 8 ) )
  263. ret += '_';
  264. assert( ndx < arrayDim( hex ) );
  265. ret += hex[ndx];
  266. }
  267. // reverse of string
  268. return std::string( ret.rbegin(), ret.rend() );
  269. }
  270. int LSET::ParseHex( const char* aStart, int aCount )
  271. {
  272. LSET tmp;
  273. const char* rstart = aStart + aCount - 1;
  274. const char* rend = aStart - 1;
  275. const int bitcount = size();
  276. int nibble_ndx = 0;
  277. while( rstart > rend )
  278. {
  279. int cc = *rstart--;
  280. if( cc == '_' )
  281. continue;
  282. int nibble;
  283. if( cc >= '0' && cc <= '9' )
  284. nibble = cc - '0';
  285. else if( cc >= 'a' && cc <= 'f' )
  286. nibble = cc - 'a' + 10;
  287. else if( cc >= 'A' && cc <= 'F' )
  288. nibble = cc - 'A' + 10;
  289. else
  290. break;
  291. int bit = nibble_ndx * 4;
  292. for( int ndx=0; bit<bitcount && ndx<4; ++bit, ++ndx )
  293. if( nibble & (1<<ndx) )
  294. tmp.set( bit );
  295. if( bit >= bitcount )
  296. break;
  297. ++nibble_ndx;
  298. }
  299. int byte_count = aStart + aCount - 1 - rstart;
  300. assert( byte_count >= 0 );
  301. if( byte_count > 0 )
  302. *this = tmp;
  303. return byte_count;
  304. }
  305. LSEQ LSET::Seq( const PCB_LAYER_ID* aWishListSequence, unsigned aCount ) const
  306. {
  307. LSEQ ret;
  308. #if defined(DEBUG) && 0
  309. LSET dup_detector;
  310. for( unsigned i=0; i<aCount; ++i )
  311. {
  312. PCB_LAYER_ID id = aWishListSequence[i];
  313. if( test( id ) )
  314. {
  315. wxASSERT_MSG( !dup_detector[id], wxT( "Duplicate in aWishListSequence" ) );
  316. dup_detector[id] = true;
  317. ret.push_back( id );
  318. }
  319. }
  320. #else
  321. for( unsigned i=0; i<aCount; ++i )
  322. {
  323. PCB_LAYER_ID id = aWishListSequence[i];
  324. if( test( id ) )
  325. ret.push_back( id );
  326. }
  327. #endif
  328. return ret;
  329. }
  330. LSEQ LSET::Seq() const
  331. {
  332. LSEQ ret;
  333. for( unsigned i=0; i<size(); ++i )
  334. {
  335. if( test(i) )
  336. ret.push_back( PCB_LAYER_ID( i ) );
  337. }
  338. return ret;
  339. }
  340. LSEQ LSET::SeqStackupBottom2Top() const
  341. {
  342. // bottom-to-top stack-up layers
  343. static const PCB_LAYER_ID sequence[] = {
  344. B_Fab,
  345. B_CrtYd,
  346. B_Adhes,
  347. B_SilkS,
  348. B_Paste,
  349. B_Mask,
  350. B_Cu,
  351. In30_Cu,
  352. In29_Cu,
  353. In28_Cu,
  354. In27_Cu,
  355. In26_Cu,
  356. In25_Cu,
  357. In24_Cu,
  358. In23_Cu,
  359. In22_Cu,
  360. In21_Cu,
  361. In20_Cu,
  362. In19_Cu,
  363. In18_Cu,
  364. In17_Cu,
  365. In16_Cu,
  366. In15_Cu,
  367. In14_Cu,
  368. In13_Cu,
  369. In12_Cu,
  370. In11_Cu,
  371. In10_Cu,
  372. In9_Cu,
  373. In8_Cu,
  374. In7_Cu,
  375. In6_Cu,
  376. In5_Cu,
  377. In4_Cu,
  378. In3_Cu,
  379. In2_Cu,
  380. In1_Cu,
  381. F_Cu,
  382. F_Mask,
  383. F_Paste,
  384. F_SilkS,
  385. F_Adhes,
  386. F_CrtYd,
  387. F_Fab,
  388. Dwgs_User,
  389. Cmts_User,
  390. Eco1_User,
  391. Eco2_User,
  392. Margin,
  393. Edge_Cuts,
  394. };
  395. return Seq( sequence, arrayDim( sequence ) );
  396. }
  397. PCB_LAYER_ID FlipLayer( PCB_LAYER_ID aLayerId, int aCopperLayersCount )
  398. {
  399. switch( aLayerId )
  400. {
  401. case B_Cu: return F_Cu;
  402. case F_Cu: return B_Cu;
  403. case B_SilkS: return F_SilkS;
  404. case F_SilkS: return B_SilkS;
  405. case B_Adhes: return F_Adhes;
  406. case F_Adhes: return B_Adhes;
  407. case B_Mask: return F_Mask;
  408. case F_Mask: return B_Mask;
  409. case B_Paste: return F_Paste;
  410. case F_Paste: return B_Paste;
  411. case B_CrtYd: return F_CrtYd;
  412. case F_CrtYd: return B_CrtYd;
  413. case B_Fab: return F_Fab;
  414. case F_Fab: return B_Fab;
  415. default: // change internal layer if aCopperLayersCount is >= 4
  416. if( IsCopperLayer( aLayerId ) && aCopperLayersCount >= 4 )
  417. {
  418. // internal copper layers count is aCopperLayersCount-2
  419. PCB_LAYER_ID fliplayer = PCB_LAYER_ID(aCopperLayersCount - 2 - ( aLayerId - In1_Cu ) );
  420. // Ensure fliplayer has a value which does not crash pcbnew:
  421. if( fliplayer < F_Cu )
  422. fliplayer = F_Cu;
  423. if( fliplayer > B_Cu )
  424. fliplayer = B_Cu;
  425. return fliplayer;
  426. }
  427. // No change for the other layers
  428. return aLayerId;
  429. }
  430. }
  431. LSET FlipLayerMask( LSET aMask, int aCopperLayersCount )
  432. {
  433. // layers on physical outside of a board:
  434. const static LSET and_mask( 16, // !! update count
  435. B_Cu, F_Cu,
  436. B_SilkS, F_SilkS,
  437. B_Adhes, F_Adhes,
  438. B_Mask, F_Mask,
  439. B_Paste, F_Paste,
  440. B_Adhes, F_Adhes,
  441. B_CrtYd, F_CrtYd,
  442. B_Fab, F_Fab
  443. );
  444. LSET newMask = aMask & ~and_mask;
  445. if( aMask[B_Cu] )
  446. newMask.set( F_Cu );
  447. if( aMask[F_Cu] )
  448. newMask.set( B_Cu );
  449. if( aMask[B_SilkS] )
  450. newMask.set( F_SilkS );
  451. if( aMask[F_SilkS] )
  452. newMask.set( B_SilkS );
  453. if( aMask[B_Adhes] )
  454. newMask.set( F_Adhes );
  455. if( aMask[F_Adhes] )
  456. newMask.set( B_Adhes );
  457. if( aMask[B_Mask] )
  458. newMask.set( F_Mask );
  459. if( aMask[F_Mask] )
  460. newMask.set( B_Mask );
  461. if( aMask[B_Paste] )
  462. newMask.set( F_Paste );
  463. if( aMask[F_Paste] )
  464. newMask.set( B_Paste );
  465. if( aMask[B_Adhes] )
  466. newMask.set( F_Adhes );
  467. if( aMask[F_Adhes] )
  468. newMask.set( B_Adhes );
  469. if( aMask[B_CrtYd] )
  470. newMask.set( F_CrtYd );
  471. if( aMask[F_CrtYd] )
  472. newMask.set( B_CrtYd );
  473. if( aMask[B_Fab] )
  474. newMask.set( F_Fab );
  475. if( aMask[F_Fab] )
  476. newMask.set( B_Fab );
  477. if( aCopperLayersCount >= 4 ) // Internal layers exist
  478. {
  479. LSET internalMask = aMask & LSET::InternalCuMask();
  480. if( internalMask != LSET::InternalCuMask() )
  481. {
  482. // the mask does not include all internal layers. Therefore
  483. // the flipped mask for internal copper layers must be built
  484. int innerLayerCnt = aCopperLayersCount -2;
  485. // the flipped mask is the innerLayerCnt bits rewritten in reverse order
  486. // ( bits innerLayerCnt to 1 rewritten in bits 1 to innerLayerCnt )
  487. for( int ii = 0; ii < innerLayerCnt; ii++ )
  488. {
  489. if( internalMask[innerLayerCnt - ii] )
  490. {
  491. newMask.set( ii + In1_Cu );
  492. }
  493. else
  494. {
  495. newMask.reset( ii + In1_Cu );
  496. }
  497. }
  498. }
  499. }
  500. return newMask;
  501. }
  502. PCB_LAYER_ID LSET::ExtractLayer() const
  503. {
  504. unsigned set_count = count();
  505. if( !set_count )
  506. return UNSELECTED_LAYER;
  507. else if( set_count > 1 )
  508. return UNDEFINED_LAYER;
  509. for( unsigned i=0; i < size(); ++i )
  510. {
  511. if( test( i ) )
  512. return PCB_LAYER_ID( i );
  513. }
  514. wxASSERT( 0 ); // set_count was verified as 1 above, what did you break?
  515. return UNDEFINED_LAYER;
  516. }
  517. LSET LSET::FrontAssembly()
  518. {
  519. static const PCB_LAYER_ID front_assembly[] = {
  520. F_SilkS,
  521. F_Mask,
  522. F_Fab,
  523. };
  524. static const LSET saved( front_assembly, arrayDim( front_assembly ) );
  525. return saved;
  526. }
  527. LSET LSET::BackAssembly()
  528. {
  529. static const PCB_LAYER_ID back_assembly[] = {
  530. B_SilkS,
  531. B_Mask,
  532. B_Fab,
  533. };
  534. static const LSET saved( back_assembly, arrayDim( back_assembly ) );
  535. return saved;
  536. }
  537. LSET LSET::InternalCuMask()
  538. {
  539. static const PCB_LAYER_ID cu_internals[] = {
  540. In1_Cu,
  541. In2_Cu,
  542. In3_Cu,
  543. In4_Cu,
  544. In5_Cu,
  545. In6_Cu,
  546. In7_Cu,
  547. In8_Cu,
  548. In9_Cu,
  549. In10_Cu,
  550. In11_Cu,
  551. In12_Cu,
  552. In13_Cu,
  553. In14_Cu,
  554. In15_Cu,
  555. In16_Cu,
  556. In17_Cu,
  557. In18_Cu,
  558. In19_Cu,
  559. In20_Cu,
  560. In21_Cu,
  561. In22_Cu,
  562. In23_Cu,
  563. In24_Cu,
  564. In25_Cu,
  565. In26_Cu,
  566. In27_Cu,
  567. In28_Cu,
  568. In29_Cu,
  569. In30_Cu,
  570. };
  571. static const LSET saved( cu_internals, arrayDim( cu_internals ) );
  572. return saved;
  573. }
  574. LSET LSET::AllCuMask( int aCuLayerCount )
  575. {
  576. // retain all in static as the full set, which is a common case.
  577. static const LSET all = InternalCuMask().set( F_Cu ).set( B_Cu );
  578. if( aCuLayerCount == MAX_CU_LAYERS )
  579. return all;
  580. // subtract out some Cu layers not wanted in the mask.
  581. LSET ret = all;
  582. int clear_count = MAX_CU_LAYERS - aCuLayerCount;
  583. clear_count = Clamp( 0, clear_count, MAX_CU_LAYERS - 2 );
  584. for( LAYER_NUM elem=In30_Cu; clear_count; --elem, --clear_count )
  585. {
  586. ret.set( elem, false );
  587. }
  588. return ret;
  589. }
  590. LSET LSET::AllNonCuMask()
  591. {
  592. static const LSET saved = LSET().set() & ~AllCuMask();
  593. return saved;
  594. }
  595. LSET LSET::ExternalCuMask()
  596. {
  597. static const LSET saved( 2, F_Cu, B_Cu );
  598. return saved;
  599. }
  600. LSET LSET::AllLayersMask()
  601. {
  602. static const LSET saved = LSET().set();
  603. return saved;
  604. }
  605. LSET LSET::BackTechMask()
  606. {
  607. static const LSET saved( 6, B_SilkS, B_Mask, B_Adhes, B_Paste, B_CrtYd, B_Fab );
  608. return saved;
  609. }
  610. LSET LSET::BackBoardTechMask()
  611. {
  612. static const LSET saved( 4, B_SilkS, B_Mask, B_Adhes, B_Paste );
  613. return saved;
  614. }
  615. LSET LSET::FrontTechMask()
  616. {
  617. static const LSET saved( 6, F_SilkS, F_Mask, F_Adhes, F_Paste, F_CrtYd, F_Fab );
  618. return saved;
  619. }
  620. LSET LSET::FrontBoardTechMask()
  621. {
  622. static const LSET saved( 4, F_SilkS, F_Mask, F_Adhes, F_Paste );
  623. return saved;
  624. }
  625. LSET LSET::AllTechMask()
  626. {
  627. static const LSET saved = BackTechMask() | FrontTechMask();
  628. return saved;
  629. }
  630. LSET LSET::AllBoardTechMask()
  631. {
  632. static const LSET saved = BackBoardTechMask() | FrontBoardTechMask();
  633. return saved;
  634. }
  635. LSET LSET::UserMask()
  636. {
  637. static const LSET saved( 6,
  638. Dwgs_User,
  639. Cmts_User,
  640. Eco1_User,
  641. Eco2_User,
  642. Edge_Cuts,
  643. Margin
  644. );
  645. return saved;
  646. }
  647. LSET LSET::FrontMask()
  648. {
  649. static const LSET saved = FrontTechMask().set( F_Cu );
  650. return saved;
  651. }
  652. LSET LSET::BackMask()
  653. {
  654. static const LSET saved = BackTechMask().set( B_Cu );
  655. return saved;
  656. }
  657. LSET LSET::ForbiddenFootprintLayers()
  658. {
  659. static const LSET saved = InternalCuMask().set( Edge_Cuts ).set( Margin );
  660. return saved;
  661. }
  662. LSET LSET::ForbiddenTextLayers()
  663. {
  664. static const LSET saved( 1, Edge_Cuts );
  665. return saved;
  666. }
  667. LSEQ LSET::UIOrder() const
  668. {
  669. LSEQ order = CuStack();
  670. LSEQ techuser = TechAndUserUIOrder();
  671. order.insert( order.end(), techuser.begin(), techuser.end() );
  672. return order;
  673. }
  674. PCB_LAYER_ID ToLAYER_ID( int aLayer )
  675. {
  676. wxASSERT( aLayer < GAL_LAYER_ID_END );
  677. return PCB_LAYER_ID( aLayer );
  678. }