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-2023 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
166
168
169 std::shared_ptr<SPICE_CIRCUIT_MODEL> GetCircuitModel() const { return m_circuitModel; }
170
171 std::shared_ptr<SPICE_SIMULATOR> GetSimulator() const { return m_simulator; }
172
173 wxString GetCurrentSimCommand() const;
175 int GetCurrentOptions() const;
176
177 bool SimFinished() const { return m_simFinished; }
178
179 // Simulator doesn't host a canvas
180 wxWindow* GetToolCanvas() const override { return nullptr; }
181
185 void UpdateTitle();
186
187 void OnModify() override;
188
189 DECLARE_EVENT_TABLE()
190
191private:
192 void setupTools();
193 void doReCreateMenuBar() override;
194
195 void setupUIConditions() override;
196
197 bool canCloseWindow( wxCloseEvent& aEvent ) override;
198 void doCloseWindow() override;
199
200 void onUpdateSim( wxCommandEvent& aEvent );
201 void onSimReport( wxCommandEvent& aEvent );
202 void onSimStarted( wxCommandEvent& aEvent );
203 void onSimFinished( wxCommandEvent& aEvent );
204
205 void onExit( wxCommandEvent& event );
206
207private:
211
215
218};
219
220// Commands
221wxDECLARE_EVENT( EVT_SIM_UPDATE, wxCommandEvent );
222wxDECLARE_EVENT( EVT_SIM_REPORT, wxCommandEvent );
223
224// Notifications
225wxDECLARE_EVENT( EVT_SIM_STARTED, wxCommandEvent );
226wxDECLARE_EVENT( EVT_SIM_FINISHED, wxCommandEvent );
227
228#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:67
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:279
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:109
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
std::shared_ptr< SPICE_CIRCUIT_MODEL > GetCircuitModel() const
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.
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