2019-08-13 21:36:46 +02:00
|
|
|
import OHIF from "@ohif/core";
|
|
|
|
|
import PluginSwitch from "./PluginSwitch.js";
|
|
|
|
|
import { commandsManager } from "./../App.js";
|
|
|
|
|
import { connect } from "react-redux";
|
2019-02-24 15:26:50 +01:00
|
|
|
|
2019-05-30 06:46:45 +02:00
|
|
|
const { setLayout } = OHIF.redux.actions;
|
2019-02-24 15:26:50 +01:00
|
|
|
|
|
|
|
|
const mapStateToProps = state => {
|
2019-06-15 14:26:09 +02:00
|
|
|
const { activeViewportIndex, layout, viewportSpecificData } = state.viewports;
|
2019-02-24 15:26:50 +01:00
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
activeViewportIndex,
|
2019-06-15 14:26:09 +02:00
|
|
|
viewportSpecificData,
|
2019-08-13 21:36:46 +02:00
|
|
|
layout
|
2019-05-30 06:46:45 +02:00
|
|
|
};
|
|
|
|
|
};
|
2019-02-24 15:26:50 +01:00
|
|
|
|
|
|
|
|
const mapDispatchToProps = dispatch => {
|
|
|
|
|
return {
|
2019-03-01 10:55:52 +01:00
|
|
|
setLayout: data => {
|
2019-05-30 06:46:45 +02:00
|
|
|
dispatch(setLayout(data));
|
2019-08-13 21:36:46 +02:00
|
|
|
}
|
2019-05-30 06:46:45 +02:00
|
|
|
};
|
|
|
|
|
};
|
2019-02-24 15:26:50 +01:00
|
|
|
|
2019-06-15 14:26:09 +02:00
|
|
|
/*function setSingleLayoutData(originalArray, viewportIndex, data) {
|
2019-05-30 06:46:45 +02:00
|
|
|
const viewports = originalArray.slice();
|
|
|
|
|
const layoutData = Object.assign({}, viewports[viewportIndex], data);
|
2019-02-24 15:26:50 +01:00
|
|
|
|
2019-05-30 06:46:45 +02:00
|
|
|
viewports[viewportIndex] = layoutData;
|
2019-02-24 15:26:50 +01:00
|
|
|
|
2019-05-30 06:46:45 +02:00
|
|
|
return viewports;
|
2019-06-15 14:26:09 +02:00
|
|
|
}*/
|
2019-02-24 15:26:50 +01:00
|
|
|
|
|
|
|
|
const mergeProps = (propsFromState, propsFromDispatch, ownProps) => {
|
2019-06-15 14:26:09 +02:00
|
|
|
//const { activeViewportIndex, layout } = propsFromState;
|
|
|
|
|
//const { setLayout } = propsFromDispatch;
|
2019-02-24 15:26:50 +01:00
|
|
|
|
|
|
|
|
// TODO: Do not display certain options if the current display set
|
|
|
|
|
// cannot be displayed using these view types
|
2019-03-01 10:55:52 +01:00
|
|
|
const buttons = [
|
2019-06-15 14:26:09 +02:00
|
|
|
/*{
|
2019-03-01 10:55:52 +01:00
|
|
|
text: 'Acquired',
|
|
|
|
|
type: 'command',
|
2019-05-28 20:51:29 +02:00
|
|
|
icon: 'bars',
|
2019-03-01 10:55:52 +01:00
|
|
|
active: false,
|
2019-05-28 20:51:29 +02:00
|
|
|
onClick: () => {
|
2019-05-30 06:46:45 +02:00
|
|
|
console.warn('Original Acquisition');
|
2019-02-24 15:26:50 +01:00
|
|
|
|
2019-03-01 10:55:52 +01:00
|
|
|
const layoutData = setSingleLayoutData(
|
|
|
|
|
layout.viewports,
|
|
|
|
|
activeViewportIndex,
|
|
|
|
|
{ plugin: 'cornerstone' }
|
2019-05-30 06:46:45 +02:00
|
|
|
);
|
2019-02-24 15:26:50 +01:00
|
|
|
|
2019-05-30 06:46:45 +02:00
|
|
|
setLayout({ viewports: layoutData });
|
2019-05-01 19:10:44 +02:00
|
|
|
},
|
2019-02-24 15:26:50 +01:00
|
|
|
},
|
|
|
|
|
{
|
2019-03-01 10:55:52 +01:00
|
|
|
text: 'Axial',
|
2019-05-28 20:51:29 +02:00
|
|
|
icon: 'cube',
|
2019-03-01 10:55:52 +01:00
|
|
|
active: false,
|
2019-05-28 20:51:29 +02:00
|
|
|
onClick: () => {
|
2019-06-17 21:42:11 +02:00
|
|
|
commandsManager.runCommand('axial');
|
2019-05-01 19:10:44 +02:00
|
|
|
},
|
2019-02-24 15:26:50 +01:00
|
|
|
},
|
|
|
|
|
{
|
2019-03-01 10:55:52 +01:00
|
|
|
text: 'Sagittal',
|
2019-05-28 20:51:29 +02:00
|
|
|
icon: 'cube',
|
2019-03-01 10:55:52 +01:00
|
|
|
active: false,
|
2019-05-28 20:51:29 +02:00
|
|
|
onClick: () => {
|
2019-06-17 21:42:11 +02:00
|
|
|
commandsManager.runCommand('sagittal');
|
2019-05-01 19:10:44 +02:00
|
|
|
},
|
2019-02-24 15:26:50 +01:00
|
|
|
},
|
|
|
|
|
{
|
2019-03-01 10:55:52 +01:00
|
|
|
text: 'Coronal',
|
2019-05-28 20:51:29 +02:00
|
|
|
icon: 'cube',
|
2019-03-01 10:55:52 +01:00
|
|
|
active: false,
|
2019-05-28 20:51:29 +02:00
|
|
|
onClick: () => {
|
2019-06-17 21:42:11 +02:00
|
|
|
commandsManager.runCommand('coronal');
|
2019-06-15 14:26:09 +02:00
|
|
|
},
|
|
|
|
|
},*/
|
|
|
|
|
{
|
2019-08-13 21:36:46 +02:00
|
|
|
label: "2D MPR",
|
|
|
|
|
icon: "cube",
|
2019-06-15 14:26:09 +02:00
|
|
|
onClick: () => {
|
2019-08-13 21:36:46 +02:00
|
|
|
commandsManager.runCommand("mpr2d");
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-05-30 06:46:45 +02:00
|
|
|
];
|
2019-02-24 15:26:50 +01:00
|
|
|
|
|
|
|
|
return {
|
2019-08-13 21:36:46 +02:00
|
|
|
buttons
|
2019-05-30 06:46:45 +02:00
|
|
|
};
|
|
|
|
|
};
|
2019-02-24 15:26:50 +01:00
|
|
|
|
|
|
|
|
const ConnectedPluginSwitch = connect(
|
|
|
|
|
mapStateToProps,
|
|
|
|
|
mapDispatchToProps,
|
|
|
|
|
mergeProps
|
2019-05-30 06:46:45 +02:00
|
|
|
)(PluginSwitch);
|
2019-02-24 15:26:50 +01:00
|
|
|
|
2019-05-30 06:46:45 +02:00
|
|
|
export default ConnectedPluginSwitch;
|