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 The 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 {
63 m_fixIncludePaths->SetValue( aOptions &
67 m_saveAllDissipations->SetValue( aOptions &
70 }
71
72 void SetPlotSettings( const SIM_TAB* aSimTab );
73
74 bool TransferDataFromWindow() override;
75 bool TransferDataToWindow() override;
76
77 // The default dialog Validate() calls the validators of all widgets.
78 // This is not what we want; We want only validators of the selected page
79 // of the notebooks. So disable the wxDialog::Validate(), and let our
80 // TransferDataFromWindow doing the job.
81 virtual bool Validate() override
82 {
83 return true;
84 }
85
86 void ApplySettings( SIM_TAB* aTab );
87
88private:
90 {
93 LINEAR
94 };
95
98 {
99 wxQueueEvent( m_dcEnable2, new wxCommandEvent( wxEVT_CHECKBOX ) );
100 wxQueueEvent( m_dcSourceType1, new wxCommandEvent( wxEVT_RADIOBOX ) );
101 wxQueueEvent( m_dcSourceType2, new wxCommandEvent( wxEVT_RADIOBOX ) );
102 wxQueueEvent( m_inputSignalsFilter, new wxCommandEvent( wxEVT_TEXT ) );
103 }
104
110 wxString evaluateDCControls( wxChoice* aDcSource, wxTextCtrl* aDcStart, wxTextCtrl* aDcStop,
111 wxTextCtrl* aDcIncr );
112
116 void updateDCSources( wxChar aType, wxChoice* aSource );
117
121 void updateDCUnits( wxChar aType, wxStaticText* aStartValUnit, wxStaticText* aEndValUnit,
122 wxStaticText* aStepUnit );
123
124 virtual void onInitDlg( wxInitDialogEvent& event ) override
125 {
126 // Call the default wxDialog handler of a wxInitDialogEvent
128
129 // Now all widgets have the size fixed, call FinishDialogSettings
131 }
132
138 void parseCommand( const wxString& aCommand );
139
140 void onLoadDirectives( wxCommandEvent& event ) override
141 {
143 }
144
145 void onDCEnableSecondSource( wxCommandEvent& event ) override;
146 void onSwapDCSources( wxCommandEvent& event ) override;
147 void onDCSource1Selected( wxCommandEvent& event ) override;
148 void onDCSource2Selected( wxCommandEvent& event ) override;
149
150 void OnUpdateUILockY1( wxUpdateUIEvent& event ) override;
151 void OnUpdateUILockY2( wxUpdateUIEvent& event ) override;
152 void OnUpdateUILockY3( wxUpdateUIEvent& event ) override;
153
154 static wxString scaleToString( int aOption )
155 {
156 switch( aOption )
157 {
158 case DECADE: return wxString( "dec" );
159 case OCTAVE: return wxString( "oct" );
160 case LINEAR: return wxString( "lin" );
161 default: wxFAIL_MSG( "Unhandled scale type" ); return wxEmptyString;
162 }
163 }
164
165 void OnCommandType( wxCommandEvent& event ) override;
166 void OnFilterMouseMoved( wxMouseEvent& event ) override;
167 void OnFilterText( wxCommandEvent& event ) override;
168
169 void loadDirectives();
170
171private:
173 wxString m_simCommand;
174 std::shared_ptr<SPICE_CIRCUIT_MODEL> m_circuitModel;
175 std::shared_ptr<SPICE_SETTINGS> m_settings;
178 wxIntegerValidator<int> m_posIntValidator;
179 std::set<wxString> m_fftInputSignals;
180};
181
182#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 refreshUIControls()
Generate events to update UI state.
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.