From f92c1341a2de32f46a37b2ac24db19ab16336ee6 Mon Sep 17 00:00:00 2001 From: Thomas Pointhuber Date: Mon, 10 Jan 2022 13:59:20 +0100 Subject: [PATCH] altium: Move file loading from altium_pcb into altium_*_plugin --- .../altium/altium_circuit_maker_plugin.cpp | 16 +++++++++++++--- .../altium/altium_circuit_studio_plugin.cpp | 16 +++++++++++++--- .../plugins/altium/altium_designer_plugin.cpp | 16 +++++++++++++--- pcbnew/plugins/altium/altium_parser_pcb.cpp | 4 ++-- pcbnew/plugins/altium/altium_pcb.cpp | 17 ----------------- pcbnew/plugins/altium/altium_pcb.h | 12 ------------ 6 files changed, 41 insertions(+), 40 deletions(-) diff --git a/pcbnew/plugins/altium/altium_circuit_maker_plugin.cpp b/pcbnew/plugins/altium/altium_circuit_maker_plugin.cpp index 2d35262b2e..b2c72064ad 100644 --- a/pcbnew/plugins/altium/altium_circuit_maker_plugin.cpp +++ b/pcbnew/plugins/altium/altium_circuit_maker_plugin.cpp @@ -27,12 +27,11 @@ * @brief Pcbnew PLUGIN for Altium *.PcbDoc format. */ -#include - #include #include #include +#include "plugins/altium/altium_parser.h" #include @@ -100,7 +99,18 @@ BOARD* ALTIUM_CIRCUIT_MAKER_PLUGIN::Load( const wxString& aFileName, BOARD* aApp }; // clang-format on - ParseAltiumPcb( m_board, aFileName, aProgressReporter, mapping ); + ALTIUM_COMPOUND_FILE altiumPcbFile( aFileName ); + + try + { + // Parse File + ALTIUM_PCB pcb( m_board, aProgressReporter ); + pcb.Parse( altiumPcbFile, mapping ); + } + catch( CFB::CFBException& exception ) + { + THROW_IO_ERROR( exception.what() ); + } return m_board; } diff --git a/pcbnew/plugins/altium/altium_circuit_studio_plugin.cpp b/pcbnew/plugins/altium/altium_circuit_studio_plugin.cpp index 7f1cb5580a..7241057acf 100644 --- a/pcbnew/plugins/altium/altium_circuit_studio_plugin.cpp +++ b/pcbnew/plugins/altium/altium_circuit_studio_plugin.cpp @@ -27,12 +27,11 @@ * @brief Pcbnew PLUGIN for Altium *.PcbDoc format. */ -#include - #include #include #include +#include "plugins/altium/altium_parser.h" #include @@ -100,7 +99,18 @@ BOARD* ALTIUM_CIRCUIT_STUDIO_PLUGIN::Load( const wxString& aFileName, BOARD* aAp }; // clang-format on - ParseAltiumPcb( m_board, aFileName, aProgressReporter, mapping ); + ALTIUM_COMPOUND_FILE altiumPcbFile( aFileName ); + + try + { + // Parse File + ALTIUM_PCB pcb( m_board, aProgressReporter ); + pcb.Parse( altiumPcbFile, mapping ); + } + catch( CFB::CFBException& exception ) + { + THROW_IO_ERROR( exception.what() ); + } return m_board; } diff --git a/pcbnew/plugins/altium/altium_designer_plugin.cpp b/pcbnew/plugins/altium/altium_designer_plugin.cpp index e603105c10..a9c329bf3c 100644 --- a/pcbnew/plugins/altium/altium_designer_plugin.cpp +++ b/pcbnew/plugins/altium/altium_designer_plugin.cpp @@ -27,12 +27,11 @@ * @brief Pcbnew PLUGIN for Altium *.PcbDoc format. */ -#include - #include #include #include +#include "plugins/altium/altium_parser.h" #include @@ -100,7 +99,18 @@ BOARD* ALTIUM_DESIGNER_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendTo }; // clang-format on - ParseAltiumPcb( m_board, aFileName, aProgressReporter, mapping ); + ALTIUM_COMPOUND_FILE altiumPcbFile( aFileName ); + + try + { + // Parse File + ALTIUM_PCB pcb( m_board, aProgressReporter ); + pcb.Parse( altiumPcbFile, mapping ); + } + catch( CFB::CFBException& exception ) + { + THROW_IO_ERROR( exception.what() ); + } return m_board; } diff --git a/pcbnew/plugins/altium/altium_parser_pcb.cpp b/pcbnew/plugins/altium/altium_parser_pcb.cpp index 629eb8d221..de1a4595c9 100644 --- a/pcbnew/plugins/altium/altium_parser_pcb.cpp +++ b/pcbnew/plugins/altium/altium_parser_pcb.cpp @@ -338,7 +338,7 @@ AMODEL::AMODEL( ALTIUM_PARSER& aReader ) std::map properties = aReader.ReadProperties(); if( properties.empty() ) - THROW_IO_ERROR( "Classes6 stream has no properties!" ); + THROW_IO_ERROR( "Model stream has no properties!" ); name = ALTIUM_PARSER::ReadString( properties, "NAME", "" ); id = ALTIUM_PARSER::ReadString( properties, "ID", "" ); @@ -349,7 +349,7 @@ AMODEL::AMODEL( ALTIUM_PARSER& aReader ) rotation.z = ALTIUM_PARSER::ReadDouble( properties, "ROTZ", 0. ); if( aReader.HasParsingError() ) - THROW_IO_ERROR( "Classes6 stream was not parsed correctly" ); + THROW_IO_ERROR( "Model stream was not parsed correctly" ); } ANET6::ANET6( ALTIUM_PARSER& aReader ) diff --git a/pcbnew/plugins/altium/altium_pcb.cpp b/pcbnew/plugins/altium/altium_pcb.cpp index 20319ed56d..fe7734a5d6 100644 --- a/pcbnew/plugins/altium/altium_pcb.cpp +++ b/pcbnew/plugins/altium/altium_pcb.cpp @@ -57,23 +57,6 @@ constexpr double BOLD_FACTOR = 1.75; // CSS font-weight-normal is 400; bold is 700 -void ParseAltiumPcb( BOARD* aBoard, const wxString& aFileName, PROGRESS_REPORTER* aProgressReporter, - const std::map& aFileMapping ) -{ - ALTIUM_COMPOUND_FILE altiumPcbFile( aFileName ); - - try - { - // Parse File - ALTIUM_PCB pcb( aBoard, aProgressReporter ); - pcb.Parse( altiumPcbFile, aFileMapping ); - } - catch( CFB::CFBException& exception ) - { - THROW_IO_ERROR( exception.what() ); - } -} - void ParseAltiumPcbLibFootprintNames( wxArrayString& aFootprintNames, const wxString& aLibraryPath ) { diff --git a/pcbnew/plugins/altium/altium_pcb.h b/pcbnew/plugins/altium/altium_pcb.h index 99d13d8831..eda806519d 100644 --- a/pcbnew/plugins/altium/altium_pcb.h +++ b/pcbnew/plugins/altium/altium_pcb.h @@ -88,18 +88,6 @@ class ZONE; class PCB_DIM_RADIAL; class PROGRESS_REPORTER; - -/** - * Helper method which opens a Altium Board File and parses it. - * - * @param aBoard board the pcb should be appended to - * @param aFileName file name of board file - * @param aProgressReporter report import progress, might be a nullptr. - * @param aFileMapping mapping how altium stream names are mapped - */ -void ParseAltiumPcb( BOARD* aBoard, const wxString& aFileName, PROGRESS_REPORTER* aProgressReporter, - const std::map& aFileMapping ); - /** * Helper method to get all footprint names in a given library *