|
@@ -5,7 +5,8 @@ import { SMathUtil } from "../utils/SMathUtil";
|
|
import {
|
|
import {
|
|
SGraphItem,
|
|
SGraphItem,
|
|
SGraphPointListDelete,
|
|
SGraphPointListDelete,
|
|
- SGraphPointListInsert, SGraphPointListUpdate
|
|
|
|
|
|
+ SGraphPointListInsert,
|
|
|
|
+ SGraphPointListUpdate
|
|
} from "@saga-web/graph/lib";
|
|
} from "@saga-web/graph/lib";
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -128,9 +129,9 @@ export class SPolylineItem extends SGraphItem {
|
|
} // Function canHandle()
|
|
} // Function canHandle()
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 添加点至数组中
|
|
|
|
|
|
+ * 根据索引删除点
|
|
*
|
|
*
|
|
- * @param index 添加到的索引
|
|
|
|
|
|
+ * @param index 删除点
|
|
* */
|
|
* */
|
|
private delPoint(index: number): void {
|
|
private delPoint(index: number): void {
|
|
if (this.canHandle(index) && this.pointList.length > 2) {
|
|
if (this.canHandle(index) && this.pointList.length > 2) {
|
|
@@ -138,12 +139,14 @@ export class SPolylineItem extends SGraphItem {
|
|
this.pointList[this.curIndex].x,
|
|
this.pointList[this.curIndex].x,
|
|
this.pointList[this.curIndex].y
|
|
this.pointList[this.curIndex].y
|
|
);
|
|
);
|
|
- this.pointList.splice(index, 0);
|
|
|
|
|
|
+ this.pointList.splice(index, 1);
|
|
this.recordAction(SGraphPointListDelete, [
|
|
this.recordAction(SGraphPointListDelete, [
|
|
this.pointList,
|
|
this.pointList,
|
|
p,
|
|
p,
|
|
index
|
|
index
|
|
]);
|
|
]);
|
|
|
|
+ this.curIndex = -1;
|
|
|
|
+ this.curPoint = null;
|
|
this.update();
|
|
this.update();
|
|
}
|
|
}
|
|
} // Function delPoint
|
|
} // Function delPoint
|
|
@@ -170,9 +173,7 @@ export class SPolylineItem extends SGraphItem {
|
|
}
|
|
}
|
|
// 删除点
|
|
// 删除点
|
|
if (event.altKey && this.canHandle(this.curIndex)) {
|
|
if (event.altKey && this.canHandle(this.curIndex)) {
|
|
- this.pointList.splice(this.curIndex, 1);
|
|
|
|
- this.curIndex = -1;
|
|
|
|
- this.curPoint = null;
|
|
|
|
|
|
+ this.delPoint(this.curIndex);
|
|
}
|
|
}
|
|
this.update();
|
|
this.update();
|
|
return true;
|
|
return true;
|
|
@@ -246,14 +247,10 @@ export class SPolylineItem extends SGraphItem {
|
|
onDoubleClick(event: SMouseEvent): boolean {
|
|
onDoubleClick(event: SMouseEvent): boolean {
|
|
if (this.status == SItemStatus.Normal) {
|
|
if (this.status == SItemStatus.Normal) {
|
|
this.status = SItemStatus.Edit;
|
|
this.status = SItemStatus.Edit;
|
|
- if (this.scene) {
|
|
|
|
- this.scene.grabItem = this;
|
|
|
|
- }
|
|
|
|
|
|
+ this.grabItem(this);
|
|
} else if (this.status == SItemStatus.Edit) {
|
|
} else if (this.status == SItemStatus.Edit) {
|
|
this.status = SItemStatus.Normal;
|
|
this.status = SItemStatus.Normal;
|
|
- if (this.scene) {
|
|
|
|
- this.scene.grabItem = null;
|
|
|
|
- }
|
|
|
|
|
|
+ this.releaseItem();
|
|
} else if (this.status == SItemStatus.Create) {
|
|
} else if (this.status == SItemStatus.Create) {
|
|
this.status = SItemStatus.Edit;
|
|
this.status = SItemStatus.Edit;
|
|
}
|
|
}
|
|
@@ -269,6 +266,7 @@ export class SPolylineItem extends SGraphItem {
|
|
onKeyUp(event: KeyboardEvent): void {
|
|
onKeyUp(event: KeyboardEvent): void {
|
|
if (event.keyCode == 13) {
|
|
if (event.keyCode == 13) {
|
|
this.status = SItemStatus.Normal;
|
|
this.status = SItemStatus.Normal;
|
|
|
|
+ this.releaseItem();
|
|
}
|
|
}
|
|
} // Function onKeyUp()
|
|
} // Function onKeyUp()
|
|
|
|
|
|
@@ -392,6 +390,20 @@ export class SPolylineItem extends SGraphItem {
|
|
} // Function redo()
|
|
} // Function redo()
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 取消操作执行
|
|
|
|
+ *
|
|
|
|
+ * */
|
|
|
|
+ cancelOperate(): void {
|
|
|
|
+ if (this.status == SItemStatus.Create) {
|
|
|
|
+ this.parent = null;
|
|
|
|
+ this.releaseItem();
|
|
|
|
+ } else if (this.status == SItemStatus.Edit) {
|
|
|
|
+ this.status = SItemStatus.Normal;
|
|
|
|
+ this.releaseItem();
|
|
|
|
+ }
|
|
|
|
+ } // Function cancelOperate()
|
|
|
|
+
|
|
|
|
+ /**
|
|
* Item绘制操作
|
|
* Item绘制操作
|
|
*
|
|
*
|
|
* @param painter painter对象
|
|
* @param painter painter对象
|