26#include <wx/filedlg.h>
29#include <wx/stc/stc.h>
44#include <wx/clipbrd.h>
45#include <wx/dataobj.h>
46#include <wx/mstream.h>
111 if( openDlg.ShowModal() == wxID_CANCEL )
121 wxFileName filename =
m_simulator->Settings()->GetWorkbookFilename();
123 if( filename.GetName().IsEmpty() )
127 filename.SetName(
_(
"noname" ) );
137 return filename.GetFullName();
147 return path.GetPath();
156 filename =
m_simulator->Settings()->GetWorkbookFilename();
158 if( filename.IsEmpty() )
163 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
167 if( saveAsDlg.ShowModal() == wxID_CANCEL )
170 filename = saveAsDlg.GetPath();
187 if( saveDlg.ShowModal() == wxID_CANCEL )
191 plotTab->GetPlotWin()->SaveScreenshot( screenImage );
192 screenImage.SaveFile( saveDlg.GetPath(), wxBITMAP_TYPE_PNG );
204 plotTab->GetPlotWin()->SaveScreenshot( screenImage );
206 if( wxTheClipboard->Open() )
208 wxBitmap bm( screenImage );
210 wxTheClipboard->SetData(
new wxBitmapDataObject( bm ) );
211 wxTheClipboard->Flush();
212 wxTheClipboard->Close();
229 if( blocking_dialog )
230 blocking_dialog->Close(
true );
233 plotTab->GetPlotWin()->SaveScreenshot( screenImage );
235 if( wxTheClipboard->Open() )
238 wxMemoryOutputStream stream;
239 screenImage.SaveFile( stream, wxBITMAP_TYPE_PNG );
244 string <<
"(image (at 0 0)\n";
245 string <<
" (data\n";
248 buff.GetWriteBuf( stream.GetLength() );
249 stream.CopyTo( buff.GetData(), stream.GetLength() );
250 buff.SetDataLen( stream.GetLength() );
253 out << wxBase64Encode( buff );
255 #define MIME_BASE64_LENGTH 76
258 while( first < out.Length() )
266 wxTheClipboard->SetData(
new wxTextDataObject(
string ) );
267 wxTheClipboard->Close();
292 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
296 if( saveDlg.ShowModal() == wxID_CANCEL )
299 wxFFile out( saveDlg.GetPath(),
"wb" );
301 std::map<wxString, TRACE*> traces = plotTab->GetTraces();
303 if( traces.size() == 0 )
306 SIM_TYPE simType = plotTab->GetSimType();
308 std::size_t rowCount = traces.begin()->second->GetDataX().size();
311 wxString xAxisName(
m_simulator->GetXAxis( simType ) );
312 out.Write( wxString::Format( wxT(
"%s%c" ), xAxisName,
SEPARATOR ) );
314 for(
const auto& [
name, trace] : traces )
315 out.Write( wxString::Format( wxT(
"%s%c" ), trace->GetDisplayName(),
SEPARATOR ) );
317 out.Write( wxS(
"\r\n" ) );
320 for ( std::size_t curRow=0; curRow < rowCount; curRow++ )
322 double xAxisValue = traces.begin()->second->GetDataX().at( curRow );
323 out.Write( wxString::Format( wxT(
"%g%c" ), xAxisValue,
SEPARATOR ) );
325 for(
const auto& [
name, trace] : traces )
327 double yAxisValue = trace->GetDataY().at( curRow );
328 out.Write( wxString::Format( wxT(
"%g%c" ), yAxisValue,
SEPARATOR ) );
331 out.Write( wxS(
"\r\n" ) );
380 wxCommandEvent
dummy;
392 plotTab->GetPlotWin()->ZoomUndo();
401 plotTab->GetPlotWin()->ZoomRedo();
429 plotTab->ShowGrid( !plotTab->IsGridShown() );
441 plotTab->ShowLegend( !plotTab->IsLegendShown() );
453 plotTab->SetDottedSecondary( !plotTab->GetDottedSecondary() );
502 if( blocking_dialog )
503 blocking_dialog->Close(
true );
519 if( blocking_dialog )
520 blocking_dialog->Close(
true );
539 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL ) );
543 DIALOG_SHIM( parent, wxID_ANY,
_(
"SPICE Netlist" ), wxDefaultPosition,
544 wxSize( 800, 800 ), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
548 m_splitter =
new wxSplitterWindow(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
549 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
552 m_splitter->SetExtraStyle( wxWS_EX_TRANSIENT );
557 m_textCtrl->StyleSetForeground( wxSTC_STYLE_LINENUMBER, wxColour( 75, 75, 75 ) );
558 m_textCtrl->StyleSetBackground( wxSTC_STYLE_LINENUMBER, wxColour( 220, 220, 220 ) );
563 for(
int i = 0; i < wxSTC_STYLE_MAX; ++i )
582 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
583 sizer->Add(
m_splitter, 1, wxEXPAND | wxALL, 5 );
616 std::map<int, wxString> userSignals =
m_simulatorFrame->UserDefinedSignals();
static TOOL_ACTION toggleGrid
static TOOL_ACTION zoomOutCenter
static TOOL_ACTION zoomRedo
static TOOL_ACTION zoomOutHorizontally
static TOOL_ACTION zoomOutVertically
static TOOL_ACTION zoomInHorizontally
static TOOL_ACTION zoomFitScreen
static TOOL_ACTION zoomInCenter
static TOOL_ACTION zoomInVertically
static TOOL_ACTION zoomUndo
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
DIALOG_SHIM(wxWindow *aParent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER, const wxString &name=wxDialogNameStr)
void SetSimCommand(const wxString &aCommand)
void ApplySettings(SIM_TAB *aTab)
void SetSimOptions(int aOptions)
const wxString & GetSimCommand() const
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
A pure virtual class used to derive REPORTER objects from.
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 editUserDefinedSignals
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
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 RedoZoom(const TOOL_EVENT &aEvent)
int ShowNetlist(const TOOL_EVENT &aEvent)
int ExportPlotToClipboard(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)
int RunSimulation(const TOOL_EVENT &aEvent)
SIM_TAB * getCurrentSimTab()
Set up handlers for various events.
int OpenWorkbook(const TOOL_EVENT &aEvent)
int EditUserDefinedSignals(const TOOL_EVENT &aEvent)
std::shared_ptr< SPICE_CIRCUIT_MODEL > m_circuitModel
int ToggleGrid(const TOOL_EVENT &aEvent)
int Zoom(const TOOL_EVENT &aEvent)
int EditAnalysisTab(const TOOL_EVENT &aEvent)
int ToggleSimConsolePanel(const TOOL_EVENT &aEvent)
int ToggleDottedSecondary(const TOOL_EVENT &aEvent)
std::shared_ptr< SPICE_SIMULATOR > m_simulator
int ExportPlotAsCSV(const TOOL_EVENT &aEvent)
int UndoZoom(const TOOL_EVENT &aEvent)
int ExportPlotToSchematic(const TOOL_EVENT &aEvent)
int Probe(const TOOL_EVENT &aEvent)
int ToggleSimSidePanel(const TOOL_EVENT &aEvent)
int NewAnalysisTab(const TOOL_EVENT &aEvent)
int Close(const TOOL_EVENT &aEvent)
A slimmed down version of WX_HTML_REPORT_PANEL.
A wrapper for reporting to a wxString object.
Canvas for plotting mpLayer implementations.
static double zoomIncrementalFactor
This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse...
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
static const std::string WorkbookFileExtension
static wxString PngFileWildcard()
static wxString CsvFileWildcard()
static wxString WorkbookFileWildcard()
KICOMMON_API wxFont GetMonospacedUIFont()
SIM_TYPE
< Possible simulation types
#define MIME_BASE64_LENGTH
std::vector< FAB_LAYER_COLOR > dummy
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
IbisParser parser & reporter
Definition of file extensions used in Kicad.
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().