From 8c8c5e18248bd547b1e69aec099c3866257c6625 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 25 Feb 2023 22:42:52 +0000 Subject: [PATCH] Provide a default xaxis for DC-sweep so we can add traces before sim is run. --- eeschema/sim/ngspice.cpp | 25 +++++++++---------------- eeschema/sim/ngspice.h | 2 +- eeschema/sim/sim_plot_frame.cpp | 1 + eeschema/sim/spice_simulator.h | 2 +- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/eeschema/sim/ngspice.cpp b/eeschema/sim/ngspice.cpp index ce480185b3..2c77b039f1 100644 --- a/eeschema/sim/ngspice.cpp +++ b/eeschema/sim/ngspice.cpp @@ -339,37 +339,30 @@ bool NGSPICE::Command( const std::string& aCmd ) } -std::string NGSPICE::GetXAxis( SIM_TYPE aType ) const +wxString NGSPICE::GetXAxis( SIM_TYPE aType ) const { switch( aType ) { case ST_AC: case ST_NOISE: - return std::string( "frequency" ); + return wxS( "frequency" ); case ST_DC: // find plot, which ends with "-sweep" - for( auto& plot : AllPlots() ) + for( wxString plot : AllPlots() ) { - const std::string sweepEnding = "-sweep"; - unsigned int len = sweepEnding.length(); - - if( plot.length() > len - && plot.substr( plot.length() - len, len ).compare( sweepEnding ) == 0 ) - { - return std::string( plot ); - } + if( plot.Lower().EndsWith( wxS( "-sweep" ) ) ) + return plot; } - break; + + return wxS( "sweep" ); case ST_TRANSIENT: - return std::string( "time" ); + return wxS( "time" ); default: - break; + return wxEmptyString; } - - return std::string( "" ); } diff --git a/eeschema/sim/ngspice.h b/eeschema/sim/ngspice.h index 1b8bd2b85e..c1179d6713 100644 --- a/eeschema/sim/ngspice.h +++ b/eeschema/sim/ngspice.h @@ -78,7 +78,7 @@ public: bool Command( const std::string& aCmd ) override final; ///< @copydoc SPICE_SIMULATOR::GetXAxis() - std::string GetXAxis( SIM_TYPE aType ) const override final; + wxString GetXAxis( SIM_TYPE aType ) const override final; ///< @copydoc SPICE_SIMULATOR::AllPlots() std::vector AllPlots() const override final; diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index d285676206..d1c8b1a5bd 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -2377,6 +2377,7 @@ void SIM_PLOT_FRAME::onPlotClosed( wxAuiNotebookEvent& event ) void SIM_PLOT_FRAME::onPlotChanged( wxAuiNotebookEvent& event ) { + rebuildSignalsList(); rebuildSignalsGrid( m_filter->GetValue() ); updateCursors(); } diff --git a/eeschema/sim/spice_simulator.h b/eeschema/sim/spice_simulator.h index 30417538ef..3306d432a7 100644 --- a/eeschema/sim/spice_simulator.h +++ b/eeschema/sim/spice_simulator.h @@ -78,7 +78,7 @@ public: virtual bool Command( const std::string& aCmd ) = 0; ///< Return X axis name for a given simulation type - virtual std::string GetXAxis( SIM_TYPE aType ) const = 0; + virtual wxString GetXAxis( SIM_TYPE aType ) const = 0; ///< Set a #SPICE_REPORTER object to receive the simulation log. virtual void SetReporter( SPICE_REPORTER* aReporter )