changeset 561:1201b12eb9f8 dev

merge default -> dev
author Alain Mazy <alain@mazy.be>
date Thu, 18 Apr 2019 09:30:00 +0200
parents d5579bdc59b5 (current diff) aaeec7be8fb7 (diff)
children 37e396ae08a3 9b5d1bae869d
files Applications/StoneApplicationContext.h Framework/Layers/GrayscaleFrameRenderer.cpp Framework/Radiography/RadiographyWidget.cpp Framework/StoneEnumerations.h Framework/Viewport/WidgetViewport.cpp Framework/Widgets/WorldSceneWidget.cpp Resources/CMake/OrthancStoneConfiguration.cmake UnitTestsSources/TestMessageBroker.cpp
diffstat 16 files changed, 121 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/Sdl/SdlCairoSurface.cpp	Wed Apr 17 16:13:42 2019 +0200
+++ b/Applications/Sdl/SdlCairoSurface.cpp	Thu Apr 18 09:30:00 2019 +0200
@@ -51,7 +51,7 @@
         cairoSurface_->GetWidth() != width ||
         cairoSurface_->GetHeight() != height)
     {
-      cairoSurface_.reset(new CairoSurface(width, height));
+      cairoSurface_.reset(new CairoSurface(width, height, false /* no alpha */));
 
       // TODO Big endian?
       static const uint32_t rmask = 0x00ff0000;
--- a/Applications/Sdl/SdlWindow.h	Wed Apr 17 16:13:42 2019 +0200
+++ b/Applications/Sdl/SdlWindow.h	Thu Apr 18 09:30:00 2019 +0200
@@ -44,6 +44,11 @@
 
     ~SdlWindow();
 
+    SDL_Window *GetObject() const
+    {
+      return window_;
+    }
+
     unsigned int GetWidth() const;
 
     unsigned int GetHeight() const;
--- a/Applications/StoneApplicationContext.h	Wed Apr 17 16:13:42 2019 +0200
+++ b/Applications/StoneApplicationContext.h	Thu Apr 18 09:30:00 2019 +0200
@@ -27,24 +27,7 @@
 #include "../Framework/Viewport/WidgetViewport.h"
 
 
-#ifdef _MSC_VER
-  #if _MSC_VER > 1910
-    #define orthanc_override override
   #else
-    #define orthanc_override
-  #endif
-#elif defined __GNUC__
-  #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
-/* Test for GCC > 3.2.0 */
-  #if GCC_VERSION > 40900
-    #define orthanc_override override
-  #else
-    #define orthanc_override
-  #endif
-#else
-    #define orthanc_override
-#endif
-
 #include <list>
 
 namespace OrthancStone
--- a/Framework/Layers/ColorFrameRenderer.cpp	Wed Apr 17 16:13:42 2019 +0200
+++ b/Framework/Layers/ColorFrameRenderer.cpp	Thu Apr 18 09:30:00 2019 +0200
@@ -29,7 +29,7 @@
 {
   CairoSurface* ColorFrameRenderer::GenerateDisplay(const RenderStyle& style)
   {
-    std::auto_ptr<CairoSurface> display(new CairoSurface(frame_->GetWidth(), frame_->GetHeight()));
+    std::auto_ptr<CairoSurface> display(new CairoSurface(frame_->GetWidth(), frame_->GetHeight(), false /* no alpha */));
 
     Orthanc::ImageAccessor target;
     display->GetWriteableAccessor(target);
--- a/Framework/Layers/GrayscaleFrameRenderer.cpp	Wed Apr 17 16:13:42 2019 +0200
+++ b/Framework/Layers/GrayscaleFrameRenderer.cpp	Thu Apr 18 09:30:00 2019 +0200
@@ -41,7 +41,7 @@
 
     //LOG(INFO) << "Window: " << x0 << " => " << x1;
 
-    result.reset(new CairoSurface(frame_->GetWidth(), frame_->GetHeight()));
+    result.reset(new CairoSurface(frame_->GetWidth(), frame_->GetHeight(), false /* no alpha */));
 
     const uint8_t* lut = NULL;
     if (style.applyLut_)
--- a/Framework/Radiography/RadiographyWidget.cpp	Wed Apr 17 16:13:42 2019 +0200
+++ b/Framework/Radiography/RadiographyWidget.cpp	Thu Apr 18 09:30:00 2019 +0200
@@ -94,7 +94,7 @@
           cairoBuffer_->GetWidth() != width ||
           cairoBuffer_->GetHeight() != height)
       {
-        cairoBuffer_.reset(new CairoSurface(width, height));
+        cairoBuffer_.reset(new CairoSurface(width, height, false /* no alpha */));
       }
 
       RenderBackground(*floatBuffer_, x0, x1);
--- a/Framework/StoneEnumerations.cpp	Wed Apr 17 16:13:42 2019 +0200
+++ b/Framework/StoneEnumerations.cpp	Thu Apr 18 09:30:00 2019 +0200
@@ -78,7 +78,8 @@
                                 double& deltaY,
                                 BitmapAnchor anchor,
                                 unsigned int bitmapWidth,
-                                unsigned int bitmapHeight)
+                                unsigned int bitmapHeight,
+                                unsigned int border)
   {
     double dw = static_cast<double>(bitmapWidth);
     double dh = static_cast<double>(bitmapHeight);
@@ -133,5 +134,46 @@
       default:
         throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
     }    
