16#ifndef QGSLAYOUTSNAPPER_H
17#define QGSLAYOUTSNAPPER_H
45 QString
stringType()
const override {
return QStringLiteral(
"LayoutSnapper" ); }
52 void setSnapTolerance(
int snapTolerance );
70 void setSnapToGrid(
bool enabled );
82 void setSnapToGuides(
bool enabled );
94 void setSnapToItems(
bool enabled );
112 QPointF snapPoint( QPointF point,
double scaleFactor,
bool &snapped
SIP_OUT, QGraphicsLineItem *horizontalSnapLine =
nullptr,
113 QGraphicsLineItem *verticalSnapLine =
nullptr,
114 const QList< QgsLayoutItem * > *ignoreItems =
nullptr )
const;
135 QRectF snapRect(
const QRectF &rect,
double scaleFactor,
bool &snapped
SIP_OUT, QGraphicsLineItem *horizontalSnapLine =
nullptr,
136 QGraphicsLineItem *verticalSnapLine =
nullptr,
137 const QList< QgsLayoutItem * > *ignoreItems =
nullptr )
const;
153 QPointF snapPointToGrid( QPointF point,
double scaleFactor,
bool &snappedX
SIP_OUT,
bool &snappedY
SIP_OUT )
const;
170 QPointF snapPointsToGrid(
const QList< QPointF > &points,
double scaleFactor,
bool &snappedX
SIP_OUT,
bool &snappedY
SIP_OUT )
const;
185 double snapPointToGuides(
double original, Qt::Orientation orientation,
double scaleFactor,
bool &snapped
SIP_OUT )
const;
202 double snapPointsToGuides(
const QList< double > &points, Qt::Orientation orientation,
double scaleFactor,
bool &snapped
SIP_OUT )
const;
222 double snapPointToItems(
double original, Qt::Orientation orientation,
double scaleFactor,
const QList< QgsLayoutItem * > &ignoreItems,
bool &snapped
SIP_OUT,
223 QGraphicsLineItem *snapLine =
nullptr )
const;
240 double snapPointsToItems(
const QList< double > &points, Qt::Orientation orientation,
double scaleFactor,
const QList< QgsLayoutItem * > &ignoreItems,
bool &snapped
SIP_OUT,
241 QGraphicsLineItem *snapLine =
nullptr )
const;
268 bool mSnapToGrid =
false;
269 bool mSnapToGuides =
true;
270 bool mSnapToItems =
true;
272 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.