QGIS API Documentation 3.41.0-Master (57ec4277f5e)
Loading...
Searching...
No Matches
qgsmodelsnapper.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmodelsnapper.h
3 -------------------
4 begin : March 2020
5 copyright : (C) 2020 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16#ifndef QGSMODELSNAPPER_H
17#define QGSMODELSNAPPER_H
18
19#include "qgis_gui.h"
20#include "qgis_sip.h"
21#include <QPen>
22
23
24#define SIP_NO_FILE
25
33class GUI_EXPORT QgsModelSnapper
34{
35 public:
40
45 void setSnapTolerance( int snapTolerance );
46
51 int snapTolerance() const { return mTolerance; }
52
57 bool snapToGrid() const { return mSnapToGrid; }
58
63 void setSnapToGrid( bool enabled );
64
81 QPointF snapPoint( QPointF point, double scaleFactor, bool &snapped SIP_OUT, bool snapHorizontal = true, bool snapVertical = true ) const;
82
102 QRectF snapRect( const QRectF &rect, double scaleFactor, bool &snapped SIP_OUT, bool snapHorizontal = true, bool snapVertical = true ) const;
103
120 QRectF snapRectWithResize( const QRectF &rect, double scaleFactor, bool &snapped SIP_OUT, bool snapHorizontal = true, bool snapVertical = true ) const;
121
136 QPointF snapPointToGrid( QPointF point, double scaleFactor, bool &snappedX SIP_OUT, bool &snappedY SIP_OUT ) const;
137
153 QPointF snapPointsToGrid( const QList<QPointF> &points, double scaleFactor, bool &snappedX SIP_OUT, bool &snappedY SIP_OUT ) const;
154
155 private:
156 int mTolerance = 5;
157 bool mSnapToGrid = false;
158};
159
160#endif //QGSMODELSNAPPER_H
Manages snapping grids and preset snap lines in a layout, and handles snapping points to the nearest ...
int snapTolerance() const
Returns the snap tolerance (in pixels) to use when snapping.
bool snapToGrid() const
Returns true if snapping to grid is enabled.
#define SIP_OUT
Definition qgis_sip.h:58