# HG changeset patch # User Sebastien Jodogne # Date 1699452801 -3600 # Node ID ec676dbe85acb0ae962c553e97212857a9474d90 # Parent 7c3d65166c266557ad95566c95792f3a69104f65 partial integration dicom-sr->mainline diff -r 7c3d65166c26 -r ec676dbe85ac Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp --- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Wed Nov 08 14:54:15 2023 +0100 +++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Wed Nov 08 15:13:21 2023 +0100 @@ -819,32 +819,31 @@ } } - bool SortSeriesFrames(OrthancStone::SortedFrames& target, - const std::string& seriesInstanceUid) const + IFramesCollection* GetSeriesFrames(const std::string& seriesInstanceUid) const { OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid); if (accessor.IsComplete()) { - target.Clear(); + std::unique_ptr target(new OrthancStone::SortedFrames); + target->Clear(); for (size_t i = 0; i < accessor.GetInstancesCount(); i++) { - target.AddInstance(accessor.GetInstance(i)); + target->AddInstance(accessor.GetInstance(i)); } - target.Sort(); + target->Sort(); - return true; + return new SortedFramesCollection(target.release()); } else { - return false; + return NULL; } } - bool SortVirtualSeriesFrames(OrthancStone::SortedFrames& target, - const std::string& virtualSeriesId) const + IFramesCollection* GetVirtualSeriesFrames(const std::string& virtualSeriesId) const { const std::string& seriesInstanceUid = virtualSeries_.GetSeriesInstanceUid(virtualSeriesId); @@ -854,7 +853,8 @@ { const std::list& sopInstanceUids = virtualSeries_.GetSopInstanceUids(virtualSeriesId); - target.Clear(); + std::unique_ptr target(new OrthancStone::SortedFrames); + target->Clear(); for (std::list::const_iterator it = sopInstanceUids.begin(); it != sopInstanceUids.end(); ++it) @@ -862,7 +862,7 @@ Orthanc::DicomMap instance; if (accessor.LookupInstance(instance, *it)) { - target.AddInstance(instance); + target->AddInstance(instance); } else { @@ -870,12 +870,13 @@ } } - target.Sort(); - return true; + target->Sort(); + + return new SortedFramesCollection(target.release()); } else { - return false; + return NULL; } } @@ -1635,7 +1636,6 @@ - class ViewerViewport : public OrthancStone::ObserverBase { public: @@ -1917,6 +1917,8 @@ class SetFullDicomFrame : public ICommand { private: + std::string studyInstanceUid_; + std::string seriesInstanceUid_; std::string sopInstanceUid_; unsigned int frameNumber_; int priority_; @@ -1925,12 +1927,16 @@ public: SetFullDicomFrame(boost::shared_ptr viewport, + const std::string& studyInstanceUid, + const std::string& seriesInstanceUid, const std::string& sopInstanceUid, unsigned int frameNumber, int priority, bool isPrefetch, bool serverSideTranscoding) : ICommand(viewport), + studyInstanceUid_(studyInstanceUid), + seriesInstanceUid_(seriesInstanceUid), sopInstanceUid_(sopInstanceUid), frameNumber_(frameNumber), priority_(priority), @@ -1956,7 +1962,7 @@ // If we haven't tried server-side rendering yet, give it a try LOG(INFO) << "Switching to server-side transcoding"; GetViewport().serverSideTranscoding_ = true; - GetViewport().ScheduleLoadFullDicomFrame(sopInstanceUid_, frameNumber_, priority_, isPrefetch_); + GetViewport().ScheduleLoadFullDicomFrame(studyInstanceUid_, seriesInstanceUid_, sopInstanceUid_, frameNumber_, priority_, isPrefetch_); } return; } @@ -2074,7 +2080,7 @@ boost::shared_ptr loader_; OrthancStone::DicomSource source_; boost::shared_ptr framesCache_; - std::unique_ptr frames_; + std::unique_ptr frames_; std::unique_ptr cursor_; float windowingCenter_; float windowingWidth_; @@ -2432,7 +2438,7 @@ if (instance.GetSopInstanceUid() == loadedSopInstanceUid && frameNumber == loadedFrameNumber) { - const OrthancStone::CoordinateSystem3D plane = frames_->GetFrameGeometry(cursorIndex); + const OrthancStone::CoordinateSystem3D plane = IFramesCollection::GetFrameGeometry(*frames_, cursorIndex); if (quality == DisplayedFrameQuality_Low) { @@ -2471,7 +2477,9 @@ } } - void ScheduleLoadFullDicomFrame(const std::string& sopInstanceUid, + void ScheduleLoadFullDicomFrame(const std::string& studyInstanceUid, + const std::string& seriesInstanceUid, + const std::string& sopInstanceUid, unsigned int frameNumber, int priority, bool isPrefetch) @@ -2481,10 +2489,10 @@ std::unique_ptr lock(context_.Lock()); lock->Schedule( GetSharedObserver(), priority, OrthancStone::ParseDicomFromWadoCommand::Create( - source_, frames_->GetStudyInstanceUid(), frames_->GetSeriesInstanceUid(), - sopInstanceUid, serverSideTranscoding_, + source_, studyInstanceUid, seriesInstanceUid, sopInstanceUid, serverSideTranscoding_, Orthanc::DicomTransferSyntax_LittleEndianExplicit, - new SetFullDicomFrame(GetSharedObserver(), sopInstanceUid, frameNumber, priority, isPrefetch, serverSideTranscoding_))); + new SetFullDicomFrame(GetSharedObserver(), studyInstanceUid, seriesInstanceUid, + sopInstanceUid, frameNumber, priority, isPrefetch, serverSideTranscoding_))); } } @@ -2494,9 +2502,11 @@ { if (frames_.get() != NULL) { + std::string studyInstanceUid = frames_->GetInstanceOfFrame(cursorIndex).GetStudyInstanceUid(); + std::string seriesInstanceUid = frames_->GetInstanceOfFrame(cursorIndex).GetSeriesInstanceUid(); std::string sopInstanceUid = frames_->GetInstanceOfFrame(cursorIndex).GetSopInstanceUid(); unsigned int frameNumber = frames_->GetFrameNumberInInstance(cursorIndex); - ScheduleLoadFullDicomFrame(sopInstanceUid, frameNumber, priority, isPrefetch); + ScheduleLoadFullDicomFrame(studyInstanceUid, seriesInstanceUid, sopInstanceUid, frameNumber, priority, isPrefetch); } } @@ -2545,8 +2555,8 @@ bool isMonochrome1 = (instance.GetImageInformation().GetPhotometricInterpretation() == Orthanc::PhotometricInterpretation_Monochrome1); - const std::string uri = ("studies/" + frames_->GetStudyInstanceUid() + - "/series/" + frames_->GetSeriesInstanceUid() + + const std::string uri = ("studies/" + instance.GetStudyInstanceUid() + + "/series/" + instance.GetSeriesInstanceUid() + "/instances/" + instance.GetSopInstanceUid() + "/frames/" + boost::lexical_cast(frameNumber + 1) + "/rendered"); @@ -2587,7 +2597,6 @@ } } - ViewerViewport(OrthancStone::WebAssemblyLoadersContext& context, const OrthancStone::DicomSource& source, const std::string& canvas, @@ -2682,14 +2691,12 @@ { const size_t currentCursorIndex = that.cursor_->GetCurrentIndex(); - const OrthancStone::CoordinateSystem3D current = - that.frames_->GetFrameGeometry(currentCursorIndex); + const OrthancStone::CoordinateSystem3D current = IFramesCollection::GetFrameGeometry(*that.frames_, currentCursorIndex); if (isShift && previousCursorIndex != currentCursorIndex) { - const OrthancStone::CoordinateSystem3D previous = - that.frames_->GetFrameGeometry(previousCursorIndex); + const OrthancStone::CoordinateSystem3D previous = IFramesCollection::GetFrameGeometry(*that.frames_, previousCursorIndex); that.synchronizationOffset_ += previous.GetOrigin() - current.GetOrigin(); } @@ -2836,7 +2843,7 @@ return viewport; } - void SetFrames(OrthancStone::SortedFrames* frames) + void SetFrames(IFramesCollection* frames) { if (frames == NULL) { @@ -2906,8 +2913,8 @@ GetSeriesThumbnailType(uid) != OrthancStone::SeriesThumbnailType_Video) { // Fetch the details of the series from the central instance - const std::string uri = ("studies/" + frames_->GetStudyInstanceUid() + - "/series/" + frames_->GetSeriesInstanceUid() + + const std::string uri = ("studies/" + centralInstance.GetStudyInstanceUid() + + "/series/" + centralInstance.GetSeriesInstanceUid() + "/instances/" + centralInstance.GetSopInstanceUid() + "/metadata"); loader_->ScheduleGetDicomWeb( @@ -2963,7 +2970,7 @@ FramesCache::Accessor accessor(*framesCache_, instance.GetSopInstanceUid(), frameNumber); if (accessor.IsValid()) { - RenderCurrentScene(accessor.GetImage(), instance, frameNumber, frames_->GetFrameGeometry(cursorIndex)); + RenderCurrentScene(accessor.GetImage(), instance, frameNumber, IFramesCollection::GetFrameGeometry(*frames_, cursorIndex)); DisplayedFrameQuality quality; @@ -3074,7 +3081,7 @@ if (cursor_.get() != NULL && frames_.get() != NULL) { - plane = frames_->GetFrameGeometry(cursor_->GetCurrentIndex()); + plane = IFramesCollection::GetFrameGeometry(*frames_, cursor_->GetCurrentIndex()); return true; } else @@ -3148,7 +3155,7 @@ void SetWindowingPreset() { assert(windowingPresetCenters_.size() == windowingPresetWidths_.size()); - + if (windowingPresetCenters_.empty()) { SetWindowing(128, 256); @@ -3574,8 +3581,7 @@ { const size_t currentCursorIndex = cursor_->GetCurrentIndex(); - const OrthancStone::CoordinateSystem3D current = - frames_->GetFrameGeometry(currentCursorIndex); + const OrthancStone::CoordinateSystem3D current = IFramesCollection::GetFrameGeometry(*frames_, currentCursorIndex); observer_->SignalSynchronizedBrowsing( *this, current.GetOrigin() + synchronizationOffset_, current.GetNormal()); @@ -4226,9 +4232,9 @@ { try { - std::unique_ptr frames(new OrthancStone::SortedFrames); - - if (GetResourcesLoader().SortSeriesFrames(*frames, seriesInstanceUid)) + std::unique_ptr frames(GetResourcesLoader().GetSeriesFrames(seriesInstanceUid)); + + if (frames.get() != NULL) { GetViewport(canvas)->SetFrames(frames.release()); return 1; @@ -4249,9 +4255,9 @@ { try { - std::unique_ptr frames(new OrthancStone::SortedFrames); - - if (GetResourcesLoader().SortVirtualSeriesFrames(*frames, virtualSeriesId)) + std::unique_ptr frames(GetResourcesLoader().GetVirtualSeriesFrames(virtualSeriesId)); + + if (frames.get() != NULL) { GetViewport(canvas)->SetFrames(frames.release()); return 1;