summaryrefslogtreecommitdiffstats
path: root/src/snap.cpp
diff options
context:
space:
mode:
authorDiederik van Lierop <mailat-signdiedenrezidotnl>2010-12-27 22:03:25 +0000
committerDiederik van Lierop <mailat-signdiedenrezidotnl>2010-12-27 22:03:25 +0000
commite2fe5c8411dcbd514f1df51de0925c0719019dc9 (patch)
treed4abec2bbf8a962033c65795c7fd88dad07c4787 /src/snap.cpp
parentNode tool: snap while scaling a selection of nodes. Consider this as experime... (diff)
downloadinkscape-e2fe5c8411dcbd514f1df51de0925c0719019dc9.tar.gz
inkscape-e2fe5c8411dcbd514f1df51de0925c0719019dc9.zip
Snapping: improve calculation of metrics for scaling, modify some comments, and remove a line of obsolete debugging output
(bzr r9986)
Diffstat (limited to 'src/snap.cpp')
-rw-r--r--src/snap.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/snap.cpp b/src/snap.cpp
index 85d2fd5af..f13b02b46 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -826,11 +826,11 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed(
/* Consider the case in which a box is almost aligned with a grid in both
* horizontal and vertical directions. The distance to the intersection of
* the grid lines will always be larger then the distance to a single grid
- * line. If we prefer snapping to an intersection instead of to a single
+ * line. If we prefer snapping to an intersection over to a single
* grid line, then we cannot use "metric = Geom::L2(result)". Therefore the
* snapped distance will be used as a metric. Please note that the snapped
- * distance is defined as the distance to the nearest line of the intersection,
- * and not to the intersection itself!
+ * distance to an intersection is defined as the distance to the nearest line
+ * of the intersection, and not to the intersection itself!
*/
// Only for translations, the relevant metric will be the real snapped distance,
// so we don't have to do anything special here
@@ -848,7 +848,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed(
if (fabs(fabs(a[index]/b[index]) - fabs(transformation[index])) > 1e-12) { // if SNAPPING DID occur in this direction
result[index] = a[index] / b[index]; // then calculate it!
}
- // we might leave result[1-index] = NR_HUGE
+ // we might have left result[1-index] = NR_HUGE
// if scaling didn't occur in the other direction
}
}
@@ -861,8 +861,12 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed(
}
// Compare the resulting scaling with the desired scaling
Geom::Point scale_metric = Geom::abs(result - transformation); // One or both of its components might be NR_HUGE
- snapped_point.setSnapDistance(std::min(scale_metric[0], scale_metric[1]));
- snapped_point.setSecondSnapDistance(std::max(scale_metric[0], scale_metric[1]));
+ if (scale_metric[0] == NR_HUGE || scale_metric[1] == NR_HUGE) {
+ snapped_point.setSnapDistance(std::min(scale_metric[0], scale_metric[1]));
+ } else {
+ snapped_point.setSnapDistance(Geom::L2(scale_metric));
+ }
+ snapped_point.setSecondSnapDistance(NR_HUGE);
break;
}
case STRETCH:
@@ -901,7 +905,6 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed(
if (snapped_point.getSnapped()) {
// We snapped; keep track of the best snap
- // TODO: Compare the transformations instead of the snap points; we should be looking for the closest transformation
if (best_snapped_point.isOtherSnapBetter(snapped_point, true)) {
best_transformation = result;
best_snapped_point = snapped_point;