Commit e0beb71c1358b4d2e51ad6afc7646870185253fb
1 parent
29f20c1d
deleted extra file and one modified file
Showing
2 changed files
with
2 additions
and
3580 deletions
400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController 1.js deleted
1 | -'use strict'; | |
2 | - | |
3 | -AIA.controller("DAController", ["$scope", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "DA", "Modules", "$routeParams", "DataService", | |
4 | -function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Modules, $routeParam, DataService) { | |
5 | - | |
6 | - console.log('DAController initialized') | |
7 | - $scope.genderId = ""; | |
8 | - $scope.BodyViewData; | |
9 | - $scope.selectedGenderBodyViewData; | |
10 | - $scope.imagePath = ""; | |
11 | - $scope.BodyRegionData; | |
12 | - $scope.BodyRegionCordinatesData; | |
13 | - $scope.isTransparencyActivated; | |
14 | - $scope.BodyLayerData; | |
15 | - $scope.VocabTermData; | |
16 | - $scope.CommonData | |
17 | - $scope.TermNumberData; | |
18 | - $rootScope.BodySystemData | |
19 | - $scope.bodyViewId = 0; | |
20 | - $scope.bgartData; | |
21 | - //view specific constants | |
22 | - $scope.voId; | |
23 | - $scope.layerNumber; | |
24 | - $scope.daCounter = 1; | |
25 | - $scope.bagartDetails; | |
26 | - $scope.transNumber = 50; | |
27 | - | |
28 | - //for transarency scale | |
29 | - $scope.TBDrawStartX; | |
30 | - $scope.TBDrawStartY; | |
31 | - | |
32 | - $rootScope.isHighLight = false; | |
33 | - $rootScope.coloredImageCanvasList = []; | |
34 | - $rootScope.coloredImageMRCanvasList = []; | |
35 | - $rootScope.ColoredCanvasData = []; | |
36 | - $rootScope.grayImageDataList = []; | |
37 | - $rootScope.grayImageMRDataList = []; | |
38 | - | |
39 | - $scope.zoomInOut = 75; | |
40 | - $scope.i = 0; | |
41 | - $scope.speachBubbleArray = []; | |
42 | - $scope.multiAnnotationIsON = true; | |
43 | - $scope.previousGrayImageDataVar; | |
44 | - $scope.previousGrayCanvas; | |
45 | - | |
46 | - $scope.previousSelectedTermList = []; | |
47 | - | |
48 | - | |
49 | - // This variable is used for unhighlight previously highlighted body portion, if multiAnnotation is false. | |
50 | - $scope.machedIcolorInBodyRegion = []; | |
51 | - | |
52 | - $scope.MaskCanvasData = []; | |
53 | - | |
54 | - //array for bodyviewid correspoing to male female(used for gender change) | |
55 | - $scope.correspondingBodyViewIds = { | |
56 | - '1': '5', | |
57 | - '2': '6', | |
58 | - '3': '7', | |
59 | - '4': '8', | |
60 | - '9': '11', | |
61 | - '10': '12', | |
62 | - | |
63 | - '5': '1', | |
64 | - '6': '2', | |
65 | - '7': '3', | |
66 | - '8': '4', | |
67 | - '11': '9', | |
68 | - '12': '10', | |
69 | - | |
70 | - } | |
71 | - | |
72 | - $scope.bodyViews = { | |
73 | - 'Anterior': '1', | |
74 | - 'Lateral': '2', | |
75 | - 'Medial': '3', | |
76 | - 'Posterior': '4', | |
77 | - 'Lateral Arm': '5', | |
78 | - 'Medial Arm': '6' | |
79 | - } | |
80 | - | |
81 | - $scope.isBodylayerdataLoaded = false; | |
82 | - $scope.isBodyRegionDataLoaded = false; | |
83 | - $scope.showme = false; | |
84 | - $scope.IsVisible = function () { | |
85 | - $scope.scroll(); | |
86 | - | |
87 | - } | |
88 | - | |
89 | - $scope.scroll = function () { | |
90 | - // $window.scrollTo(0, 0); | |
91 | - $("html,body").scrollTop(0); | |
92 | - //alert("scroll"); | |
93 | - } | |
94 | - | |
95 | - | |
96 | - //get the DA body view list based on selected gender | |
97 | - //get the DA body view list based on selected gender | |
98 | - $scope.getDAViewList = function ($event) { | |
99 | - | |
100 | - // debugger; | |
101 | - if ($('#MainImage') != null) { | |
102 | - $('#MainImage').remove(); | |
103 | - } | |
104 | - $rootScope.currentActiveModuleTitle = Modules[0].Name; | |
105 | - $("#bodyViewList").empty(); | |
106 | - //for default load | |
107 | - if ($event == null || $event == undefined) { | |
108 | - //if ((localStorage.getItem("genderId") != "")||(localStorage.getItem("genderId")!="null")) { | |
109 | - // $scope.genderId = localStorage.getItem("genderId"); | |
110 | - //} | |
111 | - var selectedGender = localStorage.getItem("genderId"); | |
112 | - if ((selectedGender == null)) { | |
113 | - $scope.genderId = "Male"; | |
114 | - } | |
115 | - else | |
116 | - $scope.genderId = localStorage.getItem("genderId"); | |
117 | - | |
118 | - } | |
119 | - else { | |
120 | - $scope.genderId = $event.currentTarget.id; | |
121 | - } | |
122 | - | |
123 | - localStorage.setItem("genderId", $scope.genderId); | |
124 | - | |
125 | - var selectedGender = localStorage.getItem("genderId"); | |
126 | - | |
127 | - if (selectedGender != null) { | |
128 | - if (selectedGender == "Male") { | |
129 | - $('#Male').addClass('active'); | |
130 | - $('#Female').removeClass("active"); | |
131 | - } | |
132 | - else { | |
133 | - $('#Female').addClass('active'); | |
134 | - $('#Male').removeClass("active"); | |
135 | - } | |
136 | - | |
137 | - } | |
138 | - $scope.selectedGenderBodyViewData = new jinqJs() | |
139 | - .from($scope.BodyViewData.BodyViews.view) | |
140 | - .where('_gender == ' + $scope.genderId) | |
141 | - .select(); | |
142 | - | |
143 | - | |
144 | - angular.forEach($scope.selectedGenderBodyViewData, function (value, key) { | |
145 | - | |
146 | - var userEthnicity = DA[0].ethnicity; | |
147 | - var userModestysettings = DA[0].modesty; | |
148 | - var userSelectedSkintone = 'W'; | |
149 | - $scope.userModestySetting = 'Y' | |
150 | - var thumbnailImage; | |
151 | - if ((value._id == 1) || (value._id == 3) || (value._id == 5) || (value._id == 6) || (value._id == 7) || (value._id == 11)) | |
152 | - thumbnailImage = ((value._thumbnailImage).replace('.jpg', '_' + userEthnicity + userModestysettings)) + '.jpg'; | |
153 | - else { | |
154 | - thumbnailImage = ((value._thumbnailImage).replace('.jpg', '_' + userEthnicity)) + '.jpg'; | |
155 | - | |
156 | - } | |
157 | - | |
158 | - $scope.imagePath = "~/../content/images/DA/" + $scope.zoomInOut + "/body-views/" + value._id + '/skintone/' + userEthnicity + '/' + thumbnailImage; | |
159 | - // debugger; | |
160 | - | |
161 | - var $el = $('<div id=' + value._id + ' class="col-sm-3 col-lg-2" title = ' + value._title + ' data-ng-click="openView($event)"><div class="thumbnail" >' | |
162 | - + '<img class= "daImg" id="' + value._title + '" src="' + $scope.imagePath + '" alt="" title="" >' | |
163 | - + '<div class="caption"><p>' + value._title + '</p></div></a></div></div>').appendTo('#bodyViewList'); | |
164 | - | |
165 | - | |
166 | - $compile($el)($scope); | |
167 | - $(".sidebar").mCustomScrollbar({ | |
168 | - autoHideScrollbar: true, | |
169 | - //theme:"rounded" | |
170 | - }); | |
171 | - | |
172 | - }); | |
173 | - | |
174 | - }; | |
175 | - | |
176 | - | |
177 | - | |
178 | - $scope.openView = function ($event) { | |
179 | - // debugger; | |
180 | - $rootScope.currentBodyViewId = $event.currentTarget.id; | |
181 | - $rootScope.ViewTitle = $event.currentTarget.textContent; | |
182 | - | |
183 | - localStorage.setItem("currentViewTitleFromJson", $event.currentTarget.textContent); | |
184 | - localStorage.setItem("currentBodyViewId", $event.currentTarget.id); | |
185 | - | |
186 | - var u = $location.url(); | |
187 | - $location.url('/da-body-view'); | |
188 | - | |
189 | - | |
190 | - } | |
191 | - | |
192 | - | |
193 | - //load json data for body view | |
194 | - $scope.loadDissectibleAnatomyData = function () { | |
195 | - | |
196 | - $rootScope.ClearIframe(); | |
197 | - | |
198 | - //load common data | |
199 | - var commondataJsonPath = '~/../content/data/json/da/da_dat_common.json'; | |
200 | - | |
201 | - DataService.getAnotherJson(commondataJsonPath) | |
202 | - .then( | |
203 | - function (result) { | |
204 | - | |
205 | - $rootScope.CommonData = result; | |
206 | - $http({ method: 'GET', url: '~/../content/data/json/da/da_dat_contentlist.json' }).success(function (data) { | |
207 | - | |
208 | - $scope.BodyViewData = data; | |
209 | - //load default body view list for male | |
210 | - $scope.getDAViewList(); | |
211 | - | |
212 | - }) | |
213 | - .error(function (data, status, headers, config) { | |
214 | - console.log(data); | |
215 | - }); | |
216 | - | |
217 | - | |
218 | - }, | |
219 | - function (error) { | |
220 | - console.log(error.statusText) | |
221 | - } | |
222 | - ) | |
223 | - //load body-views data | |
224 | - | |
225 | - | |
226 | - // $('#daLoaderLabel').css('visibility', 'hidden') | |
227 | - $rootScope.isLoading = false; | |
228 | - | |
229 | - | |
230 | - | |
231 | - //push the details of open module in array $rootScope.openModules | |
232 | - $rootScope.openModules.push({ "ModuleId": 1 }); | |
233 | - | |
234 | - | |
235 | - } | |
236 | - | |
237 | - | |
238 | - //da-body-views functions | |
239 | - | |
240 | - $scope.openBodyView = function () { | |
241 | - //debugger; | |
242 | - $rootScope.isLoading = true; | |
243 | - $scope.voId = localStorage.getItem("currentBodyViewId");; | |
244 | - | |
245 | - //load bodyRegion data | |
246 | - var brViewdata = DataService.getJson('~/../content/data/json/da/da_dat_brview.json') | |
247 | - brViewdata.then( | |
248 | - function (result) { | |
249 | - // debugger; | |
250 | - $scope.BodyRegionData = result; | |
251 | - $scope.isBodyRegionDataLoaded = true; | |
252 | - // alert('da_dat_brview= ' + result) | |
253 | - | |
254 | - var currentBodyViewId = localStorage.getItem("currentBodyViewId"); | |
255 | - var layerJsonPath = ''; | |
256 | - var bgArtJsonPath = ''; | |
257 | - var CommonViewId = 0; | |
258 | - | |
259 | - layerJsonPath = '~/../content/data/json/da/body-views/' + currentBodyViewId + '/da_dat_layer_' + currentBodyViewId + '.json'; | |
260 | - | |
261 | - | |
262 | - | |
263 | - DataService.getAnotherJson(layerJsonPath) | |
264 | - .then( | |
265 | - function (result) { | |
266 | - //debugger; | |
267 | - | |
268 | - $scope.BodyLayerData = result; | |
269 | - $scope.isBodylayerdataLoaded = true; | |
270 | - | |
271 | - //load json for annotations | |
272 | - // $http({ method: 'GET', url: '~/../content/data/json/da_dat_tm_sg_1.json' }).success(function (data) { | |
273 | - $http({ method: 'GET', url: '~/../content/data/json/da/body-views/' + currentBodyViewId + '/da_dat_tm_sg_' + currentBodyViewId + '.json' }).success(function (data) { | |
274 | - $scope.TermNumberData = data; | |
275 | - | |
276 | - | |
277 | - }) | |
278 | - .error(function (data, status, headers, config) { | |
279 | - console.log(data); | |
280 | - }); | |
281 | - | |
282 | - var path = '~/../content/data/json/da/vocab/english/cm_dat_vocabterm_1.json'; | |
283 | - | |
284 | - //load vocabterm data | |
285 | - //$http({ method: 'GET', url: '~/../content/data/json/cm_dat_vocabterm_1.json' }).success(function (data) { | |
286 | - $http({ method: 'GET', url: path }).success(function (data) { | |
287 | - | |
288 | - $scope.VocabTermData = data; | |
289 | - }) | |
290 | - .error(function (data, status, headers, config) { | |
291 | - console.log(data); | |
292 | - }); | |
293 | - | |
294 | - var openViews; | |
295 | - | |
296 | - | |
297 | - // debugger; | |
298 | - if ($rootScope.openViews.length > 0) { | |
299 | - openViews = new jinqJs() | |
300 | - .from($rootScope.openViews) | |
301 | - .where("BodyViewId==" + currentBodyViewId) | |
302 | - .select(); | |
303 | - } | |
304 | - var counter = 1; | |
305 | - | |
306 | - // var tittle = $rootScope.ViewTitle; | |
307 | - var tittle = localStorage.getItem("currentViewTitleFromJson"); | |
308 | - | |
309 | - if (openViews != null && openViews.length > 0) { | |
310 | - angular.forEach(openViews, function (value, key) { | |
311 | - | |
312 | - if (value.body - views == tittle) { | |
313 | - tittle = localStorage.getItem("currentViewTitleFromJson") + counter++; | |
314 | - $rootScope.currentActiveViewTitle = tittle; | |
315 | - localStorage.setItem("currentViewTitle", tittle); | |
316 | - } | |
317 | - | |
318 | - }); | |
319 | - } | |
320 | - else { | |
321 | - localStorage.setItem("currentViewTitle", tittle); | |
322 | - } | |
323 | - | |
324 | - | |
325 | - $.jsPanel({ | |
326 | - id: 'daImagePanel', | |
327 | - selector: '.daBodyView', | |
328 | - theme: 'success', | |
329 | - currentController: 'DAController', | |
330 | - parentSlug: 'da-view-list', | |
331 | - ajax: { | |
332 | - url: 'app/views/da/da-view.html' | |
333 | - }, | |
334 | - title: localStorage.getItem("currentViewTitle"), | |
335 | - position: { | |
336 | - top: 70, | |
337 | - left: 1, | |
338 | - }, | |
339 | - | |
340 | - size: { width: $(window).outerWidth() - 10, height: $(window).outerHeight() - 110 }, | |
341 | - | |
342 | - }); | |
343 | - | |
344 | - | |
345 | - | |
346 | - // $rootScope.openViewsDA.push({ "ViewId": 1 }); | |
347 | - $rootScope.currentSlug = 'da-body-view'; | |
348 | - | |
349 | - //hide scrollbar | |
350 | - | |
351 | - | |
352 | - $rootScope.openViews.push( | |
353 | - { | |
354 | - "module": $rootScope.currentActiveModuleTitle, "body-views": tittle, "state": 'max', "BodyViewId": $rootScope.currentBodyViewId, | |
355 | - "slug": $rootScope.currentSlug | |
356 | - } | |
357 | - ); | |
358 | - // debugger; | |
359 | - | |
360 | - var e1 = angular.element(document.getElementById("daBodyview")); | |
361 | - $timeout(function () { $compile(e1.contents())($scope) }, 250); | |
362 | - // $compile(e1.contents())($scope); | |
363 | - | |
364 | - $('#daBodyview').css("height", $(window).outerHeight()); | |
365 | - | |
366 | - $('#daBodyview').css("width", $(window).outerWidth()); | |
367 | - | |
368 | - // debugger | |
369 | - if ($scope.isBodylayerdataLoaded) { | |
370 | - $timeout(function () { $scope.LoadDefaultLayerImage() }, 350); | |
371 | - } | |
372 | - }, | |
373 | - function (error) { | |
374 | - // handle errors here | |
375 | - console.log(' $scope.BodyLayerData= ' + error.statusText); | |
376 | - } | |
377 | - ); | |
378 | - }, | |
379 | - function (error) { | |
380 | - // handle errors here | |
381 | - console.log(' $scope.BodyRegionData = ' + error.statusText); | |
382 | - } | |
383 | - ); | |
384 | - | |
385 | - // debugger | |
386 | - $('#daBodyview').css("height", $(window).outerHeight()); | |
387 | - | |
388 | - $('#daBodyview').css("width", $(window).outerWidth()); | |
389 | - } | |
390 | - | |
391 | - angular.element(document).ready(function () { | |
392 | - | |
393 | - | |
394 | - }) | |
395 | - | |
396 | - | |
397 | - $scope.LoadDefaultLayerImage = function () { | |
398 | - // debugger; | |
399 | - | |
400 | - $scope.layerNumber = 0; | |
401 | - $scope.skinTone = DA[0].ethnicity; | |
402 | - | |
403 | - $scope.viewOrientationId = $scope.voId; | |
404 | - if ($scope.voId == 5) { | |
405 | - $scope.viewOrientationId = 1; | |
406 | - } | |
407 | - else if ($scope.voId == 6) { | |
408 | - $scope.viewOrientationId = 2; | |
409 | - } | |
410 | - else if ($scope.voId == 7) { | |
411 | - $scope.viewOrientationId = 3; | |
412 | - } | |
413 | - else if ($scope.voId == 8) { | |
414 | - $scope.viewOrientationId = 4; | |
415 | - } | |
416 | - else if ($scope.voId == 9) { | |
417 | - $scope.viewOrientationId = 5; | |
418 | - } | |
419 | - else if ($scope.voId == 10) { | |
420 | - $scope.viewOrientationId = 6; | |
421 | - } | |
422 | - else if ($scope.voId == 11) { | |
423 | - $scope.viewOrientationId = 5; | |
424 | - } | |
425 | - else if ($scope.voId == 12) { | |
426 | - $scope.viewOrientationId = 6; | |
427 | - } | |
428 | - | |
429 | - // debugger; | |
430 | - var bgArtJsonPath = ''; | |
431 | - | |
432 | - bgArtJsonPath = '~/../content/data/json/da/da_dat_bgart.json'; | |
433 | - | |
434 | - var bgartdata = DataService.getJson(bgArtJsonPath) | |
435 | - bgartdata.then( | |
436 | - function (result) { | |
437 | - //debugger; | |
438 | - $scope.bgartData = result; | |
439 | - $scope.CalculateImageCordinates($scope.viewOrientationId); | |
440 | - | |
441 | - }, | |
442 | - function (error) { | |
443 | - // handle errors here | |
444 | - console.log(' $scope.bgartData = ' + error.statusText); | |
445 | - }); | |
446 | - }; | |
447 | - | |
448 | - | |
449 | - //calculate coordinates for body region images | |
450 | - $scope.CalculateImageCordinates = function (viewOrientationId) { | |
451 | - | |
452 | - // debugger; | |
453 | - | |
454 | - //set height of canvas div and left tool bar as per window size | |
455 | - $scope.BodyRegionCordinatesData = []; // create an empty array | |
456 | - | |
457 | - $('#daBodyview').css('width', '100%'); | |
458 | - $('#canvasDiv').css('height', $('#daImagePanel').outerHeight() - 104) | |
459 | - //$('#canvasDiv').css('width', $('#daImagePanel').outerWidth() - 100) | |
460 | - $('#leftToolBar').css('height', $('#daImagePanel').outerHeight()) | |
461 | - | |
462 | - | |
463 | - | |
464 | - //calculate image coordinates and draw image | |
465 | - var bodyRegionCoordinates = $scope.BodyRegionData.BodyRegionViews; | |
466 | - // var viewOrientationId = String($scope.voId); | |
467 | - | |
468 | - | |
469 | - $scope.bodyRegionCoordinates = new jinqJs() | |
470 | - .from($scope.BodyRegionData.BodyRegionViews.BodyRegionCordinates) | |
471 | - .where('_ViewOrientationId == ' + viewOrientationId) | |
472 | - .select(); | |
473 | - | |
474 | - // if ($scope.voId == 9 || $scope.voId == 11) { | |
475 | - | |
476 | - $scope.bagartDetails = new jinqJs() | |
477 | - .from($scope.bgartData.BackgroundArts.BackgroundArtDetail) | |
478 | - .where('_ViewOrientationId == ' + viewOrientationId) | |
479 | - .select(); | |
480 | - //} | |
481 | - | |
482 | - $scope.ColoredImageSRC = []; | |
483 | - | |
484 | - angular.forEach($scope.bodyRegionCoordinates, function (value, key) { | |
485 | - | |
486 | - | |
487 | - | |
488 | - if (value._HaveMirrorImage == 'Y') { | |
489 | - | |
490 | - //DrawMirroredImage | |
491 | - | |
492 | - //0. Scaling as per default zoom | |
493 | - var rectangle = scaleRectangle(value._X, value._Y, value._Height, value._Width, value._MirrorValue); | |
494 | - | |
495 | - //1.Get image source | |
496 | - var src = $scope.GetImageSource(value._BodyRegionId); | |
497 | - $scope.imageSource = src; | |
498 | - // debugger; | |
499 | - | |
500 | - $scope.ColoredImageSRC.push( | |
501 | - { | |
502 | - "bodyRegionId": value._BodyRegionId, "SRC": src, | |
503 | - "Height": rectangle.scaledHeight, | |
504 | - "Width": rectangle.scaledWidth, | |
505 | - "x": rectangle.scaledX, | |
506 | - "y": rectangle.scaledY, | |
507 | - "haveMirror": 'true' | |
508 | - } | |
509 | - ); | |
510 | - | |
511 | - | |
512 | - //2.Draw mirror image | |
513 | - $scope.DrawMirroredImage(Math.round(rectangle.scaledHeight), Math.round(rectangle.scaledWidth), Math.round(rectangle.scaledX), Math.round(rectangle.scaledY), src, value._BodyRegionId, 'N'); | |
514 | - // debugger; | |
515 | - $scope.BodyRegionCordinatesData.push( | |
516 | - { | |
517 | - "bodyRegionId": value._BodyRegionId, "Height": Math.round(rectangle.scaledHeight), "Width": Math.round(rectangle.scaledWidth), | |
518 | - "X": Math.round(rectangle.scaledX), "Y": Math.round(rectangle.scaledY), "IsMirror": 'Yes' | |
519 | - } | |
520 | - ); | |
521 | - | |
522 | - //3.GetMaskImageSource | |
523 | - var maskImageSrc = $scope.GetMaskImageSource($scope.imageSource); | |
524 | - // debugger; | |
525 | - //4 Draw Mask Mirror Image | |
526 | - $scope.DrawMirroredImage(Math.round(rectangle.scaledHeight), Math.round(rectangle.scaledWidth), Math.round(rectangle.scaledX), Math.round(rectangle.scaledY), maskImageSrc, value._BodyRegionId, 'Y'); | |
527 | - | |
528 | - | |
529 | - //Draw Normal Image | |
530 | - | |
531 | - //0. Scaling as per default zoom | |
532 | - var rectangle = scaleRectangle(value._X, value._Y, value._Height, value._Width, 0); | |
533 | - | |
534 | - $scope.ColoredImageSRC.push( | |
535 | - { | |
536 | - "bodyRegionId": value._BodyRegionId, "SRC": src, | |
537 | - "Height": rectangle.scaledHeight, | |
538 | - "Width": rectangle.scaledWidth, | |
539 | - "x": rectangle.scaledX, | |
540 | - "y": rectangle.scaledY, | |
541 | - "haveMirror": 'false' | |
542 | - } | |
543 | - ); | |
544 | - | |
545 | - | |
546 | - //1.Draw body region which have mirror image | |
547 | - $scope.DrawImage(Math.round(rectangle.scaledHeight), Math.round(rectangle.scaledWidth), Math.round(rectangle.scaledX), Math.round(rectangle.scaledY), src, value._BodyRegionId, 'N'); | |
548 | - $scope.BodyRegionCordinatesData.push( | |
549 | - { | |
550 | - "bodyRegionId": value._BodyRegionId, "Height": Math.round(rectangle.scaledHeight), "Width": Math.round(rectangle.scaledWidth), | |
551 | - "X": Math.round(rectangle.scaledX), "Y": Math.round(rectangle.scaledY), "IsMirror": 'No' | |
552 | - } | |
553 | - ); | |
554 | - | |
555 | - //2.Draw body region for mask image | |
556 | - $scope.DrawImage(Math.round(rectangle.scaledHeight), Math.round(rectangle.scaledWidth), Math.round(rectangle.scaledX), Math.round(rectangle.scaledY), maskImageSrc, value._BodyRegionId, 'Y'); | |
557 | - | |
558 | - | |
559 | - } | |
560 | - else { | |
561 | - //Draw body region which don't have mirror image | |
562 | - | |
563 | - | |
564 | - //0.Scaling as per default zoom | |
565 | - var rectangle = scaleRectangle(value._X, value._Y, value._Height, value._Width, value._MirrorValue); | |
566 | - | |
567 | - //1.Get image source | |
568 | - if (value._IsPrimary == 'N') { | |
569 | - var src = $scope.GetBackgroundImgSource(value._BodyRegionId); | |
570 | - $scope.imageSource = src; | |
571 | - } | |
572 | - else { | |
573 | - var src = $scope.GetImageSource(value._BodyRegionId); | |
574 | - $scope.imageSource = src; | |
575 | - } | |
576 | - | |
577 | - $scope.ColoredImageSRC.push( | |
578 | - { | |
579 | - "bodyRegionId": value._BodyRegionId, "SRC": src, | |
580 | - "Height": rectangle.scaledHeight, | |
581 | - "Width": rectangle.scaledWidth, | |
582 | - "x": rectangle.scaledX, | |
583 | - "y": rectangle.scaledY, | |
584 | - "haveMirror": 'false' | |
585 | - } | |
586 | - ); | |
587 | - | |
588 | - //2.Draw body region which don't have mirror image | |
589 | - $scope.DrawImage(Math.round(rectangle.scaledHeight), Math.round(rectangle.scaledWidth), Math.round(rectangle.scaledX), Math.round(rectangle.scaledY), src, value._BodyRegionId, 'N'); | |
590 | - | |
591 | - $scope.BodyRegionCordinatesData.push( | |
592 | - { | |
593 | - "bodyRegionId": value._BodyRegionId, "Height": Math.round(rectangle.scaledHeight), "Width": Math.round(rectangle.scaledWidth), | |
594 | - "X": Math.round(rectangle.scaledX), "Y": Math.round(rectangle.scaledY), "IsMirror": 'No' | |
595 | - } | |
596 | - ); | |
597 | - | |
598 | - //3.GetMaskImageSource | |
599 | - var maskSRC = $scope.GetMaskImageSource($scope.imageSource); | |
600 | - | |
601 | - //4.Draw body region for mask image | |
602 | - $scope.DrawImage(Math.round(rectangle.scaledHeight), Math.round(rectangle.scaledWidth), Math.round(rectangle.scaledX), Math.round(rectangle.scaledY), maskSRC, value._BodyRegionId, 'Y'); | |
603 | - | |
604 | - | |
605 | - //draw figLeaf for modesty | |
606 | - | |
607 | - $scope.figLaefImageName; | |
608 | - $scope.figLaefX; | |
609 | - $scope.figLaefY; | |
610 | - var gender; | |
611 | - if (localStorage.getItem("genderId") == 'Female') { | |
612 | - gender = 'F'; | |
613 | - | |
614 | - } | |
615 | - else { | |
616 | - gender = 'M'; | |
617 | - } | |
618 | - if (((localStorage.getItem("genderId") == 'Female') && (value._BodyRegionId == 2)) || (value._BodyRegionId == 3)) { | |
619 | - | |
620 | - var dtlOfBr = new jinqJs() | |
621 | - .from($scope.bagartDetails) | |
622 | - .where('_BodyRegionId == ' + value._BodyRegionId) | |
623 | - .select(); | |
624 | - | |
625 | - | |
626 | - // debugger | |
627 | - | |
628 | - var dtlOfGender = new jinqJs() | |
629 | - .from(dtlOfBr) | |
630 | - .where('_Gender == ' + gender) | |
631 | - .select(); | |
632 | - var dtlOfSktn = new jinqJs() | |
633 | - .from(dtlOfGender) | |
634 | - .where('_Skintone == +') | |
635 | - .select(); | |
636 | - //multiple conditions are not working in where clause of JinQ so need multiple filtered variables | |
637 | - if (dtlOfSktn.length > 0) { | |
638 | - | |
639 | - if ((parseInt(dtlOfSktn[0]._lns) <= parseInt($scope.layerNumber)) && (parseInt(dtlOfSktn[0]._lne) > parseInt($scope.layerNumber)) && (dtlOfSktn[0]._isfr == 'Y')) { | |
640 | - $scope.figLaefImageName = dtlOfSktn[0]._ImageId; | |
641 | - //$scope.figLaefX = filtereddata[0]._X; | |
642 | - //$scope.figLaefY = filtereddata[0]._Y; | |
643 | - | |
644 | - var rectangle = scaleRectangle(value._X, value._Y, value._Height, value._Width, value._MirrorValue); | |
645 | - | |
646 | - | |
647 | - var src = "content/images/DA/" + $scope.zoomInOut + "/body-views/" + $scope.voId + "/layers/0/" + value._BodyRegionId + "/" + $scope.figLaefImageName; | |
648 | - | |
649 | - $scope.DrawImage(rectangle.scaledHeight, rectangle.scaledWidth, rectangle.scaledX, rectangle.scaledY, src, 'modestyImg' + value._BodyRegionId, 'N') | |
650 | - | |
651 | - } | |
652 | - } | |
653 | - | |
654 | - } | |
655 | - | |
656 | - | |
657 | - } | |
658 | - | |
659 | - | |
660 | - }); | |
661 | - | |
662 | - if ((DA[0].modesty == 'Y')) { | |
663 | - if ($('.modestyImg') != null) { | |
664 | - $('.modestyImg').css('visibility', 'visible'); | |
665 | - } | |
666 | - } | |
667 | - //set scrollbars on canvas and hide loading label | |
668 | - // debugger; | |
669 | - // var isiOSSafari = (navigator.userAgent.match(/like Mac OS X/i)) ? true : false; | |
670 | - var isiOSSafari = (navigator.userAgent.match(/iPad/i)) ? true : false; | |
671 | - | |
672 | - //set scrollbars on canvas and hide loading label | |
673 | - // $('#daLoaderLabel').css('visibility', 'hidden') | |
674 | - | |
675 | - $('#canvasDiv').css('overflow', 'scroll') | |
676 | - if (isiOSSafari) { | |
677 | - $('#canvasDiv').scrollLeft($('#canvasDiv').width() + 150) | |
678 | - | |
679 | - } | |
680 | - else { | |
681 | - $('#canvasDiv').scrollLeft($('#canvasDiv').width() / 2) | |
682 | - } | |
683 | - // $('#canvasDiv').scrollLeft($scope.imageHorizontlScrollPosition) | |
684 | - $('#canvasDiv').scrollTop(50) | |
685 | - var abc = $scope.BodyRegionCordinatesData; | |
686 | - //debugger; | |
687 | - $('#layerChangeSlider').slider("option", "value", parseInt($scope.totalLayers) - parseInt($scope.layerNumber)); | |
688 | - // $('#spinner').css('visibility', 'hidden'); | |
689 | - $rootScope.isLoading = false; | |
690 | - | |
691 | - } | |
692 | - | |
693 | - function scaleRectangle(x, y, height, width, mirrorValue) { | |
694 | - var nzoom = $scope.zoomInOut; | |
695 | - var existingZoon = 100; | |
696 | - | |
697 | - var X = 0; | |
698 | - var scaledY = 0; | |
699 | - var scaledHeight = 0; | |
700 | - var scaledWidth = 0; | |
701 | - | |
702 | - if (mirrorValue != 0) { | |
703 | - var mirroredX = parseInt(mirrorValue) + parseInt(x); | |
704 | - var newX = (mirroredX * nzoom); | |
705 | - mirroredX = (newX / existingZoon); | |
706 | - X = mirroredX; | |
707 | - } | |
708 | - else { | |
709 | - var newX = (x * nzoom); | |
710 | - X = (newX / existingZoon); | |
711 | - } | |
712 | - | |
713 | - var newY = (y * nzoom); | |
714 | - var Y = (newY / existingZoon); | |
715 | - | |
716 | - var newHeight = (height * nzoom); | |
717 | - var ht = (newHeight / existingZoon); | |
718 | - | |
719 | - var newWidth = (width * nzoom); | |
720 | - var wt = (newWidth / existingZoon); | |
721 | - | |
722 | - return { | |
723 | - scaledX: X, | |
724 | - scaledY: Y, | |
725 | - scaledHeight: ht, | |
726 | - scaledWidth: wt | |
727 | - } | |
728 | - } | |
729 | - | |
730 | - $scope.GetMaskImageSource = function (src) { | |
731 | - | |
732 | - if (src.match('.png')) { | |
733 | - var mciImage = src.replace('.png', '_mci.png') | |
734 | - } | |
735 | - else { | |
736 | - var mciImage = src.replace('.jpg', '_mci.png') | |
737 | - } | |
738 | - return mciImage; | |
739 | - | |
740 | - } | |
741 | - | |
742 | - | |
743 | - $scope.GetImageSource = function (bodyRegionId) { | |
744 | - // debugger; | |
745 | - var dataLength = $scope.BodyLayerData.Layers.DataLayer.length; | |
746 | - | |
747 | - //set max for LayerNumber input | |
748 | - $scope.totalLayers = dataLength - 1; | |
749 | - // debugger | |
750 | - $('#txtLayerNumber').attr('max', $scope.totalLayers); | |
751 | - $('#layerChangeSlider').slider("option", "max", $scope.totalLayers); | |
752 | - // $('#layerChangeSlider').slider("option", "value",parseInt($scope.totalLayers)-parseInt($scope.layerNumber)); | |
753 | - | |
754 | - $scope.one = 1; | |
755 | - | |
756 | - $scope.userInput = parseInt($scope.layerNumber); | |
757 | - | |
758 | - | |
759 | - var SelectedLayerData = []; | |
760 | - SelectedLayerData = $scope.BodyLayerData.Layers.DataLayer[dataLength - $scope.userInput - 1]; | |
761 | - if ($scope.layerNumber == 0) { | |
762 | - for (var z = 0; z <= SelectedLayerData.BodyRegion.length; z++) { | |
763 | - | |
764 | - var bodyRegion = SelectedLayerData.BodyRegion[z]._BodyRegionId; | |
765 | - var bodyRegionSkinTone = SelectedLayerData.BodyRegion[z].Image._SkintTone; | |
766 | - | |
767 | - if (bodyRegion == bodyRegionId && bodyRegionSkinTone == $scope.skinTone) { | |
768 | - | |
769 | - return "content/images/DA/" + $scope.zoomInOut + "/body-views/" + $scope.voId + "/layers/" + $scope.layerNumber + "/" + bodyRegionId + "/" + $scope.skinTone + "/" + SelectedLayerData.BodyRegion[z].Image._ImageName; | |
770 | - } | |
771 | - } | |
772 | - } | |
773 | - | |
774 | - else { | |
775 | - // debugger; | |
776 | - //below 4 bodyviews have only single body region | |
777 | - if ($scope.voId == 9 || $scope.voId == 11 || $scope.voId == 10 || $scope.voId == 12) { | |
778 | - var bodyRegion = SelectedLayerData.BodyRegion._BodyRegionId; | |
779 | - | |
780 | - return "content/images/DA/" + $scope.zoomInOut + "/body-views/" + $scope.voId + "/layers/" + $scope.layerNumber + "/" + bodyRegionId + "/" + SelectedLayerData.BodyRegion.Image._ImageName; | |
781 | - | |
782 | - } | |
783 | - else // it is for other body view which have multiple body regions and layer no > 0 | |
784 | - { | |
785 | - // debugger; | |
786 | - for (var z = 0; z <= SelectedLayerData.BodyRegion.length; z++) { | |
787 | - var bodyRegion = SelectedLayerData.BodyRegion[z]._BodyRegionId; | |
788 | - if (bodyRegion == bodyRegionId) { | |
789 | - | |
790 | - return "content/images/DA/" + $scope.zoomInOut + "/body-views/" + $scope.voId + "/layers/" + $scope.layerNumber + "/" + bodyRegionId + "/" + SelectedLayerData.BodyRegion[z].Image._ImageName; | |
791 | - | |
792 | - | |
793 | - } | |
794 | - } | |
795 | - } | |
796 | - } | |
797 | - } | |
798 | - | |
799 | - $scope.GetBackgroundImgSource = function (bodyRegionId) { | |
800 | - // debugger; | |
801 | - | |
802 | - var selectedGender; | |
803 | - if (localStorage.getItem("genderId") == "Male") { | |
804 | - selectedGender = 'M'; | |
805 | - } | |
806 | - else { | |
807 | - selectedGender = 'F'; | |
808 | - | |
809 | - } | |
810 | - //filter data based on bodyRegion | |
811 | - $scope.bagartBodyRegionDetails = new jinqJs() | |
812 | - .from($scope.bagartDetails) | |
813 | - .where('_BodyRegionId == ' + bodyRegionId) | |
814 | - .select(); | |
815 | - | |
816 | - //filter bodyRegion data basd on skintone | |
817 | - $scope.bagartDetailsOnSktn = new jinqJs() | |
818 | - .from($scope.bagartBodyRegionDetails) | |
819 | - .where('_Skintone == ' + $scope.skinTone) | |
820 | - .select(); | |
821 | - | |
822 | - //only brid=2 is having different male,female image, other bodr region have common images for male, female | |
823 | - if (bodyRegionId == 2) { | |
824 | - for (var z = 0; z <= $scope.bagartDetailsOnSktn.length; z++) { | |
825 | - var gender = $scope.bagartDetailsOnSktn[z]._Gender; | |
826 | - if (gender == selectedGender) { | |
827 | - return "content/images/DA/" + $scope.zoomInOut + "/body-views/" + $scope.voId + "/layers/0/" + bodyRegionId + "/" + $scope.skinTone + "/" + $scope.bagartDetailsOnSktn[z]._ImageId; | |
828 | - } | |
829 | - } | |
830 | - } | |
831 | - else { | |
832 | - return "content/images/DA/" + $scope.zoomInOut + "/body-views/" + $scope.voId + "/layers/0/" + bodyRegionId + "/" + $scope.skinTone + "/" + $scope.bagartDetailsOnSktn[0]._ImageId; | |
833 | - | |
834 | - } | |
835 | - } | |
836 | - | |
837 | - | |
838 | - $scope.DrawMirroredImage = function (h, w, x, y, src, bodyRegionId, isMaskImage) { | |
839 | - | |
840 | - var FlipedImgCanvas = document.createElement('canvas'); | |
841 | - FlipedImgCanvas.height = h; | |
842 | - FlipedImgCanvas.width = w; | |
843 | - FlipedImgCanvas.setAttribute("data-IsMirrored", "Y") | |
844 | - FlipedImgCanvas.style.position = "absolute"; | |
845 | - FlipedImgCanvas.style.left = x + "px"; | |
846 | - FlipedImgCanvas.style.top = y + "px"; | |
847 | - | |
848 | - | |
849 | - | |
850 | - if (isMaskImage == 'Y') { | |
851 | - FlipedImgCanvas.id = 'imageCanvas' + bodyRegionId + '_MR_mci'; | |
852 | - FlipedImgCanvas.style.visibility = 'hidden' | |
853 | - | |
854 | - } | |
855 | - else { | |
856 | - FlipedImgCanvas.id = 'imageCanvas' + bodyRegionId + '_MR'; | |
857 | - FlipedImgCanvas.style.visibility = 'visible' | |
858 | - | |
859 | - if ($rootScope.isHighLight) { | |
860 | - FlipedImgCanvas.style.visibility = 'hidden'; | |
861 | - } | |
862 | - } | |
863 | - | |
864 | - | |
865 | - | |
866 | - FlipedImgCanvas.addEventListener('click', function (evt) { | |
867 | - | |
868 | - if (evt.ctrlKey) { | |
869 | - $scope.multiAnnotationIsON = true; | |
870 | - } | |
871 | - else { | |
872 | - $scope.multiAnnotationIsON = false; | |
873 | - } | |
874 | - | |
875 | - //get mouse coordinate of mirror image click | |
876 | - var mousePos = $scope.getMousePos(evt); | |
877 | - | |
878 | - var context = FlipedImgCanvas.getContext("2d"); | |
879 | - var canvasId = context.canvas.getAttribute('id'); | |
880 | - | |
881 | - | |
882 | - var mirrorCanvasX = context.canvas.offsetLeft; | |
883 | - var mirrorCanvasWidth = context.canvas.clientWidth; | |
884 | - | |
885 | - var maskCanvasId = (canvasId.replace('_MR', '')) + '_mci'; | |
886 | - var maskCanvas = document.getElementById(maskCanvasId); | |
887 | - var maskCanvasContext = maskCanvas.getContext("2d"); | |
888 | - | |
889 | - | |
890 | - var canvasDiv = document.getElementById('canvasDiv'); | |
891 | - var verticalScrollPosition = canvasDiv.scrollTop; | |
892 | - var horizontlScrollPosition = canvasDiv.scrollLeft; | |
893 | - | |
894 | - var distanceXOnMirrorImage = (parseInt(mirrorCanvasX) + parseInt(mirrorCanvasWidth)) - (parseInt(mousePos.x) + horizontlScrollPosition);// - 135); | |
895 | - | |
896 | - var mirrorXOnNormalImage = parseInt(maskCanvasContext.canvas.offsetLeft) + parseInt(distanceXOnMirrorImage); | |
897 | - | |
898 | - var actulalX = mirrorXOnNormalImage | |
899 | - var actualY = mousePos.y + verticalScrollPosition | |
900 | - | |
901 | - | |
902 | - var pixelData = maskCanvasContext.getImageData(Math.round(actulalX - parseInt(maskCanvasContext.canvas.offsetLeft)), Math.round(actualY - y), 1, 1); | |
903 | - | |
904 | - pixelData.data[0] = pixelData.data[0] - 9; | |
905 | - pixelData.data[1] = pixelData.data[1] - 9; | |
906 | - pixelData.data[2] = pixelData.data[2] - 9 | |
907 | - | |
908 | - var Red; | |
909 | - var Green; | |
910 | - var Blue; | |
911 | - var zero = "0"; | |
912 | - | |
913 | - if ((pixelData.data[0]).toString().length != 2) { | |
914 | - Red = zero.concat((pixelData.data[0]).toString()) | |
915 | - } | |
916 | - else { | |
917 | - Red = (pixelData.data[0]).toString() | |
918 | - } | |
919 | - if ((pixelData.data[1]).toString().length != 2) { | |
920 | - Green = zero.concat((pixelData.data[1]).toString()) | |
921 | - } | |
922 | - else { | |
923 | - Green = (pixelData.data[1]).toString() | |
924 | - | |
925 | - } | |
926 | - if ((pixelData.data[2]).toString().length != 2) { | |
927 | - Blue = zero.concat((pixelData.data[2]).toString()) | |
928 | - } | |
929 | - else { | |
930 | - Blue = (pixelData.data[2]).toString() | |
931 | - | |
932 | - } | |
933 | - var RGBColor = (Red + Green + Blue); | |
934 | - | |
935 | - if ($rootScope.isHighLight) { | |
936 | - ////2. Find Actul Term No Based on Icolor. | |
937 | - //var ActualTermNo = $scope.getActualTermNumber(RGBColor); | |
938 | - ////alert('actual term no: ' + ActualTermNo); | |
939 | - | |
940 | - ////3. Find Term No List Based on ActualTermNo | |
941 | - //var TermList = $scope.getTermNumberList(ActualTermNo); | |
942 | - //// alert('termList.count: ' + TermList.length); | |
943 | - | |
944 | - ////4. | |
945 | - | |
946 | - //$scope.machedTermNoLocation = []; | |
947 | - //for (var i = 0; i < TermList.length; i++) { | |
948 | - | |
949 | - // var termNumber = parseInt(TermList[i]._TermNumber); | |
950 | - | |
951 | - // //Match Term No List in each bodyRegion | |
952 | - // $scope.getLocationsForMatchedTermsInWholeBody(termNumber); | |
953 | - //} | |
954 | - | |
955 | - if ($scope.machedIcolorInBodyRegion.length > 0) { | |
956 | - if ($scope.multiAnnotationIsON == false) { | |
957 | - for (var i = 0; i < $scope.machedIcolorInBodyRegion.length; i++) { | |
958 | - var bodyRegionId = $scope.machedIcolorInBodyRegion[i]; | |
959 | - | |
960 | - var grayCanvasID = 'imageCanvas' + bodyRegionId; | |
961 | - var grayCanvas = document.getElementById(grayCanvasID); | |
962 | - | |
963 | - var grayCanvasContext = grayCanvas.getContext("2d"); | |
964 | - | |
965 | - var grayImageData = $rootScope.grayImageDataList[bodyRegionId - 1]; | |
966 | - | |
967 | - grayCanvasContext.putImageData(grayImageData, 0, 0) | |
968 | - | |
969 | - // for mirrored canvas | |
970 | - | |
971 | - if (bodyRegionId == 4 || bodyRegionId == 5 || bodyRegionId == 6) { | |
972 | - var grayCanvasID = 'imageCanvas' + bodyRegionId + '_MR'; | |
973 | - var grayCanvasMR = document.getElementById(grayCanvasID); | |
974 | - | |
975 | - var grayCanvasContextMR = grayCanvasMR.getContext("2d"); | |
976 | - | |
977 | - var grayImageDataMR = $rootScope.grayImageMRDataList[bodyRegionId]; | |
978 | - | |
979 | - grayCanvasContextMR.putImageData(grayImageDataMR, 0, 0) | |
980 | - } | |
981 | - | |
982 | - } | |
983 | - } | |
984 | - } | |
985 | - | |
986 | - $scope.highLightBodyBasedOnIcolor(RGBColor); | |
987 | - } | |
988 | - | |
989 | - | |
990 | - var annotationText = $scope.GetAnnotationText(parseInt(RGBColor)); | |
991 | - | |
992 | - if ($('#speechBubbleTrns').length > 0) | |
993 | - $('#speechBubbleTrns').remove(); | |
994 | - | |
995 | - if ($scope.multiAnnotationIsON == true) { | |
996 | - | |
997 | - $scope.createDynamicSpeechBubble(evt, annotationText, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top); | |
998 | - | |
999 | - } | |
1000 | - else { | |
1001 | - | |
1002 | - if ($('#dot').length > 0) { | |
1003 | - $('#dot').remove(); | |
1004 | - } | |
1005 | - | |
1006 | - if ($('#sppeachBubble').length > 0) { | |
1007 | - $('#sppeachBubble').remove(); | |
1008 | - | |
1009 | - | |
1010 | - $scope.createDynamicSpeechBubble(evt, annotationText, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top); | |
1011 | - } | |
1012 | - else { | |
1013 | - | |
1014 | - $scope.createDynamicSpeechBubble(evt, annotationText, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top); | |
1015 | - } | |
1016 | - | |
1017 | - | |
1018 | - } | |
1019 | - }, false); | |
1020 | - | |
1021 | - FlipedImgCanvas.addEventListener('mousedown', function (evt) { | |
1022 | - | |
1023 | - //alert('mousedown') | |
1024 | - }, false); | |
1025 | - | |
1026 | - | |
1027 | - FlipedImgCanvas.addEventListener('mouseup', function (evt) { | |
1028 | - //alert('mouseup') | |
1029 | - | |
1030 | - | |
1031 | - }, false); | |
1032 | - | |
1033 | - var context = FlipedImgCanvas.getContext("2d"); | |
1034 | - | |
1035 | - var PI = Math.PI; | |
1036 | - var PI2 = PI * 2; | |
1037 | - var cw, ch, imgW, imgH, mouseX, mouseY; | |
1038 | - var scaleFactor = 1.00; | |
1039 | - | |
1040 | - //$scaler = $("#scaler"); | |
1041 | - //$scaler.val(scaleFactor); | |
1042 | - //$scaler.hide(); | |
1043 | - | |
1044 | - var img = new Image(); | |
1045 | - img.onload = start; | |
1046 | - | |
1047 | - // img.src = "~/../content/images/" + src;; | |
1048 | - img.src = src; | |
1049 | - | |
1050 | - | |
1051 | - function start() { | |
1052 | - context.save(); | |
1053 | - context.translate(w, 0); | |
1054 | - context.scale(-1, 1); | |
1055 | - context.drawImage(img, 0, 0); | |
1056 | - context.restore(); | |
1057 | - | |
1058 | - | |
1059 | - }; | |
1060 | - | |
1061 | - document.getElementById('canvasDiv').appendChild(FlipedImgCanvas); | |
1062 | - | |
1063 | - if (FlipedImgCanvas.id.match('_mci')) { | |
1064 | - | |
1065 | - var maskImgData = context.getImageData(0, 0, w, h); | |
1066 | - | |
1067 | - $scope.MaskCanvasData.push( | |
1068 | - { | |
1069 | - "bodyRegionId": bodyRegionId, | |
1070 | - "canvasId": FlipedImgCanvas.id, | |
1071 | - "maskData": maskImgData, | |
1072 | - | |
1073 | - } | |
1074 | - ); | |
1075 | - } | |
1076 | - else { | |
1077 | - var colorImgData = context.getImageData(0, 0, w, h); | |
1078 | - $scope.ColoredCanvasData.push( | |
1079 | - { | |
1080 | - "bodyRegionId": bodyRegionId, | |
1081 | - "canvasId": FlipedImgCanvas.id, | |
1082 | - "coloredImageData": colorImgData.data, | |
1083 | - | |
1084 | - } | |
1085 | - ); | |
1086 | - } | |
1087 | - | |
1088 | - } | |
1089 | - | |
1090 | - $scope.DrawImage = function (h, w, x, y, src, bodyRegionId, isMaskImage) { | |
1091 | - | |
1092 | - var imgCanvas = document.createElement('canvas'); | |
1093 | - // imgCanvas.style.backgroundColor = 'red'; | |
1094 | - imgCanvas.height = h; | |
1095 | - imgCanvas.width = w; | |
1096 | - imgCanvas.setAttribute("data-IsMirrored", "N") | |
1097 | - imgCanvas.style.position = "absolute"; | |
1098 | - imgCanvas.style.left = x + "px"; | |
1099 | - imgCanvas.style.top = y + "px"; | |
1100 | - | |
1101 | - if (isMaskImage == 'Y') { | |
1102 | - imgCanvas.style.visibility = 'hidden' | |
1103 | - imgCanvas.id = 'imageCanvas' + bodyRegionId + '_mci'; | |
1104 | - | |
1105 | - } | |
1106 | - else { | |
1107 | - | |
1108 | - | |
1109 | - imgCanvas.id = 'imageCanvas' + bodyRegionId; | |
1110 | - imgCanvas.style.visibility = 'visible' | |
1111 | - | |
1112 | - if ($rootScope.isHighLight) { | |
1113 | - imgCanvas.style.visibility = 'hidden'; | |
1114 | - } | |
1115 | - | |
1116 | - if (bodyRegionId == 3) { | |
1117 | - //set z index of hip canavs to fix the issue caused by overlapping of arm canavs on hip canavs. | |
1118 | - imgCanvas.style.zIndex = "100"; | |
1119 | - } | |
1120 | - if (bodyRegionId.match('modestyImg')) { | |
1121 | - //added class to further access this canavs to show and hide leaf as per modesty seting | |
1122 | - imgCanvas.className = 'modestyImg' | |
1123 | - imgCanvas.style.visibility = 'hidden' | |
1124 | - //set z index to make leaf canvas on top of hip canavs | |
1125 | - imgCanvas.style.zIndex = "200"; | |
1126 | - } | |
1127 | - if (($scope.voId == 11 || $scope.voId == 9) && bodyRegionId == 6) { | |
1128 | - imgCanvas.style.zIndex = "500"; | |
1129 | - } | |
1130 | - } | |
1131 | - | |
1132 | - imgCanvas.addEventListener('click', function (evt) { | |
1133 | - | |
1134 | - if (evt.ctrlKey) { | |
1135 | - $scope.multiAnnotationIsON = true; | |
1136 | - } | |
1137 | - else { | |
1138 | - $scope.multiAnnotationIsON = false; | |
1139 | - } | |
1140 | - | |
1141 | - var annotationText; | |
1142 | - var context = imgCanvas.getContext("2d"); | |
1143 | - | |
1144 | - | |
1145 | - var canvasId = context.canvas.getAttribute('id'); | |
1146 | - var maskCanvasId; | |
1147 | - //for leaf canvas | |
1148 | - if (canvasId.match('modestyImg')) { | |
1149 | - maskCanvasId = canvasId; | |
1150 | - } | |
1151 | - else { | |
1152 | - maskCanvasId = canvasId + '_mci'; | |
1153 | - } | |
1154 | - var maskCanvas = document.getElementById(maskCanvasId); | |
1155 | - var maskCanvasContext = maskCanvas.getContext("2d"); | |
1156 | - | |
1157 | - //if ($scope.zoomInOut == 25) { | |
1158 | - // var mousePos = $scope.getMousePos1(evt); | |
1159 | - //} | |
1160 | - //else | |
1161 | - var mousePos = $scope.getMousePos(evt); | |
1162 | - // alert(mousePos.x + ',' + mousePos.y); | |
1163 | - | |
1164 | - var canvasDiv = document.getElementById('canvasDiv'); | |
1165 | - var verticalScrollPosition = canvasDiv.scrollTop; | |
1166 | - var horizontlScrollPosition = canvasDiv.scrollLeft; | |
1167 | - | |
1168 | - | |
1169 | - //We substracted 135, as the difference between flex and html coordinates for same organ is 135 | |
1170 | - var actulalX = mousePos.x + horizontlScrollPosition; | |
1171 | - var actualY = mousePos.y + verticalScrollPosition; | |
1172 | - | |
1173 | - | |
1174 | - | |
1175 | - var RGBColor = $scope.GetRGBColor(maskCanvasContext, actulalX, actualY, x, y); | |
1176 | - | |
1177 | - if ($rootScope.isHighLight) { | |
1178 | - | |
1179 | - if ($scope.machedIcolorInBodyRegion.length > 0) { | |
1180 | - if ($scope.multiAnnotationIsON == false) { | |
1181 | - for (var i = 0; i < $scope.machedIcolorInBodyRegion.length; i++) { | |
1182 | - var bodyRegionId = $scope.machedIcolorInBodyRegion[i]; | |
1183 | - | |
1184 | - var grayCanvasID = 'imageCanvas' + bodyRegionId; | |
1185 | - var grayCanvas = document.getElementById(grayCanvasID); | |
1186 | - | |
1187 | - var grayCanvasContext = grayCanvas.getContext("2d"); | |
1188 | - | |
1189 | - var grayImageData = $rootScope.grayImageDataList[bodyRegionId - 1]; | |
1190 | - | |
1191 | - grayCanvasContext.putImageData(grayImageData, 0, 0) | |
1192 | - | |
1193 | - // for unhighlight the mirrored body region | |
1194 | - if (bodyRegionId == 4 || bodyRegionId == 5 || bodyRegionId == 6) { | |
1195 | - var grayCanvasID = 'imageCanvas' + bodyRegionId + '_MR'; | |
1196 | - var grayCanvasMR = document.getElementById(grayCanvasID); | |
1197 | - | |
1198 | - var grayCanvasContextMR = grayCanvasMR.getContext("2d"); | |
1199 | - | |
1200 | - var grayImageDataMR = $rootScope.grayImageMRDataList[bodyRegionId]; | |
1201 | - | |
1202 | - grayCanvasContextMR.putImageData(grayImageDataMR, 0, 0) | |
1203 | - } | |
1204 | - | |
1205 | - } | |
1206 | - } | |
1207 | - } | |
1208 | - | |
1209 | - // var IcolorWithCordinate = new Object; | |
1210 | - var previousIcolor = RGBColor; | |
1211 | - //var previousX; | |
1212 | - // var previousY; | |
1213 | - | |
1214 | - //IcolorWithCordinate.previousIcolor= RGBColor; | |
1215 | - // IcolorWithCordinate.previousX = x; | |
1216 | - // IcolorWithCordinate.previousY = y; | |
1217 | - | |
1218 | - $scope.previousSelectedTermList.push(previousIcolor); | |
1219 | - | |
1220 | - $scope.highLightBodyBasedOnIcolor(RGBColor); | |
1221 | - | |
1222 | - //var ActualTermNo = $scope.getActualTermNumber(RGBColor); | |
1223 | - ////3. Find Term No List Based on ActualTermNo | |
1224 | - //var TermList = $scope.getTermNumberList(ActualTermNo); | |
1225 | - //// alert('termList.count: ' + TermList.length); | |
1226 | - | |
1227 | - ////4. | |
1228 | - | |
1229 | - //$scope.machedTermNoLocation = []; | |
1230 | - //for (var i = 0; i < TermList.length; i++) { | |
1231 | - | |
1232 | - // var termNumber = parseInt(TermList[i]._TermNumber); | |
1233 | - | |
1234 | - // //Match Term No List in each bodyRegion | |
1235 | - // $scope.getLocationsForMatchedTermsInWholeBody(termNumber, x, y); | |
1236 | - //} | |
1237 | - | |
1238 | - } | |
1239 | - | |
1240 | - else { | |
1241 | - // $scope.highLightBodyBasedOnIcolor(RGBColor); | |
1242 | - | |
1243 | - ////2. Find Actul Term No Based on Icolor. | |
1244 | - //var ActualTermNo = $scope.getActualTermNumber(RGBColor); | |
1245 | - | |
1246 | - ////3. Find Term No List Based on ActualTermNo | |
1247 | - //var TermList = $scope.getTermNumberList(ActualTermNo); | |
1248 | - | |
1249 | - | |
1250 | - ////4. | |
1251 | - | |
1252 | - //$scope.machedTermNoLocation = []; | |
1253 | - //for (var i = 0; i < TermList.length; i++) { | |
1254 | - | |
1255 | - // var termNumber = parseInt(TermList[i]._TermNumber); | |
1256 | - | |
1257 | - // //Match Term No List in each bodyRegion | |
1258 | - // $scope.getLocationsForMatchedTermsInWholeBody(termNumber, x, y); | |
1259 | - //} | |
1260 | - } | |
1261 | - | |
1262 | - | |
1263 | - | |
1264 | - | |
1265 | - //Modesty ON | |
1266 | - if (maskCanvasId.match('modestyImg') && RGBColor != '000000') { | |
1267 | - RGBColor = DA[0].figLeafTermId; | |
1268 | - annotationText = $scope.GetAnnotationBasedOnActualTermNo(RGBColor); | |
1269 | - } | |
1270 | - //Modesty On but clicked somewhre else, we did modesty check because the modesty image covers whole body region so if user will click to | |
1271 | - //see the annotation apart from leaf then the actual click will be on modesty canvas, but for annotation er | |
1272 | - // | |
1273 | - else if (maskCanvasId.match('modestyImg') && RGBColor == '000000') { | |
1274 | - //if ($scope.voId == 11) { | |
1275 | - // maskCanvasId = 'imageCanvas6_mci'; | |
1276 | - // x = $('#imageCanvas6_mci').left; | |
1277 | - // y = $('#imageCanvas6_mci').top; | |
1278 | - //} | |
1279 | - //else { | |
1280 | - bodyRegionId = maskCanvasId.slice(-1); | |
1281 | - maskCanvasId = 'imageCanvas' + bodyRegionId + '_mci'; | |
1282 | - // } | |
1283 | - var maskCanvas = document.getElementById(maskCanvasId); | |
1284 | - var maskCanvasContext = maskCanvas.getContext("2d"); | |
1285 | - RGBColor = $scope.GetRGBColor(maskCanvasContext, actulalX, actualY, x, y); | |
1286 | - annotationText = $scope.GetAnnotationText(parseInt(RGBColor)); | |
1287 | - } | |
1288 | - else { | |
1289 | - RGBColor = $scope.GetRGBColor(maskCanvasContext, actulalX, actualY, x, y); | |
1290 | - annotationText = $scope.GetAnnotationText(parseInt(RGBColor)); | |
1291 | - | |
1292 | - } | |
1293 | - | |
1294 | - | |
1295 | - if ($('#speechBubbleTrns').length > 0) | |
1296 | - $('#speechBubbleTrns').remove(); | |
1297 | - | |
1298 | - if ($scope.multiAnnotationIsON == true) { | |
1299 | - | |
1300 | - $scope.createDynamicSpeechBubble(evt, annotationText, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top); | |
1301 | - | |
1302 | - } | |
1303 | - else { | |
1304 | - if ($('#dot').length > 0) { | |
1305 | - $('#dot').remove(); | |
1306 | - | |
1307 | - if ($('#sppeachBubble').length > 0) { | |
1308 | - $('#sppeachBubble').remove(); | |
1309 | - } | |
1310 | - | |
1311 | - | |
1312 | - | |
1313 | - $scope.createDynamicSpeechBubble(evt, annotationText, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top); | |
1314 | - } | |
1315 | - else { | |
1316 | - | |
1317 | - $scope.createDynamicSpeechBubble(evt, annotationText, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top); | |
1318 | - } | |
1319 | - | |
1320 | - | |
1321 | - } | |
1322 | - }, false); | |
1323 | - | |
1324 | - var PI = Math.PI; | |
1325 | - var PI2 = PI * 2; | |
1326 | - var cw, ch, imgW, imgH, mouseX, mouseY; | |
1327 | - var scaleFactor = 1.00; | |
1328 | - | |
1329 | - var context = imgCanvas.getContext('2d'); | |
1330 | - var img = new Image(); | |
1331 | - img.onload = start; | |
1332 | - | |
1333 | - img.src = src; | |
1334 | - | |
1335 | - function start() { | |
1336 | - // debugger; | |
1337 | - context.drawImage(img, 0, 0); | |
1338 | - | |
1339 | - if (imgCanvas.id.match('_mci')) { | |
1340 | - var maskImgData = context.getImageData(0, 0, w, h); | |
1341 | - $scope.MaskCanvasData.push( | |
1342 | - { | |
1343 | - "bodyRegionId": bodyRegionId, | |
1344 | - "canvasId": imgCanvas.id, | |
1345 | - "maskData": maskImgData, | |
1346 | - | |
1347 | - } | |
1348 | - ); | |
1349 | - } | |
1350 | - else { | |
1351 | - var colorImgData = context.getImageData(0, 0, w, h); | |
1352 | - $scope.ColoredCanvasData.push( | |
1353 | - { | |
1354 | - "bodyRegionId": bodyRegionId, | |
1355 | - "canvasId": imgCanvas.id, | |
1356 | - "coloredImageData": colorImgData.data, | |
1357 | - | |
1358 | - } | |
1359 | - ); | |
1360 | - } | |
1361 | - }; | |
1362 | - | |
1363 | - document.getElementById('canvasDiv').appendChild(imgCanvas); | |
1364 | - | |
1365 | - | |
1366 | - } | |
1367 | - $scope.highLightBodyBasedOnIcolor = function (RGBColor) { | |
1368 | - | |
1369 | - //2. Find Actul Term No Based on Icolor. | |
1370 | - var ActualTermNo = $scope.getActualTermNumber(RGBColor); | |
1371 | - | |
1372 | - //3. Find Term No List Based on ActualTermNo | |
1373 | - var TermList = $scope.getTermNumberList(ActualTermNo); | |
1374 | - | |
1375 | - | |
1376 | - //4. | |
1377 | - | |
1378 | - $scope.machedTermNoLocation = []; | |
1379 | - | |
1380 | - // debugger; | |
1381 | - var worker = new Worker('term-number-wp.js'); | |
1382 | - | |
1383 | - worker.postMessage({ | |
1384 | - | |
1385 | - 'termList': TermList, | |
1386 | - 'maskCanvasData': $scope.MaskCanvasData, | |
1387 | - 'coloredImageCanvasList': $rootScope.coloredImageCanvasList, | |
1388 | - 'coloredImageMRCanvasList': $rootScope.coloredImageMRCanvasList, | |
1389 | - 'grayImageDataList': $rootScope.grayImageDataList, | |
1390 | - 'grayImageMRDataList': $rootScope.grayImageMRDataList | |
1391 | - | |
1392 | - }); | |
1393 | - | |
1394 | - //} | |
1395 | - | |
1396 | - worker.onmessage = function (e) { | |
1397 | - debugger; | |
1398 | - | |
1399 | - var updatedData = e.data.value; | |
1400 | - | |
1401 | - for (var i = 1; i < updatedData.length; i++) { | |
1402 | - | |
1403 | - var grayCanvasID = updatedData[i].canvasID; | |
1404 | - var grayCanvas = document.getElementById(grayCanvasID); | |
1405 | - console.log('pause') | |
1406 | - var grayCanvasContext = grayCanvas.getContext("2d"); | |
1407 | - | |
1408 | - console.log('pause') | |
1409 | - debugger; | |
1410 | - grayCanvasContext.putImageData(updatedData[i].imageData, 0, 0); | |
1411 | - } | |
1412 | - | |
1413 | - | |
1414 | - }; | |
1415 | - worker.onerror = function (e) { | |
1416 | - alert('Error: Line ' + e.lineno + ' in ' + e.filename + ': ' + e.message); | |
1417 | - }; | |
1418 | - } | |
1419 | - | |
1420 | - | |
1421 | - | |
1422 | - $scope.GetRGBColor = function (maskCanvasContext, actulalX, actualY, x, y) { | |
1423 | - var pixelData = maskCanvasContext.getImageData(Math.round(actulalX - x), Math.round(actualY - y), 1, 1); | |
1424 | - | |
1425 | - pixelData.data[0] = pixelData.data[0] - 9; | |
1426 | - pixelData.data[1] = pixelData.data[1] - 9; | |
1427 | - pixelData.data[2] = pixelData.data[2] - 9; | |
1428 | - var Red; | |
1429 | - var Green; | |
1430 | - var Blue; | |
1431 | - var zero = "0"; | |
1432 | - | |
1433 | - if ((pixelData.data[0]).toString().length != 2) { | |
1434 | - Red = zero.concat((pixelData.data[0]).toString()) | |
1435 | - } | |
1436 | - else { | |
1437 | - Red = (pixelData.data[0]).toString() | |
1438 | - } | |
1439 | - if ((pixelData.data[1]).toString().length != 2) { | |
1440 | - Green = zero.concat((pixelData.data[1]).toString()) | |
1441 | - } | |
1442 | - else { | |
1443 | - Green = (pixelData.data[1]).toString() | |
1444 | - | |
1445 | - } | |
1446 | - if ((pixelData.data[2]).toString().length != 2) { | |
1447 | - Blue = zero.concat((pixelData.data[2]).toString()) | |
1448 | - } | |
1449 | - else { | |
1450 | - Blue = (pixelData.data[2]).toString() | |
1451 | - | |
1452 | - } | |
1453 | - var RGBColor = (Red + Green + Blue); | |
1454 | - return RGBColor; | |
1455 | - } | |
1456 | - | |
1457 | - | |
1458 | - //get annotation from term number | |
1459 | - $scope.GetAnnotationText = function (termNumber) { | |
1460 | - //debugger; | |
1461 | - | |
1462 | - var annotationText; | |
1463 | - //0 | |
1464 | - var figLeafTermNo = 5868; // to do declare constant for this | |
1465 | - | |
1466 | - if (parseInt(termNumber) != parseInt(figLeafTermNo)) { | |
1467 | - $scope.TermNumber = termNumber; | |
1468 | - $scope.matchedTermNoData = new jinqJs() | |
1469 | - .from($scope.TermNumberData.TermData.Term) | |
1470 | - .where('_TermNumber == ' + termNumber) | |
1471 | - .select(); | |
1472 | - //1. | |
1473 | - var actualTermNo = 0; | |
1474 | - for (var z = 0; z <= $scope.matchedTermNoData.length; z++) { | |
1475 | - //send actual term no to get the term text. | |
1476 | - actualTermNo = $scope.matchedTermNoData[0]._ActualTermNumber; | |
1477 | - annotationText = $scope.GetAnnotationBasedOnActualTermNo(actualTermNo); | |
1478 | - break; | |
1479 | - }; | |
1480 | - | |
1481 | - //2. | |
1482 | - | |
1483 | - } | |
1484 | - else { | |
1485 | - // send term no to vocab json data to get the text | |
1486 | - } | |
1487 | - return annotationText; | |
1488 | - } | |
1489 | - | |
1490 | - $scope.GetAnnotationBasedOnActualTermNo = function (actualTermNo) { | |
1491 | - // debugger; | |
1492 | - | |
1493 | - var Annotation; | |
1494 | - $scope.ActualTermNo = actualTermNo; | |
1495 | - | |
1496 | - $scope.matchedActualTermData = new jinqJs() | |
1497 | - .from($scope.VocabTermData.VocabTerms.Term) | |
1498 | - .where('_ActualTermNumber == ' + actualTermNo) | |
1499 | - .select(); | |
1500 | - for (var z = 0; z <= $scope.matchedActualTermData.length; z++) { | |
1501 | - //send actual term no to get the term text. | |
1502 | - Annotation = $scope.matchedActualTermData[0]._TermText; | |
1503 | - // alert("Annotation : " + Annotation); | |
1504 | - break; | |
1505 | - }; | |
1506 | - return Annotation; | |
1507 | - } | |
1508 | - | |
1509 | - | |
1510 | - //layer change function | |
1511 | - $scope.LayerChange = function () { | |
1512 | - // alert('layer chnage') | |
1513 | - | |
1514 | - var canvasDiv = document.getElementById('canvasDiv'); | |
1515 | - $scope.imageVerticalScrollPosition = canvasDiv.scrollTop; | |
1516 | - $scope.imageHorizontlScrollPosition = canvasDiv.scrollLeft; | |
1517 | - | |
1518 | - // debugger; | |
1519 | - // $('#daLoaderLabel').css('visibility', 'visible'); | |
1520 | - | |
1521 | - | |
1522 | - | |
1523 | - if ($scope.isTransparencyActivated) { | |
1524 | - | |
1525 | - //crete temp canavs to store the original data which will be used to chnange the transparency | |
1526 | - if (document.getElementById('tempCanvas') != null) { | |
1527 | - $('#tempCanvas').remove(); | |
1528 | - } | |
1529 | - | |
1530 | - if ($('#speechBubbleTrns').length > 0) { | |
1531 | - $('#speechBubbleTrns').remove(); | |
1532 | - } | |
1533 | - var tempCanvas = document.createElement('canvas'); | |
1534 | - tempCanvas.id = 'tempCanvas'; | |
1535 | - $scope.tempCanvas = tempCanvas.id; | |
1536 | - tempCanvas.height = $scope.transparencyCanvasHeight; | |
1537 | - tempCanvas.width = $scope.transparencyCanvasWidth; | |
1538 | - tempCanvas.style.position = "absolute"; | |
1539 | - tempCanvas.style.left = 200 + 'px'; | |
1540 | - tempCanvas.style.backgroundColor = "transparent"; | |
1541 | - tempCanvas.style.visibility = 'hidden'; | |
1542 | - document.getElementById('canvasDiv').appendChild(tempCanvas); | |
1543 | - | |
1544 | - // //debugger; | |
1545 | - | |
1546 | - var tCanvas = document.getElementById('transparencyCanvas'); | |
1547 | - var tCanvasContext = tCanvas.getContext('2d'); | |
1548 | - | |
1549 | - var tCanvasHeight = parseInt((tCanvas.style.height).replace('px', '')); | |
1550 | - | |
1551 | - var tCanvasWidth = parseInt((tCanvas.style.width).replace('px', '')); | |
1552 | - | |
1553 | - | |
1554 | - // var tCanvas = document.getElementById('transparencyCanvas'); | |
1555 | - if (tCanvas != null) { | |
1556 | - clearTransCanvas(); | |
1557 | - } | |
1558 | - var TransparencyBoxStartX = parseInt((tCanvas.style.left).replace('px', '')); | |
1559 | - var TransparencyEndX = parseInt((tCanvas.style.left).replace('px', '')) + parseInt((tCanvas.style.width.replace('px', ''))); | |
1560 | - var TransparencyBoxStartY = parseInt((tCanvas.style.top).replace('px', '')); | |
1561 | - var TransparencyBoxEndY = parseInt((tCanvas.style.top).replace('px', '')) + parseInt((tCanvas.style.height).replace('px', '')); | |
1562 | - var transparencyBoxBottom = parseInt(TransparencyBoxStartY) + parseInt(tCanvasHeight); | |
1563 | - var transparencyBoxRight = parseInt(TransparencyBoxStartX) + parseInt(tCanvasWidth); | |
1564 | - | |
1565 | - var BodyRegionDictionary = $scope.BodyRegionCordinatesData; | |
1566 | - | |
1567 | - $.each(BodyRegionDictionary, function (index, value) { | |
1568 | - //debugger; | |
1569 | - // alert(' $.each(BodyRegionDictionary1') | |
1570 | - | |
1571 | - var bodyRegionRight = parseInt(value.X) + parseInt(value.Width); | |
1572 | - var bodyRegionBottom = parseInt(value.Y) + parseInt(value.Height); | |
1573 | - | |
1574 | - | |
1575 | - // alert(' $.each(BodyRegionDictionary3. bodyRegionRight: ' + bodyRegionRight + ', bodyRegionBottom: ' + bodyRegionBottom) | |
1576 | - if (TransparencyBoxStartX <= bodyRegionRight && value.X <= transparencyBoxRight && TransparencyBoxStartY <= bodyRegionBottom && value.Y <= transparencyBoxBottom) { | |
1577 | - //var transNumber = parseInt(document.getElementById("txtTransparencyChange").value); | |
1578 | - // debugger; | |
1579 | - $scope.layerNumber = parseInt(txtlayerNumber.value); | |
1580 | - | |
1581 | - | |
1582 | - $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.X, value.Y, value.IsMirror, TransparencyBoxStartX, transparencyBoxRight, TransparencyBoxStartY, transparencyBoxBottom, $scope, true, false); | |
1583 | - } | |
1584 | - | |
1585 | - | |
1586 | - }) | |
1587 | - } | |
1588 | - | |
1589 | - else { | |
1590 | - $scope.currentLayerNumber = parseInt($('#txtlayerNumber').val()); | |
1591 | - | |
1592 | - $rootScope.isLoading = true; | |
1593 | - $('#spinner').css('visibility', 'visible'); | |
1594 | - var canDiv = document.getElementById('canvasDiv'); | |
1595 | - var canDivChildCount = canDiv.childElementCount; | |
1596 | - if (canDivChildCount > 0) { | |
1597 | - canDiv.innerHTML = ''; | |
1598 | - } | |
1599 | - | |
1600 | - $scope.CalculateImageCordinates($scope.viewOrientationId); | |
1601 | - | |
1602 | - $('#canvasDiv').scrollLeft($scope.imageHorizontlScrollPosition) | |
1603 | - $('#canvasDiv').scrollTop($scope.imageVerticalScrollPosition) | |
1604 | - | |
1605 | - $timeout(function () { $scope.DisableProgressBar() }, 1000); | |
1606 | - } | |
1607 | - | |
1608 | - //if ($rootScope.isHighLight) { | |
1609 | - // //alert('isHighlight: ' + $scope.isHighLight); | |
1610 | - | |
1611 | - // $('#btnHighLight').removeClass('btn btn-black'); | |
1612 | - // $('#btnHighLight').addClass('btn-primary'); | |
1613 | - | |
1614 | - // $timeout(function () { $scope.highLightBody() }, 350); | |
1615 | - | |
1616 | - | |
1617 | - | |
1618 | - //} | |
1619 | - | |
1620 | - } | |
1621 | - | |
1622 | - $scope.DisableProgressBar = function () { | |
1623 | - | |
1624 | - // alert('Disabled wait cursor is called'); | |
1625 | - | |
1626 | - | |
1627 | - if ($rootScope.isHighLight) { | |
1628 | - //alert('isHighlight: ' + $scope.isHighLight); | |
1629 | - | |
1630 | - $('#btnHighLight').removeClass('btn btn-black'); | |
1631 | - $('#btnHighLight').addClass('btn-primary'); | |
1632 | - | |
1633 | - $scope.highLightBody(); | |
1634 | - | |
1635 | - | |
1636 | - | |
1637 | - } | |
1638 | - $rootScope.isLoading = false; | |
1639 | - $('#spinner').css('visibility', 'hidden'); | |
1640 | - | |
1641 | - //alert('Disabled wait cursor is done.See val :' + $rootScope.isLoading); | |
1642 | - } | |
1643 | - | |
1644 | - | |
1645 | - $scope.changeLayer = function () { | |
1646 | - //console.log('changeLayer'); | |
1647 | - // alert('slide') | |
1648 | - } | |
1649 | - | |
1650 | - $('layerChangeSlider').slider().on('slideStop', function (ev) { | |
1651 | - | |
1652 | - var newVal = $('.span2').data('slider').getValue(); | |
1653 | - if (originalVal != newVal) { | |
1654 | - | |
1655 | - } | |
1656 | - }); | |
1657 | - | |
1658 | - | |
1659 | - $scope.getMousePos = function (evt) { | |
1660 | - | |
1661 | - return { | |
1662 | - x: Math.round(evt.pageX - $('#canvasDiv').offset().left), | |
1663 | - y: Math.round(evt.pageY - $('#canvasDiv').offset().top) | |
1664 | - } | |
1665 | - } | |
1666 | - | |
1667 | - $scope.createDynamicSpeechBubble = function (event, text, x, y) { | |
1668 | - | |
1669 | - if (event.ctrlKey) { | |
1670 | - | |
1671 | - $scope.multiAnnotationIsON = true; | |
1672 | - | |
1673 | - $scope.i = $scope.i + 1; | |
1674 | - // var a = $("#sppeachBubble").find('span').html(); | |
1675 | - // alert(a); | |
1676 | - var sub_id = "black" + $scope.i; | |
1677 | - $("#canvasDiv").append("<div class='com'><div style='position:absolute;border-top:2px solid #000;transform:rotate(40deg);-moz-transform:rotate(40deg);-o-transform:rotate(40deg);-ms-transform:rotate(40deg);-webkit-transform:rotate(40deg);height:15px;width:35px;left:" + (x - 10) + "px;top:" + (y + 10) + "px;'' id='bubble" + $scope.i + "'></div><div data=" + $scope.i + " id=" + sub_id + " class='appendDragg' style='z-index:10000;margin-left:25px;border:1px solid #000;padding:5px 10px;width:200px;position:absolute;color:#000;text-align:left;font-size: 12px;background-color:#fff;font-weight:bold;left:" + x + "px;top:" + y + "px;'>" + text + "<div style='z-index:7000;position:absolute;right:-4px;top:-4px;color:#ffffff;cursor:pointer;'><img id=" + $scope.i + " class='dynCross' src='/AIA/content/images/speeachBubbleClose.png'></div></div><div style='position:absolute;border:1px solid #000;display:none;z-index:9000;' id='bord" + $scope.i + "'></div></div>"); | |
1678 | - | |
1679 | - | |
1680 | - $scope.speachBubbleArray.push({ xaxis: x, yaxis: y, ids: sub_id }); | |
1681 | - | |
1682 | - $('.appendDragg').draggable({ | |
1683 | - drag: function (evt) { | |
1684 | - $(this).prev('div').css("display", "none"); | |
1685 | - var bor_id = $(this).next('div').attr('id'); | |
1686 | - var sub_id1 = $(this).attr('id'); | |
1687 | - var verticalScrollPosition = canvasDiv.scrollTop; | |
1688 | - var horizontlScrollPosition = canvasDiv.scrollLeft; | |
1689 | - for (var m = 0; m <= $scope.speachBubbleArray.length - 1; m++) { | |
1690 | - if ($scope.speachBubbleArray[m].ids == sub_id1) { | |
1691 | - | |
1692 | - $scope.angle1($scope.speachBubbleArray[m].xaxis, $scope.speachBubbleArray[m].yaxis, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, bor_id); | |
1693 | - break; | |
1694 | - | |
1695 | - } | |
1696 | - } | |
1697 | - | |
1698 | - }, | |
1699 | - }); | |
1700 | - | |
1701 | - | |
1702 | - | |
1703 | - $('.dynCross').on('click', function (evt) { | |
1704 | - $(this).parent().parent().parent().css('display', 'none'); | |
1705 | - | |
1706 | - // $("#bord").css("display", "none"); | |
1707 | - // $("#dot").css("display", "none"); | |
1708 | - | |
1709 | - | |
1710 | - }); | |
1711 | - | |
1712 | - | |
1713 | - } | |
1714 | - | |
1715 | - | |
1716 | - else { | |
1717 | - $scope.multiAnnotationIsON = false; | |
1718 | - | |
1719 | - $(".com").css("display", "none"); | |
1720 | - $("#bord").css({ "width": "0px", "display": "none" }); | |
1721 | - | |
1722 | - $('<div id="dot" style="position:absolute;height:15px;width:35px;display:none;border-top:2px solid #000;transform:rotate(40deg);-moz-transform:rotate(40deg);-o-transform:rotate(40deg);-ms-transform:rotate(40deg);-webkit-transform:rotate(40deg);"></div>' | |
1723 | - + '<div id="sppeachBubble" style="height:auto!important;z-index:10000;margin-left:25px;border:1px solid #000;display:none;padding:5px 10px;width:200px;position:absolute;color:#000;text-align:left;font-size:12px;background-color:#fff;font-weight:bold;"><span>' + text + '</span>' | |
1724 | - + '<span style="position:absolute;right:-4px;top:-4px;color:#ffffff;cursor:pointer;">' | |
1725 | - + '<img class="crossDiv_temp" src="/AIA/content/images/speeachBubbleClose.png"></span></div>' | |
1726 | - | |
1727 | - + '<div style="position:absolute;border:1px solid #000;display:none;z-index:9000;" id="bord">' | |
1728 | - + '</div>').appendTo('#canvasDiv'); | |
1729 | - var Globe = []; | |
1730 | - Globe.push({ currentX: x, currentY: y }); | |
1731 | - | |
1732 | - document.getElementById('dot').style.display = 'block'; | |
1733 | - document.getElementById('dot').style.left = ((Globe[0].currentX) - 10) + 'px'; | |
1734 | - document.getElementById('dot').style.top = ((Globe[0].currentY) + 10) + 'px'; | |
1735 | - document.getElementById('sppeachBubble').style.display = 'block'; | |
1736 | - document.getElementById('sppeachBubble').style.left = (Globe[0].currentX) + 'px'; | |
1737 | - document.getElementById('sppeachBubble').style.top = (Globe[0].currentY) + 'px'; | |
1738 | - | |
1739 | - $('#sppeachBubble').draggable( | |
1740 | - { | |
1741 | - drag: function (evt) { | |
1742 | - | |
1743 | - $("#dot").css("display", "none"); | |
1744 | - var verticalScrollPosition = canvasDiv.scrollTop; | |
1745 | - var horizontlScrollPosition = canvasDiv.scrollLeft; | |
1746 | - $scope.angle(x, y, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top); | |
1747 | - | |
1748 | - | |
1749 | - }, | |
1750 | - }); | |
1751 | - | |
1752 | - | |
1753 | - $('.crossDiv_temp').on('click', function (evt) { | |
1754 | - $('#sppeachBubble').css('display', 'none'); | |
1755 | - | |
1756 | - $("#bord").css("display", "none"); | |
1757 | - $("#dot").css("display", "none"); | |
1758 | - | |
1759 | - | |
1760 | - }); | |
1761 | - | |
1762 | - } | |
1763 | - | |
1764 | - | |
1765 | - } | |
1766 | - | |
1767 | - $scope.angle1 = function (cx1, cy1, ex1, ey1, id, id2) { | |
1768 | - | |
1769 | - // console.log(cx1 + " " + cy1); | |
1770 | - var dy = ey1 - cy1; | |
1771 | - var dx = ex1 - cx1; | |
1772 | - var theta = 0; | |
1773 | - if (dx < 0) { | |
1774 | - theta = Math.atan(dy / dx) * (180 / Math.PI); | |
1775 | - theta = theta + 180; | |
1776 | - | |
1777 | - } | |
1778 | - else if (dy < 0) { | |
1779 | - theta = Math.atan(dy / dx) * (180 / Math.PI); | |
1780 | - theta = theta + 360; | |
1781 | - | |
1782 | - } | |
1783 | - else { | |
1784 | - theta = Math.atan(dy / dx) * (180 / Math.PI); | |
1785 | - } | |
1786 | - | |
1787 | - var g = Math.sqrt((cx1 - ex1) * (cx1 - ex1) + (cy1 - ey1) * (cy1 - ey1)); | |
1788 | - var e = cy1; | |
1789 | - var f = cx1; | |
1790 | - | |
1791 | - $('#' + id).css({ 'display': 'block', 'width': g + 'px', 'top': e + 'px', 'left': f + 'px', 'transform': 'rotate(' + theta + 'deg)', '-moz-transform': 'rotate(' + theta + 'deg)', '-webkit-transform': 'rotate(' + theta + 'deg)', 'transform-origin': '0% 0%' }); | |
1792 | - | |
1793 | - } | |
1794 | - | |
1795 | - function myFunction(crossId) { | |
1796 | - alert(crossId); | |
1797 | - $('#' + crossId).parent().parent().parent().css("display", "none"); | |
1798 | - | |
1799 | - } | |
1800 | - | |
1801 | - | |
1802 | - $scope.angle = function (cx, cy, ex, ey) { | |
1803 | - | |
1804 | - | |
1805 | - var dy = ey - cy; | |
1806 | - var dx = ex - cx; | |
1807 | - var theta = 0; | |
1808 | - if (dx < 0) { | |
1809 | - theta = Math.atan(dy / dx) * (180 / Math.PI); | |
1810 | - theta = theta + 180; | |
1811 | - | |
1812 | - } | |
1813 | - else if (dy < 0) { | |
1814 | - theta = Math.atan(dy / dx) * (180 / Math.PI); | |
1815 | - theta = theta + 360; | |
1816 | - | |
1817 | - } | |
1818 | - else { | |
1819 | - theta = Math.atan(dy / dx) * (180 / Math.PI); | |
1820 | - } | |
1821 | - | |
1822 | - var d = Math.sqrt((cx - ex) * (cx - ex) + (cy - ey) * (cy - ey)); | |
1823 | - var e = cy; | |
1824 | - var f = cx; | |
1825 | - | |
1826 | - $("#bord").css({ 'display': 'block', 'width': d + 'px', 'top': e + 'px', 'left': f + 'px', 'transform': 'rotate(' + theta + 'deg)', '-moz-transform': 'rotate(' + theta + 'deg)', '-webkit-transform': 'rotate(' + theta + 'deg)', 'transform-origin': '0% 0%' }); | |
1827 | - | |
1828 | - | |
1829 | - } | |
1830 | - | |
1831 | - | |
1832 | - $scope.createSpeechBubble = function (event, text, x, y) { | |
1833 | - //set z index to make annoation speech buble on top others | |
1834 | - $('#canvasDiv').css('cursor', 'pointer'); | |
1835 | - $('<div id="speechBubble" class="BubbleDiv" style="display:visible; top:' + y + 'px; left:' + x + 'px; z-index:700"> <div class="">' | |
1836 | - + '<div class="Bubble">' | |
1837 | - + '<div class="BubbleCloseBtn"></div><div class="BubbleContent">' + text + '</div><div class="bottomLeftArrow"></div>' | |
1838 | - //+'<div class="bottomRightArrow"></div><div class="topLeftArrow"></div><div class="topRightArrow"></div> | |
1839 | - + '</div></div></div>').appendTo('#canvasDiv'); | |
1840 | - | |
1841 | - $('#speechBubble').on('click', '.BubbleCloseBtn', function (evt) { | |
1842 | - $('#speechBubble').css('display', 'none'); | |
1843 | - }); | |
1844 | - | |
1845 | - $('#canvasDiv').attr("data-bubbleid", "speechBubble") | |
1846 | - | |
1847 | - | |
1848 | - }; | |
1849 | - | |
1850 | - | |
1851 | - $scope.createTransparencyBox = function () { | |
1852 | - | |
1853 | - // debugger | |
1854 | - // alert('transparency clcked') | |
1855 | - | |
1856 | - | |
1857 | - | |
1858 | - $scope.isTransparencyActivated = true; | |
1859 | - // alert('transparencyClicked' + $scope.isTransparencyActivated) | |
1860 | - $('#btnTranparency').addClass('tButtonActive'); | |
1861 | - $('#btnIdentity').removeClass(' btn-primary'); | |
1862 | - $('#btnIdentity').addClass('btn-black'); | |
1863 | - | |
1864 | - var canvasDiv = document.getElementById('canvasDiv'); | |
1865 | - $scope.verticalScrollPosition = canvasDiv.scrollTop; | |
1866 | - $scope.horizontlScrollPosition = canvasDiv.scrollLeft; | |
1867 | - | |
1868 | - var canvasDiv = document.getElementById('canvasDiv'); | |
1869 | - canvasDiv.addEventListener("mousedown", mouseDownListener); | |
1870 | - | |
1871 | - canvasDiv.addEventListener("mousemove", mouseMoveListener); | |
1872 | - | |
1873 | - canvasDiv.addEventListener("mouseup", mouseUpListener) | |
1874 | - | |
1875 | - } | |
1876 | - | |
1877 | - function mouseDownListener(e) { | |
1878 | - | |
1879 | - var $container = document.getElementById('canvasDiv'); | |
1880 | - var $selection = $('<div>').addClass('rectangle'); | |
1881 | - document.getElementById("DAView") | |
1882 | - $selection.css({ | |
1883 | - 'position': 'absolute', | |
1884 | - //'background': 'transparent', | |
1885 | - 'border': '1px dotted #000' | |
1886 | - }); | |
1887 | - | |
1888 | - var currentMousePosition = $scope.getMousePos(e); | |
1889 | - | |
1890 | - $scope.TBDrawStartX = currentMousePosition.x; | |
1891 | - $scope.TBDrawStartY = currentMousePosition.y; | |
1892 | - | |
1893 | - | |
1894 | - var actulalX = currentMousePosition.x + $scope.horizontlScrollPosition | |
1895 | - var actualY = currentMousePosition.y + $scope.verticalScrollPosition | |
1896 | - | |
1897 | - //alert('$scope.TransparencyBoxStartX in mouseDown: ' + $scope.TransparencyBoxStartX + ' & Y= ' + $scope.TransparencyBoxStartY); | |
1898 | - $scope.TransparencyBoxStartX = actulalX; | |
1899 | - $scope.TransparencyBoxStartY = actualY | |
1900 | - $scope.startX = actulalX; | |
1901 | - $scope.startY = actualY; | |
1902 | - var tBox = document.getElementById('transparencyCanvas'); | |
1903 | - | |
1904 | - if (tBox == null) { | |
1905 | - //// canvasDiv.style.cursor = "crosshair"; | |
1906 | - $selection.css({ | |
1907 | - 'top': actualY, | |
1908 | - 'left': actulalX, | |
1909 | - 'width': 0, | |
1910 | - 'height': 0, | |
1911 | - 'z-index': 1000 | |
1912 | - //'background': 'transparent', | |
1913 | - }); | |
1914 | - $selection.appendTo($container); | |
1915 | - } | |
1916 | - | |
1917 | - document.getElementById('canvasDiv').removeEventListener("mousedown", mouseDownListener); | |
1918 | - | |
1919 | - } | |
1920 | - | |
1921 | - function mouseMoveListener(e) { | |
1922 | - | |
1923 | - var currentMousePosition = $scope.getMousePos(e); | |
1924 | - var move_x = currentMousePosition.x + $scope.horizontlScrollPosition, | |
1925 | - move_y = currentMousePosition.y + $scope.verticalScrollPosition, | |
1926 | - | |
1927 | - width = move_x - $scope.TransparencyBoxStartX, | |
1928 | - height = move_y - $scope.TransparencyBoxStartY, | |
1929 | - new_x, new_y; | |
1930 | - | |
1931 | - new_x = (move_x < $scope.TransparencyBoxStartX) ? ($scope.TransparencyBoxStartX - width) : $scope.TransparencyBoxStartX; | |
1932 | - new_y = (move_y < $scope.TransparencyBoxStartY) ? ($scope.TransparencyBoxStartY - height) : $scope.TransparencyBoxStartY; | |
1933 | - | |
1934 | - $('.rectangle').css({ | |
1935 | - 'width': width, | |
1936 | - 'height': height, | |
1937 | - //'background': 'transparent' | |
1938 | - | |
1939 | - }); | |
1940 | - | |
1941 | - | |
1942 | - | |
1943 | - } | |
1944 | - | |
1945 | - | |
1946 | - function mouseUpListener(e) { | |
1947 | - // $selection.remove(); | |
1948 | - // debugger; | |
1949 | - | |
1950 | - $scope.currentLayerNumber = parseInt($('#txtlayerNumber').val()); | |
1951 | - $('.rectangle').remove(); | |
1952 | - | |
1953 | - var currentMousePosition = $scope.getMousePos(e); | |
1954 | - | |
1955 | - | |
1956 | - var canvasDiv = document.getElementById('canvasDiv'); | |
1957 | - var verticalScrollPosition = canvasDiv.scrollTop; | |
1958 | - var horizontlScrollPosition = canvasDiv.scrollLeft; | |
1959 | - | |
1960 | - var TransparencyEndX = currentMousePosition.x + horizontlScrollPosition | |
1961 | - var TransparencyBoxEndY = currentMousePosition.y + verticalScrollPosition | |
1962 | - | |
1963 | - | |
1964 | - $scope.isTboxDrwan = true; | |
1965 | - $scope.TbEndX = TransparencyEndX; | |
1966 | - $scope.TbEndY = TransparencyBoxEndY; | |
1967 | - $scope.TransparencyEndX = TransparencyEndX; | |
1968 | - $scope.TransparencyBoxEndY = TransparencyBoxEndY; | |
1969 | - | |
1970 | - | |
1971 | - | |
1972 | - //draw temp box to store the canvas data with original transparecy | |
1973 | - if (document.getElementById('tempCanvas') != null) { | |
1974 | - $('#tempCanvas').remove(); | |
1975 | - } | |
1976 | - if (document.getElementById('tempCanvas') == null) { | |
1977 | - var tempCanvas = document.createElement('canvas'); | |
1978 | - tempCanvas.id = 'tempCanvas'; | |
1979 | - // $scope.tempCanvas = transparencyCanvas.id; | |
1980 | - tempCanvas.height = TransparencyBoxEndY - $scope.startY; | |
1981 | - tempCanvas.width = TransparencyEndX - $scope.startX; | |
1982 | - tempCanvas.style.position = "absolute"; | |
1983 | - tempCanvas.style.left = 200 + 'px'; | |
1984 | - tempCanvas.style.top = 200 + 'px'; | |
1985 | - tempCanvas.style.backgroundColor = "transparent"; | |
1986 | - tempCanvas.style.visibility = 'hidden'; | |
1987 | - tempCanvas.style.border = "black 1px solid"; | |
1988 | - document.getElementById('canvasDiv').appendChild(tempCanvas); | |
1989 | - } | |
1990 | - | |
1991 | - | |
1992 | - var BodyRegionDictionary = $scope.BodyRegionCordinatesData; | |
1993 | - | |
1994 | - $scope.IncludedBodyRegions = []; | |
1995 | - ////debugger; | |
1996 | - $.each(BodyRegionDictionary, function (index, value) { | |
1997 | - // alert(' $.each(BodyRegionDictionary1') | |
1998 | - var transparencyBoxHeight = parseInt(TransparencyBoxEndY) - parseInt($scope.TransparencyBoxStartY); | |
1999 | - var transparencyBoxWidth = parseInt(TransparencyEndX) - parseInt($scope.TransparencyBoxStartX); | |
2000 | - var transparencyBoxBottom = parseInt($scope.TransparencyBoxStartY) + parseInt(transparencyBoxHeight); | |
2001 | - var transparencyBoxRight = parseInt($scope.TransparencyBoxStartX) + parseInt(transparencyBoxWidth); | |
2002 | - // alert(' $.each(BodyRegionDictionary2. transparencyBoxHeight: ' + transparencyBoxHeight + ',transparencyBoxBottom: ' + transparencyBoxBottom+', transparencyBoxRight: '+transparencyBoxRight) | |
2003 | - var bodyRegionRight = parseInt(value.X) + parseInt(value.Width); | |
2004 | - var bodyRegionBottom = parseInt(value.Y) + parseInt(value.Height); | |
2005 | - | |
2006 | - | |
2007 | - | |
2008 | - var transparencyCanvas = document.createElement('canvas'); | |
2009 | - var tBox = document.getElementById('transparencyCanvas'); | |
2010 | - if (tBox == null) { | |
2011 | - | |
2012 | - transparencyCanvas.id = 'transparencyCanvas'; | |
2013 | - $scope.transparencyCanvasId = transparencyCanvas.id; | |
2014 | - transparencyCanvas.height = TransparencyBoxEndY - $scope.startY; | |
2015 | - transparencyCanvas.width = TransparencyEndX - $scope.startX; | |
2016 | - transparencyCanvas.style.position = "absolute"; | |
2017 | - transparencyCanvas.style.left = $scope.startX + 'px' // x + "px"; | |
2018 | - transparencyCanvas.style.top = $scope.startY + "px"//y + "px"; | |
2019 | - transparencyCanvas.style.border = "black 1px solid"; | |
2020 | - transparencyCanvas.style.backgroundColor = "transparent"; | |
2021 | - // transparencyCanvas.style.visibility = 'hidden'; | |
2022 | - document.getElementById('canvasDiv').appendChild(transparencyCanvas); | |
2023 | - $scope.transparencyChangeCounter = 0; | |
2024 | - | |
2025 | - $('#transparencyCanvas').resizable({ handles: "e,s,se,w,n,ne,nw,sw", stop: function (event, ui) { resizeCanvas(); }, start: function (event, ui) { clearTransCanvas(); } }); | |
2026 | - | |
2027 | - $scope.transparencyCanvasHeight = transparencyCanvas.height; | |
2028 | - $scope.transparencyCanvasWidth = transparencyCanvas.width; | |
2029 | - | |
2030 | - //bind click listener | |
2031 | - transparencyCanvas.addEventListener('click', TransparencyCanvasClickListener); | |
2032 | - | |
2033 | - $(".ui-wrapper").css("z-index", "600"); | |
2034 | - | |
2035 | - // $('#transparencyScale').modal('show'); | |
2036 | - | |
2037 | - //canvasDiv.removeEventListener('mouseup', arguments.callee); | |
2038 | - //canvasDiv.removeEventListener('mousedown', arguments.callee); | |
2039 | - //canvasDiv.removeEventListener('mousemove', arguments.callee); | |
2040 | - } | |
2041 | - if ($scope.TransparencyBoxStartX <= bodyRegionRight && value.X <= transparencyBoxRight && $scope.TransparencyBoxStartY <= bodyRegionBottom && value.Y <= transparencyBoxBottom) { | |
2042 | - | |
2043 | - //if ($scope.voId != "9") { | |
2044 | - // if ($scope.voId != "11") { | |
2045 | - // $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.X, value.Y, value.IsMirror, $scope.TransparencyBoxStartX, TransparencyEndX, $scope.TransparencyBoxStartY, TransparencyBoxEndY, $scope, false, false); | |
2046 | - | |
2047 | - // } | |
2048 | - | |
2049 | - //} | |
2050 | - | |
2051 | - //else { | |
2052 | - // if (value.bodyRegionId == "6") { | |
2053 | - // $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.X, value.Y, value.IsMirror, $scope.TransparencyBoxStartX, TransparencyEndX, $scope.TransparencyBoxStartY, TransparencyBoxEndY, $scope, false, false); | |
2054 | - // } | |
2055 | - //} | |
2056 | - if (($scope.voId == "9" || $scope.voId == "11")) { | |
2057 | - if (value.bodyRegionId == "6") { | |
2058 | - $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.X, value.Y, value.IsMirror, $scope.TransparencyBoxStartX, TransparencyEndX, $scope.TransparencyBoxStartY, TransparencyBoxEndY, $scope, false, false); | |
2059 | - } | |
2060 | - else { | |
2061 | - | |
2062 | - } | |
2063 | - } | |
2064 | - else { | |
2065 | - $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.X, value.Y, value.IsMirror, $scope.TransparencyBoxStartX, TransparencyEndX, $scope.TransparencyBoxStartY, TransparencyBoxEndY, $scope, false, false); | |
2066 | - | |
2067 | - } | |
2068 | - } | |
2069 | - }) | |
2070 | - | |
2071 | - // $('#transparencyScale').modal('show'); | |
2072 | - $('#transparencyScale').css('position', 'fixed') | |
2073 | - $('#transparencyScale').css('top', $scope.TBDrawStartY - 10) | |
2074 | - $('#transparencyScale').css('left', $scope.TBDrawStartX + 130) | |
2075 | - $('#transparencyScale').css('visibility', 'visible') | |
2076 | - $('#transparencyScale').css("z-index", "900") | |
2077 | - | |
2078 | - | |
2079 | - | |
2080 | - document.getElementById('canvasDiv').removeEventListener("mousedown", mouseUpListener); | |
2081 | - document.getElementById('canvasDiv').removeEventListener("mousemove", mouseUpListener); | |
2082 | - | |
2083 | - document.getElementById('canvasDiv').removeEventListener("mouseup", mouseUpListener); | |
2084 | - // document.getElementById('canvasDiv').removeEventListener("mousemove", mouseMoveListener); | |
2085 | - $('#btnTranparency').removeClass('btn-black'); | |
2086 | - | |
2087 | - $('#btnTranparency').addClass('tButtonActive'); | |
2088 | - //debugger; | |
2089 | - $('#txtlayerNumber').val((parseInt($scope.currentLayerNumber)) + 1); | |
2090 | - } | |
2091 | - | |
2092 | - $scope.loadTransparencyImage = function (bodyRegionId, Height, Width, X, Y, IsMirror, TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, scope, isLayerChanged, isTransparencyChanged) { | |
2093 | - // debugger; | |
2094 | - var scope1 = angular.element(document.getElementById("DAView")).scope(); | |
2095 | - var transparencyCanvas = document.getElementById('transparencyCanvas'); | |
2096 | - | |
2097 | - TransparencyBoxStartX = parseInt((transparencyCanvas.style.left).replace('px', '')); | |
2098 | - TransparencyBoxStartY = parseInt((transparencyCanvas.style.top).replace('px', '')); | |
2099 | - TransparencyEndX = parseInt(transparencyCanvas.width) + parseInt(TransparencyBoxStartX); | |
2100 | - TransparencyBoxEndY = parseInt(transparencyCanvas.height) + parseInt(TransparencyBoxStartY); | |
2101 | - | |
2102 | - | |
2103 | - var XforCopyImage = 0; | |
2104 | - var YforCopyImage = 0; | |
2105 | - var WidthforCopyImage = 0; | |
2106 | - var HeightforCopyImage = 0; | |
2107 | - var XforTransImage = 0; | |
2108 | - var WidthforTransImage = 0; | |
2109 | - var HeightforTransImage = 0; | |
2110 | - var YforTransImage = 0; | |
2111 | - var PreviousBodyRegionHeight = 0; | |
2112 | - var PreviousBodyRegionY; | |
2113 | - var PreviousBodyRegionWidth; | |
2114 | - var PreviousBodyRegionX; | |
2115 | - var previousBodyRegionId; | |
2116 | - var transparencyTempCanvas; | |
2117 | - | |
2118 | - | |
2119 | - //X ends outside and start outside of bodyregion | |
2120 | - if (TransparencyBoxStartX < X && TransparencyEndX > parseInt(X) + parseInt(Width)) { | |
2121 | - XforCopyImage = 0; | |
2122 | - WidthforCopyImage = Width; | |
2123 | - WidthforTransImage = Width; | |
2124 | - XforTransImage = parseInt(X) - (parseInt(TransparencyBoxStartX)); | |
2125 | - // alert('1') | |
2126 | - } | |
2127 | - else if (TransparencyBoxStartX < X && TransparencyEndX < parseInt(X) + parseInt(Width)) { | |
2128 | - | |
2129 | - XforCopyImage = 0; | |
2130 | - | |
2131 | - WidthforCopyImage = parseInt(TransparencyEndX) - parseInt(X); | |
2132 | - | |
2133 | - WidthforTransImage = parseInt(TransparencyEndX) - parseInt(X); | |
2134 | - | |
2135 | - // alert(' scope.WidthforCopyImage: ' + scope.WidthforCopyImage) | |
2136 | - XforTransImage = parseInt(X) - (parseInt(TransparencyBoxStartX)); | |
2137 | - | |
2138 | - // alert('2') | |
2139 | - } | |
2140 | - else if (TransparencyBoxStartX > X && TransparencyEndX > parseInt(X) + parseInt(Width)) { | |
2141 | - // alert('TransparencyEndX: ' + TransparencyEndX + ', X: ' + X + ', Width: ' + Width + 'scope.TransparencyBoxStartX: ' + scope.TransparencyBoxStartX) | |
2142 | - | |
2143 | - XforCopyImage = parseInt(TransparencyBoxStartX) - parseInt(X); | |
2144 | - WidthforCopyImage = parseInt(X) + parseInt(Width) - parseInt(TransparencyBoxStartX); | |
2145 | - WidthforTransImage = parseInt(X) + parseInt(Width) - parseInt(TransparencyBoxStartX); | |
2146 | - XforTransImage = 0; | |
2147 | - // alert('3') | |
2148 | - } | |
2149 | - else if (TransparencyBoxStartX > X && TransparencyEndX < parseInt(X) + parseInt(Width)) { | |
2150 | - // alert('startX inside & endX inside') | |
2151 | - XforCopyImage = parseInt(TransparencyBoxStartX) - parseInt(X);//parseInt(X) + parseInt(Width) - parseInt(scope.TransparencyBoxStartX)// scope.TransparencyBoxStartX ; | |
2152 | - WidthforCopyImage = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX); | |
2153 | - WidthforTransImage = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX); | |
2154 | - XforTransImage = 0 | |
2155 | - // alert('4. TransparencyBoxStartX: ' + TransparencyBoxStartX + ',X: ' + parseInt(X) + ',TransparencyEndX: ' + TransparencyEndX + ',XforCopyImage: ' + XforCopyImage) | |
2156 | - } | |
2157 | - | |
2158 | - //calculate Y and height for tempTranparency box from where to cut the image | |
2159 | - | |
2160 | - | |
2161 | - if (TransparencyBoxStartY < Y && TransparencyBoxEndY > parseInt(Y) + parseInt(Height)) { | |
2162 | - | |
2163 | - // alert('start Y outside and end Y outside'); | |
2164 | - | |
2165 | - YforCopyImage = 0; | |
2166 | - HeightforCopyImage = Height; | |
2167 | - | |
2168 | - HeightforTransImage = Height; | |
2169 | - //alert('Y ' + Y) | |
2170 | - YforTransImage = parseFloat(Y) - parseInt(TransparencyBoxStartY)//parseFloat(Y) - (24.4); | |
2171 | - // alert('5') | |
2172 | - } | |
2173 | - else if (TransparencyBoxStartY < Y && TransparencyBoxEndY < (parseInt(Y) + parseInt(Height))) { | |
2174 | - | |
2175 | - YforCopyImage = 0; | |
2176 | - HeightforCopyImage = (parseInt(TransparencyBoxEndY)) - parseInt(Y)//(parseInt(Height) + parseInt(Y)) - (parseInt(TransparencyBoxEndY) - parseInt(scope.TransparencyBoxStartY)); | |
2177 | - | |
2178 | - HeightforTransImage = (parseInt(TransparencyBoxEndY)) - parseInt(Y)// - parseInt(scope.TransparencyBoxStartY)); | |
2179 | - | |
2180 | - YforTransImage = parseFloat(Y) - parseInt(TransparencyBoxStartY);// - (24.4); | |
2181 | - | |
2182 | - } | |
2183 | - else if (TransparencyBoxStartY > Y && TransparencyBoxEndY > parseInt(Y) + parseInt(Height)) { | |
2184 | - | |
2185 | - YforCopyImage = parseInt(TransparencyBoxStartY) - parseInt(Y); | |
2186 | - HeightforCopyImage = parseInt(Y) + parseInt(Height) - parseInt(TransparencyBoxStartY); | |
2187 | - HeightforTransImage = parseInt(Y) + parseInt(Height) - parseInt(TransparencyBoxStartY); | |
2188 | - YforTransImage = 0; | |
2189 | - | |
2190 | - } | |
2191 | - else if (TransparencyBoxStartY > Y && TransparencyBoxEndY < parseInt(Y) + parseInt(Height)) { | |
2192 | - | |
2193 | - YforCopyImage = parseInt(TransparencyBoxStartY) - parseInt(Y); | |
2194 | - HeightforCopyImage = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY); | |
2195 | - HeightforTransImage = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY); | |
2196 | - YforTransImage = 0; | |
2197 | - } | |
2198 | - | |
2199 | - | |
2200 | - //this changes the transparency when user click on transparency scale(we have already set the original | |
2201 | - //data on tras canvas irrespective of the trans number, so we can chnage the transparnecy of original data not the manipulated) | |
2202 | - if (isTransparencyChanged == true) { | |
2203 | - | |
2204 | - // var txtTransparencyChange = document.getElementById("txtTransparencyChange"); | |
2205 | - | |
2206 | - var transNumber = $scope.transNumber; | |
2207 | - | |
2208 | - var ctx = document.getElementById('transparencyCanvas').getContext('2d'); | |
2209 | - | |
2210 | - var imageDa = ctx.getImageData(XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage); | |
2211 | - | |
2212 | - // get the image data values | |
2213 | - var imageData = imageDa.data; | |
2214 | - var length = imageData.length; | |
2215 | - // set every fourth value to 50 | |
2216 | - for (var i = 3; i < length; i += 4) { | |
2217 | - imageData[i] = ((255) * (parseInt(transNumber))) / 100; | |
2218 | - } | |
2219 | - // after the manipulation, reset the data | |
2220 | - // imageDa.data = imageData; | |
2221 | - // and put the imagedata back to the canvas | |
2222 | - ctx.putImageData(imageDa, XforTransImage, YforTransImage); | |
2223 | - | |
2224 | - | |
2225 | - } | |
2226 | - else { | |
2227 | - | |
2228 | - //0. get current layer number | |
2229 | - if ($scope.isResized) { | |
2230 | - //do nothing | |
2231 | - } | |
2232 | - else if (isLayerChanged) { | |
2233 | - // debugger | |
2234 | - $scope.layerNumber = parseInt($('#txtlayerNumber').val()); | |
2235 | - | |
2236 | - } | |
2237 | - else { | |
2238 | - var currentLayer = parseInt($('#txtlayerNumber').val()); | |
2239 | - | |
2240 | - var tranparencyLayer = currentLayer + 1; | |
2241 | - $scope.layerNumber = tranparencyLayer; | |
2242 | - } | |
2243 | - | |
2244 | - //dedebugger; | |
2245 | - //1. get the image source | |
2246 | - var tranparencyImgSrc; | |
2247 | - | |
2248 | - tranparencyImgSrc = $scope.GetImageSource(bodyRegionId); | |
2249 | - var tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc); | |
2250 | - // debugger; | |
2251 | - var oldCanvas; | |
2252 | - | |
2253 | - if (IsMirror == 'Yes') { | |
2254 | - oldCanvas = document.getElementById('transparencyTempCanvas_MR_' + bodyRegionId) | |
2255 | - } | |
2256 | - else { | |
2257 | - oldCanvas = document.getElementById('transparencyTempCanvas_' + bodyRegionId) | |
2258 | - | |
2259 | - } | |
2260 | - | |
2261 | - if (oldCanvas != null) { | |
2262 | - document.getElementById('canvasDiv').removeChild(oldCanvas); | |
2263 | - } | |
2264 | - | |
2265 | - //remove tempmask canvas | |
2266 | - var oldtempTransCanvasMask; | |
2267 | - if (IsMirror == 'Yes') { | |
2268 | - oldtempTransCanvasMask = document.getElementById('transparencyTempCanvasMask_MR_' + bodyRegionId + '_mci'); | |
2269 | - } | |
2270 | - else { | |
2271 | - oldtempTransCanvasMask = document.getElementById('transparencyTempCanvasMask_' + bodyRegionId + '_mci'); | |
2272 | - | |
2273 | - } | |
2274 | - if (oldtempTransCanvasMask != null) { | |
2275 | - document.getElementById('canvasDiv').removeChild(oldtempTransCanvasMask); | |
2276 | - } | |
2277 | - | |
2278 | - transparencyTempCanvas = document.createElement('canvas'); | |
2279 | - var transparencyTempcanavsMask = document.createElement('canvas'); | |
2280 | - //if mirror then draw mask image for non mirrored body region for annotation | |
2281 | - if (IsMirror == 'Yes') { | |
2282 | - transparencyTempCanvas.id = 'transparencyTempCanvas_MR_' + bodyRegionId; | |
2283 | - transparencyTempcanavsMask.id = 'transparencyTempCanvasMask_MR' + bodyRegionId + '_mci'; | |
2284 | - } | |
2285 | - else { | |
2286 | - transparencyTempCanvas.id = 'transparencyTempCanvas_' + bodyRegionId; | |
2287 | - transparencyTempcanavsMask.id = 'transparencyTempCanvasMask_' + bodyRegionId + '_mci'; | |
2288 | - | |
2289 | - } | |
2290 | - transparencyTempCanvas.height = Height; | |
2291 | - transparencyTempCanvas.width = Width; | |
2292 | - transparencyTempCanvas.style.position = "absolute"; | |
2293 | - transparencyTempCanvas.style.left = X + 'px' // x + "px"; | |
2294 | - transparencyTempCanvas.style.top = Y + "px"//y + "px"; | |
2295 | - transparencyTempCanvas.style.visibility = 'hidden'; | |
2296 | - //transparencyTempCanvas.style.visibility = 'visible'; | |
2297 | - // transparencyCanvas.style.zIndex = 4000; | |
2298 | - document.getElementById('canvasDiv').appendChild(transparencyTempCanvas); | |
2299 | - | |
2300 | - //create temp mask canvas | |
2301 | - transparencyTempcanavsMask.height = Height; | |
2302 | - transparencyTempcanavsMask.width = Width; | |
2303 | - transparencyTempcanavsMask.style.position = "absolute"; | |
2304 | - transparencyTempcanavsMask.style.left = X + 'px' // x + "px"; | |
2305 | - transparencyTempcanavsMask.style.top = Y + "px"//y + "px"; | |
2306 | - transparencyTempcanavsMask.style.visibility = 'hidden'; | |
2307 | - //transparencyTempCanvas.style.visibility = 'visible'; | |
2308 | - // transparencyCanvas.style.border = "black 1px solid"; | |
2309 | - document.getElementById('canvasDiv').appendChild(transparencyTempcanavsMask); | |
2310 | - | |
2311 | - | |
2312 | - var tempImg = new Image(); | |
2313 | - tempImg.src = tranparencyImgSrc;//"http://localhost/AIA/" + tranparencyImgSrc; | |
2314 | - | |
2315 | - | |
2316 | - tempImg.onload = function () { | |
2317 | - // debugger; | |
2318 | - var tempCtx = transparencyTempCanvas.getContext('2d'); | |
2319 | - | |
2320 | - if (IsMirror == 'Yes') { | |
2321 | - //debugger; | |
2322 | - tempCtx.save(); | |
2323 | - tempCtx.translate(Width, 0); | |
2324 | - tempCtx.scale(-1, 1); | |
2325 | - tempCtx.drawImage(tempImg, 0, 0); | |
2326 | - } | |
2327 | - else { | |
2328 | - tempCtx.drawImage(tempImg, 0, 0); | |
2329 | - | |
2330 | - } | |
2331 | - // debugger; | |
2332 | - var tempCanvasID; | |
2333 | - | |
2334 | - if (IsMirror == 'Yes') { | |
2335 | - tempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId; | |
2336 | - } | |
2337 | - else { | |
2338 | - tempCanvasID = 'transparencyTempCanvas_' + bodyRegionId; | |
2339 | - } | |
2340 | - | |
2341 | - | |
2342 | - // niki 3june | |
2343 | - //var txtTransparencyChange = document.getElementById("txtTransparencyChange"); | |
2344 | - ////for first time, the transparency should be 50% | |
2345 | - //if ($scope.isTboxDrwan) { | |
2346 | - | |
2347 | - // if (txtTransparencyChange != null) | |
2348 | - // txtTransparencyChange.value = 50; | |
2349 | - | |
2350 | - // $scope.isTboxDrwan = false; | |
2351 | - | |
2352 | - //} | |
2353 | - | |
2354 | - //check if transparency is activated | |
2355 | - | |
2356 | - | |
2357 | - var transNumber = $scope.transNumber;//txtTransparencyChange.value; | |
2358 | - // debugger; | |
2359 | - //this changes the transparency when transparency is already activated(on scale the value is >0) and user resizes or chage the layer | |
2360 | - | |
2361 | - var imageD = tempCtx.getImageData(0, 0, Width, Height); | |
2362 | - | |
2363 | - if (transNumber > 0) { | |
2364 | - // debugger; | |
2365 | - | |
2366 | - | |
2367 | - // tempCanvasID = 'transparencyTempCanvas_' + bodyRegionId; | |
2368 | - var tempCtx = document.getElementById(tempCanvasID).getContext('2d'); | |
2369 | - | |
2370 | - // var image = ctx.getImageData(0, 0, scope.transparencyCanvasWidth, scope.transparencyCanvasHeight); | |
2371 | - | |
2372 | - | |
2373 | - //keep the original image on temp canavs to use it in changing transparency | |
2374 | - // if (scope.isResized == true || scope.isLayerChanged) { | |
2375 | - //debugger; | |
2376 | - | |
2377 | - if (document.getElementById('tempCanvas') != null) { | |
2378 | - var contx = document.getElementById('tempCanvas').getContext('2d'); | |
2379 | - var tbTempCanvas = document.getElementById(tempCanvasID) | |
2380 | - contx.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage); | |
2381 | - | |
2382 | - } | |
2383 | - | |
2384 | - // get the image data values | |
2385 | - | |
2386 | - var imageData = imageD.data; | |
2387 | - var length = imageData.length; | |
2388 | - | |
2389 | - //change background of image from transparent to white | |
2390 | - if ($scope.voId == 9 || $scope.voId == 11) { | |
2391 | - for (var i = 3; i < length; i += 4) { | |
2392 | - imageData[i] = '#FFFFFFFF'; | |
2393 | - } | |
2394 | - | |
2395 | - tempCtx.putImageData(imageD, 0, 0); | |
2396 | - | |
2397 | - var imageDWhite = tempCtx.getImageData(0, 0, Width, Height); | |
2398 | - var imageDataWhite = imageDWhite.data; | |
2399 | - var lengthW = imageDataWhite.length; | |
2400 | - // | |
2401 | - for (var i = 3; i < lengthW; i += 4) { | |
2402 | - imageDataWhite[i] = ((255) * (parseInt(transNumber))) / 100; | |
2403 | - } | |
2404 | - | |
2405 | - // imageD.data = imageData; | |
2406 | - // and put the imagedata back to the canvas | |
2407 | - // debugger | |
2408 | - tempCtx.putImageData(imageDWhite, 0, 0); | |
2409 | - } | |
2410 | - else { | |
2411 | - | |
2412 | - | |
2413 | - // set every fourth value to 50 | |
2414 | - for (var i = 3; i < length; i += 4) { | |
2415 | - imageData[i] = ((255) * (parseInt(transNumber))) / 100; | |
2416 | - } | |
2417 | - | |
2418 | - // imageD.data = imageData; | |
2419 | - // and put the imagedata back to the canvas | |
2420 | - // debugger | |
2421 | - tempCtx.putImageData(imageD, 0, 0); | |
2422 | - } | |
2423 | - | |
2424 | - | |
2425 | - } | |
2426 | - | |
2427 | - var ctx = transparencyCanvas.getContext('2d'); | |
2428 | - | |
2429 | - | |
2430 | - var TrtempCanvasID | |
2431 | - if (IsMirror == 'Yes') { | |
2432 | - TrtempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId; | |
2433 | - } | |
2434 | - else { | |
2435 | - TrtempCanvasID = 'transparencyTempCanvas_' + bodyRegionId; | |
2436 | - } | |
2437 | - | |
2438 | - var tmpCanvasContext = document.getElementById(TrtempCanvasID);//.getContext('2d'); | |
2439 | - | |
2440 | - ctx.drawImage(tmpCanvasContext, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage) | |
2441 | - | |
2442 | - | |
2443 | - XforCopyImage = 0; | |
2444 | - YforCopyImage = 0; | |
2445 | - WidthforCopyImage = 0; | |
2446 | - HeightforCopyImage = 0; | |
2447 | - XforTransImage = 0; | |
2448 | - WidthforTransImage = 0; | |
2449 | - HeightforTransImage = 0; | |
2450 | - YforTransImage = 0; | |
2451 | - PreviousBodyRegionHeight = 0; | |
2452 | - | |
2453 | - } //niki | |
2454 | - // } | |
2455 | - | |
2456 | - | |
2457 | - //mask image code | |
2458 | - //draw mask for annotation | |
2459 | - var tempMaskImg = new Image(); | |
2460 | - var tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc); | |
2461 | - tempMaskImg.src = tranparencyMaskImgSrc;//"http://localhost/AIA/" + tranparencyMaskImgSrc; | |
2462 | - tempMaskImg.onload = function () { | |
2463 | - // debugger; | |
2464 | - var tempmaskCtx = transparencyTempcanavsMask.getContext('2d'); | |
2465 | - | |
2466 | - if (IsMirror == 'Yes') { | |
2467 | - //debugger; | |
2468 | - tempmaskCtx.save(); | |
2469 | - tempmaskCtx.translate(Width, 0); | |
2470 | - tempmaskCtx.scale(-1, 1); | |
2471 | - tempmaskCtx.drawImage(tempMaskImg, 0, 0); | |
2472 | - } | |
2473 | - else { | |
2474 | - tempmaskCtx.drawImage(tempMaskImg, 0, 0); | |
2475 | - | |
2476 | - } | |
2477 | - | |
2478 | - | |
2479 | - } | |
2480 | - | |
2481 | - | |
2482 | - PreviousBodyRegionHeight = HeightforTransImage; | |
2483 | - PreviousBodyRegionY = YforTransImage; | |
2484 | - PreviousBodyRegionWidth = WidthforTransImage; | |
2485 | - PreviousBodyRegionX = XforTransImage; | |
2486 | - previousBodyRegionId = bodyRegionId; | |
2487 | - | |
2488 | - // $scope.layerNumber = parseInt($scope.layerNumber - 1); | |
2489 | - | |
2490 | - } | |
2491 | - | |
2492 | - } | |
2493 | - | |
2494 | - | |
2495 | - | |
2496 | - | |
2497 | - | |
2498 | - | |
2499 | - function resizeCanvas() { | |
2500 | - //debugger; | |
2501 | - // alert('reload') | |
2502 | - clearTransCanvas(); | |
2503 | - if ($('#speechBubbleTrns').length > 0) { | |
2504 | - $('#speechBubbleTrns').remove(); | |
2505 | - } | |
2506 | - var tCanvas = document.getElementById('transparencyCanvas'); | |
2507 | - var tCanvasContext = tCanvas.getContext('2d'); | |
2508 | - | |
2509 | - var tCanvasHeight = parseInt((tCanvas.style.height).replace('px', '')); | |
2510 | - | |
2511 | - var tCanvasWidth = parseInt((tCanvas.style.width).replace('px', '')); | |
2512 | - | |
2513 | - var tBoxStartX = parseInt((tCanvas.style.left).replace('px', '')); | |
2514 | - var tBoxEndX = parseInt((tCanvas.style.left).replace('px', '')) + parseInt((tCanvas.style.width.replace('px', ''))); | |
2515 | - var tBoxStartY = parseInt((tCanvas.style.top).replace('px', '')); | |
2516 | - var tBoxEndY = parseInt((tCanvas.style.top).replace('px', '')) + parseInt((tCanvas.style.height).replace('px', '')); | |
2517 | - var transparencyBoxBottom = parseInt(tBoxStartY) + parseInt(tCanvasHeight); | |
2518 | - var transparencyBoxRight = parseInt(tBoxStartX) + parseInt(tCanvasWidth); | |
2519 | - | |
2520 | - if (tCanvas != null) { | |
2521 | - $('#transparencyCanvas').remove(); | |
2522 | - } | |
2523 | - | |
2524 | - | |
2525 | - $scope.isResized = true; | |
2526 | - | |
2527 | - | |
2528 | - if (tCanvasHeight != $scope.transparencyCanvasHeight || tCanvasWidth != $scope.transparencyCanvasWidth) { | |
2529 | - | |
2530 | - | |
2531 | - var transparencyCanvas = document.createElement('canvas'); | |
2532 | - transparencyCanvas.id = 'transparencyCanvas'; | |
2533 | - $scope.transparencyCanvas = tCanvas.id; | |
2534 | - transparencyCanvas.height = tCanvasHeight; | |
2535 | - transparencyCanvas.width = tCanvasWidth; | |
2536 | - transparencyCanvas.style.position = "absolute"; | |
2537 | - transparencyCanvas.style.left = tCanvas.style.left; // x + "px"; | |
2538 | - transparencyCanvas.style.top = tCanvas.style.top//y + "px"; | |
2539 | - transparencyCanvas.style.border = "black 1px solid"; | |
2540 | - document.getElementById('canvasDiv').appendChild(transparencyCanvas); | |
2541 | - | |
2542 | - $('#transparencyCanvas').resizable({ handles: "e,s,se,w,n,ne,nw,sw", stop: function (event, ui) { resizeCanvas(); }, start: function (event, ui) { clearTransCanvas(); } }); | |
2543 | - | |
2544 | - } | |
2545 | - $scope.transparencyCanvasHeight = tCanvasHeight; | |
2546 | - $scope.transparencyCanvasWidth = tCanvasWidth; | |
2547 | - | |
2548 | - // debugger; | |
2549 | - //create temp cavas to retain the original anavs data for use in transparency change as | |
2550 | - //if u use original canvas data for transprency change then at 0 transparency all data will become transparent and if u increase transparency with this data then the canavs will be blank | |
2551 | - if (document.getElementById('tempCanvas') != null) { | |
2552 | - $('#tempCanvas').remove(); | |
2553 | - } | |
2554 | - var tempCanvas = document.createElement('canvas'); | |
2555 | - tempCanvas.id = 'tempCanvas'; | |
2556 | - $scope.tempCanvas = tempCanvas.id; | |
2557 | - tempCanvas.height = $scope.transparencyCanvasHeight; | |
2558 | - tempCanvas.width = $scope.transparencyCanvasWidth; | |
2559 | - tempCanvas.style.position = "absolute"; | |
2560 | - tempCanvas.style.left = 200 + 'px'; | |
2561 | - tempCanvas.style.backgroundColor = "transparent"; | |
2562 | - tempCanvas.style.visibility = 'hidden'; | |
2563 | - // tempCanvas.style.border = "black 1px solid"; | |
2564 | - | |
2565 | - document.getElementById('canvasDiv').appendChild(tempCanvas); | |
2566 | - | |
2567 | - | |
2568 | - var BodyRegionDictionary = $scope.BodyRegionCordinatesData; | |
2569 | - | |
2570 | - $scope.IncludedBodyRegions = []; | |
2571 | - // $scope.layerNo = parseInt(document.getElementById('')) | |
2572 | - var counter = 0; | |
2573 | - $.each(BodyRegionDictionary, function (index, value) { | |
2574 | - | |
2575 | - var bodyRegionRight = parseInt(value.X) + parseInt(value.Width); | |
2576 | - var bodyRegionBottom = parseInt(value.Y) + parseInt(value.Height); | |
2577 | - var TBRight = parseInt((document.getElementById('transparencyCanvas').style.left).replace('px', '')) + parseInt((document.getElementById('transparencyCanvas').style.width).replace('px', '')); | |
2578 | - var TBBottom = parseInt((document.getElementById('transparencyCanvas').style.top).replace('px', '')) + parseInt((document.getElementById('transparencyCanvas').style.height).replace('px', '')); | |
2579 | - var TBStartX = parseInt((document.getElementById('transparencyCanvas').style.left).replace('px', '')); | |
2580 | - var TBStartY = parseInt((document.getElementById('transparencyCanvas').style.top).replace('px', '')); | |
2581 | - | |
2582 | - | |
2583 | - | |
2584 | - | |
2585 | - if (TBStartX <= bodyRegionRight && value.X <= TBRight && TBStartY <= bodyRegionBottom && value.Y <= TBBottom) { | |
2586 | - | |
2587 | - | |
2588 | - $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.X, value.Y, value.IsMirror, $scope.TransparencyBoxStartX, $scope.TransparencyEndX, $scope.TransparencyBoxStartY, $scope.TransparencyBoxEndY, $scope, false, false); | |
2589 | - | |
2590 | - } | |
2591 | - | |
2592 | - | |
2593 | - }) | |
2594 | - //bind click listener | |
2595 | - //bind click listener | |
2596 | - transparencyCanvas.addEventListener('click', TransparencyCanvasClickListener); | |
2597 | - | |
2598 | - | |
2599 | - | |
2600 | - // }); | |
2601 | - $(".ui-wrapper").css("z-index", "600"); | |
2602 | - $scope.isResized = false; | |
2603 | - } | |
2604 | - | |
2605 | - function TransparencyCanvasClickListener(evt) { | |
2606 | - //alert('tb clicked') | |
2607 | - // debugger; | |
2608 | - var pixelData; | |
2609 | - var pixelDataTrans; | |
2610 | - var mousePos = $scope.getMousePos(evt); | |
2611 | - // alert(mousePos.x + ',' + mousePos.y); | |
2612 | - | |
2613 | - var canvasDiv = document.getElementById('canvasDiv'); | |
2614 | - var verticalScrollPosition = canvasDiv.scrollTop; | |
2615 | - var horizontlScrollPosition = canvasDiv.scrollLeft; | |
2616 | - | |
2617 | - | |
2618 | - //We substracted 135, as the difference between flex and html coordinates for same organ is 135 | |
2619 | - var actulalX = mousePos.x + horizontlScrollPosition; | |
2620 | - var actualY = mousePos.y + verticalScrollPosition //- 135; //+ tomenuBarheight + titleBarheight + searchComboheight; | |
2621 | - var clickedBodyRegion; | |
2622 | - var x; | |
2623 | - var y; | |
2624 | - var isMirror; | |
2625 | - var width; | |
2626 | - var BodyRegionDictionary = $scope.BodyRegionCordinatesData; | |
2627 | - $.each(BodyRegionDictionary, function (index, value) { | |
2628 | - | |
2629 | - var bodyRegionRight = parseInt(value.X) + parseInt(value.Width); | |
2630 | - var bodyRegionBottom = parseInt(value.Y) + parseInt(value.Height); | |
2631 | - if (actulalX <= bodyRegionRight && value.X <= actulalX && actualY <= bodyRegionBottom && value.Y <= actualY) { | |
2632 | - | |
2633 | - clickedBodyRegion = value.bodyRegionId; | |
2634 | - x = value.X; | |
2635 | - y = value.Y; | |
2636 | - width = value.Width; | |
2637 | - isMirror = value.IsMirror; | |
2638 | - return false; | |
2639 | - } | |
2640 | - }) | |
2641 | - | |
2642 | - if (isMirror == "Yes") { | |
2643 | - | |
2644 | - var mirrorCanvasX = x; | |
2645 | - var mirrorCanvasWidth = width; | |
2646 | - | |
2647 | - var clickedCanvasMaskId = 'imageCanvas' + clickedBodyRegion + '_mci'; | |
2648 | - var clickedCanavs = document.getElementById(clickedCanvasMaskId); | |
2649 | - | |
2650 | - //if non mirrored canvas does not exist for this irror Body region then draw non mirrored image to get annotation | |
2651 | - var clickedBodyRegionData = new jinqJs() | |
2652 | - .from(BodyRegionDictionary) | |
2653 | - .where('bodyRegionId == ' + clickedBodyRegion) | |
2654 | - .select(); | |
2655 | - | |
2656 | - var nomMirroredBodyRegion = new jinqJs() | |
2657 | - .from(clickedBodyRegionData) | |
2658 | - .where('IsMirror == No') | |
2659 | - .select(); | |
2660 | - | |
2661 | - | |
2662 | - //debugger; | |
2663 | - var oldMirrorMaskId = 'transparencyTempCanvasMask_' + clickedBodyRegion + '_mci'; | |
2664 | - var oldMirrorMask = document.getElementById(oldMirrorMaskId); | |
2665 | - if (oldMirrorMask != null) { | |
2666 | - document.getElementById('canvasDiv').removeChild(oldMirrorMask); | |
2667 | - } | |
2668 | - var transparencyTempcanavsMask = document.createElement('canvas'); | |
2669 | - transparencyTempcanavsMask.id = 'transparencyTempCanvasMask_' + clickedBodyRegion + '_mci'; | |
2670 | - transparencyTempcanavsMask.height = nomMirroredBodyRegion[0].Height; | |
2671 | - transparencyTempcanavsMask.width = nomMirroredBodyRegion[0].Width; | |
2672 | - transparencyTempcanavsMask.style.position = "absolute"; | |
2673 | - transparencyTempcanavsMask.style.left = nomMirroredBodyRegion[0].X + 'px' // x + "px"; | |
2674 | - transparencyTempcanavsMask.style.top = nomMirroredBodyRegion[0].Y + "px"//y + "px"; | |
2675 | - transparencyTempcanavsMask.style.visibility = 'hidden'; | |
2676 | - | |
2677 | - document.getElementById('canvasDiv').appendChild(transparencyTempcanavsMask); | |
2678 | - | |
2679 | - var tranparencyImgSrc = $scope.GetImageSource(clickedBodyRegion); | |
2680 | - var tempMaskImg = new Image(); | |
2681 | - var tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc); | |
2682 | - tempMaskImg.onload = function () { | |
2683 | - var tempmaskCtx = transparencyTempcanavsMask.getContext('2d'); | |
2684 | - tempmaskCtx.drawImage(tempMaskImg, 0, 0); | |
2685 | - | |
2686 | - //get x,y of non mirrored canvas for this body region | |
2687 | - x = transparencyTempcanavsMask.style.left; | |
2688 | - y = transparencyTempcanavsMask.style.top; | |
2689 | - | |
2690 | - var maskCanvasTransId = 'transparencyTempCanvasMask_' + clickedBodyRegion + '_mci'; | |
2691 | - var maskCanvastrans = document.getElementById(maskCanvasTransId); | |
2692 | - var maskCanvasContexttrans = maskCanvastrans.getContext("2d"); | |
2693 | - | |
2694 | - | |
2695 | - | |
2696 | - | |
2697 | - var canvasDiv = document.getElementById('canvasDiv'); | |
2698 | - var verticalScrollPosition = canvasDiv.scrollTop; | |
2699 | - var horizontlScrollPosition = canvasDiv.scrollLeft; | |
2700 | - | |
2701 | - var distanceXOnMirrorImage = (parseInt(mirrorCanvasX) + parseInt(mirrorCanvasWidth)) - (parseInt(mousePos.x) + horizontlScrollPosition);// - 135); | |
2702 | - | |
2703 | - var mirrorXOnNormalImage = parseInt(maskCanvasContexttrans.canvas.offsetLeft) + parseInt(distanceXOnMirrorImage); | |
2704 | - | |
2705 | - var actulalX = mirrorXOnNormalImage | |
2706 | - var actualY = mousePos.y + verticalScrollPosition | |
2707 | - | |
2708 | - | |
2709 | - | |
2710 | - var clickedCanvasMaskId = 'imageCanvas' + clickedBodyRegion + '_mci'; | |
2711 | - var maskCanvas = document.getElementById(clickedCanvasMaskId); | |
2712 | - var maskCanvasContext = maskCanvas.getContext("2d"); | |
2713 | - var imgX = Math.round(actulalX - parseInt(x.replace('px', ''))); | |
2714 | - var imgY = Math.round(actualY - parseInt(y.replace('px', ''))); | |
2715 | - pixelData = maskCanvasContext.getImageData(imgX, imgY, 1, 1); | |
2716 | - | |
2717 | - | |
2718 | - //trans layer image data | |
2719 | - pixelDataTrans = maskCanvasContexttrans.getImageData(imgX, imgY, 1, 1); | |
2720 | - // console.log('at the time' + pixelData.data[0]) | |
2721 | - // debugger; | |
2722 | - var annotations = $scope.getAnnotationForTransparencyBox(pixelData, pixelDataTrans, $scope); | |
2723 | - if ($('#speechBubble').length > 0) | |
2724 | - $('#speechBubble').remove(); | |
2725 | - | |
2726 | - | |
2727 | - if ($('#speechBubbleTrns').length > 0) { | |
2728 | - $('#speechBubbleTrns').remove(); | |
2729 | - | |
2730 | - createSpeechBubbleOnTransparencyBox(evt, annotations.annotationT1, annotations.annotationT2, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left + 5, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top - 50) | |
2731 | - | |
2732 | - } | |
2733 | - else | |
2734 | - createSpeechBubbleOnTransparencyBox(evt, annotations.annotationT1, annotations.annotationT2, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left + 5, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top - 50) | |
2735 | - | |
2736 | - } | |
2737 | - tempMaskImg.src = "http://localhost/AIAHtml/" + tranparencyMaskImgSrc; | |
2738 | - | |
2739 | - | |
2740 | - | |
2741 | - | |
2742 | - } | |
2743 | - else { | |
2744 | - | |
2745 | - var clickedCanvasMaskId = 'imageCanvas' + clickedBodyRegion + '_mci'; | |
2746 | - var maskCanvas = document.getElementById(clickedCanvasMaskId); | |
2747 | - var maskCanvasContext = maskCanvas.getContext("2d"); | |
2748 | - | |
2749 | - //transparecncy canvas | |
2750 | - var maskCanvasTransId = 'transparencyTempCanvasMask_' + clickedBodyRegion + '_mci'; | |
2751 | - var maskCanvastrans = document.getElementById(maskCanvasTransId); | |
2752 | - var maskCanvasContexttrans = maskCanvastrans.getContext("2d"); | |
2753 | - | |
2754 | - pixelData = maskCanvasContext.getImageData(Math.round(actulalX - x), Math.round(actualY - y), 1, 1); | |
2755 | - | |
2756 | - pixelDataTrans = maskCanvasContexttrans.getImageData(Math.round(actulalX - x), Math.round(actualY - y), 1, 1); | |
2757 | - var annotations = $scope.getAnnotationForTransparencyBox(pixelData, pixelDataTrans, $scope); | |
2758 | - //var annotations = $scope.getAnnotationForTransparencyBox(pixelData, pixelDataTrans, $scope); | |
2759 | - | |
2760 | - if ($('#speechBubble').length > 0) | |
2761 | - $('#speechBubble').remove(); | |
2762 | - | |
2763 | - if ($('#speechBubbleTrns').length > 0) { | |
2764 | - $('#speechBubbleTrns').remove(); | |
2765 | - | |
2766 | - $scope.createSpeechBubbleOnTransparencyBox(evt, annotations.annotationT1, annotations.annotationT2, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left + 5, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top - 50) | |
2767 | - | |
2768 | - } | |
2769 | - else | |
2770 | - $scope.createSpeechBubbleOnTransparencyBox(evt, annotations.annotationT1, annotations.annotationT2, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left + 5, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top - 50) | |
2771 | - | |
2772 | - } | |
2773 | - //debugger; | |
2774 | - } | |
2775 | - function clearTransCanvas() { | |
2776 | - | |
2777 | - var tCanvas = document.getElementById('transparencyCanvas'); | |
2778 | - if (tCanvas != null) { | |
2779 | - var tCanvasContext = tCanvas.getContext('2d'); | |
2780 | - tCanvasContext.clearRect(0, 0, parseInt(tCanvas.style.width), parseInt(tCanvas.style.height)); | |
2781 | - } | |
2782 | - | |
2783 | - } | |
2784 | - | |
2785 | - | |
2786 | - $scope.getAnnotationForTransparencyBox = function (pixelData, pixelDataTrans, scope) { | |
2787 | - | |
2788 | - | |
2789 | - | |
2790 | - pixelData.data[0] = pixelData.data[0] - 9; | |
2791 | - pixelData.data[1] = pixelData.data[1] - 9; | |
2792 | - pixelData.data[2] = pixelData.data[2] - 9; | |
2793 | - | |
2794 | - //trans pixel data | |
2795 | - pixelDataTrans.data[0] = pixelDataTrans.data[0] - 9; | |
2796 | - pixelDataTrans.data[1] = pixelDataTrans.data[1] - 9; | |
2797 | - pixelDataTrans.data[2] = pixelDataTrans.data[2] - 9; | |
2798 | - | |
2799 | - var Red; | |
2800 | - var Green; | |
2801 | - var Blue; | |
2802 | - var zero = "0"; | |
2803 | - | |
2804 | - if ((pixelData.data[0]).toString().length != 2) { | |
2805 | - Red = zero.concat((pixelData.data[0]).toString()) | |
2806 | - } | |
2807 | - else { | |
2808 | - Red = (pixelData.data[0]).toString() | |
2809 | - } | |
2810 | - if ((pixelData.data[1]).toString().length != 2) { | |
2811 | - Green = zero.concat((pixelData.data[1]).toString()) | |
2812 | - } | |
2813 | - else { | |
2814 | - Green = (pixelData.data[1]).toString() | |
2815 | - | |
2816 | - } | |
2817 | - if ((pixelData.data[2]).toString().length != 2) { | |
2818 | - Blue = zero.concat((pixelData.data[2]).toString()) | |
2819 | - } | |
2820 | - else { | |
2821 | - Blue = (pixelData.data[2]).toString() | |
2822 | - | |
2823 | - } | |
2824 | - var RGBColor = (Red + Green + Blue); | |
2825 | - | |
2826 | - | |
2827 | - var annotationText1 = $scope.GetAnnotationText(parseInt(RGBColor)); | |
2828 | - | |
2829 | - //get annotation for trans canavs | |
2830 | - var RedTrans; | |
2831 | - var GreenTrans; | |
2832 | - var BlueTrans; | |
2833 | - var zero = "0"; | |
2834 | - | |
2835 | - if ((pixelDataTrans.data[0]).toString().length != 2) { | |
2836 | - RedTrans = zero.concat((pixelDataTrans.data[0]).toString()) | |
2837 | - } | |
2838 | - else { | |
2839 | - RedTrans = (pixelDataTrans.data[0]).toString() | |
2840 | - } | |
2841 | - if ((pixelDataTrans.data[1]).toString().length != 2) { | |
2842 | - GreenTrans = zero.concat((pixelDataTrans.data[1]).toString()) | |
2843 | - } | |
2844 | - else { | |
2845 | - GreenTrans = (pixelDataTrans.data[1]).toString() | |
2846 | - | |
2847 | - } | |
2848 | - if ((pixelDataTrans.data[2]).toString().length != 2) { | |
2849 | - BlueTrans = zero.concat((pixelDataTrans.data[2]).toString()) | |
2850 | - } | |
2851 | - else { | |
2852 | - BlueTrans = (pixelDataTrans.data[2]).toString() | |
2853 | - | |
2854 | - } | |
2855 | - var RGBColorTrans = (RedTrans + GreenTrans + BlueTrans); | |
2856 | - | |
2857 | - | |
2858 | - var annotationText2 = $scope.GetAnnotationText(parseInt(RGBColorTrans)); | |
2859 | - | |
2860 | - return { | |
2861 | - annotationT1: annotationText1, | |
2862 | - annotationT2: annotationText2 | |
2863 | - } | |
2864 | - } | |
2865 | - | |
2866 | - | |
2867 | - $scope.onTransparencyChange = function (ev, ui) { | |
2868 | - //debugger; | |
2869 | - // alert('t change') | |
2870 | - $scope.transNumber = ui.value; | |
2871 | - | |
2872 | - var tCanvas = document.getElementById('transparencyCanvas'); | |
2873 | - var tCanvasContext = tCanvas.getContext('2d'); | |
2874 | - | |
2875 | - var tCanvasHeight = parseInt((tCanvas.style.height).replace('px', '')); | |
2876 | - | |
2877 | - var tCanvasWidth = parseInt((tCanvas.style.width).replace('px', '')); | |
2878 | - | |
2879 | - var tBoxStartX = parseInt((tCanvas.style.left).replace('px', '')); | |
2880 | - var tBoxEndX = parseInt((tCanvas.style.left).replace('px', '')) + parseInt((tCanvas.style.width.replace('px', ''))); | |
2881 | - var tBoxStartY = parseInt((tCanvas.style.top).replace('px', '')); | |
2882 | - var tBoxEndY = parseInt((tCanvas.style.top).replace('px', '')) + parseInt((tCanvas.style.height).replace('px', '')); | |
2883 | - var transparencyBoxBottom = parseInt(tBoxStartY) + parseInt(tCanvasHeight); | |
2884 | - var transparencyBoxRight = parseInt(tBoxStartX) + parseInt(tCanvasWidth); | |
2885 | - | |
2886 | - //var scope = angular.element(document.getElementById("DAView")).scope(); | |
2887 | - //scope.$apply(function () { | |
2888 | - var arr = []; | |
2889 | - $scope.transparencyChangeCounter++; | |
2890 | - //before changing the transparency of first canvas, hold the orignal canvas data on temp canvas | |
2891 | - | |
2892 | - //put original data on transcanvas so that it can be used to change transparency properly | |
2893 | - var tempCanavs = document.getElementById('tempCanvas'); | |
2894 | - var tempCanvasContext = tempCanavs.getContext('2d'); | |
2895 | - | |
2896 | - var originalTransparencyData = tempCanvasContext.getImageData(0, 0, $scope.transparencyCanvasWidth, $scope.transparencyCanvasHeight); | |
2897 | - var ctx = document.getElementById('transparencyCanvas').getContext('2d'); | |
2898 | - ctx.putImageData(originalTransparencyData, 0, 0); | |
2899 | - | |
2900 | - | |
2901 | - var BodyRegionDictionary = $scope.BodyRegionCordinatesData; | |
2902 | - | |
2903 | - $scope.IncludedBodyRegions = []; | |
2904 | - var counter = 0; | |
2905 | - $.each(BodyRegionDictionary, function (index, value) { | |
2906 | - | |
2907 | - var bodyRegionRight = parseInt(value.X) + parseInt(value.Width); | |
2908 | - var bodyRegionBottom = parseInt(value.Y) + parseInt(value.Height); | |
2909 | - | |
2910 | - | |
2911 | - | |
2912 | - if (tBoxStartX <= bodyRegionRight && value.X <= transparencyBoxRight && tBoxStartY <= bodyRegionBottom && value.Y <= transparencyBoxBottom) { | |
2913 | - | |
2914 | - $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.X, value.Y, value.IsMirror, $scope.TransparencyBoxStartX, $scope.TransparencyEndX, $scope.TransparencyBoxStartY, $scope.TransparencyBoxEndY, $scope, false, true); | |
2915 | - | |
2916 | - } | |
2917 | - | |
2918 | - }); | |
2919 | - | |
2920 | - | |
2921 | - | |
2922 | - // }); | |
2923 | - } | |
2924 | - | |
2925 | - $scope.CloseTransparencyBox = function () { | |
2926 | - var tBox = document.getElementById('transparencyCanvas'); | |
2927 | - // debugger; | |
2928 | - // alert('mouseDown is called'); | |
2929 | - if (tBox != null) { | |
2930 | - tBox.parentNode.removeChild(tBox) | |
2931 | - var elements = document.getElementsByClassName('ui-icon ui-icon-gripsmall-diagonal-se'); | |
2932 | - while (elements.length > 0) { | |
2933 | - elements[0].parentNode.removeChild(elements[0]); | |
2934 | - } | |
2935 | - //var txtTransparencyChange = document.getElementById("txtTransparencyChange"); | |
2936 | - //txtTransparencyChange.value = 0; | |
2937 | - // document.getElementById('txtLayerNumber').value = 0; | |
2938 | - // debugger; | |
2939 | - | |
2940 | - | |
2941 | - $('#layerChangeSlider').slider("option", "value", parseInt($scope.totalLayers) - parseInt($scope.currentLayerNumber)); | |
2942 | - $("#txtlayerNumber").val(parseInt($scope.currentLayerNumber)); | |
2943 | - | |
2944 | - | |
2945 | - if (document.getElementById('tempCanvas') != null) { | |
2946 | - $('#tempCanvas').remove(); | |
2947 | - } | |
2948 | - if ($('#speechBubbleTrns').length > 0) { | |
2949 | - $('#speechBubbleTrns').remove(); | |
2950 | - } | |
2951 | - //var scope = angular.element(document.getElementById("DAView")).scope(); | |
2952 | - //scope.$apply(function () { | |
2953 | - // $scope.layerNumber = 0; | |
2954 | - $scope.isTransparencyActivated = false; | |
2955 | - //}) | |
2956 | - | |
2957 | - | |
2958 | - var tempCanvases = $("canvas[id*='transparencyTempCanvas']"); | |
2959 | - for (var i = 0; i < tempCanvases.length; i++) { | |
2960 | - tempCanvases[i].remove(); | |
2961 | - } | |
2962 | - | |
2963 | - $('.ui-wrapper').remove(); | |
2964 | - | |
2965 | - //$("canvas[name*='transparencyTempCanvas']").nextUntil($("canvas[name*='transparencyTempCanvas']")) | |
2966 | - //.remove(); | |
2967 | - $scope.layerNumber = $scope.currentLayerNumber; | |
2968 | - $scope.transNumber = 50; | |
2969 | - $('.slider').value = 50; | |
2970 | - } | |
2971 | - $('#transparencyScale').css('visibility', 'hidden'); | |
2972 | - | |
2973 | - $scope.isTransparencyActivated = false; | |
2974 | - // document.getElementById('btnTranparency').className = 't-transparency' | |
2975 | - $('#btnTranparency').removeClass('tButtonActive'); | |
2976 | - $('#btnTranparency').addClass('btn-black'); | |
2977 | - $('#btnIdentity').removeClass('btn-black'); | |
2978 | - | |
2979 | - $('#btnIdentity').addClass('btn-primary'); | |
2980 | - | |
2981 | - document.getElementById('btnTranparency').removeEventListener("click", $scope.createTransparencyBox); | |
2982 | - | |
2983 | - } | |
2984 | - | |
2985 | - $scope.createSpeechBubbleOnTransparencyBox = function (event, text1, text2, x, y) { | |
2986 | - | |
2987 | - $('#canvasDiv').css('cursor', 'pointer'); | |
2988 | - $('<div id="speechBubbleTrns" class="BubbleDiv" style="display:visible; top:' + y + 'px; left:' + x + 'px;z-index:700"> <div class="">' | |
2989 | - + '<div class="Bubble">' | |
2990 | - + '<div class="BubbleCloseBtn"></div><div class="BubbleContent">' + text1 + '</div><div class="BubbleContent">' + text2 + '</div><div class="bottomLeftArrow"></div>' | |
2991 | - //+'<div class="bottomRightArrow"></div><div class="topLeftArrow"></div><div class="topRightArrow"></div> | |
2992 | - + '</div></div></div>').appendTo('#canvasDiv'); | |
2993 | - | |
2994 | - $('#speechBubbleTrns').on('click', '.BubbleCloseBtn', function (e) { | |
2995 | - $('#speechBubbleTrns').css('display', 'none'); | |
2996 | - }); | |
2997 | - | |
2998 | - $('#canvasDiv').attr("data-bubbleid", "speechBubble") | |
2999 | - | |
3000 | - | |
3001 | - }; | |
3002 | - | |
3003 | - | |
3004 | - function positionTooltip(event, x, y) { | |
3005 | - // alert('positionTooltip') | |
3006 | - x = 100, | |
3007 | - y = 200, | |
3008 | - | |
3009 | - $('div.speech-bubble').css({ | |
3010 | - 'position': 'absolute', 'top': x, 'left': y, 'background-color': '#f8f8f8', | |
3011 | - 'border': '2px solid #c8c8c8', 'width': '150px', 'height': '50px' | |
3012 | - }); | |
3013 | - | |
3014 | - | |
3015 | - $('.arrow').css({ | |
3016 | - 'border-style': 'solid', | |
3017 | - 'position': 'absolute' | |
3018 | - }); | |
3019 | - | |
3020 | - $('.bottom').css({ | |
3021 | - 'border-color': '#c8c8c8 transparent transparent transparent', | |
3022 | - 'border-width': ' 8px 8px 0px 8px', | |
3023 | - 'bottom': -'8px' | |
3024 | - }) | |
3025 | - }; | |
3026 | - | |
3027 | - | |
3028 | - $scope.OnIdentityClick = function () { | |
3029 | - | |
3030 | - // $('#btnIdentity').addClass('btn-primary'); | |
3031 | - | |
3032 | - if ($scope.isTransparencyActivated == true) { | |
3033 | - | |
3034 | - $scope.isTransparencyActivated = false; | |
3035 | - | |
3036 | - var canvasDiv = document.getElementById('canvasDiv'); | |
3037 | - canvasDiv.removeEventListener("mousedown", mouseDownListener); | |
3038 | - | |
3039 | - canvasDiv.removeEventListener("mousemove", mouseMoveListener); | |
3040 | - | |
3041 | - canvasDiv.removeEventListener("mouseup", mouseUpListener) | |
3042 | - $('#btnTranparency').removeClass('tButtonActive'); | |
3043 | - $('#btnTranparency').addClass('btn-black'); | |
3044 | - } | |
3045 | - | |
3046 | - } | |
3047 | - | |
3048 | - $scope.Zoom = function () { | |
3049 | - $scope.flushCanvas(); | |
3050 | - | |
3051 | - if ($scope.zoomInOut == 25) { | |
3052 | - $scope.zoomInOut = 75; | |
3053 | - | |
3054 | - } | |
3055 | - else { | |
3056 | - $scope.zoomInOut = 25; | |
3057 | - } | |
3058 | - | |
3059 | - $scope.CalculateImageCordinates($scope.viewOrientationId); | |
3060 | - if ($scope.zoomInOut == 25) | |
3061 | - $('#canvasDiv').scrollLeft(0) | |
3062 | - else | |
3063 | - $('#canvasDiv').scrollLeft($('#canvasDiv').width() / 2) | |
3064 | - | |
3065 | - //remove annotation speech bubble | |
3066 | - if ($('#dot').length > 0) { | |
3067 | - $('#dot').remove(); | |
3068 | - } | |
3069 | - | |
3070 | - if ($('#sppeachBubble').length > 0) { | |
3071 | - $('#sppeachBubble').remove(); | |
3072 | - } | |
3073 | - } | |
3074 | - | |
3075 | - $scope.flushCanvas = function () { | |
3076 | - angular.forEach($scope.ColoredImageSRC, function (value, key) { | |
3077 | - | |
3078 | - | |
3079 | - var id; | |
3080 | - var maskId; | |
3081 | - if (value.haveMirror == 'true') { | |
3082 | - id = 'imageCanvas' + value.bodyRegionId + '_MR'; | |
3083 | - maskId = 'imageCanvas' + value.bodyRegionId + '_MR_mci' | |
3084 | - } | |
3085 | - else { | |
3086 | - id = 'imageCanvas' + value.bodyRegionId; | |
3087 | - maskId = 'imageCanvas' + value.bodyRegionId + '_mci'; | |
3088 | - } | |
3089 | - | |
3090 | - var canvas = document.getElementById(id); | |
3091 | - document.getElementById('canvasDiv').removeChild(canvas); | |
3092 | - | |
3093 | - var maskcanvas = document.getElementById(maskId); | |
3094 | - document.getElementById('canvasDiv').removeChild(maskcanvas); | |
3095 | - | |
3096 | - var modestyCanvases = $("canvas[id*='imageCanvasmodestyImg']"); | |
3097 | - for (var i = 0; i < modestyCanvases.length; i++) { | |
3098 | - modestyCanvases[i].remove(); | |
3099 | - } | |
3100 | - }); | |
3101 | - } | |
3102 | - | |
3103 | - $scope.enableHighlight = function () { | |
3104 | - | |
3105 | - if ($rootScope.isHighLight == true) { | |
3106 | - | |
3107 | - } | |
3108 | - else { | |
3109 | - $rootScope.isHighLight = true; | |
3110 | - $scope.highLightBody(); | |
3111 | - } | |
3112 | - | |
3113 | - | |
3114 | - } | |
3115 | - | |
3116 | - | |
3117 | - $scope.highLightBody = function () { | |
3118 | - | |
3119 | - | |
3120 | - if ($rootScope.isHighLight == true) { | |
3121 | - | |
3122 | - angular.forEach($scope.ColoredImageSRC, function (value, key) { | |
3123 | - var id; | |
3124 | - if (value.haveMirror == 'true') { | |
3125 | - id = 'imageCanvas' + value.bodyRegionId + '_MR'; | |
3126 | - } | |
3127 | - else { | |
3128 | - id = 'imageCanvas' + value.bodyRegionId; | |
3129 | - } | |
3130 | - | |
3131 | - var imageCanvas = document.getElementById(id); | |
3132 | - | |
3133 | - //var coloredCanvasID = 'imageCanvas' + bodyRegionId; | |
3134 | - //var coloredCanvas = document.getElementById(coloredCanvasID); | |
3135 | - | |
3136 | - var width = value.Width; | |
3137 | - var ht = value.Height; | |
3138 | - | |
3139 | - var coloredCanvasContext = imageCanvas.getContext("2d"); | |
3140 | - var coloredImageData = coloredCanvasContext.getImageData(0, 0, width, ht); | |
3141 | - var coloredImageDataVar = coloredImageData; | |
3142 | - | |
3143 | - | |
3144 | - if (value.haveMirror == 'true') { | |
3145 | - $rootScope.coloredImageMRCanvasList[parseInt(value.bodyRegionId)] = coloredImageDataVar; | |
3146 | - } | |
3147 | - else { | |
3148 | - //$rootScope.coloredImageMRCanvasList[parseInt(value.bodyRegionId - 1)] = 1; | |
3149 | - | |
3150 | - $rootScope.coloredImageCanvasList[parseInt(value.bodyRegionId - 1)] = coloredImageDataVar; | |
3151 | - | |
3152 | - } | |
3153 | - | |
3154 | - | |
3155 | - var context_gray = imageCanvas.getContext('2d'); | |
3156 | - | |
3157 | - | |
3158 | - var dataURL = imageCanvas.toDataURL(); | |
3159 | - | |
3160 | - | |
3161 | - var img = new Image(); | |
3162 | - | |
3163 | - img.src = dataURL; | |
3164 | - | |
3165 | - | |
3166 | - | |
3167 | - img.onload = function () { | |
3168 | - //console.log(Math.max(img.width) + ', ' + Math.max(img.height)) | |
3169 | - | |
3170 | - var DAData = new BitmapData(Math.max(img.width), Math.max(img.height)); | |
3171 | - DAData.draw(img); | |
3172 | - var RED = 0.3086; // luminance contrast value for red | |
3173 | - var GREEN = 0.694; // luminance contrast value for green | |
3174 | - var BLUE = 0.0820; // luminance contrast value for blue | |
3175 | - | |
3176 | - var RGB = [RED, GREEN, BLUE, 0, 0]; | |
3177 | - var RGB2 = [RED, GREEN, BLUE, 0, 0]; | |
3178 | - var RGB3 = [RED, GREEN, BLUE, 0, 0]; | |
3179 | - var ALPHA = [0, 0, 0, 1, 0]; | |
3180 | - | |
3181 | - var rgbPx = RGB.concat(RGB2); | |
3182 | - var rgbPx2 = rgbPx.concat(RGB3); | |
3183 | - var matrix = rgbPx2.concat(ALPHA); | |
3184 | - | |
3185 | - var zeroPoint = new Point(); | |
3186 | - var grayScale = new ColorMatrixFilter(matrix); | |
3187 | - DAData.applyFilter(DAData, DAData.rect, zeroPoint, grayScale); | |
3188 | - | |
3189 | - context_gray.putImageData(DAData.data, 0, 0) | |
3190 | - | |
3191 | - var grayImageData = context_gray.getImageData(0, 0, width, ht); | |
3192 | - var grayImageImageDataVar = grayImageData.data; | |
3193 | - | |
3194 | - if (value.haveMirror == 'true') { | |
3195 | - $rootScope.grayImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData; | |
3196 | - } | |
3197 | - else { | |
3198 | - //$rootScope.coloredImageMRCanvasList[parseInt(value.bodyRegionId - 1)] = 1; | |
3199 | - | |
3200 | - $rootScope.grayImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData; | |
3201 | - } | |
3202 | - } | |
3203 | - | |
3204 | - $timeout(function () { imageCanvas.style.visibility = 'visible' }, 50); | |
3205 | - }) | |
3206 | - | |
3207 | - | |
3208 | - if ($scope.previousSelectedTermList.length > 0) { | |
3209 | - | |
3210 | - //alert('previousSelectedTermList length: ' + $scope.previousSelectedTermList.length); | |
3211 | - | |
3212 | - for (var i = 0; i < $scope.previousSelectedTermList.length; i++) { | |
3213 | - $scope.highLightBodyBasedOnIcolor($scope.previousSelectedTermList[i]); | |
3214 | - | |
3215 | - } | |
3216 | - } | |
3217 | - | |
3218 | - } | |
3219 | - } | |
3220 | - | |
3221 | - | |
3222 | - | |
3223 | - $scope.applyGrayMatrix = function (img, context_gray) { | |
3224 | - var DAData = new BitmapData(img.width, img.height); | |
3225 | - DAData.draw(img); | |
3226 | - var RED = 0.3086; // luminance contrast value for red | |
3227 | - var GREEN = 0.694; // luminance contrast value for green | |
3228 | - var BLUE = 0.0820; // luminance contrast value for blue | |
3229 | - | |
3230 | - var RGB = [RED, GREEN, BLUE, 0, 0]; | |
3231 | - var RGB2 = [RED, GREEN, BLUE, 0, 0]; | |
3232 | - var RGB3 = [RED, GREEN, BLUE, 0, 0]; | |
3233 | - var ALPHA = [0, 0, 0, 1, 0]; | |
3234 | - | |
3235 | - var rgbPx = RGB.concat(RGB2); | |
3236 | - var rgbPx2 = rgbPx.concat(RGB3); | |
3237 | - var matrix = rgbPx2.concat(ALPHA); | |
3238 | - | |
3239 | - var zeroPoint = new Point(); | |
3240 | - var grayScale = new ColorMatrixFilter(matrix); | |
3241 | - DAData.applyFilter(DAData, DAData.rect, zeroPoint, grayScale); | |
3242 | - | |
3243 | - context_gray.putImageData(DAData.data, 0, 0) | |
3244 | - | |
3245 | - var grayImageData = context_gray.getImageData(0, 0, width, ht); | |
3246 | - var grayImageImageDataVar = grayImageData.data; | |
3247 | - | |
3248 | - } | |
3249 | - | |
3250 | - $scope.getActualTermNumber = function (iColor) { | |
3251 | - $scope.actualTermNo = new jinqJs() | |
3252 | - .from($scope.TermNumberData.TermData.Term) | |
3253 | - .where('_TermNumber == ' + iColor) | |
3254 | - .select('_ActualTermNumber'); | |
3255 | - return $scope.actualTermNo[0]._ActualTermNumber; | |
3256 | - } | |
3257 | - | |
3258 | - $scope.getTermNumberList = function (actualTermNo) { | |
3259 | - $scope.termList = new jinqJs() | |
3260 | - .from($scope.TermNumberData.TermData.Term) | |
3261 | - .where('_ActualTermNumber == ' + actualTermNo) | |
3262 | - .select(); | |
3263 | - return $scope.termList; | |
3264 | - } | |
3265 | - | |
3266 | - | |
3267 | - $scope.OnGenderChange = function (event) { | |
3268 | - | |
3269 | - //use $scope.correspondingBodyViewIds for getting correspnding viewid | |
3270 | - // alert('gender changed= ' + event.currentTarget.attributes[1].value) | |
3271 | - | |
3272 | - // $(".enableGender li").removeClass("active"); | |
3273 | - // $(event.currentTarget.attributes[2].value).parent().addClass("active"); | |
3274 | - | |
3275 | - var viewname = localStorage.getItem("currentViewTitle") | |
3276 | - var currentBodyViewId = $scope.correspondingBodyViewIds[$scope.voId]; | |
3277 | - | |
3278 | - if ((event.currentTarget.attributes[1].value == 'Male') && (localStorage.getItem("genderId") == 'Female')) { | |
3279 | - | |
3280 | - localStorage.setItem("genderId", 'Male'); | |
3281 | - | |
3282 | - | |
3283 | - $scope.loadSelectedBodyView(currentBodyViewId); | |
3284 | - | |
3285 | - $('#daImagePanel')[0].childNodes[0].childNodes[0].innerHTML = localStorage.getItem("currentViewTitle").replace('Female', 'Male'); | |
3286 | - $rootScope.isLoading = true; | |
3287 | - | |
3288 | - } | |
3289 | - | |
3290 | - else if ((event.currentTarget.attributes[1].value == 'Female') && (localStorage.getItem("genderId") == 'Male')) { | |
3291 | - | |
3292 | - localStorage.setItem("genderId", 'Female'); | |
3293 | - | |
3294 | - | |
3295 | - $scope.loadSelectedBodyView(currentBodyViewId) | |
3296 | - $('#daImagePanel')[0].childNodes[0].childNodes[0].innerHTML = localStorage.getItem("currentViewTitle").replace('Male', 'Female'); | |
3297 | - | |
3298 | - $rootScope.isLoading = true; | |
3299 | - | |
3300 | - } | |
3301 | - | |
3302 | - } | |
3303 | - | |
3304 | - | |
3305 | - | |
3306 | - $scope.loadSelectedBodyView = function (currentBodyViewId) { | |
3307 | - | |
3308 | - //remove transaprency scale | |
3309 | - if ($('#transparencyScale') != null) { | |
3310 | - | |
3311 | - $('#transparencyScale').css('visibility', 'hidden'); | |
3312 | - } | |
3313 | - | |
3314 | - | |
3315 | - $scope.voId = currentBodyViewId; | |
3316 | - | |
3317 | - var layerJsonPath = '~/../content/data/json/da/body-views/' + currentBodyViewId + '/da_dat_layer_' + currentBodyViewId + '.json'; | |
3318 | - | |
3319 | - DataService.getJson(layerJsonPath) | |
3320 | - .then( | |
3321 | - function (result) { | |
3322 | - //debugger; | |
3323 | - | |
3324 | - $scope.BodyLayerData = result; | |
3325 | - $scope.isBodylayerdataLoaded = true; | |
3326 | - | |
3327 | - //load json for annotations | |
3328 | - // $http({ method: 'GET', url: '~/../content/data/json/da_dat_tm_sg_1.json' }).success(function (data) { | |
3329 | - var termJsonPath = '~/../content/data/json/da/body-views/' + currentBodyViewId + '/da_dat_tm_sg_' + currentBodyViewId + '.json'; | |
3330 | - DataService.getAnotherJson(termJsonPath) | |
3331 | - .then( | |
3332 | - function (result) { | |
3333 | - $scope.TermNumberData = result; | |
3334 | - | |
3335 | - var canDiv = document.getElementById('canvasDiv'); | |
3336 | - var canDivChildCount = canDiv.childElementCount; | |
3337 | - if (canDivChildCount > 0) { | |
3338 | - canDiv.innerHTML = ''; | |
3339 | - } | |
3340 | - $scope.CalculateImageCordinates($scope.viewOrientationId); | |
3341 | - }, | |
3342 | - function (error) { | |
3343 | - // handle errors here | |
3344 | - console.log(' $scope.TermNumberData= ' + error.statusText); | |
3345 | - } | |
3346 | - ) | |
3347 | - }, | |
3348 | - | |
3349 | - function (error) { | |
3350 | - // handle errors here | |
3351 | - console.log(' $scope.BodyLayerData= ' + error.statusText); | |
3352 | - } | |
3353 | - ); | |
3354 | - } | |
3355 | - | |
3356 | - $scope.OnViewChange = function (event) { | |
3357 | - | |
3358 | - | |
3359 | - $scope.layerNumber = 0; | |
3360 | - // debugger; | |
3361 | - var selectedViewId = $scope.bodyViews[event.currentTarget.attributes[1].value]; | |
3362 | - $scope.viewOrientationId = selectedViewId; | |
3363 | - if (localStorage.getItem("genderId") == 'Male') { | |
3364 | - if ($scope.voId != selectedViewId) { | |
3365 | - if (selectedViewId == 5) { | |
3366 | - $scope.voId = 9; | |
3367 | - } | |
3368 | - else if (selectedViewId == 6) { | |
3369 | - $scope.voId = 10; | |
3370 | - } | |
3371 | - else | |
3372 | - $scope.voId = selectedViewId; | |
3373 | - $rootScope.isLoading = true; | |
3374 | - | |
3375 | - $scope.loadSelectedBodyView($scope.voId); | |
3376 | - }; | |
3377 | - | |
3378 | - | |
3379 | - //set selected view name as the title of jspanel | |
3380 | - // $('#daImagePanel')[0].childNodes[0].childNodes[0].innerHTML = localStorage.getItem("genderId") +" "+ event.currentTarget.attributes[1].value; | |
3381 | - | |
3382 | - } | |
3383 | - else { | |
3384 | - if (selectedViewId == 5) { | |
3385 | - selectedViewId = 11; | |
3386 | - } | |
3387 | - else if (selectedViewId == 6) { | |
3388 | - selectedViewId = 12; | |
3389 | - } | |
3390 | - else | |
3391 | - selectedViewId = $scope.correspondingBodyViewIds[selectedViewId];; | |
3392 | - if ($scope.voId != selectedViewId) { | |
3393 | - $scope.voId = selectedViewId; | |
3394 | - $rootScope.isLoading = true; | |
3395 | - | |
3396 | - $scope.loadSelectedBodyView($scope.voId); | |
3397 | - }; | |
3398 | - | |
3399 | - | |
3400 | - // $('#daImagePanel')[0].childNodes[0].childNodes[0].innerHTML = localStorage.getItem("genderId") + " " + $scope.bodyViews[event.currentTarget.attributes[1].value; | |
3401 | - | |
3402 | - } | |
3403 | - $('#daImagePanel')[0].childNodes[0].childNodes[0].innerHTML = localStorage.getItem("genderId") + " " + event.currentTarget.attributes[1].value; | |
3404 | - localStorage.setItem("currentViewTitle", localStorage.getItem("genderId") + " " + event.currentTarget.attributes[1].value); | |
3405 | - } | |
3406 | - | |
3407 | - | |
3408 | - //Annotation tool event lsitener | |
3409 | - $scope.$on('annotationToolEvent', function (event, data) { | |
3410 | - //console.log('annotation window opend'); | |
3411 | - //draw new canvas on canavs div to draw/paint on that | |
3412 | - //debugger; | |
3413 | - if (document.getElementById('paintCanvas') == null) { | |
3414 | - var paintCanvas = document.createElement('canvas'); | |
3415 | - paintCanvas.id = 'paintCanvas'; | |
3416 | - paintCanvas.height = parseInt(document.getElementById('canvasDiv').style.height);// - 5; | |
3417 | - paintCanvas.style.width = '2277px';//(this is width of canavses of arm+thorax+arm+40) | |
3418 | - paintCanvas.style.position = "absolute"; | |
3419 | - paintCanvas.style.left = 0 + 'px'; | |
3420 | - paintCanvas.style.top = 0 + 'px'; | |
3421 | - // paintCanvas.className = 'col-lg-12'; | |
3422 | - paintCanvas.style.backgroundColor = 'yellow'; | |
3423 | - paintCanvas.style.zIndex = '1100' | |
3424 | - //this is to get annoatation while annotation window is open | |
3425 | - paintCanvas.addEventListener('click', OnPaintCanvasClick); | |
3426 | - | |
3427 | - paintCanvas.addEventListener('mousedown', OnPaintCanvasMouseDown, false) | |
3428 | - paintCanvas.addEventListener('mouseup', OnPaintCanvasMouseUp, false) | |
3429 | - | |
3430 | - document.getElementById('canvasDiv').appendChild(paintCanvas); | |
3431 | - | |
3432 | - $scope.paintCanvasContext = document.getElementById('paintCanvas').getContext('2d'); | |
3433 | - } | |
3434 | - }); | |
3435 | - | |
3436 | - function OnPaintCanvasClick(event) { | |
3437 | - if ($rootScope.isIdetifyClicked == true) { | |
3438 | - // alert('show annotation') | |
3439 | - } | |
3440 | - | |
3441 | - | |
3442 | - } | |
3443 | - | |
3444 | - $scope.mousePressed = false; | |
3445 | - $scope.lastX; $scope.lastY; | |
3446 | - var ctx; | |
3447 | - | |
3448 | - function OnPaintCanvasMouseDown(event) { | |
3449 | - | |
3450 | - if ($rootScope.isDrawingToolSelected == true) { | |
3451 | - | |
3452 | - | |
3453 | - //var mousePos = $scope.getMousePos(event) | |
3454 | - //var canvasDiv = document.getElementById('canvasDiv'); | |
3455 | - //var verticalScrollPosition = canvasDiv.scrollTop; | |
3456 | - //var horizontlScrollPosition = canvasDiv.scrollLeft; | |
3457 | - | |
3458 | - //$rootScope.PaintCanvasMousedownListener($scope.paintCanvasContext,mousePos.x, mousePos.y) | |
3459 | - var mousePos = $scope.getMousePos(event) | |
3460 | - $scope.mousePressed = true; | |
3461 | - $rootScope.Draw(mousePos.x, mousePos.y, false, $scope.paintCanvasContext); | |
3462 | - | |
3463 | - if ($rootScope.isAnnotationWindowClose) { | |
3464 | - document.getElementById('paintCanvas').removeEventListener('mousemove', OnPaintCanvasMouseMove, false); | |
3465 | - | |
3466 | - } | |
3467 | - else | |
3468 | - document.getElementById('paintCanvas').addEventListener('mousemove', OnPaintCanvasMouseMove, false) | |
3469 | - | |
3470 | - } | |
3471 | - //ctx.moveTo(50, 50); | |
3472 | - } | |
3473 | - | |
3474 | - function OnPaintCanvasMouseUp(event) { | |
3475 | - if ($rootScope.isDrawingToolSelected == true) { | |
3476 | - //$rootScope.paint = false; | |
3477 | - $scope.mousePressed = false; | |
3478 | - //// $rootScope.Redraw(); | |
3479 | - document.getElementById('paintCanvas').removeEventListener('mousemove', OnPaintCanvasMouseMove, false); | |
3480 | - | |
3481 | - } | |
3482 | - | |
3483 | - | |
3484 | - } | |
3485 | - | |
3486 | - function OnPaintCanvasMouseMove(event) { | |
3487 | - | |
3488 | - if ($rootScope.isDrawingToolSelected == true) { | |
3489 | - // console.log('moving'); | |
3490 | - //var mousePos = $scope.getMousePos(event); | |
3491 | - //var canvasDiv = document.getElementById('canvasDiv'); | |
3492 | - //var verticalScrollPosition = canvasDiv.scrollTop; | |
3493 | - //var horizontlScrollPosition = canvasDiv.scrollLeft; | |
3494 | - | |
3495 | - //$rootScope.PaintCanvasMousemoveListener($scope.paintCanvasContext, mousePos.x, mousePos.y) | |
3496 | - | |
3497 | - if ($scope.mousePressed) { | |
3498 | - var mousePos = $scope.getMousePos(event) | |
3499 | - | |
3500 | - $rootScope.Draw(mousePos.x, mousePos.y, true, $scope.paintCanvasContext); | |
3501 | - } | |
3502 | - } | |
3503 | - } | |
3504 | - | |
3505 | - | |
3506 | - | |
3507 | - | |
3508 | - // $scope.Draw=function(x, y, isDown) { | |
3509 | - // if (isDown) { | |
3510 | - // $scope.paintCanvasContext.beginPath(); | |
3511 | - // $scope.paintCanvasContext.strokeStyle = '#000000'; | |
3512 | - // $scope.paintCanvasContext.lineWidth = 1//$('#selWidth').val(); | |
3513 | - // $scope.paintCanvasContext.lineJoin = "round"; | |
3514 | - // $scope.paintCanvasContext.moveTo($scope.lastX, $scope.lastY); | |
3515 | - // $scope.paintCanvasContext.lineTo(x, y); | |
3516 | - // $scope.paintCanvasContext.closePath(); | |
3517 | - // $scope.paintCanvasContext.stroke(); | |
3518 | - // } | |
3519 | - // $scope.lastX = x; $scope.lastY = y; | |
3520 | - //} | |
3521 | - | |
3522 | - //body highlight options functinality | |
3523 | - $scope.LoadBodySystemList = function () { | |
3524 | - | |
3525 | - var currentBodyViewId = $scope.voId; | |
3526 | - var systemListHtml = '<ul class="dropdown-menu" aria-labelledby="dropdownMenu2"><li><a href="#" title="Current Structure">Current Structure</a></li> <li role="separator" class="divider"></li>' | |
3527 | - var systemList = $rootScope.CommonData.DACommonData.BodySystems.Item; | |
3528 | - | |
3529 | - angular.forEach(systemList, function (value, key) { | |
3530 | - | |
3531 | - systemListHtml = systemListHtml + '<li><a href="#" id="' + value._BodySystemId + '" title="' + value._Name + '">' + value._Name + '</a></li>' | |
3532 | - }) | |
3533 | - | |
3534 | - systemListHtml = systemListHtml + '</ul>'; | |
3535 | - $('#bodySystem').append(systemListHtml); | |
3536 | - | |
3537 | - var bodySystemDataPath = '~/../content/data/json/da/body-views/' + currentBodyViewId + '/da_dat_body_system_term_' + currentBodyViewId + '.json'; | |
3538 | - DataService.getJson(bodySystemDataPath) | |
3539 | - .then( | |
3540 | - function (result) { | |
3541 | - | |
3542 | - $rootScope.BodySystemData = result; | |
3543 | - | |
3544 | - }, | |
3545 | - function (error) { | |
3546 | - console.log(error.statusText) | |
3547 | - } | |
3548 | - ) | |
3549 | - | |
3550 | - } | |
3551 | - | |
3552 | - $scope.HighlightBodysystem = function (event) { | |
3553 | - var systemMatchedTermList = new jinqJs() | |
3554 | - .from($rootScope.BodySystemData.BodySystem.BodySystemTerm) | |
3555 | - .where('_SystemNumber == ' + event.currentTarget.id) | |
3556 | - .select(); | |
3557 | - | |
3558 | - //color the body gray | |
3559 | - $rootScope.isHighLight = true | |
3560 | - $scope.highLightBody(); | |
3561 | - //now highlight the selected body system in whole body | |
3562 | - | |
3563 | - var termNumber = parseInt(systemMatchedTermList[0]._TermNumber); | |
3564 | - | |
3565 | - //Match Term No List in each bodyRegion | |
3566 | - $scope.getLocationsForMatchedTermsInWholeBody(termNumber); | |
3567 | - //for (var i = 0; i < systemMatchedTermList.length; i++) { | |
3568 | - | |
3569 | - // var termNumber = parseInt(systemMatchedTermList[i]._TermNumber); | |
3570 | - | |
3571 | - // //Match Term No List in each bodyRegion | |
3572 | - // $scope.getLocationsForMatchedTermsInWholeBody(termNumber, 0, 0); | |
3573 | - //} | |
3574 | - } | |
3575 | - | |
3576 | -}] | |
3577 | - | |
3578 | - | |
3579 | - | |
3580 | -); |
400-SOURCECODE/AIAHTML5.Web/extract-wp.js
... | ... | @@ -4,6 +4,8 @@ var abc = 'hello'; |
4 | 4 | previousGrayImageDataList = []; |
5 | 5 | getLocationForMatchedTermsInWholeBody = function (termList, maskCanvasData, coloredImageData, grayImageData, bodyRegionId, canvasId) { |
6 | 6 | console.log('for bodyRegionId: ' + bodyRegionId + ', time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1")) |
7 | + console.log('imagredata= ' + grayImageData) | |
8 | + | |
7 | 9 | var matchedRGBLocationInBodyRegion = []; |
8 | 10 | var matched; |
9 | 11 | ... | ... |