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 )
104 const std::map<std::string, UTF8>* aProperties )
106 wxArrayString footprintNames;
110 if( footprintNames.empty() )
113 if( footprintNames.size() > 1 )
115 wxLogWarning(
_(
"Selected file contains multiple footprints. Only the first one will be "
116 "imported.\nTo load all footprints, add it as a library using Preferences "
117 "-> Manage Footprint "
121 aFootprintNameOut = footprintNames.front();
123 return FootprintLoad( aFootprintPath, aFootprintNameOut,
false, aProperties );
128 const wxString& aFootprintName,
129 const std::map<std::string, UTF8>* aProperties )
132 return FootprintLoad( aLibraryPath, aFootprintName,
false, aProperties );
137 const std::map<std::string, UTF8>* aProperties )
140 return FootprintLoad( aLibraryPath, aFootprintName,
true, aProperties ) !=
nullptr;
145 bool aKeepUUID,
const std::map<std::string, UTF8>* aProperties )
153 const std::map<std::string, UTF8>* aProperties )
161 const std::map<std::string, UTF8>* aProperties )
175 (*aListToAppendTo)[
"debug_level"] =
UTF8(
_(
"Enable <b>debug</b> logging for Footprint*() "
176 "functions in this PCB_IO." ) );
178 (*aListToAppendTo)[
"read_filter_regex"] =
UTF8(
_(
"Regular expression <b>footprint name</b> "
181 (*aListToAppendTo)[
"enable_transaction_logging"] =
UTF8(
_(
"Enable transaction logging. The "
182 "mere presence of this option "
183 "turns on the logging, no need to "
186 (*aListToAppendTo)[
"username"] =
UTF8(
_(
"User name for <b>login</b> to some special library "
189 (*aListToAppendTo)[
"password"] =
UTF8(
_(
"Password for <b>login</b> to some special library "
196 (*aListToAppendTo)[
"python_footprint_plugin"] =
UTF8(
_(
"Enter the python module which "
197 "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.