|
@@ -59,13 +59,13 @@ export class SPolygonItem extends SGraphItem {
|
|
|
/** 是否闭合 */
|
|
|
closeFlag: boolean = false;
|
|
|
// 当前状态
|
|
|
- _status: number = SItemStatus.Normal;
|
|
|
+ protected _status: number = SItemStatus.Normal;
|
|
|
// 获取当前状态
|
|
|
- get getStatus(): number {
|
|
|
+ get status(): SItemStatus {
|
|
|
return this._status;
|
|
|
}
|
|
|
// 编辑当前状态
|
|
|
- set setStatus(value: number) {
|
|
|
+ set status(value: SItemStatus) {
|
|
|
this._status = value;
|
|
|
// 如果状态为show则需清栈
|
|
|
if (value == SItemStatus.Normal) {
|
|
@@ -101,7 +101,6 @@ export class SPolygonItem extends SGraphItem {
|
|
|
}
|
|
|
set lineWidth(v: number) {
|
|
|
this._lineWidth = v;
|
|
|
- alert(v)
|
|
|
this.update();
|
|
|
};
|
|
|
/** 鼠标移动点 */
|
|
@@ -117,7 +116,7 @@ export class SPolygonItem extends SGraphItem {
|
|
|
/** 场景像素 */
|
|
|
private isAlt: boolean = false;
|
|
|
/** undoredo堆栈 */
|
|
|
- private undoStack: SUndoStack | null = new SUndoStack();
|
|
|
+ protected undoStack: SUndoStack | null = new SUndoStack();
|
|
|
|
|
|
/**
|
|
|
* 构造函数
|
|
@@ -386,7 +385,7 @@ export class SPolygonItem extends SGraphItem {
|
|
|
* 执行取消操作执行
|
|
|
*/
|
|
|
undo(): void {
|
|
|
- if (this._status == SItemStatus.Normal) {
|
|
|
+ if (this.status == SItemStatus.Normal) {
|
|
|
return
|
|
|
}
|
|
|
if (this.undoStack) {
|
|
@@ -398,7 +397,7 @@ export class SPolygonItem extends SGraphItem {
|
|
|
* 执行重做操作执行
|
|
|
*/
|
|
|
redo(): void {
|
|
|
- if (this._status == SItemStatus.Normal) {
|
|
|
+ if (this.status == SItemStatus.Normal) {
|
|
|
return
|
|
|
}
|
|
|
if (this.undoStack) {
|
|
@@ -417,11 +416,11 @@ export class SPolygonItem extends SGraphItem {
|
|
|
*/
|
|
|
onDoubleClick(event: SMouseEvent): boolean {
|
|
|
// 如果位show状态 双击改对象则需改为编辑状态
|
|
|
- if (SItemStatus.Normal == this._status) {
|
|
|
- this._status = SItemStatus.Edit;
|
|
|
+ if (SItemStatus.Normal == this.status) {
|
|
|
+ this.status = SItemStatus.Edit;
|
|
|
this.grabItem(this);
|
|
|
- } else if (SItemStatus.Edit == this._status) {
|
|
|
- this._status = SItemStatus.Normal;
|
|
|
+ } else if (SItemStatus.Edit == this.status) {
|
|
|
+ this.status = SItemStatus.Normal;
|
|
|
this.releaseItem();
|
|
|
if (this.undoStack) {
|
|
|
this.undoStack.clear()
|
|
@@ -440,13 +439,13 @@ export class SPolygonItem extends SGraphItem {
|
|
|
*/
|
|
|
|
|
|
onKeyDown(event: KeyboardEvent): boolean {
|
|
|
- if (this._status == SItemStatus.Normal) {
|
|
|
+ if (this.status == SItemStatus.Normal) {
|
|
|
return false;
|
|
|
- } else if (this._status == SItemStatus.Create) {
|
|
|
+ } else if (this.status == SItemStatus.Create) {
|
|
|
if (event.code == 'Enter') {
|
|
|
// 当顶点大于二个时才又条件执行闭合操作并清空堆栈
|
|
|
if (this.pointList.length > 2) {
|
|
|
- this._status = SItemStatus.Normal;
|
|
|
+ this.status = SItemStatus.Normal;
|
|
|
//3 传递完成事件状态
|
|
|
this.$emit('finishCreated')
|
|
|
//1 grabItem 置为null
|
|
@@ -457,7 +456,7 @@ export class SPolygonItem extends SGraphItem {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- } else if (this._status == SItemStatus.Edit) {
|
|
|
+ } else if (this.status == SItemStatus.Edit) {
|
|
|
if (event.key == 'Alt') {
|
|
|
this.isAlt = true;
|
|
|
}
|
|
@@ -474,7 +473,7 @@ export class SPolygonItem extends SGraphItem {
|
|
|
* @return boolean
|
|
|
*/
|
|
|
onKeyUp(event: KeyboardEvent): void {
|
|
|
- if (this._status == SItemStatus.Edit) {
|
|
|
+ if (this.status == SItemStatus.Edit) {
|
|
|
if (event.key == 'Alt') {
|
|
|
this.isAlt = false;
|
|
|
}
|
|
@@ -490,13 +489,13 @@ export class SPolygonItem extends SGraphItem {
|
|
|
*/
|
|
|
onMouseDown(event: SMouseEvent): boolean {
|
|
|
// 如果状态为编辑状态则添加点
|
|
|
- if (this._status == SItemStatus.Create) {
|
|
|
+ if (this.status == SItemStatus.Create) {
|
|
|
// 新增顶点
|
|
|
this.insertPoint(event.x, event.y);
|
|
|
// 记录新增顶点操作记录压入堆栈
|
|
|
let pos = new SPoint(event.x, event.y);
|
|
|
this.recordAction(SGraphPointListInsert, [this.pointList, pos]);
|
|
|
- } else if (this._status == SItemStatus.Edit) {
|
|
|
+ } else if (this.status == SItemStatus.Edit) {
|
|
|
// 对多边形数组做编辑操作
|
|
|
this.editPolygonPoint(event);
|
|
|
} else {
|
|
@@ -536,12 +535,12 @@ export class SPolygonItem extends SGraphItem {
|
|
|
*/
|
|
|
|
|
|
onMouseMove(event: SMouseEvent): boolean {
|
|
|
- if (this._status == SItemStatus.Create) {
|
|
|
+ if (this.status == SItemStatus.Create) {
|
|
|
this.lastPoint = new SPoint
|
|
|
this.lastPoint.x = event.x;
|
|
|
this.lastPoint.y = event.y;
|
|
|
this.update();
|
|
|
- } else if (this._status == SItemStatus.Edit) {
|
|
|
+ } else if (this.status == SItemStatus.Edit) {
|
|
|
if (-1 != this.curIndex) {
|
|
|
this.pointList[this.curIndex].x = event.x;
|
|
|
this.pointList[this.curIndex].y = event.y;
|
|
@@ -562,7 +561,7 @@ export class SPolygonItem extends SGraphItem {
|
|
|
* @return boolean
|
|
|
*/
|
|
|
onMouseUp(event: SMouseEvent): boolean {
|
|
|
- if (this._status == SItemStatus.Edit) {
|
|
|
+ if (this.status == SItemStatus.Edit) {
|
|
|
if (-1 != this.curIndex) {
|
|
|
const pos = new SPoint(this.pointList[this.curIndex].x, this.pointList[this.curIndex].y)
|
|
|
this.recordAction(SGraphPointListUpdate, [this.pointList, this.curPoint, pos, this.curIndex])
|
|
@@ -593,12 +592,12 @@ export class SPolygonItem extends SGraphItem {
|
|
|
*/
|
|
|
cancelOperate(): void {
|
|
|
// 当状态为展示状态
|
|
|
- if (this._status == SItemStatus.Create) {
|
|
|
+ if (this.status == SItemStatus.Create) {
|
|
|
// 闭合多边形
|
|
|
this.parent = null
|
|
|
- } else if (this._status == SItemStatus.Edit) {
|
|
|
+ } else if (this.status == SItemStatus.Edit) {
|
|
|
// 编辑状态
|
|
|
- this._status = SItemStatus.Normal
|
|
|
+ this.status = SItemStatus.Normal
|
|
|
}
|
|
|
this.update()
|
|
|
} // Function cancelOperate()
|
|
@@ -661,10 +660,10 @@ export class SPolygonItem extends SGraphItem {
|
|
|
onDraw(painter: SPainter): void {
|
|
|
this.scenceLen = painter.toPx(this.len)
|
|
|
// 当状态为展示状态
|
|
|
- if (this._status == SItemStatus.Normal) {
|
|
|
+ if (this.status == SItemStatus.Normal) {
|
|
|
// 闭合多边形
|
|
|
this.drawShowPolygon(painter, this.pointList);
|
|
|
- } else if (this._status == SItemStatus.Create) {
|
|
|
+ } else if (this.status == SItemStatus.Create) {
|
|
|
// 创建状态
|
|
|
this.drawCreatePolygon(painter, this.pointList)
|
|
|
} else {
|