Explorar o código

items<fix>:去掉部分item的编辑功能

YaolongHan %!s(int64=4) %!d(string=hai) anos
pai
achega
f802feecbc

+ 2 - 36
persagy-web-big/src/items/SIconTextItem.ts

@@ -349,23 +349,7 @@ export class SIconTextItem extends SObjectItem {
         }
     }
 
-    /**
-     * 鼠标按下事件
-     *
-     * @param event   事件对象
-     * @return 是否处理事件
-     */
-    onMouseDown(event: SMouseEvent): boolean {
-        // 如果为show状态 双击改对象则需改为编辑状态
-        if (this.status == SItemStatus.Normal) {
-            super.onMouseDown(event);
-            return true;
-        } else if (this.status == SItemStatus.Edit) {
-            // 编辑状态时
-            return super.onMouseDown(event);
-        }
-        return true;
-    }
+
 
     /**
      * 宽高发发生变化
@@ -377,25 +361,7 @@ export class SIconTextItem extends SObjectItem {
         console.log(arguments);
     }
 
-    /**
-     * 鼠标双击事件
-     *
-     * @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 对象边界区域

+ 0 - 119
persagy-web-big/src/items/SLineItem.ts

@@ -176,125 +176,6 @@ export class SLineItem extends SGraphStyleItem {
     }
 
     /**
-     * 鼠标双击事件
-     *
-     * @param event     事件参数
-     * @return 是否处理事件
-     */
-    onDoubleClick(event: SMouseEvent): boolean {
-        // 如果为show状态 双击改对象则需改为编辑状态
-        if (this.status == SItemStatus.Normal) {
-            this.status = SItemStatus.Edit;
-            this.grabItem(this);
-        } else if (this.status == SItemStatus.Edit) {
-            // 处于编辑状态时
-            this.status = SItemStatus.Normal;
-            this.releaseItem();
-        }
-        this.update();
-        return true;
-    }
-
-    /**
-     * 鼠标按下事件
-     *
-     * @param event     鼠标事件
-     * @return 是否处理事件
-     */
-    onMouseDown(event: SMouseEvent): boolean {
-        this.curIndex = -1;
-        this.curPoint = null;
-        // 按下 shiftKey 键
-        if (event.shiftKey) {
-            event = this.compare(event);
-        }
-        // 按下鼠标左键
-        if (event.buttons == SMouseButton.LeftButton) {
-            if (this.status == SItemStatus.Normal) {
-                //标准状态时
-                return super.onMouseDown(event);
-            } else if (this.status == SItemStatus.Edit) {
-                // 编辑状态时
-                // 判断是否点击到端点上(获取端点索引值)
-                this.findNearestPoint(new SPoint(event.x, event.y));
-            } else if (this.status == SItemStatus.Create) {
-                // 创建状态时
-                this.addPoint(new SPoint(event.x, event.y));
-                return true;
-            }
-        }
-
-        return true;
-    }
-
-    /**
-     * 鼠标抬起事件
-     *
-     * @param event     事件参数
-     * @return 是否处理事件
-     */
-    onMouseUp(event: SMouseEvent): boolean {
-        // 处于编辑状态时
-        if (this.status == SItemStatus.Edit) {
-            // 当前点索引大于 -1 时
-            if (this.curIndex > -1) {
-                const p = new SPoint(
-                    this.line[this.curIndex].x,
-                    this.line[this.curIndex].y
-                );
-                this.recordAction(SGraphPointListUpdate, [
-                    this.line,
-                    this.curPoint,
-                    p,
-                    this.curIndex
-                ]);
-            }
-        } else if (this.status == SItemStatus.Normal) {
-            // 标准状态时
-            this.moveToOrigin(this.x, this.y);
-            return super.onMouseUp(event);
-        }
-
-        this.curIndex = -1;
-        this.curPoint = null;
-        return true;
-    }
-
-    /**
-     * 鼠标移动事件
-     *
-     * @param event     事件参数
-     * @return 是否处理事件
-     */
-    onMouseMove(event: SMouseEvent): boolean {
-        // 按下 shiftKey 键
-        if (event.shiftKey) {
-            event = this.compare(event);
-        }
-
-        // 处于创建状态时
-        if (this.status == SItemStatus.Create) {
-            if (this.line[0] instanceof SPoint) {
-                this.line[1] = new SPoint(event.x, event.y);
-                this.pointChange();
-            }
-        } else if (this.status == SItemStatus.Edit) {
-            // 处于编辑状态时
-            // 当前索引不等于 -1 时
-            if (-1 != this.curIndex) {
-                this.line[this.curIndex].x = event.x;
-                this.line[this.curIndex].y = event.y;
-                this.pointChange();
-            }
-        } else {
-            return super.onMouseMove(event);
-        }
-
-        this.update();
-        return true;
-    }
-
-    /**
      * 获取点击点与 Point[] 中的点距离最近点
      *
      * @param p     鼠标点击点

+ 0 - 178
persagy-web-big/src/items/SPolygonItem.ts

@@ -499,124 +499,6 @@ export class SPolygonItem extends SGraphItem {
     // 以下为鼠标事件
 
     /**
-     * 鼠标双击事件
-     *
-     * @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;
-    }
-
-    /**
-     * 键盘事件
-     *
-     * @param event     事件参数
-     * @return 是否处理
-     */
-
-    onKeyDown(event: KeyboardEvent): boolean {
-        if (this.status == SItemStatus.Normal) {
-            return false;
-        } else if (this.status == SItemStatus.Create) {
-            if (event.code == "Enter") {
-                // 当顶点大于二个时才又条件执行闭合操作并清空堆栈
-                if (this.pointList.length > 2) {
-                    this.status = SItemStatus.Normal;
-                    //3 传递完成事件状态
-                    this.$emit("finishCreated");
-                    //1 grabItem 置为null
-                    this.releaseItem();
-                }
-            }
-        } else if (this.status == SItemStatus.Edit) {
-            if (event.key == "Alt") {
-                this.isAlt = true;
-            }
-        }
-
-        this.update();
-        return true;
-    }
-
-    /**
-     * 键盘键抬起事件
-     *
-     * @param event     事件参数
-     * @return 是否处理
-     */
-    onKeyUp(event: KeyboardEvent): void {
-        if (this.status == SItemStatus.Edit) {
-            if (event.key == "Alt") {
-                this.isAlt = false;
-            } else if (event.keyCode == SKeyCode.Delete) {
-                // 当多边形的顶点大于三个允许删除点
-                if (this.pointList.length > 3) {
-                    this.deletePoint(this.curIndex);
-                }
-            }
-        }
-
-        this.update();
-    }
-
-    /**
-     * 鼠标按下事件
-     *
-     * @param event     事件参数
-     * @return 是否处理
-     */
-    onMouseDown(event: SMouseEvent): boolean {
-        if (event.shiftKey) {
-            event = this.compare(event);
-        }
-
-        // 如果状态为编辑状态则添加点
-        if (this.status == SItemStatus.Create) {
-            // 新增顶点
-            let len = -1;
-            if (this.pointList.length) {
-                len = SMathUtil.pointDistance(
-                    event.x,
-                    event.y,
-                    this.pointList[0].x,
-                    this.pointList[0].y
-                );
-            }
-
-            if (this.pointList.length > 2 && len > 0 && len < this.scenceLen) {
-                this.status = SItemStatus.Normal;
-                //3 传递完成事件状态
-                this.$emit("finishCreated");
-                //1 grabItem 置为null
-                this.releaseItem();
-            } else {
-                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) {
-            // 对多边形数组做编辑操作
-            this.editPolygonPoint(event);
-        } else {
-            return super.onMouseDown(event);
-        }
-
-        return true;
-    }
-
-    /**
      * 鼠标移入事件
      *
      * @param event     事件参数
@@ -637,38 +519,6 @@ export class SPolygonItem extends SGraphItem {
     }
 
     /**
-     * 鼠标移动事件
-     *
-     * @param event     事件参数
-     * @return 是否处理
-     */
-    onMouseMove(event: SMouseEvent): boolean {
-        if (event.shiftKey) {
-            event = this.compare(event);
-        }
-
-        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) {
-            if (event.buttons == 1) {
-                if (-1 != this.curIndex) {
-                    this.pointList[this.curIndex].x = event.x;
-                    this.pointList[this.curIndex].y = event.y;
-                }
-            }
-
-            this.update();
-        } else {
-            return super.onMouseMove(event);
-        }
-
-        return true;
-    }
-
-    /**
      * shift 垂直水平创建或编辑
      *
      * @param event     事件
@@ -698,34 +548,6 @@ export class SPolygonItem extends SGraphItem {
     }
 
     /**
-     * 鼠标抬起事件
-     *
-     * @param event     事件参数
-     * @return 是否处理
-     */
-    onMouseUp(event: SMouseEvent): boolean {
-        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
-                ]);
-            }
-        } else if (this.status == SItemStatus.Normal) {
-            this.moveToOrigin(this.x, this.y);
-            return super.onMouseUp(event);
-        }
-
-        return true;
-    }
-
-    /**
      * 移动后处理所有坐标,并肩原点置为场景原点
      *
      * @param x   x 坐标

+ 3 - 162
persagy-web-big/src/items/SPolylineItem.ts

@@ -203,165 +203,6 @@ export class SPolylineItem extends SGraphItem {
     }
 
     /**
-     * 鼠标按下事件
-     *
-     * @param event     鼠标事件
-     * @return 是否处理事件
-     */
-    onMouseDown(event: SMouseEvent): boolean {
-        this.curIndex = -1;
-        this.curPoint = null;
-        if (event.shiftKey) {
-            event = this.compare(event);
-        }
-
-        if (event.buttons == 1) {
-            if (this.status == SItemStatus.Create) {
-                this.addPoint(new SPoint(event.x, event.y));
-                return true;
-            } else if (this.status == SItemStatus.Edit) {
-                // 查询鼠标最近的索引
-                this.findNearestPoint(new SPoint(event.x, event.y));
-
-                // 增加点
-                if (this.curIndex < 0) {
-                    this.findAddPos(new SPoint(event.x, event.y));
-                }
-
-                // 删除点
-                if (event.altKey && this.canHandle(this.curIndex)) {
-                    this.deletePoint(this.curIndex);
-                }
-
-                this.update();
-                return true;
-            } else {
-                return super.onMouseDown(event);
-            }
-        }
-
-        return super.onMouseDown(event);
-    }
-
-    /**
-     * 鼠标移动事件
-     *
-     * @param event     鼠标事件
-     * @return 是否处理事件
-     */
-    onMouseMove(event: SMouseEvent): boolean {
-        if (event.shiftKey) {
-            event = this.compare(event);
-        }
-
-        if (this.status == SItemStatus.Create) {
-            if (this.lastPoint) {
-                this.lastPoint.x = event.x;
-                this.lastPoint.y = event.y;
-            } else {
-                this.lastPoint = new SPoint(event.x, event.y);
-            }
-
-            this.update();
-            return true;
-        } else if (this.status == SItemStatus.Edit) {
-            if (event.buttons == 1) {
-                if (this.canHandle(this.curIndex)) {
-                    this.pointList[this.curIndex].x = event.x;
-                    this.pointList[this.curIndex].y = event.y;
-                }
-            }
-
-            this.update();
-            return true;
-        } else {
-            return super.onMouseMove(event);
-        }
-    }
-
-    /**
-     * 鼠标移动事件
-     *
-     * @param event     鼠标事件
-     * @return 是否处理事件
-     */
-    onMouseUp(event: SMouseEvent): boolean {
-        if (this.status == SItemStatus.Edit) {
-            if (this.curIndex > -1) {
-                const p = new SPoint(
-                    this.pointList[this.curIndex].x,
-                    this.pointList[this.curIndex].y
-                );
-                this.recordAction(SGraphPointListUpdate, [
-                    this.pointList,
-                    this.curPoint,
-                    p,
-                    this.curIndex
-                ]);
-            }
-        } else if (this.status == SItemStatus.Normal) {
-            this.moveToOrigin(this.x, this.y);
-            return super.onMouseUp(event);
-        }
-
-        return true;
-    }
-
-    /**
-     * 鼠标双击事件
-     *
-     * @param event     事件参数
-     * @return 是否处理
-     */
-    onDoubleClick(event: SMouseEvent): boolean {
-        // 如果为show状态 双击改对象则需改为编辑状态
-        if (this.status == SItemStatus.Normal) {
-            this.status = SItemStatus.Edit;
-            this.grabItem(this);
-        } else if (this.status == SItemStatus.Edit) {
-            // 编辑状态
-            this.status = SItemStatus.Normal;
-            this.releaseItem();
-        } else if (this.status == SItemStatus.Create) {
-            // 创建状态
-            if (this.pointList.length > 1) {
-                this.status = SItemStatus.Normal;
-                this.releaseItem();
-                this.$emit("finishCreated");
-            }
-        }
-
-        this.$emit("onDoubleClick", event);
-        return true;
-    }
-
-    /***
-     * 键盘按键弹起事件
-     *
-     * @param event     事件参数
-     */
-    onKeyUp(event: KeyboardEvent): void {
-        if (event.keyCode == SKeyCode.Enter) {
-            if (this.pointList.length > 1) {
-                if (this.status == SItemStatus.Create) {
-                    this.$emit("finishCreated");
-                }
-
-                this.status = SItemStatus.Normal;
-                this.releaseItem();
-            }
-        }
-
-        // delete删除点
-        if (
-            event.keyCode == SKeyCode.Delete &&
-            this.status == SItemStatus.Edit
-        ) {
-            this.deletePoint(this.curIndex);
-        }
-    }
-
-    /**
      * 移动后处理所有坐标,并肩原点置为场景原点
      *
      * @param x     x 坐标
@@ -412,9 +253,9 @@ export class SPolylineItem extends SGraphItem {
      */
     findAddPos(p: SPoint): void {
         let len = SMathUtil.pointToLine(
-                p,
-                new SLine(this.pointList[0], this.pointList[1])
-            ),
+            p,
+            new SLine(this.pointList[0], this.pointList[1])
+        ),
             index = 0;
         if (this.pointList.length > 2) {
             for (let i = 1; i < this.pointList.length - 1; i++) {