|
@@ -0,0 +1,111 @@
|
|
|
+import { ElementData } from "../types/ElementData";
|
|
|
+import { Legend } from "../types/Legend";
|
|
|
+import { Marker } from "../types/Marker";
|
|
|
+import { Relation } from "../types/Relation";
|
|
|
+import { SGraphElementType } from "../enums/SGraphElementType";
|
|
|
+import { SMarkerType } from "../enums/SMarkerType";
|
|
|
+import { SParser, SRelation } from '@saga-web/big/lib';
|
|
|
+import { SNoneLegendItem } from '../items/SNoneLegendItem';
|
|
|
+import { SLineLegendItem } from '../items/SLineLegendItem';
|
|
|
+import { SZoneLegendItem } from '../items/SZoneLegendItem';
|
|
|
+import { SImageLegendItem } from '../items/SImageLegendItem';
|
|
|
+import { SImageMarkerItem } from '../items/SImageMarkerItem';
|
|
|
+import { SLineMarkerItem } from '../items/SLineMarkerItem';
|
|
|
+import { STextMarkerItem } from '../items/STextMarkerItem';
|
|
|
+
|
|
|
+/**
|
|
|
+ * 拓扑图信息解析器
|
|
|
+ *
|
|
|
+ */
|
|
|
+export class STopologyParser extends SParser {
|
|
|
+ /** 图例list(非图例类型) */
|
|
|
+ noneLegendList: SNoneLegendItem[] = [];
|
|
|
+ /** 图例list(线类型) */
|
|
|
+ lineLegendList: SLineLegendItem[] = [];
|
|
|
+ /** 图例list(区域类型) */
|
|
|
+ zoneLegendList: SZoneLegendItem[] = [];
|
|
|
+ /** 图例list(图标类型) */
|
|
|
+ imageLegendList: SImageLegendItem[] = [];
|
|
|
+
|
|
|
+ /** 标识list(图类型) */
|
|
|
+ imageMarkerList: SImageMarkerItem[] = [];
|
|
|
+ /** 标识list(线类型) */
|
|
|
+ lineMarkerList: SLineMarkerItem[] = [];
|
|
|
+ /** 标识list(文本类型) */
|
|
|
+ textMarkerList: STextMarkerItem[] = [];
|
|
|
+
|
|
|
+ /** 管线关系对象关系list */
|
|
|
+ relationList: SRelation[] = [];
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 解析数据
|
|
|
+ *
|
|
|
+ * @param data 系统图数据
|
|
|
+ * */
|
|
|
+ parseData(data: ElementData): void {
|
|
|
+ if (data.Nodes) {
|
|
|
+ data.Nodes.forEach((t: Legend): void => {
|
|
|
+ this.addLegend(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 addLegend(t: Legend): void {
|
|
|
+ if (t.GraphElementType == SGraphElementType.None) {
|
|
|
+ let item = this.factory.createNoneLegend(t);
|
|
|
+ this.noneLegendList.push(item);
|
|
|
+ } else if (t.GraphElementType == SGraphElementType.Line) {
|
|
|
+ let item = this.factory.createLineLegend(t);
|
|
|
+ this.lineLegendList.push(item);
|
|
|
+ } else if (t.GraphElementType == SGraphElementType.Zone) {
|
|
|
+ let item = this.factory.createZoneLegend(t);
|
|
|
+ this.zoneLegendList.push(item);
|
|
|
+ } else if (t.GraphElementType == SGraphElementType.Image) {
|
|
|
+ let item = this.factory.createImageLegend(t);
|
|
|
+ this.imageLegendList.push(item);
|
|
|
+ }
|
|
|
+ } // Function addNode()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加标识对象至场景中
|
|
|
+ *
|
|
|
+ * @param t 标识对象数据
|
|
|
+ * */
|
|
|
+ private addMarker(t: Marker): void {
|
|
|
+ if (t.Type == SMarkerType.Image) {
|
|
|
+ let item = this.factory.createImageMarker(t);
|
|
|
+ this.imageMarkerList.push(item);
|
|
|
+ } else if (t.Type == SMarkerType.Line) {
|
|
|
+ let item = this.factory.createLineMarker(t);
|
|
|
+ this.lineMarkerList.push(item);
|
|
|
+ } else if (t.Type == SMarkerType.Text) {
|
|
|
+ let item = this.factory.createTextMarker(t);
|
|
|
+ this.textMarkerList.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
|