* feat: Implement a 'Exit 2D MPR' button in the toolbar to act as a toggle when '2D MPR' button is clicked * Move logic to exit MPR and toggling into ConnectedPluginSwitch and PluginSwitch. Also, discard the ConnectedExitPluginSwitch and ExitPluginSwitch components. * Update ToolbarRow.js
73 lines
1.5 KiB
JavaScript
73 lines
1.5 KiB
JavaScript
import OHIF from '@ohif/core';
|
|
import React from 'react';
|
|
import PluginSwitch from './PluginSwitch.js';
|
|
import { commandsManager } from './../App.js';
|
|
import { connect } from 'react-redux';
|
|
|
|
const { setLayout } = OHIF.redux.actions;
|
|
|
|
const ConnectedPluginSwitch = (props) => {
|
|
return (
|
|
<PluginSwitch {...props} />
|
|
)
|
|
};
|
|
|
|
const mapStateToProps = state => {
|
|
const { activeViewportIndex, layout, viewportSpecificData } = state.viewports;
|
|
|
|
return {
|
|
activeViewportIndex,
|
|
viewportSpecificData,
|
|
layout,
|
|
};
|
|
};
|
|
|
|
const mapDispatchToProps = dispatch => {
|
|
return {
|
|
setLayout: data => {
|
|
dispatch(setLayout(data));
|
|
}
|
|
};
|
|
};
|
|
|
|
/*function setSingleLayoutData(originalArray, viewportIndex, data) {
|
|
const viewports = originalArray.slice();
|
|
const layoutData = Object.assign({}, viewports[viewportIndex], data);
|
|
|
|
viewports[viewportIndex] = layoutData;
|
|
|
|
return viewports;
|
|
}*/
|
|
|
|
const mergeProps = (propsFromState, propsFromDispatch, ownProps) => {
|
|
//const { activeViewportIndex, layout } = propsFromState;
|
|
const { setLayout } = propsFromDispatch;
|
|
|
|
// TODO: Do not display certain options if the current display set
|
|
// cannot be displayed using these view types
|
|
const mpr = () => {
|
|
commandsManager.runCommand("mpr2d");
|
|
};
|
|
|
|
const exitMpr = () => {
|
|
const layout = {
|
|
numRows: 1,
|
|
numColumns: 1,
|
|
viewports: [{ plugin: 'cornerstone' }],
|
|
};
|
|
|
|
setLayout(layout);
|
|
};
|
|
|
|
return {
|
|
mpr,
|
|
exitMpr
|
|
};
|
|
};
|
|
|
|
export default connect(
|
|
mapStateToProps,
|
|
mapDispatchToProps,
|
|
mergeProps
|
|
)(ConnectedPluginSwitch);
|