|
1 | 1 | <script setup lang="ts"> |
2 | | -import { computed, ref } from "vue"; |
| 2 | +import { computed, ref, watchEffect } from "vue"; |
3 | 3 | import { useCameraSettingsStore } from "@/stores/settings/CameraSettingsStore"; |
4 | 4 | import { CalibrationBoardTypes, CalibrationTagFamilies, type VideoFormat } from "@/types/SettingTypes"; |
5 | 5 | import MonoLogo from "@/assets/images/logoMono.png"; |
@@ -79,6 +79,18 @@ const calibrationDivisors = computed(() => |
79 | 79 | }) |
80 | 80 | ); |
81 | 81 |
|
| 82 | +const uniqueVideoResolutionString = ref(""); |
| 83 | +
|
| 84 | +// Use a watchEffect so the value is populated/reacts when the stores become available or update. |
| 85 | +// This avoids trying to index into an array that may be empty during page reload. |
| 86 | +watchEffect(() => { |
| 87 | + const currentIndex = useCameraSettingsStore().currentVideoFormat.index ?? 0; |
| 88 | + useStateStore().calibrationData.videoFormatIndex = currentIndex; |
| 89 | + const names = useCameraSettingsStore().currentCameraSettings.validVideoFormats.map((f) => |
| 90 | + getResolutionString(f.resolution) |
| 91 | + ); |
| 92 | + uniqueVideoResolutionString.value = names[currentIndex] ?? names[0] ?? ""; |
| 93 | +}); |
82 | 94 | const squareSizeIn = ref(1); |
83 | 95 | const markerSizeIn = ref(0.75); |
84 | 96 | const patternWidth = ref(8); |
@@ -279,13 +291,16 @@ const setSelectedVideoFormat = (format: VideoFormat) => { |
279 | 291 | : 'MrCal failed to load, check journalctl logs for details.' |
280 | 292 | " |
281 | 293 | /> |
282 | | - <!-- TODO: the default videoFormatIndex is 0, but the list of unique video mode indexes might not include 0. getUniqueVideoResolutionStrings indexing is also different from the normal video mode indexing --> |
283 | 294 | <pv-select |
284 | | - v-model="useStateStore().calibrationData.videoFormatIndex" |
| 295 | + v-model="uniqueVideoResolutionString" |
285 | 296 | label="Resolution" |
286 | 297 | :select-cols="8" |
287 | 298 | :disabled="isCalibrating" |
288 | 299 | tooltip="Resolution to calibrate at (you will have to calibrate every resolution you use 3D mode on)" |
| 300 | + @update:model-value=" |
| 301 | + useStateStore().calibrationData.videoFormatIndex = |
| 302 | + getUniqueVideoResolutionStrings().find((v) => v.value === $event)?.value || 0 |
| 303 | + " |
289 | 304 | :items="getUniqueVideoResolutionStrings()" |
290 | 305 | /> |
291 | 306 | <pv-select |
@@ -527,9 +542,9 @@ const setSelectedVideoFormat = (format: VideoFormat) => { |
527 | 542 | <v-card-text> |
528 | 543 | Camera has been successfully calibrated for |
529 | 544 | {{ |
530 | | - getUniqueVideoResolutionStrings().find( |
531 | | - (v) => v.value === useStateStore().calibrationData.videoFormatIndex |
532 | | - )?.name |
| 545 | + useCameraSettingsStore().currentCameraSettings.validVideoFormats.map((f) => |
| 546 | + getResolutionString(f.resolution) |
| 547 | + )[useStateStore().calibrationData.videoFormatIndex] |
533 | 548 | }}! |
534 | 549 | </v-card-text> |
535 | 550 | </template> |
|
0 commit comments