<template>
    <div>
        <canvas id="wall" width="800" height="400"  tabindex="0" />
    </div>
</template>

<script lang="ts">
import { SGraphScene, SGraphView } from "@persagy-web/graph/";
import { SSpaceItem } from "@persagy-web/big/lib/items/floor/SSpaceItem";
import { Component, Vue } from "vue-property-decorator";

/**
 * 空间对象示例
 *
 * @author 郝洁 <haojie@persagy.com>
 */
@Component
export default class SpaceCanvas extends Vue {
    /** 实例化 view */
    view: SGraphView | undefined;
    /** 图中靠上位置的黑色矩形轮廓 */
    outline1 = [[{X: 120, Y: 10}, {X: 120, Y: 30}, {X: 10, Y: 30}, {X: 10, Y: 10}]];
    /** 图中靠下位置的,中间掏洞 */
    outline2 = [
        [{X: 120, Y: -30}, {X: 120, Y: -50}, {X: 10, Y: -50}, {X: 10, Y: -30}],
        [{X: 20, Y: -40}, {X: 20, Y: -45}, {X: 100, Y: -45}, {X: 100, Y: -40}]
    ];

    /**
     * 页面挂载
     */
    mounted(): void {
        this.init();
    };

    /**
     * 初始化加载
     */
    init(): void {
        this.view = new SGraphView('wall');
        const scene = new SGraphScene();
        this.view.scene = scene;
        // 只模拟了轮廓数据
        // @ts-ignore
        const item = new SSpaceItem(null, {OutLine: this.outline1, Name: '测试', Location: {Points: [{X: 65, Y: 20}]}});
        scene.addItem(item);
        // 只模拟了轮廓数据
        // @ts-ignore
        const item2 = new SSpaceItem(null, {OutLine: this.outline2});
        scene.addItem(item2);
        this.view.fitSceneToView();
        this.view.scalable = false;
    }
}
</script>

<style scoped>

</style>
