25 static const double SOFT_CONSTRAINT_TOLERANCE_PIXEL = 15;
 
   26 static const double SOFT_CONSTRAINT_TOLERANCE_DEGREES = 10;
 
   80       const double dx = edgePt1.
x() - edgePt0.
x();
 
   83         point.
setY( edgePt0.
y() );
 
   87         const double dy = edgePt1.
y() - edgePt0.
y();
 
   88         point.
setY( edgePt0.
y() + ( dy * ( point.
x() - edgePt0.
x() ) ) / dx );
 
  108       const double dy = edgePt1.
y() - edgePt0.
y();
 
  111         point.
setX( edgePt0.
x() );
 
  115         const double dx = edgePt1.
x() - edgePt0.
x();
 
  116         point.
setX( edgePt0.
x() + ( dx * ( point.
y() - edgePt0.
y() ) ) / dy );
 
  128     double softAngle = std::atan2( point.
y() - previousPt.
y(),
 
  129                                    point.
x() - previousPt.
x() );
 
  130     double deltaAngle = 0;
 
  134       deltaAngle = std::atan2( previousPt.
y() - penultimatePt.
y(),
 
  135                                previousPt.
x() - penultimatePt.
x() );
 
  136       softAngle -= deltaAngle;
 
  138     int quo = std::round( softAngle / commonAngle );
 
  139     if ( std::fabs( softAngle - quo * commonAngle ) * 180.0 * M_1_PI <= SOFT_CONSTRAINT_TOLERANCE_DEGREES )
 
  142       softAngle = quo * commonAngle;
 
  145       const double dist = std::fabs( std::cos( softAngle + deltaAngle ) * ( previousPt.
y() - point.
y() )
 
  146                                      - std::sin( softAngle + deltaAngle ) * ( previousPt.
x() - point.
x() ) );
 
  157   bool angleLocked = 
false, angleRelative = 
false;
 
  158   double angleValueDeg = 0;
 
  177     double angleValue = angleValueDeg * M_PI / 180;
 
  181       angleValue += std::atan2( previousPt.
y() - penultimatePt.
y(),
 
  182                                 previousPt.
x() - penultimatePt.
x() );
 
  185     double cosa = std::cos( angleValue );
 
  186     double sina = std::sin( angleValue );
 
  187     double v = ( point.
x() - previousPt.
x() ) * cosa + ( point.
y() - previousPt.
y() ) * sina;
 
  205         point.
setY( previousPt.
y() + x * sina / cosa );
 
  221         point.
setX( previousPt.
x() + y * cosa / sina );
 
  226       point.
setX( previousPt.
x() + cosa * v );
 
  227       point.
setY( previousPt.
y() + sina * v );
 
  235       const double x1 = previousPt.
x();
 
  236       const double y1 = previousPt.
y();
 
  237       const double x2 = previousPt.
x() + cosa;
 
  238       const double y2 = previousPt.
y() + sina;
 
  240       const double x3 = edgePt0.
x();
 
  241       const double y3 = edgePt0.
y();
 
  242       const double x4 = edgePt1.
x();
 
  243       const double y4 = edgePt1.
y();
 
  245       const double d = ( x1 - x2 ) * ( y3 - y4 ) - ( y1 - y2 ) * ( x3 - x4 );
 
  249       if ( std::fabs( d ) > 0.01 )
 
  251         point.
setX( ( ( x3 - x4 ) * ( x1 * y2 - y1 * x2 ) - ( x1 - x2 ) * ( x3 * y4 - y3 * x4 ) ) / d );
 
  252         point.
setY( ( ( y3 - y4 ) * ( x1 * y2 - y1 * x2 ) - ( y1 - y2 ) * ( x3 * y4 - y3 * x4 ) ) / d );
 
  279       const double dist = std::sqrt( point.
sqrDist( previousPt ) );
 
  289         point.
set( previousPt.
x() + ( point.
x() - previousPt.
x() ) * vP,
 
  290                    previousPt.
y() + ( point.
y() - previousPt.
y() ) * vP );
 
  303   QgsDebugMsgLevel( QStringLiteral( 
"point:             %1 %2" ).arg( point.
x() ).arg( point.
y() ), 4 );
 
  304   QgsDebugMsgLevel( QStringLiteral( 
"previous point:    %1 %2" ).arg( previousPt.
x() ).arg( previousPt.
y() ), 4 );
 
  305   QgsDebugMsgLevel( QStringLiteral( 
"penultimate point: %1 %2" ).arg( penultimatePt.
x() ).arg( penultimatePt.
y() ), 4 );
 
  316   QgsDebugMsg( QStringLiteral( 
"Constraints (locked / relative / value" ) );
 
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.
static bool lineCircleIntersection(const QgsPointXY ¢er, double radius, const QgsPointXY &linePoint1, const QgsPointXY &linePoint2, QgsPointXY &intersection) SIP_HOLDGIL
Compute the intersection of a line and a circle.
A class to represent a 2D point.
void set(double x, double y) SIP_HOLDGIL
Sets the x and y value of the point.
double sqrDist(double x, double y) const SIP_HOLDGIL
Returns the squared distance between this point a specified x, y coordinate.
void setX(double x) SIP_HOLDGIL
Sets the x value of the point.
void setY(double y) SIP_HOLDGIL
Sets the y value of the point.
QgsPointLocator::Match snapToMap(QPoint point, QgsPointLocator::MatchFilter *filter=nullptr, bool relaxed=false)
Snap to map according to the current configuration.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
#define QgsDebugMsgLevel(str, level)
bool locked
Whether the constraint is active, i.e. should be considered.
double value
Numeric value of the constraint (coordinate/distance in map units or angle in degrees)
bool relative
Whether the value is relative to previous value.
Structure defining all constraints for alignMapPoint() method.
QgsCadUtils::AlignMapPointConstraint yConstraint
Constraint for Y coordinate.
QgsCadUtils::AlignMapPointConstraint xConstraint
Constraint for X coordinate.
double mapUnitsPerPixel
Map units/pixel ratio from map canvas. Needed for.
QgsCadUtils::AlignMapPointConstraint distanceConstraint
Constraint for distance.
QList< QgsPointXY > cadPointList
List of recent CAD points in map coordinates.
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.
void dump() const
Dumps the context's properties, for debugging.
QgsCadUtils::AlignMapPointConstraint angleConstraint
Constraint for angle.
Structure returned from alignMapPoint() method.
QgsPointXY finalMapPoint
map point aligned according to the constraints
bool valid
Whether the combination of constraints is actually valid.
QgsPointLocator::Match snapMatch
Snapped point - only valid if actually used for something.
QgsPointLocator::Match edgeMatch
Snapped segment - only valid if actually used for something.
double softLockCommonAngle
Angle (in degrees) to which we have soft-locked ourselves (if not set it is -1)
Interface that allows rejection of some matches in intersection queries (e.g.
virtual bool acceptMatch(const QgsPointLocator::Match &match)=0
QgsPointXY point() const
for vertex / edge match coords depending on what class returns it (geom.cache: layer coords,...
bool hasEdge() const
Returns true if the Match is an edge.
void edgePoints(QgsPointXY &pt1, QgsPointXY &pt2) const
Only for a valid edge match - obtain endpoints of the edge.