25#include <unordered_set>
30#include <wx/filename.h>
31#include <wx/translation.h>
35#define FMT_UNIMPLEMENTED wxT( "Plugin \"%s\" does not implement the \"%s\" function." )
36#define NOT_IMPLEMENTED( aCaller ) \
37 THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, \
39 wxString::FromUTF8( aCaller ) ) );
46 wxString fileExt = wxFileName( aFileName ).GetExt().MakeLower();
48 for(
const std::string& ext : exts )
50 if( fileExt == wxString( ext ).Lower() )
62 wxString fileExt = wxFileName( aFileName ).GetExt().MakeLower();
64 for(
const std::string& ext : exts )
66 if( fileExt == wxString( ext ).Lower() )
75 const std::map<std::string, UTF8>* aProperties,
PROJECT* aProject )
88 const std::map<std::string, UTF8>* aProperties )
96 bool aBestEfforts,
const std::map<std::string, UTF8>* aProperties )
109 const std::map<std::string, UTF8>* aProperties )
111 wxArrayString footprintNames;
115 if( footprintNames.empty() )
118 if( footprintNames.size() > 1 )
120 wxLogWarning(
_(
"Selected file contains multiple footprints. Only the first one will be "
121 "imported.\nTo load all footprints, add it as a library using Preferences "
122 "-> Manage Footprint "
126 aFootprintNameOut = footprintNames.front();
128 return FootprintLoad( aFootprintPath, aFootprintNameOut,
false, aProperties );
133 const wxString& aFootprintName,
134 const std::map<std::string, UTF8>* aProperties )
137 return FootprintLoad( aLibraryPath, aFootprintName,
false, aProperties );
142 const std::map<std::string, UTF8>* aProperties )
145 return FootprintLoad( aLibraryPath, aFootprintName,
true, aProperties ) !=
nullptr;
150 bool aKeepUUID,
const std::map<std::string, UTF8>* aProperties )
158 const std::map<std::string, UTF8>* aProperties )
166 const std::map<std::string, UTF8>* aProperties )
180 (*aListToAppendTo)[
"debug_level"] =
UTF8(
_(
"Enable <b>debug</b> logging for Footprint*() "
181 "functions in this PCB_IO." ) );
183 (*aListToAppendTo)[
"read_filter_regex"] =
UTF8(
_(
"Regular expression <b>footprint name</b> "
186 (*aListToAppendTo)[
"enable_transaction_logging"] =
UTF8(
_(
"Enable transaction logging. The "
187 "mere presence of this option "
188 "turns on the logging, no need to "
191 (*aListToAppendTo)[
"username"] =
UTF8(
_(
"User name for <b>login</b> to some special library "
194 (*aListToAppendTo)[
"password"] =
UTF8(
_(
"Password for <b>login</b> to some special library "
201 (*aListToAppendTo)[
"python_footprint_plugin"] =
UTF8(
_(
"Enter the python module which "
202 "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 void PrefetchLib(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr)
If possible, prefetches the specified library (e.g.
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.