@@ -2509,31 +2509,28 @@ QPointF UBGraphicsScene::snap(const QPointF& point, double* force, std::optional
25092509 double snapForce{0 };
25102510 double gridSize = backgroundGridSize ();
25112511
2512- // determine closest grid point
2513- if (mPageBackground != UBPageBackground::plain)
2512+ if (mIntermediateLines )
25142513 {
2515- if (mIntermediateLines )
2516- {
2517- gridSize /= 2 .;
2518- }
2514+ gridSize /= 2 .;
2515+ }
25192516
2520- // y axis
2521- double floorY = std::floor (point.y () / gridSize) * gridSize;
2522- snapPoint.setY (point.y () - floorY < gridSize / 2 . ? floorY : floorY + gridSize);
2517+ // y axis
2518+ double floorY = std::floor (point.y () / gridSize) * gridSize;
2519+ snapPoint.setY (point.y () - floorY < gridSize / 2 . ? floorY : floorY + gridSize);
25232520
2524- if (mPageBackground == UBPageBackground::crossed)
2525- {
2526- // x axis
2527- double floorX = std::floor (point.x () / gridSize) * gridSize;
2528- snapPoint.setX (point.x () - floorX < gridSize / 2 . ? floorX : floorX + gridSize);
2529- }
2530-
2531- // force is a number between 0 and 1 based on the manhattan distance of the snap point
2532- // from the original point
2533- double relativeDist = (snapPoint - point).manhattanLength () / gridSize;
2534- snapForce = std::max (1 . - relativeDist, 0 .);
2521+ // for blank background, use same snapping as for grid
2522+ if (mPageBackground == UBPageBackground::crossed || mPageBackground == UBPageBackground::plain)
2523+ {
2524+ // x axis
2525+ double floorX = std::floor (point.x () / gridSize) * gridSize;
2526+ snapPoint.setX (point.x () - floorX < gridSize / 2 . ? floorX : floorX + gridSize);
25352527 }
25362528
2529+ // force is a number between 0 and 1 based on the manhattan distance of the snap point
2530+ // from the original point
2531+ double relativeDist = (snapPoint - point).manhattanLength () / gridSize;
2532+ snapForce = std::max (1 . - relativeDist, 0 .);
2533+
25372534 if (proposedPoint)
25382535 {
25392536 // compute force for proposed point and take that if it has higher force
0 commit comments