Push PCB_IOs to use the base progress reporter instead of per-function

This commit is contained in:
Ian McInerney 2023-12-27 17:06:23 +00:00
parent 4a67761d29
commit d7fe668d79
34 changed files with 90 additions and 128 deletions

View File

@ -291,8 +291,9 @@ void DIALOG_BOARD_SETUP::onAuxiliaryAction( wxCommandEvent& aEvent )
{ {
WX_PROGRESS_REPORTER progressReporter( this, _( "Loading PCB" ), 1 ); WX_PROGRESS_REPORTER progressReporter( this, _( "Loading PCB" ), 1 );
otherBoard = pi->LoadBoard( boardFn.GetFullPath(), nullptr, nullptr, nullptr, pi->SetProgressReporter( &progressReporter );
&progressReporter );
otherBoard = pi->LoadBoard( boardFn.GetFullPath(), nullptr );
if( importDlg.m_LayersOpt->GetValue() ) if( importDlg.m_LayersOpt->GetValue() )
{ {

View File

@ -675,7 +675,8 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
unsigned startTime = GetRunningMicroSecs(); unsigned startTime = GetRunningMicroSecs();
#endif #endif
loadedBoard = pi->LoadBoard( fullFileName, nullptr, &props, &Prj(), &progressReporter ); pi->SetProgressReporter( &progressReporter );
loadedBoard = pi->LoadBoard( fullFileName, nullptr, &props, &Prj() );
#if USE_INSTRUMENTATION #if USE_INSTRUMENTATION
unsigned stopTime = GetRunningMicroSecs(); unsigned stopTime = GetRunningMicroSecs();
@ -1273,8 +1274,8 @@ void PCB_EDIT_FRAME::GenIPC2581File( wxCommandEvent& event )
try try
{ {
PCB_IO::RELEASER pi( PCB_IO_MGR::PluginFind( PCB_IO_MGR::IPC2581 ) ); PCB_IO::RELEASER pi( PCB_IO_MGR::PluginFind( PCB_IO_MGR::IPC2581 ) );
pi->SetProgressReporter( &reporter );
pi->SaveBoard( tempFile, GetBoard(), &props, &reporter ); pi->SaveBoard( tempFile, GetBoard(), &props );
return true; return true;
} }
catch( const IO_ERROR& ioe ) catch( const IO_ERROR& ioe )

View File

@ -330,8 +330,7 @@ BOARD_ITEM* CLIPBOARD_IO::Parse()
void CLIPBOARD_IO::SaveBoard( const wxString& aFileName, BOARD* aBoard, void CLIPBOARD_IO::SaveBoard( const wxString& aFileName, BOARD* aBoard,
const STRING_UTF8_MAP* aProperties, const STRING_UTF8_MAP* aProperties )
PROGRESS_REPORTER* aProgressReporter )
{ {
init( aProperties ); init( aProperties );
@ -376,8 +375,7 @@ void CLIPBOARD_IO::SaveBoard( const wxString& aFileName, BOARD* aBoard,
BOARD* CLIPBOARD_IO::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* CLIPBOARD_IO::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties, PROJECT* aProject, const STRING_UTF8_MAP* aProperties, PROJECT* aProject )
PROGRESS_REPORTER* aProgressReporter )
{ {
std::string result; std::string result;

View File

@ -48,8 +48,7 @@ public:
* Saves the entire board to the clipboard formatted using the PCB_IO_KICAD_SEXPR formatting * Saves the entire board to the clipboard formatted using the PCB_IO_KICAD_SEXPR formatting
*/ */
void SaveBoard( const wxString& aFileName, BOARD* aBoard, void SaveBoard( const wxString& aFileName, BOARD* aBoard,
const STRING_UTF8_MAP* aProperties = nullptr, const STRING_UTF8_MAP* aProperties = nullptr ) override;
PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
/* /*
* Write all the settings of the BOARD* set by setBoard() and then adds all the * Write all the settings of the BOARD* set by setBoard() and then adds all the
@ -60,8 +59,7 @@ public:
BOARD_ITEM* Parse(); BOARD_ITEM* Parse();
BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr, const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr ) override;
PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
void SetBoard( BOARD* aBoard ); void SetBoard( BOARD* aBoard );

View File

@ -60,8 +60,7 @@ bool PCB_IO_ALTIUM_CIRCUIT_MAKER::CanReadBoard( const wxString& aFileName ) cons
BOARD* PCB_IO_ALTIUM_CIRCUIT_MAKER::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* PCB_IO_ALTIUM_CIRCUIT_MAKER::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties, const STRING_UTF8_MAP* aProperties,
PROJECT* aProject, PROJECT* aProject )
PROGRESS_REPORTER* aProgressReporter )
{ {
m_props = aProperties; m_props = aProperties;
@ -101,7 +100,7 @@ BOARD* PCB_IO_ALTIUM_CIRCUIT_MAKER::LoadBoard( const wxString& aFileName, BOARD*
try try
{ {
// Parse File // Parse File
ALTIUM_PCB pcb( m_board, aProgressReporter ); ALTIUM_PCB pcb( m_board, m_progressReporter );
pcb.Parse( altiumPcbFile, mapping ); pcb.Parse( altiumPcbFile, mapping );
} }
catch( CFB::CFBException& exception ) catch( CFB::CFBException& exception )

View File

@ -46,8 +46,7 @@ public:
bool CanReadBoard( const wxString& aFileName ) const override; bool CanReadBoard( const wxString& aFileName ) const override;
BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties, PROJECT* aProject = nullptr, const STRING_UTF8_MAP* aProperties, PROJECT* aProject = nullptr ) override;
PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override
{ {

View File

@ -60,8 +60,7 @@ bool PCB_IO_ALTIUM_CIRCUIT_STUDIO::CanReadBoard( const wxString& aFileName ) con
BOARD* PCB_IO_ALTIUM_CIRCUIT_STUDIO::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* PCB_IO_ALTIUM_CIRCUIT_STUDIO::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties, const STRING_UTF8_MAP* aProperties,
PROJECT* aProject, PROJECT* aProject )
PROGRESS_REPORTER* aProgressReporter )
{ {
m_props = aProperties; m_props = aProperties;
@ -101,7 +100,7 @@ BOARD* PCB_IO_ALTIUM_CIRCUIT_STUDIO::LoadBoard( const wxString& aFileName, BOARD
try try
{ {
// Parse File // Parse File
ALTIUM_PCB pcb( m_board, aProgressReporter ); ALTIUM_PCB pcb( m_board, m_progressReporter );
pcb.Parse( altiumPcbFile, mapping ); pcb.Parse( altiumPcbFile, mapping );
} }
catch( CFB::CFBException& exception ) catch( CFB::CFBException& exception )

View File

@ -45,8 +45,7 @@ public:
bool CanReadBoard( const wxString& aFileName ) const override; bool CanReadBoard( const wxString& aFileName ) const override;
BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties, PROJECT* aProject, const STRING_UTF8_MAP* aProperties, PROJECT* aProject ) override;
PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override
{ {

View File

@ -75,8 +75,7 @@ bool PCB_IO_ALTIUM_DESIGNER::CanReadLibrary( const wxString& aFileName ) const
BOARD* PCB_IO_ALTIUM_DESIGNER::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* PCB_IO_ALTIUM_DESIGNER::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties, PROJECT* aProject, const STRING_UTF8_MAP* aProperties, PROJECT* aProject )
PROGRESS_REPORTER* aProgressReporter )
{ {
m_props = aProperties; m_props = aProperties;
@ -117,7 +116,7 @@ BOARD* PCB_IO_ALTIUM_DESIGNER::LoadBoard( const wxString& aFileName, BOARD* aApp
try try
{ {
// Parse File // Parse File
ALTIUM_PCB pcb( m_board, aProgressReporter ); ALTIUM_PCB pcb( m_board, m_progressReporter );
pcb.Parse( altiumPcbFile, mapping ); pcb.Parse( altiumPcbFile, mapping );
} }
catch( CFB::CFBException& exception ) catch( CFB::CFBException& exception )

View File

@ -52,8 +52,7 @@ public:
bool CanReadLibrary( const wxString& aFileName ) const override; bool CanReadLibrary( const wxString& aFileName ) const override;
BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties, PROJECT* aProject = nullptr, const STRING_UTF8_MAP* aProperties, PROJECT* aProject = nullptr ) override;
PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override; long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;

View File

@ -50,8 +50,7 @@ bool PCB_IO_SOLIDWORKS::CanReadBoard( const wxString& aFileName ) const
BOARD* PCB_IO_SOLIDWORKS::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* PCB_IO_SOLIDWORKS::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties, PROJECT* aProject, const STRING_UTF8_MAP* aProperties, PROJECT* aProject )
PROGRESS_REPORTER* aProgressReporter )
{ {
m_props = aProperties; m_props = aProperties;
@ -120,7 +119,7 @@ BOARD* PCB_IO_SOLIDWORKS::LoadBoard( const wxString& aFileName, BOARD* aAppendTo
try try
{ {
// Parse File // Parse File
ALTIUM_PCB pcb( m_board, aProgressReporter ); ALTIUM_PCB pcb( m_board, m_progressReporter );
pcb.Parse( altiumPcbFile, mapping ); pcb.Parse( altiumPcbFile, mapping );
} }
catch( CFB::CFBException& exception ) catch( CFB::CFBException& exception )

View File

@ -40,8 +40,7 @@ public:
bool CanReadBoard( const wxString& aFileName ) const override; bool CanReadBoard( const wxString& aFileName ) const override;
BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties, PROJECT* aProject = nullptr, const STRING_UTF8_MAP* aProperties, PROJECT* aProject = nullptr ) override;
PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override
{ {

View File

@ -94,15 +94,14 @@ std::vector<FOOTPRINT*> PCB_IO_CADSTAR_ARCHIVE::GetImportedCachedLibraryFootprin
BOARD* PCB_IO_CADSTAR_ARCHIVE::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* PCB_IO_CADSTAR_ARCHIVE::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties, PROJECT* aProject, const STRING_UTF8_MAP* aProperties, PROJECT* aProject )
PROGRESS_REPORTER* aProgressReporter )
{ {
m_props = aProperties; m_props = aProperties;
m_board = aAppendToMe ? aAppendToMe : new BOARD(); m_board = aAppendToMe ? aAppendToMe : new BOARD();
clearLoadedFootprints(); clearLoadedFootprints();
CADSTAR_PCB_ARCHIVE_LOADER tempPCB( aFileName, m_layer_mapping_handler, CADSTAR_PCB_ARCHIVE_LOADER tempPCB( aFileName, m_layer_mapping_handler,
m_show_layer_mapping_warnings, aProgressReporter ); m_show_layer_mapping_warnings, m_progressReporter );
tempPCB.Load( m_board, aProject ); tempPCB.Load( m_board, aProject );
//center the board: //center the board:

View File

@ -44,8 +44,7 @@ public:
bool CanReadFootprint( const wxString& aFileName ) const override; bool CanReadFootprint( const wxString& aFileName ) const override;
BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr, const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr ) override;
PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
std::vector<FOOTPRINT*> GetImportedCachedLibraryFootprints() override; std::vector<FOOTPRINT*> GetImportedCachedLibraryFootprints() override;

View File

@ -321,8 +321,7 @@ VECTOR2I inline PCB_IO_EAGLE::kicad_fontsize( const ECOORD& d, int aTextThicknes
BOARD* PCB_IO_EAGLE::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* PCB_IO_EAGLE::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties, PROJECT* aProject, const STRING_UTF8_MAP* aProperties, PROJECT* aProject )
PROGRESS_REPORTER* aProgressReporter )
{ {
LOCALE_IO toggle; // toggles on, then off, the C locale. LOCALE_IO toggle; // toggles on, then off, the C locale.
wxXmlNode* doc; wxXmlNode* doc;
@ -330,7 +329,6 @@ BOARD* PCB_IO_EAGLE::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
init( aProperties ); init( aProperties );
m_board = aAppendToMe ? aAppendToMe : new BOARD(); m_board = aAppendToMe ? aAppendToMe : new BOARD();
m_progressReporter = aProgressReporter;
// Give the filename to the board if it's new // Give the filename to the board if it's new
if( !aAppendToMe ) if( !aAppendToMe )

View File

@ -146,8 +146,7 @@ public:
bool CanReadFootprint( const wxString& aFileName ) const override; bool CanReadFootprint( const wxString& aFileName ) const override;
BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr, const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr ) override;
PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
std::vector<FOOTPRINT*> GetImportedCachedLibraryFootprints() override; std::vector<FOOTPRINT*> GetImportedCachedLibraryFootprints() override;

View File

@ -133,8 +133,7 @@ bool PCB_IO_EASYEDA::CanReadLibrary( const wxString& aFileName ) const
BOARD* PCB_IO_EASYEDA::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* PCB_IO_EASYEDA::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties, PROJECT* aProject, const STRING_UTF8_MAP* aProperties, PROJECT* aProject )
PROGRESS_REPORTER* aProgressReporter )
{ {
m_loadedFootprints.clear(); m_loadedFootprints.clear();
@ -145,11 +144,11 @@ BOARD* PCB_IO_EASYEDA::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
if( !aAppendToMe ) if( !aAppendToMe )
m_board->SetFileName( aFileName ); m_board->SetFileName( aFileName );
if( aProgressReporter ) if( m_progressReporter )
{ {
aProgressReporter->Report( wxString::Format( _( "Loading %s..." ), aFileName ) ); m_progressReporter->Report( wxString::Format( _( "Loading %s..." ), aFileName ) );
if( !aProgressReporter->KeepRefreshing() ) if( !m_progressReporter->KeepRefreshing() )
THROW_IO_ERROR( _( "Open cancelled by user." ) ); THROW_IO_ERROR( _( "Open cancelled by user." ) );
} }

View File

@ -48,8 +48,7 @@ public:
bool CanReadLibrary( const wxString& aFileName ) const override; bool CanReadLibrary( const wxString& aFileName ) const override;
BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr, const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr ) override;
PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override; long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;

View File

@ -98,8 +98,7 @@ bool PCB_IO_EASYEDAPRO::CanReadBoard( const wxString& aFileName ) const
BOARD* PCB_IO_EASYEDAPRO::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* PCB_IO_EASYEDAPRO::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties, PROJECT* aProject, const STRING_UTF8_MAP* aProperties, PROJECT* aProject )
PROGRESS_REPORTER* aProgressReporter )
{ {
m_props = aProperties; m_props = aProperties;
@ -109,11 +108,11 @@ BOARD* PCB_IO_EASYEDAPRO::LoadBoard( const wxString& aFileName, BOARD* aAppendTo
if( !aAppendToMe ) if( !aAppendToMe )
m_board->SetFileName( aFileName ); m_board->SetFileName( aFileName );
if( aProgressReporter ) if( m_progressReporter )
{ {
aProgressReporter->Report( wxString::Format( _( "Loading %s..." ), aFileName ) ); m_progressReporter->Report( wxString::Format( _( "Loading %s..." ), aFileName ) );
if( !aProgressReporter->KeepRefreshing() ) if( !m_progressReporter->KeepRefreshing() )
THROW_IO_ERROR( _( "Open cancelled by user." ) ); THROW_IO_ERROR( _( "Open cancelled by user." ) );
} }

View File

@ -55,8 +55,7 @@ public:
bool CanReadBoard( const wxString& aFileName ) const override; bool CanReadBoard( const wxString& aFileName ) const override;
BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr, const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr ) override;
PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override; long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;

View File

@ -44,8 +44,7 @@ PCB_IO_FABMASTER::~PCB_IO_FABMASTER()
BOARD* PCB_IO_FABMASTER::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* PCB_IO_FABMASTER::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties, PROJECT* aProject, const STRING_UTF8_MAP* aProperties, PROJECT* aProject )
PROGRESS_REPORTER* aProgressReporter )
{ {
m_props = aProperties; m_props = aProperties;
@ -55,11 +54,11 @@ BOARD* PCB_IO_FABMASTER::LoadBoard( const wxString& aFileName, BOARD* aAppendToM
if( !aAppendToMe ) if( !aAppendToMe )
m_board->SetFileName( aFileName ); m_board->SetFileName( aFileName );
if( aProgressReporter ) if( m_progressReporter )
{ {
aProgressReporter->Report( wxString::Format( _( "Loading %s..." ), aFileName ) ); m_progressReporter->Report( wxString::Format( _( "Loading %s..." ), aFileName ) );
if( !aProgressReporter->KeepRefreshing() ) if( !m_progressReporter->KeepRefreshing() )
THROW_IO_ERROR( _( "Open cancelled by user." ) ); THROW_IO_ERROR( _( "Open cancelled by user." ) );
} }
@ -72,7 +71,7 @@ BOARD* PCB_IO_FABMASTER::LoadBoard( const wxString& aFileName, BOARD* aAppendToM
} }
m_fabmaster.Process(); m_fabmaster.Process();
m_fabmaster.LoadBoard( m_board, aProgressReporter ); m_fabmaster.LoadBoard( m_board, m_progressReporter );
return m_board; return m_board;
} }

View File

@ -45,8 +45,7 @@ public:
} }
BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr, const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr ) override;
PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override
{ {

View File

@ -301,8 +301,8 @@ wxXmlNode* PCB_IO_IPC2581::generateXmlHeader()
wxXmlNode* PCB_IO_IPC2581::generateContentSection() wxXmlNode* PCB_IO_IPC2581::generateContentSection()
{ {
if( m_progress_reporter ) if( m_progressReporter )
m_progress_reporter->AdvancePhase( _( "Generating content section" ) ); m_progressReporter->AdvancePhase( _( "Generating content section" ) );
wxXmlNode* contentNode = appendNode( m_xml_root, "Content" ); wxXmlNode* contentNode = appendNode( m_xml_root, "Content" );
addAttribute( contentNode, "roleRef", "Owner" ); addAttribute( contentNode, "roleRef", "Owner" );
@ -1116,8 +1116,8 @@ wxXmlNode* PCB_IO_IPC2581::generateLogisticSection()
wxXmlNode* PCB_IO_IPC2581::generateHistorySection() wxXmlNode* PCB_IO_IPC2581::generateHistorySection()
{ {
if( m_progress_reporter ) if( m_progressReporter )
m_progress_reporter->AdvancePhase( _( "Generating history section" ) ); m_progressReporter->AdvancePhase( _( "Generating history section" ) );
wxXmlNode* historyNode = appendNode( m_xml_root, "HistoryRecord" ); wxXmlNode* historyNode = appendNode( m_xml_root, "HistoryRecord" );
addAttribute( historyNode, "number", "1" ); addAttribute( historyNode, "number", "1" );
@ -1143,8 +1143,8 @@ wxXmlNode* PCB_IO_IPC2581::generateHistorySection()
wxXmlNode* PCB_IO_IPC2581::generateBOMSection( wxXmlNode* aEcadNode ) wxXmlNode* PCB_IO_IPC2581::generateBOMSection( wxXmlNode* aEcadNode )
{ {
if( m_progress_reporter ) if( m_progressReporter )
m_progress_reporter->AdvancePhase( _( "Generating BOM section" ) ); m_progressReporter->AdvancePhase( _( "Generating BOM section" ) );
struct REFDES struct REFDES
{ {
@ -1307,8 +1307,8 @@ wxXmlNode* PCB_IO_IPC2581::generateBOMSection( wxXmlNode* aEcadNode )
wxXmlNode* PCB_IO_IPC2581::generateEcadSection() wxXmlNode* PCB_IO_IPC2581::generateEcadSection()
{ {
if( m_progress_reporter ) if( m_progressReporter )
m_progress_reporter->AdvancePhase( _( "Generating CAD data" ) ); m_progressReporter->AdvancePhase( _( "Generating CAD data" ) );
wxXmlNode* ecadNode = appendNode( m_xml_root, "Ecad" ); wxXmlNode* ecadNode = appendNode( m_xml_root, "Ecad" );
addAttribute( ecadNode, "name", "Design" ); addAttribute( ecadNode, "name", "Design" );
@ -2339,20 +2339,20 @@ void PCB_IO_IPC2581::generateLayerFeatures( wxXmlNode* aStepNode )
for( PCB_LAYER_ID layer : layers ) for( PCB_LAYER_ID layer : layers )
{ {
if( m_progress_reporter ) if( m_progressReporter )
m_progress_reporter->SetMaxProgress( nets.GetNetCount() * layers.size() ); m_progressReporter->SetMaxProgress( nets.GetNetCount() * layers.size() );
wxXmlNode* layerNode = appendNode( aStepNode, "LayerFeature" ); wxXmlNode* layerNode = appendNode( aStepNode, "LayerFeature" );
addAttribute( layerNode, "layerRef", m_layer_name_map[layer] ); addAttribute( layerNode, "layerRef", m_layer_name_map[layer] );
for( const NETINFO_ITEM* net : nets ) for( const NETINFO_ITEM* net : nets )
{ {
if( m_progress_reporter ) if( m_progressReporter )
{ {
m_progress_reporter->Report( wxString::Format( _( "Exporting Layer %s, Net %s" ), m_progressReporter->Report( wxString::Format( _( "Exporting Layer %s, Net %s" ),
m_board->GetLayerName( layer ), m_board->GetLayerName( layer ),
net->GetNetname() ) ); net->GetNetname() ) );
m_progress_reporter->AdvanceProgress(); m_progressReporter->AdvanceProgress();
} }
std::vector<BOARD_ITEM*>& vec = elements[layer][net->GetNetCode()]; std::vector<BOARD_ITEM*>& vec = elements[layer][net->GetNetCode()];
@ -2735,8 +2735,8 @@ void PCB_IO_IPC2581::generateLayerSetNet( wxXmlNode* aLayerNode, PCB_LAYER_ID aL
wxXmlNode* PCB_IO_IPC2581::generateAvlSection() wxXmlNode* PCB_IO_IPC2581::generateAvlSection()
{ {
if( m_progress_reporter ) if( m_progressReporter )
m_progress_reporter->AdvancePhase( _( "Generating BOM section" ) ); m_progressReporter->AdvancePhase( _( "Generating BOM section" ) );
wxXmlNode* avl = appendNode( m_xml_root, "Avl" ); wxXmlNode* avl = appendNode( m_xml_root, "Avl" );
addAttribute( avl, "name", "Primary_Vendor_List" ); addAttribute( avl, "name", "Primary_Vendor_List" );
@ -2827,14 +2827,12 @@ wxXmlNode* PCB_IO_IPC2581::generateAvlSection()
void PCB_IO_IPC2581::SaveBoard( const wxString& aFileName, BOARD* aBoard, void PCB_IO_IPC2581::SaveBoard( const wxString& aFileName, BOARD* aBoard,
const STRING_UTF8_MAP* aProperties, const STRING_UTF8_MAP* aProperties )
PROGRESS_REPORTER* aProgressReporter )
{ {
m_board = aBoard; m_board = aBoard;
m_units_str = "MILLIMETER"; m_units_str = "MILLIMETER";
m_scale = 1.0 / PCB_IU_PER_MM; m_scale = 1.0 / PCB_IU_PER_MM;
m_sigfig = 4; m_sigfig = 4;
m_progress_reporter = aProgressReporter;
if( auto it = aProperties->find( "units" ); it != aProperties->end() ) if( auto it = aProperties->find( "units" ); it != aProperties->end() )
{ {
@ -2889,11 +2887,11 @@ void PCB_IO_IPC2581::SaveBoard( const wxString& aFileName, BOARD* aBoard,
generateContentSection(); generateContentSection();
if( m_progress_reporter ) if( m_progressReporter )
{ {
m_progress_reporter->SetNumPhases( 7 ); m_progressReporter->SetNumPhases( 7 );
m_progress_reporter->BeginPhase( 1 ); m_progressReporter->BeginPhase( 1 );
m_progress_reporter->Report( _( "Generating logistic section" ) ); m_progressReporter->Report( _( "Generating logistic section" ) );
} }
generateLogisticSection(); generateLogisticSection();
@ -2903,9 +2901,9 @@ void PCB_IO_IPC2581::SaveBoard( const wxString& aFileName, BOARD* aBoard,
generateBOMSection( ecad_node ); generateBOMSection( ecad_node );
generateAvlSection(); generateAvlSection();
if( m_progress_reporter ) if( m_progressReporter )
{ {
m_progress_reporter->AdvancePhase( _( "Saving file" ) ); m_progressReporter->AdvancePhase( _( "Saving file" ) );
} }
wxFileOutputStreamWithProgress out_stream( aFileName ); wxFileOutputStreamWithProgress out_stream( aFileName );
@ -2922,13 +2920,13 @@ void PCB_IO_IPC2581::SaveBoard( const wxString& aFileName, BOARD* aBoard,
written_bytes += aBytes; written_bytes += aBytes;
double percent = written_bytes / static_cast<double>( m_total_bytes ); double percent = written_bytes / static_cast<double>( m_total_bytes );
if( m_progress_reporter ) if( m_progressReporter )
{ {
// Only update every percent // Only update every percent
if( last_yield + 0.01 < percent ) if( last_yield + 0.01 < percent )
{ {
last_yield = percent; last_yield = percent;
m_progress_reporter->SetCurrentProgress( percent ); m_progressReporter->SetCurrentProgress( percent );
} }
} }
}; };

View File

@ -78,12 +78,10 @@ public:
* *
*/ */
// BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, // BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
// const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr, // const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr ) override;
// PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
void SaveBoard( const wxString& aFileName, BOARD* aBoard, void SaveBoard( const wxString& aFileName, BOARD* aBoard,
const STRING_UTF8_MAP* aProperties = nullptr, const STRING_UTF8_MAP* aProperties = nullptr ) override;
PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override
{ {

View File

@ -466,8 +466,7 @@ bool PCB_IO_KICAD_LEGACY::CanReadFootprint( const wxString& aFileName ) const
BOARD* PCB_IO_KICAD_LEGACY::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* PCB_IO_KICAD_LEGACY::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties, PROJECT* aProject, const STRING_UTF8_MAP* aProperties, PROJECT* aProject )
PROGRESS_REPORTER* aProgressReporter )
{ {
LOCALE_IO toggle; // toggles on, then off, the C locale. LOCALE_IO toggle; // toggles on, then off, the C locale.
@ -492,7 +491,6 @@ BOARD* PCB_IO_KICAD_LEGACY::LoadBoard( const wxString& aFileName, BOARD* aAppend
FILE_LINE_READER reader( aFileName ); FILE_LINE_READER reader( aFileName );
m_reader = &reader; m_reader = &reader;
m_progressReporter = aProgressReporter;
m_loading_format_version = getVersion( m_reader ); m_loading_format_version = getVersion( m_reader );
m_board->SetFileFormatVersionAtLoad( m_loading_format_version ); m_board->SetFileFormatVersionAtLoad( m_loading_format_version );

View File

@ -80,8 +80,7 @@ public:
bool CanReadFootprint( const wxString& aFileName ) const override; bool CanReadFootprint( const wxString& aFileName ) const override;
BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr, const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr ) override;
PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath, void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
bool aBestEfforts, bool aBestEfforts,

View File

@ -294,8 +294,7 @@ bool PCB_IO_KICAD_SEXPR::CanReadBoard( const wxString& aFileName ) const
void PCB_IO_KICAD_SEXPR::SaveBoard( const wxString& aFileName, BOARD* aBoard, void PCB_IO_KICAD_SEXPR::SaveBoard( const wxString& aFileName, BOARD* aBoard,
const STRING_UTF8_MAP* aProperties, const STRING_UTF8_MAP* aProperties )
PROGRESS_REPORTER* aProgressReporter )
{ {
LOCALE_IO toggle; // toggles on, then off, the C locale. LOCALE_IO toggle; // toggles on, then off, the C locale.
@ -2415,18 +2414,17 @@ PCB_IO_KICAD_SEXPR::~PCB_IO_KICAD_SEXPR()
BOARD* PCB_IO_KICAD_SEXPR::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* PCB_IO_KICAD_SEXPR::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties, PROJECT* aProject, const STRING_UTF8_MAP* aProperties, PROJECT* aProject )
PROGRESS_REPORTER* aProgressReporter )
{ {
FILE_LINE_READER reader( aFileName ); FILE_LINE_READER reader( aFileName );
unsigned lineCount = 0; unsigned lineCount = 0;
if( aProgressReporter ) if( m_progressReporter )
{ {
aProgressReporter->Report( wxString::Format( _( "Loading %s..." ), aFileName ) ); m_progressReporter->Report( wxString::Format( _( "Loading %s..." ), aFileName ) );
if( !aProgressReporter->KeepRefreshing() ) if( !m_progressReporter->KeepRefreshing() )
THROW_IO_ERROR( _( "Open cancelled by user." ) ); THROW_IO_ERROR( _( "Open cancelled by user." ) );
while( reader.ReadLine() ) while( reader.ReadLine() )
@ -2435,7 +2433,7 @@ BOARD* PCB_IO_KICAD_SEXPR::LoadBoard( const wxString& aFileName, BOARD* aAppendT
reader.Rewind(); reader.Rewind();
} }
BOARD* board = DoLoad( reader, aAppendToMe, aProperties, aProgressReporter, lineCount ); BOARD* board = DoLoad( reader, aAppendToMe, aProperties, m_progressReporter, lineCount );
// Give the filename to the board if it's new // Give the filename to the board if it's new
if( !aAppendToMe ) if( !aAppendToMe )

View File

@ -305,12 +305,10 @@ public:
bool CanReadBoard( const wxString& aFileName ) const override; bool CanReadBoard( const wxString& aFileName ) const override;
void SaveBoard( const wxString& aFileName, BOARD* aBoard, void SaveBoard( const wxString& aFileName, BOARD* aBoard,
const STRING_UTF8_MAP* aProperties = nullptr, const STRING_UTF8_MAP* aProperties = nullptr ) override;
PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr, const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr ) override;
PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
BOARD* DoLoad( LINE_READER& aReader, BOARD* aAppendToMe, const STRING_UTF8_MAP* aProperties, BOARD* DoLoad( LINE_READER& aReader, BOARD* aAppendToMe, const STRING_UTF8_MAP* aProperties,
PROGRESS_REPORTER* aProgressReporter, unsigned aLineCount ); PROGRESS_REPORTER* aProgressReporter, unsigned aLineCount );

View File

@ -63,8 +63,7 @@ bool PCB_IO_PCAD::CanReadBoard( const wxString& aFileName ) const
BOARD* PCB_IO_PCAD::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* PCB_IO_PCAD::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties, PROJECT* aProject, const STRING_UTF8_MAP* aProperties, PROJECT* aProject )
PROGRESS_REPORTER* aProgressReporter )
{ {
wxXmlDocument xmlDoc; wxXmlDocument xmlDoc;

View File

@ -53,8 +53,7 @@ public:
bool CanReadBoard( const wxString& aFileName ) const override; bool CanReadBoard( const wxString& aFileName ) const override;
BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr, const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr ) override;
PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override
{ {

View File

@ -73,8 +73,7 @@ bool PCB_IO::CanReadFootprint( const wxString& aFileName ) const
BOARD* PCB_IO::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, BOARD* PCB_IO::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties, PROJECT* aProject, const STRING_UTF8_MAP* aProperties, PROJECT* aProject )
PROGRESS_REPORTER* aProgressReporter )
{ {
NOT_IMPLEMENTED( __FUNCTION__ ); NOT_IMPLEMENTED( __FUNCTION__ );
} }
@ -87,7 +86,7 @@ std::vector<FOOTPRINT*> PCB_IO::GetImportedCachedLibraryFootprints()
void PCB_IO::SaveBoard( const wxString& aFileName, BOARD* aBoard, void PCB_IO::SaveBoard( const wxString& aFileName, BOARD* aBoard,
const STRING_UTF8_MAP* aProperties, PROGRESS_REPORTER* aProgressReporter ) const STRING_UTF8_MAP* aProperties )
{ {
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
NOT_IMPLEMENTED( __FUNCTION__ ); NOT_IMPLEMENTED( __FUNCTION__ );

View File

@ -119,8 +119,6 @@ public:
* it to be optionally NULL. * it to be optionally NULL.
* @param aProject is the optional #PROJECT object primarily used by third party * @param aProject is the optional #PROJECT object primarily used by third party
* importers. * importers.
* @param aProgressReporter an optional progress reporter
* @param aLineCount a line count (necessary if a progress reporter is supplied)
* @return the successfully loaded board, or the same one as \a aAppendToMe if aAppendToMe * @return the successfully loaded board, or the same one as \a aAppendToMe if aAppendToMe
* was not NULL, and caller owns it. * was not NULL, and caller owns it.
* *
@ -129,8 +127,7 @@ public:
* possible. * possible.
*/ */
virtual BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, virtual BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr, const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr );
PROGRESS_REPORTER* aProgressReporter = nullptr );
/** /**
* Return a container with the cached library footprints generated in the last call to * Return a container with the cached library footprints generated in the last call to
@ -157,13 +154,11 @@ public:
* tuning arguments that the plugin is known to support. The caller * tuning arguments that the plugin is known to support. The caller
* continues to own this object (plugin may not delete it) and plugins * continues to own this object (plugin may not delete it) and plugins
* should expect it to be optionally NULL. * should expect it to be optionally NULL.
* @param aProgressReporter an optional progress reporter
* *
* @throw IO_ERROR if there is a problem saving or exporting. * @throw IO_ERROR if there is a problem saving or exporting.
*/ */
virtual void SaveBoard( const wxString& aFileName, BOARD* aBoard, virtual void SaveBoard( const wxString& aFileName, BOARD* aBoard,
const STRING_UTF8_MAP* aProperties = nullptr, const STRING_UTF8_MAP* aProperties = nullptr );
PROGRESS_REPORTER* aProgressReporter = nullptr );
/** /**
* Return a list of footprint names contained within the library at @a aLibraryPath. * Return a list of footprint names contained within the library at @a aLibraryPath.

View File

@ -172,7 +172,8 @@ BOARD* PCB_IO_MGR::Load( PCB_FILE_T aFileType, const wxString& aFileName, BOARD*
if( (PCB_IO*) pi ) // test pi->plugin if( (PCB_IO*) pi ) // test pi->plugin
{ {
return pi->LoadBoard( aFileName, aAppendToMe, aProperties, aProject, aProgressReporter ); pi->SetProgressReporter( aProgressReporter );
return pi->LoadBoard( aFileName, aAppendToMe, aProperties, aProject );
} }
THROW_IO_ERROR( wxString::Format( FMT_NOTFOUND, ShowType( aFileType ).GetData() ) ); THROW_IO_ERROR( wxString::Format( FMT_NOTFOUND, ShowType( aFileType ).GetData() ) );

View File

@ -1303,7 +1303,8 @@ int PCB_CONTROL::AppendBoard( PCB_IO& pi, wxString& fileName )
WX_PROGRESS_REPORTER progressReporter( editFrame, _( "Loading PCB" ), 1 ); WX_PROGRESS_REPORTER progressReporter( editFrame, _( "Loading PCB" ), 1 );
editFrame->GetDesignSettings().m_NetSettings->m_NetClasses.clear(); editFrame->GetDesignSettings().m_NetSettings->m_NetClasses.clear();
pi.LoadBoard( fileName, brd, &props, nullptr, &progressReporter ); pi.SetProgressReporter( &progressReporter );
pi.LoadBoard( fileName, brd, &props, nullptr );
} }
catch( const IO_ERROR& ioe ) catch( const IO_ERROR& ioe )
{ {