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.
|
||||
// Otherwise, use whichever plugin is currently in use in this viewport.
|
||||
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
|
||||
this.viewportData[viewportIndex] = {
|
||||
viewportIndex: viewportIndex,
|
||||
viewportIndex,
|
||||
displaySetInstanceUid: data.displaySetInstanceUid,
|
||||
seriesInstanceUid: data.seriesInstanceUid,
|
||||
studyInstanceUid: data.studyInstanceUid,
|
||||
renderedCallback: data.renderedCallback,
|
||||
currentImageIdIndex: data.currentImageIdIndex || 0,
|
||||
plugin,
|
||||
pluginData,
|
||||
};
|
||||
|
||||
const newViewportContainer = document.createElement('div');
|
||||
@ -282,7 +284,7 @@ export class LayoutManager {
|
||||
container.innerHTML = '';
|
||||
container.appendChild(newViewportContainer);
|
||||
}
|
||||
|
||||
|
||||
this.updateSession();
|
||||
}
|
||||
|
||||
|
||||
@ -43,7 +43,9 @@ export class OHIFPlugin {
|
||||
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];
|
||||
|
||||
if (entryPointFunction) {
|
||||
|
||||
@ -64,7 +64,6 @@ export class ViewportPlugin extends OHIFPlugin {
|
||||
const viewportData = layoutManager.viewportData[viewportIndex];
|
||||
if (viewportData.plugin === this.name) {
|
||||
OHIF.log.info(`setViewportToPlugin: Viewport ${viewportIndex} already set to plugin ${this.name}`);
|
||||
return;
|
||||
}
|
||||
|
||||
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
|
||||
const allViewports = Array.from(document.querySelectorAll('.viewportContainer'));
|
||||
|
||||
const { layoutManager } = OHIF.viewerbase;
|
||||
|
||||
emptyPluginDivs.forEach(div => {
|
||||
// Identify the Viewport index, and any display set that is currently
|
||||
// hung in the viewport
|
||||
const viewportIndex = allViewports.indexOf(div.parentNode);
|
||||
const viewportDetails = { viewportIndex };
|
||||
const viewportData = layoutManager.viewportData[viewportIndex];
|
||||
const displaySet = ViewportPlugin.getDisplaySet(viewportIndex);
|
||||
|
||||
// Use the plugin's setupViewport function to render the contents
|
||||
// of this viewport.
|
||||
this.setupViewport(div, viewportDetails, displaySet);
|
||||
this.setupViewport(div, viewportData, displaySet);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user