diff Applications/StoneWebViewer/WebApplication/app.js @ 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 b81775f1b196
children a56bf4c534ef
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
     });
   }
 });