# HG changeset patch # User Benjamin Golinvaux # Date 1551212120 -3600 # Node ID 7cdb4634846cc1536222678c6601abd176023e33 # Parent 4d8ac609fc339f8b88a222da2551f38aa99fc20c# Parent 8424b10df93a3d391b9a97b320b49b83c7c59186 Merge diff -r 8424b10df93a -r 7cdb4634846c Applications/Samples/build-wasm.sh diff -r 8424b10df93a -r 7cdb4634846c Framework/Messages/ICallable.h --- a/Framework/Messages/ICallable.h Mon Feb 25 14:51:34 2019 +0100 +++ b/Framework/Messages/ICallable.h Tue Feb 26 21:15:20 2019 +0100 @@ -89,4 +89,41 @@ return &observer_; } }; + +#if 0 /* __cplusplus >= 201103L*/ + +#include + + template + class LambdaCallable : public MessageHandler + { + private: + + IObserver& observer_; + std::function lambda_; + + public: + LambdaCallable(IObserver& observer, + std::function lambdaFunction) : + observer_(observer), + lambda_(lambdaFunction) + { + } + + virtual void Apply(const IMessage& message) + { + lambda_(dynamic_cast(message)); + } + + virtual MessageType GetMessageType() const + { + return static_cast(TMessage::Type); + } + + virtual IObserver* GetObserver() const + { + return &observer_; + } + }; +#endif //__cplusplus >= 201103L } diff -r 8424b10df93a -r 7cdb4634846c Framework/Radiography/RadiographyScene.h --- a/Framework/Radiography/RadiographyScene.h Mon Feb 25 14:51:34 2019 +0100 +++ b/Framework/Radiography/RadiographyScene.h Tue Feb 26 21:15:20 2019 +0100 @@ -106,7 +106,7 @@ }; - private: + protected: typedef std::map Layers; size_t countLayers_; diff -r 8424b10df93a -r 7cdb4634846c Framework/Radiography/RadiographyWindowingTracker.cpp --- a/Framework/Radiography/RadiographyWindowingTracker.cpp Mon Feb 25 14:51:34 2019 +0100 +++ b/Framework/Radiography/RadiographyWindowingTracker.cpp Tue Feb 26 21:15:20 2019 +0100 @@ -137,21 +137,9 @@ assert(minValue <= maxValue); - float tmp; - float delta = (maxValue - minValue); - if (delta <= 1) - { - tmp = 0; - } - else - { - // NB: Visual Studio 2008 does not provide "log2f()", so we - // implement it by ourselves - tmp = logf(delta) / logf(2.0f); - } + strength_ = delta / 1000.0f; // 1px move will change the ww/wc by 0.1% - strength_ = tmp - 7; if (strength_ < 1) { strength_ = 1; diff -r 8424b10df93a -r 7cdb4634846c Platforms/Wasm/WasmWebService.cpp --- a/Platforms/Wasm/WasmWebService.cpp Mon Feb 25 14:51:34 2019 +0100 +++ b/Platforms/Wasm/WasmWebService.cpp Tue Feb 26 21:15:20 2019 +0100 @@ -45,11 +45,7 @@ const char* uri, void* payload) { - if (failureCallable == NULL) - { - throw; - } - else + if (failureCallable != NULL) { reinterpret_cast*>(failureCallable)-> Apply(OrthancStone::IWebService::HttpRequestErrorMessage(uri, reinterpret_cast(payload))); @@ -77,16 +73,12 @@ const char* answerHeaders, void* payload) { - if (successCallable == NULL) - { - throw; - } - else + if (successCallable != NULL) { OrthancStone::IWebService::HttpHeaders headers; // TODO - Parse "answerHeaders" - printf("TODO: parse headers [%s]\n", answerHeaders); + //printf("TODO: parse headers [%s]\n", answerHeaders); reinterpret_cast*>(successCallable)-> Apply(OrthancStone::IWebService::HttpRequestSuccessMessage(uri, body, bodySize, headers, diff -r 8424b10df93a -r 7cdb4634846c Platforms/Wasm/wasm-viewport.ts --- a/Platforms/Wasm/wasm-viewport.ts Mon Feb 25 14:51:34 2019 +0100 +++ b/Platforms/Wasm/wasm-viewport.ts Tue Feb 26 21:15:20 2019 +0100 @@ -48,6 +48,11 @@ private context_ : CanvasRenderingContext2D; private imageData_ : any = null; private renderingBuffer_ : any = null; + + private touchGestureInProgress_: boolean = false; + private touchCount_: number = 0; + private touchGestureLastCoordinates_: [number, number][] = []; // last x,y coordinates of each touch + private touchZoom_ : any = false; private touchTranslation_ : any = false; @@ -192,7 +197,7 @@ this.htmlCanvas_.addEventListener('mousedown', function(event) { var x = event.pageX - this.offsetLeft; var y = event.pageY - this.offsetTop; - that.ViewportMouseDown(that.pimpl_, event.button, x, y, 0 /* TODO */); + that.ViewportMouseDown(that.pimpl_, event.button, x, y, 0 /* TODO detect modifier keys*/); }); this.htmlCanvas_.addEventListener('mousemove', function(event) { @@ -225,15 +230,46 @@ }); this.htmlCanvas_.addEventListener('touchstart', function(event) { + // don't propagate events to the whole body (this could zoom the entire page instead of zooming the viewport) + event.preventDefault(); + event.stopPropagation(); + that.ResetTouch(); }); this.htmlCanvas_.addEventListener('touchend', function(event) { + // don't propagate events to the whole body (this could zoom the entire page instead of zooming the viewport) + event.preventDefault(); + event.stopPropagation(); + that.ResetTouch(); }); - this.htmlCanvas_.addEventListener('touchmove', function(event) { - if (that.touchTranslation_.length == 2) { + this.htmlCanvas_.addEventListener('touchmove', function(event: TouchEvent) { + + // don't propagate events to the whole body (this could zoom the entire page instead of zooming the viewport) + event.preventDefault(); + event.stopPropagation(); + + // if (!that.touchGestureInProgress_) { + // // starting a new gesture + // that.touchCount_ = event.targetTouches.length; + // for (var t = 0; t < event.targetTouches.length; t++) { + // that.touchGestureLastCoordinates_.push([event.targetTouches[t].pageX, event.targetTouches[t].pageY]); + // } + // that.touchGestureInProgress_ = true; + // } else { + // // continuing a gesture + // // TODO: we shall probably forward all touches to the C++ code and let the "interactors/trackers" handle them + + // if (that.touchCount_ == 1) { // consider it's a left mouse drag + + // } + // } + + // TODO: we shall probably forward all touches to the C++ code and let the "interactors/trackers" handle them + + if (that.touchTranslation_.length == 2) { // var t = that.GetTouchTranslation(event); that.ViewportMouseMove(that.pimpl_, t[0], t[1]); } @@ -248,7 +284,7 @@ // Exactly one finger inside the canvas => Setup a translation that.touchTranslation_ = that.GetTouchTranslation(event); that.ViewportMouseDown(that.pimpl_, - 1 /* middle button */, + 0 /* left button */, that.touchTranslation_[0], that.touchTranslation_[1], 0); } else if (event.targetTouches.length == 2) { @@ -272,6 +308,10 @@ this.touchTranslation_ = false; this.touchZoom_ = false; + + // this.touchGestureInProgress_ = false; + // this.touchCount_ = 0; + // this.touchGestureLastCoordinates_ = []; } public GetTouchTranslation(event) { diff -r 8424b10df93a -r 7cdb4634846c README.md --- a/README.md Mon Feb 25 14:51:34 2019 +0100 +++ b/README.md Tue Feb 26 21:15:20 2019 +0100 @@ -85,7 +85,7 @@ Installation and usage ---------------------- Build instructions are similar to that of Orthanc: -https://orthanc.chu.ulg.ac.be/book/faq/compiling.html +http://book.orthanc-server.com/faq/compiling.html Usage details are available as part of the Orthanc Book: http://book.orthanc-server.com/developers/stone.html diff -r 8424b10df93a -r 7cdb4634846c Resources/CMake/CairoConfiguration.cmake --- a/Resources/CMake/CairoConfiguration.cmake Mon Feb 25 14:51:34 2019 +0100 +++ b/Resources/CMake/CairoConfiguration.cmake Tue Feb 26 21:15:20 2019 +0100 @@ -22,7 +22,7 @@ if (STATIC_BUILD OR NOT USE_SYSTEM_CAIRO) SET(CAIRO_SOURCES_DIR ${CMAKE_BINARY_DIR}/cairo-1.14.12) - SET(CAIRO_URL "http://www.orthanc-server.com/downloads/third-party/Stone/cairo-1.14.12.tar.xz") + SET(CAIRO_URL "http://orthanc.osimis.io/ThirdPartyDownloads/cairo-1.14.12.tar.xz") SET(CAIRO_MD5 "9f0db9dbfca0966be8acd682e636d165") DownloadPackage(${CAIRO_MD5} ${CAIRO_URL} "${CAIRO_SOURCES_DIR}") diff -r 8424b10df93a -r 7cdb4634846c Resources/CMake/PixmanConfiguration.cmake --- a/Resources/CMake/PixmanConfiguration.cmake Mon Feb 25 14:51:34 2019 +0100 +++ b/Resources/CMake/PixmanConfiguration.cmake Tue Feb 26 21:15:20 2019 +0100 @@ -19,7 +19,7 @@ if (STATIC_BUILD OR NOT USE_SYSTEM_PIXMAN) SET(PIXMAN_SOURCES_DIR ${CMAKE_BINARY_DIR}/pixman-0.34.0) - SET(PIXMAN_URL "http://www.orthanc-server.com/downloads/third-party/Stone/pixman-0.34.0.tar.gz") + SET(PIXMAN_URL "http://orthanc.osimis.io/ThirdPartyDownloads/pixman-0.34.0.tar.gz") SET(PIXMAN_MD5 "e80ebae4da01e77f68744319f01d52a3") if (IS_DIRECTORY "${PIXMAN_SOURCES_DIR}") diff -r 8424b10df93a -r 7cdb4634846c Resources/CMake/SdlConfiguration.cmake --- a/Resources/CMake/SdlConfiguration.cmake Mon Feb 25 14:51:34 2019 +0100 +++ b/Resources/CMake/SdlConfiguration.cmake Tue Feb 26 21:15:20 2019 +0100 @@ -19,7 +19,7 @@ if (STATIC_BUILD OR NOT USE_SYSTEM_SDL) SET(SDL_SOURCES_DIR ${CMAKE_BINARY_DIR}/SDL2-2.0.4) - SET(SDL_URL "http://www.orthanc-server.com/downloads/third-party/Stone/SDL2-2.0.4.tar.gz") + SET(SDL_URL "http://orthanc.osimis.io/ThirdPartyDownloads/SDL2-2.0.4.tar.gz") SET(SDL_MD5 "44fc4a023349933e7f5d7a582f7b886e") DownloadPackage(${SDL_MD5} ${SDL_URL} "${SDL_SOURCES_DIR}") diff -r 8424b10df93a -r 7cdb4634846c Resources/Orthanc/DownloadOrthancFramework.cmake --- a/Resources/Orthanc/DownloadOrthancFramework.cmake Mon Feb 25 14:51:34 2019 +0100 +++ b/Resources/Orthanc/DownloadOrthancFramework.cmake Tue Feb 26 21:15:20 2019 +0100 @@ -229,8 +229,7 @@ else() # Default case: Download from the official Web site set(ORTHANC_FRAMEMORK_FILENAME Orthanc-${ORTHANC_FRAMEWORK_VERSION}.tar.gz) - #set(ORTHANC_FRAMEWORK_URL "http://www.orthanc-server.com/downloads/get.php?path=/orthanc/${ORTHANC_FRAMEMORK_FILENAME}") - set(ORTHANC_FRAMEWORK_URL "http://www.orthanc-server.com/downloads/third-party/orthanc-framework/${ORTHANC_FRAMEMORK_FILENAME}") + set(ORTHANC_FRAMEWORK_URL "http://orthanc.osimis.io/ThirdPartyDownloads/orthanc-framework/${ORTHANC_FRAMEMORK_FILENAME}") endif() set(ORTHANC_FRAMEWORK_ARCHIVE "${CMAKE_SOURCE_DIR}/ThirdPartyDownloads/${ORTHANC_FRAMEMORK_FILENAME}") diff -r 8424b10df93a -r 7cdb4634846c UnitTestsSources/TestMessageBroker.cpp --- a/UnitTestsSources/TestMessageBroker.cpp Mon Feb 25 14:51:34 2019 +0100 +++ b/UnitTestsSources/TestMessageBroker.cpp Tue Feb 26 21:15:20 2019 +0100 @@ -314,45 +314,6 @@ #if __cplusplus >= 201103L -#include - -namespace OrthancStone { - - template - class LambdaCallable : public MessageHandler - { - private: - - IObserver& observer_; - std::function lambda_; - - public: - LambdaCallable(IObserver& observer, - std::function lambdaFunction) : - observer_(observer), - lambda_(lambdaFunction) - { - } - - virtual void Apply(const IMessage& message) - { - lambda_(dynamic_cast(message)); - } - - virtual MessageType GetMessageType() const - { - return static_cast(TMessage::Type); - } - - virtual IObserver* GetObserver() const - { - return &observer_; - } - }; - - -} - TEST(MessageBroker, TestLambdaSimpleUseCase) { MessageBroker broker;