getStartShow1.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <!-- 画板 -->
  2. <template>
  3. <div ref="baseMap1" class="base-map">
  4. <canvas
  5. v-loading="loading"
  6. id="floorMap1"
  7. :width="canvasWidth"
  8. :height="canvasHeight"
  9. tabindex="0"
  10. ></canvas>
  11. </div>
  12. </template>
  13. <script>
  14. import { SGraphView, SGraphScene } from "@persagy-web/graph";
  15. import { SColor } from "@persagy-web/draw";
  16. import { SFloorParser, getJsonz, SZoneParser } from "@persagy-web/big/lib";
  17. // 获取压缩包数据并解压
  18. const map1 = require("../../../public/assets/map/1.json");
  19. export default {
  20. data() {
  21. return {
  22. canvasWidth: 0, // 画布的宽
  23. canvasHeight: 0, // 画布的高
  24. view: null, // 视图 view
  25. scene: null, // 场景类
  26. dataKey: "base/f2a4b3d10d3511eb9a1da1ce4aece47c.jsonz", // 基 路径
  27. mapUrl: "/image-service/common/file_get?systemId=revit&key=", // 图 key
  28. loading: false,
  29. isShowColumn: false, //是否展示柱子
  30. isShowWall: false, //是否显示墙
  31. isShowVirtualWall: false, //是否显示虚拟墙
  32. isShowDoor: false, // 是否显示门
  33. isShowWindow: false, //是否显示窗户
  34. isSpaceSelectable: true, //是否显示空间
  35. };
  36. },
  37. methods: {
  38. // 初始化
  39. init() {
  40. this.view ? (this.view.scene = this.scene) : null;
  41. // 解析数据并放入压缩包中
  42. setTimeout(() => {
  43. this.parserData(map1.EntityList[0].Elements);
  44. });
  45. },
  46. // 解析数据并注入 scene 类中
  47. parserData(data) {
  48. let parser = new SFloorParser();
  49. parser.parseData(data);
  50. parser.spaceList.forEach((t) => {
  51. /////////////////////////////////////////
  52. // 样式调整
  53. // 是否显示实例
  54. t.visible = this.isSpaceSelectable;
  55. //是否展示名称
  56. t.showBaseName = false;
  57. // 显示边框色
  58. t.strokeColor = new SColor("#F0F3F7");
  59. // 填充色
  60. t.fillColor = new SColor("#F0F3F7");
  61. // 边框线宽
  62. t.lineWidth = 1;
  63. // 添加图例
  64. this.scene.addItem(t);
  65. });
  66. parser.wallList.forEach((t) => {
  67. // 是否显示实例
  68. t.visible = this.isShowWall;
  69. this.scene.addItem(t);
  70. });
  71. parser.virtualWallList.forEach((t) => {
  72. // 是否显示实例
  73. t.visible = this.isShowVirtualWall;
  74. this.scene.addItem(t);
  75. });
  76. parser.doorList.forEach((t) => {
  77. // 是否显示实例
  78. t.visible = this.isShowDoor;
  79. this.scene.addItem(t);
  80. });
  81. parser.columnList.forEach((t) => {
  82. // 是否显示实例
  83. t.visible = this.isShowColumn;
  84. this.scene.addItem(t);
  85. });
  86. parser.casementList.forEach((t) => {
  87. // 是否显示实例
  88. t.visible = this.isShowWindow;
  89. this.scene.addItem(t);
  90. });
  91. // 画板是否可拖动
  92. if (this.view) {
  93. this.view.DragMove = true;
  94. this.view.fitSceneToView();
  95. }
  96. },
  97. // 清空画布
  98. clearImg() {
  99. this.scene = new SGraphScene();
  100. if (this.view) {
  101. this.view.update();
  102. }
  103. },
  104. },
  105. created() {
  106. this.clearImg();
  107. },
  108. mounted() {
  109. // 获取 canvas 的宽高
  110. this.canvasWidth = 800;
  111. this.canvasHeight = 600;
  112. // 初始化场景类
  113. this.view = new SGraphView("floorMap1");
  114. if (this.scene) {
  115. this.view.scene = this.scene;
  116. this.init();
  117. }
  118. },
  119. };
  120. </script>