47 static const std::vector<uint8_t> allegroVString = {
'a',
'l',
'l' };
48 static const size_t allegroVStringOffset = 0xf8;
58 static const std::vector<uint8_t> v16Magic = { 0x13, 0x00 };
59 static const std::vector<uint8_t> v17Magic = { 0x14, 0x00 };
60 static const std::vector<uint8_t> v18Magic = { 0x15, 0x00 };
61 static const std::vector<uint8_t> v19Magic = { 0x16, 0x00 };
62 static const size_t magicMajorOffset = 2;
77static std::map<wxString, PCB_LAYER_ID>
80 std::map<wxString, PCB_LAYER_ID> retval;
83 retval.insert( { layerDesc.Name, layerDesc.AutoMapLayer } );
114 const std::map<std::string, UTF8>* aProperties,
PROJECT* aProject )
119 std::unique_ptr<KIPLATFORM::IO::MAPPED_FILE> mappedFile;
123 mappedFile = std::make_unique<KIPLATFORM::IO::MAPPED_FILE>( aFileName );
125 catch(
const std::runtime_error& e )
130 if( !mappedFile->Data() || mappedFile->Size() == 0 )
134 THROW_IO_ERRORF(
_(
"Failed to load Allegro board from file: %s" ), aFileName );
150 wxLogTrace(
traceAllegroPerf, wxT(
"=== Allegro Import Performance ===" ) );
154 std::unique_ptr<ALLEGRO::BRD_DB> brdDb = parser.
Parse();
172 wxLogTrace( wxT(
"KICAD_ALLEGRO" ),
"Phase 2 board construction failed" );
177 wxLogTrace( wxT(
"KICAD_ALLEGRO" ),
"Board construction completed successfully" );
178 wxLogTrace(
traceAllegroPerf, wxT(
"LoadBoard total (Phase 1 + Phase 2): %.3f ms" ), totalTimer.
msecs() );
Class that builds a KiCad board from a BRD_DB (= FILE_HEADER + STRINGS + OBJECTS + bookkeeping)
Stream that reads primitive types from a memory buffer containing Allegro .brd (or ....
Class that parses a single FILE_STREAM into a BRD_DB, and handles any state involved in that parsing.
std::unique_ptr< BRD_DB > Parse()
void EndAtUnknownBlock(bool aEndAtUnknownBlock)
When set to true, the parser will stop at the first unknown block, rather than throwing an error.
Information pertinent to a Pcbnew printed circuit board.
bool m_LegacyDesignSettingsLoaded
True if the legacy board design settings were loaded from a file.
bool m_LegacyNetclassesLoaded
True if netclasses were loaded from the file.
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.
virtual void RegisterCallback(LAYER_MAPPING_HANDLER aLayerMappingHandler)
Register a different handler to be called when mapping of input layers to KiCad layers occurs.
LAYER_MAPPING_HANDLER m_layer_mapping_handler
Callback to get layer mapping.
static REPORTER & GetInstance()
bool CanReadBoard(const wxString &aFileName) const override
Checks if this PCB_IO can read the specified board file.
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, PROJECT *aProject) override
Parse aFileName into aBoard.
bool LoadBoardFromData(const uint8_t *aData, size_t aSize, BOARD &aBoard)
BOARD * m_board
The board BOARD being worked on, no ownership here.
virtual bool CanReadBoard(const wxString &aFileName) const
Checks if this PCB_IO can read the specified board file.
PCB_IO(const wxString &aName)
const std::map< std::string, UTF8 > * m_props
Properties passed via Save() or Load(), no ownership, may be NULL.
A small class to help profiling.
void Stop()
Save the time when this function was called, and set the counter stane to stop.
void Start()
Start or restart the counter.
double msecs(bool aSinceLast=false)
Container for project specific data.
A pure virtual class used to derive REPORTER objects from.
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
#define THROW_IO_ERRORF(msg,...)
bool fileHasBinaryHeader(const wxString &aFilePath, const std::vector< uint8_t > &aHeader, size_t aOffset)
Check if a file starts with a defined binary header.
static std::map< wxString, PCB_LAYER_ID > allegroDefaultLayerMappingCallback(const std::vector< INPUT_LAYER_DESC > &aInputLayerDescriptionVector)
static bool checkFileHeader(const wxString &aFileName)
static const wxChar *const traceAllegroPerf
IbisParser parser & reporter