+
+    if (border != 0)
+    {
+      double b = static_cast<double>(border);
+
+      switch (anchor)
+      {
+        case BitmapAnchor_TopLeft:
+        case BitmapAnchor_TopCenter:
+        case BitmapAnchor_TopRight:
+          deltaY += b;
+          break;
+        
+        case BitmapAnchor_BottomLeft:
+        case BitmapAnchor_BottomCenter:
+        case BitmapAnchor_BottomRight:
+          deltaY -= b;
+          break;
+        
+        default:
+          break;
+      }    
+
+      switch (anchor)
+      {
+        case BitmapAnchor_TopLeft:
+        case BitmapAnchor_CenterLeft:
+        case BitmapAnchor_BottomLeft:
+          deltaX += b;
+          break;
+
+        case BitmapAnchor_CenterRight:
+        case BitmapAnchor_TopRight:
+        case BitmapAnchor_BottomRight:
+          deltaX -= b;
+          break;
+        
+        default:
+          break;
+      }
+    }
   }
 }
--- a/Framework/StoneEnumerations.h	Wed Apr 17 16:13:42 2019 +0200
+++ b/Framework/StoneEnumerations.h	Thu Apr 18 09:30:00 2019 +0200
@@ -206,5 +206,6 @@
                                 double& deltaY /* out */,
                                 BitmapAnchor anchor,
                                 unsigned int bitmapWidth,
-                                unsigned int bitmapHeight);
+                                unsigned int bitmapHeight,
+                                unsigned int border = 0);
 }
