QGIS API Documentation  3.23.0-Master (dd0cd13a00)
qgscadutils.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscadutils.h
3  -------------------
4  begin : September 2017
5  copyright : (C) 2017 by Martin Dobias
6  email : wonder dot sk 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 
17 #ifndef QGSCADUTILS_H
18 #define QGSCADUTILS_H
19 
20 #include "qgis_core.h"
21 
22 #include "qgspointlocator.h"
23 
24 class QgsSnappingUtils;
25 
32 class CORE_EXPORT QgsCadUtils
33 {
34  public:
35 
42  {
43  public:
44 
48  AlignMapPointConstraint( bool locked = false, bool relative = false, double value = 0 )
49  : locked( locked )
50  , relative( relative )
51  , value( value )
52  {}
53 
55  bool locked;
57  bool relative;
59  double value;
60  };
61 
68  {
69  public:
70 
72  bool valid;
73 
76 
82 
88 
91  };
92 
99  {
100  public:
102  QgsSnappingUtils *snappingUtils = nullptr;
105 
110 
116 
128 
133  SIP_SKIP void dump() const;
134 
144  QList< QgsPoint > cadPoints() const { return mCadPointList; } ;
145 
152  void setCadPoints( const QList< QgsPoint> &points ) { mCadPointList = points; };
153 
160  void setCadPoint( int index, const QgsPoint &point ) { mCadPointList[index] = point; };
161 
168  QgsPoint cadPoint( int index ) const { return mCadPointList[index]; };
169 
170 
171 #ifdef SIP_RUN
172  SIP_PROPERTY( name = cadPointList, get = _cadPointList, set = _setCadPointList )
173 #endif
175  void _setCadPointList( const QList< QgsPointXY > &list ) { mCadPointList.clear(); for ( const auto &pointxy : list ) { mCadPointList.append( QgsPoint( pointxy ) );} }
176  QList< QgsPointXY > _cadPointList() const { QList< QgsPointXY> list; for ( const auto &point : mCadPointList ) { list.append( QgsPointXY( point.x(), point.y() ) ); }; return list; }
178 
179  private:
180 
186  QList<QgsPoint> mCadPointList;
187 
188  };
189 
195  static QgsCadUtils::AlignMapPointOutput alignMapPoint( const QgsPointXY &originalMapPoint, const QgsCadUtils::AlignMapPointContext &ctx );
196 
197 };
198 
199 #endif // QGSCADUTILS_H
Structure with details of one constraint.
Definition: qgscadutils.h:42
AlignMapPointConstraint(bool locked=false, bool relative=false, double value=0)
Constructor for AlignMapPointConstraint.
Definition: qgscadutils.h:48
bool locked
Whether the constraint is active, i.e. should be considered.
Definition: qgscadutils.h:55
double value
Numeric value of the constraint (coordinate/distance in map units or angle in degrees)
Definition: qgscadutils.h:59
bool relative
Whether the value is relative to previous value.
Definition: qgscadutils.h:57
Defines constraints for the QgsCadUtils::alignMapPoint() method.
Definition: qgscadutils.h:99
QgsCadUtils::AlignMapPointConstraint yConstraint
Constraint for Y coordinate.
Definition: qgscadutils.h:109
QgsCadUtils::AlignMapPointConstraint xConstraint
Constraint for X coordinate.
Definition: qgscadutils.h:107
double mapUnitsPerPixel
Map units/pixel ratio from map canvas.
Definition: qgscadutils.h:104
void setCadPoints(const QList< QgsPoint > &points)
Sets the list of recent CAD points (in map coordinates).
Definition: qgscadutils.h:152
QgsCadUtils::AlignMapPointConstraint mConstraint
Constraint for M coordinate.
Definition: qgscadutils.h:121
QgsPoint cadPoint(int index) const
Returns the recent CAD point at the specified index (in map coordinates).
Definition: qgscadutils.h:168
void setCadPoint(int index, const QgsPoint &point)
Sets the recent CAD point at the specified index to point (in map coordinates).
Definition: qgscadutils.h:160
QgsCadUtils::AlignMapPointConstraint distanceConstraint
Constraint for distance.
Definition: qgscadutils.h:123
QgsCadUtils::AlignMapPointConstraint zConstraint
Constraint for Z coordinate.
Definition: qgscadutils.h:115
QgsCadUtils::AlignMapPointConstraint commonAngleConstraint
Constraint for soft lock to a common angle.
Definition: qgscadutils.h:127
QList< QgsPoint > cadPoints() const
Returns the list of recent CAD points in map coordinates.
Definition: qgscadutils.h:144
QgsCadUtils::AlignMapPointConstraint angleConstraint
Constraint for angle.
Definition: qgscadutils.h:125
Structure returned from alignMapPoint() method.
Definition: qgscadutils.h:68
QgsPointXY finalMapPoint
map point aligned according to the constraints
Definition: qgscadutils.h:75
bool valid
Whether the combination of constraints is actually valid.
Definition: qgscadutils.h:72
QgsPointLocator::Match snapMatch
Snapped point - only valid if actually used for something.
Definition: qgscadutils.h:81
QgsPointLocator::Match edgeMatch
Snapped segment - only valid if actually used for something.
Definition: qgscadutils.h:87
double softLockCommonAngle
Angle (in degrees) to which we have soft-locked ourselves (if not set it is -1)
Definition: qgscadutils.h:90
The QgsCadUtils class provides routines for CAD editing.
Definition: qgscadutils.h:33
A class to represent a 2D point.
Definition: qgspointxy.h:59
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:49
This class has all the configuration of snapping and can return answers to snapping queries.
#define SIP_PROPERTY(name, getter, setter)
Definition: qgis_sip.h:264
#define SIP_SKIP
Definition: qgis_sip.h:126