QGIS API Documentation 3.41.0-Master (45a0abf3bec)
|
Manages snapping grids and preset snap lines in a layout, and handles snapping points to the nearest grid coordinate/snap line when possible. More...
#include <qgsmodelsnapper.h>
Public Member Functions | |
QgsModelSnapper () | |
Constructor for QgsModelSnapper, attached to the specified layout. | |
void | setSnapToGrid (bool enabled) |
Sets whether snapping to grid is enabled. | |
void | setSnapTolerance (int snapTolerance) |
Sets the snap tolerance (in pixels) to use when snapping. | |
QPointF | snapPoint (QPointF point, double scaleFactor, bool &snapped, bool snapHorizontal=true, bool snapVertical=true) const |
Snaps a layout coordinate point. | |
QPointF | snapPointsToGrid (const QList< QPointF > &points, double scaleFactor, bool &snappedX, bool &snappedY) const |
Snaps a set of points to the grid. | |
QPointF | snapPointToGrid (QPointF point, double scaleFactor, bool &snappedX, bool &snappedY) const |
Snaps a layout coordinate point to the grid. | |
QRectF | snapRect (const QRectF &rect, double scaleFactor, bool &snapped, bool snapHorizontal=true, bool snapVertical=true) const |
Snaps a layout coordinate rect. | |
QRectF | snapRectWithResize (const QRectF &rect, double scaleFactor, bool &snapped, bool snapHorizontal=true, bool snapVertical=true) const |
Snaps a layout coordinate rect. | |
bool | snapToGrid () const |
Returns true if snapping to grid is enabled. | |
int | snapTolerance () const |
Returns the snap tolerance (in pixels) to use when snapping. | |
Manages snapping grids and preset snap lines in a layout, and handles snapping points to the nearest grid coordinate/snap line when possible.
Definition at line 33 of file qgsmodelsnapper.h.
QgsModelSnapper::QgsModelSnapper | ( | ) |
Constructor for QgsModelSnapper, attached to the specified layout.
Definition at line 21 of file qgsmodelsnapper.cpp.
void QgsModelSnapper::setSnapToGrid | ( | bool | enabled | ) |
Sets whether snapping to grid is enabled.
Definition at line 32 of file qgsmodelsnapper.cpp.
void QgsModelSnapper::setSnapTolerance | ( | int | snapTolerance | ) |
Sets the snap tolerance (in pixels) to use when snapping.
Definition at line 27 of file qgsmodelsnapper.cpp.
QPointF QgsModelSnapper::snapPoint | ( | QPointF | point, |
double | scaleFactor, | ||
bool & | snapped, | ||
bool | snapHorizontal = true , |
||
bool | snapVertical = true |
||
) | const |
Snaps a layout coordinate point.
If point was snapped, snapped will be set to true
.
The scaleFactor argument should be set to the transformation from scalar transform from layout coordinates to pixels, i.e. the graphics view transform().m11() value.
This method considers snapping to the grid, snap lines, etc.
If the horizontalSnapLine and verticalSnapLine arguments are specified, then the snapper will automatically display and position these lines to indicate snapping positions to item bounds.
A list of items to ignore during the snapping can be specified via the ignoreItems list.
Definition at line 37 of file qgsmodelsnapper.cpp.
QPointF QgsModelSnapper::snapPointsToGrid | ( | const QList< QPointF > & | points, |
double | scaleFactor, | ||
bool & | snappedX, | ||
bool & | snappedY | ||
) | const |
Snaps a set of points to the grid.
If the points were snapped, snapped will be set to true
.
The scaleFactor argument should be set to the transformation from scalar transform from layout coordinates to pixels, i.e. the graphics view transform().m11() value.
If snapToGrid() is disabled, this method will not attempt to snap the points.
The returned value is the smallest delta which the points need to be shifted by in order to align one of the points to the grid.
Definition at line 121 of file qgsmodelsnapper.cpp.
QPointF QgsModelSnapper::snapPointToGrid | ( | QPointF | point, |
double | scaleFactor, | ||
bool & | snappedX, | ||
bool & | snappedY | ||
) | const |
Snaps a layout coordinate point to the grid.
If point was snapped horizontally, snappedX will be set to true
. If point was snapped vertically, snappedY will be set to true
.
The scaleFactor argument should be set to the transformation from scalar transform from layout coordinates to pixels, i.e. the graphics view transform().m11() value.
If snapToGrid() is disabled, this method will return the point unchanged.
Definition at line 115 of file qgsmodelsnapper.cpp.
QRectF QgsModelSnapper::snapRect | ( | const QRectF & | rect, |
double | scaleFactor, | ||
bool & | snapped, | ||
bool | snapHorizontal = true , |
||
bool | snapVertical = true |
||
) | const |
Snaps a layout coordinate rect.
If rect was snapped, snapped will be set to true
.
Snapping occurs by moving the rectangle alone. The rectangle will not be resized as a result of the snap operation.
The scaleFactor argument should be set to the transformation from scalar transform from layout coordinates to pixels, i.e. the graphics view transform().m11() value.
This method considers snapping to the grid, snap lines, etc.
If the horizontalSnapLine and verticalSnapLine arguments are specified, then the snapper will automatically display and position these lines to indicate snapping positions to item bounds.
A list of items to ignore during the snapping can be specified via the ignoreItems list.
Definition at line 58 of file qgsmodelsnapper.cpp.
QRectF QgsModelSnapper::snapRectWithResize | ( | const QRectF & | rect, |
double | scaleFactor, | ||
bool & | snapped, | ||
bool | snapHorizontal = true , |
||
bool | snapVertical = true |
||
) | const |
Snaps a layout coordinate rect.
If rect was snapped, snapped will be set to true
.
The scaleFactor argument should be set to the transformation from scalar transform from layout coordinates to pixels, i.e. the graphics view transform().m11() value.
This method considers snapping to the grid, snap lines, etc.
If the horizontalSnapLine and verticalSnapLine arguments are specified, then the snapper will automatically display and position these lines to indicate snapping positions to item bounds.
A list of items to ignore during the snapping can be specified via the ignoreItems list.
Definition at line 82 of file qgsmodelsnapper.cpp.
|
inline |
Returns true
if snapping to grid is enabled.
Definition at line 59 of file qgsmodelsnapper.h.
|
inline |
Returns the snap tolerance (in pixels) to use when snapping.
Definition at line 53 of file qgsmodelsnapper.h.