explicitely call int version of former calls to toMapCoordinates

This commit is contained in:
Denis Rouzaud 2018-09-29 15:48:05 -04:00
parent 157ba0f4be
commit e2aa0b715b
5 changed files with 14 additions and 9 deletions

View File

@ -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 );
}

View File

@ -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 );
}

View File

@ -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() );
}

View File

@ -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() );
}

View File

@ -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 );