Mercurial > hg > orthanc-stone
diff Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp @ 1822:0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 26 May 2021 18:13:35 +0200 |
parents | dccdc7e59929 |
children | a56bf4c534ef |
line wrap: on
line diff
--- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Wed May 26 14:02:12 2021 +0200 +++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Wed May 26 18:13:35 2021 +0200 @@ -1399,6 +1399,30 @@ { OrthancStone::DicomInstanceParameters params(dicom); + + params.EnrichUsingDicomWeb(message.GetResources()->GetSourceJson(0)); + GetViewport().centralPixelSpacingX_ = params.GetPixelSpacingX(); + GetViewport().centralPixelSpacingY_ = params.GetPixelSpacingY(); + + if (params.HasPixelSpacing()) + { + GetViewport().stoneAnnotations_->SetUnits(OrthancStone::Units_Millimeters); + } + else + { + GetViewport().stoneAnnotations_->SetUnits(OrthancStone::Units_Pixels); + } + + if (params.GetPixelSpacingX() != 0 && + params.GetPixelSpacingY() != 0 && + params.GetWidth() != 0 && + params.GetHeight()) + { + GetViewport().centralPhysicalWidth_ = (params.GetPixelSpacingX() * + static_cast<double>(params.GetWidth())); + GetViewport().centralPhysicalHeight_ = (params.GetPixelSpacingY() * + static_cast<double>(params.GetHeight())); + } GetViewport().windowingPresetCenters_.resize(params.GetWindowingPresetsCount()); GetViewport().windowingPresetWidths_.resize(params.GetWindowingPresetsCount()); @@ -1703,6 +1727,8 @@ bool synchronizationEnabled_; double centralPhysicalWidth_; // LSD-479 double centralPhysicalHeight_; + double centralPixelSpacingX_; + double centralPixelSpacingY_; bool hasFocusOnInstance_; std::string focusSopInstanceUid_; @@ -1856,7 +1882,17 @@ layer->SetFlipY(flipY_); double pixelSpacingX, pixelSpacingY; - OrthancStone::GeometryToolbox::GetPixelSpacing(pixelSpacingX, pixelSpacingY, instance.GetTags()); + + if (instance.HasPixelSpacing()) + { + pixelSpacingX = instance.GetPixelSpacingX(); + pixelSpacingY = instance.GetPixelSpacingY(); + } + else + { + pixelSpacingX = centralPixelSpacingX_; + pixelSpacingY = centralPixelSpacingY_; + } if (FIX_LSD_479) { @@ -2144,7 +2180,9 @@ synchronizationOffset_(OrthancStone::LinearAlgebra::CreateVector(0, 0, 0)), synchronizationEnabled_(false), centralPhysicalWidth_(1), - centralPhysicalHeight_(1) + centralPhysicalHeight_(1), + centralPixelSpacingX_(1), + centralPixelSpacingY_(1) { if (!framesCache_) { @@ -2420,17 +2458,6 @@ boost::make_shared<OrthancStone::LoadedDicomResources>(Orthanc::DICOM_TAG_SOP_INSTANCE_UID), 0, source_, uri, new LoadSeriesDetailsFromInstance(GetSharedObserver())); } - - if (centralInstance.GetPixelSpacingX() != 0 && - centralInstance.GetPixelSpacingY() != 0 && - centralInstance.GetWidth() != 0 && - centralInstance.GetHeight()) - { - centralPhysicalWidth_ = (centralInstance.GetPixelSpacingX() * - static_cast<double>(centralInstance.GetWidth())); - centralPhysicalHeight_ = (centralInstance.GetPixelSpacingY() * - static_cast<double>(centralInstance.GetHeight())); - } } ApplyScheduledFocus();