Jelajahi Sumber

'添加系统图解析器'

zhangyu 5 tahun lalu
induk
melakukan
c19adba93f

+ 13 - 0
saga-web-big/src/enums/SLineType.ts

@@ -0,0 +1,13 @@
+/**
+ * 线类型
+ *
+ * @author  张宇
+ */
+export enum SLineType {
+	/** 直线    */
+	Straight,
+	/** 水平/垂直线    */
+	Angle,
+	/** 曲线    */
+	Curve
+} // Enum SLineType

+ 11 - 0
saga-web-big/src/enums/SMarkerType.ts

@@ -0,0 +1,11 @@
+/**
+ * 标识对象类型
+ *
+ * @author  张宇
+ */
+export enum SMarkerType {
+	/** 图标    */
+	Image,
+	/** 线类型    */
+	Line,
+} // Enum SMarkerType

+ 13 - 0
saga-web-big/src/enums/SRlationDir.ts

@@ -0,0 +1,13 @@
+/**
+ * 关系方向
+ *
+ * @author  张宇
+ */
+export enum SRlationDir {
+	/** 无向    */
+	Undirected,
+	/** 正向(节点1到节点2)    */
+	Forward,
+	/** 逆向(节点2到节点1)    */
+	Reverse
+} // Enum SRlationDir

+ 67 - 0
saga-web-big/src/factories/SItemFactory.ts

@@ -15,6 +15,17 @@ import { Zone } from "../types/floor/Zone";
 import { SImageItem, STextItem } from "..";
 import { ImageData } from "../types/ImageData";
 import { TextData } from "../types/TextData";
+import { Node } from "../types/topology/Node";
+import { Marker } from "../types/topology/Marker";
+import { Relation } from "../types/topology/Relation";
+import { SEntityItem } from "./../items/topology/SEntityItem";
+import { SRelation } from "./../items/topology/SRelation";
+import { SLineRelation } from "./../items/topology/SLineRelation";
+import { SVerticalRelation } from "./../items/topology/SVerticalRelation";
+import { SCurveRelation } from "./../items/topology/SCurveRelation";
+import { Anchor } from "../types/topology/Anchor";
+import { SAnchorItem } from "../items/topology/SAnchorItem";
+import { SLineType } from "../enums/SLineType";
 
 /**
  * 拓扑图信息解析器
@@ -115,4 +126,60 @@ export class SItemFactory {
     // createText(data: TextData): STextItem {
     //     return new STextItem(null);
     // } // Function createImage()
+
+    /**
+     * 创建图例节点item
+     *
+     * @param   data    图例节点数据
+     * */
+    createNode(data: Node): SEntityItem {
+        let entityItem = new SEntityItem(null);
+        if (data.AnchorList && data.AnchorList.length ) {
+            data.AnchorList.forEach((anchor: Anchor) => {
+                let anchorItem = new SAnchorItem(entityItem);
+                if (anchor && anchor.Pos) {
+                    anchorItem.moveTo(anchor.Pos.X, anchor.Pos.Y)
+                }
+            }) 
+        }
+        return entityItem;
+    } // Function createNode()
+
+    /**
+     * 创建标识item
+     *
+     * @param   data    标识对象数据
+     * */
+    createMarker(data: Marker): SImageItem {
+        return new SImageItem(null);
+    } // Function createMarker()
+
+    /**
+     * 创建管线关系item
+     *
+     * @param   data    管线关系对象数据
+     * */
+    createRelation(data: Relation): SRelation {
+        switch(data.LineType) {
+            case SLineType.Straight:
+                return new SLineRelation(null);
+            case SLineType.Angle: 
+                return new SVerticalRelation(null);
+            case SLineType.Curve:
+                return new SCurveRelation(null);
+            default:
+                return new SLineRelation(null);
+        }
+    } // Function createRelation()
+
+    
+    /**
+     * 创建锚点item
+     *
+     * @param   data    锚点数据
+     * */
+    createAnchor(data: Anchor): SAnchorItem {
+        return new SAnchorItem(null);
+    } // Function createAnchor()
+
 } // class SItemFactory

