Merge branch 'master' of github.com:OHIF/Viewers into feature/extensions-panels-and-docs
# Conflicts: # extensions/ohif-vtk-extension/package.json # extensions/ohif-vtk-extension/src/commandsModule.js # extensions/ohif-vtk-extension/yarn.lock
This commit is contained in:
commit
a75bae90aa
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ohif/extension-vtk",
|
||||
"version": "0.0.5",
|
||||
"version": "0.0.6",
|
||||
"description": "OHIF extension for VTK.js",
|
||||
"author": "OHIF",
|
||||
"license": "MIT",
|
||||
@ -104,8 +104,7 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.4.5",
|
||||
"@ohif/i18n": "0.0.4",
|
||||
"kw-web-suite": "^8.0.0",
|
||||
"react-vtkjs-viewport": "0.0.8",
|
||||
"react-vtkjs-viewport": "0.0.9",
|
||||
"vtk.js": "^8.9.1"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
import {
|
||||
vtkInteractorStyleMPRCrosshairs,
|
||||
vtkInteractorStyleMPRSlice,
|
||||
vtkInteractorStyleMPRWindowLevel
|
||||
vtkInteractorStyleMPRWindowLevel,
|
||||
vtkSVGCrosshairsWidget,
|
||||
vtkSVGWidgetManager
|
||||
} from 'react-vtkjs-viewport';
|
||||
|
||||
import setMPRLayout from './utils/setMPRLayout.js';
|
||||
import setViewportToVTK from './utils/setViewportToVTK.js';
|
||||
import vtkCoordinate from 'vtk.js/Sources/Rendering/Core/Coordinate';
|
||||
import vtkMath from 'vtk.js/Sources/Common/Core/Math';
|
||||
import vtkMatrixBuilder from 'vtk.js/Sources/Common/Core/MatrixBuilder';
|
||||
|
||||
@ -13,32 +16,44 @@ import vtkMatrixBuilder from 'vtk.js/Sources/Common/Core/MatrixBuilder';
|
||||
let apis = {};
|
||||
|
||||
function getCrosshairCallbackForIndex(index) {
|
||||
return worldPos => {
|
||||
return ({ worldPos }) => {
|
||||
// Set camera focal point to world coordinate for linked views
|
||||
apis.forEach((api, viewportIndex) => {
|
||||
if (viewportIndex === index) {
|
||||
return;
|
||||
if (viewportIndex !== index) {
|
||||
// We are basically doing the same as getSlice but with the world coordinate
|
||||
// that we want to jump to instead of the camera focal point.
|
||||
// I would rather do the camera adjustment directly but I keep
|
||||
// doing it wrong and so this is good enough for now.
|
||||
const renderWindow = api.genericRenderWindow.getRenderWindow();
|
||||
|
||||
const istyle = renderWindow.getInteractor().getInteractorStyle();
|
||||
const sliceNormal = istyle.getSliceNormal();
|
||||
const transform = vtkMatrixBuilder
|
||||
.buildFromDegree()
|
||||
.identity()
|
||||
.rotateFromDirections(sliceNormal, [1, 0, 0]);
|
||||
|
||||
const mutatedWorldPos = worldPos.slice();
|
||||
transform.apply(mutatedWorldPos);
|
||||
const slice = mutatedWorldPos[0];
|
||||
|
||||
istyle.setSlice(slice);
|
||||
|
||||
renderWindow.render();
|
||||
}
|
||||
|
||||
// We are basically doing the same as getSlice but with the world coordinate
|
||||
// that we want to jump to instead of the camera focal point.
|
||||
// I would rather do the camera adjustment directly but I keep
|
||||
// doing it wrong and so this is good enough for now.
|
||||
const renderWindow = api.genericRenderWindow.getRenderWindow();
|
||||
const istyle = renderWindow.getInteractor().getInteractorStyle();
|
||||
const sliceNormal = istyle.getSliceNormal();
|
||||
const transform = vtkMatrixBuilder
|
||||
.buildFromDegree()
|
||||
.identity()
|
||||
.rotateFromDirections(sliceNormal, [1, 0, 0]);
|
||||
const renderer = api.genericRenderWindow.getRenderer();
|
||||
const wPos = vtkCoordinate.newInstance();
|
||||
wPos.setCoordinateSystemToWorld();
|
||||
wPos.setValue(worldPos);
|
||||
|
||||
const mutatedWorldPos = worldPos.slice();
|
||||
transform.apply(mutatedWorldPos);
|
||||
const slice = mutatedWorldPos[0];
|
||||
|
||||
istyle.setSlice(slice);
|
||||
|
||||
renderWindow.render();
|
||||
const displayPosition = wPos.getComputedDisplayValue(renderer);
|
||||
const { svgWidgetManager } = api;
|
||||
api.svgWidgets.crosshairsWidget.setPoint(
|
||||
displayPosition[0],
|
||||
displayPosition[1]
|
||||
);
|
||||
svgWidgetManager.render();
|
||||
});
|
||||
};
|
||||
}
|
||||
@ -204,6 +219,20 @@ const actions = {
|
||||
istyle.setVolumeMapper(api.volumes[0]);
|
||||
istyle.setCallback(getCrosshairCallbackForIndex(index));
|
||||
|
||||
const svgWidgetManager = vtkSVGWidgetManager.newInstance();
|
||||
svgWidgetManager.setRenderer(renderer);
|
||||
svgWidgetManager.setScale(1);
|
||||
|
||||
const crosshairsWidget = vtkSVGCrosshairsWidget.newInstance();
|
||||
|
||||
svgWidgetManager.addWidget(crosshairsWidget);
|
||||
svgWidgetManager.render();
|
||||
|
||||
api.svgWidgetManager = svgWidgetManager;
|
||||
api.svgWidgets = {
|
||||
crosshairsWidget
|
||||
};
|
||||
|
||||
switch (index) {
|
||||
default:
|
||||
case 0:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user