Reset scales when a plot is removed

This commit is contained in:
Maciej Suminski 2016-08-11 14:42:03 +02:00
parent ba3ce9b566
commit 9d8b40b93d
3 changed files with 25 additions and 4 deletions

View File

@ -3600,15 +3600,17 @@ void mpFXY::SetScale ( mpScaleBase *scaleX, mpScaleBase *scaleY )
m_scaleY = scaleY;
//printf("SetScales : %p %p\n", scaleX, scaleY);
UpdateScales();
}
void mpFXY::UpdateScales()
{
if(m_scaleX)
{
m_scaleX->ExtendDataRange(GetMinX(), GetMaxX());
}
if(m_scaleY)
{
m_scaleY->ExtendDataRange(GetMinY(), GetMaxY());
}
}

View File

@ -453,6 +453,19 @@ bool SIM_PLOT_PANEL::DeleteTrace( const wxString& aName )
DelLayer( trace, true, true );
// Reset scales
if( m_axis_x )
m_axis_x->ResetDataRange();
if( m_axis_y1 )
m_axis_y1->ResetDataRange();
if( m_axis_y2 )
m_axis_y2->ResetDataRange();
for( auto t : m_traces )
t.second->UpdateScales();
return true;
}

View File

@ -612,6 +612,8 @@ class WXDLLIMPEXP_MATHPLOT mpFXY : public mpLayer
virtual void SetScale(mpScaleBase *scaleX, mpScaleBase *scaleY);
void UpdateScales();
double s2x(double plotCoordX) const;
double s2y(double plotCoordY) const;
@ -740,6 +742,10 @@ public:
}
}
void ResetDataRange()
{
m_rangeSet = 0;
}
double AbsMaxValue() const
{