16 #ifndef QGSLAYOUTSNAPPER_H
17 #define QGSLAYOUTSNAPPER_H
19 #include "qgis_core.h"
46 QString
stringType()
const override {
return QStringLiteral(
"LayoutSnapper" ); }
53 void setSnapTolerance(
int snapTolerance );
71 void setSnapToGrid(
bool enabled );
83 void setSnapToGuides(
bool enabled );
95 void setSnapToItems(
bool enabled );
113 QPointF snapPoint( QPointF point,
double scaleFactor,
bool &snapped
SIP_OUT, QGraphicsLineItem *horizontalSnapLine =
nullptr,
114 QGraphicsLineItem *verticalSnapLine =
nullptr,
115 const QList< QgsLayoutItem * > *ignoreItems =
nullptr )
const;
136 QRectF snapRect(
const QRectF &rect,
double scaleFactor,
bool &snapped
SIP_OUT, QGraphicsLineItem *horizontalSnapLine =
nullptr,
137 QGraphicsLineItem *verticalSnapLine =
nullptr,
138 const QList< QgsLayoutItem * > *ignoreItems =
nullptr )
const;
154 QPointF snapPointToGrid( QPointF point,
double scaleFactor,
bool &snappedX
SIP_OUT,
bool &snappedY
SIP_OUT )
const;
171 QPointF snapPointsToGrid(
const QList< QPointF > &points,
double scaleFactor,
bool &snappedX
SIP_OUT,
bool &snappedY
SIP_OUT )
const;
186 double snapPointToGuides(
double original, Qt::Orientation orientation,
double scaleFactor,
bool &snapped
SIP_OUT )
const;
203 double snapPointsToGuides(
const QList< double > &points, Qt::Orientation orientation,
double scaleFactor,
bool &snapped
SIP_OUT )
const;
223 double snapPointToItems(
double original, Qt::Orientation orientation,
double scaleFactor,
const QList< QgsLayoutItem * > &ignoreItems,
bool &snapped
SIP_OUT,
224 QGraphicsLineItem *snapLine =
nullptr )
const;
241 double snapPointsToItems(
const QList< double > &points, Qt::Orientation orientation,
double scaleFactor,
const QList< QgsLayoutItem * > &ignoreItems,
bool &snapped
SIP_OUT,
242 QGraphicsLineItem *snapLine =
nullptr )
const;
269 bool mSnapToGrid =
false;
270 bool mSnapToGuides =
true;
271 bool mSnapToItems =
true;
273 friend class QgsLayoutSnapperUndoCommand;
An interface for layout objects which can be stored and read from DOM elements.
virtual bool writeXml(QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context) const =0
Stores the objects's state in a DOM element.
virtual bool readXml(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context)=0
Sets the objects's state from a DOM element.
virtual QgsLayout * layout()=0
Returns the layout the object belongs to.
Manages snapping grids and preset snap lines in a layout, and handles snapping points to the nearest ...
QString stringType() const override
Returns the object type as a string.
bool snapToItems() const
Returns true if snapping to items is enabled.
int snapTolerance() const
Returns the snap tolerance (in pixels) to use when snapping.
bool snapToGrid() const
Returns true if snapping to grid is enabled.
bool snapToGuides() const
Returns true if snapping to guides is enabled.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
The class is used as a container of context for various read/write operations on other objects.