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 The 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
56class SIMULATOR_INIT_ERR : public std::runtime_error
57{
58public:
59 explicit SIMULATOR_INIT_ERR(const std::string& what_arg)
60 : std::runtime_error(what_arg) {}
61};
62
63
84{
85public:
86 SIMULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent );
88
93 bool LoadSimulator( const wxString& aSimCommand, unsigned aSimOptions );
94
98 void ReloadSimulator( const wxString& aSimCommand, unsigned aSimOptions );
99
100 void StartSimulation();
101
107 SIM_TAB* NewSimTab( const wxString& aSimCommand );
108
113 bool EditAnalysis();
114
118 const std::vector<wxString> SimPlotVectors();
119
123 const std::vector<wxString> Signals();
124
125 const std::map<int, wxString>& UserDefinedSignals();
126
127 void SetUserDefinedSignals( const std::map<int, wxString>& aSignals );
128
134 void AddVoltageTrace( const wxString& aNetName );
135
142 void AddCurrentTrace( const wxString& aDeviceName );
143
147 void AddTuner( const SCH_SHEET_PATH& aSheetPath, SCH_SYMBOL* aSymbol );
148
152 SIM_TAB* GetCurrentSimTab() const;
153
154 void ToggleSimConsole();
155
156 void ToggleSimSidePanel();
157
161 void ToggleDarkModePlots();
162
163 void ShowChangedLanguage() override;
164
168 bool LoadWorkbook( const wxString& aPath );
169
173 bool SaveWorkbook( const wxString& aPath );
174
175 void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
176
177 void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
178
179 void CommonSettingsChanged( int aFlags ) override;
180
182
184
185 std::shared_ptr<SPICE_CIRCUIT_MODEL> GetCircuitModel() const { return m_circuitModel; }
186
187 std::shared_ptr<SPICE_SIMULATOR> GetSimulator() const { return m_simulator; }
188
189 wxString GetCurrentSimCommand() const;
191 int GetCurrentOptions() const;
192
193 bool SimFinished() const { return m_simFinished; }
194
195 // Simulator doesn't host a canvas
196 wxWindow* GetToolCanvas() const override { return nullptr; }
197
201 void UpdateTitle();
202
203 void OnModify() override;
204
205 DECLARE_EVENT_TABLE()
206
207private:
208 void setupTools();
209 void doReCreateMenuBar() override;
210
211 void setupUIConditions() override;
212
213 void showNetlistErrors( const WX_STRING_REPORTER& aReporter );
214
215 bool canCloseWindow( wxCloseEvent& aEvent ) override;
216 void doCloseWindow() override;
217
218 void onUpdateSim( wxCommandEvent& aEvent );
219 void onSimReport( wxCommandEvent& aEvent );
220 void onSimStarted( wxCommandEvent& aEvent );
221 void onSimFinished( wxCommandEvent& aEvent );
222
223 void onExit( wxCommandEvent& event );
224
225private:
229
233
236};
237
238// Commands
239wxDECLARE_EVENT( EVT_SIM_UPDATE, wxCommandEvent );
240wxDECLARE_EVENT( EVT_SIM_REPORT, wxCommandEvent );
241
242// Notifications
243wxDECLARE_EVENT( EVT_SIM_STARTED, wxCommandEvent );
244wxDECLARE_EVENT( EVT_SIM_FINISHED, wxCommandEvent );
245
246#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:108
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:286
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:75
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)
bool LoadSimulator(const wxString &aSimCommand, unsigned aSimOptions)
Check and load the current netlist into the simulator.
void onSimReport(wxCommandEvent &aEvent)
wxString GetCurrentSimCommand() const
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
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
Simple error container for failure to init the simulation engine and ultimately abort the frame const...
SIMULATOR_INIT_ERR(const std::string &what_arg)
Special netlist exporter flavor that allows one to override simulation commands.
A wrapper for reporting to a wxString object.
Definition: reporter.h:190
STL namespace.
SIM_TYPE
< Possible simulation types
Definition: sim_types.h:32
wxDECLARE_EVENT(EVT_SIM_UPDATE, wxCommandEvent)
Store the common settings that are saved and loaded for each window / frame.
Definition: app_settings.h:90