From a717194b1ef5a1545cf4fcac7c46475f8249f3da Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Thu, 11 Aug 2016 14:41:45 +0200 Subject: [PATCH] Enable tuner for RLC components only --- eeschema/netlist_exporters/netlist_exporter_pspice.cpp | 8 ++++++++ eeschema/netlist_exporters/netlist_exporter_pspice.h | 5 +++++ eeschema/sim/sim_plot_frame.cpp | 6 ++++++ eeschema/widgets/tuner_slider.cpp | 4 +--- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp index c3fc92e780..2d3d5c4519 100644 --- a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp @@ -140,6 +140,14 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* aFormatter, unsigned aCtl } +wxString NETLIST_EXPORTER_PSPICE::GetSpiceField( SPICE_FIELD aField, + SCH_COMPONENT* aComponent, unsigned aCtl ) +{ + SCH_FIELD* field = aComponent->FindField( GetSpiceFieldName( aField ) ); + return field ? field->GetText() : GetSpiceFieldDefVal( SPICE_PRIMITIVE, aComponent, aCtl ); +} + + wxString NETLIST_EXPORTER_PSPICE::GetSpiceFieldDefVal( SPICE_FIELD aField, SCH_COMPONENT* aComponent, unsigned aCtl ) { diff --git a/eeschema/netlist_exporters/netlist_exporter_pspice.h b/eeschema/netlist_exporters/netlist_exporter_pspice.h index c45c4be425..e678079d01 100644 --- a/eeschema/netlist_exporters/netlist_exporter_pspice.h +++ b/eeschema/netlist_exporters/netlist_exporter_pspice.h @@ -130,6 +130,11 @@ public: return m_spiceFields[(int) aField]; } + /** + * @brief Retrieves either the requested field value or the default value. + */ + static wxString GetSpiceField( SPICE_FIELD aField, SCH_COMPONENT* aComponent, unsigned aCtl ); + static wxString GetSpiceFieldDefVal( SPICE_FIELD aField, SCH_COMPONENT* aComponent, unsigned aCtl ); void UpdateDirectives( unsigned aCtl ); diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index f0f2db250d..174ae3403f 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -184,6 +184,12 @@ void SIM_PLOT_FRAME::AddTuner( SCH_COMPONENT* aComponent ) if( !plotPanel ) return; + // For now limit the tuner tool to RLC components + char primitiveType = NETLIST_EXPORTER_PSPICE::GetSpiceField( SPICE_PRIMITIVE, aComponent, 0 )[0]; + + if( primitiveType != SP_RESISTOR && primitiveType != SP_CAPACITOR && primitiveType != SP_INDUCTOR ) + return; + const wxString& componentName = aComponent->GetField( REFERENCE )->GetText(); auto& tunerList = m_tuners[plotPanel]; diff --git a/eeschema/widgets/tuner_slider.cpp b/eeschema/widgets/tuner_slider.cpp index 276a910b46..ee0e0cfc42 100644 --- a/eeschema/widgets/tuner_slider.cpp +++ b/eeschema/widgets/tuner_slider.cpp @@ -38,9 +38,7 @@ TUNER_SLIDER::TUNER_SLIDER( SIM_PLOT_FRAME* aParent, SCH_COMPONENT* aComponent ) m_value = SPICE_VALUE( aComponent->GetField( VALUE )->GetText() ); // Generate Spice component name - SCH_FIELD* fieldPrim = aComponent->FindField( NETLIST_EXPORTER_PSPICE::GetSpiceFieldName( SPICE_PRIMITIVE ) ); - char prim = fieldPrim ? fieldPrim->GetText()[0] - : NETLIST_EXPORTER_PSPICE::GetSpiceFieldDefVal( SPICE_PRIMITIVE, m_component, 0 )[0]; + char prim = NETLIST_EXPORTER_PSPICE::GetSpiceField( SPICE_PRIMITIVE, aComponent, 0 )[0]; m_spiceName = wxString( prim + compName ).Lower(); // Call Set*() methods to update fields and slider