Mercurial > hg > orthanc-stone
comparison Framework/Toolbox/OrthancSlicesLoader.cpp @ 726:4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 21 May 2019 11:43:25 +0200 |
parents | d2c0e347ddc2 |
children |
comparison
equal
deleted
inserted
replaced
714:d2c0e347ddc2 | 726:4f2416d519b4 |
---|---|
66 return out; | 66 return out; |
67 } | 67 } |
68 | 68 |
69 | 69 |
70 | 70 |
71 namespace OrthancStone | 71 namespace Deprecated |
72 { | 72 { |
73 class OrthancSlicesLoader::Operation : public Orthanc::IDynamicObject | 73 class OrthancSlicesLoader::Operation : public Orthanc::IDynamicObject |
74 { | 74 { |
75 private: | 75 private: |
76 Mode mode_; | 76 Mode mode_; |
77 unsigned int frame_; | 77 unsigned int frame_; |
78 unsigned int sliceIndex_; | 78 unsigned int sliceIndex_; |
79 const Deprecated::Slice* slice_; | 79 const Slice* slice_; |
80 std::string instanceId_; | 80 std::string instanceId_; |
81 SliceImageQuality quality_; | 81 OrthancStone::SliceImageQuality quality_; |
82 | 82 |
83 Operation(Mode mode) : | 83 Operation(Mode mode) : |
84 mode_(mode) | 84 mode_(mode) |
85 { | 85 { |
86 } | 86 } |
89 Mode GetMode() const | 89 Mode GetMode() const |
90 { | 90 { |
91 return mode_; | 91 return mode_; |
92 } | 92 } |
93 | 93 |
94 SliceImageQuality GetQuality() const | 94 OrthancStone::SliceImageQuality GetQuality() const |
95 { | 95 { |
96 assert(mode_ == Mode_LoadImage || | 96 assert(mode_ == Mode_LoadImage || |
97 mode_ == Mode_LoadRawImage); | 97 mode_ == Mode_LoadRawImage); |
98 return quality_; | 98 return quality_; |
99 } | 99 } |
103 assert(mode_ == Mode_LoadImage || | 103 assert(mode_ == Mode_LoadImage || |
104 mode_ == Mode_LoadRawImage); | 104 mode_ == Mode_LoadRawImage); |
105 return sliceIndex_; | 105 return sliceIndex_; |
106 } | 106 } |
107 | 107 |
108 const Deprecated::Slice& GetSlice() const | 108 const Slice& GetSlice() const |
109 { | 109 { |
110 assert(mode_ == Mode_LoadImage || | 110 assert(mode_ == Mode_LoadImage || |
111 mode_ == Mode_LoadRawImage); | 111 mode_ == Mode_LoadRawImage); |
112 assert(slice_ != NULL); | 112 assert(slice_ != NULL); |
113 return *slice_; | 113 return *slice_; |
141 operation->frame_ = frame; | 141 operation->frame_ = frame; |
142 return operation.release(); | 142 return operation.release(); |
143 } | 143 } |
144 | 144 |
145 static Operation* DownloadSliceImage(unsigned int sliceIndex, | 145 static Operation* DownloadSliceImage(unsigned int sliceIndex, |
146 const Deprecated::Slice& slice, | 146 const Slice& slice, |
147 SliceImageQuality quality) | 147 OrthancStone::SliceImageQuality quality) |
148 { | 148 { |
149 std::auto_ptr<Operation> tmp(new Operation(Mode_LoadImage)); | 149 std::auto_ptr<Operation> tmp(new Operation(Mode_LoadImage)); |
150 tmp->sliceIndex_ = sliceIndex; | 150 tmp->sliceIndex_ = sliceIndex; |
151 tmp->slice_ = &slice; | 151 tmp->slice_ = &slice; |
152 tmp->quality_ = quality; | 152 tmp->quality_ = quality; |
153 return tmp.release(); | 153 return tmp.release(); |
154 } | 154 } |
155 | 155 |
156 static Operation* DownloadSliceRawImage(unsigned int sliceIndex, | 156 static Operation* DownloadSliceRawImage(unsigned int sliceIndex, |
157 const Deprecated::Slice& slice) | 157 const Slice& slice) |
158 { | 158 { |
159 std::auto_ptr<Operation> tmp(new Operation(Mode_LoadRawImage)); | 159 std::auto_ptr<Operation> tmp(new Operation(Mode_LoadRawImage)); |
160 tmp->sliceIndex_ = sliceIndex; | 160 tmp->sliceIndex_ = sliceIndex; |
161 tmp->slice_ = &slice; | 161 tmp->slice_ = &slice; |
162 tmp->quality_ = SliceImageQuality_InternalRaw; | 162 tmp->quality_ = OrthancStone::SliceImageQuality_InternalRaw; |
163 return tmp.release(); | 163 return tmp.release(); |
164 } | 164 } |
165 | 165 |
166 static Operation* DownloadDicomFile(const Deprecated::Slice& slice) | 166 static Operation* DownloadDicomFile(const Slice& slice) |
167 { | 167 { |
168 std::auto_ptr<Operation> tmp(new Operation(Mode_LoadDicomFile)); | 168 std::auto_ptr<Operation> tmp(new Operation(Mode_LoadDicomFile)); |
169 tmp->slice_ = &slice; | 169 tmp->slice_ = &slice; |
170 return tmp.release(); | 170 return tmp.release(); |
171 } | 171 } |
229 for (size_t i = 0; i < instances.size(); i++) | 229 for (size_t i = 0; i < instances.size(); i++) |
230 { | 230 { |
231 OrthancPlugins::FullOrthancDataset dataset(series[instances[i]]); | 231 OrthancPlugins::FullOrthancDataset dataset(series[instances[i]]); |
232 | 232 |
233 Orthanc::DicomMap dicom; | 233 Orthanc::DicomMap dicom; |
234 MessagingToolbox::ConvertDataset(dicom, dataset); | 234 OrthancStone::MessagingToolbox::ConvertDataset(dicom, dataset); |
235 | 235 |
236 unsigned int frames; | 236 unsigned int frames; |
237 if (!dicom.ParseUnsignedInteger32(frames, Orthanc::DICOM_TAG_NUMBER_OF_FRAMES)) | 237 if (!dicom.ParseUnsignedInteger32(frames, Orthanc::DICOM_TAG_NUMBER_OF_FRAMES)) |
238 { | 238 { |
239 frames = 1; | 239 frames = 1; |
240 } | 240 } |
241 | 241 |
242 for (unsigned int frame = 0; frame < frames; frame++) | 242 for (unsigned int frame = 0; frame < frames; frame++) |
243 { | 243 { |
244 std::auto_ptr<Deprecated::Slice> slice(new Deprecated::Slice); | 244 std::auto_ptr<Slice> slice(new Slice); |
245 if (slice->ParseOrthancFrame(dicom, instances[i], frame)) | 245 if (slice->ParseOrthancFrame(dicom, instances[i], frame)) |
246 { | 246 { |
247 CoordinateSystem3D geometry = slice->GetGeometry(); | 247 OrthancStone::CoordinateSystem3D geometry = slice->GetGeometry(); |
248 slices_.AddSlice(geometry, slice.release()); | 248 slices_.AddSlice(geometry, slice.release()); |
249 } | 249 } |
250 else | 250 else |
251 { | 251 { |
252 LOG(WARNING) << "Skipping invalid frame " << frame << " within instance " << instances[i]; | 252 LOG(WARNING) << "Skipping invalid frame " << frame << " within instance " << instances[i]; |
263 const std::string& instanceId = dynamic_cast<const OrthancSlicesLoader::Operation&>(message.GetPayload()).GetInstanceId(); | 263 const std::string& instanceId = dynamic_cast<const OrthancSlicesLoader::Operation&>(message.GetPayload()).GetInstanceId(); |
264 | 264 |
265 OrthancPlugins::FullOrthancDataset dataset(tags); | 265 OrthancPlugins::FullOrthancDataset dataset(tags); |
266 | 266 |
267 Orthanc::DicomMap dicom; | 267 Orthanc::DicomMap dicom; |
268 MessagingToolbox::ConvertDataset(dicom, dataset); | 268 OrthancStone::MessagingToolbox::ConvertDataset(dicom, dataset); |
269 | 269 |
270 unsigned int frames; | 270 unsigned int frames; |
271 if (!dicom.ParseUnsignedInteger32(frames, Orthanc::DICOM_TAG_NUMBER_OF_FRAMES)) | 271 if (!dicom.ParseUnsignedInteger32(frames, Orthanc::DICOM_TAG_NUMBER_OF_FRAMES)) |
272 { | 272 { |
273 frames = 1; | 273 frames = 1; |
275 | 275 |
276 LOG(INFO) << "Instance " << instanceId << " contains " << frames << " frame(s)"; | 276 LOG(INFO) << "Instance " << instanceId << " contains " << frames << " frame(s)"; |
277 | 277 |
278 for (unsigned int frame = 0; frame < frames; frame++) | 278 for (unsigned int frame = 0; frame < frames; frame++) |
279 { | 279 { |
280 std::auto_ptr<Deprecated::Slice> slice(new Deprecated::Slice); | 280 std::auto_ptr<Slice> slice(new Slice); |
281 if (slice->ParseOrthancFrame(dicom, instanceId, frame)) | 281 if (slice->ParseOrthancFrame(dicom, instanceId, frame)) |
282 { | 282 { |
283 CoordinateSystem3D geometry = slice->GetGeometry(); | 283 OrthancStone::CoordinateSystem3D geometry = slice->GetGeometry(); |
284 slices_.AddSlice(geometry, slice.release()); | 284 slices_.AddSlice(geometry, slice.release()); |
285 } | 285 } |
286 else | 286 else |
287 { | 287 { |
288 LOG(WARNING) << "Skipping invalid multi-frame instance " << instanceId; | 288 LOG(WARNING) << "Skipping invalid multi-frame instance " << instanceId; |
304 OrthancPlugins::FullOrthancDataset dataset(tags); | 304 OrthancPlugins::FullOrthancDataset dataset(tags); |
305 | 305 |
306 state_ = State_GeometryReady; | 306 state_ = State_GeometryReady; |
307 | 307 |
308 Orthanc::DicomMap dicom; | 308 Orthanc::DicomMap dicom; |
309 MessagingToolbox::ConvertDataset(dicom, dataset); | 309 OrthancStone::MessagingToolbox::ConvertDataset(dicom, dataset); |
310 | 310 |
311 std::auto_ptr<Deprecated::Slice> slice(new Deprecated::Slice); | 311 std::auto_ptr<Slice> slice(new Slice); |
312 if (slice->ParseOrthancFrame(dicom, instanceId, frame)) | 312 if (slice->ParseOrthancFrame(dicom, instanceId, frame)) |
313 { | 313 { |
314 LOG(INFO) << "Loaded instance geometry " << instanceId; | 314 LOG(INFO) << "Loaded instance geometry " << instanceId; |
315 | 315 |
316 CoordinateSystem3D geometry = slice->GetGeometry(); | 316 OrthancStone::CoordinateSystem3D geometry = slice->GetGeometry(); |
317 slices_.AddSlice(geometry, slice.release()); | 317 slices_.AddSlice(geometry, slice.release()); |
318 | 318 |
319 BroadcastMessage(SliceGeometryReadyMessage(*this)); | 319 BroadcastMessage(SliceGeometryReadyMessage(*this)); |
320 } | 320 } |
321 else | 321 else |
542 Orthanc::ImageProcessing::Convert(*image, *reader); | 542 Orthanc::ImageProcessing::Convert(*image, *reader); |
543 reader.reset(); | 543 reader.reset(); |
544 | 544 |
545 float scaling = static_cast<float>(stretchHigh - stretchLow) / 255.0f; | 545 float scaling = static_cast<float>(stretchHigh - stretchLow) / 255.0f; |
546 | 546 |
547 if (!LinearAlgebra::IsCloseToZero(scaling)) | 547 if (!OrthancStone::LinearAlgebra::IsCloseToZero(scaling)) |
548 { | 548 { |
549 float offset = static_cast<float>(stretchLow) / scaling; | 549 float offset = static_cast<float>(stretchLow) / scaling; |
550 Orthanc::ImageProcessing::ShiftScale(*image, offset, scaling, true); | 550 Orthanc::ImageProcessing::ShiftScale(*image, offset, scaling, true); |
551 } | 551 } |
552 | 552 |
637 } | 637 } |
638 | 638 |
639 } | 639 } |
640 | 640 |
641 | 641 |
642 OrthancSlicesLoader::OrthancSlicesLoader(MessageBroker& broker, | 642 OrthancSlicesLoader::OrthancSlicesLoader(OrthancStone::MessageBroker& broker, |
643 OrthancApiClient& orthanc) : | 643 OrthancApiClient& orthanc) : |
644 IObservable(broker), | 644 OrthancStone::IObservable(broker), |
645 IObserver(broker), | 645 OrthancStone::IObserver(broker), |
646 orthanc_(orthanc), | 646 orthanc_(orthanc), |
647 state_(State_Initialization) | 647 state_(State_Initialization) |
648 { | 648 { |
649 } | 649 } |
650 | 650 |
657 } | 657 } |
658 else | 658 else |
659 { | 659 { |
660 state_ = State_LoadingGeometry; | 660 state_ = State_LoadingGeometry; |
661 orthanc_.GetJsonAsync("/series/" + seriesId + "/instances-tags", | 661 orthanc_.GetJsonAsync("/series/" + seriesId + "/instances-tags", |
662 new Callable<OrthancSlicesLoader, OrthancApiClient::JsonResponseReadyMessage>(*this, &OrthancSlicesLoader::ParseSeriesGeometry), | 662 new OrthancStone::Callable<OrthancSlicesLoader, OrthancApiClient::JsonResponseReadyMessage>(*this, &OrthancSlicesLoader::ParseSeriesGeometry), |
663 new Callable<OrthancSlicesLoader, IWebService::HttpRequestErrorMessage>(*this, &OrthancSlicesLoader::OnGeometryError), | 663 new OrthancStone::Callable<OrthancSlicesLoader, IWebService::HttpRequestErrorMessage>(*this, &OrthancSlicesLoader::OnGeometryError), |
664 NULL); | 664 NULL); |
665 } | 665 } |
666 } | 666 } |
667 | 667 |
668 void OrthancSlicesLoader::ScheduleLoadInstance(const std::string& instanceId) | 668 void OrthancSlicesLoader::ScheduleLoadInstance(const std::string& instanceId) |
676 state_ = State_LoadingGeometry; | 676 state_ = State_LoadingGeometry; |
677 | 677 |
678 // Tag "3004-000c" is "Grid Frame Offset Vector", which is | 678 // Tag "3004-000c" is "Grid Frame Offset Vector", which is |
679 // mandatory to read RT DOSE, but is too long to be returned by default | 679 // mandatory to read RT DOSE, but is too long to be returned by default |
680 orthanc_.GetJsonAsync("/instances/" + instanceId + "/tags?ignore-length=3004-000c", | 680 orthanc_.GetJsonAsync("/instances/" + instanceId + "/tags?ignore-length=3004-000c", |
681 new Callable<OrthancSlicesLoader, OrthancApiClient::JsonResponseReadyMessage>(*this, &OrthancSlicesLoader::ParseInstanceGeometry), | 681 new OrthancStone::Callable<OrthancSlicesLoader, OrthancApiClient::JsonResponseReadyMessage>(*this, &OrthancSlicesLoader::ParseInstanceGeometry), |
682 new Callable<OrthancSlicesLoader, IWebService::HttpRequestErrorMessage>(*this, &OrthancSlicesLoader::OnGeometryError), | 682 new OrthancStone::Callable<OrthancSlicesLoader, IWebService::HttpRequestErrorMessage>(*this, &OrthancSlicesLoader::OnGeometryError), |
683 Operation::DownloadInstanceGeometry(instanceId)); | 683 Operation::DownloadInstanceGeometry(instanceId)); |
684 } | 684 } |
685 } | 685 } |
686 | 686 |
687 | 687 |
695 else | 695 else |
696 { | 696 { |
697 state_ = State_LoadingGeometry; | 697 state_ = State_LoadingGeometry; |
698 | 698 |
699 orthanc_.GetJsonAsync("/instances/" + instanceId + "/tags", | 699 orthanc_.GetJsonAsync("/instances/" + instanceId + "/tags", |
700 new Callable<OrthancSlicesLoader, OrthancApiClient::JsonResponseReadyMessage>(*this, &OrthancSlicesLoader::ParseFrameGeometry), | 700 new OrthancStone::Callable<OrthancSlicesLoader, OrthancApiClient::JsonResponseReadyMessage>(*this, &OrthancSlicesLoader::ParseFrameGeometry), |
701 new Callable<OrthancSlicesLoader, IWebService::HttpRequestErrorMessage>(*this, &OrthancSlicesLoader::OnGeometryError), | 701 new OrthancStone::Callable<OrthancSlicesLoader, IWebService::HttpRequestErrorMessage>(*this, &OrthancSlicesLoader::OnGeometryError), |
702 Operation::DownloadFrameGeometry(instanceId, frame)); | 702 Operation::DownloadFrameGeometry(instanceId, frame)); |
703 } | 703 } |
704 } | 704 } |
705 | 705 |
706 | 706 |
719 | 719 |
720 return slices_.GetSlicesCount(); | 720 return slices_.GetSlicesCount(); |
721 } | 721 } |
722 | 722 |
723 | 723 |
724 const Deprecated::Slice& OrthancSlicesLoader::GetSlice(size_t index) const | 724 const Slice& OrthancSlicesLoader::GetSlice(size_t index) const |
725 { | 725 { |
726 if (state_ != State_GeometryReady) | 726 if (state_ != State_GeometryReady) |
727 { | 727 { |
728 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | 728 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
729 } | 729 } |
730 | 730 |
731 return dynamic_cast<const Deprecated::Slice&>(slices_.GetSlicePayload(index)); | 731 return dynamic_cast<const Slice&>(slices_.GetSlicePayload(index)); |
732 } | 732 } |
733 | 733 |
734 | 734 |
735 bool OrthancSlicesLoader::LookupSlice(size_t& index, | 735 bool OrthancSlicesLoader::LookupSlice(size_t& index, |
736 const CoordinateSystem3D& plane) const | 736 const OrthancStone::CoordinateSystem3D& plane) const |
737 { | 737 { |
738 if (state_ != State_GeometryReady) | 738 if (state_ != State_GeometryReady) |
739 { | 739 { |
740 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | 740 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
741 } | 741 } |
744 return (slices_.LookupClosestSlice(index, distance, plane) && | 744 return (slices_.LookupClosestSlice(index, distance, plane) && |
745 distance <= GetSlice(index).GetThickness() / 2.0); | 745 distance <= GetSlice(index).GetThickness() / 2.0); |
746 } | 746 } |
747 | 747 |
748 | 748 |
749 void OrthancSlicesLoader::ScheduleSliceImagePng(const Deprecated::Slice& slice, | 749 void OrthancSlicesLoader::ScheduleSliceImagePng(const Slice& slice, |
750 size_t index) | 750 size_t index) |
751 { | 751 { |
752 std::string uri = ("/instances/" + slice.GetOrthancInstanceId() + "/frames/" + | 752 std::string uri = ("/instances/" + slice.GetOrthancInstanceId() + "/frames/" + |
753 boost::lexical_cast<std::string>(slice.GetFrame())); | 753 boost::lexical_cast<std::string>(slice.GetFrame())); |
754 | 754 |
769 default: | 769 default: |
770 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | 770 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
771 } | 771 } |
772 | 772 |
773 orthanc_.GetBinaryAsync(uri, "image/png", | 773 orthanc_.GetBinaryAsync(uri, "image/png", |
774 new Callable<OrthancSlicesLoader, | 774 new OrthancStone::Callable<OrthancSlicesLoader, |
775 OrthancApiClient::BinaryResponseReadyMessage> | 775 OrthancApiClient::BinaryResponseReadyMessage> |
776 (*this, &OrthancSlicesLoader::ParseSliceImagePng), | 776 (*this, &OrthancSlicesLoader::ParseSliceImagePng), |
777 new Callable<OrthancSlicesLoader, | 777 new OrthancStone::Callable<OrthancSlicesLoader, |
778 IWebService::HttpRequestErrorMessage> | 778 IWebService::HttpRequestErrorMessage> |
779 (*this, &OrthancSlicesLoader::OnSliceImageError), | 779 (*this, &OrthancSlicesLoader::OnSliceImageError), |
780 Operation::DownloadSliceImage( | 780 Operation::DownloadSliceImage( |
781 static_cast<unsigned int>(index), slice, SliceImageQuality_FullPng)); | 781 static_cast<unsigned int>(index), slice, OrthancStone::SliceImageQuality_FullPng)); |
782 } | 782 } |
783 | 783 |
784 void OrthancSlicesLoader::ScheduleSliceImagePam(const Deprecated::Slice& slice, | 784 void OrthancSlicesLoader::ScheduleSliceImagePam(const Slice& slice, |
785 size_t index) | 785 size_t index) |
786 { | 786 { |
787 std::string uri = | 787 std::string uri = |
788 ("/instances/" + slice.GetOrthancInstanceId() + "/frames/" + | 788 ("/instances/" + slice.GetOrthancInstanceId() + "/frames/" + |
789 boost::lexical_cast<std::string>(slice.GetFrame())); | 789 boost::lexical_cast<std::string>(slice.GetFrame())); |
805 default: | 805 default: |
806 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | 806 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
807 } | 807 } |
808 | 808 |
809 orthanc_.GetBinaryAsync(uri, "image/x-portable-arbitrarymap", | 809 orthanc_.GetBinaryAsync(uri, "image/x-portable-arbitrarymap", |
810 new Callable<OrthancSlicesLoader, | 810 new OrthancStone::Callable<OrthancSlicesLoader, |
811 OrthancApiClient::BinaryResponseReadyMessage> | 811 OrthancApiClient::BinaryResponseReadyMessage> |
812 (*this, &OrthancSlicesLoader::ParseSliceImagePam), | 812 (*this, &OrthancSlicesLoader::ParseSliceImagePam), |
813 new Callable<OrthancSlicesLoader, | 813 new OrthancStone::Callable<OrthancSlicesLoader, |
814 IWebService::HttpRequestErrorMessage> | 814 IWebService::HttpRequestErrorMessage> |
815 (*this, &OrthancSlicesLoader::OnSliceImageError), | 815 (*this, &OrthancSlicesLoader::OnSliceImageError), |
816 Operation::DownloadSliceImage(static_cast<unsigned int>(index), | 816 Operation::DownloadSliceImage(static_cast<unsigned int>(index), |
817 slice, SliceImageQuality_FullPam)); | 817 slice, OrthancStone::SliceImageQuality_FullPam)); |
818 } | 818 } |
819 | 819 |
820 | 820 |
821 | 821 |
822 void OrthancSlicesLoader::ScheduleSliceImageJpeg(const Deprecated::Slice& slice, | 822 void OrthancSlicesLoader::ScheduleSliceImageJpeg(const Slice& slice, |
823 size_t index, | 823 size_t index, |
824 SliceImageQuality quality) | 824 OrthancStone::SliceImageQuality quality) |
825 { | 825 { |
826 unsigned int value; | 826 unsigned int value; |
827 | 827 |
828 switch (quality) | 828 switch (quality) |
829 { | 829 { |
830 case SliceImageQuality_Jpeg50: | 830 case OrthancStone::SliceImageQuality_Jpeg50: |
831 value = 50; | 831 value = 50; |
832 break; | 832 break; |
833 | 833 |
834 case SliceImageQuality_Jpeg90: | 834 case OrthancStone::SliceImageQuality_Jpeg90: |
835 value = 90; | 835 value = 90; |
836 break; | 836 break; |
837 | 837 |
838 case SliceImageQuality_Jpeg95: | 838 case OrthancStone::SliceImageQuality_Jpeg95: |
839 value = 95; | 839 value = 95; |
840 break; | 840 break; |
841 | 841 |
842 default: | 842 default: |
843 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | 843 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
848 boost::lexical_cast<std::string>(value) + | 848 boost::lexical_cast<std::string>(value) + |
849 "-" + slice.GetOrthancInstanceId() + "_" + | 849 "-" + slice.GetOrthancInstanceId() + "_" + |
850 boost::lexical_cast<std::string>(slice.GetFrame())); | 850 boost::lexical_cast<std::string>(slice.GetFrame())); |
851 | 851 |
852 orthanc_.GetJsonAsync(uri, | 852 orthanc_.GetJsonAsync(uri, |
853 new Callable<OrthancSlicesLoader, | 853 new OrthancStone::Callable<OrthancSlicesLoader, |
854 OrthancApiClient::JsonResponseReadyMessage> | 854 OrthancApiClient::JsonResponseReadyMessage> |
855 (*this, &OrthancSlicesLoader::ParseSliceImageJpeg), | 855 (*this, &OrthancSlicesLoader::ParseSliceImageJpeg), |
856 new Callable<OrthancSlicesLoader, | 856 new OrthancStone::Callable<OrthancSlicesLoader, |
857 IWebService::HttpRequestErrorMessage> | 857 IWebService::HttpRequestErrorMessage> |
858 (*this, &OrthancSlicesLoader::OnSliceImageError), | 858 (*this, &OrthancSlicesLoader::OnSliceImageError), |
859 Operation::DownloadSliceImage( | 859 Operation::DownloadSliceImage( |
860 static_cast<unsigned int>(index), slice, quality)); | 860 static_cast<unsigned int>(index), slice, quality)); |
861 } | 861 } |
862 | 862 |
863 | 863 |
864 | 864 |
865 void OrthancSlicesLoader::ScheduleLoadSliceImage(size_t index, | 865 void OrthancSlicesLoader::ScheduleLoadSliceImage(size_t index, |
866 SliceImageQuality quality) | 866 OrthancStone::SliceImageQuality quality) |
867 { | 867 { |
868 if (state_ != State_GeometryReady) | 868 if (state_ != State_GeometryReady) |
869 { | 869 { |
870 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | 870 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
871 } | 871 } |
872 | 872 |
873 const Deprecated::Slice& slice = GetSlice(index); | 873 const Slice& slice = GetSlice(index); |
874 | 874 |
875 if (slice.HasOrthancDecoding()) | 875 if (slice.HasOrthancDecoding()) |
876 { | 876 { |
877 switch (quality) | 877 switch (quality) |
878 { | 878 { |
879 case SliceImageQuality_FullPng: | 879 case OrthancStone::SliceImageQuality_FullPng: |
880 ScheduleSliceImagePng(slice, index); | 880 ScheduleSliceImagePng(slice, index); |
881 break; | 881 break; |
882 case SliceImageQuality_FullPam: | 882 case OrthancStone::SliceImageQuality_FullPam: |
883 ScheduleSliceImagePam(slice, index); | 883 ScheduleSliceImagePam(slice, index); |
884 break; | 884 break; |
885 default: | 885 default: |
886 ScheduleSliceImageJpeg(slice, index, quality); | 886 ScheduleSliceImageJpeg(slice, index, quality); |
887 } | 887 } |
889 else | 889 else |
890 { | 890 { |
891 std::string uri = ("/instances/" + slice.GetOrthancInstanceId() + "/frames/" + | 891 std::string uri = ("/instances/" + slice.GetOrthancInstanceId() + "/frames/" + |
892 boost::lexical_cast<std::string>(slice.GetFrame()) + "/raw.gz"); | 892 boost::lexical_cast<std::string>(slice.GetFrame()) + "/raw.gz"); |
893 orthanc_.GetBinaryAsync(uri, IWebService::HttpHeaders(), | 893 orthanc_.GetBinaryAsync(uri, IWebService::HttpHeaders(), |
894 new Callable<OrthancSlicesLoader, | 894 new OrthancStone::Callable<OrthancSlicesLoader, |
895 OrthancApiClient::BinaryResponseReadyMessage> | 895 OrthancApiClient::BinaryResponseReadyMessage> |
896 (*this, &OrthancSlicesLoader::ParseSliceRawImage), | 896 (*this, &OrthancSlicesLoader::ParseSliceRawImage), |
897 new Callable<OrthancSlicesLoader, | 897 new OrthancStone::Callable<OrthancSlicesLoader, |
898 IWebService::HttpRequestErrorMessage> | 898 IWebService::HttpRequestErrorMessage> |
899 (*this, &OrthancSlicesLoader::OnSliceImageError), | 899 (*this, &OrthancSlicesLoader::OnSliceImageError), |
900 Operation::DownloadSliceRawImage( | 900 Operation::DownloadSliceRawImage( |
901 static_cast<unsigned int>(index), slice)); | 901 static_cast<unsigned int>(index), slice)); |
902 } | 902 } |