# HG changeset patch # User Benjamin Golinvaux # Date 1584430813 -3600 # Node ID cbfdba08e039556e591c3589a61067cfc10b30ec # Parent 8981bfca3457f9360c4b7cec10e54f334acc8024 removed SDL code in wasm + added undostack CTOR in Wasm viewport + build fix + ORTHANC_OVERRIDE diff -r 8981bfca3457 -r cbfdba08e039 Applications/Generic/GuiAdapter.h --- 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. diff -r 8981bfca3457 -r cbfdba08e039 Framework/Deprecated/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp --- 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(message.GetOrigin()).GetQuality()) diff -r 8981bfca3457 -r cbfdba08e039 Framework/Deprecated/Loaders/OrthancSeriesVolumeProgressiveLoader.h --- 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(); } diff -r 8981bfca3457 -r cbfdba08e039 Framework/Loaders/WebAssemblyLoadersContext.h --- 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 + namespace OrthancStone { class WebAssemblyLoadersContext : public ILoadersContext diff -r 8981bfca3457 -r cbfdba08e039 Framework/Viewport/WebAssemblyCairoViewport.cpp --- 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()) { unsigned int width, height; GetCanvasSize(width, height); diff -r 8981bfca3457 -r cbfdba08e039 Framework/Viewport/WebAssemblyViewport.cpp --- 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 undoStackW) : shortCanvasId_(canvasId), - fullCanvasId_("#" + canvasId), + fullCanvasId_(canvasId), interactor_(new DefaultViewportInteractor) { - if (scene == NULL) + if(undoStackW.lock() != NULL) + { + controller_ = boost::make_shared(*this,undoStackW); + } + else if (scene == NULL) { controller_ = boost::make_shared(*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"; } diff -r 8981bfca3457 -r cbfdba08e039 Framework/Viewport/WebAssemblyViewport.h --- 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 undoStackW); virtual ILock* Lock() ORTHANC_OVERRIDE; diff -r 8981bfca3457 -r cbfdba08e039 Framework/Viewport/WebGLViewport.cpp --- 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 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()), context_(GetFullCanvasId()) { AcquireCompositor(new OpenGLCompositor(context_)); } - + WebGLViewport::WebGLViewport(const std::string& canvasId, + const Scene2D& scene) : + WebAssemblyViewport(canvasId, &scene, boost::weak_ptr()), + context_(GetFullCanvasId()) + { + AcquireCompositor(new OpenGLCompositor(context_)); + } + WebGLViewport::~WebGLViewport() { // Make sure to delete the compositor before its parent "context_" gets deleted diff -r 8981bfca3457 -r cbfdba08e039 Framework/Viewport/WebGLViewport.h --- 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 undoStackW); + + WebGLViewport(const std::string& canvasId, const Scene2D& scene); virtual ~WebGLViewport();