comparison Framework/Radiography/RadiographyScene.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 c35e98d22764
comparison
equal deleted inserted replaced
714:d2c0e347ddc2 726:4f2416d519b4
362 layer.SetPreferredPhotomotricDisplayMode(preferredPhotometricDisplayMode); 362 layer.SetPreferredPhotomotricDisplayMode(preferredPhotometricDisplayMode);
363 363
364 return layer; 364 return layer;
365 } 365 }
366 366
367 RadiographyLayer& RadiographyScene::LoadDicomFrame(OrthancApiClient& orthanc, 367 RadiographyLayer& RadiographyScene::LoadDicomFrame(Deprecated::OrthancApiClient& orthanc,
368 const std::string& instance, 368 const std::string& instance,
369 unsigned int frame, 369 unsigned int frame,
370 bool httpCompression, 370 bool httpCompression,
371 RadiographyLayer::Geometry* geometry) 371 RadiographyLayer::Geometry* geometry)
372 { 372 {
377 { 377 {
378 layer.SetGeometry(*geometry); 378 layer.SetGeometry(*geometry);
379 } 379 }
380 380
381 { 381 {
382 IWebService::HttpHeaders headers; 382 Deprecated::IWebService::HttpHeaders headers;
383 std::string uri = "/instances/" + instance + "/tags"; 383 std::string uri = "/instances/" + instance + "/tags";
384 384
385 orthanc.GetBinaryAsync( 385 orthanc.GetBinaryAsync(
386 uri, headers, 386 uri, headers,
387 new Callable<RadiographyScene, OrthancApiClient::BinaryResponseReadyMessage> 387 new Callable<RadiographyScene, Deprecated::OrthancApiClient::BinaryResponseReadyMessage>
388 (*this, &RadiographyScene::OnTagsReceived), NULL, 388 (*this, &RadiographyScene::OnTagsReceived), NULL,
389 new Orthanc::SingleValueObject<size_t>(layer.GetIndex())); 389 new Orthanc::SingleValueObject<size_t>(layer.GetIndex()));
390 } 390 }
391 391
392 { 392 {
393 IWebService::HttpHeaders headers; 393 Deprecated::IWebService::HttpHeaders headers;
394 headers["Accept"] = "image/x-portable-arbitrarymap"; 394 headers["Accept"] = "image/x-portable-arbitrarymap";
395 395
396 if (httpCompression) 396 if (httpCompression)
397 { 397 {
398 headers["Accept-Encoding"] = "gzip"; 398 headers["Accept-Encoding"] = "gzip";
401 std::string uri = ("/instances/" + instance + "/frames/" + 401 std::string uri = ("/instances/" + instance + "/frames/" +
402 boost::lexical_cast<std::string>(frame) + "/image-uint16"); 402 boost::lexical_cast<std::string>(frame) + "/image-uint16");
403 403
404 orthanc.GetBinaryAsync( 404 orthanc.GetBinaryAsync(
405 uri, headers, 405 uri, headers,
406 new Callable<RadiographyScene, OrthancApiClient::BinaryResponseReadyMessage> 406 new Callable<RadiographyScene, Deprecated::OrthancApiClient::BinaryResponseReadyMessage>
407 (*this, &RadiographyScene::OnFrameReceived), NULL, 407 (*this, &RadiographyScene::OnFrameReceived), NULL,
408 new Orthanc::SingleValueObject<size_t>(layer.GetIndex())); 408 new Orthanc::SingleValueObject<size_t>(layer.GetIndex()));
409 } 409 }
410 410
411 return layer; 411 return layer;
412 } 412 }
413 413
414 414
415 RadiographyLayer& RadiographyScene::LoadDicomWebFrame(IWebService& web) 415 RadiographyLayer& RadiographyScene::LoadDicomWebFrame(Deprecated::IWebService& web)
416 { 416 {
417 RadiographyLayer& layer = RegisterLayer(new RadiographyDicomLayer(IObservable::GetBroker(), *this)); 417 RadiographyLayer& layer = RegisterLayer(new RadiographyDicomLayer(IObservable::GetBroker(), *this));
418 418
419 419
420 return layer; 420 return layer;
421 } 421 }
422 422
423 423
424 424
425 void RadiographyScene::OnTagsReceived(const OrthancApiClient::BinaryResponseReadyMessage& message) 425 void RadiographyScene::OnTagsReceived(const Deprecated::OrthancApiClient::BinaryResponseReadyMessage& message)
426 { 426 {
427 size_t index = dynamic_cast<const Orthanc::SingleValueObject<size_t>&> 427 size_t index = dynamic_cast<const Orthanc::SingleValueObject<size_t>&>
428 (message.GetPayload()).GetValue(); 428 (message.GetPayload()).GetValue();
429 429
430 LOG(INFO) << "JSON received: " << message.GetUri().c_str() 430 LOG(INFO) << "JSON received: " << message.GetUri().c_str()
450 BroadcastMessage(GeometryChangedMessage(*this, *(layer->second))); 450 BroadcastMessage(GeometryChangedMessage(*this, *(layer->second)));
451 } 451 }
452 } 452 }
453 453
454 454
455 void RadiographyScene::OnFrameReceived(const OrthancApiClient::BinaryResponseReadyMessage& message) 455 void RadiographyScene::OnFrameReceived(const Deprecated::OrthancApiClient::BinaryResponseReadyMessage& message)
456 { 456 {
457 size_t index = dynamic_cast<const Orthanc::SingleValueObject<size_t>&>(message.GetPayload()).GetValue(); 457 size_t index = dynamic_cast<const Orthanc::SingleValueObject<size_t>&>(message.GetPayload()).GetValue();
458 458
459 LOG(INFO) << "DICOM frame received: " << message.GetUri().c_str() 459 LOG(INFO) << "DICOM frame received: " << message.GetUri().c_str()
460 << " (" << message.GetAnswerSize() << " bytes) for layer " << index; 460 << " (" << message.GetAnswerSize() << " bytes) for layer " << index;
724 724
725 VLOG(1) << "Exporting RadiographyScene: create-dicom request is ready"; 725 VLOG(1) << "Exporting RadiographyScene: create-dicom request is ready";
726 } 726 }
727 727
728 728
729 void RadiographyScene::ExportDicom(OrthancApiClient& orthanc, 729 void RadiographyScene::ExportDicom(Deprecated::OrthancApiClient& orthanc,
730 const Json::Value& dicomTags, 730 const Json::Value& dicomTags,
731 const std::string& parentOrthancId, 731 const std::string& parentOrthancId,
732 double pixelSpacingX, 732 double pixelSpacingX,
733 double pixelSpacingY, 733 double pixelSpacingY,
734 bool invert, 734 bool invert,
739 739
740 ExportToCreateDicomRequest(createDicomRequestContent, dicomTags, parentOrthancId, pixelSpacingX, pixelSpacingY, invert, interpolation, usePam); 740 ExportToCreateDicomRequest(createDicomRequestContent, dicomTags, parentOrthancId, pixelSpacingX, pixelSpacingY, invert, interpolation, usePam);
741 741
742 orthanc.PostJsonAsyncExpectJson( 742 orthanc.PostJsonAsyncExpectJson(
743 "/tools/create-dicom", createDicomRequestContent, 743 "/tools/create-dicom", createDicomRequestContent,
744 new Callable<RadiographyScene, OrthancApiClient::JsonResponseReadyMessage> 744 new Callable<RadiographyScene, Deprecated::OrthancApiClient::JsonResponseReadyMessage>
745 (*this, &RadiographyScene::OnDicomExported), 745 (*this, &RadiographyScene::OnDicomExported),
746 NULL, NULL); 746 NULL, NULL);
747 747
748 } 748 }
749 749
750 750
751 // Export using PAM is faster than using PNG, but requires Orthanc 751 // Export using PAM is faster than using PNG, but requires Orthanc
752 // core >= 1.4.3 752 // core >= 1.4.3
753 void RadiographyScene::ExportDicom(OrthancApiClient& orthanc, 753 void RadiographyScene::ExportDicom(Deprecated::OrthancApiClient& orthanc,
754 const Orthanc::DicomMap& dicom, 754 const Orthanc::DicomMap& dicom,
755 const std::string& parentOrthancId, 755 const std::string& parentOrthancId,
756 double pixelSpacingX, 756 double pixelSpacingX,
757 double pixelSpacingY, 757 double pixelSpacingY,
758 bool invert, 758 bool invert,
776 } 776 }
777 777
778 ExportDicom(orthanc, jsonTags, parentOrthancId, pixelSpacingX, pixelSpacingY, invert, interpolation, usePam); 778 ExportDicom(orthanc, jsonTags, parentOrthancId, pixelSpacingX, pixelSpacingY, invert, interpolation, usePam);
779 } 779 }
780 780
781 void RadiographyScene::OnDicomExported(const OrthancApiClient::JsonResponseReadyMessage& message) 781 void RadiographyScene::OnDicomExported(const Deprecated::OrthancApiClient::JsonResponseReadyMessage& message)
782 { 782 {
783 LOG(INFO) << "DICOM export was successful: " 783 LOG(INFO) << "DICOM export was successful: "
784 << message.GetJson().toStyledString(); 784 << message.GetJson().toStyledString();
785 } 785 }
786 786
787 787
788 void RadiographyScene::OnDicomWebReceived(const IWebService::HttpRequestSuccessMessage& message) 788 void RadiographyScene::OnDicomWebReceived(const Deprecated::IWebService::HttpRequestSuccessMessage& message)
789 { 789 {
790 LOG(INFO) << "DICOMweb WADO-RS received: " << message.GetAnswerSize() << " bytes"; 790 LOG(INFO) << "DICOMweb WADO-RS received: " << message.GetAnswerSize() << " bytes";
791 791
792 const IWebService::HttpHeaders& h = message.GetAnswerHttpHeaders(); 792 const Deprecated::IWebService::HttpHeaders& h = message.GetAnswerHttpHeaders();
793 for (IWebService::HttpHeaders::const_iterator 793 for (Deprecated::IWebService::HttpHeaders::const_iterator
794 it = h.begin(); it != h.end(); ++it) 794 it = h.begin(); it != h.end(); ++it)
795 { 795 {
796 printf("[%s] = [%s]\n", it->first.c_str(), it->second.c_str()); 796 printf("[%s] = [%s]\n", it->first.c_str(), it->second.c_str());
797 } 797 }
798 } 798 }