Spice simulator: faster graph rendering
Graph rendering takes a lot of time, especially when there is a high number of points to be drawn. The initial implementation drew all points/lines even if the the coordinates were duplicates, in the new version duplicated coordinates are skipped. Fixes: lp:1674143 * https://bugs.launchpad.net/kicad/+bug/1674143
This commit is contained in:
parent
d2585fda50
commit
70c1de3275
|
@ -628,7 +628,6 @@ void mpFXY::Plot( wxDC& dc, mpWindow& w )
|
||||||
{
|
{
|
||||||
dc.SetPen( m_pen );
|
dc.SetPen( m_pen );
|
||||||
|
|
||||||
|
|
||||||
double x, y;
|
double x, y;
|
||||||
// Do this to reset the counters to evaluate bounding box for label positioning
|
// Do this to reset the counters to evaluate bounding box for label positioning
|
||||||
Rewind(); GetNextXY( x, y );
|
Rewind(); GetNextXY( x, y );
|
||||||
|
@ -643,7 +642,7 @@ void mpFXY::Plot( wxDC& dc, mpWindow& w )
|
||||||
|
|
||||||
dc.SetClippingRegion( startPx, minYpx, endPx - startPx + 1, maxYpx - minYpx + 1 );
|
dc.SetClippingRegion( startPx, minYpx, endPx - startPx + 1, maxYpx - minYpx + 1 );
|
||||||
|
|
||||||
wxCoord ix = 0, iy = 0;
|
wxCoord ix = std::numeric_limits<wxCoord>::min(), iy = 0;
|
||||||
|
|
||||||
if( !m_continuous )
|
if( !m_continuous )
|
||||||
{
|
{
|
||||||
|
@ -655,8 +654,12 @@ void mpFXY::Plot( wxDC& dc, mpWindow& w )
|
||||||
{
|
{
|
||||||
double px = m_scaleX->TransformToPlot( x );
|
double px = m_scaleX->TransformToPlot( x );
|
||||||
double py = m_scaleY->TransformToPlot( y );
|
double py = m_scaleY->TransformToPlot( y );
|
||||||
|
wxCoord newX = w.x2p( px );
|
||||||
|
|
||||||
ix = w.x2p( px );
|
if( newX == ix ) // continue until a new X coordinate is reached
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ix = newX;
|
||||||
iy = w.y2p( py );
|
iy = w.y2p( py );
|
||||||
|
|
||||||
if( m_drawOutsideMargins
|
if( m_drawOutsideMargins
|
||||||
|
@ -675,7 +678,12 @@ void mpFXY::Plot( wxDC& dc, mpWindow& w )
|
||||||
double px = m_scaleX->TransformToPlot( x );
|
double px = m_scaleX->TransformToPlot( x );
|
||||||
double py = m_scaleY->TransformToPlot( y );
|
double py = m_scaleY->TransformToPlot( y );
|
||||||
|
|
||||||
ix = w.x2p( px );
|
wxCoord newX = w.x2p( px );
|
||||||
|
|
||||||
|
if( newX == ix ) // continue until a new X coordinate is reached
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ix = newX;
|
||||||
iy = w.y2p( py );
|
iy = w.y2p( py );
|
||||||
|
|
||||||
if( m_drawOutsideMargins
|
if( m_drawOutsideMargins
|
||||||
|
@ -705,28 +713,23 @@ void mpFXY::Plot( wxDC& dc, mpWindow& w )
|
||||||
if( py >= 0.0 && py <= 1.0 )
|
if( py >= 0.0 && py <= 1.0 )
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
// printf("py %.1f\n", py);
|
|
||||||
|
|
||||||
wxCoord x1 = w.x2p( px );
|
wxCoord x1 = w.x2p( px );
|
||||||
wxCoord c1 = w.y2p( py );
|
wxCoord c1 = w.y2p( py );
|
||||||
|
|
||||||
// printf("px %.10f py %.10f c1 %d\n", px, py, c1);
|
|
||||||
|
|
||||||
// wxCoord x1 = XScale().X2p(w,x); // (wxCoord) ((x - w.GetPosX()) * w.GetScaleX());
|
|
||||||
// wxCoord c1 = YScale().X2p(w,y); // (wxCoord) ((w.GetPosY() - y) * w.GetScaleY());
|
|
||||||
|
|
||||||
if( first )
|
if( first )
|
||||||
{
|
{
|
||||||
first = false;
|
first = false;
|
||||||
x0 = x1; c0 = c1;
|
x0 = x1; c0 = c1;
|
||||||
}
|
}
|
||||||
|
else if( x0 == x1 ) // continue until a new X coordinate is reached
|
||||||
bool outUp, outDown;
|
|
||||||
|
|
||||||
if( (x1 >= startPx)&&(x0 <= endPx) )
|
|
||||||
{
|
{
|
||||||
outDown = (c0 > maxYpx) && (c1 > maxYpx);
|
continue;
|
||||||
outUp = (c0 < minYpx) && (c1 < minYpx);
|
}
|
||||||
|
|
||||||
|
if( ( x1 >= startPx ) && ( x0 <= endPx ) )
|
||||||
|
{
|
||||||
|
bool outDown = ( c0 > maxYpx ) && ( c1 > maxYpx );
|
||||||
|
bool outUp = ( c0 < minYpx ) && ( c1 < minYpx );
|
||||||
|
|
||||||
if( !outUp && !outDown )
|
if( !outUp && !outDown )
|
||||||
{
|
{
|
||||||
|
@ -737,8 +740,6 @@ void mpFXY::Plot( wxDC& dc, mpWindow& w )
|
||||||
|
|
||||||
x0 = x1; c0 = c1;
|
x0 = x1; c0 = c1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// printf("n %s %d\n", (const char *) m_name.c_str(), n);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !m_name.IsEmpty() && m_showName )
|
if( !m_name.IsEmpty() && m_showName )
|
||||||
|
@ -3340,13 +3341,15 @@ void mpFXYVector::Rewind()
|
||||||
|
|
||||||
bool mpFXYVector::GetNextXY( double& x, double& y )
|
bool mpFXYVector::GetNextXY( double& x, double& y )
|
||||||
{
|
{
|
||||||
if( m_index>=m_xs.size() )
|
if( m_index >= m_xs.size() )
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
x = m_xs[m_index];
|
x = m_xs[m_index];
|
||||||
y = m_ys[m_index++];
|
y = m_ys[m_index++];
|
||||||
return m_index<=m_xs.size();
|
return m_index <= m_xs.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue