diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js index a15f151..23a1569 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,74 +2784,224 @@ 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('HighlightBodyByTermListForBodySystem 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) { + console.log('1. HighlightBodyByTermListForBodySystem is called'); $rootScope.macthedTermList = result; var termNo = 0; var pixcelLocation = 0; - + var prevBRID = 0; if ($rootScope.macthedTermList.length > 0) { + console.log('2. HighlightBodyByTermListForBodySystem is called'); + //remove existing data and draw fresh data + 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; + console.log('3. HighlightBodyByTermListForBodySystem is called TermExistInBodyRegionId=' + TermExistInBodyRegionId); + if (TermExistInBodyRegionId != undefined) { + if (prevBRID != TermExistInBodyRegionId) { - $rootScope.termListWithLocation = value.terms; - angular.forEach($rootScope.termListWithLocation.PixelLocations, function (value1, key1) { - //debugger; + var grayCanvasID = 'imageCanvas' + TermExistInBodyRegionId; + var grayCanvas = document.getElementById(grayCanvasID); - var RED = coloredImageDataValue[value1]; - var GREEN = coloredImageDataValue[value1 + 1]; - var BLUE = coloredImageDataValue[value1 + 2]; + if (grayCanvas != null) { - grayImageDataValue[value1] = RED; - grayImageDataValue[value1+1] = GREEN; - grayImageDataValue[value1+2] = BLUE; - }) + var grayCanvasContext = grayCanvas.getContext("2d"); - var grayCanvasID = 'imageCanvas' + TermExistInBodyRegionId; - var grayCanvas = document.getElementById(grayCanvasID); - if (grayCanvas != null) { - debugger; - var grayCanvasContext = grayCanvas.getContext("2d"); + var canvasHeight = grayCanvas.height; + var canvasWidth = grayCanvas.width; + var canvasX = grayCanvas.style.left; + var canvasY = grayCanvas.style.top; - //var canvasHeight = grayCanvas.height + 'px'; - //var canvasWidth = grayCanvas.width + 'px'; + grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth) + grayCanvasContext.putImageData($rootScope.grayImageDataList[parseInt(TermExistInBodyRegionId) - 1], 0, 0); - var canvasHeight = grayCanvas.height; - var canvasWidth = grayCanvas.width; + var gData = grayCanvasContext.getImageData(0, 0, canvasWidth, canvasHeight); - grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth) + //for mirror images + var grayCanvasMRID = 'imageCanvas' + TermExistInBodyRegionId + '_MR'; + var grayCanvasMR = document.getElementById(grayCanvasMRID); + var grayCanvasMRX; + var grayCanvasMRY; + + //draw a canvas for same bodyregion wich will be flipped after coloring the body system + if (TermExistInBodyRegionId == 4 || TermExistInBodyRegionId == 5 || TermExistInBodyRegionId == 6) { + + + var grayCanvasMRID = 'imageCanvas' + TermExistInBodyRegionId + '_MR'; + var grayCanvasMR = document.getElementById(grayCanvasMRID); + grayCanvasMRX = grayCanvasMR.style.left; + grayCanvasMRY = grayCanvasMR.style.top; + + var FlipedImgCanvas = document.createElement('canvas'); + FlipedImgCanvas.height = canvasHeight; + FlipedImgCanvas.width = canvasWidth; + FlipedImgCanvas.setAttribute("data-IsMirrored", "Y") + FlipedImgCanvas.style.position = "absolute"; + FlipedImgCanvas.style.left = canvasX + "px"; + FlipedImgCanvas.style.top = canvasY + "px"; + FlipedImgCanvas.style.visibility = 'hidden'; + FlipedImgCanvas.id = 'imageCanvas' + TermExistInBodyRegionId + '_MR'; + + //remove previous canavs + $('#' + grayCanvasMRID).remove(); + + //add new canvas on same location and after flipping it will be added to mirrored position + document.getElementById('canvasDiv').appendChild(FlipedImgCanvas); + //put grayData + + var filppedCanvasContx = FlipedImgCanvas.getContext("2d"); + filppedCanvasContx.putImageData(gData, 0, 0); + + } + + grayImageDataVar = null; + var macthedData = new jinqJs() + .from($rootScope.macthedTermList) + .where('bodyRegionId == ' + TermExistInBodyRegionId) + .select(); + + + + var coloredImageDataVar = $rootScope.coloredImageCanvasList[parseInt(TermExistInBodyRegionId) - 1]; + + var grayImageDataValue = gData.data; + var coloredImageDataValue = coloredImageDataVar.data; + + + angular.forEach(macthedData, function (value2, key) { + + $rootScope.termListWithLocation = value2.terms; - grayCanvasContext.putImageData(grayImageDataVar, 0, 0); + //pick the color from coloredImage data and put on gray imagedata + angular.forEach($rootScope.termListWithLocation.PixelLocations, function (value1, key1) { + var RED = coloredImageDataValue[value1]; + var GREEN = coloredImageDataValue[value1 + 1]; + var BLUE = coloredImageDataValue[value1 + 2]; + grayImageDataValue[value1] = RED; + grayImageDataValue[value1 + 1] = GREEN; + grayImageDataValue[value1 + 2] = BLUE; + }) + + //for non mirrored bpdy regions + var grayCanvasID = 'imageCanvas' + TermExistInBodyRegionId; + var grayCanvas = document.getElementById(grayCanvasID); + + if (grayCanvas != null) { + + var grayCanvasContext = grayCanvas.getContext("2d"); + + grayCanvasContext.putImageData(gData, 0, 0); + + } + + //for mirror body regions + if (TermExistInBodyRegionId == 4 || TermExistInBodyRegionId == 5 || TermExistInBodyRegionId == 6) { + + var grayCanvasMRID = 'imageCanvas' + TermExistInBodyRegionId + '_MR'; + + var grayCanvasMR = document.getElementById(grayCanvasMRID); + + if (grayCanvasMR != null) { + + var grayCanvasMRContext = grayCanvasMR.getContext("2d"); + + grayCanvasMRContext.save(); + grayCanvasMRContext.translate(canvasWidth, 0); + grayCanvasMRContext.scale(-1, 1); + //flip does not work with putImageData, that is why we used drawImage + grayCanvasMRContext.drawImage(grayCanvas, 0, 0, canvasWidth, canvasHeight, 0, 0, canvasWidth, canvasHeight); + grayCanvasMRContext.restore(); + + //set this canavs on the actual posution of mirror image + grayCanvasMR.style.left = grayCanvasMRX; + grayCanvasMR.style.top = grayCanvasMRY; + grayCanvasMR.style.visibility = 'visible'; + + + } + } + + $('#spinner').css('visibility', 'hidden') + $rootScope.isLoading = false; + + prevBRID = TermExistInBodyRegionId; + }) + } + } + } + else { + $('#spinner').css('visibility', 'hidden') + $rootScope.isLoading = false; } - $('#spinner').css('visibility', 'hidden') - $rootScope.isLoading = false; }) - } + } + }, function (error) { @@ -2925,7 +3013,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } - $scope.createTermListByPreviousTermsAndHighlight = function () { @@ -6922,7 +7009,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 +7895,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 +8959,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); }); } diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/TileViewListController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/TileViewListController.js index 5d25a7e..831c213 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/TileViewListController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/TileViewListController.js @@ -916,7 +916,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo $scope.drawStaticPinsOnImage = function (canvasId, PinId, offsetX1, offsetY1, x, y) { - console.log('drawStaticPinsOnImage') + $scope.clickedPins = []; // if ($scope.isSliderChange == true) { console.log('isSliderrChange') var radial = $('#' + canvasId).createGradient({ @@ -1302,6 +1302,22 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo .where('_PinId != ' + value.id) .select(); }) + angular.forEach($scope.clickedPins, function (value1, key1) { + + // if (aaPinDataValue._PinId != value.id) { + var pinName = 'Pin_' + value1.id; + var pinArcName = 'PinArc_' + value1.id; + + $('#aaDetailViewCanvas').setLayer(pinName, { + visible: true // set to true instead to show the layer again + }).drawLayers(); + + $('#aaDetailViewCanvas').setLayer(pinArcName, { + visible: true // set to true instead to show the layer again + }).drawLayers(); + // } + }) + angular.forEach(seletedSystemPinData, function (aaPinDataValue, aaPinDataKey) { // if (aaPinDataValue._PinId != value.id) { @@ -1319,8 +1335,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo }) // }) - alert($scope.clickedPins.length); - $scope.clickedPins = []; + // $scope.clickedPins = []; } else {