From c801b5a63edd94b5aae0eb193d24e9968b9b458a Mon Sep 17 00:00:00 2001 From: James Petts Date: Wed, 23 Oct 2019 16:40:10 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fix=20crosshairs=20issue?= =?UTF-8?q?=20whilst=20using=20a=20slab/MIP=20(#64)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes: #63 --- .../vtkInteractorStyleMPRCrosshairs.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/VTKViewport/vtkInteractorStyleMPRCrosshairs.js b/src/VTKViewport/vtkInteractorStyleMPRCrosshairs.js index 058effa5..d8167ee3 100644 --- a/src/VTKViewport/vtkInteractorStyleMPRCrosshairs.js +++ b/src/VTKViewport/vtkInteractorStyleMPRCrosshairs.js @@ -63,14 +63,28 @@ function vtkInteractorStyleMPRCrosshairs(publicAPI, model) { } function moveCrosshairs(callData) { + const { apis, apiIndex } = model; const pos = [callData.position.x, callData.position.y]; const renderer = callData.pokedRenderer; + const dPos = vtkCoordinate.newInstance(); dPos.setCoordinateSystemToDisplay(); + dPos.setValue(pos[0], pos[1], 0); - const worldPos = dPos.getComputedWorldValue(renderer); + let worldPos = dPos.getComputedWorldValue(renderer); - const { apis, apiIndex } = model; + const camera = renderer.getActiveCamera(); + const directionOfProjection = camera.getDirectionOfProjection(); + + const api = apis[apiIndex]; + const halfSlabThickness = api.getSlabThickness() / 2; + + for (let i = 0; i < worldPos.length; i++) { + worldPos[i] += halfSlabThickness * directionOfProjection[i]; + } + + // Add half of the slab thickness to the world position, such that we select + // The center of the slice. if (apis === undefined || apiIndex === undefined) { console.error(