Skip to content

Commit

Permalink
fix: placement of useVTKCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
jadh4v committed Aug 18, 2023
1 parent 2a8ea38 commit eb2d9d8
Showing 1 changed file with 49 additions and 37 deletions.
86 changes: 49 additions & 37 deletions src/components/VtkObliqueView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -292,27 +292,6 @@ export default defineComponent({
baseImage: curImageID
});
const obliqueRep = baseImageRep?.value;
if (obliqueRep) {
switch(viewDirection.value) {
case 'Left':
case 'Right':
obliqueRep.setOutlineColor([1, 0, 0]);
break;
case 'Posterior':
case 'Anterior':
obliqueRep.setOutlineColor([0, 1, 0]);
break;
case 'Superior':
case 'Inferior':
obliqueRep.setOutlineColor([0, 0, 1]);
break;
default:
obliqueRep.setOutlineColor([0, 0, 0]);
break;
};
}
onBeforeMount(() => {
// do this before mount, as the ManipulatorTools run onMounted
// before this component does.
Expand All @@ -334,6 +313,14 @@ export default defineComponent({
}
}
const onPlanesUpdated = useVTKCallback(
resliceCursorRef.value.getWidgetState().onModified
);
onPlanesUpdated(() => {
updateViewFromResliceCursor();
});
onMounted(() => {
setViewProxyContainer(vtkContainerRef.value);
viewProxy.value.setOrientationAxesVisibility(false);
Expand All @@ -342,14 +329,6 @@ export default defineComponent({
if (curImageData.value) {
resliceCursorRef.value.updateCameraPoints(viewProxy.value.getRenderer(), VTKViewType.value, true, false, true);
}
const onPlanesUpdated = useVTKCallback(
resliceCursorRef.value.getWidgetState().onModified
);
onPlanesUpdated(() => {
updateViewFromResliceCursor();
});
});
onBeforeUnmount(() => {
Expand Down Expand Up @@ -499,6 +478,33 @@ export default defineComponent({
{ immediate: true }
);
watch(
baseImageRep,
(obliqueRep) => {
if (obliqueRep) {
switch(viewDirection.value) {
case 'Left':
case 'Right':
obliqueRep.setOutlineColor([1, 0, 0]);
break;
case 'Posterior':
case 'Anterior':
obliqueRep.setOutlineColor([0, 1, 0]);
break;
case 'Superior':
case 'Inferior':
obliqueRep.setOutlineColor([0, 0, 1]);
break;
default:
obliqueRep.setOutlineColor([0, 0, 0]);
break;
}
}
},
{ immediate: true }
);
// --- camera setup --- //
// Set default cutting plane parameters.
Expand Down Expand Up @@ -593,6 +599,8 @@ export default defineComponent({
resizeToFitScene();
updateViewFromResliceCursor();
viewProxy.value.renderLater();
};
Expand Down Expand Up @@ -634,9 +642,9 @@ export default defineComponent({
const { width, level } = wlConfig.value;
if (obliqueRep) {
obliqueRep.setWindowWidth(width);
obliqueRep.setWindowLevel(level);
if (baseImageRep.value) {
baseImageRep.value.setWindowWidth(width);
baseImageRep.value.setWindowLevel(level);
}
viewProxy.value.renderLater();
Expand All @@ -650,6 +658,11 @@ export default defineComponent({
resetCamera();
});
const enableResizeToFit = () => {
resizeToFit.value = true;
resetCamera();
};
return {
vtkContainerRef,
toolContainer,
Expand All @@ -663,14 +676,13 @@ export default defineComponent({
isImageLoading,
widgetManager,
dicomInfo,
enableResizeToFit() {
console.log('reset cam clicked.');
resizeToFit.value = true;
resetCamera();
},
enableResizeToFit,
hover,
};
},
mounted() {
this.enableResizeToFit();
},
});
</script>

Expand Down

0 comments on commit eb2d9d8

Please sign in to comment.