소스 검색

'合并冲突'

zhangyu 4 년 전
부모
커밋
38e4e57e4a
5개의 변경된 파일313개의 추가작업 그리고 31개의 파일을 삭제
  1. 7 27
      package-lock.json
  2. 1 1
      package.json
  3. 1 0
      src/components/baseEditer.vue
  4. 211 3
      src/components/mapClass/EditScence.ts
  5. 93 0
      src/lib/items/HighlightItem.ts

+ 7 - 27
package-lock.json

@@ -1064,21 +1064,11 @@
       "integrity": "sha512-lVDkCBkgu+nSkwyJrOU09aNnInRGrfeMFYANABSwtVmO7+4HK/T0qPCP1KiGZsq8vP6s1MDe+9fax1hp9Evefg=="
     },
     "@saga-web/big": {
-      "version": "1.0.48",
-      "resolved": "http://192.168.200.80:8081/repository/npm-saga/@saga-web/big/-/big-1.0.48.tgz",
-      "integrity": "sha512-ql3Hglt9HcdbtoJ2v5k6vEs4ECvDTQoBvILLh22K4ByEc26k9kLITISDjQx2l5tL19HSQ8nr0RH2fi9UHY9e9A==",
+      "version": "1.0.47",
+      "resolved": "http://192.168.200.80:8081/repository/npm-saga/@saga-web/big/-/big-1.0.47.tgz",
+      "integrity": "sha512-lRm/99xR2ahnGEaG1fVEyjXq2c0W68H2dnxCxuygbNBnfrrW8RVMHeSQMEH/irjCB8u8NdaVbBYlzUwUQPknog==",
       "requires": {
         "@saga-web/graph": "2.1.91"
-      },
-      "dependencies": {
-        "@saga-web/graph": {
-          "version": "2.1.91",
-          "resolved": "http://192.168.200.80:8081/repository/npm-saga/@saga-web/graph/-/graph-2.1.91.tgz",
-          "integrity": "sha512-wMMufmOKa8VjBP9qcM7n4V6CMfa3Wj5PDasqT30rqFfbkHAw1YzKFHJp//85bZue8D3nSi53STYWmby4a/KZqg==",
-          "requires": {
-            "@saga-web/draw": "2.1.98"
-          }
-        }
       }
     },
     "@saga-web/draw": {
@@ -1125,21 +1115,11 @@
       }
     },
     "@saga-web/graph": {
-      "version": "2.1.90",
-      "resolved": "http://192.168.200.80:8081/repository/npm-saga/@saga-web/graph/-/graph-2.1.90.tgz",
-      "integrity": "sha512-3tIknvC9HMGztOar5MWa7ezGlu15P+Q886e1VOpTvJ8Wz+SQ+FASjWOqSdYPWqA8SfNHHLDhyY2pmlR9wiyd3g==",
+      "version": "2.1.91",
+      "resolved": "http://192.168.200.80:8081/repository/npm-saga/@saga-web/graph/-/graph-2.1.91.tgz",
+      "integrity": "sha512-wMMufmOKa8VjBP9qcM7n4V6CMfa3Wj5PDasqT30rqFfbkHAw1YzKFHJp//85bZue8D3nSi53STYWmby4a/KZqg==",
       "requires": {
-        "@saga-web/draw": "2.1.97"
-      },
-      "dependencies": {
-        "@saga-web/draw": {
-          "version": "2.1.97",
-          "resolved": "http://192.168.200.80:8081/repository/npm-saga/@saga-web/draw/-/draw-2.1.97.tgz",
-          "integrity": "sha512-wQw6XI5SrY0bvgBvdPguMPEv/mY3FGUxjm9fctGDHhrX0m9x8h4wljTYaRWXe/VhtMDO4dSXLu2pzvWd+/b69g==",
-          "requires": {
-            "@saga-web/base": "^2.1.21"
-          }
-        }
+        "@saga-web/draw": "2.1.98"
       }
     },
     "@saga-web/graphy": {

+ 1 - 1
package.json

@@ -12,7 +12,7 @@
     "@saga-web/big": "1.0.48",
     "@saga-web/draw": "2.1.98",
     "@saga-web/feng-map": "1.0.11",
-    "@saga-web/graph": "2.1.90",
+    "@saga-web/graph": "2.1.91",
     "@saga-web/topology": "1.0.84",
     "ant-design-vue": "^1.6.0",
     "core-js": "^3.6.4",

+ 1 - 0
src/components/baseEditer.vue

@@ -163,6 +163,7 @@ export default {
               t.selectable = true;
               this.scene.addItem(t);
             });
