21#include <unordered_set>
26#include <wx/filename.h>
27#include <wx/translation.h>
31#define FMT_UNIMPLEMENTED wxT( "Plugin \"%s\" does not implement the \"%s\" function." )
32#define NOT_IMPLEMENTED( aCaller ) \
33 THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, \
35 wxString::FromUTF8( aCaller ) ) );
42 wxString fileExt = wxFileName( aFileName ).GetExt().MakeLower();
44 for(
const std::string& ext : exts )
46 if( fileExt == wxString( ext ).Lower() )
58 wxString fileExt = wxFileName( aFileName ).GetExt().MakeLower();
60 for(
const std::string& ext : exts )
62 if( fileExt == wxString( ext ).Lower() )
71 const std::map<std::string, UTF8>* aProperties,
PROJECT* aProject )
84 const std::map<std::string, UTF8>* aProperties )
92 bool aBestEfforts,
const std::map<std::string, UTF8>* aProperties )
100 const std::map<std::string, UTF8>* aProperties )
102 wxArrayString footprintNames;
106 if( footprintNames.empty() )
109 if( footprintNames.size() > 1 )
111 wxLogWarning(
_(
"Selected file contains multiple footprints. Only the first one will be "
112 "imported.\nTo load all footprints, add it as a library using Preferences "
113 "-> Manage Footprint "
117 aFootprintNameOut = footprintNames.front();
119 return FootprintLoad( aFootprintPath, aFootprintNameOut,
false, aProperties );
124 const wxString& aFootprintName,
125 const std::map<std::string, UTF8>* aProperties )
128 return FootprintLoad( aLibraryPath, aFootprintName,
false, aProperties );
133 const std::map<std::string, UTF8>* aProperties )
136 return FootprintLoad( aLibraryPath, aFootprintName,
true, aProperties ) !=
nullptr;
141 bool aKeepUUID,
const std::map<std::string, UTF8>* aProperties )
149 const std::map<std::string, UTF8>* aProperties )
157 const std::map<std::string, UTF8>* aProperties )
171 (*aListToAppendTo)[
"debug_level"] =
UTF8(
_(
"Enable <b>debug</b> logging for Footprint*() "
172 "functions in this PCB_IO." ) );
174 (*aListToAppendTo)[
"read_filter_regex"] =
UTF8(
_(
"Regular expression <b>footprint name</b> "
177 (*aListToAppendTo)[
"enable_transaction_logging"] =
UTF8(
_(
"Enable transaction logging. The "
178 "mere presence of this option "
179 "turns on the logging, no need to "
182 (*aListToAppendTo)[
"username"] =
UTF8(
_(
"User name for <b>login</b> to some special library "
185 (*aListToAppendTo)[
"password"] =
UTF8(
_(
"Password for <b>login</b> to some special library "
192 (*aListToAppendTo)[
"python_footprint_plugin"] =
UTF8(
_(
"Enter the python module which "
193 "implements the PCB_IO::Footprint*() "
Information pertinent to a Pcbnew printed circuit board.
virtual const IO_FILE_DESC GetLibraryFileDesc() const
Get the descriptor for the individual library elements that this IO plugin operates on.
virtual void GetLibraryOptions(std::map< std::string, UTF8 > *aListToAppendTo) const
Append supported IO options to aListToAppenTo along with internationalized descriptions.
virtual bool CanReadFootprint(const wxString &aFileName) const
Checks if this PCB_IO can read a footprint from specified file or directory.
virtual bool CanReadBoard(const wxString &aFileName) const
Checks if this PCB_IO can read the specified board file.
virtual FOOTPRINT * ImportFootprint(const wxString &aFootprintPath, wxString &aFootprintNameOut, const std::map< std::string, UTF8 > *aProperties=nullptr)
Load a single footprint from aFootprintPath and put its name in aFootprintNameOut.
virtual void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const std::map< std::string, UTF8 > *aProperties=nullptr)
Return a list of footprint names contained within the library at aLibraryPath.
virtual void SaveBoard(const wxString &aFileName, BOARD *aBoard, const std::map< std::string, UTF8 > *aProperties=nullptr)
Write aBoard to a storage file in a format that this PCB_IO implementation knows about or it can be u...
virtual void GetLibraryOptions(std::map< std::string, UTF8 > *aListToAppendTo) const override
Append supported PLUGIN options to aListToAppenTo along with internationalized descriptions.
virtual bool FootprintExists(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr)
Check for the existence of a footprint.
virtual std::vector< FOOTPRINT * > GetImportedCachedLibraryFootprints()
Return a container with the cached library footprints generated in the last call to Load.
virtual BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr)
Load information from some input file format that this PCB_IO implementation knows about into either ...
virtual const FOOTPRINT * GetEnumeratedFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr)
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.
virtual const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const
Returns board file description for the PCB_IO.
virtual void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr)
Delete aFootprintName from the library at aLibraryPath.
virtual FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const std::map< std::string, UTF8 > *aProperties=nullptr)
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PC...
virtual void FootprintSave(const wxString &aLibraryPath, const FOOTPRINT *aFootprint, const std::map< std::string, UTF8 > *aProperties=nullptr)
Write aFootprint to an existing library located at aLibraryPath.
Container for project specific data.
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
#define NOT_IMPLEMENTED(aCaller)
std::vector< std::string > m_FileExtensions
Filter used for file pickers if m_IsFile is true.