Sfoglia il codice sorgente

折线取消锚点连接

haojianlong 4 anni fa
parent
commit
84157725e2
2 ha cambiato i file con 76 aggiunte e 9 eliminazioni
  1. 2 2
      package.json
  2. 74 7
      src/components/mapClass/EditScence.ts

+ 2 - 2
package.json

@@ -9,10 +9,10 @@
   },
   "dependencies": {
     "@saga-web/base": "2.1.22",
-    "@saga-web/big": "1.0.60",
+    "@saga-web/big": "1.0.61",
     "@saga-web/draw": "2.1.100",
     "@saga-web/feng-map": "1.0.16",
-    "@saga-web/graph": "2.1.97",
+    "@saga-web/graph": "2.1.98",
     "ant-design-vue": "^1.6.0",
     "core-js": "^3.6.4",
     "element-ui": "^2.13.2",

+ 74 - 7
src/components/mapClass/EditScence.ts

@@ -937,6 +937,9 @@ export class EditScence extends SGraphScene {
             if (this.grabItem instanceof SLineMarkerItem && this.grabItem.status == SItemStatus.Edit) {
                 this.setLineItem(event)
                 return true;
+            } else if (this.grabItem instanceof TipelineItem){
+                this.updateTipeAnc(event);
+                return true;
             }
             return this.grabItem.onMouseUp(event);
         }
@@ -993,13 +996,13 @@ export class EditScence extends SGraphScene {
     */
     setTipeEndanchor(event: SMouseEvent): void {
         if (this.grabItem instanceof TipelineItem) {
-            if (this.grabItem.status == SItemStatus.Create) {
-                const anc = this.clickIsAnchor(event);
-                if (anc) {
-                    const p = anc.mapToScene(0, 0)
-                    anc.isConnected = true;
-                    event.x = p.x;
-                    event.y = p.y;
+            const anc = this.clickIsAnchor(event);
+            if (anc) {
+                const p = anc.mapToScene(0, 0)
+                anc.isConnected = true;
+                event.x = p.x;
+                event.y = p.y;
+                if (this.grabItem.status == SItemStatus.Create) {
                     if (this.grabItem.pointList.length) {
                         this.grabItem.endAnchor = anc;
                         anc.parent ?.connect('changePos', this.grabItem, this.grabItem.changePos)
@@ -1017,6 +1020,70 @@ export class EditScence extends SGraphScene {
     }
 
     /**
+     * 管线item修改锚点 
+     * 
+    */
+    updateTipeAnc(event: SMouseEvent): void {
+        if (this.grabItem instanceof TipelineItem){
+            const anc = this.clickIsAnchor(event);
+            if (anc) {
+                const p = anc.mapToScene(0, 0)
+                event.x = p.x;
+                event.y = p.y;
+                if (this.grabItem.status == SItemStatus.Edit) {
+                    if (this.grabItem.curIndex == 0) {
+                        if (this.grabItem.startAnchor){
+                            this.grabItem.startAnchor.isConnected = false
+                            this.grabItem.startAnchor.parent.disconnect('changePos',this.grabItem);
+                        }
+                        anc.isConnected = true;
+                        this.grabItem.startAnchor = anc;
+                        this.grabItem.anchor1ID = anc.id
+                        this.grabItem.node1Id = anc.parent.id
+                        anc.parent.connect('changePos', this.grabItem, this.grabItem.changePos)
+                    }
+                    if (this.grabItem.curIndex == this.grabItem.pointList.length-1) {
+                        if (this.grabItem.endAnchor){
+                            this.grabItem.endAnchor.isConnected = false
+                            this.grabItem.endAnchor.parent.disconnect('changePos',this.grabItem);
+                        }
+                        anc.isConnected = true;
+                        this.grabItem.endAnchor = anc;
+                        this.grabItem.anchor2ID = anc.id
+                        this.grabItem.node2Id = anc.parent.id
+                        anc.parent.connect('changePos', this.grabItem, this.grabItem.changePos)
+                    }
+                }
+                this.grabItem.onMouseUp(event)
+                return
+            } else {
+                if (this.grabItem.status == SItemStatus.Edit) {
+                    if (this.grabItem.curIndex == 0) {
+                        if (this.grabItem.startAnchor){
+                            this.grabItem.startAnchor.isConnected = false
+                            this.grabItem.startAnchor.parent.disconnect('changePos',this.grabItem);
+                            this.grabItem.startAnchor = null;
+                            this.grabItem.anchor1ID = ''
+                            this.grabItem.node1Id = ''
+                        }
+                    }
+                    if (this.grabItem.curIndex == this.grabItem.pointList.length-1) {
+                        if (this.grabItem.endAnchor){
+                            this.grabItem.endAnchor.isConnected = false
+                            this.grabItem.endAnchor.parent.disconnect('changePos',this.grabItem);
+                            this.grabItem.endAnchor = null;
+                            this.grabItem.anchor2ID = ''
+                            this.grabItem.node2Id = ''
+                        }
+                    }
+                }
+                this.grabItem.onMouseUp(event)
+                return
+            }
+        }
+    }
+
+    /**
      * 设置直线结束Item
      *
     */