Skip to content

Commit

Permalink
explicitely call int version of former calls to toMapCoordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Sep 29, 2018
1 parent 157ba0f commit e2aa0b7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/app/qgsmaptoolselectutils.cpp
Expand Up @@ -82,8 +82,8 @@ QgsRectangle QgsMapToolSelectUtils::expandSelectRectangle( QgsPointXY mapPoint,

const QgsMapToPixel *transform = canvas->getCoordinateTransform();
QgsPointXY point = transform->transform( mapPoint );
QgsPointXY ll = transform->toMapCoordinates( point.x() - boxSize, point.y() + boxSize );
QgsPointXY ur = transform->toMapCoordinates( point.x() + boxSize, point.y() - boxSize );
QgsPointXY ll = transform->toMapCoordinates( static_cast<int>( point.x() - boxSize ), static_cast<int>( point.y() + boxSize ) );
QgsPointXY ur = transform->toMapCoordinates( static_cast<int>( point.x() + boxSize ), static_cast<int>( point.y() - boxSize ) );
return QgsRectangle( ll, ur );
}

Expand Down
6 changes: 4 additions & 2 deletions src/app/qgspointmarkeritem.cpp
Expand Up @@ -108,8 +108,10 @@ void QgsPointMarkerItem::updateSize()
mMarkerSymbol->startRender( rc, mFeature.fields() );
QRectF bounds = mMarkerSymbol->bounds( mLocation, rc, mFeature );
mMarkerSymbol->stopRender( rc );
QgsRectangle r( mMapCanvas->mapSettings().mapToPixel().toMapCoordinates( bounds.x(), bounds.y() ),
mMapCanvas->mapSettings().mapToPixel().toMapCoordinates( bounds.x() + bounds.width() * 2, bounds.y() + bounds.height() * 2 ) );
QgsRectangle r( mMapCanvas->mapSettings().mapToPixel().toMapCoordinates( static_cast<int>( bounds.x() ),
static_cast<int>( bounds.y() ) ),
mMapCanvas->mapSettings().mapToPixel().toMapCoordinates( static_cast<int>( bounds.x() + bounds.width() * 2 ),
static_cast<int>( bounds.y() + bounds.height() * 2 ) ) );
setRect( r );
}

Expand Down
3 changes: 2 additions & 1 deletion src/core/qgsvectorlayerlabelprovider.cpp
Expand Up @@ -319,7 +319,8 @@ QgsGeometry QgsVectorLayerLabelProvider::getPointObstacleGeometry( QgsFeature &f
//TODO - remove when labeling is refactored to use screen units
for ( int i = 0; i < boundLineString->numPoints(); ++i )
{
QgsPointXY point = context.mapToPixel().toMapCoordinates( boundLineString->xAt( i ), boundLineString->yAt( i ) );
QgsPointXY point = context.mapToPixel().toMapCoordinates( static_cast<int>( boundLineString->xAt( i ) ),
static_cast<int>( boundLineString->yAt( i ) ) );
boundLineString->setXAt( i, point.x() );
boundLineString->setYAt( i, point.y() );
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgsrasterlayerrenderer.cpp
Expand Up @@ -79,8 +79,8 @@ QgsRasterLayerRenderer::QgsRasterLayerRenderer( QgsRasterLayer *layer, QgsRender
// TODO: provide a method of QgsMapToPixel to fetch map center
// in geographical units
QgsPointXY center = mapToPixel.toMapCoordinates(
mapToPixel.mapWidth() / 2.0,
mapToPixel.mapHeight() / 2.0
static_cast<int>( mapToPixel.mapWidth() / 2.0 ),
static_cast<int>( mapToPixel.mapHeight() / 2.0 )
);
mapToPixel.setMapRotation( 0, center.x(), center.y() );
}
Expand Down
6 changes: 4 additions & 2 deletions src/gui/qgssnaptogridcanvasitem.cpp
Expand Up @@ -148,8 +148,10 @@ void QgsSnapToGridCanvasItem::updateZoomFactor()
const QgsPointXY centerPoint = mMapCanvas->extent().center();
const QPointF canvasCenter = toCanvasCoordinates( centerPoint );

const QgsPointXY pt1 = mMapCanvas->mapSettings().mapToPixel().toMapCoordinates( canvasCenter.x() - threshold, canvasCenter.y() - threshold );
const QgsPointXY pt2 = mMapCanvas->mapSettings().mapToPixel().toMapCoordinates( canvasCenter.x() + threshold, canvasCenter.y() + threshold );
const QgsPointXY pt1 = mMapCanvas->mapSettings().mapToPixel().toMapCoordinates( static_cast<int>( canvasCenter.x() - threshold ),
static_cast<int>( canvasCenter.y() - threshold ) );
const QgsPointXY pt2 = mMapCanvas->mapSettings().mapToPixel().toMapCoordinates( static_cast<int>( canvasCenter.x() + threshold ),
static_cast<int>( canvasCenter.y() + threshold ) );

const QgsPointXY layerPt1 = mTransform.transform( pt1, QgsCoordinateTransform::ReverseTransform );
const QgsPointXY layerPt2 = mTransform.transform( pt2, QgsCoordinateTransform::ReverseTransform );
Expand Down

0 comments on commit e2aa0b7

Please sign in to comment.