diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js index a15f151..ddd1fe9 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js @@ -46,6 +46,9 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo $rootScope.coloredImageMRCanvasList = []; $rootScope.ColoredCanvasData = []; $rootScope.grayImageDataList = []; + + $rootScope.rawGrayImageDataList = []; + $rootScope.grayImageMRDataList = []; $rootScope.updatedGrayDataList = []; $rootScope.updatedGrayMRDataList = []; @@ -2646,71 +2649,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo if ($scope.layerNumber == 224) { - //debugger; - - //var matchedTermListPath = '~/../content/data/json/da/body-views/1/bodyLayers-CardioVascular.json'; - - //DataService.getJson(matchedTermListPath) - //.then( - // function (result) - // { - // $rootScope.macthedTermList = result; - // var termNo=0; - // var pixcelLocation = 0; - - // if ($rootScope.macthedTermList.length > 0) { - // angular.forEach($rootScope.macthedTermList, function (value, key) { - - // debugger; - - // var TermExistInBodyRegionId = value.bodyRegionId; - // var grayImageDataVar = $rootScope.grayImageDataList[TermExistInBodyRegionId - 1]; - // var coloredImageDataVar = $rootScope.coloredImageCanvasList[TermExistInBodyRegionId - 1]; - - // var grayImageDataValue = grayImageDataVar.data; - // var coloredImageDataValue = coloredImageDataVar.data; - - // $rootScope.termListWithLocation = value.terms; - - // angular.forEach($rootScope.termListWithLocation[0].PixelLocations, function (value1, key1) - // { - // //debugger; - - // var coloredImageData = coloredImageDataValue[value1]; - // grayImageDataValue[value1] = coloredImageData; - - - // }) - - // var grayCanvasID = 'imageCanvas' + TermExistInBodyRegionId; - // var grayCanvas = document.getElementById(grayCanvasID); - // if (grayCanvas != null) - // { - // debugger; - // var grayCanvasContext = grayCanvas.getContext("2d"); - - // var canvasHeight = grayCanvas.height + 'px'; - // var canvasWidth = grayCanvas.width + 'px'; - // grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth) - - // grayCanvasContext.putImageData(grayImageDataVar, 0, 0); - - - // } - // $('#spinner').css('visibility', 'hidden') - // $rootScope.isLoading = false; - - // }) - // } - - - - // }, - // function (error) { - // console.log(' Error in getting term data = ' + error.statusText); - - // }); - } else { @@ -2846,71 +2784,144 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } }, 100) + + } + + + + $scope.HighlightBodyByTermListForBodySystem = function (TermList) { + + $("#btnTranparency").attr('disabled', 'disabled'); + $scope.currentLayerNumber = $scope.layerNumber; + + $scope.layerNumber = $('#txtlayerNumber').val(); + + $rootScope.isLoading = true; + $('#spinner').css('visibility', 'visible'); + + + if ($rootScope.isHighLight == true) { + false; + } + + console.log('HighlightBodyByTermList is called'); + + $scope.highlightedBR = []; + if ($scope.layerNumber == 224) { - // debugger; var matchedTermListPath = '~/../content/data/json/da/body-views/1/BodySystem_' + $rootScope.systemNumber + '.json'; - + var grayImageDataVar = null; + DataService.getJson(matchedTermListPath) .then( function (result) { $rootScope.macthedTermList = result; var termNo = 0; var pixcelLocation = 0; - + var prevBRID = 0; if ($rootScope.macthedTermList.length > 0) { - + for(var i=0; i<$rootScope.grayImageDataList.length;i++){ + var grayCanvasID = 'imageCanvas' + parseInt(i+1); + var grayCanvas = document.getElementById(grayCanvasID); + + if (grayCanvas != null) { + var grayCanvasContext = grayCanvas.getContext("2d"); + + var canvasHeight = grayCanvas.height; + var canvasWidth = grayCanvas.width; + grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth) + grayCanvasContext.putImageData($rootScope.grayImageDataList[parseInt(i)], 0, 0); + } + } + for (var i = 4; i <= $rootScope.grayImageMRDataList.length; i++) { + var grayCanvasMRID = 'imageCanvas' + i+'_MR'; + var grayCanvasMR = document.getElementById(grayCanvasMRID); + + if (grayCanvasMR != null) { + var grayCanvasContextMR = grayCanvasMR.getContext("2d"); + + var canvasHeight = grayCanvasMR.height; + var canvasWidth = grayCanvasMR.width; + grayCanvasContextMR.clearRect(0, 0, canvasHeight, canvasWidth) + grayCanvasContextMR.putImageData($rootScope.grayImageMRDataList[parseInt(i)], 0, 0); + } + } angular.forEach($rootScope.macthedTermList, function (value, key) { - // debugger; - var TermExistInBodyRegionId = value.bodyRegionId; - - var grayImageDataVar = $rootScope.grayImageDataList[parseInt(TermExistInBodyRegionId) - 1]; - - var coloredImageDataVar = $rootScope.coloredImageCanvasList[parseInt(TermExistInBodyRegionId) - 1]; - var grayImageDataValue = grayImageDataVar.data; - var coloredImageDataValue = coloredImageDataVar.data; + var TermExistInBodyRegionId = value.bodyRegionId; - $rootScope.termListWithLocation = value.terms; + if (prevBRID != TermExistInBodyRegionId) { + var grayCanvasID = 'imageCanvas' + TermExistInBodyRegionId; + var grayCanvas = document.getElementById(grayCanvasID); + + if (grayCanvas != null) { + var grayCanvasContext = grayCanvas.getContext("2d"); - angular.forEach($rootScope.termListWithLocation.PixelLocations, function (value1, key1) { - //debugger; + var canvasHeight = grayCanvas.height; + var canvasWidth = grayCanvas.width; + grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth) + grayCanvasContext.putImageData($rootScope.grayImageDataList[parseInt(TermExistInBodyRegionId) - 1], 0, 0); - var RED = coloredImageDataValue[value1]; - var GREEN = coloredImageDataValue[value1 + 1]; - var BLUE = coloredImageDataValue[value1 + 2]; + var gData = grayCanvasContext.getImageData(0, 0, canvasWidth,canvasHeight ) - grayImageDataValue[value1] = RED; - grayImageDataValue[value1+1] = GREEN; - grayImageDataValue[value1+2] = BLUE; - }) + grayImageDataVar = null; + var macthedData = new jinqJs() + .from($rootScope.macthedTermList) + .where('bodyRegionId == ' + TermExistInBodyRegionId) + .select(); - var grayCanvasID = 'imageCanvas' + TermExistInBodyRegionId; - var grayCanvas = document.getElementById(grayCanvasID); - if (grayCanvas != null) { - debugger; - var grayCanvasContext = grayCanvas.getContext("2d"); + //grayImageDataVar = $rootScope.grayImageDataList[parseInt(TermExistInBodyRegionId) - 1] + + + var coloredImageDataVar = $rootScope.coloredImageCanvasList[parseInt(TermExistInBodyRegionId) - 1]; - //var canvasHeight = grayCanvas.height + 'px'; - //var canvasWidth = grayCanvas.width + 'px'; + var grayImageDataValue = gData.data; + var coloredImageDataValue = coloredImageDataVar.data; + // $rootScope.termListWithLocation = value.terms; - var canvasHeight = grayCanvas.height; - var canvasWidth = grayCanvas.width; + angular.forEach(macthedData, function (value2, key) { + $rootScope.termListWithLocation = value2.terms; + angular.forEach($rootScope.termListWithLocation.PixelLocations, function (value1, key1) { - grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth) + var RED = coloredImageDataValue[value1]; + var GREEN = coloredImageDataValue[value1 + 1]; + var BLUE = coloredImageDataValue[value1 + 2]; - grayCanvasContext.putImageData(grayImageDataVar, 0, 0); + grayImageDataValue[value1] = RED; + grayImageDataValue[value1 + 1] = GREEN; + grayImageDataValue[value1 + 2] = BLUE; + }) + var grayCanvasID = 'imageCanvas' + TermExistInBodyRegionId; + var grayCanvas = document.getElementById(grayCanvasID); + if (grayCanvas != null) { + var grayCanvasContext = grayCanvas.getContext("2d"); - } - $('#spinner').css('visibility', 'hidden') - $rootScope.isLoading = false; + var canvasHeight = grayCanvas.height; + var canvasWidth = grayCanvas.width; + + //grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth) + + grayCanvasContext.putImageData(gData, 0, 0); + + // grayCanvasContext.putImageData($rootScope.rawGrayImageDataList[parseInt(TermExistInBodyRegionId) - 1], 0, 0); + + } + $('#spinner').css('visibility', 'hidden') + $rootScope.isLoading = false; + + prevBRID = TermExistInBodyRegionId; + }) + } + } }) + } @@ -2925,7 +2936,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } - $scope.createTermListByPreviousTermsAndHighlight = function () { @@ -6922,7 +6932,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo $scope.isLoading = true; $('#spinner').css('visibility', 'visible'); - $timeout(function () { $scope.HighlightBodyByTermList($scope.systemMatchedTermList) }, 100); + $timeout(function () { $scope.HighlightBodyByTermListForBodySystem($scope.systemMatchedTermList) }, 100); } else if (($rootScope.isListManagerSelected == true) || ($rootScope.previousHighlightList != null && $rootScope.previousHighlightList.length > 0) && ($rootScope.isGenderChnage == true || $rootScope.isViewChange == true) || $rootScope.isListManagerAlreadySelected == true) { @@ -7808,7 +7818,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo $scope.isLoading = true; $('#spinner').css('visibility', 'visible'); - $timeout(function () { $scope.HighlightBodyByTermList($scope.systemMatchedTermList) }, 100); + $timeout(function () { $scope.HighlightBodyByTermListForBodySystem($scope.systemMatchedTermList) }, 100); } } } @@ -8872,7 +8882,10 @@ function OnViewChange(event) { function OnBodySystemSelection(event) { console.log('OnBodySystem chnaged is called outside '); var scope = angular.element(document.getElementById("daView")).scope(); - scope.$apply(function () { + + + scope.$apply(function () + { scope.HighlightBodyByBodySystem(event); }); }