Don't auto-adjust time axis while sim is running.

Just use start and end time.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15673
This commit is contained in:
Jeff Young 2023-09-20 17:23:08 +01:00
parent d781d70a09
commit 1ff279bf72
3 changed files with 58 additions and 20 deletions

View File

@ -191,26 +191,40 @@ class TIME_SCALE : public LIN_SCALE<mpScaleX>
{
public:
TIME_SCALE( const wxString& name, const wxString& unit, int flags ) :
LIN_SCALE( name, unit, flags )
LIN_SCALE( name, unit, flags ),
m_startTime( 0.0 ),
m_endTime( 1.0 )
{};
void ExtendDataRange( double minV, double maxV ) override
{
if( !m_rangeSet )
LIN_SCALE::ExtendDataRange( minV, maxV );
// Time is never longer than the simulation itself
if( m_minV < m_startTime )
m_minV = m_startTime;
if( m_maxV > m_endTime )
m_maxV = m_endTime;
};
void SetStartAndEnd( double aStartTime, double aEndTime )
{
m_minV = minV;
m_maxV = maxV;
m_startTime = aStartTime;
m_endTime = aEndTime;
ResetDataRange();
}
void ResetDataRange() override
{
m_minV = m_startTime;
m_maxV = m_endTime;
m_rangeSet = true;
}
else
{
if( minV < m_minV )
m_minV -= abs( maxV - minV );
if( maxV > m_maxV )
m_maxV += abs( maxV - minV );
}
}
protected:
double m_startTime;
double m_endTime;
};
@ -975,8 +989,33 @@ void SIM_PLOT_TAB::EnableCursor( const wxString& aVectorName, int aType, int aCu
void SIM_PLOT_TAB::ResetScales( bool aIncludeX )
{
if( m_axis_x && aIncludeX )
{
m_axis_x->ResetDataRange();
if( GetSimType() == ST_TRAN )
{
wxStringTokenizer tokenizer( GetSimCommand(), wxS( " \t\n\r" ), wxTOKEN_STRTOK );
wxString cmd = tokenizer.GetNextToken().Lower();
wxASSERT( cmd == wxS( ".tran" ) );
SPICE_VALUE step;
SPICE_VALUE end( 1.0 );
SPICE_VALUE start( 0.0 );
if( tokenizer.HasMoreTokens() )
step = SPICE_VALUE( tokenizer.GetNextToken() );
if( tokenizer.HasMoreTokens() )
end = SPICE_VALUE( tokenizer.GetNextToken() );
if( tokenizer.HasMoreTokens() )
start = SPICE_VALUE( tokenizer.GetNextToken() );
static_cast<TIME_SCALE*>( m_axis_x )->SetStartAndEnd( start.ToDouble(), end.ToDouble() );
}
}
if( m_axis_y1 )
m_axis_y1->ResetDataRange();

View File

@ -2555,11 +2555,6 @@ void SIMULATOR_FRAME_UI::OnSimUpdate()
void SIMULATOR_FRAME_UI::OnSimReport( const wxString& aMsg )
{
// Required in win32 to ensure wxTimer events get scheduled in between other events
// Or else we may stall them out entirely and never get them during actions like rapid
// console updates.
KIPLATFORM::APP::ForceTimerMessagesToBeCreatedIfNecessary();
m_simConsole->AppendText( aMsg + "\n" );
m_simConsole->SetInsertionPointEnd();
}
@ -2728,6 +2723,10 @@ void SIMULATOR_FRAME_UI::OnSimRefresh( bool aFinal )
case SPT_POWER:
value.Append( wxS( "W" ) );
break;
default:
value.Append( wxS( "?" ) );
break;
}
msg.Printf( wxT( "%s%s\n" ),

View File

@ -664,7 +664,7 @@ public:
}
}
void ResetDataRange()
virtual void ResetDataRange()
{
m_rangeSet = false;
}