+ 69 - 1
saga-web-big/src/parser/STopologyParser.ts

@@ -1,7 +1,75 @@
 import { SParser } from "./SParser";
+import { SEntityItem } from "./../items/topology/SEntityItem";
+import { SRelation } from "./../items/topology/SRelation";
+import { SImageItem } from "./../items/SImageItem";
+import { ElementData } from "../types/ElementData";
+import { Node } from "../types/topology/Node";
+import { Marker } from "../types/topology/Marker";
+import { Relation } from "../types/topology/Relation";
 
 /**
  * 拓扑图信息解析器
  *
  */
-export class STopologyParser extends SParser {} // class STopologyParser
+export class STopologyParser extends SParser {
+	/** 图例节点list   */
+	nodeList: SEntityItem[] = [];
+	/** 标识对象list   */
+	markersList: SImageItem[] = [];
+	/** 管线关系对象关系list   */
+	relationList: SRelation[] = [];
+
+	/**
+     * 解析数据
+     *
+     * @param   data    系统图数据
+     * */
+    parseData(data: ElementData): void {
+        if (data.Nodes) {
+            data.Nodes.forEach((t: Node): void => {
+                this.addNode(t);
+            });
+        }
+        if (data.Markers) {
+            data.Markers.forEach((t: Marker): void => {
+                this.addMarker(t);
+            });
+        }
+        if (data.Relations) {
+            data.Relations.forEach((t: Relation): void => {
+                this.addRelation(t);
+            });
+        }
+	} // Function parseData()
+	
+	/**
+     * 添加图例节点至场景中
+     *
+     * @param   t       图例节点数据
+     * */
+    private addNode(t: Node): void {
+        let item = this.factory.createNode(t);
+        this.nodeList.push(item);
+	} // Function addNode()
+	
+	/**
+     * 添加标识对象至场景中
+     *
+     * @param   t       标识对象数据
+     * */
+    private addMarker(t: Marker): void {
+        let item = this.factory.createMarker(t);
+        this.markersList.push(item);
+	} // Function addMarker()
+	
+	/**
+     * 添加管线关系至场景中
+     *
+     * @param   t       管线关系对象数据
+     * */
+    private addRelation(t: Relation): void {
+        let item = this.factory.createRelation(t);
+        this.relationList.push(item);
+    } // Function addRelation()
+
+} // class STopologyParser

+ 34 - 0
saga-web-big/src/types/ElementData.ts

@@ -0,0 +1,34 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+import { Node } from "./topology/Node";
+import { Marker } from "./topology/Marker";
+import { Relation } from "./topology/Relation";
+
+/**
+ * 系统图数据接口
+ *
+ * @author  张宇
+ */
+export interface ElementData {
+    Nodes: Node[];
+    Markers: Marker[];
+    Relations: Relation[];
+} // Interface ElementData

+ 1 - 1
saga-web-big/src/types/Point.ts

@@ -26,5 +26,5 @@
 export interface Point {
     X: number;
     Y: number;
-    Z: number;
+    Z?: number;
 } // Interface Point

+ 29 - 0
saga-web-big/src/types/Size.ts

@@ -0,0 +1,29 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+/**
+ * 大小接口
+ *
+ * @author  张宇
+ */
+export interface Size {
+  Width: number;
+  Height: number;
+} // Interface Size

+ 45 - 0
saga-web-big/src/types/TopologyData.ts

