Don't run simulation twice when the sim command is overridden.
Fixes https://gitlab.com/kicad/code/kicad/issues/12731
This commit is contained in:
parent
da0624286c
commit
69448afb47
|
@ -349,7 +349,7 @@ if( KICAD_SPICE )
|
|||
dialogs/dialog_sim_settings_base.cpp
|
||||
dialogs/dialog_sim_model.cpp
|
||||
dialogs/dialog_sim_model_base.cpp
|
||||
sim/ngspice_helpers.cpp
|
||||
sim/ngspice_circuit_model.cpp
|
||||
sim/ngspice.cpp
|
||||
sim/sim_panel_base.cpp
|
||||
sim/sim_plot_colors.cpp
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <string_utils.h>
|
||||
#include <sim/sim_plot_frame.h>
|
||||
|
||||
#include <sim/ngspice_helpers.h>
|
||||
#include <sim/ngspice_circuit_model.h>
|
||||
#include <sim/spice_generator.h>
|
||||
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
|
||||
#include "dialog_sim_settings.h"
|
||||
#include <sim/ngspice_helpers.h>
|
||||
#include <sim/ngspice_circuit_model.h>
|
||||
#include <sim/ngspice.h>
|
||||
|
||||
#include <confirm.h>
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include <sim/kibis/kibis.h>
|
||||
#include "netlist_exporter_spice.h"
|
||||
#include "sim/ngspice_circuit_model.h"
|
||||
#include <sim/sim_library_spice.h>
|
||||
#include <sim/sim_model_raw_spice.h>
|
||||
#include <sim/sim_model_ideal.h>
|
||||
|
@ -539,7 +540,17 @@ void NETLIST_EXPORTER_SPICE::WriteDirectives( OUTPUTFORMATTER& aFormatter,
|
|||
aFormatter.Print( 0, ".probe alli\n" );
|
||||
|
||||
for( const std::string& directive : m_directives )
|
||||
aFormatter.Print( 0, "%s\n", directive.c_str() );
|
||||
{
|
||||
if( NGSPICE_CIRCUIT_MODEL::IsSimCommand( directive ) )
|
||||
{
|
||||
if( aNetlistOptions & OPTION_SIM_COMMAND )
|
||||
aFormatter.Print( 0, "%s\n", directive.c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
aFormatter.Print( 0, "%s\n", directive.c_str() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -48,11 +48,12 @@ class NETLIST_EXPORTER_SPICE : public NETLIST_EXPORTER_BASE
|
|||
public:
|
||||
enum OPTIONS
|
||||
{
|
||||
OPTION_ADJUST_INCLUDE_PATHS = 0x10,
|
||||
OPTION_ADJUST_PASSIVE_VALS = 0x20,
|
||||
OPTION_SAVE_ALL_VOLTAGES = 0x40,
|
||||
OPTION_SAVE_ALL_CURRENTS = 0x80,
|
||||
OPTION_CUR_SHEET_AS_ROOT = 0x0100,
|
||||
OPTION_ADJUST_INCLUDE_PATHS = 0x0010,
|
||||
OPTION_ADJUST_PASSIVE_VALS = 0x0020,
|
||||
OPTION_SAVE_ALL_VOLTAGES = 0x0040,
|
||||
OPTION_SAVE_ALL_CURRENTS = 0x0080,
|
||||
OPTION_CUR_SHEET_AS_ROOT = 0x0100,
|
||||
OPTION_SIM_COMMAND = 0x0200,
|
||||
OPTION_DEFAULT_FLAGS = OPTION_ADJUST_INCLUDE_PATHS
|
||||
| OPTION_ADJUST_PASSIVE_VALS
|
||||
| OPTION_SAVE_ALL_VOLTAGES
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <config.h> // Needed for MSW compilation
|
||||
#include <wx/log.h>
|
||||
|
||||
#include "ngspice_helpers.h"
|
||||
#include "ngspice_circuit_model.h"
|
||||
#include "ngspice.h"
|
||||
#include "spice_reporter.h"
|
||||
#include "spice_settings.h"
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "ngspice_helpers.h"
|
||||
#include "ngspice_circuit_model.h"
|
||||
#include <macros.h> // for TO_UTF8 def
|
||||
#include <wx/regex.h>
|
||||
#include <wx/tokenzr.h>
|
||||
|
@ -149,8 +149,11 @@ bool NGSPICE_CIRCUIT_MODEL::ParseDCCommand( const wxString& aCmd, SPICE_DC_PARAM
|
|||
void NGSPICE_CIRCUIT_MODEL::WriteDirectives( OUTPUTFORMATTER& aFormatter,
|
||||
unsigned aNetlistOptions ) const
|
||||
{
|
||||
if( GetSimCommandOverride().IsEmpty() )
|
||||
aNetlistOptions |= OPTION_SIM_COMMAND;
|
||||
|
||||
NETLIST_EXPORTER_SPICE::WriteDirectives( aFormatter, aNetlistOptions );
|
||||
|
||||
if( GetSimCommandOverride() != "" )
|
||||
if( !GetSimCommandOverride().IsEmpty() )
|
||||
aFormatter.Print( 0, "%s\n", TO_UTF8( GetSimCommandOverride() ) );
|
||||
}
|
|
@ -24,8 +24,8 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef NETLIST_EXPORTER_PSPICE_SIM_H
|
||||
#define NETLIST_EXPORTER_PSPICE_SIM_H
|
||||
#ifndef NGSPICE_CIRCUIT_MODEL_H
|
||||
#define NGSPICE_CIRCUIT_MODEL_H
|
||||
|
||||
#include <netlist_exporters/netlist_exporter_spice.h>
|
||||
#include <vector>
|
||||
|
@ -155,4 +155,4 @@ private:
|
|||
int m_options;
|
||||
};
|
||||
|
||||
#endif /* NETLIST_EXPORTER_PSPICE_SIM_H */
|
||||
#endif /* NGSPICE_CIRCUIT_MODEL_H */
|
|
@ -27,7 +27,7 @@
|
|||
#include "sim_panel_base.h"
|
||||
|
||||
#include "sim_plot_frame.h"
|
||||
#include "ngspice_helpers.h"
|
||||
#include "ngspice_circuit_model.h"
|
||||
|
||||
|
||||
SIM_PANEL_BASE::SIM_PANEL_BASE() : m_simCommand( wxEmptyString )
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#define __SIM_PLOT_PANEL_BASE_H
|
||||
|
||||
#include "sim_types.h"
|
||||
#include "ngspice_helpers.h"
|
||||
#include "ngspice_circuit_model.h"
|
||||
#include <wx/panel.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/stattext.h>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2021 Mikołaj Wielgus <wielgusmikolaj@gmail.com>
|
||||
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -32,7 +32,8 @@ SIM_WORKBOOK::SIM_WORKBOOK() : wxAuiNotebook()
|
|||
|
||||
|
||||
SIM_WORKBOOK::SIM_WORKBOOK( wxWindow* aParent, wxWindowID aId, const wxPoint& aPos, const wxSize&
|
||||
aSize, long aStyle ) : wxAuiNotebook( aParent, aId, aPos, aSize, aStyle )
|
||||
aSize, long aStyle ) :
|
||||
wxAuiNotebook( aParent, aId, aPos, aSize, aStyle )
|
||||
{
|
||||
m_modified = false;
|
||||
}
|
||||
|
@ -40,33 +41,49 @@ SIM_WORKBOOK::SIM_WORKBOOK( wxWindow* aParent, wxWindowID aId, const wxPoint& aP
|
|||
|
||||
bool SIM_WORKBOOK::AddPage( wxWindow* page, const wxString& caption, bool select, const wxBitmap& bitmap )
|
||||
{
|
||||
bool res = wxAuiNotebook::AddPage( page, caption, select, bitmap );
|
||||
setModified( res );
|
||||
return res;
|
||||
if( wxAuiNotebook::AddPage( page, caption, select, bitmap ) )
|
||||
{
|
||||
setModified();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool SIM_WORKBOOK::AddPage( wxWindow* page, const wxString& text, bool select, int imageId )
|
||||
{
|
||||
bool res = wxAuiNotebook::AddPage( page, text, select, imageId );
|
||||
setModified( res );
|
||||
return res;
|
||||
if( wxAuiNotebook::AddPage( page, text, select, imageId ) )
|
||||
{
|
||||
setModified();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool SIM_WORKBOOK::DeleteAllPages()
|
||||
{
|
||||
bool res = wxAuiNotebook::DeleteAllPages();
|
||||
setModified( res );
|
||||
return res;
|
||||
if( wxAuiNotebook::DeleteAllPages() )
|
||||
{
|
||||
setModified();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool SIM_WORKBOOK::DeletePage( size_t page )
|
||||
{
|
||||
bool res = wxAuiNotebook::DeletePage( page );
|
||||
setModified( res );
|
||||
return res;
|
||||
if( wxAuiNotebook::DeletePage( page ) )
|
||||
{
|
||||
setModified();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -74,30 +91,41 @@ bool SIM_WORKBOOK::AddTrace( SIM_PLOT_PANEL* aPlotPanel, const wxString& aTitle,
|
|||
const wxString& aName, int aPoints, const double* aX, const double* aY,
|
||||
SIM_PLOT_TYPE aType )
|
||||
{
|
||||
bool res = aPlotPanel->addTrace( aTitle, aName, aPoints, aX, aY, aType );
|
||||
setModified( res );
|
||||
return res;
|
||||
if( aPlotPanel->addTrace( aTitle, aName, aPoints, aX, aY, aType ) )
|
||||
{
|
||||
setModified();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool SIM_WORKBOOK::DeleteTrace( SIM_PLOT_PANEL* aPlotPanel, const wxString& aName )
|
||||
{
|
||||
bool res = aPlotPanel->deleteTrace( aName );
|
||||
setModified( res );
|
||||
return res;
|
||||
if( aPlotPanel->deleteTrace( aName ) )
|
||||
{
|
||||
setModified();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void SIM_WORKBOOK::ClrModified()
|
||||
{
|
||||
m_modified = false;
|
||||
wxPostEvent( GetParent(), wxCommandEvent( EVT_WORKBOOK_CLR_MODIFIED ) );
|
||||
}
|
||||
|
||||
void SIM_WORKBOOK::setModified( bool value )
|
||||
|
||||
void SIM_WORKBOOK::setModified()
|
||||
{
|
||||
m_modified = value;
|
||||
m_modified = true;
|
||||
wxPostEvent( GetParent(), wxCommandEvent( EVT_WORKBOOK_MODIFIED ) );
|
||||
}
|
||||
|
||||
|
||||
wxDEFINE_EVENT( EVT_WORKBOOK_MODIFIED, wxCommandEvent );
|
||||
wxDEFINE_EVENT( EVT_WORKBOOK_CLR_MODIFIED, wxCommandEvent );
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
bool IsModified() const { return m_modified; }
|
||||
|
||||
private:
|
||||
void setModified( bool value = true );
|
||||
void setModified();
|
||||
|
||||
///< Dirty bit, indicates something in the workbook has changed
|
||||
bool m_modified;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <sim/sim_plot_frame.h>
|
||||
#include <sch_symbol.h>
|
||||
#include <template_fieldnames.h>
|
||||
#include <sim/ngspice_helpers.h>
|
||||
#include <sim/ngspice_circuit_model.h>
|
||||
|
||||
#include <cmath> // log log1p expm1
|
||||
#include <complex> // norm
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include <project.h>
|
||||
#include <schematic.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <sim/ngspice_helpers.h>
|
||||
#include <sim/ngspice_circuit_model.h>
|
||||
|
||||
class TEST_NGSPICE_HELPERS
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue