Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Do not render grid annotation if the lines/markers would be extremely…
… dense

Otherwise drawing of huge amount of lines/markers can lock GUI
  • Loading branch information
wonder-sk committed Apr 1, 2014
1 parent 434574e commit 1b4c8b6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/app/qgsdecorationgrid.cpp
Expand Up @@ -537,6 +537,11 @@ int QgsDecorationGrid::xGridLines( QList< QPair< double, QLineF > >& lines, QPai
QPolygonF mapPolygon = canvasExtent();
QRectF mapBoundingRect = mapPolygon.boundingRect();

// draw nothing if the distance between grid lines would be less than 1px
// otherwise the grid lines would completely cover the whole map
if ( mapBoundingRect.width() / mGridIntervalX >= p->device()->width() )
return 1;

//consider to round up to the next step in case the left boundary is > 0
double roundCorrection = mapBoundingRect.top() > 0 ? 1.0 : 0.0;
double currentLevel = ( int )(( mapBoundingRect.top() - mGridOffsetY ) / mGridIntervalY + roundCorrection ) * mGridIntervalY + mGridOffsetY;
Expand Down Expand Up @@ -606,6 +611,11 @@ int QgsDecorationGrid::yGridLines( QList< QPair< double, QLineF > >& lines, QPai
QPolygonF mapPolygon = canvasExtent();
QRectF mapBoundingRect = mapPolygon.boundingRect();

// draw nothing if the distance between grid lines would be less than 1px
// otherwise the grid lines would completely cover the whole map
if ( mapBoundingRect.height() / mGridIntervalY >= p->device()->height() )
return 1;

//consider to round up to the next step in case the left boundary is > 0
double roundCorrection = mapBoundingRect.left() > 0 ? 1.0 : 0.0;
double currentLevel = ( int )(( mapBoundingRect.left() - mGridOffsetX ) / mGridIntervalX + roundCorrection ) * mGridIntervalX + mGridOffsetX;
Expand Down

0 comments on commit 1b4c8b6

Please sign in to comment.