Skip to content

Commit 3bab781

Browse files
authored
feat: 🎸 Fix second wave of bugs (OHIF#120)
Fix bugs relating to pan resetting the slice thickness.
1 parent e9ca239 commit 3bab781

File tree

4 files changed

+24
-36
lines changed

4 files changed

+24
-36
lines changed

‎.webpack/webpack.dev.js

+7
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ const ENTRY_EXAMPLES = path.join(__dirname, './../examples/index.js');
3636
const SRC_PATH = path.join(__dirname, './../src');
3737
const OUT_PATH = path.join(__dirname, './../dist');
3838

39+
// Add this additional call so we can yarn link vtk.js
40+
// const shaderLoader = {
41+
// test: /\.glsl$/i,
42+
// loader: 'shader-loader',
43+
// };
44+
3945
module.exports = {
4046
entry: {
4147
examples: ENTRY_EXAMPLES,
@@ -70,6 +76,7 @@ module.exports = {
7076
],
7177
},
7278
].concat(vtkRules),
79+
//.concat(shaderLoader),
7380
},
7481
resolve: {
7582
modules: [path.resolve(__dirname, './../node_modules'), SRC_PATH],

‎examples/VTKRotatableCrosshairsExample.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class VTKRotatableCrosshairsExample extends Component {
123123

124124
const istyle = vtkInteractorStyleRotatableMPRCrosshairs.newInstance();
125125

126-
// // add istyle
126+
// add istyle
127127
api.setInteractorStyle({
128128
istyle,
129129
configuration: {
@@ -132,8 +132,6 @@ class VTKRotatableCrosshairsExample extends Component {
132132
},
133133
});
134134

135-
//api.setInteractorStyle({ istyle });
136-
137135
// set blend mode to MIP.
138136
const mapper = api.volumes[0].getMapper();
139137
if (mapper.setBlendModeToMaximumIntensity) {

‎src/VTKViewport/vtkInteractorStyleMPRSlice.js

+10
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
165165
// should be set after pos and distance
166166
camera.setDirectionOfProjection(..._normal);
167167
camera.setViewAngle(angle);
168+
168169
camera.setThicknessFromFocalPoint(model.slabThickness);
169170

170171
publicAPI.setCenterOfRotation(center);
@@ -280,6 +281,15 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
280281
superHandleMouseMove(callData);
281282
}
282283

284+
const { apis, apiIndex } = model;
285+
const thisApi = apis[apiIndex];
286+
287+
// This stops the clipping range being randomly reset.
288+
const renderer = thisApi.genericRenderWindow.getRenderer();
289+
const camera = renderer.getActiveCamera();
290+
291+
camera.setThicknessFromFocalPoint(model.slabThickness);
292+
283293
if (model.state === States.IS_PAN) {
284294
const { apis, apiIndex } = model;
285295
const api = apis[apiIndex];

‎src/VTKViewport/vtkInteractorStyleRotatableMPRCrosshairs.js

+6-33
Original file line numberDiff line numberDiff line change
@@ -281,32 +281,9 @@ function vtkInteractorStyleRotatableMPRCrosshairs(publicAPI, model) {
281281

282282
const { rotatableCrosshairsWidget } = thisApi.svgWidgets;
283283

284-
const point = rotatableCrosshairsWidget.getPoint();
285-
286-
const renderer = callData.pokedRenderer;
287-
const dPos = vtkCoordinate.newInstance();
288-
dPos.setCoordinateSystemToDisplay();
289-
290-
dPos.setValue(point[0], point[1], 0);
291-
let worldPos = dPos.getComputedWorldValue(renderer);
292-
293-
const camera = renderer.getActiveCamera();
294-
const directionOfProjection = camera.getDirectionOfProjection();
295-
296-
const halfSlabThickness = thisApi.getSlabThickness() / 2;
297-
298-
// Add half of the slab thickness to the world position, such that we select
299-
// The center of the slice.
284+
const worldPos = thisApi.get('cachedCrosshairWorldPosition');
300285

301-
for (let i = 0; i < worldPos.length; i++) {
302-
worldPos[i] += halfSlabThickness * directionOfProjection[i];
303-
}
304-
305-
thisApi.svgWidgets.rotatableCrosshairsWidget.moveCrosshairs(
306-
worldPos,
307-
apis,
308-
apiIndex
309-
);
286+
rotatableCrosshairsWidget.moveCrosshairs(worldPos, apis, apiIndex);
310287
}
311288

312289
function snapPosToLine(position, lineIndex) {
@@ -364,7 +341,7 @@ function vtkInteractorStyleRotatableMPRCrosshairs(publicAPI, model) {
364341

365342
function moveCrosshairs(pos, renderer) {
366343
const { apis, apiIndex } = model;
367-
const api = apis[apiIndex];
344+
const thisApi = apis[apiIndex];
368345

369346
const dPos = vtkCoordinate.newInstance();
370347
dPos.setCoordinateSystemToDisplay();
@@ -375,7 +352,7 @@ function vtkInteractorStyleRotatableMPRCrosshairs(publicAPI, model) {
375352
const camera = renderer.getActiveCamera();
376353
const directionOfProjection = camera.getDirectionOfProjection();
377354

378-
const halfSlabThickness = api.getSlabThickness() / 2;
355+
const halfSlabThickness = thisApi.getSlabThickness() / 2;
379356

380357
// Add half of the slab thickness to the world position, such that we select
381358
// The center of the slice.
@@ -384,7 +361,7 @@ function vtkInteractorStyleRotatableMPRCrosshairs(publicAPI, model) {
384361
worldPos[i] += halfSlabThickness * directionOfProjection[i];
385362
}
386363

387-
api.svgWidgets.rotatableCrosshairsWidget.moveCrosshairs(
364+
thisApi.svgWidgets.rotatableCrosshairsWidget.moveCrosshairs(
388365
worldPos,
389366
apis,
390367
apiIndex
@@ -467,11 +444,7 @@ function vtkInteractorStyleRotatableMPRCrosshairs(publicAPI, model) {
467444
};
468445

469446
// Move point.
470-
moveCrosshairs(
471-
displayCoordinate,
472-
//{ x: newCenterPointSVG[0], y: newCenterPointSVG[1] },
473-
renderer
474-
);
447+
moveCrosshairs(displayCoordinate, renderer);
475448
}
476449

477450
function getDisplayCoordinateScrollIncrement(point) {

0 commit comments

Comments
 (0)