Warning messages for simulation tuning.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20274
This commit is contained in:
Jeff Young
2025-03-11 11:02:20 +00:00
parent b11b1a6f72
commit 7401b57fcb
3 changed files with 24 additions and 18 deletions
+18 -16
View File
@@ -1616,7 +1616,12 @@ void SIMULATOR_FRAME_UI::AddTuner( const SCH_SHEET_PATH& aSheetPath, SCH_SYMBOL*
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( 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() );
}
}
}
+3
View File
@@ -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<SCH_FIELD*>( item )->GetParentSymbol();
if( m_pickerItem != item )
{
if( m_pickerItem )
+3 -2
View File
@@ -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 ) );