|
Krita Source Code Documentation
|
#include <kis_coordinates_converter.h>
Inheritance diagram for KisCoordinatesConverter:Classes | |
| struct | Private |
Public Member Functions | |
| void | beginRotation () |
| qreal | clampZoom (qreal zoom) const |
| qreal | devicePixelRatio () const |
| QPoint | documentOffset () const |
| QPointF | documentOffsetF () const |
| template<class T > | |
| _Private::Traits< T >::Result | documentToFlake (const T &obj) const |
| QTransform | documentToFlakeTransform () const |
| template<class T > | |
| _Private::Traits< T >::Result | documentToImage (const T &obj) const |
| template<class T > | |
| _Private::Traits< T >::Result | documentToWidget (const T &obj) const |
| QTransform | documentToWidgetTransform () const |
| qreal | effectivePhysicalZoom () const |
| qreal | effectiveZoom () const |
| void | enableNatureGestureFlag () |
| void | endRotation () |
| QPointF | flakeCenterPoint () const |
| template<class T > | |
| _Private::Traits< T >::Result | flakeToDocument (const T &obj) const |
| template<class T > | |
| _Private::Traits< T >::Result | flakeToWidget (const T &obj) const |
| QTransform | flakeToWidgetTransform () const |
| QSizeF | getCanvasWidgetSize () const |
| void | getOpenGLCheckersInfo (const QRectF &viewportRect, QTransform *textureTransform, QTransform *modelTransform, QRectF *textureRect, QRectF *modelRect, const bool scrollCheckers) const |
| void | getQPainterCheckersInfo (QTransform *transform, QPointF *brushOrigin, QPolygonF *polygon, const bool scrollCheckers) const |
| QPointF | imageCenterInWidgetPixel () const |
| void | imagePhysicalScale (qreal *scaleX, qreal *scaleY) const |
| QRectF | imageRectInDocumentPixels () const |
| QRect | imageRectInImagePixels () const |
| QRectF | imageRectInViewportPixels () const |
| QRectF | imageRectInWidgetPixels () const |
| void | imageScale (qreal *scaleX, qreal *scaleY) const |
| QSizeF | imageSizeInFlakePixels () const |
| template<class T > | |
| _Private::Traits< T >::Result | imageToDocument (const T &obj) const |
| QTransform | imageToDocumentTransform () const |
| template<class T > | |
| _Private::Traits< T >::Result | imageToViewport (const T &obj) const |
| QTransform | imageToViewportTransform () const |
| template<class T > | |
| _Private::Traits< T >::Result | imageToWidget (const T &obj) const |
| QTransform | imageToWidgetTransform () const |
| KisCoordinatesConverter () | |
| KoViewTransformStillPoint | makeDocStillPoint (const QPointF &docPoint) const override |
Creates a still point that links the docPoint of the image (in document pixels!) to the corresponding point on the screen (in the canvas widget). | |
| KoViewTransformStillPoint | makeWidgetStillPoint (const QPointF &viewPoint) const override |
Creates a still point that links the viewPoint of the widget to the corresponding point of the image. | |
| QPoint | maximumOffset () const |
| qreal | maxZoom () const |
| QPoint | minimumOffset () const |
| qreal | minZoom () const |
| void | mirror (const std::optional< KoViewTransformStillPoint > &stillPoint, bool mirrorXAxis, bool mirrorYAxis) |
| mirrors the canvas | |
| QPointF | preferredTransformationCenter () const |
| returns the point in image coordinates which is supposed to be the default still point for the transformations of the canvas. It returns the point of the image that is "roughly" mapped to to the center of the canvas widget. | |
| void | resetRotation (const std::optional< KoViewTransformStillPoint > &stillPoint) |
| resets canvas rotation | |
| void | rotate (const std::optional< KoViewTransformStillPoint > &stillPoint, qreal angle) |
| rotates the canvas | |
| qreal | rotationAngle () const |
| void | setCanvasWidgetSize (QSizeF size) |
| void | setCanvasWidgetSizeKeepZoom (const QSizeF &size) |
| void | setDevicePixelRatio (qreal value) |
| void | setDocumentOffset (const QPointF &offset) |
| void | setExtraReferencesBounds (const QRect &imageRect) |
| void | setImage (KisImageWSP image) |
| void | setImageBounds (const QRect &rect, const QPointF oldImageStillPoint, const QPointF newImageStillPoint) |
| void | setImageResolution (qreal xRes, qreal yRes) |
| void | setZoom (KoZoomMode::Mode mode, qreal zoom, qreal resolutionX, qreal resolutionY, const std::optional< KoViewTransformStillPoint > &stillPoint) |
| changes the zoom mode of the canvas | |
| void | setZoom (qreal zoom) override |
| QPointF | snapToDevicePixel (const QPointF &point) const |
Adjust a given pair of coordinates to the nearest device pixel according to the value of devicePixelRatio. | |
| QSizeF | snapWidgetSizeToDevicePixel (const QSizeF &size) const |
| QVector< qreal > | standardZoomLevels () const |
| QSize | viewportDevicePixelSize () const |
| template<class T > | |
| _Private::Traits< T >::Result | viewportToImage (const T &obj) const |
| template<class T > | |
| _Private::Traits< T >::Result | viewportToWidget (const T &obj) const |
| QTransform | viewportToWidgetTransform () const |
| QTransform | viewToWidget () const override |
| QPointF | widgetCenterPoint () const |
| QRectF | widgetRectInFlakePixels () const |
| QRectF | widgetRectInImagePixels () const |
| template<class T > | |
| _Private::Traits< T >::Result | widgetToDocument (const T &obj) const |
| template<class T > | |
| _Private::Traits< T >::Result | widgetToFlake (const T &obj) const |
| template<class T > | |
| _Private::Traits< T >::Result | widgetToImage (const T &obj) const |
| QTransform | widgetToView () const override |
| template<class T > | |
| _Private::Traits< T >::Result | widgetToViewport (const T &obj) const |
| bool | xAxisMirrored () const |
| bool | yAxisMirrored () const |
| void | zoomTo (const QRectF &widgetRect) |
| ~KisCoordinatesConverter () override | |
Public Member Functions inherited from KoZoomHandler | |
| QPointF | documentToView (const QPointF &documentPoint) const override |
| QRectF | documentToView (const QRectF &documentRect) const override |
| QSizeF | documentToView (const QSizeF &documentSize) const override |
| qreal | documentToViewX (qreal documentX) const override |
| qreal | documentToViewY (qreal documentY) const override |
| KoZoomHandler () | |
| qreal | resolutionX () const |
| qreal | resolutionY () const |
| void | setDpi (int dpiX, int dpiY) |
| void | setResolution (qreal resolutionX, qreal resolutionY) |
| void | setZoom (qreal zoom) override |
| virtual void | setZoomedResolution (qreal zoomedResolutionX, qreal zoomedResolutionY) |
| void | setZoomMarginSize (int size) |
| void | setZoomMode (KoZoomMode::Mode zoomMode) |
| qreal | unzoomItX (qreal x) const |
| qreal | unzoomItY (qreal y) const |
| QPointF | viewToDocument (const QPointF &viewPoint) const override |
| QRectF | viewToDocument (const QRectF &viewRect) const override |
| QSizeF | viewToDocument (const QSizeF &viewSize) const override |
| qreal | viewToDocumentX (qreal viewX) const override |
| qreal | viewToDocumentY (qreal viewY) const override |
| qreal | zoom () const |
| virtual void | zoom (qreal *zoomX, qreal *zoomY) const |
| void | zoom (qreal *zoomX, qreal *zoomY) const override |
| qreal | zoomedResolutionX () const |
| qreal | zoomedResolutionY () const |
| qreal | zoomFactorX () const |
| qreal | zoomFactorY () const |
| int | zoomInPercent () const |
| qreal | zoomItX (qreal z) const |
| qreal | zoomItY (qreal z) const |
| int | zoomMarginSize () const |
| KoZoomMode::Mode | zoomMode () const |
| ~KoZoomHandler () override | |
Public Member Functions inherited from KoViewConverter | |
| QTransform | documentToView () const |
| KoViewConverter () | |
| QTransform | viewToDocument () const |
| qreal | zoom () const |
| virtual | ~KoViewConverter () |
Static Public Member Functions | |
| static qreal | findNextZoom (qreal currentZoom, const QVector< qreal > &zoomLevels) |
| static qreal | findPrevZoom (qreal currentZoom, const QVector< qreal > &zoomLevels) |
Private Member Functions | |
| QPointF | centeringCorrection () const |
| void | correctOffsetToTransformationAndSnap () |
| void | correctTransformationToOffset () |
| void | recalculateOffsetBoundsAndCrop () |
| void | recalculateTransformations () |
| void | recalculateZoomLevelLimits () |
| void | resetPreferredTransformationCenter () |
Private Attributes | |
| Private *const | m_d |
Friends | |
| class | KisCoordinatesConverterTest |
| class | KisZoomAndPanTest |
Additional Inherited Members | |
Protected Attributes inherited from KoZoomHandler | |
| qreal | m_resolutionX |
| qreal | m_resolutionY |
| qreal | m_zoomedResolutionX |
| qreal | m_zoomedResolutionY |
| int | m_zoomMarginSize |
| KoZoomMode::Mode | m_zoomMode |
Definition at line 48 of file kis_coordinates_converter.h.
| KisCoordinatesConverter::KisCoordinatesConverter | ( | ) |
Definition at line 216 of file kis_coordinates_converter.cpp.
|
override |
Definition at line 219 of file kis_coordinates_converter.cpp.
References m_d.
| void KisCoordinatesConverter::beginRotation | ( | ) |
Definition at line 568 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::flakeToWidget, KisCoordinatesConverter::Private::isRotating, KIS_SAFE_ASSERT_RECOVER_NOOP, m_d, KisCoordinatesConverter::Private::rotationAngle, KisCoordinatesConverter::Private::rotationBaseAngle, and KisCoordinatesConverter::Private::rotationBaseTransform.
|
private |
When vastScrolling value is less than 0.5 it is possible that the whole scrolling area (viewport) will be smaller than the size of the widget. In such cases the image should be centered in the widget. Previously we used a special parameter documentOrigin for this purpose, now the value for this centering is calculated dynamically, helping the offset to center the image inside the widget
Note that the correction is null when the size of the document plus vast scrolling reserve is larger than the widget. This is always true for vastScrolling parameter > 0.5.
Definition at line 96 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::canvasWidgetSize, imageRectInWidgetPixels(), m_d, and KisConfig::vastScrolling().
| qreal KisCoordinatesConverter::clampZoom | ( | qreal | zoom | ) | const |
Definition at line 927 of file kis_coordinates_converter.cpp.
References maxZoom(), minZoom(), and KoZoomHandler::zoom().
|
private |
The document offset and the position of the top left corner of the image must always coincide, that is why we need to correct them to and fro.
When we change zoom level, the calculation of the new offset is done by KoCanvasControllerWidget, that is why we just passively fix the flakeToWidget transform to conform the offset and wait until the canvas controller will recenter us.
But when we do our own transformations of the canvas, like rotation and mirroring, we cannot rely on the centering of the canvas controller and we do it ourselves. Then we just set new offset and return its value to be set in the canvas controller explicitly.
Definition at line 173 of file kis_coordinates_converter.cpp.
References centeringCorrection(), KisCoordinatesConverter::Private::documentOffset, imageRectInWidgetPixels(), m_d, and snapToDevicePixel().
|
private |
Definition at line 179 of file kis_coordinates_converter.cpp.
References centeringCorrection(), KisCoordinatesConverter::Private::documentOffset, KisCoordinatesConverter::Private::flakeToWidget, imageRectInWidgetPixels(), and m_d.
| qreal KisCoordinatesConverter::devicePixelRatio | ( | ) | const |
Definition at line 352 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::devicePixelRatio, and m_d.
| QPoint KisCoordinatesConverter::documentOffset | ( | ) | const |
Definition at line 357 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::documentOffset, and m_d.
| QPointF KisCoordinatesConverter::documentOffsetF | ( | ) | const |
Definition at line 362 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::documentOffset, and m_d.
|
inline |
Definition at line 182 of file kis_coordinates_converter.h.
References _Private::Traits< T >::map().
| QTransform KisCoordinatesConverter::documentToFlakeTransform | ( | ) | const |
Definition at line 738 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::documentToFlake, and m_d.
|
inline |
Definition at line 179 of file kis_coordinates_converter.h.
References _Private::Traits< T >::map().
|
inline |
Definition at line 172 of file kis_coordinates_converter.h.
References _Private::Traits< T >::map().
| QTransform KisCoordinatesConverter::documentToWidgetTransform | ( | ) | const |
Definition at line 746 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::documentToFlake, KisCoordinatesConverter::Private::flakeToWidget, and m_d.
| qreal KisCoordinatesConverter::effectivePhysicalZoom | ( | ) | const |
Definition at line 550 of file kis_coordinates_converter.cpp.
References imagePhysicalScale(), ppVar, and qFuzzyCompare().
| qreal KisCoordinatesConverter::effectiveZoom | ( | ) | const |
A composition of to scale methods: zoom level + image resolution
Definition at line 537 of file kis_coordinates_converter.cpp.
References imageScale(), ppVar, and qFuzzyCompare().
| void KisCoordinatesConverter::enableNatureGestureFlag | ( | ) |
Definition at line 563 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::isNativeGesture, and m_d.
| void KisCoordinatesConverter::endRotation | ( | ) |
Definition at line 578 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::isNativeGesture, KisCoordinatesConverter::Private::isRotating, KIS_SAFE_ASSERT_RECOVER_NOOP, and m_d.
|
static |
Definition at line 957 of file kis_coordinates_converter.cpp.
References KoZoomMode::findNextZoom().
|
static |
Definition at line 962 of file kis_coordinates_converter.cpp.
References KoZoomMode::findPrevZoom().
| QPointF KisCoordinatesConverter::flakeCenterPoint | ( | ) | const |
Definition at line 855 of file kis_coordinates_converter.cpp.
References widgetRectInFlakePixels().
|
inline |
Definition at line 184 of file kis_coordinates_converter.h.
References _Private::Traits< T >::map().
|
inline |
Definition at line 162 of file kis_coordinates_converter.h.
References _Private::Traits< T >::map().
| QTransform KisCoordinatesConverter::flakeToWidgetTransform | ( | ) | const |
Definition at line 742 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::flakeToWidget, and m_d.
| QSizeF KisCoordinatesConverter::getCanvasWidgetSize | ( | ) | const |
Definition at line 224 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::canvasWidgetSize, and m_d.
| void KisCoordinatesConverter::getOpenGLCheckersInfo | ( | const QRectF & | viewportRect, |
| QTransform * | textureTransform, | ||
| QTransform * | modelTransform, | ||
| QRectF * | textureRect, | ||
| QRectF * | modelRect, | ||
| const bool | scrollCheckers ) const |
Definition at line 787 of file kis_coordinates_converter.cpp.
References viewportToWidgetTransform().
| void KisCoordinatesConverter::getQPainterCheckersInfo | ( | QTransform * | transform, |
| QPointF * | brushOrigin, | ||
| QPolygonF * | polygon, | ||
| const bool | scrollCheckers ) const |
Qt has different rounding for QPainter::drawRect/drawImage. The image is rounded mathematically, while rect in aligned to the next integer. That causes transparent line appear on the canvas.
See: https://bugreports.qt.nokia.com/browse/QTBUG-22827
Definition at line 758 of file kis_coordinates_converter.cpp.
References imageRectInViewportPixels(), imageToViewport(), and viewportToWidgetTransform().
| QPointF KisCoordinatesConverter::imageCenterInWidgetPixel | ( | ) | const |
Definition at line 807 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::imageBounds, imageToWidget(), and m_d.
| void KisCoordinatesConverter::imagePhysicalScale | ( | qreal * | scaleX, |
| qreal * | scaleY ) const |
Definition at line 882 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::devicePixelRatio, imageScale(), and m_d.
| QRectF KisCoordinatesConverter::imageRectInDocumentPixels | ( | ) | const |
Definition at line 831 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::imageBounds, imageToDocument(), and m_d.
| QRect KisCoordinatesConverter::imageRectInImagePixels | ( | ) | const |
Definition at line 826 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::imageBounds, and m_d.
| QRectF KisCoordinatesConverter::imageRectInViewportPixels | ( | ) | const |
Definition at line 821 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::imageBounds, imageToViewport(), and m_d.
| QRectF KisCoordinatesConverter::imageRectInWidgetPixels | ( | ) | const |
Definition at line 816 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::imageBounds, imageToWidget(), and m_d.
| void KisCoordinatesConverter::imageScale | ( | qreal * | scaleX, |
| qreal * | scaleY ) const |
Definition at line 867 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::imageXRes, KisCoordinatesConverter::Private::imageYRes, m_d, and KoZoomHandler::zoom().
| QSizeF KisCoordinatesConverter::imageSizeInFlakePixels | ( | ) | const |
Definition at line 836 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::imageBounds, imageScale(), and m_d.
|
inline |
Definition at line 177 of file kis_coordinates_converter.h.
References _Private::Traits< T >::map().
| QTransform KisCoordinatesConverter::imageToDocumentTransform | ( | ) | const |
Definition at line 734 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::imageToDocument, and m_d.
|
inline |
Definition at line 157 of file kis_coordinates_converter.h.
References _Private::Traits< T >::map().
| QTransform KisCoordinatesConverter::imageToViewportTransform | ( | ) | const |
Definition at line 754 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::documentToFlake, KisCoordinatesConverter::Private::flakeToWidget, KisCoordinatesConverter::Private::imageToDocument, m_d, and KisCoordinatesConverter::Private::widgetToViewport.
|
inline |
Definition at line 187 of file kis_coordinates_converter.h.
References _Private::Traits< T >::map().
| QTransform KisCoordinatesConverter::imageToWidgetTransform | ( | ) | const |
Definition at line 730 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::documentToFlake, KisCoordinatesConverter::Private::flakeToWidget, KisCoordinatesConverter::Private::imageToDocument, and m_d.
|
overridevirtual |
Creates a still point that links the docPoint of the image (in document pixels!) to the corresponding point on the screen (in the canvas widget).
The link is "baked" in KoViewTransformStillPoint object, hence intermediate transformations will not affect it.
Reimplemented in KisCoordinatesConverter.
Reimplemented from KoViewConverter.
Definition at line 972 of file kis_coordinates_converter.cpp.
References documentToWidget().
|
overridevirtual |
Creates a still point that links the viewPoint of the widget to the corresponding point of the image.
The link is "baked" in KoViewTransformStillPoint object, hence intermediate transformations will not affect it.
Reimplemented in KisCoordinatesConverter.
Reimplemented from KoViewConverter.
Definition at line 967 of file kis_coordinates_converter.cpp.
References widgetToDocument().
| QPoint KisCoordinatesConverter::maximumOffset | ( | ) | const |
Definition at line 152 of file kis_coordinates_converter.cpp.
References m_d, and KisCoordinatesConverter::Private::maximumOffset.
| qreal KisCoordinatesConverter::maxZoom | ( | ) | const |
Definition at line 923 of file kis_coordinates_converter.cpp.
References m_d, and KisCoordinatesConverter::Private::maxZoom.
| QPoint KisCoordinatesConverter::minimumOffset | ( | ) | const |
Definition at line 147 of file kis_coordinates_converter.cpp.
References m_d, and KisCoordinatesConverter::Private::minimumOffset.
| qreal KisCoordinatesConverter::minZoom | ( | ) | const |
Definition at line 919 of file kis_coordinates_converter.cpp.
References m_d, and KisCoordinatesConverter::Private::minZoom.
| void KisCoordinatesConverter::mirror | ( | const std::optional< KoViewTransformStillPoint > & | stillPoint, |
| bool | mirrorXAxis, | ||
| bool | mirrorYAxis ) |
mirrors the canvas
For the meaning of stillPoint
Definition at line 628 of file kis_coordinates_converter.cpp.
References correctOffsetToTransformationAndSnap(), KoViewTransformStillPoint::docPoint(), KisCoordinatesConverter::Private::documentOffset, documentToWidget(), KisCoordinatesConverter::Private::flakeToWidget, KisCoordinatesConverter::Private::isXAxisMirrored, KisCoordinatesConverter::Private::isYAxisMirrored, kisSquareDistance(), m_d, mirror(), KisCoordinatesConverter::Private::preferredTransformationCenterInDocumentPixels(), recalculateTransformations(), resetPreferredTransformationCenter(), KisCoordinatesConverter::Private::rotationAngle, KoZoomHandler::setZoomMode(), snapToDevicePixel(), KoViewTransformStillPoint::viewPoint(), widgetCenterPoint(), KoZoomMode::ZOOM_CONSTANT, and KoZoomHandler::zoomMode().
| QPointF KisCoordinatesConverter::preferredTransformationCenter | ( | ) | const |
returns the point in image coordinates which is supposed to be the default still point for the transformations of the canvas. It returns the point of the image that is "roughly" mapped to to the center of the canvas widget.
Some of the methods of the converter accept std::optional<KoViewTransformStillPoint> for a still point, over which the transformation should happen. When this argument is std::nullotp, then preferredTransformationCenter() is used.
One important property of preferredTransformationCenter() is that it is not changed when the canvas is transformed over it, even when pixel alignment happens. It means that preferredTransformationCenter() may not exactly map to the center of the widget, due to hardware-pixel-alignment.
Keeping this value unchanged allows us to avoid drifts of the offset when zooming and rotating the canvas.
Definition at line 367 of file kis_coordinates_converter.cpp.
References m_d, and KisCoordinatesConverter::Private::preferredTransformationCenterImage.
|
private |
Definition at line 117 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::canvasWidgetSize, KisAlgebra2D::clampPoint(), correctTransformationToOffset(), KisCoordinatesConverter::Private::documentOffset, KisCoordinatesConverter::Private::extraReferencesBounds, imageRectInWidgetPixels(), imageToWidget(), m_d, KisCoordinatesConverter::Private::maximumOffset, KisCoordinatesConverter::Private::minimumOffset, snapToDevicePixel(), and KisConfig::vastScrolling().
|
private |
Definition at line 192 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::canvasWidgetSize, correctTransformationToOffset(), KisCoordinatesConverter::Private::documentToFlake, flakeToWidgetTransform(), imageRectInWidgetPixels(), KisCoordinatesConverter::Private::imageToDocument, KisCoordinatesConverter::Private::imageXRes, KisCoordinatesConverter::Private::imageYRes, m_d, recalculateOffsetBoundsAndCrop(), KisCoordinatesConverter::Private::widgetToViewport, and KoZoomHandler::zoom().
|
private |
Definition at line 942 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::imageBounds, KisCoordinatesConverter::Private::imageXRes, KisCoordinatesConverter::Private::imageYRes, m_d, KisCoordinatesConverter::Private::maxZoom, KisCoordinatesConverter::Private::minZoom, KoZoomHandler::resolutionX(), KoZoomHandler::resolutionY(), and KisCoordinatesConverter::Private::standardZoomLevels.
|
private |
Definition at line 187 of file kis_coordinates_converter.cpp.
References m_d, KisCoordinatesConverter::Private::preferredTransformationCenterImage, widgetCenterPoint(), and widgetToImage().
| void KisCoordinatesConverter::resetRotation | ( | const std::optional< KoViewTransformStillPoint > & | stillPoint | ) |
resets canvas rotation
For the meaning of stillPoint
Definition at line 704 of file kis_coordinates_converter.cpp.
References correctOffsetToTransformationAndSnap(), KoViewTransformStillPoint::docPoint(), KisCoordinatesConverter::Private::documentOffset, documentToWidget(), KisCoordinatesConverter::Private::flakeToWidget, m_d, KisCoordinatesConverter::Private::preferredTransformationCenterInDocumentPixels(), recalculateTransformations(), resetPreferredTransformationCenter(), KisCoordinatesConverter::Private::rotationAngle, KisCoordinatesConverter::Private::rotationIsOrthogonal, snapToDevicePixel(), KoViewTransformStillPoint::viewPoint(), and widgetCenterPoint().
| void KisCoordinatesConverter::rotate | ( | const std::optional< KoViewTransformStillPoint > & | stillPoint, |
| qreal | angle ) |
rotates the canvas
For the meaning of stillPoint
Definition at line 586 of file kis_coordinates_converter.cpp.
References correctOffsetToTransformationAndSnap(), KoViewTransformStillPoint::docPoint(), KisCoordinatesConverter::Private::documentOffset, documentToWidget(), KisCoordinatesConverter::Private::flakeToWidget, KisCoordinatesConverter::Private::isNativeGesture, KisCoordinatesConverter::Private::isRotating, m_d, KisCoordinatesConverter::Private::preferredTransformationCenterInDocumentPixels(), recalculateTransformations(), resetPreferredTransformationCenter(), KisCoordinatesConverter::Private::rotationAngle, KisCoordinatesConverter::Private::rotationBaseAngle, KisCoordinatesConverter::Private::rotationBaseTransform, KisCoordinatesConverter::Private::rotationIsOrthogonal, KoZoomHandler::setZoomMode(), snapToDevicePixel(), KoViewTransformStillPoint::viewPoint(), widgetCenterPoint(), and KoZoomMode::ZOOM_CONSTANT.
| qreal KisCoordinatesConverter::rotationAngle | ( | ) | const |
Definition at line 372 of file kis_coordinates_converter.cpp.
References m_d, and KisCoordinatesConverter::Private::rotationAngle.
| void KisCoordinatesConverter::setCanvasWidgetSize | ( | QSizeF | size | ) |
Definition at line 229 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::canvasWidgetSize, m_d, recalculateTransformations(), resetPreferredTransformationCenter(), and snapWidgetSizeToDevicePixel().
| void KisCoordinatesConverter::setCanvasWidgetSizeKeepZoom | ( | const QSizeF & | size | ) |
WARNING: we can safely call setZoom() after changing widget size only for non-constant modes, because they have no still points, they always align to the center of the widget. Constant mode, reads the state of the canvas before transformation to calculate the position of the still point, hence we cannot change the state separately.
Definition at line 388 of file kis_coordinates_converter.cpp.
References KoZoomHandler::resolutionX(), KoZoomHandler::resolutionY(), setCanvasWidgetSize(), setZoom(), KoZoomMode::ZOOM_CONSTANT, and KoZoomHandler::zoomMode().
| void KisCoordinatesConverter::setDevicePixelRatio | ( | qreal | value | ) |
Definition at line 239 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::devicePixelRatio, m_d, and value().
| void KisCoordinatesConverter::setDocumentOffset | ( | const QPointF & | offset | ) |
Definition at line 329 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::documentOffset, m_d, recalculateTransformations(), resetPreferredTransformationCenter(), KoZoomHandler::setZoomMode(), snapToDevicePixel(), and KoZoomMode::ZOOM_CONSTANT.
| void KisCoordinatesConverter::setExtraReferencesBounds | ( | const QRect & | imageRect | ) |
Definition at line 269 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::extraReferencesBounds, m_d, and recalculateTransformations().
| void KisCoordinatesConverter::setImage | ( | KisImageWSP | image | ) |
Definition at line 244 of file kis_coordinates_converter.cpp.
References KisImage::bounds(), KisCoordinatesConverter::Private::canvasWidgetSize, KisCoordinatesConverter::Private::imageBounds, KisCoordinatesConverter::Private::imageXRes, KisCoordinatesConverter::Private::imageYRes, m_d, KisCoordinatesConverter::Private::preferredTransformationCenterImage, recalculateTransformations(), recalculateZoomLevelLimits(), KoZoomHandler::resolutionX(), KoZoomHandler::resolutionY(), setZoom(), KoZoomHandler::setZoomMode(), KisImage::xRes(), KisImage::yRes(), and KoZoomMode::ZOOM_PAGE.
| void KisCoordinatesConverter::setImageBounds | ( | const QRect & | rect, |
| const QPointF | oldImageStillPoint, | ||
| const QPointF | newImageStillPoint ) |
Definition at line 279 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::documentOffset, KisCoordinatesConverter::Private::imageBounds, imageToWidget(), m_d, recalculateTransformations(), recalculateZoomLevelLimits(), resetPreferredTransformationCenter(), KoZoomHandler::setZoomMode(), snapToDevicePixel(), and KoZoomMode::ZOOM_CONSTANT.
| void KisCoordinatesConverter::setImageResolution | ( | qreal | xRes, |
| qreal | yRes ) |
Definition at line 300 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::documentOffset, imageCenterInWidgetPixel(), KisCoordinatesConverter::Private::imageXRes, KisCoordinatesConverter::Private::imageYRes, m_d, qFuzzyCompare(), recalculateTransformations(), recalculateZoomLevelLimits(), resetPreferredTransformationCenter(), KoZoomHandler::setZoomMode(), snapToDevicePixel(), and KoZoomMode::ZOOM_CONSTANT.
| void KisCoordinatesConverter::setZoom | ( | KoZoomMode::Mode | mode, |
| qreal | zoom, | ||
| qreal | resolutionX, | ||
| qreal | resolutionY, | ||
| const std::optional< KoViewTransformStillPoint > & | stillPoint ) |
changes the zoom mode of the canvas
When mode is KoZoomMode::ZOOM_CONSTANT, stillPoint instructs the converter to keep the passed point "still", i.e. to make sure that stillPoint.docPoint() maps to stillPoint.widgetPoint() on screen.
Please make sure that there is no guarantee that the still point will map to the passed points exactly! The still point may be offset by at most (0.5 * sqrt(2) / devicePixelRatio()) due to hardware pixel alignment.
This alignment is the reason why we pass both document and view points as a still point, because both values should be kept constant during iterative zoom operations. Otherwise the canvas will drift to the side because of the pixel alignmentl.
If stillPoint is std::nullopt, then the zooming happens over preferredTransformationCenter(), which is basically the center of canvas widget, but with some guards against the drifting.
only constant mode is a subject for clamping, fit-modes are allowed to zoom as much as needed
Definition at line 433 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::canvasWidgetSize, clampZoom(), KoViewTransformStillPoint::docPoint(), KisCoordinatesConverter::Private::documentOffset, documentToWidget(), imageCenterInWidgetPixel(), imageRectInWidgetPixels(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_d, KisCoordinatesConverter::Private::preferredTransformationCenterInDocumentPixels(), qFuzzyCompare(), qFuzzyIsNull(), recalculateTransformations(), recalculateZoomLevelLimits(), resetPreferredTransformationCenter(), KoZoomHandler::resolutionX(), KoZoomHandler::resolutionY(), KoZoomHandler::setResolution(), KoZoomHandler::setZoom(), KoZoomHandler::setZoomMode(), snapToDevicePixel(), KoViewTransformStillPoint::viewPoint(), widgetCenterPoint(), KoZoomHandler::zoom(), KoZoomMode::ZOOM_CONSTANT, KoZoomMode::ZOOM_HEIGHT, KoZoomMode::ZOOM_PAGE, KoZoomMode::ZOOM_WIDTH, and KoZoomHandler::zoomMarginSize().
|
overridevirtual |
Set the zoom level. 1.0 is 100%.
Reimplemented from KoViewConverter.
Definition at line 377 of file kis_coordinates_converter.cpp.
References recalculateTransformations(), resetPreferredTransformationCenter(), KoZoomHandler::setZoom(), KoZoomHandler::setZoomMode(), KoZoomHandler::zoom(), and KoZoomMode::ZOOM_CONSTANT.
| QPointF KisCoordinatesConverter::snapToDevicePixel | ( | const QPointF & | point | ) | const |
Adjust a given pair of coordinates to the nearest device pixel according to the value of devicePixelRatio.
| point | a point in logical pixel space |
Definition at line 897 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::devicePixelRatio, m_d, and KisCoordinatesConverter::Private::rotationIsOrthogonal.
| QSizeF KisCoordinatesConverter::snapWidgetSizeToDevicePixel | ( | const QSizeF & | size | ) | const |
Definition at line 407 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::devicePixelRatio, m_d, and qFuzzyCompare().
| QVector< qreal > KisCoordinatesConverter::standardZoomLevels | ( | ) | const |
Definition at line 932 of file kis_coordinates_converter.cpp.
References m_d, and KisCoordinatesConverter::Private::standardZoomLevels.
| QSize KisCoordinatesConverter::viewportDevicePixelSize | ( | ) | const |
Definition at line 424 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::canvasWidgetSize, KisCoordinatesConverter::Private::devicePixelRatio, m_d, and qFuzzyCompare().
|
inline |
Definition at line 159 of file kis_coordinates_converter.h.
References _Private::Traits< T >::map().
|
inline |
Definition at line 169 of file kis_coordinates_converter.h.
References _Private::Traits< T >::map().
| QTransform KisCoordinatesConverter::viewportToWidgetTransform | ( | ) | const |
Definition at line 750 of file kis_coordinates_converter.cpp.
References m_d, and KisCoordinatesConverter::Private::widgetToViewport.
|
overridevirtual |
Reimplemented from KoViewConverter.
Definition at line 909 of file kis_coordinates_converter.cpp.
References flakeToWidgetTransform().
| QPointF KisCoordinatesConverter::widgetCenterPoint | ( | ) | const |
Definition at line 862 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::canvasWidgetSize, and m_d.
| QRectF KisCoordinatesConverter::widgetRectInFlakePixels | ( | ) | const |
Definition at line 845 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::canvasWidgetSize, m_d, and widgetToFlake().
| QRectF KisCoordinatesConverter::widgetRectInImagePixels | ( | ) | const |
Definition at line 850 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::canvasWidgetSize, m_d, and widgetToImage().
|
inline |
Definition at line 174 of file kis_coordinates_converter.h.
References _Private::Traits< T >::map().
|
inline |
Definition at line 164 of file kis_coordinates_converter.h.
References _Private::Traits< T >::map().
|
inline |
Definition at line 189 of file kis_coordinates_converter.h.
References _Private::Traits< T >::map().
|
overridevirtual |
Reimplemented from KoViewConverter.
Definition at line 914 of file kis_coordinates_converter.cpp.
References flakeToWidgetTransform().
|
inline |
Definition at line 167 of file kis_coordinates_converter.h.
References _Private::Traits< T >::map().
| bool KisCoordinatesConverter::xAxisMirrored | ( | ) | const |
Definition at line 694 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::isXAxisMirrored, and m_d.
| bool KisCoordinatesConverter::yAxisMirrored | ( | ) | const |
Definition at line 699 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::isYAxisMirrored, and m_d.
| void KisCoordinatesConverter::zoomTo | ( | const QRectF & | widgetRect | ) |
Definition at line 513 of file kis_coordinates_converter.cpp.
References KisCoordinatesConverter::Private::canvasWidgetSize, KisCoordinatesConverter::Private::documentOffset, imageToWidget(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_d, recalculateTransformations(), resetPreferredTransformationCenter(), KoZoomHandler::setZoom(), KoZoomHandler::setZoomMode(), snapToDevicePixel(), widgetCenterPoint(), widgetToImage(), KoZoomHandler::zoom(), and KoZoomMode::ZOOM_CONSTANT.
|
friend |
Definition at line 250 of file kis_coordinates_converter.h.
|
friend |
Definition at line 249 of file kis_coordinates_converter.h.
|
private |
Definition at line 262 of file kis_coordinates_converter.h.