virtualWall.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <div>
  3. <canvas id="wall" width="800" height="400" tabindex="0"/>
  4. </div>
  5. </template>
  6. <script lang="ts">
  7. import { SGraphScene, SGraphView } from "@persagy-web/graph/";
  8. import { SVirtualWallItem } from "@persagy-web/big/lib/items/floor/SVirtualWallItem";
  9. import { Component, Vue } from "vue-property-decorator";
  10. /**
  11. * 虚拟墙对象示例
  12. *
  13. * @author 郝洁 <haojie@persagy.com>
  14. */
  15. @Component
  16. export default class VirtualWallCanvas extends Vue {
  17. /** 实例化 view */
  18. view: SGraphView | undefined;
  19. /** 图中靠上位置的黑色矩形轮廓 */
  20. outline1 = [[{X: 12000, Y: 1000}, {X: 12000, Y: 3000}, {X: 1000, Y: 3000}, {X: 1000, Y: 1000}]];
  21. /** 图中靠下位置的,中间掏洞 */
  22. outline2 = [
  23. [{X: 12000, Y: -3000}, {X: 12000, Y: -5000}, {X: 1000, Y: -5000}, {X: 10, Y: -3000}],
  24. [{X: 2000, Y: -4000}, {X: 2000, Y: -4500}, {X: 10000, Y: -4500}, {X: 10000, Y: -4000}]
  25. ];
  26. /**
  27. * 页面挂载
  28. */
  29. mounted() {
  30. this.init();
  31. };
  32. /**
  33. * 初始化加载
  34. */
  35. init() {
  36. this.view = new SGraphView('wall');
  37. const scene = new SGraphScene();
  38. this.view.scene = scene;
  39. // 只模拟了轮廓数据
  40. const item = new SVirtualWallItem(null, {OutLine: this.outline1});
  41. scene.addItem(item);
  42. // 只模拟了轮廓数据
  43. const item2 = new SVirtualWallItem(null, {OutLine: this.outline2});
  44. scene.addItem(item2);
  45. this.view.fitSceneToView();
  46. this.view.scalable = false;
  47. }
  48. }
  49. </script>
  50. <style scoped>
  51. </style>