Mercurial > hg > orthanc-stone
comparison Applications/StoneWebViewer/WebApplication/app.js @ 2003:963f28eb40cb deep-learning
integration default->deep-learning
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 02 Nov 2022 15:14:56 +0100 |
parents | 2034ae383cfd e943a84da9ac |
children | 04148de691a7 |
comparison
equal
deleted
inserted
replaced
1964:2034ae383cfd | 2003:963f28eb40cb |
---|---|
40 | 40 |
41 var MOUSE_TOOL_COMBINED = 1; | 41 var MOUSE_TOOL_COMBINED = 1; |
42 var MOUSE_TOOL_ZOOM = 2; | 42 var MOUSE_TOOL_ZOOM = 2; |
43 var MOUSE_TOOL_PAN = 3; | 43 var MOUSE_TOOL_PAN = 3; |
44 var MOUSE_TOOL_CROSSHAIR = 4; | 44 var MOUSE_TOOL_CROSSHAIR = 4; |
45 var MOUSE_TOOL_CREATE_SEGMENT = 5; | 45 var MOUSE_TOOL_CREATE_LENGTH = 5; |
46 var MOUSE_TOOL_CREATE_ANGLE = 6; | 46 var MOUSE_TOOL_CREATE_ANGLE = 6; |
47 var MOUSE_TOOL_CREATE_CIRCLE = 7; | 47 var MOUSE_TOOL_CREATE_CIRCLE = 7; |
48 var MOUSE_TOOL_REMOVE_MEASURE = 8; | 48 var MOUSE_TOOL_REMOVE_MEASURE = 8; |
49 var MOUSE_TOOL_CREATE_PIXEL_PROBE = 9; // New in 2.4 | |
50 var MOUSE_TOOL_CREATE_ELLIPSE_PROBE = 10; // New in 2.4 | |
51 var MOUSE_TOOL_CREATE_RECTANGLE_PROBE = 11; // New in 2.4 | |
52 var MOUSE_TOOL_CREATE_TEXT_ANNOTATION = 12; // New in 2.4 | |
53 var MOUSE_TOOL_MAGNIFYING_GLASS = 13; // New in 2.4 | |
49 | 54 |
50 | 55 |
51 function getParameterFromUrl(key) { | 56 function getParameterFromUrl(key) { |
52 var url = window.location.search.substring(1); | 57 var url = window.location.search.substring(1); |
53 var args = url.split('&'); | 58 var args = url.split('&'); |
106 else if (config == "Rotate") { | 111 else if (config == "Rotate") { |
107 return stone.WebViewerAction.ROTATE; | 112 return stone.WebViewerAction.ROTATE; |
108 } | 113 } |
109 else if (config == "Crosshair") { | 114 else if (config == "Crosshair") { |
110 return stone.WebViewerAction.CROSSHAIR; | 115 return stone.WebViewerAction.CROSSHAIR; |
116 } | |
117 else if (config == "MagnifyingGlass") { | |
118 return stone.WebViewerAction.MAGNIFYING_GLASS; | |
111 } | 119 } |
112 else { | 120 else { |
113 alert('Unsupported mouse action in the configuration file: ' + config); | 121 alert('Unsupported mouse action in the configuration file: ' + config); |
114 return stone.WebViewerAction.PAN; | 122 return stone.WebViewerAction.PAN; |
115 } | 123 } |
139 data: function () { | 147 data: function () { |
140 return { | 148 return { |
141 stone: stone, // To access global object "stone" from "index.html" | 149 stone: stone, // To access global object "stone" from "index.html" |
142 status: 'waiting', | 150 status: 'waiting', |
143 currentFrame: 0, | 151 currentFrame: 0, |
152 currentFrameFromUser: 0, | |
144 numberOfFrames: 0, | 153 numberOfFrames: 0, |
145 quality: '', | 154 quality: '', |
146 cineControls: false, | 155 cineControls: false, |
147 cineIncrement: 0, | 156 cineIncrement: 0, |
148 cineFramesPerSecond: 30, | 157 cineFramesPerSecond: 30, |
156 contentTime: '', | 165 contentTime: '', |
157 } | 166 } |
158 }, | 167 }, |
159 watch: { | 168 watch: { |
160 currentFrame: function(newVal, oldVal) { | 169 currentFrame: function(newVal, oldVal) { |
161 /** | 170 this.currentFrameFromUser = newVal + 1; |
162 * The "FrameUpdated" event has been received, which indicates | 171 if (this.cineLoadingFrame) { |
163 * that the schedule frame has been displayed: The cine loop can | 172 /** |
164 * proceed to the next frame (check out "CineCallback()"). | 173 * The "FrameUpdated" event has been received, which indicates |
165 **/ | 174 * that the schedule frame has been displayed: The cine loop can |
166 this.cineLoadingFrame = false; | 175 * proceed to the next frame (check out "CineCallback()"). |
176 **/ | |
177 this.cineLoadingFrame = false; | |
178 } else { | |
179 stone.SetFrame(this.canvasId, newVal); | |
180 } | |
181 }, | |
182 currentFrameFromUser: function(newVal, oldVal) { | |
183 if (parseInt(newVal, 10) !== NaN && | |
184 newVal >= 1 && | |
185 newVal <= this.numberOfFrames) { | |
186 this.currentFrame = this.currentFrameFromUser - 1; | |
187 } | |
167 }, | 188 }, |
168 content: function(newVal, oldVal) { | 189 content: function(newVal, oldVal) { |
169 this.status = 'loading'; | 190 this.status = 'loading'; |
170 this.cineControls = false; | 191 this.cineControls = false; |
171 this.cineMode = ''; | 192 this.cineMode = ''; |
422 modalPreferences: false, | 443 modalPreferences: false, |
423 | 444 |
424 // User preferences (stored in the local storage) | 445 // User preferences (stored in the local storage) |
425 settingNotDiagnostic: true, | 446 settingNotDiagnostic: true, |
426 settingSoftwareRendering: false, | 447 settingSoftwareRendering: false, |
448 settingLinearInterpolation: true, | |
427 | 449 |
428 layoutCountX: 1, | 450 layoutCountX: 1, |
429 layoutCountY: 1, | 451 layoutCountY: 1, |
430 | 452 |
431 viewport1Width: '100%', | 453 viewport1Width: '100%', |
503 settingNotDiagnostic: function(newVal, oldVal) { | 525 settingNotDiagnostic: function(newVal, oldVal) { |
504 localStorage.settingNotDiagnostic = (newVal ? '1' : '0'); | 526 localStorage.settingNotDiagnostic = (newVal ? '1' : '0'); |
505 }, | 527 }, |
506 settingSoftwareRendering: function(newVal, oldVal) { | 528 settingSoftwareRendering: function(newVal, oldVal) { |
507 localStorage.settingSoftwareRendering = (newVal ? '1' : '0'); | 529 localStorage.settingSoftwareRendering = (newVal ? '1' : '0'); |
530 }, | |
531 settingLinearInterpolation: function(newVal, oldVal) { | |
532 localStorage.settingLinearInterpolation = (newVal ? '1' : '0'); | |
508 } | 533 } |
509 }, | 534 }, |
510 methods: { | 535 methods: { |
511 FitContent: function() { | 536 FitContent: function() { |
512 // This function can be used even if WebAssembly is not initialized yet | 537 // This function can be used even if WebAssembly is not initialized yet |
883 if (canvas != '') { | 908 if (canvas != '') { |
884 stone.FlipY(canvas); | 909 stone.FlipY(canvas); |
885 } | 910 } |
886 }, | 911 }, |
887 | 912 |
913 RotateLeft: function() { | |
914 var canvas = this.GetActiveCanvas(); | |
915 if (canvas != '') { | |
916 stone.RotateLeft(canvas); | |
917 } | |
918 }, | |
919 | |
920 RotateRight: function() { | |
921 var canvas = this.GetActiveCanvas(); | |
922 if (canvas != '') { | |
923 stone.RotateRight(canvas); | |
924 } | |
925 }, | |
926 | |
888 ApplyPreferences: function() { | 927 ApplyPreferences: function() { |
889 this.modalPreferences = false; | 928 this.modalPreferences = false; |
929 | |
930 stone.SetLinearInterpolation(localStorage.settingLinearInterpolation); | |
890 | 931 |
891 if ((stone.IsSoftwareRendering() != 0) != this.settingSoftwareRendering) { | 932 if ((stone.IsSoftwareRendering() != 0) != this.settingSoftwareRendering) { |
892 document.location.reload(); | 933 document.location.reload(); |
893 } | 934 } |
894 }, | 935 }, |
1112 stone.ApplyDeepLearningModel(this.GetActiveCanvas()); | 1153 stone.ApplyDeepLearningModel(this.GetActiveCanvas()); |
1113 } | 1154 } |
1114 }, | 1155 }, |
1115 | 1156 |
1116 mounted: function() { | 1157 mounted: function() { |
1158 // Warning: In this function, the "stone" global object is not initialized yet! | |
1159 | |
1117 this.SetViewportLayout('1x1'); | 1160 this.SetViewportLayout('1x1'); |
1118 | 1161 |
1119 if (localStorage.settingNotDiagnostic) { | 1162 if (localStorage.settingNotDiagnostic) { |
1120 this.settingNotDiagnostic = (localStorage.settingNotDiagnostic == '1'); | 1163 this.settingNotDiagnostic = (localStorage.settingNotDiagnostic == '1'); |
1121 } | 1164 } |
1122 | 1165 |
1123 if (localStorage.settingSoftwareRendering) { | 1166 if (localStorage.settingSoftwareRendering) { |
1124 this.settingSoftwareRendering = (localStorage.settingSoftwareRendering == '1'); | 1167 this.settingSoftwareRendering = (localStorage.settingSoftwareRendering == '1'); |
1168 } | |
1169 | |
1170 if (localStorage.settingLinearInterpolation) { | |
1171 this.settingLinearInterpolation = (localStorage.settingLinearInterpolation == '1'); | |
1125 } | 1172 } |
1126 | 1173 |
1127 var that = this; | 1174 var that = this; |
1128 | 1175 |
1129 window.addEventListener('VirtualSeriesThumbnailLoaded', function(args) { | 1176 window.addEventListener('VirtualSeriesThumbnailLoaded', function(args) { |
1147 }); | 1194 }); |
1148 | 1195 |
1149 window.addEventListener('StoneAnnotationRemoved', function() { | 1196 window.addEventListener('StoneAnnotationRemoved', function() { |
1150 // Ignore | 1197 // Ignore |
1151 }); | 1198 }); |
1199 | |
1200 window.addEventListener('TextAnnotationRequired', function(args) { | |
1201 var label = prompt('Enter your annotation:', ''); | |
1202 if (label !== null) { | |
1203 stone.AddTextAnnotation(args.detail.canvasId, label, | |
1204 args.detail.pointedX, args.detail.pointedY, | |
1205 args.detail.labelX, args.detail.labelY); | |
1206 } | |
1207 }); | |
1152 } | 1208 } |
1153 }); | 1209 }); |
1154 | 1210 |
1155 | 1211 |
1156 | 1212 |
1161 **/ | 1217 **/ |
1162 | 1218 |
1163 stone.Setup(Module); | 1219 stone.Setup(Module); |
1164 stone.SetDicomWebRoot(app.globalConfiguration.DicomWebRoot, | 1220 stone.SetDicomWebRoot(app.globalConfiguration.DicomWebRoot, |
1165 true /* assume "/rendered" is available in DICOMweb (could be a configuration option) */); | 1221 true /* assume "/rendered" is available in DICOMweb (could be a configuration option) */); |
1166 stone.SetSoftwareRendering(localStorage.settingSoftwareRendering == '1'); | 1222 stone.SetSoftwareRendering(app.settingSoftwareRendering); |
1223 stone.SetLinearInterpolation(app.settingLinearInterpolation); | |
1167 | 1224 |
1168 if ('DicomCacheSize' in app.globalConfiguration) { | 1225 if ('DicomCacheSize' in app.globalConfiguration) { |
1169 stone.SetDicomCacheSize(app.globalConfiguration.DicomCacheSize); | 1226 stone.SetDicomCacheSize(app.globalConfiguration.DicomCacheSize); |
1170 } | 1227 } |
1171 | 1228 |