KiCad PCB EDA Suite
dialog_sim_command.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2016-2022 CERN
5 * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Maciej Suminski <[email protected]>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 3
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, you may find one here:
21 * https://www.gnu.org/licenses/gpl-3.0.html
22 * or you may search the http://www.gnu.org website for the version 3 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
27#ifndef DIALOG_SIM_COMMAND_H
28#define DIALOG_SIM_COMMAND_H
29
32#include <sim/spice_value.h>
33
34#include <wx/valnum.h>
35
38
39
41{
42public:
43 DIALOG_SIM_COMMAND( wxWindow* aParent, std::shared_ptr<NGSPICE_CIRCUIT_MODEL> aCircuitModel,
44 std::shared_ptr<SPICE_SIMULATOR_SETTINGS>& aSettings );
45
46 const wxString& GetSimCommand() const
47 {
48 return m_simCommand;
49 }
50
51 bool SetSimCommand( const wxString& aCommand )
52 {
53 bool res = parseCommand( aCommand );
54
55 if( res )
56 m_simCommand = aCommand;
57
58 return res;
59 }
60
61 int GetSimOptions() const
62 {
64
65 if( !m_fixIncludePaths->GetValue() )
66 options &= ~NETLIST_EXPORTER_SPICE::OPTION_ADJUST_INCLUDE_PATHS;
67
68 if( !m_saveAllVoltages->GetValue() )
69 options &= ~NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_VOLTAGES;
70
71 if( !m_saveAllCurrents->GetValue() )
72 options &= ~NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_CURRENTS;
73
74 if( !m_saveAllDissipations->GetValue() )
75 options &= ~NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_DISSIPATIONS;
76
77 return options;
78 }
79
80 void SetSimOptions( int aOptions )
81 {
86 }
87
88 bool TransferDataFromWindow() override;
89 bool TransferDataToWindow() override;
90
91 // The default dialog Validate() calls the validators of all widgets.
92 // This is not what we want; We want only validators of the selected page
93 // of the notebooks. So disable the wxDialog::Validate(), and let our
94 // TransferDataFromWindow doing the job.
95 virtual bool Validate() override
96 {
97 return true;
98 }
99
100 int ShowModal() override;
101
102private:
104 {
107 LINEAR
108 };
109
112 {
113 wxQueueEvent( m_dcEnable2, new wxCommandEvent( wxEVT_CHECKBOX ) );
114 wxQueueEvent( m_dcSourceType1, new wxCommandEvent( wxEVT_RADIOBOX ) );
115 wxQueueEvent( m_dcSourceType2, new wxCommandEvent( wxEVT_RADIOBOX ) );
116 }
117
123 wxString evaluateDCControls( wxChoice* aDcSource, wxTextCtrl* aDcStart, wxTextCtrl* aDcStop,
124 wxTextCtrl* aDcIncr );
125
129 void updateDCSources( wxChar aType, wxChoice* aSource );
130
134 void updateDCUnits( wxChar aType, wxChoice* aSource, wxStaticText* aStartValUnit,
135 wxStaticText* aEndValUnit, wxStaticText* aStepUnit );
136
137 virtual void onInitDlg( wxInitDialogEvent& event ) override
138 {
139 // Call the default wxDialog handler of a wxInitDialogEvent
141
142 // Now all widgets have the size fixed, call FinishDialogSettings
144 }
145
152 bool parseCommand( const wxString& aCommand );
153
154 void onLoadDirectives( wxCommandEvent& event ) override
155 {
157 }
158
159 void onDCEnableSecondSource( wxCommandEvent& event ) override;
160 void onSwapDCSources( wxCommandEvent& event ) override;
161 void onDCSource1Selected( wxCommandEvent& event ) override
162 {
163 wxChar type =
164 m_dcSourceType1->GetString( m_dcSourceType1->GetSelection() ).Upper().GetChar( 0 );
168 }
169
170 void onDCSource2Selected( wxCommandEvent& event ) override
171 {
172 wxChar type =
173 m_dcSourceType2->GetString( m_dcSourceType2->GetSelection() ).Upper().GetChar( 0 );
177 }
178
179 static wxString scaleToString( int aOption )
180 {
181 switch( aOption )
182 {
183 case DECADE: return wxString( "dec" );
184 case OCTAVE: return wxString( "oct" );
185 case LINEAR: return wxString( "lin" );
186 default: wxFAIL_MSG( "Unhandled scale type" ); return wxEmptyString;
187 }
188 }
189
190 void loadDirectives();
191
192private:
193 wxString m_simCommand;
194 std::shared_ptr<NGSPICE_CIRCUIT_MODEL> m_circuitModel;
195 std::shared_ptr<SPICE_SIMULATOR_SETTINGS> m_settings;
198 wxIntegerValidator<int> m_posIntValidator;
199};
200
201#endif /* DIALOG_SIM_COMMAND_H */
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Class DIALOG_SIM_COMMAND_BASE.
wxString evaluateDCControls(wxChoice *aDcSource, wxTextCtrl *aDcStart, wxTextCtrl *aDcStop, wxTextCtrl *aDcIncr)
Read values from one DC sweep source to form a part of simulation command.
virtual bool Validate() override
void onSwapDCSources(wxCommandEvent &event) override
static wxString scaleToString(int aOption)
std::shared_ptr< NGSPICE_CIRCUIT_MODEL > m_circuitModel
wxIntegerValidator< int > m_posIntValidator
void onDCSource2Selected(wxCommandEvent &event) override
bool TransferDataFromWindow() override
std::shared_ptr< SPICE_SIMULATOR_SETTINGS > m_settings
void updateDCSources(wxChar aType, wxChoice *aSource)
Update DC sweep source with symbols from schematic.
DIALOG_SIM_COMMAND(wxWindow *aParent, std::shared_ptr< NGSPICE_CIRCUIT_MODEL > aCircuitModel, std::shared_ptr< SPICE_SIMULATOR_SETTINGS > &aSettings)
SPICE_VALIDATOR m_spiceValidator
void onDCEnableSecondSource(wxCommandEvent &event) override
void SetSimOptions(int aOptions)
void onDCSource1Selected(wxCommandEvent &event) override
bool TransferDataToWindow() override
bool SetSimCommand(const wxString &aCommand)
const wxString & GetSimCommand() const
void updateDCUnits(wxChar aType, wxChoice *aSource, wxStaticText *aStartValUnit, wxStaticText *aEndValUnit, wxStaticText *aStepUnit)
Update units on labels depending on selected source.
bool parseCommand(const wxString &aCommand)
Parse a Spice directive.
virtual void onInitDlg(wxInitDialogEvent &event) override
SPICE_VALIDATOR m_spiceEmptyValidator
void onLoadDirectives(wxCommandEvent &event) override
Special netlist exporter flavor that allows one to override simulation commands.
Storage for simulator specific settings.
VECTOR3I res