Skip to content

Commit

Permalink
fix: πŸ› Fix crosshairs issue whilst using a slab/MIP (#64)
Browse files Browse the repository at this point in the history
Closes: #63
  • Loading branch information
JamesAPetts authored Oct 23, 2019
1 parent ea4685d commit c801b5a
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/VTKViewport/vtkInteractorStyleMPRCrosshairs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit c801b5a

Please sign in to comment.