Store values, not pointers to PlotItems.

This commit is contained in:
Bartosz Taudul 2017-10-19 18:28:11 +02:00
parent 8958780b18
commit 6e5ccf8391
2 changed files with 7 additions and 7 deletions

View File

@ -2492,25 +2492,25 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover )
while( it < range )
{
m_tmpVec.emplace_back( &*it );
m_tmpVec.emplace_back( it->val );
++it;
}
std::sort( m_tmpVec.begin(), m_tmpVec.end(), [] ( const auto& l, const auto& r ) { return l->val < r->val; } );
std::sort( m_tmpVec.begin(), m_tmpVec.end(), [] ( const auto& l, const auto& r ) { return l < r; } );
draw->AddLine( wpos + ImVec2( x1, offset + PlotHeight - ( (*m_tmpVec.begin())->val - min ) * revrange * PlotHeight ), wpos + ImVec2( x1, offset + PlotHeight - ( m_tmpVec.back()->val - min ) * revrange * PlotHeight ), 0xFF44DDDD );
draw->AddLine( wpos + ImVec2( x1, offset + PlotHeight - ( m_tmpVec.front() - min ) * revrange * PlotHeight ), wpos + ImVec2( x1, offset + PlotHeight - ( m_tmpVec.back() - min ) * revrange * PlotHeight ), 0xFF44DDDD );
auto vit = m_tmpVec.begin();
while( vit < m_tmpVec.end() )
{
auto vrange = std::upper_bound( vit, m_tmpVec.end(), (*vit)->val + 3.0 / ( revrange * PlotHeight ), [] ( const auto& l, const auto& r ) { return l < r->val; } );
auto vrange = std::upper_bound( vit, m_tmpVec.end(), *vit + 3.0 / ( revrange * PlotHeight ), [] ( const auto& l, const auto& r ) { return l < r; } );
assert( vrange > vit );
if( std::distance( vit, vrange ) == 1 )
{
DrawPlotPoint( wpos, x1, PlotHeight - ( (*vit)->val - min ) * revrange * PlotHeight, offset, 0xFF44DDDD, hover, false, (*vit)->val, 0, false );
DrawPlotPoint( wpos, x1, PlotHeight - ( *vit - min ) * revrange * PlotHeight, offset, 0xFF44DDDD, hover, false, *vit, 0, false );
}
else
{
DrawPlotPoint( wpos, x1, PlotHeight - ( (*vit)->val - min ) * revrange * PlotHeight, offset, 0xFF44DDDD, hover, false, (*vit)->val, 0, true );
DrawPlotPoint( wpos, x1, PlotHeight - ( *vit - min ) * revrange * PlotHeight, offset, 0xFF44DDDD, hover, false, *vit, 0, true );
}
vit = vrange;
}

View File

@ -251,7 +251,7 @@ private:
bool m_terminate;
std::vector<PlotItem*> m_tmpVec;
std::vector<double> m_tmpVec;
};
}