Explorar el Código

修改fittoview 底图跑偏问题;高亮item添加时机(待优化至get与set中)

haojianlong hace 5 años
padre
commit
3b361d319f

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/cad-engine",
-    "version": "2.0.489",
+    "version": "2.0.496",
     "description": "上格云 CAD图形引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 22 - 5
src/DivideFloorScene.ts

@@ -66,7 +66,7 @@ export class DivideFloorScene extends FloorScene {
     /** 类空间itemList */
     likeSpaceList: LikeSpaceItem[] = [];
     /** 高亮item  */
-    highLight: HighlightItem = new HighlightItem(null);
+    highLight: HighlightItem | null = null;
     /** 是否开启切分  */
     isCutting: boolean = false;
     /** 业务空间是否可选    */
@@ -116,7 +116,6 @@ export class DivideFloorScene extends FloorScene {
      */
     constructor() {
         super();
-        this.addItem(this.highLight);
     } // Constructor
 
     /**
@@ -256,7 +255,11 @@ export class DivideFloorScene extends FloorScene {
         if (event.buttons == 1) {
             if (this.isMarking) {
                 // 判断是否开启吸附,并且有吸附的点
-                if (this.isAbsorbing && this.highLight.visible) {
+                if (
+                    this.isAbsorbing &&
+                    this.highLight &&
+                    this.highLight.visible
+                ) {
                     event.x = this.highLight.point.x;
                     event.y = this.highLight.point.y;
                 }
@@ -274,7 +277,11 @@ export class DivideFloorScene extends FloorScene {
                 }
             } else if (this.isCutting) {
                 // 判断是否开启吸附,并且有吸附的点
-                if (this.isAbsorbing && this.highLight.visible) {
+                if (
+                    this.isAbsorbing &&
+                    this.highLight &&
+                    this.highLight.visible
+                ) {
                     event.x = this.highLight.point.x;
                     event.y = this.highLight.point.y;
                 }
@@ -345,8 +352,12 @@ export class DivideFloorScene extends FloorScene {
             return false;
         }
         super.onMouseMove(event);
-        this.highLight.visible = false;
         if (this.isAbsorbing) {
+            if (!this.highLight) {
+                this.highLight = new HighlightItem(null);
+                this.addItem(this.highLight);
+            }
+            this.highLight.visible = false;
             if (!this.absorbShade(event)) {
                 this.absorbSpace(event);
             }
@@ -452,6 +463,9 @@ export class DivideFloorScene extends FloorScene {
      *  @return boolean 是否找到吸附的对象
      */
     absorbSpace(event: SMouseEvent): boolean {
+        if (!this.highLight) {
+            return false;
+        }
         let absorbLen = 1000;
         if (this.view) {
             absorbLen = 10 / this.view.scale;
@@ -593,6 +607,9 @@ export class DivideFloorScene extends FloorScene {
      *  @return boolean 是否找到吸附的对象
      */
     absorbShade(event: SMouseEvent): boolean {
+        if (!this.highLight) {
+            return false;
+        }
         let absorbLen = 1000;
         if (this.view) {
             absorbLen = 10 / this.view.scale;

+ 30 - 0
src/RelationScene.ts

@@ -0,0 +1,30 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+import { FloorScene } from "./FloorScene";
+
+/**
+ * 空间关系图
+ *
+ * @author 郝建龙
+ */
+export class RelationScene extends FloorScene {
+
+} // Class RelationScene

+ 8 - 1
src/index.ts

@@ -15,8 +15,15 @@ import { HighlightItem } from "./items/HighlightItem";
 import { ShadeItem } from "./items/ShadeItem";
 import { RectSelectItem } from "./items/RectSelectItem";
 import { LikeSpaceItem } from "./items/LikeSpaceItem";
+import { RelationScene } from "./RelationScene";
 
-export { FloorScene, LocationPointScene, DivideFloorScene, FloorView };
+export {
+    FloorScene,
+    LocationPointScene,
+    DivideFloorScene,
+    FloorView,
+    RelationScene
+};
 
 export {
     SpaceItem,

+ 10 - 1
src/items/HighlightItem.ts

@@ -19,7 +19,7 @@
  */
 
 import { SGraphyItem } from "@saga-web/graphy/lib";
-import { SColor, SLine, SPainter, SPoint } from "@saga-web/draw/lib";
+import { SColor, SLine, SPainter, SPoint, SRect } from "@saga-web/draw/lib";
 import { Opt } from "../types/Opt";
 import { ItemOrder } from "../types/ItemOrder";
 
@@ -66,6 +66,15 @@ export class HighlightItem extends SGraphyItem {
     } // Constructor
 
     /**
+     * Item对象边界区域
+     *
+     * @return	SRect
+     */
+    boundingRect(): SRect {
+        return new SRect(this.point.x, this.point.y, 10, 10);
+    } // Function boundingRect()
+
+    /**
      * Item绘制操作
      *
      * @param   painter painter对象

+ 4 - 4
src/items/LikeSpaceItem.ts

@@ -43,13 +43,13 @@ export class LikeSpaceItem extends SGraphyItem {
     /** 空间轮廓线坐标list  */
     readonly pointArr: SPoint[][] = [];
     /** X坐标最小值  */
-    minX = 0;
+    minX = Number.MAX_SAFE_INTEGER;
     /** X坐标最大值  */
-    maxX = 0;
+    maxX = Number.MIN_SAFE_INTEGER;
     /** Y坐标最小值  */
-    minY = 0;
+    minY = Number.MAX_SAFE_INTEGER;
     /** Y坐标最大值  */
-    maxY = 0;
+    maxY = Number.MIN_SAFE_INTEGER;
     /** path对象      */
     private path = new SPath2D();
     /** 高亮状态    */

+ 14 - 0
src/items/WindowItem.ts

@@ -77,6 +77,20 @@ export class WindowItem extends SGraphyItem {
     } // Constructor
 
     /**
+     * Item对象边界区域
+     *
+     * @return SRect
+     */
+    boundingRect(): SRect {
+        return new SRect(
+            this.minX,
+            this.minY,
+            this.maxX - this.minX,
+            this.maxY - this.minY
+        );
+    } // Function boundingRect()
+
+    /**
      * Item绘制操作
      *
      * @param   painter       painter对象

+ 39 - 0
src/types/Vertex.ts

@@ -0,0 +1,39 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+import { Point } from "./Point";
+
+/**
+ * 空间关系点接口
+ *
+ * @author  郝建龙
+ */
+export interface Vertex {
+    /** 位置  */
+    Location: Point;
+    /** 模型id(外键)    */
+    Radius: number;
+    /** 名称  */
+    Thickness: number;
+    /** 轮廓线  */
+    Id: string | null;
+    /** 对应Revit模型id */
+    SourceId: string;
+} // interface Vertex