Handle single-source DC analyses correctly.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17119
This commit is contained in:
Jeff Young 2024-02-26 18:09:51 +00:00
parent 81c22542e4
commit 2f8f7c11f1
2 changed files with 20 additions and 6 deletions

View File

@ -51,7 +51,10 @@ static void setStringSelection( wxChoice* aCtrl, const wxString& aStr )
static wxString getStringSelection( const wxChoice* aCtrl )
{
return aCtrl->GetString( aCtrl->GetSelection() );
if( aCtrl->GetSelection() >= 0 )
return aCtrl->GetString( aCtrl->GetSelection() );
else
return wxEmptyString;
}
@ -915,7 +918,15 @@ void DIALOG_SIM_COMMAND::onDCSource2Selected( wxCommandEvent& event )
void DIALOG_SIM_COMMAND::onDCEnableSecondSource( wxCommandEvent& event )
{
bool is2ndSrcEnabled = m_dcEnable2->IsChecked();
wxChar type = getStringSelection( m_dcSourceType2 ).Upper().GetChar( 0 );
wxChar type = '?';
if( is2ndSrcEnabled )
{
wxString fullType = getStringSelection( m_dcSourceType2 ).Upper();
if( fullType.Length() > 0 )
type = fullType.GetChar( 0 );
}
m_dcSourceType2->Enable( is2ndSrcEnabled );
m_dcSource2->Enable( is2ndSrcEnabled && type != 'T' );

View File

@ -131,10 +131,13 @@ bool SPICE_CIRCUIT_MODEL::ParseDCCommand( const wxString& aCmd, SPICE_DC_PARAMS*
aSource1->m_vend = SPICE_VALUE( tokens.GetNextToken() );
aSource1->m_vincrement = SPICE_VALUE( tokens.GetNextToken() );
aSource2->m_source = tokens.GetNextToken();
aSource2->m_vstart = SPICE_VALUE( tokens.GetNextToken() );
aSource2->m_vend = SPICE_VALUE( tokens.GetNextToken() );
aSource2->m_vincrement = SPICE_VALUE( tokens.GetNextToken() );
if( tokens.HasMoreTokens() )
{
aSource2->m_source = tokens.GetNextToken();
aSource2->m_vstart = SPICE_VALUE( tokens.GetNextToken() );
aSource2->m_vend = SPICE_VALUE( tokens.GetNextToken() );
aSource2->m_vincrement = SPICE_VALUE( tokens.GetNextToken() );
}
return true;
}