Procházet zdrojové kódy

折线item添加点完成

haojianlong před 5 roky
rodič
revize
2ccd6a55c0

+ 2 - 2
saga-web-big/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/big",
-    "version": "1.0.16",
+    "version": "1.0.17",
     "description": "上格云建筑信息化库",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -42,6 +42,6 @@
         "typescript": "^3.9.3"
     },
     "dependencies": {
-        "@saga-web/graph": "2.1.65"
+        "@saga-web/graph": "2.1.66"
     }
 }

+ 12 - 8
saga-web-big/src/items/SPolylineItem.ts

@@ -141,6 +141,9 @@ export class SPolylineItem extends SGraphItem {
                 // 查询鼠标最近的索引
                 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.pointList.splice(this.curIndex, 1);
@@ -250,14 +253,15 @@ export class SPolylineItem extends SGraphItem {
      * @param   p   鼠标点击点
      * */
     findAddPos(p: SPoint): void {
-        let len = {
-                MinDis: this.sceneDis
-            },
+        let len = SMathUtil.pointToLine(
+                p,
+                new SLine(this.pointList[0], this.pointList[1])
+            ),
             index = 0;
         if (this.pointList.length > 2) {
-            for (let i = 0; i < this.pointList.length - 1; i++) {
+            for (let i = 1; i < this.pointList.length - 1; i++) {
                 let dis = SMathUtil.pointToLine(
-                    new SPoint(p.x, p.y),
+                    p,
                     new SLine(this.pointList[i], this.pointList[i + 1])
                 );
                 if (dis.MinDis < len.MinDis) {
@@ -265,10 +269,10 @@ export class SPolylineItem extends SGraphItem {
                     index = i;
                 }
             }
-            // @ts-ignore
+        }
+        if (len.MinDis < this.sceneDis) {
             if (len.Point) {
-                // @ts-ignore
-                this.addPoint(new SPoint(len.Point.X, len.Point.Y), index);
+                this.addPoint(len.Point, index + 1);
             }
         }
     } // Function findAddPos()

+ 29 - 32
saga-web-big/src/items/floor/SSpaceItem.ts

@@ -119,40 +119,37 @@ export class SSpaceItem extends SGraphItem {
         );
     } // Function boundingRect()
 
-    /**
-     * 鼠标单击事件
-     *
-     * @param	event         事件参数
-     * @return	boolean
-     */
-    onMouseDown(event: SMouseEvent): boolean {
-        console.log("spaceDown");
-        if (this.selectable) {
-            this.selected = !this.selected;
-        }
-        this.$emit("click", event);
-        return true;
-    } // Function onMouseDown()
+    // /**
+    //  * 鼠标单击事件
+    //  *
+    //  * @param	event         事件参数
+    //  * @return	boolean
+    //  */
+    // onMouseDown(event: SMouseEvent): boolean {
+    //     console.log("spaceDown");
+    //     this.$emit("click", event);
+    //     return true;
+    // } // Function onMouseDown()
 
-    /**
-     * 鼠标移动事件
-     *
-     * @param event 事件参数
-     */
-    onMouseMove(event: SMouseEvent): boolean {
-        return false;
-    } // Function onMouseMove()
+    // /**
+    //  * 鼠标移动事件
+    //  *
+    //  * @param event 事件参数
+    //  */
+    // onMouseMove(event: SMouseEvent): boolean {
+    //     return false;
+    // } // Function onMouseMove()
 
-    /**
-     * 鼠标抬起事件
-     *
-     * @param	event         事件参数
-     * @return	boolean
-     */
-    onMouseUp(event: SMouseEvent): boolean {
-        console.log("spaceUp");
-        return false;
-    } // Function onClick()
+    // /**
+    //  * 鼠标抬起事件
+    //  *
+    //  * @param	event         事件参数
+    //  * @return	boolean
+    //  */
+    // onMouseUp(event: SMouseEvent): boolean {
+    //     console.log("spaceUp");
+    //     return false;
+    // } // Function onClick()
 
     /**
      * 判断点是否在区域内

+ 1 - 1
saga-web-graph/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/graph",
-    "version": "2.1.65",
+    "version": "2.1.66",
     "description": "上格云二维图形引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 1 - 1
saga-web-graph/src/SGraphItem.ts

@@ -578,7 +578,7 @@ export class SGraphItem extends SObject {
      */
     private clickSelect(event: SMouseEvent): void {
         // 如果Item不可被选中,或没有按下鼠标左键,则直接返回
-        if (!this.selectable && event.buttons != SMouseButton.LeftButton) {
+        if (!this.selectable || event.buttons != SMouseButton.LeftButton) {
             return;
         }
         const scene = this.scene;

+ 7 - 0
saga-web-graph/src/SGraphSelectContainer.ts

@@ -16,6 +16,13 @@ export class SGraphSelectContainer extends SObject {
     }
 
     /**
+     * 构造体
+     * */
+    constructor() {
+        super();
+    } // Constructor
+
+    /**
      * 添加item到list
      *
      * @param   item    当前选中的item