Skip to content

Commit

Permalink
refactor: simplify calculation of angle snap point
Browse files Browse the repository at this point in the history
- change angle of current line to snapped angle
- use end point as alternative position
- remove check for maximum distance for angle snap
- not necessary as snapping is now user controllable
  • Loading branch information
letsfindaway committed Sep 23, 2024
1 parent 1dd184b commit 7d60b3b
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/domain/UBGraphicsScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,13 +585,8 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
QLineF radius(mPreviousPoint, position);
qreal angle = radius.angle();
angle = qRound(angle / step) * step;
qreal radiusLength = radius.length();
QPointF newPosition(
mPreviousPoint.x() + radiusLength * cos((angle * PI) / 180),
mPreviousPoint.y() - radiusLength * sin((angle * PI) / 180));
QLineF chord(position, newPosition);
if (chord.length() < qMin((int)16, (int)(radiusLength / 20)))
altPosition = newPosition;
radius.setAngle(angle);
altPosition = radius.p2();
}
}

Expand Down

0 comments on commit 7d60b3b

Please sign in to comment.