Skip to content

Commit

Permalink
Fix locking logic with X,Y locked and soft locks to angle (fixes #12940)
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Jun 18, 2015
1 parent b81933e commit 646b445
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions src/app/qgsadvanceddigitizingdockwidget.cpp
Expand Up @@ -631,40 +631,40 @@ bool QgsAdvancedDigitizingDockWidget::applyConstraints( QgsMapMouseEvent* e )
double cosa = qCos( angleValue );
double sina = qSin( angleValue );
double v = ( point.x() - previousPt.x() ) * cosa + ( point.y() - previousPt.y() ) * sina ;
if ( mXConstraint->isLocked() || mYConstraint->isLocked() )
if ( mXConstraint->isLocked() && mYConstraint->isLocked() )
{
// perform both to detect errors in constraints
if ( mXConstraint->isLocked() )
// do nothing if both X,Y are already locked
}
else if ( mXConstraint->isLocked() )
{
if ( cosa == 0 )
{
if ( cosa == 0 )
{
res = false;
}
else
{
double x = mXConstraint->value();
if ( !mXConstraint->relative() )
{
x -= previousPt.x();
}
point.setY( previousPt.y() + x * sina / cosa );
}
res = false;
}
else if ( mYConstraint->isLocked() )
else
{
if ( sina == 0 )
double x = mXConstraint->value();
if ( !mXConstraint->relative() )
{
res = false;
x -= previousPt.x();
}
else
point.setY( previousPt.y() + x * sina / cosa );
}
}
else if ( mYConstraint->isLocked() )
{
if ( sina == 0 )
{
res = false;
}
else
{
double y = mYConstraint->value();
if ( !mYConstraint->relative() )
{
double y = mYConstraint->value();
if ( !mYConstraint->relative() )
{
y -= previousPt.y();
}
point.setX( previousPt.x() + y * cosa / sina );
y -= previousPt.y();
}
point.setX( previousPt.x() + y * cosa / sina );
}
}
else
Expand Down

0 comments on commit 646b445

Please sign in to comment.