STopologyParser.ts 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. import { TipelineItem } from '../items/TipelineItem';
  16. import { ItemOrder } from "@saga-web/big";
  17. import { SItemStatus } from "@saga-web/big";
  18. import { SSCPZZoneLegendItem } from '../items/SSCPZZoneLegendItem';
  19. import { SFHFQZoneLegendItem } from '../items/SFHFQZoneLegendItem';
  20. import { SCustomLegendItem } from '../items/SCustomLegendItem';
  21. /**
  22. * 拓扑图信息解析器
  23. *
  24. */
  25. export class STopologyParser extends SParser {
  26. /** 图例list(非图例类型) */
  27. noneLegendList: SNoneLegendItem[] = [];
  28. /** 图例list(线类型) */
  29. lineLegendList: SLineLegendItem[] = [];
  30. /** 图例list(区域类型) */
  31. zoneLegendList: SZoneLegendItem[] = [];
  32. /** 图例list(图标类型) */
  33. imageLegendList: SImageLegendItem[] = [];
  34. /** 标识list(图类型) */
  35. imageMarkerList: SImageMarkerItem[] = [];
  36. /** 标识list(线类型) */
  37. lineMarkerList: SLineMarkerItem[] = [];
  38. /** 标识list(文本类型) */
  39. textMarkerList: STextMarkerItem[] = [];
  40. /** 管线关系对象关系list */
  41. relationList: SRelation[] = [];
  42. /**
  43. * 解析数据
  44. *
  45. * @param data 系统图数据
  46. * */
  47. parseData(data: ElementData): void {
  48. if (data.Nodes) {
  49. data.Nodes.forEach((t: Legend): void => {
  50. this.addLegend(t);
  51. });
  52. }
  53. if (data.Markers) {
  54. data.Markers.forEach((t: Marker): void => {
  55. this.addMarker(t);
  56. });
  57. }
  58. if (data.Relations) {
  59. data.Relations.forEach((t: Relation): void => {
  60. this.addRelation(t);
  61. });
  62. }
  63. } // Function parseData()
  64. /**
  65. * 添加图例节点至场景中
  66. *
  67. * @param t 图例节点数据
  68. * */
  69. private addLegend(t: Legend): void {
  70. if (t.GraphElementType == 'None') {
  71. let item = new SNoneLegendItem(null, t);
  72. this.noneLegendList.push(item);
  73. } else if (t.GraphElementType == "Zone") {
  74. if (t.SubType == "SCPZ") {
  75. let item = new SSCPZZoneLegendItem(null, t);
  76. item.selectable = true;
  77. this.zoneLegendList.push(item);
  78. } else if (t.SubType == "FHFQ") {
  79. let item = new SFHFQZoneLegendItem(null, t);
  80. item.selectable = true;
  81. this.zoneLegendList.push(item);
  82. } else if (t.SubType == "CUSTOM") {
  83. let item = new SCustomLegendItem(null, t);
  84. item.selectable = true;
  85. this.zoneLegendList.push(item);
  86. } else {
  87. let item = new SZoneLegendItem(null, t);
  88. item.selectable = true;
  89. this.zoneLegendList.push(item);
  90. }
  91. } else if (t.GraphElementType == 'Image') {
  92. let item = new SImageLegendItem(null, t);
  93. item.selectable = true;
  94. this.imageLegendList.push(item);
  95. }
  96. } // Function addNode()
  97. /**
  98. * 添加标识对象至场景中
  99. *
  100. * @param t 标识对象数据
  101. * */
  102. private addMarker(t: Marker): void {
  103. if (t.Type == "Image") {
  104. let item = new SImageMarkerItem(null, t);
  105. this.imageMarkerList.push(item);
  106. item.selectable = true;
  107. } else if (t.Type == "Line") {
  108. let item = new SLineMarkerItem(null, t);
  109. item.selectable = true;
  110. this.lineMarkerList.push(item);
  111. } else if (t.Type == "Text") {
  112. let item = new STextMarkerItem(null, t);
  113. item.selectable = true;
  114. this.textMarkerList.push(item);
  115. }
  116. } // Function addMarker()
  117. /**
  118. * 添加管线关系至场景中
  119. *
  120. * @param t 管线关系对象数据
  121. * */
  122. private addRelation(t: Relation): void {
  123. let item = new TipelineItem(null, t);
  124. item.selectable = true;
  125. this.relationList.push(item);
  126. } // Function addRelation()
  127. } // class STopologyParser