28#include <wx/mstream.h>
33#include <fmt/format.h>
79 nets.insert( zone->GetNetCode() );
82 nets.insert( track->GetNetCode() );
97 for(
PAD*
pad : footprint->Pads() )
98 nets.insert(
pad->GetNetCode() );
103 for(
int netCode : nets )
119 if( stackup.
GetList().empty() )
122 aFormatter->
Print(
"(stackup" );
131 layer_name.Printf( wxT(
"dielectric %d" ), item->GetDielectricLayerId() );
133 layer_name =
LSET::Name( item->GetBrdLayerId() );
135 aFormatter->
Print(
"(layer %s (type %s)", aFormatter->
Quotew( layer_name ).c_str(),
136 aFormatter->
Quotew( item->GetTypeName() ).c_str() );
139 for(
int idx = 0; idx < item->GetSublayersCount(); idx++ )
142 aFormatter->
Print(
" addsublayer" );
144 if( item->IsColorEditable() &&
IsPrmSpecified( item->GetColor( idx ) ) )
146 aFormatter->
Print(
"(color %s)", aFormatter->
Quotew( item->GetColor( idx ) ).c_str() );
149 if( item->IsThicknessEditable() )
156 aFormatter->
Print(
" locked" );
158 aFormatter->
Print(
")" );
161 if( item->HasMaterialValue( idx ) )
163 aFormatter->
Print(
"(material %s)", aFormatter->
Quotew( item->GetMaterial( idx ) ).c_str() );
166 if( item->HasEpsilonRValue() && item->HasMaterialValue( idx ) )
167 aFormatter->
Print(
"(epsilon_r %g)", item->GetEpsilonR( idx ) );
169 if( item->HasLossTangentValue() && item->HasMaterialValue( idx ) )
175 aFormatter->
Print(
")" );
190 bool castellatedPads =
false;
194 for(
PAD*
pad : footprint->Pads() )
198 castellatedPads =
true;
203 if( castellatedPads )
207 if( castellatedPads )
213 aFormatter->
Print(
")" );
224 if(
m_board->GetAreFontsEmbedded() )
227 m_board->GetEmbeddedFiles()->ClearEmbeddedFonts();
235 m_out->Print(
"(kicad_pcb (version %d) (generator \"pcbnew\") (generator_version %s)",
251 switch( aItem->
Type() )
291 default: wxFAIL_MSG( wxT(
"Cannot format item " ) + aItem->
GetClass() );
323 m_out->Print(
"(layer %s %s)",
m_out->Quotew(
LSET::Name( aLayer ) ).c_str(), aIsKnockout ?
"knockout" :
"" );
329 m_out->Print(
"(pts" );
331 for(
int ii = 0; ii < aOutline.
PointCount(); ++ii )
362 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = aText->
GetRenderCache( aText->
GetFont(), resolvedText );
364 m_out->Print(
"(render_cache %s %s",
m_out->Quotew( resolvedText ).c_str(),
373 m_out->Print(
"(polygon" );
379 callback_gal.DrawGlyphs( *cache );
388 m_out->Print(
"(setup" );
410 m_out->Print(
"(pad_to_paste_clearance_ratio %s)",
424 m_out->Print(
"(tenting none)" );
453 m_out->Print(
"(general" );
468 m_out->Print(
"(layers" );
478 :
m_out->Quotew(
m_board->GetLayerName( layer ) ).c_str() );
491 :
m_out->Quotew(
m_board->GetLayerName( layer ) ).c_str() );
505 m_out->Print(
"(net %d %s)",
m_mapping.Translate( net->GetNetCode() ),
506 m_out->Quotew( net->GetNetname() ).c_str() );
513 for(
const std::pair<const wxString, wxString>& prop : aBoard->
GetProperties() )
515 m_out->Print(
"(property %s %s)",
m_out->Quotew( prop.first ).c_str(),
m_out->Quotew( prop.second ).c_str() );
553 m_out->Print(
"(teardrops (best_length_ratio %s) (max_length %s) (best_width_ratio %s) "
573 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_footprints( aBoard->
Footprints().begin(),
575 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_drawings( aBoard->
Drawings().begin(), aBoard->
Drawings().end() );
576 std::set<PCB_TRACK*, PCB_TRACK::cmp_tracks> sorted_tracks( aBoard->
Tracks().begin(), aBoard->
Tracks().end() );
577 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_zones( aBoard->
Zones().begin(), aBoard->
Zones().end() );
578 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_groups( aBoard->
Groups().begin(), aBoard->
Groups().end() );
579 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_generators( aBoard->
Generators().begin(),
584 for(
BOARD_ITEM* footprint : sorted_footprints )
598 for(
auto zone : sorted_zones )
615 files_to_write.
AddFile( file.second );
622 files_to_write.
AddFile( file.second );
627 if( !files_to_write.
IsEmpty() )
643 m_out->Print(
"(dimension" );
647 m_out->Print(
"(type orthogonal)" );
649 m_out->Print(
"(type aligned)" );
651 m_out->Print(
"(type leader)" );
653 m_out->Print(
"(type center)" );
655 m_out->Print(
"(type radial)" );
657 wxFAIL_MSG( wxT(
"Cannot format unknown dimension type!" ) );
680 m_out->Print(
"(orientation %d)",
static_cast<int>(
ortho->GetOrientation() ) );
684 m_out->Print(
"(format (prefix %s) (suffix %s) (units %d) (units_format %d) (precision %d)",
701 m_out->Print(
"(style (thickness %s) (arrow_length %s) (text_position_mode %d)",
706 if(
ortho || aligned )
712 m_out->Print(
"(arrow_direction inward)" );
745 std::string prefix = parentFP ?
"fp" :
"gr";
750 m_out->Print(
"(%s_line (start %s) (end %s)", prefix.c_str(),
756 m_out->Print(
"(%s_rect (start %s) (end %s)", prefix.c_str(),
762 m_out->Print(
"(%s_circle (center %s) (end %s)", prefix.c_str(),
768 m_out->Print(
"(%s_arc (start %s) (mid %s) (end %s)", prefix.c_str(),
780 m_out->Print(
"(%s_poly", prefix.c_str() );
785 wxFAIL_MSG( wxT(
"Cannot format invalid polygon." ) );
792 m_out->Print(
"(%s_curve (pts (xy %s) (xy %s) (xy %s) (xy %s))", prefix.c_str(),
822 m_out->Print(
"(solder_mask_margin %s)",
836 wxCHECK_RET( aBitmap !=
nullptr &&
m_out !=
nullptr,
"" );
842 wxCHECK_RET(
image !=
nullptr,
"wxImage* is NULL" );
855 wxMemoryOutputStream ostream;
867 m_out->Print(
"(target %s (at %s) (size %s)", ( aTarget->
GetShape() ) ?
"x" :
"plus",
886 if( initial_comments )
888 for(
unsigned i = 0; i < initial_comments->GetCount(); ++i )
889 m_out->Print(
"%s\n",
TO_UTF8( ( *initial_comments )[i] ) );
899 m_out->Print(
"(footprint %s",
939 m_out->Print(
"(property %s %s",
m_out->Quotew( field->GetUntranslatedName() ).c_str(),
940 m_out->Quotew( field->GetText() ).c_str() );
949 if( !compClass->IsEmpty() )
951 m_out->Print(
"(component_classes" );
954 m_out->Print(
"(class %s)",
m_out->Quotew( constituent->GetName() ).c_str() );
962 m_out->Print(
"(property ki_fp_filters %s)",
m_out->Quotew( aFootprint->
GetFilters() ).c_str() );
976 m_out->Print(
"(solder_mask_margin %s)",
982 m_out->Print(
"(solder_paste_margin %s)",
988 m_out->Print(
"(solder_paste_margin_ratio %s)",
1005 m_out->Print(
"(attr" );
1008 m_out->Print(
" smd" );
1011 m_out->Print(
" through_hole" );
1014 m_out->Print(
" board_only" );
1017 m_out->Print(
" exclude_from_pos_files" );
1020 m_out->Print(
" exclude_from_bom" );
1023 m_out->Print(
" allow_missing_courtyard" );
1026 m_out->Print(
" dnp" );
1029 m_out->Print(
" allow_soldermask_bridges" );
1031 m_out->Print(
")" );
1036 m_out->Print(
"(private_layers" );
1040 wxString canonicalName(
LSET::Name( layer ) );
1041 m_out->Print(
" %s",
m_out->Quotew( canonicalName ).c_str() );
1044 m_out->Print(
")" );
1049 m_out->Print(
"(net_tie_pad_groups" );
1054 m_out->Print(
")" );
1060 std::set<PAD*, FOOTPRINT::cmp_pads> sorted_pads( aFootprint->
Pads().begin(), aFootprint->
Pads().end() );
1061 std::set<BOARD_ITEM*, KICAD_FORMAT::LEGACY::FP_DRAWING_ORDER_V9> sorted_drawings(
1063 std::set<ZONE*, FOOTPRINT::cmp_zones> sorted_zones( aFootprint->
Zones().begin(), aFootprint->
Zones().end() );
1064 std::set<BOARD_ITEM*, PCB_GROUP::ptr_cmp> sorted_groups( aFootprint->
Groups().begin(), aFootprint->
Groups().end() );
1072 for(
PAD*
pad : sorted_pads )
1089 auto bs3D = aFootprint->
Models().begin();
1090 auto es3D = aFootprint->
Models().end();
1092 while( bs3D != es3D )
1094 if( !bs3D->m_Filename.IsEmpty() )
1096 m_out->Print(
"(model %s",
m_out->Quotew( bs3D->m_Filename ).c_str() );
1101 if( bs3D->m_Opacity != 1.0 )
1102 m_out->Print(
"(opacity %0.4f)", bs3D->m_Opacity );
1114 m_out->Print(
")" );
1120 m_out->Print(
")" );
1139 if( !aEnumerateLayers )
1142 if( ( aLayerMask & cu_board_mask ) == cu_board_mask )
1144 output +=
' ' +
m_out->Quotew(
"*.Cu" );
1149 aLayerMask &= ~cu_all;
1151 else if( ( aLayerMask & cu_board_mask ) == fr_bk )
1153 output +=
' ' +
m_out->Quotew(
"F&B.Cu" );
1154 aLayerMask &= ~fr_bk;
1157 if( ( aLayerMask & adhes ) == adhes )
1159 output +=
' ' +
m_out->Quotew(
"*.Adhes" );
1160 aLayerMask &= ~adhes;
1165 output +=
' ' +
m_out->Quotew(
"*.Paste" );
1169 if( ( aLayerMask & silks ) == silks )
1171 output +=
' ' +
m_out->Quotew(
"*.SilkS" );
1172 aLayerMask &= ~silks;
1175 if( ( aLayerMask & mask ) == mask )
1177 output +=
' ' +
m_out->Quotew(
"*.Mask" );
1178 aLayerMask &= ~mask;
1181 if( ( aLayerMask & crt_yd ) == crt_yd )
1183 output +=
' ' +
m_out->Quotew(
"*.CrtYd" );
1184 aLayerMask &= ~crt_yd;
1187 if( ( aLayerMask & fab ) == fab )
1189 output +=
' ' +
m_out->Quotew(
"*.Fab" );
1197 if( aLayerMask[layer] )
1201 m_out->Print(
"(layers %s)", output.c_str() );
1237 const char*
property =
nullptr;
1269 if( ( sz.
x > 0 ) || ( sz.
y > 0 ) || ( shapeoffset.
x != 0 ) || ( shapeoffset.
y != 0 ) )
1271 m_out->Print(
"(drill" );
1274 m_out->Print(
" oval" );
1279 if( sz.
y > 0 && sz.
x != sz.
y )
1286 if( shapeoffset.
x != 0 || shapeoffset.
y != 0 )
1291 m_out->Print(
")" );
1296 m_out->Print(
"(property %s)", property );
1310 m_out->Print(
"(zone_layer_connections" );
1318 m_out->Print(
")" );
1323 auto formatCornerProperties = [&](
PCB_LAYER_ID aLayer )
1328 m_out->Print(
"(roundrect_rratio %s)",
1337 m_out->Print(
"(chamfer" );
1340 m_out->Print(
" top_left" );
1343 m_out->Print(
" top_right" );
1346 m_out->Print(
" bottom_left" );
1349 m_out->Print(
" bottom_right" );
1351 m_out->Print(
")" );
1357 formatCornerProperties(
F_Cu );
1384 m_out->Print(
"(solder_mask_margin %s)",
1390 m_out->Print(
"(solder_paste_margin %s)",
1396 m_out->Print(
"(solder_paste_margin_ratio %s)",
1412 m_out->Print(
"(thermal_bridge_width %s)",
1421 defaultThermalSpokeAngle =
ANGLE_45;
1426 m_out->Print(
"(thermal_bridge_angle %s)",
1447 m_out->Print(
"(primitives" );
1450 for(
const std::shared_ptr<PCB_SHAPE>& primitive : aPad->
GetPrimitives( aLayer ) )
1454 bool emitted =
true;
1456 switch( primitive->GetShape() )
1459 if( primitive->IsProxyItem() )
1461 m_out->Print(
"(gr_vector (start %s) (end %s)",
1473 if( primitive->IsProxyItem() )
1486 m_out->Print(
"(gr_arc (start %s) (mid %s) (end %s)",
1498 m_out->Print(
"(gr_curve (pts (xy %s) (xy %s) (xy %s) (xy %s))",
1506 if( !primitive->IsPolyShapeValid() )
1515 m_out->Print(
"(gr_poly" );
1520 default: emitted =
false;
break;
1526 if( !primitive->IsProxyItem() )
1537 m_out->Print(
")" );
1540 m_out->Print(
")" );
1545 m_out->Print(
"(options" );
1548 m_out->Print(
"(clearance convexhull)" );
1550 m_out->Print(
"(clearance outline)" );
1553 m_out->Print(
"(anchor %s)", anchorShape(
F_Cu ) );
1555 m_out->Print(
")" );
1558 formatPrimitives(
F_Cu );
1572 m_out->Print(
"(shape %s)", shapeName( aLayer ) );
1580 shapeoffset = aPad->
GetOffset( aLayer );
1582 if( shapeoffset.
x != 0 || shapeoffset.
y != 0 )
1585 formatCornerProperties( aLayer );
1589 m_out->Print(
"(options" );
1592 m_out->Print(
"(anchor %s)", anchorShape( aLayer ) );
1594 m_out->Print(
")" );
1597 formatPrimitives( aLayer );
1611 if( layerSpokeAngle != defaultLayerAngle )
1616 if( padstack.
ThermalGap( aLayer ).has_value() )
1623 m_out->Print(
"(thermal_bridge_width %s)",
1627 if( padstack.
Clearance( aLayer ).has_value() )
1634 m_out->Print(
"(zone_connect %d)",
static_cast<int>( *padstack.
ZoneConnection( aLayer ) ) );
1643 m_out->Print(
"(padstack (mode front_inner_back)" );
1645 m_out->Print(
"(layer \"Inner\"" );
1647 m_out->Print(
")" );
1648 m_out->Print(
"(layer \"B.Cu\"" );
1649 formatPadLayer(
B_Cu );
1650 m_out->Print(
")" );
1654 m_out->Print(
"(padstack (mode custom)" );
1664 formatPadLayer( layer );
1665 m_out->Print(
")" );
1669 m_out->Print(
")" );
1672 m_out->Print(
")" );
1681 if( front.has_value() || back.has_value() )
1683 if( front.value_or(
false ) || back.value_or(
false ) )
1685 m_out->Print(
"(tenting %s %s)", front.value_or(
false ) ?
"front" :
"",
1686 back.value_or(
false ) ?
"back" :
"" );
1690 m_out->Print(
"(tenting none)" );
1723 m_out->Print(
"(%s_text %s %s", prefix.c_str(), type.c_str(),
m_out->Quotew( aText->
GetText() ).c_str() );
1754 m_out->Print(
")" );
1762 m_out->Print(
"(%s %s",
1764 : parentFP ?
"fp_text_box"
1794 m_out->Print(
"(span %d %d)", cell->GetColSpan(), cell->GetRowSpan() );
1823 m_out->Print(
")" );
1829 wxCHECK_RET( aTable !=
nullptr &&
m_out !=
nullptr,
"" );
1838 m_out->Print(
"(border" );
1845 m_out->Print(
")" );
1847 m_out->Print(
"(separators" );
1854 m_out->Print(
")" );
1856 m_out->Print(
"(column_widths" );
1858 for(
int col = 0; col < aTable->
GetColCount(); ++col )
1861 m_out->Print(
")" );
1863 m_out->Print(
"(row_heights" );
1865 for(
int row = 0; row < aTable->
GetRowCount(); ++row )
1868 m_out->Print(
")" );
1870 m_out->Print(
"(cells" );
1875 m_out->Print(
")" );
1876 m_out->Print(
")" );
1893 wxArrayString memberIds;
1896 memberIds.Add( member->m_Uuid.AsString() );
1900 m_out->Print(
"(members" );
1902 for(
const wxString& memberId : memberIds )
1903 m_out->Print(
" %s",
m_out->Quotew( memberId ).c_str() );
1905 m_out->Print(
")" );
1906 m_out->Print(
")" );
1918 m_out->Print(
"(generated" );
1931 if( value.CheckType<
double>() || value.CheckType<
int>() || value.CheckType<
long>()
1932 || value.CheckType<
long long>() )
1936 if( !value.GetAs( &val ) )
1939 std::string buf = fmt::format(
"{:.10g}", val );
1942 m_out->Print(
"(%s %s)", key.c_str(), buf.c_str() );
1944 else if( value.CheckType<
bool>() )
1947 value.GetAs( &val );
1951 else if( value.CheckType<
VECTOR2I>() )
1954 value.GetAs( &val );
1961 value.GetAs( &val );
1963 m_out->Print(
"(%s ", key.c_str() );
1965 m_out->Print(
")" );
1971 if( value.CheckType<wxString>() )
1973 value.GetAs( &val );
1975 else if( value.CheckType<std::string>() )
1978 value.GetAs( &str );
1980 val = wxString::FromUTF8( str );
1983 m_out->Print(
"(%s %s)", key.c_str(),
m_out->Quotew( val ).c_str() );
1987 wxArrayString memberIds;
1990 memberIds.Add( member->m_Uuid.AsString() );
1994 m_out->Print(
"(members" );
1996 for(
const wxString& memberId : memberIds )
1997 m_out->Print(
" %s",
m_out->Quotew( memberId ).c_str() );
1999 m_out->Print(
")" );
2000 m_out->Print(
")" );
2011 const BOARD* board =
via->GetBoard();
2013 wxCHECK_RET( board !=
nullptr, wxT(
"Via has no parent." ) );
2015 m_out->Print(
"(via" );
2017 via->LayerPair( &layer1, &layer2 );
2019 switch(
via->GetViaType() )
2029 default:
THROW_IO_ERROR( wxString::Format(
_(
"unknown via type %d" ),
via->GetViaType() ) );
2048 switch(
via->Padstack().UnconnectedLayerMode() )
2065 if(
via->IsLocked() )
2068 if(
via->GetIsFree() )
2071 if(
via->GetRemoveUnconnected() )
2073 m_out->Print(
"(zone_layer_connections" );
2081 m_out->Print(
")" );
2090 m_out->Print(
"(padstack" );
2094 m_out->Print(
"(mode front_inner_back)" );
2096 m_out->Print(
"(layer \"Inner\"" );
2098 m_out->Print(
")" );
2099 m_out->Print(
"(layer \"B.Cu\"" );
2101 m_out->Print(
")" );
2105 m_out->Print(
"(mode custom)" );
2114 m_out->Print(
")" );
2118 m_out->Print(
")" );
2130 m_out->Print(
"(arc (start %s) (mid %s) (end %s) (width %s)",
2153 m_out->Print(
"(solder_mask_margin %s)",
2161 m_out->Print(
")" );
2175 m_out->Quotew( has_no_net ? wxString( wxT(
"" ) ) : aZone->
GetNetname() ).c_str() );
2187 if( layers.count() > 1 )
2217 m_out->Print(
"(attr (teardrop (type %s)))",
2221 m_out->Print(
"(connect_pads" );
2238 m_out->Print(
")" );
2243 m_out->Print(
"(filled_areas_thickness no)" );
2248 m_out->Print(
"(keepout (tracks %s) (vias %s) (pads %s) (copperpour %s) (footprints %s))",
2256 m_out->Print(
"(placement" );
2270 THROW_IO_ERROR( wxT(
"Group placement linkage must be removed before writing KiCad 9." ) );
2277 m_out->Print(
")" );
2280 m_out->Print(
"(fill" );
2284 m_out->Print(
" yes" );
2288 m_out->Print(
"(mode hatch)" );
2290 m_out->Print(
"(thermal_gap %s) (thermal_bridge_width %s)",
2303 THROW_IO_ERROR( wxString::Format(
_(
"unknown zone corner smoothing type %d" ),
2313 m_out->Print(
"(island_removal_mode %d) (island_area_min %s)",
2320 m_out->Print(
"(hatch_thickness %s) (hatch_gap %s) (hatch_orientation %s)",
2331 m_out->Print(
"(hatch_border_algorithm %s) (hatch_min_hole_area %s)",
2336 m_out->Print(
")" );
2346 m_out->Print(
"(polygon" );
2348 m_out->Print(
")" );
2357 for(
int ii = 0; ii < fv->OutlineCount(); ++ii )
2359 m_out->Print(
"(filled_polygon" );
2363 m_out->Print(
"(island)" );
2368 m_out->Print(
")" );
2372 m_out->Print(
")" );
constexpr EDA_IU_SCALE pcbIUScale
bool IsPrmSpecified(const wxString &aPrmValue)
@ BS_ITEM_TYPE_DIELECTRIC
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.
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 one layer needed to make a physical board.
Manage layers needed to make a physical board.
const std::vector< BOARD_STACKUP_ITEM * > & GetList() const
bool m_HasDielectricConstrains
True if some layers have impedance controlled tracks or have specific constrains for micro-wave appli...
bool m_EdgePlating
True if the edge board is plated.
BS_EDGE_CONNECTOR_CONSTRAINTS m_EdgeConnectorConstraints
If the board has edge connector cards, some constrains can be specified in job file: BS_EDGE_CONNECTO...
wxString m_FinishType
The name of external copper finish.
Information pertinent to a Pcbnew printed circuit board.
EMBEDDED_FILES * GetEmbeddedFiles() override
const GENERATORS & Generators() const
const PAGE_INFO & GetPageSettings() const
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
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
bool LegacyTeardrops() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
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.
std::unordered_set< EDA_ITEM * > & GetItems()
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
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,...
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(RESOLUTION_CONTEXT aContext, int aDepth=0) const
Return the string actually shown after processing of the base text.
virtual int GetTextThickness() const
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
virtual bool IsOutline() const
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual wxString GetClass() const =0
Return the class name.
wxString AsString() const
const UTF8 & GetLibItemName() const
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.
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.
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)
std::map< int, int > m_map
std::vector< NETINFO_ITEM * > m_nets
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.
@ FRONT_INNER_BACK
Up to three shapes can be defined (F_Cu, inner copper layers, B_Cu)
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
VECTOR2I GetSize(PCB_LAYER_ID aLayer) 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
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
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
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
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
virtual wxString GetGeneratorType() const
A set of BOARD_ITEMs (i.e., without duplicates).
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 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
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
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
virtual int GetWidth() const
void formatHeader(const BOARD *aBoard) const
static constexpr int FORMAT_VERSION
void formatRenderCache(const EDA_TEXT *aText) const
void formatTenting(const PADSTACK &aPadstack) const
void Format(const BOARD_ITEM *aItem) const
void SaveFootprintFile(const wxString &aFileName, FOOTPRINT *aFootprint)
void formatLayer(PCB_LAYER_ID aLayer, bool aIsKnockout=false) const
void formatSetup(const BOARD *aBoard) const
void formatTeardropParameters(const TEARDROP_PARAMETERS &tdParams) const
void formatBoardLayers(const BOARD *aBoard) const
void formatProperties(const BOARD *aBoard) const
void SaveBoard(const wxString &aFileName, BOARD *aBoard)
void formatLayers(LSET aLayerMask, bool aEnumerateLayers) const
void formatNetInformation(const BOARD *aBoard) const
void format(const BOARD *aBoard) const
void formatPolyPts(const SHAPE_LINE_CHAIN &aOutline, const FOOTPRINT *aParentFP=nullptr) const
void formatGeneral(const BOARD *aBoard) const
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.
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.
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.
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
bool GetDoNotAllowVias() const
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
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
SHAPE_POLY_SET GetBoardOutline() 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
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.
@ 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.
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_45
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
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:
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
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.
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
@ 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
@ 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
Class to handle a set of BOARD_ITEMs.
bool isDefaultTeardropParameters(const TEARDROP_PARAMETERS &tdParams)
std::string formatInternalUnits(const int aValue, const EDA_DATA_TYPE aDataType=EDA_DATA_TYPE::DISTANCE)
#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.
#define UNDEFINED_DRILL_DIAMETER
static void formatBoardStackupV9(OUTPUTFORMATTER *aFormatter, const BOARD *aBoard)
static bool isDefaultTeardropParameters(const TEARDROP_PARAMETERS &tdParams)
static std::string formatInternalUnits(int aValue)
std::string FormatDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 This function is intended in...
std::optional< bool > has_solder_mask
True if this outer layer has mask (is not tented)
const SHAPE_LINE_CHAIN chain
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
@ 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