diff --git a/400-SOURCECODE/AIAHTML5.API/Models/PixelLocator.cs b/400-SOURCECODE/AIAHTML5.API/Models/PixelLocator.cs index 7c6fcf4..e4b2562 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/PixelLocator.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/PixelLocator.cs @@ -14,6 +14,7 @@ namespace AIAHTML5.API.Models { try { + //var client = new MongoClient("mongodb://192.168.90.43:27017"); var client = new MongoClient(); var db = client.GetDatabase("AIAHTML5"); diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js index 6c80624..c0c1995 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js @@ -2847,193 +2847,202 @@ AIA.controller("DAController", ["$scope", "$rootScope", "$compile", "$http", "$l .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); + + if (result.length == 0) + { + $rootScope.isLoading = false; + $('#spinner').css('visibility', 'hidden'); + + } + else { + 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); + 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"); + 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); + 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) { + angular.forEach($rootScope.macthedTermList, function (value, key) { - var TermExistInBodyRegionId = value.bodyRegionId; - console.log('3. HighlightBodyByTermListForBodySystem is called TermExistInBodyRegionId=' + TermExistInBodyRegionId); - if (TermExistInBodyRegionId != undefined) { - if (prevBRID != TermExistInBodyRegionId) { + var TermExistInBodyRegionId = value.bodyRegionId; + console.log('3. HighlightBodyByTermListForBodySystem is called TermExistInBodyRegionId=' + TermExistInBodyRegionId); + if (TermExistInBodyRegionId != undefined) { + if (prevBRID != TermExistInBodyRegionId) { - var grayCanvasID = 'imageCanvas' + TermExistInBodyRegionId; - var grayCanvas = document.getElementById(grayCanvasID); + var grayCanvasID = 'imageCanvas' + TermExistInBodyRegionId; + var grayCanvas = document.getElementById(grayCanvasID); - if (grayCanvas != null) { + if (grayCanvas != null) { - var grayCanvasContext = grayCanvas.getContext("2d"); + 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; + var canvasWidth = grayCanvas.width; + var canvasX = grayCanvas.style.left; + var canvasY = grayCanvas.style.top; - grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth) - grayCanvasContext.putImageData($rootScope.grayImageDataList[parseInt(TermExistInBodyRegionId) - 1], 0, 0); + grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth) + grayCanvasContext.putImageData($rootScope.grayImageDataList[parseInt(TermExistInBodyRegionId) - 1], 0, 0); - var gData = grayCanvasContext.getImageData(0, 0, canvasWidth, canvasHeight); + var gData = grayCanvasContext.getImageData(0, 0, canvasWidth, canvasHeight); - //for mirror images - var grayCanvasMRID = 'imageCanvas' + TermExistInBodyRegionId + '_MR'; - var grayCanvasMR = document.getElementById(grayCanvasMRID); - var grayCanvasMRX; - var grayCanvasMRY; + //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) { + //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 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'; + 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(); + //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 + //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); + var filppedCanvasContx = FlipedImgCanvas.getContext("2d"); + filppedCanvasContx.putImageData(gData, 0, 0); - } + } - grayImageDataVar = null; - var macthedData = new jinqJs() - .from($rootScope.macthedTermList) - .where('bodyRegionId == ' + TermExistInBodyRegionId) - .select(); + grayImageDataVar = null; + var macthedData = new jinqJs() + .from($rootScope.macthedTermList) + .where('bodyRegionId == ' + TermExistInBodyRegionId) + .select(); - var coloredImageDataVar = $rootScope.coloredImageCanvasList[parseInt(TermExistInBodyRegionId) - 1]; + var coloredImageDataVar = $rootScope.coloredImageCanvasList[parseInt(TermExistInBodyRegionId) - 1]; - var grayImageDataValue = gData.data; - var coloredImageDataValue = coloredImageDataVar.data; + var grayImageDataValue = gData.data; + var coloredImageDataValue = coloredImageDataVar.data; - angular.forEach(macthedData, function (value2, key) { + angular.forEach(macthedData, function (value2, key) { - $rootScope.termListWithLocation = value2.terms; + $rootScope.termListWithLocation = value2.terms; - //pick the color from coloredImage data and put on gray imagedata - angular.forEach($rootScope.termListWithLocation.PixelLocations, function (value1, key1) { + //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]; + 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; - }) + 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); + //for non mirrored bpdy regions + var grayCanvasID = 'imageCanvas' + TermExistInBodyRegionId; + var grayCanvas = document.getElementById(grayCanvasID); - if (grayCanvas != null) { + if (grayCanvas != null) { - var grayCanvasContext = grayCanvas.getContext("2d"); + var grayCanvasContext = grayCanvas.getContext("2d"); - grayCanvasContext.putImageData(gData, 0, 0); + grayCanvasContext.putImageData(gData, 0, 0); - } + } - //for mirror body regions - if (TermExistInBodyRegionId == 4 || TermExistInBodyRegionId == 5 || TermExistInBodyRegionId == 6) { + //for mirror body regions + if (TermExistInBodyRegionId == 4 || TermExistInBodyRegionId == 5 || TermExistInBodyRegionId == 6) { - var grayCanvasMRID = 'imageCanvas' + TermExistInBodyRegionId + '_MR'; + var grayCanvasMRID = 'imageCanvas' + TermExistInBodyRegionId + '_MR'; - var grayCanvasMR = document.getElementById(grayCanvasMRID); + var grayCanvasMR = document.getElementById(grayCanvasMRID); - if (grayCanvasMR != null) { + if (grayCanvasMR != null) { - var grayCanvasMRContext = grayCanvasMR.getContext("2d"); + 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(); + 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'; + //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; + $('#spinner').css('visibility', 'hidden') + $rootScope.isLoading = false; - prevBRID = TermExistInBodyRegionId; - }) + prevBRID = TermExistInBodyRegionId; + }) + } } } - } - else { - $('#spinner').css('visibility', 'hidden') - $rootScope.isLoading = false; - } + else { + $('#spinner').css('visibility', 'hidden') + $rootScope.isLoading = false; + } - }) + }) + + } - } - + } }, function (error) { console.log(' Error in getting term data = ' + error.statusText);