32#include <wx/mstream.h>
76using namespace PCB_KEYS_T;
80 m_filename( aFileName ),
81 m_footprint( aFootprint )
101 THROW_IO_ERROR( wxString::Format(
_(
"Cannot create footprint library '%s'." ),
107 THROW_IO_ERROR( wxString::Format(
_(
"Footprint library '%s' is read only." ),
113 if( aFootprint && aFootprint != it->second->GetFootprint() )
126 wxString tempFileName =
128 wxFileName::CreateTempFileName( fn.
GetPath() );
149 wxMilliSleep( 250L );
154 if( !wxRenameFile( tempFileName, fn.
GetFullPath() ) )
156 wxString msg = wxString::Format(
_(
"Cannot rename temporary file '%s' to '%s'" ),
180 if( !dir.IsOpened() )
182 wxString msg = wxString::Format(
_(
"Footprint library '%s' not found." ),
194 if( dir.GetFirst( &fullName, fileSpec ) )
209 wxString fpName = fn.
GetName();
219 if( !cacheError.IsEmpty() )
220 cacheError += wxT(
"\n\n" );
222 cacheError += wxString::Format(
_(
"Unable to read file '%s'" ) +
'\n',
224 cacheError += ioe.
What();
226 }
while( dir.GetNext( &fullName ) );
230 if( !cacheError.IsEmpty() )
238 FP_CACHE_FOOTPRINT_MAP::const_iterator it =
m_footprints.find( aFootprintName );
242 wxString msg = wxString::Format(
_(
"Library '%s' has no footprint '%s'." ),
249 wxString fullPath = it->second->GetFileName().GetFullPath();
251 wxRemoveFile( fullPath );
269 footprint.second->SetFilePath( aPath );
311 const std::map<std::string, UTF8>* aProperties )
320 _(
"Internal Group Data Error" ), wxICON_ERROR,
321 wxString::Format(
_(
"Please report this bug. Error validating group "
322 "structure: %s\n\nSave anyway?" ), sanityResult ),
323 _(
"Save Anyway" ) ) )
347 m_out->
Print( 0,
"(kicad_pcb (version %d) (generator \"pcbnew\") (generator_version \"%s\")\n",
361 std::string input =
TO_UTF8( aClipboardSourceInput );
368 return parser.
Parse();
384 switch( aItem->
Type() )
387 format(
static_cast<const BOARD*
>( aItem ), aNestLevel );
415 format(
static_cast<const PAD*
>( aItem ), aNestLevel );
449 format(
static_cast<const ZONE*
>( aItem ), aNestLevel );
453 wxFAIL_MSG( wxT(
"Cannot format item " ) + aItem->
GetClass() );
487 aIsKnockout ?
" knockout" :
"" );
492 bool aCompact,
const FOOTPRINT* aParentFP )
const
496 bool needNewline =
false;
497 int nestLevel = aNestLevel + 2;
500 for(
int ii = 0; ii < outline.
PointCount(); ++ii )
513 m_out->
Print( nestLevel,
"(arc (start %s) (mid %s) (end %s))",
529 if( !( shapesAdded % 4 ) || !aCompact )
550 m_out->
Print( aNestLevel,
"(render_cache %s %s\n",
566 callback_gal.DrawGlyphs( *cache );
585 m_out->
Print( aNestLevel+1,
"(pad_to_mask_clearance %s)\n",
590 m_out->
Print( aNestLevel+1,
"(solder_mask_min_width %s)\n",
596 m_out->
Print( aNestLevel+1,
"(pad_to_paste_clearance %s)\n",
602 m_out->
Print( aNestLevel+1,
"(pad_to_paste_clearance_ratio %s)\n",
629 m_out->
Print( aNestLevel+1,
"(aux_axis_origin %s %s)\n",
638 m_out->
Print( aNestLevel+1,
"(grid_origin %s %s)\n",
656 m_out->
Print( aNestLevel+1,
"(thickness %s)\n",
731 for(
const std::pair<const wxString, wxString>& prop : aBoard->
GetProperties() )
733 m_out->
Print( aNestLevel,
"(property %s %s)\n",
778 int aNestLevel )
const
780 m_out->
Print( aNestLevel,
"(teardrops (best_length_ratio %s) (max_length %s) "
781 "(best_width_ratio %s) (max_width %s) (curve_points %d) "
801 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_footprints( aBoard->
Footprints().begin(),
803 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_drawings( aBoard->
Drawings().begin(),
805 std::set<PCB_TRACK*, PCB_TRACK::cmp_tracks> sorted_tracks( aBoard->
Tracks().begin(),
807 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_zones( aBoard->
Zones().begin(),
808 aBoard->
Zones().end() );
809 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_groups( aBoard->
Groups().begin(),
811 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_generators( aBoard->
Generators().begin(),
816 for(
BOARD_ITEM* footprint : sorted_footprints )
818 Format( footprint, aNestLevel );
824 Format( item, aNestLevel );
826 if( sorted_drawings.size() )
833 Format( track, aNestLevel );
835 if( sorted_tracks.size() )
839 for(
auto zone : sorted_zones )
840 Format( zone, aNestLevel );
848 Format( gen, aNestLevel );
856 files_to_write.
AddFile( file.second );
863 files_to_write.
AddFile( file.second );
866 m_out->
Print( aNestLevel + 1,
"(embedded_fonts %s)\n",
869 if( !files_to_write.
IsEmpty() )
899 wxFAIL_MSG( wxT(
"Cannot format unknown dimension type!" ) );
908 m_out->
Print( aNestLevel+1,
"(pts (xy %s %s) (xy %s %s))\n",
922 m_out->
Print( aNestLevel+1,
"(leader_length %s)\n",
928 m_out->
Print( aNestLevel+1,
"(orientation %d)\n",
929 static_cast<int>(
ortho->GetOrientation() ) );
934 m_out->
Print( aNestLevel + 1,
"(format (prefix %s) (suffix %s) (units %d) (units_format %d) (precision %d)",
956 m_out->
Print( aNestLevel+1,
"(style (thickness %s) (arrow_length %s) (text_position_mode %d)",
961 if(
ortho || aligned )
965 case DIM_ARROW_DIRECTION::OUTWARD:
966 m_out->
Print( 0,
" (arrow_direction outward)" );
968 case DIM_ARROW_DIRECTION::INWARD:
969 m_out->
Print( 0,
" (arrow_direction inward)" );
995 format(
static_cast<const PCB_TEXT*
>( aDimension ), aNestLevel + 1 );
1004 std::string prefix = parentFP ?
"fp" :
"gr";
1008 case SHAPE_T::SEGMENT:
1009 m_out->
Print( aNestLevel,
"(%s_line (start %s) (end %s)\n",
1015 case SHAPE_T::RECTANGLE:
1016 m_out->
Print( aNestLevel,
"(%s_rect (start %s) (end %s)\n",
1022 case SHAPE_T::CIRCLE:
1023 m_out->
Print( aNestLevel,
"(%s_circle (center %s) (end %s)\n",
1030 m_out->
Print( aNestLevel,
"(%s_arc (start %s) (mid %s) (end %s)\n",
1043 m_out->
Print( aNestLevel,
"(%s_poly\n", prefix.c_str() );
1048 wxFAIL_MSG( wxT(
"Cannot format invalid polygon." ) );
1054 case SHAPE_T::BEZIER:
1055 m_out->
Print( aNestLevel,
"(%s_curve (pts (xy %s) (xy %s) (xy %s) (xy %s))\n",
1074 if( ( aShape->
GetShape() == SHAPE_T::POLY )
1075 || ( aShape->
GetShape() == SHAPE_T::RECTANGLE )
1076 || ( aShape->
GetShape() == SHAPE_T::CIRCLE ) )
1105 wxCHECK_RET( aBitmap !=
nullptr &&
m_out !=
nullptr,
"" );
1111 wxCHECK_RET(
image !=
nullptr,
"wxImage* is NULL" );
1113 m_out->
Print( aNestLevel,
"(image (at %s %s)",
1131#define MIME_BASE64_LENGTH 76
1135 while( first < out.Length() )
1153 m_out->
Print( aNestLevel,
"(target %s (at %s) (size %s)",
1154 ( aTarget->
GetShape() ) ?
"x" :
"plus",
1175 if( initial_comments )
1177 for(
unsigned i = 0; i < initial_comments->GetCount(); ++i )
1196 m_out->
Print( 0,
" (version %d) (generator \"pcbnew\") (generator_version \"%s\")\n ",
1204 if(
const bool placed = aFootprint->
IsPlaced() )
1228 m_out->
Print( aNestLevel + 1,
"(descr %s)\n",
1240 m_out->
Print( aNestLevel + 1,
"(property %s %s",
1241 m_out->
Quotew( field->GetCanonicalName() ).c_str(),
1244 format( field, aNestLevel + 1 );
1251 if( !compClass->IsEmpty() )
1253 m_out->
Print( aNestLevel + 1,
"(component_classes\n" );
1257 m_out->
Print( aNestLevel + 2,
"(class %s)\n",
1258 m_out->
Quotew( constituent->GetFullName() ).c_str() );
1267 m_out->
Print( aNestLevel + 1,
"(property ki_fp_filters %s)\n",
1279 m_out->
Print( aNestLevel + 1,
"(sheetname %s)\n",
1285 m_out->
Print( aNestLevel + 1,
"(sheetfile %s)\n",
1291 m_out->
Print( aNestLevel+1,
"(solder_mask_margin %s)\n",
1297 m_out->
Print( aNestLevel+1,
"(solder_paste_margin %s)\n",
1303 m_out->
Print( aNestLevel+1,
"(solder_paste_margin_ratio %s)\n",
1309 m_out->
Print( aNestLevel+1,
"(clearance %s)\n",
1315 m_out->
Print( aNestLevel+1,
"(zone_connect %d)\n",
1334 m_out->
Print( 0,
" exclude_from_pos_files" );
1340 m_out->
Print( 0,
" allow_missing_courtyard" );
1346 m_out->
Print( 0,
" allow_soldermask_bridges" );
1353 m_out->
Print( aNestLevel+1,
"(private_layers" );
1357 wxString canonicalName(
LSET::Name( layer ) );
1358 m_out->
Print( 0,
" \"%s\"", canonicalName.ToStdString().c_str() );
1366 m_out->
Print( aNestLevel+1,
"(net_tie_pad_groups" );
1377 std::set<PAD*, FOOTPRINT::cmp_pads> sorted_pads( aFootprint->
Pads().begin(),
1378 aFootprint->
Pads().end() );
1379 std::set<BOARD_ITEM*, FOOTPRINT::cmp_drawings> sorted_drawings(
1382 std::set<ZONE*, FOOTPRINT::cmp_zones> sorted_zones( aFootprint->
Zones().begin(),
1383 aFootprint->
Zones().end() );
1384 std::set<BOARD_ITEM*, PCB_GROUP::ptr_cmp> sorted_groups( aFootprint->
Groups().begin(),
1385 aFootprint->
Groups().end() );
1390 Format( gr, aNestLevel+1 );
1393 for(
PAD*
pad : sorted_pads )
1398 Format( zone, aNestLevel + 1 );
1404 m_out->
Print( aNestLevel + 1,
"(embedded_fonts %s)\n",
1413 auto bs3D = aFootprint->
Models().begin();
1414 auto es3D = aFootprint->
Models().end();
1416 while( bs3D != es3D )
1418 if( !bs3D->m_Filename.IsEmpty() )
1426 if( bs3D->m_Opacity != 1.0 )
1427 m_out->
Print( aNestLevel+2,
"(opacity %0.4f)", bs3D->m_Opacity );
1429 m_out->
Print( aNestLevel+2,
"(offset (xyz %s %s %s))\n",
1434 m_out->
Print( aNestLevel+2,
"(scale (xyz %s %s %s))\n",
1439 m_out->
Print( aNestLevel+2,
"(rotate (xyz %s %s %s))\n",
1458 if( aNestLevel == 0 )
1461 output +=
"(layers";
1472 LSET cu_mask = cu_all;
1476 if( ( aLayerMask & cu_mask ) == cu_mask )
1479 aLayerMask &= ~cu_all;
1481 else if( ( aLayerMask & cu_mask ) == fr_bk )
1484 aLayerMask &= ~fr_bk;
1487 if( ( aLayerMask & adhes ) == adhes )
1490 aLayerMask &= ~adhes;
1496 aLayerMask &= ~paste;
1499 if( ( aLayerMask & silks ) == silks )
1502 aLayerMask &= ~silks;
1505 if( ( aLayerMask & mask ) == mask )
1508 aLayerMask &= ~mask;
1511 if( ( aLayerMask & crt_yd ) == crt_yd )
1514 aLayerMask &= ~crt_yd;
1517 if( ( aLayerMask & fab ) == fab )
1528 if( aLayerMask[layer] )
1536 m_out->
Print( aNestLevel,
"%s)", output.c_str() );
1549 case PAD_SHAPE::CIRCLE:
return "circle";
1550 case PAD_SHAPE::RECTANGLE:
return "rect";
1551 case PAD_SHAPE::OVAL:
return "oval";
1552 case PAD_SHAPE::TRAPEZOID:
return "trapezoid";
1553 case PAD_SHAPE::CHAMFERED_RECT:
1554 case PAD_SHAPE::ROUNDRECT:
return "roundrect";
1555 case PAD_SHAPE::CUSTOM:
return "custom";
1567 case PAD_ATTRIB::PTH: type =
"thru_hole";
break;
1568 case PAD_ATTRIB::SMD: type =
"smd";
break;
1569 case PAD_ATTRIB::CONN: type =
"connect";
break;
1570 case PAD_ATTRIB::NPTH: type =
"np_thru_hole";
break;
1573 THROW_IO_ERROR( wxString::Format( wxT(
"unknown pad attribute: %d" ),
1577 const char*
property =
nullptr;
1581 case PAD_PROP::NONE:
break;
1582 case PAD_PROP::BGA:
property =
"pad_prop_bga";
break;
1583 case PAD_PROP::FIDUCIAL_GLBL:
property =
"pad_prop_fiducial_glob";
break;
1584 case PAD_PROP::FIDUCIAL_LOCAL:
property =
"pad_prop_fiducial_loc";
break;
1585 case PAD_PROP::TESTPOINT:
property =
"pad_prop_testpoint";
break;
1586 case PAD_PROP::HEATSINK:
property =
"pad_prop_heatsink";
break;
1587 case PAD_PROP::CASTELLATED:
property =
"pad_prop_castellated";
break;
1588 case PAD_PROP::MECHANICAL:
property =
"pad_prop_mechanical";
break;
1591 THROW_IO_ERROR( wxString::Format( wxT(
"unknown pad property: %d" ),
1619 if( (sz.
x > 0) || (sz.
y > 0) ||
1620 (shapeoffset.
x != 0) || (shapeoffset.
y != 0) )
1630 if( sz.
y > 0 && sz.
x != sz.
y )
1637 if( shapeoffset.
x != 0 || shapeoffset.
y != 0 )
1648 m_out->
Print( 0,
" (property %s)", property );
1662 m_out->
Print( 0,
" (zone_layer_connections" );
1675 auto formatCornerProperties =
1679 if( aPad->
GetShape( aLayer ) == PAD_SHAPE::ROUNDRECT
1680 || aPad->
GetShape( aLayer ) == PAD_SHAPE::CHAMFERED_RECT)
1687 if( aPad->
GetShape( aLayer ) == PAD_SHAPE::CHAMFERED_RECT)
1691 m_out->
Print( aNestLevel+1,
"(chamfer_ratio %s)",
1732 StrPrintf( &output,
" (pinfunction %s)",
1751 StrPrintf( &output,
" (solder_mask_margin %s)",
1757 StrPrintf( &output,
" (solder_paste_margin %s)",
1763 StrPrintf( &output,
" (solder_paste_margin_ratio %s)",
1775 StrPrintf( &output,
" (zone_connect %d)",
1781 StrPrintf( &output,
" (thermal_bridge_width %s)",
1791 defaultThermalSpokeAngle =
ANGLE_45;
1796 StrPrintf( &output,
" (thermal_bridge_angle %s)",
1802 StrPrintf( &output,
" (thermal_gap %s)",
1809 m_out->
Print( aNestLevel+1,
"%s", output.c_str()+1 );
1817 case PAD_SHAPE::RECTANGLE:
return "rect";
1819 case PAD_SHAPE::CIRCLE:
return "circle";
1823 auto formatPrimitives =
1828 int nested_level = aNestLevel+2;
1831 for(
const std::shared_ptr<PCB_SHAPE>& primitive : aPad->
GetPrimitives( aLayer ) )
1835 switch( primitive->GetShape() )
1837 case SHAPE_T::SEGMENT:
1838 if( primitive->IsProxyItem() )
1840 m_out->
Print( nested_level,
"(gr_vector (start %s) (end %s)",
1846 m_out->
Print( nested_level,
"(gr_line (start %s) (end %s)",
1852 case SHAPE_T::RECTANGLE:
1853 if( primitive->IsProxyItem() )
1855 m_out->
Print( nested_level,
"(gr_bbox (start %s) (end %s)",
1861 m_out->
Print( nested_level,
"(gr_rect (start %s) (end %s)",
1868 m_out->
Print( nested_level,
"(gr_arc (start %s) (mid %s) (end %s)",
1874 case SHAPE_T::CIRCLE:
1875 m_out->
Print( nested_level,
"(gr_circle (center %s) (end %s)",
1880 case SHAPE_T::BEZIER:
1881 m_out->
Print( nested_level,
"(gr_curve (pts (xy %s) (xy %s) (xy %s) (xy %s))",
1889 if( primitive->IsPolyShapeValid() )
1906 if( !primitive->IsProxyItem() )
1911 if( ( primitive->GetShape() == SHAPE_T::POLY )
1912 || ( primitive->GetShape() == SHAPE_T::RECTANGLE )
1913 || ( primitive->GetShape() == SHAPE_T::CIRCLE ) )
1931 m_out->
Print( 0,
" (clearance convexhull)" );
1958 auto formatPadLayer =
1963 m_out->
Print( 0,
" (shape %s)", shapeName( aLayer ) );
1973 shapeoffset = aPad->
GetOffset( aLayer );
1975 if( shapeoffset.
x != 0 || shapeoffset.
y != 0 )
1978 formatCornerProperties( aLayer );
1980 if( aPad->
GetShape( aLayer ) == PAD_SHAPE::CUSTOM )
1985 m_out->
Print( 0,
" (anchor %s)", anchorShape( aLayer ) );
1990 formatPrimitives( aLayer );
1995 if( aPad->
GetShape( aLayer ) == PAD_SHAPE::CIRCLE ||
1996 ( aPad->
GetShape( aLayer ) == PAD_SHAPE::CUSTOM
2004 if( layerSpokeAngle != defaultLayerAngle )
2006 StrPrintf( &output,
" (thermal_bridge_angle %s)",
2010 if( padstack.
ThermalGap( aLayer ).has_value() )
2012 StrPrintf( &output,
" (thermal_gap %s)",
2018 StrPrintf( &output,
" (thermal_bridge_width %s)",
2022 if( padstack.
Clearance( aLayer ).has_value() )
2030 StrPrintf( &output,
" (zone_connect %d)",
2040 m_out->
Print( 0,
"(padstack (mode %s)", mode.c_str() );
2047 formatPadLayer(
B_Cu );
2058 formatPadLayer( layer );
2076 if( front.has_value() || back.has_value() )
2078 if( front.value_or(
false ) || back.value_or(
false ) )
2082 if( front.value_or(
false ) )
2084 if( back.value_or(
false ) )
2103 bool isField =
dynamic_cast<const PCB_FIELD*
>( aText ) !=
nullptr;
2124 m_out->
Print( aNestLevel,
"(%s_text%s %s", prefix.c_str(), type.c_str(),
2155 aText->EDA_TEXT::Format(
m_out, aNestLevel, ctl_flags );
2171 : parentFP ?
"fp_text_box"
2178 if( aTextBox->
GetShape() == SHAPE_T::RECTANGLE )
2180 m_out->
Print( aNestLevel + 1,
"(start %s) (end %s)",
2184 else if( aTextBox->
GetShape() == SHAPE_T::POLY )
2203 m_out->
Print( 0,
" (span %d %d)", cell->GetColSpan(), cell->GetRowSpan() );
2240 wxCHECK_RET( aTable !=
nullptr &&
m_out !=
nullptr,
"" );
2242 m_out->
Print( aNestLevel,
"(table (column_count %d)",
2252 angle -= parentFP->GetOrientation();
2263 m_out->
Print( aNestLevel + 1,
"(border (external %s) (header %s)",
2275 m_out->
Print( aNestLevel + 1,
"(separators (rows %s) (cols %s)",
2287 m_out->
Print( aNestLevel + 1,
"(column_widths" );
2289 for(
int col = 0; col < aTable->
GetColCount(); ++col )
2294 m_out->
Print( aNestLevel + 1,
"(row_heights" );
2296 for(
int row = 0; row < aTable->
GetRowCount(); ++row )
2324 m_out->
Print( aNestLevel + 1,
"(members\n" );
2326 wxArrayString memberIds;
2329 memberIds.Add( member->m_Uuid.AsString() );
2333 for(
const wxString& memberId : memberIds )
2347 m_out->
Print( aNestLevel + 1,
"(type %s) (name %s)\n",
2358 for(
const auto& [key, value] : aGenerator->
GetProperties() )
2360 if( value.CheckType<
double>() || value.CheckType<
int>() || value.CheckType<
long>()
2361 || value.CheckType<
long long>() )
2365 if( !value.GetAs( &val ) )
2368 std::string buf = fmt::format(
"{:.10g}", val );
2371 m_out->
Print( aNestLevel + 1,
"(%s %s)\n", key.c_str(), buf.c_str() );
2373 else if( value.CheckType<
bool>() )
2376 value.GetAs( &val );
2378 m_out->
Print( aNestLevel + 1,
"(%s %s)\n", key.c_str(), val ?
"yes" :
"no" );
2380 else if( value.CheckType<
VECTOR2I>() )
2383 value.GetAs( &val );
2385 m_out->
Print( aNestLevel + 1,
"(%s (xy %s))\n", key.c_str(),
2391 value.GetAs( &val );
2393 m_out->
Print( aNestLevel + 1,
"(%s (pts\n", key.c_str() );
2404 if( value.CheckType<wxString>() )
2406 value.GetAs( &val );
2408 else if( value.CheckType<std::string>() )
2411 value.GetAs( &str );
2413 val = wxString::FromUTF8( str );
2420 m_out->
Print( aNestLevel + 1,
"(members\n" );
2422 wxArrayString memberIds;
2425 memberIds.Add( member->m_Uuid.AsString() );
2429 for(
const wxString& memberId : memberIds )
2445 const BOARD* board =
via->GetBoard();
2447 wxCHECK_RET( board !=
nullptr, wxT(
"Via has no parent." ) );
2451 via->LayerPair( &layer1, &layer2 );
2453 switch(
via->GetViaType() )
2455 case VIATYPE::THROUGH:
2458 case VIATYPE::BLIND_BURIED:
2462 case VIATYPE::MICROVIA:
2488 switch(
via->Padstack().UnconnectedLayerMode() )
2491 m_out->
Print( 0,
"(remove_unused_layers yes)" );
2496 m_out->
Print( 0,
"(remove_unused_layers yes)" );
2504 if(
via->IsLocked() )
2507 if(
via->GetIsFree() )
2510 if(
via->GetRemoveUnconnected() )
2512 m_out->
Print( 0,
" (zone_layer_connections" );
2531 m_out->
Print( 0,
"(padstack (mode %s)", mode.c_str() );
2572 m_out->
Print( aNestLevel,
"(arc (start %s) (mid %s) (end %s) (width %s)",
2580 m_out->
Print( aNestLevel,
"(segment (start %s) (end %s) (width %s)",
2620 m_out->
Print( aNestLevel,
"(zone (net %d) (net_name %s)",
2633 if( layers.count() > 1 )
2653 case ZONE_BORDER_DISPLAY_STYLE::NO_HATCH: hatch =
"none";
break;
2654 case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE: hatch =
"edge";
break;
2655 case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL: hatch =
"full";
break;
2658 m_out->
Print( 0,
" (hatch %s %s)\n", hatch.c_str(),
2669 const char* td_type;
2673 case TEARDROP_TYPE::TD_VIAPAD:
2678 case TEARDROP_TYPE::TD_TRACKEND:
2679 td_type =
"track_end";
2683 m_out->
Print( aNestLevel+1,
"(attr (teardrop (type %s)))\n", td_type );
2686 m_out->
Print( aNestLevel+1,
"(connect_pads" );
2691 case ZONE_CONNECTION::THERMAL:
2694 case ZONE_CONNECTION::THT_THERMAL:
2698 case ZONE_CONNECTION::FULL:
2702 case ZONE_CONNECTION::NONE:
2710 m_out->
Print( aNestLevel+1,
"(min_thickness %s)",
2714 m_out->
Print( 0,
" (filled_areas_thickness no)" );
2722 "(keepout (tracks %s) (vias %s) (pads %s) (copperpour %s) "
2723 "(footprints %s))\n",
2733 m_out->
Print( aNestLevel + 1,
"(placement" );
2743 case RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME:
2744 m_out->
Print( aNestLevel + 2,
"(sheetname %s)",
2747 case RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS:
2748 m_out->
Print( aNestLevel + 2,
"(component_class %s)",
2764 if( aZone->
GetFillMode() == ZONE_FILL_MODE::HATCH_PATTERN )
2767 m_out->
Print( 0,
" (thermal_gap %s) (thermal_bridge_width %s)",
2786 THROW_IO_ERROR( wxString::Format(
_(
"unknown zone corner smoothing type %d" ),
2797 m_out->
Print( 0,
" (island_removal_mode %d) (island_area_min %s)",
2802 if( aZone->
GetFillMode() == ZONE_FILL_MODE::HATCH_PATTERN )
2805 m_out->
Print( aNestLevel+2,
"(hatch_thickness %s) (hatch_gap %s) (hatch_orientation %s)",
2813 m_out->
Print( aNestLevel+2,
"(hatch_smoothing_level %d) (hatch_smoothing_value %s)",
2819 m_out->
Print( aNestLevel+2,
"(hatch_border_algorithm %s) (hatch_min_hole_area %s)",
2830 for(
auto& chain : poly )
2832 m_out->
Print( aNestLevel + 1,
"(polygon\n" );
2843 for(
int ii = 0; ii < fv->OutlineCount(); ++ii )
2845 m_out->
Print( aNestLevel + 1,
"(filled_polygon\n" );
2846 m_out->
Print( aNestLevel + 2,
"(layer %s)\n",
2850 m_out->
Print( aNestLevel + 2,
"(island)\n" );
2865 m_ctl( aControlFlags ),
2881 const std::map<std::string, UTF8>* aProperties,
PROJECT* aProject )
2885 unsigned lineCount = 0;
2915 init( aProperties );
2922 board =
dynamic_cast<BOARD*
>( parser.
Parse() );
2941 parser.CurLine(), parser.CurLineNumber(), parser.CurOffset() );
2971 bool aBestEfforts,
const std::map<std::string, UTF8>* aProperties )
2974 wxDir dir( aLibPath );
2977 init( aProperties );
2985 errorMsg = ioe.
What();
2992 aFootprintNames.Add( footprint.first );
2994 if( !errorMsg.IsEmpty() && !aBestEfforts )
3000 const wxString& aFootprintName,
3001 const std::map<std::string, UTF8>* aProperties,
3002 bool checkModified )
3006 init( aProperties );
3018 FP_CACHE_FOOTPRINT_MAP::const_iterator it = footprints.find( aFootprintName );
3020 if( it == footprints.end() )
3023 return it->second->GetFootprint();
3028 const wxString& aFootprintName,
3029 const std::map<std::string, UTF8>* aProperties )
3031 return getFootprint( aLibraryPath, aFootprintName, aProperties,
false );
3036 const std::map<std::string, UTF8>* aProperties )
3047 return footprintFile.Exists();
3052 const std::map<std::string, UTF8>* aProperties )
3055 wxFFile f( aFootprintPath );
3062 f.ReadAll( &fcontents );
3064 aFootprintNameOut = wxFileName( aFootprintPath ).GetName();
3071 const wxString& aFootprintName,
3073 const std::map<std::string, UTF8>* aProperties )
3088 copy->SetParent(
nullptr );
3097 const std::map<std::string, UTF8>* aProperties )
3101 init( aProperties );
3107 validateCache( aLibraryPath, !aProperties || !aProperties->contains(
"skip_cache_validation" ) );
3113 const wxString msg = wxString::Format(
_(
"Library '%s' does not exist.\n"
3114 "Would you like to create it?"),
3118 || wxMessageBox( msg,
_(
"Library Not Found" ), wxYES_NO | wxICON_QUESTION )
3127 wxString msg = wxString::Format(
_(
"Library '%s' is read only." ), aLibraryPath );
3146 THROW_IO_ERROR( wxString::Format(
_(
"Footprint file name '%s' is not valid." ),
3147 fn.GetFullPath() ) );
3150 if( fn.FileExists() && !fn.IsFileWritable() )
3152 THROW_IO_ERROR( wxString::Format(
_(
"Insufficient permissions to delete '%s'." ),
3153 fn.GetFullPath() ) );
3156 wxString fullPath = fn.GetFullPath();
3157 wxString fullName = fn.GetFullName();
3158 FP_CACHE_FOOTPRINT_MAP::const_iterator it = footprints.find( footprintName );
3160 if( it != footprints.end() )
3163 footprints.erase( footprintName );
3164 wxRemoveFile( fullPath );
3180 footprint->
Flip( footprint->
GetPosition(), FLIP_DIRECTION::TOP_BOTTOM );
3187 wxLogTrace(
traceKicadPcbPlugin, wxT(
"Creating s-expr footprint file '%s'." ), fullPath );
3188 footprints.insert( footprintName,
3195 const std::map<std::string, UTF8>* aProperties )
3199 init( aProperties );
3206 aLibraryPath.GetData() ) );
3222 if( wxDir::Exists( aLibraryPath ) )
3224 THROW_IO_ERROR( wxString::Format(
_(
"Cannot overwrite library path '%s'." ),
3225 aLibraryPath.GetData() ) );
3230 init( aProperties );
3241 fn.SetPath( aLibraryPath );
3244 if( !fn.DirExists() )
3247 if( !fn.IsDirWritable() )
3249 THROW_IO_ERROR( wxString::Format(
_(
"Insufficient permissions to delete folder '%s'." ),
3250 aLibraryPath.GetData() ) );
3253 wxDir dir( aLibraryPath );
3255 if( dir.HasSubDirs() )
3257 THROW_IO_ERROR( wxString::Format(
_(
"Library folder '%s' has unexpected sub-folders." ),
3258 aLibraryPath.GetData() ) );
3262 if( dir.HasFiles() )
3266 wxArrayString files;
3268 wxDir::GetAllFiles( aLibraryPath, &files );
3270 for( i = 0; i < files.GetCount(); i++ )
3276 THROW_IO_ERROR( wxString::Format(
_(
"Unexpected file '%s' found in library "
3279 aLibraryPath.GetData() ) );
3283 for( i = 0; i < files.GetCount(); i++ )
3284 wxRemoveFile( files[i] );
3288 aLibraryPath.GetData() );
3292 if( !wxRmdir( aLibraryPath ) )
3294 THROW_IO_ERROR( wxString::Format(
_(
"Footprint library '%s' cannot be deleted." ),
3295 aLibraryPath.GetData() ) );
3302 wxMilliSleep( 250L );
constexpr EDA_IU_SCALE pcbIUScale
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
wxString GetMajorMinorVersion()
Get only the major and minor version in a string major.minor.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
const wxMemoryBuffer & GetImageDataBuffer() const
wxString GetNetname() const
TEARDROP_PARAMETERS & GetTeardropParams()
Container for design settings for a BOARD object.
int GetBoardThickness() const
The full thickness of the board including copper and masks.
const VECTOR2I & GetGridOrigin()
const VECTOR2I & GetAuxOrigin()
bool m_AllowSoldermaskBridgesInFPs
int m_SolderMaskExpansion
BOARD_STACKUP & GetStackupDescriptor()
double m_SolderPasteMarginRatio
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
void SetParentGroup(PCB_GROUP *aGroup)
virtual bool IsKnockout() const
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
FOOTPRINT * GetParentFootprint() const
VECTOR2I GetFPRelativePosition() const
virtual bool IsLocked() const
Manage layers needed to make a physical board.
void FormatBoardStackup(OUTPUTFORMATTER *aFormatter, const BOARD *aBoard, int aNestLevel) const
Write the stackup info on board file.
Information pertinent to a Pcbnew printed circuit board.
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
EMBEDDED_FILES * GetEmbeddedFiles() override
const GENERATORS & Generators() const
void SetFileName(const wxString &aFileName)
const PAGE_INFO & GetPageSettings() const
const ZONES & Zones() const
const GROUPS & Groups() const
The groups must maintain the following invariants.
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Return the type of the copper layer given by aLayer.
TITLE_BLOCK & GetTitleBlock()
int GetCopperLayerCount() const
const std::map< wxString, wxString > & GetProperties() const
const FOOTPRINTS & Footprints() const
const TRACKS & Tracks() const
const PCB_PLOT_PARAMS & GetPlotOptions() const
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
bool LegacyTeardrops() const
wxString GroupsSanityCheck(bool repair=false)
Consistency check of internal m_groups structure.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
void EmbedFonts() override
Finds all fonts used in the board and embeds them in the file if permissions allow.
const DRAWINGS & Drawings() const
const std::vector< COMPONENT_CLASS * > & GetConstituentClasses() const
Fetches a vector of the constituent classes for this (effective) class.
KICAD_T Type() const
Returns the type of object.
virtual void SetParent(EDA_ITEM *aParent)
virtual wxString GetClass() const =0
Return the class name.
const VECTOR2I & GetBezierC2() const
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.
wxString SHAPE_T_asString() const
const VECTOR2I & GetBezierC1() const
bool IsPolyShapeValid() const
VECTOR2I GetArcMid() const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
const VECTOR2I & GetTextPos() const
const EDA_ANGLE & GetTextAngle() const
virtual const wxString & GetText() const
Return the string associated with the text object.
bool IsKeepUpright() const
virtual bool IsVisible() const
KIFONT::FONT * GetFont() const
std::vector< std::unique_ptr< KIFONT::GLYPH > > * GetRenderCache(const KIFONT::FONT *aFont, const wxString &forResolvedText, const VECTOR2I &aOffset={ 0, 0 }) const
virtual EDA_ANGLE GetDrawRotation() const
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
int GetTextThickness() const
void WriteEmbeddedFiles(OUTPUTFORMATTER &aOut, int aNestLevel, bool aWriteData) const
Output formatter for the embedded files.
void ClearEmbeddedFiles(bool aDeleteFiles=true)
void ClearEmbeddedFonts()
Removes all embedded fonts from the collection.
EMBEDDED_FILE * AddFile(const wxFileName &aName, bool aOverwrite)
Loads a file from disk and adds it to the collection.
const std::map< wxString, EMBEDDED_FILE * > & EmbeddedFileMap() const
bool GetAreFontsEmbedded() const
A LINE_READER that reads from an open file.
void Rewind()
Rewind the file and resets the line number back to zero.
char * ReadLine() override
Read a line of text into the buffer and increments the line number counter.
Helper class for creating a footprint library cache.
FP_CACHE_ITEM(FOOTPRINT *aFootprint, const WX_FILENAME &aFileName)
static long long GetTimestamp(const wxString &aLibPath)
Generate a timestamp representing all source files in the cache (including the parent directory).
FP_CACHE_FOOTPRINT_MAP & GetFootprints()
void Save(FOOTPRINT *aFootprint=nullptr)
Save the footprint cache or a single footprint from it to disk.
PCB_IO_KICAD_SEXPR * m_owner
bool IsModified()
Return true if the cache is not up-to-date.
long long m_cache_timestamp
void SetPath(const wxString &aPath)
bool IsPath(const wxString &aPath) const
Check if aPath is the same as the current cache path.
FP_CACHE_FOOTPRINT_MAP m_footprints
FP_CACHE(PCB_IO_KICAD_SEXPR *aOwner, const wxString &aLibraryPath)
void Remove(const wxString &aFootprintName)
PROGRESS_REPORTER * m_progressReporter
Progress reporter to track the progress of the operation, may be nullptr.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
APP_SETTINGS_BASE * KifaceSettings() const
virtual bool IsOutline() const
virtual void SetLineWidth(float aLineWidth)
Set the line width.
wxString AsString() const
A logical library item identifier and consists of various portions much like a URI.
const UTF8 & GetLibItemName() const
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
LSET is a set of PCB_LAYER_IDs.
LSEQ CuStack() const
Return a sequence of copper layers in starting from the front/top and extending to the back/bottom.
LSEQ TechAndUserUIOrder() const
Returns the technical and user layers in the order shown in layer widget.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
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 ...
void SetBoard(const BOARD *aBoard)
Set a BOARD object that is used to prepare the net code map.
int Translate(int aNetCode) const
Translate net number according to the map prepared by Update() function.
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()
std::optional< int > & ThermalSpokeWidth(PCB_LAYER_ID aLayer=F_Cu)
EDA_ANGLE ThermalSpokeAngle(PCB_LAYER_ID aLayer=F_Cu) const
std::optional< int > & ThermalGap(PCB_LAYER_ID aLayer=F_Cu)
const VECTOR2I & Size(PCB_LAYER_ID aLayer) const
@ NORMAL
Shape is the same on all layers.
@ 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)
@ REMOVE_EXCEPT_START_AND_END
MASK_LAYER_PROPS & BackOuterLayers()
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
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)
PAD_PROP GetProperty() const
bool GetRemoveUnconnected() const
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives(PCB_LAYER_ID aLayer) const
Accessor to the basic shape list for custom-shaped pads.
const ZONE_LAYER_OVERRIDE & GetZoneLayerOverride(PCB_LAYER_ID aLayer) const
std::optional< double > GetLocalSolderPasteMarginRatio() const
const wxString & GetPinType() const
const VECTOR2I & GetDrillSize() const
PAD_ATTRIB GetAttribute() const
const wxString & GetPinFunction() const
const wxString & GetNumber() const
const VECTOR2I & GetDelta(PCB_LAYER_ID aLayer) const
EDA_ANGLE GetThermalSpokeAngle() const
double GetRoundRectRadiusRatio(PCB_LAYER_ID aLayer) const
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
bool GetKeepTopBottom() const
std::optional< int > GetLocalClearance() const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
const PADSTACK & Padstack() const
const VECTOR2I & GetOffset(PCB_LAYER_ID aLayer) const
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
PADSTACK::CUSTOM_SHAPE_ZONE_MODE GetCustomShapeInZoneOpt() const
PAD_DRILL_SHAPE GetDrillShape() const
int GetChamferPositions(PCB_LAYER_ID aLayer) const
std::optional< int > GetLocalSolderPasteMargin() const
std::optional< int > GetLocalSolderMaskMargin() const
int GetThermalSpokeWidth() const
double GetChamferRectRatio(PCB_LAYER_ID aLayer) const
ZONE_CONNECTION GetLocalZoneConnection() const
int GetThermalGap() const
PAD_SHAPE GetAnchorPadShape(PCB_LAYER_ID aLayer) const
int GetPadToDieLength() const
const VECTOR2I & GetSize(PCB_LAYER_ID aLayer) const
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the page class to aFormatter in s-expression form.
FLIP_DIRECTION m_FlipDirection
const VECTOR2I & GetMid() const
wxString GetOverrideText() const
wxString GetSuffix() const
int GetLineThickness() const
DIM_TEXT_POSITION GetTextPositionMode() const
bool GetKeepTextAligned() const
DIM_PRECISION GetPrecision() const
wxString GetPrefix() const
DIM_UNITS_MODE GetUnitsMode() const
DIM_UNITS_FORMAT GetUnitsFormat() const
virtual const VECTOR2I & GetStart() const
The dimension's origin is the first feature point for the dimension.
DIM_ARROW_DIRECTION GetArrowDirection() const
bool GetSuppressZeroes() const
int GetExtensionOffset() const
int GetArrowLength() const
bool GetOverrideTextEnabled() const
virtual const VECTOR2I & GetEnd() const
For better understanding of the points that make a dimension:
int GetExtensionHeight() const
Mark the center of a circle or arc with a cross shape.
A leader is a dimension-like object pointing to a specific point.
DIM_TEXT_BORDER GetTextBorder() const
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.
int GetLeaderLength() const
virtual const STRING_ANY_MAP GetProperties() const
virtual wxString GetGeneratorType() const
A set of BOARD_ITEMs (i.e., without duplicates).
std::unordered_set< BOARD_ITEM * > & GetItems()
Read a Pcbnew s-expression formatted LINE_READER object and returns the appropriate BOARD_ITEM object...
bool IsTooRecent()
Return whether a version number, if any was parsed, was too recent.
bool IsValidBoardHeader()
Partially parse the input and check if it matches expected header.
wxString GetRequiredVersion()
Return a string representing the version of KiCad required to open this file.
A #PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
BOARD * DoLoad(LINE_READER &aReader, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties, PROGRESS_REPORTER *aProgressReporter, unsigned aLineCount)
bool CanReadBoard(const wxString &aFileName) const override
Checks if this PCB_IO can read the specified board file.
void formatRenderCache(const EDA_TEXT *aText, int aNestLevel) const
FOOTPRINT * ImportFootprint(const wxString &aFootprintPath, wxString &aFootprintNameOut, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load a single footprint from aFootprintPath and put its name in aFootprintNameOut.
void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Delete aFootprintName from the library at aLibraryPath.
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
bool IsLibraryWritable(const wxString &aLibraryPath) override
Return true if the library at aLibraryPath is writable.
bool DeleteLibrary(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Delete an existing library and returns true, or if library does not exist returns false,...
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
const FOOTPRINT * GetEnumeratedFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.
void CreateLibrary(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Create a new empty library at aLibraryPath empty.
void formatLayers(LSET aLayerMask, int aNestLevel=0) const
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Return a list of footprint names contained within the library at aLibraryPath.
void formatSetup(const BOARD *aBoard, int aNestLevel=0) const
formats the board setup information
FP_CACHE * m_cache
Footprint library cache.
void formatPolyPts(const SHAPE_LINE_CHAIN &outline, int aNestLevel, bool aCompact, const FOOTPRINT *aParentFP=nullptr) const
void formatHeader(const BOARD *aBoard, int aNestLevel=0) const
writes everything that comes before the board_items, like settings and layers etc
void formatNetInformation(const BOARD *aBoard, int aNestLevel=0) const
formats the Nets and Netclasses
void formatProperties(const BOARD *aBoard, int aNestLevel=0) const
formats the Nets and Netclasses
FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PC...
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
bool FootprintExists(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Check for the existence of a footprint.
void FootprintSave(const wxString &aLibraryPath, const FOOTPRINT *aFootprint, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aFootprint to an existing library located at aLibraryPath.
void formatGeneral(const BOARD *aBoard, int aNestLevel=0) const
formats the General section of the file
void SaveBoard(const wxString &aFileName, BOARD *aBoard, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aBoard to a storage file in a format that this PCB_IO implementation knows about or it can be u...
void formatTenting(const PADSTACK &aPadstack) const
void Format(const BOARD_ITEM *aItem, int aNestLevel=0) const
Output aItem to aFormatter in s-expression format.
void format(const BOARD *aBoard, int aNestLevel=0) const
std::function< bool(wxString aTitle, int aIcon, wxString aMsg, wxString aAction)> m_queryUserCallback
BOARD_ITEM * Parse(const wxString &aClipboardSourceInput)
void init(const std::map< std::string, UTF8 > *aProperties)
void formatBoardLayers(const BOARD *aBoard, int aNestLevel=0) const
formats the board layer information
void formatTeardropParameters(const TEARDROP_PARAMETERS &tdParams, int aNestLevel=0) const
void formatLayer(PCB_LAYER_ID aLayer, bool aIsKnockout=false) const
const FOOTPRINT * getFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties, bool checkModified)
void SetOutputFormatter(OUTPUTFORMATTER *aFormatter)
PCB_IO_KICAD_SEXPR(int aControlFlags=CTL_FOR_BOARD)
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
virtual ~PCB_IO_KICAD_SEXPR()
LINE_READER * m_reader
no ownership
A base class that BOARD loading and saving plugins should derive from.
BOARD * m_board
The board BOARD being worked on, no ownership here.
virtual bool CanReadBoard(const wxString &aFileName) const
Checks if this PCB_IO can read the specified board file.
const std::map< std::string, UTF8 > * m_props
Properties passed via Save() or Load(), no ownership, may be NULL.
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControl=0) const
Object to handle a bitmap image that can be inserted in a PCB.
VECTOR2I GetPosition() const override
Get the position of the image (this is the center of the image).
REFERENCE_IMAGE & GetReferenceImage()
std::optional< int > GetLocalSolderMaskMargin() const
bool HasSolderMask() const
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
STROKE_PARAMS GetStroke() const override
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
bool StrokeColumns() const
bool StrokeExternal() const
bool StrokeHeader() const
std::vector< PCB_TABLECELL * > GetCells() const
const STROKE_PARAMS & GetSeparatorsStroke() const
const STROKE_PARAMS & GetBorderStroke() const
int GetColWidth(int aCol) const
EDA_ANGLE GetOrientation() const
int GetRowHeight(int aRow) const
VECTOR2I GetPosition() const override
bool IsBorderEnabled() const
Disables the border, this is done by changing the stroke internally.
int GetMarginBottom() const
int GetMarginLeft() const
int GetMarginRight() const
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
bool HasSolderMask() const
std::optional< int > GetLocalSolderMaskMargin() const
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
virtual int GetWidth() const
A progress reporter interface for use in multi-threaded environments.
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
virtual void Report(const wxString &aMessage)=0
Display aMessage in the progress bar dialog.
Container for project specific data.
A REFERENCE_IMAGE is a wrapper around a BITMAP_IMAGE that is displayed in an editor as a reference fo...
const BITMAP_BASE & GetImage() const
Get the underlying image.
double GetImageScale() const
const VECTOR2I & GetArcMid() const
const VECTOR2I & GetP1() const
const VECTOR2I & GetP0() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const SHAPE_ARC & Arc(size_t aArc) const
int PointCount() const
Return the number of points (vertices) in this line chain.
ssize_t ArcIndex(size_t aSegment) const
Return the arc index for the given segment index.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
const std::vector< VECTOR2I > & CPoints() const
Represent a set of closed polygons.
POLYGON & Polygon(int aIndex)
Return the aIndex-th subpolygon in the set.
std::vector< SHAPE_LINE_CHAIN > POLYGON
represents a single polygon outline with holes.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
void Format(OUTPUTFORMATTER *out, const EDA_IU_SCALE &aIuScale, int nestLevel) const
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
int m_CurveSegCount
True if the teardrop should be curved.
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.
virtual void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the object to aFormatter in s-expression form.
static REPORTER & GetInstance()
A wrapper around a wxFileName which is much more performant with a subset of the API.
void SetFullName(const wxString &aFileNameAndExtension)
static void ResolvePossibleSymlinks(wxFileName &aFilename)
wxString GetFullPath() const
Handle a list of polygons defining a copper zone.
int GetHatchBorderAlgorithm() const
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
std::optional< int > GetLocalClearance() const override
wxString GetRuleAreaPlacementSource() const
bool GetDoNotAllowVias() const
const std::shared_ptr< SHAPE_POLY_SET > & GetFilledPolysList(PCB_LAYER_ID aLayer) const
bool GetDoNotAllowPads() const
bool GetDoNotAllowTracks() const
bool GetRuleAreaPlacementEnabled() const
ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
SHAPE_POLY_SET * Outline()
bool IsIsland(PCB_LAYER_ID aLayer, int aPolyIdx) const
Check if a given filled polygon is an insulated island.
long long int GetMinIslandArea() const
const wxString & GetZoneName() const
int GetMinThickness() const
ZONE_CONNECTION GetPadConnection() const
int GetHatchThickness() const
double GetHatchHoleMinArea() const
bool IsTeardropArea() const
int GetThermalReliefSpokeWidth() const
int GetBorderHatchPitch() const
HatchBorder related methods.
ZONE_BORDER_DISPLAY_STYLE GetHatchStyle() const
EDA_ANGLE GetHatchOrientation() const
bool GetDoNotAllowFootprints() const
ZONE_FILL_MODE GetFillMode() const
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
bool GetDoNotAllowCopperPour() const
RULE_AREA_PLACEMENT_SOURCE_TYPE GetRuleAreaPlacementSourceType() const
TEARDROP_TYPE GetTeardropAreaType() const
double GetHatchSmoothingValue() const
int GetHatchSmoothingLevel() const
unsigned int GetCornerRadius() const
int GetCornerSmoothingType() const
bool IsOnCopperLayer() const override
PCB_LAYER_ID GetFirstLayer() const
int GetThermalReliefGap() const
unsigned GetAssignedPriority() const
int GetNumCorners(void) const
Access to m_Poly parameters.
static void SetReporter(REPORTER *aReporter)
Set the reporter to use for reporting font substitution warnings.
long long TimestampDir(const wxString &aDirPath, const wxString &aFilespec)
A copy of ConvertFileTimeToWx() because wxWidgets left it as a static function private to src/common/...
This file is part of the common library.
@ RECT_CHAMFER_BOTTOM_RIGHT
@ RECT_CHAMFER_BOTTOM_LEFT
#define CTL_OMIT_HYPERLINK
Omit the hyperlink attribute in .kicad_xxx files.
#define CTL_OMIT_UUIDS
Omit component unique ids (useless in library)
#define CTL_OMIT_FOOTPRINT_VERSION
Omit the version string from the (footprint) sexpr group.
#define CTL_OMIT_INITIAL_COMMENTS
omit FOOTPRINT initial comments
#define CTL_OMIT_LIBNAME
Omit lib alias when saving (used for board/not library).
#define CTL_OMIT_PATH
Omit component sheet time stamp (useless in library)
#define CTL_OMIT_HIDE
Omit the hide attribute in .kicad_xxx files.
#define CTL_OMIT_AT
Omit position and rotation.
#define CTL_OMIT_PAD_NETS
Omit pads net names (useless in library)
#define CTL_OMIT_COLOR
Omit the color attribute in .kicad_xxx files.
#define MIME_BASE64_LENGTH
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_45
static const std::string KiCadFootprintFileExtension
const wxChar *const traceKicadPcbPlugin
Flag to enable GEDA PCB plugin debug output.
#define THROW_IO_ERROR(msg)
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
bool IsExternalCopperLayer(int aLayerId)
Tests whether a layer is an external (F_Cu or B_Cu) copper layer.
PCB_LAYER_ID
A quick note on layer IDs:
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
KICOMMON_API std::string FormatInternalUnits(const EDA_IU_SCALE &aIuScale, int aValue)
Converts aValue from internal units to a string appropriate for writing to file.
KICOMMON_API std::string FormatAngle(const EDA_ANGLE &aAngle)
Converts aAngle from board units to a string appropriate for writing to file.
Class to handle a set of BOARD_ITEMs.
bool isDefaultTeardropParameters(const TEARDROP_PARAMETERS &tdParams)
std::string formatInternalUnits(int aValue)
#define SEXPR_BOARD_FILE_VERSION
Current s-expression file format version. 2 was the last legacy format version.
#define CTL_FOR_BOARD
The zero arg constructor when PCB_PLUGIN is used for PLUGIN::Load() and PLUGIN::Save()ing a BOARD fil...
boost::ptr_map< wxString, FP_CACHE_ITEM > FP_CACHE_FOOTPRINT_MAP
#define CTL_FOR_LIBRARY
Format output for a footprint library instead of clipboard or BOARD.
Pcbnew s-expression file format parser definition.
#define UNDEFINED_DRILL_DIAMETER
PGM_BASE & Pgm()
The global Program "get" accessor.
int StrPrintf(std::string *result, const char *format,...)
This is like sprintf() but the output is appended to a std::string instead of to a character array.
bool ReplaceIllegalFileNameChars(std::string *aName, int aReplaceChar)
Checks aName for illegal file name characters.
std::string FormatDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 This function is intended in...
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
static const char * ShowType(LAYER_T aType)
Convert a LAYER_T enum to a string representation of the layer type.
std::optional< bool > has_solder_mask
True if this outer layer has mask (is not tented)
A filename or source description, a problem input line, a line number, a byte offset,...
wxLogTrace helper definitions.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ 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_GENERATOR_T
class PCB_GENERATOR, generator on a layer
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
VECTOR2< int32_t > VECTOR2I
Definition of file extensions used in Kicad.