diff --git a/src/components/VtkThreeView.vue b/src/components/VtkThreeView.vue
index 1e7d17f01..7e7ab3298 100644
--- a/src/components/VtkThreeView.vue
+++ b/src/components/VtkThreeView.vue
@@ -6,7 +6,9 @@
class="vtk-view"
ref="vtkContainerRef"
data-testid="vtk-view vtk-three-view"
- />
+ >
+
+
@@ -77,6 +79,7 @@ import type { Vector3 } from '@kitware/vtk.js/types';
import { useProxyManager } from '@/src/composables/proxyManager';
import ViewOverlayGrid from '@/src/components/ViewOverlayGrid.vue';
+import { onVTKEvent } from '@/src/composables/onVTKEvent';
import { useResizeObserver } from '../composables/useResizeObserver';
import { useCurrentImage } from '../composables/useCurrentImage';
import { useCameraOrientation } from '../composables/useCameraOrientation';
@@ -427,22 +430,51 @@ export default defineComponent({
// --- view proxy setup --- //
- const { viewProxy, setContainer: setViewProxyContainer } =
- useViewProxy(viewID, ViewProxyType.Volume);
+ const { viewProxy } = useViewProxy(
+ viewID,
+ ViewProxyType.Volume
+ );
+
+ const canvasRef = ref(null);
+
+ const interactor = computed(() => viewProxy.value.getInteractor());
+ onVTKEvent(interactor, 'onRenderEvent' as 'onModified', () => {
+ if (!canvasRef.value) return;
+ const ctx = canvasRef.value.getContext('2d');
+ const src = viewProxy.value.getOpenGLRenderWindow().getCanvas();
+ if (ctx && src) {
+ ctx.clearRect(0, 0, canvasRef.value.width, canvasRef.value.height);
+ ctx.drawImage(src, 0, 0);
+ }
+ });
onMounted(() => {
viewProxy.value.setOrientationAxesVisibility(true);
viewProxy.value.setOrientationAxesType('cube');
viewProxy.value.setBackground([0, 0, 0, 0]);
- setViewProxyContainer(vtkContainerRef.value);
+ viewProxy.value.setInteractionContainer(canvasRef.value);
+ // setViewProxyContainer(vtkContainerRef.value);
});
onBeforeUnmount(() => {
- setViewProxyContainer(null);
- viewProxy.value.setContainer(null);
+ // setViewProxyContainer(null);
});
- useResizeObserver(vtkContainerRef, () => viewProxy.value.resize());
+ useResizeObserver(vtkContainerRef, (entry) => {
+ const bbox = entry.contentRect;
+ if (!bbox.width || !bbox.height) return;
+
+ canvasRef.value?.setAttribute(
+ 'width',
+ String(bbox.width * window.devicePixelRatio)
+ );
+ canvasRef.value?.setAttribute(
+ 'height',
+ String(bbox.height * window.devicePixelRatio)
+ );
+
+ viewProxy.value.setSize(bbox.width, bbox.height);
+ });
// --- scene setup --- //
@@ -606,6 +638,7 @@ export default defineComponent({
return {
vtkContainerRef,
+ canvasRef,
viewID,
active: false,
topLeftLabel: computed(
@@ -628,4 +661,9 @@ export default defineComponent({
background-color: black;
grid-template-columns: auto;
}
+
+.ccc {
+ width: 100%;
+ height: 100%;
+}
diff --git a/src/components/VtkTwoView.vue b/src/components/VtkTwoView.vue
index 542f9dc05..8a5b6e701 100644
--- a/src/components/VtkTwoView.vue
+++ b/src/components/VtkTwoView.vue
@@ -38,7 +38,9 @@
class="vtk-view"
ref="vtkContainerRef"
data-testid="vtk-view vtk-two-view"
- />
+ >
+
+