63#include <wx/mstream.h>
66using namespace PCB_KEYS_T;
70 m_filename( aFileName ),
71 m_footprint( aFootprint )
103 if( aFootprint && aFootprint != it->second->GetFootprint() )
108 wxString tempFileName =
110 wxFileName::CreateTempFileName( fn.
GetPath() );
131 wxMilliSleep( 250L );
133 if( !wxRenameFile( tempFileName, fn.
GetFullPath() ) )
135 wxString msg =
wxString::Format(
_(
"Cannot rename temporary file '%s' to '%s'" ),
159 if( !dir.IsOpened() )
173 if( dir.GetFirst( &fullName, fileSpec ) )
185 PCB_PARSER parser( &reader,
nullptr,
nullptr );
190 wxString fpName = fn.
GetName();
202 if( !cacheError.IsEmpty() )
203 cacheError += wxT(
"\n\n" );
205 cacheError += ioe.
What();
207 }
while( dir.GetNext( &fullName ) );
211 if( !cacheError.IsEmpty() )
219 FP_CACHE_FOOTPRINT_MAP::const_iterator it =
m_footprints.find( aFootprintName );
230 wxString fullPath = it->second->GetFileName().GetFullPath();
232 wxRemoveFile( fullPath );
250 footprint.second->SetFilePath( aPath );
280 _(
"Internal Group Data Error" ), wxICON_ERROR,
282 "structure: %s\n\nSave anyway?" ), sanityResult ),
283 _(
"Save Anyway" ) ) )
312 std::string input =
TO_UTF8( aClipboardSourceInput );
319 return parser.
Parse();
335 switch( aItem->
Type() )
338 format(
static_cast<const BOARD*
>( aItem ), aNestLevel );
375 format(
static_cast<const PAD*
>( aItem ), aNestLevel );
406 format(
static_cast<const ZONE*
>( aItem ), aNestLevel );
410 wxFAIL_MSG( wxT(
"Cannot format item " ) + aItem->
GetClass() );
419 aIsKnockout ?
" knockout" :
"" );
424 bool aCompact )
const
428 bool needNewline =
false;
429 int nestLevel = aNestLevel + 2;
432 for(
int ii = 0; ii < outline.
PointCount(); ++ii )
445 m_out->
Print( nestLevel,
"(arc (start %s) (mid %s) (end %s))",
461 if( !( shapesAdded % 4 ) || !aCompact )
482 m_out->
Print( aNestLevel,
"(render_cache %s %s\n",
486 for(
const std::unique_ptr<KIFONT::GLYPH>& baseGlyph : *cache )
498 for(
int jj = 0; jj < glyph->
HoleCount( ii ); ++jj )
523 m_out->
Print( aNestLevel+1,
"(pad_to_mask_clearance %s)\n",
528 m_out->
Print( aNestLevel+1,
"(solder_mask_min_width %s)\n",
534 m_out->
Print( aNestLevel+1,
"(pad_to_paste_clearance %s)\n",
540 m_out->
Print( aNestLevel+1,
"(pad_to_paste_clearance_ratio %s)\n",
546 m_out->
Print( aNestLevel+1,
"(allow_soldermask_bridges_in_footprints yes)\n" );
553 m_out->
Print( aNestLevel+1,
"(aux_axis_origin %s %s)\n",
562 m_out->
Print( aNestLevel+1,
"(grid_origin %s %s)\n",
579 m_out->
Print( aNestLevel+1,
"(thickness %s)\n",
599 m_out->
Print( aNestLevel+1,
"(%d %s %s", layer,
646 m_out->
Print( aNestLevel+1,
"(%d %s user", layer,
677 for(
const std::pair<const wxString, wxString>& prop : aBoard->
GetProperties() )
679 m_out->
Print( aNestLevel,
"(property %s %s)\n",
709 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_footprints( aBoard->
Footprints().begin(),
711 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_drawings( aBoard->
Drawings().begin(),
713 std::set<PCB_TRACK*, PCB_TRACK::cmp_tracks> sorted_tracks( aBoard->
Tracks().begin(),
715 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_zones( aBoard->
Zones().begin(),
716 aBoard->
Zones().end() );
717 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_groups( aBoard->
Groups().begin(),
722 for(
BOARD_ITEM* footprint : sorted_footprints )
724 Format( footprint, aNestLevel );
730 Format( item, aNestLevel );
732 if( sorted_drawings.size() )
739 Format( track, aNestLevel );
741 if( sorted_tracks.size() )
745 for(
auto zone : sorted_zones )
746 Format( zone, aNestLevel );
779 wxFAIL_MSG( wxT(
"Cannot format unknown dimension type!" ) );
787 m_out->
Print( aNestLevel+1,
"(pts (xy %s %s) (xy %s %s))\n",
801 m_out->
Print( aNestLevel+1,
"(leader_length %s)\n",
807 m_out->
Print( aNestLevel+1,
"(orientation %d)\n",
808 static_cast<int>(
ortho->GetOrientation() ) );
813 format(
static_cast<const PCB_TEXT*
>( aDimension ), aNestLevel + 1 );
815 m_out->
Print( aNestLevel + 1,
"(format (prefix %s) (suffix %s) (units %d) (units_format %d) (precision %d)",
834 m_out->
Print( aNestLevel+1,
"(style (thickness %s) (arrow_length %s) (text_position_mode %d)",
867 m_out->
Print( aNestLevel,
"(gr_line%s (start %s) (end %s)",
874 m_out->
Print( aNestLevel,
"(gr_rect%s (start %s) (end %s)",
881 m_out->
Print( aNestLevel,
"(gr_circle%s (center %s) (end %s)",
888 m_out->
Print( aNestLevel,
"(gr_arc%s (start %s) (mid %s) (end %s)",
906 wxFAIL_MSG( wxT(
"Cannot format invalid polygon." ) );
913 m_out->
Print( aNestLevel,
"(gr_curve%s (pts (xy %s) (xy %s) (xy %s) (xy %s))",
951 wxCHECK_RET( aBitmap !=
nullptr &&
m_out !=
nullptr,
"" );
955 wxCHECK_RET(
image !=
nullptr,
"wxImage* is NULL" );
957 m_out->
Print( aNestLevel,
"(image (at %s %s)",
970 wxMemoryOutputStream stream;
972 image->SaveFile( stream, wxBITMAP_TYPE_PNG );
975 wxStreamBuffer* buffer = stream.GetOutputStreamBuffer();
976 wxString out = wxBase64Encode( buffer->GetBufferStart(), buffer->GetBufferSize() );
980#define MIME_BASE64_LENGTH 76
984 while( first < out.Length() )
1004 m_out->
Print( aNestLevel,
"(fp_line%s (start %s) (end %s)",
1011 m_out->
Print( aNestLevel,
"(fp_rect%s (start %s) (end %s)",
1018 m_out->
Print( aNestLevel,
"(fp_circle%s (center %s) (end %s)",
1025 m_out->
Print( aNestLevel,
"(fp_arc%s (start %s) (mid %s) (end %s)",
1043 wxFAIL_MSG( wxT(
"Cannot format invalid polygon." ) );
1049 m_out->
Print( aNestLevel,
"(fp_curve%s (pts (xy %s) (xy %s) (xy %s) (xy %s))",
1058 wxFAIL_MSG( wxT(
"PCB_PLUGIN::format not implemented for " ) + aFPShape->
SHAPE_T_asString() );
1087 m_out->
Print( aNestLevel,
"(target %s (at %s) (size %s)",
1088 ( aTarget->
GetShape() ) ?
"x" :
"plus",
1109 if( initial_comments )
1111 for(
unsigned i = 0; i < initial_comments->GetCount(); ++i )
1168 const std::map<wxString, wxString>& props = aFootprint->
GetProperties();
1170 for(
const std::pair<const wxString, wxString>& prop : props )
1172 m_out->
Print( aNestLevel+1,
"(property %s %s)\n",
1185 m_out->
Print( aNestLevel+1,
"(solder_mask_margin %s)\n",
1191 m_out->
Print( aNestLevel+1,
"(solder_paste_margin %s)\n",
1197 m_out->
Print( aNestLevel+1,
"(solder_paste_ratio %s)\n",
1203 m_out->
Print( aNestLevel+1,
"(clearance %s)\n",
1209 m_out->
Print( aNestLevel+1,
"(zone_connect %d)\n",
1228 m_out->
Print( 0,
" exclude_from_pos_files" );
1234 m_out->
Print( 0,
" allow_missing_courtyard" );
1237 m_out->
Print( 0,
" allow_soldermask_bridges" );
1244 m_out->
Print( aNestLevel+1,
"(private_layers" );
1248 wxString canonicalName(
LSET::Name( layer ) );
1249 m_out->
Print( 0,
" \"%s\"", canonicalName.ToStdString().c_str() );
1257 m_out->
Print( aNestLevel+1,
"(net_tie_pad_groups" );
1271 std::set<PAD*, FOOTPRINT::cmp_pads> sorted_pads( aFootprint->
Pads().begin(),
1272 aFootprint->
Pads().end() );
1273 std::set<BOARD_ITEM*, FOOTPRINT::cmp_drawings> sorted_drawings(
1276 std::set<FP_ZONE*, FOOTPRINT::cmp_zones> sorted_zones( aFootprint->
Zones().begin(),
1277 aFootprint->
Zones().end() );
1278 std::set<BOARD_ITEM*, PCB_GROUP::ptr_cmp> sorted_groups( aFootprint->
Groups().begin(),
1279 aFootprint->
Groups().end() );
1284 Format( gr, aNestLevel+1 );
1287 for(
PAD*
pad : sorted_pads )
1292 Format( zone, aNestLevel + 1 );
1299 auto bs3D = aFootprint->
Models().begin();
1300 auto es3D = aFootprint->
Models().end();
1302 while( bs3D != es3D )
1304 if( !bs3D->m_Filename.IsEmpty() )
1308 bs3D->m_Show ?
"" :
" hide" );
1310 if( bs3D->m_Opacity != 1.0 )
1311 m_out->
Print( aNestLevel+2,
"(opacity %0.4f)", bs3D->m_Opacity );
1313 m_out->
Print( aNestLevel+2,
"(offset (xyz %s %s %s))\n",
1318 m_out->
Print( aNestLevel+2,
"(scale (xyz %s %s %s))\n",
1323 m_out->
Print( aNestLevel+2,
"(rotate (xyz %s %s %s))\n",
1342 if( aNestLevel == 0 )
1345 output +=
"(layers";
1356 LSET cu_mask = cu_all;
1360 if( ( aLayerMask & cu_mask ) == cu_mask )
1363 aLayerMask &= ~cu_all;
1365 else if( ( aLayerMask & cu_mask ) == fr_bk )
1368 aLayerMask &= ~fr_bk;
1371 if( ( aLayerMask & adhes ) == adhes )
1374 aLayerMask &= ~adhes;
1380 aLayerMask &= ~paste;
1383 if( ( aLayerMask & silks ) == silks )
1386 aLayerMask &= ~silks;
1389 if( ( aLayerMask & mask ) == mask )
1392 aLayerMask &= ~mask;
1395 if( ( aLayerMask & crt_yd ) == crt_yd )
1398 aLayerMask &= ~crt_yd;
1401 if( ( aLayerMask & fab ) == fab )
1412 if( aLayerMask[layer] )
1420 m_out->
Print( aNestLevel,
"%s)", output.c_str() );
1457 const char*
property =
nullptr;
1497 if( (sz.
x > 0) || (sz.
y > 0) ||
1498 (shapeoffset.
x != 0) || (shapeoffset.
y != 0) )
1508 if( sz.
y > 0 && sz.
x != sz.
y )
1511 if( (shapeoffset.
x != 0) || (shapeoffset.
y != 0) )
1519 m_out->
Print( 0,
" (property %s)", property );
1527 m_out->
Print( 0,
" (remove_unused_layers)" );
1534 m_out->
Print( 0,
" (zone_layer_connections" );
1559 m_out->
Print( aNestLevel+1,
"(chamfer_ratio %s)",
1594 StrPrintf( &output,
" (pinfunction %s)",
1613 StrPrintf( &output,
" (solder_mask_margin %s)",
1619 StrPrintf( &output,
" (solder_paste_margin %s)",
1625 StrPrintf( &output,
" (solder_paste_margin_ratio %s)",
1637 StrPrintf( &output,
" (zone_connect %d)",
1643 StrPrintf( &output,
" (thermal_bridge_width %s)",
1650 StrPrintf( &output,
" (thermal_bridge_angle %s)",
1656 StrPrintf( &output,
" (thermal_gap %s)",
1663 m_out->
Print( aNestLevel+1,
"%s", output.c_str()+1 );
1672 m_out->
Print( 0,
" (clearance convexhull)" );
1692 int nested_level = aNestLevel+2;
1695 for(
const std::shared_ptr<PCB_SHAPE>& primitive : aPad->
GetPrimitives() )
1699 switch( primitive->GetShape() )
1702 m_out->
Print( nested_level,
"(gr_line (start %s) (end %s)",
1708 if( primitive->IsAnnotationProxy() )
1710 m_out->
Print( nested_level,
"(gr_bbox (start %s) (end %s)",
1716 m_out->
Print( nested_level,
"(gr_rect (start %s) (end %s)",
1723 m_out->
Print( nested_level,
"(gr_arc (start %s) (mid %s) (end %s)",
1730 m_out->
Print( nested_level,
"(gr_circle (center %s) (end %s)",
1736 m_out->
Print( nested_level,
"(gr_curve (pts (xy %s) (xy %s) (xy %s) (xy %s))",
1744 if( primitive->IsPolyShapeValid() )
1768 if( primitive->IsFilled() )
1824 m_out->
Print( aNestLevel,
"(gr_text_box%s %s\n",
1830 m_out->
Print( aNestLevel + 1,
"(start %s) (end %s)",
1874 m_out->
Print( aNestLevel,
"(group %s%s (id %s)\n",
1876 aGroup->
IsLocked() ?
" locked" :
"",
1879 m_out->
Print( aNestLevel + 1,
"(members\n" );
1881 wxArrayString memberIds;
1884 memberIds.Add( member->m_Uuid.AsString() );
1888 for(
const wxString& memberId : memberIds )
1909 m_out->
Print( aNestLevel,
"(fp_text %s%s %s (at %s",
1968 m_out->
Print( aNestLevel,
"(fp_text_box%s %s\n",
1974 m_out->
Print( aNestLevel,
"(start %s) (end %s)",
2019 const BOARD* board =
via->GetBoard();
2021 wxCHECK_RET( board !=
nullptr, wxT(
"Via has no parent." ) );
2025 via->LayerPair( &layer1, &layer2 );
2027 switch(
via->GetViaType() )
2044 if(
via->IsLocked() )
2071 if(
via->GetRemoveUnconnected() )
2073 m_out->
Print( 0,
" (remove_unused_layers)" );
2075 if(
via->GetKeepStartEnd() )
2079 if(
via->GetIsFree() )
2082 if(
via->GetRemoveUnconnected() )
2084 m_out->
Print( 0,
" (zone_layer_connections" );
2100 m_out->
Print( aNestLevel,
"(arc%s (start %s) (mid %s) (end %s) (width %s)",
2113 m_out->
Print( aNestLevel,
"(segment%s (start %s) (end %s) (width %s)",
2140 m_out->
Print( aNestLevel,
"(zone%s (net %d) (net_name %s)",
2171 m_out->
Print( 0,
" (hatch %s %s)\n", hatch.c_str(),
2180 const char* td_type;
2190 td_type =
"track_end";
2194 m_out->
Print( aNestLevel+1,
"(attr (teardrop (type %s)))\n", td_type );
2197 m_out->
Print( aNestLevel+1,
"(connect_pads" );
2221 m_out->
Print( aNestLevel+1,
"(min_thickness %s)",
2225 m_out->
Print( 0,
" (filled_areas_thickness no)" );
2232 "(keepout (tracks %s) (vias %s) (pads %s) (copperpour %s) "
2233 "(footprints %s))\n",
2251 m_out->
Print( 0,
" (thermal_gap %s) (thermal_bridge_width %s)",
2282 m_out->
Print( 0,
" (island_removal_mode %d) (island_area_min %s)",
2290 m_out->
Print( aNestLevel+2,
"(hatch_thickness %s) (hatch_gap %s) (hatch_orientation %s)",
2298 m_out->
Print( aNestLevel+2,
"(hatch_smoothing_level %d) (hatch_smoothing_value %s)",
2304 m_out->
Print( aNestLevel+2,
"(hatch_border_algorithm %s) (hatch_min_hole_area %s)",
2315 for(
auto& chain : poly )
2317 m_out->
Print( aNestLevel + 1,
"(polygon\n" );
2328 for(
int ii = 0; ii < fv->OutlineCount(); ++ii )
2330 m_out->
Print( aNestLevel + 1,
"(filled_polygon\n" );
2331 m_out->
Print( aNestLevel + 2,
"(layer %s)\n",
2335 m_out->
Print( aNestLevel + 2,
"(island)\n" );
2350 m_ctl( aControlFlags ),
2352 m_queryUserCallback( nullptr )
2372 unsigned lineCount = 0;
2374 if( aProgressReporter )
2387 BOARD* board =
DoLoad( reader, aAppendToMe, aProperties, aProgressReporter, lineCount );
2400 init( aProperties );
2407 board =
dynamic_cast<BOARD*
>( parser.
Parse() );
2426 parser.CurLine(), parser.CurLineNumber(), parser.CurOffset() );
2457 wxDir dir( aLibPath );
2460 init( aProperties );
2468 errorMsg = ioe.
What();
2475 aFootprintNames.Add( footprint.first );
2477 if( !errorMsg.IsEmpty() && !aBestEfforts )
2483 const wxString& aFootprintName,
2485 bool checkModified )
2489 init( aProperties );
2501 FP_CACHE_FOOTPRINT_MAP::const_iterator it = footprints.find( aFootprintName );
2503 if( it == footprints.end() )
2506 return it->second->GetFootprint();
2511 const wxString& aFootprintName,
2514 return getFootprint( aLibraryPath, aFootprintName, aProperties,
false );
2530 return footprintFile.Exists();
2535 const wxString& aFootprintName,
2550 copy->SetParent(
nullptr );
2563 init( aProperties );
2576 "Would you like to create it?"),
2579 if( !
IsGUI() || wxMessageBox( msg,
_(
"Library Not Found"), wxYES_NO | wxICON_QUESTION ) != wxYES )
2587 wxString msg =
wxString::Format(
_(
"Library '%s' is read only." ), aLibraryPath );
2606 fn.GetFullPath() ) );
2609 if( fn.FileExists() && !fn.IsFileWritable() )
2612 fn.GetFullPath() ) );
2615 wxString fullPath = fn.GetFullPath();
2616 wxString fullName = fn.GetFullName();
2617 FP_CACHE_FOOTPRINT_MAP::const_iterator it = footprints.find( footprintName );
2619 if( it != footprints.end() )
2622 footprints.erase( footprintName );
2623 wxRemoveFile( fullPath );
2645 wxLogTrace(
traceKicadPcbPlugin, wxT(
"Creating s-expr footprint file '%s'." ), fullPath );
2646 footprints.insert( footprintName,
2657 init( aProperties );
2664 aLibraryPath.GetData() ) );
2680 if( wxDir::Exists( aLibraryPath ) )
2683 aLibraryPath.GetData() ) );
2688 init( aProperties );
2699 fn.SetPath( aLibraryPath );
2702 if( !fn.DirExists() )
2705 if( !fn.IsDirWritable() )
2708 aLibraryPath.GetData() ) );
2711 wxDir dir( aLibraryPath );
2713 if( dir.HasSubDirs() )
2716 aLibraryPath.GetData() ) );
2720 if( dir.HasFiles() )
2724 wxArrayString files;
2726 wxDir::GetAllFiles( aLibraryPath, &files );
2728 for( i = 0; i < files.GetCount(); i++ )
2737 aLibraryPath.GetData() ) );
2741 for( i = 0; i < files.GetCount(); i++ )
2742 wxRemoveFile( files[i] );
2746 aLibraryPath.GetData() );
2750 if( !wxRmdir( aLibraryPath ) )
2753 aLibraryPath.GetData() ) );
2760 wxMilliSleep( 250L );
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
constexpr EDA_IU_SCALE pcbIUScale
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
wxString GetNetname() const
Container for design settings for a BOARD object.
int GetBoardThickness() const
The full thickness of the board including copper and masks.
const VECTOR2I & GetGridOrigin()
const VECTOR2I & GetAuxOrigin()
bool m_AllowSoldermaskBridgesInFPs
int m_SolderMaskExpansion
BOARD_STACKUP & GetStackupDescriptor()
double m_SolderPasteMarginRatio
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual bool IsKnockout() const
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
virtual bool IsLocked() const
BOARD_ITEM_CONTAINER * GetParent() const
Manage layers needed to make a physical board.
void FormatBoardStackup(OUTPUTFORMATTER *aFormatter, const BOARD *aBoard, int aNestLevel) const
Write the stackup info on board file.
Information pertinent to a Pcbnew printed circuit board.
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
void SetFileName(const wxString &aFileName)
const PAGE_INFO & GetPageSettings() const
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Return the type of the copper layer given by aLayer.
TITLE_BLOCK & GetTitleBlock()
FOOTPRINTS & Footprints()
const std::map< wxString, wxString > & GetProperties() const
GROUPS & Groups()
The groups must maintain the following invariants.
const PCB_PLOT_PARAMS & GetPlotOptions() const
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
wxString GroupsSanityCheck(bool repair=false)
Consistency check of internal m_groups structure.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
KICAD_T Type() const
Returns the type of object.
virtual void SetParent(EDA_ITEM *aParent)
virtual wxString GetClass() const =0
Return the class name.
const VECTOR2I & GetBezierC2() const
SHAPE_POLY_SET & GetPolyShape()
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
wxString SHAPE_T_asString() const
const VECTOR2I & GetBezierC1() const
bool IsPolyShapeValid() const
VECTOR2I GetArcMid() const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
const VECTOR2I & GetTextPos() const
const EDA_ANGLE & GetTextAngle() const
virtual const wxString & GetText() const
Return the string associated with the text object.
bool IsKeepUpright() const
virtual bool IsVisible() const
KIFONT::FONT * GetFont() const
std::vector< std::unique_ptr< KIFONT::GLYPH > > * GetRenderCache(const KIFONT::FONT *aFont, const wxString &forResolvedText, const VECTOR2I &aOffset={ 0, 0 }) const
virtual EDA_ANGLE GetDrawRotation() const
virtual wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const
Return the string actually shown after processing of the base text.
A LINE_READER that reads from an open file.
void Rewind()
Rewind the file and resets the line number back to zero.
char * ReadLine() override
Read a line of text into the buffer and increments the line number counter.
Helper class for creating a footprint library cache.
FP_CACHE_ITEM(FOOTPRINT *aFootprint, const WX_FILENAME &aFileName)
static long long GetTimestamp(const wxString &aLibPath)
Generate a timestamp representing all source files in the cache (including the parent directory).
FP_CACHE_FOOTPRINT_MAP & GetFootprints()
void Save(FOOTPRINT *aFootprint=nullptr)
Save the footprint cache or a single footprint from it to disk.
bool IsModified()
Return true if the cache is not up-to-date.
long long m_cache_timestamp
void SetPath(const wxString &aPath)
FP_CACHE(PCB_PLUGIN *aOwner, const wxString &aLibraryPath)
bool IsPath(const wxString &aPath) const
Check if aPath is the same as the current cache path.
FP_CACHE_FOOTPRINT_MAP m_footprints
void Remove(const wxString &aFootprintName)
VECTOR2I GetArcMid0() const
const VECTOR2I & GetBezierC1_0() const
const VECTOR2I & GetEnd0() const
const VECTOR2I & GetBezierC2_0() const
const VECTOR2I & GetStart0() const
const VECTOR2I & GetPos0() const
TEXT_TYPE GetType() const
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
APP_SETTINGS_BASE * KifaceSettings() const
virtual bool IsOutline() const
wxString AsString() const
wxString AsString() const
A logical library item identifier and consists of various portions much like a URI.
const UTF8 & GetLibItemName() const
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
LSET is a set of PCB_LAYER_IDs.
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
LSEQ CuStack() const
Return a sequence of copper layers in starting from the front/top and extending to the back/bottom.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Handle the data for a net.
static const int UNCONNECTED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
void SetBoard(const BOARD *aBoard)
Set a BOARD object that is used to prepare the net code map.
int Translate(int aNetCode) const
Translate net number according to the map prepared by Update() function.
int GetLocalClearance(wxString *aSource) const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
PAD_PROP GetProperty() const
bool GetRemoveUnconnected() const
PAD_DRILL_SHAPE_T GetDrillShape() const
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
const ZONE_LAYER_OVERRIDE & GetZoneLayerOverride(PCB_LAYER_ID aLayer) const
const wxString & GetPinType() const
const VECTOR2I & GetDrillSize() const
PAD_ATTRIB GetAttribute() const
ZONE_CONNECTION GetZoneConnection() const
const wxString & GetPinFunction() const
const wxString & GetNumber() const
double GetLocalSolderPasteMarginRatio() const
bool IsLocked() const override
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives() const
Accessor to the basic shape list for custom-shaped pads.
EDA_ANGLE GetThermalSpokeAngle() const
const VECTOR2I & GetOffset() const
int GetLocalSolderMaskMargin() const
bool GetKeepTopBottom() const
CUST_PAD_SHAPE_IN_ZONE GetCustomShapeInZoneOpt() const
const VECTOR2I & GetDelta() const
PAD_SHAPE GetShape() const
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
int GetThermalSpokeWidth() const
int GetLocalSolderPasteMargin() const
int GetChamferPositions() const
double GetRoundRectRadiusRatio() const
int GetThermalGap() const
const VECTOR2I & GetPos0() const
const VECTOR2I & GetSize() const
PAD_SHAPE GetAnchorPadShape() const
double GetChamferRectRatio() const
int GetPadToDieLength() const
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the page class to aFormatter in s-expression form.
const VECTOR2I & GetMid() const
Object to handle a bitmap image that can be inserted in a PCB.
VECTOR2I GetPosition() const override
const BITMAP_BASE * GetImage() const
wxString GetOverrideText() const
wxString GetSuffix() const
int GetLineThickness() const
DIM_TEXT_POSITION GetTextPositionMode() const
bool GetKeepTextAligned() const
DIM_PRECISION GetPrecision() const
wxString GetPrefix() const
DIM_UNITS_MODE GetUnitsMode() const
DIM_UNITS_FORMAT GetUnitsFormat() const
virtual const VECTOR2I & GetStart() const
The dimension's origin is the first feature point for the dimension.
bool GetSuppressZeroes() const
int GetExtensionOffset() const
int GetArrowLength() const
bool GetOverrideTextEnabled() const
virtual const VECTOR2I & GetEnd() const
For better understanding of the points that make a dimension:
int GetExtensionHeight() const
Mark the center of a circle or arc with a cross shape.
A leader is a dimension-like object pointing to a specific point.
DIM_TEXT_BORDER GetTextBorder() const
An orthogonal dimension is like an aligned dimension, but the extension lines are locked to the X or ...
A radial dimension indicates either the radius or diameter of an arc or circle.
int GetLeaderLength() const
A set of BOARD_ITEMs (i.e., without duplicates).
std::unordered_set< BOARD_ITEM * > & GetItems()
Read a Pcbnew s-expression formatted LINE_READER object and returns the appropriate BOARD_ITEM object...
bool IsTooRecent()
Return whether a version number, if any was parsed, was too recent.
wxString GetRequiredVersion()
Return a string representing the version of KiCad required to open this file.
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControl=0) const
A PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
void formatSetup(const BOARD *aBoard, int aNestLevel=0) const
formats the board setup information
void FootprintSave(const wxString &aLibraryPath, const FOOTPRINT *aFootprint, const STRING_UTF8_MAP *aProperties=nullptr) override
Write aFootprint to an existing library located at aLibraryPath.
BOARD * m_board
which BOARD, no ownership here
LINE_READER * m_reader
no ownership here.
void formatPolyPts(const SHAPE_LINE_CHAIN &outline, int aNestLevel, bool aCompact) const
void init(const STRING_UTF8_MAP *aProperties)
bool FootprintLibDelete(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr) override
Delete an existing footprint library and returns true, or if library does not exist returns false,...
FP_CACHE * m_cache
Footprint library cache.
void formatLayer(PCB_LAYER_ID aLayer, bool aIsKnockout=false) const
BOARD_ITEM * Parse(const wxString &aClipboardSourceInput)
std::function< bool(wxString aTitle, int aIcon, wxString aMsg, wxString aAction)> * m_queryUserCallback
void formatHeader(const BOARD *aBoard, int aNestLevel=0) const
writes everything that comes before the board_items, like settings and layers etc
void formatLayers(LSET aLayerMask, int aNestLevel=0) const
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
bool IsFootprintLibWritable(const wxString &aLibraryPath) override
Return true if the library at aLibraryPath is writable.
BOARD * Load(const wxString &aFileName, BOARD *aAppendToMe, const STRING_UTF8_MAP *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 ...
void SetOutputFormatter(OUTPUTFORMATTER *aFormatter)
void formatRenderCache(const EDA_TEXT *aText, int aNestLevel) const
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
const FOOTPRINT * GetEnumeratedFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr) override
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.
const STRING_UTF8_MAP * m_props
passed via Save() or Load(), no ownership, may be NULL.
BOARD * DoLoad(LINE_READER &aReader, BOARD *aAppendToMe, const STRING_UTF8_MAP *aProperties, PROGRESS_REPORTER *aProgressReporter, unsigned aLineCount)
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
void format(const BOARD *aBoard, int aNestLevel=0) const
void formatNetInformation(const BOARD *aBoard, int aNestLevel=0) const
formats the Nets and Netclasses
PCB_PLUGIN(int aControlFlags=CTL_FOR_BOARD)
void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr) override
Delete aFootprintName from the library at aLibraryPath.
bool FootprintExists(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr) override
Check for the existence of a footprint.
void FootprintLibCreate(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr) override
Create a new empty footprint library at aLibraryPath empty.
void formatProperties(const BOARD *aBoard, int aNestLevel=0) const
formats the Nets and Netclasses
FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const STRING_UTF8_MAP *aProperties=nullptr) override
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PL...
const FOOTPRINT * getFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties, bool checkModified)
void formatBoardLayers(const BOARD *aBoard, int aNestLevel=0) const
formats the board layer information
void formatGeneral(const BOARD *aBoard, int aNestLevel=0) const
formats the General section of the file
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
void Save(const wxString &aFileName, BOARD *aBoard, const STRING_UTF8_MAP *aProperties=nullptr) override
Write aBoard to a storage file in a format that this PLUGIN implementation knows about or it can be u...
void Format(const BOARD_ITEM *aItem, int aNestLevel=0) const
Output aItem to aFormatter in s-expression format.
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const STRING_UTF8_MAP *aProperties=nullptr) override
Return a list of footprint names contained within the library at aLibraryPath.
STROKE_PARAMS GetStroke() const override
VECTOR2I GetPosition() const override
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
A progress reporter interface for use in multi-threaded environments.
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
virtual void Report(const wxString &aMessage)=0
Display aMessage in the progress bar dialog.
Container for project specific data.
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)
int HoleCount(int aOutline) const
Return the reference to aIndex-th outline in the set.
std::vector< SHAPE_LINE_CHAIN > POLYGON
< represents a single polygon outline with holes.
SHAPE_LINE_CHAIN & Outline(int aIndex)
SHAPE_LINE_CHAIN & Hole(int aOutline, int aHole)
Return the aIndex-th subpolygon in the set.
int OutlineCount() const
Return the number of vertices in a given outline/hole.
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
A name/value tuple with unique names and optional values.
void Format(OUTPUTFORMATTER *out, const EDA_IU_SCALE &aIuScale, int nestLevel) const
virtual void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the object to aFormatter in s-expression form.
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:
bool GetDoNotAllowVias() const
const std::shared_ptr< SHAPE_POLY_SET > & GetFilledPolysList(PCB_LAYER_ID aLayer) const
const ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
bool GetDoNotAllowPads() const
bool GetDoNotAllowTracks() 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
wxString GetZoneName() const
int GetLocalClearance(wxString *aSource) const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
int GetMinThickness() const
ZONE_CONNECTION GetPadConnection() const
int GetHatchThickness() const
double GetHatchHoleMinArea() const
bool IsTeardropArea() const
int GetThermalReliefSpokeWidth() const
int GetBorderHatchPitch() const
HatchBorder related methods.
ZONE_BORDER_DISPLAY_STYLE GetHatchStyle() const
EDA_ANGLE GetHatchOrientation() const
bool GetDoNotAllowFootprints() const
ZONE_FILL_MODE GetFillMode() const
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
bool GetDoNotAllowCopperPour() const
TEARDROP_TYPE GetTeardropAreaType() const
double GetHatchSmoothingValue() const
int GetHatchSmoothingLevel() const
unsigned int GetCornerRadius() const
int GetCornerSmoothingType() const
bool IsOnCopperLayer() const override
PCB_LAYER_ID GetFirstLayer() const
int GetThermalReliefGap() const
unsigned GetAssignedPriority() const
int GetNumCorners(void) const
Access to m_Poly parameters.
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/...
bool IsGUI()
Determine if the application is running with a GUI.
This file is part of the common library.
@ RECT_CHAMFER_BOTTOM_RIGHT
@ RECT_CHAMFER_BOTTOM_LEFT
static constexpr EDA_ANGLE & ANGLE_45
static constexpr EDA_ANGLE & ANGLE_90
static constexpr EDA_ANGLE & ANGLE_0
const std::string KiCadFootprintFileExtension
const wxChar *const traceKicadPcbPlugin
Flag to enable GEDA PCB plugin debug output.
#define THROW_IO_ERROR(msg)
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
PCB_LAYER_ID
A quick note on layer IDs:
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
std::string FormatInternalUnits(const EDA_IU_SCALE &aIuScale, int aValue)
Converts aValue from internal units to a string appropriate for writing to file.
std::string FormatAngle(const EDA_ANGLE &aAngle)
Converts aAngle from board units to a string appropriate for writing to file.
@ CUST_PAD_SHAPE_IN_ZONE_CONVEXHULL
@ NPTH
like PAD_PTH, but not plated
@ 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)
@ FIDUCIAL_LOCAL
a fiducial (usually a smd) local to the parent footprint
@ FIDUCIAL_GLBL
a fiducial (usually a smd) for the full board
@ 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.
Pcbnew s-expression file format parser definition.
#define MIME_BASE64_LENGTH
#define CTL_OMIT_FOOTPRINT_VERSION
Omit the version string from the (footprint) sexpr group.
#define SEXPR_BOARD_FILE_VERSION
Current s-expression file format version. 2 was the last legacy format version.
#define CTL_OMIT_TSTAMPS
Omit component time stamp (useless in library)
#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)
boost::ptr_map< wxString, FP_CACHE_ITEM > FP_CACHE_FOOTPRINT_MAP
#define CTL_FOR_LIBRARY
Format output for a footprint library instead of clipboard or BOARD.
#define UNDEFINED_DRILL_DIAMETER
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
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.
std::string FormatDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 This function is intended in...
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
static const char * ShowType(LAYER_T aType)
Convert a LAYER_T enum to a string representation of the layer type.
A filename or source description, a problem input line, a line number, a byte offset,...
wxLogTrace helper definitions.
T NormalizeAnglePos(T Angle)
Normalize angle to be in the 0.0 .. 360.0 range: angle is in 1/10 degrees.
@ PCB_FP_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ 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_FP_SHAPE_T
class FP_SHAPE, a footprint edge
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
@ 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_FP_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
@ PCB_FP_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_FP_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_FP_ZONE_T
class ZONE, managed by a footprint
@ PCB_BITMAP_T
class PCB_BITMAP, bitmap on a layer
@ PCB_FP_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ 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
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