Mercurial > hg > orthanc-stone
comparison Framework/Deprecated/Toolbox/OrthancSlicesLoader.cpp @ 1066:b537002f83a9 broker
removing broker from deprecated classes
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 15 Oct 2019 15:39:39 +0200 |
parents | 4fe4b221a31f |
children | 04a95ee91327 |
comparison
equal
deleted
inserted
replaced
1065:9d42f89b8c3c | 1066:b537002f83a9 |
---|---|
637 } | 637 } |
638 | 638 |
639 } | 639 } |
640 | 640 |
641 | 641 |
642 OrthancSlicesLoader::OrthancSlicesLoader(OrthancStone::MessageBroker& broker, | 642 OrthancSlicesLoader::OrthancSlicesLoader(OrthancApiClient& orthanc) : |
643 OrthancApiClient& orthanc) : | |
644 OrthancStone::IObservable(broker), | |
645 OrthancStone::IObserver(broker), | |
646 orthanc_(orthanc), | 643 orthanc_(orthanc), |
647 state_(State_Initialization) | 644 state_(State_Initialization) |
648 { | 645 { |
649 } | 646 } |
650 | 647 |
657 } | 654 } |
658 else | 655 else |
659 { | 656 { |
660 state_ = State_LoadingGeometry; | 657 state_ = State_LoadingGeometry; |
661 orthanc_.GetJsonAsync("/series/" + seriesId + "/instances-tags", | 658 orthanc_.GetJsonAsync("/series/" + seriesId + "/instances-tags", |
662 new OrthancStone::Callable<OrthancSlicesLoader, OrthancApiClient::JsonResponseReadyMessage>(*this, &OrthancSlicesLoader::ParseSeriesGeometry), | 659 new OrthancStone::Callable<OrthancSlicesLoader, OrthancApiClient::JsonResponseReadyMessage>(GetSharedObserver(), &OrthancSlicesLoader::ParseSeriesGeometry), |
663 new OrthancStone::Callable<OrthancSlicesLoader, IWebService::HttpRequestErrorMessage>(*this, &OrthancSlicesLoader::OnGeometryError), | 660 new OrthancStone::Callable<OrthancSlicesLoader, IWebService::HttpRequestErrorMessage>(GetSharedObserver(), &OrthancSlicesLoader::OnGeometryError), |
664 NULL); | 661 NULL); |
665 } | 662 } |
666 } | 663 } |
667 | 664 |
668 void OrthancSlicesLoader::ScheduleLoadInstance(const std::string& instanceId) | 665 void OrthancSlicesLoader::ScheduleLoadInstance(const std::string& instanceId) |
676 state_ = State_LoadingGeometry; | 673 state_ = State_LoadingGeometry; |
677 | 674 |
678 // Tag "3004-000c" is "Grid Frame Offset Vector", which is | 675 // 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 | 676 // mandatory to read RT DOSE, but is too long to be returned by default |
680 orthanc_.GetJsonAsync("/instances/" + instanceId + "/tags?ignore-length=3004-000c", | 677 orthanc_.GetJsonAsync("/instances/" + instanceId + "/tags?ignore-length=3004-000c", |
681 new OrthancStone::Callable<OrthancSlicesLoader, OrthancApiClient::JsonResponseReadyMessage>(*this, &OrthancSlicesLoader::ParseInstanceGeometry), | 678 new OrthancStone::Callable<OrthancSlicesLoader, OrthancApiClient::JsonResponseReadyMessage>(GetSharedObserver(), &OrthancSlicesLoader::ParseInstanceGeometry), |
682 new OrthancStone::Callable<OrthancSlicesLoader, IWebService::HttpRequestErrorMessage>(*this, &OrthancSlicesLoader::OnGeometryError), | 679 new OrthancStone::Callable<OrthancSlicesLoader, IWebService::HttpRequestErrorMessage>(GetSharedObserver(), &OrthancSlicesLoader::OnGeometryError), |
683 Operation::DownloadInstanceGeometry(instanceId)); | 680 Operation::DownloadInstanceGeometry(instanceId)); |
684 } | 681 } |
685 } | 682 } |
686 | 683 |
687 | 684 |
695 else | 692 else |
696 { | 693 { |
697 state_ = State_LoadingGeometry; | 694 state_ = State_LoadingGeometry; |
698 | 695 |
699 orthanc_.GetJsonAsync("/instances/" + instanceId + "/tags", | 696 orthanc_.GetJsonAsync("/instances/" + instanceId + "/tags", |
700 new OrthancStone::Callable<OrthancSlicesLoader, OrthancApiClient::JsonResponseReadyMessage>(*this, &OrthancSlicesLoader::ParseFrameGeometry), | 697 new OrthancStone::Callable<OrthancSlicesLoader, OrthancApiClient::JsonResponseReadyMessage>(GetSharedObserver(), &OrthancSlicesLoader::ParseFrameGeometry), |
701 new OrthancStone::Callable<OrthancSlicesLoader, IWebService::HttpRequestErrorMessage>(*this, &OrthancSlicesLoader::OnGeometryError), | 698 new OrthancStone::Callable<OrthancSlicesLoader, IWebService::HttpRequestErrorMessage>(GetSharedObserver(), &OrthancSlicesLoader::OnGeometryError), |
702 Operation::DownloadFrameGeometry(instanceId, frame)); | 699 Operation::DownloadFrameGeometry(instanceId, frame)); |
703 } | 700 } |
704 } | 701 } |
705 | 702 |
706 | 703 |
769 default: | 766 default: |
770 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | 767 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
771 } | 768 } |
772 | 769 |
773 orthanc_.GetBinaryAsync(uri, "image/png", | 770 orthanc_.GetBinaryAsync(uri, "image/png", |
774 new OrthancStone::Callable<OrthancSlicesLoader, | 771 new OrthancStone::Callable<OrthancSlicesLoader, |
775 OrthancApiClient::BinaryResponseReadyMessage> | 772 OrthancApiClient::BinaryResponseReadyMessage> |
776 (*this, &OrthancSlicesLoader::ParseSliceImagePng), | 773 (GetSharedObserver(), &OrthancSlicesLoader::ParseSliceImagePng), |
777 new OrthancStone::Callable<OrthancSlicesLoader, | 774 new OrthancStone::Callable<OrthancSlicesLoader, |
778 IWebService::HttpRequestErrorMessage> | 775 IWebService::HttpRequestErrorMessage> |
779 (*this, &OrthancSlicesLoader::OnSliceImageError), | 776 (GetSharedObserver(), &OrthancSlicesLoader::OnSliceImageError), |
780 Operation::DownloadSliceImage( | 777 Operation::DownloadSliceImage( |
781 static_cast<unsigned int>(index), slice, SliceImageQuality_FullPng)); | 778 static_cast<unsigned int>(index), slice, SliceImageQuality_FullPng)); |
782 } | 779 } |
783 | 780 |
784 void OrthancSlicesLoader::ScheduleSliceImagePam(const Slice& slice, | 781 void OrthancSlicesLoader::ScheduleSliceImagePam(const Slice& slice, |
785 size_t index) | 782 size_t index) |
786 { | 783 { |
787 std::string uri = | 784 std::string uri = |
788 ("/instances/" + slice.GetOrthancInstanceId() + "/frames/" + | 785 ("/instances/" + slice.GetOrthancInstanceId() + "/frames/" + |
789 boost::lexical_cast<std::string>(slice.GetFrame())); | 786 boost::lexical_cast<std::string>(slice.GetFrame())); |
790 | 787 |
791 switch (slice.GetConverter().GetExpectedPixelFormat()) | 788 switch (slice.GetConverter().GetExpectedPixelFormat()) |
792 { | 789 { |
793 case Orthanc::PixelFormat_RGB24: | 790 case Orthanc::PixelFormat_RGB24: |
794 uri += "/preview"; | 791 uri += "/preview"; |
805 default: | 802 default: |
806 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | 803 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
807 } | 804 } |
808 | 805 |
809 orthanc_.GetBinaryAsync(uri, "image/x-portable-arbitrarymap", | 806 orthanc_.GetBinaryAsync(uri, "image/x-portable-arbitrarymap", |
810 new OrthancStone::Callable<OrthancSlicesLoader, | 807 new OrthancStone::Callable<OrthancSlicesLoader, |
811 OrthancApiClient::BinaryResponseReadyMessage> | 808 OrthancApiClient::BinaryResponseReadyMessage> |
812 (*this, &OrthancSlicesLoader::ParseSliceImagePam), | 809 (GetSharedObserver(), &OrthancSlicesLoader::ParseSliceImagePam), |
813 new OrthancStone::Callable<OrthancSlicesLoader, | 810 new OrthancStone::Callable<OrthancSlicesLoader, |
814 IWebService::HttpRequestErrorMessage> | 811 IWebService::HttpRequestErrorMessage> |
815 (*this, &OrthancSlicesLoader::OnSliceImageError), | 812 (GetSharedObserver(), &OrthancSlicesLoader::OnSliceImageError), |
816 Operation::DownloadSliceImage(static_cast<unsigned int>(index), | 813 Operation::DownloadSliceImage(static_cast<unsigned int>(index), |
817 slice, SliceImageQuality_FullPam)); | 814 slice, SliceImageQuality_FullPam)); |
818 } | 815 } |
819 | 816 |
820 | 817 |
821 | 818 |
822 void OrthancSlicesLoader::ScheduleSliceImageJpeg(const Slice& slice, | 819 void OrthancSlicesLoader::ScheduleSliceImageJpeg(const Slice& slice, |
848 boost::lexical_cast<std::string>(value) + | 845 boost::lexical_cast<std::string>(value) + |
849 "-" + slice.GetOrthancInstanceId() + "_" + | 846 "-" + slice.GetOrthancInstanceId() + "_" + |
850 boost::lexical_cast<std::string>(slice.GetFrame())); | 847 boost::lexical_cast<std::string>(slice.GetFrame())); |
851 | 848 |
852 orthanc_.GetJsonAsync(uri, | 849 orthanc_.GetJsonAsync(uri, |
853 new OrthancStone::Callable<OrthancSlicesLoader, | 850 new OrthancStone::Callable<OrthancSlicesLoader, |
854 OrthancApiClient::JsonResponseReadyMessage> | 851 OrthancApiClient::JsonResponseReadyMessage> |
855 (*this, &OrthancSlicesLoader::ParseSliceImageJpeg), | 852 (GetSharedObserver(), &OrthancSlicesLoader::ParseSliceImageJpeg), |
856 new OrthancStone::Callable<OrthancSlicesLoader, | 853 new OrthancStone::Callable<OrthancSlicesLoader, |
857 IWebService::HttpRequestErrorMessage> | 854 IWebService::HttpRequestErrorMessage> |
858 (*this, &OrthancSlicesLoader::OnSliceImageError), | 855 (GetSharedObserver(), &OrthancSlicesLoader::OnSliceImageError), |
859 Operation::DownloadSliceImage( | 856 Operation::DownloadSliceImage( |
860 static_cast<unsigned int>(index), slice, quality)); | 857 static_cast<unsigned int>(index), slice, quality)); |
861 } | 858 } |
862 | 859 |
863 | 860 |
864 | 861 |
865 void OrthancSlicesLoader::ScheduleLoadSliceImage(size_t index, | 862 void OrthancSlicesLoader::ScheduleLoadSliceImage(size_t index, |
889 else | 886 else |
890 { | 887 { |
891 std::string uri = ("/instances/" + slice.GetOrthancInstanceId() + "/frames/" + | 888 std::string uri = ("/instances/" + slice.GetOrthancInstanceId() + "/frames/" + |
892 boost::lexical_cast<std::string>(slice.GetFrame()) + "/raw.gz"); | 889 boost::lexical_cast<std::string>(slice.GetFrame()) + "/raw.gz"); |
893 orthanc_.GetBinaryAsync(uri, IWebService::HttpHeaders(), | 890 orthanc_.GetBinaryAsync(uri, IWebService::HttpHeaders(), |
894 new OrthancStone::Callable<OrthancSlicesLoader, | 891 new OrthancStone::Callable<OrthancSlicesLoader, |
895 OrthancApiClient::BinaryResponseReadyMessage> | 892 OrthancApiClient::BinaryResponseReadyMessage> |
896 (*this, &OrthancSlicesLoader::ParseSliceRawImage), | 893 (GetSharedObserver(), &OrthancSlicesLoader::ParseSliceRawImage), |
897 new OrthancStone::Callable<OrthancSlicesLoader, | 894 new OrthancStone::Callable<OrthancSlicesLoader, |
898 IWebService::HttpRequestErrorMessage> | 895 IWebService::HttpRequestErrorMessage> |
899 (*this, &OrthancSlicesLoader::OnSliceImageError), | 896 (GetSharedObserver(), &OrthancSlicesLoader::OnSliceImageError), |
900 Operation::DownloadSliceRawImage( | 897 Operation::DownloadSliceRawImage( |
901 static_cast<unsigned int>(index), slice)); | 898 static_cast<unsigned int>(index), slice)); |
902 } | 899 } |
903 } | 900 } |
904 } | 901 } |