Pārlūkot izejas kodu

Merge branch 'develop' of http://39.106.8.246:3003/web/wanda-editer into develop

YaolongHan 4 gadi atpakaļ
vecāks
revīzija
daeb52fae9

BIN
public/favicon.ico


+ 50 - 0
src/components/mapClass/EditScence.ts

@@ -144,6 +144,13 @@ export class EditScence extends SGraphScene {
      * 增加线段item
      */
     addLine(event: SMouseEvent): boolean {
+        const clickItem = this.clickIsItem(event);
+        if (clickItem) {
+            let centerPoint = clickItem.boundingRect().center();
+            const p = clickItem.mapToScene(centerPoint.x, centerPoint.y);
+            event.x = p.x;
+            event.y = p.y;
+        }
         const data = {
             /** ID */
             ID: uuid(),
@@ -928,6 +935,49 @@ export class EditScence extends SGraphScene {
     }
 
     /**
+     *  划线时点击位置是在文本,图片,,区域内
+     *
+     *  @param  event   事件
+     *  @return 点击的item
+     * */
+    clickIsItem(event: SMouseEvent): SGraphItem | null {
+        let minIten = null;
+        let len: number = -1;
+        let itemList = this.Nodes.concat(this.Markers);
+        itemList.forEach(item => {
+            if (
+                item instanceof STextMarkerItem || 
+                item instanceof SImageMarkerItem ||
+                item instanceof SZoneLegendItem ||
+                item instanceof SFHFQZoneLegendItem ||
+                item instanceof SSCPZZoneLegendItem
+            ) {
+                let scenePoint = item.mapFromScene(event.x, event.y);
+                if (item.contains(scenePoint.x, scenePoint.y)) {
+                    let dis = SMathUtil.pointDistance(
+                        scenePoint.x,
+                        scenePoint.y,
+                        item.boundingRect().center().x,
+                        item.boundingRect().center().y
+                    );
+                    if (len < 0) {
+                        minIten = item;
+                        len = dis;
+                    }
+                    if (dis < len) {
+                        minIten = item;
+                        len = dis;
+                    }
+                }
+            }
+        })
+        console.log('-----------------------')
+        console.log(minIten)
+        console.log('-----------------------')
+        return minIten;
+    }
+
+    /**
       *  点是否在吸附区域内
       *
       *  @param  p       要判断的点

+ 27 - 0
src/lib/items/SLineMarkerItem.ts

@@ -10,6 +10,11 @@ import { Marker } from '../types/Marker';
  * * @author  张宇(taohuzy@163.com)
  */
 export class SLineMarkerItem extends SLineItem {
+     /** 起始锚点  */
+    startItem: SGraphItem | null = null;
+    /** 结束锚点  */
+    endItem: SGraphItem | null = null;
+
     /** 标识对象数据 */
     data: Marker;
 
@@ -57,6 +62,22 @@ export class SLineMarkerItem extends SLineItem {
         }
     } // Constructor
 
+    /** 接收事件作出修改  */
+    changePos() {
+        if (this.startItem) {
+            // 判断删除equip后,不移动
+            if (this.startItem.parent) {
+                this.line[0] = this.startItem.mapToScene(0, 0);
+            }
+        }
+        if (this.endItem) {
+            // 删除equip后
+            if (this.endItem.parent) {
+                this.line[1] = this.endItem.mapToScene(0, 0);
+            }
+        }
+    }
+
     toData(): Marker {
         this.data.Pos = { X: this.x, Y: this.y };
         this.data.Properties.Line = this.line.map(pos => {
@@ -68,6 +89,12 @@ export class SLineMarkerItem extends SLineItem {
         this.data.Properties.LineWidth = this.lineWidth;
         this.data.Properties.StrokeColor = this.strokeColor.value;
         this.data.Properties.LineStyle = this.lineStyle;
+        if (this.startItem && this.startItem.parent) {
+            this.data.Properties.StartItemId = this.startItem.id;
+        }
+        if (this.endItem && this.endItem.parent) {
+            this.data.Properties.EndItemId = this.endItem.id;
+        }
         return this.data;
     }