|
@@ -488,35 +488,27 @@ class EditUtil {
|
|
if(this.template.mainPipes) {
|
|
if(this.template.mainPipes) {
|
|
for(const mp of this.template.mainPipes){
|
|
for(const mp of this.template.mainPipes){
|
|
for(const line of mp.locationPath) {
|
|
for(const line of mp.locationPath) {
|
|
- var pre: Point = null;
|
|
|
|
- for(var point of line) {
|
|
|
|
- point = this.toCanvas(point);
|
|
|
|
- if(pre != null) {
|
|
|
|
- var x1:number;
|
|
|
|
- var y1:number;
|
|
|
|
- var x2:number;
|
|
|
|
- var y2:number;
|
|
|
|
- const scope = 3;
|
|
|
|
- if(pre.y == point.y) { //水平
|
|
|
|
- y1 = pre.y - scope;
|
|
|
|
- y2 = pre.y + scope;
|
|
|
|
- x1 = Math.min(pre.x, point.x);
|
|
|
|
- x2 = Math.max(pre.x, point.x);
|
|
|
|
- } else { //垂直
|
|
|
|
- x1 = pre.x - scope;
|
|
|
|
- x2 = pre.x + scope;
|
|
|
|
- y1 = Math.min(pre.y, point.y);
|
|
|
|
- y2 = Math.max(pre.y, point.y);
|
|
|
|
- }
|
|
|
|
- if(x >= x1 && y >= y1 && x <= x2 && y <= y2)
|
|
|
|
- return mp;
|
|
|
|
- }
|
|
|
|
- pre = point;
|
|
|
|
- }
|
|
|
|
|
|
+ if(this.onPath(x, y, line))
|
|
|
|
+ return mp;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private onPath(x:number, y:number, path: Array<Point>): boolean {
|
|
|
|
+ var p = new Point(x, y);
|
|
|
|
+ var pre: Point = null;
|
|
|
|
+ for(var point of path) {
|
|
|
|
+ point = this.toCanvas(point);
|
|
|
|
+ if(pre != null) {
|
|
|
|
+ var d = ViewTool.distance(p, [pre, point]);
|
|
|
|
+ if(d < 3)
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ pre = point;
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|