Skip to content

Commit 9c220b8

Browse files
committed
disable 3d viewer toggle if no stereo3d_* attributes
1 parent bcf3602 commit 9c220b8

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

client/dive-common/components/Viewer.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import context from 'dive-common/store/context';
4848
import { EditAnnotationTypes, VisibleAnnotationTypes } from 'vue-media-annotator/layers';
4949
import { TrackWithContext } from 'vue-media-annotator/BaseFilterControls';
5050
import TrackViewer from 'vue-media-annotator/components/track_3d_viewer/TrackViewer.vue';
51+
import { isStereo3dReady } from 'vue-media-annotator/components/track_3d_viewer/misc';
5152
import TrackViewerSettingsStore from 'vue-media-annotator/components/track_3d_viewer/TrackViewerSettingsStore';
5253
import TrackViewerSettings from 'vue-media-annotator/components/track_3d_viewer/TrackViewerSettings.vue';
5354
import GroupSidebarVue from './GroupSidebar.vue';
@@ -95,6 +96,7 @@ export default defineComponent({
9596
9697
const showTrack3dViewer = ref(false);
9798
const isStereoConfigMode = ref(false);
99+
const hasStereo3dAttributes = ref(false);
98100
99101
const baseMulticamDatasetId = ref(null as string | null);
100102
const datasetId = toRef(props, 'id');
@@ -698,6 +700,9 @@ export default defineComponent({
698700
await nextTick();
699701
handleResize();
700702
});
703+
watch(attributes, (attrs) => {
704+
hasStereo3dAttributes.value = isStereo3dReady(attrs);
705+
});
701706
onBeforeUnmount(() => {
702707
if (controlsRef.value) observer.unobserve(controlsRef.value.$el);
703708
});
@@ -882,6 +887,7 @@ export default defineComponent({
882887
datasetId,
883888
showTrack3dViewer,
884889
isStereoConfigMode,
890+
hasStereo3dAttributes,
885891
};
886892
},
887893
});
@@ -970,6 +976,7 @@ export default defineComponent({
970976
v-model="showTrack3dViewer"
971977
label="Track 3D Viewer"
972978
color="primary"
979+
:disabled="!hasStereo3dAttributes"
973980
hide-details
974981
/>
975982
</template>
Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,33 @@
1-
// eslint-disable-next-line import/prefer-default-export
1+
import { Attribute } from 'vue-media-annotator/use/useAttributes';
2+
3+
const EXPECTED_ATTRIBUTE_NAMES = [
4+
'stereo3d_x',
5+
'stereo3d_y',
6+
'stereo3d_z',
7+
];
8+
29
export const noOp = () => undefined;
10+
11+
export function isStereo3dReady(attrs: Attribute[]) {
12+
const attributeNamesToFind = [...EXPECTED_ATTRIBUTE_NAMES];
13+
14+
// eslint-disable-next-line no-restricted-syntax
15+
for (const attr of attrs) {
16+
// eslint-disable-next-line no-plusplus
17+
for (let i = 0; i < attributeNamesToFind.length; i++) {
18+
if (attr.name === attributeNamesToFind[i]) {
19+
if (attr.belongs === 'detection' && attr.datatype === 'number') {
20+
attributeNamesToFind.splice(i, 1);
21+
} else {
22+
return false;
23+
}
24+
}
25+
}
26+
27+
if (attributeNamesToFind.length === 0) {
28+
return true;
29+
}
30+
}
31+
32+
return false;
33+
}

0 commit comments

Comments
 (0)