STopologyParser.js 3.9 KB

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