changeset 1071:6dd90b8d1589

Fixes related to refactorings in viewports.
author Benjamin Golinvaux <bgo@osimis.io>
date Tue, 15 Oct 2019 14:30:19 +0200
parents 2d6237221ff1
children 391fb6d6905d
files Framework/Messages/LockingEmitter.h Framework/StoneException.h Framework/Viewport/IViewport.h Framework/Viewport/ViewportBase.cpp Framework/Viewport/ViewportBase.h Resources/CMake/OrthancStoneConfiguration.cmake
diffstat 6 files changed, 52 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Messages/LockingEmitter.h	Tue Oct 15 10:54:53 2019 +0200
+++ b/Framework/Messages/LockingEmitter.h	Tue Oct 15 14:30:19 2019 +0200
@@ -20,6 +20,9 @@
 
 #pragma once
 
+#include <Core/Enumerations.h>
+#include <Core/OrthancException.h>
+
 #include "IMessageEmitter.h"
 #include "IObservable.h"
 
@@ -39,7 +42,7 @@
   class LockingEmitter : public IMessageEmitter
   {
   private:
-    boost::shared_mutex                mutex_;
+    boost::shared_mutex  mutex_;
     MessageBroker        broker_;
     IObservable          oracleObservable_;
 
--- a/Framework/StoneException.h	Tue Oct 15 10:54:53 2019 +0200
+++ b/Framework/StoneException.h	Tue Oct 15 14:30:19 2019 +0200
@@ -43,6 +43,7 @@
   };
 
 
+
   class StoneException
   {
   protected:
@@ -63,7 +64,35 @@
 
     virtual const char* What() const
     {
-      return "TODO: EnumerationToString for StoneException";
+      switch (errorCode_)
+      {
+      case ErrorCode_Success:
+        return "Success";
+        break;
+      case ErrorCode_OrthancError:
+        return "OrthancError";
+        break;
+      case ErrorCode_ApplicationException:
+        return "ApplicationException";
+        break;
+      case ErrorCode_NotImplemented:
+        return "NotImplemented";
+        break;
+      case ErrorCode_CanOnlyAddOneLayerAtATime:
+        return "CanOnlyAddOneLayerAtATime";
+        break;
+      case ErrorCode_CommandJsonInvalidFormat:
+        return "CommandJsonInvalidFormat";
+        break;
+      case ErrorCode_WebGLContextLost:
+        return "WebGLContextLost";
+        break;
+      case ErrorCode_Last:
+        return "Last";
+        break;
+      default:
+        return "Unknown exception code!";
+      }
     }
   };
 }
--- a/Framework/Viewport/IViewport.h	Tue Oct 15 10:54:53 2019 +0200
+++ b/Framework/Viewport/IViewport.h	Tue Oct 15 14:30:19 2019 +0200
@@ -42,10 +42,13 @@
 
     virtual void Refresh() = 0;
 
-    virtual ScenePoint2D GetPixelCenterCoordinates(int x, int y) = 0;
+    virtual ScenePoint2D GetPixelCenterCoordinates(int x, int y) const = 0;
 
     virtual bool HasCompositor() const = 0;
 
     virtual ICompositor& GetCompositor() = 0;
+
+    virtual const ICompositor& GetCompositor() const = 0;
   };
 }
+
--- a/Framework/Viewport/ViewportBase.cpp	Tue Oct 15 10:54:53 2019 +0200
+++ b/Framework/Viewport/ViewportBase.cpp	Tue Oct 15 14:30:19 2019 +0200
@@ -42,7 +42,7 @@
   }
   
 
-  ScenePoint2D ViewportBase::GetPixelCenterCoordinates(int x, int y)
+  ScenePoint2D ViewportBase::GetPixelCenterCoordinates(int x, int y) const
   {
     if (HasCompositor())
     {
--- a/Framework/Viewport/ViewportBase.h	Tue Oct 15 10:54:53 2019 +0200
+++ b/Framework/Viewport/ViewportBase.h	Tue Oct 15 14:30:19 2019 +0200
@@ -41,6 +41,14 @@
       return *scene_;
     }
 
-    virtual ScenePoint2D GetPixelCenterCoordinates(int x, int y) ORTHANC_OVERRIDE;
+    virtual ScenePoint2D GetPixelCenterCoordinates(int x, int y) const ORTHANC_OVERRIDE;
+
+    virtual const ICompositor& GetCompositor() const ORTHANC_OVERRIDE
+    {
+      IViewport* mutableThis = 
+        const_cast<IViewport*>(static_cast<const IViewport*>(this));
+      return mutableThis->GetCompositor();
+    }
+
   };
 }
--- a/Resources/CMake/OrthancStoneConfiguration.cmake	Tue Oct 15 10:54:53 2019 +0200
+++ b/Resources/CMake/OrthancStoneConfiguration.cmake	Tue Oct 15 14:30:19 2019 +0200
@@ -572,6 +572,8 @@
   ${ORTHANC_STONE_ROOT}/Framework/Toolbox/UndoRedoStack.cpp
   ${ORTHANC_STONE_ROOT}/Framework/Toolbox/UndoRedoStack.h
   
+  ${ORTHANC_STONE_ROOT}/Framework/Viewport/IViewport.h
+  ${ORTHANC_STONE_ROOT}/Framework/Viewport/ViewportBase.h
   ${ORTHANC_STONE_ROOT}/Framework/Viewport/ViewportBase.cpp
   
   ${ORTHANC_STONE_ROOT}/Framework/Volumes/IVolumeSlicer.cpp
@@ -658,14 +660,15 @@
 
   if (ENABLE_WASM)
     list(APPEND ORTHANC_STONE_SOURCES
+      ${ORTHANC_STONE_ROOT}/Framework/OpenGL/WebAssemblyOpenGLContext.h
       ${ORTHANC_STONE_ROOT}/Framework/OpenGL/WebAssemblyOpenGLContext.cpp
+      ${ORTHANC_STONE_ROOT}/Framework/Viewport/WebAssemblyViewport.h
       ${ORTHANC_STONE_ROOT}/Framework/Viewport/WebAssemblyViewport.cpp
       )
   endif()
 endif()
 
 
-
 ##
 ## TEST - Automatically add all ".h" headers to the list of sources
 ##