Просмотр исходного кода

修改 层级 单独opt配置文件

haojianlong 5 лет назад
Родитель
Сommit
28461c0564

+ 1 - 1
package.json

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

+ 0 - 1
src/DivideFloorScene.ts

@@ -201,7 +201,6 @@ export class DivideFloorScene extends FloorScene {
      */
     addZone(zone: Zone): void {
         let item = new ZoneItem(null, zone);
-        item.zOrder = 3;
         item.selectable = this.isZoneSelectable;
         this.zoneList.push(item);
         this.addItem(item);

+ 0 - 17
src/FloorScene.ts

@@ -309,7 +309,6 @@ export class FloorScene extends SGraphyScene {
      */
     addSpace(space: Space): void {
         let item = new SpaceItem(null, space);
-        item.zOrder = 2;
         item.visible = this.isShowSpace;
         item.selectable = this.isSpaceSelectable;
         this.spaceList.push(item);
@@ -324,7 +323,6 @@ export class FloorScene extends SGraphyScene {
     addColumn(column: Column): void {
         let item = new ColumnItem(null, column);
         item.visible = this.isShowColumn;
-        item.zOrder = 4;
         this.columnList.push(item);
         this.addItem(item);
     } // Function addColumn
@@ -337,7 +335,6 @@ export class FloorScene extends SGraphyScene {
     addWall(wall: Wall): void {
         let item = new WallItem(null, wall);
         item.visible = this.isShowWall;
-        item.zOrder = 5;
         this.wallList.push(item);
         this.addItem(item);
     } // Function addWall
@@ -350,7 +347,6 @@ export class FloorScene extends SGraphyScene {
     addVirtualWall(virtualWall: VirtualWall): void {
         let item = new VirtualWallItem(null, virtualWall);
         item.visible = this.isShowVirtualWall;
-        item.zOrder = 6;
         this.virtualWallList.push(item);
         this.addItem(item);
     } // Function addVirtualWall
@@ -362,7 +358,6 @@ export class FloorScene extends SGraphyScene {
      */
     addDoor(door: Door): void {
         let item = new DoorItem(null, door);
-        item.zOrder = 7;
         item.visible = this.isShowDoor;
         this.doorList.push(item);
         this.addItem(item);
@@ -375,7 +370,6 @@ export class FloorScene extends SGraphyScene {
      */
     addCasement(casement: Casement): void {
         let item = new WindowItem(null, casement);
-        item.zOrder = 8;
         item.visible = this.isShowWindow;
         this.casementList.push(item);
         this.addItem(item);
@@ -458,15 +452,4 @@ export class FloorScene extends SGraphyScene {
             return sp;
         });
     } // Function clearSelectedSpaces
-
-    /**
-     *  点到点距离
-     *  @param  p1  第一点
-     *  @param  p2  第二点
-     */
-    PointToPointDis(p1: SPoint, p2: SPoint): number {
-        return Math.sqrt(
-            (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y)
-        );
-    } // Function PointToPointDis()
 } // Class FloorScene

+ 0 - 1
src/LocationPointScene.ts

@@ -73,7 +73,6 @@ export class LocationPointScene extends FloorScene {
     addMarker(marker: Marker) {
         let mark = new MarkerItem(null, marker);
         mark.moveTo(marker.X, marker.Y);
-        mark.zOrder = 99999;
         mark.selectable = this.isMarkSelectable;
         this.markerList.push(mark);
         this.addItem(mark);

+ 2 - 0
src/items/ColumnItem.ts

@@ -22,6 +22,7 @@ import { Column } from "../types/Column";
 import { Opt } from "../types/Opt";
 import { SGraphyItem } from "@saga-web/graphy/lib";
 import { SPainter, SPoint, SRect } from "@saga-web/draw/lib";
+import { ItemOrder } from "../types/ItemOrder";
 
 /**
  * 柱子item
@@ -51,6 +52,7 @@ export class ColumnItem extends SGraphyItem {
     constructor(parent: SGraphyItem | null, data: Column) {
         super(parent);
         this.data = data;
+        this.zOrder = ItemOrder.columnOrder;
         let tempArr = this.data.OutLine;
         if (tempArr && tempArr.length) {
             this.minX = tempArr[0][0].X;

+ 4 - 3
src/items/DoorItem.ts

@@ -22,6 +22,8 @@ import { Door } from "../types/Door";
 import { Opt } from "../types/Opt";
 import { SGraphyItem } from "@saga-web/graphy/lib";
 import { SPainter, SPoint, SRect } from "@saga-web/draw/lib";
+import { SMathUtil } from "../utils/SMathUtil";
+import { ItemOrder } from "../types/ItemOrder";
 
 /**
  * 门item
@@ -51,6 +53,7 @@ export class DoorItem extends SGraphyItem {
     constructor(parent: SGraphyItem | null, data: Door) {
         super(parent);
         this.data = data;
+        this.zOrder = ItemOrder.doorOrder;
         if (this.data.OutLine.length) {
             this.pointArr = this.data.OutLine[0].map(t => {
                 return new SPoint(t.X, -t.Y);
@@ -77,9 +80,7 @@ export class DoorItem extends SGraphyItem {
                 -this.data.FaceDirection.Y / this.data.FaceDirection.X
             );
             // 两点间距离
-            this.r = Math.sqrt(
-                (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y)
-            );
+            this.r = SMathUtil.pointDistance(p1.x, p1.y, p2.x, p2.y);
             // 门朝向角度
             this.ang = this.data.FaceDirection.X > 0 ? fo : fo + Math.PI;
             // 旋转点

+ 4 - 3
src/items/HighlightItem.ts

@@ -21,6 +21,7 @@
 import { SGraphyItem } from "@saga-web/graphy/lib";
 import { SColor, SLine, SPainter, SPoint } from "@saga-web/draw/lib";
 import { Opt } from "../types/Opt";
+import { ItemOrder } from "../types/ItemOrder";
 
 /**
  * 吸附时高亮对象
@@ -61,7 +62,7 @@ export class HighlightItem extends SGraphyItem {
     constructor(parent: SGraphyItem | null) {
         super(parent);
         this.visible = false;
-        this.zOrder = 99;
+        this.zOrder = ItemOrder.highLightOrder;
     } // Constructor
 
     /**
@@ -71,12 +72,12 @@ export class HighlightItem extends SGraphyItem {
      */
     onDraw(painter: SPainter): void {
         if (this.type == 2) {
-            painter.pen.color = Opt.hightLightLineColor;
+            painter.pen.color = Opt.highLightLineColor;
             painter.pen.lineWidth = painter.toPx(6);
             painter.drawLine(this.line);
         }
         painter.pen.color = SColor.Transparent;
-        painter.brush.color = Opt.hightLightPointColor;
+        painter.brush.color = Opt.highLightPointColor;
         painter.drawCircle(this.point.x, this.point.y, painter.toPx(5));
     } // Function onDraw()
 } // Class HighlightItem

+ 2 - 0
src/items/MarkItem.ts

@@ -22,6 +22,7 @@ import { Marker } from "../types/Marker";
 import { SGraphyItem } from "@saga-web/graphy/lib";
 import { SPainter, SRect } from "@saga-web/draw/lib";
 import { SMouseEvent } from "@saga-web/base/lib";
+import {ItemOrder} from "../types/ItemOrder";
 
 /**
  * 标志item
@@ -51,6 +52,7 @@ export class MarkerItem extends SGraphyItem {
     constructor(parent: SGraphyItem | null, data: Marker) {
         super(parent);
         this.data = data;
+        this.zOrder = ItemOrder.markOrder;
         this.Img = new Image();
         this.Img.src = MarkerItem.imgSource;
         this.isTransform = false;

+ 2 - 1
src/items/SceneMarkItem.ts

@@ -30,6 +30,7 @@ import {
     SRect
 } from "@saga-web/draw/lib";
 import { SMouseEvent } from "@saga-web/base/lib";
+import { ItemOrder } from "../types/ItemOrder";
 
 /**
  * 蒙版item
@@ -77,7 +78,7 @@ export class SceneMarkItem extends SGraphyItem {
             this.outLine.push(data);
             this.lastPoint = data;
         }
-        this.zOrder = Number.MAX_SAFE_INTEGER;
+        this.zOrder = ItemOrder.sceneMarkOrder;
     } // Constructor
 
     /**

+ 2 - 0
src/items/SpaceItem.ts

@@ -30,6 +30,7 @@ import {
 import { Space } from "../types/Space";
 import { Opt } from "../types/Opt";
 import { SMouseEvent } from "@saga-web/base/lib";
+import { ItemOrder } from "../types/ItemOrder";
 
 /**
  * 模型空间item
@@ -62,6 +63,7 @@ export class SpaceItem extends SGraphyItem {
     constructor(parent: SGraphyItem | null, data: Space) {
         super(parent);
         this.data = data;
+        this.zOrder = ItemOrder.spaceOrder;
         let tempArr = this.data.OutLine;
         if (tempArr && tempArr.length) {
             this.minX = tempArr[0][0].X;

+ 2 - 0
src/items/VirtualWallItem.ts

@@ -22,6 +22,7 @@ import { SGraphyItem } from "@saga-web/graphy/lib";
 import { SPainter, SPoint, SRect } from "@saga-web/draw/lib";
 import { VirtualWall } from "../types/VirtualWall";
 import { Opt } from "../types/Opt";
+import { ItemOrder } from "../types/ItemOrder";
 
 /**
  * 墙item
@@ -51,6 +52,7 @@ export class VirtualWallItem extends SGraphyItem {
     constructor(parent: SGraphyItem | null, data: VirtualWall) {
         super(parent);
         this.data = data;
+        this.zOrder = ItemOrder.virtualWallOrder;
         let tempArr = this.data.OutLine;
         if (tempArr && tempArr.length) {
             this.minX = tempArr[0][0].X;

+ 2 - 0
src/items/WallItem.ts

@@ -22,6 +22,7 @@ import { SGraphyItem } from "@saga-web/graphy/lib";
 import { SPainter, SPoint, SRect } from "@saga-web/draw/lib";
 import { Wall } from "../types/Wall";
 import { Opt } from "../types/Opt";
+import {ItemOrder} from "../types/ItemOrder";
 
 /**
  * 墙item
@@ -51,6 +52,7 @@ export class WallItem extends SGraphyItem {
     constructor(parent: SGraphyItem | null, data: Wall) {
         super(parent);
         this.data = data;
+        this.zOrder = ItemOrder.wallOrder;
         let tempArr = this.data.OutLine;
         if (tempArr && tempArr.length) {
             this.minX = tempArr[0][0].X;

+ 2 - 0
src/items/WindowItem.ts

@@ -22,6 +22,7 @@ import { SGraphyItem } from "@saga-web/graphy/lib";
 import { SPainter, SPoint, SRect } from "@saga-web/draw/lib";
 import { Casement } from "../types/Casement";
 import { Opt } from "../types/Opt";
+import { ItemOrder } from "../types/ItemOrder";
 
 /**
  * 窗户item
@@ -43,6 +44,7 @@ export class WindowItem extends SGraphyItem {
     constructor(parent: SGraphyItem | null, data: Casement) {
         super(parent);
         this.data = data;
+        this.zOrder = ItemOrder.windowOrder;
         if (this.data.OutLine.length) {
             this.pointArr = this.data.OutLine[0].map(t => {
                 return new SPoint(t.X, -t.Y);

+ 2 - 0
src/items/ZoneItem.ts

@@ -29,6 +29,7 @@ import {
 } from "@saga-web/draw/lib";
 import { Zone } from "../types/Zone";
 import { SMouseEvent } from "@saga-web/base/lib";
+import { ItemOrder } from "../types/ItemOrder";
 
 /**
  * 业务空间item
@@ -68,6 +69,7 @@ export class ZoneItem extends SGraphyItem {
     constructor(parent: SGraphyItem | null, data: Zone) {
         super(parent);
         this.data = data;
+        this.zOrder = ItemOrder.zoneOrder;
         if (
             this.data.OutLine.length &&
             this.data.OutLine[0] &&

+ 47 - 0
src/types/ItemOrder.ts

@@ -0,0 +1,47 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+/**
+ * 接口
+ *
+ * @author  郝建龙
+ */
+export class ItemOrder {
+    /** 空间层级 */
+    static spaceOrder = 2;
+    /** 业务空间层级 */
+    static zoneOrder = 3;
+    /** 柱子层级 */
+    static columnOrder = 4;
+    /** 墙层级 */
+    static wallOrder = 5;
+    /** 虚拟墙层级 */
+    static virtualWallOrder = 6;
+    /** 门层级 */
+    static doorOrder = 7;
+    /** 窗户层级 */
+    static windowOrder = 8;
+    /** 位置标签对象层级 */
+    static markOrder = 99;
+    /** 高亮对象层级 */
+    static highLightOrder = 999;
+    /** 蒙版层级 */
+    static sceneMarkOrder = Number.MAX_SAFE_INTEGER;
+} // Interface ItemOrder

+ 2 - 2
src/types/Opt.ts

@@ -41,7 +41,7 @@ export class Opt {
     /** 蒙版颜色    */
     static sceneMarkColor = new SColor("#00000080");
     /** 高亮item吸附点颜色    */
-    static hightLightPointColor = new SColor("#efff00");
+    static highLightPointColor = new SColor("#ff8d00");
     /** 高亮item吸附线颜色    */
-    static hightLightLineColor = new SColor("#409EFF");
+    static highLightLineColor = new SColor("#409EFF");
 } // Interface Opt