changeset 1820:5baaad557d58

don't change mouse tool after creating an annotation
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 26 May 2021 13:08:49 +0200
parents fe402c678d18
children 36430d73e36c
files Applications/StoneWebViewer/WebApplication/app.js Applications/StoneWebViewer/WebApplication/index.html
diffstat 2 files changed, 40 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/StoneWebViewer/WebApplication/app.js	Wed May 26 13:08:15 2021 +0200
+++ b/Applications/StoneWebViewer/WebApplication/app.js	Wed May 26 13:08:49 2021 +0200
@@ -37,6 +37,15 @@
 // Registry of the PDF series for which the instance metadata is still waiting
 var pendingSeriesPdf_ = {};
 
+var MOUSE_TOOL_COMBINED = 1;
+var MOUSE_TOOL_ZOOM = 2;
+var MOUSE_TOOL_PAN = 3;
+var MOUSE_TOOL_CROSSHAIR = 4;
+var MOUSE_TOOL_CREATE_SEGMENT = 5;
+var MOUSE_TOOL_CREATE_ANGLE = 6;
+var MOUSE_TOOL_CREATE_CIRCLE = 7;
+var MOUSE_TOOL_REMOVE_MEASURE = 8;
+
 
 function getParameterFromUrl(key) {
   var url = window.location.search.substring(1);
@@ -391,8 +400,7 @@
       globalConfiguration: {},
       creatingArchive: false,
       archiveJob: '',
-      annotationsCurrentAction: stone.WebViewerAction.NONE,  // dummy value
-      annotationsBackupAction: stone.WebViewerAction.NONE,  // dummy value
+      mouseTool: 0,
 
       modalWarning: false,
       modalNotDiagnostic: false,
@@ -654,8 +662,6 @@
           sopInstanceUid: info.sopInstanceUid
         };
       }
-
-      this.ResetAnnotationsAction();
     },
     
     ClickSeries: function(seriesIndex) {
@@ -753,7 +759,6 @@
       }
 
       this.FitContent();
-      this.ResetAnnotationsAction();
     },
 
     UpdateSeriesThumbnail: function(seriesInstanceUid) {
@@ -863,39 +868,19 @@
       $('[data-toggle="tooltip"]').tooltip('hide');
     },
 
-    SetMouseButtonActions: function(left, middle, right) {
+    SetMouseButtonActions: function(tool, left, middle, right) {
       this.mouseActionsVisible = false;
-      this.annotationsBackupAction = stone.WebViewerAction.NONE;
+      this.mouseTool = tool;
       stone.SetMouseButtonActions(left, middle, right);
     },
 
-    SetAnnotationsAction: function(action) {
-      if (this.annotationsCurrentAction == action) {
-        this.ResetAnnotationsAction();
-      } else {
-        this.annotationsCurrentAction = action;
-
-        if (this.annotationsBackupAction == stone.WebViewerAction.NONE) {
-          this.annotationsBackupAction = stone.GetLeftMouseButtonAction();
-        }
-
-        stone.SetMouseButtonActions(action,
-                                    stone.GetMiddleMouseButtonAction(),
-                                    stone.GetRightMouseButtonAction());
-      }
+    SetLeftMouseButtonAction: function(tool, left) {
+      this.mouseActionsVisible = false;
+      this.mouseTool = tool;
+      stone.SetMouseButtonActions(left, stone.GetMiddleMouseButtonAction(),
+                                  stone.GetRightMouseButtonAction());
     },
 
-    ResetAnnotationsAction: function() {
-      if (this.annotationsBackupAction != stone.WebViewerAction.NONE) {
-        stone.SetMouseButtonActions(this.annotationsBackupAction,
-                                    stone.GetMiddleMouseButtonAction(),
-                                    stone.GetRightMouseButtonAction());
-      }
-
-      this.annotationsBackupAction = stone.WebViewerAction.NONE;
-      this.annotationsCurrentAction = stone.WebViewerAction.NONE;
-    },    
-
     LoadOsiriXAnnotations: function(xml, clearPrevious)
     {
       if (stone.LoadOsiriXAnnotations(xml, clearPrevious)) {
@@ -969,8 +954,8 @@
         middle = ConvertMouseAction(behaviour['MiddleMouseButton'], middle);
         right = ConvertMouseAction(behaviour['RightMouseButton'], right);
       }
-      
-      this.SetMouseButtonActions(left, middle, right);
+
+      this.SetMouseButtonActions(MOUSE_TOOL_COMBINED, left, middle, right);
     },
 
     CheckIsDownloadComplete: function()
@@ -1072,11 +1057,11 @@
     });
 
     window.addEventListener('StoneAnnotationAdded', function() {
-      that.ResetAnnotationsAction();
+      // Ignore
     });
 
     window.addEventListener('StoneAnnotationRemoved', function() {
-      that.ResetAnnotationsAction();
+      // Ignore
     });
   }
 });
--- a/Applications/StoneWebViewer/WebApplication/index.html	Wed May 26 13:08:15 2021 +0200
+++ b/Applications/StoneWebViewer/WebApplication/index.html	Wed May 26 13:08:49 2021 +0200
@@ -353,30 +353,34 @@
                 
                 <div class="tbGroup__buttons--bottom" v-show="mouseActionsVisible">
                   <div class="inline-object" v-if="globalConfiguration.CombinedToolEnabled">
-                    <button class="wvButton"
+                    <button class="wvButton--underline"
                             data-toggle="tooltip" data-title="Combined tool"
