# HG changeset patch # User Sebastien Jodogne # Date 1689158104 -7200 # Node ID 801790c81f20b503f2363870e92caf7be11c716f # Parent 2805246064aae88f73987def8d322b851d45f6ea configuration options of IIIF diff -r 2805246064aa -r 801790c81f20 ViewerPlugin/IIIF.cpp --- a/ViewerPlugin/IIIF.cpp Wed Jul 12 11:24:56 2023 +0200 +++ b/ViewerPlugin/IIIF.cpp Wed Jul 12 12:35:04 2023 +0200 @@ -445,7 +445,7 @@ const std::string sopClassUid = Orthanc::Toolbox::StripSpaces(oneInstance[SOP_CLASS_UID].asString()); - const std::string base = iiifPublicUrl_ + seriesId; + const std::string base = iiifPublicUrl_ + "series/" + seriesId; Json::Value manifest; manifest["@context"] = "http://iiif.io/api/presentation/3/context.json"; @@ -613,7 +613,7 @@ OrthancPlugins::RegisterRestCallback("/wsi/iiif/tiles/([0-9a-f-]+)/info.json", true); OrthancPlugins::RegisterRestCallback("/wsi/iiif/tiles/([0-9a-f-]+)/([0-9a-z,:]+)/([0-9a-z,!:]+)/([0-9,!]+)/([a-z]+)\\.([a-z]+)", true); - OrthancPlugins::RegisterRestCallback("/wsi/iiif/([0-9a-f-]+)/manifest.json", true); + OrthancPlugins::RegisterRestCallback("/wsi/iiif/series/([0-9a-f-]+)/manifest.json", true); OrthancPlugins::RegisterRestCallback("/wsi/iiif/frames/([0-9a-f-]+)/([0-9]+)/info.json", true); OrthancPlugins::RegisterRestCallback("/wsi/iiif/frames/([0-9a-f-]+)/([0-9]+)/full/max/0/default.jpg", true); } diff -r 2805246064aa -r 801790c81f20 ViewerPlugin/OrthancExplorer.js --- a/ViewerPlugin/OrthancExplorer.js Wed Jul 12 11:24:56 2023 +0200 +++ b/ViewerPlugin/OrthancExplorer.js Wed Jul 12 12:35:04 2023 +0200 @@ -74,7 +74,7 @@ } } - if (${SERVE_IIIF}) { + if (${ENABLE_IIIF}) { var b = $('') .attr('data-role', 'button') .attr('href', '#') @@ -90,7 +90,7 @@ b.click(function(e) { if ($.mobile.pageData) { e.preventDefault(); - var url = new URL('${IIIF_PUBLIC_URL}' + seriesId + '/manifest.json', window.location.href); + var url = new URL('../wsi/iiif/series/' + seriesId + '/manifest.json', window.location.href); navigator.clipboard.writeText(url.href); $(e.target).closest('li').buttonMarkup({ icon: 'check' }); } @@ -110,7 +110,7 @@ b.insertAfter($('#series-info')); b.click(function() { if ($.mobile.pageData) { - window.open('../wsi/app/mirador.html?iiif-content=../iiif/' + seriesId + '/manifest.json'); + window.open('../wsi/app/mirador.html?iiif-content=../iiif/series/' + seriesId + '/manifest.json'); } }); } diff -r 2805246064aa -r 801790c81f20 ViewerPlugin/Plugin.cpp --- a/ViewerPlugin/Plugin.cpp Wed Jul 12 11:24:56 2023 +0200 +++ b/ViewerPlugin/Plugin.cpp Wed Jul 12 12:35:04 2023 +0200 @@ -293,15 +293,23 @@ OrthancPlugins::RegisterRestCallback("/wsi/pyramids/([0-9a-f-]+)", true); OrthancPlugins::RegisterRestCallback("/wsi/tiles/([0-9a-f-]+)/([0-9-]+)/([0-9-]+)/([0-9-]+)", true); - bool serveMirador; - bool serveOpenSeadragon; - bool serveIIIF = true; // TODO => CONFIG + OrthancPlugins::OrthancConfiguration mainConfiguration; + + OrthancPlugins::OrthancConfiguration wsiConfiguration; + mainConfiguration.GetSection(wsiConfiguration, "WholeSlideImaging"); + + const bool enableIIIF = wsiConfiguration.GetBooleanValue("EnableIIIF", true); + bool serveMirador = false; + bool serveOpenSeadragon = false; std::string iiifPublicUrl; - if (serveIIIF) + if (enableIIIF) { - // TODO => CONFIG - iiifPublicUrl = "http://localhost:8042/wsi/iiif"; + if (!wsiConfiguration.LookupStringValue(iiifPublicUrl, "OrthancPublicURL")) + { + unsigned int port = mainConfiguration.GetUnsignedIntegerValue("HttpPort", 8042); + iiifPublicUrl = "http://localhost:" + boost::lexical_cast(port) + "/"; + } if (iiifPublicUrl.empty() || iiifPublicUrl[iiifPublicUrl.size() - 1] != '/') @@ -309,26 +317,41 @@ iiifPublicUrl += "/"; } - InitializeIIIF(iiifPublicUrl); - SetIIIFForcePowersOfTwoScaleFactors(true); // TODO => CONFIG + iiifPublicUrl += "wsi/iiif/"; - serveMirador = true; // TODO => CONFIG - serveOpenSeadragon = true; // TODO => CONFIG + InitializeIIIF(iiifPublicUrl); + + serveMirador = wsiConfiguration.GetBooleanValue("ServeMirador", false); + serveOpenSeadragon = wsiConfiguration.GetBooleanValue("ServeOpenSeadragon", false); - if (serveMirador) + bool value; + if (wsiConfiguration.LookupBooleanValue(value, "ForcePowersOfTwoScaleFactors")) { - OrthancPlugins::RegisterRestCallback("/wsi/app/(mirador.html)", true); + SetIIIFForcePowersOfTwoScaleFactors(value); } - - if (serveOpenSeadragon) + else { - OrthancPlugins::RegisterRestCallback("/wsi/app/(openseadragon.html)", true); + /** + * By default, compatibility mode is disabled. However, if + * Mirador or OSD are enabled, compatibility mode is + * automatically enabled to enhance user experience, at least + * until issue 2379 of OSD is solved: + * https://github.com/openseadragon/openseadragon/issues/2379 + **/ + SetIIIFForcePowersOfTwoScaleFactors(serveMirador || serveOpenSeadragon); } } - else + + LOG(WARNING) << "Support of IIIF is " << (enableIIIF ? "enabled" : "disabled") << " in the whole-slide imaging plugin"; + + if (serveMirador) { - serveMirador = false; - serveOpenSeadragon = false; + OrthancPlugins::RegisterRestCallback("/wsi/app/(mirador.html)", true); + } + + if (serveOpenSeadragon) + { + OrthancPlugins::RegisterRestCallback("/wsi/app/(openseadragon.html)", true); } { @@ -338,10 +361,9 @@ Orthanc::EmbeddedResources::GetFileResource(explorer, Orthanc::EmbeddedResources::ORTHANC_EXPLORER); std::map dictionary; - dictionary["SERVE_IIIF"] = (serveIIIF ? "true" : "false"); + dictionary["ENABLE_IIIF"] = (enableIIIF ? "true" : "false"); dictionary["SERVE_MIRADOR"] = (serveMirador ? "true" : "false"); dictionary["SERVE_OPEN_SEADRAGON"] = (serveOpenSeadragon ? "true" : "false"); - dictionary["IIIF_PUBLIC_URL"] = iiifPublicUrl; explorer = Orthanc::Toolbox::SubstituteVariables(explorer, dictionary); OrthancPluginExtendOrthancExplorer(OrthancPlugins::GetGlobalContext(), explorer.c_str());