Mercurial > hg > orthanc-stone
comparison Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp @ 1665:f62f685e0eb2
avoid loading instance metadata on RTSTRUCT to avoid JSON parsing that freezes the browser
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 19 Nov 2020 15:39:30 +0100 |
parents | fc883105ee11 |
children | 1e6d3289b1ad |
comparison
equal
deleted
inserted
replaced
1664:32e765ca7193 | 1665:f62f685e0eb2 |
---|---|
1855 if (observer_.get() != NULL) | 1855 if (observer_.get() != NULL) |
1856 { | 1856 { |
1857 observer_->SignalFrameUpdated(*this, cursor_->GetCurrentIndex(), | 1857 observer_->SignalFrameUpdated(*this, cursor_->GetCurrentIndex(), |
1858 frames_->GetFramesCount(), DisplayedFrameQuality_None); | 1858 frames_->GetFramesCount(), DisplayedFrameQuality_None); |
1859 } | 1859 } |
1860 | 1860 |
1861 if (frames_->GetFramesCount() != 0) | 1861 if (frames_->GetFramesCount() != 0) |
1862 { | 1862 { |
1863 const std::string& sopInstanceUid = frames_->GetInstanceOfFrame(cursor_->GetCurrentIndex()).GetSopInstanceUid(); | 1863 const OrthancStone::DicomInstanceParameters& centralInstance = frames_->GetInstanceOfFrame(cursor_->GetCurrentIndex()); |
1864 | 1864 |
1865 /** | |
1866 * Avoid loading metadata if we know that this cannot be a | |
1867 * "true" image with pixel data. Retrieving instance metadata on | |
1868 * RTSTRUCT can lead to very large JSON whose parsing will | |
1869 * freeze the browser for several seconds. | |
1870 **/ | |
1871 const OrthancStone::SopClassUid uid = centralInstance.GetSopClassUid(); | |
1872 if (uid != OrthancStone::SopClassUid_EncapsulatedPdf && | |
1873 uid != OrthancStone::SopClassUid_RTDose && | |
1874 uid != OrthancStone::SopClassUid_RTPlan && | |
1875 uid != OrthancStone::SopClassUid_RTStruct && | |
1876 GetSeriesThumbnailType(uid) != OrthancStone::SeriesThumbnailType_Video) | |
1865 { | 1877 { |
1866 // Fetch the default windowing for the central instance | 1878 // Fetch the default windowing for the central instance |
1867 const std::string uri = ("studies/" + frames_->GetStudyInstanceUid() + | 1879 const std::string uri = ("studies/" + frames_->GetStudyInstanceUid() + |
1868 "/series/" + frames_->GetSeriesInstanceUid() + | 1880 "/series/" + frames_->GetSeriesInstanceUid() + |
1869 "/instances/" + sopInstanceUid + "/metadata"); | 1881 "/instances/" + centralInstance.GetSopInstanceUid() + "/metadata"); |
1870 | 1882 |
1871 loader_->ScheduleGetDicomWeb( | 1883 loader_->ScheduleGetDicomWeb( |
1872 boost::make_shared<OrthancStone::LoadedDicomResources>(Orthanc::DICOM_TAG_SOP_INSTANCE_UID), | 1884 boost::make_shared<OrthancStone::LoadedDicomResources>(Orthanc::DICOM_TAG_SOP_INSTANCE_UID), |
1873 0, source_, uri, new SetDefaultWindowingCommand(GetSharedObserver())); | 1885 0, source_, uri, new SetDefaultWindowingCommand(GetSharedObserver())); |
1874 } | 1886 } |
2421 | 2433 |
2422 extern "C" | 2434 extern "C" |
2423 { | 2435 { |
2424 int main(int argc, char const *argv[]) | 2436 int main(int argc, char const *argv[]) |
2425 { | 2437 { |
2426 printf("OK\n"); | 2438 printf("Initializing Stone\n"); |
2427 Orthanc::InitializeFramework("", true); | 2439 Orthanc::InitializeFramework("", true); |
2428 Orthanc::Logging::EnableInfoLevel(true); | 2440 Orthanc::Logging::EnableInfoLevel(true); |
2429 //Orthanc::Logging::EnableTraceLevel(true); | 2441 //Orthanc::Logging::EnableTraceLevel(true); |
2430 | 2442 |
2431 context_.reset(new OrthancStone::WebAssemblyLoadersContext(1, 4, 1)); | 2443 context_.reset(new OrthancStone::WebAssemblyLoadersContext(1, 4, 1)); |