26#include <unordered_set>
31#include <wx/filename.h>
32#include <wx/translation.h>
36#define FMT_UNIMPLEMENTED wxT( "Plugin \"%s\" does not implement the \"%s\" function." )
37#define NOT_IMPLEMENTED( aCaller ) \
38 THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, \
40 wxString::FromUTF8( aCaller ) ) );
65 wxString fileExt = wxFileName( aFileName ).GetExt().MakeLower();
67 for(
const std::string& ext : exts )
69 if( fileExt == wxString( ext ).Lower() )
81 wxString fileExt = wxFileName( aFileName ).GetExt().MakeLower();
83 for(
const std::string& ext : exts )
85 if( fileExt == wxString( ext ).Lower() )
101 wxString fileExt = wxFileName( aFileName ).GetExt().MakeLower();
103 for(
const std::string& ext : exts )
105 if( fileExt == wxString( ext ).Lower() )
111 wxDir dir( aFileName );
113 if( !dir.IsOpened() )
117 std::unordered_set<wxString> lowerExts;
119 for(
const std::string& ext : exts )
120 lowerExts.emplace( wxString( ext ).MakeLower() );
122 wxString filenameStr;
124 bool cont = dir.GetFirst( &filenameStr, wxEmptyString, wxDIR_FILES | wxDIR_HIDDEN );
127 wxString ext = wxS(
"" );
129 int idx = filenameStr.Find(
'.',
true );
131 ext = filenameStr.Mid( idx + 1 ).MakeLower();
133 if( lowerExts.count( ext ) )
136 cont = dir.GetNext( &filenameStr );
182 wxArrayString footprintNames;
186 if( footprintNames.empty() )
189 if( footprintNames.size() > 1 )
191 wxLogWarning(
_(
"Selected file contains multiple footprints. Only the first one will be "
195 aFootprintNameOut = footprintNames.front();
197 return FootprintLoad( aFootprintPath, aFootprintNameOut,
false, aProperties );
202 const wxString& aFootprintName,
206 return FootprintLoad( aLibraryPath, aFootprintName,
false, aProperties );
214 return FootprintLoad( aLibraryPath, aFootprintName,
true, aProperties ) !=
nullptr;
267 (*aListToAppendTo)[
"debug_level"] =
UTF8(
_(
"Enable <b>debug</b> logging for Footprint*() "
268 "functions in this PLUGIN." ) );
270 (*aListToAppendTo)[
"read_filter_regex"] =
UTF8(
_(
"Regular expression <b>footprint name</b> "
273 (*aListToAppendTo)[
"enable_transaction_logging"] =
UTF8(
_(
"Enable transaction logging. The "
274 "mere presence of this option "
275 "turns on the logging, no need to "
278 (*aListToAppendTo)[
"username"] =
UTF8(
_(
"User name for <b>login</b> to some special library "
281 (*aListToAppendTo)[
"password"] =
UTF8(
_(
"Password for <b>login</b> to some special library "
288 (*aListToAppendTo)[
"python_footprint_plugin"] =
UTF8(
_(
"Enter the python module which "
289 "implements the PLUGIN::Footprint*() "
Information pertinent to a Pcbnew printed circuit board.
virtual bool CanReadFootprintLib(const wxString &aFileName) const
Checks if this PLUGIN can read footprint library from specified file or directory.
virtual const FOOTPRINT * GetEnumeratedFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr)
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.
virtual void FootprintLibCreate(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr)
Create a new empty footprint library at aLibraryPath empty.
virtual bool FootprintLibDelete(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr)
Delete an existing footprint library and returns true, or if library does not exist returns false,...
virtual PLUGIN_FILE_DESC GetBoardFileDesc() const
Returns board file description for the PLUGIN.
virtual void FootprintSave(const wxString &aLibraryPath, const FOOTPRINT *aFootprint, const STRING_UTF8_MAP *aProperties=nullptr)
Write aFootprint to an existing library located at aLibraryPath.
virtual std::vector< FOOTPRINT * > GetImportedCachedLibraryFootprints()
Return a container with the cached library footprints generated in the last call to Load.
virtual PLUGIN_FILE_DESC GetFootprintFileDesc() const
Returns footprint file description for the PLUGIN.
virtual void SaveBoard(const wxString &aFileName, BOARD *aBoard, const STRING_UTF8_MAP *aProperties=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
Write aBoard to a storage file in a format that this PLUGIN implementation knows about or it can be u...
virtual void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr)
Delete aFootprintName from the library at aLibraryPath.
virtual bool FootprintExists(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr)
Check for the existence of a footprint.
virtual FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const STRING_UTF8_MAP *aProperties=nullptr)
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PL...
virtual bool IsFootprintLibWritable(const wxString &aLibraryPath)
Return true if the library at aLibraryPath is writable.
virtual bool CanReadFootprint(const wxString &aFileName) const
Checks if this PLUGIN can read a footprint from specified file or directory.
virtual bool CanReadBoard(const wxString &aFileName) const
Checks if this PLUGIN can read the specified board file.
virtual PLUGIN_FILE_DESC GetFootprintLibDesc() const
Returns footprint library description for the PLUGIN.
virtual void FootprintLibOptions(STRING_UTF8_MAP *aListToAppendTo) const
Append supported PLUGIN options to aListToAppenTo along with internationalized descriptions.
virtual void PrefetchLib(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr)
If possible, prefetches the specified library (e.g.
virtual FOOTPRINT * ImportFootprint(const wxString &aFootprintPath, wxString &aFootprintNameOut, const STRING_UTF8_MAP *aProperties=nullptr)
Load a single footprint from aFootprintPath and put its name in aFootprintNameOut.
virtual BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const STRING_UTF8_MAP *aProperties=nullptr, PROJECT *aProject=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
Load information from some input file format that this PLUGIN implementation knows about into either ...
virtual void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const STRING_UTF8_MAP *aProperties=nullptr)
Return a list of footprint names contained within the library at aLibraryPath.
A progress reporter interface for use in multi-threaded environments.
Container for project specific data.
A name/value tuple with unique names and optional values.
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
#define NOT_IMPLEMENTED(aCaller)
Container that describes file type info.
std::vector< std::string > m_ExtensionsInDir
In case of folders: extensions of files inside.
bool m_IsFile
Whether the library is a folder or a file.
std::vector< std::string > m_FileExtensions
Filter used for file pickers if m_IsFile is true.