From ee3e2853935a5f7305a6ce4b96d86ce42e20d372 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Thu, 19 Jan 2023 07:59:18 -0500 Subject: [PATCH] Correctly parent simulator netlist error dialogs. --- .../netlist_exporter_spice.cpp | 18 +++++++++++------- .../netlist_exporters/netlist_exporter_spice.h | 18 ++++++++++++++---- eeschema/sim/ngspice_circuit_model.h | 6 +++--- eeschema/sim/sim_plot_frame.cpp | 10 ++++++---- 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/eeschema/netlist_exporters/netlist_exporter_spice.cpp b/eeschema/netlist_exporters/netlist_exporter_spice.cpp index 202ea35e2c..01b7f0e518 100644 --- a/eeschema/netlist_exporters/netlist_exporter_spice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_spice.cpp @@ -100,9 +100,11 @@ std::string NAME_GENERATOR::Generate( const std::string& aProposedName ) } -NETLIST_EXPORTER_SPICE::NETLIST_EXPORTER_SPICE( SCHEMATIC_IFACE* aSchematic ) : +NETLIST_EXPORTER_SPICE::NETLIST_EXPORTER_SPICE( SCHEMATIC_IFACE* aSchematic, + wxWindow* aDialogParent ) : NETLIST_EXPORTER_BASE( aSchematic ), - m_libMgr( &aSchematic->Prj() ) + m_libMgr( &aSchematic->Prj() ), + m_dialogParent( aDialogParent ) { } @@ -509,9 +511,10 @@ void NETLIST_EXPORTER_SPICE::readModel( SCH_SHEET_PATH& aSheet, SCH_SYMBOL& aSym if( !cacheFile.IsOpened() ) { - DisplayErrorMessage( nullptr, wxString::Format( _( "Could not open file '%s' to write " - "IBIS model" ), - cacheFn.GetFullPath() ) ); + DisplayErrorMessage( m_dialogParent, + wxString::Format( _( "Could not open file '%s' to write " + "IBIS model" ), + cacheFn.GetFullPath() ) ); } auto spiceGenerator = static_cast( kibisModel->SpiceGenerator() ); @@ -560,8 +563,9 @@ void NETLIST_EXPORTER_SPICE::writeInclude( OUTPUTFORMATTER& aFormatter, unsigned if( fullPath.IsEmpty() ) { - DisplayErrorMessage( nullptr, wxString::Format( _( "Could not find library file '%s'" ), - expandedPath ) ); + DisplayErrorMessage( m_dialogParent, + wxString::Format( _( "Could not find library file '%s'" ), + expandedPath ) ); fullPath = expandedPath; } } diff --git a/eeschema/netlist_exporters/netlist_exporter_spice.h b/eeschema/netlist_exporters/netlist_exporter_spice.h index bdd94fd599..ca8685dfeb 100644 --- a/eeschema/netlist_exporters/netlist_exporter_spice.h +++ b/eeschema/netlist_exporters/netlist_exporter_spice.h @@ -33,6 +33,9 @@ #include +class wxWindow; + + class NAME_GENERATOR { public: @@ -60,7 +63,7 @@ public: | OPTION_SAVE_ALL_CURRENTS }; - NETLIST_EXPORTER_SPICE( SCHEMATIC_IFACE* aSchematic ); + NETLIST_EXPORTER_SPICE( SCHEMATIC_IFACE* aSchematic, wxWindow* aDialogParent = nullptr ); /** * Write to specified output file. @@ -129,7 +132,8 @@ protected: void ReadDirectives( unsigned aNetlistOptions ); virtual void WriteDirectives( OUTPUTFORMATTER& aFormatter, unsigned aNetlistOptions ) const; - virtual std::string GenerateItemPinNetName( const std::string& aNetName, int& aNcCounter ) const; + virtual std::string GenerateItemPinNetName( const std::string& aNetName, + int& aNcCounter ) const; /** * Return the paths of exported sheets (either all or the current one). @@ -152,11 +156,17 @@ private: SIM_LIB_MGR m_libMgr; ///< Holds libraries and models NAME_GENERATOR m_modelNameGenerator; ///< Generates unique model names - NAME_GENERATOR m_netNameGenerator; ///< Generates unique net names (only unique for NC nets for now) + + ///< Generates unique net names (only unique for NC nets for now) + NAME_GENERATOR m_netNameGenerator; std::vector m_directives; ///< Spice directives found in the schematic sheet std::set m_rawIncludes; ///< include directives found in symbols std::set m_nets; - std::list m_items; ///< Items representing schematic symbols in Spice world + + ///< Items representing schematic symbols in Spice world. + std::list m_items; + + wxWindow* m_dialogParent; }; diff --git a/eeschema/sim/ngspice_circuit_model.h b/eeschema/sim/ngspice_circuit_model.h index 88ec757119..faecc687a7 100644 --- a/eeschema/sim/ngspice_circuit_model.h +++ b/eeschema/sim/ngspice_circuit_model.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016-2022 CERN - * Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2017-2023 KiCad Developers, see AUTHORS.txt for contributors. * * @author Maciej Suminski * @@ -47,8 +47,8 @@ struct SPICE_DC_PARAMS class NGSPICE_CIRCUIT_MODEL : public NETLIST_EXPORTER_SPICE, public SIMULATION_MODEL { public: - NGSPICE_CIRCUIT_MODEL( SCHEMATIC_IFACE* aSchematic ) : - NETLIST_EXPORTER_SPICE( aSchematic ), + NGSPICE_CIRCUIT_MODEL( SCHEMATIC_IFACE* aSchematic, wxWindow* aDialogParent = nullptr ) : + NETLIST_EXPORTER_SPICE( aSchematic, aDialogParent ), m_options( NETLIST_EXPORTER_SPICE::OPTION_DEFAULT_FLAGS ) {} diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index b9a88acb62..7f70992408 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016-2022 CERN - * Copyright (C) 2016-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors. * @author Tomasz Wlostowski * @author Maciej Suminski * @@ -147,9 +147,10 @@ SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_reporter = new SIM_THREAD_REPORTER( this ); m_simulator->SetReporter( m_reporter ); - m_circuitModel.reset( new NGSPICE_CIRCUIT_MODEL( &m_schematicFrame->Schematic() ) ); + m_circuitModel.reset( new NGSPICE_CIRCUIT_MODEL( &m_schematicFrame->Schematic(), this ) ); - Bind( wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME::menuExit ), this, wxID_EXIT ); + Bind( wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME::menuExit ), this, + wxID_EXIT ); Bind( EVT_SIM_UPDATE, &SIM_PLOT_FRAME::onSimUpdate, this ); Bind( EVT_SIM_REPORT, &SIM_PLOT_FRAME::onSimReport, this ); @@ -925,7 +926,8 @@ void SIM_PLOT_FRAME::applyTuners() } if( reporter.HasMessage() ) - DisplayErrorMessage( this, _( "Could not apply tuned value(s):" ) + wxS( "\n\n" ) + errors ); + DisplayErrorMessage( this, + _( "Could not apply tuned value(s):" ) + wxS( "\n\n" ) + errors ); }