diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js index 78d084d..3c8264b 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js @@ -41,7 +41,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo $rootScope.updatedGrayDataList = []; $rootScope.updatedGrayMRDataList = []; $scope.isEligibleForHighlight = false; - $scope.doHighlight = false; + $scope.doHighlightOrExtract = false; $scope.isEligibleForHighlightBodyByTermList = false; $scope.AnteriorView = "active"; @@ -626,6 +626,9 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo //calculate coordinates for body region images $scope.CalculateImageCordinates = function (viewOrientationId) { + + $scope.terminateCurrentlyRunningWPs(); + var drawnBodyRegionCount = []; if ($rootScope.MaskCanvasData != null || $rootScope.MaskCanvasData != undefined) { @@ -1328,9 +1331,11 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } ); - console.log('$rootScope.isListManagerSelected= ' + $rootScope.isListManagerSelected + ' length= ' + $scope.ColoredImageSRC.length) + // console.log('$rootScope.isListManagerSelected= ' + $rootScope.isListManagerSelected + ' length= ' + $scope.ColoredImageSRC.length) - if (($scope.ColoredImageSRC != null || $scope.ColoredImageSRC != undefined)){ + if (($rootScope.isListManagerSelected == true) || (($rootScope.isGenderChnage == true) && ($rootScope.isHighLight == true)) || (($rootScope.isViewChange == true) && ($rootScope.isHighLight == true))) { + + if (($scope.ColoredImageSRC != null || $scope.ColoredImageSRC != undefined)) { if((($rootScope.viewOrientationId=='1') || ($rootScope.viewOrientationId=='4')) && ($scope.ColoredImageSRC.length == 9)) { @@ -1340,14 +1345,17 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo { $scope.isEligibleForHighlight = true; } - else if((($rootScope.viewOrientationId=='5')) && ($scope.ColoredImageSRC.length == 4)) + else if(($rootScope.viewOrientationId=='5') && ($scope.ColoredImageSRC.length == 4)) { $scope.isEligibleForHighlight = true; } - else if((($rootScope.viewOrientationId=='6')) && ($scope.ColoredImageSRC.length == 1)) + else if(($rootScope.viewOrientationId=='6') && ($scope.ColoredImageSRC.length == 1)) { $scope.isEligibleForHighlight = true; } + else { + $scope.isEligibleForHighlight = false; + } if($scope.isEligibleForHighlight == true) { @@ -1355,8 +1363,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo $rootScope.isLoading = false; $('#spinner').css('visibility', 'hidden'); - if (($rootScope.isListManagerSelected == true) || ( $rootScope.isGenderChnage == true && $rootScope.isHighLight==true) || ($rootScope.isViewChange == true&& $rootScope.isHighLight==true)) - { + $rootScope.isLoading = true; $('#spinner').css('visibility', 'visible'); $timeout(function () { @@ -1369,7 +1376,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } } - console.log('ColoredImageSRC. pushed and length: ' + $scope.ColoredImageSRC.length); + // console.log('ColoredImageSRC. pushed and length: ' + $scope.ColoredImageSRC.length); } if (FlipedImgCanvas.id.match('_mci')) { @@ -1658,30 +1665,32 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo ); console.log('$rootScope.isListManagerSelected= ' + $rootScope.isListManagerSelected + ' length= ' + $scope.ColoredImageSRC.length) + if (($rootScope.isListManagerSelected == true) || (($rootScope.isGenderChnage == true) && ($rootScope.isHighLight == true)) || (($rootScope.isViewChange == true) && ($rootScope.isHighLight == true))) { + if (($scope.ColoredImageSRC != null || $scope.ColoredImageSRC != undefined)) { + if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.ColoredImageSRC.length == 9)) { + $scope.isEligibleForHighlight = true; + } + else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.ColoredImageSRC.length == 5)) { + $scope.isEligibleForHighlight = true; + } + else if (($rootScope.viewOrientationId == '5') && ($scope.ColoredImageSRC.length == 4)) { + $scope.isEligibleForHighlight = true; + } + else if (($rootScope.viewOrientationId == '6') && ($scope.ColoredImageSRC.length == 1)) { + $scope.isEligibleForHighlight = true; + } + else { + $scope.isEligibleForHighlight = false; + } - if (($scope.ColoredImageSRC != null || $scope.ColoredImageSRC != undefined)) { - - if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.ColoredImageSRC.length == 9)) { - $scope.isEligibleForHighlight = true; - } - else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.ColoredImageSRC.length == 5)) { - $scope.isEligibleForHighlight = true; - } - else if ((($rootScope.viewOrientationId == '5')) && ($scope.ColoredImageSRC.length == 4)) { - $scope.isEligibleForHighlight = true; - } - else if ((($rootScope.viewOrientationId == '6')) && ($scope.ColoredImageSRC.length == 1)) { - $scope.isEligibleForHighlight = true; - } + if ($scope.isEligibleForHighlight == true) { - if ($scope.isEligibleForHighlight == true) { + $rootScope.isLoading = false; + $('#spinner').css('visibility', 'hidden'); - $rootScope.isLoading = false; - $('#spinner').css('visibility', 'hidden'); - if (($rootScope.isListManagerSelected == true) || ($rootScope.isGenderChnage == true && $rootScope.isHighLight == true) || ($rootScope.isViewChange == true && $rootScope.isHighLight == true)) { $rootScope.isLoading = true; $('#spinner').css('visibility', 'visible'); $timeout(function () { @@ -4669,388 +4678,402 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo if (($scope.ColoredImageSRC != null || $scope.ColoredImageSRC != undefined)) { if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.ColoredImageSRC.length == 9)) { - $scope.doHighlight = true; + $scope.doHighlightOrExtract = true; } else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.ColoredImageSRC.length == 5)) { - $scope.doHighlight = true; + $scope.doHighlightOrExtract = true; } else if ((($rootScope.viewOrientationId == '5')) && ($scope.ColoredImageSRC.length == 4)) { - $scope.doHighlight = true; + $scope.doHighlightOrExtract = true; } else if ((($rootScope.viewOrientationId == '6')) && ($scope.ColoredImageSRC.length == 1)) { - $scope.doHighlight = true; + $scope.doHighlightOrExtract = true; + } + else { + $scope.doHighlightOrExtract = false; } - if( $scope.doHighlight == true){ - if ($rootScope.isHighLight == true) { + if ($scope.doHighlightOrExtract == true) { + if ($rootScope.isHighLight == true) { - $scope.grayeddBR = []; + $scope.grayeddBR = []; - angular.forEach($scope.ColoredImageSRC, function (value, key) { - console.log('$scope.ColoredImageSRC length begore gray= ' + $scope.ColoredImageSRC.length) - var id; - if (value.haveMirror == 'true') { - id = 'imageCanvas' + value.bodyRegionId + '_MR'; - } - else { - id = 'imageCanvas' + value.bodyRegionId; - } + angular.forEach($scope.ColoredImageSRC, function (value, key) { + console.log('$scope.ColoredImageSRC length begore gray= ' + $scope.ColoredImageSRC.length) + var id; + if (value.haveMirror == 'true') { + id = 'imageCanvas' + value.bodyRegionId + '_MR'; + } + else { + id = 'imageCanvas' + value.bodyRegionId; + } - //alert(value.bodyRegionId) + //alert(value.bodyRegionId) - var imageCanvas = document.getElementById(id); + var imageCanvas = document.getElementById(id); - //var coloredCanvasID = 'imageCanvas' + bodyRegionId; - //var coloredCanvas = document.getElementById(coloredCanvasID); + //var coloredCanvasID = 'imageCanvas' + bodyRegionId; + //var coloredCanvas = document.getElementById(coloredCanvasID); - var width = value.Width; - var ht = value.Height; + var width = value.Width; + var ht = value.Height; - var coloredCanvasContext = imageCanvas.getContext("2d"); - var coloredImageData = coloredCanvasContext.getImageData(0, 0, width, ht); - var coloredImageDataVar = coloredImageData; + var coloredCanvasContext = imageCanvas.getContext("2d"); + var coloredImageData = coloredCanvasContext.getImageData(0, 0, width, ht); + var coloredImageDataVar = coloredImageData; - if (value.haveMirror == 'true') { - $rootScope.coloredImageMRCanvasList[parseInt(value.bodyRegionId)] = coloredImageDataVar; - } - else { + if (value.haveMirror == 'true') { + $rootScope.coloredImageMRCanvasList[parseInt(value.bodyRegionId)] = coloredImageDataVar; + } + else { - $rootScope.coloredImageCanvasList[parseInt(value.bodyRegionId - 1)] = coloredImageDataVar; + $rootScope.coloredImageCanvasList[parseInt(value.bodyRegionId - 1)] = coloredImageDataVar; - } + } - var context_gray = imageCanvas.getContext('2d'); + var context_gray = imageCanvas.getContext('2d'); - //NIKI- for lateral arm highlight issue + //NIKI- for lateral arm highlight issue - if ($rootScope.viewOrientationId && value.bodyRegionId == 6) { - var imgData = context_gray.getImageData(0, 0, width, ht); - var data = imgData.data; - for (var i = 0; i < data.length; i += 4) { - // if (data[i + 3] < 255) { - // data[i] = 255 - data[i]; - // data[i + 1] = 255 - data[i + 1]; - // data[i + 2] = 255 - data[i + 2]; + if ($rootScope.viewOrientationId && value.bodyRegionId == 6) { + var imgData = context_gray.getImageData(0, 0, width, ht); + var data = imgData.data; + for (var i = 0; i < data.length; i += 4) { + // if (data[i + 3] < 255) { + // data[i] = 255 - data[i]; + // data[i + 1] = 255 - data[i + 1]; + // data[i + 2] = 255 - data[i + 2]; data[i + 3] = 255//255 - data[i + 3]; - // } + // } + } + context_gray.putImageData(imgData, 0, 0); } - context_gray.putImageData(imgData, 0, 0); - } - //NIKI + //NIKI - var dataURL = imageCanvas.toDataURL(); + var dataURL = imageCanvas.toDataURL(); - var img = new Image(); + var img = new Image(); - img.src = dataURL; + img.src = dataURL; - img.onload = function () { - console.log('Before BitmapData call, width: ' + Math.max(img.width) + ', height: ' + Math.max(img.height) + ' value.bodyRegionId= ' - + value.bodyRegionId) + img.onload = function () { + console.log('Before BitmapData call, width: ' + Math.max(img.width) + ', height: ' + Math.max(img.height) + ' value.bodyRegionId= ' + + value.bodyRegionId) - var DAData = new BitmapData(Math.max(img.width), Math.max(img.height)); - DAData.draw(img); + var DAData = new BitmapData(Math.max(img.width), Math.max(img.height)); + DAData.draw(img); - var colorMode; + var colorMode; - if ($scope.isExtract == true) { - colorMode = $scope.applyWhiteMatrix(img, context_gray); - } - else { - colorMode = $scope.applyGrayMatrix(img, context_gray); - } + if ($scope.isExtract == true) { + colorMode = $scope.applyWhiteMatrix(img, context_gray); + } + else { + colorMode = $scope.applyGrayMatrix(img, context_gray); + } - var zeroPoint = new Point(); + var zeroPoint = new Point(); - DAData.applyFilter(DAData, DAData.rect, zeroPoint, colorMode); + DAData.applyFilter(DAData, DAData.rect, zeroPoint, colorMode); - context_gray.putImageData(DAData.data, 0, 0) + context_gray.putImageData(DAData.data, 0, 0) - var grayImageData = context_gray.getImageData(0, 0, width, ht); - var grayImageImageDataVar = grayImageData.data; + //push BRID into array + $scope.grayeddBR.push({ 'BRID': value.bodyRegionId }); - if ($scope.isExtract == true) { - if (value.haveMirror == 'true') { - $rootScope.whiteImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData; - } - else { + var grayImageData = context_gray.getImageData(0, 0, width, ht); + var grayImageImageDataVar = grayImageData.data; - $rootScope.whiteImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData; - } - } - else { + if ($scope.isExtract == true) { + if (value.haveMirror == 'true') { + $rootScope.whiteImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData; + } + else { - if (value.haveMirror == 'true') { - $rootScope.grayImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData; + $rootScope.whiteImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData; + } } else { - $rootScope.grayImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData; + if (value.haveMirror == 'true') { + $rootScope.grayImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData; + } + else { + + $rootScope.grayImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData; + } } - } - //push BRID into array - $scope.grayeddBR.push({ 'BRID': value.bodyRegionId }); - if ($scope.grayeddBR != null || $scope.grayeddBR != undefined) { - if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.grayeddBR.length == 9)) { - $scope.isEligibleForHighlightBodyByTermList = true; - } - else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.grayeddBR.length == 5)) { - $scope.isEligibleForHighlightBodyByTermList = true; - } - else if ((($rootScope.viewOrientationId == '5')) && ($scope.grayeddBR.length == 4)) { - $scope.isEligibleForHighlightBodyByTermList = true; - } - else if ((($rootScope.viewOrientationId == '6')) && ($scope.grayeddBR.length == 1)) { - $scope.isEligibleForHighlightBodyByTermList = true; - } - if ($scope.isEligibleForHighlightBodyByTermList == true) { - //DISABLE PROGERSS BAR FOR GENDER OR VIEW CHANGE - if ($rootScope.isGenderChnage == true || $rootScope.isViewChange == true) { - $scope.isLoading = false; + if ($scope.grayeddBR != null || $scope.grayeddBR != undefined) { + if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.grayeddBR.length == 9)) { + $scope.isEligibleForHighlightBodyByTermList = true; + $scope.doHighlightOrExtract = false; + } + else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.grayeddBR.length == 5)) { + $scope.isEligibleForHighlightBodyByTermList = true; + $scope.doHighlightOrExtract = false; + } + else if ((($rootScope.viewOrientationId == '5')) && ($scope.grayeddBR.length == 4)) { + $scope.isEligibleForHighlightBodyByTermList = true; + $scope.doHighlightOrExtract = false; + } + else if ((($rootScope.viewOrientationId == '6')) && ($scope.grayeddBR.length == 1)) { + $scope.isEligibleForHighlightBodyByTermList = true; + $scope.doHighlightOrExtract = false; + } + else { - $('#spinner').css('visibility', 'hidden'); + $scope.isEligibleForHighlightBodyByTermList = false; } - if (($scope.isHighlightBodysystem == true) && ($scope.systemMatchedTermList != null || $scope.systemMatchedTermList != undefined)) { + if ($scope.isEligibleForHighlightBodyByTermList == true) { + //DISABLE PROGERSS BAR FOR GENDER OR VIEW CHANGE + if ($rootScope.isGenderChnage == true || $rootScope.isViewChange == true) { + $scope.isLoading = false; - $timeout(function () { $scope.HighlightBodyByTermList($scope.systemMatchedTermList) }, 100); - } - else if ($scope.isHighlightByListManager == true) { + $('#spinner').css('visibility', 'hidden'); + } - // console.log('$scope.grayeddBR.length is ' + $scope.grayeddBR.length); - $timeout(function () { + if (($scope.isHighlightBodysystem == true) && ($scope.systemMatchedTermList != null || $scope.systemMatchedTermList != undefined)) { - // $rootScope.isHighLight = false; - //align - // $scope.aligneCanvasWithTerm(); + $timeout(function () { $scope.HighlightBodyByTermList($scope.systemMatchedTermList) }, 100); + } + else if ($scope.isHighlightByListManager == true) { - $scope.HighlightBodyByTermList($scope.AllTerms) - }, 800); + // console.log('$scope.grayeddBR.length is ' + $scope.grayeddBR.length); + $timeout(function () { - } + // $rootScope.isHighLight = false; + //align + // $scope.aligneCanvasWithTerm(); - if (($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined) && $rootScope.previousHighlightList.length > 0) { + $scope.HighlightBodyByTermList($scope.AllTerms) + }, 800); + } - console.log('inside highlight body'); + if (($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined) && $rootScope.previousHighlightList.length > 0) { - var multiTermList = []; - angular.forEach($rootScope.previousHighlightList, function (value, key) { - //debugger; + //console.log('inside highlight body'); - var ActualTermNo = $scope.getActualTermNumber(value); - if (ActualTermNo != null) { - var TermList = $scope.getTermNumberList(ActualTermNo); - if (TermList != null) { - for (var i = 0; i < TermList.length; i++) { + var multiTermList = []; + angular.forEach($rootScope.previousHighlightList, function (value, key) { - multiTermList.push(TermList[i]); + //debugger; + + var ActualTermNo = $scope.getActualTermNumber(value); + if (ActualTermNo != null) { + var TermList = $scope.getTermNumberList(ActualTermNo); + if (TermList != null) { + for (var i = 0; i < TermList.length; i++) { + + multiTermList.push(TermList[i]); + } } } - } - }); + }); - $timeout(function () { $scope.HighlightBodyByTermList(multiTermList) }, 80); - } + $timeout(function () { $scope.HighlightBodyByTermList(multiTermList) }, 80); + } + } + } } - - } - $timeout(function () { imageCanvas.style.visibility = 'visible' }, 50); + $timeout(function () { imageCanvas.style.visibility = 'visible' }, 50); - // console.log('the value of isHighlightByListManager ' + $scope.isHighlightByListManager); + // console.log('the value of isHighlightByListManager ' + $scope.isHighlightByListManager); - // console.log('$scope.grayeddBR.length: ' + $scope.grayeddBR.length) + // console.log('$scope.grayeddBR.length: ' + $scope.grayeddBR.length) - if ($rootScope.isExtract == true) { - if (($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined) && $rootScope.previousHighlightList.length > 0) { + if ($rootScope.isExtract == true) { + if (($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined) && $rootScope.previousHighlightList.length > 0) { - $timeout(function () { $scope.HighlightBodyOnExtract() }, 50); - } - } - else { - // this code is for the case where user first clcik on normal mode then extract then again highlight then we need to call highlight body in gray mode - //and then highlight the previously selected body regions at the time of normal mode. - if ($scope.grayeddBR != null || $scope.grayeddBR != undefined) { - if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.grayeddBR.length == 9)) { - $scope.isEligibleForHighlightBodyByTermList = true; - } - else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.grayeddBR.length == 5)) { - $scope.isEligibleForHighlightBodyByTermList = true; - } - else if ((($rootScope.viewOrientationId == '5')) && ($scope.grayeddBR.length == 4)) { - $scope.isEligibleForHighlightBodyByTermList = true; - } - else if ((($rootScope.viewOrientationId == '6')) && ($scope.grayeddBR.length == 1)) { - $scope.isEligibleForHighlightBodyByTermList = true; + $timeout(function () { $scope.HighlightBodyOnExtract() }, 50); } + } + else { + // this code is for the case where user first clcik on normal mode then extract then again highlight then we need to call highlight body in gray mode + //and then highlight the previously selected body regions at the time of normal mode. + if ($scope.grayeddBR != null || $scope.grayeddBR != undefined) { + if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.grayeddBR.length == 9)) { + $scope.isEligibleForHighlightBodyByTermList = true; + } + else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.grayeddBR.length == 5)) { + $scope.isEligibleForHighlightBodyByTermList = true; + } + else if ((($rootScope.viewOrientationId == '5')) && ($scope.grayeddBR.length == 4)) { + $scope.isEligibleForHighlightBodyByTermList = true; + } + else if ((($rootScope.viewOrientationId == '6')) && ($scope.grayeddBR.length == 1)) { + $scope.isEligibleForHighlightBodyByTermList = true; + } - if ($scope.isEligibleForHighlightBodyByTermList == true) { + if ($scope.isEligibleForHighlightBodyByTermList == true) { - if (($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined) && $rootScope.previousHighlightList.length > 0) { + if (($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined) && $rootScope.previousHighlightList.length > 0) { - var multiTermList = []; - angular.forEach($rootScope.previousHighlightList, function (value, key) { + var multiTermList = []; + angular.forEach($rootScope.previousHighlightList, function (value, key) { - //debugger; + //debugger; - var ActualTermNo = $scope.getActualTermNumber(value); - if (ActualTermNo != null) { - var TermList = $scope.getTermNumberList(ActualTermNo); - if (TermList != null) { - for (var i = 0; i < TermList.length; i++) { + var ActualTermNo = $scope.getActualTermNumber(value); + if (ActualTermNo != null) { + var TermList = $scope.getTermNumberList(ActualTermNo); + if (TermList != null) { + for (var i = 0; i < TermList.length; i++) { - multiTermList.push(TermList[i]); + multiTermList.push(TermList[i]); + } } } - } - }); + }); - $timeout(function () { $scope.HighlightBodyByTermList(multiTermList) }, 80); - } + $timeout(function () { $scope.HighlightBodyByTermList(multiTermList) }, 80); + } + } } - } - // - } - }) + // + } + }) - } - } + } - else { - // This code will execute when user will select normal Mode but this time isHighlight will be false - angular.forEach($scope.ColoredImageSRC, function (value, key) { - var id; - if (value.haveMirror == 'true') { - id = 'imageCanvas' + value.bodyRegionId + '_MR'; - } else { - id = 'imageCanvas' + value.bodyRegionId; - } + // This code will execute when user will select normal Mode but this time isHighlight will be false - var imageCanvas = document.getElementById(id); + angular.forEach($scope.ColoredImageSRC, function (value, key) { + var id; + if (value.haveMirror == 'true') { + id = 'imageCanvas' + value.bodyRegionId + '_MR'; + } + else { + id = 'imageCanvas' + value.bodyRegionId; + } - //var coloredCanvasID = 'imageCanvas' + bodyRegionId; - //var coloredCanvas = document.getElementById(coloredCanvasID); + var imageCanvas = document.getElementById(id); - var width = value.Width; - var ht = value.Height; + //var coloredCanvasID = 'imageCanvas' + bodyRegionId; + //var coloredCanvas = document.getElementById(coloredCanvasID); - var coloredCanvasContext = imageCanvas.getContext("2d"); - var coloredImageData = coloredCanvasContext.getImageData(0, 0, width, ht); - var coloredImageDataVar = coloredImageData; + var width = value.Width; + var ht = value.Height; + var coloredCanvasContext = imageCanvas.getContext("2d"); + var coloredImageData = coloredCanvasContext.getImageData(0, 0, width, ht); + var coloredImageDataVar = coloredImageData; - if (value.haveMirror == 'true') { - $rootScope.coloredImageMRCanvasList[parseInt(value.bodyRegionId)] = coloredImageDataVar; - } - else { - $rootScope.coloredImageCanvasList[parseInt(value.bodyRegionId - 1)] = coloredImageDataVar; + if (value.haveMirror == 'true') { + $rootScope.coloredImageMRCanvasList[parseInt(value.bodyRegionId)] = coloredImageDataVar; + } + else { - } + $rootScope.coloredImageCanvasList[parseInt(value.bodyRegionId - 1)] = coloredImageDataVar; + } - var context = imageCanvas.getContext('2d'); + var context = imageCanvas.getContext('2d'); - var dataURL = imageCanvas.toDataURL(); + var dataURL = imageCanvas.toDataURL(); - var img = new Image(); - img.src = dataURL; + var img = new Image(); + img.src = dataURL; - img.onload = function () { - //console.log(Math.max(img.width) + ', ' + Math.max(img.height)) - var DAData = new BitmapData(Math.max(img.width), Math.max(img.height)); - DAData.draw(img); + img.onload = function () { + //console.log(Math.max(img.width) + ', ' + Math.max(img.height)) - var colorMode; + var DAData = new BitmapData(Math.max(img.width), Math.max(img.height)); + DAData.draw(img); - if ($scope.isExtract == true) { - colorMode = $scope.applyWhiteMatrix(img, context); - } + var colorMode; - var zeroPoint = new Point(); + if ($scope.isExtract == true) { + colorMode = $scope.applyWhiteMatrix(img, context); + } - DAData.applyFilter(DAData, DAData.rect, zeroPoint, colorMode); + var zeroPoint = new Point(); - context.putImageData(DAData.data, 0, 0) + DAData.applyFilter(DAData, DAData.rect, zeroPoint, colorMode); - var grayImageData = context.getImageData(0, 0, width, ht); - var grayImageImageDataVar = grayImageData.data; + context.putImageData(DAData.data, 0, 0) - if ($scope.isExtract == true) { - if (value.haveMirror == 'true') { - $rootScope.whiteImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData; - } - else { + var grayImageData = context.getImageData(0, 0, width, ht); + var grayImageImageDataVar = grayImageData.data; - $rootScope.whiteImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData; - } - } - else { + if ($scope.isExtract == true) { + if (value.haveMirror == 'true') { + $rootScope.whiteImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData; + } + else { - if (value.haveMirror == 'true') { - $rootScope.grayImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData; - } - else { + $rootScope.whiteImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData; + } + } + else { - $rootScope.grayImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData; + if (value.haveMirror == 'true') { + $rootScope.grayImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData; + } + else { + + $rootScope.grayImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData; + } + } } - } - } - $timeout(function () { imageCanvas.style.visibility = 'visible' }, 50); - }) + $timeout(function () { imageCanvas.style.visibility = 'visible' }, 50); + }) - if ($rootScope.isExtract == true) { - if ($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined || $rootScope.previousHighlightList.length > 0) { - - $timeout(function () { $scope.HighlightBodyOnExtract() }, 50); + if ($rootScope.isExtract == true) { + if ($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined || $rootScope.previousHighlightList.length > 0) { + + $timeout(function () { $scope.HighlightBodyOnExtract() }, 50); + + // to do + + } + } - // to do - } } - - } - } + } }