changeset 1993:317a53d4fdc6

added magnifying glass
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 31 Oct 2022 22:19:57 +0100
parents 237e0eb40f38
children 2f242d231a22
files Applications/StoneWebViewer/NEWS Applications/StoneWebViewer/WebApplication/app.js Applications/StoneWebViewer/WebApplication/configuration.json Applications/StoneWebViewer/WebApplication/index.html Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp OrthancStone/Resources/CMake/OrthancStoneConfiguration.cmake OrthancStone/Sources/Scene2D/MagnifyingGlassTracker.cpp OrthancStone/Sources/Scene2D/MagnifyingGlassTracker.h OrthancStone/Sources/StoneEnumerations.h OrthancStone/Sources/Viewport/DefaultViewportInteractor.cpp
diffstat 10 files changed, 177 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/StoneWebViewer/NEWS	Mon Oct 31 21:07:36 2022 +0100
+++ b/Applications/StoneWebViewer/NEWS	Mon Oct 31 22:19:57 2022 +0100
@@ -6,6 +6,7 @@
   - Rectangle probe
   - Ellipse probe
 * Added left/right rotation buttons
+* Added magnifying glass
 * Added vertical slider showing position of the current frame inside the series
 * Display of orientation markers
 * The text field with the instance number is editable to go to a specific instance
--- a/Applications/StoneWebViewer/WebApplication/app.js	Mon Oct 31 21:07:36 2022 +0100
+++ b/Applications/StoneWebViewer/WebApplication/app.js	Mon Oct 31 22:19:57 2022 +0100
@@ -50,6 +50,7 @@
 var MOUSE_TOOL_CREATE_ELLIPSE_PROBE = 10;    // New in 2.4
 var MOUSE_TOOL_CREATE_RECTANGLE_PROBE = 11;  // New in 2.4
 var MOUSE_TOOL_CREATE_TEXT_ANNOTATION = 12;  // New in 2.4
