KiCad PCB EDA Suite
Loading...
Searching...
No Matches
simulator_frame.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-2023 CERN
5 * Copyright (C) 2017-2024 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Tomasz Wlostowski <[email protected]>
8 * @author Maciej Suminski <[email protected]>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 3
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, you may find one here:
22 * https://www.gnu.org/licenses/gpl-3.0.html
23 * or you may search the http://www.gnu.org website for the version 3 license,
24 * or you may write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 */
27
28#ifndef SIMULATOR_FRAME_H
29#define SIMULATOR_FRAME_H
30
31
33#include <sim/sim_types.h>
34
35#include <kiway_player.h>
37
38#include <wx/event.h>
39
40#include <list>
41#include <memory>
42#include <map>
43
44class SCH_EDIT_FRAME;
45class SCH_SYMBOL;
48class ACTION_TOOLBAR;
49class SPICE_SIMULATOR;
50
51
72{
73public:
74 SIMULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent );
76
81 bool LoadSimulator( const wxString& aSimCommand, unsigned aSimOptions );
82
86 void ReloadSimulator( const wxString& aSimCommand, unsigned aSimOptions );
87
88 void StartSimulation();
89
95 SIM_TAB* NewSimTab( const wxString& aSimCommand );
96
101 bool EditAnalysis();
102
106 const std::vector<wxString> SimPlotVectors();
107
111 const std::vector<wxString> Signals();
112
113 const std::map<int, wxString>& UserDefinedSignals();
114
115 void SetUserDefinedSignals( const std::map<int, wxString>& aSignals );
116
122 void AddVoltageTrace( const wxString& aNetName );
123
130 void AddCurrentTrace( const wxString& aDeviceName );
131
135 void AddTuner( const SCH_SHEET_PATH& aSheetPath, SCH_SYMBOL* aSymbol );
136
140 SIM_TAB* GetCurrentSimTab() const;
141
145 void ToggleDarkModePlots();
146
147 void ShowChangedLanguage() override;
148
149 void ReCreateHToolbar();
150
154 bool LoadWorkbook( const wxString& aPath );
155
159 bool SaveWorkbook( const wxString& aPath );
160
161 void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
162
163 void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
164
165 void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
166
168
170
171 std::shared_ptr<SPICE_CIRCUIT_MODEL> GetCircuitModel() const { return m_circuitModel; }
172
173 std::shared_ptr<SPICE_SIMULATOR> GetSimulator() const { return m_simulator; }
174
175 wxString GetCurrentSimCommand() const;
177 int GetCurrentOptions() const;
178
179 bool SimFinished() const { return m_simFinished; }
180
181 // Simulator doesn't host a canvas
182 wxWindow* GetToolCanvas() const override { return nullptr; }
183
187 void UpdateTitle();
188
189 void OnModify() override;
190
191 DECLARE_EVENT_TABLE()
192
193private:
194 void setupTools();
195 void doReCreateMenuBar() override;
196
197 void setupUIConditions() override;
198
199 void showNetlistErrors( const WX_STRING_REPORTER& aReporter );
200
201 bool canCloseWindow( wxCloseEvent& aEvent ) override;
202 void doCloseWindow() override;
203
204 void onUpdateSim( wxCommandEvent& aEvent );
205 void onSimReport( wxCommandEvent& aEvent );
206 void onSimStarted( wxCommandEvent& aEvent );
207 void onSimFinished( wxCommandEvent& aEvent );
208
209 void onExit( wxCommandEvent& event );
210
211private:
215
219
222};
223
224// Commands
225wxDECLARE_EVENT( EVT_SIM_UPDATE, wxCommandEvent );
226wxDECLARE_EVENT( EVT_SIM_REPORT, wxCommandEvent );
227
228// Notifications
229wxDECLARE_EVENT( EVT_SIM_STARTED, wxCommandEvent );
230wxDECLARE_EVENT( EVT_SIM_FINISHED, wxCommandEvent );
231
232#endif // SIMULATOR_FRAME_H
Define the structure of a toolbar with buttons that invoke ACTIONs.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:92
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:65
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:284
Schematic editor (Eeschema) main window.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Schematic symbol object.
Definition: sch_symbol.h:104
The SIMULATOR_FRAME_UI holds the main user-interface for running simulations.
The SIMULATOR_FRAME holds the main user-interface for running simulations.
SIM_TAB * GetCurrentSimTab() const
Return the current tab (or NULL if there is none).
void ShowChangedLanguage() override
bool canCloseWindow(wxCloseEvent &aEvent) override
void onSimFinished(wxCommandEvent &aEvent)
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
bool LoadSimulator(const wxString &aSimCommand, unsigned aSimOptions)
Check and load the current netlist into the simulator.
void onSimReport(wxCommandEvent &aEvent)
wxString GetCurrentSimCommand() const
std::shared_ptr< SPICE_CIRCUIT_MODEL > GetCircuitModel() const
void showNetlistErrors(const WX_STRING_REPORTER &aReporter)
void onExit(wxCommandEvent &event)
std::shared_ptr< SPICE_SIMULATOR > m_simulator
SIM_TYPE GetCurrentSimType() const
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
ACTION_TOOLBAR * m_toolBar
void AddCurrentTrace(const wxString &aDeviceName)
Add a current trace for a given device to the current plot.
void OnModify() override
Must be called after a model change in order to set the "modify" flag and do other frame-specific pro...
bool SaveWorkbook(const wxString &aPath)
Save plot, signal, cursor, measurement, etc.
void doReCreateMenuBar() override
SCH_EDIT_FRAME * GetSchematicFrame() const
const std::vector< wxString > Signals()
void doCloseWindow() override
bool SimFinished() const
const std::vector< wxString > SimPlotVectors()
void AddVoltageTrace(const wxString &aNetName)
Add a voltage trace for a given net to the current plot.
void ToggleDarkModePlots()
Toggle dark-mode of the plot tabs.
SIM_THREAD_REPORTER * m_reporter
void AddTuner(const SCH_SHEET_PATH &aSheetPath, SCH_SYMBOL *aSymbol)
Add a tuner for a symbol.
void onSimStarted(wxCommandEvent &aEvent)
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
std::shared_ptr< SPICE_CIRCUIT_MODEL > m_circuitModel
SIM_TAB * NewSimTab(const wxString &aSimCommand)
Create a new plot tab for a given simulation type.
bool EditAnalysis()
Shows a dialog for editing the current tab's simulation command, or creating a new tab with a differe...
int GetCurrentOptions() const
bool LoadWorkbook(const wxString &aPath)
Load plot, signal, cursor, measurement, etc.
WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg) override
Return a pointer to the window settings for this frame.
void onUpdateSim(wxCommandEvent &aEvent)
void UpdateTitle()
Set the main window title bar text.
const std::map< int, wxString > & UserDefinedSignals()
std::shared_ptr< SPICE_SIMULATOR > GetSimulator() const
void SetUserDefinedSignals(const std::map< int, wxString > &aSignals)
wxWindow * GetToolCanvas() const override
Canvas access.
void ReloadSimulator(const wxString &aSimCommand, unsigned aSimOptions)
Re-send the current command and settings to the simulator.
SCH_EDIT_FRAME * m_schematicFrame
SIMULATOR_FRAME_UI * m_ui
Special netlist exporter flavor that allows one to override simulation commands.
A wrapper for reporting to a wxString object.
Definition: reporter.h:171
STL namespace.
SIM_TYPE
< Possible simulation types
Definition: sim_types.h:32
wxDECLARE_EVENT(EVT_SIM_UPDATE, wxCommandEvent)
Stores the common settings that are saved and loaded for each window / frame.
Definition: app_settings.h:74