|
@@ -161,6 +161,8 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
|
|
|
radiusIsPx: boolean = false;
|
|
|
/** path 对象 */
|
|
|
path: SPath = new SPath();
|
|
|
+ /** 圆角半径最大值 */
|
|
|
+ maxRadius: number = 0;
|
|
|
|
|
|
/**
|
|
|
* 构造函数
|
|
@@ -312,7 +314,7 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
|
|
|
if (event.altKey && this.canHandle(this.curIndex)) {
|
|
|
this.deletePoint(this.curIndex);
|
|
|
}
|
|
|
-
|
|
|
+ this.calMinEdge();
|
|
|
this.update();
|
|
|
return true;
|
|
|
} else {
|
|
@@ -388,6 +390,7 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
|
|
|
p,
|
|
|
this.curIndex
|
|
|
]);
|
|
|
+ this.calMinEdge();
|
|
|
}
|
|
|
} else if (this.status == SItemStatus.Normal) {
|
|
|
// 处于正常态
|
|
@@ -413,14 +416,17 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
|
|
|
} else if (this.status == SItemStatus.Edit) {
|
|
|
// 处于编辑状态 双击则改为正常态
|
|
|
this.status = SItemStatus.Normal;
|
|
|
+ this.calMinEdge();
|
|
|
this.releaseItem();
|
|
|
} else if (this.status == SItemStatus.Create) {
|
|
|
+ this.removeRepeat();
|
|
|
// 处于创建状态
|
|
|
if (this.pointList.length > 1) {
|
|
|
// 本对象点数据中已经给存在的点个数大于1个
|
|
|
this.status = SItemStatus.Normal;
|
|
|
this.releaseItem();
|
|
|
this.$emit("finishCreated");
|
|
|
+ this.calMinEdge();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -441,6 +447,7 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
|
|
|
if (this.status == SItemStatus.Create) {
|
|
|
// 处于创建态
|
|
|
this.$emit("finishCreated");
|
|
|
+ this.calMinEdge();
|
|
|
}
|
|
|
|
|
|
this.status = SItemStatus.Normal;
|
|
@@ -655,6 +662,49 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 计算最短边
|
|
|
+ */
|
|
|
+ calMinEdge(): void {
|
|
|
+ return;
|
|
|
+ // if (this.pointList.length > 1) {
|
|
|
+ // this.maxRadius = 0;
|
|
|
+ // for (let i = 0; i < this.pointList.length - 1; i++) {
|
|
|
+ // const dis = SMathUtil.pointDistance(
|
|
|
+ // this.pointList[i].x,
|
|
|
+ // this.pointList[i].y,
|
|
|
+ // this.pointList[i + 1].x,
|
|
|
+ // this.pointList[i + 1].y
|
|
|
+ // );
|
|
|
+ // if (this.maxRadius == 0 || dis < this.maxRadius) {
|
|
|
+ // this.maxRadius = dis;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // // 与夹角有关 this.maxRadius = (this.maxRadius / 2;) * Math.tan(θ/2)
|
|
|
+ // this.maxRadius = this.maxRadius / 2;
|
|
|
+ // if (this.radius > this.maxRadius) {
|
|
|
+ // this.radius = this.maxRadius;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 去除重复点
|
|
|
+ */
|
|
|
+ removeRepeat(): void {
|
|
|
+ if (this.pointList.length > 1) {
|
|
|
+ for (let i = 0; i < this.pointList.length - 1; i++) {
|
|
|
+ if (
|
|
|
+ this.pointList[i].x == this.pointList[i + 1].x &&
|
|
|
+ this.pointList[i].y == this.pointList[i + 1].y
|
|
|
+ ) {
|
|
|
+ this.pointList.splice(i, 1);
|
|
|
+ i--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 撤销操作
|
|
|
*/
|
|
|
undo(): void {
|