Skip to content

Commit d9bd775

Browse files
committed
disable 3d viewer toggle if no stereo3d_* attributes
1 parent c93df3e commit d9bd775

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

client/dive-common/components/Viewer.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import context from 'dive-common/store/context';
5050
import { MarkChangesPendingFilter, TrackWithContext } from 'vue-media-annotator/BaseFilterControls';
5151
import { EditAnnotationTypes, VisibleAnnotationTypes } from 'vue-media-annotator/layers';
5252
import TrackViewer from 'vue-media-annotator/components/track_3d_viewer/TrackViewer.vue';
53+
import { isStereo3dReady } from 'vue-media-annotator/components/track_3d_viewer/misc';
5354
import TrackViewerSettingsStore from 'vue-media-annotator/components/track_3d_viewer/TrackViewerSettingsStore';
5455
import TrackViewerSettings from 'vue-media-annotator/components/track_3d_viewer/TrackViewerSettings.vue';
5556
import GroupSidebarVue from './GroupSidebar.vue';
@@ -108,6 +109,7 @@ export default defineComponent({
108109
109110
const showTrack3dViewer = ref(false);
110111
const isStereoConfigMode = ref(false);
112+
const hasStereo3dAttributes = ref(false);
111113
112114
const baseMulticamDatasetId = ref(null as string | null);
113115
const datasetId = toRef(props, 'id');
@@ -793,6 +795,9 @@ export default defineComponent({
793795
await nextTick();
794796
handleResize();
795797
});
798+
watch(attributes, (attrs) => {
799+
hasStereo3dAttributes.value = isStereo3dReady(attrs);
800+
});
796801
onBeforeUnmount(() => {
797802
if (controlsRef.value) observer.unobserve(controlsRef.value.$el);
798803
});
@@ -989,6 +994,7 @@ export default defineComponent({
989994
datasetId,
990995
showTrack3dViewer,
991996
isStereoConfigMode,
997+
hasStereo3dAttributes,
992998
};
993999
},
9941000
});
@@ -1114,6 +1120,7 @@ export default defineComponent({
11141120
v-model="showTrack3dViewer"
11151121
label="Track 3D Viewer"
11161122
color="primary"
1123+
:disabled="!hasStereo3dAttributes"
11171124
hide-details
11181125
/>
11191126
</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)