diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2020-02-03 16:18:20 +0100 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2020-02-28 08:57:57 +0100 |
commit | 1ba46c9b632731d7d7e791de2b203d0d933245b9 (patch) | |
tree | a7933031bde57f582181c2e9c185989ebdbb9470 /src/widgets | |
parent | d2068b24e4b2e96832af154d02e19b5333880c21 (diff) |
Get rid of QMatrix
Task-number: QTBUG-81628
Change-Id: Iad66bfdf49b9ee65558a451108c086fc40dc3884
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/graphicsview/qgraphicsitem.cpp | 103 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicsitem.h | 14 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicsitemanimation.cpp | 14 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicsitemanimation.h | 5 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicsview.cpp | 70 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicsview.h | 5 | ||||
-rw-r--r-- | src/widgets/styles/qstyleoption.cpp | 4 | ||||
-rw-r--r-- | src/widgets/styles/qstyleoption.h | 4 |
8 files changed, 5 insertions, 214 deletions
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index db5c53a48a..af4443fa00 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -530,9 +530,6 @@ setEnabled() in itemChange() as this notification is delivered. The return value is ignored. - \value ItemMatrixChange The item's affine transformation matrix is - changing. This value is obsolete; you can use ItemTransformChange instead. - \value ItemPositionChange The item's position changes. This notification is sent if the ItemSendsGeometryChanges flag is enabled, and when the item's local position changes, relative to its parent (i.e., as a result @@ -1506,7 +1503,7 @@ void QGraphicsItemPrivate::initStyleOption(QStyleOptionGraphicsItem *option, con return; // Initialize QStyleOptionGraphicsItem specific values (matrix, exposedRect). - option->matrix = worldTransform.toAffine(); //### discards perspective + option->matrix = worldTransform; //### discards perspective if (!allItems) { // Determine the item's exposed area @@ -3997,24 +3994,6 @@ void QGraphicsItem::ensureVisible(const QRectF &rect, int xmargin, int ymargin) ensureVisible(QRectF(\a x, \a y, \a w, \a h), \a xmargin, \a ymargin). */ -#if QT_DEPRECATED_SINCE(5, 13) -/*! - \obsolete - - Returns the item's affine transformation matrix. This is a subset or the - item's full transformation matrix, and might not represent the item's full - transformation. - - Use transform() instead. - - \sa setTransform(), sceneTransform() -*/ -QMatrix QGraphicsItem::matrix() const -{ - return transform().toAffine(); -} -#endif - /*! \since 4.3 @@ -4323,22 +4302,6 @@ void QGraphicsItem::setTransformOriginPoint(const QPointF &origin) \sa setTransformOriginPoint(), {Transformations} */ - -#if QT_DEPRECATED_SINCE(5, 13) -/*! - \obsolete - - Use sceneTransform() instead. - - \sa transform(), setTransform(), scenePos(), {The Graphics View Coordinate System} -*/ -QMatrix QGraphicsItem::sceneMatrix() const -{ - d_ptr->ensureSceneTransform(); - return d_ptr->sceneTransform.toAffine(); -} -#endif - /*! \since 4.3 @@ -4549,50 +4512,6 @@ QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) co return x; } -#if QT_DEPRECATED_SINCE(5, 13) -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED -/*! - \obsolete - - Sets the item's affine transformation matrix. This is a subset or the - item's full transformation matrix, and might not represent the item's full - transformation. - - Use setTransform() instead. - - \sa transform(), {The Graphics View Coordinate System} -*/ -void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine) -{ - if (!d_ptr->transformData) - d_ptr->transformData = new QGraphicsItemPrivate::TransformData; - - QTransform newTransform(combine ? QTransform(matrix) * d_ptr->transformData->transform : QTransform(matrix)); - if (d_ptr->transformData->transform == newTransform) - return; - - // Update and set the new transformation. - if (!(d_ptr->flags & ItemSendsGeometryChanges)) { - d_ptr->setTransformHelper(newTransform); - return; - } - - // Notify the item that the transformation matrix is changing. - const QVariant newMatrixVariant = QVariant::fromValue<QMatrix>(newTransform.toAffine()); - newTransform = QTransform(qvariant_cast<QMatrix>(itemChange(ItemMatrixChange, newMatrixVariant))); - if (d_ptr->transformData->transform == newTransform) - return; - - // Update and set the new transformation. - d_ptr->setTransformHelper(newTransform); - - // Send post-notification. - itemChange(ItemTransformHasChanged, QVariant::fromValue<QTransform>(newTransform)); -} -QT_WARNING_POP -#endif - /*! \since 4.3 @@ -4646,18 +4565,6 @@ void QGraphicsItem::setTransform(const QTransform &matrix, bool combine) d_ptr->sendScenePosChange(); } -#if QT_DEPRECATED_SINCE(5, 13) -/*! - \obsolete - - Use resetTransform() instead. -*/ -void QGraphicsItem::resetMatrix() -{ - resetTransform(); -} -#endif - /*! \since 4.3 @@ -11526,14 +11433,6 @@ QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemChange change) case QGraphicsItem::ItemFlagsHaveChanged: str = "ItemFlagsHaveChanged"; break; -#if QT_DEPRECATED_SINCE(5, 14) -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - case QGraphicsItem::ItemMatrixChange: - str = "ItemMatrixChange"; - break; -QT_WARNING_POP -#endif case QGraphicsItem::ItemParentChange: str = "ItemParentChange"; break; diff --git a/src/widgets/graphicsview/qgraphicsitem.h b/src/widgets/graphicsview/qgraphicsitem.h index d66a4917e5..c78d31bbd4 100644 --- a/src/widgets/graphicsview/qgraphicsitem.h +++ b/src/widgets/graphicsview/qgraphicsitem.h @@ -71,7 +71,6 @@ class QGraphicsTransform; class QGraphicsWidget; class QInputMethodEvent; class QKeyEvent; -class QMatrix; class QMenu; class QPainter; class QPen; @@ -110,9 +109,6 @@ public: enum GraphicsItemChange { ItemPositionChange, -#if QT_DEPRECATED_SINCE(5, 14) - ItemMatrixChange Q_DECL_ENUMERATOR_DEPRECATED_X("Use ItemTransformChange instead"), -#endif ItemVisibleChange = 2, ItemEnabledChange, ItemSelectedChange, @@ -285,16 +281,6 @@ public: inline void ensureVisible(qreal x, qreal y, qreal w, qreal h, int xmargin = 50, int ymargin = 50); // Local transformation -#if QT_DEPRECATED_SINCE(5, 13) - QT_DEPRECATED_X("Use transform() instead") - QMatrix matrix() const; - QT_DEPRECATED_X("Use sceneTransform() instead") - QMatrix sceneMatrix() const; - QT_DEPRECATED_X("Use setTransform() instead") - void setMatrix(const QMatrix &matrix, bool combine = false); - QT_DEPRECATED_X("Use resetTransform() instead") - void resetMatrix(); -#endif QTransform transform() const; QTransform sceneTransform() const; QTransform deviceTransform(const QTransform &viewportTransform) const; diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.cpp b/src/widgets/graphicsview/qgraphicsitemanimation.cpp index 1c5dbf265c..45b4871e24 100644 --- a/src/widgets/graphicsview/qgraphicsitemanimation.cpp +++ b/src/widgets/graphicsview/qgraphicsitemanimation.cpp @@ -87,7 +87,6 @@ #include <QtCore/qpoint.h> #include <QtCore/qpointer.h> #include <QtCore/qpair.h> -#include <QtGui/qmatrix.h> #include <algorithm> @@ -294,19 +293,6 @@ QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::posList() const return list; } -#if QT_DEPRECATED_SINCE(5, 14) -/*! - Returns the matrix used to transform the item at the specified \a step value. - - \obsolete Use transformAt() instead -*/ -QMatrix QGraphicsItemAnimation::matrixAt(qreal step) const -{ - check_step_valid(step, "matrixAt"); - return transformAt(step).toAffine(); -} -#endif - /*! Returns the transform used for the item at the specified \a step value. diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.h b/src/widgets/graphicsview/qgraphicsitemanimation.h index 3051fb2e2b..af54dfff93 100644 --- a/src/widgets/graphicsview/qgraphicsitemanimation.h +++ b/src/widgets/graphicsview/qgraphicsitemanimation.h @@ -48,7 +48,6 @@ QT_REQUIRE_CONFIG(graphicsview); QT_BEGIN_NAMESPACE class QGraphicsItem; -class QMatrix; class QPointF; class QTimeLine; class QTransform; @@ -72,10 +71,6 @@ public: QList<QPair<qreal, QPointF> > posList() const; void setPosAt(qreal step, const QPointF &pos); -#if QT_DEPRECATED_SINCE(5, 14) - QT_DEPRECATED_X("Use transformAt() instead") - QMatrix matrixAt(qreal step) const; -#endif QTransform transformAt(qreal step) const; qreal rotationAt(qreal step) const; diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index a75f1ab24b..f806ecebad 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -292,7 +292,6 @@ static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503; // largest prime < #include <QtGui/qevent.h> #include <QtWidgets/qlayout.h> #include <QtGui/qtransform.h> -#include <QtGui/qmatrix.h> #include <QtGui/qpainter.h> #include <QtWidgets/qscrollbar.h> #include <QtWidgets/qstyleoption.h> @@ -1824,75 +1823,6 @@ void QGraphicsView::setSceneRect(const QRectF &rect) d->recalculateContentSize(); } -#if QT_DEPRECATED_SINCE(5, 15) - -/*! - \obsolete - - Use transform() instead. - - Returns the current transformation matrix for the view. If no current - transformation is set, the identity matrix is returned. - - \sa setMatrix(), transform(), rotate(), scale(), shear(), translate() -*/ -QMatrix QGraphicsView::matrix() const -{ - Q_D(const QGraphicsView); - return d->matrix.toAffine(); -} - -/*! - \obsolete - - Use setTransform() instead. - - Sets the view's current transformation matrix to \a matrix. - - If \a combine is true, then \a matrix is combined with the current matrix; - otherwise, \a matrix \e replaces the current matrix. \a combine is false - by default. - - The transformation matrix tranforms the scene into view coordinates. Using - the default transformation, provided by the identity matrix, one pixel in - the view represents one unit in the scene (e.g., a 10x10 rectangular item - is drawn using 10x10 pixels in the view). If a 2x2 scaling matrix is - applied, the scene will be drawn in 1:2 (e.g., a 10x10 rectangular item is - then drawn using 20x20 pixels in the view). - - Example: - - \snippet code/src_gui_graphicsview_qgraphicsview.cpp 3 - - To simplify interation with items using a transformed view, QGraphicsView - provides mapTo... and mapFrom... functions that can translate between - scene and view coordinates. For example, you can call mapToScene() to map - a view coordinate to a floating point scene coordinate, or mapFromScene() - to map from floating point scene coordinates to view coordinates. - - \sa matrix(), setTransform(), rotate(), scale(), shear(), translate() -*/ -void QGraphicsView::setMatrix(const QMatrix &matrix, bool combine) -{ - setTransform(QTransform(matrix), combine); -} - -/*! - \obsolete - - Use resetTransform() instead. - - Resets the view transformation matrix to the identity matrix. - - \sa resetTransform() -*/ -void QGraphicsView::resetMatrix() -{ - resetTransform(); -} - -#endif // QT_DEPRECATED_SINCE(5, 15) - /*! Rotates the current view transformation \a angle degrees clockwise. diff --git a/src/widgets/graphicsview/qgraphicsview.h b/src/widgets/graphicsview/qgraphicsview.h index e98ec52d8f..4c0b70bdd7 100644 --- a/src/widgets/graphicsview/qgraphicsview.h +++ b/src/widgets/graphicsview/qgraphicsview.h @@ -165,11 +165,6 @@ public: void setSceneRect(const QRectF &rect); inline void setSceneRect(qreal x, qreal y, qreal w, qreal h); -#if QT_DEPRECATED_SINCE(5, 15) - QT_DEPRECATED_X("Use transform()") QMatrix matrix() const; - QT_DEPRECATED_X("Use setTransform()") void setMatrix(const QMatrix &matrix, bool combine = false); - QT_DEPRECATED_X("Use resetTransform()") void resetMatrix(); -#endif // QT_DEPRECATED_SINCE(5, 15) QTransform transform() const; QTransform viewportTransform() const; bool isTransformed() const; diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index bf365585d4..356092074c 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -3763,7 +3763,7 @@ qreal QStyleOptionGraphicsItem::levelOfDetailFromTransform(const QTransform &wor \brief the complete transformation matrix for the item \obsolete - The QMatrix provided through this member does include information about + The QTransform provided through this member does include information about any perspective transformations applied to the view or item. To get the correct transformation matrix, use QPainter::transform() on the painter passed into the QGraphicsItem::paint() implementation. @@ -3774,7 +3774,7 @@ qreal QStyleOptionGraphicsItem::levelOfDetailFromTransform(const QTransform &wor item drawing. To find the dimensions of an item in screen coordinates (i.e., pixels), - you can use the mapping functions of QMatrix, such as QMatrix::map(). + you can use the mapping functions of QTransform, such as QTransform::map(). This member is only initialized for items that have the QGraphicsItem::ItemUsesExtendedStyleOption flag set. diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h index a8ce3b465e..a93f0c7ca6 100644 --- a/src/widgets/styles/qstyleoption.h +++ b/src/widgets/styles/qstyleoption.h @@ -47,7 +47,7 @@ #include <QtWidgets/qabstractspinbox.h> #endif #include <QtGui/qicon.h> -#include <QtGui/qmatrix.h> +#include <QtGui/qtransform.h> #if QT_CONFIG(slider) #include <QtWidgets/qslider.h> #endif @@ -693,7 +693,7 @@ public: enum StyleOptionVersion { Version = 1 }; QRectF exposedRect; - QMatrix matrix; + QTransform matrix; qreal levelOfDetail; QStyleOptionGraphicsItem(); |