QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
33 class GUI_EXPORT QgsModelSnapper
34 {
35 
36  public:
37 
42 
47  void setSnapTolerance( int snapTolerance );
48 
53  int snapTolerance() const { return mTolerance; }
54 
59  bool snapToGrid() const { return mSnapToGrid; }
60 
65  void setSnapToGrid( bool enabled );
66 
83  QPointF snapPoint( QPointF point, double scaleFactor, bool &snapped SIP_OUT, bool snapHorizontal = true, bool snapVertical = true ) const;
84 
104  QRectF snapRect( const QRectF &rect, double scaleFactor, bool &snapped SIP_OUT, bool snapHorizontal = true, bool snapVertical = true ) const;
105 
122  QRectF snapRectWithResize( const QRectF &rect, double scaleFactor, bool &snapped SIP_OUT, bool snapHorizontal = true, bool snapVertical = true ) const;
123 
138  QPointF snapPointToGrid( QPointF point, double scaleFactor, bool &snappedX SIP_OUT, bool &snappedY SIP_OUT ) const;
139 
155  QPointF snapPointsToGrid( const QList< QPointF > &points, double scaleFactor, bool &snappedX SIP_OUT, bool &snappedY SIP_OUT ) const;
156 
157  private:
158 
159  int mTolerance = 5;
160  bool mSnapToGrid = false;
161 
162 };
163 
164 #endif //QGSMODELSNAPPER_H
QgsModelSnapper::snapTolerance
int snapTolerance() const
Returns the snap tolerance (in pixels) to use when snapping.
Definition: qgsmodelsnapper.h:53
SIP_OUT
#define SIP_OUT
Definition: qgis_sip.h:58
QgsModelSnapper::snapToGrid
bool snapToGrid() const
Returns true if snapping to grid is enabled.
Definition: qgsmodelsnapper.h:59
QgsModelSnapper
Manages snapping grids and preset snap lines in a layout, and handles snapping points to the nearest ...
Definition: qgsmodelsnapper.h:33
qgis_sip.h