51 static const std::vector<uint8_t> allegroVString = {
'a',
'l',
'l' };
52 static const size_t allegroVStringOffset = 0xf8;
62 static const std::vector<uint8_t> v16Magic = { 0x13, 0x00 };
63 static const std::vector<uint8_t> v17Magic = { 0x14, 0x00 };
64 static const std::vector<uint8_t> v18Magic = { 0x15, 0x00 };
65 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 } );
116 const std::map<std::string, UTF8>* aProperties,
PROJECT* aProject )
122 m_board->SetFileName( aFileName );
124 std::unique_ptr<BOARD> deleter( aAppendToMe ?
nullptr :
m_board );
126 std::unique_ptr<KIPLATFORM::IO::MAPPED_FILE> mappedFile;
130 mappedFile = std::make_unique<KIPLATFORM::IO::MAPPED_FILE>( aFileName );
132 catch(
const std::runtime_error& e )
137 if( !mappedFile->Data() || mappedFile->Size() == 0 )
138 THROW_IO_ERROR( wxString::Format( wxS(
"File is empty: %s" ), aFileName ) );
150 wxLogTrace(
traceAllegroPerf, wxT(
"=== Allegro Import Performance ===" ) );
154 std::unique_ptr<ALLEGRO::BRD_DB> brdDb = parser.
Parse();
171 wxLogTrace( wxT(
"KICAD_ALLEGRO" ),
"Phase 2 board construction failed" );
176 wxLogTrace( wxT(
"KICAD_ALLEGRO" ),
"Board construction completed successfully" );
177 wxLogTrace(
traceAllegroPerf, wxT(
"LoadBoard total (Phase 1 + Phase 2): %.3f ms" ), totalTimer.
msecs() );
179 m_board->m_LegacyNetclassesLoaded =
true;
180 m_board->m_LegacyDesignSettingsLoaded =
true;
182 (void) deleter.release();
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 RAW_BOARD, and handles any state involved in that parsi...
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.
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.
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.
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties, PROJECT *aProject) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
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.
static REPORTER & GetInstance()
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
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