25#include <wx/mstream.h>
34#include <fmt/format.h>
78using namespace PCB_KEYS_T;
110 std::unique_ptr<FOOTPRINT>& footprint = fpCacheEntry->
GetFootprint();
112 if( aFootprintFilter && footprint.get() != aFootprintFilter )
125 m_owner->SetOutputFormatter( &formatter );
127 m_owner->FormatFootprintLibFile( footprint.get() );
138 if( !aFootprintFilter )
150 if( !dir.IsOpened() )
160 if( dir.GetFirst( &fullName, fileSpec ) )
176 wxString fpName = fn.
GetName();
182 FOOTPRINT* footprint = tmp.release( tmp.begin() )->GetFootprint().release();
196 if( !cacheError.IsEmpty() )
197 cacheError += wxT(
"\n\n" );
199 cacheError += wxString::Format(
_(
"Unable to read file '%s'" ) +
'\n',
201 cacheError += ioe.
What();
203 }
while( dir.GetNext( &fullName ) );
207 if( !cacheError.IsEmpty() )
225 wxString fullPath = it->second->GetFileName().GetFullPath();
227 wxRemoveFile( fullPath );
244 footprint.second->SetFilePath( aPath );
285 const std::map<std::string, UTF8>* aProperties )
292 _(
"Internal Group Data Error" ), wxICON_ERROR,
293 wxString::Format(
_(
"Please report this bug. Error validating group "
294 "structure: %s\n\nSave anyway?" ), sanityResult ),
295 _(
"Save Anyway" ) ) )
308 const std::map<std::string, UTF8>* aProperties )
316 if(
m_board->GetAreFontsEmbedded() )
319 m_board->GetEmbeddedFiles()->ClearEmbeddedFonts();
336 std::string input =
TO_UTF8( aClipboardSourceInput );
343 return parser.
Parse();
366 m_out->Print(
"(kicad_footprint_lib (version %d) (generator \"kicad_footprint_editor\")"
367 " (generator_version \"%s\")\n",
370 format( aFootprint,
true );
371 m_out->Print(
")\n" );
377 switch( aItem->
Type() )
416 format(
static_cast<const PAD*
>( aItem ) );
471 wxFAIL_MSG( wxT(
"Cannot format item " ) + aItem->
GetClass() );
527 return KiROUND( aValue / avg );
533 m_out->Print(
"(layer %s %s)",
535 aIsKnockout ?
"knockout" :
"" );
542 m_out->Print(
"(pts" );
544 for(
int ii = 0; ii < outline.
PointCount(); ++ii )
550 m_out->Print(
"(xy %s)",
556 m_out->Print(
"(arc (start %s) (mid %s) (end %s))",
580 m_out->Print(
"(render_cache %s %s",
581 m_out->Quotew( resolvedText ).c_str(),
590 m_out->Print(
"(polygon" );
596 callback_gal.DrawGlyphs( *cache );
605 m_out->Print(
"(setup" );
627 m_out->Print( 0,
" (tenting " );
630 m_out->Print( 0,
")" );
632 m_out->Print( 0,
" (covering " );
635 m_out->Print( 0,
")" );
637 m_out->Print( 0,
" (plugging " );
640 m_out->Print( 0,
")" );
648 m_out->Print( 0,
" (zone_defaults" );
651 format( properties, 0, layer );
653 m_out->Print( 0,
")\n" );
660 m_out->Print(
"(aux_axis_origin %s %s)",
669 m_out->Print(
"(grid_origin %s %s)",
690 aOut->
Print(
" backdrill" );
693 aOut->
Print(
" npth" );
703 if( profile == defaults )
708 m_out->Print(
"(drill_symbol_profile" );
710 if( !profile.
GetName().IsEmpty() )
713 m_out->Print(
"(group_by" );
726 for(
const auto& [key, assignment] : profile.
Assignments() )
728 m_out->Print(
"(assignment (key %s) (mark %s",
729 m_out->Quotew( wxString::FromUTF8( key ) ).c_str(),
733 m_out->Print(
" %d", assignment.m_ShapeIndex );
735 m_out->Print(
" %s",
m_out->Quotew( assignment.m_Letter ).c_str() );
739 if( !assignment.m_Description.IsEmpty() )
740 m_out->Print(
"(descr %s)",
m_out->Quotew( assignment.m_Description ).c_str() );
753 m_out->Print(
"(general" );
768 m_out->Print(
"(layers" );
774 m_out->Print(
"(%d %s %s %s)",
789 bool print_type =
false;
803 m_out->Print(
"(%d %s %s %s)",
820 for(
const std::pair<const wxString, wxString>& prop : aBoard->
GetProperties() )
822 m_out->Print(
"(property %s %s)",
823 m_out->Quotew( prop.first ).c_str(),
824 m_out->Quotew( prop.second ).c_str() );
833 if( variantNames.empty() )
836 m_out->Print(
"(variants" );
838 for(
const wxString& variantName : variantNames )
840 m_out->Print(
"(variant (name %s)",
m_out->Quotew( variantName ).c_str() );
844 if( !description.IsEmpty() )
845 m_out->Print(
"(description %s)",
m_out->Quotew( description ).c_str() );
890 m_out->Print(
"(teardrops (best_length_ratio %s) (max_length %s) (best_width_ratio %s) "
899 m_out->Print(
"(filter_ratio %s)",
911 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_footprints( aBoard->
Footprints().begin(),
913 std::set<BOARD_ITEM*, BOARD::cmp_drawings> sorted_drawings( aBoard->
Drawings().begin(),
915 std::set<PCB_TRACK*, PCB_TRACK::cmp_tracks> sorted_tracks( aBoard->
Tracks().begin(),
917 std::set<PCB_POINT*, PCB_POINT::cmp_points> sorted_points( aBoard->
Points().begin(),
919 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_zones( aBoard->
Zones().begin(),
920 aBoard->
Zones().end() );
921 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_groups( aBoard->
Groups().begin(),
923 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_generators( aBoard->
Generators().begin(),
925 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_constraints( aBoard->
Constraints().begin(),
930 for(
BOARD_ITEM* footprint : sorted_footprints )
948 for(
auto zone : sorted_zones )
960 for(
BOARD_ITEM* constraint : sorted_constraints )
966 std::vector<NETINFO_ITEM*> nets;
967 PAD* pads[2] = {
nullptr,
nullptr };
971 auto cmp = [](
const wxString& a,
const wxString& b )
976 std::map<wxString, CHAIN_INFO,
decltype( cmp )> chains( cmp );
983 if( net->GetNetChain().IsEmpty() && !net->GetTerminalPad( 0 ) && !net->GetTerminalPad( 1 ) )
986 wxString chainName = net->GetNetChain();
988 if( chainName.IsEmpty() && ( net->GetTerminalPad( 0 ) || net->GetTerminalPad( 1 ) ) )
989 chainName = net->GetNetname();
991 CHAIN_INFO&
info = chains[chainName];
992 info.nets.push_back( net );
993 for(
int i = 0; i < 2; ++i )
995 if( net->GetTerminalPad( i ) && !
info.pads[i] )
996 info.pads[i] = net->GetTerminalPad( i );
1001 for(
const auto&
kv : chains )
1003 const CHAIN_INFO& si =
kv.second;
1004 const wxString& chainName =
kv.first;
1006 if( si.nets.size() > 1 || si.pads[0] || si.pads[1] || !chainName.IsEmpty() )
1012 m_out->Print(
"(net_chains" );
1013 for(
const auto&
kv : chains )
1015 const wxString&
name =
kv.first;
1016 const CHAIN_INFO& si =
kv.second;
1018 if( si.nets.size() == 1 && !si.pads[0] && !si.pads[1] &&
name.IsEmpty() )
1021 m_out->Print(
" (net_chain (name %s)",
m_out->Quotew(
name ).c_str() );
1022 m_out->Print(
" (members" );
1027 m_out->Print(
")" );
1029 for(
int i = 0; i < 2; ++i )
1032 m_out->Print(
" (terminal_pad %s)",
1033 m_out->Quotew( si.pads[i]->m_Uuid.AsString() ).c_str() );
1036 m_out->Print(
")" );
1038 m_out->Print(
")" );
1047 files_to_write.
AddFile( file.second );
1054 files_to_write.
AddFile( file.second );
1057 m_out->Print(
"(embedded_fonts %s)",
1060 if( !files_to_write.
IsEmpty() )
1076 m_out->Print(
"(dimension" );
1080 m_out->Print(
"(type orthogonal)" );
1082 m_out->Print(
"(type aligned)" );
1084 m_out->Print(
"(type leader)" );
1086 m_out->Print(
"(type center)" );
1088 m_out->Print(
"(type radial)" );
1090 wxFAIL_MSG( wxT(
"Cannot format unknown dimension type!" ) );
1099 m_out->Print(
"(pts (xy %s %s) (xy %s %s))",
1110 m_out->Print(
"(leader_length %s)",
1115 m_out->Print(
"(orientation %d)",
static_cast<int>(
ortho->GetOrientation() ) );
1119 m_out->Print(
"(format (prefix %s) (suffix %s) (units %d) (units_format %d) (precision %d)",
1128 m_out->Print(
"(override_value %s)",
1135 m_out->Print(
")" );
1138 m_out->Print(
"(style (thickness %s) (arrow_length %s) (text_position_mode %d)",
1143 if(
ortho || aligned )
1148 m_out->Print(
"(arrow_direction outward)" );
1151 m_out->Print(
"(arrow_direction inward)" );
1159 m_out->Print(
"(extension_height %s)",
1166 m_out->Print(
"(extension_offset %s)",
1172 m_out->Print(
")" );
1180 m_out->Print(
")" );
1187 std::string prefix = parentFP ?
"fp" :
"gr";
1192 m_out->Print(
"(%s_line (start %s) (end %s)",
1199 m_out->Print(
"(%s_rect (start %s) (end %s)", prefix.c_str(),
1209 m_out->Print(
"(%s_circle (center %s) (end %s)", prefix.c_str(),
1215 m_out->Print(
"(%s_arc (start %s) (mid %s) (end %s)", prefix.c_str(),
1227 m_out->Print(
"(%s_poly", prefix.c_str() );
1238 m_out->Print(
"(%s_curve (pts (xy %s) (xy %s) (xy %s) (xy %s))",
1247 m_out->Print(
"(%s_ellipse (center %s) (major_radius %s) (minor_radius %s) "
1248 "(rotation_angle %s)",
1257 m_out->Print(
"(%s_ellipse_arc (center %s) (major_radius %s) (minor_radius %s) "
1258 "(rotation_angle %s) (start_angle %s) (end_angle %s)",
1289 m_out->Print(
"(fill hatch)" );
1293 m_out->Print(
"(fill reverse_hatch)" );
1297 m_out->Print(
"(fill cross_hatch)" );
1322 m_out->Print(
"(solder_mask_margin %s)",
1331 m_out->Print(
")" );
1337 wxCHECK_RET( aBitmap !=
nullptr &&
m_out !=
nullptr,
"" );
1343 wxCHECK_RET(
image !=
nullptr,
"wxImage* is NULL" );
1345 m_out->Print(
"(image (at %s %s)",
1358 m_out->Print(
"%s", fmt::format(
"(opacity {:g})", refImage.
GetOpacity() ).c_str() );
1363 wxMemoryOutputStream ostream;
1370 m_out->Print(
")" );
1383 m_out->Print(
")" );
1389 m_out->Print(
"(target %s (at %s) (size %s)",
1390 ( aTarget->
GetShape() ) ?
"x" :
"plus",
1400 m_out->Print(
")" );
1410 m_out->Print(
"(grid_item %s (at %s)", polar ?
"polar" :
"xy",
1439 m_out->Print(
" (affects (cursor %s) (routing %s) (placement %s))",
1440 aff.
cursor ?
"yes" :
"no",
1449 m_out->Print(
")\n" );
1459 if( initial_comments )
1461 for(
unsigned i = 0; i < initial_comments->GetCount(); ++i )
1462 m_out->Print(
"%s\n",
TO_UTF8( (*initial_comments)[i] ) );
1475 m_out->Print(
"(footprint %s",
1480 m_out->Print(
"(footprint %s",
1503 m_out->Print(
"(transform (translate %s) (rotate %s) (scale %s %s))",
1524 m_out->Print(
"(property %s %s",
1525 m_out->Quotew( field->GetUntranslatedName() ).c_str(),
1526 m_out->Quotew( field->GetText() ).c_str() );
1530 m_out->Print(
")" );
1535 if( !compClass->IsEmpty() )
1537 m_out->Print(
"(component_classes" );
1540 m_out->Print(
"(class %s)",
m_out->Quotew( constituent->GetName() ).c_str() );
1542 m_out->Print(
")" );
1548 m_out->Print(
"(property ki_fp_filters %s)",
1564 m_out->Print(
"(units" );
1568 m_out->Print(
"(unit (name %s)",
m_out->Quotew( u.m_unitName ).c_str() );
1569 m_out->Print(
"(pins" );
1571 for(
const wxString& n : u.m_pins )
1572 m_out->Print(
" %s",
m_out->Quotew( n ).c_str() );
1574 m_out->Print(
")" );
1575 m_out->Print(
")" );
1578 m_out->Print(
")" );
1583 m_out->Print(
"(solder_mask_margin %s)",
1589 m_out->Print(
"(solder_paste_margin %s)",
1595 m_out->Print(
"(solder_paste_margin_ratio %s)",
1601 m_out->Print(
"(clearance %s)",
1607 m_out->Print(
"(zone_connect %d)",
1616 m_out->Print(
"(attr" );
1619 m_out->Print(
" smd" );
1622 m_out->Print(
" through_hole" );
1625 m_out->Print(
" board_only" );
1628 m_out->Print(
" exclude_from_pos_files" );
1631 m_out->Print(
" exclude_from_bom" );
1634 m_out->Print(
" exclude_from_sim" );
1637 m_out->Print(
" allow_missing_courtyard" );
1640 m_out->Print(
" dnp" );
1643 m_out->Print(
" allow_soldermask_bridges" );
1645 m_out->Print(
")" );
1651 m_out->Print(
"(stackup" );
1656 wxString canonicalName(
LSET::Name( layer ) );
1657 m_out->Print(
"(layer %s)",
m_out->Quotew( canonicalName ).c_str() );
1660 m_out->Print(
")" );
1665 m_out->Print(
"(private_layers" );
1669 wxString canonicalName(
LSET::Name( layer ) );
1670 m_out->Print(
" %s",
m_out->Quotew( canonicalName ).c_str() );
1673 m_out->Print(
")" );
1678 m_out->Print(
"(net_tie_pad_groups" );
1683 m_out->Print(
")" );
1693 m_out->Print(
"(jumper_pad_groups" );
1697 m_out->Print(
"(" );
1699 for(
const wxString& padName :
group.GetNames() )
1700 m_out->Print(
"%s ",
m_out->Quotew( padName ).c_str() );
1702 m_out->Print(
")" );
1705 m_out->Print(
")" );
1711 std::set<PAD*, FOOTPRINT::cmp_pads> sorted_pads( aFootprint->
Pads().begin(),
1712 aFootprint->
Pads().end() );
1713 std::set<BOARD_ITEM*, FOOTPRINT::cmp_drawings> sorted_drawings(
1716 std::set<PCB_POINT*, PCB_POINT::cmp_points> sorted_points(
1717 aFootprint->
Points().begin(),
1718 aFootprint->
Points().end() );
1719 std::set<ZONE*, FOOTPRINT::cmp_zones> sorted_zones( aFootprint->
Zones().begin(),
1720 aFootprint->
Zones().end() );
1721 std::set<BOARD_ITEM*, PCB_GROUP::ptr_cmp> sorted_groups( aFootprint->
Groups().begin(),
1722 aFootprint->
Groups().end() );
1723 std::set<BOARD_ITEM*, PCB_GROUP::ptr_cmp> sorted_constraints( aFootprint->
Constraints().begin(),
1735 for(
PAD*
pad : sorted_pads )
1747 for(
BOARD_ITEM* constraint : sorted_constraints )
1751 const bool baseDnp = aFootprint->
IsDNP();
1756 for(
const auto& [variantName, variant] : aFootprint->
GetVariants() )
1758 m_out->Print(
"(variant (name %s)",
m_out->Quotew( variantName ).c_str() );
1760 if( variant.GetDNP() != baseDnp )
1763 if( variant.GetExcludedFromBOM() != baseExcludedFromBOM )
1766 if( variant.GetExcludedFromSim() != baseExcludedFromSim )
1769 if( variant.GetExcludedFromPosFiles() != baseExcludedFromPosFiles )
1772 variant.GetExcludedFromPosFiles() );
1775 for(
const auto& [fieldName, fieldValue] : variant.GetFields() )
1778 const wxString baseValue = baseField ? baseField->
GetText() : wxString();
1780 if( fieldValue == baseValue )
1783 m_out->Print(
"(field (name %s) (value %s))",
1784 m_out->Quotew( fieldName ).c_str(),
1785 m_out->Quotew( fieldValue ).c_str() );
1788 m_out->Print(
")" );
1800 if( bodyItem->GetExtruded()->m_height <= 0 )
1804 m_out->Print(
"(model" );
1805 m_out->Print(
"(type extruded)" );
1812 m_out->Print(
"(layer pad_bbox)" );
1816 m_out->Print(
"(layer auto)" );
1819 static const char* matNames[] = {
"plastic",
"matte",
"metal",
"copper" };
1820 m_out->Print(
"(material %s)", matNames[
static_cast<int>( body->
m_material )] );
1831 m_out->Print(
"(color unspecified)" );
1843 m_out->Print(
")" );
1847 auto bs3D = aFootprint->
Models().begin();
1848 auto es3D = aFootprint->
Models().end();
1850 while( bs3D != es3D )
1852 if( !bs3D->m_Filename.IsEmpty() )
1854 m_out->Print(
"(model %s",
m_out->Quotew( bs3D->m_Filename ).c_str() );
1859 if( bs3D->m_Opacity != 1.0 )
1860 m_out->Print(
"%s", fmt::format(
"(opacity {:.4f})", bs3D->m_Opacity).c_str() );
1862 m_out->Print(
"(offset (xyz %s %s %s))",
1867 m_out->Print(
"(scale (xyz %s %s %s))",
1872 m_out->Print(
"(rotate (xyz %s %s %s))",
1877 m_out->Print(
")" );
1884 m_out->Print(
")" );
1903 if( !aEnumerateLayers )
1906 if( ( aLayerMask & cu_board_mask ) == cu_board_mask )
1908 output +=
' ' +
m_out->Quotew(
"*.Cu" );
1913 aLayerMask &= ~cu_all;
1915 else if( ( aLayerMask & cu_board_mask ) == fr_bk )
1918 output +=
' ' +
m_out->Quotew(
"F&B.Cu" );
1920 output +=
' ' +
m_out->Quotew(
"*.Cu" );
1922 aLayerMask &= ~fr_bk;
1925 if( ( aLayerMask & adhes ) == adhes )
1927 output +=
' ' +
m_out->Quotew(
"*.Adhes" );
1928 aLayerMask &= ~adhes;
1933 output +=
' ' +
m_out->Quotew(
"*.Paste" );
1937 if( ( aLayerMask & silks ) == silks )
1939 output +=
' ' +
m_out->Quotew(
"*.SilkS" );
1940 aLayerMask &= ~silks;
1943 if( ( aLayerMask & mask ) == mask )
1945 output +=
' ' +
m_out->Quotew(
"*.Mask" );
1946 aLayerMask &= ~mask;
1949 if( ( aLayerMask & crt_yd ) == crt_yd )
1951 output +=
' ' +
m_out->Quotew(
"*.CrtYd" );
1952 aLayerMask &= ~crt_yd;
1955 if( ( aLayerMask & fab ) == fab )
1957 output +=
' ' +
m_out->Quotew(
"*.Fab" );
1965 if( aLayerMask[layer] )
1969 m_out->Print(
"(layers %s)", output.c_str() );
1996 const char* type =
nullptr;
2010 const char*
property =
nullptr;
2028 const char* simElectricalType =
nullptr;
2034 default: simElectricalType =
nullptr;
break;
2037 m_out->Print(
"(pad %s %s %s",
2040 shapeName(
F_Cu ) );
2042 m_out->Print(
"(at %s %s)",
2059 bool forceShapeOffsetOutput =
false;
2064 if( aPad->
GetOffset( layer ) != shapeoffset )
2065 forceShapeOffsetOutput =
true;
2068 if( drill.
x > 0 || drill.
y > 0 || shapeoffset.
x != 0 || shapeoffset.
y != 0 || forceShapeOffsetOutput )
2070 m_out->Print(
"(drill" );
2073 m_out->Print(
" oval" );
2078 if( drill.
y > 0 && drill.
x != drill.
y )
2085 if( shapeoffset.
x != 0 || shapeoffset.
y != 0 || forceShapeOffsetOutput )
2088 m_out->Print(
")" );
2094 m_out->Print(
"(backdrill (size %s) (layers %s %s))",
2102 m_out->Print(
"(tertiary_drill (size %s) (layers %s %s))",
2108 auto formatPostMachining =
2114 m_out->Print(
"(%s %s",
2119 if( aProps.size > 0 )
2122 if( aProps.depth > 0 )
2125 if( aProps.angle > 0 )
2128 m_out->Print(
")" );
2136 m_out->Print(
"(property %s)", property );
2138 if( simElectricalType )
2139 m_out->Print(
"(sim_electrical_type %s)", simElectricalType );
2153 m_out->Print(
"(zone_layer_connections" );
2161 m_out->Print(
")" );
2166 auto formatCornerProperties =
2173 m_out->Print(
"(roundrect_rratio %s)",
2180 m_out->Print(
"(chamfer_ratio %s)",
2183 m_out->Print(
"(chamfer" );
2186 m_out->Print(
" top_left" );
2189 m_out->Print(
" top_right" );
2192 m_out->Print(
" bottom_left" );
2195 m_out->Print(
" bottom_right" );
2197 m_out->Print(
")" );
2204 formatCornerProperties(
F_Cu );
2223 m_out->Print(
"(die_length %s)",
2229 m_out->Print(
"(die_delay %s)",
2235 m_out->Print(
"(solder_mask_margin %s)",
2241 m_out->Print(
"(solder_paste_margin %s)",
2247 m_out->Print(
"(solder_paste_margin_ratio %s)",
2253 m_out->Print(
"(clearance %s)",
2259 m_out->Print(
"(zone_connect %d)",
2265 m_out->Print(
"(thermal_bridge_width %s)",
2271 m_out->Print(
"(thermal_bridge_angle %s)",
2277 m_out->Print(
"(thermal_gap %s)",
2292 auto formatPrimitives =
2295 m_out->Print(
"(primitives" );
2298 for(
const std::shared_ptr<PCB_SHAPE>& primitive : aPad->
GetPrimitives( aLayer ) )
2300 const SHAPE_T libShape = primitive->GetLibraryShape();
2305 if( primitive->IsProxyItem() )
2307 m_out->Print(
"(gr_vector (start %s) (end %s)",
2313 m_out->Print(
"(gr_line (start %s) (end %s)",
2320 if( primitive->IsProxyItem() )
2322 m_out->Print(
"(gr_bbox (start %s) (end %s)",
2328 m_out->Print(
"(gr_rect (start %s) (end %s)",
2332 if( primitive->GetCornerRadius() > 0 )
2334 m_out->Print(
" (radius %s)",
2341 m_out->Print(
"(gr_arc (start %s) (mid %s) (end %s)",
2348 m_out->Print(
"(gr_circle (center %s) (end %s)",
2356 m_out->Print(
"(gr_curve (pts (xy %s) (xy %s) (xy %s) (xy %s))",
2364 if( primitive->IsPolyShapeValid() )
2369 m_out->Print(
"(gr_poly" );
2378 if( !primitive->IsProxyItem() )
2388 m_out->Print(
")" );
2391 m_out->Print(
")" );
2396 m_out->Print(
"(options" );
2399 m_out->Print(
"(clearance convexhull)" );
2401 m_out->Print(
"(clearance outline)" );
2404 m_out->Print(
"(anchor %s)", anchorShape(
F_Cu ) );
2409 formatPrimitives(
F_Cu );
2418 m_out->Print( 0,
" (tenting " );
2423 m_out->Print( 0,
")" );
2429 auto formatPadLayer =
2434 m_out->Print(
"(shape %s)", shapeName( aLayer ) );
2443 shapeoffset = aPad->
GetOffset( aLayer );
2445 if( shapeoffset.
x != 0 || shapeoffset.
y != 0 )
2448 formatCornerProperties( aLayer );
2452 m_out->Print(
"(options" );
2455 m_out->Print(
"(clearance convexhull)" );
2457 m_out->Print(
"(clearance outline)" );
2460 m_out->Print(
"(anchor %s)", anchorShape( aLayer ) );
2462 m_out->Print(
")" );
2465 formatPrimitives( aLayer );
2479 if( layerSpokeAngle != defaultLayerAngle )
2481 m_out->Print(
"(thermal_bridge_angle %s)",
2485 if( padstack.
ThermalGap( aLayer ).has_value() )
2487 m_out->Print(
"(thermal_gap %s)",
2493 m_out->Print(
"(thermal_bridge_width %s)",
2497 if( padstack.
Clearance( aLayer ).has_value() )
2499 m_out->Print(
"(clearance %s)",
2505 m_out->Print(
"(zone_connect %d)",
2515 m_out->Print(
"(padstack (mode front_inner_back)" );
2517 m_out->Print(
"(layer \"Inner\"" );
2519 m_out->Print(
")" );
2520 m_out->Print(
"(layer \"B.Cu\"" );
2521 formatPadLayer(
B_Cu );
2522 m_out->Print(
")" );
2526 m_out->Print(
"(padstack (mode custom)" );
2540 formatPadLayer( layer );
2541 m_out->Print(
")" );
2545 m_out->Print(
")" );
2549 m_out->Print(
")" );
2555 wxCHECK_RET( aBarcode !=
nullptr &&
m_out !=
nullptr,
"" );
2557 m_out->Print(
"(barcode" );
2562 m_out->Print(
"(at %s %s)",
2568 m_out->Print(
"(size %s %s)",
2576 const char* typeStr =
"code39";
2587 m_out->Print(
"(type %s)", typeStr );
2592 const char* eccStr =
"L";
2601 m_out->Print(
"(ecc_level %s)", eccStr );
2616 m_out->Print(
")" );
2649 m_out->Print(
"(%s_text %s %s",
2658 m_out->Print(
"(at %s %s)",
2685 aText->EDA_TEXT::Format(
m_out, ctl_flags );
2694 m_out->Print(
")" );
2702 m_out->Print(
"(%s %s",
2704 : parentFP ?
"fp_text_box"
2735 m_out->Print(
"(margins %s %s %s %s)",
2742 m_out->Print(
"(span %d %d)", cell->GetColSpan(), cell->GetRowSpan() );
2759 aTextBox->EDA_TEXT::Format(
m_out, 0 );
2773 m_out->Print(
")" );
2783 m_out->Print(
"(border" );
2790 m_out->Print(
")" );
2792 m_out->Print(
"(separators" );
2799 m_out->Print(
")" );
2801 m_out->Print(
"(column_widths" );
2803 for(
int col = 0; col < aTable->
GetColCount(); ++col )
2806 m_out->Print(
")" );
2808 m_out->Print(
"(row_heights" );
2810 for(
int row = 0; row < aTable->
GetRowCount(); ++row )
2813 m_out->Print(
")" );
2815 m_out->Print(
"(cells" );
2820 m_out->Print(
")" );
2828 wxCHECK_RET( aMap !=
nullptr &&
m_out !=
nullptr,
"" );
2830 m_out->Print(
"(drill_map " );
2846 m_out->Print(
"(span all)" );
2850 m_out->Print(
"(span " );
2852 m_out->Print(
")" );
2859 m_out->Print(
")" );
2865 wxCHECK_RET( aTable !=
nullptr &&
m_out !=
nullptr,
"" );
2867 switch( aTable->
Type() )
2873 wxFAIL_MSG( wxT(
"Unhandled generated table type " ) + aTable->
GetClass() );
2898 m_out->Print(
"(column (id %s)", schema.
Token( col.m_Id ) );
2903 m_out->Print(
"(name %s)",
m_out->Quotew( col.m_Heading ).c_str() );
2908 if( col.m_Width > 0 )
2911 if( !col.m_Visible )
2914 m_out->Print(
")" );
2917 if( !aTable->
RowKeys().empty() )
2921 m_out->Print(
"(row_keys" );
2923 for(
const auto& [row, key] : aTable->
RowKeys() )
2924 m_out->Print(
"(key %d %s)", row,
m_out->Quotew( wxString::FromUTF8( key ) ).c_str() );
2926 m_out->Print(
")" );
2934 m_out->Print(
")" );
2940 switch( aTable->
Type() )
2950 m_out->Print(
"(filter" );
2957 m_out->Print(
")" );
2969 for(
const auto& [row, shapeIndex] : chart->
RowShapes() )
2970 m_out->Print(
"(shape %d %d)", row, shapeIndex );
2972 m_out->Print(
")" );
2986 wxCHECK_RET( aTable !=
nullptr &&
m_out !=
nullptr,
"" );
2988 m_out->Print(
"(table " );
2999 m_out->Print(
")" );
3005 wxArrayString memberIds;
3014 bool validateAgainstBoard =
m_board &&
m_board->IsItemIndexedById( aGroup );
3016 memberIds.Alloc( aGroup->
GetItems().size() );
3020 if( !validateAgainstBoard
3023 memberIds.Add( member->m_Uuid.AsString() );
3027 if( memberIds.empty() )
3042 m_out->Print(
"(members" );
3044 for(
const wxString& memberId : memberIds )
3045 m_out->Print(
" %s",
m_out->Quotew( memberId ).c_str() );
3047 m_out->Print(
")" );
3050 m_out->Print(
")" );
3056 const std::vector<CONSTRAINT_MEMBER>& members = aConstraint->
GetMembers();
3058 if( members.empty() )
3068 m_out->Print(
"(members" );
3075 m_out->Print(
"(member %s %s %d)",
m_out->Quotew( member.m_item.AsString() ).c_str(),
3080 m_out->Print(
"(member %s %s)",
m_out->Quotew( member.m_item.AsString() ).c_str(),
3085 m_out->Print(
")" );
3091 double value = *aConstraint->
GetValue();
3103 m_out->Print(
")" );
3119 m_out->Print(
"(generated" );
3123 m_out->Print(
"(type %s) (name %s) (layer %s)",
3131 for(
const auto& [key, value] : aGenerator->
GetProperties() )
3133 if( value.CheckType<
double>() || value.CheckType<
int>() || value.CheckType<
long>()
3134 || value.CheckType<
long long>() )
3138 if( !value.GetAs( &val ) )
3141 std::string buf = fmt::format(
"{:.10g}", val );
3144 m_out->Print(
"(%s %s)", key.c_str(), buf.c_str() );
3146 else if( value.CheckType<
bool>() )
3149 value.GetAs( &val );
3153 else if( value.CheckType<
VECTOR2I>() )
3156 value.GetAs( &val );
3158 m_out->Print(
"(%s (xy %s))",
3165 value.GetAs( &val );
3167 m_out->Print(
"(%s ", key.c_str() );
3169 m_out->Print(
")" );
3171 else if( value.CheckType<std::vector<VECTOR2I>>() )
3174 std::vector<VECTOR2I> val;
3175 value.GetAs( &val );
3177 m_out->Print(
"(%s (cells", key.c_str() );
3180 m_out->Print(
"(ij %d %d)", cell.x, cell.y );
3182 m_out->Print(
"))" );
3188 if( value.CheckType<wxString>() )
3190 value.GetAs( &val );
3192 else if( value.CheckType<std::string>() )
3195 value.GetAs( &str );
3197 val = wxString::FromUTF8( str );
3200 m_out->Print(
"(%s %s)", key.c_str(),
m_out->Quotew( val ).c_str() );
3204 std::vector<std::pair<wxString, const BOARD_ITEM*>> templateItems = aGenerator->
GetTemplateItems();
3206 if( !templateItems.empty() )
3208 m_out->Print(
"(templates" );
3210 for(
const auto& [
name, item] : templateItems )
3215 m_out->Print(
"(template (name %s)",
m_out->Quotew(
name ).c_str() );
3217 m_out->Print(
")" );
3220 m_out->Print(
")" );
3223 wxArrayString memberIds;
3226 memberIds.Add( member->m_Uuid.AsString() );
3230 m_out->Print(
"(members" );
3232 for(
const wxString& memberId : memberIds )
3233 m_out->Print(
" %s",
m_out->Quotew( memberId ).c_str() );
3235 m_out->Print(
")" );
3238 m_out->Print(
")" );
3249 const BOARD* board =
via->GetBoard();
3251 wxCHECK_RET( board !=
nullptr, wxT(
"Via has no parent." ) );
3253 m_out->Print(
"(via" );
3255 via->LayerPair( &layer1, &layer2 );
3257 switch(
via->GetViaType() )
3263 m_out->Print(
" blind " );
3267 m_out->Print(
" buried " );
3271 m_out->Print(
" micro " );
3278 m_out->Print(
"(at %s) (size %s)",
3292 if(
via->Padstack().SecondaryDrill().size.x > 0 &&
via->Padstack().SecondaryDrill().start !=
UNDEFINED_LAYER )
3294 m_out->Print(
"(backdrill (size %s) (layers %s %s))",
3300 if(
via->Padstack().TertiaryDrill().size.x > 0 &&
via->Padstack().TertiaryDrill().start !=
UNDEFINED_LAYER )
3302 m_out->Print(
"(tertiary_drill (size %s) (layers %s %s))",
3313 m_out->Print(
"(%s %s", aName,
3316 if( aProps.size > 0 )
3319 if( aProps.depth > 0 )
3322 if( aProps.angle > 0 )
3325 m_out->Print(
")" );
3328 formatPostMachining(
"front_post_machining",
via->Padstack().FrontPostMachining() );
3329 formatPostMachining(
"back_post_machining",
via->Padstack().BackPostMachining() );
3331 m_out->Print(
"(layers %s %s)",
3335 switch(
via->Padstack().UnconnectedLayerMode() )
3355 if(
via->IsLocked() )
3358 if(
via->GetIsFree() )
3361 if(
via->GetRemoveUnconnected() )
3363 m_out->Print(
"(zone_layer_connections" );
3371 m_out->Print(
")" );
3379 m_out->Print( 0,
" (tenting " );
3384 m_out->Print( 0,
")" );
3393 m_out->Print( 0,
" (covering " );
3398 m_out->Print( 0,
")" );
3404 m_out->Print( 0,
" (plugging " );
3409 m_out->Print( 0,
")" );
3417 m_out->Print(
"(padstack" );
3421 m_out->Print(
"(mode front_inner_back)" );
3423 m_out->Print(
"(layer \"Inner\"" );
3424 m_out->Print(
"(size %s)",
3426 m_out->Print(
")" );
3427 m_out->Print(
"(layer \"B.Cu\"" );
3428 m_out->Print(
"(size %s)",
3430 m_out->Print(
")" );
3434 m_out->Print(
"(mode custom)" );
3442 m_out->Print(
"(size %s)",
3444 m_out->Print(
")" );
3448 m_out->Print(
")" );
3460 m_out->Print(
"(arc (start %s) (mid %s) (end %s) (width %s)",
3468 m_out->Print(
"(segment (start %s) (end %s) (width %s)",
3486 m_out->Print(
"(solder_mask_margin %s)",
3496 m_out->Print(
")" );
3502 m_out->Print(
"(zone" );
3520 if( layers.count() > 1 )
3542 m_out->Print(
"(hatch %s %s)", hatch.c_str(),
3553 m_out->Print(
"(attr (teardrop (type %s)))",
3558 m_out->Print(
"(connect_pads" );
3567 m_out->Print(
" thru_hole_only" );
3571 m_out->Print(
" yes" );
3575 m_out->Print(
" no" );
3579 m_out->Print(
"(clearance %s)",
3582 m_out->Print(
")" );
3584 m_out->Print(
"(min_thickness %s)",
3590 m_out->Print(
"(keepout (tracks %s) (vias %s) (pads %s) (copperpour %s) (footprints %s))",
3598 m_out->Print(
"(placement" );
3632 m_out->Print(
")" );
3635 m_out->Print(
")" );
3638 m_out->Print(
"(fill" );
3642 m_out->Print(
" yes" );
3646 m_out->Print(
"(mode hatch)" );
3648 m_out->Print(
"(mode thieving)" );
3652 m_out->Print(
"(thermal_gap %s) (thermal_bridge_width %s)",
3662 m_out->Print(
"(smoothing chamfer)" );
3666 m_out->Print(
"(smoothing fillet)" );
3677 m_out->Print(
"(island_removal_mode %d)",
3682 m_out->Print(
"(island_area_min %s)",
3688 m_out->Print(
"(hatch_thickness %s) (hatch_gap %s) (hatch_orientation %s)",
3695 m_out->Print(
"(hatch_smoothing_level %d) (hatch_smoothing_value %s)",
3700 m_out->Print(
"(hatch_border_algorithm %s) (hatch_min_hole_area %s)",
3707 const char* patternStr =
"dots";
3714 default: patternStr =
"dots";
break;
3717 m_out->Print(
"(thieving (type %s) (size %s) (gap %s) (width %s) "
3718 "(stagger %s) (orientation %s))",
3723 thieving.
stagger ?
"yes" :
"no",
3727 m_out->Print(
")" );
3731 format( properties, 0, layer );
3740 if(
chain.PointCount() == 0 )
3743 m_out->Print(
"(polygon" );
3745 m_out->Print(
")" );
3754 for(
int ii = 0; ii < fv->OutlineCount(); ++ii )
3756 m_out->Print(
"(filled_polygon" );
3765 m_out->Print(
")" );
3770 m_out->Print(
")" );
3781 m_out->Print( aNestLevel,
"(property\n" );
3786 m_out->Print( aNestLevel,
"(hatch_position (xy %s))",
3790 m_out->Print( aNestLevel,
")\n" );
3795 PCB_IO( wxS(
"KiCad" ) ),
3797 m_ctl( aControlFlags )
3814 const std::map<std::string, UTF8>* aProperties,
PROJECT* aProject )
3818 unsigned lineCount = 0;
3841 const std::map<std::string, UTF8>* aProperties,
PROGRESS_REPORTER* aProgressReporter,
3842 unsigned aLineCount )
3844 init( aProperties );
3846 bool preserveDestinationStackup =
3850 preserveDestinationStackup, !aIsNewLoad );
3854 std::set<BOARD_ITEM*> itemsBefore;
3855 std::set<NETINFO_ITEM*> netsBefore;
3860 itemsBefore.insert( item );
3863 netsBefore.insert( net );
3866 auto revertPartialAppend = [&]()
3871 std::vector<BOARD_ITEM*> addedItems;
3875 if( !itemsBefore.contains( item ) )
3876 addedItems.push_back( item );
3887 std::vector<NETINFO_ITEM*> addedNets;
3891 if( !netsBefore.contains( net ) )
3892 addedNets.push_back( net );
3902 BOARD* board =
nullptr;
3906 board =
dynamic_cast<BOARD*
>( parser.
Parse() );
3910 revertPartialAppend();
3917 revertPartialAppend();
3926 revertPartialAppend();
3930 if( board != &aBoard )
3934 parser.CurLine(), parser.CurLineNumber(), parser.CurOffset() );
3967 const wxString& aLibPath,
bool aBestEfforts,
3968 const std::map<std::string, UTF8>* aProperties )
3970 wxDir dir( aLibPath );
3973 init( aProperties );
3979 if( !dir.IsOpened() )
3984 errorMsg = ioe.
What();
3990 for(
const auto& footprint :
m_cache->GetFootprints() )
3991 aFootprintNames.Add( footprint.first );
3993 if( !errorMsg.IsEmpty() && !aBestEfforts )
3999 const wxString& aFootprintName,
4000 const std::map<std::string, UTF8>* aProperties,
4001 bool checkModified )
4003 init( aProperties );
4014 auto it =
m_cache->GetFootprints().find( aFootprintName );
4016 if( it ==
m_cache->GetFootprints().end() )
4019 return it->second->GetFootprint().get();
4024 const wxString& aFootprintName,
4025 const std::map<std::string, UTF8>* aProperties )
4027 return getFootprint( aLibraryPath, aFootprintName, aProperties,
false );
4032 const wxString& aFootprintName,
4033 const std::map<std::string, UTF8>* aProperties )
4044 return footprintFile.Exists();
4049 wxString& aFootprintNameOut,
4050 const std::map<std::string, UTF8>* aProperties )
4061 if( footprints.empty() )
4064 auto it = footprints.begin();
4066 aFootprintNameOut = wxFileName( aFootprintPath ).GetName();
4068 std::unique_ptr<FOOTPRINT> retv;
4076 const wxString& aFootprintName,
bool aKeepUUID,
4077 const std::map<std::string, UTF8>* aProperties )
4086 std::unique_ptr<FOOTPRINT>
copy;
4093 copy->SetParent(
nullptr );
4102 const std::map<std::string, UTF8>* aProperties )
4104 init( aProperties );
4112 wxString libPath = aLibraryPath;
4113 wxString singleFileBaseName;
4114 bool saveSingleFile =
false;
4117 wxFileName asFile( aLibraryPath );
4121 saveSingleFile =
true;
4122 libPath = asFile.GetPath();
4123 singleFileBaseName = asFile.GetName();
4127 validateCache( libPath, !aProperties || !aProperties->contains(
"skip_cache_validation" ) );
4133 const wxString msg = wxString::Format(
_(
"Library '%s' does not exist.\n"
4134 "Would you like to create it?"),
4137 if( !
Pgm().IsGUI() || wxMessageBox( msg,
_(
"Library Not Found" ), wxYES_NO | wxICON_QUESTION ) != wxYES )
4150 wxString footprintName = saveSingleFile ? singleFileBaseName
4153 wxString fpName = saveSingleFile ? singleFileBaseName
4164 THROW_IO_ERRORF(
_(
"Footprint file name '%s' is not valid." ), fn.GetFullPath() );
4166 if( fn.FileExists() && !fn.IsFileWritable() )
4167 THROW_IO_ERRORF(
_(
"Insufficient permissions to delete '%s'." ), fn.GetFullPath() );
4169 wxString fullPath = fn.GetFullPath();
4170 wxString fullName = fn.GetFullName();
4171 auto it =
m_cache->GetFootprints().find( footprintName );
4173 if( it !=
m_cache->GetFootprints().end() )
4177 m_cache->GetFootprints().erase( footprintName );
4208 wxLogTrace(
traceKicadPcbPlugin, wxT(
"Creating s-expr footprint file '%s'." ), fullPath );
4209 m_cache->GetFootprints().insert( footprintName,
4217 const wxString& aFootprintName,
4218 const std::map<std::string, UTF8>* aProperties )
4220 init( aProperties );
4225 THROW_IO_ERRORF(
_(
"Library '%s' is read only." ), aLibraryPath.GetData() );
4227 m_cache->Remove( aFootprintName );
4248 const std::map<std::string, UTF8>* aProperties )
4250 if( wxDir::Exists( aLibraryPath ) )
4251 THROW_IO_ERRORF(
_(
"Cannot overwrite library path '%s'." ), aLibraryPath.GetData() );
4253 init( aProperties );
4262 const std::map<std::string, UTF8>* aProperties )
4265 fn.SetPath( aLibraryPath );
4268 if( !fn.DirExists() )
4271 if( !fn.IsDirWritable() )
4272 THROW_IO_ERRORF(
_(
"Insufficient permissions to delete folder '%s'." ), aLibraryPath.GetData() );
4274 wxDir dir( aLibraryPath );
4276 if( dir.HasSubDirs() )
4277 THROW_IO_ERRORF(
_(
"Library folder '%s' has unexpected sub-folders." ), aLibraryPath.GetData() );
4280 if( dir.HasFiles() )
4284 wxArrayString files;
4288 for( i = 0; i < files.GetCount(); i++ )
4296 aLibraryPath.GetData() );
4300 for( i = 0; i < files.GetCount(); i++ )
4301 wxRemoveFile( files[i] );
4305 aLibraryPath.GetData() );
4309 if( !wxRmdir( aLibraryPath ) )
4310 THROW_IO_ERRORF(
_(
"Footprint library '%s' cannot be deleted." ), aLibraryPath.GetData() );
4316 wxMilliSleep( 250L );
constexpr EDA_IU_SCALE pcbIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
wxString GetMajorMinorVersion()
Get only the major and minor version in a string major.minor.
bool SaveImageData(wxOutputStream &aOutStream) const
Write the bitmap data to aOutStream.
wxString GetNetname() const
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
TEARDROP_PARAMETERS & GetTeardropParams()
Container for design settings for a BOARD object.
std::map< PCB_LAYER_ID, ZONE_LAYER_PROPERTIES > m_ZoneLayerProperties
DRILL_SYMBOL_PROFILE & GetDrillSymbolProfile()
const VECTOR2I & GetGridOrigin() const
int GetBoardThickness() const
The full thickness of the board including copper and masks.
bool m_AllowSoldermaskBridgesInFPs
const VECTOR2I & GetAuxOrigin() const
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 bool IsKnockout() const
bool IsLocked() const override
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
FOOTPRINT * GetParentFootprint() const
VECTOR2I GetFPRelativePosition() const
Manage layers needed to make a physical board.
void FormatBoardStackup(OUTPUTFORMATTER *aFormatter, const BOARD *aBoard) const
Write the stackup info on board file.
Information pertinent to a Pcbnew printed circuit board.
const NETINFO_LIST & GetNetInfo() const
EMBEDDED_FILES * GetEmbeddedFiles() override
const std::vector< wxString > & GetVariantNames() const
const GENERATORS & Generators() const
const PCB_POINTS & Points() const
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 BOARD_ITEM_SET GetItemSet()
Collect every owned item (tracks, zones, generators, footprints, drawings, markers,...
const TRACKS & Tracks() const
const CONSTRAINTS & Constraints() const
Geometric constraints (#2329) owned by this board.
wxString GetVariantDescription(const wxString &aVariantName) 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.
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
BOARD_DESIGN_SETTINGS & GetDesignSettings()
const DRAWINGS & Drawings() const
A lightweight representation of a component class.
const std::vector< COMPONENT_CLASS * > & GetConstituentClasses() const
Fetches a vector of the constituent classes for this (effective) class.
The column set and formatting a new chart starts from.
static DRILL_CHART_TEMPLATE MakeDefault()
bool GetShowTotals() const
Grouping rules and symbol assignments, shared by reference so a chart and its map can never disagree ...
const wxString & GetName() const
int GetSymbolWidth() const
const std::map< std::string, DRILL_SYMBOL_ASSIGNMENT > & Assignments() const
bool GetFreezeAssignments() const
const std::set< DRILL_GROUP_KEY > & GroupKeys() const
DRILL_MARK_POLICY GetMarkPolicy() const
int GetSymbolSize() const
const LIB_ID & GetDesignBlockLibId() const
std::unordered_set< EDA_ITEM * > & GetItems()
bool HasDesignBlockLink() const
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
virtual void SetParentGroup(EDA_GROUP *aGroup)
virtual void SetParent(EDA_ITEM *aParent)
EDA_ANGLE GetAngle() const
const VECTOR2I & GetBezierC2() const
FILL_T GetFillMode() 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.
const LINE_ENDING & GetStartEnding() const
wxString SHAPE_T_asString() const
const VECTOR2I & GetBezierC1() const
const LINE_ENDING & GetEndEnding() const
int GetCornerRadius() const
bool IsPolyShapeValid() const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
virtual const wxString & GetText() const
Return the string associated with the text object.
bool IsKeepUpright() const
virtual bool IsVisible() const
KIFONT::FONT * GetFont() const
void SetAttributes(const EDA_TEXT &aSrc, bool aSetPosition=true)
Set the text attributes from another instance.
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(RESOLUTION_CONTEXT aContext, int aDepth=0) const
Return the string actually shown after processing of the base text.
virtual void Format(OUTPUTFORMATTER *aFormatter, int aControlBits) const
Output the object to aFormatter in s-expression form.
const TEXT_ATTRIBUTES & GetAttributes() const
virtual int GetTextThickness() const
void WriteEmbeddedFiles(OUTPUTFORMATTER &aOut, bool aWriteData) const
Output formatter for the embedded files.
void ClearEmbeddedFiles(bool aDeleteFiles=true)
void ClearEmbeddedFonts()
Remove all embedded fonts from the collection.
EMBEDDED_FILE * AddFile(const wxFileName &aName, bool aOverwrite)
Load a file from disk and adds it to the collection.
const std::map< wxString, std::shared_ptr< EMBEDDED_FILE > > & EmbeddedFileMap() const
Provide an iterable view of the file collection.
bool GetAreFontsEmbedded() const
EXTRUSION_MATERIAL m_material
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.
RAII class to set and restore the fontconfig reporter.
Helper class for creating a footprint library cache.
std::unique_ptr< FOOTPRINT > m_footprint
FP_CACHE_ENTRY(FOOTPRINT *aFootprint, const WX_FILENAME &aFileName)
const WX_FILENAME & GetFileName() const
std::unique_ptr< FOOTPRINT > & GetFootprint()
static long long GetTimestamp(const wxString &aLibPath)
Generate a timestamp representing all source files in the cache (including the parent directory).
boost::ptr_map< wxString, FP_CACHE_ENTRY > m_footprints
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.
void Save(FOOTPRINT *aFootprintFilter=nullptr)
Save the footprint cache or a single footprint from it to disk.
FP_CACHE(PCB_IO_KICAD_SEXPR *aOwner, const wxString &aLibraryPath)
boost::ptr_map< wxString, FP_CACHE_ENTRY > & GetFootprints()
void Remove(const wxString &aFootprintName)
The columns one generator (the drill chart, a stackup table, ...) can produce, and the units and prec...
const char * Token(int aId) const
The file token for a known id, or a stable placeholder for one the schema does not recognize,...
const GENERATED_TABLE_COLUMN_DEF * Find(int aId) const
GENERATED_TABLE_UNITS DefaultUnits() const
int DefaultPrecision() const
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()
Represents an (ordered) list of JUMPER_GROUP objects.
const std::vector< JUMPER_GROUP > & GetAll() const
Represents a group of jumper pins or pads, keyed by name.
APP_SETTINGS_BASE * KifaceSettings() const
virtual bool IsOutline() const
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual wxString GetClass() const =0
Return the class name.
wxString AsString() const
wxString AsString() const
LAYER_MAPPING_HANDLER m_layer_mapping_handler
Callback to get layer mapping.
A logical library item identifier and consists of various portions much like a URI.
const wxString GetUniStringLibItemName() const
Get strings for display messages in dialogs.
const UTF8 & GetLibItemName() const
virtual wxString GetFootprint() const
For items with footprint fields.
void Format(OUTPUTFORMATTER *aOut, const EDA_IU_SCALE &aIuScale, const char *aToken) const
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
static LOAD_INFO_REPORTER & GetInstance()
REPORTER & Report(const wxString &aMsg, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
LSET is a set of PCB_LAYER_IDs.
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
LSEQ CuStack() const
Return a sequence of copper layers in starting from the front/top and extending to the back/bottom.
LSEQ TechAndUserUIOrder() const
Return the technical and user layers in the order shown in layer widget.
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Handle the data for a net.
const wxString & GetNetname() const
A PADSTACK defines the characteristics of a single or multi-layer pad, in the IPC sense of the word.
std::optional< int > & Clearance(PCB_LAYER_ID aLayer=F_Cu)
MASK_LAYER_PROPS & FrontOuterLayers()
void ForEachUniqueLayer(const std::function< void(PCB_LAYER_ID)> &aMethod) const
Runs the given callable for each active unique copper layer in this padstack, meaning F_Cu for MODE::...
bool HasExplicitDefinitionForLayer(PCB_LAYER_ID aLayer) const
Check if the padstack has an explicit definition for the given layer.
std::optional< int > & ThermalSpokeWidth(PCB_LAYER_ID aLayer=F_Cu)
EDA_ANGLE DefaultThermalSpokeAngleForShape(PCB_LAYER_ID aLayer=F_Cu) const
VECTOR2I & Offset(PCB_LAYER_ID aLayer)
EDA_ANGLE ThermalSpokeAngle(PCB_LAYER_ID aLayer=F_Cu) const
POST_MACHINING_PROPS & FrontPostMachining()
std::optional< int > & ThermalGap(PCB_LAYER_ID aLayer=F_Cu)
DRILL_PROPS & TertiaryDrill()
const VECTOR2I & Size(PCB_LAYER_ID aLayer) const
@ NORMAL
Shape is the same on all layers.
@ FRONT_INNER_BACK
Up to three shapes can be defined (F_Cu, inner copper layers, B_Cu)
DRILL_PROPS & SecondaryDrill()
POST_MACHINING_PROPS & BackPostMachining()
MASK_LAYER_PROPS & BackOuterLayers()
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
PAD_ATTRIB GetAttribute() const
const wxString & GetPinFunction() const
const wxString & GetNumber() const
const VECTOR2I & GetDelta(PCB_LAYER_ID aLayer) const
EDA_ANGLE GetThermalSpokeAngle() const
VECTOR2I GetOffset(PCB_LAYER_ID aLayer) const
VECTOR2I GetDrillSize() const
double GetRoundRectRadiusRatio(PCB_LAYER_ID aLayer) const
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
bool GetKeepTopBottom() const
int GetPadToDieDelay() const
std::optional< int > GetLocalClearance() const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
const PADSTACK & Padstack() const
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
PAD_DRILL_SHAPE GetDrillShape() const
int GetChamferPositions(PCB_LAYER_ID aLayer) const
std::optional< int > GetLocalSolderPasteMargin() const
PAD_SIM_ELECTRICAL_TYPE GetSimElectricalType() const
std::optional< int > GetLocalSolderMaskMargin() const
double GetChamferRectRatio(PCB_LAYER_ID aLayer) const
std::optional< int > GetLocalThermalSpokeWidthOverride() const
ZONE_CONNECTION GetLocalZoneConnection() const
CUSTOM_SHAPE_ZONE_MODE GetCustomShapeInZoneOpt() const
int GetLocalThermalGapOverride(wxString *aSource) const
PAD_SHAPE GetAnchorPadShape(PCB_LAYER_ID aLayer) const
int GetPadToDieLength() const
void Format(OUTPUTFORMATTER *aFormatter) const
Output the page class to aFormatter in s-expression form.
FLIP_DIRECTION m_FlipDirection
A 3D body attached to a footprint (or, later, placed on a board).
const VECTOR2I & GetMid() const
const VECTOR2I & GetMargin() const
Get the barcode margin (in internal units).
VECTOR2I GetPosition() const override
Get the position (center) of the barcode in internal units.
bool IsKnockout() const override
int GetHeight() const
Get the barcode height (in internal units).
BARCODE_ECC_T GetErrorCorrection() const
EDA_ANGLE GetAngle() const
BARCODE_T GetKind() const
Returns the type of the barcode (QR, CODE_39, etc.).
int GetWidth() const
Get the barcode width (in internal units).
A geometric constraint between board items (issue #2329).
const std::vector< CONSTRAINT_MEMBER > & GetMembers() const
std::optional< double > GetValue() const
bool IsDriving() const
A driving constraint forces its value; a reference (non-driving) one only measures it.
PCB_CONSTRAINT_TYPE GetConstraintType() 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
DIM_ARROW_DIRECTION GetArrowDirection() const
virtual VECTOR2I GetEnd() const
bool GetSuppressZeroes() const
int GetExtensionOffset() const
virtual VECTOR2I GetStart() const
The dimension's origin is the first feature point for the dimension.
int GetArrowLength() const
bool GetOverrideTextEnabled() 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
A drill chart placed on the board, kept in step with the holes.
const std::map< int, int > & RowShapes() const
Curated shape index for each generated row, by table row.
bool GetShowTotals() const
DRILL_CHART_FILTER & Filter()
int GetSymbolColumn() const
Table column the symbol is drawn in, or -1 when the chart has no symbol column.
Turns on drill symbols at the holes, for one layer.
int GetSymbolSize() const
bool GetGuideCross() const
bool GetOutlineSlots() const
const DRILL_SPAN & GetSpan() const
const VECTOR2I & GetOffset() const
A table whose cell text is derived from the board and rebuilt whenever it goes stale.
std::vector< GENERATED_TABLE_COLUMN > AllColumns() const
Every column the table has been given, in order, with hidden ones marked by m_Visible.
const std::map< int, std::string > & RowKeys() const
What each generated row reports on, by table row.
virtual const GENERATED_TABLE_SCHEMA & Schema() const =0
GENERATED_TABLE_UNITS GetUnits() const
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
virtual std::vector< std::pair< wxString, const BOARD_ITEM * > > GetTemplateItems() const
Named template items used by the generator.
virtual const STRING_ANY_MAP GetProperties() const
virtual wxString GetGeneratorType() const
EDA_ANGLE GetPhiExtent() const
VECTOR2I GetSpacing() const
VECTOR2I GetExtent() const
unsigned GetAssignedPriority() const
unsigned GetTickInterval() const
VECTOR2I GetPosition() const override
int GetRadiusSpacing() const
EDA_ANGLE GetOrientation() const
EDA_ANGLE GetPhiSpacing() const
PCB_GRID_AFFECTS & Affects()
int GetRadiusExtent() const
PCB_GRID_TYPE GetGridItemType() const
A set of BOARD_ITEMs (i.e., without duplicates).
Read a Pcbnew s-expression formatted LINE_READER object and returns the appropriate BOARD_ITEM object...
const std::vector< wxString > & GetParseWarnings() const
Return any non-fatal parse warnings that occurred during parsing.
void SetLayerMappingHandler(LAYER_MAPPING_HANDLER aHandler)
Handler to remap an appended board's layers onto the destination board, used on mismatch.
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.
void ParseFootprintLib(boost::ptr_map< wxString, FP_CACHE_ENTRY, std::less< wxString >, boost::heap_clone_allocator, std::allocator< std::pair< const wxString, void * > > > &aFootprints)
Parse a footprint library file.
wxString GetRequiredVersion()
Return a string representing the version of KiCad required to open this file.
A PCB_IO derivation for saving and loading Pcbnew s-expression formatted files.
bool CanReadBoard(const wxString &aFileName) const override
void loadBoard(const wxString &aFileName, BOARD &aBoard, bool aIsNewLoad, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr) override
Parse aFileName into aBoard.
void formatProperties(const BOARD *aBoard) const
formats the Nets and Netclasses
void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Delete aFootprintName from the library at aLibraryPath.
void formatTableData(const PCB_TABLE *aTable) const
Geometry and cells with no identity, so an enclosing form owns uuid/layer/locked.
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.
void formatTeardropParameters(const TEARDROP_PARAMETERS &tdParams) const
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,...
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 i...
void CreateLibrary(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Create a new empty library at aLibraryPath empty.
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 formatDrillSymbolProfile(const BOARD_DESIGN_SETTINGS &aSettings) const
void formatPolyPts(const SHAPE_LINE_CHAIN &outline, const FOOTPRINT *aParentFP=nullptr) const
std::unique_ptr< 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.
FP_CACHE * m_cache
Footprint library cache.
void DoLoad(LINE_READER &aReader, BOARD &aBoard, bool aIsNewLoad, const std::map< std::string, UTF8 > *aProperties, PROGRESS_REPORTER *aProgressReporter, unsigned aLineCount)
void FormatFootprintLibFile(FOOTPRINT *aFootprint) const
Output aFootprint as a complete footprint library file.
void formatBoardLayers(const BOARD *aBoard) const
formats the board layer information
std::unique_ptr< 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...
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 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 format(const BOARD *aBoard) const
void formatLayers(LSET aLayerMask, bool aEnumerateLayers, bool aIsZone=false) const
void formatGeneral(const BOARD *aBoard) const
formats the General section of the file
void formatVariants(const BOARD *aBoard) const
formats the board variant registry
void ClearCachedFootprints(const wxString &aLibraryPath) override
Clear any cached footprint data for the given library path.
void formatSetup(const BOARD *aBoard) const
formats the board setup information
void formatGeneratedTableExtras(const PCB_GENERATED_TABLE *aTable) const
What only one kind of generated table carries, written after the shared settings.
void FormatBoardToFormatter(OUTPUTFORMATTER *aOut, BOARD *aBoard, const std::map< std::string, UTF8 > *aProperties=nullptr)
Serialize a BOARD to an OUTPUTFORMATTER without file I/O or Prettify.
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 Format(const BOARD_ITEM *aItem) const
Output aItem to aFormatter in s-expression format.
void formatLayer(PCB_LAYER_ID aLayer, bool aIsKnockout=false) const
void formatHeader(const BOARD *aBoard) const
writes everything that comes before the board_items, like settings and layers etc
const FOOTPRINT * getFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties, bool checkModified)
PCB_IO_KICAD_SEXPR(int aControlFlags=CTL_FOR_BOARD)
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
void formatInitialComments(const FOOTPRINT *aFootprint) const
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
virtual ~PCB_IO_KICAD_SEXPR()
void formatRenderCache(const EDA_TEXT *aText) const
LINE_READER * m_reader
no ownership
BOARD * m_board
The board BOARD being worked on, no ownership here.
virtual bool CanReadBoard(const wxString &aFileName) const
PCB_IO(const wxString &aName)
const std::map< std::string, UTF8 > * m_props
Properties passed via Save() or Load(), no ownership, may be NULL.
void Format(OUTPUTFORMATTER *aFormatter) const
A PCB_POINT is a 0-dimensional point that is used to mark a position on a PCB, or more usually a foot...
VECTOR2I GetLibraryPosition() 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()
EDA_ANGLE GetLibraryEllipseEndAngle() const
std::optional< int > GetLocalSolderMaskMargin() const
bool HasSolderMask() const
int GetLibraryEllipseMinorRadius() const
EDA_ANGLE GetLibraryEllipseStartAngle() const
int GetLibraryEllipseMajorRadius() const
EDA_ANGLE GetLibraryEllipseRotation() const
SHAPE_T GetLibraryShape() const
VECTOR2I GetLibraryEllipseCenter() const
VECTOR2I GetLibraryEnd() const
const SHAPE_POLY_SET & GetLibPoly() const
VECTOR2I GetLibraryStart() const
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
STROKE_PARAMS GetStroke() const override
VECTOR2I GetLibraryArcMid() const
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
int GetLibraryCornerRadius() const
bool StrokeHeaderSeparator() const
bool StrokeColumns() const
bool StrokeExternal() const
std::vector< PCB_TABLECELL * > GetCells() const
const STROKE_PARAMS & GetSeparatorsStroke() const
const STROKE_PARAMS & GetBorderStroke() const
int GetColWidth(int aCol) const
virtual wxString GetClass() const override
Return the class name.
int GetRowHeight(int aRow) const
VECTOR2I GetPosition() const override
bool IsBorderEnabled() const
Tests whether the border is disabled, as configured by the stroke.
int GetMarginBottom() const
EDA_ANGLE GetTextAngle() const override
int GetMarginLeft() const
int GetMarginRight() const
EDA_ANGLE GetTextAngle() const override
VECTOR2I GetTextPos() const override
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
virtual int GetWidth() const
A progress reporter interface for use in multi-threaded environments.
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...
EDA_ANGLE GetOrientation() const
double GetOpacity() const
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.
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.
int OutlineCount() const
Return the number of outlines in the set.
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Simple container to manage line stroke parameters.
void SetWidth(int aWidth)
void Format(OUTPUTFORMATTER *out, const EDA_IU_SCALE &aIuScale) const
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
double m_BestWidthRatio
The height of a teardrop as ratio between height and size of pad/via.
int m_TdMaxLen
max allowed length for teardrops in IU. <= 0 to disable
bool m_AllowUseTwoTracks
True to create teardrops using 2 track segments if the first in too small.
int m_TdMaxWidth
max allowed height for teardrops in IU. <= 0 to disable
double m_BestLengthRatio
The length of a teardrop as ratio between length and size of pad/via.
double m_WidthtoSizeFilterRatio
The ratio (H/D) between the via/pad size and the track width max value to create a teardrop 1....
bool m_TdOnPadsInZones
A filter to exclude pads inside zone fills.
bool m_Enabled
Flag to enable teardrops.
bool m_CurvedEdges
True if the teardrop should be curved.
virtual void Format(OUTPUTFORMATTER *aFormatter) const
Output the object to aFormatter in s-expression form.
const char * c_str() const
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
const THIEVING_SETTINGS & GetThievingSettings() const
bool GetDoNotAllowVias() const
const REPEAT_LAYOUT_OPTIONS & GetRepeatOptions() const
ZONE_LAYER_PROPERTIES & LayerProperties(PCB_LAYER_ID aLayer)
wxString GetPlacementAreaSource() const
std::shared_ptr< SHAPE_POLY_SET > GetFilledPolysList(PCB_LAYER_ID aLayer) const
bool GetDoNotAllowPads() const
PLACEMENT_SOURCE_T GetPlacementAreaSourceType() const
bool GetDoNotAllowTracks() 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_SETTINGS::CORNER_SMOOTHING GetCornerSmoothingType() const
ZONE_CONNECTION GetPadConnection() const
int GetHatchThickness() const
double GetHatchHoleMinArea() const
bool GetPlacementAreaEnabled() 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.
TEARDROP_TYPE GetTeardropAreaType() const
const KIID & GetLinkSet() const
The set of placement rule areas that share one layout, or niluuid when this one is not linked.
double GetHatchSmoothingValue() const
bool GetDoNotAllowZoneFills() const
int GetHatchSmoothingLevel() const
unsigned int GetCornerRadius() 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.
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_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.
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
const char * DrillGroupKeyToken(DRILL_GROUP_KEY aKey)
Stable file tokens, deliberately independent of enum ordering so a later insertion into the enum cann...
const char * DrillMarkModeToken(DRILL_MARK_MODE aMode)
const char * DrillMarkPolicyToken(DRILL_MARK_POLICY aPolicy)
DRILL_GROUP_KEY
Which properties split holes into separate chart rows and symbols.
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_45
@ FILLED_SHAPE
Fill with object color.
#define IGNORE_PARENT_GROUP
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
EDA_DATA_TYPE
The type of unit.
const char * GeneratedTableUnitsToken(GENERATED_TABLE_UNITS aUnits)
Stable file tokens, independent of enum ordering so inserting a value later cannot change what an exi...
const char * GeneratedTableAlignToken(GENERATED_TABLE_ALIGN aAlign)
void CollectFilesLoopSafe(const wxString &aRoot, wxArrayString &aFiles, const wxString &aFileSpec, int aFlags)
Recursively collect every file under aRoot, deduplicating subdirectories by their resolved path.
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
#define THROW_IO_ERRORF(msg,...)
#define THROW_IO_CANCELLED()
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
static const std::string KiCadFootprintFileExtension
const wxChar *const traceKicadPcbPlugin
Flag to enable KiCad PCB plugin debug output.
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
bool IsExternalCopperLayer(int aLayerId)
Test whether a layer is an external (F_Cu or B_Cu) copper layer.
PCB_LAYER_ID
A quick note on layer IDs:
Utilities for intentionally "leaking" memory at program exit.
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
KICOMMON_API std::string FormatAngle(const EDA_ANGLE &aAngle)
Convert aAngle from board units to a string appropriate for writing to file.
KICOMMON_API std::string FormatInternalUnits(const EDA_IU_SCALE &aIuScale, int aValue, EDA_DATA_TYPE aDataType=EDA_DATA_TYPE::DISTANCE)
Converts aValue from internal units to a string appropriate for writing to file.
constexpr char APPEND_PRESERVE_DESTINATION_STACKUP[]
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
@ NON_COMPONENT
Pad with no hole that does not connect to a physical component, but rather provides a connection poin...
@ SMD
Smd pad, appears on the solder paste layer (default)
@ PTH
Plated through hole pad.
@ CONN
Like smd, does not appear on the solder paste layer (default) Note: also has a special attribute in G...
@ FIDUCIAL_LOCAL
a fiducial (usually a smd) local to the parent footprint
@ FIDUCIAL_GLBL
a fiducial (usually a smd) for the full board
@ MECHANICAL
a pad used for mechanical support
@ PRESSFIT
a PTH with a hole diameter with tight tolerances for press fit pin
@ HEATSINK
a pad used as heat sink, usually in SMD footprints
@ NONE
no special fabrication property
@ TESTPOINT
a test point pad
@ CASTELLATED
a pad with a castellated through hole
@ BGA
Smd pad, used in BGA footprints.
@ REMOVE_EXCEPT_START_AND_END
BARCODE class definition.
bool ConstraintValueIsLength(PCB_CONSTRAINT_TYPE aType)
True if this type's value is a length in IU (serialized in mm); false for an angle in degrees.
const char * ConstraintTypeToken(PCB_CONSTRAINT_TYPE aType)
Stable file-format token for a constraint type (e.g. "parallel"). Used by serialization.
const char * ConstraintAnchorToken(CONSTRAINT_ANCHOR aAnchor)
Stable file-format token for a member anchor (e.g. "start").
@ VERTEX
An indexed rectangle corner or polygon outline vertex; pairs with CONSTRAINT_MEMBER::m_index.
Class to handle a set of BOARD_ITEMs.
static void formatDrillSpan(OUTPUTFORMATTER *aOut, const DRILL_SPAN &aSpan)
Layers plus the flags that distinguish a backdrill or non-plated span from the primary one that share...
bool isDefaultTeardropParameters(const TEARDROP_PARAMETERS &tdParams)
static VECTOR2I unbakeSize(const VECTOR2I &aSize, const FOOTPRINT *aParentFP)
std::string formatInternalUnits(const int aValue, const EDA_DATA_TYPE aDataType=EDA_DATA_TYPE::DISTANCE)
static int unbakeLinear(int aValue, const FOOTPRINT *aParentFP)
static VECTOR2I unbakeSizeUniform(const VECTOR2I &aSize, const FOOTPRINT *aParentFP)
#define SEXPR_FOOTPRINT_LIB_FILE_VERSION
#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...
#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.
std::string FormatDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 This function is intended in...
bool ReplaceIllegalFileNameChars(std::string &aName, int aReplaceChar)
Checks aName for illegal file name characters.
int ValueStringCompare(const wxString &strFWord, const wxString &strSWord)
Compare strings like the strcmp function but handle numbers and modifiers within the string text corr...
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
One participant in a constraint: a referenced board item plus the feature of that item that participa...
Which holes a chart reports on.
PCB_LAYER_ID DrillEndLayer() const
PCB_LAYER_ID DrillStartLayer() const
The column a schema knows how to build, independent of whether any particular table shows it.
GENERATED_TABLE_ALIGN m_Align
A column as a generated table actually carries it: what a row's cell in that column holds and how it ...
VECTOR2I size
Drill diameter (x == y) or slot dimensions (x != y)
std::optional< bool > is_capped
True if the drill hole should be capped.
std::optional< bool > is_filled
True if the drill hole should be filled completely.
std::optional< bool > has_covering
True if the pad on this side should have covering.
std::optional< bool > has_solder_mask
True if this outer layer has mask (is not tented)
std::optional< bool > has_plugging
True if the drill hole should be plugged on this side.
A filename or source description, a problem input line, a line number, a byte offset,...
bool routing
Used by the router as a local routing frame.
bool cursor
Replace the display grid for cursor snapping inside coverage.
bool placement
Used by edit/move tools for placement snap.
Options for copying a placement rule area onto the others linked to it.
bool m_connectedRoutingOnly
KIID m_anchor
This area's own anchor footprint, or niluuid for the area center.
bool m_includeLockedItems
Parameters that drive copper-thieving fill generation.
EDA_ORIENTATION orientation
std::optional< VECTOR2I > hatching_offset
const SHAPE_LINE_CHAIN chain
wxLogTrace helper definitions.
@ PCB_CONSTRAINT_T
a geometric constraint between board items
@ 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_DRILL_MAP_T
class PCB_DRILL_MAP, drill symbols drawn at the holes
@ 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_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
@ 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_GRID_ITEM_T
a subgrid placed on a board
@ 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_STACKUP_TABLE_T
class PCB_STACKUP_TABLE, a live stackup table derived from PCB_TABLE
@ PCB_POINT_T
class PCB_POINT, a 0-dimensional point
@ 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
@ PCB_DRILL_CHART_T
class PCB_DRILL_CHART, a live drill chart derived from PCB_TABLE
VECTOR2< int32_t > VECTOR2I
Definition of file extensions used in Kicad.
@ THERMAL
Use thermal relief for pads.
@ THT_THERMAL
Thermal relief only for THT pads.
@ NONE
Pads are not covered.
@ FULL
pads are covered by copper