mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-08 01:13:27 +01:00
increase pick limit
This commit is contained in:
parent
0dfc9a73be
commit
2bae555c8d
3 changed files with 9 additions and 4 deletions
|
|
@ -92,14 +92,16 @@ export class AddCircleDimTool extends Tool {
|
||||||
|
|
||||||
mousemove(e) {
|
mousemove(e) {
|
||||||
var p = this.viewer.screenToModel(e);
|
var p = this.viewer.screenToModel(e);
|
||||||
var objects = this.viewer.search(p.x, p.y, 20 / this.viewer.scale, true, false, []).filter(function (o) {
|
var objects = this.viewer.search(p.x, p.y, 20, true, false, []).filter(function (o) {
|
||||||
return o._class === 'TCAD.TWO.Circle' || o._class === 'TCAD.TWO.Arc';
|
return o._class === 'TCAD.TWO.Circle' || o._class === 'TCAD.TWO.Arc';
|
||||||
});
|
});
|
||||||
|
|
||||||
if (objects.length != 0) {
|
if (objects.length != 0) {
|
||||||
this.dim.obj = objects[0];
|
this.dim.obj = objects[0];
|
||||||
|
this.viewer.capture('tool', [this.dim.obj], true);
|
||||||
} else {
|
} else {
|
||||||
this.dim.obj = null;
|
this.dim.obj = null;
|
||||||
|
this.viewer.withdrawAll('tool');
|
||||||
}
|
}
|
||||||
if (this.dim.obj != null) {
|
if (this.dim.obj != null) {
|
||||||
this.dim.angle = Math.atan2(p.y - this.dim.obj.c.y, p.x - this.dim.obj.c.x);
|
this.dim.angle = Math.atan2(p.y - this.dim.obj.c.y, p.x - this.dim.obj.c.x);
|
||||||
|
|
@ -113,6 +115,8 @@ export class AddCircleDimTool extends Tool {
|
||||||
} else {
|
} else {
|
||||||
this.viewer.remove(this.dim);
|
this.viewer.remove(this.dim);
|
||||||
}
|
}
|
||||||
|
this.viewer.withdrawAll('tool');
|
||||||
|
this.viewer.refresh();
|
||||||
this.viewer.toolManager.releaseControl();
|
this.viewer.toolManager.releaseControl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ export class LoopPickTool extends Tool {
|
||||||
};
|
};
|
||||||
|
|
||||||
pickLoop(p) {
|
pickLoop(p) {
|
||||||
const pickResult = this.viewer.search(p.x, p.y, 20 / this.viewer.scale, true, false, []);
|
const pickResult = this.viewer.search(p.x, p.y, 20, true, false, []);
|
||||||
for (let obj of pickResult) {
|
for (let obj of pickResult) {
|
||||||
for (let point of [obj.a, obj.b]) {
|
for (let point of [obj.a, obj.b]) {
|
||||||
const loop = this.loops.get(point);
|
const loop = this.loops.get(point);
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,7 @@ class Viewer {
|
||||||
|
|
||||||
search(x, y, buffer, deep, onlyPoints, filter) {
|
search(x, y, buffer, deep, onlyPoints, filter) {
|
||||||
|
|
||||||
|
buffer /= this.scale / this.retinaPxielRatio;
|
||||||
buffer *= 0.5;
|
buffer *= 0.5;
|
||||||
|
|
||||||
var pickResult = [];
|
var pickResult = [];
|
||||||
|
|
@ -292,7 +293,7 @@ class Viewer {
|
||||||
|
|
||||||
snap(x, y, excl) {
|
snap(x, y, excl) {
|
||||||
this.cleanSnap();
|
this.cleanSnap();
|
||||||
const snapTo = this.search(x, y, 20 / this.scale, true, true, excl);
|
const snapTo = this.search(x, y, 20, true, true, excl);
|
||||||
if (snapTo.length > 0) {
|
if (snapTo.length > 0) {
|
||||||
this.capture('tool', [snapTo[0]], true);
|
this.capture('tool', [snapTo[0]], true);
|
||||||
}
|
}
|
||||||
|
|
@ -469,7 +470,7 @@ class Viewer {
|
||||||
|
|
||||||
pick(e) {
|
pick(e) {
|
||||||
const m = this.screenToModel(e);
|
const m = this.screenToModel(e);
|
||||||
return this.search(m.x, m.y, 20 / this.scale, true, false, []);
|
return this.search(m.x, m.y, 20, true, false, []);
|
||||||
};
|
};
|
||||||
|
|
||||||
getActiveLayer() {
|
getActiveLayer() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue