# HG changeset patch # User Sebastien Jodogne # Date 1539886029 -7200 # Node ID c4d4213f095ce35f6565d6fa6d092503b4d6f8e2 # Parent c7fdc8bac581b51b418b0954f172da4bb2be416d cont diff -r c7fdc8bac581 -r c4d4213f095c Applications/Samples/SingleFrameEditorApplication.h --- a/Applications/Samples/SingleFrameEditorApplication.h Thu Oct 18 19:29:14 2018 +0200 +++ b/Applications/Samples/SingleFrameEditorApplication.h Thu Oct 18 20:07:09 2018 +0200 @@ -32,30 +32,50 @@ class GrayscaleBitmapStack : public WorldSceneWidget, + public IObserver, public IObservable { public: typedef OriginMessage GeometryChangedMessage; typedef OriginMessage ContentChangedMessage; + private: + OrthancApiClient& orthanc_; + protected: virtual Extent2D GetSceneExtent() { + return Extent2D(-1, -1, 1, 1); } virtual bool RenderScene(CairoContext& context, const ViewportGeometry& view) { + return true; } public: GrayscaleBitmapStack(MessageBroker& broker, + OrthancApiClient& orthanc, const std::string& name) : WorldSceneWidget(name), - IObservable(broker) + IObserver(broker), + IObservable(broker), + orthanc_(orthanc) { } + + void LoadDicom(const std::string& dicom) + { + orthanc_.GetBinaryAsync("/instances/" + dicom + "/file", "application/dicom", + new Callable(*this, &GrayscaleBitmapStack::OnDicomReceived)); + } + void OnDicomReceived(const OrthancApiClient::BinaryResponseReadyMessage& message) + { + printf("DICOM received: [%s] (%d bytes)\n", message.Uri.c_str(), message.AnswerSize); + } + }; @@ -230,7 +250,10 @@ int frame = parameters["frame"].as(); orthancApiClient_.reset(new OrthancApiClient(IObserver::broker_, context_->GetWebService())); - mainWidget_ = new GrayscaleBitmapStack(broker_, "main-widget"); + + + mainWidget_ = new GrayscaleBitmapStack(broker_, *orthancApiClient_, "main-widget"); + dynamic_cast(mainWidget_)->LoadDicom(instance); dynamic_cast(mainWidget_)->RegisterObserverCallback( new Callable