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",
|
"name": "@ohif/extension-vtk",
|
||||||
"version": "0.0.5",
|
"version": "0.0.6",
|
||||||
"description": "OHIF extension for VTK.js",
|
"description": "OHIF extension for VTK.js",
|
||||||
"author": "OHIF",
|
"author": "OHIF",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -104,8 +104,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.4.5",
|
"@babel/runtime": "^7.4.5",
|
||||||
"@ohif/i18n": "0.0.4",
|
"@ohif/i18n": "0.0.4",
|
||||||
"kw-web-suite": "^8.0.0",
|
"react-vtkjs-viewport": "0.0.9",
|
||||||
"react-vtkjs-viewport": "0.0.8",
|
|
||||||
"vtk.js": "^8.9.1"
|
"vtk.js": "^8.9.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,14 @@
|
|||||||
import {
|
import {
|
||||||
vtkInteractorStyleMPRCrosshairs,
|
vtkInteractorStyleMPRCrosshairs,
|
||||||
vtkInteractorStyleMPRSlice,
|
vtkInteractorStyleMPRSlice,
|
||||||
vtkInteractorStyleMPRWindowLevel
|
vtkInteractorStyleMPRWindowLevel,
|
||||||
|
vtkSVGCrosshairsWidget,
|
||||||
|
vtkSVGWidgetManager
|
||||||
} from 'react-vtkjs-viewport';
|
} from 'react-vtkjs-viewport';
|
||||||
|
|
||||||
import setMPRLayout from './utils/setMPRLayout.js';
|
import setMPRLayout from './utils/setMPRLayout.js';
|
||||||
import setViewportToVTK from './utils/setViewportToVTK.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 vtkMath from 'vtk.js/Sources/Common/Core/Math';
|
||||||
import vtkMatrixBuilder from 'vtk.js/Sources/Common/Core/MatrixBuilder';
|
import vtkMatrixBuilder from 'vtk.js/Sources/Common/Core/MatrixBuilder';
|
||||||
|
|
||||||
@ -13,18 +16,16 @@ import vtkMatrixBuilder from 'vtk.js/Sources/Common/Core/MatrixBuilder';
|
|||||||
let apis = {};
|
let apis = {};
|
||||||
|
|
||||||
function getCrosshairCallbackForIndex(index) {
|
function getCrosshairCallbackForIndex(index) {
|
||||||
return worldPos => {
|
return ({ worldPos }) => {
|
||||||
// Set camera focal point to world coordinate for linked views
|
// Set camera focal point to world coordinate for linked views
|
||||||
apis.forEach((api, viewportIndex) => {
|
apis.forEach((api, viewportIndex) => {
|
||||||
if (viewportIndex === index) {
|
if (viewportIndex !== index) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We are basically doing the same as getSlice but with the world coordinate
|
// 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.
|
// that we want to jump to instead of the camera focal point.
|
||||||
// I would rather do the camera adjustment directly but I keep
|
// I would rather do the camera adjustment directly but I keep
|
||||||
// doing it wrong and so this is good enough for now.
|
// doing it wrong and so this is good enough for now.
|
||||||
const renderWindow = api.genericRenderWindow.getRenderWindow();
|
const renderWindow = api.genericRenderWindow.getRenderWindow();
|
||||||
|
|
||||||
const istyle = renderWindow.getInteractor().getInteractorStyle();
|
const istyle = renderWindow.getInteractor().getInteractorStyle();
|
||||||
const sliceNormal = istyle.getSliceNormal();
|
const sliceNormal = istyle.getSliceNormal();
|
||||||
const transform = vtkMatrixBuilder
|
const transform = vtkMatrixBuilder
|
||||||
@ -39,6 +40,20 @@ function getCrosshairCallbackForIndex(index) {
|
|||||||
istyle.setSlice(slice);
|
istyle.setSlice(slice);
|
||||||
|
|
||||||
renderWindow.render();
|
renderWindow.render();
|
||||||
|
}
|
||||||
|
|
||||||
|
const renderer = api.genericRenderWindow.getRenderer();
|
||||||
|
const wPos = vtkCoordinate.newInstance();
|
||||||
|
wPos.setCoordinateSystemToWorld();
|
||||||
|
wPos.setValue(worldPos);
|
||||||
|
|
||||||
|
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.setVolumeMapper(api.volumes[0]);
|
||||||
istyle.setCallback(getCrosshairCallbackForIndex(index));
|
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) {
|
switch (index) {
|
||||||
default:
|
default:
|
||||||
case 0:
|
case 0:
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user