29 #include <boost/ptr_container/ptr_map.hpp> 58 using namespace PCB_KEYS_T;
83 m_filename( aFileName ),
84 m_footprint( aFootprint )
127 void Remove(
const wxString& aFootprintName );
134 static long long GetTimestamp(
const wxString& aLibPath );
152 bool IsPath(
const wxString& aPath )
const;
184 if( aFootprint && aFootprint != it->second->GetFootprint() )
189 wxString tempFileName =
191 wxFileName::CreateTempFileName( fn.
GetPath() );
212 wxMilliSleep( 250L );
214 if( !wxRenameFile( tempFileName, fn.
GetFullPath() ) )
216 wxString msg =
wxString::Format(
_(
"Cannot rename temporary file '%s' to '%s'" ),
240 if( !dir.IsOpened() )
254 if( dir.GetFirst( &fullName, fileSpec ) )
275 wxString fpName = fn.
GetName();
282 if( !cacheError.IsEmpty() )
283 cacheError += wxT(
"\n\n" );
285 cacheError += ioe.
What();
287 }
while( dir.GetNext( &fullName ) );
291 if( !cacheError.IsEmpty() )
299 FOOTPRINT_MAP::const_iterator it =
m_footprints.find( aFootprintName );
310 wxString fullPath = it->second->GetFileName().GetFullPath();
312 wxRemoveFile( fullPath );
344 if( sanityResult != wxEmptyString )
347 _(
"Please report this bug. Error validating group structure: %s" 348 "\n\nSave anyway?" ), sanityResult ),
349 _(
"Internal group data structure corrupt" ),
350 wxOK | wxCANCEL | wxICON_ERROR );
351 dlg.SetOKLabel(
_(
"Save Anyway" ) );
380 std::string input =
TO_UTF8( aClipboardSourceInput );
404 switch( aItem->
Type() )
407 format( static_cast<const BOARD*>( aItem ), aNestLevel );
414 format( static_cast<const PCB_DIMENSION_BASE*>( aItem ), aNestLevel );
418 format( static_cast<const PCB_SHAPE*>( aItem ), aNestLevel );
422 format( static_cast<const FP_SHAPE*>( aItem ), aNestLevel );
426 format( static_cast<const PCB_TARGET*>( aItem ), aNestLevel );
430 format( static_cast<const FOOTPRINT*>( aItem ), aNestLevel );
434 format( static_cast<const PAD*>( aItem ), aNestLevel );
438 format( static_cast<const PCB_TEXT*>( aItem ), aNestLevel );
442 format( static_cast<const FP_TEXT*>( aItem ), aNestLevel );
446 format( static_cast<const PCB_GROUP*>( aItem ), aNestLevel );
452 format( static_cast<const PCB_TRACK*>( aItem ), aNestLevel );
457 format( static_cast<const ZONE*>( aItem ), aNestLevel );
461 wxFAIL_MSG( wxT(
"Cannot format item " ) + aItem->
GetClass() );
487 m_out->
Print( aNestLevel+1,
"(pad_to_mask_clearance %s)\n",
491 m_out->
Print( aNestLevel+1,
"(solder_mask_min_width %s)\n",
495 m_out->
Print( aNestLevel+1,
"(pad_to_paste_clearance %s)\n",
499 m_out->
Print( aNestLevel+1,
"(pad_to_paste_clearance_ratio %s)\n",
504 if( origin != wxPoint( 0, 0 ) )
506 m_out->
Print( aNestLevel+1,
"(aux_axis_origin %s %s)\n",
513 if( origin != wxPoint( 0, 0 ) )
515 m_out->
Print( aNestLevel+1,
"(grid_origin %s %s)\n",
532 m_out->
Print( aNestLevel+1,
"(thickness %s)\n",
552 m_out->
Print( aNestLevel+1,
"(%d %s %s", layer,
599 m_out->
Print( aNestLevel+1,
"(%d %s user", layer,
630 for(
const std::pair<const wxString, wxString>& prop : aBoard->
GetProperties() )
632 m_out->
Print( aNestLevel,
"(property %s %s)\n",
662 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_footprints( aBoard->
Footprints().begin(),
664 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_drawings( aBoard->
Drawings().begin(),
666 std::set<PCB_TRACK*, PCB_TRACK::cmp_tracks> sorted_tracks( aBoard->
Tracks().begin(),
668 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_zones( aBoard->
Zones().begin(),
669 aBoard->
Zones().end() );
670 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_groups( aBoard->
Groups().begin(),
675 for(
BOARD_ITEM* footprint : sorted_footprints )
677 Format( footprint, aNestLevel );
683 Format( item, aNestLevel );
685 if( sorted_drawings.size() )
692 Format( track, aNestLevel );
694 if( sorted_tracks.size() )
698 for(
auto zone : sorted_zones )
699 Format( zone, aNestLevel );
709 const PCB_DIM_ALIGNED* aligned = dynamic_cast<const PCB_DIM_ALIGNED*>( aDimension );
711 const PCB_DIM_CENTER* center = dynamic_cast<const PCB_DIM_CENTER*>( aDimension );
712 const PCB_DIM_LEADER* leader = dynamic_cast<const PCB_DIM_LEADER*>( aDimension );
728 wxFAIL_MSG( wxT(
"Cannot format unknown dimension type!" ) );
736 m_out->
Print( aNestLevel+1,
"(pts (xy %s %s) (xy %s %s))\n",
750 m_out->
Print( aNestLevel+1,
"(orientation %d)\n",
751 static_cast<int>(
ortho->GetOrientation() ) );
756 Format( &aDimension->
Text(), aNestLevel + 1 );
766 m_out->
Print( 0,
" (units %d) (units_format %d) (precision %d)",
780 m_out->
Print( aNestLevel+1,
"(style (thickness %s) (arrow_length %s) (text_position_mode %d)",
813 m_out->
Print( aNestLevel,
"(gr_line%s (start %s) (end %s)",
820 m_out->
Print( aNestLevel,
"(gr_rect%s (start %s) (end %s)",
827 m_out->
Print( aNestLevel,
"(gr_circle%s (center %s) (end %s)",
834 m_out->
Print( aNestLevel,
"(gr_arc%s (start %s) (mid %s) (end %s)",
850 bool needNewline =
false;
851 int nestLevel = aNestLevel + 2;
854 for(
int ii = 0; ii < outline.
PointCount(); ++ii )
867 m_out->
Print( nestLevel,
"(arc (start %s) (mid %s) (end %s))",
898 wxFAIL_MSG( wxT(
"Cannot format invalid polygon." ) );
905 m_out->
Print( aNestLevel,
"(gr_curve%s (pts (xy %s) (xy %s) (xy %s) (xy %s))",
946 m_out->
Print( aNestLevel,
"(fp_line%s (start %s) (end %s)",
953 m_out->
Print( aNestLevel,
"(fp_rect%s (start %s) (end %s)",
960 m_out->
Print( aNestLevel,
"(fp_circle%s (center %s) (end %s)",
967 m_out->
Print( aNestLevel,
"(fp_arc%s (start %s) (mid %s) (end %s)",
983 bool need_newline =
false;
985 for(
int ii = 0; ii < outline.
PointCount(); ++ii )
993 need_newline =
false;
994 nestLevel = aNestLevel + 2;
1002 nestLevel ?
"" :
" ",
1004 need_newline =
true;
1008 auto& arc = outline.
Arc( ind );
1009 m_out->
Print( nestLevel,
"%s(arc (start %s) (mid %s) (end %s))",
1010 nestLevel ?
"" :
" ",
1014 need_newline =
true;
1032 wxFAIL_MSG( wxT(
"Cannot format invalid polygon." ) );
1038 m_out->
Print( aNestLevel,
"(fp_curve%s (pts (xy %s) (xy %s) (xy %s) (xy %s))",
1047 wxFAIL_MSG( wxT(
"PCB_PLUGIN::format not implemented for " ) + aFPShape->
SHAPE_T_asString() );
1074 m_out->
Print( aNestLevel,
"(target %s (at %s) (size %s)",
1075 ( aTarget->
GetShape() ) ?
"x" :
"plus",
1096 if( initial_comments )
1098 for(
unsigned i = 0; i < initial_comments->GetCount(); ++i )
1150 const std::map<wxString, wxString>& props = aFootprint->
GetProperties();
1152 for(
const std::pair<const wxString, wxString>& prop : props )
1154 m_out->
Print( aNestLevel+1,
"(property %s %s)\n",
1170 m_out->
Print( aNestLevel+1,
"(solder_mask_margin %s)\n",
1174 m_out->
Print( aNestLevel+1,
"(solder_paste_margin %s)\n",
1178 m_out->
Print( aNestLevel+1,
"(solder_paste_ratio %s)\n",
1182 m_out->
Print( aNestLevel+1,
"(clearance %s)\n",
1186 m_out->
Print( aNestLevel+1,
"(zone_connect %d)\n",
1190 m_out->
Print( aNestLevel+1,
"(thermal_width %s)\n",
1194 m_out->
Print( aNestLevel+1,
"(thermal_gap %s)\n",
1212 m_out->
Print( 0,
" exclude_from_pos_files" );
1223 std::set<PAD*, FOOTPRINT::cmp_pads> sorted_pads( aFootprint->
Pads().begin(),
1224 aFootprint->
Pads().end() );
1225 std::set<BOARD_ITEM*, FOOTPRINT::cmp_drawings> sorted_drawings(
1228 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_zones( aFootprint->
Zones().begin(),
1229 aFootprint->
Zones().end() );
1230 std::set<BOARD_ITEM*, PCB_GROUP::ptr_cmp> sorted_groups( aFootprint->
Groups().begin(),
1231 aFootprint->
Groups().end() );
1236 Format( gr, aNestLevel+1 );
1239 for(
PAD*
pad : sorted_pads )
1244 Format( zone, aNestLevel + 1 );
1251 auto bs3D = aFootprint->
Models().begin();
1252 auto es3D = aFootprint->
Models().end();
1254 while( bs3D != es3D )
1256 if( !bs3D->m_Filename.IsEmpty() )
1260 bs3D->m_Show ?
"" :
" hide" );
1262 if( bs3D->m_Opacity != 1.0 )
1263 m_out->
Print( aNestLevel+2,
"(opacity %0.4f)", bs3D->m_Opacity );
1265 m_out->
Print( aNestLevel+2,
"(offset (xyz %s %s %s))\n",
1270 m_out->
Print( aNestLevel+2,
"(scale (xyz %s %s %s))\n",
1275 m_out->
Print( aNestLevel+2,
"(rotate (xyz %s %s %s))\n",
1294 if( aNestLevel == 0 )
1297 output +=
"(layers";
1308 LSET cu_mask = cu_all;
1312 if( ( aLayerMask & cu_mask ) == cu_mask )
1315 aLayerMask &= ~cu_all;
1317 else if( ( aLayerMask & cu_mask ) == fr_bk )
1319 output +=
" F&B.Cu";
1320 aLayerMask &= ~fr_bk;
1323 if( ( aLayerMask & adhes ) == adhes )
1325 output +=
" *.Adhes";
1326 aLayerMask &= ~adhes;
1331 output +=
" *.Paste";
1332 aLayerMask &= ~
paste;
1335 if( ( aLayerMask & silks ) == silks )
1337 output +=
" *.SilkS";
1338 aLayerMask &= ~silks;
1341 if( ( aLayerMask & mask ) == mask )
1343 output +=
" *.Mask";
1344 aLayerMask &= ~mask;
1347 if( ( aLayerMask & crt_yd ) == crt_yd )
1349 output +=
" *.CrtYd";
1350 aLayerMask &= ~crt_yd;
1353 if( ( aLayerMask & fab ) == fab )
1364 if( aLayerMask[layer] )
1372 m_out->
Print( aNestLevel,
"%s)", output.c_str() );
1408 const char*
property =
nullptr;
1442 if( (aPad->
GetDelta().GetWidth()) != 0 || (aPad->
GetDelta().GetHeight() != 0 ) )
1446 wxPoint shapeoffset = aPad->
GetOffset();
1448 if( (sz.GetWidth() > 0) || (sz.GetHeight() > 0) ||
1449 (shapeoffset.x != 0) || (shapeoffset.y != 0) )
1456 if( sz.GetWidth() > 0 )
1459 if( sz.GetHeight() > 0 && sz.GetWidth() != sz.GetHeight() )
1462 if( (shapeoffset.x != 0) || (shapeoffset.y != 0) )
1470 m_out->
Print( 0,
" (property %s)", property );
1478 m_out->
Print( 0,
" (remove_unused_layers)" );
1497 m_out->
Print( aNestLevel+1,
"(chamfer_ratio %s)",
1532 StrPrintf( &output,
" (pinfunction %s)",
1551 StrPrintf( &output,
" (solder_mask_margin %s)",
1557 StrPrintf( &output,
" (solder_paste_margin %s)",
1563 StrPrintf( &output,
" (solder_paste_margin_ratio %s)",
1575 StrPrintf( &output,
" (zone_connect %d)",
1581 StrPrintf( &output,
" (thermal_width %s)",
1587 StrPrintf( &output,
" (thermal_gap %s)",
1594 m_out->
Print( aNestLevel+1,
"%s", output.c_str()+1 );
1603 m_out->
Print( 0,
" (clearance convexhull)" );
1604 #if 1 // Set to 1 to output the default option 1623 int nested_level = aNestLevel+2;
1626 for(
const std::shared_ptr<PCB_SHAPE>& primitive : aPad->
GetPrimitives() )
1630 switch( primitive->GetShape() )
1633 m_out->
Print( nested_level,
"(gr_line (start %s) (end %s)",
1639 m_out->
Print( nested_level,
"(gr_rect (start %s) (end %s)",
1645 m_out->
Print( aNestLevel,
"(gr_arc (start %s) (mid %s) (end %s)",
1652 m_out->
Print( nested_level,
"(gr_circle (center %s) (end %s)",
1658 m_out->
Print( nested_level,
"(gr_curve (pts (xy %s) (xy %s) (xy %s) (xy %s))",
1666 if( primitive->IsPolyShapeValid() )
1671 m_out->
Print( nested_level,
"(gr_poly (pts" );
1673 bool need_newline =
false;
1675 for(
int ii = 0; ii < outline.
PointCount(); ++ii )
1683 need_newline =
false;
1684 nested_level = aNestLevel + 4;
1692 nested_level ?
"" :
" ",
1694 need_newline =
true;
1699 m_out->
Print( nested_level,
"%s(arc (start %s) (mid %s) (end %s))",
1700 nested_level ?
"" :
" ",
1704 need_newline =
true;
1729 if( primitive->IsFilled() )
1747 m_out->
Print( aNestLevel,
"(gr_text %s (at %s",
1775 m_out->
Print( aNestLevel,
"(group %s%s (id %s)\n",
1777 aGroup->
IsLocked() ?
" locked" :
"",
1780 m_out->
Print( aNestLevel + 1,
"(members\n" );
1782 wxArrayString memberIds;
1785 memberIds.Add( member->m_Uuid.AsString() );
1789 for(
const wxString& memberId : memberIds )
1810 m_out->
Print( aNestLevel,
"(fp_text %s%s %s (at %s",
1868 const PCB_VIA*
via = static_cast<const PCB_VIA*>( aTrack );
1871 wxCHECK_RET( board !=
nullptr, wxT(
"Via " ) +
1876 via->LayerPair( &layer1, &layer2 );
1878 switch(
via->GetViaType() )
1895 if(
via->IsLocked() )
1916 if(
via->GetRemoveUnconnected() )
1918 m_out->
Print( 0,
" (remove_unused_layers)" );
1920 if(
via->GetKeepTopBottom() )
1924 if(
via->GetIsFree() )
1929 const PCB_ARC* arc = static_cast<const PCB_ARC*>( aTrack );
1932 m_out->
Print( aNestLevel,
"(arc%s (start %s) (mid %s) (end %s) (width %s)",
1945 m_out->
Print( aNestLevel,
"(segment%s (start %s) (end %s) (width %s)",
1969 m_out->
Print( aNestLevel,
"(zone%s (net %d) (net_name %s)",
2000 m_out->
Print( 0,
" (hatch %s %s)\n", hatch.c_str(),
2006 m_out->
Print( aNestLevel+1,
"(connect_pads" );
2030 m_out->
Print( aNestLevel+1,
"(min_thickness %s)",
2036 m_out->
Print( 0,
" (filled_areas_thickness no)" );
2043 "(keepout (tracks %s) (vias %s) (pads %s ) (copperpour %s) " 2044 "(footprints %s))\n",
2062 m_out->
Print( 0,
" (thermal_gap %s) (thermal_bridge_width %s)",
2093 m_out->
Print( 0,
" (island_removal_mode %d) (island_area_min %s)",
2101 m_out->
Print( aNestLevel+2,
"(hatch_thickness %s) (hatch_gap %s) (hatch_orientation %s)",
2109 m_out->
Print( aNestLevel+2,
"(hatch_smoothing_level %d) (hatch_smoothing_value %s)",
2115 m_out->
Print( aNestLevel+2,
"(hatch_border_algorithm %s) (hatch_min_hole_area %s)",
2126 for(
auto& chain : poly )
2128 m_out->
Print( aNestLevel + 1,
"(polygon\n" );
2131 bool need_newline =
true;
2133 for(
int ii = 0; ii < chain.PointCount(); ++ii )
2140 need_newline =
false;
2141 nestLevel = aNestLevel + 3;
2144 int ind = chain.ArcIndex( ii );
2149 nestLevel ?
"" :
" ",
2151 need_newline =
true;
2155 auto& arc = chain.Arc( ind );
2156 m_out->
Print( nestLevel,
"%s(arc (start %s) (mid %s) (end %s))",
2157 nestLevel ?
"" :
" ",
2161 need_newline =
true;
2166 }
while( ii < chain.PointCount() && chain.ArcIndex( ii ) == ind );
2188 m_out->
Print( aNestLevel + 1,
"(filled_polygon\n" );
2189 m_out->
Print( aNestLevel + 2,
"(layer %s)\n",
2193 m_out->
Print( aNestLevel + 2,
"(island)\n" );
2199 bool need_newline =
true;
2201 for(
int jj = 0; jj < chain.
PointCount(); ++jj )
2208 need_newline =
false;
2209 nestLevel = aNestLevel + 3;
2217 nestLevel ?
"" :
" ",
2219 need_newline =
true;
2223 auto& arc = chain.
Arc( ind );
2224 m_out->
Print( nestLevel,
"%s(arc (start %s) (mid %s) (end %s))",
2225 nestLevel ?
"" :
" ",
2229 need_newline =
true;
2248 const std::vector<SEG>& segs = aZone->
FillSegments( layer );
2252 m_out->
Print( aNestLevel + 1,
"(fill_segments\n" );
2253 m_out->
Print( aNestLevel + 2,
"(layer %s)\n",
2256 for(
const SEG& seg : segs )
2258 m_out->
Print( aNestLevel + 2,
"(pts (xy %s) (xy %s))\n",
2273 m_ctl( aControlFlags ),
2295 unsigned lineCount = 0;
2297 if( aProgressReporter )
2310 BOARD* board =
DoLoad( reader, aAppendToMe, aProperties, aProgressReporter, lineCount );
2323 init( aProperties );
2380 bool aBestEfforts,
const PROPERTIES* aProperties )
2383 wxDir dir( aLibPath );
2386 init( aProperties );
2394 errorMsg = ioe.
What();
2401 aFootprintNames.Add( footprint.first );
2403 if( !errorMsg.IsEmpty() && !aBestEfforts )
2409 const wxString& aFootprintName,
2411 bool checkModified )
2415 init( aProperties );
2427 FOOTPRINT_MAP::const_iterator it = footprints.find( aFootprintName );
2429 if( it == footprints.end() )
2432 return it->second->GetFootprint();
2437 const wxString& aFootprintName,
2440 return getFootprint( aLibraryPath, aFootprintName, aProperties,
false );
2456 return footprintFile.Exists();
2461 const wxString& aFootprintName,
2472 copy = static_cast<FOOTPRINT*>( footprint->
Clone() );
2476 copy->SetParent(
nullptr );
2489 init( aProperties );
2502 "Would you like to create it?"),
2505 if( wxMessageBox( msg,
_(
"Library Not Found"), wxYES_NO | wxICON_QUESTION ) != wxYES )
2513 wxString msg =
wxString::Format(
_(
"Library '%s' is read only." ), aLibraryPath );
2532 fn.GetFullPath() ) );
2535 if( fn.FileExists() && !fn.IsFileWritable() )
2538 fn.GetFullPath() ) );
2541 wxString fullPath = fn.GetFullPath();
2542 wxString fullName = fn.GetFullName();
2543 FOOTPRINT_MAP::const_iterator it = footprints.find( footprintName );
2545 if( it != footprints.end() )
2548 footprints.erase( footprintName );
2549 wxRemoveFile( fullPath );
2553 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( aFootprint->
Clone() );
2571 wxLogTrace(
traceKicadPcbPlugin, wxT(
"Creating s-expr footprint file '%s'." ), fullPath );
2572 footprints.insert( footprintName,
2583 init( aProperties );
2590 aLibraryPath.GetData() ) );
2606 if( wxDir::Exists( aLibraryPath ) )
2609 aLibraryPath.GetData() ) );
2614 init( aProperties );
2625 fn.SetPath( aLibraryPath );
2628 if( !fn.DirExists() )
2631 if( !fn.IsDirWritable() )
2634 aLibraryPath.GetData() ) );
2637 wxDir dir( aLibraryPath );
2639 if( dir.HasSubDirs() )
2642 aLibraryPath.GetData() ) );
2646 if( dir.HasFiles() )
2650 wxArrayString files;
2652 wxDir::GetAllFiles( aLibraryPath, &files );
2654 for( i = 0; i < files.GetCount(); i++ )
2663 aLibraryPath.GetData() ) );
2667 for( i = 0; i < files.GetCount(); i++ )
2668 wxRemoveFile( files[i] );
2672 aLibraryPath.GetData() );
2676 if( !wxRmdir( aLibraryPath ) )
2679 aLibraryPath.GetData() ) );
2686 wxMilliSleep( 250L );
void SetProgressReporter(PROGRESS_REPORTER *aProgressReporter, const LINE_READER *aLineReader, unsigned aLineCount)
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
bool GetKeepTextAligned() const
std::vector< SHAPE_LINE_CHAIN > POLYGON
< represents a single polygon outline with holes.
FOOTPRINT_MAP & GetFootprints()
int GetNumCorners(void) const
Access to m_Poly parameters.
const FOOTPRINT * GetEnumeratedFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=nullptr) override
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.
DIM_UNITS_FORMAT GetUnitsFormat() const
int GetLocalSolderMaskMargin() const
const SHAPE_ARC & Arc(size_t aArc) const
#define SEXPR_BOARD_FILE_VERSION
Current s-expression file format version. 2 was the last legacy format version.
LSEQ CuStack() const
Return a sequence of copper layers in starting from the front/top and extending to the back/bottom.
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
const UTF8 & GetLibItemName() const
char * ReadLine() override
Read a line of text into the buffer and increments the line number counter.
const PAGE_INFO & GetPageSettings() const
bool IsModified()
Return true if the cache is not up-to-date.
bool m_CompactSave
Save files in compact display mode When is is not specified, points are written one per line.
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
const PCB_PLOT_PARAMS & GetPlotOptions() const
class PCB_DIM_LEADER, a leader dimension (graphic item)
int OutlineCount() const
Return the number of vertices in a given outline/hole.
virtual void Report(const wxString &aMessage)=0
Display aMessage in the progress bar dialog.
void formatSetup(const BOARD *aBoard, int aNestLevel=0) const
formats the board setup information
class FP_TEXT, text in a footprint
bool GetDoNotAllowFootprints() const
Container for project specific data.
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
int GetLocalSolderPasteMargin() const
double GetRoundRectRadiusRatio() const
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
int GetHatchThickness() const
#define CTL_OMIT_PATH
Omit component sheet time stamp (useless in library)
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
const wxPoint & GetEnd() const
unsigned GetPriority() const
Manage layers needed to make a physical board.
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Implementation of conversion functions that require both schematic and board internal units.
This file is part of the common library.
bool IsKeepUpright() const
void Save(FOOTPRINT *aFootprint=nullptr)
Save the footprint cache or a single footprint from it to disk.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
const wxPoint & GetStart() const
Return the starting point of the graphic.
class PCB_GROUP, a set of BOARD_ITEMs
const std::string KiCadFootprintFileExtension
bool IsFootprintLibWritable(const wxString &aLibraryPath) override
Return true if the library at aLibraryPath is writable.
PAD_PROP GetProperty() const
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static constexpr double IU_PER_MM
Mock up a conversion function.
GROUPS & Groups()
The groups must maintain the following invariants.
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...
A progress reporter interface for use in multi-threaded environments.
int GetBorderHatchPitch() const
HatchBorder related methods.
int GetExtensionOffset() const
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControl=0) const
class PCB_DIM_CENTER, a center point marking (graphic item)
SHAPE_POLY_SET * Outline()
bool GetDoNotAllowVias() const
virtual void Save(const wxString &aFileName, BOARD *aBoard, const PROPERTIES *aProperties=nullptr) override
Write aBoard to a storage file in a format that this PLUGIN implementation knows about or it can be u...
Like smd, does not appear on the solder paste layer (default)
Smd pad, appears on the solder paste layer (default)
const WX_FILENAME & GetFileName() const
void init(const PROPERTIES *aProperties)
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
double GetHatchSmoothingValue() const
bool IsLocked() const override
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
double GetTextAngle() const
class PCB_TEXT, text on a layer
class PCB_ARC, an arc track segment on a copper layer
void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=nullptr) override
Delete aFootprintName from the library at aLibraryPath.
int GetBoardThickness() const
const wxPoint & GetStart0() const
int LAYER_NUM
This can be replaced with int and removed.
A PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
wxString GetNetname() const
wxString AsString() const
class FP_SHAPE, a footprint edge
bool GetOverrideTextEnabled() const
class PAD, a pad in a footprint
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
#define CTL_OMIT_FOOTPRINT_VERSION
Omit the version string from the (footprint)
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
A logical library item identifier and consists of various portions much like a URI.
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the page class to aFormatter in s-expression form.
void SetFullName(const wxString &aFileNameAndExtension)
#define CTL_OMIT_TSTAMPS
Omit component time stamp (useless in library)
const wxPoint & GetGridOrigin()
bool IsPolyShapeValid() const
A name/value tuple with unique names and optional values.
virtual bool IsLocked() const
int PointCount() const
Return the number of points (vertices) in this line chain.
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
int GetThermalGap() const
FOOTPRINT_MAP m_footprints
std::unordered_set< BOARD_ITEM * > & GetItems()
std::unique_ptr< FOOTPRINT > m_footprint
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
bool GetKeepTopBottom() const
An orthogonal dimension is like an aligned dimension, but the extension lines are locked to the X or ...
BOARD_ITEM * Parse(const wxString &aClipboardSourceInput)
ZONE_FILL_MODE GetFillMode() const
virtual void SetParent(EDA_ITEM *aParent)
class PCB_TRACK, a track segment (segment on a copper layer)
This file contains miscellaneous commonly used macros and functions.
void format(const BOARD *aBoard, int aNestLevel=0) const
static const char * ShowType(LAYER_T aType)
Convert a LAYER_T enum to a string representation of the layer type.
DIM_UNITS_MODE GetUnitsMode() const
For better understanding of the points that make a dimension:
void SetBoard(const BOARD *aBoard)
Set a BOARD object that is used to prepare the net code map.
long long m_cache_timestamp
a pad used as heat sink, usually in SMD footprints
int GetThermalReliefGap() const
int StrPrintf(std::string *result, const char *format,...)
This is like sprintf() but the output is appended to a std::string instead of to a character array.
wxPoint GetPosition() const override
ssize_t ArcIndex(size_t aSegment) const
Return the arc index for the given segment index.
void Rewind()
Rewind the file and resets the line number back to zero.
const wxPoint & GetBezierC1() const
wxPoint GetArcMid0() const
#define CTL_OMIT_LIBNAME
Omit lib alias when saving (used for.
wxString GetPrefix() const
const std::map< wxString, wxString > & GetProperties() const
ZONE_CONNECTION GetZoneConnection() const
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
double GetHatchHoleMinArea() const
BOARD * DoLoad(LINE_READER &aReader, BOARD *aAppendToMe, const PROPERTIES *aProperties, PROGRESS_REPORTER *aProgressReporter, unsigned aLineCount)
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
DIM_TEXT_FRAME GetTextFrame() const
virtual const wxPoint & GetStart() const
The dimension's origin is the first feature point for the dimension.
bool GetDoNotAllowPads() const
const wxPoint & GetOffset() const
void Remove(const wxString &aFootprintName)
const wxSize & GetDrillSize() const
like PAD_PTH, but not plated
std::string FormatAngle(double aAngle)
Function FormatAngle converts aAngle from board units to a string appropriate for writing to file.
BOARD_STACKUP & GetStackupDescriptor()
A LINE_READER that reads from an open file.
const wxPoint & GetEnd() const
Return the ending point of the graphic.
wxString GetRequiredVersion()
Return a string representing the version of KiCad required to open this file.
bool GetDoNotAllowCopperPour() const
int GetExtensionHeight() const
LSET is a set of PCB_LAYER_IDs.
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
pads are covered by copper
int GetThermalSpokeWidth() const
void SetBoard(BOARD *aBoard)
int GetArrowLength() const
int GetMinThickness() const
double GetOrientation() const
Return the rotation angle of the pad in a variety of units (the basic call returns tenths of degrees)...
virtual const wxString What() const
A composite of Problem() and Where()
bool FootprintExists(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=nullptr) override
Check for the existence of a footprint.
int GetHatchSmoothingLevel() const
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
wxString GetSuffix() const
TEXT_TYPE GetType() const
bool IsPath(const wxString &aPath) const
Check if aPath is the same as the current cache path.
std::vector< SEG > & FillSegments(PCB_LAYER_ID aLayer)
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
int GetLocalClearance(wxString *aSource) const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
virtual bool IsVisible() const
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
void formatHeader(const BOARD *aBoard, int aNestLevel=0) const
writes everything that comes before the board_items, like settings and layers etc
bool GetSuppressZeroes() const
const VECTOR2I & GetP0() const
FOOTPRINTS & Footprints()
const wxSize & GetSize() const
#define UNDEFINED_DRILL_DIAMETER
Mark the center of a circle or arc with a cross shape.
Smd pad, used in BGA footprints.
bool GetDoNotAllowTracks() const
static void ResolvePossibleSymlinks(wxFileName &aFilename)
const wxPoint & GetBezierC2() const
Definition of file extensions used in Kicad.
#define CTL_OMIT_INITIAL_COMMENTS
omit FOOTPRINT initial comments
const VECTOR2I & GetArcMid() const
const wxChar *const traceKicadPcbPlugin
Flag to enable GEDA PCB plugin debug output.
const wxString & GetNumber() const
#define UNIMPLEMENTED_FOR(type)
const wxString & GetPinType() const
PAD_SHAPE GetShape() const
a fiducial (usually a smd) local to the parent footprint
long long TimestampDir(const wxString &aDirPath, const wxString &aFilespec)
A copy of ConvertFileTimeToWx() because wxWidgets left it as a static function private to src/common/...
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
wxLogTrace helper definitions.
virtual void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the object to aFormatter in s-expression form.
Handle a list of polygons defining a copper zone.
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
class ZONE, a copper pour area
void SetFileName(const wxString &aFileName)
ZONE_BORDER_DISPLAY_STYLE GetHatchStyle() const
const PROPERTIES * m_props
passed via Save() or Load(), no ownership, may be NULL.
bool FootprintLibDelete(const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr) override
Delete an existing footprint library and returns true, or if library does not exist returns false,...
wxString SHAPE_T_asString() const
Helper class for creating a footprint library cache.
int GetLocalClearance(wxString *aSource) const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
BOARD * m_board
which BOARD, no ownership here
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
SHAPE_POLY_SET & GetPolyShape()
void FormatBoardStackup(OUTPUTFORMATTER *aFormatter, const BOARD *aBoard, int aNestLevel) const
Write the stackup info on board file.
void Format(const BOARD_ITEM *aItem, int aNestLevel=0) const
Output aItem to aFormatter in s-expression format.
LINE_READER * SetLineReader(LINE_READER *aReader)
Set aLineReader into the parser, and returns the previous one, if any.
Thermal relief only for THT pads.
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
void FootprintSave(const wxString &aLibraryPath, const FOOTPRINT *aFootprint, const PROPERTIES *aProperties=nullptr) override
Write aFootprint to an existing library located at aLibraryPath.
class PCB_TARGET, a target (graphic item)
double GetLocalSolderPasteMarginRatio() const
class FOOTPRINT, a footprint
BOARD * Load(const wxString &aFileName, BOARD *aAppendToMe, const PROPERTIES *aProperties=nullptr, PROJECT *aProject=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr) override
Load information from some input file format that this PLUGIN implementation knows about into either ...
const wxSize & GetDelta() const
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
const wxPoint & GetPos0() const
double GetHatchOrientation() const
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Return the type of the copper layer given by aLayer.
Use thermal relief for pads.
unsigned int GetCornerRadius() const
const wxPoint & GetPos0() const
wxString GetFullPath() const
int GetHatchBorderAlgorithm() const
#define CTL_OMIT_AT
Omit position and rotation.
const ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
Handle the data for a net.
bool IsTooRecent()
Return whether a version number, if any was parsed, was too recent.
A filename or source description, a problem input line, a line number, a byte offset,...
void formatGeneral(const BOARD *aBoard, int aNestLevel=0) const
formats the General section of the file
PCB_PLUGIN(int aControlFlags=CTL_FOR_BOARD)
CUST_PAD_SHAPE_IN_ZONE GetCustomShapeInZoneOpt() const
virtual wxString GetClass() const =0
Return the class name.
TITLE_BLOCK & GetTitleBlock()
A wrapper around a wxFileName which is much more performant with a subset of the API.
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const PROPERTIES *aProperties=nullptr) override
Return a list of footprint names contained within the library at aLibraryPath.
a fiducial (usually a smd) for the full board
double GetChamferRectRatio() const
const wxPoint & GetAuxOrigin()
PAD_DRILL_SHAPE_T GetDrillShape() const
no special fabrication property
Information pertinent to a Pcbnew printed circuit board.
bool IsIsland(PCB_LAYER_ID aLayer, int aPolyIdx) const
Check if a given filled polygon is an insulated island.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
PCB_LAYER_ID
A quick note on layer IDs:
PAD_ATTRIB GetAttribute() const
void formatBoardLayers(const BOARD *aBoard, int aNestLevel=0) const
formats the board layer information
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
std::map< wxString, FOOTPRINT * > FOOTPRINT_MAP
void SetOutputFormatter(OUTPUTFORMATTER *aFormatter)
T NormalizeAnglePos(T Angle)
Normalize angle to be in the 0.0 .. 360.0 range: angle is in 1/10 degrees.
wxString AsString() const
void formatProperties(const BOARD *aBoard, int aNestLevel=0) const
formats the Nets and Netclasses
class ZONE, managed by a footprint
wxPoint GetArcMid() const
void FootprintLibCreate(const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr) override
Create a new empty footprint library at aLibraryPath empty.
const wxPoint & GetEnd0() const
LINE_READER * m_reader
no ownership here.
std::string Double2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 We want to avoid scientific ...
FP_CACHE(PCB_PLUGIN *aOwner, const wxString &aLibraryPath)
void formatNetInformation(const BOARD *aBoard, int aNestLevel=0) const
formats the Nets and Netclasses
int GetChamferPositions() const
const wxPoint & GetTextPos() const
wxString GroupsSanityCheck(bool repair=false)
Consistency check of internal m_groups structure.
A leader is a dimension-like object pointing to a specific point.
const wxPoint & GetBezierC2_0() const
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
a pad with a castellated through hole
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
class PCB_VIA, a via (like a track segment on a copper layer)
virtual const wxPoint & GetEnd() const
Pcbnew s-expression file format parser definition.
long long int GetMinIslandArea() const
int GetThermalReliefSpokeWidth() const
void formatLayer(const BOARD_ITEM *aItem) const
POLYGON & Polygon(int aIndex)
const FOOTPRINT * GetFootprint() const
boost::ptr_map< wxString, FP_CACHE_ITEM > FOOTPRINT_MAP
FP_CACHE * m_cache
Footprint library cache.
ZONE_CONNECTION GetPadConnection(PAD *aPad, wxString *aSource=nullptr) const
double m_SolderPasteMarginRatio
DIM_TEXT_POSITION GetTextPositionMode() const
T NormalizeAngle360Min(T Angle)
Normalize angle to be > -360.0 and < 360.0 Angle equal to -360 or +360 are set to 0.
wxString GetZoneName() const
BOARD_ITEM_CONTAINER * GetParent() const
FP_CACHE_ITEM(FOOTPRINT *aFootprint, const WX_FILENAME &aFileName)
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const PROPERTIES *aProperties=nullptr) override
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PL...
class PCB_SHAPE, a segment not on copper layers
int GetPadToDieLength() const
static long long GetTimestamp(const wxString &aLibPath)
Generate a timestamp representing all source files in the cache (including the parent directory).
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
const wxString & GetPinFunction() const
static const int UNCONNECTED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
#define THROW_IO_ERROR(msg)
bool GetRemoveUnconnected() const
const wxPoint & GetMid() const
void formatLayers(LSET aLayerMask, int aNestLevel=0) const
virtual const wxString & GetText() const
Return the string associated with the text object.
#define CTL_OMIT_PAD_NETS
Omit pads net names (useless in library)
const VECTOR2I & GetP1() const
int GetLineThickness() const
int GetCornerSmoothingType() const
const wxPoint & GetBezierC1_0() const
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives() const
Accessor to the basic shape list for custom-shaped pads.
PAD_SHAPE GetAnchorPadShape() const
wxString GetOverrideText() const
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
const wxPoint & GetStart() const
#define CTL_FOR_LIBRARY
Format output for a footprint library instead of clipboard or BOARD.
int Translate(int aNetCode) const
Translate net number according to the map prepared by Update() function.
KICAD_T Type() const
Returns the type of object.
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Return an "English Standard" name of a PCB layer when given aLayerNumber.
const FOOTPRINT * getFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties, bool checkModified)
bool GetFilledPolysUseThickness() const
Container for design settings for a BOARD object.