25 static const double SOFT_CONSTRAINT_TOLERANCE_PIXEL = 15;
    26 static const double SOFT_CONSTRAINT_TOLERANCE_DEGREES = 10;
    49   EdgesOnlyFilter edgesOnlyFilter;
    77       const double dx = edgePt1.
x() - edgePt0.
x();
    80         point.
setY( edgePt0.
y() );
    84         const double dy = edgePt1.
y() - edgePt0.
y();
    85         point.
setY( edgePt0.
y() + ( dy * ( point.
x() - edgePt0.
x() ) ) / dx );
   105       const double dy = edgePt1.
y() - edgePt0.
y();
   108         point.
setX( edgePt0.
x() );
   112         const double dx = edgePt1.
x() - edgePt0.
x();
   113         point.
setX( edgePt0.
x() + ( dx * ( point.
y() - edgePt0.
y() ) ) / dy );
   125     double softAngle = std::atan2( point.
y() - previousPt.
y(),
   126                                    point.
x() - previousPt.
x() );
   127     double deltaAngle = 0;
   131       deltaAngle = std::atan2( previousPt.
y() - penultimatePt.
y(),
   132                                previousPt.
x() - penultimatePt.
x() );
   133       softAngle -= deltaAngle;
   135     int quo = std::round( softAngle / commonAngle );
   136     if ( std::fabs( softAngle - quo * commonAngle ) * 180.0 * M_1_PI <= SOFT_CONSTRAINT_TOLERANCE_DEGREES )
   139       softAngle = quo * commonAngle;
   142       const double dist = std::fabs( std::cos( softAngle + deltaAngle ) * ( previousPt.
y() - point.
y() )
   143                                      - std::sin( softAngle + deltaAngle ) * ( previousPt.
x() - point.
x() ) );
   154   bool angleLocked = 
false, angleRelative = 
false;
   155   double angleValueDeg = 0;
   174     double angleValue = angleValueDeg * M_PI / 180;
   178       angleValue += std::atan2( previousPt.
y() - penultimatePt.
y(),
   179                                 previousPt.
x() - penultimatePt.
x() );
   182     double cosa = std::cos( angleValue );
   183     double sina = std::sin( angleValue );
   184     double v = ( point.
x() - previousPt.
x() ) * cosa + ( point.
y() - previousPt.
y() ) * sina;
   202         point.
setY( previousPt.
y() + x * sina / cosa );
   218         point.
setX( previousPt.
x() + y * cosa / sina );
   223       point.
setX( previousPt.
x() + cosa * v );
   224       point.
setY( previousPt.
y() + sina * v );
   232       const double x1 = previousPt.
x();
   233       const double y1 = previousPt.
y();
   234       const double x2 = previousPt.
x() + cosa;
   235       const double y2 = previousPt.
y() + sina;
   237       const double x3 = edgePt0.
x();
   238       const double y3 = edgePt0.
y();
   239       const double x4 = edgePt1.
x();
   240       const double y4 = edgePt1.
y();
   242       const double d = ( x1 - x2 ) * ( y3 - y4 ) - ( y1 - y2 ) * ( x3 - x4 );
   246       if ( std::fabs( d ) > 0.01 )
   248         point.
setX( ( ( x3 - x4 ) * ( x1 * y2 - y1 * x2 ) - ( x1 - x2 ) * ( x3 * y4 - y3 * x4 ) ) / d );
   249         point.
setY( ( ( y3 - y4 ) * ( x1 * y2 - y1 * x2 ) - ( y1 - y2 ) * ( x3 * y4 - y3 * x4 ) ) / d );
   276       const double dist = std::sqrt( point.
sqrDist( previousPt ) );
   286         point.