+            this.scene.spaceList = this.fParser.spaceList;
             this.fParser.wallList.forEach(t => this.scene.addItem(t));
             this.fParser.virtualWallList.forEach(t => this.scene.addItem(t));
             this.fParser.doorList.forEach(t => this.scene.addItem(t));

+ 211 - 3
src/components/mapClass/EditScence.ts

@@ -1,5 +1,5 @@
 import { SMouseEvent, SUndoStack } from "@saga-web/base";
-import { SGraphScene, SGraphLayoutType } from '@saga-web/graph/lib';
+import { SGraphScene, SGraphLayoutType, SAnchorItem } from '@saga-web/graph/lib';
 import { SFloorParser, SLineItem, SPolylineItem, SItemStatus, ItemOrder, STooltipItem } from "@saga-web/big";
 import { SGraphItem, SLineStyle, SImageItem, STextItem, SGraphPointListInsert, SGraphPointListDelete, SGraphPointListUpdate, SGraphAddCommand } from "@saga-web/graph/lib";
 import { SZoneLegendItem } from "@/lib/items/SZoneLegendItem";
@@ -7,9 +7,8 @@ import { SSCPZZoneLegendItem } from "@/lib/items/SSCPZZoneLegendItem";
 import { SFHFQZoneLegendItem } from "@/lib/items/SFHFQZoneLegendItem";
 import { SImageLegendItem } from "@/lib/items/SImageLegendItem";
 import { TipelineItem } from "@/lib/items/TipelineItem";
-import { SImgTextItem } from "@/lib/items/SImgTextItem";
 import { SImageMarkerItem } from "@/lib/items/SImageMarkerItem"
-import { SPoint, SFont, SColor } from '@saga-web/draw/lib';
+import { SPoint, SFont, SColor, SRect } from '@saga-web/draw/lib';
 import { Legend } from '@/lib/types/Legend';
 import { Relation } from '@/lib/types/Relation';
 
@@ -17,6 +16,9 @@ import { uuid } from "@/components/mapClass/until";
 import { STextMarkerItem } from '@/lib/items/STextMarkerItem';
 import { SLineMarkerItem } from '@/lib/items/SLineMarkerItem';
 import { SSpaceItem } from '@saga-web/big/lib/items/floor/SSpaceItem';
+import { SMathUtil } from '@saga-web/big/lib/utils/SMathUtil';
+import { MinDis } from '@saga-web/big/lib/types/MinDis';
+import { HighlightItem } from '@/lib/items/HighlightItem';
 /**
  * 在线绘图
  *
@@ -51,6 +53,11 @@ export class EditScence extends SGraphScene {
     /** 绘制区域时 是否为点选   */
     isSelecting: boolean = false;
 
+    /** 是否开启吸附  */
+    isAbsorbing: boolean = false;
+    /** 吸附展示item    */
+    highLight: HighlightItem | null = null;
+
     /** 当前选中焦点Item */
     focusItem: SGraphItem | null = null;
 
