diff --git a/python/PyQt6/core/auto_additions/qgis.py b/python/PyQt6/core/auto_additions/qgis.py index d04002e5503..4e240d61f6e 100644 --- a/python/PyQt6/core/auto_additions/qgis.py +++ b/python/PyQt6/core/auto_additions/qgis.py @@ -11505,10 +11505,10 @@ Qgis.MouseHandlesAction.ResizeLeftUp.__doc__ = "Resize left up (Top left handle) Qgis.MouseHandlesAction.ResizeRightUp.__doc__ = "Resize right up (Top right handle)" Qgis.MouseHandlesAction.ResizeLeftDown.__doc__ = "Resize left down (Bottom left handle)" Qgis.MouseHandlesAction.ResizeRightDown.__doc__ = "Resize right down (Bottom right handle)" -Qgis.MouseHandlesAction.RotateLeftUp.__doc__ = "Rotate left up (Top left handle)" -Qgis.MouseHandlesAction.RotateRightUp.__doc__ = "Rotate right up (Top right handle)" -Qgis.MouseHandlesAction.RotateLeftDown.__doc__ = "Rotate left up (Bottom left handle)" -Qgis.MouseHandlesAction.RotateRightDown.__doc__ = "Rotate right up (Bottom right handle)" +Qgis.MouseHandlesAction.RotateLeftUp.__doc__ = "Rotate from top left handle. \n.. versionadded:: 4.0" +Qgis.MouseHandlesAction.RotateRightUp.__doc__ = "Rotate from top right handle. \n.. versionadded:: 4.0" +Qgis.MouseHandlesAction.RotateLeftDown.__doc__ = "Rotate from bottom left handle. \n.. versionadded:: 4.0" +Qgis.MouseHandlesAction.RotateRightDown.__doc__ = "Rotate right bottom right handle. \n.. versionadded:: 4.0" Qgis.MouseHandlesAction.SelectItem.__doc__ = "Select item" Qgis.MouseHandlesAction.NoAction.__doc__ = "No action" Qgis.MouseHandlesAction.__doc__ = """Action to be performed by the mouse handles @@ -11524,10 +11524,22 @@ Qgis.MouseHandlesAction.__doc__ = """Action to be performed by the mouse handles * ``ResizeRightUp``: Resize right up (Top right handle) * ``ResizeLeftDown``: Resize left down (Bottom left handle) * ``ResizeRightDown``: Resize right down (Bottom right handle) -* ``RotateLeftUp``: Rotate left up (Top left handle) -* ``RotateRightUp``: Rotate right up (Top right handle) -* ``RotateLeftDown``: Rotate left up (Bottom left handle) -* ``RotateRightDown``: Rotate right up (Bottom right handle) +* ``RotateLeftUp``: Rotate from top left handle. + + .. versionadded:: 4.0 + +* ``RotateRightUp``: Rotate from top right handle. + + .. versionadded:: 4.0 + +* ``RotateLeftDown``: Rotate from bottom left handle. + + .. versionadded:: 4.0 + +* ``RotateRightDown``: Rotate right bottom right handle. + + .. versionadded:: 4.0 + * ``SelectItem``: Select item * ``NoAction``: No action diff --git a/python/core/auto_additions/qgis.py b/python/core/auto_additions/qgis.py index 7a3e596cb88..67562021b58 100644 --- a/python/core/auto_additions/qgis.py +++ b/python/core/auto_additions/qgis.py @@ -11411,10 +11411,10 @@ Qgis.MouseHandlesAction.ResizeLeftUp.__doc__ = "Resize left up (Top left handle) Qgis.MouseHandlesAction.ResizeRightUp.__doc__ = "Resize right up (Top right handle)" Qgis.MouseHandlesAction.ResizeLeftDown.__doc__ = "Resize left down (Bottom left handle)" Qgis.MouseHandlesAction.ResizeRightDown.__doc__ = "Resize right down (Bottom right handle)" -Qgis.MouseHandlesAction.RotateLeftUp.__doc__ = "Rotate left up (Top left handle)" -Qgis.MouseHandlesAction.RotateRightUp.__doc__ = "Rotate right up (Top right handle)" -Qgis.MouseHandlesAction.RotateLeftDown.__doc__ = "Rotate left up (Bottom left handle)" -Qgis.MouseHandlesAction.RotateRightDown.__doc__ = "Rotate right up (Bottom right handle)" +Qgis.MouseHandlesAction.RotateLeftUp.__doc__ = "Rotate from top left handle. \n.. versionadded:: 4.0" +Qgis.MouseHandlesAction.RotateRightUp.__doc__ = "Rotate from top right handle. \n.. versionadded:: 4.0" +Qgis.MouseHandlesAction.RotateLeftDown.__doc__ = "Rotate from bottom left handle. \n.. versionadded:: 4.0" +Qgis.MouseHandlesAction.RotateRightDown.__doc__ = "Rotate right bottom right handle. \n.. versionadded:: 4.0" Qgis.MouseHandlesAction.SelectItem.__doc__ = "Select item" Qgis.MouseHandlesAction.NoAction.__doc__ = "No action" Qgis.MouseHandlesAction.__doc__ = """Action to be performed by the mouse handles @@ -11430,10 +11430,22 @@ Qgis.MouseHandlesAction.__doc__ = """Action to be performed by the mouse handles * ``ResizeRightUp``: Resize right up (Top right handle) * ``ResizeLeftDown``: Resize left down (Bottom left handle) * ``ResizeRightDown``: Resize right down (Bottom right handle) -* ``RotateLeftUp``: Rotate left up (Top left handle) -* ``RotateRightUp``: Rotate right up (Top right handle) -* ``RotateLeftDown``: Rotate left up (Bottom left handle) -* ``RotateRightDown``: Rotate right up (Bottom right handle) +* ``RotateLeftUp``: Rotate from top left handle. + + .. versionadded:: 4.0 + +* ``RotateRightUp``: Rotate from top right handle. + + .. versionadded:: 4.0 + +* ``RotateLeftDown``: Rotate from bottom left handle. + + .. versionadded:: 4.0 + +* ``RotateRightDown``: Rotate right bottom right handle. + + .. versionadded:: 4.0 + * ``SelectItem``: Select item * ``NoAction``: No action diff --git a/src/core/qgis.h b/src/core/qgis.h index 0635a142d4a..ab598e66199 100644 --- a/src/core/qgis.h +++ b/src/core/qgis.h @@ -5897,10 +5897,10 @@ class CORE_EXPORT Qgis ResizeRightUp, //!< Resize right up (Top right handle) ResizeLeftDown, //!< Resize left down (Bottom left handle) ResizeRightDown, //!< Resize right down (Bottom right handle) - RotateLeftUp, //!< Rotate left up (Top left handle) - RotateRightUp, //!< Rotate right up (Top right handle) - RotateLeftDown, //!< Rotate left up (Bottom left handle) - RotateRightDown, //!< Rotate right up (Bottom right handle) + RotateLeftUp, //!< Rotate from top left handle. \since QGIS 4.0 + RotateRightUp, //!< Rotate from top right handle. \since QGIS 4.0 + RotateLeftDown, //!< Rotate from bottom left handle. \since QGIS 4.0 + RotateRightDown, //!< Rotate right bottom right handle. \since QGIS 4.0 SelectItem, //!< Select item NoAction //!< No action }; diff --git a/src/gui/qgsgraphicsviewmousehandles.cpp b/src/gui/qgsgraphicsviewmousehandles.cpp index 053c87c828f..e8ce61a4b5e 100644 --- a/src/gui/qgsgraphicsviewmousehandles.cpp +++ b/src/gui/qgsgraphicsviewmousehandles.cpp @@ -15,10 +15,13 @@ * * ***************************************************************************/ -#include "qgsgraphicsviewmousehandles.h" #include "moc_qgsgraphicsviewmousehandles.cpp" -#include "qgsrendercontext.h" + #include "qgis.h" +#include "qgsgraphicsviewmousehandles.h" +#include "qgslayoututils.h" +#include "qgsrendercontext.h" + #include #include #include @@ -86,6 +89,7 @@ QRectF QgsGraphicsViewMouseHandles::storedItemRect( QGraphicsItem *item ) const void QgsGraphicsViewMouseHandles::rotateItem( QGraphicsItem *, double, double, double ) { + QgsDebugError( QStringLiteral( "Rotation is not implemented for this class" ) ); } void QgsGraphicsViewMouseHandles::previewItemMove( QGraphicsItem *, double, double ) @@ -930,13 +934,7 @@ void QgsGraphicsViewMouseHandles::rotateMouseMove( QPointF currentPosition, bool mRotationDelta = mRotationCurrent - mRotationBegin; if ( snapToCommonAngles ) { - const double commonAngles = 15; - double snappedRotationDelta = std::floor( std::abs( mRotationDelta ) / commonAngles ) * commonAngles; - if ( std::abs( std::fmod( mRotationDelta, commonAngles ) ) >= 10 ) - { - snappedRotationDelta += commonAngles; - } - mRotationDelta = mRotationDelta >= 0 ? snappedRotationDelta : -snappedRotationDelta; + mRotationDelta = QgsLayoutUtils::snappedAngle( mRotationDelta ); } const double itemRotationRadian = rotation() * M_PI / 180; diff --git a/src/gui/qgsgraphicsviewmousehandles.h b/src/gui/qgsgraphicsviewmousehandles.h index af844f456af..6b3ca556873 100644 --- a/src/gui/qgsgraphicsviewmousehandles.h +++ b/src/gui/qgsgraphicsviewmousehandles.h @@ -77,7 +77,11 @@ class GUI_EXPORT QgsGraphicsViewMouseHandles : public QObject, public QGraphicsR //! Returns TRUE is user is currently resizing with the handles bool isResizing() const { return mIsResizing; } - //! Returns TRUE is user is currently rotating with the handles + /** + * Returns TRUE is user is currently rotating with the handles. + * + * \since QGIS 4.0 + */ bool isRotating() const { return mIsRotating; } bool shouldBlockEvent( QInputEvent *event ) const; @@ -85,10 +89,23 @@ class GUI_EXPORT QgsGraphicsViewMouseHandles : public QObject, public QGraphicsR //! Initializes a drag operation \since QGIS 3.34 void startMove( QPointF sceneCoordPos ); - //! Returns TRUE if rotation functionality is enabled + /** + * Returns TRUE if rotation functionality is enabled. + * + * Rotation is not enabled by default. + * + * \since QGIS 4.0 + */ bool isRotationEnabled() const { return mRotationEnabled; } - //! Sets whether rotation functionality is enabled + /** + * Sets whether rotation functionality is enabled. + * + * Rotation is not enabled by default. Subclasses must implement the + * rotateItem() method in order to support rotation. + * + * \since QGIS 4.0 + */ void setRotationEnabled( bool enable ); public slots: