|
@@ -24,6 +24,7 @@
|
|
|
* *********************************************************************************************************************
|
|
|
*/
|
|
|
|
|
|
+import { SMouseEvent } from "@persagy-web/base";
|
|
|
import { SGraphItem, SLineStyle, STextOrigin, Point } from "@persagy-web/graph";
|
|
|
import { SColor, SFont, SPainter, SLineCapStyle, SPoint, SPath, SPolygonUtil, SRect } from "@persagy-web/draw";
|
|
|
import { Example } from "../index";
|
|
@@ -201,7 +202,6 @@ export class SPlanZone extends SGraphEdit {
|
|
|
obj.color = this.color;
|
|
|
obj.originPosition = STextOrigin.Center;
|
|
|
obj.isTransform = false;
|
|
|
- obj.moveable = true;
|
|
|
obj.showSelect = false;
|
|
|
textItemList.push(obj);
|
|
|
});
|
|
@@ -321,12 +321,42 @@ export class SPlanZone extends SGraphEdit {
|
|
|
moveText() {}
|
|
|
|
|
|
/**
|
|
|
+ * 鼠标双击事件
|
|
|
+ *
|
|
|
+ * @param event 鼠标事件
|
|
|
+ * @return 是否处理事件
|
|
|
+ */
|
|
|
+ onDoubleClick(event: SMouseEvent): boolean {
|
|
|
+ // 如果位show状态 双击改对象则需改为编辑状态
|
|
|
+ if (SItemStatus.Normal == this.status) {
|
|
|
+ this.status = SItemStatus.Edit;
|
|
|
+ this.grabItem(this);
|
|
|
+ } else if (SItemStatus.Edit == this.status) {
|
|
|
+ this.status = SItemStatus.Normal;
|
|
|
+ this.releaseItem();
|
|
|
+ }
|
|
|
+
|
|
|
+ this.update();
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+ /**
|
|
|
* Item 对象边界区域
|
|
|
*
|
|
|
* @return 对象边界区域
|
|
|
*/
|
|
|
boundingRect(): SRect {
|
|
|
- return new SRect(this.minX, this.minY, this.maxX - this.minX, this.maxY - this.minY);
|
|
|
+ let rect = new SRect(this.minX, this.minY, this.maxX - this.minX, this.maxY - this.minY);
|
|
|
+ if (this.showText) {
|
|
|
+ this.textItemList.forEach(item => {
|
|
|
+ rect = rect.unioned(
|
|
|
+ item
|
|
|
+ .boundingRect()
|
|
|
+ .adjusted(item.pos.x, item.pos.y, 0, 0)
|
|
|
+ );
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return rect.adjusted(-5, -5, 10, 10);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -386,6 +416,24 @@ export class SPlanZone extends SGraphEdit {
|
|
|
* @param painter 绘制对象
|
|
|
*/
|
|
|
onDraw(painter: SPainter) {
|
|
|
+ const rect = this.boundingRect();
|
|
|
+ const lw = painter.toPx(1);
|
|
|
+ // 编辑态出现四个角的圆点和外接矩阵轮廓
|
|
|
+ if (this.status == SItemStatus.Edit) {
|
|
|
+ painter.pen.lineWidth = lw;
|
|
|
+ painter.pen.lineDash = [3 * lw, 7 * lw];
|
|
|
+ painter.pen.color = SColor.Black;
|
|
|
+ painter.brush.color = SColor.Transparent;
|
|
|
+ painter.drawRect(rect);
|
|
|
+
|
|
|
+ painter.pen.lineDash = [];
|
|
|
+ painter.brush.color = SColor.White;
|
|
|
+ painter.drawCircle(rect.x, rect.y, 5 * lw)
|
|
|
+ painter.drawCircle(rect.right, rect.bottom, 5 * lw)
|
|
|
+ painter.drawCircle(rect.x, rect.bottom, 5 * lw)
|
|
|
+ painter.drawCircle(rect.right, rect.y, 5 * lw)
|
|
|
+ }
|
|
|
+
|
|
|
painter.pen.lineCapStyle = SLineCapStyle.Square;
|
|
|
painter.pen.color = this.strokeColor;
|
|
|
painter.brush.color = this.fillColor;
|