Bring in rotatable crosshairs. (#2101)
* Bring in rotatable crosshairs. * Pull in react-vtkjs-viewport 0.13.1 fix.
This commit is contained in:
parent
7c3ac387ef
commit
c0280e28ca
@ -50,7 +50,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.5.5",
|
"@babel/runtime": "^7.5.5",
|
||||||
"lodash.throttle": "^4.1.1",
|
"lodash.throttle": "^4.1.1",
|
||||||
"react-vtkjs-viewport": "^0.10.4"
|
"react-vtkjs-viewport": "^0.13.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@ohif/core": "^2.10.7",
|
"@ohif/core": "^2.10.7",
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import throttle from 'lodash.throttle';
|
import throttle from 'lodash.throttle';
|
||||||
import {
|
import {
|
||||||
vtkInteractorStyleMPRCrosshairs,
|
|
||||||
vtkInteractorStyleMPRWindowLevel,
|
vtkInteractorStyleMPRWindowLevel,
|
||||||
|
vtkInteractorStyleRotatableMPRCrosshairs,
|
||||||
|
vtkSVGRotatableCrosshairsWidget,
|
||||||
vtkInteractorStyleMPRRotate,
|
vtkInteractorStyleMPRRotate,
|
||||||
vtkSVGCrosshairsWidget,
|
|
||||||
} from 'react-vtkjs-viewport';
|
} from 'react-vtkjs-viewport';
|
||||||
import { getImageData } from 'react-vtkjs-viewport';
|
import { getImageData } from 'react-vtkjs-viewport';
|
||||||
import { vec3 } from 'gl-matrix';
|
import { vec3 } from 'gl-matrix';
|
||||||
@ -11,7 +11,6 @@ import setMPRLayout from './utils/setMPRLayout.js';
|
|||||||
import setViewportToVTK from './utils/setViewportToVTK.js';
|
import setViewportToVTK from './utils/setViewportToVTK.js';
|
||||||
import Constants from 'vtk.js/Sources/Rendering/Core/VolumeMapper/Constants.js';
|
import Constants from 'vtk.js/Sources/Rendering/Core/VolumeMapper/Constants.js';
|
||||||
import OHIFVTKViewport from './OHIFVTKViewport';
|
import OHIFVTKViewport from './OHIFVTKViewport';
|
||||||
import vtkCoordinate from 'vtk.js/Sources/Rendering/Core/Coordinate';
|
|
||||||
|
|
||||||
const { BlendMode } = Constants;
|
const { BlendMode } = Constants;
|
||||||
|
|
||||||
@ -119,6 +118,14 @@ const commandsModule = ({ commandsManager }) => {
|
|||||||
getVtkApis: ({ index }) => {
|
getVtkApis: ({ index }) => {
|
||||||
return apis[index];
|
return apis[index];
|
||||||
},
|
},
|
||||||
|
resetMPRView() {
|
||||||
|
apis.forEach(api => {
|
||||||
|
api.resetOrientation();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Reset the crosshairs
|
||||||
|
apis[0].svgWidgets.rotatableCrosshairsWidget.resetCrosshairs(apis, 0);
|
||||||
|
},
|
||||||
axial: async ({ viewports }) => {
|
axial: async ({ viewports }) => {
|
||||||
const api = await _getActiveViewportVTKApi(viewports);
|
const api = await _getActiveViewportVTKApi(viewports);
|
||||||
|
|
||||||
@ -165,7 +172,7 @@ const commandsModule = ({ commandsManager }) => {
|
|||||||
segmentNumber,
|
segmentNumber,
|
||||||
frameIndex,
|
frameIndex,
|
||||||
frame,
|
frame,
|
||||||
done = () => { }
|
done = () => {},
|
||||||
}) => {
|
}) => {
|
||||||
let api = apis[viewports.activeViewportIndex];
|
let api = apis[viewports.activeViewportIndex];
|
||||||
|
|
||||||
@ -180,10 +187,13 @@ const commandsModule = ({ commandsManager }) => {
|
|||||||
displaySetInstanceUID,
|
displaySetInstanceUID,
|
||||||
SOPClassUID,
|
SOPClassUID,
|
||||||
SOPInstanceUID,
|
SOPInstanceUID,
|
||||||
frameIndex,
|
frameIndex
|
||||||
);
|
);
|
||||||
|
|
||||||
const imageDataObject = getImageData(stack.imageIds, displaySetInstanceUID);
|
const imageDataObject = getImageData(
|
||||||
|
stack.imageIds,
|
||||||
|
displaySetInstanceUID
|
||||||
|
);
|
||||||
|
|
||||||
let pixelIndex = 0;
|
let pixelIndex = 0;
|
||||||
let x = 0;
|
let x = 0;
|
||||||
@ -209,9 +219,12 @@ const commandsModule = ({ commandsManager }) => {
|
|||||||
y /= count;
|
y /= count;
|
||||||
|
|
||||||
const position = [x, y, frameIndex];
|
const position = [x, y, frameIndex];
|
||||||
const worldPos = _convertModelToWorldSpace(position, imageDataObject.vtkImageData);
|
const worldPos = _convertModelToWorldSpace(
|
||||||
|
position,
|
||||||
|
imageDataObject.vtkImageData
|
||||||
|
);
|
||||||
|
|
||||||
api.svgWidgets.crosshairsWidget.moveCrosshairs(worldPos, apis);
|
api.svgWidgets.rotatableCrosshairsWidget.moveCrosshairs(worldPos, apis);
|
||||||
done();
|
done();
|
||||||
},
|
},
|
||||||
setSegmentationConfiguration: async ({
|
setSegmentationConfiguration: async ({
|
||||||
@ -254,21 +267,35 @@ const commandsModule = ({ commandsManager }) => {
|
|||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
},
|
},
|
||||||
enableRotateTool: () => {
|
enableRotateTool: () => {
|
||||||
apis.forEach(api => {
|
apis.forEach((api, apiIndex) => {
|
||||||
const istyle = vtkInteractorStyleMPRRotate.newInstance();
|
const istyle = vtkInteractorStyleMPRRotate.newInstance();
|
||||||
|
|
||||||
api.setInteractorStyle({ istyle });
|
api.setInteractorStyle({ istyle, configuration: { apis, apiIndex } });
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
enableCrosshairsTool: () => {
|
enableCrosshairsTool: () => {
|
||||||
apis.forEach((api, apiIndex) => {
|
apis.forEach((api, apiIndex) => {
|
||||||
const istyle = vtkInteractorStyleMPRCrosshairs.newInstance();
|
const istyle = vtkInteractorStyleRotatableMPRCrosshairs.newInstance();
|
||||||
|
|
||||||
api.setInteractorStyle({
|
api.setInteractorStyle({
|
||||||
istyle,
|
istyle,
|
||||||
configuration: { apis, apiIndex },
|
configuration: {
|
||||||
|
apis,
|
||||||
|
apiIndex,
|
||||||
|
uid: api.uid,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const rotatableCrosshairsWidget =
|
||||||
|
apis[0].svgWidgets.rotatableCrosshairsWidget;
|
||||||
|
|
||||||
|
const referenceLines = rotatableCrosshairsWidget.getReferenceLines();
|
||||||
|
|
||||||
|
// Initilise crosshairs if not initialised.
|
||||||
|
if (!referenceLines) {
|
||||||
|
rotatableCrosshairsWidget.resetCrosshairs(apis, 0);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
enableLevelTool: () => {
|
enableLevelTool: () => {
|
||||||
function updateVOI(apis, windowWidth, windowCenter) {
|
function updateVOI(apis, windowWidth, windowCenter) {
|
||||||
@ -391,18 +418,24 @@ const commandsModule = ({ commandsManager }) => {
|
|||||||
// Add widgets and set default interactorStyle of each viewport.
|
// Add widgets and set default interactorStyle of each viewport.
|
||||||
apis.forEach((api, apiIndex) => {
|
apis.forEach((api, apiIndex) => {
|
||||||
api.addSVGWidget(
|
api.addSVGWidget(
|
||||||
vtkSVGCrosshairsWidget.newInstance(),
|
vtkSVGRotatableCrosshairsWidget.newInstance(),
|
||||||
'crosshairsWidget'
|
'rotatableCrosshairsWidget'
|
||||||
);
|
);
|
||||||
|
|
||||||
const uid = api.uid;
|
const uid = api.uid;
|
||||||
const istyle = vtkInteractorStyleMPRCrosshairs.newInstance();
|
const istyle = vtkInteractorStyleRotatableMPRCrosshairs.newInstance();
|
||||||
|
|
||||||
api.setInteractorStyle({
|
api.setInteractorStyle({
|
||||||
istyle,
|
istyle,
|
||||||
configuration: { apis, apiIndex, uid },
|
configuration: { apis, apiIndex, uid },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
api.svgWidgets.rotatableCrosshairsWidget.setApiIndex(apiIndex);
|
||||||
|
api.svgWidgets.rotatableCrosshairsWidget.setApis(apis);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Initialise crosshairs
|
||||||
|
apis[0].svgWidgets.rotatableCrosshairsWidget.resetCrosshairs(apis, 0);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -456,6 +489,10 @@ const commandsModule = ({ commandsManager }) => {
|
|||||||
commandFn: actions.enableLevelTool,
|
commandFn: actions.enableLevelTool,
|
||||||
options: {},
|
options: {},
|
||||||
},
|
},
|
||||||
|
resetMPRView: {
|
||||||
|
commandFn: actions.resetMPRView,
|
||||||
|
options: {},
|
||||||
|
},
|
||||||
setBlendModeToComposite: {
|
setBlendModeToComposite: {
|
||||||
commandFn: actions.setBlendModeToComposite,
|
commandFn: actions.setBlendModeToComposite,
|
||||||
options: { blendMode: BlendMode.COMPOSITE_BLEND },
|
options: { blendMode: BlendMode.COMPOSITE_BLEND },
|
||||||
|
|||||||
@ -25,6 +25,15 @@ const definitions = [
|
|||||||
commandName: 'enableLevelTool',
|
commandName: 'enableLevelTool',
|
||||||
commandOptions: {},
|
commandOptions: {},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'Reset',
|
||||||
|
label: 'Reset',
|
||||||
|
icon: 'reset',
|
||||||
|
//
|
||||||
|
type: TOOLBAR_BUTTON_TYPES.COMMAND,
|
||||||
|
commandName: 'resetMPRView',
|
||||||
|
commandOptions: {},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'Rotate',
|
id: 'Rotate',
|
||||||
label: 'Rotate',
|
label: 'Rotate',
|
||||||
@ -131,4 +140,4 @@ const definitions = [
|
|||||||
export default {
|
export default {
|
||||||
definitions,
|
definitions,
|
||||||
defaultContext: 'ACTIVE_VIEWPORT::VTK',
|
defaultContext: 'ACTIVE_VIEWPORT::VTK',
|
||||||
}
|
};
|
||||||
|
|||||||
17
yarn.lock
17
yarn.lock
@ -6539,13 +6539,14 @@ dateformat@^3.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae"
|
resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae"
|
||||||
integrity sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==
|
integrity sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==
|
||||||
|
|
||||||
dcmjs@0.16.3:
|
dcmjs@0.16.5:
|
||||||
version "0.16.3"
|
version "0.16.5"
|
||||||
resolved "https://registry.yarnpkg.com/dcmjs/-/dcmjs-0.16.3.tgz#ef44ccc4988a473fd40e1601122c57f2babded11"
|
resolved "https://registry.yarnpkg.com/dcmjs/-/dcmjs-0.16.5.tgz#05aa0c8d539a4d5777f996b9b796932d1f848993"
|
||||||
integrity sha512-pMQGifMpMW9i9ufCdUoEPHrLWnm6ilnpfLqUc+PPoWr7OnuBhiRVRunbv39oTtFDZOLhQ2Ampm7UrkidWAbqiA==
|
integrity sha512-Y92KAx4JSfev79xjYhaukQZjWgyJlaHnXSTdbtkGkJAHERjIakgHcCIPmACuVmtW/nHViTu04zIGAB0pmZ4GaA==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@babel/polyfill" "^7.8.3"
|
"@babel/polyfill" "^7.8.3"
|
||||||
"@babel/runtime" "^7.8.4"
|
"@babel/runtime" "^7.8.4"
|
||||||
|
gl-matrix "^3.1.0"
|
||||||
loglevelnext "^3.0.1"
|
loglevelnext "^3.0.1"
|
||||||
ndarray "^1.0.19"
|
ndarray "^1.0.19"
|
||||||
|
|
||||||
@ -16060,10 +16061,10 @@ react-transition-group@^4.1.1:
|
|||||||
loose-envify "^1.4.0"
|
loose-envify "^1.4.0"
|
||||||
prop-types "^15.6.2"
|
prop-types "^15.6.2"
|
||||||
|
|
||||||
react-vtkjs-viewport@^0.10.4:
|
react-vtkjs-viewport@^0.13.1:
|
||||||
version "0.10.4"
|
version "0.13.1"
|
||||||
resolved "https://registry.yarnpkg.com/react-vtkjs-viewport/-/react-vtkjs-viewport-0.10.4.tgz#eb038b0bf5c384bd3b45f2a0a57f52c682607fea"
|
resolved "https://registry.yarnpkg.com/react-vtkjs-viewport/-/react-vtkjs-viewport-0.13.1.tgz#11b69873377cd66b6522079eb05d54317c2e8903"
|
||||||
integrity sha512-J1WxwHbjlttEWvdkM33DJx8QxHr3J7HR6wFSDVBDKY7McK2lwDAdRN8wSqy2BVNILlyurUUVwg2tK2txiJ+tuw==
|
integrity sha512-P2jmv0rZtas9+pZCzVBr0R/EqmXpWqPP8JA1DScwKgFoYj4ApqnQeLXSVz2VHXi58q87k2uay9k7xcchLiStrQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
date-fns "^2.2.1"
|
date-fns "^2.2.1"
|
||||||
gl-matrix "^3.1.0"
|
gl-matrix "^3.1.0"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user