update branch
This commit is contained in:
commit
8c608dc05b
25 files changed
+749
-199
No files matched your search
+40
-21
@@ -1,8 +1,13 @@
|
||||
import './config';
|
||||
|
||||
import { OidcProvider, reducer as oidcReducer } from 'redux-oidc';
|
||||
import {
|
||||
CommandsManager,
|
||||
HotkeysManager,
|
||||
extensions,
|
||||
redux,
|
||||
utils,
|
||||
} from 'ohif-core';
|
||||
import React, { Component } from 'react';
|
||||
import { combineReducers, createStore } from 'redux';
|
||||
import {
|
||||
getDefaultToolbarButtons,
|
||||
getUserManagerForOpenIdConnectClient,
|
||||
@@ -10,59 +15,73 @@ import {
|
||||
} from './utils/index.js';
|
||||
|
||||
import ConnectedToolContextMenu from './connectedComponents/ConnectedToolContextMenu';
|
||||
import OHIF from 'ohif-core';
|
||||
import OHIFCornerstoneExtension from '@ohif/extension-cornerstone';
|
||||
import OHIFDicomHtmlExtension from 'ohif-dicom-html-extension';
|
||||
import OHIFDicomMicroscopyExtension from '@ohif/extension-dicom-microscopy';
|
||||
import OHIFDicomPDFExtension from 'ohif-dicom-pdf-extension';
|
||||
import OHIFStandaloneViewer from './OHIFStandaloneViewer';
|
||||
import OHIFVTKExtension from '@ohif/extension-vtk';
|
||||
import { OidcProvider } from 'redux-oidc';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Provider } from 'react-redux';
|
||||
import { BrowserRouter as Router } from 'react-router-dom';
|
||||
import WhiteLabellingContext from './WhiteLabellingContext';
|
||||
import appCommands from './appCommands';
|
||||
import setupTools from './setupTools';
|
||||
import ui from './redux/ui.js';
|
||||
import i18n from '@ohif/i18n';
|
||||
import { I18nextProvider } from 'react-i18next';
|
||||
import store from './store';
|
||||
|
||||
const { ExtensionManager } = OHIF.extensions;
|
||||
const { reducers, localStorage } = OHIF.redux;
|
||||
// ~~~~ APP SETUP
|
||||
const commandsManagerConfig = {
|
||||
getAppState: () => store.getState(),
|
||||
getActiveContexts: () => store.getState().ui.activeContexts,
|
||||
};
|
||||
|
||||
reducers.ui = ui;
|
||||
reducers.oidc = oidcReducer;
|
||||
const commandsManager = new CommandsManager(commandsManagerConfig);
|
||||
const hotkeysManager = new HotkeysManager(commandsManager);
|
||||
|
||||
const combined = combineReducers(reducers);
|
||||
const store = createStore(combined, localStorage.loadState());
|
||||
// TODO: Should be done in extensions w/ commandsModule
|
||||
// ~~ ADD COMMANDS
|
||||
appCommands.init(commandsManager);
|
||||
if (window.config.hotkeys) {
|
||||
hotkeysManager.setHotkeys(window.config.hotkeys, true);
|
||||
}
|
||||
|
||||
store.subscribe(() => {
|
||||
localStorage.saveState({
|
||||
preferences: store.getState().preferences,
|
||||
});
|
||||
// Force active contexts for now. These should be set in Viewer/ActiveViewer
|
||||
store.dispatch({
|
||||
type: 'ADD_ACTIVE_CONTEXT',
|
||||
item: 'VIEWER',
|
||||
});
|
||||
store.dispatch({
|
||||
type: 'ADD_ACTIVE_CONTEXT',
|
||||
item: 'VIEWER::CORNERSTONE',
|
||||
});
|
||||
|
||||
// ~~~~ END APP SETUP
|
||||
|
||||
setupTools(store);
|
||||
|
||||
const children = {
|
||||
viewport: [<ConnectedToolContextMenu />],
|
||||
viewport: [<ConnectedToolContextMenu key="tool-context" />],
|
||||
};
|
||||
|
||||
/** TODO: extensions should be passed in as prop as soon as we have the extensions as separate packages and then registered by ExtensionsManager */
|
||||
const extensions = [
|
||||
extensions.ExtensionManager.registerExtensions(store, [
|
||||
new OHIFCornerstoneExtension({ children }),
|
||||
new OHIFVTKExtension(),
|
||||
new OHIFDicomPDFExtension(),
|
||||
new OHIFDicomHtmlExtension(),
|
||||
new OHIFDicomMicroscopyExtension(),
|
||||
];
|
||||
ExtensionManager.registerExtensions(store, extensions);
|
||||
]);
|
||||
|
||||
// TODO[react] Use a provider when the whole tree is React
|
||||
window.store = store;
|
||||
|
||||
function handleServers(servers) {
|
||||
if (servers) {
|
||||
OHIF.utils.addServers(servers, store);
|
||||
utils.addServers(servers, store);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,9 +104,7 @@ class App extends Component {
|
||||
|
||||
//
|
||||
const defaultButtons = getDefaultToolbarButtons(this.props.routerBasename);
|
||||
const buttonsAction = OHIF.redux.actions.setAvailableButtons(
|
||||
defaultButtons
|
||||
);
|
||||
const buttonsAction = redux.actions.setAvailableButtons(defaultButtons);
|
||||
|
||||
store.dispatch(buttonsAction);
|
||||
|
||||
@@ -142,3 +159,5 @@ class App extends Component {
|
||||
}
|
||||
|
||||
export default App;
|
||||
|
||||
export { commandsManager, hotkeysManager };
|
||||
@@ -0,0 +1 @@
|
||||
# Commands
|
||||
@@ -0,0 +1,185 @@
|
||||
import cornerstone from 'cornerstone-core';
|
||||
import { redux } from 'ohif-core';
|
||||
import store from './../store/';
|
||||
|
||||
const { setToolActive } = redux.actions;
|
||||
|
||||
const actions = {
|
||||
rotateViewport: ({ viewports, rotation }) => {
|
||||
const enabledElement = _getActiveViewportEnabledElement(
|
||||
viewports.viewportSpecificData,
|
||||
viewports.activeViewportIndex
|
||||
);
|
||||
|
||||
if (enabledElement) {
|
||||
let viewport = cornerstone.getViewport(enabledElement);
|
||||
viewport.rotation += rotation;
|
||||
cornerstone.setViewport(enabledElement, viewport);
|
||||
}
|
||||
},
|
||||
flipViewportHorizontal: ({ viewports }) => {
|
||||
const enabledElement = _getActiveViewportEnabledElement(
|
||||
viewports.viewportSpecificData,
|
||||
viewports.activeViewportIndex
|
||||
);
|
||||
|
||||
if (enabledElement) {
|
||||
let viewport = cornerstone.getViewport(enabledElement);
|
||||
viewport.hflip = !viewport.hflip;
|
||||
cornerstone.setViewport(enabledElement, viewport);
|
||||
}
|
||||
},
|
||||
flipViewportVertical: ({ viewports }) => {
|
||||
const enabledElement = _getActiveViewportEnabledElement(
|
||||
viewports.viewportSpecificData,
|
||||
viewports.activeViewportIndex
|
||||
);
|
||||
|
||||
if (enabledElement) {
|
||||
let viewport = cornerstone.getViewport(enabledElement);
|
||||
viewport.vflip = !viewport.vflip;
|
||||
cornerstone.setViewport(enabledElement, viewport);
|
||||
}
|
||||
},
|
||||
scaleViewport: ({ viewports, direction }) => {
|
||||
const enabledElement = _getActiveViewportEnabledElement(
|
||||
viewports.viewportSpecificData,
|
||||
viewports.activeViewportIndex
|
||||
);
|
||||
const step = direction * 0.15;
|
||||
|
||||
if (enabledElement) {
|
||||
if (step) {
|
||||
let viewport = cornerstone.getViewport(enabledElement);
|
||||
viewport.scale += step;
|
||||
cornerstone.setViewport(enabledElement, viewport);
|
||||
} else {
|
||||
cornerstone.fitToWindow(enabledElement);
|
||||
}
|
||||
}
|
||||
},
|
||||
resetViewport: ({ viewports }) => {
|
||||
const enabledElement = _getActiveViewportEnabledElement(
|
||||
viewports.viewportSpecificData,
|
||||
viewports.activeViewportIndex
|
||||
);
|
||||
|
||||
if (enabledElement) {
|
||||
cornerstone.reset(enabledElement);
|
||||
}
|
||||
},
|
||||
invertViewport: ({ viewports }) => {
|
||||
const enabledElement = _getActiveViewportEnabledElement(
|
||||
viewports.viewportSpecificData,
|
||||
viewports.activeViewportIndex
|
||||
);
|
||||
|
||||
if (enabledElement) {
|
||||
let viewport = cornerstone.getViewport(enabledElement);
|
||||
viewport.invert = !viewport.invert;
|
||||
cornerstone.setViewport(enabledElement, viewport);
|
||||
}
|
||||
},
|
||||
// This has a weird hard dependency on the tools that are available as toolbar
|
||||
// buttons. You can see this in `ohif-core/src/redux/reducers/tools.js`
|
||||
// the `toolName` needs to equal the button's `command` property.
|
||||
// NOTE: It would be nice if `hotkeys` could set this, instead of creating a command per tool
|
||||
setCornerstoneToolActive: ({ toolName }) => {
|
||||
store.dispatch(setToolActive(toolName));
|
||||
},
|
||||
updateViewportDisplaySet: ({ direction }) => {
|
||||
// TODO
|
||||
console.warn('updateDisplaySet: ', direction);
|
||||
},
|
||||
clearAnnotations: () => {
|
||||
console.warn('clearAnnotations: not yet implemented');
|
||||
// const toolState =
|
||||
// cornerstoneTools.globalImageIdSpecificToolStateManager.toolState;
|
||||
// if (!toolState) return;
|
||||
// Object.keys(toolState).forEach(imageId => {
|
||||
// if (!cornerstoneImageId || cornerstoneImageId === imageId)
|
||||
// delete toolState[imageId];
|
||||
// });
|
||||
},
|
||||
};
|
||||
|
||||
const definitions = {
|
||||
rotateViewportCW: {
|
||||
commandFn: actions.rotateViewport,
|
||||
storeContexts: ['viewports'],
|
||||
options: { rotation: 90 },
|
||||
},
|
||||
rotateViewportCCW: {
|
||||
commandFn: actions.rotateViewport,
|
||||
storeContexts: ['viewports'],
|
||||
options: { rotation: -90 },
|
||||
},
|
||||
invertViewport: {
|
||||
commandFn: actions.invertViewport,
|
||||
storeContexts: ['viewports'],
|
||||
options: {},
|
||||
},
|
||||
flipViewportVertical: {
|
||||
commandFn: actions.flipViewportVertical,
|
||||
storeContexts: ['viewports'],
|
||||
options: {},
|
||||
},
|
||||
flipViewportHorizontal: {
|
||||
commandFn: actions.flipViewportHorizontal,
|
||||
storeContexts: ['viewports'],
|
||||
options: {},
|
||||
},
|
||||
scaleUpViewport: {
|
||||
keys: '',
|
||||
commandFn: actions.scaleViewport,
|
||||
storeContexts: ['viewports'],
|
||||
options: { direction: 1 },
|
||||
},
|
||||
scaleDownViewport: {
|
||||
keys: '',
|
||||
commandFn: actions.scaleViewport,
|
||||
storeContexts: ['viewports'],
|
||||
options: { direction: -1 },
|
||||
},
|
||||
fitViewportToWindow: {
|
||||
commandFn: actions.scaleViewport,
|
||||
storeContexts: ['viewports'],
|
||||
options: { direction: 0 },
|
||||
},
|
||||
resetViewport: {
|
||||
commandFn: actions.resetViewport,
|
||||
storeContexts: ['viewports'],
|
||||
options: {},
|
||||
},
|
||||
// TODO: Clear Annotations
|
||||
// TODO: Next/Previous image
|
||||
// TODO: First/Last image
|
||||
// Next/Previous series/DisplaySet
|
||||
nextViewportDisplaySet: {
|
||||
commandFn: actions.updateViewportDisplaySet,
|
||||
storeContexts: [],
|
||||
options: { direction: 1 },
|
||||
},
|
||||
previousViewportDisplaySet: {
|
||||
commandFn: actions.updateViewportDisplaySet,
|
||||
storeContexts: [],
|
||||
options: { direction: -1 },
|
||||
},
|
||||
// TOOLS
|
||||
setZoomTool: {
|
||||
commandFn: actions.setCornerstoneToolActive,
|
||||
storeContexts: [],
|
||||
options: { toolName: 'Zoom' },
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Grabs `dom` reference for the enabledElement of
|
||||
* the active viewport
|
||||
*/
|
||||
function _getActiveViewportEnabledElement(viewports, activeIndex) {
|
||||
const activeViewport = viewports[activeIndex] || {};
|
||||
return activeViewport.dom;
|
||||
}
|
||||
|
||||
export default definitions;
|
||||
@@ -0,0 +1,60 @@
|
||||
import cornerstoneCommandDefinitions from './cornerstone.js';
|
||||
import viewerCommandDefinitions from './viewer.js';
|
||||
|
||||
const CONTEXTS = {
|
||||
viewer: 'VIEWER',
|
||||
cornerstone: 'VIEWER::CORNERSTONE',
|
||||
};
|
||||
|
||||
/**
|
||||
* Register all commands.
|
||||
* TODO: Extensions should self-register their commands
|
||||
*/
|
||||
function init(commandsManager) {
|
||||
_registerViewerCommands(commandsManager);
|
||||
_registerCornerstoneCommands(commandsManager);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all Viewer commands
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function _registerViewerCommands(commandsManager) {
|
||||
const commandContext = CONTEXTS.viewer;
|
||||
|
||||
commandsManager.createContext(commandContext);
|
||||
Object.keys(viewerCommandDefinitions).forEach(commandName => {
|
||||
const commandDefinition = viewerCommandDefinitions[commandName];
|
||||
|
||||
commandsManager.registerCommand(
|
||||
commandContext,
|
||||
commandName,
|
||||
commandDefinition
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all Cornerstone commands
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function _registerCornerstoneCommands(commandsManager) {
|
||||
const commandContext = CONTEXTS.cornerstone;
|
||||
|
||||
commandsManager.createContext(commandContext);
|
||||
Object.keys(cornerstoneCommandDefinitions).forEach(commandName => {
|
||||
const commandDefinition = cornerstoneCommandDefinitions[commandName];
|
||||
|
||||
commandsManager.registerCommand(
|
||||
commandContext,
|
||||
commandName,
|
||||
commandDefinition
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export default {
|
||||
init,
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
import { redux } from 'ohif-core';
|
||||
import store from './../store';
|
||||
const { setViewportActive } = redux.actions;
|
||||
|
||||
const actions = {
|
||||
updateViewportDisplaySet: ({ direction }) => {
|
||||
// TODO
|
||||
console.warn('updateDisplaySet: ', direction);
|
||||
},
|
||||
updateActiveViewport: ({ viewports, direction }) => {
|
||||
const { viewportSpecificData, activeViewportIndex } = viewports;
|
||||
const maxIndex = Object.keys(viewportSpecificData).length - 1;
|
||||
|
||||
let newIndex = activeViewportIndex + direction;
|
||||
newIndex = newIndex > maxIndex ? 0 : newIndex;
|
||||
newIndex = newIndex < 0 ? maxIndex : newIndex;
|
||||
|
||||
store.dispatch(setViewportActive(newIndex));
|
||||
},
|
||||
};
|
||||
|
||||
const definitions = {
|
||||
// Next/Previous active viewport
|
||||
incrementActiveViewport: {
|
||||
commandFn: actions.updateActiveViewport,
|
||||
storeContexts: ['viewports'],
|
||||
options: { direction: 1 },
|
||||
},
|
||||
decrementActiveViewport: {
|
||||
commandFn: actions.updateActiveViewport,
|
||||
storeContexts: ['viewports'],
|
||||
options: { direction: -1 },
|
||||
},
|
||||
};
|
||||
|
||||
export default definitions;
|
||||
@@ -1,17 +1,20 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import './Header.css';
|
||||
|
||||
import { Link, withRouter } from 'react-router-dom';
|
||||
import React, { Component } from 'react';
|
||||
|
||||
import { Dropdown } from 'react-viewerbase';
|
||||
import { withTranslation } from 'react-i18next';
|
||||
import './Header.css';
|
||||
import OHIFLogo from '../OHIFLogo/OHIFLogo.js';
|
||||
import ConnectedUserPreferencesModal from '../../connectedComponents/ConnectedUserPreferencesModal.js';
|
||||
import PropTypes from 'prop-types';
|
||||
// import { UserPreferencesModal } from 'react-viewerbase';
|
||||
import { hotkeysManager } from './../../App.js';
|
||||
|
||||
class Header extends Component {
|
||||
static propTypes = {
|
||||
home: PropTypes.bool.isRequired,
|
||||
location: PropTypes.object.isRequired,
|
||||
openUserPreferencesModal: PropTypes.func,
|
||||
children: PropTypes.node,
|
||||
t: PropTypes.func.isRequired,
|
||||
};
|
||||
@@ -21,12 +24,25 @@ class Header extends Component {
|
||||
children: OHIFLogo(),
|
||||
};
|
||||
|
||||
// onSave: data => {
|
||||
// const contextName = window.store.getState().commandContext.context;
|
||||
// const preferences = cloneDeep(window.store.getState().preferences);
|
||||
// preferences[contextName] = data;
|
||||
// dispatch(setUserPreferences(preferences));
|
||||
// dispatch(setUserPreferencesModalOpen(false));
|
||||
// OHIF.hotkeysUtil.setHotkeys(data.hotKeysData);
|
||||
// },
|
||||
// onResetToDefaults: () => {
|
||||
// dispatch(setUserPreferences());
|
||||
// dispatch(setUserPreferencesModalOpen(false));
|
||||
// OHIF.hotkeysUtil.setHotkeys();
|
||||
// },
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = { isUserPreferencesOpen: false };
|
||||
|
||||
this.state = {
|
||||
userPreferencesOpen: false,
|
||||
};
|
||||
// const onClick = this.toggleUserPreferences.bind(this);
|
||||
|
||||
this.loadOptions();
|
||||
}
|
||||
@@ -34,11 +50,11 @@ class Header extends Component {
|
||||
loadOptions() {
|
||||
const { t } = this.props;
|
||||
this.options = [
|
||||
{
|
||||
title: t('Preferences'),
|
||||
icon: { name: 'user' },
|
||||
onClick: this.props.openUserPreferencesModal,
|
||||
},
|
||||
// {
|
||||
// title: t('Preferences'),
|
||||
// icon: { name: 'user' },
|
||||
// onClick: onClick,
|
||||
// },
|
||||
{
|
||||
title: t('About'),
|
||||
icon: {
|
||||
@@ -47,6 +63,23 @@ class Header extends Component {
|
||||
link: 'http://ohif.org',
|
||||
},
|
||||
];
|
||||
|
||||
this.hotKeysData = hotkeysManager.hotkeyDefinitions;
|
||||
}
|
||||
|
||||
toggleUserPreferences() {
|
||||
const isOpen = this.state.isUserPreferencesOpen;
|
||||
|
||||
this.setState({
|
||||
isUserPreferencesOpen: !isOpen,
|
||||
});
|
||||
}
|
||||
|
||||
onUserPreferencesSave({ windowLevelData, hotKeysData }) {
|
||||
// console.log(windowLevelData);
|
||||
// console.log(hotKeysData);
|
||||
// TODO: Update hotkeysManager
|
||||
// TODO: reset `this.hotKeysData`
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -81,7 +114,7 @@ class Header extends Component {
|
||||
<div className="header-menu">
|
||||
<span className="research-use">{t('INVESTIGATIONAL USE ONLY')}</span>
|
||||
<Dropdown title={t('Options')} list={this.options} align="right" />
|
||||
<ConnectedUserPreferencesModal />
|
||||
{/* <ConnectedUserPreferencesModal /> */}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { connect } from 'react-redux';
|
||||
import Header from '../components/Header/Header.js';
|
||||
import { setUserPreferencesModalOpen } from '../redux/actions.js';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
const mapStateToProps = state => {
|
||||
return {
|
||||
@@ -8,17 +7,6 @@ const mapStateToProps = state => {
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
openUserPreferencesModal: () => {
|
||||
dispatch(setUserPreferencesModalOpen(true));
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
const ConnectedHeader = connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(Header);
|
||||
const ConnectedHeader = connect(mapStateToProps)(Header);
|
||||
|
||||
export default ConnectedHeader;
|
||||
@@ -1,6 +1,10 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
setLeftSidebarOpen,
|
||||
setRightSidebarOpen,
|
||||
} from './../store/layout/actions.js';
|
||||
|
||||
import ToolbarRow from './ToolbarRow';
|
||||
import { setLeftSidebarOpen, setRightSidebarOpen } from '../redux/actions.js';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
const defaultPlugin = 'cornerstone';
|
||||
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { UserPreferencesModal } from 'react-viewerbase';
|
||||
import OHIF from 'ohif-core';
|
||||
import { setUserPreferencesModalOpen } from '../redux/actions.js';
|
||||
import cloneDeep from 'lodash.clonedeep';
|
||||
|
||||
const { setUserPreferences } = OHIF.redux.actions;
|
||||
|
||||
const mapStateToProps = state => {
|
||||
const contextName = window.store.getState().commandContext.context;
|
||||
return {
|
||||
isOpen: state.ui.userPreferencesModalOpen,
|
||||
windowLevelData: state.preferences[contextName]
|
||||
? state.preferences[contextName].windowLevelData
|
||||
: {},
|
||||
hotKeysData: state.preferences[contextName]
|
||||
? state.preferences[contextName].hotKeysData
|
||||
: {},
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
onCancel: () => {
|
||||
dispatch(setUserPreferencesModalOpen(false));
|
||||
},
|
||||
onSave: data => {
|
||||
const contextName = window.store.getState().commandContext.context;
|
||||
const preferences = cloneDeep(window.store.getState().preferences);
|
||||
preferences[contextName] = data;
|
||||
dispatch(setUserPreferences(preferences));
|
||||
dispatch(setUserPreferencesModalOpen(false));
|
||||
OHIF.hotkeysUtil.setHotkeys(data.hotKeysData);
|
||||
},
|
||||
onResetToDefaults: () => {
|
||||
dispatch(setUserPreferences());
|
||||
dispatch(setUserPreferencesModalOpen(false));
|
||||
OHIF.hotkeysUtil.setHotkeys();
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
const ConnectedUserPreferencesModal = connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(UserPreferencesModal);
|
||||
|
||||
export default ConnectedUserPreferencesModal;
|
||||
@@ -1,12 +1,12 @@
|
||||
import { connect } from 'react-redux';
|
||||
import ViewerMain from './ViewerMain';
|
||||
import OHIF from 'ohif-core';
|
||||
import ViewerMain from './ViewerMain';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
const {
|
||||
setViewportSpecificData,
|
||||
clearViewportSpecificData,
|
||||
setToolActive,
|
||||
setActiveViewportSpecificData,
|
||||
// setToolActive,
|
||||
// setActiveViewportSpecificData,
|
||||
} = OHIF.redux.actions;
|
||||
|
||||
const mapStateToProps = state => {
|
||||
@@ -16,6 +16,7 @@ const mapStateToProps = state => {
|
||||
activeViewportIndex,
|
||||
layout,
|
||||
viewportSpecificData,
|
||||
viewports: state.viewports,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -27,12 +28,12 @@ const mapDispatchToProps = dispatch => {
|
||||
clearViewportSpecificData: () => {
|
||||
dispatch(clearViewportSpecificData());
|
||||
},
|
||||
setToolActive: tool => {
|
||||
dispatch(setToolActive(tool));
|
||||
},
|
||||
setActiveViewportSpecificData: viewport => {
|
||||
dispatch(setActiveViewportSpecificData(viewport));
|
||||
},
|
||||
// setToolActive: tool => {
|
||||
// dispatch(setToolActive(tool));
|
||||
// },
|
||||
// setActiveViewportSpecificData: viewport => {
|
||||
// dispatch(setActiveViewportSpecificData(viewport));
|
||||
// },
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,29 +1,32 @@
|
||||
import { Component } from 'react';
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { OHIF } from 'ohif-core';
|
||||
import ConnectedLayoutManager from './ConnectedLayoutManager.js';
|
||||
import './ViewerMain.css';
|
||||
|
||||
import { Component } from 'react';
|
||||
import ConnectedLayoutManager from './ConnectedLayoutManager.js';
|
||||
// import { OHIF } from 'ohif-core';
|
||||
//
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
|
||||
class ViewerMain extends Component {
|
||||
static propTypes = {
|
||||
studies: PropTypes.array.isRequired,
|
||||
activeViewportIndex: PropTypes.number.isRequired,
|
||||
layout: PropTypes.object,
|
||||
viewportSpecificData: PropTypes.object,
|
||||
setViewportSpecificData: PropTypes.func.isRequired,
|
||||
clearViewportSpecificData: PropTypes.func.isRequired,
|
||||
setToolActive: PropTypes.func.isRequired,
|
||||
setActiveViewportSpecificData: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
// Initialize hotkeys
|
||||
new OHIF.HotkeysUtil('viewer', {
|
||||
setViewportSpecificData: props.setViewportSpecificData,
|
||||
clearViewportSpecificData: props.clearViewportSpecificData,
|
||||
setToolActive: props.setToolActive,
|
||||
setActiveViewportSpecificData: props.setActiveViewportSpecificData,
|
||||
});
|
||||
// new OHIF.HotkeysUtil('viewer', {
|
||||
// setViewportSpecificData: props.setViewportSpecificData,
|
||||
// clearViewportSpecificData: props.clearViewportSpecificData,
|
||||
// setToolActive: props.setToolActive,
|
||||
// setActiveViewportSpecificData: props.setActiveViewportSpecificData,
|
||||
// });
|
||||
// hotkeys.init();
|
||||
|
||||
this.state = {
|
||||
displaySets: [],
|
||||
@@ -147,6 +150,10 @@ class ViewerMain extends Component {
|
||||
this.props.clearViewportSpecificData(viewportIndex);
|
||||
});
|
||||
|
||||
// TODO: These don't have to be viewer specific?
|
||||
// Could qualify for other routes?
|
||||
// hotkeys.destroy();
|
||||
|
||||
// Remove beforeUnload event handler...
|
||||
//window.removeEventListener('beforeunload', unloadHandlers.beforeUnload);
|
||||
// Destroy the synchronizer used to update reference lines
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
export const setLeftSidebarOpen = state => ({
|
||||
type: 'SET_LEFT_SIDEBAR_OPEN',
|
||||
state,
|
||||
});
|
||||
|
||||
export const setRightSidebarOpen = state => ({
|
||||
type: 'SET_RIGHT_SIDEBAR_OPEN',
|
||||
state,
|
||||
});
|
||||
|
||||
export const setUserPreferencesModalOpen = state => ({
|
||||
type: 'SET_USER_PREFERENCES_MODAL_OPEN',
|
||||
state,
|
||||
});
|
||||
|
||||
const actions = {
|
||||
setLeftSidebarOpen,
|
||||
setRightSidebarOpen,
|
||||
setUserPreferencesModalOpen,
|
||||
};
|
||||
|
||||
export default actions;
|
||||
@@ -0,0 +1,25 @@
|
||||
import { combineReducers, createStore } from 'redux';
|
||||
|
||||
import layoutReducers from './layout/reducers.js';
|
||||
import { reducer as oidcReducer } from 'redux-oidc';
|
||||
import { redux } from 'ohif-core';
|
||||
|
||||
// Combine our ohif-core, ui, and oidc reducers
|
||||
// Set init data, using values found in localStorage
|
||||
const { reducers, localStorage } = redux;
|
||||
|
||||
reducers.ui = layoutReducers;
|
||||
reducers.oidc = oidcReducer;
|
||||
|
||||
const combined = combineReducers(reducers);
|
||||
const store = createStore(combined, localStorage.loadState());
|
||||
|
||||
// When the store's preferences change,
|
||||
// Update our cached preferences in localStorage
|
||||
store.subscribe(() => {
|
||||
localStorage.saveState({
|
||||
preferences: store.getState().preferences,
|
||||
});
|
||||
});
|
||||
|
||||
export default store;
|
||||
@@ -0,0 +1,35 @@
|
||||
export const addActiveContext = state => ({
|
||||
type: 'ADD_ACTIVE_CONTEXT',
|
||||
state,
|
||||
});
|
||||
|
||||
export const removeActiveContext = state => ({
|
||||
type: 'REMOVE_ACTIVE_CONTEXT',
|
||||
state,
|
||||
});
|
||||
|
||||
export const clearActiveContexts = state => ({
|
||||
type: 'CLEAR_ACTIVE_CONTEXTS',
|
||||
state,
|
||||
});
|
||||
|
||||
export const setLeftSidebarOpen = state => ({
|
||||
type: 'SET_LEFT_SIDEBAR_OPEN',
|
||||
state,
|
||||
});
|
||||
|
||||
export const setRightSidebarOpen = state => ({
|
||||
type: 'SET_RIGHT_SIDEBAR_OPEN',
|
||||
state,
|
||||
});
|
||||
|
||||
const actions = {
|
||||
addActiveContext,
|
||||
removeActiveContext,
|
||||
clearActiveContexts,
|
||||
//
|
||||
setLeftSidebarOpen,
|
||||
setRightSidebarOpen,
|
||||
};
|
||||
|
||||
export default actions;
|
||||
@@ -1,26 +1,40 @@
|
||||
const defaultState = {
|
||||
leftSidebarOpen: true,
|
||||
rightSidebarOpen: false,
|
||||
userPreferencesModalOpen: false,
|
||||
labelling: {},
|
||||
contextMenu: {},
|
||||
activeContexts: [],
|
||||
};
|
||||
|
||||
const ui = (state = defaultState, action) => {
|
||||
switch (action.type) {
|
||||
// ~ ACTIVE CONTEXTS
|
||||
// https://redux.js.org/recipes/structuring-reducers/immutable-update-patterns#inserting-and-removing-items-in-arrays
|
||||
case 'ADD_ACTIVE_CONTEXT': {
|
||||
const shallowCopy = Object.assign({}, state);
|
||||
shallowCopy.activeContexts = [...shallowCopy.activeContexts, action.item];
|
||||
return shallowCopy;
|
||||
}
|
||||
case 'REMOVE_ACTIVE_CONTEXT': {
|
||||
const shallowCopy = Object.assign({}, state);
|
||||
shallowCopy.activeContexts = shallowCopy.activeContexts.filter(
|
||||
item => item !== action.item
|
||||
);
|
||||
return shallowCopy;
|
||||
}
|
||||
case 'CLEAR_ACTIVE_CONTEXTS':
|
||||
return Object.assign({}, state, { activeContexts: [] });
|
||||
// ~ SIDEBAR
|
||||
case 'SET_LEFT_SIDEBAR_OPEN':
|
||||
return Object.assign({}, state, { leftSidebarOpen: action.state });
|
||||
case 'SET_RIGHT_SIDEBAR_OPEN':
|
||||
return Object.assign({}, state, { rightSidebarOpen: action.state });
|
||||
case 'SET_USER_PREFERENCES_MODAL_OPEN':
|
||||
return Object.assign({}, state, {
|
||||
userPreferencesModalOpen: action.state,
|
||||
});
|
||||
case 'SET_LABELLING_FLOW_DATA':
|
||||
case 'SET_LABELLING_FLOW_DATA': {
|
||||
const labelling = Object.assign({}, action.labellingFlowData);
|
||||
|
||||
return Object.assign({}, state, { labelling });
|
||||
case 'SET_TOOL_CONTEXT_MENU_DATA':
|
||||
}
|
||||
case 'SET_TOOL_CONTEXT_MENU_DATA': {
|
||||
const contextMenu = Object.assign({}, state.contextMenu);
|
||||
|
||||
contextMenu[action.viewportIndex] = Object.assign(
|
||||
@@ -29,6 +43,7 @@ const ui = (state = defaultState, action) => {
|
||||
);
|
||||
|
||||
return Object.assign({}, state, { contextMenu });
|
||||
}
|
||||
case 'RESET_LABELLING_AND_CONTEXT_MENU':
|
||||
return Object.assign({}, state, {
|
||||
labelling: defaultState.labelling,
|
||||
Reference in new issue
Block a user