30#include <wx/filedlg.h>
33#include <wx/stc/stc.h>
48#include <wx/clipbrd.h>
49#include <wx/dataobj.h>
50#include <wx/mstream.h>
115 if( openDlg.ShowModal() == wxID_CANCEL )
125 wxFileName filename =
m_simulator->Settings()->GetWorkbookFilename();
127 if( filename.GetName().IsEmpty() )
131 filename.SetName(
_(
"noname" ) );
141 return filename.GetFullName();
151 return path.GetPath();
160 filename =
m_simulator->Settings()->GetWorkbookFilename();
162 if( filename.IsEmpty() )
167 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
171 if( saveAsDlg.ShowModal() == wxID_CANCEL )
174 filename = saveAsDlg.GetPath();
191 if( saveDlg.ShowModal() == wxID_CANCEL )
195 plotTab->GetPlotWin()->SaveScreenshot( screenImage );
196 screenImage.SaveFile( saveDlg.GetPath(), wxBITMAP_TYPE_PNG );
208 plotTab->GetPlotWin()->SaveScreenshot( screenImage );
210 if( wxTheClipboard->Open() )
212 wxBitmap bm( screenImage );
214 wxTheClipboard->SetData(
new wxBitmapDataObject( bm ) );
215 wxTheClipboard->Flush();
216 wxTheClipboard->Close();
233 if( blocking_dialog )
234 blocking_dialog->Close(
true );
237 plotTab->GetPlotWin()->SaveScreenshot( screenImage );
239 if( wxTheClipboard->Open() )
242 wxMemoryOutputStream stream;
243 screenImage.SaveFile( stream, wxBITMAP_TYPE_PNG );
248 string <<
"(image (at 0 0)\n";
249 string <<
" (data\n";
252 buff.GetWriteBuf( stream.GetLength() );
253 stream.CopyTo( buff.GetData(), stream.GetLength() );
254 buff.SetDataLen( stream.GetLength() );
257 out << wxBase64Encode( buff );
259 #define MIME_BASE64_LENGTH 76
262 while( first < out.Length() )
270 wxTheClipboard->SetData(
new wxTextDataObject(
string ) );
271 wxTheClipboard->Close();
296 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
300 if( saveDlg.ShowModal() == wxID_CANCEL )
303 wxFFile out( saveDlg.GetPath(),
"wb" );
305 std::map<wxString, TRACE*> traces = plotTab->GetTraces();
307 if( traces.size() == 0 )
310 SIM_TYPE simType = plotTab->GetSimType();
312 std::size_t rowCount = traces.begin()->second->GetDataX().size();
315 wxString xAxisName(
m_simulator->GetXAxis( simType ) );
316 out.Write( wxString::Format( wxT(
"%s%c" ), xAxisName,
SEPARATOR ) );
318 for(
const auto& [
name, trace] : traces )
319 out.Write( wxString::Format( wxT(
"%s%c" ), trace->GetDisplayName(),
SEPARATOR ) );
321 out.Write( wxS(
"\r\n" ) );
324 for ( std::size_t curRow=0; curRow < rowCount; curRow++ )
326 double xAxisValue = traces.begin()->second->GetDataX().at( curRow );
327 out.Write( wxString::Format( wxT(
"%g%c" ), xAxisValue,
SEPARATOR ) );
329 for(
const auto& [
name, trace] : traces )
331 double yAxisValue = trace->GetDataY().at( curRow );
332 out.Write( wxString::Format( wxT(
"%g%c" ), yAxisValue,
SEPARATOR ) );
335 out.Write( wxS(
"\r\n" ) );
384 wxCommandEvent
dummy;
396 plotTab->GetPlotWin()->ZoomUndo();
405 plotTab->GetPlotWin()->ZoomRedo();
433 plotTab->ShowGrid( !plotTab->IsGridShown() );
445 plotTab->ShowLegend( !plotTab->IsLegendShown() );
457 plotTab->SetDottedSecondary( !plotTab->GetDottedSecondary() );
506 if( blocking_dialog )
507 blocking_dialog->Close(
true );
523 if( blocking_dialog )
524 blocking_dialog->Close(
true );
543 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL ) );
547 DIALOG_SHIM( parent, wxID_ANY,
_(
"SPICE Netlist" ), wxDefaultPosition,
548 wxSize( 800, 800 ), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
552 m_splitter =
new wxSplitterWindow(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
553 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
556 m_splitter->SetExtraStyle( wxWS_EX_TRANSIENT );
561 m_textCtrl->StyleSetForeground( wxSTC_STYLE_LINENUMBER, wxColour( 75, 75, 75 ) );
562 m_textCtrl->StyleSetBackground( wxSTC_STYLE_LINENUMBER, wxColour( 220, 220, 220 ) );
567 for(
int i = 0; i < wxSTC_STYLE_MAX; ++i )
586 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
587 sizer->Add(
m_splitter, 1, wxEXPAND | wxALL, 5 );
620 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().