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 {
67 }
68
69 void SetPlotSettings( const SIM_TAB* aSimTab );
70
71 bool TransferDataFromWindow() override;
72 bool TransferDataToWindow() override;
73
74 // The default dialog Validate() calls the validators of all widgets.
75 // This is not what we want; We want only validators of the selected page
76 // of the notebooks. So disable the wxDialog::Validate(), and let our
77 // TransferDataFromWindow doing the job.
78 virtual bool Validate() override
79 {
80 return true;
81 }
82
83 void ApplySettings( SIM_TAB* aTab );
84
85private:
87 {
90 LINEAR
91 };
92
95 {
96 wxQueueEvent( m_dcEnable2, new wxCommandEvent( wxEVT_CHECKBOX ) );
97 wxQueueEvent( m_dcSourceType1, new wxCommandEvent( wxEVT_RADIOBOX ) );
98 wxQueueEvent( m_dcSourceType2, new wxCommandEvent( wxEVT_RADIOBOX ) );
99 wxQueueEvent( m_inputSignalsFilter, new wxCommandEvent( wxEVT_TEXT ) );
100 }
101
107 wxString evaluateDCControls( wxChoice* aDcSource, wxTextCtrl* aDcStart, wxTextCtrl* aDcStop,
108 wxTextCtrl* aDcIncr );
109
113 void updateDCSources( wxChar aType, wxChoice* aSource );
114
118 void updateDCUnits( wxChar aType, wxStaticText* aStartValUnit, wxStaticText* aEndValUnit,
119 wxStaticText* aStepUnit );
120
121 virtual void onInitDlg( wxInitDialogEvent& event ) override
122 {
123 // Call the default wxDialog handler of a wxInitDialogEvent
125
126 // Now all widgets have the size fixed, call FinishDialogSettings
128 }
129
135 void parseCommand( const wxString& aCommand );
136
137 void onLoadDirectives( wxCommandEvent& event ) override
138 {
140 }
141
142 void onDCEnableSecondSource( wxCommandEvent& event ) override;
143 void onSwapDCSources( wxCommandEvent& event ) override;
144 void onDCSource1Selected( wxCommandEvent& event ) override;
145 void onDCSource2Selected( wxCommandEvent& event ) override;
146
147 void OnUpdateUILockY1( wxUpdateUIEvent& event ) override;
148 void OnUpdateUILockY2( wxUpdateUIEvent& event ) override;
149 void OnUpdateUILockY3( wxUpdateUIEvent& event ) override;
150
151 static wxString scaleToString( int aOption )
152 {
153 switch( aOption )
154 {
155 case DECADE: return wxString( "dec" );
156 case OCTAVE: return wxString( "oct" );
157 case LINEAR: return wxString( "lin" );
158 default: wxFAIL_MSG( "Unhandled scale type" ); return wxEmptyString;
159 }
160 }
161
162 void OnCommandType( wxCommandEvent& event ) override;
163 void OnFilterMouseMoved( wxMouseEvent& event ) override;
164 void OnFilterText( wxCommandEvent& event ) override;
165
166 void loadDirectives();
167
168private:
170 wxString m_simCommand;
171 std::shared_ptr<SPICE_CIRCUIT_MODEL> m_circuitModel;
172 std::shared_ptr<SPICE_SETTINGS> m_settings;
175 wxIntegerValidator<int> m_posIntValidator;
176 std::set<wxString> m_fftInputSignals;
177};
178
179#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.