25#include <wx/filename.h>
26#include <wx/translation.h>
33#define FMT_UNIMPLEMENTED wxT( "Plugin \"%s\" does not implement the \"%s\" function." )
34#define NOT_IMPLEMENTED( aCaller ) \
35 THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, \
37 wxString::FromUTF8( aCaller ) ) );
44 wxString fileExt = wxFileName( aFileName ).GetExt().MakeLower();
46 for(
const std::string& ext : exts )
48 if( fileExt == wxString( ext ).Lower() )
60 wxString fileExt = wxFileName( aFileName ).GetExt().MakeLower();
62 for(
const std::string& ext : exts )
64 if( fileExt == wxString( ext ).Lower() )
72std::unique_ptr<BOARD>
PCB_IO::LoadBoard(
const wxString& aFileName,
const std::map<std::string, UTF8>* aProperties,
75 std::unique_ptr<BOARD> newBoard = std::make_unique<BOARD>();
77 newBoard->SetFileName( aFileName );
79 loadBoard( aFileName, *newBoard,
true, aProperties, aProject );
86 const std::map<std::string, UTF8>* aProperties,
PROJECT* aProject )
88 loadBoard( aFileName, aAppendToMe,
false, aProperties, aProject );
93 const std::map<std::string, UTF8>* aProperties,
PROJECT* aProject )
113 bool aBestEfforts,
const std::map<std::string, UTF8>* aProperties )
121 const std::map<std::string, UTF8>* aProperties )
123 wxArrayString footprintNames;
127 if( footprintNames.empty() )
130 if( footprintNames.size() > 1 )
132 Report(
_(
"Selected file contains multiple footprints. Only the first one will be "
133 "imported.\nTo load all footprints, add it as a library using Preferences "
134 "-> Manage Footprint "
138 aFootprintNameOut = footprintNames.front();
140 return FootprintLoad( aFootprintPath, aFootprintNameOut,
false, aProperties );
145 const std::map<std::string, UTF8>* aProperties )
148 return FootprintLoad( aLibraryPath, aFootprintName,
false, aProperties ).release();
153 const std::map<std::string, UTF8>* aProperties )
156 return FootprintLoad( aLibraryPath, aFootprintName,
true, aProperties ) !=
nullptr;
161 bool aKeepUUID,
const std::map<std::string, UTF8>* aProperties )
170 const std::map<std::string, UTF8>* aProperties )
178 const std::map<std::string, UTF8>* aProperties )
192 (*aListToAppendTo)[
"debug_level"] =
UTF8(
_(
"Enable <b>debug</b> logging for Footprint*() "
193 "functions in this PCB_IO." ) );
195 (*aListToAppendTo)[
"read_filter_regex"] =
UTF8(
_(
"Regular expression <b>footprint name</b> "
198 (*aListToAppendTo)[
"enable_transaction_logging"] =
UTF8(
_(
"Enable transaction logging. The "
199 "mere presence of this option "
200 "turns on the logging, no need to "
203 (*aListToAppendTo)[
"username"] =
UTF8(
_(
"User name for <b>login</b> to some special library "
206 (*aListToAppendTo)[
"password"] =
UTF8(
_(
"Password for <b>login</b> to some special library "
213 (*aListToAppendTo)[
"python_footprint_plugin"] =
UTF8(
_(
"Enter the python module which "
214 "implements the PCB_IO::Footprint*() "
Information pertinent to a Pcbnew printed circuit board.
virtual void Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) const
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 std::unique_ptr< 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...
void LoadAndAppendBoard(const wxString &aFileName, BOARD &aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr)
Same as LoadBoard(), but appends the loaded board to an existing board, which must already exist.
virtual bool CanReadBoard(const wxString &aFileName) const
Checks if this PCB_IO can read the specified board file.
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 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 std::unique_ptr< 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 GetLibraryOptions(std::map< std::string, UTF8 > *aListToAppendTo) const override
Append supported PLUGIN options to aListToAppenTo along with internationalized descriptions.
std::unique_ptr< BOARD > LoadBoard(const wxString &aFileName, 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 new BOA...
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 void loadBoard(const wxString &aFileName, BOARD &aBoard, bool aIsNewLoad, const std::map< std::string, UTF8 > *aProperties, PROJECT *aProject)
Parse aFileName into aBoard.
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 i...
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 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.