From 92a3e405c213b4421091e8e96e9a16d7f354c849 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Thu, 11 Aug 2016 14:41:45 +0200 Subject: [PATCH] Tuner tool. --- eeschema/CMakeLists.txt | 2 + eeschema/eeschema_id.h | 3 +- eeschema/onleftclick.cpp | 25 +- eeschema/schedit.cpp | 7 +- eeschema/schframe.cpp | 3 +- eeschema/schframe.h | 4 + eeschema/sim/sim_plot_frame.cpp | 144 ++++++- eeschema/sim/sim_plot_frame.h | 27 +- eeschema/sim/sim_plot_frame_base.cpp | 35 +- eeschema/sim/sim_plot_frame_base.fbp | 572 +++++++++++---------------- eeschema/sim/sim_plot_frame_base.h | 5 +- eeschema/sim/simulate.cpp | 49 ++- 12 files changed, 499 insertions(+), 377 deletions(-) diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 8e8f02126b..3d32a8f3ff 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -191,6 +191,8 @@ set( EESCHEMA_SRCS dialogs/dialog_sim_settings_base.cpp dialogs/dialog_spice_model.cpp dialogs/dialog_spice_model_base.cpp + widgets/tuner_slider.cpp + widgets/tuner_slider_base.cpp netlist_exporters/netlist_exporter.cpp netlist_exporters/netlist_exporter_cadstar.cpp diff --git a/eeschema/eeschema_id.h b/eeschema/eeschema_id.h index 2e94e51e5a..94d764893a 100644 --- a/eeschema/eeschema_id.h +++ b/eeschema/eeschema_id.h @@ -257,7 +257,8 @@ enum id_eeschema_frm ID_UPDATE_SCH_FROM_PCB, ID_SIM_SHOW, - ID_SIM_ADD_PROBE + ID_SIM_PROBE, + ID_SIM_TUNE }; diff --git a/eeschema/onleftclick.cpp b/eeschema/onleftclick.cpp index 114b2266e3..a35baab2d9 100644 --- a/eeschema/onleftclick.cpp +++ b/eeschema/onleftclick.cpp @@ -325,7 +325,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) } break; - case ID_SIM_ADD_PROBE: + case ID_SIM_PROBE: { const KICAD_T wiresAndComponents[] = { SCH_LINE_T, SCH_COMPONENT_T, SCH_SHEET_PIN_T }; item = LocateAndShowItem( aPosition, wiresAndComponents ); @@ -350,6 +350,29 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) } break; + case ID_SIM_TUNE: + { + const KICAD_T fieldsAndComponents[] = { SCH_COMPONENT_T, SCH_FIELD_T }; + item = LocateAndShowItem( aPosition, fieldsAndComponents ); + + if( !item ) + return; + + if( item->Type() != SCH_COMPONENT_T ) + { + item = static_cast( item->GetParent() ); + + if( item->Type() != SCH_COMPONENT_T ) + return; + } + + SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false ); + + if( simFrame ) + simFrame->AddTuner( static_cast( item ) ); + } + break; + default: SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString ); wxFAIL_MSG( wxT( "SCH_EDIT_FRAME::OnLeftClick invalid tool ID <" ) + diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index aa9615a9f1..10917ff499 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -609,11 +609,16 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) ); break; - case ID_SIM_ADD_PROBE: + case ID_SIM_PROBE: SetToolID( id, -1, _( "Add a simulator probe" ) ); m_canvas->SetCursor( CURSOR_PROBE ); break; + case ID_SIM_TUNE: + SetToolID( id, -1, _( "Select a value to be tuned" ) ); + m_canvas->SetCursor( CURSOR_TUNE ); + break; + default: SetRepeatItem( NULL ); } diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index ccd1180859..cd26bf7051 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -281,7 +281,8 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_TOOL_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START, ID_SCHEMATIC_VERTICAL_TOOLBAR_END, SCH_EDIT_FRAME::OnSelectTool ) - EVT_TOOL( ID_SIM_ADD_PROBE, SCH_EDIT_FRAME::OnSelectTool ) + EVT_TOOL( ID_SIM_PROBE, SCH_EDIT_FRAME::OnSelectTool ) + EVT_TOOL( ID_SIM_TUNE, SCH_EDIT_FRAME::OnSelectTool ) EVT_MENU( ID_CANCEL_CURRENT_COMMAND, SCH_EDIT_FRAME::OnCancelCurrentCommand ) EVT_MENU( ID_SCH_DRAG_ITEM, SCH_EDIT_FRAME::OnDragItem ) diff --git a/eeschema/schframe.h b/eeschema/schframe.h index 7c7938f65d..9c5c40b1b8 100644 --- a/eeschema/schframe.h +++ b/eeschema/schframe.h @@ -1381,8 +1381,12 @@ public: wxString GetNetListerCommand() const { return m_netListerCommand; } + ///> Probe cursor, used by circuit simulator const static wxCursor CURSOR_PROBE; + ///> Tuner cursor, used by circuit simulator + const static wxCursor CURSOR_TUNE; + DECLARE_EVENT_TABLE() }; diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index ffd6d08bb1..f0f2db250d 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -26,7 +26,9 @@ #include #include #include +#include +#include #include #include "netlist_exporter_pspice_sim.h" @@ -87,6 +89,7 @@ SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) updateNetlistExporter(); Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( SIM_PLOT_FRAME::onClose ), NULL, this ); + Connect( EVT_SIM_UPDATE, wxCommandEventHandler( SIM_PLOT_FRAME::onSimUpdate ), NULL, this ); Connect( EVT_SIM_REPORT, wxCommandEventHandler( SIM_PLOT_FRAME::onSimReport ), NULL, this ); Connect( EVT_SIM_STARTED, wxCommandEventHandler( SIM_PLOT_FRAME::onSimStarted ), NULL, this ); Connect( EVT_SIM_FINISHED, wxCommandEventHandler( SIM_PLOT_FRAME::onSimFinished ), NULL, this ); @@ -105,17 +108,20 @@ void SIM_PLOT_FRAME::StartSimulation() m_simConsole->Clear(); - // TODO check if there is a valid simulation command + updateNetlistExporter(); + m_exporter->SetSimCommand( m_settingsDlg.GetSimCommand() ); + m_exporter->Format( &formatter, m_settingsDlg.GetNetlistOptions() ); + + if( m_exporter->GetSimType() == ST_UNKNOWN ) + { + DisplayInfoMessage( this, wxT( "You need to select the simulation settings first" ) ); + return; + } /// @todo is it necessary to recreate simulator every time? m_simulator.reset( SPICE_SIMULATOR::CreateInstance( "ngspice" ) ); m_simulator->SetReporter( new SIM_THREAD_REPORTER( this ) ); m_simulator->Init(); - - updateNetlistExporter(); - m_exporter->SetSimCommand( m_settingsDlg.GetSimCommand() ); - m_exporter->Format( &formatter, m_settingsDlg.GetNetlistOptions() ); - m_simulator->LoadNetlist( formatter.GetString() ); m_simulator->Run(); } @@ -128,6 +134,12 @@ void SIM_PLOT_FRAME::StopSimulation() } +bool SIM_PLOT_FRAME::IsSimulationRunning() +{ + return m_simulator ? m_simulator->IsRunning() : false; +} + + SIM_PLOT_PANEL* SIM_PLOT_FRAME::NewPlotPanel( SIM_TYPE aSimType ) { SIM_PLOT_PANEL* plot = new SIM_PLOT_PANEL( aSimType, m_plotNotebook, wxID_ANY ); @@ -165,15 +177,56 @@ void SIM_PLOT_FRAME::AddVoltagePlot( const wxString& aNetName ) } -SIM_PLOT_PANEL* SIM_PLOT_FRAME::CurrentPlot() const +void SIM_PLOT_FRAME::AddTuner( SCH_COMPONENT* aComponent ) { - return static_cast( m_plotNotebook->GetCurrentPage() ); + SIM_PLOT_PANEL* plotPanel = CurrentPlot(); + + if( !plotPanel ) + return; + + const wxString& componentName = aComponent->GetField( REFERENCE )->GetText(); + auto& tunerList = m_tuners[plotPanel]; + + // Do not add multiple instances for the same component + auto tunerIt = std::find_if( tunerList.begin(), tunerList.end(), [&]( const TUNER_SLIDER* t ) + { + return t->GetComponentName() == componentName; + } + ); + + if( tunerIt != tunerList.end() ) + return; // We already have it + + try + { + TUNER_SLIDER* tuner = new TUNER_SLIDER( this, aComponent ); + m_tuneSizer->Add( tuner ); + tunerList.push_back( tuner ); + Layout(); + } + catch( ... ) + { + // Sorry, no bonus + } } -bool SIM_PLOT_FRAME::isSimulationRunning() +void SIM_PLOT_FRAME::RemoveTuner( TUNER_SLIDER* aTuner ) { - return m_simulator ? m_simulator->IsRunning() : false; + SIM_PLOT_PANEL* plotPanel = CurrentPlot(); + + if( !plotPanel ) + return; + + m_tuners[plotPanel].remove( aTuner ); + aTuner->Destroy(); + Layout(); +} + + +SIM_PLOT_PANEL* SIM_PLOT_FRAME::CurrentPlot() const +{ + return static_cast( m_plotNotebook->GetCurrentPage() ); } @@ -283,6 +336,28 @@ void SIM_PLOT_FRAME::updateSignalList() } +void SIM_PLOT_FRAME::updateTuners() +{ + SIM_PLOT_PANEL* plotPanel = CurrentPlot(); + + if( !plotPanel ) + return; + + for( unsigned int i = 0; i < m_tuneSizer->GetItemCount(); ++i ) + m_tuneSizer->Hide( i ); + + m_tuneSizer->Clear(); + + for( auto tuner : m_tuners[plotPanel] ) + { + m_tuneSizer->Add( tuner ); + tuner->Show(); + } + + Layout(); +} + + int SIM_PLOT_FRAME::getNodeNumber( const wxString& aNetName ) { const auto& netMapping = m_exporter->GetNetIndexMap(); @@ -419,6 +494,7 @@ void SIM_PLOT_FRAME::menuShowCoordsUpdate( wxUpdateUIEvent& event ) void SIM_PLOT_FRAME::onPlotChanged( wxNotebookEvent& event ) { updateSignalList(); + updateTuners(); // Update cursors wxQueueEvent( this, new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) ); @@ -461,7 +537,7 @@ void SIM_PLOT_FRAME::onSignalRClick( wxMouseEvent& event ) void SIM_PLOT_FRAME::onSimulate( wxCommandEvent& event ) { - if( isSimulationRunning() ) + if( IsSimulationRunning() ) StopSimulation(); else StartSimulation(); @@ -489,14 +565,22 @@ void SIM_PLOT_FRAME::onProbe( wxCommandEvent& event ) if( m_schematicFrame == NULL ) return; - wxCommandEvent* placeProbe = new wxCommandEvent( wxEVT_TOOL, ID_SIM_ADD_PROBE ); - wxQueueEvent( m_schematicFrame, placeProbe ); + wxQueueEvent( m_schematicFrame, new wxCommandEvent( wxEVT_TOOL, ID_SIM_PROBE ) ); +} + + +void SIM_PLOT_FRAME::onTune( wxCommandEvent& event ) +{ + if( m_schematicFrame == NULL ) + return; + + wxQueueEvent( m_schematicFrame, new wxCommandEvent( wxEVT_TOOL, ID_SIM_TUNE ) ); } void SIM_PLOT_FRAME::onClose( wxCloseEvent& aEvent ) { - if( isSimulationRunning() ) + if( IsSimulationRunning() ) m_simulator->Stop(); Destroy(); @@ -539,6 +623,10 @@ void SIM_PLOT_FRAME::onSimFinished( wxCommandEvent& aEvent ) SetCursor( wxCURSOR_ARROW ); SIM_TYPE simType = m_exporter->GetSimType(); + + if( simType == ST_UNKNOWN ) + return; + SIM_PLOT_PANEL* plotPanel = CurrentPlot(); if( plotPanel == nullptr || plotPanel->GetType() != simType ) @@ -565,6 +653,32 @@ void SIM_PLOT_FRAME::onSimFinished( wxCommandEvent& aEvent ) } +void SIM_PLOT_FRAME::onSimUpdate( wxCommandEvent& aEvent ) +{ + if( !m_simulator ) + return; + + if( IsSimulationRunning() ) + StopSimulation(); + + m_simConsole->Clear(); + + // Apply tuned values + if( SIM_PLOT_PANEL* plotPanel = CurrentPlot() ) + { + for( auto tuner : m_tuners[plotPanel] ) + { + /// @todo no ngspice hardcoding + std::string command( "alter @" + tuner->GetSpiceName() + + "=" + tuner->GetValue().ToSpiceString() ); + m_simulator->Command( command ); + } + } + + m_simulator->Run(); +} + + void SIM_PLOT_FRAME::onSimReport( wxCommandEvent& aEvent ) { std::cout << aEvent.GetString() << std::endl; @@ -624,6 +738,8 @@ void SIM_PLOT_FRAME::SIGNAL_CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent ) } } +wxDEFINE_EVENT( EVT_SIM_UPDATE, wxCommandEvent ); wxDEFINE_EVENT( EVT_SIM_REPORT, wxCommandEvent ); + wxDEFINE_EVENT( EVT_SIM_STARTED, wxCommandEvent ); wxDEFINE_EVENT( EVT_SIM_FINISHED, wxCommandEvent ); diff --git a/eeschema/sim/sim_plot_frame.h b/eeschema/sim/sim_plot_frame.h index a46e76c270..899a5d5bbe 100644 --- a/eeschema/sim/sim_plot_frame.h +++ b/eeschema/sim/sim_plot_frame.h @@ -36,12 +36,18 @@ #include #include + +#include #include +#include class SCH_EDIT_FRAME; +class SCH_COMPONENT; + class SPICE_SIMULATOR; class NETLIST_EXPORTER_PSPICE_SIM; class SIM_PLOT_PANEL; +class TUNER_SLIDER; /** Implementing SIM_PLOT_FRAME_BASE */ class SIM_PLOT_FRAME : public SIM_PLOT_FRAME_BASE @@ -53,6 +59,7 @@ class SIM_PLOT_FRAME : public SIM_PLOT_FRAME_BASE void StartSimulation(); void StopSimulation(); + bool IsSimulationRunning(); /** * @brief Creates a new plot panel for a given simulation type and adds it to the main @@ -64,11 +71,13 @@ class SIM_PLOT_FRAME : public SIM_PLOT_FRAME_BASE void AddVoltagePlot( const wxString& aNetName ); + void AddTuner( SCH_COMPONENT* aComponent ); + + void RemoveTuner( TUNER_SLIDER* aTuner ); + SIM_PLOT_PANEL* CurrentPlot() const; private: - bool isSimulationRunning(); - void updateNetlistExporter(); /** @@ -87,6 +96,11 @@ class SIM_PLOT_FRAME : public SIM_PLOT_FRAME_BASE */ void updateSignalList(); + /** + * @brief Fills the tuners area with the ones related to the current plot. + */ + void updateTuners(); + /** * @brief Returns node number for a given net. * @param aNetName is the net number. @@ -124,17 +138,20 @@ class SIM_PLOT_FRAME : public SIM_PLOT_FRAME_BASE void onSettings( wxCommandEvent& event ) override; void onAddSignal( wxCommandEvent& event ) override; void onProbe( wxCommandEvent& event ) override; + void onTune( wxCommandEvent& event ) override; void onClose( wxCloseEvent& aEvent ); void onCursorUpdate( wxCommandEvent& aEvent ); + void onSimUpdate( wxCommandEvent& aEvent ); + void onSimReport( wxCommandEvent& aEvent ); void onSimStarted( wxCommandEvent& aEvent ); void onSimFinished( wxCommandEvent& aEvent ); - void onSimReport( wxCommandEvent& aEvent ); SCH_EDIT_FRAME* m_schematicFrame; std::unique_ptr m_exporter; std::unique_ptr m_simulator; + std::map > m_tuners; // Trick to preserve settings between runs DIALOG_SIM_SETTINGS m_settingsDlg; @@ -161,7 +178,11 @@ class SIM_PLOT_FRAME : public SIM_PLOT_FRAME_BASE }; }; +// Commands +wxDECLARE_EVENT( EVT_SIM_UPDATE, wxCommandEvent ); wxDECLARE_EVENT( EVT_SIM_REPORT, wxCommandEvent ); + +// Notifications wxDECLARE_EVENT( EVT_SIM_STARTED, wxCommandEvent ); wxDECLARE_EVENT( EVT_SIM_FINISHED, wxCommandEvent ); diff --git a/eeschema/sim/sim_plot_frame_base.cpp b/eeschema/sim/sim_plot_frame_base.cpp index a105066b44..b5c2429d0e 100644 --- a/eeschema/sim/sim_plot_frame_base.cpp +++ b/eeschema/sim/sim_plot_frame_base.cpp @@ -104,19 +104,34 @@ SIM_PLOT_FRAME_BASE::SIM_PLOT_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxBoxSizer* bSizer7; bSizer7 = new wxBoxSizer( wxVERTICAL ); - m_staticText2 = new wxStaticText( this, wxID_ANY, _("Signals"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE ); - m_staticText2->Wrap( -1 ); - bSizer7->Add( m_staticText2, 0, wxALL|wxEXPAND, 5 ); + wxStaticBoxSizer* sbSizer1; + sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Signals") ), wxVERTICAL ); - m_signals = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE|wxLB_SORT ); - bSizer7->Add( m_signals, 1, wxALL|wxEXPAND, 5 ); + m_signals = new wxListBox( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE|wxLB_SORT ); + sbSizer1->Add( m_signals, 1, wxALL|wxEXPAND, 5 ); - m_staticText21 = new wxStaticText( this, wxID_ANY, _("Cursors"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText21->Wrap( -1 ); - bSizer7->Add( m_staticText21, 0, wxALL, 5 ); - m_cursors = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL ); - bSizer7->Add( m_cursors, 1, wxALL|wxEXPAND, 5 ); + bSizer7->Add( sbSizer1, 1, wxEXPAND, 5 ); + + wxStaticBoxSizer* sbSizer3; + sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Cursors") ), wxVERTICAL ); + + m_cursors = new wxListCtrl( sbSizer3->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL ); + sbSizer3->Add( m_cursors, 1, wxALL|wxEXPAND, 5 ); + + + bSizer7->Add( sbSizer3, 1, wxEXPAND, 5 ); + + wxStaticBoxSizer* sbSizer4; + sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Tune") ), wxVERTICAL ); + + m_tuneSizer = new wxBoxSizer( wxHORIZONTAL ); + + + sbSizer4->Add( m_tuneSizer, 1, wxEXPAND, 5 ); + + + bSizer7->Add( sbSizer4, 1, wxEXPAND, 5 ); wxBoxSizer* bSizer4; bSizer4 = new wxBoxSizer( wxHORIZONTAL ); diff --git a/eeschema/sim/sim_plot_frame_base.fbp b/eeschema/sim/sim_plot_frame_base.fbp index a52ded7398..ebd2282bd0 100644 --- a/eeschema/sim/sim_plot_frame_base.fbp +++ b/eeschema/sim/sim_plot_frame_base.fbp @@ -544,371 +544,261 @@ 5 wxEXPAND 1 - + bSizer7 wxVERTICAL none - + 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 + wxEXPAND + 1 + wxID_ANY Signals - - 0 - - - 0 - 1 - m_staticText2 - 1 - - - protected - 1 - - Resizable - 1 - - wxALIGN_CENTRE - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - + sbSizer1 + wxVERTICAL + 1 + none + + 5 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_signals + 1 + + + protected + 1 + + Resizable + 1 + + wxLB_SINGLE|wxLB_SORT + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + onSignalDblClick + + + + + + + + + + onSignalRClick + + + + + - + 5 - wxALL|wxEXPAND + wxEXPAND 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_signals - 1 - - - protected - 1 - - Resizable - 1 - - wxLB_SINGLE|wxLB_SORT - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - onSignalDblClick - - - - - - - - - - onSignalRClick - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 + wxID_ANY Cursors - - 0 - - - 0 - 1 - m_staticText21 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - + sbSizer3 + wxVERTICAL + 1 + none + + 5 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_cursors + 1 + + + protected + 1 + + Resizable + 1 + + wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + 5 - wxALL|wxEXPAND + wxEXPAND 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 + wxID_ANY - - 0 - - - 0 + Tune - 1 - m_cursors - 1 - - - protected - 1 - - Resizable - 1 - - wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + sbSizer4 + wxVERTICAL + 1 + none + + 5 + wxEXPAND + 1 + + + m_tuneSizer + wxHORIZONTAL + protected + + - + 5 0 @@ -1093,11 +983,11 @@ - + 5 wxALL|wxEXPAND 0 - + 1 1 1 diff --git a/eeschema/sim/sim_plot_frame_base.h b/eeschema/sim/sim_plot_frame_base.h index c4154d890f..b4859b9882 100644 --- a/eeschema/sim/sim_plot_frame_base.h +++ b/eeschema/sim/sim_plot_frame_base.h @@ -26,8 +26,8 @@ class KIWAY_PLAYER; #include #include #include -#include #include +#include #include #include #include @@ -48,10 +48,9 @@ class SIM_PLOT_FRAME_BASE : public KIWAY_PLAYER wxMenu* m_viewMenu; wxNotebook* m_plotNotebook; wxTextCtrl* m_simConsole; - wxStaticText* m_staticText2; wxListBox* m_signals; - wxStaticText* m_staticText21; wxListCtrl* m_cursors; + wxBoxSizer* m_tuneSizer; wxButton* m_simulateBtn; wxButton* m_settingsBtn; wxButton* m_addSignal; diff --git a/eeschema/sim/simulate.cpp b/eeschema/sim/simulate.cpp index 6da2f5d43e..af151291c4 100644 --- a/eeschema/sim/simulate.cpp +++ b/eeschema/sim/simulate.cpp @@ -67,8 +67,34 @@ static const unsigned char cursor_probe_mask[] { 0x7c, 0x07, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 }; +static const unsigned char cursor_tune[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0xc0, 0x0f, + 0x00, 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x0f, + 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00, 0xff, 0x01, + 0x00, 0x80, 0xff, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, + 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0xfc, 0x07, 0x00, + 0x00, 0xfc, 0x03, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0xf4, 0x00, 0x00, + 0x00, 0xea, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, + 0x40, 0x01, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, + 0x2c, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00 }; + +static const unsigned char cursor_tune_mask[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0xc0, 0x0f, + 0x00, 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x0f, + 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00, 0xff, 0x01, + 0x00, 0x80, 0xff, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, + 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0xfc, 0x07, 0x00, + 0x00, 0xfc, 0x03, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, + 0x00, 0xee, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, + 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, + 0x3c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00 }; + #ifdef __WXMSW__ -struct CURSOR_PROBE_INIT +struct SIM_CURSORS_INIT { public: static wxImage& GetProbeImage() @@ -87,9 +113,28 @@ public: return *probe_image; } + + static wxImage& GetTuneImage() + { + static wxImage* tune_image = NULL; + + if( tune_image == NULL ) + { + wxBitmap tune_bitmap( (const char*) cursor_tune, 32, 32 ); + wxBitmap tune_mask_bitmap( (const char*) cursor_tune_mask, 32, 32 ); + tune_bitmap.SetMask( new wxMask( tune_mask_bitmap ) ); + tune_image = new wxImage( tune_bitmap.ConvertToImage() ); + tune_image->SetOption( wxIMAGE_OPTION_CUR_HOTSPOT_X, 0 ); + tune_image->SetOption( wxIMAGE_OPTION_CUR_HOTSPOT_Y, 31 ); + } + + return *tune_image; + } }; -const wxCursor SCH_EDIT_FRAME::CURSOR_PROBE( CURSOR_PROBE_INIT::GetProbeImage() ); +const wxCursor SCH_EDIT_FRAME::CURSOR_PROBE( SIM_CURSORS_INIT::GetProbeImage() ); +const wxCursor SCH_EDIT_FRAME::CURSOR_TUNE( SIM_CURSORS_INIT::GetTuneImage() ); #elif defined(__WXGTK__) or defined(__WXMOTIF__) const wxCursor SCH_EDIT_FRAME::CURSOR_PROBE( (const char*) cursor_probe, 32, 32, 0, 31, (const char*) cursor_probe_mask ); +const wxCursor SCH_EDIT_FRAME::CURSOR_TUNE( (const char*) cursor_tune, 32, 32, 1, 30, (const char*) cursor_tune_mask ); #endif