KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2023 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
37class SPICE_SETTINGS;
38class SIMULATOR_FRAME;
39class SIM_TAB;
40
41
43{
44public:
46 std::shared_ptr<SPICE_CIRCUIT_MODEL> aCircuitModel,
47 std::shared_ptr<SPICE_SETTINGS>& aSettings );
48
49 const wxString& GetSimCommand() const
50 {
51 return m_simCommand;
52 }
53
54 void SetSimCommand( const wxString& aCommand )
55 {
56 parseCommand( aCommand );
57 m_simCommand = aCommand;
59 }
60
61 void SetSimOptions( int aOptions )
62 {
68 }
69
70 void SetPlotSettings( const SIM_TAB* aSimTab );
71
72 bool TransferDataFromWindow() override;
73 bool TransferDataToWindow() override;
74
75 // The default dialog Validate() calls the validators of all widgets.
76 // This is not what we want; We want only validators of the selected page
77 // of the notebooks. So disable the wxDialog::Validate(), and let our
78 // TransferDataFromWindow doing the job.
79 virtual bool Validate() override
80 {
81 return true;
82 }
83
84 void ApplySettings( SIM_TAB* aTab );
85
86private:
88 {
91 LINEAR
92 };
93
96 {
97 wxQueueEvent( m_dcEnable2, new wxCommandEvent( wxEVT_CHECKBOX ) );
98 wxQueueEvent( m_dcSourceType1, new wxCommandEvent( wxEVT_RADIOBOX ) );
99 wxQueueEvent( m_dcSourceType2, new wxCommandEvent( wxEVT_RADIOBOX ) );
100 wxQueueEvent( m_inputSignalsFilter, new wxCommandEvent( wxEVT_TEXT ) );
101 }
102
108 wxString evaluateDCControls( wxChoice* aDcSource, wxTextCtrl* aDcStart, wxTextCtrl* aDcStop,
109 wxTextCtrl* aDcIncr );
110
114 void updateDCSources( wxChar aType, wxChoice* aSource );
115
119 void updateDCUnits( wxChar aType, wxStaticText* aStartValUnit, wxStaticText* aEndValUnit,
120 wxStaticText* aStepUnit );
121
122 virtual void onInitDlg( wxInitDialogEvent& event ) override
123 {
124 // Call the default wxDialog handler of a wxInitDialogEvent
126
127 // Now all widgets have the size fixed, call FinishDialogSettings
129 }
130
136 void parseCommand( const wxString& aCommand );
137
138 void onLoadDirectives( wxCommandEvent& event ) override
139 {
141 }
142
143 void onDCEnableSecondSource( wxCommandEvent& event ) override;
144 void onSwapDCSources( wxCommandEvent& event ) override;
145 void onDCSource1Selected( wxCommandEvent& event ) override;
146 void onDCSource2Selected( wxCommandEvent& event ) override;
147
148 void OnUpdateUILockY1( wxUpdateUIEvent& event ) override;
149 void OnUpdateUILockY2( wxUpdateUIEvent& event ) override;
150 void OnUpdateUILockY3( wxUpdateUIEvent& event ) override;
151
152 static wxString scaleToString( int aOption )
153 {
154 switch( aOption )
155 {
156 case DECADE: return wxString( "dec" );
157 case OCTAVE: return wxString( "oct" );
158 case LINEAR: return wxString( "lin" );
159 default: wxFAIL_MSG( "Unhandled scale type" ); return wxEmptyString;
160 }
161 }
162
163 void OnCommandType( wxCommandEvent& event ) override;
164 void OnFilterMouseMoved( wxMouseEvent& event ) override;
165 void OnFilterText( wxCommandEvent& event ) override;
166
167 void loadDirectives();
168
169private:
171 wxString m_simCommand;
172 std::shared_ptr<SPICE_CIRCUIT_MODEL> m_circuitModel;
173 std::shared_ptr<SPICE_SETTINGS> m_settings;
176 wxIntegerValidator<int> m_posIntValidator;
177 std::set<wxString> m_fftInputSignals;
178};
179
180#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)
void SetPlotSettings(const SIM_TAB *aSimTab)
void SetSimCommand(const wxString &aCommand)
void OnCommandType(wxCommandEvent &event) override
void OnFilterMouseMoved(wxMouseEvent &event) override
wxIntegerValidator< int > m_posIntValidator
void onDCSource2Selected(wxCommandEvent &event) override
void OnUpdateUILockY3(wxUpdateUIEvent &event) override
bool TransferDataFromWindow() override
void updateDCSources(wxChar aType, wxChoice *aSource)
Update DC sweep source with symbols from schematic.
void OnUpdateUILockY1(wxUpdateUIEvent &event) override
std::set< wxString > m_fftInputSignals
SPICE_VALIDATOR m_spiceValidator
void onDCEnableSecondSource(wxCommandEvent &event) override
void ApplySettings(SIM_TAB *aTab)
void SetSimOptions(int aOptions)
SIMULATOR_FRAME * m_simulatorFrame
void onDCSource1Selected(wxCommandEvent &event) override
void parseCommand(const wxString &aCommand)
Parse a Spice directive.
bool TransferDataToWindow() override
void updateDCUnits(wxChar aType, wxStaticText *aStartValUnit, wxStaticText *aEndValUnit, wxStaticText *aStepUnit)
Update units on labels depending on selected source.
void OnFilterText(wxCommandEvent &event) override
const wxString & GetSimCommand() const
std::shared_ptr< SPICE_CIRCUIT_MODEL > m_circuitModel
virtual void onInitDlg(wxInitDialogEvent &event) override
std::shared_ptr< SPICE_SETTINGS > m_settings
void OnUpdateUILockY2(wxUpdateUIEvent &event) override
SPICE_VALIDATOR m_spiceEmptyValidator
void onLoadDirectives(wxCommandEvent &event) override
The SIMULATOR_FRAME holds the main user-interface for running simulations.
Special netlist exporter flavor that allows one to override simulation commands.
Storage for simulator specific settings.