80        wxCommandEvent* 
event = 
new wxCommandEvent( EVT_SIM_REPORT );
 
   81        event->SetString( aText );
 
 
   93        wxCommandEvent* 
event = 
nullptr;
 
   97        case SIM_IDLE:    
event = 
new wxCommandEvent( EVT_SIM_FINISHED ); 
break;
 
   98        case SIM_RUNNING: 
event = 
new wxCommandEvent( EVT_SIM_STARTED );  
break;
 
   99        default:          wxFAIL;                                         
return;
 
 
 
  118                      wxDefaultSize, wxDEFAULT_FRAME_STYLE, wxT( 
"simulator" ), 
unityScale ),
 
  133    wxBoxSizer* mainSizer = 
new wxBoxSizer( wxVERTICAL );
 
  134    SetSizer( mainSizer );
 
  137    mainSizer->Add( 
m_infoBar, 0, wxEXPAND, 0 );
 
  140                                      wxAUI_TB_DEFAULT_STYLE|wxAUI_TB_HORZ_LAYOUT|wxAUI_TB_PLAIN_BACKGROUND );
 
  145    mainSizer->Add( 
m_ui, 1, wxEXPAND, 5 );
 
  156    if( cfg->GetWorkbookFilename().IsEmpty() )
 
  194    m_ui->SetSubWindowsSashSize();
 
  199    m_ui->InitWorkbook();
 
 
  208    m_simulator->Attach( 
nullptr, wxEmptyString, 0, wxEmptyString, devnull );
 
 
  239    m_ui->ShowChangedLanguage();
 
 
  248        m_ui->LoadSettings( cfg );
 
 
  261        m_ui->SaveSettings( cfg );
 
 
  276        m_ui->ApplyPreferences( cfg->m_Simulator.preferences );
 
 
  283        return &cfg->m_Simulator.window;
 
  285    wxFAIL_MSG( wxT( 
"SIMULATOR not running with EESCHEMA_SETTINGS" ) );
 
 
  292    if( 
m_ui->GetCurrentSimTab() )
 
  293        return m_ui->GetCurrentSimTab()->GetSimCommand();
 
 
  308        return simTab->GetSimOptions();
 
 
  317    bool                              readOnly = 
false;
 
  320    wxFileName                        filename = 
Prj().
AbsolutePath( cfg->GetWorkbookFilename() );
 
  322    if( filename.IsOk() && filename.FileExists() )
 
  325        readOnly = !filename.IsFileWritable();
 
  329        title = wxT( 
"*" ) + filename.GetName();
 
  331        title = filename.GetName();
 
  334        title += wxS( 
" " ) + 
_( 
"[Read Only]" );
 
  337        title += wxS( 
" " ) + 
_( 
"[Unsaved]" );
 
  339    title += wxT( 
" \u2014 " ) + 
_( 
"SPICE Simulator" );
 
 
  346#define MAX_MESSAGES 20 
  353    wxArrayString lines = wxSplit( aReporter.
GetMessages(), 
'\n' );
 
  358        lines.Add( wxS( 
"..." ) );
 
  364                             wxJoin( lines, 
'\n' ) );
 
  369                             wxJoin( lines, 
'\n' ) );
 
 
  378    if( !
m_schematicFrame->ReadyToNetlist( 
_( 
"Simulator requires a fully annotated schematic." ) ) )
 
 
  412    if( simTab->
GetSimCommand().Upper().StartsWith( wxT( 
"FFT" ) )
 
  413        || simTab->
GetSimCommand().Upper().Contains( wxT( 
"\nFFT" ) ) )
 
  415        wxString tranSpicePlot;
 
  418            tranSpicePlot = tranPlotTab->GetSpicePlotName();
 
  420        if( tranSpicePlot.IsEmpty() )
 
  423                                          "will be used for the fast Fourier transform." ) );
 
  427            m_simulator->Command( 
"setplot " + tranSpicePlot.ToStdString() );
 
  429            wxArrayString commands = wxSplit( simTab->
GetSimCommand(), 
'\n' );
 
  431            for( 
const wxString& command : commands )
 
  438            m_ui->OnSimRefresh( 
true );
 
  450        if( 
m_ui->GetSimTabIndex( simTab ) == 0
 
  454                || 
IsOK( 
this, 
_( 
"Schematic sheet simulation command directive has changed.  " 
  455                                  "Do you wish to update the Simulation Command?" ) ) )
 
  467    std::unique_lock<std::mutex> simulatorLock( 
m_simulator->GetMutex(), std::try_to_lock );
 
  469    if( simulatorLock.owns_lock() )
 
  478        m_ui->OnPlotSettingsChanged();
 
 
  489    return m_ui->NewSimTab( aSimCommand );
 
 
  495    return m_ui->SimPlotVectors();
 
 
  501    return m_ui->Signals();
 
 
  507    return m_ui->UserDefinedSignals();
 
 
  513    m_ui->SetUserDefinedSignals( aSignals );
 
 
  531    m_ui->AddTuner( aSheetPath, aSymbol );
 
 
  537    return m_ui->GetCurrentSimTab();
 
 
  543    if( 
m_ui->LoadWorkbook( aPath ) )
 
 
  564    if( 
m_ui->SaveWorkbook( aPath ) )
 
 
  578    m_ui->ToggleSimConsole();
 
 
  584    m_ui->ToggleSimSidePanel();
 
 
  590    m_ui->ToggleDarkModePlots();
 
 
  617        m_ui->OnPlotSettingsChanged();
 
 
  630        wxFileName filename = 
