diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp
index e73fce831b..f5c2836273 100644
--- a/eeschema/sim/sim_plot_frame.cpp
+++ b/eeschema/sim/sim_plot_frame.cpp
@@ -185,6 +185,58 @@ int SIM_PLOT_FRAME::getNodeNumber( const wxString& aNetName )
}
+void SIM_PLOT_FRAME::menuSaveImage( wxCommandEvent& event )
+{
+ wxFileDialog saveDlg( this, wxT( "Save plot as image" ), "", "",
+ "PNG file (*.png)|*.png", wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
+
+ if( saveDlg.ShowModal() == wxID_CANCEL )
+ return;
+
+ CurrentPlot()->SaveScreenshot( saveDlg.GetPath(), wxBITMAP_TYPE_PNG );
+}
+
+
+void SIM_PLOT_FRAME::menuSaveCsv( wxCommandEvent& event )
+{
+ const wxChar SEPARATOR = ';';
+
+ wxFileDialog saveDlg( this, wxT( "Save plot data" ), "", "",
+ "CSV file (*.csv)|*.csv", wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
+
+ if( saveDlg.ShowModal() == wxID_CANCEL )
+ return;
+
+ wxFile out( saveDlg.GetPath(), wxFile::write );
+ bool timeWritten = false;
+
+ for( const auto& t : CurrentPlot()->GetTraces() )
+ {
+ const TRACE* trace = t.second;
+
+ if( !timeWritten )
+ {
+ out.Write( wxString::Format( "Time%c", SEPARATOR ) );
+
+ for( double v : trace->GetDataX() )
+ out.Write( wxString::Format( "%f%c", v, SEPARATOR ) );
+
+ out.Write( "\r\n" );
+ timeWritten = true;
+ }
+
+ out.Write( wxString::Format( "%s%c", t.first, SEPARATOR ) );
+
+ for( double v : trace->GetDataY() )
+ out.Write( wxString::Format( "%f%c", v, SEPARATOR ) );
+
+ out.Write( "\r\n" );
+ }
+
+ out.Close();
+}
+
+
void SIM_PLOT_FRAME::menuZoomIn( wxCommandEvent& event )
{
CurrentPlot()->ZoomIn();
diff --git a/eeschema/sim/sim_plot_frame.h b/eeschema/sim/sim_plot_frame.h
index be3a664256..b46e556dda 100644
--- a/eeschema/sim/sim_plot_frame.h
+++ b/eeschema/sim/sim_plot_frame.h
@@ -92,6 +92,8 @@ class SIM_PLOT_FRAME : public SIM_PLOT_FRAME_BASE
}
// Event handlers
+ void menuSaveImage( wxCommandEvent& event ) override;
+ void menuSaveCsv( wxCommandEvent& event ) override;
void menuZoomIn( wxCommandEvent& event ) override;
void menuZoomOut( wxCommandEvent& event ) override;
void menuZoomFit( wxCommandEvent& event ) override;
diff --git a/eeschema/sim/sim_plot_frame_base.cpp b/eeschema/sim/sim_plot_frame_base.cpp
index a13990e4b1..75a1544d48 100644
--- a/eeschema/sim/sim_plot_frame_base.cpp
+++ b/eeschema/sim/sim_plot_frame_base.cpp
@@ -15,25 +15,35 @@ SIM_PLOT_FRAME_BASE::SIM_PLOT_FRAME_BASE( wxWindow* parent, wxWindowID id, const
m_mainMenu = new wxMenuBar( 0 );
m_fileMenu = new wxMenu();
- wxMenuItem* m_menuItem7;
- m_menuItem7 = new wxMenuItem( m_fileMenu, wxID_NEW, wxString( _("New Plot") ) , wxEmptyString, wxITEM_NORMAL );
- m_fileMenu->Append( m_menuItem7 );
+ wxMenuItem* m_newPlot;
+ m_newPlot = new wxMenuItem( m_fileMenu, wxID_NEW, wxString( _("New Plot") ) , wxEmptyString, wxITEM_NORMAL );
+ m_fileMenu->Append( m_newPlot );
m_fileMenu->AppendSeparator();
- wxMenuItem* m_menuItem8;
- m_menuItem8 = new wxMenuItem( m_fileMenu, wxID_OPEN, wxString( _("Open Workbook") ) , wxEmptyString, wxITEM_NORMAL );
- m_fileMenu->Append( m_menuItem8 );
+ wxMenuItem* m_openWorkbook;
+ m_openWorkbook = new wxMenuItem( m_fileMenu, wxID_OPEN, wxString( _("Open Workbook") ) , wxEmptyString, wxITEM_NORMAL );
+ m_fileMenu->Append( m_openWorkbook );
- wxMenuItem* m_menuItem2;
- m_menuItem2 = new wxMenuItem( m_fileMenu, wxID_SAVE, wxString( _("Save Workbook") ) , wxEmptyString, wxITEM_NORMAL );
- m_fileMenu->Append( m_menuItem2 );
+ wxMenuItem* m_saveWorkbook;
+ m_saveWorkbook = new wxMenuItem( m_fileMenu, wxID_SAVE, wxString( _("Save Workbook") ) , wxEmptyString, wxITEM_NORMAL );
+ m_fileMenu->Append( m_saveWorkbook );
m_fileMenu->AppendSeparator();
- wxMenuItem* m_menuItem1;
- m_menuItem1 = new wxMenuItem( m_fileMenu, wxID_CLOSE, wxString( _("Exit Simulation") ) , wxEmptyString, wxITEM_NORMAL );
- m_fileMenu->Append( m_menuItem1 );
+ wxMenuItem* m_saveImage;
+ m_saveImage = new wxMenuItem( m_fileMenu, wxID_ANY, wxString( _("Save as image") ) , wxEmptyString, wxITEM_NORMAL );
+ m_fileMenu->Append( m_saveImage );
+
+ wxMenuItem* m_saveCsv;
+ m_saveCsv = new wxMenuItem( m_fileMenu, wxID_ANY, wxString( _("Save as .csv file") ) , wxEmptyString, wxITEM_NORMAL );
+ m_fileMenu->Append( m_saveCsv );
+
+ m_fileMenu->AppendSeparator();
+
+ wxMenuItem* m_exitSim;
+ m_exitSim = new wxMenuItem( m_fileMenu, wxID_CLOSE, wxString( _("Exit Simulation") ) , wxEmptyString, wxITEM_NORMAL );
+ m_fileMenu->Append( m_exitSim );
m_mainMenu->Append( m_fileMenu, _("File") );
@@ -132,10 +142,12 @@ SIM_PLOT_FRAME_BASE::SIM_PLOT_FRAME_BASE( wxWindow* parent, wxWindowID id, const
this->Centre( wxBOTH );
// Connect Events
- this->Connect( m_menuItem7->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuNewPlot ) );
- this->Connect( m_menuItem8->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuOpenWorkbook ) );
- this->Connect( m_menuItem2->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuSaveWorkbook ) );
- this->Connect( m_menuItem1->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuExit ) );
+ this->Connect( m_newPlot->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuNewPlot ) );
+ this->Connect( m_openWorkbook->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuOpenWorkbook ) );
+ this->Connect( m_saveWorkbook->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuSaveWorkbook ) );
+ this->Connect( m_saveImage->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuSaveImage ) );
+ this->Connect( m_saveCsv->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuSaveCsv ) );
+ this->Connect( m_exitSim->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuExit ) );
this->Connect( m_zoomIn->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuZoomIn ) );
this->Connect( m_zoomOut->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuZoomOut ) );
this->Connect( m_zoomFit->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuZoomFit ) );
@@ -159,6 +171,8 @@ SIM_PLOT_FRAME_BASE::~SIM_PLOT_FRAME_BASE()
this->Disconnect( wxID_NEW, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuNewPlot ) );
this->Disconnect( wxID_OPEN, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuOpenWorkbook ) );
this->Disconnect( wxID_SAVE, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuSaveWorkbook ) );
+ this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuSaveImage ) );
+ this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuSaveCsv ) );
this->Disconnect( wxID_CLOSE, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuExit ) );
this->Disconnect( wxID_ZOOM_IN, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuZoomIn ) );
this->Disconnect( wxID_ZOOM_OUT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuZoomOut ) );
diff --git a/eeschema/sim/sim_plot_frame_base.fbp b/eeschema/sim/sim_plot_frame_base.fbp
index 9c941424c4..92a27ad63a 100644
--- a/eeschema/sim/sim_plot_frame_base.fbp
+++ b/eeschema/sim/sim_plot_frame_base.fbp
@@ -133,7 +133,7 @@
-