QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
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#include "qgspointlocator.h"
22
23#include <QQueue>
24
26
32class CORE_EXPORT QgsCadUtils
33{
34 public:
40 {
41 public:
45 AlignMapPointConstraint( bool locked = false, bool relative = false, double value = 0 )
46 : locked( locked )
48 , value( value )
49 {}
50
52 bool locked;
56 double value;
57 };
58
91
97 {
98 public:
103
108
114
126
129
135
140 SIP_SKIP void dump() const;
141
151 QList< QgsPoint > cadPoints() const { return mCadPointList; };
152
159 void setCadPoints( const QList< QgsPoint > &points ) { mCadPointList = points; };
160
167 void setCadPoint( int index, const QgsPoint &point ) { mCadPointList[index] = point; };
168
175 QgsPoint cadPoint( int index ) const { return mCadPointList[index]; };
176
185 void setLockedSnapVertices( const QQueue< QgsPointLocator::Match > &lockedSnapVertices ) { mLockedSnapVertices = lockedSnapVertices; }
186 SIP_SKIP;
187
194 QQueue< QgsPointLocator::Match > lockedSnapVertices() const { return mLockedSnapVertices; }
195 SIP_SKIP;
196
197#ifdef SIP_RUN
198 SIP_PROPERTY( name = cadPointList, get = _cadPointList, set = _setCadPointList )
199#endif
201 void _setCadPointList( const QList< QgsPointXY > &list )
202 {
203 mCadPointList.clear();
204 for ( const auto &pointxy : list )
205 {
206 mCadPointList.append( QgsPoint( pointxy ) );
207 }
208 }
209 QList< QgsPointXY > _cadPointList() const
210 {
211 QList< QgsPointXY> list;
212 for ( const auto &point : mCadPointList )
213 {
214 list.append( QgsPointXY( point.x(), point.y() ) );
215 };
216 return list;
217 }
219
220 private:
226 QList<QgsPoint> mCadPointList;
227 QQueue< QgsPointLocator::Match > mLockedSnapVertices;
228 };
229
235 static QgsCadUtils::AlignMapPointOutput alignMapPoint( const QgsPointXY &originalMapPoint, const QgsCadUtils::AlignMapPointContext &ctx );
236};
237
238#endif // QGSCADUTILS_H
LineExtensionSide
Designates whether the line extension constraint is currently soft locked with the previous or next v...
Definition qgis.h:4178
Structure with details of one constraint.
Definition qgscadutils.h:40
AlignMapPointConstraint(bool locked=false, bool relative=false, double value=0)
Constructor for AlignMapPointConstraint.
Definition qgscadutils.h:45
bool locked
Whether the constraint is active, i.e. should be considered.
Definition qgscadutils.h:52
double value
Numeric value of the constraint (coordinate/distance in map units or angle in degrees).
Definition qgscadutils.h:56
bool relative
Whether the value is relative to previous value.
Definition qgscadutils.h:54
Defines constraints for the QgsCadUtils::alignMapPoint() method.
Definition qgscadutils.h:97
QgsCadUtils::AlignMapPointConstraint xyVertexConstraint
QgsCadUtils::AlignMapPointConstraint yConstraint
Constraint for Y coordinate.
QgsCadUtils::AlignMapPointConstraint xConstraint
Constraint for X coordinate.
double mapUnitsPerPixel
Map units/pixel ratio from map canvas.
void setCadPoints(const QList< QgsPoint > &points)
Sets the list of recent CAD points (in map coordinates).
void setLockedSnapVertices(const QQueue< QgsPointLocator::Match > &lockedSnapVertices)
Sets the queue of locked vertices.
QgsCadUtils::AlignMapPointConstraint mConstraint
Constraint for M coordinate.
QgsPoint cadPoint(int index) const
Returns the recent CAD point at the specified index (in map coordinates).
void setCadPoint(int index, const QgsPoint &point)
Sets the recent CAD point at the specified index to point (in map coordinates).
QgsCadUtils::AlignMapPointConstraint distanceConstraint
Constraint for distance.
bool snappingToFeaturesOverridesCommonAngle
Flag to set snapping to features priority over common angle.
QgsCadUtils::AlignMapPointConstraint zConstraint
Constraint for Z coordinate.
QgsSnappingUtils * snappingUtils
Snapping utils that will be used to snap point to map. Must not be nullptr.
QgsCadUtils::AlignMapPointConstraint commonAngleConstraint
Constraint for soft lock to a common angle.
QQueue< QgsPointLocator::Match > lockedSnapVertices() const
Returns the queue of point locator matches that contain the locked vertices.
QgsCadUtils::AlignMapPointConstraint lineExtensionConstraint
QList< QgsPoint > cadPoints() const
Returns the list of recent CAD points in map coordinates.
void dump() const
Dumps the context's properties, for debugging.
QgsCadUtils::AlignMapPointConstraint angleConstraint
Constraint for angle.
Structure returned from alignMapPoint() method.
Definition qgscadutils.h:64
Qgis::LineExtensionSide softLockLineExtension
Definition qgscadutils.h:87
QgsPointXY finalMapPoint
map point aligned according to the constraints
Definition qgscadutils.h:70
bool valid
Whether the combination of constraints is actually valid.
Definition qgscadutils.h:67
QgsPointLocator::Match snapMatch
Snapped point - only valid if actually used for something.
Definition qgscadutils.h:76
QgsPointLocator::Match edgeMatch
Snapped segment - only valid if actually used for something.
Definition qgscadutils.h:82
double softLockCommonAngle
Angle (in degrees) to which we have soft-locked ourselves (if not set it is -1).
Definition qgscadutils.h:85
Provides routines for CAD editing.
Definition qgscadutils.h:33
Represents a 2D point.
Definition qgspointxy.h:62
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:53
Contains configuration of snapping and can return answers to snapping queries.
#define SIP_PROPERTY(name, getter, setter)
Definition qgis_sip.h:279
#define SIP_SKIP
Definition qgis_sip.h:133