comparison Applications/StoneWebViewer/WebApplication/app.js @ 1865:4d83d27a955e

merge
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 24 Nov 2021 12:25:32 +0100
parents 63587fdeec69
children 3889ae96d2e9
comparison
equal deleted inserted replaced
1864:35ac2be493e2 1865:4d83d27a955e
148 cineTimeoutId: null, 148 cineTimeoutId: null,
149 cineLoadingFrame: false, 149 cineLoadingFrame: false,
150 videoUri: '', 150 videoUri: '',
151 windowingCenter: 0, 151 windowingCenter: 0,
152 windowingWidth: 0, 152 windowingWidth: 0,
153 instanceNumber: 0 153 instanceNumber: 0,
154 contentDate: '',
155 contentTime: '',
154 } 156 }
155 }, 157 },
156 watch: { 158 watch: {
157 currentFrame: function(newVal, oldVal) { 159 currentFrame: function(newVal, oldVal) {
158 /** 160 /**
169 this.cineLoadingFrame = false; 171 this.cineLoadingFrame = false;
170 this.cineRate = 30; // Default value 172 this.cineRate = 30; // Default value
171 this.windowingCenter = 0; 173 this.windowingCenter = 0;
172 this.windowingWidth = 0; 174 this.windowingWidth = 0;
173 this.instanceNumber = 0; 175 this.instanceNumber = 0;
174 176 this.contentDate = '';
177 this.contentTime = ''
178
175 if (this.cineTimeoutId !== null) { 179 if (this.cineTimeoutId !== null) {
176 clearTimeout(this.cineTimeoutId); 180 clearTimeout(this.cineTimeoutId);
177 this.cineTimeoutId = null; 181 this.cineTimeoutId = null;
178 } 182 }
179 183
253 if (args.detail.canvasId == that.canvasId) { 257 if (args.detail.canvasId == that.canvasId) {
254 that.currentFrame = (args.detail.currentFrame + 1); 258 that.currentFrame = (args.detail.currentFrame + 1);
255 that.numberOfFrames = args.detail.numberOfFrames; 259 that.numberOfFrames = args.detail.numberOfFrames;
256 that.quality = args.detail.quality; 260 that.quality = args.detail.quality;
257 that.instanceNumber = args.detail.instanceNumber; 261 that.instanceNumber = args.detail.instanceNumber;
262 that.contentDate = args.detail.contentDate;
263 that.contentTime = args.detail.contentTime;
258 } 264 }
259 }); 265 });
260 266
261 window.addEventListener('SeriesDetailsReady', function(args) { 267 window.addEventListener('SeriesDetailsReady', function(args) {
262 if (args.detail.canvasId == that.canvasId) { 268 if (args.detail.canvasId == that.canvasId) {
559 var indexStudies = {}; 565 var indexStudies = {};
560 566
561 var studies = []; 567 var studies = [];
562 var posColor = 0; 568 var posColor = 0;
563 569
570 // order series by SeriesNumber
571 sourceSeries.sort((a, b) => {return a[SERIES_NUMBER] - b[SERIES_NUMBER];})
572
564 for (var i = 0; i < sourceStudies.length; i++) { 573 for (var i = 0; i < sourceStudies.length; i++) {
565 var studyInstanceUid = sourceStudies[i][STUDY_INSTANCE_UID]; 574 var studyInstanceUid = sourceStudies[i][STUDY_INSTANCE_UID];
566 if (studyInstanceUid !== undefined) { 575 if (studyInstanceUid !== undefined) {
567 if (studyInstanceUid in indexStudies) { 576 if (studyInstanceUid in indexStudies) {
568 console.error('Twice the same study: ' + studyInstanceUid); 577 console.error('Twice the same study: ' + studyInstanceUid);
932 else { 941 else {
933 var year = date.replace(/^([0-9]{4})([0-9]{2})([0-9]{2})$/, '$1'); 942 var year = date.replace(/^([0-9]{4})([0-9]{2})([0-9]{2})$/, '$1');
934 var month = date.replace(/^([0-9]{4})([0-9]{2})([0-9]{2})$/, '$2'); 943 var month = date.replace(/^([0-9]{4})([0-9]{2})([0-9]{2})$/, '$2');
935 var day = date.replace(/^([0-9]{4})([0-9]{2})([0-9]{2})$/, '$3'); 944 var day = date.replace(/^([0-9]{4})([0-9]{2})([0-9]{2})$/, '$3');
936 return format.replace(/YYYY/g, year).replace(/MM/g, month).replace(/DD/g, day); 945 return format.replace(/YYYY/g, year).replace(/MM/g, month).replace(/DD/g, day);
946 }
947 }
948 },
949
950 FormatTime: function(time)
951 {
952 if (time === undefined ||
953 time.length == 0) {
954 return '';
955 }
956 else {
957 var format = this.globalConfiguration['TimeFormat'];
958 if (format === undefined) {
959 // No configuration for the date format, use the DICOM tag as such
960 return time;
961 }
962 else {
963 var timeRegexHMS = /([0-9]{2})([0-9]{2})([0-9]{2})/;
964 var timeRegexHMSms = /([0-9]{2})([0-9]{2})([0-9]{2}).([0-9]*)/
965 var m = time.match(timeRegexHMSms);
966 if (m) {
967 format = format.replace(/hh/g, m[1]).replace(/mm/g, m[2]).replace(/ss/g, m[3]);
968 if (format.indexOf('f') != -1) { // format expects ms
969 return format.replace(/f/g, m[4])
970 } else {
971 return format;
972 }
973 }
974 var m = time.match(timeRegexHMS);
975 if (m) {
976 format = format.replace(/hh/g, m[1]).replace(/mm/g, m[2]).replace(/ss/g, m[3]);
977 if (format.indexOf('f') != -1) { // format expects ms but we could not capture one
978 return format.replace(/.f/g, '')
979 }
980 }
981
982 return time;
937 } 983 }
938 } 984 }
939 }, 985 },
940 986
941 DownloadJpeg: function() 987 DownloadJpeg: function()
1095 1141
1096 if ('DicomCacheSize' in app.globalConfiguration) { 1142 if ('DicomCacheSize' in app.globalConfiguration) {
1097 stone.SetDicomCacheSize(app.globalConfiguration.DicomCacheSize); 1143 stone.SetDicomCacheSize(app.globalConfiguration.DicomCacheSize);
1098 } 1144 }
1099 1145
1146 if ('SkipSeriesFromModalities' in app.globalConfiguration) {
1147 stone.SetSkipSeriesFromModalities(JSON.stringify(app.globalConfiguration.SkipSeriesFromModalities));
1148 }
1149
1100 // Bearer token is new in Stone Web viewer 2.0 1150 // Bearer token is new in Stone Web viewer 2.0
1101 var token = getParameterFromUrl('token'); 1151 var token = getParameterFromUrl('token');
1102 if (token !== undefined) 1152 if (token !== undefined)
1103 { 1153 {
1104 stone.AddHttpHeader('Authorization', 'Bearer ' + token); 1154 stone.AddHttpHeader('Authorization', 'Bearer ' + token);
1159 } 1209 }
1160 }); 1210 });
1161 1211
1162 1212
1163 window.addEventListener('ResourcesLoaded', function() { 1213 window.addEventListener('ResourcesLoaded', function() {
1164 console.log('resources loaded'); 1214 console.log('resources loaded: ', stone.GetStudiesCount(), 'studies &', stone.GetSeriesCount(), 'series');
1165 1215
1166 var studies = []; 1216 var studies = [];
1167 for (var i = 0; i < stone.GetStudiesCount(); i++) { 1217 for (var i = 0; i < stone.GetStudiesCount(); i++) {
1168 stone.LoadStudyTags(i); 1218 stone.LoadStudyTags(i);
1169 studies.push(JSON.parse(stone.GetStringBuffer())); 1219 studies.push(JSON.parse(stone.GetStringBuffer()));