# HG changeset patch # User am@osimis.io # Date 1530014117 -7200 # Node ID 5470b15f7cf223a929daddaca0e6698a6f076ebd # Parent e802578e1554d66e3ec5b6e5481b330fce571ea7 first usage of boost::signals2 diff -r e802578e1554 -r 5470b15f7cf2 Applications/Samples/SimpleViewerApplication.h --- a/Applications/Samples/SimpleViewerApplication.h Wed Jun 20 15:59:52 2018 +0200 +++ b/Applications/Samples/SimpleViewerApplication.h Tue Jun 26 13:55:17 2018 +0200 @@ -109,6 +109,10 @@ case 's': widget.SetDefaultView(); break; + case 'n': + application_.NextImage(widget); + //widget.SetDefaultView(); + break; default: break; @@ -182,7 +186,12 @@ mainLayout_->SetDefaultView(); } - + + void OnGeometryReady(const ILayerSource& source) + { + mainLayout_->SetDefaultView(); + } + virtual void NotifyGeometryError(const ILayerSource& source) { } @@ -292,7 +301,8 @@ // sources source_ = new OrthancFrameLayerSource(context_->GetWebService()); source_->LoadFrame(instances_[currentInstanceIndex_], 0); - source_->Register(*this); +// source_->Register(*this); + source_->SignalGeometryReady.connect(boost::bind(&SimpleViewerApplication::OnGeometryReady, this, _1)); mainViewport_->AddLayer(source_); @@ -316,6 +326,19 @@ AttachWidgetToWasmViewport("canvas2", mainViewport_); } #endif + void NextImage(WorldSceneWidget& widget) { + assert(context_); + + currentInstanceIndex_ = (currentInstanceIndex_ + 1) % instances_.size(); + + std::auto_ptr layer + (new OrthancFrameLayerSource(context_->GetWebService())); + layer->LoadFrame(instances_[currentInstanceIndex_], 0); + + mainViewport_->ReplaceLayer(0, layer.release()); + // source_->LoadFrame("45b7e6bc-168e8ed1-063dc08d-cffd6431-133a276a", 0); + } + }; } } diff -r e802578e1554 -r 5470b15f7cf2 Framework/Layers/LayerSourceBase.cpp --- a/Framework/Layers/LayerSourceBase.cpp Wed Jun 20 15:59:52 2018 +0200 +++ b/Framework/Layers/LayerSourceBase.cpp Tue Jun 26 13:55:17 2018 +0200 @@ -54,6 +54,10 @@ void LayerSourceBase::NotifyGeometryReady() { + //new observers + SignalGeometryReady(*this); + + //old observers observers_.Apply(*this, &IObserver::NotifyGeometryReady); } diff -r e802578e1554 -r 5470b15f7cf2 Framework/Layers/LayerSourceBase.h --- a/Framework/Layers/LayerSourceBase.h Wed Jun 20 15:59:52 2018 +0200 +++ b/Framework/Layers/LayerSourceBase.h Tue Jun 26 13:55:17 2018 +0200 @@ -23,6 +23,7 @@ #include "ILayerSource.h" #include "../Toolbox/ObserversRegistry.h" +#include namespace OrthancStone { @@ -48,5 +49,6 @@ public: virtual void Register(IObserver& observer); + boost::signals2::signal SignalGeometryReady; }; } diff -r e802578e1554 -r 5470b15f7cf2 Platforms/Generic/CMakeLists.txt --- a/Platforms/Generic/CMakeLists.txt Wed Jun 20 15:59:52 2018 +0200 +++ b/Platforms/Generic/CMakeLists.txt Tue Jun 26 13:55:17 2018 +0200 @@ -71,7 +71,7 @@ BuildSample(OrthancStoneSimpleViewer SimpleViewerApplication.h 8) -##################################################################### +#################################################################### ## Build the unit tests ##################################################################### diff -r e802578e1554 -r 5470b15f7cf2 Platforms/Generic/OracleWebService.h --- a/Platforms/Generic/OracleWebService.h Wed Jun 20 15:59:52 2018 +0200 +++ b/Platforms/Generic/OracleWebService.h Tue Jun 26 13:55:17 2018 +0200 @@ -46,6 +46,7 @@ const std::string& uri, Orthanc::IDynamicObject* payload) { + oracle_.Submit(new WebServiceGetCommand(callback, parameters_, uri, payload)); } diff -r e802578e1554 -r 5470b15f7cf2 Platforms/Generic/WebServiceGetCommand.cpp --- a/Platforms/Generic/WebServiceGetCommand.cpp Wed Jun 20 15:59:52 2018 +0200 +++ b/Platforms/Generic/WebServiceGetCommand.cpp Tue Jun 26 13:55:17 2018 +0200 @@ -34,6 +34,7 @@ uri_(uri), payload_(payload) { + //SignalSuccess.connect(boost::bind(&IWebService::ICallback::NotifySuccess, callback, _1, _2, _3, _4)); } @@ -50,7 +51,8 @@ { if (success_) { - callback_.NotifySuccess(uri_, answer_.c_str(), answer_.size(), payload_.release()); + SignalSuccess(uri_, answer_.c_str(), answer_.size(), payload_.release()); + //callback_.NotifySuccess(uri_, answer_.c_str(), answer_.size(), payload_.release()); } else { diff -r e802578e1554 -r 5470b15f7cf2 Platforms/Generic/WebServiceGetCommand.h --- a/Platforms/Generic/WebServiceGetCommand.h Wed Jun 20 15:59:52 2018 +0200 +++ b/Platforms/Generic/WebServiceGetCommand.h Tue Jun 26 13:55:17 2018 +0200 @@ -28,6 +28,7 @@ #include #include +#include namespace OrthancStone { @@ -50,5 +51,11 @@ virtual void Execute(); virtual void Commit(); + + boost::signals2::signal SignalSuccess; + }; } diff -r e802578e1554 -r 5470b15f7cf2 Platforms/Wasm/build-wasm.sh --- a/Platforms/Wasm/build-wasm.sh Wed Jun 20 15:59:52 2018 +0200 +++ b/Platforms/Wasm/build-wasm.sh Tue Jun 26 13:55:17 2018 +0200 @@ -7,7 +7,7 @@ cd $wasmRootDir/build source ~/Downloads/emsdk/emsdk_env.sh -cmake -DCMAKE_TOOLCHAIN_FILE=${EMSCRIPTEN}/cmake/Modules/Platform/Emscripten.cmake .. -DCMAKE_BUILD_TYPE=Release -DSTONE_SOURCES_DIR=$currentDir/../../../orthanc-stone -DORTHANC_FRAMEWORK_SOURCE=path -DORTHANC_FRAMEWORK_ROOT=$currentDir/../../../orthanc -DALLOW_DOWNLOADS=ON -DSTATIC_BUILD=OFF +cmake -DCMAKE_TOOLCHAIN_FILE=${EMSCRIPTEN}/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_BUILD_TYPE=Release -DSTONE_SOURCES_DIR=$currentDir/../../../orthanc-stone -DORTHANC_FRAMEWORK_SOURCE=path -DORTHANC_FRAMEWORK_ROOT=$currentDir/../../../orthanc -DALLOW_DOWNLOADS=ON .. make -j 5 echo "-- building the web application -- " diff -r e802578e1554 -r 5470b15f7cf2 Resources/CMake/OrthancStoneConfiguration.cmake --- a/Resources/CMake/OrthancStoneConfiguration.cmake Wed Jun 20 15:59:52 2018 +0200 +++ b/Resources/CMake/OrthancStoneConfiguration.cmake Tue Jun 26 13:55:17 2018 +0200 @@ -145,6 +145,7 @@ ${ORTHANC_STONE_ROOT}/Platforms/Generic/WebServiceGetCommand.cpp ${ORTHANC_STONE_ROOT}/Platforms/Generic/WebServicePostCommand.cpp ${ORTHANC_STONE_ROOT}/Platforms/Generic/Oracle.cpp + ${ORTHANC_STONE_ROOT}/Platforms/Generic/OracleWebService.h ) list(APPEND APPLICATIONS_SOURCES