feat(plugins): Add pluginData to viewportData so that plugins can manage their own data
This commit is contained in:
parent
f6b82baae3
commit
ddbe8b38aa
@ -241,16 +241,18 @@ export class LayoutManager {
|
|||||||
// If we have been provided with a plugin to use, use it.
|
// If we have been provided with a plugin to use, use it.
|
||||||
// Otherwise, use whichever plugin is currently in use in this viewport.
|
// Otherwise, use whichever plugin is currently in use in this viewport.
|
||||||
const plugin = data.plugin || this.viewportData[viewportIndex].plugin;
|
const plugin = data.plugin || this.viewportData[viewportIndex].plugin;
|
||||||
|
const pluginData = data.pluginData || this.viewportData[viewportIndex].pluginData;
|
||||||
|
|
||||||
// Update the dictionary of loaded displaySet for the specified viewport
|
// Update the dictionary of loaded displaySet for the specified viewport
|
||||||
this.viewportData[viewportIndex] = {
|
this.viewportData[viewportIndex] = {
|
||||||
viewportIndex: viewportIndex,
|
viewportIndex,
|
||||||
displaySetInstanceUid: data.displaySetInstanceUid,
|
displaySetInstanceUid: data.displaySetInstanceUid,
|
||||||
seriesInstanceUid: data.seriesInstanceUid,
|
seriesInstanceUid: data.seriesInstanceUid,
|
||||||
studyInstanceUid: data.studyInstanceUid,
|
studyInstanceUid: data.studyInstanceUid,
|
||||||
renderedCallback: data.renderedCallback,
|
renderedCallback: data.renderedCallback,
|
||||||
currentImageIdIndex: data.currentImageIdIndex || 0,
|
currentImageIdIndex: data.currentImageIdIndex || 0,
|
||||||
plugin,
|
plugin,
|
||||||
|
pluginData,
|
||||||
};
|
};
|
||||||
|
|
||||||
const newViewportContainer = document.createElement('div');
|
const newViewportContainer = document.createElement('div');
|
||||||
@ -282,7 +284,7 @@ export class LayoutManager {
|
|||||||
container.innerHTML = '';
|
container.innerHTML = '';
|
||||||
container.appendChild(newViewportContainer);
|
container.appendChild(newViewportContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateSession();
|
this.updateSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -43,7 +43,9 @@ export class OHIFPlugin {
|
|||||||
scriptURL += "?" + performance.now();
|
scriptURL += "?" + performance.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loadScript(scriptURL).onload = function() {
|
const type = plugin.module === true ? 'module' : 'text/javascript'
|
||||||
|
|
||||||
|
this.loadScript(scriptURL, type).onload = function() {
|
||||||
const entryPointFunction = OHIF.plugins.entryPoints[plugin.name];
|
const entryPointFunction = OHIF.plugins.entryPoints[plugin.name];
|
||||||
|
|
||||||
if (entryPointFunction) {
|
if (entryPointFunction) {
|
||||||
|
|||||||
@ -64,7 +64,6 @@ export class ViewportPlugin extends OHIFPlugin {
|
|||||||
const viewportData = layoutManager.viewportData[viewportIndex];
|
const viewportData = layoutManager.viewportData[viewportIndex];
|
||||||
if (viewportData.plugin === this.name) {
|
if (viewportData.plugin === this.name) {
|
||||||
OHIF.log.info(`setViewportToPlugin: Viewport ${viewportIndex} already set to plugin ${this.name}`);
|
OHIF.log.info(`setViewportToPlugin: Viewport ${viewportIndex} already set to plugin ${this.name}`);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
viewportData.plugin = this.name;
|
viewportData.plugin = this.name;
|
||||||
@ -102,16 +101,18 @@ export class ViewportPlugin extends OHIFPlugin {
|
|||||||
// Retrieve the list of all viewports, so we can figure out the viewport details
|
// Retrieve the list of all viewports, so we can figure out the viewport details
|
||||||
const allViewports = Array.from(document.querySelectorAll('.viewportContainer'));
|
const allViewports = Array.from(document.querySelectorAll('.viewportContainer'));
|
||||||
|
|
||||||
|
const { layoutManager } = OHIF.viewerbase;
|
||||||
|
|
||||||
emptyPluginDivs.forEach(div => {
|
emptyPluginDivs.forEach(div => {
|
||||||
// Identify the Viewport index, and any display set that is currently
|
// Identify the Viewport index, and any display set that is currently
|
||||||
// hung in the viewport
|
// hung in the viewport
|
||||||
const viewportIndex = allViewports.indexOf(div.parentNode);
|
const viewportIndex = allViewports.indexOf(div.parentNode);
|
||||||
const viewportDetails = { viewportIndex };
|
const viewportData = layoutManager.viewportData[viewportIndex];
|
||||||
const displaySet = ViewportPlugin.getDisplaySet(viewportIndex);
|
const displaySet = ViewportPlugin.getDisplaySet(viewportIndex);
|
||||||
|
|
||||||
// Use the plugin's setupViewport function to render the contents
|
// Use the plugin's setupViewport function to render the contents
|
||||||
// of this viewport.
|
// of this viewport.
|
||||||
this.setupViewport(div, viewportDetails, displaySet);
|
this.setupViewport(div, viewportData, displaySet);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user