diff --git a/eeschema/sim/simulator_frame_ui.cpp b/eeschema/sim/simulator_frame_ui.cpp index 3acb233ae2..127a6ab801 100644 --- a/eeschema/sim/simulator_frame_ui.cpp +++ b/eeschema/sim/simulator_frame_ui.cpp @@ -1616,7 +1616,12 @@ void SIMULATOR_FRAME_UI::AddTuner( const SCH_SHEET_PATH& aSheetPath, SCH_SYMBOL* SIM_PLOT_TAB* plotTab = dynamic_cast( GetCurrentSimTab() ); if( !plotTab ) + { + DisplayErrorMessage( nullptr, _( "The current analysis must have a plot in order to tune " + "the value of a passive R, L, C model or voltage or " + "current source." ) ); return; + } wxString ref = aSymbol->GetRef( &aSheetPath ); @@ -1627,23 +1632,20 @@ void SIMULATOR_FRAME_UI::AddTuner( const SCH_SHEET_PATH& aSheetPath, SCH_SYMBOL* return; } - const SPICE_ITEM* item = GetExporter()->FindItem( ref ); - - // Do nothing if the symbol is not tunable. - if( !item || !item->model->GetTunerParam() ) - return; - - try + if( const SPICE_ITEM* item = GetExporter()->FindItem( ref ) ) { - TUNER_SLIDER* tuner = new TUNER_SLIDER( this, m_panelTuners, aSheetPath, aSymbol ); - m_sizerTuners->Add( tuner ); - m_tuners.push_back( tuner ); - m_panelTuners->Layout(); - OnModify(); - } - catch( const KI_PARAM_ERROR& e ) - { - DisplayErrorMessage( nullptr, e.What() ); + try + { + TUNER_SLIDER* tuner = new TUNER_SLIDER( this, m_panelTuners, aSheetPath, aSymbol ); + m_sizerTuners->Add( tuner ); + m_tuners.push_back( tuner ); + m_panelTuners->Layout(); + OnModify(); + } + catch( const KI_PARAM_ERROR& e ) + { + DisplayErrorMessage( nullptr, e.What() ); + } } } diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 50c4402f16..9847d4a4db 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -773,6 +773,9 @@ int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent ) EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr; + if( item && item->Type() == SCH_FIELD_T ) + item = static_cast( item )->GetParentSymbol(); + if( m_pickerItem != item ) { if( m_pickerItem ) diff --git a/eeschema/widgets/tuner_slider.cpp b/eeschema/widgets/tuner_slider.cpp index a7597b144b..7edd9c8ba6 100644 --- a/eeschema/widgets/tuner_slider.cpp +++ b/eeschema/widgets/tuner_slider.cpp @@ -81,8 +81,9 @@ TUNER_SLIDER::TUNER_SLIDER( SIMULATOR_FRAME_UI* aFrame, wxWindow* aParent, if( !tunerParam ) { - throw KI_PARAM_ERROR( wxString::Format( _( "%s has simulation model of type '%s %s'; " - "only RLC passives be tuned" ), + throw KI_PARAM_ERROR( wxString::Format( _( "%s has simulation model of type '%s %s'.\n\n" + "Only passvie R, L, C models and voltage and " + "current sources may be tuned." ), m_ref, item->model->GetDeviceInfo().fieldValue, item->model->GetTypeInfo().fieldValue ) );