-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5183 from wonder-sk/cad-utils
Refactor CAD editing alignment logic to new QgsCadUtils class
- Loading branch information
Showing
11 changed files
with
1,013 additions
and
348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.