[OHIF-261 & OHIF-262] (#1862)
* WIP * Reset viewport grid on mode switch. * Make lifecyclehooks distinct from modules. Add needed SR hydration state on creation. * Update extensions/cornerstone/src/init.js * Remove unused REMOVE_MEASUREMENT listener. Co-authored-by: Danny Brown <danny.ri.brown@gmail.com>
This commit is contained in:
1 parent
4dfe144bf8
commit
14797a8973
13 files changed
+156
-25
No files matched your search
@@ -16,6 +16,7 @@ export default class ExtensionManager {
|
||||
this.moduleTypeNames.forEach(moduleType => {
|
||||
this.modules[moduleType] = [];
|
||||
});
|
||||
this._extensionLifeCycleHooks = { onModeEnter: {} };
|
||||
this.dataSourceMap = {};
|
||||
this.defaultDataSourceName = appConfig.defaultDataSourceName;
|
||||
this.activeDataSource = undefined;
|
||||
@@ -25,6 +26,27 @@ export default class ExtensionManager {
|
||||
this.activeDataSource = dataSourceName;
|
||||
}
|
||||
|
||||
onModeEnter() {
|
||||
const {
|
||||
registeredExtensionIds,
|
||||
getModuleEntry,
|
||||
_servicesManager,
|
||||
_commandsManager,
|
||||
_extensionLifeCycleHooks,
|
||||
} = this;
|
||||
|
||||
registeredExtensionIds.forEach(extensionId => {
|
||||
const onModeEnter = _extensionLifeCycleHooks.onModeEnter[extensionId];
|
||||
|
||||
if (typeof onModeEnter === 'function') {
|
||||
onModeEnter({
|
||||
servicesManager: _servicesManager,
|
||||
commandsManager: _commandsManager,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* An array of extensions, or an array of arrays that contains extension
|
||||
* configuration pairs.
|
||||
@@ -83,6 +105,11 @@ export default class ExtensionManager {
|
||||
});
|
||||
}
|
||||
|
||||
if (extension.onModeEnter) {
|
||||
this._extensionLifeCycleHooks.onModeEnter[extensionId] =
|
||||
extension.onModeEnter;
|
||||
}
|
||||
|
||||
// Register Modules
|
||||
this.moduleTypeNames.forEach(moduleType => {
|
||||
const extensionModule = this._getExtensionModule(
|
||||
@@ -146,7 +173,7 @@ export default class ExtensionManager {
|
||||
};
|
||||
|
||||
getActiveDataSource = () => {
|
||||
return this.activeDataSource;
|
||||
return this.dataSourceMap[this.activeDataSource];
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,6 @@ const displaySetCache = [];
|
||||
|
||||
export default class DisplaySetService {
|
||||
constructor() {
|
||||
this.displaySets = {};
|
||||
this.activeDisplaySets = [];
|
||||
this.listeners = {};
|
||||
this.EVENTS = EVENTS;
|
||||
@@ -33,6 +32,10 @@ export default class DisplaySetService {
|
||||
});
|
||||
}
|
||||
|
||||
getDisplaySetCache() {
|
||||
return displaySetCache;
|
||||
}
|
||||
|
||||
getActiveDisplaySets() {
|
||||
return this.activeDisplaySets;
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ class MeasurementService {
|
||||
if (this.measurements[id]) {
|
||||
const updatedMeasurement = {
|
||||
...measurement,
|
||||
modifiedTimestamp: Math.floor(Date.now() / 1000)
|
||||
modifiedTimestamp: Math.floor(Date.now() / 1000),
|
||||
};
|
||||
|
||||
log.info(`Updating measurement...`, updatedMeasurement);
|
||||
@@ -492,6 +492,12 @@ class MeasurementService {
|
||||
this._broadcastChange(this.EVENTS.MEASUREMENT_REMOVED, source, id);
|
||||
}
|
||||
|
||||
clearMeasurements() {
|
||||
this.measurements = {};
|
||||
|
||||
this._broadcastChange(this.EVENTS.MEASUREMENTS_CLEARED);
|
||||
}
|
||||
|
||||
_getMappingByMeasurementSource(measurementId, definition) {
|
||||
const measurement = this.getMeasurement(measurementId);
|
||||
if (this._isValidSource(measurement.source)) {
|
||||
|
||||
@@ -8,6 +8,7 @@ const publicAPI = {
|
||||
setLayout: _setLayout,
|
||||
setCachedLayout: _setCachedLayout,
|
||||
setServiceImplementation,
|
||||
reset: _reset,
|
||||
};
|
||||
|
||||
const serviceImplementation = {
|
||||
@@ -17,6 +18,7 @@ const serviceImplementation = {
|
||||
_setDisplaysetForViewport: () =>
|
||||
console.warn('setDisplaysetForViewport() NOT IMPLEMENTED'),
|
||||
_setLayout: () => console.warn('setLayout() NOT IMPLEMENTED'),
|
||||
_reset: () => console.warn('reset() NOT IMPLEMENTED'),
|
||||
_setCachedLayout: () => console.warn('setCachedLayout() NOT IMPLEMENTED'),
|
||||
};
|
||||
|
||||
@@ -39,6 +41,9 @@ function _setLayout({ numCols, numRows }) {
|
||||
return serviceImplementation._setLayout({ numCols, numRows });
|
||||
}
|
||||
|
||||
function _reset() {
|
||||
return serviceImplementation._reset({});
|
||||
}
|
||||
function _setCachedLayout({ numCols, numRows, viewports }) {
|
||||
return serviceImplementation._setLayout({ numCols, numRows, viewports });
|
||||
}
|
||||
@@ -49,6 +54,7 @@ function setServiceImplementation({
|
||||
setDisplaysetForViewport: setDisplaysetForViewportImplementation,
|
||||
setCachedLayout: setCachedLayoutImplementation,
|
||||
setLayout: setLayoutImplementation,
|
||||
reset: resetImplementation,
|
||||
}) {
|
||||
if (getStateImplementation) {
|
||||
serviceImplementation._getState = getStateImplementation;
|
||||
@@ -62,6 +68,9 @@ function setServiceImplementation({
|
||||
if (setLayoutImplementation) {
|
||||
serviceImplementation._setLayout = setLayoutImplementation;
|
||||
}
|
||||
if (resetImplementation) {
|
||||
serviceImplementation._reset = resetImplementation;
|
||||
}
|
||||
if (setCachedLayoutImplementation) {
|
||||
serviceImplementation._setCachedLayout = setCachedLayoutImplementation;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user