changeset 409:f4483be2364e

backward compatibility in the viewer if x/y are swapped
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 05 Nov 2025 20:44:55 +0100
parents bdc8449b00cb
children 6e838900498a
files Framework/Inputs/DicomPyramidInstance.cpp ViewerPlugin/viewer.js
diffstat 2 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Inputs/DicomPyramidInstance.cpp	Wed Nov 05 19:03:33 2025 +0100
+++ b/Framework/Inputs/DicomPyramidInstance.cpp	Wed Nov 05 20:44:55 2025 +0100
@@ -301,11 +301,6 @@
     hasImagedVolumeSize_ = (
       reader.GetDoubleValue(imagedVolumeWidth_, Orthanc::DicomPath(DICOM_TAG_IMAGED_VOLUME_WIDTH)) &&
       reader.GetDoubleValue(imagedVolumeHeight_, Orthanc::DicomPath(DICOM_TAG_IMAGED_VOLUME_HEIGHT)));
-
-    if (hasImagedVolumeSize_)
-    {
-      // TODO - SWAP WIDTH/HEIGHT FOR OLD VERSIONS OF ORTHANC
-    }
   }
 
 
--- a/ViewerPlugin/viewer.js	Wed Nov 05 19:03:33 2025 +0100
+++ b/ViewerPlugin/viewer.js	Wed Nov 05 20:44:55 2025 +0100
@@ -21,6 +21,12 @@
  **/
 
 
+function IsNear(a, b)
+{
+  return Math.abs(a - b) <= 0.000000001;
+}
+
+
 function InitializePyramid(pyramid, tilesBaseUrl)
 {
   $('#map').css('background', pyramid['BackgroundColor']);  // New in WSI 2.1
@@ -36,10 +42,17 @@
       imagedVolumeHeight !== undefined) {
     var metersPerUnitX = parseFloat(imagedVolumeWidth) / (1000.0 * parseFloat(width));
     var metersPerUnitY = parseFloat(imagedVolumeHeight) / (1000.0 * parseFloat(height));
-    if (Math.abs(metersPerUnitX - metersPerUnitY) <= 0.000000001) {
+    if (IsNear(metersPerUnitX, metersPerUnitY)) {
       metersPerUnit = metersPerUnitX;
     } else {
-      console.error('Inconsistency in the imaged volume size, not showing the scale');
+      // Backward compatibility with OrthancWSIDicomizer <= 3.2, where X/Y were swapped
+      metersPerUnitX = parseFloat(imagedVolumeWidth) / (1000.0 * parseFloat(height));
+      metersPerUnitY = parseFloat(imagedVolumeHeight) / (1000.0 * parseFloat(width));
+      if (IsNear(metersPerUnitX, metersPerUnitY)) {
+        metersPerUnit = metersPerUnitX;
+      } else {
+        console.error('Inconsistency in the imaged volume size, not showing the scale');
+      }
     }
   }