25#include <wx/filedlg.h>
27#include <wx/stc/stc.h>
82 if( openDlg.ShowModal() == wxID_CANCEL )
92 wxFileName filename =
m_simulator->Settings()->GetWorkbookFilename();
94 if( filename.GetName().IsEmpty() )
98 filename.SetName(
_(
"noname" ) );
108 return filename.GetFullName();
118 return path.GetPath();
127 filename =
m_simulator->Settings()->GetWorkbookFilename();
129 if( filename.IsEmpty() )
133 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
135 if( saveAsDlg.ShowModal() == wxID_CANCEL )
138 filename = saveAsDlg.GetPath();
152 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
154 if( saveDlg.ShowModal() == wxID_CANCEL )
172 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
174 if( saveDlg.ShowModal() == wxID_CANCEL )
177 wxFFile out( saveDlg.GetPath(),
"wb" );
181 if( traces.size() == 0 )
186 std::size_t rowCount = traces.begin()->second->GetDataX().size();
189 wxString xAxisName(
m_simulator->GetXAxis( simType ) );
190 out.Write( wxString::Format( wxT(
"%s%c" ), xAxisName,
SEPARATOR ) );
192 for(
const auto& [
name, trace] : traces )
193 out.Write( wxString::Format( wxT(
"%s%c" ),
name,
SEPARATOR ) );
195 out.Write( wxS(
"\r\n" ) );
198 for ( std::size_t curRow=0; curRow < rowCount; curRow++ )
200 double xAxisValue = traces.begin()->second->GetDataX().at( curRow );
201 out.Write( wxString::Format( wxT(
"%g%c" ), xAxisValue,
SEPARATOR ) );
203 for(
const auto& [
name, trace] : traces )
205 double yAxisValue = trace->GetDataY().at( curRow );
206 out.Write( wxString::Format( wxT(
"%g%c" ), yAxisValue,
SEPARATOR ) );
209 out.Write( wxS(
"\r\n" ) );
246 plot->ShowGrid( !
plot->IsGridShown() );
260 plot->ShowLegend( !
plot->IsLegendShown() );
274 plot->SetDottedSecondary( !
plot->GetDottedSecondary() );
314 if( blocking_dialog )
315 blocking_dialog->Close(
true );
331 if( blocking_dialog )
332 blocking_dialog->Close(
true );
351 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL ) );
355 DIALOG_SHIM( parent, wxID_ANY,
_(
"SPICE Netlist" ), wxDefaultPosition,
356 wxSize( 800, 800 ), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
360 m_splitter =
new wxSplitterWindow(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
361 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
364 m_splitter->SetExtraStyle( wxWS_EX_TRANSIENT );
369 m_textCtrl->StyleSetForeground( wxSTC_STYLE_LINENUMBER, wxColour( 75, 75, 75 ) );
370 m_textCtrl->StyleSetBackground( wxSTC_STYLE_LINENUMBER, wxColour( 220, 220, 220 ) );
375 for(
int i = 0; i < wxSTC_STYLE_MAX; ++i )
394 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
395 sizer->Add(
m_splitter, 1, wxEXPAND | wxALL, 5 );
static TOOL_ACTION toggleGrid
static TOOL_ACTION zoomOutCenter
static TOOL_ACTION zoomFitScreen
static TOOL_ACTION zoomInCenter
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
static TOOL_ACTION editUserDefinedSignals
static TOOL_ACTION simCommand
static TOOL_ACTION openWorkbook
static TOOL_ACTION stopSimulation
static TOOL_ACTION toggleLegend
static TOOL_ACTION saveWorkbook
static TOOL_ACTION saveWorkbookAs
static TOOL_ACTION exportPlotAsCSV
static TOOL_ACTION simTune
static TOOL_ACTION toggleDarkModePlots
static TOOL_ACTION exportPlotAsPNG
static TOOL_ACTION showNetlist
static TOOL_ACTION simProbe
static TOOL_ACTION toggleDottedSecondary
static TOOL_ACTION newPlot
static TOOL_ACTION runSimulation
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.
wxWindow * GetBlockingDialog()
Gets the window pointer to the blocking dialog (to send it signals)
WX_HTML_REPORT_BOX * m_reporter
void SetNetlist(const wxString &aSource)
std::unique_ptr< SCINTILLA_TRICKS > m_scintillaTricks
void onClose(wxCloseEvent &evt)
wxStyledTextCtrl * m_textCtrl
NETLIST_VIEW_DIALOG(wxWindow *parent)
wxSplitterWindow * m_splitter
virtual const wxString GetProjectPath() const
Return the full path of the project.
virtual const wxString GetProjectName() const
Return the short name of the project.
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.
A pure virtual class used to derive REPORTER objects from.
int ExportPlotAsPNG(const TOOL_EVENT &aEvent)
wxString getDefaultPath()
Return the default path to be used in file browser dialog.
SCH_EDIT_FRAME * m_schematicFrame
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
int ToggleLegend(const TOOL_EVENT &aEvent)
int ShowNetlist(const TOOL_EVENT &aEvent)
int NewPlot(const TOOL_EVENT &aEvent)
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
int ToggleDarkModePlots(const TOOL_EVENT &aEvent)
int Tune(const TOOL_EVENT &aEvent)
wxString getDefaultFilename()
Return the default filename (with extension) to be used in file browser dialog.
SIMULATOR_FRAME * m_simulatorFrame
bool Init() override
Init() is called once upon a registration of the tool.
int SaveWorkbook(const TOOL_EVENT &aEvent)
std::shared_ptr< NGSPICE_CIRCUIT_MODEL > m_circuitModel
int RunSimulation(const TOOL_EVENT &aEvent)
int OpenWorkbook(const TOOL_EVENT &aEvent)
int EditUserDefinedSignals(const TOOL_EVENT &aEvent)
int ToggleGrid(const TOOL_EVENT &aEvent)
int Zoom(const TOOL_EVENT &aEvent)
int ToggleDottedSecondary(const TOOL_EVENT &aEvent)
std::shared_ptr< SPICE_SIMULATOR > m_simulator
int EditSimCommand(const TOOL_EVENT &aEvent)
int ExportPlotAsCSV(const TOOL_EVENT &aEvent)
int Probe(const TOOL_EVENT &aEvent)
int Close(const TOOL_EVENT &aEvent)
SIM_PANEL_BASE * NewPlotPanel(const wxString &aSimCommand, int aSimOptions)
Create a new plot tab for a given simulation type.
void OnModify() override
Must be called after a model change in order to set the "modify" flag and do other frame-specific pro...
std::shared_ptr< NGSPICE_CIRCUIT_MODEL > GetCircuitModel() const
bool SaveWorkbook(const wxString &aPath)
Save plot, signal, cursor, measurement, etc.
SCH_EDIT_FRAME * GetSchematicFrame() const
void ToggleDarkModePlots()
Toggle dark-mode of the plot tabs.
SIM_PLOT_PANEL * GetCurrentPlot() const
Return the current tab (or NULL if there is none).
int GetCurrentOptions() const
bool LoadWorkbook(const wxString &aPath)
Load plot, signal, cursor, measurement, etc.
bool EditSimCommand()
Shows a dialog for editing the current tab's simulation command, or creating a new tab with a differe...
const std::map< int, wxString > & UserDefinedSignals()
std::shared_ptr< SPICE_SIMULATOR > GetSimulator() const
void SetUserDefinedSignals(const std::map< int, wxString > &aSignals)
static bool IsPlottable(SIM_TYPE aSimType)
const std::map< wxString, TRACE * > & GetTraces() const
mpWindow * GetPlotWin() const
A slimmed down version of WX_HTML_REPORT_PANEL.
void Flush()
Build the HTML messages page.
bool SaveScreenshot(const wxString &filename, wxBitmapType type=wxBITMAP_TYPE_BMP, wxSize imageSize=wxDefaultSize, bool fit=false)
Draw the window on a wxBitmap, then save it to a file.
void ZoomIn(const wxPoint ¢erPoint=wxDefaultPosition)
Zoom into current view and refresh display.
void ZoomOut(const wxPoint ¢erPoint=wxDefaultPosition)
Zoom out current view and refresh display.
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
This file is part of the common library.
const std::string WorkbookFileExtension
wxString WorkbookFileWildcard()
wxString PngFileWildcard()
wxString CsvFileWildcard()
wxFont GetMonospacedUIFont()
SIM_TYPE
< Possible simulation types
Definition of file extensions used in Kicad.
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().