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, see <https://www.gnu.org/licenses/>.
21 */
22
23#ifndef DIALOG_SIM_COMMAND_H
24#define DIALOG_SIM_COMMAND_H
25
28#include <sim/spice_value.h>
29
30#include <wx/valnum.h>
31
33class SPICE_SETTINGS;
34class SIMULATOR_FRAME;
35class SIM_TAB;
36
37
39{
40public:
42 std::shared_ptr<SPICE_CIRCUIT_MODEL> aCircuitModel,
43 std::shared_ptr<SPICE_SETTINGS>& aSettings );
44
45 const wxString& GetSimCommand() const
46 {
47 return m_simCommand;
48 }
49
50 void SetSimCommand( const wxString& aCommand )
51 {
52 parseCommand( aCommand );
53 m_simCommand = aCommand;
55 }
56
67
68 void SetPlotSettings( const SIM_TAB* aSimTab );
69
70 bool TransferDataFromWindow() override;
71 bool TransferDataToWindow() override;
72
73 // The default dialog Validate() calls the validators of all widgets.
74 // This is not what we want; We want only validators of the selected page
75 // of the notebooks. So disable the wxDialog::Validate(), and let our
76 // TransferDataFromWindow doing the job.
77 virtual bool Validate() override
78 {
79 return true;
80 }
81
82 void ApplySettings( SIM_TAB* aTab );
83
84private:
91
94 {
95 wxQueueEvent( m_dcEnable2, new wxCommandEvent( wxEVT_CHECKBOX ) );
96 wxQueueEvent( m_dcSourceType1, new wxCommandEvent( wxEVT_RADIOBOX ) );
97 wxQueueEvent( m_dcSourceType2, new wxCommandEvent( wxEVT_RADIOBOX ) );
98 wxQueueEvent( m_inputSignalsFilter, new wxCommandEvent( wxEVT_TEXT ) );
99 }
100
106 wxString evaluateDCControls( wxChoice* aDcSource, wxTextCtrl* aDcStart, wxTextCtrl* aDcStop,
107 wxTextCtrl* aDcIncr );
108
112 void updateDCSources( wxChar aType, wxChoice* aSource );
113
117 void updateDCUnits( wxChar aType, wxStaticText* aStartValUnit, wxStaticText* aEndValUnit,
118 wxStaticText* aStepUnit );
119
120 virtual void onInitDlg( wxInitDialogEvent& event ) override
121 {
122 // Call the default wxDialog handler of a wxInitDialogEvent
124
125 // Now all widgets have the size fixed, call FinishDialogSettings
127 }
128
134 void parseCommand( const wxString& aCommand );
135
136 void onLoadDirectives( wxCommandEvent& event ) override
137 {
139 }
140
141 void onDCEnableSecondSource( wxCommandEvent& event ) override;
142 void onSwapDCSources( wxCommandEvent& event ) override;
143 void onDCSource1Selected( wxCommandEvent& event ) override;
144 void onDCSource2Selected( wxCommandEvent& event ) override;
145
146 void OnUpdateUILockY1( wxUpdateUIEvent& event ) override;
147 void OnUpdateUILockY2( wxUpdateUIEvent& event ) override;
148 void OnUpdateUILockY3( wxUpdateUIEvent& event ) override;
149
150 static wxString scaleToString( int aOption )
151 {
152 switch( aOption )
153 {
154 case DECADE: return wxString( "dec" );
155 case OCTAVE: return wxString( "oct" );
156 case LINEAR: return wxString( "lin" );
157 default: wxFAIL_MSG( "Unhandled scale type" ); return wxEmptyString;
158 }
159 }
160
161 void OnCommandType( wxCommandEvent& event ) override;
162 void OnFilterMouseMoved( wxMouseEvent& event ) override;
163 void OnFilterText( wxCommandEvent& event ) override;
164
165 void loadDirectives();
166
167private:
169 wxString m_simCommand;
170 std::shared_ptr<SPICE_CIRCUIT_MODEL> m_circuitModel;
171 std::shared_ptr<SPICE_SETTINGS> m_settings;
174 wxIntegerValidator<int> m_posIntValidator;
175 std::set<wxString> m_fftInputSignals;
176};
177
178#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...
DIALOG_SIM_COMMAND_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Simulation Analysis"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
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
DIALOG_SIM_COMMAND(SIMULATOR_FRAME *aParent, std::shared_ptr< SPICE_CIRCUIT_MODEL > aCircuitModel, std::shared_ptr< SPICE_SETTINGS > &aSettings)
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.