QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 <QQueue>
21 
22 #include "qgis_core.h"
23 #include "qgspointlocator.h"
24 
25 
26 class QgsSnappingUtils;
27 
34 class CORE_EXPORT QgsCadUtils
35 {
36  public:
37 
44  {
45  public:
46 
50  AlignMapPointConstraint( bool locked = false, bool relative = false, double value = 0 )
51  : locked( locked )
52  , relative( relative )
53  , value( value )
54  {}
55 
57  bool locked;
59  bool relative;
61  double value;
62  };
63 
70  {
71  public:
73  bool valid;
74 
77 
83 
89 
92 
94  double softLockX;
95  double softLockY;
96  };
97 
104  {
105  public:
107  QgsSnappingUtils *snappingUtils = nullptr;
110 
115 
121 
133 
136 
141  SIP_SKIP void dump() const;
142 
152  QList< QgsPoint > cadPoints() const { return mCadPointList; } ;
153 
160  void setCadPoints( const QList< QgsPoint > &points ) { mCadPointList = points; };
161 
168  void setCadPoint( int index, const QgsPoint &point ) { mCadPointList[index] = point; };
169 
176  QgsPoint cadPoint( int index ) const { return mCadPointList[index]; };
177 
186  void setLockedSnapVertices( const QQueue< QgsPointLocator::Match > &lockedSnapVertices ) { mLockedSnapVertices = lockedSnapVertices; } SIP_SKIP;
187 
194  QQueue< QgsPointLocator::Match > lockedSnapVertices() const { return mLockedSnapVertices; } SIP_SKIP;
195 
196 
197 #ifdef SIP_RUN
198  SIP_PROPERTY( name = cadPointList, get = _cadPointList, set = _setCadPointList )
199 #endif
200  void _setCadPointList( const QList< QgsPointXY > &list ) { mCadPointList.clear(); for ( const auto &pointxy : list ) { mCadPointList.append( QgsPoint( pointxy ) );} }
202  QList< QgsPointXY > _cadPointList() const { QList< QgsPointXY> list; for ( const auto &point : mCadPointList ) { list.append( QgsPointXY( point.x(), point.y() ) ); }; return list; }
204 
205  private:
206 
212  QList<QgsPoint> mCadPointList;
213  QQueue< QgsPointLocator::Match > mLockedSnapVertices;
214 
215  };
216 
222  static QgsCadUtils::AlignMapPointOutput alignMapPoint( const QgsPointXY &originalMapPoint, const QgsCadUtils::AlignMapPointContext &ctx );
223 
224 };
225 
226 #endif // QGSCADUTILS_H
QgsCadUtils::AlignMapPointContext::cadPoints
QList< QgsPoint > cadPoints() const
Returns the list of recent CAD points in map coordinates.
Definition: qgscadutils.h:152
QgsCadUtils::AlignMapPointContext::xyVertexConstraint
QgsCadUtils::AlignMapPointConstraint xyVertexConstraint
Definition: qgscadutils.h:135
QgsCadUtils::AlignMapPointContext::lockedSnapVertices
QQueue< QgsPointLocator::Match > lockedSnapVertices() const
Returns the queue of point locator matches that contain the locked vertices.
Definition: qgscadutils.h:194
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:48
QgsCadUtils::AlignMapPointOutput::edgeMatch
QgsPointLocator::Match edgeMatch
Snapped segment - only valid if actually used for something.
Definition: qgscadutils.h:88
QgsCadUtils::AlignMapPointContext::commonAngleConstraint
QgsCadUtils::AlignMapPointConstraint commonAngleConstraint
Constraint for soft lock to a common angle.
Definition: qgscadutils.h:132
QgsCadUtils
The QgsCadUtils class provides routines for CAD editing.
Definition: qgscadutils.h:34
QgsCadUtils::AlignMapPointContext::xConstraint
QgsCadUtils::AlignMapPointConstraint xConstraint
Constraint for X coordinate.
Definition: qgscadutils.h:112
QgsCadUtils::AlignMapPointContext::lineExtensionConstraint
QgsCadUtils::AlignMapPointConstraint lineExtensionConstraint
Definition: qgscadutils.h:134
QgsCadUtils::AlignMapPointConstraint
Structure with details of one constraint.
Definition: qgscadutils.h:43
QgsCadUtils::AlignMapPointConstraint::locked
bool locked
Whether the constraint is active, i.e. should be considered.
Definition: qgscadutils.h:57
Qgis::LineExtensionSide
LineExtensionSide
Designates whether the line extension constraint is currently soft locked with the previous or next v...
Definition: qgis.h:1795
QgsCadUtils::AlignMapPointOutput::finalMapPoint
QgsPointXY finalMapPoint
map point aligned according to the constraints
Definition: qgscadutils.h:76
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsCadUtils::AlignMapPointOutput::snapMatch
QgsPointLocator::Match snapMatch
Snapped point - only valid if actually used for something.
Definition: qgscadutils.h:82
QgsCadUtils::AlignMapPointConstraint::AlignMapPointConstraint
AlignMapPointConstraint(bool locked=false, bool relative=false, double value=0)
Constructor for AlignMapPointConstraint.
Definition: qgscadutils.h:50
QgsCadUtils::AlignMapPointContext::setLockedSnapVertices
void setLockedSnapVertices(const QQueue< QgsPointLocator::Match > &lockedSnapVertices)
Sets the queue of locked vertices.
Definition: qgscadutils.h:186
QgsCadUtils::AlignMapPointConstraint::value
double value
Numeric value of the constraint (coordinate/distance in map units or angle in degrees)
Definition: qgscadutils.h:61
QgsCadUtils::AlignMapPointContext::distanceConstraint
QgsCadUtils::AlignMapPointConstraint distanceConstraint
Constraint for distance.
Definition: qgscadutils.h:128
QgsCadUtils::AlignMapPointContext::mapUnitsPerPixel
double mapUnitsPerPixel
Map units/pixel ratio from map canvas.
Definition: qgscadutils.h:109
QgsSnappingUtils
This class has all the configuration of snapping and can return answers to snapping queries.
Definition: qgssnappingutils.h:50
QgsCadUtils::AlignMapPointOutput::softLockLineExtension
Qgis::LineExtensionSide softLockLineExtension
Definition: qgscadutils.h:93
QgsCadUtils::AlignMapPointContext
Defines constraints for the QgsCadUtils::alignMapPoint() method.
Definition: qgscadutils.h:103
QgsPointLocator::Match
Definition: qgspointlocator.h:187
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:58
QgsCadUtils::AlignMapPointOutput::softLockCommonAngle
double softLockCommonAngle
Angle (in degrees) to which we have soft-locked ourselves (if not set it is -1)
Definition: qgscadutils.h:91
QgsCadUtils::AlignMapPointOutput::valid
bool valid
Whether the combination of constraints is actually valid.
Definition: qgscadutils.h:73
QgsCadUtils::AlignMapPointOutput::softLockY
double softLockY
Definition: qgscadutils.h:95
QgsCadUtils::AlignMapPointContext::setCadPoints
void setCadPoints(const QList< QgsPoint > &points)
Sets the list of recent CAD points (in map coordinates).
Definition: qgscadutils.h:160
QgsCadUtils::AlignMapPointContext::setCadPoint
void setCadPoint(int index, const QgsPoint &point)
Sets the recent CAD point at the specified index to point (in map coordinates).
Definition: qgscadutils.h:168
SIP_PROPERTY
#define SIP_PROPERTY(name, getter, setter)
Definition: qgis_sip.h:273
qgspointlocator.h
QgsCadUtils::AlignMapPointContext::mConstraint
QgsCadUtils::AlignMapPointConstraint mConstraint
Constraint for M coordinate.
Definition: qgscadutils.h:126
QgsCadUtils::AlignMapPointOutput::softLockX
double softLockX
Definition: qgscadutils.h:94
QgsCadUtils::AlignMapPointContext::zConstraint
QgsCadUtils::AlignMapPointConstraint zConstraint
Constraint for Z coordinate.
Definition: qgscadutils.h:120
QgsCadUtils::AlignMapPointContext::yConstraint
QgsCadUtils::AlignMapPointConstraint yConstraint
Constraint for Y coordinate.
Definition: qgscadutils.h:114
QgsCadUtils::AlignMapPointOutput
Structure returned from alignMapPoint() method.
Definition: qgscadutils.h:69
QgsCadUtils::AlignMapPointConstraint::relative
bool relative
Whether the value is relative to previous value.
Definition: qgscadutils.h:59
QgsCadUtils::AlignMapPointContext::cadPoint
QgsPoint cadPoint(int index) const
Returns the recent CAD point at the specified index (in map coordinates).
Definition: qgscadutils.h:176
QgsCadUtils::AlignMapPointContext::angleConstraint
QgsCadUtils::AlignMapPointConstraint angleConstraint
Constraint for angle.
Definition: qgscadutils.h:130