@@ -0,0 +1,45 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+import { ElementData } from "./ElementData";
+
+/**
+ * 系统图json数据接口
+ *
+ * @author  张宇
+ */
+export interface TopologyData {
+    /** ID */
+    ID: string;
+    /** 系统图展示所需数据 */
+    Elements: ElementData;
+    /** 名称  */
+    Name?: string;
+    /** 图分类ID  */
+    CategoryID?: string;
+    /** 项目ID  */
+    ProjectID?: string;
+    /** 建筑ID  */
+    BuildingID?: string;
+    /** 楼层ID  */
+    FloorID?: string;
+    /** 图说明  */
+    Note?: string;
+} // Interface TopologyData

+ 33 - 0
saga-web-big/src/types/topology/Anchor.ts

@@ -0,0 +1,33 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+import { Point } from "../Point";
+
+/**
+ * 锚点item接口
+ *
+ * @author  张宇
+ */
+export interface Anchor {
+    /** 锚点ID */
+    ID: string;
+    /** 锚点的坐标  */
+    Pos?: Point;
+} // Interface Anchor

+ 47 - 0
saga-web-big/src/types/topology/Marker.ts

@@ -0,0 +1,47 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+import { Point } from "../Point";
+import { Size } from "../Size";
+import { SMarkerType } from "../../enums/SMarkerType";
+
+/**
+ * 标识对象接口
+ *
+ * @author  张宇
+ */
+export interface Marker {
+    /** ID */
+    ID: string;
+    /** 名称  */
+    Name?: string;
+    /** 图标(Image),线类型(Line) */
+    Type?: SMarkerType;
+    /** 位置  */
+    Pos?: Point;
+    /** 缩放  */
+    Scale?: Point;
+    /** 旋转  */
+    Rolate?: Point;
+    /** 大小  */
+    Size?: Size;
+    /** 由应用自己定义  */
+    Properties?: any;
+} // Interface Marker

+ 55 - 0
saga-web-big/src/types/topology/Node.ts

@@ -0,0 +1,55 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+import { Point } from "../Point";
+import { Size } from "../Size";
+import { Anchor } from "./Anchor";
+
+/**
+ * 图例节点接口
+ *
+ * @author  张宇
+ */
+export interface Node {
+    /** ID */
+    ID: string;
+    /** 名称  */
+    Name?: string;
+    /** 返回工程信息化对象 ID 列表 */
+    AttachObjectIds?: string[];
+    /** 图标,区域类型  */
+    GraphElementType?: string;
+    /** 对应的图例ID  */
+    GraphElementId?: string;
+    /** 位置  */
+    Pos?: Point;
+    /** 缩放  */
+    Scale?: Point;
+    /** 旋转  */
+    Rolate?: Point;
+    /** 大小  */
+    Size?: Size;
+    /** 锚点List  */
+    AnchorList?: Anchor[];
+    /** 轮廓线  */
+    OutLine: Point[][];
+    /** 由应用自己定义  */
+    Properties?: any;
+} // Interface Node

+ 53 - 0
saga-web-big/src/types/topology/Relation.ts

@@ -0,0 +1,53 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+import { Point } from "../Point";
+import { SRlationDir } from "../../enums/SRlationDir";
+import { SLineType } from "../../enums/SLineType";
+
+/**
+ * 管线对象关系接口
+ *
+ * @author  张宇
+ */
+export interface Relation {
+     /** ID */
+     ID: string;
+     /** 名称 */
+     Name?: string;
+     /** 对应的图例ID */
+    GraphElementId?: string;
+    /** 关联节点1_id */
+    NodeID1?: string;
+    /** 关联节点2_id */
+    NodeID2?: string;
+    /** 关联锚点1_id  */
+    Anchor1ID: Point[][];
+    /** 关联锚点2_id */
+    Anchor2ID?: string;
+    /** 方向(0:无向,1:节点1到节点2,2:节点2到节点1) */
+    Dir?: SRlationDir;
+    /** 线类型(0:直线,1:水平/垂直线,2:曲线) */
+    LineType?: SLineType;
+    /** 线的顶点坐标 */
+    PointList?: Point[];
+    /** 线的绘图样式 */
+    Style?: string;
+} // Interface Relation