KiCad PCB EDA Suite
dialog_sim_settings.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 CERN
5 * Copyright (C) 2021 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_SETTINGS_H
28#define DIALOG_SIM_SETTINGS_H
29
31#include <sim/spice_value.h>
32
33#include <wx/valnum.h>
34
37
38
40{
41public:
42 DIALOG_SIM_SETTINGS( wxWindow* aParent, std::shared_ptr<NGSPICE_CIRCUIT_MODEL> aCircuitModel,
43 std::shared_ptr<SPICE_SIMULATOR_SETTINGS>& aSettings );
44
45 const wxString& GetSimCommand() const
46 {
47 return m_simCommand;
48 }
49
50 bool SetSimCommand( const wxString& aCommand )
51 {
52 bool res = parseCommand( aCommand );
53
54 if( res )
55 m_simCommand = aCommand;
56
57 return res;
58 }
59
61 {
62 return m_netlistOpts;
63 }
64
65
66 bool TransferDataFromWindow() override;
67 bool TransferDataToWindow() override;
68
69 // The default dialog Validate() calls the validators of all widgets.
70 // This is not what we want; We want only validators of the selected page
71 // of the notebooks. So disable the wxDialog::Validate(), and let our
72 // TransferDataFromWindow doing the job.
73 virtual bool Validate() override
74 {
75 return true;
76 }
77
78 int ShowModal() override;
79
80private:
82 {
85 LINEAR
86 };
87
90 {
91 wxQueueEvent( m_dcEnable2, new wxCommandEvent( wxEVT_CHECKBOX ) );
92 wxQueueEvent( m_dcSourceType1, new wxCommandEvent( wxEVT_RADIOBOX ) );
93 wxQueueEvent( m_dcSourceType2, new wxCommandEvent( wxEVT_RADIOBOX ) );
94 }
95
101 wxString evaluateDCControls( wxChoice* aDcSource, wxTextCtrl* aDcStart, wxTextCtrl* aDcStop,
102 wxTextCtrl* aDcIncr );
103
107 void updateDCSources( wxChar aType, wxChoice* aSource );
108
112 void updateDCUnits( wxChar aType, wxChoice* aSource, wxStaticText* aStartValUnit,
113 wxStaticText* aEndValUnit, wxStaticText* aStepUnit );
114
115 virtual void onInitDlg( wxInitDialogEvent& event ) override
116 {
117 // Call the default wxDialog handler of a wxInitDialogEvent
119
120 // Now all widgets have the size fixed, call FinishDialogSettings
122 }
123
130 bool parseCommand( const wxString& aCommand );
131
132 void onLoadDirectives( wxCommandEvent& event ) override
133 {
135 }
136
137 void onDCEnableSecondSource( wxCommandEvent& event ) override;
138 void onSwapDCSources( wxCommandEvent& event ) override;
139 void onDCSource1Selected( wxCommandEvent& event ) override
140 {
141 wxChar type =
142 m_dcSourceType1->GetString( m_dcSourceType1->GetSelection() ).Upper().GetChar( 0 );
146 }
147
148 void onDCSource2Selected( wxCommandEvent& event ) override
149 {
150 wxChar type =
151 m_dcSourceType2->GetString( m_dcSourceType2->GetSelection() ).Upper().GetChar( 0 );
155 }
156
157 static wxString scaleToString( int aOption )
158 {
159 switch( aOption )
160 {
161 case DECADE:
162 return wxString( "dec" );
163
164 case OCTAVE:
165 return wxString( "oct" );
166
167 case LINEAR:
168 return wxString( "lin" );
169 }
170
171 wxASSERT_MSG( false, "Unhandled scale type" );
172
173 return wxEmptyString;
174 }
175
176 void loadDirectives();
177 void updateNetlistOpts();
178
179 wxString m_simCommand;
181 std::shared_ptr<NGSPICE_CIRCUIT_MODEL> m_circuitModel;
182 std::shared_ptr<SPICE_SIMULATOR_SETTINGS> m_settings;
185 wxIntegerValidator<int> m_posIntValidator;
186};
187
188#endif /* DIALOG_SIM_SETTINGS_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_SETTINGS_BASE.
void onDCSource1Selected(wxCommandEvent &event) override
const wxString & GetSimCommand() const
bool TransferDataToWindow() override
wxIntegerValidator< int > m_posIntValidator
void onLoadDirectives(wxCommandEvent &event) override
virtual bool Validate() override
std::shared_ptr< SPICE_SIMULATOR_SETTINGS > m_settings
SPICE_VALIDATOR m_spiceEmptyValidator
void updateDCUnits(wxChar aType, wxChoice *aSource, wxStaticText *aStartValUnit, wxStaticText *aEndValUnit, wxStaticText *aStepUnit)
Update units on labels depending on selected source.
void onDCEnableSecondSource(wxCommandEvent &event) override
bool TransferDataFromWindow() override
static wxString scaleToString(int aOption)
bool SetSimCommand(const wxString &aCommand)
void updateDCSources(wxChar aType, wxChoice *aSource)
Update DC sweep source with symbols from schematic.
void onDCSource2Selected(wxCommandEvent &event) override
DIALOG_SIM_SETTINGS(wxWindow *aParent, std::shared_ptr< NGSPICE_CIRCUIT_MODEL > aCircuitModel, std::shared_ptr< SPICE_SIMULATOR_SETTINGS > &aSettings)
virtual void onInitDlg(wxInitDialogEvent &event) override
SPICE_VALIDATOR m_spiceValidator
bool parseCommand(const wxString &aCommand)
Parse a Spice directive.
std::shared_ptr< NGSPICE_CIRCUIT_MODEL > m_circuitModel
void onSwapDCSources(wxCommandEvent &event) override
wxString evaluateDCControls(wxChoice *aDcSource, wxTextCtrl *aDcStart, wxTextCtrl *aDcStop, wxTextCtrl *aDcIncr)
Read values from one DC sweep source to form a part of simulation command.
Special netlist exporter flavor that allows one to override simulation commands.
Storage for simulator specific settings.