|
@@ -1,5 +1,5 @@
|
|
import { SGraphItem, SGraphPointListInsert, SGraphPointListDelete, SGraphPointListUpdate } from "@saga-web/graph/lib";
|
|
import { SGraphItem, SGraphPointListInsert, SGraphPointListDelete, SGraphPointListUpdate } from "@saga-web/graph/lib";
|
|
-import { SMouseEvent, SUndoStack } from "@saga-web/base/";;
|
|
|
|
|
|
+import { SMouseEvent, SUndoStack, SKeyCode } from "@saga-web/base/";;
|
|
import {
|
|
import {
|
|
SColor,
|
|
SColor,
|
|
SLineCapStyle,
|
|
SLineCapStyle,
|
|
@@ -154,6 +154,8 @@ export class SPolygonItem extends SGraphItem {
|
|
point = null
|
|
point = null
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ this.curIndex = -1;
|
|
|
|
+ this.curPoint = null;
|
|
this.update()
|
|
this.update()
|
|
return point
|
|
return point
|
|
}
|
|
}
|
|
@@ -273,6 +275,10 @@ export class SPolygonItem extends SGraphItem {
|
|
painter.pen.color = SColor.Black;
|
|
painter.pen.color = SColor.Black;
|
|
painter.brush.color = SColor.White;
|
|
painter.brush.color = SColor.White;
|
|
pointList.forEach((item, index) => {
|
|
pointList.forEach((item, index) => {
|
|
|
|
+ painter.brush.color = SColor.White;
|
|
|
|
+ if (index == this.curIndex) {
|
|
|
|
+ painter.brush.color = new SColor(this.fillColor);
|
|
|
|
+ }
|
|
painter.drawCircle(item.x, item.y, painter.toPx(this.len / 2))
|
|
painter.drawCircle(item.x, item.y, painter.toPx(this.len / 2))
|
|
})
|
|
})
|
|
}
|
|
}
|
|
@@ -489,6 +495,8 @@ export class SPolygonItem extends SGraphItem {
|
|
if (this.status == SItemStatus.Edit) {
|
|
if (this.status == SItemStatus.Edit) {
|
|
if (event.key == 'Alt') {
|
|
if (event.key == 'Alt') {
|
|
this.isAlt = false;
|
|
this.isAlt = false;
|
|
|
|
+ } else if (event.keyCode == SKeyCode.Delete) {
|
|
|
|
+ this.deletePoint(this.curIndex);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.update()
|
|
this.update()
|
|
@@ -567,9 +575,11 @@ export class SPolygonItem extends SGraphItem {
|
|
this.lastPoint.y = event.y;
|
|
this.lastPoint.y = event.y;
|
|
this.update();
|
|
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;
|
|
|
|
|
|
+ if (event.buttons == 1) {
|
|
|
|
+ if (-1 != this.curIndex) {
|
|
|
|
+ this.pointList[this.curIndex].x = event.x;
|
|
|
|
+ this.pointList[this.curIndex].y = event.y;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
this.update()
|
|
this.update()
|
|
} else {
|
|
} else {
|
|
@@ -592,8 +602,8 @@ export class SPolygonItem extends SGraphItem {
|
|
const pos = new SPoint(this.pointList[this.curIndex].x, this.pointList[this.curIndex].y)
|
|
const pos = new SPoint(this.pointList[this.curIndex].x, this.pointList[this.curIndex].y)
|
|
this.recordAction(SGraphPointListUpdate, [this.pointList, this.curPoint, pos, this.curIndex])
|
|
this.recordAction(SGraphPointListUpdate, [this.pointList, this.curPoint, pos, this.curIndex])
|
|
}
|
|
}
|
|
- this.curIndex = -1;
|
|
|
|
- this.curPoint = null;
|
|
|
|
|
|
+ // this.curIndex = -1;
|
|
|
|
+ // this.curPoint = null;
|
|
} else {
|
|
} else {
|
|
// return super.onMouseUp(event)
|
|
// return super.onMouseUp(event)
|
|
}
|
|
}
|