Mercurial > hg > orthanc-wsi
comparison ViewerPlugin/Plugin.cpp @ 275:801790c81f20 iiif
configuration options of IIIF
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 12 Jul 2023 12:35:04 +0200 |
parents | 2805246064aa |
children | ef8a673b5fb9 |
comparison
equal
deleted
inserted
replaced
274:2805246064aa | 275:801790c81f20 |
---|---|
291 OrthancPlugins::RegisterRestCallback<ServeFile>("/wsi/app/(viewer.html)", true); | 291 OrthancPlugins::RegisterRestCallback<ServeFile>("/wsi/app/(viewer.html)", true); |
292 OrthancPlugins::RegisterRestCallback<ServeFile>("/wsi/app/(viewer.js)", true); | 292 OrthancPlugins::RegisterRestCallback<ServeFile>("/wsi/app/(viewer.js)", true); |
293 OrthancPlugins::RegisterRestCallback<ServePyramid>("/wsi/pyramids/([0-9a-f-]+)", true); | 293 OrthancPlugins::RegisterRestCallback<ServePyramid>("/wsi/pyramids/([0-9a-f-]+)", true); |
294 OrthancPlugins::RegisterRestCallback<ServeTile>("/wsi/tiles/([0-9a-f-]+)/([0-9-]+)/([0-9-]+)/([0-9-]+)", true); | 294 OrthancPlugins::RegisterRestCallback<ServeTile>("/wsi/tiles/([0-9a-f-]+)/([0-9-]+)/([0-9-]+)/([0-9-]+)", true); |
295 | 295 |
296 bool serveMirador; | 296 OrthancPlugins::OrthancConfiguration mainConfiguration; |
297 bool serveOpenSeadragon; | 297 |
298 bool serveIIIF = true; // TODO => CONFIG | 298 OrthancPlugins::OrthancConfiguration wsiConfiguration; |
299 mainConfiguration.GetSection(wsiConfiguration, "WholeSlideImaging"); | |
300 | |
301 const bool enableIIIF = wsiConfiguration.GetBooleanValue("EnableIIIF", true); | |
302 bool serveMirador = false; | |
303 bool serveOpenSeadragon = false; | |
299 std::string iiifPublicUrl; | 304 std::string iiifPublicUrl; |
300 | 305 |
301 if (serveIIIF) | 306 if (enableIIIF) |
302 { | 307 { |
303 // TODO => CONFIG | 308 if (!wsiConfiguration.LookupStringValue(iiifPublicUrl, "OrthancPublicURL")) |
304 iiifPublicUrl = "http://localhost:8042/wsi/iiif"; | 309 { |
310 unsigned int port = mainConfiguration.GetUnsignedIntegerValue("HttpPort", 8042); | |
311 iiifPublicUrl = "http://localhost:" + boost::lexical_cast<std::string>(port) + "/"; | |
312 } | |
305 | 313 |
306 if (iiifPublicUrl.empty() || | 314 if (iiifPublicUrl.empty() || |
307 iiifPublicUrl[iiifPublicUrl.size() - 1] != '/') | 315 iiifPublicUrl[iiifPublicUrl.size() - 1] != '/') |
308 { | 316 { |
309 iiifPublicUrl += "/"; | 317 iiifPublicUrl += "/"; |
310 } | 318 } |
311 | 319 |
320 iiifPublicUrl += "wsi/iiif/"; | |
321 | |
312 InitializeIIIF(iiifPublicUrl); | 322 InitializeIIIF(iiifPublicUrl); |
313 SetIIIFForcePowersOfTwoScaleFactors(true); // TODO => CONFIG | 323 |
314 | 324 serveMirador = wsiConfiguration.GetBooleanValue("ServeMirador", false); |
315 serveMirador = true; // TODO => CONFIG | 325 serveOpenSeadragon = wsiConfiguration.GetBooleanValue("ServeOpenSeadragon", false); |
316 serveOpenSeadragon = true; // TODO => CONFIG | 326 |
317 | 327 bool value; |
318 if (serveMirador) | 328 if (wsiConfiguration.LookupBooleanValue(value, "ForcePowersOfTwoScaleFactors")) |
319 { | 329 { |
320 OrthancPlugins::RegisterRestCallback<ServeFile>("/wsi/app/(mirador.html)", true); | 330 SetIIIFForcePowersOfTwoScaleFactors(value); |
321 } | 331 } |
322 | 332 else |
323 if (serveOpenSeadragon) | |
324 { | 333 { |
325 OrthancPlugins::RegisterRestCallback<ServeFile>("/wsi/app/(openseadragon.html)", true); | 334 /** |
335 * By default, compatibility mode is disabled. However, if | |
336 * Mirador or OSD are enabled, compatibility mode is | |
337 * automatically enabled to enhance user experience, at least | |
338 * until issue 2379 of OSD is solved: | |
339 * https://github.com/openseadragon/openseadragon/issues/2379 | |
340 **/ | |
341 SetIIIFForcePowersOfTwoScaleFactors(serveMirador || serveOpenSeadragon); | |
326 } | 342 } |
327 } | 343 } |
328 else | 344 |
329 { | 345 LOG(WARNING) << "Support of IIIF is " << (enableIIIF ? "enabled" : "disabled") << " in the whole-slide imaging plugin"; |
330 serveMirador = false; | 346 |
331 serveOpenSeadragon = false; | 347 if (serveMirador) |
348 { | |
349 OrthancPlugins::RegisterRestCallback<ServeFile>("/wsi/app/(mirador.html)", true); | |
350 } | |
351 | |
352 if (serveOpenSeadragon) | |
353 { | |
354 OrthancPlugins::RegisterRestCallback<ServeFile>("/wsi/app/(openseadragon.html)", true); | |
332 } | 355 } |
333 | 356 |
334 { | 357 { |
335 // Extend the default Orthanc Explorer with custom JavaScript for WSI | 358 // Extend the default Orthanc Explorer with custom JavaScript for WSI |
336 | 359 |
337 std::string explorer; | 360 std::string explorer; |
338 Orthanc::EmbeddedResources::GetFileResource(explorer, Orthanc::EmbeddedResources::ORTHANC_EXPLORER); | 361 Orthanc::EmbeddedResources::GetFileResource(explorer, Orthanc::EmbeddedResources::ORTHANC_EXPLORER); |
339 | 362 |
340 std::map<std::string, std::string> dictionary; | 363 std::map<std::string, std::string> dictionary; |
341 dictionary["SERVE_IIIF"] = (serveIIIF ? "true" : "false"); | 364 dictionary["ENABLE_IIIF"] = (enableIIIF ? "true" : "false"); |
342 dictionary["SERVE_MIRADOR"] = (serveMirador ? "true" : "false"); | 365 dictionary["SERVE_MIRADOR"] = (serveMirador ? "true" : "false"); |
343 dictionary["SERVE_OPEN_SEADRAGON"] = (serveOpenSeadragon ? "true" : "false"); | 366 dictionary["SERVE_OPEN_SEADRAGON"] = (serveOpenSeadragon ? "true" : "false"); |
344 dictionary["IIIF_PUBLIC_URL"] = iiifPublicUrl; | |
345 explorer = Orthanc::Toolbox::SubstituteVariables(explorer, dictionary); | 367 explorer = Orthanc::Toolbox::SubstituteVariables(explorer, dictionary); |
346 | 368 |
347 OrthancPluginExtendOrthancExplorer(OrthancPlugins::GetGlobalContext(), explorer.c_str()); | 369 OrthancPluginExtendOrthancExplorer(OrthancPlugins::GetGlobalContext(), explorer.c_str()); |
348 } | 370 } |
349 | 371 |