Skip to content
Permalink
Browse files

Merge pull request #5183 from wonder-sk/cad-utils

Refactor CAD editing alignment logic to new QgsCadUtils class
  • Loading branch information
wonder-sk committed Oct 3, 2017
2 parents 9256d00 + 0bffe1c commit 7874d4b6d6ef08a9f47ce2701c5e1d442a05e8f8
@@ -476,6 +476,7 @@ QgsAdvancedDigitizingDockWidget {#qgis_api_break_3_0_QgsAdvancedDigitizin

- canvasPressEvent(), canvasReleaseEvent(), canvasMoveEvent() were removed. Handling of events is done in QgsMapToolAdvancedDigitizing.
- snappingMode() was removed. Advanced digitizing now always uses project's snapping configuration.
- lineCircleIntersection() was removed


QgsApplication {#qgis_api_break_3_0_QgsApplication}
@@ -15,6 +15,7 @@
%Include qgscachedfeatureiterator.sip
%Include qgscacheindex.sip
%Include qgscacheindexfeatureid.sip
%Include qgscadutils.sip
%Include qgsclipper.sip
%Include qgscolorramp.sip
%Include qgscolorscheme.sip
@@ -0,0 +1,123 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgscadutils.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/





class QgsCadUtils
{
%Docstring
The QgsCadUtils class provides routines for CAD editing.

.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgscadutils.h"
%End
public:

struct AlignMapPointConstraint
{
AlignMapPointConstraint( bool locked = false, bool relative = false, double value = 0 );

bool locked;
%Docstring
Whether the constraint is active, i.e. should be considered
%End
bool relative;
%Docstring
Whether the value is relative to previous value
%End
double value;
%Docstring
Numeric value of the constraint (coordinate/distance in map units or angle in degrees)
%End
};

struct AlignMapPointContext
{
QgsSnappingUtils *snappingUtils;
%Docstring
Snapping utils that will be used to snap point to map. Must not be null
%End
double mapUnitsPerPixel;
%Docstring
Map units/pixel ratio from map canvas. Needed for
%End

QgsCadUtils::AlignMapPointConstraint xConstraint;
%Docstring
Constraint for X coordinate
%End
QgsCadUtils::AlignMapPointConstraint yConstraint;
%Docstring
Constraint for Y coordinate
%End
QgsCadUtils::AlignMapPointConstraint distanceConstraint;
%Docstring
Constraint for distance
%End
QgsCadUtils::AlignMapPointConstraint angleConstraint;
%Docstring
Constraint for angle
%End
QgsCadUtils::AlignMapPointConstraint commonAngleConstraint;
%Docstring
Constraint for soft lock to a common angle
%End

QList<QgsPointXY> cadPointList;
%Docstring
point (index 2) for alignment purposes.
%End

void dump() const;
};

struct AlignMapPointOutput
{
bool valid;
%Docstring
Whether the combination of constraints is actually valid
%End

QgsPointXY finalMapPoint;
%Docstring
map point aligned according to the constraints
%End

QgsPointLocator::Match edgeMatch;
%Docstring
Snapped segment - only valid if actually used for something
%End

int softLockCommonAngle;
%Docstring
Angle (in degrees) to which we have soft-locked ourselves (if not set it is -1)
%End
};

static QgsCadUtils::AlignMapPointOutput alignMapPoint( const QgsPointXY &originalMapPoint, const QgsCadUtils::AlignMapPointContext &ctx );
%Docstring
Applies X/Y/angle/distance constraints from the given context to a map point.
Returns a structure containing aligned map point, whether the constraints are valid and
some extra information.
:rtype: QgsCadUtils.AlignMapPointOutput
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgscadutils.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -11,7 +11,6 @@




class QgsAdvancedDigitizingDockWidget : QgsDockWidget
{
%Docstring
@@ -151,14 +150,6 @@ class QgsAdvancedDigitizingDockWidget : QgsDockWidget

};

static bool lineCircleIntersection( const QgsPointXY &center, const double radius, const QList<QgsPointXY> &segment, QgsPointXY &intersection );
%Docstring
.. note::

from the two solutions, the intersection will be set to the closest point
:rtype: bool
%End

explicit QgsAdvancedDigitizingDockWidget( QgsMapCanvas *canvas, QWidget *parent = 0 );
%Docstring
Create an advanced digitizing dock widget
@@ -139,6 +139,7 @@ SET(QGIS_CORE_SRCS
qgscachedfeatureiterator.cpp
qgscacheindex.cpp
qgscacheindexfeatureid.cpp
qgscadutils.cpp
qgsclipper.cpp
qgscolorramp.cpp
qgscolorscheme.cpp
@@ -792,6 +793,7 @@ SET(QGIS_CORE_HDRS
qgscachedfeatureiterator.h
qgscacheindex.h
qgscacheindexfeatureid.h
qgscadutils.h
qgsclipper.h
qgscolorramp.h
qgscolorscheme.h

0 comments on commit 7874d4b

Please sign in to comment.
You can’t perform that action at this time.