Commit 71af8460 authored by Christian Winter's avatar Christian Winter

snap to grid method now part of selection class

parent 789e58e0
......@@ -201,7 +201,7 @@
<button type="button" onclick="LineManipulator.scaleSelection(0.5)">Half Size [-]</button>
<button type="button" onclick="LineManipulator.growSelection()">Grow Selection</button>
<button type="button" onclick="LineManipulator.selectLinked()">Select Linked [L]</button>
<button type="button" onclick="Utilities.snapSelectedPointsToGrid()">Snap selection to grid [Shift+S]</button>
<button type="button" onclick="Application.currentView.selection.snapToGrid()">Snap selection to grid [Shift+S]</button>
</div>
</div>
......
......@@ -45,18 +45,9 @@ Utilities = new class {
return centerOfMass;
}
snapSelectedPointsToGrid() {
if (!Preferences.showGrid)
return;
let selection = Application.currentView.selection;
let selPoints = selection.data.getAllPositions();
for (let i = 0; i < selPoints.length; ++i)
selPoints[i].position = GridManager.grid.getNearestPointFor(selPoints[i].position);
Application.redrawAllViews();
snapPointsToGrid(points) {
for (let p of points)
p.position = GridManager.grid.getNearestPointFor(p.position);
}
// TODO make part of Line class
......
......@@ -165,6 +165,11 @@
return false;
}
snapToGrid() {
Utilities.snapPointsToGrid(this.data.getAllPositions());
Application.redrawAllViews();
}
moveBy(delta) {
let points = this.data.getAllPositions();
......
......@@ -85,7 +85,7 @@
case Key.S:
if (Input.isKeyDown(Key.Shift)) {
Utilities.snapSelectedPointsToGrid();
Application.currentView.selection.snapToGrid();
}
break;
case Key.Shift:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment