Commit ca908553 authored by Christian Winter's avatar Christian Winter

cursor class implementation wip

parent bd950b6d
......@@ -3,8 +3,22 @@
this.position = Vector2.zero;
this.range = 10;
}
// TODO use me
get currentPosition() {
return GridManager.grid.getNearestPointFor(this.position);
}
intersect(obj) {
if (obj instanceof Line) {
throw("not defined for Line!")
} else if (obj instanceof LineEnding) {
let radius = this.range + (obj.line.thickness * 0.5);
return Vector2.sqrDistance(obj.position, this.position) <= radius * radius;
} else if (obj instanceof Vector2) {
return Vector2.sqrDistance(obj, this.position) <= this.range * this.range;
}
}
withinRange(factor) {
}
}
\ No newline at end of file
......@@ -659,12 +659,12 @@
if (Preferences.selectVertices && Preferences.selectEdges) {
let s, e, m, _m;
for (let line of lines) {
s = Utilities.pointWithinCircle(line.start, mousePosition, Application.cursor.range);
e = Utilities.pointWithinCircle(line.end, mousePosition, Application.cursor.range);
s = Application.cursor.intersect(line.start);
e = Application.cursor.intersect(line.end);
_m = line.start.position.addVector(line.end.position);
_m = _m.divide(2);
_m = new LineEnding(_m.x, _m.y, line);
m = Utilities.pointWithinCircle(_m, mousePosition, Application.cursor.range);
m = Application.cursor.intersect(_m, mousePosition, Application.cursor.range);
if (s && !m && !e)
pointsToChangeSelection.push(line.start);
......@@ -705,7 +705,7 @@
}
} else if (Preferences.selectVertices) {
for (let p of Utilities.linesToLineEndings(lines)) {
if (Utilities.pointWithinCircle(p, mousePosition, Application.cursor.range))
if (Application.cursor.intersect(p))
pointsToChangeSelection.push(p);
}
}
......
......@@ -154,7 +154,7 @@
return true;
for (let p of this.data.points)
if (Utilities.pointWithinCircle(p, mousePosition, Application.cursor.range))
if (Application.cursor.intersect(p))
return true;
for (let instance of this.data.instances)
......
......@@ -14,12 +14,12 @@
if (Preferences.selectVertices && Preferences.selectEdges) {
let s, e, m, _m;
for (let line of Application.currentView.data.lines.concat(Application.currentView.selection.data.partialLines)) {
s = Utilities.pointWithinCircle(line.start, mousePosition, Application.cursor.range);
e = Utilities.pointWithinCircle(line.end, mousePosition, Application.cursor.range);
s = Application.cursor.intersect(line.start);
e = Application.cursor.intersect(line.end);
_m = line.start.position.addVector(line.end.position);
_m = _m.divide(2);
_m = new LineEnding(_m.x, _m.y, line);
m = Utilities.pointWithinCircle(_m, mousePosition, Application.cursor.range);
m = Application.cursor.intersect(_m);
if (s && !m && !e)
newSelPoints.push(line.start);
......@@ -48,15 +48,15 @@
}
} else if (Preferences.selectVertices) {
for (let line of Application.currentView.data.lines) {
if (Utilities.pointWithinCircle(line.start, mousePosition, Application.cursor.range))
if (Application.cursor.intersect(line.start));
newSelPoints.push(line.start);
if (Utilities.pointWithinCircle(line.end, mousePosition, Application.cursor.range))
if (Application.cursor.intersect(line.end))
newSelPoints.push(line.end);
}
for (let line of Application.currentView.selection.data.partialLines) {
if (Utilities.pointWithinCircle(line.start, mousePosition, Application.cursor.range))
if (Application.cursor.intersect(line.start))
newSelPoints.push(line.start);
if (Utilities.pointWithinCircle(line.end, mousePosition, Application.cursor.range))
if (Application.cursor.intersect(line.end))
newSelPoints.push(line.end);
}
}
......@@ -79,12 +79,12 @@
if (Preferences.selectVertices && Preferences.selectEdges) {
let s, e, m, _m;
for (let line of Application.currentView.selection.data.lines.concat(Application.currentView.selection.data.partialLines)) {
s = Utilities.pointWithinCircle(line.start, mousePosition, Application.cursor.range);
e = Utilities.pointWithinCircle(line.end, mousePosition, Application.cursor.range);
s = Application.cursor.intersect(line.start);
e = Application.cursor.intersect(line.end);
_m = line.start.position.addVector(line.end.position);
_m = _m.divide(2);
_m = new LineEnding(_m.x, _m.y, line);
m = Utilities.pointWithinCircle(_m, mousePosition, Application.cursor.range);
m = Application.cursor.intersect(_m);
if (s && !m && !e)
newUnselPoints.push(line.start);
......@@ -114,16 +114,16 @@
}
else if (Preferences.selectVertices) {
for (let line of Application.currentView.selection.data.lines) {
if (Utilities.pointWithinCircle(line.start, mousePosition, Application.cursor.range))
if (Application.cursor.intersect(line.start))
newUnselPoints.push(line.start);
if (Utilities.pointWithinCircle(line.end, mousePosition, Application.cursor.range))
if (Application.cursor.intersect(line.end))
newUnselPoints.push(line.end);
}
for (let line of Application.currentView.selection.data.partialLines) {
if (Utilities.pointWithinCircle(line.start, mousePosition, Application.cursor.range))
if (Application.cursor.intersect(line.start))
newUnselPoints.push(line.start);
if (Utilities.pointWithinCircle(line.end, mousePosition, Application.cursor.range))
if (Application.cursor.intersect(line.end))
newUnselPoints.push(line.end);
}
}
......
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