Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix locking logic with X,Y locked and soft locks to angle (fixes #12940)
(cherry picked from commit 646b445)
  • Loading branch information
wonder-sk committed Jul 7, 2015
1 parent 48a51ff commit be0dae1
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 be0dae1

Please sign in to comment.