@@ -725,6 +732,15 @@ export class EditScence extends SGraphScene {
     ////////////////////////
     //  以下为鼠标键盘操作事件
     onMouseDown(event: SMouseEvent): any {
+        // 判断是否开启吸附,并且有吸附的点
+        if (
+            this.isAbsorbing &&
+            this.highLight &&
+            this.highLight.visible
+        ) {
+            event.x = this.highLight.point.x;
+            event.y = this.highLight.point.y;
+        }
         if (this.grabItem) {
             return this.grabItem.onMouseDown(event);
         }
@@ -757,6 +773,18 @@ export class EditScence extends SGraphScene {
         }
     }
 
+    onMouseMove(event: SMouseEvent):boolean {
+        if (this.isAbsorbing) {
+            if (!this.highLight) {
+                this.highLight = new HighlightItem(null);
+                this.addItem(this.highLight);
+            }
+            this.highLight.visible = false;
+            this.absorbSpace(event);
+        }
+        return super.onMouseMove(event)
+    }
+
     /**
      * 键盘事件
      *
@@ -772,4 +800,184 @@ export class EditScence extends SGraphScene {
         // }
         return false
     }
+
+    /**
+     *  划线时点击位置是否是锚点
+     *
+     *  @param  event   事件
+     *  @param  len     限制距离
+     *  @return 点击的锚点
+     * */
+    clickIsAnchor(event: SMouseEvent): SAnchorItem | null {
+        let minAnchor = null;
+        let len: number = -1;
+        this.Nodes.forEach(image => {
+            if (image.anchorList && image.anchorList.length) {
+                image.anchorList.forEach(anchor => {
+                    console.log(anchor)
+                    let anchorPoint = anchor.mapToScene(0, 0);
+                    let dis = SMathUtil.pointDistance(
+                        event.x,
+                        event.y,
+                        anchorPoint.x,
+                        anchorPoint.y
+                    );
+                    if (len < 0) {
+                        len = anchor.sceneDis;
+                    }
+                    if (dis < len) {
+                        minAnchor = anchor;
+                        len = dis;
+                    }
+                })
+            }
+        })
+        console.log('-----------------------')
+        console.log(minAnchor)
+        return minAnchor;
+    }
+
+   /**
+     *  点是否在吸附区域内
+     *
+     *  @param  p       要判断的点
+     *  @param  minX    空间区域
+     *  @param  minY    空间区域
+     *  @param  maxX    空间区域
+     *  @param  maxY    空间区域
+     */
+    static isPointInAbsorbArea(
+        p: SPoint,
+        minX: number,
+        maxX: number,
+        minY: number,
+        maxY: number
+    ): boolean {
+        let rect = new SRect(
+            minX - 1000,
+            minY - 1000,
+            maxX - minX + 2000,
+            maxY - minY + 2000
+        );
+        return rect.contains(p.x, p.y);
+    } // Function isPointInAbsorbArea()
+
+    /**
+     *  吸附空间
+     *
+     *  @param  event   鼠标事件对象
+     *  @return boolean 是否找到吸附的对象
+     */
+    absorbSpace(event: SMouseEvent): boolean {
+        if (!this.highLight) {
+            return false;
+        }
+        let absorbLen = 1000;
+        if (this.view) {
+            absorbLen = 10 / this.view.scale;
+        }
+        let P = this.absorbSpacePoint(event, absorbLen);
+        if (P.Point) {
+            this.highLight.distance = P.MinDis;
+            this.highLight.point = new SPoint(P.Point.X, -P.Point.Y);
+            this.highLight.visible = true;
+            return true;
+        } else {
+            let L = this.absorbSpaceLine(event, absorbLen);
+            if (L.Line && L.Point) {
+                this.highLight.distance = L.MinDis;
+                this.highLight.point = L.Point;
+                this.highLight.line = L.Line;
+                this.highLight.visible = true;
+                return true;
+            }
+            return false;
+        }
+    } // Function absorbSpace()
+
+    /**
+     *  吸附空间点
+     *
+     *  @param  event       鼠标事件对象
+     *  @param  absorbLen   吸附距离
+     *  @return MinDis      吸附的点
+     */
+    absorbSpacePoint(event: SMouseEvent, absorbLen: number): MinDis {
+        let minPointDis = Number.MAX_SAFE_INTEGER;
+        let Point;
+        this.spaceList.map((space): void => {
+            if (
+                EditScence.isPointInAbsorbArea(
+                    new SPoint(event.x, event.y),
+                    space.minX,
+                    space.maxX,
+                    space.minY,
+                    space.maxY
+                )
+            ) {
+                space.data.OutLine.forEach((item): void => {
+                    let minDis = SMathUtil.getMinDisPoint(
+                        new SPoint(event.x, event.y),
+                        item
+                    );
+                    if (
+                        minDis &&
+                        minDis.MinDis < absorbLen &&
+                        minDis.MinDis < minPointDis
+                    ) {
+                        minPointDis = minDis.MinDis;
+                        Point = minDis.Point;
+                    }
+                });
+            }
+        });
+        return {
+            MinDis: minPointDis,
+            Point: Point
+        };
+    } // Function absorbSpacePoint()
+
+    /**
+     *  吸附空间线
+     *
+     *  @param  event       鼠标事件对象
+     *  @param  absorbLen   吸附距离
+     *  @return PointToLine 吸附的线
+     */
+    absorbSpaceLine(event: SMouseEvent, absorbLen: number): PointToLine {
+        let minPointDis = Number.MAX_SAFE_INTEGER;
+        let Point, Line;
+        this.spaceList.forEach((space): void => {
+            if (
+                EditScence.isPointInAbsorbArea(
+                    new SPoint(event.x, event.y),
+                    space.minX,
+                    space.maxX,
+                    space.minY,
+                    space.maxY
+                )
+            ) {
+                space.data.OutLine.forEach((item): void => {
+                    let minDisLine = SMathUtil.getMinDisLine(
+                        new SPoint(event.x, event.y),
+                        item
+                    );
+                    if (
+                        minDisLine &&
+                        minDisLine.MinDis < absorbLen &&
+                        minDisLine.MinDis < minPointDis
+                    ) {
+                        minPointDis = minDisLine.MinDis;
+                        Point = minDisLine.Point;
+                        Line = minDisLine.Line;
+                    }
+                });
+            }
+        });
+        return {
+            MinDis: minPointDis,
+            Point: Point,
+            Line: Line
+        };
+    } // Function absorbSpaceLine()
 }

