Mercurial > hg > orthanc-stone
comparison Applications/StoneWebViewer/WebApplication/app.js @ 2020:88673f50d7b9
added key bindings to change active study and series
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 03 Dec 2022 11:59:20 +0100 |
parents | fe9999d6a636 |
children | 96d20b42e740 |
comparison
equal
deleted
inserted
replaced
2019:fe9999d6a636 | 2020:88673f50d7b9 |
---|---|
120 } | 120 } |
121 else { | 121 else { |
122 alert('Unsupported mouse action in the configuration file: ' + config); | 122 alert('Unsupported mouse action in the configuration file: ' + config); |
123 return stone.WebViewerAction.PAN; | 123 return stone.WebViewerAction.PAN; |
124 } | 124 } |
125 } | |
126 | |
127 | |
128 function LookupIndexOfResource(array, tag, value) { | |
129 for (var i = 0; i < array.length; i++) { | |
130 if (array[i].tags[tag] == value) { | |
131 return i; | |
132 } | |
133 } | |
134 | |
135 return -1; | |
125 } | 136 } |
126 | 137 |
127 | 138 |
128 /** | 139 /** |
129 * Enable support for tooltips in Bootstrap. This function must be | 140 * Enable support for tooltips in Bootstrap. This function must be |
349 that.windowingCenter = args.detail.windowingCenter; | 360 that.windowingCenter = args.detail.windowingCenter; |
350 that.windowingWidth = args.detail.windowingWidth; | 361 that.windowingWidth = args.detail.windowingWidth; |
351 } | 362 } |
352 }); | 363 }); |
353 | 364 |
354 window.addEventListener('CineSwitch', function(args) { | 365 window.addEventListener('KeyCineSwitch', function(args) { |
355 if (that.active) { | 366 if (that.active) { |
356 that.CineSwitch(); | 367 that.KeyCineSwitch(); |
357 } | 368 } |
358 }); | 369 }); |
359 }, | 370 }, |
360 methods: { | 371 methods: { |
361 DragDrop: function(event) { | 372 DragDrop: function(event) { |
393 CineBackward: function() { | 404 CineBackward: function() { |
394 this.cineControls = true; | 405 this.cineControls = true; |
395 this.cineIncrement = 1; | 406 this.cineIncrement = 1; |
396 this.UpdateCine(); | 407 this.UpdateCine(); |
397 }, | 408 }, |
398 CineSwitch: function() { | 409 KeyCineSwitch: function() { |
399 if (this.cineIncrement != 0) { | 410 if (this.cineIncrement != 0) { |
400 this.CinePause(); | 411 this.CinePause(); |
401 } else { | 412 } else { |
402 this.CinePlay(); | 413 this.CinePlay(); |
403 } | 414 } |
587 this.$nextTick(function () { | 598 this.$nextTick(function () { |
588 stone.AllViewportsUpdateSize(true /* fit content */); | 599 stone.AllViewportsUpdateSize(true /* fit content */); |
589 }); | 600 }); |
590 } | 601 } |
591 }, | 602 }, |
603 | |
604 GetActiveViewportSeriesTags: function() { | |
605 if (this.activeViewport == 1 && | |
606 this.viewport1Content.virtualSeriesId === undefined) { | |
607 return this.viewport1Content.series.tags; | |
608 } | |
609 else if (this.activeViewport == 2 && | |
610 this.viewport2Content.virtualSeriesId === undefined) { | |
611 return this.viewport2Content.series.tags; | |
612 } | |
613 else if (this.activeViewport == 3 && | |
614 this.viewport3Content.virtualSeriesId === undefined) { | |
615 return this.viewport3Content.series.tags; | |
616 } | |
617 else if (this.activeViewport == 4 && | |
618 this.viewport4Content.virtualSeriesId === undefined) { | |
619 return this.viewport4Content.series.tags; | |
620 } | |
621 else { | |
622 return null; | |
623 } | |
624 }, | |
592 | 625 |
593 GetActiveSeries: function() { | 626 GetActiveSeriesInstanceUid: function() { |
594 var s = []; | 627 var s = []; |
595 | 628 |
596 if ('tags' in this.viewport1Content.series) | 629 if ('tags' in this.viewport1Content.series) |
597 s.push(this.viewport1Content.series.tags[SERIES_INSTANCE_UID]); | 630 s.push(this.viewport1Content.series.tags[SERIES_INSTANCE_UID]); |
598 | 631 |
1194 } | 1227 } |
1195 }) | 1228 }) |
1196 .catch(function (error) { | 1229 .catch(function (error) { |
1197 alert('Cannot find the study in Orthanc'); | 1230 alert('Cannot find the study in Orthanc'); |
1198 }); | 1231 }); |
1199 | 1232 }, |
1233 | |
1234 ChangeActiveSeries: function(offset) { | |
1235 var seriesTags = this.GetActiveViewportSeriesTags(); | |
1236 if (seriesTags !== null) { | |
1237 var studyIndex = LookupIndexOfResource(this.studies, STUDY_INSTANCE_UID, seriesTags[STUDY_INSTANCE_UID]); | |
1238 if (studyIndex != -1) { | |
1239 var seriesInStudyIndices = this.studies[studyIndex].series; | |
1240 for (var i = 0; i < seriesInStudyIndices.length; i++) { | |
1241 if (this.series[seriesInStudyIndices[i]].tags[SERIES_INSTANCE_UID] == seriesTags[SERIES_INSTANCE_UID]) { | |
1242 var next = i + offset; | |
1243 if (next >= 0 && | |
1244 next < seriesInStudyIndices.length) { | |
1245 this.SetViewportSeriesInstanceUid(this.activeViewport, this.series[seriesInStudyIndices[next]].tags[SERIES_INSTANCE_UID]); | |
1246 } | |
1247 break; | |
1248 } | |
1249 } | |
1250 } | |
1251 } | |
1252 }, | |
1253 | |
1254 ChangeActiveStudy: function(offset) { | |
1255 var seriesTags = this.GetActiveViewportSeriesTags(); | |
1256 if (seriesTags !== null) { | |
1257 var studyIndex = LookupIndexOfResource(this.studies, STUDY_INSTANCE_UID, seriesTags[STUDY_INSTANCE_UID]); | |
1258 if (studyIndex != -1) { | |
1259 var next = studyIndex + offset; | |
1260 if (next >= 0 && | |
1261 next < this.studies.length) { | |
1262 var nextStudy = this.studies[next]; | |
1263 if (nextStudy.series.length > 0) { | |
1264 var seriesIndex = nextStudy.series[0]; | |
1265 if (this.series[seriesIndex].virtualSeries !== null) { | |
1266 this.ClickVirtualSeries(seriesIndex, this.series[seriesIndex].virtualSeries); | |
1267 } else { | |
1268 this.ClickSeries(seriesIndex); | |
1269 } | |
1270 } | |
1271 } | |
1272 } | |
1273 } | |
1200 } | 1274 } |
1201 }, | 1275 }, |
1202 | 1276 |
1203 mounted: function() { | 1277 mounted: function() { |
1204 // Warning: In this function, the "stone" global object is not initialized yet! | 1278 // Warning: In this function, the "stone" global object is not initialized yet! |
1274 event.preventDefault(); | 1348 event.preventDefault(); |
1275 break; | 1349 break; |
1276 | 1350 |
1277 case 'Up': | 1351 case 'Up': |
1278 case 'ArrowUp': | 1352 case 'ArrowUp': |
1279 break; | 1353 that.ChangeActiveSeries(-1); |
1280 | 1354 break |
1355 | |
1281 case 'Down': | 1356 case 'Down': |
1282 case 'ArrowDown': | 1357 case 'ArrowDown': |
1358 that.ChangeActiveSeries(1); | |
1359 break; | |
1360 | |
1361 case 'PageUp': | |
1362 that.ChangeActiveStudy(-1); | |
1363 break | |
1364 | |
1365 case 'PageDown': | |
1366 that.ChangeActiveStudy(1); | |
1283 break; | 1367 break; |
1284 | 1368 |
1285 case ' ': | 1369 case ' ': |
1286 case 'Space': | 1370 case 'Space': |
1287 dispatchEvent(new CustomEvent('CineSwitch', { })); | 1371 dispatchEvent(new CustomEvent('KeyCineSwitch', { })); |
1288 event.preventDefault(); | 1372 event.preventDefault(); |
1289 break; | 1373 break; |
1290 | 1374 |
1291 default: | 1375 default: |
1292 break; | 1376 break; |