+var MOUSE_TOOL_MAGNIFYING_GLASS = 13;        // New in 2.4
 
 
 function getParameterFromUrl(key) {
@@ -113,6 +114,9 @@
   else if (config == "Crosshair") {
     return stone.WebViewerAction.CROSSHAIR;
   }
+  else if (config == "MagnifyingGlass") {
+    return stone.WebViewerAction.MAGNIFYING_GLASS;
+  }
   else {
     alert('Unsupported mouse action in the configuration file: ' + config);
     return stone.WebViewerAction.PAN;
--- a/Applications/StoneWebViewer/WebApplication/configuration.json	Mon Oct 31 21:07:36 2022 +0100
+++ b/Applications/StoneWebViewer/WebApplication/configuration.json	Mon Oct 31 22:19:57 2022 +0100
@@ -37,7 +37,8 @@
      * windowing, zoom and pan from a single mouse configuration. The
      * behaviour of the combined tool is defined in
      * CombinedToolBehaviour. The available mouse actions are
-     * "Crosshair", "Windowing", "Pan", "Rotate" and "Zoom".
+     * "Crosshair", "Windowing", "Pan", "Rotate", "Zoom" and
+     * "MagnifyingGlass".
      **/
     "CombinedToolEnabled" : true,
     "CombinedToolBehaviour" : {
--- a/Applications/StoneWebViewer/WebApplication/index.html	Mon Oct 31 21:07:36 2022 +0100
+++ b/Applications/StoneWebViewer/WebApplication/index.html	Mon Oct 31 22:19:57 2022 +0100
@@ -485,6 +485,15 @@
 
             <div class="ng-scope inline-object">
               <button class="wvButton--underline text-center"
+                      data-toggle="tooltip" data-title="Magnifying glass"
+                      v-bind:class="{ 'active' : mouseTool == MOUSE_TOOL_MAGNIFYING_GLASS }"
+                      v-on:click="SetMouseButtonActions(MOUSE_TOOL_MAGNIFYING_GLASS, stone.WebViewerAction.MAGNIFYING_GLASS, stone.WebViewerAction.PAN, stone.WebViewerAction.ZOOM)">
+                <i class="fas fa-search-plus"></i>
+              </button>
+            </div>
+
+            <div class="ng-scope inline-object">
+              <button class="wvButton--underline text-center"
                       data-toggle="tooltip" data-title="Rotate to the left"
                       v-on:click="RotateLeft()">
                 <i class="fas fa-undo"></i>
--- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Mon Oct 31 21:07:36 2022 +0100
+++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Mon Oct 31 22:19:57 2022 +0100
@@ -141,6 +141,7 @@
     WebViewerAction_Pan,
     WebViewerAction_Rotate,
     WebViewerAction_Crosshair,
+    WebViewerAction_MagnifyingGlass,       // New in 2.4
     
     WebViewerAction_CreateAngle,
     WebViewerAction_CreateCircle,
@@ -170,6 +171,9 @@
     case WebViewerAction_Rotate:
       return OrthancStone::MouseAction_Rotate;
       
+    case WebViewerAction_MagnifyingGlass:
+      return OrthancStone::MouseAction_MagnifyingGlass;
+      
     case WebViewerAction_None:
     case WebViewerAction_Crosshair:
     case WebViewerAction_CreateAngle:
--- a/OrthancStone/Resources/CMake/OrthancStoneConfiguration.cmake	Mon Oct 31 21:07:36 2022 +0100
+++ b/OrthancStone/Resources/CMake/OrthancStoneConfiguration.cmake	Mon Oct 31 22:19:57 2022 +0100
@@ -304,6 +304,8 @@
   ${ORTHANC_STONE_ROOT}/Scene2D/LookupTableTextureSceneLayer.h
   ${ORTHANC_STONE_ROOT}/Scene2D/MacroSceneLayer.cpp
   ${ORTHANC_STONE_ROOT}/Scene2D/MacroSceneLayer.h
+  ${ORTHANC_STONE_ROOT}/Scene2D/MagnifyingGlassTracker.cpp
+  ${ORTHANC_STONE_ROOT}/Scene2D/MagnifyingGlassTracker.h
   ${ORTHANC_STONE_ROOT}/Scene2D/NullLayer.h
   ${ORTHANC_STONE_ROOT}/Scene2D/PanSceneTracker.cpp
   ${ORTHANC_STONE_ROOT}/Scene2D/PanSceneTracker.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OrthancStone/Sources/Scene2D/MagnifyingGlassTracker.cpp	Mon Oct 31 22:19:57 2022 +0100
@@ -0,0 +1,94 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2022 Osimis S.A., Belgium
+ * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/>.
+ **/
+
+
+#include "MagnifyingGlassTracker.h"
+
+#include "../Scene2DViewport/ViewportController.h"
+#include "../Viewport/ViewportLocker.h"
+
+namespace OrthancStone
+{
+  void MagnifyingGlassTracker::Update(ViewportLocker& locker,
+                                      const PointerEvent& event)
+  {
+    ScenePoint2D p = event.GetMainPosition().Apply(originalCanvasToScene_);
+
+    locker.GetController().SetSceneToCanvasTransform(
+      AffineTransform2D::Combine(
+        originalSceneToCanvas_,
+        AffineTransform2D::CreateOffset(p.GetX(), p.GetY()),
+        AffineTransform2D::CreateScaling(5, 5),
+        AffineTransform2D::CreateOffset(-pivot_.GetX(), -pivot_.GetY())));
+
+    locker.Invalidate();
+  }
+    
+
+  MagnifyingGlassTracker::MagnifyingGlassTracker(boost::weak_ptr<IViewport> viewport,
+                                                 const PointerEvent& event) :
+    viewport_(viewport)
+  {
+    ViewportLocker locker(viewport_);
+    
+    if (locker.IsValid())
+    {
+      originalSceneToCanvas_ = locker.GetController().GetSceneToCanvasTransform();
+      originalCanvasToScene_ = locker.GetController().GetCanvasToSceneTransform();
+      pivot_ = event.GetMainPosition().Apply(locker.GetController().GetCanvasToSceneTransform());
+
+      Update(locker, event);
+    }
+  }
+      
+
+  void MagnifyingGlassTracker::PointerUp(const PointerEvent& event,
+                                         const Scene2D& scene)
+  {
+    Cancel(scene);
+    OneGesturePointerTracker::PointerUp(event, scene);
+  }
+
+  
+  void MagnifyingGlassTracker::PointerMove(const PointerEvent& event,
+                                           const Scene2D& scene)
+  {
+    ViewportLocker locker(viewport_);
+    
+    if (locker.IsValid())
+    {
+      Update(locker, event);
+    }
+  }
+    
+
+  void MagnifyingGlassTracker::Cancel(const Scene2D& scene)
+  {
+    ViewportLocker locker(viewport_);
+    
+    if (locker.IsValid())
+    {
+      locker.GetController().SetSceneToCanvasTransform(originalSceneToCanvas_);
+      locker.Invalidate();
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OrthancStone/Sources/Scene2D/MagnifyingGlassTracker.h	Mon Oct 31 22:19:57 2022 +0100
@@ -0,0 +1,56 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2022 Osimis S.A., Belgium
+ * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/>.
+ **/
+
+
+#pragma once
+
+#include "../Scene2DViewport/OneGesturePointerTracker.h"
+#include "../Viewport/ViewportLocker.h"
+
+#include <boost/weak_ptr.hpp>
+
+namespace OrthancStone
+{
+  class MagnifyingGlassTracker : public OneGesturePointerTracker
+  {
+  private:
+    boost::weak_ptr<IViewport>  viewport_;
+    ScenePoint2D                pivot_;
+    AffineTransform2D           originalSceneToCanvas_;
+    AffineTransform2D           originalCanvasToScene_;
+
+    void Update(ViewportLocker& locker,
+                const PointerEvent& event);
+    
+  public:
+    MagnifyingGlassTracker(boost::weak_ptr<IViewport> viewport,
+                           const PointerEvent& event);
+    
+    virtual void PointerUp(const PointerEvent& event,
+                           const Scene2D& scene) ORTHANC_OVERRIDE;
+    
+    virtual void PointerMove(const PointerEvent& event,
+                             const Scene2D& scene) ORTHANC_OVERRIDE;
+    
+    virtual void Cancel(const Scene2D& scene) ORTHANC_OVERRIDE;
+  };
+}
--- a/OrthancStone/Sources/StoneEnumerations.h	Mon Oct 31 21:07:36 2022 +0100
+++ b/OrthancStone/Sources/StoneEnumerations.h	Mon Oct 31 22:19:57 2022 +0100
@@ -156,6 +156,7 @@
     MouseAction_Zoom,
     MouseAction_Rotate,
     MouseAction_GrayscaleWindowing,
+    MouseAction_MagnifyingGlass,
     MouseAction_None
   };
 
--- a/OrthancStone/Sources/Viewport/DefaultViewportInteractor.cpp	Mon Oct 31 21:07:36 2022 +0100
+++ b/OrthancStone/Sources/Viewport/DefaultViewportInteractor.cpp	Mon Oct 31 22:19:57 2022 +0100
@@ -23,6 +23,7 @@
 #include "DefaultViewportInteractor.h"
 
 #include "../Scene2D/GrayscaleWindowingSceneTracker.h"
+#include "../Scene2D/MagnifyingGlassTracker.h"
 #include "../Scene2D/PanSceneTracker.h"
 #include "../Scene2D/RotateSceneTracker.h"
 #include "../Scene2D/ZoomSceneTracker.h"
@@ -77,6 +78,9 @@
       case MouseAction_Zoom:
         return new ZoomSceneTracker(viewport, event, viewportHeight);
       
+      case MouseAction_MagnifyingGlass:
+        return new MagnifyingGlassTracker(viewport, event);
+
       default:
         throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
     }