# HG changeset patch # User Sebastien Jodogne # Date 1606752586 -3600 # Node ID aec45e0b25286d1bff1aa935f25a6f9af027c294 # Parent fb57536fcc5f3e5911afa4a1e4e48abe32da051a configuration option "DicomWebRoot" diff -r fb57536fcc5f -r aec45e0b2528 Applications/StoneWebViewer/Plugin/Plugin.cpp --- a/Applications/StoneWebViewer/Plugin/Plugin.cpp Mon Nov 30 16:49:04 2020 +0100 +++ b/Applications/StoneWebViewer/Plugin/Plugin.cpp Mon Nov 30 17:09:46 2020 +0100 @@ -27,6 +27,10 @@ #include #include + +static const std::string STONE_WEB_VIEWER_ROOT = "/stone-webviewer"; + + OrthancPluginErrorCode OnChangeCallback(OrthancPluginChangeType changeType, OrthancPluginResourceType resourceType, const char* resourceId) @@ -173,6 +177,8 @@ else { static const char* CONFIG_SECTION = "StoneWebViewer"; + static const char* ORTHANC_API_ROOT = "OrthancApiRoot"; + static const char* DICOM_WEB_ROOT = "DicomWebRoot"; Json::Value config = Json::objectValue; @@ -202,8 +208,16 @@ } } - config[CONFIG_SECTION]["OrthancApiRoot"] = ".."; + assert(config[CONFIG_SECTION].type() == Json::objectValue); + + // Assume that the Stone Web viewer is mapped at "/stone-webviewer" in the REST API + config[CONFIG_SECTION][ORTHANC_API_ROOT] = ".."; + if (!config[CONFIG_SECTION].isMember(DICOM_WEB_ROOT)) + { + config[CONFIG_SECTION][DICOM_WEB_ROOT] = "../dicom-web"; + } + const std::string s = config.toStyledString(); OrthancPluginAnswerBuffer(context, output, s.c_str(), s.size(), "application/json"); } @@ -243,39 +257,39 @@ OrthancPluginExtendOrthancExplorer(OrthancPlugins::GetGlobalContext(), explorer.c_str()); OrthancPlugins::RegisterRestCallback - ("/stone-webviewer/configuration.json", true); + (STONE_WEB_VIEWER_ROOT + "/configuration.json", true); OrthancPlugins::RegisterRestCallback > - ("/stone-webviewer/StoneWebViewer.wasm", true); + (STONE_WEB_VIEWER_ROOT + "/StoneWebViewer.wasm", true); OrthancPlugins::RegisterRestCallback > - ("/stone-webviewer/StoneWebViewer.js", true); + (STONE_WEB_VIEWER_ROOT + "/StoneWebViewer.js", true); OrthancPlugins::RegisterRestCallback > - ("/stone-webviewer/stone.js", true); + (STONE_WEB_VIEWER_ROOT + "/stone.js", true); OrthancPlugins::RegisterRestCallback > - ("/stone-webviewer/img/(.*)", true); + (STONE_WEB_VIEWER_ROOT + "/img/(.*)", true); OrthancPlugins::RegisterRestCallback > - ("/stone-webviewer/css/(.*)", true); + (STONE_WEB_VIEWER_ROOT + "/css/(.*)", true); OrthancPlugins::RegisterRestCallback > - ("/stone-webviewer/js/(.*)", true); + (STONE_WEB_VIEWER_ROOT + "/js/(.*)", true); OrthancPlugins::RegisterRestCallback > - ("/stone-webviewer/webfonts/(.*)", true); + (STONE_WEB_VIEWER_ROOT + "/webfonts/(.*)", true); OrthancPlugins::RegisterRestCallback > - ("/stone-webviewer/(.*)", true); + (STONE_WEB_VIEWER_ROOT + "/(.*)", true); OrthancPluginRegisterOnChangeCallback(context, OnChangeCallback); } diff -r fb57536fcc5f -r aec45e0b2528 Applications/StoneWebViewer/WebApplication/app.js --- a/Applications/StoneWebViewer/WebApplication/app.js Mon Nov 30 16:49:04 2020 +0100 +++ b/Applications/StoneWebViewer/WebApplication/app.js Mon Nov 30 17:09:46 2020 +0100 @@ -1020,7 +1020,8 @@ window.addEventListener('StoneInitialized', function() { stone.Setup(Module); - stone.SetOrthancRoot('..', true); + stone.SetDicomWebRoot(app.globalConfiguration.DicomWebRoot, + true /* assume "/rendered" is available in DICOMweb (could be a configuration option) */); stone.SetSoftwareRendering(localStorage.settingSoftwareRendering == '1'); console.warn('Stone properly initialized'); diff -r fb57536fcc5f -r aec45e0b2528 Applications/StoneWebViewer/WebApplication/configuration.json --- a/Applications/StoneWebViewer/WebApplication/configuration.json Mon Nov 30 16:49:04 2020 +0100 +++ b/Applications/StoneWebViewer/WebApplication/configuration.json Mon Nov 30 17:09:46 2020 +0100 @@ -65,12 +65,19 @@ "ExpectedMessageOrigin" : "http://localhost:8042", /** + * Root path of the DICOMweb server. This option is automatically + * set by the Orthanc plugin if missing. + **/ + "DicomWebRoot" : "../dicom-web", + + /** * The following parameter can be set if running the Stone Web - * viewer from Orthanc, but without using the associated plugin. - * Using the plugin would overwrite this setting. This will enable - * features that are only available if the Orthanc REST API is - * accessible (download of studies, and playing videos). This - * option is typically used by the developers of Stone. + * viewer from Orthanc, but without using the associated plugin + * (e.g. using the "Serve Folders" sample plugin). Using the + * plugin would overwrite this setting. This will enable features + * that are only available if the Orthanc REST API is accessible + * (download of studies, and playing videos). This option is + * typically used by the developers of Stone. **/ "OrthancApiRoot" : ".." } diff -r fb57536fcc5f -r aec45e0b2528 Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp --- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Mon Nov 30 16:49:04 2020 +0100 +++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Mon Nov 30 17:09:46 2020 +0100 @@ -2894,13 +2894,12 @@ EMSCRIPTEN_KEEPALIVE - void SetOrthancRoot(const char* uri, - int useRendered) + void SetDicomWebRoot(const char* uri, + int useRendered) { try { - context_->SetLocalOrthanc(uri); // For "source_.SetDicomWebThroughOrthancSource()" - source_.SetDicomWebSource(std::string(uri) + "/dicom-web"); + source_.SetDicomWebSource(uri); source_.SetDicomWebRendered(useRendered != 0); } EXTERN_CATCH_EXCEPTIONS; @@ -2908,11 +2907,13 @@ EMSCRIPTEN_KEEPALIVE - void SetDicomWebServer(const char* serverName, - int hasRendered) + void SetDicomWebThroughOrthanc(const char* orthancRoot, + const char* serverName, + int hasRendered) { try { + context_->SetLocalOrthanc(orthancRoot); source_.SetDicomWebThroughOrthancSource(serverName); source_.SetDicomWebRendered(hasRendered != 0); }