ADDED support for simulation plot margins and GUI for Y axis locking.

This commit is contained in:
Jeff Young
2023-07-19 23:40:10 +01:00
parent 65f66755ee
commit 9c08d4febe
21 changed files with 10022 additions and 6954 deletions
+53 -2
View File
@@ -401,8 +401,8 @@ void CURSOR::UpdateReference()
}
SIM_PLOT_TAB::SIM_PLOT_TAB( const wxString& aSimCommand, unsigned aSimOptions, wxWindow* parent ) :
SIM_TAB( aSimCommand, aSimOptions, parent ),
SIM_PLOT_TAB::SIM_PLOT_TAB( const wxString& aSimCommand, wxWindow* parent ) :
SIM_TAB( aSimCommand, parent ),
m_axis_x( nullptr ),
m_axis_y1( nullptr ),
m_axis_y2( nullptr ),
@@ -438,6 +438,40 @@ SIM_PLOT_TAB::~SIM_PLOT_TAB()
}
void SIM_PLOT_TAB::SetY1Scale( bool aLock, double aMin, double aMax )
{
m_axis_y1->SetAxisMinMax( aLock, aMin, aMax );
if( aLock )
{
m_plotWin->Fit( m_plotWin->GetDesiredXmin(), m_plotWin->GetDesiredXmax(),
m_axis_y1->TransformToPlot( aMin ), m_axis_y1->TransformToPlot( aMax ) );
m_plotWin->LockY( true );
m_plotWin->AdjustLimitedView();
}
else
{
m_plotWin->LockY( false );
}
}
void SIM_PLOT_TAB::SetY2Scale( bool aLock, double aMin, double aMax )
{
m_axis_y2->SetAxisMinMax( aLock, aMin, aMax );
// TODO: de-couple Y2 from Y1 and independently set Y2's scale
}
void SIM_PLOT_TAB::SetY3Scale( bool aLock, double aMin, double aMax )
{
m_axis_y3->SetAxisMinMax( aLock, aMin, aMax );
// TODO: de-couple Y2 from Y1 and independently set Y2's scale
}
wxString SIM_PLOT_TAB::GetUnitsX() const
{
LOG_SCALE<mpScaleXLog>* logScale = dynamic_cast<LOG_SCALE<mpScaleXLog>*>( m_axis_x );
@@ -958,4 +992,21 @@ void SIM_PLOT_TAB::ResetScales( bool aIncludeX )
}
void SIM_PLOT_TAB::FitScales()
{
GetPlotWin()->Fit();
double min, max;
if( m_axis_y1 && m_axis_y1->GetAxisMinMax( &min, &max ) )
SetY1Scale( true, min, max );
if( m_axis_y2 && m_axis_y2->GetAxisMinMax( &min, &max ) )
SetY2Scale( true, min, max );
if( m_axis_y3 && m_axis_y3->GetAxisMinMax( &min, &max ) )
SetY3Scale( true, min, max );
}
wxDEFINE_EVENT( EVT_SIM_CURSOR_UPDATE, wxCommandEvent );