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
83 void StartSimulation();
84
90 SIM_TAB* NewSimTab( const wxString& aSimCommand );
91
96 bool EditAnalysis();
97
101 const std::vector<wxString> SimPlotVectors();
102
106 const std::vector<wxString> Signals();
107
108 const std::map<int, wxString>& UserDefinedSignals();
109
110 void SetUserDefinedSignals( const std::map<int, wxString>& aSignals );
111
117 void AddVoltageTrace( const wxString& aNetName );
118
125 void AddCurrentTrace( const wxString& aDeviceName );
126
130 void AddTuner( const SCH_SHEET_PATH& aSheetPath, SCH_SYMBOL* aSymbol );
131
135 SIM_TAB* GetCurrentSimTab() const;
136
140 void ToggleDarkModePlots();
141
142 void ShowChangedLanguage() override;
143
144 void ReCreateHToolbar();
145
149 bool LoadWorkbook( const wxString& aPath );
150
154 bool SaveWorkbook( const wxString& aPath );
155
156 void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
157
158 void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
159
161
163
164 std::shared_ptr<SPICE_CIRCUIT_MODEL> GetCircuitModel() const { return m_circuitModel; }
165
166 std::shared_ptr<SPICE_SIMULATOR> GetSimulator() const { return m_simulator; }
167
168 wxString GetCurrentSimCommand() const;
170 int GetCurrentOptions() const;
171
172 bool SimFinished() const { return m_simFinished; }
173
174 // Simulator doesn't host a canvas
175 wxWindow* GetToolCanvas() const override { return nullptr; }
176
180 void UpdateTitle();
181
182 void OnModify() override;
183
184 DECLARE_EVENT_TABLE()
185
186private:
187 void setupTools();
188 void doReCreateMenuBar() override;
189
190 void setupUIConditions() override;
191
192 bool canCloseWindow( wxCloseEvent& aEvent ) override;
193 void doCloseWindow() override;
194
195 void onUpdateSim( wxCommandEvent& aEvent );
196 void onSimReport( wxCommandEvent& aEvent );
197 void onSimStarted( wxCommandEvent& aEvent );
198 void onSimFinished( wxCommandEvent& aEvent );
199
200 void onExit( wxCommandEvent& event );
201
202private:
206
210
213};
214
215// Commands
216wxDECLARE_EVENT( EVT_SIM_UPDATE, wxCommandEvent );
217wxDECLARE_EVENT( EVT_SIM_REPORT, wxCommandEvent );
218
219// Notifications
220wxDECLARE_EVENT( EVT_SIM_STARTED, wxCommandEvent );
221wxDECLARE_EVENT( EVT_SIM_FINISHED, wxCommandEvent );
222
223#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:66
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:81
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.
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