merge plugin code to master
This commit is contained in:
parent
ea23ec84e0
commit
e896724f70
@ -57,6 +57,91 @@ Template.ohifViewer.onCreated(() => {
|
|||||||
// Set the viewer open state on session
|
// Set the viewer open state on session
|
||||||
Session.set('ViewerOpened', isViewer);
|
Session.set('ViewerOpened', isViewer);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add plugin reloader
|
||||||
|
class OHIFPlugin {
|
||||||
|
// TODO: this class is here for development purposes.
|
||||||
|
// Once it is fleshed out it would go in the OHIF
|
||||||
|
// base deployment and be available for plugins
|
||||||
|
// to inherit from.
|
||||||
|
|
||||||
|
constructor () {
|
||||||
|
this.name = "Unnamed plugin";
|
||||||
|
this.description = "No description available";
|
||||||
|
}
|
||||||
|
|
||||||
|
// load an individual script URL
|
||||||
|
static loadScript(scriptURL) {
|
||||||
|
const script = document.createElement("script");
|
||||||
|
script.src = scriptURL;
|
||||||
|
script.type = "text/javascript";
|
||||||
|
script.async = false;
|
||||||
|
const head = document.getElementsByTagName("head")[0];
|
||||||
|
head.appendChild(script);
|
||||||
|
head.removeChild(script);
|
||||||
|
return (script)
|
||||||
|
}
|
||||||
|
|
||||||
|
// reload all the dependency scripts and also
|
||||||
|
// the main plugin script url.
|
||||||
|
static reloadPlugin(plugin) {
|
||||||
|
plugin.scriptURLs = plugin.scriptURLs || {};
|
||||||
|
plugin.scriptURLs.forEach(scriptURL => {
|
||||||
|
this.loadScript(scriptURL).onload = function() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let scriptURL = plugin.url;
|
||||||
|
if (!plugin.allowCaching) {
|
||||||
|
scriptURL += "?" + performance.now();
|
||||||
|
}
|
||||||
|
this.loadScript(scriptURL).onload = function() {
|
||||||
|
if (OHIFPlugin.entryPoints[plugin.name]) {
|
||||||
|
OHIFPlugin.entryPoints[plugin.name]();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// each plugin registers an entry point function to be called
|
||||||
|
// when the loading is complete (called above in reloadPlugin).
|
||||||
|
OHIFPlugin.entryPoints = {};
|
||||||
|
|
||||||
|
window.OHIFPlugin = OHIFPlugin;
|
||||||
|
|
||||||
|
// TODO: this information should come from a plug registry
|
||||||
|
let volumeRenderingPlugin = {
|
||||||
|
name: "VolumeRenderingPlugin",
|
||||||
|
url:"https://rawgit.com/OHIF/VTKPlugin/master/vtkVolumeRendering/volumeRendering.js",
|
||||||
|
allowCaching: false,
|
||||||
|
scriptURLs: [
|
||||||
|
"https://unpkg.com/vtk.js",
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
// // TODO: this information should come from a plug registry
|
||||||
|
// let mprPlugin = {
|
||||||
|
// name: "MPRPlugin",
|
||||||
|
// url:"http://localhost/pluginsource/mprplugin.js",
|
||||||
|
// allowCaching: false,
|
||||||
|
// scriptURLs: [
|
||||||
|
// "https://unpkg.com/vtk.js",
|
||||||
|
// ]
|
||||||
|
// };
|
||||||
|
|
||||||
|
OHIF.commands.contexts.viewer.reloadVolumeRendering = {
|
||||||
|
name: "reloadVolumeRendering",
|
||||||
|
action: function(event) {
|
||||||
|
OHIFPlugin.reloadPlugin(volumeRenderingPlugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OHIF.commands.contexts.viewer.reloadVolumeRendering = {
|
||||||
|
// name: "reloadMPR",
|
||||||
|
// action: function(event) {
|
||||||
|
// OHIFPlugin.reloadPlugin(mprPlugin);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.ohifViewer.events({
|
Template.ohifViewer.events({
|
||||||
|
|||||||
@ -84,6 +84,13 @@ Template.toolbarSection.helpers({
|
|||||||
iconClasses: 'fa fa-crosshairs'
|
iconClasses: 'fa fa-crosshairs'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
extraTools.push({
|
||||||
|
id: 'stackScroll',
|
||||||
|
title: 'Stack Scroll',
|
||||||
|
classes: 'imageViewerTool',
|
||||||
|
iconClasses: 'fa fa-bars'
|
||||||
|
});
|
||||||
|
|
||||||
extraTools.push({
|
extraTools.push({
|
||||||
id: 'magnify',
|
id: 'magnify',
|
||||||
title: 'Magnify',
|
title: 'Magnify',
|
||||||
@ -164,11 +171,13 @@ Template.toolbarSection.helpers({
|
|||||||
|
|
||||||
const buttonData = [];
|
const buttonData = [];
|
||||||
|
|
||||||
|
// TODO: this is just a temp hook for the volume rendering
|
||||||
|
// There needs to be a way for plugins to register new tools
|
||||||
buttonData.push({
|
buttonData.push({
|
||||||
id: 'stackScroll',
|
id: 'reloadVolumeRendering',
|
||||||
title: 'Stack Scroll',
|
title: 'Volume Renderin',
|
||||||
classes: 'imageViewerTool',
|
classes: 'imageViewerCommand',
|
||||||
iconClasses: 'fa fa-bars'
|
iconClasses: 'fa fa-undo'
|
||||||
});
|
});
|
||||||
|
|
||||||
buttonData.push({
|
buttonData.push({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user