canvas-editor.vue 2.31 KB
<template>
    <div class="viewer-editor" id="viewer-editor" ref="viewer" />
    <div class="viewer-editor-coordinate" id="viewer-editor-coordinate" ref="coordinate" />
    <div
        v-show="isSectionViewVisible"
        class="viewer-editor-sectionview"
        id="viewer-editor-sectionview"
        ref="sectionview"
    >
        <span> {{ $t('sectionview') }}</span>
    </div>
</template>
<script setup>
import { ref, onMounted } from 'vue';
import Editor from '@/utility/jsm/canvas/editor';
import { useEditorStore } from '@/views/stores/useEditorStore';
import { useViewsAngleStore } from '@/views/stores/useViewsAngleStore';
import { storeToRefs } from 'pinia';

const store = useEditorStore();
const { setEditor, setCoordinate, setSectionViewEditor } = store;

const viewStore = useViewsAngleStore();
const { isSectionViewVisible } = storeToRefs(viewStore);

const viewer = ref(null);
const coordinate = ref(null);
const sectionview = ref(null);

onMounted(() => {
    const editor = new Editor('viewer-editor');
    if (editor) {
        editor.initialize(viewer.value);
        setEditor(editor);
    }
    const editorCoordinate = new Editor('viewer-editor-coordinate');
    if (editorCoordinate) {
        editorCoordinate.initialize(coordinate.value);
        setCoordinate(editorCoordinate);
    }
    const sectionViewEditor = new Editor('viewer-editor-sectionview');
    if (sectionViewEditor) {
        sectionViewEditor.initialize(sectionview.value);
        setSectionViewEditor(sectionViewEditor);
    }
});
</script>
<style lang="less">
.viewer-editor {
    background-color: @canvas-background-color;
    width: 100%;
    height: 100%;
}
.viewer-editor-coordinate {
    width: 200px;
    height: 200px;
    position: absolute;
    bottom: 80px;
    left: 63.63px;
    background-color: transparent;
    pointer-events: none;
}
.viewer-editor-sectionview {
    width: 500px;
    height: 500px;
    position: absolute;
    border-radius: 10px;
    box-shadow: rgba(145, 153, 163, 0.16) 0px 1px 1px;
    border: 1px solid #cdd1d5;
    background-color: #ffffff;
    bottom: 25px;
    right: 16px;
    span {
        position: absolute;
        display: flex;
        justify-content: space-around;
        margin-top: 12px;
        font-size: 16px;
        line-height: 24px;
        font-weight: 700;
        width: 500px;
    }
}
</style>