54 #include <wx/filename.h> 59 std::istringstream istr( aStr );
60 istr.imbue( std::locale::classic() );
70 std::istringstream istr( aStr );
71 istr.imbue( std::locale::classic() );
82 std::ifstream ifs( aFile, std::ios::in | std::ios::binary );
90 ifs.ignore( std::numeric_limits<std::streamsize>::max() );
91 std::streamsize length = ifs.gcount();
93 ifs.seekg( 0, std::ios_base::beg );
95 std::string buffer( std::istreambuf_iterator<char>{ ifs }, {} );
97 std::vector < std::string > row;
101 row.reserve( length / 100 );
107 for(
auto ch : buffer )
113 if( cell.empty() || cell[0] ==
'"' )
122 row.push_back( cell );
134 row.push_back( cell );
137 rows.push_back( row );
146 cell += std::toupper( ch );
151 if( !cell.empty() || !row.empty() )
153 row.push_back( cell );
155 rows.push_back( row );
167 row =
rows.at( aOffset );
169 catch( std::out_of_range& )
177 if( row[0].back() !=
'A' )
180 std::string row1 = row[1];
181 std::string row2 = row[2];
185 row1.erase( std::remove_if( row1.begin(), row1.end(), [](
char c ){
return c ==
'_'; } ),
187 row2.erase( std::remove_if( row2.begin(), row2.end(), [](
char c ){
return c ==
'_'; } ),
193 row3.erase( std::remove_if( row3.begin(), row3.end(), [](
char c ){
return c ==
'_'; } ),
197 if( row1 ==
"REFDES" && row2 ==
"COMPCLASS" )
200 if( row1 ==
"NETNAME" && row2 ==
"REFDES" )
203 if( row1 ==
"CLASS" && row2 ==
"SUBCLASS" && row3.empty() )
206 if( row1 ==
"GRAPHICDATANAME" && row2 ==
"GRAPHICDATANUMBER" )
209 if( row1 ==
"CLASS" && row2 ==
"SUBCLASS" && row3 ==
"GRAPHICDATANAME" )
212 if( row1 ==
"SYMNAME" && row2 ==
"PINNAME" )
215 if( row1 ==
"SYMNAME" && row2 ==
"SYMMIRROR" && row3 ==
"PINNAME" )
218 if( row1 ==
"VIAX" && row2 ==
"VIAY" )
221 if( row1 ==
"SUBCLASS" && row2 ==
"PADSHAPENAME" )
224 if( row1 ==
"PADNAME" )
227 if( row1 ==
"LAYERSORT" )
232 wxString::Format(
_(
"Unknown FABMASTER section %s:%s at row %zu." ), row1.c_str(),
233 row2.c_str(), aOffset ) );
242 if( aRow >=
rows.size() )
245 if(
rows[aRow].size() < 11 )
248 "Expecting 11 elements but found %zu" ), aRow,
rows[aRow].size() ) );
252 for(
int i = 7; i < 10 && retval < 1.0; ++i )
254 auto units =
rows[aRow][i];
255 std::transform(units.begin(), units.end(),units.begin(), ::toupper);
257 if( units ==
"MILS" )
259 else if( units ==
"MILLIMETERS" )
261 else if( units ==
"MICRONS" )
263 else if( units ==
"INCHES" )
269 wxLogError(
_(
"Could not find units value, defaulting to Mils" ) );
278 if( aRow >=
rows.size() )
281 auto header =
rows[aRow];
283 for(
size_t i = 0; i < header.size(); i++ )
287 header[i].erase( std::remove_if( header[i].begin(), header[i].end(),
288 [](
const char c ){
return c ==
'_'; } ), header[i].end() );
290 if( header[i] == aStr )
301 const auto& kicad_layer =
layers.find( aLayerName);
303 if( kicad_layer ==
layers.end() )
306 return static_cast<PCB_LAYER_ID>( kicad_layer->second.layerid );
312 size_t rownum = aRow + 2;
314 if( rownum >=
rows.size() )
317 const auto header =
rows[aRow];
332 for( ; rownum <
rows.size() &&
rows[rownum].size() > 0 &&
rows[rownum][0] ==
"S"; ++rownum )
334 auto row =
rows[rownum];
336 if( row.size() != header.size() )
339 "Expecting %zu elements but found %zu" ), rownum, header.size(), row.size() ) );
343 auto pad_name = row[pad_name_col];
344 auto pad_num = row[pad_num_col];
345 auto pad_layer = row[pad_lay_col];
346 auto pad_is_fixed = row[pad_fix_col];
347 auto pad_is_via = row[pad_via_col];
348 auto pad_shape = row[pad_shape_col];
349 auto pad_width = row[pad_width_col];
350 auto pad_height = row[pad_height_col];
351 auto pad_xoff = row[pad_xoff_col];
352 auto pad_yoff = row[pad_yoff_col];
353 auto pad_flash = row[pad_flash_col];
354 auto pad_shapename = row[pad_shape_name_col];
357 if( pad_layer ==
"INTERNAL_PAD_DEF" || pad_layer ==
"internal_pad_def" )
361 if( pad_layer[0] ==
'~' )
370 layer.
name = pad_layer;
388 size_t rownum = aRow + 2;
390 if( rownum >=
rows.size() )
393 const auto header =
rows[aRow];
396 if( scale_factor <= 0.0 )
412 for( ; rownum <
rows.size() &&
rows[rownum].size() > 0 &&
rows[rownum][0] ==
"S"; ++rownum )
414 auto row =
rows[rownum];
417 if( row.size() != header.size() )
420 "Expecting %zu elements but found %zu" ), rownum, header.size(), row.size() ) );
424 auto pad_name = row[pad_name_col];
425 auto pad_num = row[pad_num_col];
426 auto pad_layer = row[pad_lay_col];
427 auto pad_is_fixed = row[pad_fix_col];
428 auto pad_is_via = row[pad_via_col];
429 auto pad_shape = row[pad_shape_col];
430 auto pad_width = row[pad_width_col];
431 auto pad_height = row[pad_height_col];
432 auto pad_xoff = row[pad_xoff_col];
433 auto pad_yoff = row[pad_yoff_col];
434 auto pad_flash = row[pad_flash_col];
435 auto pad_shapename = row[pad_shape_name_col];
438 if( pad_layer ==
"INTERNAL_PAD_DEF" || pad_layer ==
"internal_pad_def" )
443 auto new_pad =
pads.find( pad_name );
445 if( new_pad !=
pads.end() )
446 pad = &new_pad->second;
450 pad = &
pads[pad_name];
451 pad->
name = pad_name;
455 if( pad_layer ==
"~DRILL" )
470 "but found %s!%s!%s at line %zu" ),
471 pad_shape.c_str(), pad_width.c_str(), pad_height.c_str(), rownum ) );
485 if( drill_x == drill_y )
487 pad->drill_size_x = drill_hit;
488 pad->drill_size_y = drill_hit;
492 pad->drill_size_x = drill_x;
493 pad->drill_size_y = drill_y;
496 if( !pad_shapename.empty() && pad_shapename[0] ==
'P' )
502 if( pad_shape.empty() )
516 "but found %s : %s at line %zu" ), pad_width.c_str(), pad_height.c_str(), rownum ) );
523 auto layer =
layers.find( pad_layer );
525 if( layer !=
layers.end() )
527 if( layer->second.layerid ==
F_Cu )
529 else if( layer->second.layerid ==
B_Cu )
533 if( w > std::numeric_limits<int>::max() || h > std::numeric_limits<int>::max() )
539 if( pad_layer ==
"~TSM" || pad_layer ==
"~BSM" )
541 if( w > 0.0 && h > 0.0 )
543 pad->mask_width =
KiROUND( w );
544 pad->mask_height =
KiROUND( h );
549 if( pad_layer ==
"~TSP" || pad_layer ==
"~BSP" )
551 if( w > 0.0 && h > 0.0 )
553 pad->paste_width =
KiROUND( w );
554 pad->paste_height =
KiROUND( h );
560 if( pad_layer[0] ==
'~' )
571 "but found %s : %s at line %zu" ), pad_xoff.c_str(), pad_yoff.c_str(), rownum ) );
575 if( w > 0.0 && h > 0.0 && recnum == 1 )
579 pad->via = ( std::toupper( pad_is_via[0] ) !=
'V' );
581 if( pad_shape ==
"CIRCLE" )
583 pad->height = pad->width;
586 else if( pad_shape ==
"RECTANGLE" )
590 else if( pad_shape ==
"ROUNDED_RECT" )
594 else if( pad_shape ==
"SQUARE" )
597 pad->height = pad->width;
599 else if( pad_shape ==
"OBLONG" || pad_shape ==
"OBLONG_X" || pad_shape ==
"OBLONG_Y" )
601 else if( pad_shape ==
"OCTAGON" )
604 pad->is_octogon =
true;
606 else if( pad_shape ==
"SHAPE" )
609 pad->custom_name = pad_shapename;
613 wxLogError(
wxString::Format(
_(
"Unknown pad shape name '%s' on layer '%s' at line %zu" ),
614 pad_shape.c_str(), pad_layer.c_str(), rownum ) );
620 return rownum - aRow;
626 size_t rownum = aRow + 2;
628 if( rownum >=
rows.size() )
631 auto header =
rows[aRow];
634 if( scale_factor <= 0.0 )
640 if( layer_class_col < 0 || layer_subclass_col < 0 )
643 for( ; rownum <
rows.size() &&
rows[rownum].size() > 0 &&
rows[rownum][0] ==
"S"; ++rownum )
645 auto row =
rows[rownum];
647 if( row.size() != header.size() )
650 "Expecting %zu elements but found %zu" ), rownum, header.size(), row.size() ) );
657 layer.
name = row[layer_subclass_col];
661 if( row[layer_class_col] ==
"ANTI ETCH" )
666 else if( row[layer_class_col] ==
"ETCH" )
672 return rownum - aRow;
680 std::string max_layer_name;
682 std::vector<std::pair<std::string, int>> extra_layers
684 {
"ASSEMBLY_TOP",
F_Fab },
685 {
"ASSEMBLY_BOTTOM",
B_Fab },
686 {
"PLACE_BOUND_TOP",
F_CrtYd },
687 {
"PLACE_BOUND_BOTTOM",
B_CrtYd },
690 std::vector<FABMASTER_LAYER*> layer_order;
699 layer_order.push_back( &layer );
701 else if( layer.
name.find(
"SILK" ) != std::string::npos &&
702 layer.
name.find(
"AUTOSILK" ) == std::string::npos )
704 if( layer.
name.find(
"B" ) != std::string::npos )
709 else if( layer.
name.find(
"MASK" ) != std::string::npos ||
710 layer.
name.find(
"MSK" ) != std::string::npos )
712 if( layer.
name.find(
"B" ) != std::string::npos )
717 else if( layer.
name.find(
"PAST" ) != std::string::npos )
719 if( layer.
name.find(
"B" ) != std::string::npos )
724 else if( layer.
name.find(
"NCLEGEND" ) != std::string::npos )
733 for(
auto layer : layer_order )
734 layer->layerid = layernum++;
738 layer_order.back()->layerid =
B_Cu;
740 for(
auto& new_pair : extra_layers )
744 new_layer.
name = new_pair.first;
745 new_layer.
layerid = new_pair.second;
748 auto result =
layers.emplace( new_pair.first, new_layer );
752 result.first->second.layerid = new_pair.second;
753 result.first->second.disable =
false;
768 size_t rownum = aRow + 2;
770 if( rownum >=
rows.size() )
773 auto header =
rows[aRow];
776 if( scale_factor <= 0.0 )
784 int layer_er_col =
getColFromName( aRow,
"LAYERDIELECTRICCONSTANT" );
785 int layer_rho_col =
getColFromName( aRow,
"LAYERELECTRICALCONDUCTIVITY" );
788 if( layer_sort_col < 0 || layer_subclass_col < 0 || layer_art_col < 0 || layer_use_col < 0
789 || layer_cond_col < 0 || layer_er_col < 0 || layer_rho_col < 0 || layer_mat_col < 0 )
792 for( ; rownum <
rows.size() &&
rows[rownum].size() > 0 &&
rows[rownum][0] ==
"S"; ++rownum )
794 auto row =
rows[rownum];
796 if( row.size() != header.size() )
799 "Expecting %zu elements but found %zu" ), rownum, header.size(), row.size() ) );
803 auto layer_sort = row[layer_sort_col];
804 auto layer_subclass = row[layer_subclass_col];
805 auto layer_art = row[layer_art_col];
806 auto layer_use = row[layer_use_col];
807 auto layer_cond = row[layer_cond_col];
808 auto layer_er = row[layer_er_col];
809 auto layer_rho = row[layer_rho_col];
810 auto layer_mat = row[layer_mat_col];
812 if( layer_mat ==
"AIR" )
817 if( layer_subclass.empty() )
819 if( layer_cond !=
"NO" )
820 layer.
name =
"In.Cu" + layer_sort;
822 layer.
name =
"Dielectric" + layer_sort;
825 layer.
positive = ( layer_art !=
"NEGATIVE" );
830 return rownum - aRow;
841 size_t rownum = aRow + 2;
843 if( rownum >=
rows.size() )
846 auto header =
rows[aRow];
849 if( scale_factor <= 0.0 )
854 int pad_grdata_name_col =
getColFromName( aRow,
"GRAPHICDATANAME" );
855 int pad_grdata_num_col =
getColFromName( aRow,
"GRAPHICDATANUMBER" );
870 if( pad_subclass_col < 0 || pad_shape_name_col < 0 || pad_grdata1_col < 0 || pad_grdata2_col < 0
871 || pad_grdata3_col < 0 || pad_grdata4_col < 0 || pad_grdata5_col < 0
872 || pad_grdata6_col < 0 || pad_grdata7_col < 0 || pad_grdata8_col < 0
873 || pad_grdata9_col < 0 || pad_stack_name_col < 0 || pad_refdes_col < 0
874 || pad_pin_num_col < 0 )
877 for( ; rownum <
rows.size() &&
rows[rownum].size() > 0 &&
rows[rownum][0] ==
"S"; ++rownum )
879 auto row =
rows[rownum];
881 if( row.size() != header.size() )
884 "Expecting %zu elements but found %zu" ), rownum, header.size(), row.size() ) );
889 auto pad_layer = row[pad_subclass_col];
890 auto pad_shape_name = row[pad_shape_name_col];
891 auto pad_record_tag = row[pad_record_tag_col];
906 auto pad_stack_name = row[pad_stack_name_col];
907 auto pad_refdes = row[pad_refdes_col];
908 auto pad_pin_num = row[pad_pin_num_col];
912 std::string prefix(
"FIG_SHAPE " );
914 if( pad_shape_name.length() <= prefix.length()
915 || !std::equal( prefix.begin(), prefix.end(), pad_shape_name.begin() ) )
925 if( std::sscanf( pad_record_tag.c_str(),
"%d %d", &id, &seq ) != 2 )
928 "in custom pad row %zu" ),
929 pad_record_tag.c_str(), rownum ) );
933 auto name = pad_shape_name.substr( prefix.length() );
934 name +=
"_" + pad_refdes +
"_" + pad_pin_num;
937 auto& custom_pad = ret.first->second;
943 custom_pad.name =
name;
944 custom_pad.padstack = pad_stack_name;
945 custom_pad.pinnum = pad_pin_num;
946 custom_pad.refdes = pad_refdes;
953 auto gr_item = std::unique_ptr<GRAPHIC_ITEM>(
processGraphic( gr_data, scale_factor ) );
957 gr_item->layer = pad_layer;
958 gr_item->refdes = pad_refdes;
964 auto retval = pad_it.first->second.insert( std::move(gr_item ) );
968 wxLogError(
wxString::Format(
_(
"Could not insert graphical item %d into padstack \"%s\"" ),
969 seq, pad_stack_name.c_str() ) );
974 wxLogError(
wxString::Format(
_(
"Unrecognized pad shape primitive \"%s\" in line %zu." ),
979 return rownum - aRow;
1026 angle = endangle - startangle;
1053 new_rect->
width = 0;
1077 if( toks.size() < 8 )
1081 " Expected 8 but found %zu" ), toks.size() ) );
1083 new_text->
width = 0;
1084 new_text->
ital =
false;
1144 size_t rownum = aRow + 2;
1146 if( rownum >=
rows.size() )
1149 const auto header =
rows[aRow];
1152 if( scale_factor <= 0.0 )
1171 if( geo_name_col < 0 || geo_num_col < 0 || geo_grdata1_col < 0 || geo_grdata2_col < 0
1172 || geo_grdata3_col < 0 || geo_grdata4_col < 0 || geo_grdata5_col < 0
1173 || geo_grdata6_col < 0 || geo_grdata7_col < 0 || geo_grdata8_col < 0
1174 || geo_grdata9_col < 0 || geo_subclass_col < 0 || geo_sym_name_col < 0
1175 || geo_refdes_col < 0 )
1178 for( ; rownum <
rows.size() &&
rows[rownum].size() > 0 &&
rows[rownum][0] ==
"S"; ++rownum )
1180 auto row =
rows[rownum];
1182 if( row.size() != header.size() )
1185 "Expecting %zu elements but found %zu" ), rownum, header.size(), row.size() ) );
1189 auto geo_tag = row[geo_tag_col];
1204 auto geo_refdes = row[geo_refdes_col];
1212 if( std::sscanf( geo_tag.c_str(),
"%d %d %d", &id, &seq, &subseq ) < 2 )
1215 "in Geometric definition row %zu" ),
1216 geo_tag.c_str(), rownum ) );
1220 auto gr_item = std::unique_ptr<GRAPHIC_ITEM>(
processGraphic( gr_data, scale_factor ) );
1225 "in Geometric definition row %zu" ),
1230 gr_item->layer = row[geo_subclass_col];
1232 gr_item->subseq = subseq;
1234 if( geo_refdes.empty() )
1239 new_gr.
subclass = row[geo_subclass_col];
1240 new_gr.
refdes = row[geo_refdes_col];
1241 new_gr.
name = row[geo_sym_name_col];
1243 new_gr.
elements = std::make_unique<graphic_element>();
1248 graphic.
elements->emplace( std::move( gr_item ) );
1253 std::map<int, GEOM_GRAPHIC>{} );
1254 auto map_it = sym_gr_it.first->second.emplace(
id,
GEOM_GRAPHIC{} );
1255 auto& gr = map_it.first;
1259 gr->second.subclass = row[geo_subclass_col];
1260 gr->second.refdes = row[geo_refdes_col];
1261 gr->second.name = row[geo_sym_name_col];
1263 gr->second.elements = std::make_unique<graphic_element>();
1266 auto result = gr->second.elements->emplace( std::move( gr_item ) );
1270 return rownum - aRow;
1279 size_t rownum = aRow + 2;
1281 if( rownum >=
rows.size() )
1284 const auto header =
rows[aRow];
1287 if( scale_factor <= 0.0 )
1296 if( viax_col < 0 || viay_col < 0 || padstack_name_col < 0 || net_name_col < 0
1297 || test_point_col < 0 )
1300 for( ; rownum <
rows.size() &&
rows[rownum].size() > 0 &&
rows[rownum][0] ==
"S"; ++rownum )
1302 auto row =
rows[rownum];
1304 if( row.size() != header.size() )
1307 "Expecting %zu elements but found %zu" ), rownum, header.size(), row.size() ) );
1311 vias.emplace_back( std::make_unique<FM_VIA>() );
1312 auto& via =
vias.back();
1316 via->padstack = row[padstack_name_col];
1317 via->net = row[net_name_col];
1318 via->test_point = ( row[test_point_col] ==
"YES" );
1321 return rownum - aRow;
1332 size_t rownum = aRow + 2;
1334 if( rownum >=
rows.size() )
1337 const auto header =
rows[aRow];
1340 if( scale_factor <= 0.0 )
1346 int grdata_num_col =
getColFromName( aRow,
"GRAPHICDATANUMBER" );
1359 if( class_col < 0 || layer_col < 0 || grdata_name_col < 0 || grdata_num_col < 0
1360 || tag_col < 0 || grdata1_col < 0 || grdata2_col < 0 || grdata3_col < 0
1361 || grdata4_col < 0 || grdata5_col < 0 || grdata6_col < 0 || grdata7_col < 0
1362 || grdata8_col < 0 || grdata9_col < 0 || netname_col < 0 )
1365 for( ; rownum <
rows.size() &&
rows[rownum].size() > 0 &&
rows[rownum][0] ==
"S"; ++rownum )
1367 auto row =
rows[rownum];
1369 if( row.size() != header.size() )
1372 "Expecting %zu elements but found %zu" ), rownum, header.size(), row.size() ) );
1389 auto geo_tag = row[tag_col];
1396 if( std::sscanf( geo_tag.c_str(),
"%d %d %d", &id, &seq, &subseq ) < 2 )
1399 "in Traces definition row %zu" ),
1400 geo_tag.c_str(), rownum ) );
1404 auto gr_item = std::unique_ptr<GRAPHIC_ITEM>(
processGraphic( gr_data, scale_factor ) );
1409 "in Traces definition row %zu" ),
1414 auto new_trace = std::make_unique<TRACE>();
1416 new_trace->layer = row[layer_col];
1417 new_trace->netname = row[netname_col];
1418 new_trace->lclass = row[class_col];
1420 gr_item->layer = row[layer_col];
1422 gr_item->subseq = subseq;
1425 if( new_trace->lclass ==
"REF DES" )
1427 auto result =
refdes.emplace( std::move( new_trace ) );
1428 auto& ref = *result.first;
1429 ref->segment.emplace( std::move( gr_item ) );
1431 else if( gr_item->width == 0 )
1433 auto result =
zones.emplace( std::move( new_trace ) );
1434 auto& zone = *result.first;
1435 auto gr_result = zone->segment.emplace( std::move( gr_item ) );
1437 if( !gr_result.second )
1440 "in Traces definition row %zu \n" ),
id, seq, rownum ) );
1446 auto result =
traces.emplace( std::move( new_trace ) );
1447 auto& trace = *result.first;
1448 auto gr_result = trace->segment.emplace( std::move( gr_item ) );
1450 if( !gr_result.second )
1453 "in Traces definition row %zu \n" ),
id, seq, rownum ) );
1458 return rownum - aRow;
1464 if( aSymType ==
"PACKAGE" )
1466 else if( aSymType ==
"DRAFTING")
1468 else if( aSymType ==
"MECHANICAL" )
1470 else if( aSymType ==
"FORMAT" )
1479 if( aCmpClass ==
"IO" )
1481 else if( aCmpClass ==
"IC" )
1483 else if( aCmpClass ==
"DISCRETE" )
1495 size_t rownum = aRow + 2;
1497 if( rownum >=
rows.size() )
1500 const auto header =
rows[aRow];
1503 if( scale_factor <= 0.0 )
1511 int compinscode_col =
getColFromName( aRow,
"COMPINSERTIONCODE" );
1522 if( refdes_col < 0 || compclass_col < 0 || comppartnum_col < 0 || compheight_col < 0
1523 || compdevlabelcol < 0 || compinscode_col < 0 || symtype_col < 0 || symname_col < 0
1524 || symmirror_col < 0 || symrotate_col < 0 || symx_col < 0 || symy_col < 0
1525 || compvalue_col < 0 || comptol_col < 0 || compvolt_col < 0 )
1528 for( ; rownum <
rows.size() &&
rows[rownum].size() > 0 &&
rows[rownum][0] ==
"S"; ++rownum )
1530 auto row =
rows[rownum];
1532 if( row.size() != header.size() )
1535 "Expecting %zu elements but found %zu" ), rownum, header.size(), row.size() ) );
1539 auto cmp = std::make_unique<COMPONENT>();
1541 cmp->refdes = row[refdes_col];
1543 cmp->pn = row[comppartnum_col];
1544 cmp->height = row[compheight_col];
1545 cmp->dev_label = row[compdevlabelcol];
1546 cmp->insert_code = row[compinscode_col];
1548 cmp->name = row[symname_col];
1549 cmp->mirror = ( row[symmirror_col] ==
"YES" );
1550 cmp->rotate =
readDouble( row[symrotate_col] );
1553 cmp->value = row[compvalue_col];
1554 cmp->tol = row[comptol_col];
1555 cmp->voltage = row[compvolt_col];
1561 auto retval =
components.insert( std::make_pair( cmp->refdes, std::vector<std::unique_ptr<COMPONENT>>{} ) );
1566 vec->second.push_back( std::move( cmp ) );
1569 return rownum - aRow;
1578 size_t rownum = aRow + 2;
1580 if( rownum >=
rows.size() )
1583 const auto header =
rows[aRow];
1586 if( scale_factor <= 0.0 )
1600 if( symname_col < 0 ||symmirror_col < 0 || pinname_col < 0 || pinnum_col < 0 || pinx_col < 0
1601 || piny_col < 0 || padstack_col < 0 || refdes_col < 0 || pinrot_col < 0
1602 || testpoint_col < 0 )
1605 for( ; rownum <
rows.size() &&
rows[rownum].size() > 0 &&
rows[rownum][0] ==
"S"; ++rownum )
1607 auto row =
rows[rownum];
1609 if( row.size() != header.size() )
1612 "Expecting %zu elements but found %zu" ), rownum, header.size(), row.size() ) );
1616 auto pin = std::make_unique<PIN>();
1618 pin->name = row[symname_col];
1619 pin->mirror = ( row[symmirror_col] ==
"YES" );
1620 pin->pin_name = row[pinname_col];
1621 pin->pin_number = row[pinnum_col];
1624 pin->padstack = row[padstack_col];
1625 pin->refdes = row[refdes_col];
1626 pin->rotation =
readDouble( row[pinrot_col] );
1628 auto map_it =
pins.find( pin->refdes );
1630 if( map_it ==
pins.end() )
1632 auto retval =
pins.insert( std::make_pair( pin->refdes, std::set<std::unique_ptr<PIN>,
PIN::BY_NUM>{} ) );
1633 map_it = retval.first;
1636 map_it->second.insert( std::move( pin ) );
1639 return rownum - aRow;
1648 size_t rownum = aRow + 2;
1650 if( rownum >=
rows.size() )
1653 const auto header =
rows[aRow];
1656 if( scale_factor <= 0.0 )
1666 if( netname_col < 0 || refdes_col < 0 || pinnum_col < 0 || pinname_col < 0 || pingnd_col < 0
1670 for( ; rownum <
rows.size() &&
rows[rownum].size() > 0 &&
rows[rownum][0] ==
"S"; ++rownum )
1672 auto row =
rows[rownum];
1674 if( row.size() != header.size() )
1677 "Expecting %zu elements but found %zu" ), rownum, header.size(), row.size() ) );
1682 new_net.
name = row[netname_col];
1683 new_net.
refdes = row[refdes_col];
1684 new_net.
pin_num = row[pinnum_col];
1685 new_net.
pin_name = row[pinname_col];
1686 new_net.
pin_gnd = ( row[pingnd_col] ==
"YES" );
1687 new_net.
pin_pwr = ( row[pinpwr_col] ==
"YES" );
1690 netnames.insert( row[netname_col] );
1693 return rownum - aRow;
1700 for(
size_t i = 0; i <
rows.size(); )
1714 i += std::max( retval, 1 );
1722 i += std::max( retval, 1 );
1730 i += std::max( retval, 1 );
1738 i += std::max( retval, 1 );
1746 i += std::max( retval, 1 );
1754 i += std::max( retval, 1 );
1762 i += std::max( retval, 1 );
1770 i += std::max( retval, 1 );
1778 i += std::max( retval, 1 );
1786 i += std::max( retval, 1 );
1804 for(
auto& zone :
zones )
1810 if( zone->layer ==
"OUTLINE" || zone->layer ==
"DESIGN_OUTLINE" )
1831 std::set<ZONE*> zones_to_delete;
1833 for(
auto zone : aBoard->
Zones() )
1836 if( zone->GetNetCode() > 0 )
1838 zones_to_delete.insert( zone );
1842 for(
auto zone1 : aBoard->
Zones() )
1845 if( zone1->GetNetCode() > 0 )
1850 std::vector<std::vector<ZONE*>> possible_deletions( overlaps.size() );
1852 for(
auto zone2 : aBoard->
Zones() )
1854 if( zone2->GetNetCode() <= 0 )
1859 if( zone1->GetLayer() != zone2->GetLayer() )
1865 for(
auto& pt1 : outline1.
CPoints() )
1869 overlaps[ zone2->GetNetCode() ]++;
1872 for(
auto& pt2 : outline2.
CPoints() )
1877 overlaps[ zone2->GetNetCode() ]++;
1882 size_t max_net_id = 0;
1884 for(
size_t el = 1; el < overlaps.size(); ++el )
1886 if( overlaps[el] > max_net )
1888 max_net = overlaps[el];
1894 zone1->SetNetCode( max_net_id );
1897 for(
auto zone : zones_to_delete )
1914 bool has_multiple = mod.second.size() > 1;
1916 for(
int i = 0; i < mod.second.size(); ++i )
1918 auto& src = mod.second[i];
1922 wxString mod_ref = src->name;
1931 wxString key = !lib_ref.empty() ? lib_ref +
":" + mod_ref : mod_ref;
1934 fpID.
Parse( key,
true );
1942 wxString reference = src->refdes;
1944 if( !std::isalpha( src->refdes[0] ) )
1945 reference.Prepend(
"UNK" );
1953 for(
auto& ref :
refdes )
1956 static_cast<const GRAPHIC_TEXT*>( ( *( ref->segment.begin() ) ).get() );
1958 if( lsrc->
text == src->refdes )
1965 printf(
"The layer %s is not mapped?\n", ref->layer.c_str() );
2010 for(
auto& gr_ref : gr_it->second )
2012 auto& graphic = gr_ref.second;
2014 for(
auto& seg : *graphic.elements )
2021 switch( seg->shape )
2026 const GRAPHIC_LINE* lsrc = static_cast<const GRAPHIC_LINE*>( seg.get() );
2033 line->SetStart( wxPoint( lsrc->
start_x, 2 * src->y - lsrc->
start_y ) );
2034 line->SetEnd( wxPoint( lsrc->
end_x, 2 * src->y - lsrc->
end_y ) );
2038 line->SetLayer( layer );
2040 line->SetEnd( wxPoint( lsrc->
end_x, lsrc->
end_y ) );
2043 line->SetWidth( lsrc->
width );
2044 line->SetLocalCoord();
2046 if( lsrc->
width == 0 )
2047 line->SetWidth( ds.GetLineThickness( line->GetLayer() ) );
2054 const GRAPHIC_ARC* lsrc = static_cast<const GRAPHIC_ARC*>( seg.get() );
2062 arc->SetArcStart( wxPoint( lsrc->
end_x, 2 * src->y - lsrc->
end_y ) );
2067 arc->SetLayer( layer );
2069 arc->SetArcStart( wxPoint( lsrc->
end_x, lsrc->
end_y ) );
2073 arc->SetWidth( lsrc->
width );
2074 arc->SetLocalCoord();
2076 if( lsrc->
width == 0 )
2077 arc->SetWidth( ds.GetLineThickness( arc->GetLayer() ) );
2085 static_cast<const GRAPHIC_RECTANGLE*>( seg.get() );
2092 rect->SetStart( wxPoint( lsrc->
start_x, 2 * src->y - lsrc->
start_y ) );
2093 rect->SetEnd( wxPoint( lsrc->
end_x, 2 * src->y - lsrc->
end_y ) );
2097 rect->SetLayer( layer );
2099 rect->SetEnd( wxPoint( lsrc->
end_x, lsrc->
end_y ) );
2102 rect->SetWidth( ds.GetLineThickness( rect->GetLayer() ) );
2103 rect->SetLocalCoord();
2111 static_cast<const GRAPHIC_TEXT*>( seg.get() );
2118 txt->SetTextPos( wxPoint( lsrc->
start_x, 2 * src->y - ( lsrc->
start_y - lsrc->
height / 2 ) ) );
2122 txt->SetLayer( layer );
2126 txt->SetText( lsrc->
text );
2127 txt->SetItalic( lsrc->
ital );
2128 txt->SetTextThickness( lsrc->
thickness );
2129 txt->SetTextHeight( lsrc->
height );
2130 txt->SetTextWidth( lsrc->
width );
2131 txt->SetHorizJustify( lsrc->
orient );
2132 txt->SetLocalCoord();
2137 txt->SetVisible(
false );
2148 auto pin_it =
pins.find( src->refdes );
2150 if( pin_it !=
pins.end() )
2152 for(
auto& pin : pin_it->second )
2154 auto pin_net_it =
pin_nets.find( std::make_pair( pin->refdes, pin->pin_number ) );
2155 auto padstack =
pads.find( pin->padstack );
2156 std::string netname =
"";
2159 netname = pin_net_it->second.name;
2161 auto net_it = netinfo.find( netname );
2163 PAD* newpad =
new PAD( fp );
2165 if( net_it != netinfo.end() )
2166 newpad->
SetNet( net_it->second );
2170 newpad->
SetX( pin->pin_x );
2173 newpad->
SetY( 2 * src->y - pin->pin_y );
2175 newpad->
SetY( pin->pin_y );
2177 newpad->
SetName( pin->pin_number );
2179 if( padstack ==
pads.end() )
2187 auto& pad = padstack->second;
2195 int pad_size = std::min( pad.width, pad.height );
2197 newpad->
SetSize( wxSize( pad_size / 2, pad_size / 2 ) );
2199 std::string custom_name = pad.custom_name +
"_" + pin->refdes +
"_" + pin->pin_number;
2200 auto custom_it =
pad_shapes.find( custom_name );
2206 int last_subseq = 0;
2213 for(
const auto& el : (*custom_it).second.elements )
2219 if(
getLayer( ( *( el.second.begin() ) )->layer ) != primary_layer )
2222 for(
const auto& seg : el.second )
2224 if( seg->subseq > 0 || seg->subseq != last_subseq )
2226 poly_outline.
Polygon(0).back().SetClosed(
true );
2232 const GRAPHIC_LINE* src = static_cast<const GRAPHIC_LINE*>( seg.get() );
2234 if( poly_outline.
VertexCount( 0, hole_idx ) == 0 )
2241 const GRAPHIC_ARC* src = static_cast<const GRAPHIC_ARC*>( seg.get() );
2253 _(
"Invalid custom pad named '%s'. Replacing with circular pad." ),
2254 custom_name.c_str() ) );
2259 poly_outline.
Fracture( SHAPE_POLY_SET::POLYGON_MODE::PM_FAST );
2265 poly_outline.
Mirror(
false,
true,
VECTOR2I( 0, ( pin->pin_y - src->y ) ) );
2266 poly_outline.
Rotate( ( -src->rotate + pin->rotation ) * M_PI / 180.0 );
2270 poly_outline.
Rotate( ( src->rotate - pin->rotation ) * M_PI / 180.0 );
2282 _(
"Invalid custom pad named '%s'. Replacing with circular pad." ),
2283 custom_name.c_str() ) );
2290 custom_name.c_str() ) );
2294 newpad->
SetSize( wxSize( pad.width, pad.height ) );
2309 if( pad.drill_size_x == pad.drill_size_y )
2314 newpad->
SetDrillSize( wxSize( pad.drill_size_x, pad.drill_size_y ) );
2322 else if( pad.bottom )
2330 newpad->
SetOrientation( ( -src->rotate + pin->rotation ) * 10.0 );
2332 newpad->
SetOrientation( ( src->rotate - pin->rotation ) * 10.0 );
2359 for(
auto& layer :
layers )
2362 layer_set.set( layer.second.layerid );
2367 for(
auto& layer :
layers )
2369 if( layer.second.conductive )
2371 aBoard->
SetLayerName( static_cast<PCB_LAYER_ID>( layer.second.layerid ),
2372 layer.second.name );
2385 for(
auto& via :
vias )
2387 auto net_it = netinfo.find( via->net );
2388 auto padstack =
pads.find( via->padstack );
2390 VIA* new_via =
new VIA( aBoard );
2392 new_via->
SetPosition( wxPoint( via->x, via->y ) );
2394 if( net_it != netinfo.end() )
2395 new_via->
SetNet( net_it->second );
2397 if( padstack ==
pads.end() )
2401 if( !ds.m_ViasDimensionsList.empty() )
2403 new_via->
SetWidth( ds.m_ViasDimensionsList[0].m_Diameter );
2404 new_via->
SetDrill( ds.m_ViasDimensionsList[0].m_Drill );
2409 new_via->
SetWidth( ds.m_ViasMinSize );
2414 new_via->
SetDrill( padstack->second.drill_size_x );
2415 new_via->
SetWidth( padstack->second.width );
2440 auto net_it = netinfo.find( aLine->netname );
2442 int last_subseq = 0;
2443 ZONE* new_zone =
nullptr;
2445 for(
const auto& seg : aLine->segment )
2453 const GRAPHIC_LINE* src = static_cast<const GRAPHIC_LINE*>( seg.get() );
2457 trk->SetLayer( layer );
2459 trk->SetEnd( wxPoint( src->
end_x, src->
end_y ) );
2460 trk->SetWidth( src->
width );
2462 if( net_it != netinfo.end() )
2463 trk->SetNet( net_it->second );
2469 const GRAPHIC_ARC* src = static_cast<const GRAPHIC_ARC*>( seg.get() );
2472 trk->SetLayer( layer );
2473 trk->SetWidth( src->
width );
2475 if( net_it != netinfo.end() )
2476 trk->SetNet( net_it->second );
2484 "Row found on layer '%s'" ), seg->layer.c_str() ) );
2495 int last_subseq = 0;
2500 for(
const auto& seg : aElement )
2502 if( seg->subseq > 0 || seg->subseq != last_subseq )
2507 const GRAPHIC_LINE* src = static_cast<const GRAPHIC_LINE*>( seg.get() );
2509 if( poly_outline.
VertexCount( 0, hole_idx ) == 0 )
2516 const GRAPHIC_ARC* src = static_cast<const GRAPHIC_ARC*>( seg.get() );
2523 poly_outline.
Fracture( SHAPE_POLY_SET::POLYGON_MODE::PM_FAST );
2524 return poly_outline;
2530 if( aLine->segment.size() < 3 )
2535 auto new_layer =
getLayer( aLine->layer );
2558 new_poly->
SetWidth( ( *( aLine->segment.begin() ) )->width );
2574 if( aLine->segment.size() < 3 )
2577 int last_subseq = 0;
2580 ZONE* zone =
nullptr;
2583 auto net_it = netinfo.find( aLine->netname );
2585 auto new_layer =
getLayer( aLine->layer );
2590 zone =
new ZONE( aBoard );
2593 if( net_it != netinfo.end() )
2594 zone->
SetNet( net_it->second );
2596 if( aLine->layer ==
"ALL" )
2608 if( aLine->lclass ==
"ROUTE KEEPOUT")
2613 else if( aLine->lclass ==
"VIA KEEPOUT")
2626 for(
const auto& seg : aLine->segment )
2628 if( seg->subseq > 0 && seg->subseq != last_subseq )
2631 if( aLine->lclass ==
"BOUNDARY" )
2635 last_subseq = seg->subseq;
2636 last_subseq = seg->subseq;
2641 const GRAPHIC_LINE* src = static_cast<const GRAPHIC_LINE*>( seg.get() );
2643 if( zone_outline->
VertexCount( 0, hole_idx ) == 0 )
2650 const GRAPHIC_ARC* src = static_cast<const GRAPHIC_ARC*>( seg.get() );
2662 delete( zone_outline );
2674 if( aLine->lclass ==
"BOARD GEOMETRY" )
2676 else if( aLine->lclass ==
"DRAWING FORMAT" )
2681 for(
auto& seg : aLine->segment )
2683 switch( seg->shape )
2688 const GRAPHIC_LINE* src = static_cast<const GRAPHIC_LINE*>( seg.get() );
2692 line->SetLayer( layer );
2694 line->SetEnd( wxPoint( src->
end_x, src->
end_y ) );
2695 line->SetWidth( src->
width );
2697 if( line->GetWidth() == 0 )
2705 const GRAPHIC_ARC* src = static_cast<const GRAPHIC_ARC*>( seg.get() );
2708 arc->SetShape(
S_ARC );
2709 arc->SetLayer( layer );
2713 arc->SetWidth( src->
width );
2715 if( arc->GetWidth() == 0 )
2724 static_cast<const GRAPHIC_RECTANGLE*>( seg.get() );
2727 rect->SetShape(
S_RECT );
2728 rect->SetLayer( layer );
2730 rect->SetEnd( wxPoint( src->
end_x, src->
end_y ) );
2739 static_cast<const GRAPHIC_TEXT*>( seg.get() );
2742 txt->SetLayer( layer );
2744 txt->SetText( src->
text );
2745 txt->SetItalic( src->
ital );
2746 txt->SetTextThickness( src->
thickness );
2747 txt->SetTextHeight( src->
height );
2748 txt->SetTextWidth( src->
width );
2749 txt->SetHorizJustify( src->
orient );
2771 if( geom.subclass ==
"PIN_NUMBER" )
2779 if( !geom.elements->empty() )
2782 if( ( *( geom.elements->begin() ) )->width == 0 )
2803 for(
auto& seg : *geom.elements )
2805 switch( seg->shape )
2810 const GRAPHIC_LINE* src = static_cast<const GRAPHIC_LINE*>( seg.get() );
2814 line->SetLayer( layer );
2816 line->SetEnd( wxPoint( src->
end_x, src->
end_y ) );
2817 line->SetWidth( src->
width );
2824 const GRAPHIC_ARC* src = static_cast<const GRAPHIC_ARC*>( seg.get() );
2827 arc->SetShape(
S_ARC );
2828 arc->SetLayer( layer );
2832 arc->SetWidth( src->
width );
2840 static_cast<const GRAPHIC_RECTANGLE*>( seg.get() );
2843 rect->SetShape(
S_RECT );
2844 rect->SetLayer( layer );
2846 rect->SetEnd( wxPoint( src->
end_x, src->
end_y ) );
2847 rect->SetWidth( 0 );
2854 static_cast<const GRAPHIC_TEXT*>( seg.get() );
2857 txt->SetLayer( layer );
2859 txt->SetText( src->
text );
2860 txt->SetItalic( src->
ital );
2861 txt->SetTextThickness( src->
thickness );
2862 txt->SetTextHeight( src->
height );
2863 txt->SetTextWidth( src->
width );
2864 txt->SetHorizJustify( src->
orient );
2884 [&](
const ZONE* a,
const ZONE* b ) {
2885 if( a->
GetLayer() == b->GetLayer() )
2888 return a->
GetLayer() < b->GetLayer();
2892 unsigned int priority = 0;
2896 if( zone->GetLayer() != layer )
2898 layer = zone->GetLayer();
2902 zone->SetPriority( priority );
2921 for(
auto& track :
traces )
2923 if( track->lclass ==
"ETCH" )
2927 else if( track->layer ==
"OUTLINE" )
SHAPE_ARC result
! KiCad-style arc representation
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
size_t processSimpleLayers(size_t aRow)
bool Read(const std::string &aFile)
std::vector< std::string > single_row
LSET FlipLayerMask(LSET aMask, int aCopperLayersCount)
Calculate the mask layer when flipping a footprint.
int OutlineCount() const
Return the number of vertices in a given outline/hole.
std::map< std::string, std::map< int, GEOM_GRAPHIC > > comp_graphics
std::string graphic_data6
void SetDoNotAllowTracks(bool aEnable)
void SetPosition(const wxPoint &aPoint) override
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
std::string name
! LAYER_SUBCLASS
static constexpr double IU_PER_MM
Mock up a conversion function.
std::map< std::string, std::vector< std::unique_ptr< COMPONENT > > > components
void SetFilled(bool aFlag)
bool ital
! GRAPHIC_DATA_6[4] != 0.0
void SetLayerSet(LSET aLayerSet) override
bool loadGraphics(BOARD *aBoard)
int readInt(const std::string aStr) const
void SetItalic(bool isItalic)
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
GRAPHIC_LINE * processLine(const GRAPHIC_DATA &aData, double aScale)
bool fill
! GRAPHIC_DATA_5
int VertexCount(int aOutline=-1, int aHole=-1) const
Returns the number of holes in a given outline.
Smd pad, appears on the solder paste layer (default)
void SetTextPos(const wxPoint &aPoint)
polygon (not yet used for tracks, but could be in microwave apps)
void SetVisible(bool aVisible)
PCB_LAYER_ID getLayer(const std::string &aLayerName)
int thickness
! GRAPHIC_DATA_6[6]
std::unique_ptr< graphic_element > elements
void SetName(const wxString &aName)
Set the pad name (sometimes called pad number, although it can be an array reference like AA12).
int end_x
! GRAPHIC_DATA_3
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
double RAD2DECIDEG(double rad)
SHAPE_LINE_CHAIN & Hole(int aOutline, int aHole)
Return the aIndex-th subpolygon in the set.
std::string subclass
! SUBCLASS
std::unordered_map< std::string, PAD_SHAPE > pad_shapes
usual segment : line with rounded ends
int start_y
! GRAPHIC_DATA_2
bool ReplaceIllegalFileNameChars(std::string *aName, int aReplaceChar)
Checks aName for illegal file name characters.
std::string graphic_data2
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
bool loadEtch(BOARD *aBoard, const std::unique_ptr< TRACE > &aLine)
const NETINFO_LIST & GetNetInfo() const
bool PointOnEdge(const VECTOR2I &aP, int aAccuracy=0) const
Check if point aP lies on an edge or vertex of the line chain.
bool loadZone(BOARD *aBoard, const std::unique_ptr< FABMASTER::TRACE > &aLine)
std::map< std::string, FABMASTER_LAYER > layers
void Rotate(double aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
void SetSize(const wxSize &aSize)
std::string refdes
! REFDES
void RotatePoint(int *pX, int *pY, double angle)
std::vector< std::unique_ptr< FM_VIA > > vias
like PAD_PTH, but not plated mechanical use only, no connection allowed
segment with non rounded ends
A logical library item identifier and consists of various portions much like a URI.
static LSET AllTechMask()
Return a mask holding all technical layers (no CU layer) on both side.
int center_x
! GRAPHIC_DATA_5
bool loadNets(BOARD *aBoard)
int PointCount() const
Function PointCount()
void SetPriority(unsigned aPriority)
Function SetPriority.
A!LAYER_SORT!LAYER_SUBCLASS!LAYER_ARTWORK!LAYER_USE!LAYER_CONDUCTOR!LAYER_DIELECTRIC_CONSTANT !...
std::string graphic_data10
A!SUBCLASS!PAD_SHAPE_NAME!GRAPHIC_DATA_NAME!GRAPHIC_DATA_NUMBER!RECORD_TAG!GRAPHIC_DATA_1!...
std::set< std::unique_ptr< TRACE >, TRACE::BY_ID > traces
bool LoadBoard(BOARD *aBoard)
void Mirror(bool aX=true, bool aY=false, const VECTOR2I &aRef={ 0, 0 })
Mirror the line points about y or x (or both)
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
void SetWidth(int aWidth)
const NETNAMES_MAP & NetsByName() const
Return the name map, at least for python.
void SetIsRuleArea(bool aEnable)
size_t processFootprints(size_t aRow)
A!REFDES!COMP_CLASS!COMP_PART_NUMBER!COMP_HEIGHT!COMP_DEVICE_LABEL!COMP_INSERTION_CODE!...
std::string graphic_data1
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.
bool Intersects(const BOX2< Vec > &aRect) const
Function Intersects.
int end_y
! GRAPHIC_DATA_4 ! width is GRAPHIC_DATA_5
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
section_type detectType(size_t aOffset)
std::vector< GEOM_GRAPHIC > board_graphics
GRAPHIC_ITEM * processGraphic(const GRAPHIC_DATA &aData, double aScale)
Specialty functions for processing graphical data rows into the internal database.
PCB_LAYER_ID
A quick note on layer IDs:
bool loadFootprints(BOARD *aBoard)
LSET is a set of PCB_LAYER_IDs.
pads are covered by copper
bool loadVias(BOARD *aBoard)
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
virtual void SetText(const wxString &aText)
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox (virtual)
int height
! GRAPHIC_DATA_6[2]
std::map< std::pair< std::string, std::string >, NETNAME > pin_nets
size_t processGeometry(size_t aRow)
A!GRAPHIC_DATA_NAME!GRAPHIC_DATA_NUMBER!RECORD_TAG!GRAPHIC_DATA_1!GRAPHIC_DATA_2!GRAPHIC_DATA_3!...
void Move(const VECTOR2I &aVector) override
void SetShape(PCB_SHAPE_TYPE_T aShape)
const std::vector< VECTOR2I > & CPoints() const
void SetLocalCoord()
< Set relative coordinates.
std::string graphic_data5
void SetDoNotAllowPads(bool aEnable)
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
virtual PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
double rotation
! GRAPHIC_DATA_3
void SetOutline(SHAPE_POLY_SET *aOutline)
std::set< std::unique_ptr< GRAPHIC_ITEM >, GRAPHIC_ITEM::SEQ_CMP > graphic_element
void SetDrillSize(const wxSize &aSize)
size_t processVias(size_t aRow)
A!VIA_X!VIA_Y!PAD_STACK_NAME!NET_NAME!TEST_POINT!
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
std::string graphic_datanum
double readDouble(const std::string aStr) const
Reads the double/integer value from a std string independent of the user locale.
static LSET PTHMask()
layer set for a through hole pad
size_t processPadStacks(size_t aRow)
A!PADNAME!RECNUMBER!LAYER!FIXFLAG!VIAFLAG!PADSHAPE1!PADWIDTH!PADHGHT! PADXOFF!PADYOFF!...
int center_y
! GRAPHIC_DATA_6
GRAPHIC_RECTANGLE * processRectangle(const GRAPHIC_DATA &aData, double aScale)
void SetDoNotAllowVias(bool aEnable)
std::string refdes
!< NET_NAME
std::string pin_num
!< REFDES
GRAPHIC_TYPE type
! Type of graphic item
std::set< std::unique_ptr< TRACE >, TRACE::BY_ID > zones
ZONE handles a list of polygons defining a copper zone.
SHAPE_POLY_SET loadShapePolySet(const graphic_element &aLine)
void SetFileName(const wxString &aFileName)
double GetArea() const
Return the area of the rectangle.
int getColFromName(size_t aRow, const std::string &aStr)
void SetShape(PAD_SHAPE_T aShape)
Set the new shape of this pad.
int NewOutline()
Creates a new hole in a given outline.
int radius
! GRAPHIC_DATA_7 ! width is GRAPHIC_DATA_8
void Fracture(POLYGON_MODE aFastMode)
Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes.
int AddHole(const SHAPE_LINE_CHAIN &aHole, int aOutline=-1)
Return the area of this poly set.
void SetDrillShape(PAD_DRILL_SHAPE_T aShape)
std::string text
! GRAPHIC_DATA_7
void SetDrillDefault()
Function SetDrillDefault sets the drill value for vias to the default value UNDEFINED_DRILL_DIAMETER.
std::map< std::string, std::set< std::unique_ptr< PIN >, PIN::BY_NUM > > pins
std::set< std::string > netnames
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
void SetTextWidth(int aWidth)
std::string graphic_data9
std::string graphic_data7
size_t processPins(size_t aRow)
A!SYM_NAME!SYM_MIRROR!PIN_NAME!PIN_NUMBER!PIN_X!PIN_Y!PAD_STACK_NAME!REFDES!PIN_ROTATION!...
int end_x
! GRAPHIC_DATA_3
std::unordered_map< std::string, FM_PAD > pads
size_t processCustomPads(size_t aRow)
A!SUBCLASS!PAD_SHAPE_NAME!GRAPHIC_DATA_NAME!GRAPHIC_DATA_NUMBER!RECORD_TAG!GRAPHIC_DATA_1!...
GRAPHIC_ARC * processArc(const GRAPHIC_DATA &aData, double aScale)
Handle the data for a net.
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
void SetPadConnection(ZONE_CONNECTION aPadConnection)
void SetLayerSet(LSET aLayers) override
void SetNet(NETINFO_ITEM *aNetInfo)
Set a NET_INFO object for the item.
int layerid
! pcbnew layer (assigned)
int start_x
! GRAPHIC_DATA_1
EDA_TEXT_HJUSTIFY_T orient
! GRAPHIC_DATA_5
bool conductive
! LAYER_CONDUCTOR
wxPoint GetPosition() const override
void MergePrimitivesAsPolygon(SHAPE_POLY_SET *aMergedPolygon, PCB_LAYER_ID aLayer) const
Merge all basic shapes to a SHAPE_POLY_SET.
Information pertinent to a Pcbnew printed circuit board.
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
void SetDoNotAllowCopperPour(bool aEnable)
std::string graphic_data4
int end_y
! GRAPHIC_DATA_4
std::string graphic_data8
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
T NormalizeAnglePos(T Angle)
Normalize angle to be in the 0.0 .
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
int end_y
! GRAPHIC_DATA_4
void AddPrimitivePoly(const SHAPE_POLY_SET &aPoly, int aThickness, bool aFilled)
Has meaning only for custom shape pads.
bool disable
! if true, prevent the layer elements from being used
double GetCentralAngle() const
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
void SetTextHeight(int aHeight)
void SetWidth(int aWidth)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
size_t processNets(size_t aRow)
A!NET_NAME!REFDES!PIN_NUMBER!PIN_NAME!PIN_GROUND!PIN_POWER!
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
size_t processLayers(size_t aRow)
A!LAYER_SORT!LAYER_SUBCLASS!LAYER_ARTWORK!LAYER_USE!LAYER_CONDUCTOR!LAYER_DIELECTRIC_CONSTANT!...
unsigned GetNetCount() const
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
COMPCLASS parseCompClass(const std::string &aCompClass)
bool loadPolygon(BOARD *aBoard, const std::unique_ptr< FABMASTER::TRACE > &aLine)
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
void SetPolyShape(const SHAPE_POLY_SET &aShape)
bool orderZones(BOARD *aBoard)
Sets zone priorities based on zone BB size.
static LSET UnplatedHoleMask()
layer set for a mechanical unplated through hole pad
void SetLocalClearance(int aClearance)
int width
! Various sections depending on type
bool IsPcbLayer(LAYER_NUM aLayer)
Test whether a layer is a valid layer for Pcbnew.
size_t processTraces(size_t aRow)
A!CLASS!SUBCLASS!GRAPHIC_DATA_NAME!GRAPHIC_DATA_NUMBER!RECORD_TAG!GRAPHIC_DATA_1!GRAPHIC_DATA_2!...
POLYGON & Polygon(int aIndex)
std::string pin_name
!< PIN_NUMBER
std::string name
! SYM_NAME
int end_x
! GRAPHIC_DATA_3
SYMTYPE parseSymType(const std::string &aSymType)
bool mirror
! GRAPHIC_DATA_4
std::string graphic_dataname
GRAPHIC_SHAPE shape
! Shape of the graphic_item
static LSET SMDMask()
layer set for a SMD pad on Front layer
bool clockwise
! GRAPHIC_DATA_9
bool loadZones(BOARD *aBoard)
Loads sections of the database into the board.
bool positive
! LAYER_ARTWORK (either POSITIVE or NEGATIVE)
#define THROW_IO_ERROR(msg)
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings Changes the bit-mask of ena...
bool loadLayers(BOARD *aBoard)
std::string graphic_data3
void SetOrientation(double aAngle)
Set the rotation angle of the pad.
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
std::set< std::unique_ptr< TRACE >, TRACE::BY_ID > refdes
static std::vector< std::string > split(const std::string &aStr, const std::string &aDelim)
Splits the input string into a vector of output strings.
bool loadOutline(BOARD *aBoard, const std::unique_ptr< TRACE > &aLine)
double processScaleFactor(size_t aRow)
Processes data from text vectors into internal database for further ordering.
void SetDoNotAllowFootprints(bool aEnable)
size_t processPadStackLayers(size_t aRow)
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
GRAPHIC_TEXT * processText(const GRAPHIC_DATA &aData, double aScale)
std::deque< single_row > rows
void SetAttribute(PAD_ATTR_T aAttribute)