+                            v-bind:class="{ 'active' : mouseTool == MOUSE_TOOL_COMBINED }"
                             @click="SetCombinedToolActions()">
                       <i class="far fa-hand-point-up"></i>
                     </button>
                   </div>
                   <div class="inline-object">
-                    <button class="wvButton"
+                    <button class="wvButton--underline"
                             data-toggle="tooltip" data-title="Zoom"
-                            @click="SetMouseButtonActions(stone.WebViewerAction.ZOOM, stone.WebViewerAction.ZOOM, stone.WebViewerAction.ZOOM)">
+                            v-bind:class="{ 'active' : mouseTool == MOUSE_TOOL_ZOOM }"
+                            @click="SetMouseButtonActions(MOUSE_TOOL_ZOOM, stone.WebViewerAction.ZOOM, stone.WebViewerAction.ZOOM, stone.WebViewerAction.ZOOM)">
                       <i class="fas fa-search"></i>
                     </button>
                   </div>
                   <div class="inline-object">
-                    <button class="wvButton"
+                    <button class="wvButton--underline"
                             data-toggle="tooltip" data-title="Pan"
-                            @click="SetMouseButtonActions(stone.WebViewerAction.PAN, stone.WebViewerAction.PAN, stone.WebViewerAction.PAN)">
+                            v-bind:class="{ 'active' : mouseTool == MOUSE_TOOL_PAN }"
+                            @click="SetMouseButtonActions(MOUSE_TOOL_PAN, stone.WebViewerAction.PAN, stone.WebViewerAction.PAN, stone.WebViewerAction.PAN)">
                       <i class="fas fa-arrows-alt"></i>
                     </button>
                   </div>
                   <div class="inline-object">
-                    <button class="wvButton"
+                    <button class="wvButton--underline"
                             data-toggle="tooltip" data-title="3D cross-hair"
-                            @click="SetMouseButtonActions(stone.WebViewerAction.CROSSHAIR, stone.WebViewerAction.PAN, stone.WebViewerAction.ZOOM)">
+                            v-bind:class="{ 'active' : mouseTool == MOUSE_TOOL_CROSSHAIR }"
+                            @click="SetMouseButtonActions(MOUSE_TOOL_CROSSHAIR, stone.WebViewerAction.CROSSHAIR, stone.WebViewerAction.PAN, stone.WebViewerAction.ZOOM)">
                       <i class="fas fa-crosshairs"></i>
                     </button>
                   </div>
@@ -472,8 +476,8 @@
             
             <div class="ng-scope inline-object">
               <button class="wvButton--underline text-center"
-                      v-bind:class="{ active: (annotationsCurrentAction == stone.WebViewerAction.CREATE_SEGMENT) }"
-                      v-on:click="SetAnnotationsAction(stone.WebViewerAction.CREATE_SEGMENT)"
+                      v-bind:class="{ 'active' : mouseTool == MOUSE_TOOL_CREATE_SEGMENT }"
+                      v-on:click="SetLeftMouseButtonAction(MOUSE_TOOL_CREATE_SEGMENT, stone.WebViewerAction.CREATE_SEGMENT)"
                       data-toggle="tooltip" data-title="Measure length">
                 <i class="fas fa-arrows-alt-h"></i>
               </button>
@@ -481,8 +485,8 @@
 
             <div class="ng-scope inline-object">
               <button class="wvButton--underline text-center"
-                      v-bind:class="{ active: (annotationsCurrentAction == stone.WebViewerAction.CREATE_ANGLE) }" 
-                      v-on:click="SetAnnotationsAction(stone.WebViewerAction.CREATE_ANGLE)"
+                      v-bind:class="{ 'active' : mouseTool == MOUSE_TOOL_CREATE_ANGLE }"
+                      v-on:click="SetLeftMouseButtonAction(MOUSE_TOOL_CREATE_ANGLE, stone.WebViewerAction.CREATE_ANGLE)"
                       data-toggle="tooltip" data-title="Measure angle">
                 <i class="fas fa-angle-left fa-lg"></i>
               </button>
@@ -490,8 +494,8 @@
 
             <div class="ng-scope inline-object">
               <button class="wvButton--underline text-center"
-                      v-bind:class="{ active: (annotationsCurrentAction == stone.WebViewerAction.CREATE_CIRCLE) }" 
-                      v-on:click="SetAnnotationsAction(stone.WebViewerAction.CREATE_CIRCLE)"
+                      v-bind:class="{ 'active' : mouseTool == MOUSE_TOOL_CREATE_CIRCLE }"
+                      v-on:click="SetLeftMouseButtonAction(MOUSE_TOOL_CREATE_CIRCLE, stone.WebViewerAction.CREATE_CIRCLE)"
                       data-toggle="tooltip" data-title="Measure circle">
                 <i class="far fa-circle"></i>
               </button>
@@ -499,8 +503,8 @@
 
             <div class="ng-scope inline-object">
               <button class="wvButton--underline text-center"
-                      v-bind:class="{ active: (annotationsCurrentAction == stone.WebViewerAction.REMOVE_MEASURE) }" 
-                      v-on:click="SetAnnotationsAction(stone.WebViewerAction.REMOVE_MEASURE)"
+                      v-bind:class="{ 'active' : mouseTool == MOUSE_TOOL_REMOVE_MEASURE }"
+                      v-on:click="SetLeftMouseButtonAction(MOUSE_TOOL_REMOVE_MEASURE, stone.WebViewerAction.REMOVE_MEASURE)"
                       data-toggle="tooltip" data-title="Delete measurement">
                 <i class="fas fa-trash"></i>
               </button>