set( previousPt.
x() + ( point.
x() - previousPt.
x() ) * vP,
   287                    previousPt.
y() + ( point.
y() - previousPt.
y() ) * vP );
   300   QgsDebugMsgLevel( QStringLiteral( 
"point:             %1 %2" ).arg( point.
x() ).arg( point.
y() ), 4 );
   301   QgsDebugMsgLevel( QStringLiteral( 
"previous point:    %1 %2" ).arg( previousPt.
x() ).arg( previousPt.
y() ), 4 );
   302   QgsDebugMsgLevel( QStringLiteral( 
"penultimate point: %1 %2" ).arg( penultimatePt.
x() ).arg( penultimatePt.
y() ), 4 );
   313   QgsDebugMsg( QStringLiteral( 
"Constraints (locked / relative / value" ) );
   314   QgsDebugMsg( QStringLiteral( 
"Angle:    %1 %2 %3" ).arg( angleConstraint.locked ).arg( angleConstraint.relative ).arg( angleConstraint.value ) );
   315   QgsDebugMsg( QStringLiteral( 
"Distance: %1 %2 %3" ).arg( distanceConstraint.locked ).arg( distanceConstraint.relative ).arg( distanceConstraint.value ) );
   316   QgsDebugMsg( QStringLiteral( 
"X:        %1 %2 %3" ).arg( xConstraint.locked ).arg( xConstraint.relative ).arg( xConstraint.value ) );
   317   QgsDebugMsg( QStringLiteral( 
"Y:        %1 %2 %3" ).arg( yConstraint.locked ).arg( yConstraint.relative ).arg( yConstraint.value ) );
 
static bool lineCircleIntersection(const QgsPointXY ¢er, double radius, const QgsPointXY &linePoint1, const QgsPointXY &linePoint2, QgsPointXY &intersection)
Compute the intersection of a line and a circle. 
 
void set(double x, double y)
Sets the x and y value of the point. 
 
QgsCadUtils::AlignMapPointConstraint yConstraint
Constraint for Y coordinate. 
 
A class to represent a 2D point. 
 
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference) 
 
Interface that allows rejection of some matches in intersection queries (e.g. 
 
QgsPointLocator::Match edgeMatch
Snapped segment - only valid if actually used for something. 
 
double sqrDist(double x, double y) const
Returns the squared distance between this point a specified x, y coordinate. 
 
bool locked
Whether the constraint is active, i.e. should be considered. 
 
QgsCadUtils::AlignMapPointConstraint distanceConstraint
Constraint for distance. 
 
#define QgsDebugMsgLevel(str, level)
 
QgsPointLocator::Match snapToMap(QPoint point, QgsPointLocator::MatchFilter *filter=nullptr, bool relaxed=false)
Snap to map according to the current configuration. 
 
void setY(double y)
Sets the y value of the point. 
 
Structure defining all constraints for alignMapPoint() method. 
 
void edgePoints(QgsPointXY &pt1, QgsPointXY &pt2) const
Only for a valid edge match - obtain endpoints of the edge. 
 
QgsCadUtils::AlignMapPointConstraint commonAngleConstraint
Constraint for soft lock to a common angle. 
 
virtual bool acceptMatch(const QgsPointLocator::Match &match)=0
 
QgsPointXY finalMapPoint
map point aligned according to the constraints 
 
double value
Numeric value of the constraint (coordinate/distance in map units or angle in degrees) ...
 
void setX(double x)
Sets the x value of the point. 
 
double softLockCommonAngle
Angle (in degrees) to which we have soft-locked ourselves (if not set it is -1) 
 
Structure returned from alignMapPoint() method. 
 
double mapUnitsPerPixel
Map units/pixel ratio from map canvas. Needed for. 
 
void dump() const
Dumps the context's properties, for debugging. 
 
QgsPointXY point() const
for vertex / edge match coords depending on what class returns it (geom.cache: layer coords...
 
QgsCadUtils::AlignMapPointConstraint xConstraint
Constraint for X coordinate. 
 
QgsCadUtils::AlignMapPointConstraint angleConstraint
Constraint for angle. 
 
bool valid
Whether the combination of constraints is actually valid. 
 
QgsSnappingUtils * snappingUtils
Snapping utils that will be used to snap point to map. Must not be nullptr. 
 
static QgsCadUtils::AlignMapPointOutput alignMapPoint(const QgsPointXY &originalMapPoint, const QgsCadUtils::AlignMapPointContext &ctx)
Applies X/Y/angle/distance constraints from the given context to a map point. 
 
bool relative
Whether the value is relative to previous value. 
 
QList< QgsPointXY > cadPointList
List of recent CAD points in map coordinates.