space.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 { SSpaceItem } from "@persagy-web/big/lib/items/floor/SSpaceItem";
  9. import { Component, Vue } from "vue-property-decorator";
  10. @Component
  11. export default class SpaceCanvas extends Vue {
  12. view: SGraphView | undefined;
  13. // 图中靠上位置的黑色矩形轮廓
  14. outline1 = [[{X: 120, Y: 10}, {X: 120, Y: 30}, {X: 10, Y: 30}, {X: 10, Y: 10}]];
  15. // 图中靠下位置的,中间掏洞
  16. outline2 = [
  17. [{X: 120, Y: -30}, {X: 120, Y: -50}, {X: 10, Y: -50}, {X: 10, Y: -30}],
  18. [{X: 20, Y: -40}, {X: 20, Y: -45}, {X: 100, Y: -45}, {X: 100, Y: -40}]
  19. ];
  20. /**
  21. * 页面挂载
  22. */
  23. mounted(): void {
  24. this.init();
  25. };
  26. init(): void {
  27. this.view = new SGraphView('wall');
  28. const scene = new SGraphScene();
  29. this.view.scene = scene;
  30. // 只模拟了轮廓数据
  31. // @ts-ignore
  32. const item = new SSpaceItem(null, {OutLine: this.outline1, Name: '测试', Location: {Points: [{X: 65, Y: 20}]}});
  33. scene.addItem(item);
  34. // 只模拟了轮廓数据
  35. // @ts-ignore
  36. const item2 = new SSpaceItem(null,{OutLine:this.outline2});
  37. scene.addItem(item2);
  38. this.view.fitSceneToView();
  39. this.view.scalable = false;
  40. }
  41. }
  42. </script>
  43. <style scoped>
  44. </style>