changeset 505:4cc7bb55bd49 bgo-commands-codegen

Merge default
author Benjamin Golinvaux <bgo@osimis.io>
date Tue, 26 Feb 2019 21:26:47 +0100
parents 8424b10df93a (current diff) 7cdb4634846c (diff)
children 801d2697a1b1
files
diffstat 11 files changed, 91 insertions(+), 74 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Messages/ICallable.h	Mon Feb 25 14:51:34 2019 +0100
+++ b/Framework/Messages/ICallable.h	Tue Feb 26 21:26:47 2019 +0100
@@ -89,4 +89,41 @@
       return &observer_;
     }
   };
+
+#if 0 /* __cplusplus >= 201103L*/
+
+#include <functional>
+
+  template <typename TMessage>
+  class LambdaCallable : public MessageHandler<TMessage>
+  {
+  private:
+
+    IObserver&      observer_;
+    std::function<void (const TMessage&)> lambda_;
+
+  public:
+    LambdaCallable(IObserver& observer,
+                    std::function<void (const TMessage&)> lambdaFunction) :
+             observer_(observer),
+             lambda_(lambdaFunction)
+    {
+    }
+
+    virtual void Apply(const IMessage& message)
+    {
+      lambda_(dynamic_cast<const TMessage&>(message));
+    }
+
+    virtual MessageType GetMessageType() const
+    {
+      return static_cast<MessageType>(TMessage::Type);
+    }
+
+    virtual IObserver* GetObserver() const
+    {
+      return &observer_;
+    }
+  };
+#endif //__cplusplus >= 201103L
 }
--- a/Framework/Radiography/RadiographyScene.h	Mon Feb 25 14:51:34 2019 +0100
+++ b/Framework/Radiography/RadiographyScene.h	Tue Feb 26 21:26:47 2019 +0100
@@ -106,7 +106,7 @@
     };
 
 
-  private:
+  protected:
     typedef std::map<size_t, RadiographyLayer*>  Layers;
 
     size_t  countLayers_;
--- a/Framework/Radiography/RadiographyWindowingTracker.cpp	Mon Feb 25 14:51:34 2019 +0100
+++ b/Framework/Radiography/RadiographyWindowingTracker.cpp	Tue Feb 26 21:26:47 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;
--- a/Platforms/Wasm/WasmWebService.cpp	Mon Feb 25 14:51:34 2019 +0100
+++ b/Platforms/Wasm/WasmWebService.cpp	Tue Feb 26 21:26:47 2019 +0100
@@ -45,11 +45,7 @@
                                                        const char* uri,
                                                        void* payload)
   {
-    if (failureCallable == NULL)
-    {
-      throw;
-    }
-    else
+    if (failureCallable != NULL)
     {
       reinterpret_cast<OrthancStone::MessageHandler<OrthancStone::IWebService::HttpRequestErrorMessage>*>(failureCallable)->
         Apply(OrthancStone::IWebService::HttpRequestErrorMessage(uri, reinterpret_cast<Orthanc::IDynamicObject*>(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<OrthancStone::MessageHandler<OrthancStone::IWebService::HttpRequestSuccessMessage>*>(successCallable)->
         Apply(OrthancStone::IWebService::HttpRequestSuccessMessage(uri, body, bodySize, headers,
--- a/Platforms/Wasm/wasm-viewport.ts	Mon Feb 25 14:51:34 2019 +0100
+++ b/Platforms/Wasm/wasm-viewport.ts	Tue Feb 26 21:26:47 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) {
--- a/README.md	Mon Feb 25 14:51:34 2019 +0100
+++ b/README.md	Tue Feb 26 21:26:47 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
--- a/Resources/CMake/CairoConfiguration.cmake	Mon Feb 25 14:51:34 2019 +0100
+++ b/Resources/CMake/CairoConfiguration.cmake	Tue Feb 26 21:26:47 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}")
--- a/Resources/CMake/PixmanConfiguration.cmake	Mon Feb 25 14:51:34 2019 +0100
+++ b/Resources/CMake/PixmanConfiguration.cmake	Tue Feb 26 21:26:47 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}")
--- a/Resources/CMake/SdlConfiguration.cmake	Mon Feb 25 14:51:34 2019 +0100
+++ b/Resources/CMake/SdlConfiguration.cmake	Tue Feb 26 21:26:47 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}")
--- a/Resources/Orthanc/DownloadOrthancFramework.cmake	Mon Feb 25 14:51:34 2019 +0100
+++ b/Resources/Orthanc/DownloadOrthancFramework.cmake	Tue Feb 26 21:26:47 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}")
--- a/UnitTestsSources/TestMessageBroker.cpp	Mon Feb 25 14:51:34 2019 +0100
+++ b/UnitTestsSources/TestMessageBroker.cpp	Tue Feb 26 21:26:47 2019 +0100
@@ -314,45 +314,6 @@
 
 #if __cplusplus >= 201103L
 
-#include <functional>
-
-namespace OrthancStone {
-
-  template <typename TMessage>
-  class LambdaCallable : public MessageHandler<TMessage>
-  {
-  private:
-
-    IObserver&      observer_;
-    std::function<void (const TMessage&)> lambda_;
-
-  public:
-    LambdaCallable(IObserver& observer,
-                    std::function<void (const TMessage&)> lambdaFunction) :
-             observer_(observer),
-             lambda_(lambdaFunction)
-    {
-    }
-
-    virtual void Apply(const IMessage& message)
-    {
-      lambda_(dynamic_cast<const TMessage&>(message));
-    }
-
-    virtual MessageType GetMessageType() const
-    {
-      return static_cast<MessageType>(TMessage::Type);
-    }
-
-    virtual IObserver* GetObserver() const
-    {
-      return &observer_;
-    }
-  };
-
-
-}
-
 TEST(MessageBroker, TestLambdaSimpleUseCase)
 {
   MessageBroker broker;