Do not add a trace if it is already plotted
This commit is contained in:
parent
cb463f48b1
commit
8a6e6f2d36
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include "sim_plot_panel.h"
|
#include "sim_plot_panel.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
SIM_PLOT_PANEL::SIM_PLOT_PANEL( wxWindow* parent, wxWindowID id, const wxPoint& pos,
|
SIM_PLOT_PANEL::SIM_PLOT_PANEL( wxWindow* parent, wxWindowID id, const wxPoint& pos,
|
||||||
|
@ -65,13 +66,27 @@ static std::pair<T, T> find_minmax( const T* aArray, unsigned int aSize )
|
||||||
void SIM_PLOT_PANEL::AddTrace( const wxString& aName, int aPoints,
|
void SIM_PLOT_PANEL::AddTrace( const wxString& aName, int aPoints,
|
||||||
double* aT, double* aY, int aFlags )
|
double* aT, double* aY, int aFlags )
|
||||||
{
|
{
|
||||||
TRACE trace;
|
// Find previous entry, if there is one
|
||||||
|
auto it = std::find_if( m_traces.begin(), m_traces.end(),
|
||||||
|
[&](const TRACE& t) { return t.name == aName; });
|
||||||
|
|
||||||
trace.name = aName;
|
if( it == m_traces.end() )
|
||||||
trace.style = wxString( '-' ) + m_painter.GenerateColor( SIM_PLOT_PAINTER::DARK );
|
{
|
||||||
trace.x.Set( aT, aPoints );
|
// New entry
|
||||||
trace.y.Set( aY, aPoints );
|
TRACE trace;
|
||||||
m_traces.push_back( trace );
|
trace.name = aName;
|
||||||
|
trace.style = wxString( '-' ) + m_painter.GenerateColor( SIM_PLOT_PAINTER::DARK );
|
||||||
|
trace.x.Set( aT, aPoints );
|
||||||
|
trace.y.Set( aY, aPoints );
|
||||||
|
m_traces.push_back( trace );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
TRACE& trace = *it;
|
||||||
|
trace.x.Set( aT, aPoints );
|
||||||
|
trace.y.Set( aY, aPoints );
|
||||||
|
}
|
||||||
|
|
||||||
// Update axis ranges
|
// Update axis ranges
|
||||||
std::pair<double, double> traceRangeT = find_minmax( aT, aPoints );
|
std::pair<double, double> traceRangeT = find_minmax( aT, aPoints );
|
||||||
|
|
Loading…
Reference in New Issue