Mercurial > hg > orthanc-stone
changeset 1551:c54bc5bffd01
software rendering
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 13 Aug 2020 22:05:13 +0200 |
parents | 012ab2c1f23b |
children | a4d82f1bcb10 |
files | Applications/StoneWebViewer/WebAssembly/StoneModule/CMakeLists.txt Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp OrthancStone/SharedLibrary/WebAssembly/CMakeLists.txt OrthancStone/Sources/Viewport/WebAssemblyCairoViewport.cpp OrthancStone/Sources/Viewport/WebAssemblyCairoViewport.h OrthancStone/Sources/Viewport/WebGLViewport.h |
diffstat | 6 files changed, 47 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/Applications/StoneWebViewer/WebAssembly/StoneModule/CMakeLists.txt Thu Aug 13 21:00:55 2020 +0200 +++ b/Applications/StoneWebViewer/WebAssembly/StoneModule/CMakeLists.txt Thu Aug 13 22:05:13 2020 +0200 @@ -51,6 +51,7 @@ include_directories( ${ORTHANC_STONE_MODULE_PREFIX}/include + ${ORTHANC_STONE_MODULE_PREFIX}/include/cairo ${ORTHANC_STONE_MODULE_PREFIX}/include/orthanc-framework ${ORTHANC_STONE_MODULE_PREFIX}/include/orthanc-stone )
--- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Thu Aug 13 21:00:55 2020 +0200 +++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Thu Aug 13 22:05:13 2020 +0200 @@ -79,6 +79,7 @@ #include <Toolbox/GeometryToolbox.h> #include <Toolbox/SortedFrames.h> #include <Viewport/WebGLViewport.h> +#include <Viewport/WebAssemblyCairoViewport.h> #include <boost/make_shared.hpp> #include <stdio.h> @@ -1222,7 +1223,7 @@ std::unique_ptr<IObserver> observer_; OrthancStone::ILoadersContext& context_; - boost::shared_ptr<OrthancStone::WebGLViewport> viewport_; + boost::shared_ptr<OrthancStone::WebAssemblyViewport> viewport_; boost::shared_ptr<OrthancStone::DicomResourcesLoader> loader_; OrthancStone::DicomSource source_; boost::shared_ptr<FramesCache> cache_; @@ -1525,6 +1526,7 @@ context_(context), source_(source), viewport_(OrthancStone::WebGLViewport::Create(canvas)), + //viewport_(OrthancStone::WebAssemblyCairoViewport::Create(canvas)), cache_(cache), fitNextContent_(true), isCtrlDown_(false)
--- a/OrthancStone/SharedLibrary/WebAssembly/CMakeLists.txt Thu Aug 13 21:00:55 2020 +0200 +++ b/OrthancStone/SharedLibrary/WebAssembly/CMakeLists.txt Thu Aug 13 22:05:13 2020 +0200 @@ -64,6 +64,7 @@ set(SOURCES_WITH_EMSCRIPTEN_CALLBACKS ${ORTHANC_STONE_ROOT}/Sources/Oracle/WebAssemblyOracle.cpp ${ORTHANC_STONE_ROOT}/Sources/Viewport/WebAssemblyViewport.cpp + ${ORTHANC_STONE_ROOT}/Sources/Viewport/WebAssemblyCairoViewport.cpp ) list(REMOVE_ITEM ORTHANC_STONE_SOURCES @@ -139,6 +140,14 @@ PATTERN "*.h" ) +file( + COPY ${CAIRO_SOURCES_DIR}/src/ + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Include/cairo/ + NO_SOURCE_PERMISSIONS + FILES_MATCHING + PATTERN "*.h" + ) + set(DCMTK_MODULES dcmdata config @@ -170,6 +179,7 @@ install( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Include/boost + ${CMAKE_CURRENT_BINARY_DIR}/Include/cairo ${CMAKE_CURRENT_BINARY_DIR}/Include/dcmtk ${CMAKE_CURRENT_BINARY_DIR}/Include/json ${CMAKE_CURRENT_BINARY_DIR}/Include/orthanc-framework
--- a/OrthancStone/Sources/Viewport/WebAssemblyCairoViewport.cpp Thu Aug 13 21:00:55 2020 +0200 +++ b/OrthancStone/Sources/Viewport/WebAssemblyCairoViewport.cpp Thu Aug 13 22:05:13 2020 +0200 @@ -19,9 +19,15 @@ **/ -#include "WebAssemblyCairoViewport.h" - -#include "../Scene2D/CairoCompositor.h" +#if defined(ORTHANC_BUILDING_STONE_LIBRARY) && ORTHANC_BUILDING_STONE_LIBRARY == 1 +# include "WebAssemblyCairoViewport.h" +# include "../Scene2D/CairoCompositor.h" +#else +// This is the case when using the WebAssembly side module, and this +// source file must be compiled within the WebAssembly main module +# include <Viewport/WebAssemblyCairoViewport.h> +# include <Scene2D/CairoCompositor.h> +#endif #include <Images/Image.h> @@ -124,16 +130,25 @@ } - WebAssemblyCairoViewport::WebAssemblyCairoViewport( - const std::string& canvasId) : - WebAssemblyViewport(canvasId) + WebAssemblyCairoViewport::WebAssemblyCairoViewport(const std::string& canvasId, + bool enableEmscriptenMouseEvents) : + WebAssemblyViewport(canvasId,enableEmscriptenMouseEvents) { unsigned int width, height; GetCanvasSize(width, height); - emscripten_set_canvas_element_size(GetCanvasCssSelector().c_str(), - width, - height); + emscripten_set_canvas_element_size(GetCanvasCssSelector().c_str(), width, height); AcquireCompositor(new CairoCompositor(width, height)); } + + + boost::shared_ptr<WebAssemblyCairoViewport> WebAssemblyCairoViewport::Create( + const std::string& canvasId, bool enableEmscriptenMouseEvents) + { + boost::shared_ptr<WebAssemblyCairoViewport> that = boost::shared_ptr<WebAssemblyCairoViewport>( + new WebAssemblyCairoViewport(canvasId, enableEmscriptenMouseEvents)); + + that->WebAssemblyViewport::PostConstructor(); + return that; + } }
--- a/OrthancStone/Sources/Viewport/WebAssemblyCairoViewport.h Thu Aug 13 21:00:55 2020 +0200 +++ b/OrthancStone/Sources/Viewport/WebAssemblyCairoViewport.h Thu Aug 13 22:05:13 2020 +0200 @@ -33,6 +33,9 @@ void GetCanvasSize(unsigned int& width, unsigned int& height); + WebAssemblyCairoViewport(const std::string& canvasId, + bool enableEmscriptenMouseEvents); + protected: virtual void Paint(ICompositor& compositor, ViewportController& controller) ORTHANC_OVERRIDE; @@ -40,7 +43,8 @@ virtual void UpdateSize(ICompositor& compositor) ORTHANC_OVERRIDE; public: - WebAssemblyCairoViewport(const std::string& canvasId); + static boost::shared_ptr<WebAssemblyCairoViewport> Create(const std::string& canvasId, + bool enableEmscriptenMouseEvents = true); virtual ~WebAssemblyCairoViewport() {
--- a/OrthancStone/Sources/Viewport/WebGLViewport.h Thu Aug 13 21:00:55 2020 +0200 +++ b/OrthancStone/Sources/Viewport/WebGLViewport.h Thu Aug 13 22:05:13 2020 +0200 @@ -31,7 +31,8 @@ private: OpenGL::WebAssemblyOpenGLContext context_; - WebGLViewport(const std::string& canvasId, bool enableEmscriptenMouseEvents); + WebGLViewport(const std::string& canvasId, + bool enableEmscriptenMouseEvents); protected: virtual void Paint(ICompositor& compositor, @@ -43,7 +44,8 @@ } public: - static boost::shared_ptr<WebGLViewport> Create(const std::string& canvasId, bool enableEmscriptenMouseEvents = true); + static boost::shared_ptr<WebGLViewport> Create(const std::string& canvasId, + bool enableEmscriptenMouseEvents = true); virtual ~WebGLViewport();