STopologyParser.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import { ElementData } from "../types/ElementData";
  2. import { Legend } from "../types/Legend";
  3. import { Marker } from "../types/Marker";
  4. import { Relation } from "../types/Relation";
  5. import { SGraphElementType } from "../enums/SGraphElementType";
  6. import { SMarkerType } from "../enums/SMarkerType";
  7. import { SParser, SRelation } from '@saga-web/big/lib';
  8. import { SNoneLegendItem } from '../items/SNoneLegendItem';
  9. import { SLineLegendItem } from '../items/SLineLegendItem';
  10. import { SZoneLegendItem } from '../items/SZoneLegendItem';
  11. import { SImageLegendItem } from '../items/SImageLegendItem';
  12. import { SImageMarkerItem } from '../items/SImageMarkerItem';
  13. import { SLineMarkerItem } from '../items/SLineMarkerItem';
  14. import { STextMarkerItem } from '../items/STextMarkerItem';
  15. /**
  16. * 拓扑图信息解析器
  17. *
  18. */
  19. export class STopologyParser extends SParser {
  20. /** 图例list(非图例类型) */
  21. noneLegendList: SNoneLegendItem[] = [];
  22. /** 图例list(线类型) */
  23. lineLegendList: SLineLegendItem[] = [];
  24. /** 图例list(区域类型) */
  25. zoneLegendList: SZoneLegendItem[] = [];
  26. /** 图例list(图标类型) */
  27. imageLegendList: SImageLegendItem[] = [];
  28. /** 标识list(图类型) */
  29. imageMarkerList: SImageMarkerItem[] = [];
  30. /** 标识list(线类型) */
  31. lineMarkerList: SLineMarkerItem[] = [];
  32. /** 标识list(文本类型) */
  33. textMarkerList: STextMarkerItem[] = [];
  34. /** 管线关系对象关系list */
  35. relationList: SRelation[] = [];
  36. /**
  37. * 解析数据
  38. *
  39. * @param data 系统图数据
  40. * */
  41. parseData(data: ElementData): void {
  42. if (data.Nodes) {
  43. data.Nodes.forEach((t: Legend): void => {
  44. this.addLegend(t);
  45. });
  46. }
  47. if (data.Markers) {
  48. data.Markers.forEach((t: Marker): void => {
  49. this.addMarker(t);
  50. });
  51. }
  52. if (data.Relations) {
  53. data.Relations.forEach((t: Relation): void => {
  54. this.addRelation(t);
  55. });
  56. }
  57. } // Function parseData()
  58. /**
  59. * 添加图例节点至场景中
  60. *
  61. * @param t 图例节点数据
  62. * */
  63. private addLegend(t: Legend): void {
  64. if (t.GraphElementType == SGraphElementType.None) {
  65. let item = this.factory.createNoneLegend(t);
  66. this.noneLegendList.push(item);
  67. } else if (t.GraphElementType == SGraphElementType.Line) {
  68. let item = this.factory.createLineLegend(t);
  69. this.lineLegendList.push(item);
  70. } else if (t.GraphElementType == SGraphElementType.Zone) {
  71. let item = this.factory.createZoneLegend(t);
  72. this.zoneLegendList.push(item);
  73. } else if (t.GraphElementType == SGraphElementType.Image) {
  74. let item = this.factory.createImageLegend(t);
  75. this.imageLegendList.push(item);
  76. }
  77. } // Function addNode()
  78. /**
  79. * 添加标识对象至场景中
  80. *
  81. * @param t 标识对象数据
  82. * */
  83. private addMarker(t: Marker): void {
  84. if (t.Type == SMarkerType.Image) {
  85. let item = this.factory.createImageMarker(t);
  86. this.imageMarkerList.push(item);
  87. } else if (t.Type == SMarkerType.Line) {
  88. let item = this.factory.createLineMarker(t);
  89. this.lineMarkerList.push(item);
  90. } else if (t.Type == SMarkerType.Text) {
  91. let item = this.factory.createTextMarker(t);
  92. this.textMarkerList.push(item);
  93. }
  94. } // Function addMarker()
  95. /**
  96. * 添加管线关系至场景中
  97. *
  98. * @param t 管线关系对象数据
  99. * */
  100. private addRelation(t: Relation): void {
  101. let item = this.factory.createRelation(t);
  102. this.relationList.push(item);
  103. } // Function addRelation()
  104. } // class STopologyParser