--- a/Framework/Viewport/CairoSurface.cpp	Wed Apr 17 16:13:42 2019 +0200
+++ b/Framework/Viewport/CairoSurface.cpp	Thu Apr 18 09:30:00 2019 +0200
@@ -38,11 +38,15 @@
 
 
   void CairoSurface::Allocate(unsigned int width,
-                              unsigned int height)
+                              unsigned int height,
+                              bool hasAlpha)
   {
     Release();
 
-    surface_ = cairo_image_surface_create(CAIRO_FORMAT_RGB24, width, height);
+    hasAlpha_ = hasAlpha;
+
+    surface_ = cairo_image_surface_create
+      (hasAlpha ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24, width, height);
     if (!surface_)
     {
       // Should never occur
@@ -63,7 +67,9 @@
   }
 
 
-  CairoSurface::CairoSurface(Orthanc::ImageAccessor& accessor)
+  CairoSurface::CairoSurface(Orthanc::ImageAccessor& accessor,
+                             bool hasAlpha) :
+    hasAlpha_(hasAlpha)
   {
     if (accessor.GetFormat() != Orthanc::PixelFormat_BGRA32)
     {
@@ -76,7 +82,9 @@
     buffer_ = accessor.GetBuffer();
 
     surface_ = cairo_image_surface_create_for_data
-      (reinterpret_cast<unsigned char*>(buffer_), CAIRO_FORMAT_RGB24, width_, height_, pitch_);
+      (reinterpret_cast<unsigned char*>(buffer_),
+       hasAlpha_ ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24,
+       width_, height_, pitch_);
     if (!surface_)
     {
       // Should never occur
@@ -93,24 +101,44 @@
 
 
   void CairoSurface::SetSize(unsigned int width,
-                             unsigned int height)
+                             unsigned int height,
+                             bool hasAlpha)
   {
-    if (width_ != width ||
+    if (hasAlpha_ != hasAlpha ||
+        width_ != width ||
         height_ != height)
     {
-      Allocate(width, height);
+      Allocate(width, height, hasAlpha);
     }
   }
 
 
   void CairoSurface::Copy(const CairoSurface& other)
   {
+    SetSize(other.GetWidth(), other.GetHeight(), other.HasAlpha());
+    
     Orthanc::ImageAccessor source, target;
 
     other.GetReadOnlyAccessor(source);
     GetWriteableAccessor(target);
 
     Orthanc::ImageProcessing::Copy(target, source);
+
+    cairo_surface_mark_dirty(surface_);
+  }
+
+
+  void CairoSurface::Copy(const Orthanc::ImageAccessor& source,
+                          bool hasAlpha)
+  {
+    SetSize(source.GetWidth(), source.GetHeight(), hasAlpha);
+
+    Orthanc::ImageAccessor target;
+    GetWriteableAccessor(target);
+
+    Orthanc::ImageProcessing::Convert(target, source);
+
+    cairo_surface_mark_dirty(surface_);
   }
 
 
--- a/Framework/Viewport/CairoSurface.h	Wed Apr 17 16:13:42 2019 +0200
+++ b/Framework/Viewport/CairoSurface.h	Thu Apr 18 09:30:00 2019 +0200
@@ -36,27 +36,31 @@
     unsigned int     height_;
     unsigned int     pitch_;
     void*            buffer_;
+    bool             hasAlpha_;
 
     void Release();
 
     void Allocate(unsigned int width,
-                  unsigned int height);
+                  unsigned int height,
+                  bool hasAlpha);
 
   public:
     CairoSurface() :
       surface_(NULL)
     {
-      Allocate(0, 0);
+      Allocate(0, 0, false);
     }
 
     CairoSurface(unsigned int width,
-                 unsigned int height) :
+                 unsigned int height,
+                 bool hasAlpha) :
       surface_(NULL)
     {
-      Allocate(width, height);
+      Allocate(width, height, hasAlpha);
     }
 
-    CairoSurface(Orthanc::ImageAccessor& accessor);
+    CairoSurface(Orthanc::ImageAccessor& accessor,
+                 bool hasAlpha);
 
     ~CairoSurface()
     {
@@ -64,10 +68,14 @@
     }
 
     void SetSize(unsigned int width,
-                 unsigned int height);
+                 unsigned int height,
+                 bool hasAlpha);
 
     void Copy(const CairoSurface& other);
 
+    void Copy(const Orthanc::ImageAccessor& source,
+              bool hasAlpha);
+
     unsigned int GetWidth() const
     {
       return width_;
@@ -98,6 +106,11 @@
       return surface_;
     }
 
+    bool HasAlpha() const
+    {
+      return hasAlpha_;
+    }
+
     void GetReadOnlyAccessor(Orthanc::ImageAccessor& target) const;
 
     void GetWriteableAccessor(Orthanc::ImageAccessor& target);
--- a/Framework/Viewport/WidgetViewport.cpp	Wed Apr 17 16:13:42 2019 +0200
+++ b/Framework/Viewport/WidgetViewport.cpp	Thu Apr 18 09:30:00 2019 +0200
@@ -90,7 +90,7 @@
   void WidgetViewport::SetSize(unsigned int width,
                                unsigned int height)
   {
-    background_.SetSize(width, height);
+    background_.SetSize(width, height, false /* no alpha */);
 
     if (centralWidget_.get() != NULL)
     {
--- a/Framework/Widgets/CairoWidget.cpp	Wed Apr 17 16:13:42 2019 +0200
+++ b/Framework/Widgets/CairoWidget.cpp	Thu Apr 18 09:30:00 2019 +0200
@@ -40,7 +40,7 @@
   void CairoWidget::SetSize(unsigned int width,
                             unsigned int height)
   {
-    surface_.SetSize(width, height);
+    surface_.SetSize(width, height, false /* no alpha */);
   }
   
 
@@ -51,7 +51,7 @@
 
     if (IsAligned(target))
     {
-      CairoSurface surface(target);
+      CairoSurface surface(target, false /* no alpha */);
       CairoContext context(surface);
       ClearBackgroundCairo(context);
       return RenderCairo(context);
@@ -82,7 +82,7 @@
   {
     if (IsAligned(target))
     {
-      CairoSurface surface(target);
+      CairoSurface surface(target, false /* no alpha */);
       CairoContext context(surface);
       RenderMouseOverCairo(context, x, y);
     }
--- a/Framework/Widgets/WidgetBase.cpp	Wed Apr 17 16:13:42 2019 +0200
+++ b/Framework/Widgets/WidgetBase.cpp	Thu Apr 18 09:30:00 2019 +0200
@@ -86,7 +86,7 @@
 
   void WidgetBase::ClearBackgroundCairo(Orthanc::ImageAccessor& target) const
   {
-    CairoSurface surface(target);
+    CairoSurface surface(target, false /* no alpha */);
     CairoContext context(surface);
     ClearBackgroundCairo(context);
   }
--- a/Framework/Widgets/WorldSceneWidget.cpp	Wed Apr 17 16:13:42 2019 +0200
+++ b/Framework/Widgets/WorldSceneWidget.cpp	Thu Apr 18 09:30:00 2019 +0200
@@ -60,7 +60,7 @@
     {
       if (tracker_->HasRender())
       {
-        CairoSurface surface(target);
+        CairoSurface surface(target, false /* no alpha */);
         CairoContext context(surface);
         view_.ApplyTransform(context);
         tracker_->Render(context, view_.GetZoom());
--- a/Resources/CMake/OrthancStoneConfiguration.cmake	Wed Apr 17 16:13:42 2019 +0200
+++ b/Resources/CMake/OrthancStoneConfiguration.cmake	Thu Apr 18 09:30:00 2019 +0200
@@ -25,7 +25,9 @@
 if (ENABLE_DCMTK)
   set(ENABLE_LOCALE ON)
 else()
-  set(ENABLE_LOCALE OFF)  # Disable support for locales (notably in Boost)
+  if (NOT DEFINED ENABLE_LOCALE)
+    set(ENABLE_LOCALE OFF)  # Disable support for locales (notably in Boost)
+  endif()
 endif()
 
 include(${ORTHANC_ROOT}/Resources/CMake/OrthancFrameworkConfiguration.cmake)
@@ -141,10 +143,12 @@
   COLORMAP_RED    ${ORTHANC_STONE_ROOT}/Resources/Colormaps/red.lut
   COLORMAP_GREEN  ${ORTHANC_STONE_ROOT}/Resources/Colormaps/green.lut
   COLORMAP_BLUE   ${ORTHANC_STONE_ROOT}/Resources/Colormaps/blue.lut
+
+  # Additional resources specific to the application being built
+  ${ORTHANC_STONE_APPLICATION_RESOURCES}
   )
 
 
-
 #####################################################################
 ## System-specific patches
 #####################################################################
--- a/UnitTestsSources/TestMessageBroker.cpp	Wed Apr 17 16:13:42 2019 +0200
+++ b/UnitTestsSources/TestMessageBroker.cpp	Thu Apr 18 09:30:00 2019 +0200
@@ -312,7 +312,7 @@
   ASSERT_EQ(0, testCounter);
 }
 
-#if 0 //__cplusplus >= 201103L
+#if 0 /* __cplusplus >= 201103L*/
 
 TEST(MessageBroker, TestLambdaSimpleUseCase)
 {