From dbb0a125ac6f61f77171b2074c1f368445d67521 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Fri, 19 Mar 2021 09:04:28 -0400 Subject: [PATCH] Fix build error when spice simulator build option is disabled. --- eeschema/CMakeLists.txt | 3 ++ eeschema/schematic_settings.cpp | 2 +- eeschema/sim/ngspice.cpp | 27 +---------- eeschema/sim/ngspice.h | 33 ------------- eeschema/sim/spice_settings.cpp | 61 ++++++++++++++++++++++++ eeschema/sim/spice_settings.h | 80 ++++++++++++++++++++++++++++++++ eeschema/sim/spice_simulator.cpp | 13 ------ eeschema/sim/spice_simulator.h | 19 +------- 8 files changed, 147 insertions(+), 91 deletions(-) create mode 100644 eeschema/sim/spice_settings.cpp create mode 100644 eeschema/sim/spice_settings.h diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 03d9396928..1659a6cb58 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -248,6 +248,9 @@ set( EESCHEMA_SRCS netlist_exporters/netlist_exporter_pspice.cpp netlist_exporters/netlist_generator.cpp + # Simulator settings must get built even when the simulator build option is disabled. + sim/spice_settings.cpp + tools/backannotate.cpp tools/assign_footprints.cpp tools/ee_actions.cpp diff --git a/eeschema/schematic_settings.cpp b/eeschema/schematic_settings.cpp index aa8d28fa6f..957ee26644 100644 --- a/eeschema/schematic_settings.cpp +++ b/eeschema/schematic_settings.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include const int schSettingsSchemaVersion = 0; diff --git a/eeschema/sim/ngspice.cpp b/eeschema/sim/ngspice.cpp index 6feb100ed8..adc0b2eb4b 100644 --- a/eeschema/sim/ngspice.cpp +++ b/eeschema/sim/ngspice.cpp @@ -30,9 +30,7 @@ #include "ngspice.h" #include "spice_reporter.h" - -#include -#include +#include "spice_settings.h" #include #include @@ -59,29 +57,6 @@ using namespace std; static const wxChar* const traceNgspice = wxT( "KICAD_NGSPICE" ); -NGSPICE_SIMULATOR_SETTINGS::NGSPICE_SIMULATOR_SETTINGS( - JSON_SETTINGS* aParent, const std::string& aPath ) : - SPICE_SIMULATOR_SETTINGS( aParent, aPath ), - m_modelMode( NGSPICE_MODEL_MODE::USER_CONFIG ) -{ - m_params.emplace_back( new PARAM_ENUM( "model_mode", &m_modelMode, - NGSPICE_MODEL_MODE::USER_CONFIG, - NGSPICE_MODEL_MODE::USER_CONFIG, - NGSPICE_MODEL_MODE::HSPICE ) ); -} - - -bool NGSPICE_SIMULATOR_SETTINGS::operator==( const SPICE_SIMULATOR_SETTINGS& aRhs ) const -{ - const NGSPICE_SIMULATOR_SETTINGS* settings = - dynamic_cast( &aRhs ); - - wxCHECK( settings, false ); - - return m_modelMode == settings->m_modelMode; -} - - NGSPICE::NGSPICE() : m_ngSpice_Init( nullptr ), m_ngSpice_Circ( nullptr ), diff --git a/eeschema/sim/ngspice.h b/eeschema/sim/ngspice.h index dfc3bd9f31..f536384ab2 100644 --- a/eeschema/sim/ngspice.h +++ b/eeschema/sim/ngspice.h @@ -34,39 +34,6 @@ class wxDynamicLibrary; -/** - * Spice model compatibility modes. - * - * @note The ngspice model modes are mutually exclusive. - */ -enum class NGSPICE_MODEL_MODE { - USER_CONFIG, - NGSPICE, - PSPICE, - LTSPICE, - LT_PSPICE, - HSPICE -}; - - -/** - * Container for Ngspice simulator settings. - */ -class NGSPICE_SIMULATOR_SETTINGS : public SPICE_SIMULATOR_SETTINGS -{ -public: - NGSPICE_SIMULATOR_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ); - - bool operator==( const SPICE_SIMULATOR_SETTINGS& aRhs ) const override; - - NGSPICE_MODEL_MODE GetModelMode() const { return m_modelMode; } - void SetModelMode( NGSPICE_MODEL_MODE aMode ) { m_modelMode = aMode; } - -private: - NGSPICE_MODEL_MODE m_modelMode; -}; - - class NGSPICE : public SPICE_SIMULATOR { public: diff --git a/eeschema/sim/spice_settings.cpp b/eeschema/sim/spice_settings.cpp new file mode 100644 index 0000000000..3108b788ec --- /dev/null +++ b/eeschema/sim/spice_settings.cpp @@ -0,0 +1,61 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2021 CERN + * + * @author Wayne Stambaugh + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * https://www.gnu.org/licenses/gpl-3.0.html + * or you may search the http://www.gnu.org website for the version 3 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "spice_settings.h" + +#include + + +const int spiceSettingsSchemaVersion = 0; + + +SPICE_SIMULATOR_SETTINGS::SPICE_SIMULATOR_SETTINGS( JSON_SETTINGS* aParent, + const std::string& aPath ) : + NESTED_SETTINGS( "simulator", spiceSettingsSchemaVersion, aParent, aPath ) +{ +} + + +NGSPICE_SIMULATOR_SETTINGS::NGSPICE_SIMULATOR_SETTINGS( + JSON_SETTINGS* aParent, const std::string& aPath ) : + SPICE_SIMULATOR_SETTINGS( aParent, aPath ), + m_modelMode( NGSPICE_MODEL_MODE::USER_CONFIG ) +{ + m_params.emplace_back( new PARAM_ENUM( "model_mode", &m_modelMode, + NGSPICE_MODEL_MODE::USER_CONFIG, + NGSPICE_MODEL_MODE::USER_CONFIG, + NGSPICE_MODEL_MODE::HSPICE ) ); +} + + +bool NGSPICE_SIMULATOR_SETTINGS::operator==( const SPICE_SIMULATOR_SETTINGS& aRhs ) const +{ + const NGSPICE_SIMULATOR_SETTINGS* settings = + dynamic_cast( &aRhs ); + + wxCHECK( settings, false ); + + return m_modelMode == settings->m_modelMode; +} diff --git a/eeschema/sim/spice_settings.h b/eeschema/sim/spice_settings.h new file mode 100644 index 0000000000..a173800217 --- /dev/null +++ b/eeschema/sim/spice_settings.h @@ -0,0 +1,80 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2021 CERN + * + * @author Wayne Stambaugh + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * https://www.gnu.org/licenses/gpl-3.0.html + * or you may search the http://www.gnu.org website for the version 3 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef __SPICE_SETTINGS_H__ +#define __SPICE_SETTINGS_H__ + +#include + + +/** + * Storage for simulator specific settings. + */ +class SPICE_SIMULATOR_SETTINGS : public NESTED_SETTINGS +{ +public: + SPICE_SIMULATOR_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ); + + virtual ~SPICE_SIMULATOR_SETTINGS() {} + + virtual bool operator==( const SPICE_SIMULATOR_SETTINGS& aRhs ) const = 0; + + bool operator!=( const SPICE_SIMULATOR_SETTINGS& aRhs ) const { return !( *this == aRhs ); } +}; + +/** + * Ngspice simulator model compatibility modes. + * + * @note The ngspice model modes are mutually exclusive. + */ +enum class NGSPICE_MODEL_MODE { + USER_CONFIG, + NGSPICE, + PSPICE, + LTSPICE, + LT_PSPICE, + HSPICE +}; + + +/** + * Container for Ngspice simulator settings. + */ +class NGSPICE_SIMULATOR_SETTINGS : public SPICE_SIMULATOR_SETTINGS +{ +public: + NGSPICE_SIMULATOR_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ); + + bool operator==( const SPICE_SIMULATOR_SETTINGS& aRhs ) const override; + + NGSPICE_MODEL_MODE GetModelMode() const { return m_modelMode; } + void SetModelMode( NGSPICE_MODEL_MODE aMode ) { m_modelMode = aMode; } + +private: + NGSPICE_MODEL_MODE m_modelMode; +}; + + +#endif // __SPICE_SETTINGS_H__ diff --git a/eeschema/sim/spice_simulator.cpp b/eeschema/sim/spice_simulator.cpp index bcbbcd8eae..2ac1729b0d 100644 --- a/eeschema/sim/spice_simulator.cpp +++ b/eeschema/sim/spice_simulator.cpp @@ -27,19 +27,6 @@ #include -#include - - -const int ngspiceSettingsSchemaVersion = 0; - - -SPICE_SIMULATOR_SETTINGS::SPICE_SIMULATOR_SETTINGS( JSON_SETTINGS* aParent, - const std::string& aPath ) : - NESTED_SETTINGS( "simulator", ngspiceSettingsSchemaVersion, aParent, aPath ) -{ -} - - std::shared_ptr SPICE_SIMULATOR::CreateInstance( const std::string& ) { try diff --git a/eeschema/sim/spice_simulator.h b/eeschema/sim/spice_simulator.h index 37adba9f8b..e005da9b1d 100644 --- a/eeschema/sim/spice_simulator.h +++ b/eeschema/sim/spice_simulator.h @@ -27,9 +27,8 @@ #ifndef SPICE_SIMULATOR_H #define SPICE_SIMULATOR_H -#include - #include "sim_types.h" +#include "spice_settings.h" #include #include @@ -43,22 +42,6 @@ class SPICE_REPORTER; typedef std::complex COMPLEX; -/** - * Storage for simulator specific settings. - */ -class SPICE_SIMULATOR_SETTINGS : public NESTED_SETTINGS -{ -public: - SPICE_SIMULATOR_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ); - - virtual ~SPICE_SIMULATOR_SETTINGS() {} - - virtual bool operator==( const SPICE_SIMULATOR_SETTINGS& aRhs ) const = 0; - - bool operator!=( const SPICE_SIMULATOR_SETTINGS& aRhs ) const { return !( *this == aRhs ); } -}; - - class SPICE_SIMULATOR { public: