mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-18 00:03:05 -04:00
Fix tools with extent when map is rotated (add a messagebar)
This commit is contained in:
parent
83d5e77434
commit
e80cafb884
@ -76,13 +76,13 @@ class QgsMapToolAddRectangle: public QgsMapToolCapture
|
|||||||
int side( ) const { return mSide; }
|
int side( ) const { return mSide; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! Convenient member for the azimuth of the rotated rectangle. \see QgsMapToolRectangle3Points
|
//! Convenient member for the azimuth of the rotated rectangle or when map is rotated.
|
||||||
double mAzimuth = 0.0;
|
double mAzimuth = 0.0;
|
||||||
//! Convenient member for the first distance of the rotated rectangle. \see QgsMapToolRectangle3Points
|
//! Convenient member for the first distance of the rotated rectangle or when map is rotated.
|
||||||
double mDistance1 = 0.0;
|
double mDistance1 = 0.0;
|
||||||
//! Convenient member for the second distance of the rotated rectangle. \see QgsMapToolRectangle3Points
|
//! Convenient member for the second distance of the rotated rectangle or when map is rotated.
|
||||||
double mDistance2 = 0.0;
|
double mDistance2 = 0.0;
|
||||||
//! Convenient member for the side where the second distance is drawn. \see QgsMapToolRectangle3Points
|
//! Convenient member for the side where the second distance is drawn or when map is rotated.
|
||||||
int mSide = 1;
|
int mSide = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -62,7 +62,13 @@ void QgsMapToolEllipseExtent::cadCanvasMoveEvent( QgsMapMouseEvent *e )
|
|||||||
QgsPoint mapPoint( e->mapPoint() );
|
QgsPoint mapPoint( e->mapPoint() );
|
||||||
if ( mTempRubberBand )
|
if ( mTempRubberBand )
|
||||||
{
|
{
|
||||||
mEllipse = QgsEllipse().fromExtent( mPoints.at( 0 ), mapPoint );
|
|
||||||
mTempRubberBand->setGeometry( mEllipse.toPolygon() );
|
if ( qgsDoubleNear( mCanvas->rotation(), 0.0 ) )
|
||||||
|
{
|
||||||
|
mEllipse = QgsEllipse().fromExtent( mPoints.at( 0 ), mapPoint );
|
||||||
|
mTempRubberBand->setGeometry( mEllipse.toPolygon() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
emit messageEmitted( tr( "Cannot use this tool when the map canvas is rotated" ), QgsMessageBar::WARNING );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,6 @@ class QgsMapToolRectangle3Points: public QgsMapToolAddRectangle
|
|||||||
void cadCanvasReleaseEvent( QgsMapMouseEvent *e ) override;
|
void cadCanvasReleaseEvent( QgsMapMouseEvent *e ) override;
|
||||||
void cadCanvasMoveEvent( QgsMapMouseEvent *e ) override;
|
void cadCanvasMoveEvent( QgsMapMouseEvent *e ) override;
|
||||||
|
|
||||||
private:
|
|
||||||
double mAzimuth;
|
|
||||||
double mDistance1;
|
|
||||||
double mDistance2;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QGSMAPTOOLRECTANGLE3POINTS_H
|
#endif // QGSMAPTOOLRECTANGLE3POINTS_H
|
||||||
|
@ -69,12 +69,18 @@ void QgsMapToolRectangleCenter::cadCanvasMoveEvent( QgsMapMouseEvent *e )
|
|||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
double xOffset = fabs( mapPoint.x() - mPoints.at( 0 ).x() );
|
|
||||||
double yOffset = fabs( mapPoint.y() - mPoints.at( 0 ).y() );
|
|
||||||
|
|
||||||
mRectangle = QgsRectangle( QgsPoint( mPoints.at( 0 ).x() - xOffset, mPoints.at( 0 ).y() - yOffset ), QgsPoint( mPoints.at( 0 ).x() + xOffset, mPoints.at( 0 ).y() + yOffset ) );
|
if ( qgsDoubleNear( mCanvas->rotation(), 0.0 ) )
|
||||||
|
{
|
||||||
|
double xOffset = fabs( mapPoint.x() - mPoints.at( 0 ).x() );
|
||||||
|
double yOffset = fabs( mapPoint.y() - mPoints.at( 0 ).y() );
|
||||||
|
|
||||||
mTempRubberBand->setGeometry( QgsMapToolAddRectangle::rectangleToPolygon() );
|
mRectangle = QgsRectangle( QgsPoint( mPoints.at( 0 ).x() - xOffset, mPoints.at( 0 ).y() - yOffset ), QgsPoint( mPoints.at( 0 ).x() + xOffset, mPoints.at( 0 ).y() + yOffset ) );
|
||||||
|
|
||||||
|
mTempRubberBand->setGeometry( QgsMapToolAddRectangle::rectangleToPolygon() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
emit messageEmitted( tr( "Cannot use this tool when the map canvas is rotated" ), QgsMessageBar::WARNING );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -68,9 +68,15 @@ void QgsMapToolRectangleExtent::cadCanvasMoveEvent( QgsMapMouseEvent *e )
|
|||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
mRectangle = QgsRectangle( mPoints.at( 0 ), mapPoint );
|
if ( qgsDoubleNear( mCanvas->rotation(), 0.0 ) )
|
||||||
|
{
|
||||||
|
|
||||||
mTempRubberBand->setGeometry( QgsMapToolAddRectangle::rectangleToPolygon() );
|
mRectangle = QgsRectangle( mPoints.at( 0 ), mapPoint );
|
||||||
|
|
||||||
|
mTempRubberBand->setGeometry( QgsMapToolAddRectangle::rectangleToPolygon( ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
emit messageEmitted( tr( "Cannot use this tool when the map canvas is rotated" ), QgsMessageBar::WARNING );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user