31#include <boost/ptr_container/ptr_map.hpp>
133#define SEXPR_BOARD_FILE_VERSION 20221018
135#define BOARD_FILE_HOST_VERSION 20200825
136#define LEGACY_ARC_FORMATTING 20210925
137#define LEGACY_NET_TIES 20220815
140#define CTL_OMIT_PAD_NETS (1 << 1)
141#define CTL_OMIT_TSTAMPS (1 << 2)
142#define CTL_OMIT_INITIAL_COMMENTS (1 << 3)
143#define CTL_OMIT_PATH (1 << 4)
144#define CTL_OMIT_AT (1 << 5)
147#define CTL_OMIT_LIBNAME (1 << 7)
149#define CTL_OMIT_FOOTPRINT_VERSION (1 << 8)
155#define CTL_FOR_CLIPBOARD (CTL_OMIT_INITIAL_COMMENTS)
158#define CTL_FOR_LIBRARY \
159 ( CTL_OMIT_PAD_NETS | CTL_OMIT_TSTAMPS | CTL_OMIT_PATH | CTL_OMIT_AT | CTL_OMIT_LIBNAME )
163#define CTL_FOR_BOARD (CTL_OMIT_INITIAL_COMMENTS|CTL_OMIT_FOOTPRINT_VERSION)
224 void Remove(
const wxString& aFootprintName );
231 static long long GetTimestamp(
const wxString& aLibPath );
249 bool IsPath(
const wxString& aPath )
const;
251 void SetPath(
const wxString& aPath );
265 return wxT(
"KiCad" );
274 return wxT(
"kicad_pcb" );
278 wxString aOKButtonTitle )> aCallback )
override
283 void Save(
const wxString& aFileName,
BOARD* aBoard,
293 void FootprintEnumerate( wxArrayString& aFootprintNames,
const wxString& aLibraryPath,
294 bool aBestEfforts,
const STRING_UTF8_MAP* aProperties =
nullptr )
override;
297 const wxString& aFootprintName,
300 bool FootprintExists(
const wxString& aLibraryPath,
const wxString& aFootprintName,
304 bool aKeepUUID =
false,
310 void FootprintDelete(
const wxString& aLibraryPath,
const wxString& aFootprintName,
351 void validateCache(
const wxString& aLibraryPath,
bool checkModified =
true );
377 void format(
const BOARD* aBoard,
int aNestLevel = 0 )
const;
381 void format(
const FP_SHAPE* aFPShape,
int aNestLevel = 0 )
const;
393 void format(
const PAD* aPad,
int aNestLevel = 0 )
const;
398 void format(
const FP_TEXT* aText,
int aNestLevel = 0 )
const;
403 void format(
const ZONE* aZone,
int aNestLevel = 0 )
const;
Container for design settings for a BOARD object.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Information pertinent to a Pcbnew printed circuit board.
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Helper class for creating a footprint library cache.
std::unique_ptr< FOOTPRINT > m_footprint
FP_CACHE_ITEM(FOOTPRINT *aFootprint, const WX_FILENAME &aFileName)
void SetFilePath(const wxString &aFilePath)
const FOOTPRINT * GetFootprint() const
const WX_FILENAME & GetFileName() const
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)
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
LSET is a set of PCB_LAYER_IDs.
Object to handle a bitmap image that can be inserted in a PCB.
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 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.
const wxString PluginName() const override
Return a brief hard coded name for this PLUGIN.
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)
wxString m_error
for throwing exceptions
const wxString GetFileExtension() const override
Returns the file extension for the PLUGIN.
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
wxString m_filename
for saves only, name is in m_reader for loads
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.
std::string GetStringOutput(bool doClear)
void SetQueryUserCallback(std::function< bool(wxString aTitle, int aIcon, wxString aMessage, wxString aOKButtonTitle)> aCallback) override
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.
A base class that BOARD loading and saving plugins should derive from.
A progress reporter interface for use in multi-threaded environments.
Container for project specific data.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
A name/value tuple with unique names and optional values.
A wrapper around a wxFileName which is much more performant with a subset of the API.
void SetPath(const wxString &aPath)
Handle a list of polygons defining a copper zone.
PCB_LAYER_ID
A quick note on layer IDs:
#define CTL_FOR_BOARD
The zero arg constructor when PCB_PLUGIN is used for PLUGIN::Load() and PLUGIN::Save()ing a BOARD fil...
boost::ptr_map< wxString, FP_CACHE_ITEM > FP_CACHE_FOOTPRINT_MAP