33#include <fmt/format.h>
44#include <magic_enum.hpp>
90#include <wx/mstream.h>
99constexpr double INT_LIMIT = std::numeric_limits<int>::max() - 10;
101using namespace PCB_KEYS_T;
142 for(
int i=1; i<=14; ++i )
144 std::string key = fmt::format(
"Inner{}.Cu", i );
155 TIME_PT curTime = CLOCK::now();
156 unsigned curLine = reader->LineNumber();
159 if(
delta > std::chrono::milliseconds( 250 ) )
178 while( ( token = NextTok() ) != T_EOF )
180 if( token == T_LEFT )
183 if( token == T_RIGHT )
200 m_netCodes.resize(
static_cast<std::size_t
>( aIndex ) + 1 );
242 else if( token == T_no )
245 Expecting(
"yes or no" );
257 else if( token == T_no )
259 else if( token == T_none )
262 Expecting(
"yes, no or none" );
273 bool ret = aDefaultValue;
275 if( PrevTok() == T_LEFT )
280 if(
static_cast<int>( token ) ==
DSN_RIGHT )
281 return aDefaultValue;
283 if( token == T_yes || token == T_true )
285 else if( token == T_no || token == T_false )
288 Expecting(
"yes or no" );
295 return aDefaultValue;
304 int token = NextTok();
313 _(
"Invalid net ID in\nfile: %s;\nline: %d\noffset: %d." ),
314 CurSource(), CurLineNumber(), CurOffset() );
321 if( !IsSymbol( token ) )
323 Expecting(
"net name" );
329 wxString netName( FromUTF8() );
353 int year, month, day;
362 if( day <= 0 || month <= 0 || month > 12 ||
363 day > wxDateTime::GetNumberOfDays( (wxDateTime::Month)( month - 1 ), year ) )
370 wxDateTime date( day, (wxDateTime::Month)( month - 1 ), year, 0, 0, 0, 0 );
371 return date.FormatDate();
377 if( CurTok() != T_LEFT )
397 if( CurTok() != T_LEFT )
416 bool has_start =
false;
417 bool has_mid =
false;
418 bool has_end =
false;
420 VECTOR2I arc_start, arc_mid, arc_end;
422 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
424 if( token != T_LEFT )
450 Expecting(
"start, mid or end" );
457 Expecting(
"start" );
465 SHAPE_ARC arc( arc_start, arc_mid, arc_end, 0 );
469 if( token != T_RIGHT )
470 Expecting( T_RIGHT );
475 Expecting(
"xy or arc" );
512 return { pName, pValue };
519 wxString key = FromUTF8();
521 wxString value = FromUTF8();
530 wxString key = FromUTF8();
532 wxString value = FromUTF8();
544 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
546 if( token == T_LEFT )
549 if( token == T_variant )
551 wxString variantName;
552 wxString description;
554 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
556 if( token == T_LEFT )
563 variantName = FromUTF8();
569 description = FromUTF8();
574 Expecting(
"name or description" );
578 if( !variantName.IsEmpty() )
580 m_board->AddVariant( variantName );
582 if( !description.IsEmpty() )
583 m_board->SetVariantDescription( variantName, description );
588 Expecting( T_variant );
599 wxString variantName;
602 bool hasExcludeFromBOM =
false;
603 bool excludeFromBOM =
false;
604 bool hasExcludeFromSim =
false;
605 bool excludeFromSim =
false;
606 bool hasExcludeFromPosFiles =
false;
607 bool excludeFromPosFiles =
false;
608 std::vector<std::pair<wxString, wxString>> fields;
610 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
612 if( token == T_LEFT )
619 variantName = FromUTF8();
628 case T_exclude_from_bom:
630 hasExcludeFromBOM =
true;
633 case T_exclude_from_sim:
635 hasExcludeFromSim =
true;
638 case T_exclude_from_pos_files:
640 hasExcludeFromPosFiles =
true;
648 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
650 if( token == T_LEFT )
653 if( token == T_name )
656 fieldName = FromUTF8();
659 else if( token == T_value )
662 fieldValue = FromUTF8();
667 Expecting(
"name or value" );
671 if( !fieldName.IsEmpty() )
672 fields.emplace_back( fieldName, fieldValue );
678 Expecting(
"name, dnp, exclude_from_bom, exclude_from_sim, exclude_from_pos_files, or field" );
682 if( variantName.IsEmpty() )
693 if( hasExcludeFromBOM )
696 if( hasExcludeFromSim )
699 if( hasExcludeFromPosFiles )
702 for(
const auto& [fieldName, fieldValue] : fields )
713 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
715 if( token == T_LEFT )
724 case T_allow_two_segments:
728 case T_prefer_zone_connections:
732 case T_best_length_ratio:
742 case T_best_width_ratio:
768 Expecting(
"enabled, allow_two_segments, prefer_zone_connections, best_length_ratio, "
769 "max_length, best_width_ratio, max_width, curve_points or filter_ratio" );
777 wxCHECK_RET( CurTok() == T_effects,
778 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as EDA_TEXT." ) );
796 bool foundTextSize =
false;
798 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
800 if( token == T_LEFT )
806 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
808 if( token == T_LEFT )
827 foundTextSize =
true;
850 Expecting(
"face, size, line_spacing, thickness, bold, or italic" );
857 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
859 if( token == T_LEFT )
869 default: Expecting(
"left, right, top, bottom, or mirror" );
886 Expecting(
"font, justify, or hide" );
894 const double defaultTextSize = 1.524 *
pcbIUScale.IU_PER_MM;
908 NeedSYMBOLorNUMBER();
909 wxString cacheText =
From_UTF8( CurText() );
912 text->SetupRenderCache( cacheText,
text->GetFont(), cacheAngle, { 0, 0 } );
914 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
916 if( token != T_LEFT )
921 if( token != T_polygon )
922 Expecting( T_polygon );
926 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
928 if( token != T_LEFT )
938 while( (token = NextTok() ) != T_RIGHT )
949 text->AddRenderCacheGlyph( poly );
956 if( !aFileNameAlreadyParsed )
958 wxCHECK_MSG( CurTok() == T_model,
nullptr,
959 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as FP_3DMODEL." ) );
961 NeedSYMBOLorNUMBER();
969 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
971 if( token == T_LEFT )
1015 if( token != T_xyz )
1033 if( token != T_xyz )
1048 if( token != T_xyz )
1060 Expecting(
"at, hide, opacity, offset, scale, or rotate" );
1078 if( CurTok() != T_LEFT )
1081 if( NextTok() != T_kicad_pcb)
1099 std::unique_ptr<wxArrayString> initial_comments( ReadCommentLines() );
1104 Unexpected( token );
1106 if( token != T_LEFT )
1107 Expecting( T_LEFT );
1128 err.Printf(
_(
"Unknown token '%s'" ), FromUTF8() );
1146 textItem->ResolveFont( embeddedFonts );
1162 boost::heap_clone_allocator,
1163 std::allocator<std::pair<const wxString, void*>>>& aFootprints )
1167 std::unique_ptr<wxArrayString> initial_comments( ReadCommentLines() );
1169 auto parseFp = [&]()
1171 std::unique_ptr<FOOTPRINT> footprint(
parseFOOTPRINT( initial_comments.release() ) );
1175 wxString fpName = footprint->GetFPID().GetLibItemName();
1176 footprint->SetFPID(
LIB_ID( wxEmptyString, fpName ) );
1179 footprint->SetLocked(
false );
1185 aFootprints.insert( fpName,
new FP_CACHE_ENTRY( footprint.release(), fn ) );
1189 for( token = CurTok(); token != T_RIGHT; token = NextTok() )
1191 if( token != T_LEFT )
1192 Expecting( T_LEFT );
1203 case T_kicad_footprint_lib:
1205 bool hasVersion =
false;
1212 Expecting(
"version" );
1218 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
1220 if( token != T_LEFT )
1221 Expecting( T_LEFT );
1230 Unexpected( token );
1234 int versionNumber =
parseInt(
"version" );
1248 case T_generator_version:
1261 Expecting(
"footprint, generator, generator_version, or version" );
1271 Expecting(
"footprint or kicad_footprint_lib" );
1296 std::map<wxString, wxString> properties;
1310 std::vector<BOARD_ITEM*> bulkAddedItems;
1313 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
1317 if( token != T_LEFT )
1318 Expecting( T_LEFT );
1329 m_board->SetGenerator( FromUTF8() );
1340 m_board->SetGenerator( FromUTF8() );
1344 case T_generator_version:
1398 m_board->m_LegacyNetclassesLoaded =
true;
1408 case T_gr_ellipse_arc:
1411 bulkAddedItems.push_back( item );
1417 bulkAddedItems.push_back( item );
1423 bulkAddedItems.push_back( item );
1429 bulkAddedItems.push_back( item );
1435 bulkAddedItems.push_back( item );
1441 bulkAddedItems.push_back( item );
1444 case T_stackup_table:
1447 bulkAddedItems.push_back( item );
1453 bulkAddedItems.push_back( item );
1459 bulkAddedItems.push_back( item );
1465 bulkAddedItems.push_back( item );
1472 bulkAddedItems.push_back( item );
1479 bulkAddedItems.push_back( track );
1488 bulkAddedItems.push_back( arc );
1508 bulkAddedItems.push_back( item );
1525 bulkAddedItems.push_back( item );
1532 bulkAddedItems.push_back( item );
1538 bulkAddedItems.push_back( item );
1544 bulkAddedItems.push_back( item );
1547 case T_embedded_fonts:
1554 embedFonts = embedFonts ||
m_board->GetEmbeddedFiles()->GetAreFontsEmbedded();
1556 m_board->GetEmbeddedFiles()->SetAreFontsEmbedded( embedFonts );
1561 case T_embedded_files:
1564 embeddedFilesParser.SyncLineReaderWith( *
this );
1578 for(
int tok = embeddedFilesParser.NextTok();
1580 tok = embeddedFilesParser.NextTok() )
1584 else if( tok ==
DSN_RIGHT && --depth < 0 )
1589 SyncLineReaderWith( embeddedFilesParser );
1595 err.Printf(
_(
"Unknown token '%s'" ), FromUTF8() );
1600 if( bulkAddedItems.size() > 0 )
1601 m_board->FinalizeBulkAdd( bulkAddedItems );
1603 m_board->SetProperties( properties );
1612 static_cast<PCB_BARCODE*
>( bc_item )->AssembleBarcode();
1617 for(
BOARD_ITEM* bc_item : fp->GraphicalItems() )
1620 static_cast<PCB_BARCODE*
>( bc_item )->AssembleBarcode();
1627 wxString msg, undefinedLayerNames, destLayerName;
1631 if( !undefinedLayerNames.IsEmpty() )
1632 undefinedLayerNames += wxT(
", " );
1634 undefinedLayerNames += layerName;
1637 destLayerName =
m_board->GetLayerName( destLayer );
1641 msg.Printf(
_(
"Items found on undefined layers (%s).\n"
1642 "Do you wish to rescue them to the %s layer?\n"
1644 "Zones will need to be refilled." ),
1645 undefinedLayerNames, destLayerName );
1656 const auto visitItem = [&](
BOARD_ITEM& curr_item )
1658 LSET layers = curr_item.GetLayerSet();
1660 if( !layers.test(
Rescue ) )
1663 layers.
set( destLayer );
1668 if( layers.count() == 1 )
1669 curr_item.SetLayer( destLayer );
1671 curr_item.SetLayerSet( layers );
1684 via->LayerPair( &top_layer, &bottom_layer );
1688 if( top_layer ==
Rescue )
1691 if( bottom_layer ==
Rescue )
1692 bottom_layer =
B_Cu;
1694 via->SetLayerPair( top_layer, bottom_layer );
1699 visitItem( *track );
1707 visitItem( *drawing );
1711 for(
BOARD_ITEM* drawing : fp->GraphicalItems() )
1712 visitItem( *drawing );
1717 for(
PCB_FIELD* field : fp->GetFields() )
1718 visitItem( *field );
1728 THROW_IO_ERRORF(
_(
"One or more items were found on undefined layers (%s). Open the board in the "
1729 "PCB Editor to resolve." ),
1730 undefinedLayerNames );
1740 ZONE* z =
static_cast<ZONE*
>( zone );
1748 std::map<KIID, KIID> appendedSets;
1756 z->SetLinkSet( appendedSets.try_emplace( z->GetLinkSet(),
KIID() ).first->second );
1763 z->SetRepeatOptions( opts );
1773 for(
int i = 0; i < 2; ++i )
1775 const KIID& original = net->GetTerminalPadUuid( i );
1782 net->SetTerminalPadUuid( i, it->second );
1787 net->ResolveTerminalPads(
m_board );
1792 m_board->RefreshDrillSymbolLayers();
1800 BOARD* board =
dynamic_cast<BOARD*
>( aParent );
1806 std::unordered_map<KIID, BOARD_ITEM*> fpItemMap;
1813 fpItemMap.insert( { child->
m_Uuid, child } );
1825 else if( footprint )
1827 auto it = fpItemMap.find( aId );
1829 return it != fpItemMap.end() ? it->second :
nullptr;
1840 std::vector<GROUP_INFO*> groupTypeObjects;
1843 groupTypeObjects.emplace_back( &groupInfo );
1846 groupTypeObjects.emplace_back( &genInfo );
1848 for(
GROUP_INFO* groupInfo : groupTypeObjects )
1860 THROW_IO_ERRORF(
_(
"Cannot create generated object of type '%s'" ), genInfo->genType );
1865 for(
auto& [
name, item] : genInfo->templates )
1871 group->SetName( groupInfo->name );
1874 group->SetUuidDirect( groupInfo->uuid );
1875 group->SetCustomProperties( groupInfo->customProperties );
1877 if( groupInfo->libId.IsValid() )
1878 group->SetDesignBlockLibId( groupInfo->libId );
1880 if( groupInfo->locked )
1881 group->SetLocked(
true );
1889 fpItemMap.insert( {
group->m_Uuid,
group } );
1897 for(
GROUP_INFO* groupInfo : groupTypeObjects )
1901 for(
const KIID& aUuid : groupInfo->memberUuids )
1908 item = getItem( aUuid );
1914 group->AddItem( item );
1922 for(
BOARD_ITEM* item : gen->GetBoardItems() )
1926 gen->SetLayer( track->GetLayer() );
1936 m_board->GroupsSanityCheck(
true );
1942 wxCHECK_RET( CurTok() == T_kicad_pcb,
1943 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a header." ) );
1949 if( tok == T_version )
1971 wxCHECK_RET( CurTok() == T_general,
1972 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a general section." ) );
1976 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
1978 if( token != T_LEFT )
1979 Expecting( T_LEFT );
1990 case T_legacy_teardrops:
1995 while( ( token = NextTok() ) != T_RIGHT )
1997 if( !IsSymbol( token ) && token != T_NUMBER )
1998 Expecting(
"symbol or number" );
2007 wxCHECK_RET( ( CurTok() == T_page &&
m_requiredVersion <= 20200119 ) || CurTok() == T_paper,
2008 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a PAGE_INFO." ) );
2015 wxString pageType = FromUTF8();
2017 if( !pageInfo.
SetType( pageType ) )
2020 err.Printf(
_(
"Page type '%s' is not valid." ), FromUTF8() );
2047 if( token == T_portrait )
2052 else if( token != T_RIGHT )
2054 Expecting(
"portrait|)" );
2057 m_board->SetPageSettings( pageInfo );
2063 wxCHECK_RET( CurTok() == T_title_block,
2064 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as TITLE_BLOCK." ) );
2069 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2071 if( token != T_LEFT )
2072 Expecting( T_LEFT );
2085 titleBlock.
SetDate( FromUTF8() );
2100 int commentNumber =
parseInt(
"comment" );
2102 switch( commentNumber )
2151 err.Printf( wxT(
"%d is not a valid title block comment number" ), commentNumber );
2159 Expecting(
"title, date, rev, company, or comment" );
2165 m_board->SetTitleBlock( titleBlock );
2174 std::string userName;
2176 bool isVisible =
true;
2180 if( CurTok() != T_LEFT )
2181 Expecting( T_LEFT );
2184 int layer_num =
parseInt(
"layer index" );
2186 NeedSYMBOLorNUMBER();
2195 if( token == T_hide )
2200 else if( token == T_STRING )
2202 userName = CurText();
2205 else if( token != T_RIGHT )
2207 Expecting(
"hide, user defined name, or )" );
2210 aLayer->
m_type = LAYER::ParseType( type.c_str() );
2230 int dielectric_idx = 1;
2238 std::set<PCB_LAYER_ID> seenBrdLayers;
2239 bool duplicatedStackup =
false;
2241 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2243 if( CurTok() != T_LEFT )
2244 Expecting( T_LEFT );
2248 if( token != T_layer )
2252 case T_copper_finish:
2258 case T_edge_plating:
2264 case T_dielectric_constraints:
2270 case T_edge_connector:
2274 if( token == T_yes )
2276 else if( token == T_bevelled )
2282 case T_castellated_pads:
2310 layerId = candidate;
2326 else if( !( layerId & 1 ) )
2329 std::unique_ptr<BOARD_STACKUP_ITEM> itemOwner;
2332 if( layerId !=
UNDEFINED_LAYER && !seenBrdLayers.insert( layerId ).second )
2333 duplicatedStackup =
true;
2341 static constexpr int MAX_STACKUP_ITEMS = 128;
2343 itemOwner = std::make_unique<BOARD_STACKUP_ITEM>( type );
2344 item = itemOwner.get();
2350 if( !duplicatedStackup && stackup.
GetCount() < MAX_STACKUP_ITEMS )
2351 stackup.
Add( itemOwner.release() );
2355 Expecting(
"layer_name" );
2358 bool has_next_sublayer =
true;
2359 int sublayer_idx = 0;
2361 wxString specFreqUnits;
2362 wxString dielectricModel;
2364 while( has_next_sublayer )
2366 has_next_sublayer =
false;
2368 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2370 if( token == T_addsublayer )
2372 has_next_sublayer =
true;
2376 if( token == T_LEFT )
2392 if( token == T_LEFT )
2395 if( token == T_locked )
2418 case T_loss_tangent:
2424 case T_spec_frequency:
2430 case T_dielectric_model:
2439 case T_djordjevic_sarkar:
2444 Expecting(
"constant or djordjevic_sarkar" );
2465 wxColour wx_color = color.
ToColour();
2468 name.Printf( wxT(
"#%02X%02X%02X%02X" ),
2488 if( has_next_sublayer )
2496 if( token != T_RIGHT )
2502 m_board->GetDesignSettings().m_HasStackup =
true;
2513 aMap[
"Adesivo.Retro"] =
"B.Adhes";
2514 aMap[
"Adesivo.Fronte"] =
"F.Adhes";
2515 aMap[
"Pasta.Retro"] =
"B.Paste";
2516 aMap[
"Pasta.Fronte"] =
"F.Paste";
2517 aMap[
"Serigrafia.Retro"] =
"B.SilkS";
2518 aMap[
"Serigrafia.Fronte"] =
"F.SilkS";
2519 aMap[
"Maschera.Retro"] =
"B.Mask";
2520 aMap[
"Maschera.Fronte"] =
"F.Mask";
2521 aMap[
"Grafica"] =
"Dwgs.User";
2522 aMap[
"Commenti"] =
"Cmts.User";
2523 aMap[
"Eco1"] =
"Eco1.User";
2524 aMap[
"Eco2"] =
"Eco2.User";
2525 aMap[
"Contorno.scheda"] =
"Edge.Cuts";
2528 aMap[
"Kleju_Dolna"] =
"B.Adhes";
2529 aMap[
"Kleju_Gorna"] =
"F.Adhes";
2530 aMap[
"Pasty_Dolna"] =
"B.Paste";
2531 aMap[
"Pasty_Gorna"] =
"F.Paste";
2532 aMap[
"Opisowa_Dolna"] =
"B.SilkS";
2533 aMap[
"Opisowa_Gorna"] =
"F.SilkS";
2534 aMap[
"Maski_Dolna"] =
"B.Mask";
2535 aMap[
"Maski_Gorna"] =
"F.Mask";
2536 aMap[
"Rysunkowa"] =
"Dwgs.User";
2537 aMap[
"Komentarzy"] =
"Cmts.User";
2538 aMap[
"ECO1"] =
"Eco1.User";
2539 aMap[
"ECO2"] =
"Eco2.User";
2540 aMap[
"Krawedziowa"] =
"Edge.Cuts";
2543 aMap[
"Dessous.Adhes"] =
"B.Adhes";
2544 aMap[
"Dessus.Adhes"] =
"F.Adhes";
2545 aMap[
"Dessous.Pate"] =
"B.Paste";
2546 aMap[
"Dessus.Pate"] =
"F.Paste";
2547 aMap[
"Dessous.SilkS"] =
"B.SilkS";
2548 aMap[
"Dessus.SilkS"] =
"F.SilkS";
2549 aMap[
"Dessous.Masque"] =
"B.Mask";
2550 aMap[
"Dessus.Masque"] =
"F.Mask";
2551 aMap[
"Dessin.User"] =
"Dwgs.User";
2552 aMap[
"Contours.Ci"] =
"Edge.Cuts";
2558 wxCHECK_RET( CurTok() == T_layers,
2559 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as layers." ) );
2564 int copperLayerCount = 0;
2566 bool anyHidden =
false;
2568 std::unordered_map< std::string, std::string > v3_layer_names;
2569 std::vector<LAYER> cu;
2574 std::vector<LAYER> appendedLayers;
2578 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2585 cu.push_back( layer );
2598 for(
size_t i = 1; i < cu.size() - 1; i++ )
2603 tmpLayer = ( i + 1 ) * 2;
2605 cu[i].m_number = tmpLayer;
2608 cu[0].m_number =
F_Cu;
2609 cu[cu.size()-1].m_number =
B_Cu;
2611 for(
auto& cu_layer : cu )
2613 enabledLayers.
set( cu_layer.m_number );
2615 if( cu_layer.m_visible )
2616 visibleLayers.
set( cu_layer.m_number );
2630 appendedLayers.push_back( cu_layer );
2633 copperLayerCount = cu.size();
2637 while( token != T_RIGHT )
2643 auto new_layer_it = v3_layer_names.find( layer.
m_name.ToStdString() );
2645 if( new_layer_it != v3_layer_names.end() )
2650 THROW_IO_ERRORF(
_(
"Layer '%s' in file '%s' at line %d is not in fixed layer hash." ),
2651 layer.
m_name, CurSource(), CurLineNumber(), CurOffset() );
2658 layer.
m_name = it->first;
2670 m_board->SetLayerDescr( it->second, layer );
2672 appendedLayers.push_back( layer );
2676 if( token != T_LEFT )
2683 if( copperLayerCount < 2 || (copperLayerCount % 2) != 0 )
2685 wxString err = wxString::Format(
_(
"%d is not a valid layer count" ), copperLayerCount );
2692 m_board->SetCopperLayerCount( std::max( copperLayerCount,
m_board->GetCopperLayerCount() ) );
2693 m_board->SetEnabledLayers( enabledLayers |
m_board->GetEnabledLayers() );
2697 m_board->SetCopperLayerCount( copperLayerCount );
2698 m_board->SetEnabledLayers( enabledLayers );
2703 m_board->m_LegacyVisibleLayers = visibleLayers;
2712 const LSET& aDestInitialEnabled,
int aDestInitialCopperCount )
2716 int srcCopperCount = 0;
2717 bool mismatch =
false;
2719 for(
const LAYER& src : aSourceLayers )
2726 if( !aDestInitialEnabled.
Contains(
id ) )
2728 else if( !src.m_userName.IsEmpty() && src.m_userName !=
m_board->GetLayerName(
id ) )
2735 std::vector<INPUT_LAYER_DESC> descs;
2737 for(
const LAYER& src : aSourceLayers )
2740 desc.
Name = src.m_userName.IsEmpty() ? src.m_name : src.m_userName;
2759 descs.push_back( desc );
2765 if( progressWindow )
2766 progressWindow->Hide();
2770 if( progressWindow )
2771 progressWindow->Show();
2775 for(
const LAYER& src : aSourceLayers )
2777 wxString key = src.m_userName.IsEmpty() ? src.m_name : src.m_userName;
2778 auto it = remap.find( key );
2795 if( !aDestInitialEnabled.
Contains( target ) )
2799 m_board->SetLayerDescr( target, descr );
2802 enabled.
set( target );
2805 m_board->SetEnabledLayers( enabled );
2811 LSET_MAP::const_iterator it = aMap.find( curText );
2813 if( it == aMap.end() )
2823 LAYER_ID_MAP::const_iterator it = aMap.find( curText );
2825 if( it == aMap.end() )
2827 if( curText ==
"UNDEFINED" && aAllowUndefined )
2835 if( it->second ==
Rescue )
2845 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as layer." ) );
2859 wxCHECK_MSG( CurTok() == T_layers,
LSET(),
2860 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as item layers." ) );
2864 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
2878 Expecting(
"single copper layer" );
2881 Expecting(
"max one soldermask layer" );
2886 Expecting(
"no mask layer when track is on internal layer" );
2890 Expecting(
"copper and mask on the same side" );
2893 Expecting(
"copper and mask on the same side" );
2901 wxCHECK_RET( CurTok() == T_drill_symbol_profile,
2902 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a drill symbol profile." ) );
2915 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
2917 if( token != T_LEFT )
2918 Expecting( T_LEFT );
2925 NeedSYMBOLorNUMBER();
2926 profile.
SetName( FromUTF8() );
2931 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2941 case T_default_marks:
2943 NeedSYMBOLorNUMBER();
2963 case T_freeze_assignments:
2973 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2975 if( token != T_LEFT )
2976 Expecting( T_LEFT );
2983 NeedSYMBOLorNUMBER();
2990 NeedSYMBOLorNUMBER();
2999 NeedSYMBOLorNUMBER();
3008 NeedSYMBOLorNUMBER();
3035 wxCHECK_RET( CurTok() == T_setup,
3036 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as setup." ) );
3046 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
3048 if( token != T_LEFT )
3049 Expecting( T_LEFT );
3055 case T_drill_symbol_profile:
3066 case T_last_trace_width:
3071 case T_user_trace_width:
3082 m_board->m_LegacyDesignSettingsLoaded =
true;
3087 case T_trace_clearance:
3088 defaultNetClass->SetClearance(
parseBoardUnits( T_trace_clearance ) );
3089 m_board->m_LegacyDesignSettingsLoaded =
true;
3093 case T_zone_clearance:
3095 m_board->m_LegacyDesignSettingsLoaded =
true;
3099 case T_zone_45_only:
3101 m_board->m_LegacyDesignSettingsLoaded =
true;
3105 case T_clearance_min:
3107 m_board->m_LegacyDesignSettingsLoaded =
true;
3113 m_board->m_LegacyDesignSettingsLoaded =
true;
3119 m_board->m_LegacyDesignSettingsLoaded =
true;
3125 m_board->m_LegacyDesignSettingsLoaded =
true;
3129 case T_via_min_annulus:
3131 m_board->m_LegacyDesignSettingsLoaded =
true;
3135 case T_via_min_size:
3137 m_board->m_LegacyDesignSettingsLoaded =
true;
3141 case T_through_hole_min:
3143 m_board->m_LegacyDesignSettingsLoaded =
true;
3148 case T_via_min_drill:
3150 m_board->m_LegacyDesignSettingsLoaded =
true;
3154 case T_hole_to_hole_min:
3156 m_board->m_LegacyDesignSettingsLoaded =
true;
3173 m_board->m_LegacyDesignSettingsLoaded =
true;
3180 m_board->m_LegacyDesignSettingsLoaded =
true;
3186 m_board->m_LegacyDesignSettingsLoaded =
true;
3190 case T_uvias_allowed:
3192 m_board->m_LegacyDesignSettingsLoaded =
true;
3196 case T_blind_buried_vias_allowed:
3198 m_board->m_LegacyDesignSettingsLoaded =
true;
3202 case T_uvia_min_size:
3204 m_board->m_LegacyDesignSettingsLoaded =
true;
3208 case T_uvia_min_drill:
3210 m_board->m_LegacyDesignSettingsLoaded =
true;
3214 case T_user_diff_pair:
3224 m_board->m_LegacyDesignSettingsLoaded =
true;
3229 case T_segment_width:
3231 m_board->m_LegacyDesignSettingsLoaded =
true;
3237 m_board->m_LegacyDesignSettingsLoaded =
true;
3241 case T_mod_edge_width:
3243 m_board->m_LegacyDesignSettingsLoaded =
true;
3247 case T_pcb_text_width:
3249 m_board->m_LegacyDesignSettingsLoaded =
true;
3253 case T_mod_text_width:
3255 m_board->m_LegacyDesignSettingsLoaded =
true;
3259 case T_pcb_text_size:
3262 m_board->m_LegacyDesignSettingsLoaded =
true;
3266 case T_mod_text_size:
3269 m_board->m_LegacyDesignSettingsLoaded =
true;
3275 m_board->m_LegacyDesignSettingsLoaded =
true;
3283 m_board->m_LegacyDesignSettingsLoaded =
true;
3292 m_board->m_LegacyDesignSettingsLoaded =
true;
3297 case T_pad_to_mask_clearance:
3302 case T_solder_mask_min_width:
3307 case T_pad_to_paste_clearance:
3312 case T_pad_to_paste_clearance_ratio:
3317 case T_allow_soldermask_bridges_in_footprints:
3360 case T_aux_axis_origin:
3384 case T_visible_elements:
3391 for(
size_t i = 0; i <
sizeof( int ) * CHAR_BIT; i++ )
3392 m_board->m_LegacyVisibleItems.set( i, visible & ( 1u << i ) );
3400 m_board->m_LegacyDesignSettingsLoaded =
true;
3404 case T_filled_areas_thickness:
3410 case T_pcbplotparams:
3416 parser.SyncLineReaderWith( *
this );
3418 plotParams.
Parse( &parser );
3419 SyncLineReaderWith( parser );
3421 m_board->SetPlotOptions( plotParams );
3435 Unexpected( CurText() );
3452 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
3454 if( token != T_LEFT )
3455 Expecting( T_LEFT );
3463 Unexpected( CurText() );
3470 std::map<PCB_LAYER_ID, ZONE_LAYER_PROPERTIES>& aProperties )
3475 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
3477 if( token != T_LEFT )
3478 Expecting( T_LEFT );
3488 case T_hatch_position:
3495 Unexpected( CurText() );
3500 aProperties.emplace( layer, properties );
3506 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
3508 if( token != T_LEFT )
3509 Expecting( T_LEFT );
3515 case T_edge_clearance:
3517 m_board->m_LegacyCopperEdgeClearanceLoaded =
true;
3521 case T_copper_line_width:
3526 case T_copper_text_dims:
3530 case T_courtyard_line_width:
3535 case T_edge_cuts_line_width:
3540 case T_silk_line_width:
3545 case T_silk_text_dims:
3549 case T_fab_layers_line_width:
3554 case T_fab_layers_text_dims:
3558 case T_other_layers_line_width:
3563 case T_other_layers_text_dims:
3567 case T_dimension_units:
3572 case T_dimension_precision:
3578 Unexpected( CurText() );
3586 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
3588 if( token == T_LEFT )
3608 case T_keep_upright:
3613 Expecting(
"size, thickness, italic or keep_upright" );
3621 wxCHECK_RET( CurTok() == T_net, wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as net." ) );
3623 int netCode =
parseInt(
"net number" );
3625 NeedSYMBOLorNUMBER();
3626 wxString
name = FromUTF8();
3651 for(
T token = NextTok(); token != T_EOF; token = NextTok() )
3653 if( token == T_RIGHT )
3655 else if( token == T_LEFT )
3658 if( token != T_net_chain )
3665 std::vector<int> netCodes;
3666 std::vector<wxString> netNames;
3670 for(
T t = NextTok(); t != T_EOF; t = NextTok() )
3674 else if( t == T_LEFT )
3680 NeedSYMBOLorNUMBER();
3687 for(
T mt = NextTok(); mt != T_RIGHT; mt = NextTok() )
3697 if( tok == T_NUMBER )
3698 netCodes.push_back( (
int) strtol( CurText(),
nullptr, 10 ) );
3700 netNames.push_back( FromUTF8() );
3704 else if( mt == T_member )
3707 T inner = NextTok();
3709 if( inner == T_LEFT )
3712 if( inner == T_net )
3716 if( tok2 == T_NUMBER )
3717 netCodes.push_back( (
int) strtol( CurText(),
nullptr, 10 ) );
3719 netNames.push_back( FromUTF8() );
3734 case T_terminal_pad:
3737 NeedSYMBOLorNUMBER();
3738 padUuids[padCount++] =
KIID( FromUTF8() );
3753 std::vector<NETINFO_ITEM*> resolvedNets;
3755 for(
int code : netCodes )
3757 int internalCode = code;
3763 resolvedNets.push_back( net );
3766 for(
const wxString& netName : netNames )
3769 resolvedNets.push_back( net );
3774 net->SetNetChain(
name );
3776 for(
int i = 0; i < padCount && i < 2; ++i )
3778 net->SetTerminalPadUuid( i, padUuids[i] );
3781 net->SetTerminalPad( i,
pad );
3790 wxCHECK_RET( CurTok() == T_net_class,
3791 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as net class." ) );
3793 std::shared_ptr<NETCLASS> nc = std::make_shared<NETCLASS>( wxEmptyString );
3796 NeedSYMBOLorNUMBER();
3797 nc->SetName( FromUTF8() );
3799 nc->SetDescription( FromUTF8() );
3801 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
3803 if( token != T_LEFT )
3804 Expecting( T_LEFT );
3834 case T_diff_pair_width:
3838 case T_diff_pair_gap:
3844 NeedSYMBOLorNUMBER();
3846 wxString netName = FromUTF8();
3853 m_board->GetDesignSettings().m_NetSettings->SetNetclassPatternAssignment( netName, nc->GetName() );
3859 Expecting(
"clearance, trace_width, via_dia, via_drill, uvia_dia, uvia_drill, "
3860 "diff_pair_width, diff_pair_gap or add_net" );
3866 std::shared_ptr<NET_SETTINGS>& netSettings =
m_board->GetDesignSettings().m_NetSettings;
3868 if( netSettings->HasNetclass( nc->GetName() ) )
3872 THROW_IO_ERRORF(
_(
"Duplicate NETCLASS name '%s' in file '%s' at line %d, offset %d." ),
3873 nc->GetName().GetData(), CurSource().GetData(), CurLineNumber(), CurOffset() );
3875 else if( nc->GetName() == netSettings->GetDefaultNetclass()->GetName() )
3877 netSettings->SetDefaultNetclass( nc );
3881 netSettings->SetNetclass( nc->GetName(), nc );
3889 T token = NextTok();
3898 default: Expecting(
"arrow, circle, square, arrow_open, or none" );
3902 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3904 if( token != T_LEFT )
3905 Expecting( T_LEFT );
3925 strokeParser.SyncLineReaderWith( *
this );
3928 SyncLineReaderWith( strokeParser );
3934 default: Expecting(
"length, width, or stroke" );
3942 wxCHECK_MSG( CurTok() == T_fp_arc || CurTok() == T_fp_circle || CurTok() == T_fp_curve || CurTok() == T_fp_rect
3943 || CurTok() == T_fp_line || CurTok() == T_fp_poly || CurTok() == T_fp_ellipse
3944 || CurTok() == T_fp_ellipse_arc || CurTok() == T_gr_arc || CurTok() == T_gr_circle
3945 || CurTok() == T_gr_curve || CurTok() == T_gr_rect || CurTok() == T_gr_bbox
3946 || CurTok() == T_gr_line || CurTok() == T_gr_poly || CurTok() == T_gr_vector
3947 || CurTok() == T_gr_ellipse || CurTok() == T_gr_ellipse_arc,
3948 nullptr, wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as PCB_SHAPE." ) );
3953 std::unique_ptr<PCB_SHAPE> shape = std::make_unique<PCB_SHAPE>( aParent );
3956 int ellipseMajor = 0;
3957 int ellipseMinor = 0;
3969 if( token == T_locked )
3971 shape->SetLocked(
true );
3975 if( token != T_LEFT )
3976 Expecting( T_LEFT );
3983 if( token != T_start )
3984 Expecting( T_start );
3988 shape->SetCenter( pt );
3994 if( token != T_end )
3999 shape->SetStart( pt );
4004 if( token != T_angle )
4005 Expecting( T_angle );
4012 VECTOR2I arc_start, arc_mid, arc_end;
4014 if( token != T_start )
4015 Expecting( T_start );
4023 if( token != T_mid )
4032 if( token != T_end )
4039 shape->SetArcOrSegment( arc_start, arc_mid, arc_end );
4049 if( token == T_locked )
4051 shape->SetLocked(
true );
4055 if( token != T_LEFT )
4056 Expecting( T_LEFT );
4060 if( token != T_center )
4061 Expecting( T_center );
4065 shape->SetStart( pt );
4071 if( token != T_end )
4076 shape->SetEnd( pt );
4085 if( token == T_locked )
4087 shape->SetLocked(
true );
4091 if( token != T_LEFT )
4092 Expecting( T_LEFT );
4096 if( token != T_pts )
4100 shape->SetBezierC1(
parseXY());
4101 shape->SetBezierC2(
parseXY());
4105 shape->RebuildBezierToSegmentsPointsList(
m_board->GetDesignSettings().m_MaxError );
4107 shape->RebuildBezierToSegmentsPointsList(
ARC_HIGH_DEF );
4118 if( token == T_locked )
4120 shape->SetLocked(
true );
4124 if( token != T_LEFT )
4125 Expecting( T_LEFT );
4129 if( token != T_start )
4130 Expecting( T_start );
4134 shape->SetStart( pt );
4139 if( token != T_end )
4144 shape->SetEnd( pt );
4165 if( token == T_locked )
4167 shape->SetLocked(
true );
4171 if( token != T_LEFT )
4172 Expecting( T_LEFT );
4176 if( token != T_start )
4177 Expecting( T_start );
4181 shape->SetStart( pt );
4186 if( token != T_end )
4191 shape->SetEnd( pt );
4199 shape->SetPolyPoints( {} );
4205 if( token == T_locked )
4207 shape->SetLocked(
true );
4211 if( token != T_LEFT )
4212 Expecting( T_LEFT );
4216 if( token != T_pts )
4219 while( (token = NextTok() ) != T_RIGHT )
4228 case T_gr_ellipse_arc:
4234 Expecting(
"fp_arc, fp_circle, fp_curve, fp_ellipse, fp_ellipse_arc, "
4235 "fp_line, fp_poly or fp_rect" );
4239 Expecting(
"gr_arc, gr_circle, gr_curve, gr_ellipse, gr_ellipse_arc, "
4240 "gr_vector, gr_line, gr_poly, gr_rect or gr_bbox" );
4244 bool foundFill =
false;
4246 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
4248 if( token != T_LEFT )
4249 Expecting( T_LEFT );
4269 case T_solder_mask_margin:
4270 shape->SetLocalSolderMaskMargin(
parseBoardUnits(
"local solder mask margin value" ) );
4287 strokeParser.SyncLineReaderWith( *
this );
4290 SyncLineReaderWith( strokeParser );
4304 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
4306 if( token == T_LEFT )
4323 default: Expecting(
"yes, no, solid, none, hatch, reverse_hatch or cross_hatch" );
4349 case T_major_radius:
4354 case T_minor_radius:
4359 case T_rotation_angle:
4378 shape->SetStartEnding( ending );
4386 shape->SetEndEnding( ending );
4390 case T_custom_property:
4395 Expecting(
"layer, width, fill, tstamp, uuid, locked, net, status, solder_mask_margin, center, "
4396 "major_radius, minor_radius, rotation_angle, start_angle, end_angle, start_shape, "
4397 "end_shape, or custom_property" );
4408 shape->SetFilled(
true );
4413 shape->SetFilled(
true );
4419 if( stroke.
GetWidth() <= 0 && !shape->IsAnyFill() )
4422 shape->SetStroke( stroke );
4424 if( shape->GetParentFootprint() )
4425 shape->SetLibStrokeWidth( stroke.
GetWidth() );
4429 shape->SetLibraryEllipse( ellipseCenter, ellipseMajor, ellipseMinor, ellipseRotation, ellipseStart,
4432 if( shape->GetParentFootprint() )
4433 shape->RebakeFromLib();
4435 else if( shape->GetParentFootprint() )
4437 const VECTOR2I libStart = shape->GetStart();
4438 const VECTOR2I libEnd = shape->GetEnd();
4441 shape->OverrideLibCoords( libStart, libEnd, libArcMid );
4444 shape->OverrideLibCornerRadius( shape->GetCornerRadius() );
4447 shape->OverrideLibBezier( shape->GetBezierC1(), shape->GetBezierC2() );
4450 shape->OverrideLibPoly( shape->GetPolyShape() );
4452 shape->RebakeFromLib();
4455 return shape.release();
4461 wxCHECK_MSG( CurTok() == T_image,
nullptr,
4462 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a reference image." ) );
4464 std::unique_ptr<PCB_REFERENCE_IMAGE> bitmap = std::make_unique<PCB_REFERENCE_IMAGE>( aParent );
4466 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
4468 if( token != T_LEFT )
4469 Expecting( T_LEFT );
4480 bitmap->SetPosition( pos );
4525 data.reserve( 1 << 19 );
4527 while( token != T_RIGHT )
4529 if( !IsSymbol( token ) )
4530 Expecting(
"base64 image data" );
4536 wxMemoryBuffer buffer = wxBase64Decode( data );
4550 bitmap->SetLocked(
locked );
4562 case T_custom_property:
4566 default: Expecting(
"at, layer, rotate, opacity, scale, data, locked, uuid, or custom_property" );
4577 int legacyPPI =
image.GetLegacyPPI();
4579 if( legacyPPI > 0 &&
image.GetPPI() != legacyPPI )
4583 return bitmap.release();
4589 std::unique_ptr<PCB_TEXT>
text( aBaseText );
4591 wxCHECK_MSG( CurTok() == T_gr_text || CurTok() == T_fp_text,
nullptr,
4592 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as PCB_TEXT." ) );
4596 T token = NextTok();
4598 if( !
text && parentFP )
4611 text = std::make_unique<PCB_TEXT>( parentFP );
4615 THROW_IO_ERRORF(
_(
"Cannot handle footprint text type %s" ), FromUTF8() );
4622 text = std::make_unique<PCB_TEXT>( aParent );
4626 if( token == T_locked )
4628 text->SetLocked(
true );
4632 if( !IsSymbol( token ) && (
int) token !=
DSN_NUMBER )
4633 Expecting(
"text value" );
4635 wxString value = FromUTF8();
4636 value.Replace( wxT(
"%V" ), wxT(
"${VALUE}" ) );
4637 value.Replace( wxT(
"%R" ), wxT(
"${REFERENCE}" ) );
4638 text->SetText( value );
4656 text->SetVisible(
true );
4659 return text.release();
4666 bool sawEffects =
false;
4667 bool hasAngle =
false;
4669 bool hasPos =
false;
4675 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
4677 if( token == T_LEFT )
4696 if( CurTok() == T_NUMBER )
4704 if( parentFP && CurTok() == T_unlocked )
4721 if( token == T_knockout )
4748 Expecting(
"layer, effects, locked, render_cache, uuid or tstamp" );
4764 Expecting(
"layer, effects, locked, render_cache or tstamp" );
4774 case T_render_cache:
4778 case T_custom_property:
4784 Expecting(
"layer, hide, effects, locked, render_cache, tstamp, uuid, or custom_property" );
4786 Expecting(
"layer, effects, locked, render_cache, tstamp, uuid, or custom_property" );
4823 wxCHECK_MSG( CurTok() == T_barcode,
nullptr,
4824 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as PCB_BARCODE." ) );
4826 std::unique_ptr<PCB_BARCODE> barcode = std::make_unique<PCB_BARCODE>( aParent );
4828 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
4830 if( token != T_LEFT )
4831 Expecting( T_LEFT );
4842 barcode->SetPosition( pos );
4845 if( CurTok() == T_NUMBER )
4861 barcode->SetWidth( w );
4862 barcode->SetHeight( h );
4868 if( NextTok() != T_STRING )
4869 Expecting( T_STRING );
4871 barcode->SetText( FromUTF8() );
4878 barcode->SetTextSize( h );
4886 std::string kind = CurText();
4887 if( kind ==
"code39" )
4889 else if( kind ==
"code128" )
4891 else if( kind ==
"datamatrix" || kind ==
"data_matrix" )
4893 else if( kind ==
"qr" || kind ==
"qrcode" )
4895 else if( kind ==
"microqr" || kind ==
"micro_qr" )
4898 Expecting(
"barcode type" );
4906 std::string ecc = CurText();
4907 if( ecc ==
"L" || ecc ==
"l" )
4909 else if( ecc ==
"M" || ecc ==
"m" )
4911 else if( ecc ==
"Q" || ecc ==
"q" )
4913 else if( ecc ==
"H" || ecc ==
"h" )
4916 Expecting(
"ecc level" );
4947 barcode->SetMargin(
VECTOR2I( marginX, marginY ) );
4952 case T_custom_property:
4957 Expecting(
"at, layer, size, text, text_height, type, ecc_level, locked, hide, knockout, margins, "
4958 "uuid, or custom_property" );
4962 barcode->AssembleBarcode();
4964 return barcode.release();
4985 aTextBox->EDA_TEXT::SetTextAngle( aTextBox->
GetTextAngle() );
4991 wxCHECK_MSG( CurTok() == T_gr_text_box || CurTok() == T_fp_text_box,
nullptr,
4992 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as PCB_TEXTBOX." ) );
4994 std::unique_ptr<PCB_TEXTBOX> textbox = std::make_unique<PCB_TEXTBOX>( aParent );
4999 return textbox.release();
5005 wxCHECK_MSG( CurTok() == T_table_cell,
nullptr,
5006 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a table cell." ) );
5008 std::unique_ptr<PCB_TABLECELL> cell = std::make_unique<PCB_TABLECELL>( aParent );
5013 return cell.release();
5024 bool foundMargins =
false;
5026 T token = NextTok();
5029 if( token == T_locked )
5035 if( !IsSymbol( token ) && (
int) token !=
DSN_NUMBER )
5036 Expecting(
"text value" );
5038 aTextBox->
SetText( FromUTF8() );
5040 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
5042 if( token != T_LEFT )
5043 Expecting( T_LEFT );
5063 if( token != T_end )
5078 while( (token = NextTok() ) != T_RIGHT )
5093 strokeParser.SyncLineReaderWith( *
this );
5096 SyncLineReaderWith( strokeParser );
5111 foundMargins =
true;
5128 cell->SetColSpan(
parseInt(
"column span" ) );
5129 cell->SetRowSpan(
parseInt(
"row span" ) );
5133 Expecting(
"locked, start, pts, angle, width, stroke, border, margins, knockout, "
5134 "layer, effects, render_cache, uuid or tstamp" );
5151 case T_render_cache:
5155 case T_custom_property:
5162 Expecting(
"locked, start, pts, angle, width, margins, knockout, layer, effects, "
5163 "span, render_cache, uuid, tstamp, or custom_property" );
5167 Expecting(
"locked, start, pts, angle, width, stroke, border, margins, knockout,"
5168 "layer, effects, render_cache, uuid, tstamp, or custom_property" );
5198 case T_column_count:
5204 if( !aAllowIdentity )
5205 Expecting(
"table geometry without identity" );
5213 if( !aAllowIdentity )
5214 Expecting(
"table geometry without identity" );
5225 if( !aAllowIdentity )
5226 Expecting(
"table geometry without identity" );
5232 case T_column_widths:
5236 while( ( token = NextTok() ) != T_RIGHT )
5246 while( ( token = NextTok() ) != T_RIGHT )
5253 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
5255 if( token != T_LEFT )
5256 Expecting( T_LEFT );
5260 if( token != T_table_cell )
5261 Expecting(
"table_cell" );
5269 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
5271 if( token != T_LEFT )
5272 Expecting( T_LEFT );
5291 strokeParser.SyncLineReaderWith( *
this );
5295 SyncLineReaderWith( strokeParser );
5297 table->SetBorderStroke( borderStroke );
5302 Expecting(
"external, header or stroke" );
5310 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
5312 if( token != T_LEFT )
5313 Expecting( T_LEFT );
5332 strokeParser.SyncLineReaderWith( *
this );
5336 SyncLineReaderWith( strokeParser );
5338 table->SetSeparatorsStroke( separatorsStroke );
5343 Expecting(
"rows, cols, or stroke" );
5350 case T_custom_property:
5362 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
5364 if( token != T_LEFT )
5365 Expecting( T_LEFT );
5370 Expecting(
"columns, layer, col_widths, row_heights, border, separators, header or cells" );
5377 wxString
name = FromUTF8();
5380 NeedSYMBOLorNUMBER();
5384 bool backdrill =
false;
5385 bool nonPlated =
false;
5389 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
5391 if( token == T_backdrill )
5393 else if( token == T_npth )
5397 return DRILL_SPAN( startLayer, endLayer, backdrill, nonPlated );
5403 wxCHECK_MSG( CurTok() == T_drill_map,
nullptr,
5404 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a drill map." ) );
5406 std::unique_ptr<PCB_DRILL_MAP> map = std::make_unique<PCB_DRILL_MAP>( aParent );
5408 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
5410 if( token != T_LEFT )
5411 Expecting( T_LEFT );
5438 map->SetOffset( offset );
5452 if( CurTok() == T_all )
5454 map->SetAllSpans(
true );
5459 map->SetAllSpans(
false );
5466 case T_outline_slots:
5476 case T_custom_property:
5488 THROW_IO_ERROR(
_(
"Invalid drill map: not on a documentation layer" ) );
5491 return map.release();
5500 std::vector<GENERATED_TABLE_COLUMN> columns;
5506 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
5508 if( token != T_LEFT )
5509 Expecting( T_LEFT );
5533 NeedSYMBOLorNUMBER();
5537 aTable->SetUnits( units );
5544 aTable->SetPrecision(
parseInt(
"generated table precision" ) );
5557 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
5559 if( token != T_LEFT )
5560 Expecting( T_LEFT );
5567 NeedSYMBOLorNUMBER();
5574 col.
m_Id = def->m_Id;
5575 col.
m_Heading = wxString( def->m_Heading );
5583 NeedSYMBOLorNUMBER();
5589 NeedSYMBOLorNUMBER();
5610 columns.push_back( col );
5615 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
5617 if( token != T_LEFT )
5618 Expecting( T_LEFT );
5622 if( token == T_key )
5624 const int row =
parseInt(
"row key row" );
5626 NeedSYMBOLorNUMBER();
5627 aTable->RowKeys()[row] = curText;
5648 if( columns.empty() )
5651 const auto anyShown =
5652 [](
const std::vector<GENERATED_TABLE_COLUMN>& aColumns )
5654 return std::any_of( aColumns.begin(), aColumns.end(),
5657 return aCol.m_Visible;
5663 if( aTable->GetColCount() < 1 || !schema.
Validate( columns ) || !anyShown( columns ) )
5665 THROW_IO_ERROR( wxString::Format(
_(
"Invalid %s: bad column set" ), aTable->GetFriendlyName() ) );
5668 aTable->RestoreColumns( columns );
5674 THROW_IO_ERROR( wxString::Format(
_(
"Invalid %s: not on a documentation layer" ),
5675 aTable->GetFriendlyName() ) );
5678 return aTable.release();
5684 switch( aTable->
Type() )
5693 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
5695 if( token != T_LEFT )
5696 Expecting( T_LEFT );
5720 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
5722 if( token != T_LEFT )
5723 Expecting( T_LEFT );
5727 if( token == T_column )
5731 else if( token == T_shape )
5733 const int row =
parseInt(
"row shape row" );
5755 wxCHECK_MSG( CurTok() == T_table,
nullptr,
5756 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a table." ) );
5758 std::unique_ptr<PCB_TABLE>
table = std::make_unique<PCB_TABLE>( aParent, -1 );
5762 return table.release();
5768 wxCHECK_MSG( CurTok() == T_dimension,
nullptr,
5769 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as DIMENSION." ) );
5773 std::unique_ptr<PCB_DIMENSION_BASE> dim;
5778 if( token == T_locked )
5785 if( token != T_LEFT )
5790 bool isLegacyDimension =
false;
5791 bool isStyleKnown =
false;
5794 if( token == T_width )
5796 isLegacyDimension =
true;
5797 dim = std::make_unique<PCB_DIM_ALIGNED>( aParent );
5803 if( token != T_type )
5804 Expecting( T_type );
5808 case T_aligned: dim = std::make_unique<PCB_DIM_ALIGNED>( aParent );
break;
5809 case T_orthogonal: dim = std::make_unique<PCB_DIM_ORTHOGONAL>( aParent );
break;
5810 case T_leader: dim = std::make_unique<PCB_DIM_LEADER>( aParent );
break;
5811 case T_center: dim = std::make_unique<PCB_DIM_CENTER>( aParent );
break;
5812 case T_radial: dim = std::make_unique<PCB_DIM_RADIAL>( aParent );
break;
5813 default: wxFAIL_MSG( wxT(
"Cannot parse unknown dimension type " ) + GetTokenString( CurTok() ) );
5823 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
5825 if( token != T_LEFT )
5826 Expecting( T_LEFT );
5851 bool is_aligned = dim->GetKeepTextAligned();
5857 dim->SetKeepTextAligned(
false );
5862 if( isLegacyDimension )
5867 dim->SetAutoUnits(
true );
5869 dim->SetUnits( units );
5874 dim->SetKeepTextAligned( is_aligned );
5875 dim->SetTextPositionMode( t_dim_pos );
5886 dim->SetStart( point );
5888 dim->SetEnd( point );
5908 case T_leader_length:
5939 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
5947 NeedSYMBOLorNUMBER();
5948 dim->SetPrefix( FromUTF8() );
5953 NeedSYMBOLorNUMBER();
5954 dim->SetSuffix( FromUTF8() );
5960 int mode =
parseInt(
"dimension units mode" );
5961 mode = std::max( 0, std::min( 4, mode ) );
5967 case T_units_format:
5969 int format =
parseInt(
"dimension units format" );
5970 format = std::clamp( format, 0, 3 );
5981 case T_override_value:
5982 NeedSYMBOLorNUMBER();
5983 dim->SetOverrideTextEnabled(
true );
5984 dim->SetOverrideText( FromUTF8() );
5988 case T_suppress_zeroes:
5993 std::cerr <<
"Unknown format token: " << GetTokenString( token ) << std::endl;
5994 Expecting(
"prefix, suffix, units, units_format, precision, override_value, suppress_zeroes" );
6002 isStyleKnown =
true;
6005 dim->SetKeepTextAligned(
false );
6007 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
6015 dim->SetLineThickness(
parseBoardUnits(
"extension line thickness value" ) );
6019 case T_arrow_direction:
6022 if( token == T_inward )
6024 else if( token == T_outward )
6027 Expecting(
"inward or outward" );
6032 case T_arrow_length:
6038 case T_text_position_mode:
6040 int mode =
parseInt(
"text position mode" );
6041 mode = std::max( 0, std::min( 3, mode ) );
6047 case T_extension_height:
6050 wxCHECK_MSG( aligned,
nullptr, wxT(
"Invalid extension_height token" ) );
6056 case T_extension_offset:
6057 dim->SetExtensionOffset(
parseBoardUnits(
"extension offset value" ) );
6061 case T_keep_text_aligned:
6067 wxCHECK_MSG( dim->Type() ==
PCB_DIM_LEADER_T,
nullptr, wxT(
"Invalid text_frame token" ) );
6071 int textFrame =
parseInt(
"text frame mode" );
6072 textFrame = std::clamp( textFrame, 0, 3 );
6079 Expecting(
"thickness, arrow_length, arrow_direction, text_position_mode, "
6080 "extension_height, extension_offset" );
6093 if( token != T_pts )
6099 dim->SetStart( point );
6113 if( token != T_pts )
6119 dim->SetEnd( point );
6133 if( token == T_pts )
6155 if( token != T_pts )
6169 if( token != T_pts )
6183 if( token != T_pts )
6197 if( token != T_pts )
6211 dim->SetLocked( isLocked );
6215 case T_custom_property:
6220 Expecting(
"layer, tstamp, uuid, gr_text, feature1, feature2, crossbar, arrow1a, "
6221 "arrow1b, arrow2a, arrow2b, locked, or custom_property" );
6226 dim->SetLocked(
true );
6230 return dim.release();
6252 wxCHECK_MSG( CurTok() == T_module || CurTok() == T_footprint,
nullptr,
6253 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as FOOTPRINT." ) );
6260 double parsedScaleX = 1.0;
6261 double parsedScaleY = 1.0;
6263 std::unique_ptr<FOOTPRINT> footprint = std::make_unique<FOOTPRINT>(
m_board );
6265 footprint->SetInitialComments( aInitialComments );
6268 footprint->SetStaticComponentClass(
m_board->GetComponentClassManager().GetNoneComponentClass() );
6272 if( !IsSymbol( token ) && token != T_NUMBER )
6273 Expecting(
"symbol|number" );
6279 THROW_IO_ERRORF(
_(
"Invalid footprint ID in\nfile: %s\nline: %d\noffset: %d." ),
6280 CurSource(), CurLineNumber(), CurOffset() );
6290 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
6292 if( token == T_LEFT )
6302 int this_version =
parseInt( FromUTF8().mb_str( wxConvUTF8 ) );
6307 footprint->SetFileFormatVersionAtLoad( this_version );
6318 case T_generator_version:
6367 footprint->SetPosition( pt );
6370 if( token == T_NUMBER )
6375 else if( token != T_RIGHT )
6377 Expecting( T_RIGHT );
6387 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
6389 if( token != T_LEFT )
6390 Expecting( T_LEFT );
6413 if( !std::isfinite( parsedScaleX ) || parsedScaleX <= 0.0 )
6416 if( !std::isfinite( parsedScaleY ) || parsedScaleY <= 0.0 )
6423 Expecting(
"translate, rotate, or scale" );
6427 footprint->SetPosition( trsTranslate );
6428 footprint->SetOrientation( trsRotate );
6429 footprint->SetTransformScale( parsedScaleX, parsedScaleY );
6434 NeedSYMBOLorNUMBER();
6435 footprint->SetLibDescription( FromUTF8() );
6440 NeedSYMBOLorNUMBER();
6441 footprint->SetKeywords( FromUTF8() );
6453 wxString pName = FromUTF8();
6455 wxString pValue = FromUTF8();
6463 if( pName ==
"ki_keywords" || pName ==
"ki_locked" )
6471 if( pName ==
"ki_description" )
6479 if( pName ==
"Sheetfile" || pName ==
"Sheet file" )
6481 footprint->SetSheetfile( pValue );
6486 if( pName ==
"Sheetname" || pName ==
"Sheet name" )
6488 footprint->SetSheetname( pValue );
6495 std::unique_ptr<PCB_FIELD> unusedField;
6496 bool newField =
false;
6500 if( pName ==
"ki_fp_filters" )
6502 footprint->SetFilters( pValue );
6507 unusedField = std::make_unique<PCB_FIELD>( footprint.get(),
FIELD_T::USER );
6508 field = unusedField.get();
6510 else if( pName ==
"Footprint" )
6516 field = unusedField.get();
6518 else if( footprint->HasField( pName ) )
6520 field = footprint->GetField( pName );
6526 footprint->Add( field );
6545 if( newField && !sawEffects &&
m_board )
6551 NeedSYMBOLorNUMBER();
6552 footprint->SetPath(
KIID_PATH( FromUTF8() ) );
6558 footprint->SetSheetname( FromUTF8() );
6564 footprint->SetSheetfile( FromUTF8() );
6570 std::vector<FOOTPRINT::FP_UNIT_INFO> unitInfos;
6573 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
6575 if( token == T_LEFT )
6578 if( token == T_unit )
6582 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
6584 if( token == T_LEFT )
6587 if( token == T_name )
6589 NeedSYMBOLorNUMBER();
6590 info.m_unitName = FromUTF8();
6593 else if( token == T_pins )
6596 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
6598 if( token == T_STRING || token == T_NUMBER )
6600 info.m_pins.emplace_back( FromUTF8() );
6604 Expecting(
"pin number" );
6615 unitInfos.push_back(
info );
6624 if( !unitInfos.empty() )
6625 footprint->SetUnitInfo( unitInfos );
6630 case T_autoplace_cost90:
6631 case T_autoplace_cost180:
6632 parseInt(
"legacy auto-place cost" );
6636 case T_private_layers:
6640 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
6645 privateLayers.
set( it->second );
6647 Expecting(
"layer name" );
6656 footprint->SetPrivateLayers( privateLayers );
6660 case T_net_tie_pad_groups:
6661 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
6662 footprint->AddNetTiePadGroup( CurStr() );
6666 case T_duplicate_pad_numbers_are_jumpers:
6667 footprint->SetDuplicatePadNumbersAreJumpers(
parseBool() );
6671 case T_jumper_pad_groups:
6674 std::set<wxString> names;
6675 bool inGroup =
false;
6677 for( token = NextTok(); inGroup || token != T_RIGHT; token = NextTok() )
6679 switch(
static_cast<int>( token ) )
6683 Expecting(
"list of pad names" );
6690 Expecting(
"list of pad names" );
6692 names.insert( FromUTF8() );
6704 Expecting(
"list of pad names" );
6711 case T_solder_mask_margin:
6712 footprint->SetLocalSolderMaskMargin(
parseBoardUnits(
"local solder mask margin value" ) );
6717 footprint->SetLocalSolderMaskMargin( {} );
6721 case T_solder_paste_margin:
6722 footprint->SetLocalSolderPasteMargin(
parseBoardUnits(
"local solder paste margin value" ) );
6727 footprint->SetLocalSolderPasteMargin( {} );
6731 case T_solder_paste_ratio:
6732 case T_solder_paste_margin_ratio:
6733 footprint->SetLocalSolderPasteMarginRatio(
parseDouble(
"local solder paste margin ratio value" ) );
6738 footprint->SetLocalSolderPasteMarginRatio( {} );
6743 footprint->SetLocalClearance(
parseBoardUnits(
"local clearance value" ) );
6748 footprint->SetLocalClearance( {} );
6752 case T_zone_connect:
6757 case T_thermal_width:
6765 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
6773 case T_through_hole:
6785 case T_exclude_from_pos_files:
6789 case T_exclude_from_bom:
6793 case T_exclude_from_sim:
6797 case T_allow_missing_courtyard:
6798 footprint->SetAllowMissingCourtyard(
true );
6805 case T_allow_soldermask_bridges:
6806 footprint->SetAllowSolderMaskBridges(
true );
6810 Expecting(
"through_hole, smd, virtual, board_only, exclude_from_pos_files, "
6811 "exclude_from_bom, exclude_from_sim or allow_solder_mask_bridges" );
6814 footprint->SetAttributes( attributes );
6823 switch( field->GetId() )
6827 footprint->Reference().SetUuidDirect(
text->m_Uuid );
6833 footprint->Value().SetUuidDirect(
text->m_Uuid );
6874 case T_fp_ellipse_arc:
6912 if( token == T_LEFT )
6917 if( token != T_type )
6918 Expecting( T_type );
6922 if( CurTok() == T_extruded )
6929 bodyItem = &footprint->EnsureBody();
6933 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
6935 if( token != T_LEFT )
6936 Expecting( T_LEFT );
6955 case T_overall_height:
6960 case T_body_pcb_gap:
6968 wxString layerName =
From_UTF8( CurText() );
6970 if( layerName == wxT(
"auto" ) )
6974 else if( layerName == wxT(
"pad_bbox" ) )
6993 wxString matName =
From_UTF8( CurText() );
6995 if( matName == wxT(
"matte" ) )
6997 else if( matName == wxT(
"metal" ) )
6999 else if( matName == wxT(
"copper" ) )
7010 NeedSYMBOLorNUMBER();
7011 wxString first =
From_UTF8( CurText() );
7013 if( first == wxT(
"unspecified" ) )
7033 if( token != T_xyz )
7047 if( token != T_xyz )
7061 if( token != T_xyz )
7072 Expecting(
"hide, uuid, overall_height, body_pcb_gap, layer, material, "
7073 "color, offset, scale, or rotate" );
7079 Expecting(
"extruded" );
7086 footprint->Add3DModel(
model );
7142 case T_embedded_fonts:
7144 footprint->GetEmbeddedFiles()->SetAreFontsEmbedded(
parseBool() );
7149 case T_embedded_files:
7152 embeddedFilesParser.SyncLineReaderWith( *
this );
7156 embeddedFilesParser.
ParseEmbedded( footprint->GetEmbeddedFiles() );
7164 for(
int tok = embeddedFilesParser.NextTok(); tok !=
DSN_EOF; tok = embeddedFilesParser.NextTok() )
7168 else if( tok ==
DSN_RIGHT && --depth < 0 )
7173 SyncLineReaderWith( embeddedFilesParser );
7177 case T_component_classes:
7179 std::unordered_set<wxString> componentClassNames;
7181 while( ( token = NextTok() ) != T_RIGHT )
7183 if( token != T_LEFT )
7184 Expecting( T_LEFT );
7186 if( ( token = NextTok() ) != T_class )
7187 Expecting( T_class );
7189 NeedSYMBOLorNUMBER();
7190 componentClassNames.insert(
From_UTF8( CurText() ) );
7194 footprint->SetTransientComponentClassNames( componentClassNames );
7197 footprint->ResolveComponentClassNames(
m_board, componentClassNames );
7206 case T_custom_property:
7211 Expecting(
"at, descr, locked, placed, tedit, tstamp, uuid, variant, autoplace_cost90, "
7212 "autoplace_cost180, attr, clearance, embedded_files, fp_arc, fp_circle, fp_curve, "
7213 "fp_line, fp_poly, fp_rect, fp_text, pad, group, generator, model, path, "
7214 "solder_mask_margin, solder_paste_margin, solder_paste_margin_ratio, tags, "
7215 "thermal_gap, version, zone, zone_connect, component_classes, or custom_property" );
7219 footprint->FixUpPadsForBoard(
m_board );
7231 if( footprint->GetKeywords().StartsWith( wxT(
"net tie" ) ) )
7235 for(
PAD*
pad : footprint->Pads() )
7237 if( !padGroup.IsEmpty() )
7238 padGroup += wxS(
", " );
7240 padGroup +=
pad->GetNumber();
7243 if( !padGroup.IsEmpty() )
7244 footprint->AddNetTiePadGroup( padGroup );
7248 footprint->SetAttributes( attributes );
7250 footprint->SetFPID( fpid );
7252 return footprint.release();
7258 wxCHECK_RET( CurTok() == T_stackup,
"Expected stackup token" );
7264 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
7266 if( CurTok() != T_LEFT )
7267 Expecting( T_LEFT );
7275 NeedSYMBOLorNUMBER();
7280 Expecting(
"layer name" );
7282 layers.
set( it->second );
7288 Expecting(
"layer" );
7296 if( gotCuLayers.count() % 2 != 0 )
7298 THROW_IO_ERRORF(
_(
"Invalid stackup in footprint: odd number of copper layers (%d)." ),
7299 gotCuLayers.count() );
7303 if( gotCuLayers != expectedCuLayers )
7305 THROW_IO_ERROR(
_(
"Invalid stackup in footprint: copper layers are not contiguous." ) );
7310 THROW_IO_ERROR(
_(
"Invalid stackup in footprint: technology layers are implicit in footprints and "
7311 "should not be specified in the stackup." ) );
7322 wxCHECK_MSG( CurTok() == T_pad,
nullptr, wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as PAD." ) );
7326 bool foundNet =
false;
7327 bool foundNetcode =
false;
7329 std::unique_ptr<PAD>
pad = std::make_unique<PAD>( aParent );
7331 NeedSYMBOLorNUMBER();
7332 pad->SetNumber( FromUTF8() );
7334 T token = NextTok();
7359 case T_non_component:
7363 case T_np_thru_hole:
7368 Expecting(
"thru_hole, smd, connect, non_component, or np_thru_hole" );
7402 Expecting(
"circle, rectangle, roundrect, oval, trapezoid or custom" );
7405 std::optional<EDA_ANGLE> thermalBrAngleOverride;
7407 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
7409 if( token == T_locked )
7415 if( token != T_LEFT )
7416 Expecting( T_LEFT );
7432 pad->SetFPRelativePosition( pt );
7438 if( token == T_NUMBER )
7443 else if( token == T_RIGHT )
7449 Expecting(
") or angle value" );
7466 bool haveWidth =
false;
7469 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
7471 if( token == T_LEFT )
7485 drillSize.
y = drillSize.
x;
7499 pad->SetLibOffset(
F_Cu, pt );
7504 Expecting(
"oval, size, or offset" );
7520 pad->SetLibDrillSize( drillSize );
7531 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
7533 if( token != T_LEFT )
7534 Expecting( T_LEFT );
7559 Expecting(
"size or layers" );
7569 case T_tertiary_drill:
7574 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
7576 if( token != T_LEFT )
7577 Expecting( T_LEFT );
7602 Expecting(
"size or layers" );
7616 pad->SetLayerSet( layerMask );
7632 CurSource(), CurLineNumber(), CurOffset() );
7636 foundNetcode =
true;
7642 if( !IsSymbol( token ) )
7644 Expecting(
"net name" );
7650 wxString netName( FromUTF8() );
7659 if( netName !=
m_board->FindNet(
pad->GetNetCode() )->GetNetname() )
7663 _(
"Net name doesn't match ID in\nfile: %s\nline: %d offset: %d" ),
7664 CurSource(), CurLineNumber(), CurOffset() );
7677 pad->SetNet( netinfo );
7685 NeedSYMBOLorNUMBER();
7686 pad->SetPinFunction( FromUTF8() );
7691 NeedSYMBOLorNUMBER();
7692 pad->SetPinType( FromUTF8() );
7696 case T_sim_electrical_type:
7704 default: Expecting(
"sink or source" );
7725 case T_solder_mask_margin:
7726 pad->SetLocalSolderMaskMargin(
parseBoardUnits(
"local solder mask margin value" ) );
7731 pad->SetLocalSolderMaskMargin( {} );
7735 case T_solder_paste_margin:
7736 pad->SetLocalSolderPasteMargin(
parseBoardUnits(
"local solder paste margin value" ) );
7741 pad->SetLocalSolderPasteMargin( {} );
7745 case T_solder_paste_margin_ratio:
7746 pad->SetLocalSolderPasteMarginRatio(
parseDouble(
"local solder paste margin ratio value" ) );
7751 pad->SetLocalSolderPasteMarginRatio( {} );
7761 pad->SetLocalClearance( {} );
7769 case T_zone_connect:
7774 case T_thermal_width:
7775 case T_thermal_bridge_width:
7780 case T_thermal_bridge_angle:
7791 case T_roundrect_rratio:
7796 case T_chamfer_ratio:
7799 if(
pad->GetChamferRectRatio(
F_Cu ) > 0 )
7808 bool end_list =
false;
7828 case T_bottom_right:
7833 pad->SetChamferPositions(
F_Cu, chamfers );
7838 Expecting(
"chamfer_top_left chamfer_top_right chamfer_bottom_left or chamfer_bottom_right" );
7849 while( token != T_RIGHT )
7864 case T_RIGHT:
break;
7868 Expecting(
"pad_prop_bga pad_prop_fiducial_glob pad_prop_fiducial_loc"
7869 " pad_prop_heatsink or pad_prop_castellated" );
7891 case T_remove_unused_layers:
7894 pad->SetRemoveUnconnected( remove );
7898 case T_keep_end_layers:
7901 pad->SetKeepTopBottom( keep );
7908 pad->Padstack().FrontOuterLayers().has_solder_mask = front;
7909 pad->Padstack().BackOuterLayers().has_solder_mask = back;
7913 case T_zone_layer_connections:
7920 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
7925 Expecting(
"copper layer name" );
7946 case T_front_post_machining:
7950 case T_back_post_machining:
7954 case T_custom_property:
7959 Expecting(
"at, locked, drill, layers, net, die_length, roundrect_rratio, "
7960 "solder_mask_margin, solder_paste_margin, solder_paste_margin_ratio, uuid, "
7961 "clearance, tstamp, primitives, remove_unused_layers, keep_end_layers, "
7962 "pinfunction, pintype, zone_connect, thermal_width, thermal_gap, padstack, "
7963 "teardrops, front_post_machining, back_post_machining, or custom_property" );
7970 pad->SetNetCode( 0,
true );
7973 if( thermalBrAngleOverride )
7975 pad->SetThermalSpokeAngle( *thermalBrAngleOverride );
7997 if( !
pad->CanHaveNumber() )
8001 pad->SetNumber( wxEmptyString );
8005 pad->Padstack().ForEachUniqueLayer(
8010 if( padSize.
x <= 0 || padSize.
y <= 0 )
8014 m_parseWarnings.push_back( wxString::Format(
_(
"Invalid zero-sized pad pinned to %s in\n"
8019 CurSource(), CurLineNumber(), CurOffset() ) );
8023 return pad.release();
8029 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
8031 if( token == T_LEFT )
8062 Expecting(
"gr_line, gr_arc, gr_circle, gr_curve, gr_rect, gr_bbox or gr_poly" );
8072 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
8074 if( token != T_LEFT )
8075 Expecting( T_LEFT );
8090 default: Expecting(
"circle or rect" );
8100 if( aLayer ==
F_Cu )
8108 default: Expecting(
"outline or convexhull" );
8116 Expecting(
"anchor or clearance" );
8128 T token = NextTok();
8134 default: Expecting(
"counterbore or countersink" );
8138 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
8140 if( token != T_LEFT )
8141 Expecting( T_LEFT );
8163 Expecting(
"size, depth, or angle" );
8173 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
8175 if( token != T_LEFT )
8176 Expecting( T_LEFT );
8187 case T_front_inner_back:
8196 Expecting(
"front_inner_back or custom" );
8207 if( curText ==
"Inner" )
8211 THROW_IO_ERRORF(
_(
"Invalid padstack layer in\nfile: %s\nline: %d\noffset: %d." ),
8212 CurSource(), CurLineNumber(), CurOffset() );
8224 THROW_IO_ERRORF(
_(
"Invalid padstack layer '%s' in file '%s' at line %d, offset %d." ),
8225 curText, CurSource().GetData(), CurLineNumber(), CurOffset() );
8232 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
8234 if( token != T_LEFT )
8235 Expecting( T_LEFT );
8273 Expecting(
"circle, rectangle, roundrect, oval, trapezoid or custom" );
8309 case T_roundrect_rratio:
8314 case T_chamfer_ratio:
8329 bool end_list =
false;
8349 case T_bottom_right:
8359 Expecting(
"chamfer_top_left chamfer_top_right chamfer_bottom_left or "
8360 "chamfer_bottom_right" );
8370 case T_thermal_bridge_width:
8380 case T_thermal_bridge_angle:
8385 case T_zone_connect:
8387 magic_enum::enum_cast<ZONE_CONNECTION>(
parseInt(
"zone connection value" ) );
8424 Expecting(
"mode or layer" );
8433 while( NextTok() != T_RIGHT )
8438 KIID uuid( CurStr() );
8446 for(
T tok = NextTok(); tok != T_RIGHT; tok = NextTok() )
8449 Expecting( T_LEFT );
8451 if( NextTok() != T_template )
8452 Expecting( T_template );
8454 wxString templateName;
8455 std::unique_ptr<BOARD_ITEM> parsed;
8458 for(
T innerTok = NextTok(); innerTok != T_RIGHT; innerTok = NextTok() )
8460 if( innerTok != T_LEFT )
8461 Expecting( T_LEFT );
8463 T inner = NextTok();
8468 NeedSYMBOLorNUMBER();
8469 templateName = FromUTF8();
8479 default: Expecting(
"name or via" );
8484 aGenInfo.
templates.emplace_back( templateName, std::move( parsed ) );
8491 wxCHECK_RET( CurTok() == T_group, wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as PCB_GROUP." ) );
8497 groupInfo.
parent = aParent;
8499 while( ( token = NextTok() ) != T_LEFT )
8501 if( token == T_STRING )
8502 groupInfo.
name = FromUTF8();
8503 else if( token == T_locked )
8506 Expecting(
"group name or locked" );
8509 for( ; token != T_RIGHT; token = NextTok() )
8511 if( token != T_LEFT )
8512 Expecting( T_LEFT );
8530 if( !IsSymbol( token ) && token != T_NUMBER )
8531 Expecting(
"symbol|number" );
8533 wxString
name = FromUTF8();
8537 name.Replace(
"{slash}",
"/" );
8543 if(
static_cast<int>(
name.size() ) > bad_pos )
8545 wxString msg = wxString::Format(
_(
"Group library link %s contains invalid character '%c'" ),
8552 THROW_PARSE_ERROR(
_(
"Invalid library ID" ), CurSource(), CurLine(), CurLineNumber(), CurOffset() );
8568 case T_custom_property:
8573 Expecting(
"uuid, locked, lib_id, or members" );
8581 wxCHECK_RET( CurTok() == T_constraint,
8582 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as PCB_CONSTRAINT." ) );
8586 info.parent = aParent;
8588 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
8590 if( token != T_LEFT )
8591 Expecting( T_LEFT );
8610 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
8612 if( token != T_LEFT )
8613 Expecting( T_LEFT );
8615 if( NextTok() != T_member )
8616 Expecting(
"member" );
8619 KIID memberId( CurStr() );
8632 if( token != T_RIGHT )
8634 if( token != T_NUMBER )
8635 Expecting(
"vertex index" );
8662 case T_custom_property:
8667 Expecting(
"type, uuid, members, value, or driving" );
8683 BOARD* board =
dynamic_cast<BOARD*
>( aParent );
8686 std::unordered_map<KIID, BOARD_ITEM*> fpItemMap;
8693 fpItemMap.insert( { child->
m_Uuid, child } );
8705 else if( footprint )
8707 auto it = fpItemMap.find( aId );
8709 return it != fpItemMap.end() ? it->second :
nullptr;
8717 std::unique_ptr<PCB_CONSTRAINT> constraint = std::make_unique<PCB_CONSTRAINT>(
info.parent,
info.type );
8719 constraint->SetUuidDirect(
info.uuid );
8720 constraint->SetValue(
info.value );
8721 constraint->SetDriving(
info.driving );
8722 constraint->SetCustomProperties(
info.customProperties );
8736 resolvedId = remap->second;
8767 wxCHECK_RET( CurTok() == T_generated,
8768 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as PCB_GENERATOR." ) );
8776 genInfo.
parent = aParent;
8783 if( token != T_uuid && token != T_id )
8784 Expecting( T_uuid );
8790 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
8792 if( token != T_LEFT )
8793 Expecting( T_LEFT );
8807 genInfo.
name = FromUTF8();
8813 genInfo.
locked = token == T_yes;
8830 case T_custom_property:
8836 wxString pName = FromUTF8();
8842 genInfo.
properties.emplace( pName, wxAny(
true ) );
8847 genInfo.
properties.emplace( pName, wxAny(
false ) );
8854 genInfo.
properties.emplace( pName, wxAny( pValue ) );
8861 wxString pValue = FromUTF8();
8881 genInfo.
properties.emplace( pName, wxAny( pt ) );
8891 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
8901 std::vector<VECTOR2I> cells;
8903 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
8905 if( token != T_LEFT )
8906 Expecting( T_LEFT );
8908 if( NextTok() != T_ij )
8917 cells.push_back( cell );
8921 genInfo.
properties.emplace( pName, wxAny( cells ) );
8926 Expecting(
"xy, pts or cells" );
8933 Expecting(
"a number, symbol, string or (" );
8944 && ( genInfo.
genType == wxT(
"tuning_pattern" ) || genInfo.
genType == wxT(
"via_stack" ) ) )
8953 wxCHECK_MSG( CurTok() == T_arc,
nullptr, wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as ARC." ) );
8956 std::unique_ptr<PCB_ARC> arc = std::make_unique<PCB_ARC>(
m_board );
8958 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
8961 if( token == T_locked )
8963 arc->SetLocked(
true );
8967 if( token != T_LEFT )
8968 Expecting( T_LEFT );
8977 arc->SetStart( pt );
9009 case T_solder_mask_margin:
9010 arc->SetLocalSolderMaskMargin(
parseBoardUnits(
"local solder mask margin value" ) );
9035 case T_custom_property:
9040 Expecting(
"start, mid, end, width, layer, solder_mask_margin, net, tstamp, uuid or status" );
9051 if(
IsStraightArc( arc->GetStart(), arc->GetMid(), arc->GetEnd() ) )
9053 std::unique_ptr<PCB_TRACK> track = std::make_unique<PCB_TRACK>(
m_board );
9056 static_cast<PCB_TRACK&
>( *track ) = *arc;
9057 track->SetUuidDirect( arc->m_Uuid );
9058 return track.release();
9061 return arc.release();
9067 wxCHECK_MSG( CurTok() == T_segment,
nullptr,
9068 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as PCB_TRACK." ) );
9071 std::unique_ptr<PCB_TRACK> track = std::make_unique<PCB_TRACK>(
m_board );
9073 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
9076 if( token == T_locked )
9078 track->SetLocked(
true );
9082 if( token != T_LEFT )
9083 Expecting( T_LEFT );
9092 track->SetStart( pt );
9099 track->SetEnd( pt );
9117 case T_solder_mask_margin:
9118 track->SetLocalSolderMaskMargin(
parseBoardUnits(
"local solder mask margin value" ) );
9143 case T_custom_property:
9148 Expecting(
"start, end, width, layer, solder_mask_margin, net, tstamp, uuid or locked" );
9158 return track.release();
9164 wxCHECK_MSG( CurTok() == T_via,
nullptr,
9165 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as PCB_VIA." ) );
9168 std::unique_ptr<PCB_VIA>
via = std::make_unique<PCB_VIA>(
m_board );
9181 via->Padstack().FrontOuterLayers().has_covering =
false;
9182 via->Padstack().BackOuterLayers().has_covering =
false;
9183 via->Padstack().FrontOuterLayers().has_plugging =
false;
9184 via->Padstack().BackOuterLayers().has_plugging =
false;
9185 via->Padstack().Drill().is_filled =
false;
9186 via->Padstack().Drill().is_capped =
false;
9189 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
9192 if( token == T_locked )
9194 via->SetLocked(
true );
9198 if( token == T_LEFT )
9218 via->SetStart( pt );
9240 via->SetLayerPair( layer1, layer2 );
9243 Expecting(
"layer name" );
9253 case T_remove_unused_layers:
9255 via->SetRemoveUnconnected(
true );
9259 case T_keep_end_layers:
9261 via->SetKeepStartEnd(
true );
9265 case T_start_end_only:
9271 case T_zone_layer_connections:
9279 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
9284 Expecting(
"copper layer name" );
9303 via->Padstack().FrontOuterLayers().has_solder_mask = front;
9304 via->Padstack().BackOuterLayers().has_solder_mask = back;
9311 via->Padstack().FrontOuterLayers().has_covering = front;
9312 via->Padstack().BackOuterLayers().has_covering = back;
9319 via->Padstack().FrontOuterLayers().has_plugging = front;
9320 via->Padstack().BackOuterLayers().has_plugging = back;
9360 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
9362 if( token != T_LEFT )
9363 Expecting( T_LEFT );
9388 Expecting(
"size or layers" );
9398 case T_tertiary_drill:
9403 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
9405 if( token != T_LEFT )
9406 Expecting( T_LEFT );
9431 Expecting(
"size or layers" );
9441 case T_front_post_machining:
9445 case T_back_post_machining:
9449 case T_custom_property:
9454 Expecting(
"blind, micro, at, size, drill, layers, net, free, tstamp, uuid, status, "
9455 "teardrops, backdrill, tertiary_drill, front_post_machining, or back_post_machining" );
9459 return via.release();
9463std::pair<std::optional<bool>, std::optional<bool>>
9466 T token = NextTok();
9468 std::pair<std::optional<bool>, std::optional<bool>>
result;
9469 auto& [front, back] =
result;
9471 if( token != T_LEFT && aAllowLegacyFormat )
9474 while( token != T_RIGHT )
9476 if( token == T_front )
9480 else if( token == T_back )
9484 else if( token == T_none )
9491 Expecting(
"front, back or none" );
9500 while( token != T_RIGHT )
9502 if( token != T_LEFT )
9507 if( token == T_front )
9509 else if( token == T_back )
9512 Expecting(
"front or back" );
9527 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
9529 if( token != T_LEFT )
9530 Expecting( T_LEFT );
9543 default: Expecting(
"front_inner_back or custom" );
9554 if( curText ==
"Inner" )
9558 THROW_IO_ERRORF(
_(
"Invalid padstack layer in\nfile: %s\nline: %d\noffset: %d." ),
9559 CurSource(), CurLineNumber(), CurOffset() );
9571 THROW_IO_ERRORF(
_(
"Invalid padstack layer '%s' in file '%s' at line %d, offset %d." ),
9572 curText, CurSource().GetData(), CurLineNumber(), CurOffset() );
9575 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
9577 if( token != T_LEFT )
9578 Expecting( T_LEFT );
9588 padstack.
SetSize( { diameter, diameter }, curLayer );
9595 Expecting(
"size" );
9603 Expecting(
"mode or layer" );
9612 wxCHECK_MSG( CurTok() == T_zone,
nullptr,
9613 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as ZONE." ) );
9619 wxString legacyNetnameFromFile;
9622 std::map<PCB_LAYER_ID, SHAPE_POLY_SET> pts;
9623 std::map<PCB_LAYER_ID, std::vector<SEG>> legacySegs;
9625 bool addedFilledPolygons =
false;
9631 std::unique_ptr<ZONE> zone = std::make_unique<ZONE>( aParent );
9633 zone->SetAssignedPriority( 0 );
9644 zone->SetCornerRadius( 0 );
9645 zone->SetHatchSmoothingLevel( 0 );
9646 zone->SetLocked(
false );
9648 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
9651 if( token == T_locked )
9653 zone->SetLocked(
true );
9657 if( token == T_LEFT )
9667 NeedSYMBOLorNUMBER();
9668 legacyNetnameFromFile = FromUTF8();
9695 if( token != T_none && token != T_edge && token != T_full )
9696 Expecting(
"none, edge, or full" );
9711 zone->SetAssignedPriority(
parseInt(
"zone priority" ) );
9715 case T_connect_pads:
9716 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
9718 if( token == T_LEFT )
9731 case T_thru_hole_only:
9741 Expecting(
"yes, no, or clearance" );
9747 case T_min_thickness:
9752 case T_filled_areas_thickness:
9759 isStrokedFill =
false;
9765 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
9767 if( token == T_LEFT )
9773 zone->SetIsFilled(
true );
9779 if( token != T_segment && token != T_hatch && token != T_polygon
9780 && token != T_thieving )
9782 Expecting(
"segment, hatch, polygon or thieving" );
9794 Expecting(
"segment, hatch or polygon "
9795 "(thieving requires file version >= 20260513)" );
9811 case T_hatch_thickness:
9821 case T_hatch_orientation:
9829 case T_hatch_smoothing_level:
9830 zone->SetHatchSmoothingLevel(
parseDouble( T_hatch_smoothing_level ) );
9834 case T_hatch_smoothing_value:
9835 zone->SetHatchSmoothingValue(
parseDouble( T_hatch_smoothing_value ) );
9839 case T_hatch_border_algorithm:
9842 if( token != T_hatch_thickness && token != T_min_thickness )
9843 Expecting(
"hatch_thickness or min_thickness" );
9845 zone->SetHatchBorderAlgorithm( token == T_hatch_thickness ? 1 : 0 );
9849 case T_hatch_min_hole_area:
9850 zone->SetHatchHoleMinArea(
parseDouble( T_hatch_min_hole_area ) );
9858 Expecting(
"thieving requires file version >= 20260513" );
9863 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
9865 if( token == T_LEFT )
9878 default: Expecting(
"dots, squares or hatch" );
9933 Expecting(
"type, size, gap, width, stagger or orientation" );
9937 zone->SetThievingSettings( thieving );
9941 case T_arc_segments:
9951 case T_thermal_bridge_width:
9952 zone->SetThermalReliefSpokeWidth(
parseBoardUnits( T_thermal_bridge_width ) );
9964 if( !zone->GetIsRuleArea() )
9970 if( !zone->GetIsRuleArea() )
9976 Expecting(
"none, chamfer, or fillet" );
9985 if( !zone->GetIsRuleArea() )
9986 zone->SetCornerRadius( tmp );
9991 case T_island_removal_mode:
9992 tmp =
parseInt(
"island_removal_mode" );
9994 if( tmp >= 0 && tmp <= 2 )
10000 case T_island_area_min:
10003 zone->SetMinIslandArea( area *
pcbIUScale.IU_PER_MM );
10009 Expecting(
"mode, arc_segments, thermal_gap, thermal_bridge_width, "
10010 "hatch_thickness, hatch_gap, hatch_orientation, "
10011 "hatch_smoothing_level, hatch_smoothing_value, "
10012 "hatch_border_algorithm, hatch_min_hole_area, thieving, "
10013 "smoothing, radius, island_removal_mode, or island_area_min" );
10020 zone->SetIsRuleArea(
true );
10022 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
10024 if( token == T_LEFT )
10033 zone->SetPlacementAreaSource( FromUTF8() );
10036 case T_component_class:
10040 zone->SetPlacementAreaSource( FromUTF8() );
10047 zone->SetPlacementAreaSource( FromUTF8() );
10054 if( token == T_yes )
10055 zone->SetPlacementAreaEnabled(
true );
10056 else if( token == T_no )
10057 zone->SetPlacementAreaEnabled(
false );
10059 Expecting(
"yes or no" );
10068 zone->SetLinkSet(
KIID( CurStr() ) );
10070 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
10072 if( token == T_LEFT )
10088 Expecting(
"placement, routing, connected_routing, other_items, group_items, "
10089 "locked_items or anchor" );
10095 zone->SetRepeatOptions( opts );
10102 Expecting(
"enabled, sheetname, component_class, group or link" );
10114 zone->SetIsRuleArea(
true );
10117 zone->SetDoNotAllowPads(
false );
10118 zone->SetDoNotAllowFootprints(
false );
10120 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
10122 if( token == T_LEFT )
10130 if( token != T_allowed && token != T_not_allowed )
10131 Expecting(
"allowed or not_allowed" );
10133 zone->SetDoNotAllowTracks( token == T_not_allowed );
10139 if( token != T_allowed && token != T_not_allowed )
10140 Expecting(
"allowed or not_allowed" );
10142 zone->SetDoNotAllowVias( token == T_not_allowed );
10148 if( token != T_allowed && token != T_not_allowed )
10149 Expecting(
"allowed or not_allowed" );
10151 zone->SetDoNotAllowZoneFills( token == T_not_allowed );
10157 if( token != T_allowed && token != T_not_allowed )
10158 Expecting(
"allowed or not_allowed" );
10160 zone->SetDoNotAllowPads( token == T_not_allowed );
10166 if( token != T_allowed && token != T_not_allowed )
10167 Expecting(
"allowed or not_allowed" );
10169 zone->SetDoNotAllowFootprints( token == T_not_allowed );
10173 Expecting(
"tracks, vias or copperpour" );
10188 if( token != T_pts )
10189 Expecting( T_pts );
10191 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
10203 zone->AddPolygon( outline );
10207 case T_filled_polygon:
10213 if( token == T_layer )
10219 if( token != T_LEFT )
10220 Expecting( T_LEFT );
10227 filledLayer = zone->GetFirstLayer();
10230 bool island =
false;
10232 if( token == T_island )
10239 if( token != T_pts )
10240 Expecting( T_pts );
10242 if( !pts.count( filledLayer ) )
10251 zone->SetIsIsland( filledLayer, idx );
10253 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
10258 addedFilledPolygons |= !poly.
IsEmpty();
10263 case T_fill_segments:
10267 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
10269 if( token != T_LEFT )
10270 Expecting( T_LEFT );
10274 if( token != T_pts )
10275 Expecting( T_pts );
10278 filledLayer = zone->GetFirstLayer();
10285 legacySegs[filledLayer].push_back( fillSegment );
10295 zone->SetZoneName( FromUTF8() );
10300 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
10302 if( token == T_LEFT )
10308 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
10310 if( token == T_LEFT )
10318 if( token == T_padvia )
10320 else if( token == T_track_end )
10323 Expecting(
"padvia or track_end" );
10329 Expecting(
"type" );
10336 Expecting(
"teardrop" );
10346 case T_custom_property:
10351 Expecting(
"net, layer/layers, tstamp, hatch, priority, connect_pads, min_thickness, "
10352 "fill, polygon, filled_polygon, fill_segments, attr, locked, uuid, or name" );
10356 if( zone->GetNumCorners() > 2 )
10358 if( !zone->IsOnCopperLayer() )
10365 zone->SetBorderDisplayStyle( hatchStyle, hatchPitch,
true );
10368 if( addedFilledPolygons )
10370 if( isStrokedFill && !zone->GetIsRuleArea() )
10374 m_parseWarnings.push_back(
_(
"Legacy zone fill strategy is not supported anymore.\n"
10375 "Zone fills will be converted on best-effort basis." ) );
10380 if( zone->GetMinThickness() > 0 )
10382 for(
auto& [layer, polyset] : pts )
10384 polyset.InflateWithLinkedHoles( zone->GetMinThickness() / 2,
10391 for(
auto& [layer, polyset] : pts )
10392 zone->SetFilledPolysList( layer, polyset );
10394 zone->CalculateFilledArea();
10396 else if( legacySegs.size() > 0 )
10404 m_parseWarnings.push_back(
_(
"The legacy segment zone fill mode is no longer supported.\n"
10405 "Zone fills will be converted on a best-effort basis." ) );
10411 for(
const auto& [layer, segments] : legacySegs )
10415 if( zone->HasFilledPolysForLayer( layer ) )
10418 for(
const auto& seg : segments )
10429 zone->SetFilledPolysList( layer, layerFill );
10430 zone->CalculateFilledArea();
10438 bool zone_has_net = zone->IsOnCopperLayer() && !zone->GetIsRuleArea();
10440 if( !zone_has_net )
10444 if(
m_board && !legacyNetnameFromFile.IsEmpty() && zone->GetNetname() != legacyNetnameFromFile )
10457 int newnetcode =
m_board->GetNetCount();
10470 m_board->SetLegacyTeardrops(
true );
10473 zone->SetNeedRefill(
false );
10476 if( zone->GetLinkSet() !=
niluuid || zone->GetRepeatOptions().m_anchor !=
niluuid )
10479 return zone.release();
10485 wxCHECK_MSG( CurTok() == T_point,
nullptr,
10486 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as PCB_POINT." ) );
10488 std::unique_ptr<PCB_POINT> point = std::make_unique<PCB_POINT>(
nullptr );
10490 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
10492 if( token == T_LEFT )
10502 point->SetPosition( pt );
10525 case T_custom_property:
10528 default: Expecting(
"at, size, layer or uuid" );
10532 return point.release();
10538 wxCHECK_MSG( CurTok() == T_target,
nullptr,
10539 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as PCB_TARGET." ) );
10544 std::unique_ptr<PCB_TARGET> target = std::make_unique<PCB_TARGET>(
nullptr );
10546 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
10548 if( token == T_LEFT )
10554 target->SetShape( 1 );
10558 target->SetShape( 0 );
10564 target->SetPosition( pt );
10590 case T_custom_property:
10595 Expecting(
"x, plus, at, size, width, layer, uuid, or tstamp" );
10599 return target.release();
10605 wxCHECK_MSG( CurTok() == T_grid_item,
nullptr,
10606 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as PCB_GRID_ITEM." ) );
10611 std::unique_ptr<PCB_GRID_ITEM> griditem = std::make_unique<PCB_GRID_ITEM>(
nullptr );
10613 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
10615 if( token == T_LEFT )
10631 griditem->SetPosition( pt );
10640 griditem->SetRadiusSpacing(
parseBoardUnits(
"grid_item radius spacing" ) );
10641 griditem->SetPhiSpacingDegrees(
parseDouble(
"grid_item phi spacing" ) );
10647 griditem->SetSpacing( pt );
10655 griditem->SetRadiusExtent(
parseBoardUnits(
"grid_item radius extent" ) );
10656 griditem->SetPhiExtentDegrees(
parseDouble(
"grid_item phi extent" ) );
10662 griditem->SetExtent( pt );
10668 griditem->SetOrientationDegrees(
parseDouble(
"grid_item orientation" ) );
10673 griditem->SetAssignedPriority(
static_cast<unsigned>(
parseInt(
"grid_item priority" ) ) );
10677 case T_tick_interval:
10678 griditem->SetTickInterval(
static_cast<unsigned>(
parseInt(
"grid_item tick_interval" ) ) );
10688 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
10690 if( token != T_LEFT )
10691 Expecting(
"cursor, routing or placement" );
10694 bool* target =
nullptr;
10698 case T_cursor: target = &aff.
cursor;
break;
10699 case T_routing: target = &aff.
routing;
break;
10700 case T_placement: target = &aff.
placement;
break;
10701 default: Expecting(
"cursor, routing or placement" );
10708 griditem->Affects() = aff;
10723 case T_custom_property:
10728 Expecting(
"xy, polar, at, spacing, extent, angle, priority, tick_interval, "
10729 "affects, locked or uuid" );
10733 return griditem.release();
10740 std::string idStr( CurStr() );
10743 if( *idStr.begin() ==
'"' && *idStr.rbegin() ==
'"' )
10744 idStr = idStr.substr( 1, idStr.length() - 1 );
10753 aId =
KIID( idStr );
constexpr int ARC_HIGH_DEF
constexpr EDA_IU_SCALE pcbIUScale
#define DEFAULT_LINE_WIDTH
@ ZLO_FORCE_NO_ZONE_CONNECTION
@ BS_EDGE_CONNECTOR_BEVELLED
@ BS_EDGE_CONNECTOR_IN_USE
@ BS_ITEM_TYPE_SILKSCREEN
@ BS_ITEM_TYPE_DIELECTRIC
@ BS_ITEM_TYPE_SOLDERPASTE
@ BS_ITEM_TYPE_SOLDERMASK
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
BASE_SET & reset(size_t pos)
BASE_SET & set(size_t pos)
This class handle bitmap images in KiCad.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
virtual bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
virtual void SetNet(NETINFO_ITEM *aNetInfo)
Set a NET_INFO object for the item.
Container for design settings for a BOARD object.
DIM_PRECISION m_DimensionPrecision
Number of digits after the decimal.
std::shared_ptr< NET_SETTINGS > m_NetSettings
int m_CopperEdgeClearance
std::map< PCB_LAYER_ID, ZONE_LAYER_PROPERTIES > m_ZoneLayerProperties
void SetGridOrigin(const VECTOR2I &aOrigin)
bool m_TextUpright[LAYER_CLASS_COUNT]
std::vector< DIFF_PAIR_DIMENSION > m_DiffPairDimensionsList
bool m_AllowSoldermaskBridgesInFPs
void SetAuxOrigin(const VECTOR2I &aOrigin)
int m_SolderMaskExpansion
BOARD_STACKUP & GetStackupDescriptor()
int m_TextThickness[LAYER_CLASS_COUNT]
std::vector< int > m_TrackWidthList
int m_LineThickness[LAYER_CLASS_COUNT]
double m_SolderPasteMarginRatio
ZONE_SETTINGS & GetDefaultZoneSettings()
VECTOR2I m_TextSize[LAYER_CLASS_COUNT]
bool m_TextItalic[LAYER_CLASS_COUNT]
DIM_UNITS_MODE m_DimensionUnitsMode
std::vector< VIA_DIMENSION > m_ViasDimensionsList
int m_ViasMinAnnularWidth
Abstract interface for BOARD_ITEMs capable of storing other items inside.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
void SetUuidDirect(const KIID &aUuid)
Raw UUID assignment.
void SetLocked(bool aLocked) override
virtual void SetIsKnockout(bool aKnockout)
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
FOOTPRINT * GetParentFootprint() const
virtual void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction, RECURSE_MODE aMode) const
Invoke a function on all children.
BOARD_ITEM_CONTAINER * GetParent() const
Manage one layer needed to make a physical board.
void AddDielectricPrms(int aDielectricPrmsIdx)
Add (insert) a DIELECTRIC_PRMS item to m_DielectricPrmsList all values are set to default.
void SetDielectricLayerId(int aLayerId)
void SetThickness(int aThickness, int aDielectricSubLayer=0)
void SetDielectricModel(DIELECTRIC_MODEL aModel, int aDielectricSubLayer=0)
void SetThicknessLocked(bool aLocked, int aDielectricSubLayer=0)
void SetSpecFreq(double aSpecFreq, int aDielectricSubLayer=0)
void SetMaterial(const wxString &aName, int aDielectricSubLayer=0)
void SetLossTangent(double aTg, int aDielectricSubLayer=0)
BOARD_STACKUP_ITEM_TYPE GetType() const
void SetBrdLayerId(PCB_LAYER_ID aBrdLayerId)
void SetTypeName(const wxString &aName)
void SetColor(const wxString &aColorName, int aDielectricSubLayer=0)
void SetEpsilonR(double aEpsilon, int aDielectricSubLayer=0)
Manage layers needed to make a physical board.
void RemoveAll()
Delete all items in list and clear the list.
bool m_HasDielectricConstrains
True if some layers have impedance controlled tracks or have specific constrains for micro-wave appli...
void Add(BOARD_STACKUP_ITEM *aItem)
Add a new item in stackup layer.
void BuildDefaultStackupList(const BOARD_DESIGN_SETTINGS *aSettings, int aActiveCopperLayersCount=0)
Create a default stackup, according to the current BOARD_DESIGN_SETTINGS settings.
bool m_EdgePlating
True if the edge board is plated.
BS_EDGE_CONNECTOR_CONSTRAINTS m_EdgeConnectorConstraints
If the board has edge connector cards, some constrains can be specified in job file: BS_EDGE_CONNECTO...
wxString m_FinishType
The name of external copper finish.
Information pertinent to a Pcbnew printed circuit board.
BOARD_ITEM * ResolveItem(const KIID &aID, bool aAllowNullptrReturn=false) const
Grouping rules and symbol assignments, shared by reference so a chart and its map can never disagree ...
void SetSymbolWidth(int aWidth)
void SetName(const wxString &aName)
void SetFreezeAssignments(bool aFreeze)
void SetGroupedBy(DRILL_GROUP_KEY aKey, bool aOn)
void SetMarkPolicy(DRILL_MARK_POLICY aPolicy)
void SetAssignment(const std::string &aKey, const DRILL_SYMBOL_ASSIGNMENT &aAssignment)
void SetSymbolSize(int aSize)
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
void SetCustomProperty(const wxString &aKey, const wxString &aValue)
virtual EMBEDDED_FILES * GetEmbeddedFiles()
SHAPE_POLY_SET & GetPolyShape()
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
virtual void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
void SetUnresolvedFontName(const wxString &aFontName)
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual void SetTextPos(const VECTOR2I &aPoint)
void SetMirrored(bool isMirrored)
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
void SetBoldFlag(bool aBold)
Set only the bold flag, without changing the font.
virtual void SetVisible(bool aVisible)
void MigrateLegacyBoldStrokeWidth()
Migrate a pre-v11 bold stroke text so its stored thickness holds the base (non-bold) width.
bool GetAutoThickness() const
void SetLineSpacing(double aLineSpacing)
virtual void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
void SetItalicFlag(bool aItalic)
Set only the italic flag, without changing the font.
void SetKeepUpright(bool aKeepUpright)
virtual void SetText(const wxString &aText)
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
void ParseEmbedded(EMBEDDED_FILES *aFiles)
const std::vector< wxString > * UpdateFontFiles()
Helper function to get a list of fonts for fontconfig to add to the library.
EXTRUSION_MATERIAL m_material
VECTOR3D m_Offset
3D model offset (mm)
VECTOR3D m_Rotation
3D model rotation (degrees)
VECTOR3D m_Scale
3D model scaling factor (dimensionless)
wxString m_Filename
The 3D shape filename in 3D library.
bool m_Show
Include model in rendering.
Helper class for creating a footprint library cache.
static GAL_SET DefaultVisible()
The columns one generator (the drill chart, a stackup table, ...) can produce, and the units and prec...
std::vector< GENERATED_TABLE_COLUMN > Defaults() const
const GENERATED_TABLE_COLUMN_DEF * FindToken(const wxString &aToken) const
GENERATED_TABLE_UNITS DefaultUnits() const
bool Validate(std::vector< GENERATED_TABLE_COLUMN > &aColumns) const
Drop a column whose id the schema does not know and a column that repeats an id already kept,...
int DefaultPrecision() const
A factory which returns an instance of a PCB_GENERATOR.
PCB_GENERATOR * CreateFromType(const wxString &aTypeStr)
static GENERATORS_MGR & Instance()
virtual const wxString What() const
A composite of Problem() and Where()
Represents an (ordered) list of JUMPER_GROUP objects.
void Add(JUMPER_GROUP aGroup)
Add a JUMPER_GROUP to the set.
static std::optional< JUMPER_GROUP > Make(std::set< wxString > aNames)
Factory method to create a JUMPER_GROUP from a set of names.
A color representation with 4 components: red, green, blue, alpha.
COLOR4D WithAlpha(double aAlpha) const
Return a color with the same color, but the given alpha.
wxColour ToColour() const
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
wxString AsString() const
A logical library item identifier and consists of various portions much like a URI.
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Decorative shape (arrowhead, circle, square) at the start or end of a graphic line,...
void SetStroke(const STROKE_PARAMS &aStroke)
void SetLength(int aLength)
void SetStyle(LINE_ENDING_STYLE aStyle)
void SetWidth(int aWidth)
LSET is a set of PCB_LAYER_IDs.
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
static int NameToLayer(wxString &aName)
Return the layer number from a layer name.
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
static const LSET & AllTechMask()
Return a mask holding all technical layers (no CU layer) on both side.
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static const LSET & AllLayersMask()
static const LSET & InternalCuMask()
Return a complete set of internal copper layers which is all Cu layers except F_Cu and B_Cu.
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
Handle the data for a net.
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
static const int ORPHANED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
std::shared_ptr< NETCLASS > GetDefaultNetclass() const
Gets the default netclass for the project.
A PADSTACK defines the characteristics of a single or multi-layer pad, in the IPC sense of the word.
std::optional< int > & Clearance(PCB_LAYER_ID aLayer=F_Cu)
MASK_LAYER_PROPS & FrontOuterLayers()
void SetThermalSpokeAngle(EDA_ANGLE aAngle, PCB_LAYER_ID aLayer=F_Cu)
std::optional< int > & ThermalSpokeWidth(PCB_LAYER_ID aLayer=F_Cu)
std::optional< int > & ThermalGap(PCB_LAYER_ID aLayer=F_Cu)
@ CUSTOM
Shapes can be defined on arbitrary layers.
@ FRONT_INNER_BACK
Up to three shapes can be defined (F_Cu, inner copper layers, B_Cu)
MASK_LAYER_PROPS & BackOuterLayers()
void SetSize(const VECTOR2I &aSize, PCB_LAYER_ID aLayer)
static constexpr PCB_LAYER_ID INNER_LAYERS
! The layer identifier to use for "inner layers" on top/inner/bottom padstacks
std::optional< ZONE_CONNECTION > & ZoneConnection(PCB_LAYER_ID aLayer=F_Cu)
void SetAnchorPadShape(PCB_LAYER_ID aLayer, PAD_SHAPE aShape)
Set the shape of the anchor pad for custom shaped pads.
void SetShape(PCB_LAYER_ID aLayer, PAD_SHAPE aShape)
Set the new shape of this pad.
void SetDelta(PCB_LAYER_ID aLayer, const VECTOR2I &aSize)
void DeletePrimitivesList(PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
Clear the basic shapes list.
void AddPrimitive(PCB_LAYER_ID aLayer, PCB_SHAPE *aPrimitive)
Add item to the custom shape primitives list.
void SetCustomShapeInZoneOpt(CUSTOM_SHAPE_ZONE_MODE aOption)
Set the option for the custom pad shape to use as clearance area in copper zones.
void SetChamferRectRatio(PCB_LAYER_ID aLayer, double aChamferScale)
Has meaning only for chamfered rectangular pads.
const PADSTACK & Padstack() const
void SetLibOffset(PCB_LAYER_ID aLayer, const VECTOR2I &aOffset)
void SetLibSize(PCB_LAYER_ID aLayer, const VECTOR2I &aSize)
void SetChamferPositions(PCB_LAYER_ID aLayer, int aPositions)
Has meaning only for chamfered rectangular pads.
void SetRoundRectRadiusRatio(PCB_LAYER_ID aLayer, double aRadiusScale)
Has meaning only for rounded rectangle pads.
Describe the page size and margins of a paper page on which to eventually print or plot.
void SetPortrait(bool aIsPortrait)
Rotate the paper page 90 degrees.
bool SetType(PAGE_SIZE_TYPE aPageSize, bool aIsPortrait=false)
Set the name of the page type and also the sizes and margins commonly associated with that type name.
void SetWidthMM(double aWidthInMM)
void SetHeightMM(double aHeightInMM)
const PAGE_SIZE_TYPE & GetType() const
A 3D body attached to a footprint (or, later, placed on a board).
EXTRUDED_3D_BODY * MutableExtruded()
For better understanding of the points that make a dimension:
void SetExtensionHeight(int aHeight)
void UpdateHeight(const VECTOR2I &aCrossbarStart, const VECTOR2I &aCrossbarEnd)
Update the stored height basing on points coordinates.
void SetHeight(int aHeight)
Set the distance from the feature points to the crossbar line.
A leader is a dimension-like object pointing to a specific point.
void SetTextBorder(DIM_TEXT_BORDER aBorder)
An orthogonal dimension is like an aligned dimension, but the extension lines are locked to the X or ...
A radial dimension indicates either the radius or diameter of an arc or circle.
void SetLeaderLength(int aLength)
A drill chart placed on the board, kept in step with the holes.
void SetSymbolColumn(int aCol)
const std::map< int, int > & RowShapes() const
Curated shape index for each generated row, by table row.
DRILL_CHART_FILTER & Filter()
void RestoreShowTotals(bool aShow)
Set it without that, for a loader whose cells were laid out with this setting.
Turns on drill symbols at the holes, for one layer.
A table whose cell text is derived from the board and rebuilt whenever it goes stale.
virtual void SetProperties(const STRING_ANY_MAP &aProps)
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
virtual bool LayerFollowsMembers() const
virtual void SetTemplateItem(const wxString &aName, std::unique_ptr< BOARD_ITEM > aItem)
Insert a template item (from board file loading)
A set of BOARD_ITEMs (i.e., without duplicates).
void parseCONSTRAINT(BOARD_ITEM *aParent)
wxString m_generatorVersion
Set to the generator version this board requires.
PCB_TABLECELL * parsePCB_TABLECELL(BOARD_ITEM *aParent)
void parseGENERATOR_templates(GENERATOR_INFO &aGenInfo)
std::unordered_map< std::string, PCB_LAYER_ID > LAYER_ID_MAP
std::vector< int > m_netCodes
net codes mapping for boards being loaded
void parseOutlinePoints(SHAPE_LINE_CHAIN &aPoly)
Parses possible outline points and stores them into aPoly.
BOARD * parseBOARD_unchecked()
std::set< wxString > m_undefinedLayers
set of layers not defined in layers section
LAYER_MAPPING_HANDLER m_layerMappingHandler
optional remap of appended layers onto dest
std::vector< CONSTRAINT_INFO > m_constraintInfos
void parseZoneLayerProperty(std::map< PCB_LAYER_ID, ZONE_LAYER_PROPERTIES > &aProperties)
PROGRESS_REPORTER * m_progressReporter
optional; may be nullptr
int getNetCode(int aNetCode)
Convert net code using the mapping table if available, otherwise returns unchanged net code if < 0 or...
void parseFootprintStackup(FOOTPRINT &aFootprint)
PCB_GENERATED_TABLE * parseGeneratedTable(std::unique_ptr< PCB_GENERATED_TABLE > aTable)
The body every generated table shares.
void createOldLayerMapping(std::unordered_map< std::string, std::string > &aMap)
Create a mapping from the (short-lived) bug where layer names were translated.
bool parseTableBodyToken(PCB_TABLE *aTable, PCB_KEYS_T::T aToken, bool aAllowIdentity)
aAllowIdentity is false inside a drill chart's table_data, where the enclosing form owns uuid,...
PCB_GRID_ITEM * parsePCB_GRID_ITEM()
void parseZoneDefaults(std::map< PCB_LAYER_ID, ZONE_LAYER_PROPERTIES > &aProperties)
std::unordered_map< std::string, LSET > LSET_MAP
void parsePadstack(PAD *aPad)
void parseEDA_TEXT(EDA_TEXT *aText)
Parse the common settings for any object derived from EDA_TEXT.
bool m_tooRecent
true if version parses as later than supported
void remapAppendedLayers(const std::vector< LAYER > &aSourceLayers, const LSET &aDestInitialEnabled, int aDestInitialCopperCount)
Remap the appended layers onto the destination using m_layerMappingHandler, on mismatch.
void parseNET_CHAINS_SECTION()
PCB_REFERENCE_IMAGE * parsePCB_REFERENCE_IMAGE(BOARD_ITEM *aParent)
LAYER_ID_MAP m_layerIndices
map layer name to it's index
void parsePostMachining(PADSTACK::POST_MACHINING_PROPS &aProps)
void parseTableBody(PCB_TABLE *aTable, bool aAllowIdentity)
FP_3DMODEL * parse3DModel(bool aFileNameAlreadyParsed=false)
void parseTextBoxContent(PCB_TEXTBOX *aTextBox)
FOOTPRINT * parseFOOTPRINT(wxArrayString *aInitialComments=nullptr)
PCB_POINT * parsePCB_POINT()
void parseLineEnding(LINE_ENDING &aEnding)
Parse a line ending definition from the token stream.
void pushValueIntoMap(int aIndex, int aValue)
Add aValue value in netcode mapping (m_netCodes) at aIndex.
void parseRenderCache(EDA_TEXT *aText)
Parse the render cache for any object derived from EDA_TEXT.
bool m_preserveDestinationStackup
append keeps destination stackup
void parseGeneralSection()
std::set< KIID > m_linkedZones
Zones read with a link set or anchor.
void init()
Clear and re-establish m_layerMap with the default layer names.
void parseGROUP(BOARD_ITEM *aParent)
void parseLayer(LAYER *aLayer)
std::pair< std::optional< bool >, std::optional< bool > > parseFrontBackOptBool(bool aAllowLegacyFormat=false)
void skipCurrent()
Skip the current token level, i.e search for the RIGHT parenthesis which closes the current descripti...
void parseMargins(int &aLeft, int &aTop, int &aRight, int &aBottom)
PCB_LAYER_ID parseBoardItemLayer()
Parse the layer definition of a BOARD_ITEM object.
LSET parseLayersForCuItemWithSoldermask()
Parse the layers definition of a BOARD_ITEM object that has a single copper layer and optional solder...
void parseDrillSymbolProfile()
void parseGENERATOR(BOARD_ITEM *aParent)
PCB_LAYER_ID lookUpLayer(const LAYER_ID_MAP &aMap, bool aAllowUndefined=false)
Parse the current token for the layer definition of a BOARD_ITEM object.
void parsePAD_option(PAD *aPad, PCB_LAYER_ID aLayer)
LSET parseBoardItemLayersAsMask()
Parse the layers definition of a BOARD_ITEM object.
void finishItem(BOARD_ITEM *aItem)
Resolve the fonts, groups and constraints of a fully parsed board or footprint.
void resolveGroups(BOARD_ITEM *aParent)
Called after parsing a footprint definition or board to build the group membership lists.
void parseDefaultTextDims(BOARD_DESIGN_SETTINGS &aSettings, int aLayer)
std::vector< GROUP_INFO > m_groupInfos
std::optional< bool > parseOptBool()
ZONE * parseZONE(BOARD_ITEM_CONTAINER *aParent)
void parseCustomProperty(EDA_ITEM *aItem)
PCB_TABLE * parsePCB_TABLE(BOARD_ITEM *aParent)
std::vector< GENERATOR_INFO > m_generatorInfos
DRILL_SPAN parseDrillSpanBody()
PCB_TEXTBOX * parsePCB_TEXTBOX(BOARD_ITEM *aParent)
std::chrono::time_point< CLOCK > TIME_PT
The type of the time stamps.
PCB_TEXT * parsePCB_TEXT(BOARD_ITEM *aParent, PCB_TEXT *aBaseText=nullptr)
unsigned m_lineCount
for progress reporting
VECTOR2I parseXY()
Parse a coordinate pair (xy X Y) in board units (mm).
void parseTEARDROP_PARAMETERS(TEARDROP_PARAMETERS *tdParams)
PCB_TRACK * parsePCB_TRACK()
int m_requiredVersion
set to the KiCad format version this board requires
PAD * parsePAD(FOOTPRINT *aParent=nullptr)
void resolveConstraints(BOARD_ITEM *aParent)
std::function< bool(wxString aTitle, int aIcon, wxString aMsg, wxString aAction)> m_queryUserCallback
bool m_showLegacySegmentZoneWarning
void parseNet(BOARD_CONNECTED_ITEM *aItem)
FOOTPRINT * parseFOOTPRINT_unchecked(wxArrayString *aInitialComments=nullptr)
PCB_DRILL_MAP * parsePCB_DRILL_MAP(BOARD_ITEM *aParent)
TIME_PT m_lastProgressTime
for progress reporting
void parseGROUP_members(GROUP_INFO &aGroupInfo)
bool IsValidBoardHeader()
Partially parse the input and check if it matches expected header.
void parseFootprintVariant(FOOTPRINT *aFootprint)
void ParseFootprintLib(boost::ptr_map< wxString, FP_CACHE_ENTRY, std::less< wxString >, boost::heap_clone_allocator, std::allocator< std::pair< const wxString, void * > > > &aFootprints)
Parse a footprint library file.
std::pair< wxString, wxString > parseBoardProperty()
LSET_MAP m_layerMasks
map layer names to their masks
bool parseMaybeAbsentBool(bool aDefaultValue)
Parses a boolean flag inside a list that existed before boolean normalization.
int parseBoardUnits()
Parse the current token as an ASCII numeric string with possible leading whitespace into a double pre...
void parseViastack(PCB_VIA *aVia)
bool parsePCB_TEXT_effects(PCB_TEXT *aText, PCB_TEXT *aBaseText=nullptr)
KIID_MAP m_resetKIIDMap
if resetting UUIDs, record new ones to update groups with.
void bakeTextBoxLib(PCB_TEXTBOX *aTextBox)
Lift disk-parsed values into PCB_TEXTBOX lib storage for new format files.
bool m_showLegacy5ZoneWarning
PCB_DIMENSION_BASE * parseDIMENSION(BOARD_ITEM *aParent)
LSET lookUpLayerSet(const LSET_MAP &aMap)
std::vector< wxString > m_parseWarnings
Non-fatal warnings collected during parsing.
bool m_appendToExisting
reading into an existing board; reset UUIDs
bool parseGeneratedTableExtra(PCB_GENERATED_TABLE *aTable, PCB_KEYS_T::T aToken)
One token only aTable's kind carries.
void parsePAD_primitives(PAD *aPad, PCB_LAYER_ID aLayer)
PCB_SHAPE * parsePCB_SHAPE(BOARD_ITEM *aParent)
void parseDefaults(BOARD_DESIGN_SETTINGS &aSettings)
wxString GetRequiredVersion()
Return a string representing the version of KiCad required to open this file.
PCB_TARGET * parsePCB_TARGET()
PCB_BARCODE * parsePCB_BARCODE(BOARD_ITEM *aParent)
The parser for PCB_PLOT_PARAMS.
Parameters and options when plotting/printing a board.
std::optional< bool > GetLegacyPlotViaOnMaskLayer() const
void Parse(PCB_PLOT_PARAMS_PARSER *aParser)
A PCB_POINT is a 0-dimensional point that is used to mark a position on a PCB, or more usually a foot...
void SetPosition(const VECTOR2I &aPos) override
VECTOR2I GetPosition() const override
Object to handle a bitmap image that can be inserted in a PCB.
void OverrideLibPoly(const SHAPE_POLY_SET &aPoly)
void SetEnd(const VECTOR2I &aEnd) override
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void OverrideLibCoords(const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aArcMid=VECTOR2I(0, 0))
void SetIsProxyItem(bool aIsProxy=true) override
void SetStart(const VECTOR2I &aStart) override
void SetStroke(const STROKE_PARAMS &aStroke) override
void SetLibTextAngle(const EDA_ANGLE &aAngle)
EDA_ANGLE GetTextAngle() const override
void SetBorderEnabled(bool enabled)
Disables the border, this is done by changing the stroke internally.
void OnFootprintTransformed() override
Hook for items inside a footprint to refresh after the FP transform changes (translate,...
void SetShape(SHAPE_T aShape) override
void SetMarginTop(int aTop)
void SetMarginLeft(int aLeft)
void SetMarginBottom(int aBottom)
void SetMarginRight(int aRight)
int GetLegacyTextMargin() const
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &aSettings, bool aCheckSide) override
EDA_ANGLE GetTextAngle() const override
void SetLibTextThickness(int aWidth)
void SetLibTextSize(const VECTOR2I &aSize)
void Move(const VECTOR2I &aMoveVector) override
Move this object.
int GetTextThickness() const override
void SetTextAngle(const EDA_ANGLE &aAngle) override
VECTOR2I GetTextSize() const override
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
void SetLibTextPos(const VECTOR2I &aPos)
const PADSTACK & Padstack() const
A REFERENCE_IMAGE is a wrapper around a BITMAP_IMAGE that is displayed in an editor as a reference fo...
bool ReadImageFile(const wxString &aFullFilename)
Read and store an image file.
void SetOrientation(const EDA_ANGLE &aAngle)
Set the rotation of the image content relative to the stored raster.
void SetOpacity(double aOpacity)
const BITMAP_BASE & GetImage() const
Get the underlying image.
double GetImageScale() const
void SetImageScale(double aScale)
Set the image "zoom" value.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
int PointCount() const
Return the number of points (vertices) in this line chain.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
Represent a set of closed polygons.
void RemoveAllContours()
Remove all outlines & holes (clears) the polygon set.
void BooleanAdd(const SHAPE_POLY_SET &b)
Perform boolean polyset union.
ITERATOR IterateWithHoles(int aOutline)
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index.
void SetVertex(const VERTEX_INDEX &aIndex, const VECTOR2I &aPos)
Accessor function to set the position of a specific point.
bool IsEmpty() const
Return true if the set is empty (no polygons at all)
int AddHole(const SHAPE_LINE_CHAIN &aHole, int aOutline=-1)
Adds a new hole to the given outline (default: last) and returns its index.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int NewOutline()
Creates a new empty polygon in the set and returns its index.
int OutlineCount() const
Return the number of outlines in the set.
A name/value tuple with unique names and wxAny values.
void ParseStroke(STROKE_PARAMS &aStroke)
Simple container to manage line stroke parameters.
void SetWidth(int aWidth)
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
double m_BestWidthRatio
The height of a teardrop as ratio between height and size of pad/via.
int m_TdMaxLen
max allowed length for teardrops in IU. <= 0 to disable
bool m_AllowUseTwoTracks
True to create teardrops using 2 track segments if the first in too small.
int m_TdMaxWidth
max allowed height for teardrops in IU. <= 0 to disable
double m_BestLengthRatio
The length of a teardrop as ratio between length and size of pad/via.
double m_WidthtoSizeFilterRatio
The ratio (H/D) between the via/pad size and the track width max value to create a teardrop 1....
bool m_TdOnPadsInZones
A filter to exclude pads inside zone fills.
bool m_Enabled
Flag to enable teardrops.
bool m_CurvedEdges
True if the teardrop should be curved.
Hold the information shown in the lower right corner of a plot, printout, or editing view.
void SetRevision(const wxString &aRevision)
void SetComment(int aIdx, const wxString &aComment)
void SetTitle(const wxString &aTitle)
void SetCompany(const wxString &aCompany)
void SetDate(const wxString &aDate)
Set the date field, and defaults to the current time and date.
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
A wrapper around a wxFileName which is much more performant with a subset of the API.
Handle a list of polygons defining a copper zone.
void HatchBorder()
Compute the hatch lines depending on the hatch parameters and stores it in the zone's attribute m_bor...
SHAPE_POLY_SET * Outline()
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
void SetLayerSetAndRemoveUnusedFills(const LSET &aLayerSet)
Set the zone to be on the aLayerSet layers and only remove the fill polygons from the unused layers,...
static int GetDefaultHatchPitch()
int GetNumCorners(void) const
Access to m_Poly parameters.
A type-safe container of any type.
constexpr any() noexcept
Default constructor, creates an empty object.
This file is part of the common library.
void TransformOvalToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a oblong shape to a polygon, using multiple segments.
@ RECT_CHAMFER_BOTTOM_RIGHT
@ RECT_CHAMFER_BOTTOM_LEFT
@ ROUND_ALL_CORNERS
All angles are rounded.
bool DrillMarkModeFromToken(const wxString &aToken, DRILL_MARK_MODE &aMode)
bool DrillMarkPolicyFromToken(const wxString &aToken, DRILL_MARK_POLICY &aPolicy)
bool DrillGroupKeyFromToken(const wxString &aToken, DRILL_GROUP_KEY &aKey)
DRILL_GROUP_KEY
Which properties split holes into separate chart rows and symbols.
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_45
@ FILLED_SHAPE
Fill with object color.
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
EDA_DATA_TYPE
The type of unit.
bool GeneratedTableUnitsFromToken(const wxString &aToken, GENERATED_TABLE_UNITS &aUnits)
LSET DocumentationLayers()
Layers a generated table or drill map may live on.
bool GeneratedTableAlignFromToken(const wxString &aToken, GENERATED_TABLE_ALIGN &aAlign)
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
#define THROW_IO_ERRORF(msg,...)
#define THROW_IO_CANCELLED()
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
const wxChar *const traceKicadPcbPlugin
Flag to enable KiCad PCB plugin debug output.
void ignore_unused(const T &)
#define MIN_VISIBILITY_MASK
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
PCB_LAYER_ID
A quick note on layer IDs:
This file contains miscellaneous commonly used macros and functions.
KICOMMON_API bool FetchUnitsFromString(const wxString &aTextValue, EDA_UNITS &aUnits)
Write any unit info found in the string to aUnits.
KICOMMON_API double GetScaleForInternalUnitType(const EDA_IU_SCALE &aIuScale, EDA_DATA_TYPE aDataType)
Returns the scaling parameter for the given units data type.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
@ NON_COMPONENT
Pad with no hole that does not connect to a physical component, but rather provides a connection poin...
@ SMD
Smd pad, appears on the solder paste layer (default)
@ PTH
Plated through hole pad.
@ CONN
Like smd, does not appear on the solder paste layer (default) Note: also has a special attribute in G...
@ FIDUCIAL_LOCAL
a fiducial (usually a smd) local to the parent footprint
@ FIDUCIAL_GLBL
a fiducial (usually a smd) for the full board
@ MECHANICAL
a pad used for mechanical support
@ PRESSFIT
a PTH with a hole diameter with tight tolerances for press fit pin
@ HEATSINK
a pad used as heat sink, usually in SMD footprints
@ NONE
no special fabrication property
@ TESTPOINT
a test point pad
@ CASTELLATED
a pad with a castellated through hole
@ BGA
Smd pad, used in BGA footprints.
#define MAX_PAGE_SIZE_PCBNEW_MM
#define MIN_PAGE_SIZE_MM
Min and max page sizes for clamping, in mm.
BARCODE class definition.
PCB_CONSTRAINT_TYPE ConstraintTypeFromToken(const wxString &aToken)
Parse a constraint-type token; returns UNDEFINED for an unknown token.
bool ConstraintValueIsLength(PCB_CONSTRAINT_TYPE aType)
True if this type's value is a length in IU (serialized in mm); false for an angle in degrees.
CONSTRAINT_ANCHOR ConstraintAnchorFromToken(const wxString &aToken)
Parse an anchor token; returns WHOLE for an unknown token.
CONSTRAINT_ANCHOR
Which feature of a referenced board item participates in a constraint.
@ VERTEX
An indexed rectangle corner or polygon outline vertex; pairs with CONSTRAINT_MEMBER::m_index.
DIM_TEXT_POSITION
Where to place the text on a dimension.
@ MANUAL
Text placement is manually set by the user.
DIM_UNITS_FORMAT
How to display the units in a dimension's text.
DIM_UNITS_MODE
Used for storing the units selection in the file because EDA_UNITS alone doesn't cut it.
DIM_TEXT_BORDER
Frame to show around dimension text.
Class to handle a set of BOARD_ITEMs.
#define SEXPR_FOOTPRINT_LIB_FILE_VERSION
#define FIRST_FP_AFFINE_TRANSFORM
First version that stores footprint children in library frame.
#define SEXPR_BOARD_FILE_VERSION
Current s-expression file format version. 2 was the last legacy format version.
#define LEGACY_ARC_FORMATTING
These were the last to use old arc formatting.
#define LEGACY_NET_TIES
These were the last to use the keywords field to indicate a net-tie.
#define BOARD_FILE_HOST_VERSION
Earlier files than this include the host tag.
constexpr double INT_LIMIT
Pcbnew s-expression file format parser definition.
PGM_BASE & Pgm()
The global program "get" accessor.
static bool IsNumber(char x)
double parseDouble(LINE_READER &aReader, const char *aLine, const char **aOutput)
Parses an ASCII point string with possible leading whitespace into a double precision floating point ...
#define DEFAULT_SOLDERMASK_OPACITY
wxString ConvertToNewOverbarNotation(const wxString &aOldStr)
Convert the old ~...~ overbar notation to the new ~{...} one.
wxString From_UTF8(const char *cstring)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
One participant in a constraint: a referenced board item plus the feature of that item that participa...
KIID m_item
Referenced board item, usually a PCB_SHAPE.
CONSTRAINT_ANCHOR m_anchor
Which feature of that item participates.
int m_index
Vertex ordinal; only meaningful for the VERTEX anchor.
Container to handle a stock of specific differential pairs each with unique track width,...
DRILL_MARK_MODE m_MarkMode
The column a schema knows how to build, independent of whether any particular table shows it.
A column as a generated table actually carries it: what a row's cell in that column holds and how it ...
GENERATED_TABLE_ALIGN m_Align
Container to hold information pertinent to a layer of a BOARD.
LAYER_T m_type
The type of the layer.
wxString m_name
The canonical name of the layer.
wxString m_userName
The user defined name of the layer.
int m_number
The layer ID.
The properties of a padstack drill.
VECTOR2I size
Drill diameter (x == y) or slot dimensions (x != y)
std::optional< bool > has_solder_mask
True if this outer layer has mask (is not tented)
std::optional< PAD_DRILL_POST_MACHINING_MODE > mode
A filename or source description, a problem input line, a line number, a byte offset,...
bool routing
Used by the router as a local routing frame.
bool cursor
Replace the display grid for cursor snapping inside coverage.
bool placement
Used by edit/move tools for placement snap.
Deferred constraint, resolved against the parsed items once the whole file is read,...
std::vector< std::pair< wxString, std::unique_ptr< BOARD_ITEM > > > templates
Named template items parsed from the generator's (templates …) section.
STRING_ANY_MAP properties
std::map< wxString, wxString > customProperties
std::vector< KIID > memberUuids
Options for copying a placement rule area onto the others linked to it.
bool m_connectedRoutingOnly
KIID m_anchor
This area's own anchor footprint, or niluuid for the area center.
bool m_includeLockedItems
Parameters that drive copper-thieving fill generation.
EDA_ORIENTATION orientation
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
std::optional< VECTOR2I > hatching_offset
wxString GetUserFieldName(int aFieldNdx, TRANSLATION aTranslation)
@ USER
The field ID hasn't been set yet; field is invalid.
@ DESCRIPTION
Field Description of part, i.e. "1/4W 1% Metal Film Resistor".
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
static EDA_ORIENTATION orientation(double d)
KIBIS top(path, &reporter)
const SHAPE_LINE_CHAIN chain
wxString result
Test unit parsing edge cases and error handling.
wxLogTrace helper definitions.
bool IsStraightArc(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
@ PCB_DRILL_CHART_T
class PCB_DRILL_CHART, a live drill chart derived from PCB_TABLE
VECTOR2< int32_t > VECTOR2I
ISLAND_REMOVAL_MODE
Whether or not to remove isolated islands from a zone.
ZONE_BORDER_DISPLAY_STYLE
Zone border styles.
ZONE_CONNECTION
How pads are covered by copper in zone.
@ THERMAL
Use thermal relief for pads.
@ THT_THERMAL
Thermal relief only for THT pads.
@ NONE
Pads are not covered.
@ FULL
pads are covered by copper