# HG changeset patch # User Sebastien Jodogne # Date 1541784630 -3600 # Node ID e7a494bdd9568b06a9affe21072f8d93fdcbc435 # Parent d87fe075d31b129b97c35d7a8291ad89e54c946c removed Messages/MessageType.h diff -r d87fe075d31b -r e7a494bdd956 Applications/Samples/SimpleViewer/Messages.h --- a/Applications/Samples/SimpleViewer/Messages.h Fri Nov 09 17:59:35 2018 +0100 +++ b/Applications/Samples/SimpleViewer/Messages.h Fri Nov 09 18:30:30 2018 +0100 @@ -1,13 +1,10 @@ #pragma once -#include "Framework/Messages/MessageType.h" - namespace SimpleViewer { enum SimpleViewerMessageType { SimpleViewerMessageType_First = OrthancStone::MessageType_CustomMessage, SimpleViewerMessageType_AppStatusUpdated - }; } diff -r d87fe075d31b -r e7a494bdd956 Applications/Samples/SimpleViewer/SimpleViewerApplication.cpp --- a/Applications/Samples/SimpleViewer/SimpleViewerApplication.cpp Fri Nov 09 17:59:35 2018 +0100 +++ b/Applications/Samples/SimpleViewer/SimpleViewerApplication.cpp Fri Nov 09 18:30:30 2018 +0100 @@ -54,17 +54,17 @@ thumbnailsLayout_->SetBackgroundColor(50, 50, 50); thumbnailsLayout_->SetVertical(); - mainWidget_ = new SliceViewerWidget(IObserver::broker_, "main-viewport"); + mainWidget_ = new SliceViewerWidget(IObserver::GetBroker(), "main-viewport"); //mainWidget_->RegisterObserver(*this); // hierarchy mainLayout_->AddWidget(thumbnailsLayout_); mainLayout_->AddWidget(mainWidget_); - orthancApiClient_.reset(new OrthancApiClient(IObserver::broker_, context_->GetWebService())); + orthancApiClient_.reset(new OrthancApiClient(IObserver::GetBroker(), context_->GetWebService())); // sources - smartLoader_.reset(new SmartLoader(IObserver::broker_, *orthancApiClient_)); + smartLoader_.reset(new SmartLoader(IObserver::GetBroker(), *orthancApiClient_)); smartLoader_->SetImageQuality(SliceImageQuality_FullPam); mainLayout_->SetTransmitMouseOver(true); @@ -153,7 +153,7 @@ { LOG(INFO) << "Loading thumbnail for series " << seriesId; SliceViewerWidget* thumbnailWidget = - new SliceViewerWidget(IObserver::broker_, "thumbnail-series-" + seriesId); + new SliceViewerWidget(IObserver::GetBroker(), "thumbnail-series-" + seriesId); thumbnails_.push_back(thumbnailWidget); thumbnailsLayout_->AddWidget(thumbnailWidget); thumbnailWidget->RegisterObserverCallback( diff -r d87fe075d31b -r e7a494bdd956 Applications/Samples/SimpleViewerApplicationSingleFile.h --- a/Applications/Samples/SimpleViewerApplicationSingleFile.h Fri Nov 09 17:59:35 2018 +0100 +++ b/Applications/Samples/SimpleViewerApplicationSingleFile.h Fri Nov 09 18:30:30 2018 +0100 @@ -298,17 +298,17 @@ thumbnailsLayout_->SetBackgroundColor(50, 50, 50); thumbnailsLayout_->SetVertical(); - mainWidget_ = new SliceViewerWidget(broker_, "main-viewport"); + mainWidget_ = new SliceViewerWidget(GetBroker(), "main-viewport"); //mainWidget_->RegisterObserver(*this); // hierarchy mainLayout_->AddWidget(thumbnailsLayout_); mainLayout_->AddWidget(mainWidget_); - orthancApiClient_.reset(new OrthancApiClient(IObserver::broker_, context_->GetWebService())); + orthancApiClient_.reset(new OrthancApiClient(GetBroker(), context_->GetWebService())); // sources - smartLoader_.reset(new SmartLoader(IObserver::broker_, *orthancApiClient_)); + smartLoader_.reset(new SmartLoader(GetBroker(), *orthancApiClient_)); smartLoader_->SetImageQuality(SliceImageQuality_FullPam); mainLayout_->SetTransmitMouseOver(true); @@ -393,7 +393,7 @@ void LoadThumbnailForSeries(const std::string& seriesId, const std::string& instanceId) { LOG(INFO) << "Loading thumbnail for series " << seriesId; - SliceViewerWidget* thumbnailWidget = new SliceViewerWidget(IObserver::broker_, "thumbnail-series-" + seriesId); + SliceViewerWidget* thumbnailWidget = new SliceViewerWidget(GetBroker(), "thumbnail-series-" + seriesId); thumbnails_.push_back(thumbnailWidget); thumbnailsLayout_->AddWidget(thumbnailWidget); thumbnailWidget->RegisterObserverCallback(new Callable(*this, &SimpleViewerApplication::OnWidgetGeometryChanged)); diff -r d87fe075d31b -r e7a494bdd956 Applications/Samples/SingleFrameApplication.h --- a/Applications/Samples/SingleFrameApplication.h Fri Nov 09 17:59:35 2018 +0100 +++ b/Applications/Samples/SingleFrameApplication.h Fri Nov 09 18:30:30 2018 +0100 @@ -242,10 +242,10 @@ std::string instance = parameters["instance"].as(); int frame = parameters["frame"].as(); - orthancApiClient_.reset(new OrthancApiClient(IObserver::broker_, context_->GetWebService())); - mainWidget_ = new SliceViewerWidget(broker_, "main-widget"); + orthancApiClient_.reset(new OrthancApiClient(GetBroker(), context_->GetWebService())); + mainWidget_ = new SliceViewerWidget(GetBroker(), "main-widget"); - std::auto_ptr layer(new OrthancFrameLayerSource(broker_, *orthancApiClient_)); + std::auto_ptr layer(new OrthancFrameLayerSource(GetBroker(), *orthancApiClient_)); source_ = layer.get(); layer->LoadFrame(instance, frame); layer->RegisterObserverCallback(new Callable(*this, &SingleFrameApplication::OnMainWidgetGeometryReady)); diff -r d87fe075d31b -r e7a494bdd956 Applications/Samples/SingleFrameEditorApplication.h --- a/Applications/Samples/SingleFrameEditorApplication.h Fri Nov 09 17:59:35 2018 +0100 +++ b/Applications/Samples/SingleFrameEditorApplication.h Fri Nov 09 18:30:30 2018 +0100 @@ -2890,12 +2890,12 @@ std::string instance = parameters["instance"].as(); int frame = parameters["frame"].as(); - orthancApiClient_.reset(new OrthancApiClient(IObserver::broker_, context_->GetWebService())); + orthancApiClient_.reset(new OrthancApiClient(GetBroker(), context_->GetWebService())); Orthanc::FontRegistry fonts; fonts.AddFromResource(Orthanc::EmbeddedResources::FONT_UBUNTU_MONO_BOLD_16); - stack_.reset(new BitmapStack(IObserver::broker_, *orthancApiClient_)); + stack_.reset(new BitmapStack(GetBroker(), *orthancApiClient_)); stack_->LoadFrame(instance, frame, false); //.SetPan(200, 0); //stack_->LoadFrame("61f3143e-96f34791-ad6bbb8d-62559e75-45943e1b", 0, false); @@ -2913,7 +2913,7 @@ } - mainWidget_ = new BitmapStackWidget(IObserver::broker_, *stack_, "main-widget"); + mainWidget_ = new BitmapStackWidget(GetBroker(), *stack_, "main-widget"); mainWidget_->SetTransmitMouseOver(true); mainWidget_->SetInteractor(interactor_); diff -r d87fe075d31b -r e7a494bdd956 Framework/Messages/IMessage.h --- a/Framework/Messages/IMessage.h Fri Nov 09 17:59:35 2018 +0100 +++ b/Framework/Messages/IMessage.h Fri Nov 09 18:30:30 2018 +0100 @@ -21,13 +21,12 @@ #pragma once -#include "MessageType.h" +#include "../StoneEnumerations.h" #include -namespace OrthancStone { - - +namespace OrthancStone +{ // base message that are exchanged between IObservable and IObserver class IMessage : public boost::noncopyable { diff -r d87fe075d31b -r e7a494bdd956 Framework/Messages/IObservable.h --- a/Framework/Messages/IObservable.h Fri Nov 09 17:59:35 2018 +0100 +++ b/Framework/Messages/IObservable.h Fri Nov 09 18:30:30 2018 +0100 @@ -21,39 +21,33 @@ #pragma once -#include -#include -#include -#include -#include - - -#include "MessageBroker.h" -#include "MessageType.h" +#include "../StoneEnumerations.h" #include "ICallable.h" #include "IObserver.h" +#include "MessageBroker.h" #include "MessageForwarder.h" -namespace OrthancStone { +#include +#include - +namespace OrthancStone +{ class IObservable : public boost::noncopyable { - protected: - MessageBroker& broker_; + private: + typedef std::map > Callables; + typedef std::set Forwarders; - typedef std::map > Callables; - Callables callables_; - - typedef std::set Forwarders; - Forwarders forwarders_; + MessageBroker& broker_; + Callables callables_; + Forwarders forwarders_; public: - - IObservable(MessageBroker& broker) - : broker_(broker) + IObservable(MessageBroker& broker) : + broker_(broker) { } + virtual ~IObservable() { // delete all callables (this will also unregister them from the broker) @@ -105,6 +99,9 @@ forwarders_.insert(forwarder); } + MessageBroker& GetBroker() const + { + return broker_; + } }; - } diff -r d87fe075d31b -r e7a494bdd956 Framework/Messages/IObserver.h --- a/Framework/Messages/IObserver.h Fri Nov 09 17:59:35 2018 +0100 +++ b/Framework/Messages/IObserver.h Fri Nov 09 18:30:30 2018 +0100 @@ -23,21 +23,17 @@ #include "MessageBroker.h" #include "IMessage.h" -#include -#include -namespace OrthancStone { - - class IObservable; - +namespace OrthancStone +{ class IObserver : public boost::noncopyable { - protected: - MessageBroker& broker_; + private: + MessageBroker& broker_; public: - IObserver(MessageBroker& broker) - : broker_(broker) + IObserver(MessageBroker& broker) : + broker_(broker) { broker_.Register(*this); } @@ -46,6 +42,10 @@ { broker_.Unregister(*this); } + + MessageBroker& GetBroker() const + { + return broker_; + } }; - } diff -r d87fe075d31b -r e7a494bdd956 Framework/Messages/MessageType.h --- a/Framework/Messages/MessageType.h Fri Nov 09 17:59:35 2018 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -/** - * Stone of Orthanc - * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics - * Department, University Hospital of Liege, Belgium - * Copyright (C) 2017-2018 Osimis S.A., Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - -#pragma once - -namespace OrthancStone { - - enum MessageType - { - MessageType_Widget_GeometryChanged, - MessageType_Widget_ContentChanged, - - MessageType_LayerSource_GeometryReady, // instance tags have been loaded - MessageType_LayerSource_GeometryError, - MessageType_LayerSource_ContentChanged, - MessageType_LayerSource_SliceChanged, - MessageType_LayerSource_ImageReady, // instance pixels data have been loaded - MessageType_LayerSource_LayerReady, // layer is ready to be rendered - MessageType_LayerSource_LayerError, - - MessageType_SliceLoader_GeometryReady, - MessageType_SliceLoader_GeometryError, - MessageType_SliceLoader_ImageReady, - MessageType_SliceLoader_ImageError, - - MessageType_HttpRequestSuccess, - MessageType_HttpRequestError, - - MessageType_OrthancApi_InternalGetJsonResponseReady, - MessageType_OrthancApi_InternalGetJsonResponseError, - - MessageType_OrthancApi_GenericGetJson_Ready, - MessageType_OrthancApi_GenericGetBinary_Ready, - MessageType_OrthancApi_GenericHttpError_Ready, - MessageType_OrthancApi_GenericEmptyResponse_Ready, - - MessageType_ViewportChanged, - - // used in unit tests only - MessageType_Test1, - MessageType_Test2, - - MessageType_CustomMessage // Custom messages ids ust be greater than this (this one must remain in last position) - }; -} diff -r d87fe075d31b -r e7a494bdd956 Framework/SmartLoader.cpp --- a/Framework/SmartLoader.cpp Fri Nov 09 17:59:35 2018 +0100 +++ b/Framework/SmartLoader.cpp Fri Nov 09 18:30:30 2018 +0100 @@ -105,7 +105,7 @@ CachedSlice* Clone() const { - CachedSlice* output = new CachedSlice(broker_); + CachedSlice* output = new CachedSlice(GetBroker()); output->sliceIndex_ = sliceIndex_; output->slice_.reset(slice_->Clone()); output->image_ = image_; @@ -150,7 +150,7 @@ } else { - layerSource.reset(new OrthancFrameLayerSource(IObserver::broker_, orthancApiClient_)); + layerSource.reset(new OrthancFrameLayerSource(IObserver::GetBroker(), orthancApiClient_)); dynamic_cast(layerSource.get())->SetImageQuality(imageQuality_); layerSource->RegisterObserverCallback(new Callable(*this, &SmartLoader::OnLayerGeometryReady)); layerSource->RegisterObserverCallback(new Callable(*this, &SmartLoader::OnImageReady)); @@ -189,7 +189,7 @@ // create the slice in the cache with "empty" data - boost::shared_ptr cachedSlice(new CachedSlice(IObserver::broker_)); + boost::shared_ptr cachedSlice(new CachedSlice(IObserver::GetBroker())); cachedSlice->slice_.reset(new Slice(instanceId, frame)); cachedSlice->status_ = CachedSliceStatus_ScheduledToLoad; std::string sliceKeyId = instanceId + ":" + boost::lexical_cast(frame); @@ -198,7 +198,7 @@ cachedSlices_[sliceKeyId] = boost::shared_ptr(cachedSlice); - std::auto_ptr layerSource(new OrthancFrameLayerSource(IObserver::broker_, orthancApiClient_)); + std::auto_ptr layerSource(new OrthancFrameLayerSource(IObserver::GetBroker(), orthancApiClient_)); dynamic_cast(layerSource.get())->SetImageQuality(imageQuality_); layerSource->RegisterObserverCallback(new Callable(*this, &SmartLoader::OnLayerGeometryReady)); @@ -233,7 +233,7 @@ LOG(WARNING) << "Geometry ready: " << sliceKeyId; - boost::shared_ptr cachedSlice(new CachedSlice(IObserver::broker_)); + boost::shared_ptr cachedSlice(new CachedSlice(IObserver::GetBroker())); cachedSlice->slice_.reset(slice.Clone()); cachedSlice->effectiveQuality_ = source.GetImageQuality(); cachedSlice->status_ = CachedSliceStatus_GeometryLoaded; @@ -256,7 +256,7 @@ LOG(WARNING) << "Image ready: " << sliceKeyId; - boost::shared_ptr cachedSlice(new CachedSlice(IObserver::broker_)); + boost::shared_ptr cachedSlice(new CachedSlice(IObserver::GetBroker())); cachedSlice->image_.reset(Orthanc::Image::Clone(message.GetImage())); cachedSlice->effectiveQuality_ = message.GetImageQuality(); cachedSlice->slice_.reset(message.GetSlice().Clone()); diff -r d87fe075d31b -r e7a494bdd956 Framework/StoneEnumerations.h --- a/Framework/StoneEnumerations.h Fri Nov 09 17:59:35 2018 +0100 +++ b/Framework/StoneEnumerations.h Fri Nov 09 18:30:30 2018 +0100 @@ -115,6 +115,45 @@ BitmapAnchor_TopRight }; + enum MessageType + { + MessageType_Widget_GeometryChanged, + MessageType_Widget_ContentChanged, + + MessageType_LayerSource_GeometryReady, // instance tags have been loaded + MessageType_LayerSource_GeometryError, + MessageType_LayerSource_ContentChanged, + MessageType_LayerSource_SliceChanged, + MessageType_LayerSource_ImageReady, // instance pixels data have been loaded + MessageType_LayerSource_LayerReady, // layer is ready to be rendered + MessageType_LayerSource_LayerError, + + MessageType_SliceLoader_GeometryReady, + MessageType_SliceLoader_GeometryError, + MessageType_SliceLoader_ImageReady, + MessageType_SliceLoader_ImageError, + + MessageType_HttpRequestSuccess, + MessageType_HttpRequestError, + + MessageType_OrthancApi_InternalGetJsonResponseReady, + MessageType_OrthancApi_InternalGetJsonResponseError, + + MessageType_OrthancApi_GenericGetJson_Ready, + MessageType_OrthancApi_GenericGetBinary_Ready, + MessageType_OrthancApi_GenericHttpError_Ready, + MessageType_OrthancApi_GenericEmptyResponse_Ready, + + MessageType_ViewportChanged, + + // used in unit tests only + MessageType_Test1, + MessageType_Test2, + + MessageType_CustomMessage // Custom messages ids ust be greater than this (this one must remain in last position) + }; + + bool StringToSopClassUid(SopClassUid& result, const std::string& source); diff -r d87fe075d31b -r e7a494bdd956 Resources/CMake/OrthancStoneConfiguration.cmake --- a/Resources/CMake/OrthancStoneConfiguration.cmake Fri Nov 09 17:59:35 2018 +0100 +++ b/Resources/CMake/OrthancStoneConfiguration.cmake Fri Nov 09 18:30:30 2018 +0100 @@ -302,7 +302,6 @@ ${ORTHANC_STONE_ROOT}/Framework/Messages/IObserver.h ${ORTHANC_STONE_ROOT}/Framework/Messages/MessageBroker.h ${ORTHANC_STONE_ROOT}/Framework/Messages/MessageForwarder.cpp - ${ORTHANC_STONE_ROOT}/Framework/Messages/MessageType.h ${ORTHANC_STONE_ROOT}/Framework/Messages/Promise.h ${ORTHANC_ROOT}/Plugins/Samples/Common/DicomDatasetReader.cpp diff -r d87fe075d31b -r e7a494bdd956 UnitTestsSources/TestMessageBroker2.cpp --- a/UnitTestsSources/TestMessageBroker2.cpp Fri Nov 09 17:59:35 2018 +0100 +++ b/UnitTestsSources/TestMessageBroker2.cpp Fri Nov 09 18:30:30 2018 +0100 @@ -112,7 +112,7 @@ Promise& StartSomethingAsync() { - currentPromise_ = new Promise(broker_); + currentPromise_ = new Promise(GetBroker()); return *currentPromise_; }