Mercurial > hg > orthanc-stone
comparison Framework/Deprecated/Toolbox/OrthancSlicesLoader.cpp @ 1068:04a95ee91327 broker
recovery of OrthancStoneSingleFrame
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 15 Oct 2019 19:36:57 +0200 |
parents | b537002f83a9 |
children | 21c2b0eee53c |
comparison
equal
deleted
inserted
replaced
1067:05b2e71ed145 | 1068:04a95ee91327 |
---|---|
637 } | 637 } |
638 | 638 |
639 } | 639 } |
640 | 640 |
641 | 641 |
642 OrthancSlicesLoader::OrthancSlicesLoader(OrthancApiClient& orthanc) : | 642 OrthancSlicesLoader::OrthancSlicesLoader(boost::shared_ptr<OrthancApiClient> orthanc) : |
643 orthanc_(orthanc), | 643 orthanc_(orthanc), |
644 state_(State_Initialization) | 644 state_(State_Initialization) |
645 { | 645 { |
646 } | 646 } |
647 | 647 |
653 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | 653 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
654 } | 654 } |
655 else | 655 else |
656 { | 656 { |
657 state_ = State_LoadingGeometry; | 657 state_ = State_LoadingGeometry; |
658 orthanc_.GetJsonAsync("/series/" + seriesId + "/instances-tags", | 658 orthanc_->GetJsonAsync("/series/" + seriesId + "/instances-tags", |
659 new OrthancStone::Callable<OrthancSlicesLoader, OrthancApiClient::JsonResponseReadyMessage>(GetSharedObserver(), &OrthancSlicesLoader::ParseSeriesGeometry), | 659 new OrthancStone::Callable<OrthancSlicesLoader, OrthancApiClient::JsonResponseReadyMessage>(GetSharedObserver(), &OrthancSlicesLoader::ParseSeriesGeometry), |
660 new OrthancStone::Callable<OrthancSlicesLoader, IWebService::HttpRequestErrorMessage>(GetSharedObserver(), &OrthancSlicesLoader::OnGeometryError), | 660 new OrthancStone::Callable<OrthancSlicesLoader, IWebService::HttpRequestErrorMessage>(GetSharedObserver(), &OrthancSlicesLoader::OnGeometryError), |
661 NULL); | 661 NULL); |
662 } | 662 } |
663 } | 663 } |
664 | 664 |
665 void OrthancSlicesLoader::ScheduleLoadInstance(const std::string& instanceId) | 665 void OrthancSlicesLoader::ScheduleLoadInstance(const std::string& instanceId) |
666 { | 666 { |
672 { | 672 { |
673 state_ = State_LoadingGeometry; | 673 state_ = State_LoadingGeometry; |
674 | 674 |
675 // Tag "3004-000c" is "Grid Frame Offset Vector", which is | 675 // Tag "3004-000c" is "Grid Frame Offset Vector", which is |
676 // mandatory to read RT DOSE, but is too long to be returned by default | 676 // mandatory to read RT DOSE, but is too long to be returned by default |
677 orthanc_.GetJsonAsync("/instances/" + instanceId + "/tags?ignore-length=3004-000c", | 677 orthanc_->GetJsonAsync("/instances/" + instanceId + "/tags?ignore-length=3004-000c", |
678 new OrthancStone::Callable<OrthancSlicesLoader, OrthancApiClient::JsonResponseReadyMessage>(GetSharedObserver(), &OrthancSlicesLoader::ParseInstanceGeometry), | 678 new OrthancStone::Callable<OrthancSlicesLoader, OrthancApiClient::JsonResponseReadyMessage>(GetSharedObserver(), &OrthancSlicesLoader::ParseInstanceGeometry), |
679 new OrthancStone::Callable<OrthancSlicesLoader, IWebService::HttpRequestErrorMessage>(GetSharedObserver(), &OrthancSlicesLoader::OnGeometryError), | 679 new OrthancStone::Callable<OrthancSlicesLoader, IWebService::HttpRequestErrorMessage>(GetSharedObserver(), &OrthancSlicesLoader::OnGeometryError), |
680 Operation::DownloadInstanceGeometry(instanceId)); | 680 Operation::DownloadInstanceGeometry(instanceId)); |
681 } | 681 } |
682 } | 682 } |
683 | 683 |
684 | 684 |
685 void OrthancSlicesLoader::ScheduleLoadFrame(const std::string& instanceId, | 685 void OrthancSlicesLoader::ScheduleLoadFrame(const std::string& instanceId, |
691 } | 691 } |
692 else | 692 else |
693 { | 693 { |
694 state_ = State_LoadingGeometry; | 694 state_ = State_LoadingGeometry; |
695 | 695 |
696 orthanc_.GetJsonAsync("/instances/" + instanceId + "/tags", | 696 orthanc_->GetJsonAsync("/instances/" + instanceId + "/tags", |
697 new OrthancStone::Callable<OrthancSlicesLoader, OrthancApiClient::JsonResponseReadyMessage>(GetSharedObserver(), &OrthancSlicesLoader::ParseFrameGeometry), | 697 new OrthancStone::Callable<OrthancSlicesLoader, OrthancApiClient::JsonResponseReadyMessage>(GetSharedObserver(), &OrthancSlicesLoader::ParseFrameGeometry), |
698 new OrthancStone::Callable<OrthancSlicesLoader, IWebService::HttpRequestErrorMessage>(GetSharedObserver(), &OrthancSlicesLoader::OnGeometryError), | 698 new OrthancStone::Callable<OrthancSlicesLoader, IWebService::HttpRequestErrorMessage>(GetSharedObserver(), &OrthancSlicesLoader::OnGeometryError), |
699 Operation::DownloadFrameGeometry(instanceId, frame)); | 699 Operation::DownloadFrameGeometry(instanceId, frame)); |
700 } | 700 } |
701 } | 701 } |
702 | 702 |
703 | 703 |
704 bool OrthancSlicesLoader::IsGeometryReady() const | 704 bool OrthancSlicesLoader::IsGeometryReady() const |
765 | 765 |
766 default: | 766 default: |
767 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | 767 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
768 } | 768 } |
769 | 769 |
770 orthanc_.GetBinaryAsync(uri, "image/png", | 770 orthanc_->GetBinaryAsync(uri, "image/png", |
771 new OrthancStone::Callable<OrthancSlicesLoader, | 771 new OrthancStone::Callable<OrthancSlicesLoader, |
772 OrthancApiClient::BinaryResponseReadyMessage> | 772 OrthancApiClient::BinaryResponseReadyMessage> |
773 (GetSharedObserver(), &OrthancSlicesLoader::ParseSliceImagePng), | 773 (GetSharedObserver(), &OrthancSlicesLoader::ParseSliceImagePng), |
774 new OrthancStone::Callable<OrthancSlicesLoader, | 774 new OrthancStone::Callable<OrthancSlicesLoader, |
775 IWebService::HttpRequestErrorMessage> | 775 IWebService::HttpRequestErrorMessage> |
776 (GetSharedObserver(), &OrthancSlicesLoader::OnSliceImageError), | 776 (GetSharedObserver(), &OrthancSlicesLoader::OnSliceImageError), |
777 Operation::DownloadSliceImage( | 777 Operation::DownloadSliceImage( |
778 static_cast<unsigned int>(index), slice, SliceImageQuality_FullPng)); | 778 static_cast<unsigned int>(index), slice, SliceImageQuality_FullPng)); |
779 } | 779 } |
780 | 780 |
781 void OrthancSlicesLoader::ScheduleSliceImagePam(const Slice& slice, | 781 void OrthancSlicesLoader::ScheduleSliceImagePam(const Slice& slice, |
782 size_t index) | 782 size_t index) |
783 { | 783 { |
801 | 801 |
802 default: | 802 default: |
803 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | 803 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
804 } | 804 } |
805 | 805 |
806 orthanc_.GetBinaryAsync(uri, "image/x-portable-arbitrarymap", | 806 orthanc_->GetBinaryAsync(uri, "image/x-portable-arbitrarymap", |
807 new OrthancStone::Callable<OrthancSlicesLoader, | 807 new OrthancStone::Callable<OrthancSlicesLoader, |
808 OrthancApiClient::BinaryResponseReadyMessage> | 808 OrthancApiClient::BinaryResponseReadyMessage> |
809 (GetSharedObserver(), &OrthancSlicesLoader::ParseSliceImagePam), | 809 (GetSharedObserver(), &OrthancSlicesLoader::ParseSliceImagePam), |
810 new OrthancStone::Callable<OrthancSlicesLoader, | 810 new OrthancStone::Callable<OrthancSlicesLoader, |
811 IWebService::HttpRequestErrorMessage> | 811 IWebService::HttpRequestErrorMessage> |
812 (GetSharedObserver(), &OrthancSlicesLoader::OnSliceImageError), | 812 (GetSharedObserver(), &OrthancSlicesLoader::OnSliceImageError), |
813 Operation::DownloadSliceImage(static_cast<unsigned int>(index), | 813 Operation::DownloadSliceImage(static_cast<unsigned int>(index), |
814 slice, SliceImageQuality_FullPam)); | 814 slice, SliceImageQuality_FullPam)); |
815 } | 815 } |
816 | 816 |
817 | 817 |
818 | 818 |
819 void OrthancSlicesLoader::ScheduleSliceImageJpeg(const Slice& slice, | 819 void OrthancSlicesLoader::ScheduleSliceImageJpeg(const Slice& slice, |
844 std::string uri = ("/web-viewer/instances/jpeg" + | 844 std::string uri = ("/web-viewer/instances/jpeg" + |
845 boost::lexical_cast<std::string>(value) + | 845 boost::lexical_cast<std::string>(value) + |
846 "-" + slice.GetOrthancInstanceId() + "_" + | 846 "-" + slice.GetOrthancInstanceId() + "_" + |
847 boost::lexical_cast<std::string>(slice.GetFrame())); | 847 boost::lexical_cast<std::string>(slice.GetFrame())); |
848 | 848 |
849 orthanc_.GetJsonAsync(uri, | 849 orthanc_->GetJsonAsync(uri, |
850 new OrthancStone::Callable<OrthancSlicesLoader, | 850 new OrthancStone::Callable<OrthancSlicesLoader, |
851 OrthancApiClient::JsonResponseReadyMessage> | 851 OrthancApiClient::JsonResponseReadyMessage> |
852 (GetSharedObserver(), &OrthancSlicesLoader::ParseSliceImageJpeg), | 852 (GetSharedObserver(), &OrthancSlicesLoader::ParseSliceImageJpeg), |
853 new OrthancStone::Callable<OrthancSlicesLoader, | 853 new OrthancStone::Callable<OrthancSlicesLoader, |
854 IWebService::HttpRequestErrorMessage> | 854 IWebService::HttpRequestErrorMessage> |
855 (GetSharedObserver(), &OrthancSlicesLoader::OnSliceImageError), | 855 (GetSharedObserver(), &OrthancSlicesLoader::OnSliceImageError), |
856 Operation::DownloadSliceImage( | 856 Operation::DownloadSliceImage( |
857 static_cast<unsigned int>(index), slice, quality)); | 857 static_cast<unsigned int>(index), slice, quality)); |
858 } | 858 } |
859 | 859 |
860 | 860 |
861 | 861 |
862 void OrthancSlicesLoader::ScheduleLoadSliceImage(size_t index, | 862 void OrthancSlicesLoader::ScheduleLoadSliceImage(size_t index, |
885 } | 885 } |
886 else | 886 else |
887 { | 887 { |
888 std::string uri = ("/instances/" + slice.GetOrthancInstanceId() + "/frames/" + | 888 std::string uri = ("/instances/" + slice.GetOrthancInstanceId() + "/frames/" + |
889 boost::lexical_cast<std::string>(slice.GetFrame()) + "/raw.gz"); | 889 boost::lexical_cast<std::string>(slice.GetFrame()) + "/raw.gz"); |
890 orthanc_.GetBinaryAsync(uri, IWebService::HttpHeaders(), | 890 orthanc_->GetBinaryAsync(uri, IWebService::HttpHeaders(), |
891 new OrthancStone::Callable<OrthancSlicesLoader, | 891 new OrthancStone::Callable<OrthancSlicesLoader, |
892 OrthancApiClient::BinaryResponseReadyMessage> | 892 OrthancApiClient::BinaryResponseReadyMessage> |
893 (GetSharedObserver(), &OrthancSlicesLoader::ParseSliceRawImage), | 893 (GetSharedObserver(), &OrthancSlicesLoader::ParseSliceRawImage), |
894 new OrthancStone::Callable<OrthancSlicesLoader, | 894 new OrthancStone::Callable<OrthancSlicesLoader, |
895 IWebService::HttpRequestErrorMessage> | 895 IWebService::HttpRequestErrorMessage> |
896 (GetSharedObserver(), &OrthancSlicesLoader::OnSliceImageError), | 896 (GetSharedObserver(), &OrthancSlicesLoader::OnSliceImageError), |
897 Operation::DownloadSliceRawImage( | 897 Operation::DownloadSliceRawImage( |
898 static_cast<unsigned int>(index), slice)); | 898 static_cast<unsigned int>(index), slice)); |
899 } | 899 } |
900 } | 900 } |
901 } | 901 } |