Skip to content

Commit e9ca239

Browse files
authored
fix: 🐛 Fix scroll issues with rotatable crosshairs (OHIF#119)
1 parent f487c93 commit e9ca239

File tree

3 files changed

+33
-15
lines changed

3 files changed

+33
-15
lines changed

Diff for: examples/VTKRotatableCrosshairsExample.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ class VTKRotatableCrosshairsExample extends Component {
126126
// // add istyle
127127
api.setInteractorStyle({
128128
istyle,
129-
configuration: { apis, apiIndex: viewportIndex },
129+
configuration: {
130+
apis,
131+
apiIndex: viewportIndex,
132+
},
130133
});
131134

132135
//api.setInteractorStyle({ istyle });

Diff for: src/VTKViewport/vtkInteractorStyleMPRSlice.js

+1-14
Original file line numberDiff line numberDiff line change
@@ -255,25 +255,12 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
255255
}
256256
}
257257

258-
function updateRotatableCrosshairs(callData) {
258+
function updateRotatableCrosshairs() {
259259
const { apis, apiIndex } = model;
260260
const thisApi = apis[apiIndex];
261261
const { rotatableCrosshairsWidget } = thisApi.svgWidgets;
262-
const renderer = callData.pokedRenderer;
263262
const worldPos = thisApi.get('cachedCrosshairWorldPosition');
264263

265-
const camera = renderer.getActiveCamera();
266-
const directionOfProjection = camera.getDirectionOfProjection();
267-
268-
const halfSlabThickness = thisApi.getSlabThickness() / 2;
269-
270-
// Add half of the slab thickness to the world position, such that we select
271-
// The center of the slice.
272-
273-
for (let i = 0; i < worldPos.length; i++) {
274-
worldPos[i] += halfSlabThickness * directionOfProjection[i];
275-
}
276-
277264
rotatableCrosshairsWidget.moveCrosshairs(worldPos, apis, apiIndex);
278265
}
279266

Diff for: src/VTKViewport/vtkInteractorStyleRotatableMPRCrosshairs.js

+28
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ function vtkInteractorStyleRotatableMPRCrosshairs(publicAPI, model) {
3131
const thisApi = apis[apiIndex];
3232
let { position } = callData;
3333

34+
setOtherApisInactive();
35+
3436
const { rotatableCrosshairsWidget } = thisApi.svgWidgets;
3537

3638
if (!rotatableCrosshairsWidget) {
@@ -81,6 +83,7 @@ function vtkInteractorStyleRotatableMPRCrosshairs(publicAPI, model) {
8183

8284
lineRotateHandles.selected = true;
8385

86+
// Set this line active.
8487
if (lineIndex === 0) {
8588
lines[0].active = true;
8689
lines[1].active = false;
@@ -128,10 +131,35 @@ function vtkInteractorStyleRotatableMPRCrosshairs(publicAPI, model) {
128131
line.active = false;
129132
});
130133

134+
setOtherApisInactive();
135+
131136
// What is the fallback? Pan? Do nothing for now.
132137
model.operation = { type: null };
133138
}
134139

140+
function setOtherApisInactive() {
141+
// Set other apis inactive
142+
143+
const { apis, apiIndex } = model;
144+
145+
apis.forEach((api, index) => {
146+
if (index !== apiIndex) {
147+
const { rotatableCrosshairsWidget } = api.svgWidgets;
148+
149+
if (!rotatableCrosshairsWidget) {
150+
throw new Error(
151+
'Must use rotatable crosshair svg widget with this istyle.'
152+
);
153+
}
154+
155+
const lines = rotatableCrosshairsWidget.getReferenceLines();
156+
157+
lines[0].active = false;
158+
lines[1].active = false;
159+
}
160+
});
161+
}
162+
135163
function distanceFromLine(line, point) {
136164
const [a, b] = line.points;
137165
const c = point;

0 commit comments

Comments
 (0)