Prechádzať zdrojové kódy

系统图解析器派生类添加

zhangyu 5 rokov pred
rodič
commit
084e0fae3d

+ 1 - 5
saga-web-big/src/enums/SLineType.ts

@@ -5,9 +5,5 @@
  */
 export enum SLineType {
     /** 直线    */
-    Line,
-    /** 水平/垂直线    */
-    Angle,
-    /** 曲线    */
-    Curve
+    Line
 } // Enum SLineType

+ 9 - 2
saga-web-big/src/factories/SItemFactory.ts

@@ -13,7 +13,7 @@ import { Casement } from "../types/floor/Casement";
 import { SZoneItem } from "../items/floor/ZoneItem";
 import { Zone } from "../types/floor/Zone";
 import { ImageData } from "../types/ImageData";
-import { Node } from "../types/topology/Node";
+import { Legend } from "../types/topology/Legend";
 import { Marker } from "../types/topology/Marker";
 import { Relation } from "../types/topology/Relation";
 import { Anchor } from "../types/topology/Anchor";
@@ -25,6 +25,7 @@ import {
     SVerticalRelation,
     SCurveRelation
 } from "..";
+import {SGraphElementType} from "../enums/SGraphElementType";
 
 /**
  * 拓扑图信息解析器
@@ -131,7 +132,13 @@ export class SItemFactory {
      *
      * @param   data    图例节点数据
      * */