+ 93 - 0
src/lib/items/HighlightItem.ts

@@ -0,0 +1,93 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+import { SGraphItem } from "@saga-web/graph/lib";
+import { SColor, SLine, SPainter, SPoint, SRect } from "@saga-web/draw/lib";
+import { ItemOrder, ItemColor } from '@saga-web/big/lib';
+
+/**
+ * 吸附时高亮对象
+ *
+ * @author  郝建龙
+ */
+export class HighlightItem extends SGraphItem {
+    /** 对象与鼠标位置距离   */
+    distance: number = 0;
+    /** 对象类型   */
+    private type: number = 1;
+
+    /** 点对象数据-当吸附的为线时,此点为垂线与线段的交点   */
+    _point: SPoint = new SPoint();
+    get point(): SPoint {
+        return this._point;
+    } // Get point
+    set point(v: SPoint) {
+        this._point = v;
+        this.type = 1;
+        this.update();
+    } // Set point
+
+    /** 点对象数据   */
+    _line: SLine = new SLine();
+    get line(): SLine {
+        return this._line;
+    } // Get line
+    set line(v: SLine) {
+        this._line = v;
+        this.type = 2;
+        this.update();
+    } // Set line
+
+    /**
+     * 构造函数
+     *
+     * @param   parent  指向父对象
+     */
+    constructor(parent: SGraphItem | null) {
+        super(parent);
+        this.visible = false;
+        this.zOrder = ItemOrder.highLightOrder;
+    } // Constructor
+
+    /**
+     * Item对象边界区域
+     *
+     * @return	SRect
+     */
+    boundingRect(): SRect {
+        return new SRect(this.point.x, this.point.y, 10, 10);
+    } // Function boundingRect()
+
+    /**
+     * Item绘制操作
+     *
+     * @param   painter painter对象
+     */
+    onDraw(painter: SPainter): void {
+        if (this.type == 2) {
+            painter.pen.color = ItemColor.highLightLineColor;
+            painter.pen.lineWidth = painter.toPx(6);
+            painter.drawLine(this.line);
+        }
+        painter.pen.color = SColor.Transparent;
+        painter.brush.color = ItemColor.highLightPointColor;
+        painter.drawCircle(this.point.x, this.point.y, painter.toPx(5));
+    } // Function onDraw()
+} // Class HighlightItem