m_simulator->Settings()->GetWorkbookFilename();
 
  632        if( filename.GetName().IsEmpty() )
 
  634            if( 
Prj().GetProjectName().IsEmpty() )
 
  635                filename.SetFullName( wxT( 
"noname.wbk" ) );
 
  637                filename.SetFullName( 
Prj().GetProjectName() + wxT( 
".wbk" ) );
 
 
  677    auto showGridCondition =
 
  684    auto showLegendCondition =
 
  691    auto showDottedCondition =
 
  698    auto darkModePlotCondition =
 
  701                return m_ui->DarkModePlots();
 
  743    auto isSimConsoleShown =
 
  749                    return m_ui->IsSimConsoleShown();
 
  754    auto isSimSidePanelShown =
 
  760                    return m_ui->IsSimSidePanelShown();
 
  766#define ENABLE( x ) ACTION_CONDITIONS().Enable( x ) 
  767#define CHECK( x )  ACTION_CONDITIONS().Check( x ) 
 
  803    SetCursor( wxCURSOR_ARROWWAIT );
 
 
  829    SetCursor( wxNullCursor );
 
  837    m_ui->OnSimRefresh( 
true );
 
 
  846    static bool updateInProgress = 
false;
 
  849    if( updateInProgress )
 
  852    updateInProgress = 
true;
 
  857    std::unique_lock<std::mutex> simulatorLock( 
m_simulator->GetMutex(), std::try_to_lock );
 
  859    if( simulatorLock.owns_lock() )
 
  869    updateInProgress = 
false;
 
 
  875    m_ui->OnSimReport( aEvent.GetString() );
 
 
  881    if( aEvent.GetId() == wxID_EXIT )
 
  884    if( aEvent.GetId() == wxID_CLOSE )
 
 
constexpr EDA_IU_SCALE unityScale
 
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
 
static TOOL_ACTION toggleGrid
 
static TOOL_ACTION cancelInteractive
 
static TOOL_ACTION zoomRedo
 
static TOOL_ACTION zoomUndo
 
Manage TOOL_ACTION objects.
 
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
 
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
 
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
 
Handle actions that are shared between different applications.
 
void SetPlotSettings(const SIM_TAB *aSimTab)
 
void SetSimCommand(const wxString &aCommand)
 
void ApplySettings(SIM_TAB *aTab)
 
void SetSimOptions(int aOptions)
 
const wxString & GetSimCommand() const
 
virtual APP_SETTINGS_BASE * config() const
Return the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
 
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
 
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
 
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
 
virtual void OnModify()
Must be called after a model change in order to set the "modify" flag and do other frame-specific pro...
 
TOOLBAR_SETTINGS * m_toolbarSettings
 
virtual void configureToolbars()
 
virtual void RecreateToolbars()
 
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
 
virtual void SaveSettings(APP_SETTINGS_BASE *aCfg)
Save common frame parameters to a configuration data file.
 
ACTION_TOOLBAR * m_tbTopMain
 
void ReCreateMenuBar()
Recreate the menu bar.
 
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
 
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
 
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
 
KIWAY_PLAYER(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName, const EDA_IU_SCALE &aIuScale)
 
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
 
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
 
