Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/components/SliceViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@

<script setup lang="ts">
import { ref, toRefs, computed } from 'vue';
import { storeToRefs } from 'pinia';
import { useCurrentImage } from '@/src/composables/useCurrentImage';
import { LPSAxisDir } from '@/src/types/lps';
import { getLPSAxisFromDir } from '@/src/utils/lps';
Expand Down Expand Up @@ -175,7 +176,7 @@ import VtkSliceViewSlicingManipulator from '@/src/components/vtk/VtkSliceViewSli
import VtkMouseInteractionManipulator from '@/src/components/vtk/VtkMouseInteractionManipulator.vue';
import vtkMouseCameraTrackballPanManipulator from '@kitware/vtk.js/Interaction/Manipulators/MouseCameraTrackballPanManipulator';
import vtkMouseCameraTrackballZoomToMouseManipulator from '@kitware/vtk.js/Interaction/Manipulators/MouseCameraTrackballZoomToMouseManipulator';
import { storeToRefs } from 'pinia';
import { useResetViewsEvents } from '@/src/components/tools/ResetViews.vue';

interface Props extends LayoutViewProps {
viewDirection: LPSAxisDir;
Expand All @@ -196,6 +197,8 @@ function resetCamera() {
vtkView.value.resetCamera();
}

useResetViewsEvents().onClick(resetCamera);

useWebGLWatchdog(vtkView);
useViewAnimationListener(vtkView, viewId, viewType);

Expand Down
16 changes: 8 additions & 8 deletions src/components/VolumeRendering.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import vtkPiecewiseFunctionProxy from '@kitware/vtk.js/Proxy/Core/PiecewiseFunct
import vtkColorTransferFunction from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction';
import { onVTKEvent } from '@/src/composables/onVTKEvent';
import useViewAnimationStore from '@/src/store/view-animation';
import { useResetViewsEvents } from '@/src/components/tools/ResetViews.vue';
import { useResizeObserver } from '../composables/useResizeObserver';
import { useCurrentImage } from '../composables/useCurrentImage';
import useVolumeColoringStore from '../store/view-configs/volume-coloring';
Expand Down Expand Up @@ -284,15 +285,14 @@ export default defineComponent({
onKeyDown('Control', () => pwfWidget.setShiftOpacityValues(true));
onKeyUp('Control', () => pwfWidget.setShiftOpacityValues(false));

const reset = () => {
rangeShift.value = 0;
rangeWidth.value = fullMappingRangeWidth.value;
};
// reset case
watch(
[selectedPreset, currentImageID],
() => {
rangeShift.value = 0;
rangeWidth.value = fullMappingRangeWidth.value;
},
{ immediate: true }
);
watch([selectedPreset, currentImageID], reset, { immediate: true });

useResetViewsEvents().onClick(reset);

watch([rangeShift, rangeWidth], ([shift, width]) => {
const imageID = currentImageID.value;
Expand Down
3 changes: 3 additions & 0 deletions src/components/VolumeViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import { useWebGLWatchdog } from '@/src/composables/useWebGLWatchdog';
import VtkOrientationMarker from '@/src/components/vtk/VtkOrientationMarker.vue';
import ViewOverlayGrid from '@/src/components/ViewOverlayGrid.vue';
import useVolumeColoringStore from '@/src/store/view-configs/volume-coloring';
import { useResetViewsEvents } from '@/src/components/tools/ResetViews.vue';

interface Props extends LayoutViewProps {
viewDirection: LPSAxisDir;
Expand All @@ -91,6 +92,8 @@ function resetCamera() {
vtkView.value.renderer.updateLightsGeometryToFollowCamera();
}

useResetViewsEvents().onClick(resetCamera);

useWebGLWatchdog(vtkView);
useViewAnimationListener(vtkView, viewId, viewType);

Expand Down
12 changes: 11 additions & 1 deletion src/composables/useWindowingConfigInitializer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { MaybeRef, computed, unref, watch } from 'vue';
import type { TypedArray } from '@kitware/vtk.js/types';
import vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray';
import { watchImmediate } from '@vueuse/core';
Expand All @@ -7,7 +8,7 @@ import { WLAutoRanges, WL_AUTO_DEFAULT, WL_HIST_BINS } from '@/src/constants';
import { getWindowLevels, useDICOMStore } from '@/src/store/datasets-dicom';
import useWindowingStore from '@/src/store/view-configs/windowing';
import { Maybe } from '@/src/types';
import { MaybeRef, computed, unref, watch } from 'vue';
import { useResetViewsEvents } from '@/src/components/tools/ResetViews.vue';

function useAutoRangeValues(imageID: MaybeRef<Maybe<string>>) {
const { imageData } = useImage(imageID);
Expand Down Expand Up @@ -139,4 +140,13 @@ export function useWindowingConfigInitializer(
});
store.resetWindowLevel(viewIdVal, imageIdVal);
});

useResetViewsEvents().onClick(() => {
const imageIdVal = unref(imageID);
const viewIdVal = unref(viewID);
if (imageIdVal == null || windowConfig.value == null) {
return;
}
store.resetWindowLevel(viewIdVal, imageIdVal);
});
}