|
| 1 | +<script lang="ts"> |
| 2 | +import { |
| 3 | + PropType, computed, defineComponent, onMounted, ref, watch, |
| 4 | +} from 'vue'; |
| 5 | +import { FMVStore, FMVVectorTypes, getFMVStore } from '../map/fmvStore'; |
| 6 | +import { FMVLayer } from '../types'; |
| 7 | +import { updateFMVLayer, updateFMVVideoMapping } from '../map/mapFMVLayer'; |
| 8 | +
|
| 9 | +export default defineComponent({ |
| 10 | + props: { |
| 11 | + layer: { |
| 12 | + type: Object as PropType<FMVLayer>, |
| 13 | + required: true, |
| 14 | + }, |
| 15 | + }, |
| 16 | + setup(props) { |
| 17 | + const fmvStore = ref<FMVStore | null>(null); |
| 18 | + const loaded = ref(false); |
| 19 | + const totalFrames = ref(0); |
| 20 | + const allProperties = ['flight_path', 'ground_frame', 'ground_union', 'video']; |
| 21 | + watch(() => fmvStore.value?.videoFrame, (newFrame) => { |
| 22 | + if (newFrame && fmvStore.value) { |
| 23 | + fmvStore.value.frameId = newFrame; |
| 24 | + updateFMVVideoMapping(props.layer); |
| 25 | + } |
| 26 | + }); |
| 27 | + const frameId = computed<number>({ |
| 28 | + get: () => fmvStore.value?.frameId ?? 0, |
| 29 | + set: (val) => { |
| 30 | + if (fmvStore.value) { |
| 31 | + fmvStore.value.frameId = val; |
| 32 | + updateFMVLayer(props.layer); |
| 33 | + updateFMVVideoMapping(props.layer); |
| 34 | + } |
| 35 | + }, |
| 36 | + }); |
| 37 | +
|
| 38 | + const visibleProperties = computed<(FMVVectorTypes | 'video')[]>({ |
| 39 | + get: () => fmvStore.value?.visibleProperties ?? [], |
| 40 | + set: (val) => { |
| 41 | + if (fmvStore.value) { |
| 42 | + fmvStore.value.visibleProperties = val; |
| 43 | + updateFMVLayer(props.layer); |
| 44 | + } |
| 45 | + }, |
| 46 | + }); |
| 47 | +
|
| 48 | + const filterFrameStatus = computed<boolean>({ |
| 49 | + get: () => fmvStore.value?.filterFrameStatus ?? false, |
| 50 | + set: (val) => { |
| 51 | + if (fmvStore.value) { |
| 52 | + fmvStore.value.filterFrameStatus = val; |
| 53 | + updateFMVLayer(props.layer); |
| 54 | + } |
| 55 | + }, |
| 56 | + }); |
| 57 | +
|
| 58 | + onMounted(async () => { |
| 59 | + fmvStore.value = await getFMVStore(props.layer.id); |
| 60 | + if (fmvStore.value) { |
| 61 | + totalFrames.value = fmvStore.value.videoData.totalFrames ?? 0; |
| 62 | + loaded.value = true; |
| 63 | + } |
| 64 | + }); |
| 65 | +
|
| 66 | + const isPlaying = computed(() => !fmvStore.value?.videoSource?.paused); |
| 67 | +
|
| 68 | + function togglePlayback() { |
| 69 | + const video = fmvStore.value?.videoSource; |
| 70 | + if (!video) return; |
| 71 | + if (video.paused) { |
| 72 | + video.play(); |
| 73 | + } else { |
| 74 | + video.pause(); |
| 75 | + } |
| 76 | + } |
| 77 | +
|
| 78 | + function seekFrames(offset: number) { |
| 79 | + const store = fmvStore.value; |
| 80 | + if (!store) return; |
| 81 | + store.seekFrames(offset); |
| 82 | + updateFMVVideoMapping(props.layer); |
| 83 | + } |
| 84 | +
|
| 85 | + return { |
| 86 | + frameId, |
| 87 | + visibleProperties, |
| 88 | + filterFrameStatus, |
| 89 | + totalFrames, |
| 90 | + allProperties, |
| 91 | + loaded, |
| 92 | + isPlaying, |
| 93 | + togglePlayback, |
| 94 | + seekFrames, |
| 95 | +
|
| 96 | + }; |
| 97 | + }, |
| 98 | +}); |
| 99 | +</script> |
| 100 | + |
| 101 | +<template> |
| 102 | + <v-card-title>FMV Layer Controls</v-card-title> |
| 103 | + <v-card-text v-if="loaded"> |
| 104 | + <v-row dense align="center" class="icon-row mb-2"> |
| 105 | + <v-col class="d-flex align-center gap-2"> |
| 106 | + <v-btn icon variant="plain" size="small" @click="seekFrames(-frameId)"> |
| 107 | + <v-icon>mdi-skip-backward</v-icon> |
| 108 | + </v-btn> |
| 109 | + <v-btn icon variant="plain" size="small" @click="seekFrames(-1)"> |
| 110 | + <v-icon>mdi-step-backward</v-icon> |
| 111 | + </v-btn> |
| 112 | + <v-btn icon variant="plain" size="small" @click="togglePlayback"> |
| 113 | + <v-icon>{{ isPlaying ? 'mdi-pause' : 'mdi-play' }}</v-icon> |
| 114 | + </v-btn> |
| 115 | + <v-btn icon variant="plain" size="small" @click="seekFrames(1)"> |
| 116 | + <v-icon>mdi-step-forward</v-icon> |
| 117 | + </v-btn> |
| 118 | + <v-btn icon variant="plain" size="small" @click="seekFrames(totalFrames - frameId)"> |
| 119 | + <v-icon>mdi-skip-forward</v-icon> |
| 120 | + </v-btn> |
| 121 | + </v-col> |
| 122 | + </v-row> |
| 123 | + <!-- Frame ID Slider --> |
| 124 | + <v-row dense align="center"> |
| 125 | + <v-col cols="3"> |
| 126 | + <span>Frame ID:</span> |
| 127 | + </v-col> |
| 128 | + <v-col> |
| 129 | + <v-slider |
| 130 | + v-model="frameId" |
| 131 | + :min="0" |
| 132 | + :max="totalFrames" |
| 133 | + step="1" |
| 134 | + thumb-label |
| 135 | + :disabled="totalFrames === 0" |
| 136 | + /> |
| 137 | + </v-col> |
| 138 | + <v-col cols="2"> |
| 139 | + <span>{{ frameId }}</span> |
| 140 | + </v-col> |
| 141 | + </v-row> |
| 142 | + |
| 143 | + <!-- Visible Properties Multi-select --> |
| 144 | + <v-row dense align="center"> |
| 145 | + <v-col cols="3"> |
| 146 | + <span>Visible Properties:</span> |
| 147 | + </v-col> |
| 148 | + <v-col> |
| 149 | + <v-select |
| 150 | + v-model="visibleProperties" |
| 151 | + :items="allProperties" |
| 152 | + label="Visible Properties" |
| 153 | + multiple |
| 154 | + chips |
| 155 | + clearable |
| 156 | + /> |
| 157 | + </v-col> |
| 158 | + </v-row> |
| 159 | + |
| 160 | + <!-- Filter by Frame Checkbox --> |
| 161 | + <v-row dense align="center"> |
| 162 | + <v-col cols="3"> |
| 163 | + <span>Filter by Frame:</span> |
| 164 | + </v-col> |
| 165 | + <v-col> |
| 166 | + <v-checkbox |
| 167 | + v-model="filterFrameStatus" |
| 168 | + label="Enable Frame Filtering" |
| 169 | + /> |
| 170 | + </v-col> |
| 171 | + </v-row> |
| 172 | + </v-card-text> |
| 173 | + <v-card-text v-else> |
| 174 | + Loading FMV Layer controls... |
| 175 | + </v-card-text> |
| 176 | +</template> |
| 177 | + |
| 178 | +<style scoped> |
| 179 | +.tab { |
| 180 | + border: 1px solid lightgray; |
| 181 | +} |
| 182 | +
|
| 183 | +.tab:hover { |
| 184 | + cursor: pointer; |
| 185 | +} |
| 186 | +
|
| 187 | +.selected-tab { |
| 188 | + background-color: lightgray; |
| 189 | +} |
| 190 | +
|
| 191 | +.icon-center { |
| 192 | + width: 35px; |
| 193 | + height: 35px; |
| 194 | + border: 1px solid lightgray; |
| 195 | + display: flex; |
| 196 | + align-items: center; |
| 197 | + justify-content: center; |
| 198 | +} |
| 199 | +</style> |
0 commit comments