-    createNode(data: Node): SEntityItem {
+    createNode(data: Legend): SEntityItem {
+        if (data.GraphElementType == SGraphElementType.None) {
+            return new SEntityItem(null, data);
+        }
+        if (data.GraphElementType == SGraphElementType.Line) {
+
+        }
         return new SEntityItem(null, data);
     } // Function createNode()
 

+ 15 - 3
saga-web-big/src/index.ts

@@ -1,8 +1,6 @@
 import { SAnchorItem } from "./items/topology/SAnchorItem";
 import { SCompassItem } from "./items/floor/SCompassItem";
 import { SCurveRelation } from "./items/topology/SCurveRelation";
-import { SEntityItem } from "./items/topology/SEntityItem";
-import { SMarkerItem } from "./items/topology/SMarkerItem";
 import { SFloorItem } from "./items/floor/SFloorItem";
 import { SImageItem } from "./items/SImageItem";
 import { SLayerItem } from "./items/SLayerItem";
@@ -27,6 +25,13 @@ import { SPolylineItem } from "./items/SPolylineItem";
 import { SLineItem } from "./items/SLineItem";
 import { SRelationState } from "./enums/SRelationState";
 import { SItemStatus } from "./enums/SItemStatus";
+import { SNoneLegendItem } from "./items/topology/SNoneLegendItem";
+import { SLineLegendItem } from "./items/topology/SLineLegendItem";
+import { SZoneLegendItem } from "./items/topology/SZoneLegendItem";
+import { SImageLegendItem } from "./items/topology/SImageLegendItem";
+import { SImageMarkerItem } from "./items/topology/SImageMarkerItem";
+import { SLineMarkerItem } from "./items/topology/SLineMarkerItem";
+import { STextMarkerItem } from "./items/topology/STextMarkerItem";
 
 export {
     SAnchorItem,
@@ -57,5 +62,12 @@ export {
     SIconTextItem,
     SRelationState,
     SItemStatus,
-    SMarkerItem
+    SMarkerItem,
+    SNoneLegendItem,
+    SLineLegendItem,
+    SZoneLegendItem,
+    SImageLegendItem,
+    SImageMarkerItem,
+    SLineMarkerItem,
+    STextMarkerItem
 };

+ 0 - 31
saga-web-big/src/items/topology/SEntityItem.ts

@@ -1,31 +0,0 @@
-import { SObjectItem } from "../SObjectItem";
-import { Node } from "../../types/topology/Node";
-import { SGraphItem } from "@saga-web/graph/lib";
-
-/**
- * 实例item,与物理世界对应
- *
- * * @author  郝建龙(1061851420@qq.com)
- */
-export class SEntityItem extends SObjectItem {
-    /** 与物理世界对应的实例的所有数据 */
-    data: Node;
-    /** 实例id    */
-    id: string = "";
-    /** 本地编码    */
-    localId: string = "";
-    /** 本地名称    */
-    localName: string = "";
-
-    /**
-     * 构造函数
-     *
-     * @param parent    指向父对象
-     * @param data      图例节点数据
-     */
-    constructor(parent: SGraphItem | null, data: Node) {
-        super(parent);
-        this.data = data;
-        this.id = data.ID;
-    }
-} // Class SEntityItem

+ 24 - 0
saga-web-big/src/items/topology/SImageLegendItem.ts

@@ -0,0 +1,24 @@
+import { Legend } from "../../types/topology/Legend";
+import { SGraphItem } from "@saga-web/graph/lib";
+import { SLineItem } from "../SLineItem";
+
+/**
+ * 图例节点Item(图标类型)
+ *
+ * * @author  张宇(taohuzy@163.com)
+ */
+export class SImageLegendItem extends SGraphItem {
+    /** 图例节点对象数据 */
+    data: Legend;
+
+    /**
+     * 构造函数
+     *
+     * @param parent    指向父对象
+     * @param data      图例节点对象数据
+     */
+    constructor(parent: SGraphItem | null, data: Legend) {
+        super(parent);
+        this.data = data;
+    }
+} // Class SImageLegendItem

+ 24 - 0
saga-web-big/src/items/topology/SImageMarkerItem.ts

@@ -0,0 +1,24 @@
+import { Marker } from "../../types/topology/Marker";
+import { SGraphItem } from "@saga-web/graph/lib";
+import { SImageItem } from "../SImageItem";
+
+/**
+ * 标识对象Item(图标类型)
+ *
+ * * @author  张宇(taohuzy@163.com)
+ */
+export class SImageMarkerItem extends SImageItem {
+    /** 标识对象数据 */
+    data: Marker;
+
+    /**
+     * 构造函数
+     *
+     * @param parent    指向父对象
+     * @param data      标识对象数据
+     */
+    constructor(parent: SGraphItem | null, data: Marker) {
+        super(parent);
+        this.data = data;
+    }
+} // Class SImageMarkerItem

+ 24 - 0
saga-web-big/src/items/topology/SLineLegendItem.ts

@@ -0,0 +1,24 @@
+import { Legend } from "../../types/topology/Legend";
+import { SGraphItem } from "@saga-web/graph/lib";
+import { SLineItem } from "../SLineItem";
+
+/**
+ * 图例节点Item(线类型)
+ *
+ * * @author  张宇(taohuzy@163.com)
+ */
+export class SLineLegendItem extends SLineItem {
+    /** 图例节点对象数据 */
+    data: Legend;
+
+    /**
+     * 构造函数
+     *
+     * @param parent    指向父对象
+     * @param data      图例节点对象数据
+     */
+    constructor(parent: SGraphItem | null, data: Legend) {
+        super(parent);
+        this.data = data;
+    }
+} // Class SLineLegendItem

+ 5 - 5
saga-web-big/src/items/topology/SMarkerItem.ts

@@ -1,13 +1,13 @@
-import { SObjectItem } from "../SObjectItem";
 import { Marker } from "../../types/topology/Marker";
 import { SGraphItem } from "@saga-web/graph/lib";
+import { SLineItem } from "../SLineItem";
 
 /**
- * 实例item,与物理世界对应
+ * 标识对象Item(线类型)
  *
  * * @author  张宇(taohuzy@163.com)
  */
-export class SMarkerItem extends SGraphItem {
+export class SLineMarkerItem extends SLineItem {
     /** 标识对象数据 */
     data: Marker;
 
@@ -15,10 +15,10 @@ export class SMarkerItem extends SGraphItem {
      * 构造函数
      *
      * @param parent    指向父对象
-     * @param data      标识数据
+     * @param data      标识对象数据
      */
     constructor(parent: SGraphItem | null, data: Marker) {
         super(parent);
         this.data = data;
     }
-} // Class SMarkerItem
+} // Class SLineMarkerItem

+ 23 - 0
saga-web-big/src/items/topology/SNoneLegendItem.ts

@@ -0,0 +1,23 @@
+import { Legend } from "../../types/topology/Legend";
+import { SGraphItem } from "@saga-web/graph/lib";
+
+/**
+ * 图例节点Item(非图例类型)
+ *
+ * * @author  张宇(taohuzy@163.com)
+ */
+export class SNoneLegendItem extends SGraphItem {
+    /** 图例节点对象数据 */
+    data: Legend;
+
+    /**
+     * 构造函数
+     *
+     * @param parent    指向父对象
+     * @param data      图例节点对象数据
+     */
+    constructor(parent: SGraphItem | null, data: Legend) {
+        super(parent);
+        this.data = data;
+    }
+} // Class SNoneLegendItem

+ 24 - 0
saga-web-big/src/items/topology/STextMarkerItem.ts

@@ -0,0 +1,24 @@
+import { Marker } from "../../types/topology/Marker";
+import { SGraphItem } from "@saga-web/graph/lib";
+import { STextItem } from "../STextItem";
+
+/**
+ * 标识对象Item(文本类型)
+ *
+ * * @author  张宇(taohuzy@163.com)
+ */
+export class STextMarkerItem extends STextItem {
+    /** 标识对象数据 */
+    data: Marker;
+
+    /**
+     * 构造函数
+     *
+     * @param parent    指向父对象
+     * @param data      标识对象数据
+     */
+    constructor(parent: SGraphItem | null, data: Marker) {
+        super(parent);
+        this.data = data;
+    }
+} // Class STextMarkerItem

+ 24 - 0
saga-web-big/src/items/topology/SZoneLegendItem.ts

@@ -0,0 +1,24 @@
+import { Legend } from "../../types/topology/Legend";
+import { SGraphItem } from "@saga-web/graph/lib";
+import { SLineItem } from "../SLineItem"; // 多边形item
+
+/**
+ * 图例节点Item(区域类型)
+ *
+ * * @author  张宇(taohuzy@163.com)
+ */
+export class SZoneLegendItem extends SGraphItem {
+    /** 图例节点对象数据 */
+    data: Legend;
+
+    /**
+     * 构造函数
+     *
+     * @param parent    指向父对象
+     * @param data      图例节点对象数据
+     */
+    constructor(parent: SGraphItem | null, data: Legend) {
+        super(parent);
+        this.data = data;
+    }
+} // Class SZoneLegendItem

+ 31 - 10
saga-web-big/src/parser/STopologyParser.ts

@@ -1,19 +1,40 @@
 import { SParser } from "./SParser";
 import { ElementData } from "../types/ElementData";
-import { Node } from "../types/topology/Node";
+import { Legend } from "../types/topology/Legend";
 import { Marker } from "../types/topology/Marker";
 import { Relation } from "../types/topology/Relation";
-import { SMarkerItem, SEntityItem, SRelation } from "..";
+import {
+    SImageLegendItem,
+    SLineLegendItem,
+    SNoneLegendItem,
+    SRelation,
+    SZoneLegendItem,
+    SImageMarkerItem,
+    SLineMarkerItem,
+    STextMarkerItem
+} from "..";
 
 /**
  * 拓扑图信息解析器
  *
  */
 export class STopologyParser extends SParser {
-    /** 图例节点list   */
-    nodeList: SEntityItem[] = [];
-    /** 标识对象list   */
-    markersList: SMarkerItem[] = [];
+    /** 图例list(非图例类型)   */
+    noneLegendList: SNoneLegendItem[] = [];
+    /** 图例list(线类型)   */
+    lineLegendList: SLineLegendItem[] = [];
+    /** 图例list(区域类型)   */
+    zoneLegendList: SZoneLegendItem[] = [];
+    /** 图例list(图标类型)   */
+    imageLegendList: SImageLegendItem[] = [];
+
+    /** 标识list(图类型)   */
+    imageMarkerList: SImageMarkerItem[] = [];
+    /** 标识list(线类型)   */
+    lineMarkerList: SLineMarkerItem[] = [];
+    /** 标识list(文本类型)   */
+    textMarkerList: STextMarkerItem[] = [];
+
     /** 管线关系对象关系list   */
     relationList: SRelation[] = [];
 
@@ -24,7 +45,7 @@ export class STopologyParser extends SParser {
      * */
     parseData(data: ElementData): void {
         if (data.Nodes) {
-            data.Nodes.forEach((t: Node): void => {
+            data.Nodes.forEach((t: Legend): void => {
                 this.addNode(t);
             });
         }
@@ -45,9 +66,9 @@ export class STopologyParser extends SParser {
      *
      * @param   t       图例节点数据
      * */
-    private addNode(t: Node): void {
+    private addNode(t: Legend): void {
         let item = this.factory.createNode(t);
-        this.nodeList.push(item);
+        // this.nodeList.push(item);
     } // Function addNode()
 
     /**
@@ -57,7 +78,7 @@ export class STopologyParser extends SParser {
      * */
     private addMarker(t: Marker): void {
         let item = this.factory.createMarker(t);
-        this.markersList.push(item);
+        // this.markersList.push(item);
     } // Function addMarker()
 
     /**

+ 2 - 2
saga-web-big/src/types/ElementData.ts

@@ -18,7 +18,7 @@
  * ********************************************************************************************************************
  */
 
-import { Node } from "./topology/Node";
+import { Legend } from "./topology/Legend";
 import { Marker } from "./topology/Marker";
 import { Relation } from "./topology/Relation";
 
@@ -28,7 +28,7 @@ import { Relation } from "./topology/Relation";
  * @author  张宇
  */
 export interface ElementData {
-    Nodes: Node[];
+    Nodes: Legend[];
     Markers: Marker[];
     Relations: Relation[];
 } // Interface ElementData

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

@@ -29,5 +29,5 @@ export interface Anchor {
     /** 锚点ID */
     ID: string;
     /** 锚点的坐标  */
-    Pos?: Point;
+    Pos: Point;
 } // Interface Anchor

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

@@ -28,19 +28,19 @@ import { SGraphElementType } from "../../enums/SGraphElementType";
  *
  * @author  张宇
  */
-export interface Node {
+export interface Legend {
     /** ID */
     ID: string;
     /** 名称  */
-    Name?: string;
+    Name: string;
     /** 返回工程信息化对象 ID 列表 */
     AttachObjectIds?: string[];
     /** 图标,区域类型  */
-    GraphElementType?: SGraphElementType;
+    GraphElementType: SGraphElementType;
     /** 对应的图例ID  */
-    GraphElementId?: string;
+    GraphElementId: string;
     /** 位置  */
-    Pos?: Point;
+    Pos: Point;
     /** 缩放  */
     Scale?: Point;
     /** 旋转  */
@@ -50,7 +50,7 @@ export interface Node {
     /** 锚点List  */
     AnchorList?: Anchor[];
     /** 轮廓线  */
-    OutLine: Point[][];
+    OutLine?: Point[][];
     /** 由应用自己定义  */
-    Properties?: any;
-} // Interface Node
+    Properties?: {};
+} // Interface Legend

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

@@ -31,11 +31,11 @@ export interface Marker {
     /** ID */
     ID: string;
     /** 名称  */
-    Name?: string;
+    Name: string;
     /** 图标(Image),线类型(Line) */
-    Type?: SMarkerType;
+    Type: SMarkerType;
     /** 位置  */
-    Pos?: Point;
+    Pos: Point;
     /** 缩放  */
     Scale?: Point;
     /** 旋转  */
@@ -43,5 +43,5 @@ export interface Marker {
     /** 大小  */
     Size?: Size;
     /** 由应用自己定义  */
-    Properties?: any;
+    Properties?: {};
 } // Interface Marker

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

@@ -31,23 +31,23 @@ export interface Relation {
     /** ID */
     ID: string;
     /** 名称 */
-    Name?: string;
+    Name: string;
     /** 对应的图例ID */
-    GraphElementId?: string;
+    GraphElementId: string;
     /** 关联节点1_id */
     Node1ID?: string;
     /** 关联节点2_id */
     Node2ID?: string;
     /** 关联锚点1_id  */
-    Anchor1ID: Point[][];
+    Anchor1ID?: string;
     /** 关联锚点2_id */
     Anchor2ID?: string;
     /** 方向(0:无向,1:节点1到节点2,2:节点2到节点1) */
     Dir?: SRelationDir;
     /** 线类型(0:直线,1:水平/垂直线,2:曲线) */
-    LineType?: SLineType;
+    LineType: SLineType;
     /** 线的顶点坐标 */
-    PointList?: Point[];
+    PointList: Point[];
     /** 线的绘图样式 */
     Style?: string;
 } // Interface Relation