comparison Framework/Radiography/RadiographyScene.cpp @ 417:aee3d7941c9b

preparing to load images using DICOMweb
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 15 Nov 2018 17:28:15 +0100
parents 71c16998fcc8
children c23df8b3433b
comparison
equal deleted inserted replaced
415:c0589c3173fd 417:aee3d7941c9b
421 421
422 return *layer; 422 return *layer;
423 } 423 }
424 424
425 425
426 RadiographyScene::RadiographyScene(MessageBroker& broker, 426 RadiographyScene::RadiographyScene(MessageBroker& broker) :
427 OrthancApiClient& orthanc) :
428 IObserver(broker), 427 IObserver(broker),
429 IObservable(broker), 428 IObservable(broker),
430 orthanc_(orthanc),
431 countLayers_(0), 429 countLayers_(0),
432 hasWindowing_(false), 430 hasWindowing_(false),
433 windowingCenter_(0), // Dummy initialization 431 windowingCenter_(0), // Dummy initialization
434 windowingWidth_(0) // Dummy initialization 432 windowingWidth_(0) // Dummy initialization
435 { 433 {
521 519
522 return RegisterLayer(alpha.release()); 520 return RegisterLayer(alpha.release());
523 } 521 }
524 522
525 523
526 RadiographyLayer& RadiographyScene::LoadDicomFrame(const std::string& instance, 524 RadiographyLayer& RadiographyScene::LoadDicomFrame(OrthancApiClient& orthanc,
525 const std::string& instance,
527 unsigned int frame, 526 unsigned int frame,
528 bool httpCompression) 527 bool httpCompression)
529 { 528 {
530 RadiographyLayer& layer = RegisterLayer(new DicomLayer); 529 RadiographyLayer& layer = RegisterLayer(new DicomLayer);
531 530
532 { 531 {
533 IWebService::Headers headers; 532 IWebService::HttpHeaders headers;
534 std::string uri = "/instances/" + instance + "/tags"; 533 std::string uri = "/instances/" + instance + "/tags";
535 534
536 orthanc_.GetBinaryAsync( 535 orthanc.GetBinaryAsync(
537 uri, headers, 536 uri, headers,
538 new Callable<RadiographyScene, OrthancApiClient::BinaryResponseReadyMessage> 537 new Callable<RadiographyScene, OrthancApiClient::BinaryResponseReadyMessage>
539 (*this, &RadiographyScene::OnTagsReceived), NULL, 538 (*this, &RadiographyScene::OnTagsReceived), NULL,
540 new Orthanc::SingleValueObject<size_t>(layer.GetIndex())); 539 new Orthanc::SingleValueObject<size_t>(layer.GetIndex()));
541 } 540 }
542 541
543 { 542 {
544 IWebService::Headers headers; 543 IWebService::HttpHeaders headers;
545 headers["Accept"] = "image/x-portable-arbitrarymap"; 544 headers["Accept"] = "image/x-portable-arbitrarymap";
546 545
547 if (httpCompression) 546 if (httpCompression)
548 { 547 {
549 headers["Accept-Encoding"] = "gzip"; 548 headers["Accept-Encoding"] = "gzip";
550 } 549 }
551 550
552 std::string uri = ("/instances/" + instance + "/frames/" + 551 std::string uri = ("/instances/" + instance + "/frames/" +
553 boost::lexical_cast<std::string>(frame) + "/image-uint16"); 552 boost::lexical_cast<std::string>(frame) + "/image-uint16");
554 553
555 orthanc_.GetBinaryAsync( 554 orthanc.GetBinaryAsync(
556 uri, headers, 555 uri, headers,
557 new Callable<RadiographyScene, OrthancApiClient::BinaryResponseReadyMessage> 556 new Callable<RadiographyScene, OrthancApiClient::BinaryResponseReadyMessage>
558 (*this, &RadiographyScene::OnFrameReceived), NULL, 557 (*this, &RadiographyScene::OnFrameReceived), NULL,
559 new Orthanc::SingleValueObject<size_t>(layer.GetIndex())); 558 new Orthanc::SingleValueObject<size_t>(layer.GetIndex()));
560 } 559 }
561 560
562 return layer; 561 return layer;
563 } 562 }
563
564
565 RadiographyLayer& RadiographyScene::LoadDicomWebFrame(IWebService& web)
566 {
567 RadiographyLayer& layer = RegisterLayer(new DicomLayer);
568
569
570 return layer;
571 }
572
564 573
565 574
566 void RadiographyScene::OnTagsReceived(const OrthancApiClient::BinaryResponseReadyMessage& message) 575 void RadiographyScene::OnTagsReceived(const OrthancApiClient::BinaryResponseReadyMessage& message)
567 { 576 {
568 size_t index = dynamic_cast<const Orthanc::SingleValueObject<size_t>&> 577 size_t index = dynamic_cast<const Orthanc::SingleValueObject<size_t>&>
726 } 735 }
727 736
728 737
729 // Export using PAM is faster than using PNG, but requires Orthanc 738 // Export using PAM is faster than using PNG, but requires Orthanc
730 // core >= 1.4.3 739 // core >= 1.4.3
731 void RadiographyScene::ExportDicom(const Orthanc::DicomMap& dicom, 740 void RadiographyScene::ExportDicom(OrthancApiClient& orthanc,
741 const Orthanc::DicomMap& dicom,
732 double pixelSpacingX, 742 double pixelSpacingX,
733 double pixelSpacingY, 743 double pixelSpacingY,
734 bool invert, 744 bool invert,
735 ImageInterpolation interpolation, 745 ImageInterpolation interpolation,
736 bool usePam) 746 bool usePam)
828 // This is Data URI scheme: https://en.wikipedia.org/wiki/Data_URI_scheme 838 // This is Data URI scheme: https://en.wikipedia.org/wiki/Data_URI_scheme
829 json["Content"] = ("data:" + 839 json["Content"] = ("data:" +
830 std::string(usePam ? Orthanc::MIME_PAM : Orthanc::MIME_PNG) + 840 std::string(usePam ? Orthanc::MIME_PAM : Orthanc::MIME_PNG) +
831 ";base64," + base64); 841 ";base64," + base64);
832 842
833 orthanc_.PostJsonAsyncExpectJson( 843 orthanc.PostJsonAsyncExpectJson(
834 "/tools/create-dicom", json, 844 "/tools/create-dicom", json,
835 new Callable<RadiographyScene, OrthancApiClient::JsonResponseReadyMessage> 845 new Callable<RadiographyScene, OrthancApiClient::JsonResponseReadyMessage>
836 (*this, &RadiographyScene::OnDicomExported), 846 (*this, &RadiographyScene::OnDicomExported),
837 NULL, NULL); 847 NULL, NULL);
838 } 848 }
839 849
840 850
841 void RadiographyScene::OnDicomExported(const OrthancApiClient::JsonResponseReadyMessage& message) 851 void RadiographyScene::OnDicomExported(const OrthancApiClient::JsonResponseReadyMessage& message)
842 { 852 {
843 LOG(INFO) << "DICOM export was successful:" 853 LOG(INFO) << "DICOM export was successful: "
844 << message.GetJson().toStyledString(); 854 << message.GetJson().toStyledString();
845 } 855 }
856
857
858 void RadiographyScene::OnDicomWebReceived(const IWebService::HttpRequestSuccessMessage& message)
859 {
860 LOG(INFO) << "DICOMweb WADO-RS received: " << message.GetAnswerSize() << " bytes";
861 }
862
846 } 863 }