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 @@ ...@@ -201,7 +201,7 @@
<button type="button" onclick="LineManipulator.scaleSelection(0.5)">Half Size [-]</button> <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.growSelection()">Grow Selection</button>
<button type="button" onclick="LineManipulator.selectLinked()">Select Linked [L]</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>
</div> </div>
......
...@@ -45,18 +45,9 @@ Utilities = new class { ...@@ -45,18 +45,9 @@ Utilities = new class {
return centerOfMass; return centerOfMass;
} }
snapSelectedPointsToGrid() { snapPointsToGrid(points) {
if (!Preferences.showGrid) for (let p of points)
return; p.position = GridManager.grid.getNearestPointFor(p.position);
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();
} }
// TODO make part of Line class // TODO make part of Line class
......
...@@ -165,6 +165,11 @@ ...@@ -165,6 +165,11 @@
return false; return false;
} }
snapToGrid() {
Utilities.snapPointsToGrid(this.data.getAllPositions());
Application.redrawAllViews();
}
moveBy(delta) { moveBy(delta) {
let points = this.data.getAllPositions(); let points = this.data.getAllPositions();
......
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
case Key.S: case Key.S:
if (Input.isKeyDown(Key.Shift)) { if (Input.isKeyDown(Key.Shift)) {
Utilities.snapSelectedPointsToGrid(); Application.currentView.selection.snapToGrid();
} }
break; break;
case Key.Shift: 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