34#include <wx/filename.h>
38 PCB_IO( wxS(
"Easy-PC / DesignSpark PCB" ) )
49 return info.FileKind == aKind;
76 if( it !=
m_libraries.end() && it->second.Timestamp == stamp )
79 std::unique_ptr<EASYPC::LIBRARY_FILE> file = std::make_unique<EASYPC::LIBRARY_FILE>( aLibraryPath );
83 THROW_IO_ERROR( wxString::Format(
_(
"'%s' is not an Easy-PC PCB symbol library" ), aLibraryPath ) );
85 for(
const wxString& warning : file->Warnings() )
97 const std::map<std::string, UTF8>* aProperties )
102 for(
const wxString&
name :
library( aLibraryPath ).File->ItemNames() )
114 const std::map<std::string, UTF8>* aProperties )
121 const std::map<std::string, UTF8>* aProperties )
126 return it->second.get();
133 std::unique_ptr<EASYPC::LIBRARY_ITEM> item = lib.
File->
LoadItem( itemName );
136 if( !item->Streams.empty() )
142 wxString::Format(
_(
"Easy-PC library item '%s' in '%s' is not a symbol" ), itemName, aLibraryPath ) );
146 std::vector<const EASYPC::SOURCE_LAYER*> layers;
148 for(
const std::unique_ptr<EASYPC::OBJECT>& obj : item->Objects )
151 layers.push_back( layer );
156 std::unique_ptr<FOOTPRINT> footprint =
158 return ( lib.
Footprints[aFootprintName] = std::move( footprint ) ).get();
164 const std::map<std::string, UTF8>* aProperties )
172 return std::make_unique<FOOTPRINT>( *cached );
179 const std::map<std::string, UTF8>* aProperties,
PROJECT* aProject )
Information pertinent to a Pcbnew printed circuit board.
std::unique_ptr< LIBRARY_ITEM > LoadItem(const wxString &aItemName) const
Throws IO_ERROR if no item has that name.
bool HasItem(const wxString &aItemName) const
static long long Timestamp(const wxString &aPath)
A library file's modification time, 0 when it does not exist.
Layer mapping for one layer table, copper in stack order and other layers by their type.
const wxString & GetName() const
Return a brief hard coded name for this IO interface.
REPORTER * m_reporter
Reporter to log errors/warnings to, may be nullptr.
PROGRESS_REPORTER * m_progressReporter
Progress reporter to track the progress of the operation, may be nullptr.
virtual bool CanReadLibrary(const wxString &aFileName) const
Checks if this IO object can read the specified library file/directory.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
LAYER_MAPPING_HANDLER m_layer_mapping_handler
Callback to get layer mapping.
A logical library item identifier and consists of various portions much like a URI.
bool CanReadBoard(const wxString &aFileName) const override
bool FootprintExists(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Check for the existence of a footprint.
~PCB_IO_EASYPC() override
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Return a list of footprint names contained within the library at aLibraryPath.
LIBRARY & library(const wxString &aLibraryPath)
The parsed library, reread when its modification time changes.
const FOOTPRINT * GetEnumeratedFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management i...
bool CanReadLibrary(const wxString &aFileName) const override
Checks if this IO object can read the specified library file/directory.
void loadBoard(const wxString &aFileName, BOARD &aBoard, bool aIsNewLoad, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr) override
Parse aFileName into aBoard.
wxString m_importedDesignRules
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
std::unique_ptr< FOOTPRINT > FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PC...
std::map< wxString, LIBRARY > m_libraries
BOARD * m_board
The board BOARD being worked on, no ownership here.
virtual bool CanReadBoard(const wxString &aFileName) const
PCB_IO(const wxString &aName)
const std::map< std::string, UTF8 > * m_props
Properties passed via Save() or Load(), no ownership, may be NULL.
Container for project specific data.
Symbols, components and gates, embedded in designs or the single object of a library item stream.
Loading designs, library items and projects.
Easy-PC / DesignSpark items to KiCad board items, shared by the board builder and the ....
#define IGNORE_PARENT_GROUP
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
#define THROW_IO_CANCELLED()
std::unique_ptr< FOOTPRINT > ConvertFootprint(const SOURCE_SYMBOL &aSymbol, const LAYER_MAPPER &aLayers, const LIB_ID &aId, const SOURCE_PCB_COMPONENT *aComponent, std::map< const SOURCE_FREE_PAD *, PAD * > *aPadMap)
A footprint in symbol coordinates.
wxString BuildBoard(const DESIGN_DOCUMENT &aDocument, BOARD &aBoard, REPORTER *aReporter, const LAYER_MAPPING_HANDLER &aLayerMapping)
Fill aBoard from a loaded Easy-PC / DesignSpark PCB design.
FILE_INFO Probe(const wxString &aPath)
Identify a file; projects are parsed fully, while designs and libraries are only inspected....
std::unique_ptr< DESIGN_DOCUMENT > LoadDesign(const wxString &aPath)
FILE_KIND
The FileType strings the importer reads.
static bool isKind(const wxString &aFileName, EASYPC::FILE_KIND aKind)
PCB_IO for Number One Systems Easy-PC and RS DesignSpark PCB boards and symbol libraries (....
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
Footprints and schematic symbols alike.
std::unique_ptr< EASYPC::LIBRARY_FILE > File
std::map< wxString, std::unique_ptr< FOOTPRINT > > Footprints