Correctly parent simulator netlist error dialogs.

This commit is contained in:
Wayne Stambaugh 2023-01-19 07:59:18 -05:00
parent 0e778f17db
commit ee3e285393
4 changed files with 34 additions and 18 deletions

View File

@ -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<const SPICE_GENERATOR_KIBIS&>( 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;
}
}

View File

@ -33,6 +33,9 @@
#include <sim/spice_generator.h>
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<wxString> m_directives; ///< Spice directives found in the schematic sheet
std::set<wxString> m_rawIncludes; ///< include directives found in symbols
std::set<std::string> m_nets;
std::list<SPICE_ITEM> m_items; ///< Items representing schematic symbols in Spice world
///< Items representing schematic symbols in Spice world.
std::list<SPICE_ITEM> m_items;
wxWindow* m_dialogParent;
};

View File

@ -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 <maciej.suminski@cern.ch>
*
@ -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 )
{}

View File

@ -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 <tomasz.wlostowski@cern.ch>
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
@ -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 );
}