Skip to content
Permalink
Browse files
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 1b4c8b66afe5835b1195dfcadda976ab516f49d5
Showing with 10 additions and 0 deletions.
  1. +10 −0 src/app/qgsdecorationgrid.cpp
@@ -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;
@@ -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;

0 comments on commit 1b4c8b6

Please sign in to comment.