fix: Exit MPR mode if Layout is changed (#984)
This commit is contained in:
parent
7a4b97b4e8
commit
674ca9f96f
@ -13,15 +13,23 @@ const mapStateToProps = state => {
|
|||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
// TODO: Change if layout switched becomes more complex
|
// TODO: Change if layout switched becomes more complex
|
||||||
onChange: selectedCell => {
|
onChange: (selectedCell, currentLayout) => {
|
||||||
let viewports = [];
|
let viewports = [];
|
||||||
const rows = selectedCell.row + 1;
|
const rows = selectedCell.row + 1;
|
||||||
const columns = selectedCell.col + 1;
|
const columns = selectedCell.col + 1;
|
||||||
const numViewports = rows * columns;
|
const numViewports = rows * columns;
|
||||||
for (let i = 0; i < numViewports; i++) {
|
for (let i = 0; i < numViewports; i++) {
|
||||||
|
// Hacky way to allow users to exit MPR "mode"
|
||||||
|
const viewport = currentLayout.viewports[i];
|
||||||
|
let plugin = viewport && viewport.plugin;
|
||||||
|
if (viewport && viewport.vtk) {
|
||||||
|
plugin = 'cornerstone';
|
||||||
|
}
|
||||||
|
|
||||||
viewports.push({
|
viewports.push({
|
||||||
height: `${100 / rows}%`,
|
height: `${100 / rows}%`,
|
||||||
width: `${100 / columns}%`,
|
width: `${100 / columns}%`,
|
||||||
|
plugin,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const layout = {
|
const layout = {
|
||||||
@ -33,9 +41,19 @@ const mapDispatchToProps = dispatch => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const mergeProps = (propsFromState, propsFromDispatch) => {
|
||||||
|
const onChangeFromDispatch = propsFromDispatch.onChange;
|
||||||
|
const { currentLayout } = propsFromState;
|
||||||
|
|
||||||
|
return {
|
||||||
|
onChange: (selectedCell) => onChangeFromDispatch(selectedCell, currentLayout)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const ConnectedLayoutButton = connect(
|
const ConnectedLayoutButton = connect(
|
||||||
mapStateToProps,
|
mapStateToProps,
|
||||||
mapDispatchToProps
|
mapDispatchToProps,
|
||||||
|
mergeProps
|
||||||
)(LayoutButton);
|
)(LayoutButton);
|
||||||
|
|
||||||
export default ConnectedLayoutButton;
|
export default ConnectedLayoutButton;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user