Mercurial > hg > orthanc-stone
changeset 1318:cbfdba08e039 broker
removed SDL code in wasm + added undostack CTOR in Wasm viewport + build fix + ORTHANC_OVERRIDE
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 17 Mar 2020 08:40:13 +0100 |
parents | 8981bfca3457 |
children | 0290b7060167 |
files | Applications/Generic/GuiAdapter.h Framework/Deprecated/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp Framework/Deprecated/Loaders/OrthancSeriesVolumeProgressiveLoader.h Framework/Loaders/WebAssemblyLoadersContext.h Framework/Viewport/WebAssemblyCairoViewport.cpp Framework/Viewport/WebAssemblyViewport.cpp Framework/Viewport/WebAssemblyViewport.h Framework/Viewport/WebGLViewport.cpp Framework/Viewport/WebGLViewport.h |
diffstat | 9 files changed, 51 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/Applications/Generic/GuiAdapter.h Tue Mar 17 08:37:12 2020 +0100 +++ b/Applications/Generic/GuiAdapter.h Tue Mar 17 08:40:13 2020 +0100 @@ -53,7 +53,7 @@ namespace OrthancStone { -#if ORTHANC_ENABLE_WASM != 1 +#if ORTHANC_ENABLE_SDL == 1 class SdlViewport; #endif @@ -73,7 +73,7 @@ public: virtual ~IGuiAdapterWidget() {} -#if ORTHANC_ENABLE_WASM != 1 +#if #if ORTHANC_ENABLE_SDL == 1 /** Returns the SdlViewport that this widget contains. If the underlying viewport type is *not* SDL, then an error is returned. @@ -118,9 +118,10 @@ typedef bool (*OnKeyDownFunc) (std::string canvasId, const GuiAdapterKeyboardEvent* keyEvent, void* userData); typedef bool (*OnKeyUpFunc) (std::string canvasId, const GuiAdapterKeyboardEvent* keyEvent, void* userData); typedef bool (*OnAnimationFrameFunc)(double time, void* userData); + +#if ORTHANC_ENABLE_SDL == 1 typedef bool (*OnSdlEventCallback) (std::string canvasId, const SDL_Event& sdlEvent, void* userData); - -#if ORTHANC_ENABLE_WASM != 1 + typedef bool (*OnSdlWindowResizeFunc)(std::string canvasId, const GuiAdapterUiEvent* uiEvent, unsigned int width, @@ -279,12 +280,13 @@ void SetWheelCallback (std::string canvasId, void* userData, bool capture, OnMouseWheelFunc func); void SetKeyDownCallback (std::string canvasId, void* userData, bool capture, OnKeyDownFunc func); void SetKeyUpCallback (std::string canvasId, void* userData, bool capture, OnKeyUpFunc func); + +#if ORTHANC_ENABLE_SDL == 1 + void SetGenericSdlEventCallback (std::string canvasId, void* userData, bool capture, OnSdlEventCallback func); typedef bool (*OnSdlEventCallback) (std::string canvasId, const SDL_Event& sdlEvent, void* userData); - -#if ORTHANC_ENABLE_WASM != 1 // if you pass "#window", then any Window resize will trigger the callback void SetSdlResizeCallback(std::string canvasId, void* userData, @@ -306,7 +308,7 @@ private: -#if ORTHANC_ENABLE_WASM != 1 +#if ORTHANC_ENABLE_SDL == 1 /** Gives observers a chance to react based on generic event handlers. This is used, for instance, when the viewport lock interface is invalidated.
--- a/Framework/Deprecated/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp Tue Mar 17 08:37:12 2020 +0100 +++ b/Framework/Deprecated/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp Tue Mar 17 08:40:13 2020 +0100 @@ -387,6 +387,7 @@ const Orthanc::ImageAccessor& image, unsigned int quality) { + LOG(ERROR) << "SetSliceContent sliceIndex = " << sliceIndex; assert(sliceIndex < slicesQuality_.size() && slicesQuality_.size() == volume_->GetPixelData().GetDepth()); @@ -416,6 +417,7 @@ void OrthancSeriesVolumeProgressiveLoader::LoadJpegSliceContent(const OrthancStone::GetOrthancWebViewerJpegCommand::SuccessMessage& message) { + LOG(ERROR) << "OrthancSeriesVolumeProgressiveLoader::LoadJpegSliceContent"; unsigned int quality; switch (dynamic_cast<const OrthancStone::GetOrthancWebViewerJpegCommand&>(message.GetOrigin()).GetQuality())
--- a/Framework/Deprecated/Loaders/OrthancSeriesVolumeProgressiveLoader.h Tue Mar 17 08:37:12 2020 +0100 +++ b/Framework/Deprecated/Loaders/OrthancSeriesVolumeProgressiveLoader.h Tue Mar 17 08:40:13 2020 +0100 @@ -151,7 +151,7 @@ subscribing, for instance if they are created or listening only AFTER the "geometry loaded" message is broadcast */ - bool HasGeometry() const + bool HasGeometry() const ORTHANC_OVERRIDE { return seriesGeometry_.HasGeometry(); } @@ -159,7 +159,7 @@ /** Same remark as HasGeometry */ - const OrthancStone::VolumeImageGeometry& GetImageGeometry() const + const OrthancStone::VolumeImageGeometry& GetImageGeometry() const ORTHANC_OVERRIDE { return seriesGeometry_.GetImageGeometry(); }
--- a/Framework/Loaders/WebAssemblyLoadersContext.h Tue Mar 17 08:37:12 2020 +0100 +++ b/Framework/Loaders/WebAssemblyLoadersContext.h Tue Mar 17 08:40:13 2020 +0100 @@ -25,6 +25,8 @@ #include "../Oracle/WebAssemblyOracle.h" #include "OracleScheduler.h" +#include <list> + namespace OrthancStone { class WebAssemblyLoadersContext : public ILoadersContext
--- a/Framework/Viewport/WebAssemblyCairoViewport.cpp Tue Mar 17 08:37:12 2020 +0100 +++ b/Framework/Viewport/WebAssemblyCairoViewport.cpp Tue Mar 17 08:40:13 2020 +0100 @@ -123,7 +123,7 @@ WebAssemblyCairoViewport::WebAssemblyCairoViewport(const std::string& canvasId) : - WebAssemblyViewport(canvasId, NULL) + WebAssemblyViewport(canvasId, NULL, boost::weak_ptr<UndoStack>()) { unsigned int width, height; GetCanvasSize(width, height);
--- a/Framework/Viewport/WebAssemblyViewport.cpp Tue Mar 17 08:37:12 2020 +0100 +++ b/Framework/Viewport/WebAssemblyViewport.cpp Tue Mar 17 08:40:13 2020 +0100 @@ -203,14 +203,19 @@ } } - - WebAssemblyViewport::WebAssemblyViewport(const std::string& canvasId, - const Scene2D* scene) : + WebAssemblyViewport::WebAssemblyViewport( + const std::string& canvasId, + const Scene2D* scene, + boost::weak_ptr<UndoStack> undoStackW) : shortCanvasId_(canvasId), - fullCanvasId_("#" + canvasId), + fullCanvasId_(canvasId), interactor_(new DefaultViewportInteractor) { - if (scene == NULL) + if(undoStackW.lock() != NULL) + { + controller_ = boost::make_shared<ViewportController>(*this,undoStackW); + } + else if (scene == NULL) { controller_ = boost::make_shared<ViewportController>(*this); } @@ -237,6 +242,10 @@ canvasId.c_str() // $0 ); + LOG(TRACE) << "2020-03-16-16h23 About to call emscripten_set_XXXX_callback on \"" + << fullCanvasId_.c_str() << "\" from WebAssemblyViewport::WebAssemblyViewport"; + +#if 1 // It is not possible to monitor the resizing of individual // canvas, so we track the full window of the browser emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, false, OnResize); @@ -244,6 +253,9 @@ emscripten_set_mousedown_callback(fullCanvasId_.c_str(), this, false, OnMouseDown); emscripten_set_mousemove_callback(fullCanvasId_.c_str(), this, false, OnMouseMove); emscripten_set_mouseup_callback(fullCanvasId_.c_str(), this, false, OnMouseUp); +#endif + LOG(TRACE) << "2020-03-16-16h23 DONE calling emscripten_set_XXXX_callback on \"" + << fullCanvasId_.c_str() << "\" from WebAssemblyViewport::WebAssemblyViewport"; }
--- a/Framework/Viewport/WebAssemblyViewport.h Tue Mar 17 08:37:12 2020 +0100 +++ b/Framework/Viewport/WebAssemblyViewport.h Tue Mar 17 08:40:13 2020 +0100 @@ -79,7 +79,8 @@ public: WebAssemblyViewport(const std::string& canvasId, - const Scene2D* scene); + const Scene2D* scene, + boost::weak_ptr<UndoStack> undoStackW); virtual ILock* Lock() ORTHANC_OVERRIDE;
--- a/Framework/Viewport/WebGLViewport.cpp Tue Mar 17 08:37:12 2020 +0100 +++ b/Framework/Viewport/WebGLViewport.cpp Tue Mar 17 08:40:13 2020 +0100 @@ -79,24 +79,29 @@ } } - - WebGLViewport::WebGLViewport(const std::string& canvasId) : - WebAssemblyViewport(canvasId, NULL), + WebGLViewport::WebGLViewport(const std::string& canvasId, + boost::weak_ptr<UndoStack> undoStackW) : + WebAssemblyViewport(canvasId, NULL, undoStackW), context_(GetFullCanvasId()) { AcquireCompositor(new OpenGLCompositor(context_)); } - - WebGLViewport::WebGLViewport(const std::string& canvasId, - const Scene2D& scene) : - WebAssemblyViewport(canvasId, &scene), + WebGLViewport::WebGLViewport(const std::string& canvasId) : + WebAssemblyViewport(canvasId, NULL, boost::weak_ptr<UndoStack>()), context_(GetFullCanvasId()) { AcquireCompositor(new OpenGLCompositor(context_)); } - + WebGLViewport::WebGLViewport(const std::string& canvasId, + const Scene2D& scene) : + WebAssemblyViewport(canvasId, &scene, boost::weak_ptr<UndoStack>()), + context_(GetFullCanvasId()) + { + AcquireCompositor(new OpenGLCompositor(context_)); + } + WebGLViewport::~WebGLViewport() { // Make sure to delete the compositor before its parent "context_" gets deleted
--- a/Framework/Viewport/WebGLViewport.h Tue Mar 17 08:37:12 2020 +0100 +++ b/Framework/Viewport/WebGLViewport.h Tue Mar 17 08:40:13 2020 +0100 @@ -41,6 +41,9 @@ WebGLViewport(const std::string& canvasId); WebGLViewport(const std::string& canvasId, + boost::weak_ptr<UndoStack> undoStackW); + + WebGLViewport(const std::string& canvasId, const Scene2D& scene); virtual ~WebGLViewport();