bool SaveToFile(const wxString &aDirectory="", bool aForce=false) override
Calls Store() and then saves the JSON document contents into the parent JSON_SETTINGS.
 
A singleton reporter that reports to nowhere.
 
SCHEMATIC_SETTINGS * m_SchematicSettings
 
virtual PROJECT_FILE & GetProjectFile() const
 
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
 
virtual bool HasMessageOfSeverity(int aSeverityMask) const
Returns true if the reporter has one or more messages matching the specified severity mask.
 
virtual bool HasMessage() const
Returns true if any messages were reported.
 
std::shared_ptr< NGSPICE_SETTINGS > m_NgspiceSettings
Ngspice simulator settings.
 
Holds all the data relating to one schematic.
 
void ClearOperatingPoints()
Clear operating points from a .op simulation.
 
static TOOL_ACTION toggleSimConsole
 
static TOOL_ACTION exportPlotToClipboard
 
static TOOL_ACTION saveWorkbookAs
 
static TOOL_ACTION toggleSimSidePanel
 
static TOOL_ACTION exportPlotAsCSV
 
static TOOL_ACTION simAnalysisProperties
 
static TOOL_ACTION toggleDottedSecondary
 
static TOOL_ACTION simTune
 
static TOOL_ACTION toggleDarkModePlots
 
static TOOL_ACTION exportPlotAsPNG
 
static TOOL_ACTION exportPlotToSchematic
 
static TOOL_ACTION runSimulation
 
static TOOL_ACTION newAnalysisTab
 
static TOOL_ACTION simProbe
 
static TOOL_ACTION showNetlist
 
static TOOL_ACTION openWorkbook
 
static TOOL_ACTION saveWorkbook
 
static TOOL_ACTION toggleLegend
 
static TOOL_ACTION stopSimulation
 
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...
 
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
 
Handle actions for the various symbol editor and viewers.
 
The SIMULATOR_FRAME_UI holds the main user-interface for running simulations.
 
The SIMULATOR_FRAME holds the main user-interface for running simulations.
 
SIMULATOR_FRAME(KIWAY *aKiway, wxWindow *aParent)
 
SIM_TAB * GetCurrentSimTab() const
Return the current tab (or NULL if there is none).
 
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
 
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.
 
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.
 
const std::vector< wxString > Signals()
 
void doCloseWindow() override
 
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()
 
void SetUserDefinedSignals(const std::map< int, wxString > &aSignals)
 
void ToggleSimSidePanel()
 
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...
 
Interface to receive simulation updates from SPICE_SIMULATOR class.
 
static std::shared_ptr< SPICE_SIMULATOR > CreateInstance(const std::string &aName)
 
mpWindow * GetPlotWin() const
 
bool GetDottedSecondary() const
Turn on/off the cursor for a particular trace.
 
bool IsLegendShown() const
 
int GetSimOptions() const
 
void SetLastSchTextSimCommand(const wxString &aCmd)
 
void SetSimCommand(const wxString &aSimCommand)
 
const wxString & GetSimCommand() const
 
wxString GetLastSchTextSimCommand() const
 
void SetSpicePlotName(const wxString &aPlotName)
 
SIMULATOR_FRAME * m_parent
 
SIM_THREAD_REPORTER(SIMULATOR_FRAME *aParent)
 
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
 
bool HasMessage() const override
Returns true if any messages were reported.
 
void OnSimStateChange(SIMULATOR *aObject, SIM_STATE aNewState) override
 
static SIM_TYPE CommandToSimType(const wxString &aCmd)
Return simulation type basing on a simulation command directive.
 
A modified version of the wxInfoBar class that allows us to:
 
A wrapper for reporting to a wxString object.
 
const wxString & GetMessages() const
 
int RedoZoomStackSize() const
 
int UndoZoomStackSize() const
 
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
 
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
 
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
 
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
 
This file is part of the common library.
 
T * GetToolbarSettings(const wxString &aFilename)
 
T * GetAppSettings(const char *aFilename)
 
SIM_TYPE
< Possible simulation types
 
wxDEFINE_EVENT(EVT_SIM_UPDATE, wxCommandEvent)
 
static WX_STRING_REPORTER s_reporter
 
KIWAY Kiway(KFCTL_STANDALONE)
 
Store the common settings that are saved and loaded for each window / frame.
 
Definition of file extensions used in Kicad.