diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js index 42563c5..420088f 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js @@ -3928,7 +3928,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo 'width': 0, 'height': 0, 'z-index': 1000 - //'background': 'transparent', }); $selection.appendTo($container); } @@ -3969,8 +3968,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo function mouseUpListener(e) { $scope.isTBDrawnOnBodyRegion = false; - //alert('mouse up'); - console.log('MOUSE UP'); + $(".com").remove(); $('#dot').remove(); $('#bord').remove(); @@ -3982,12 +3980,10 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo var currentMousePosition = $scope.getMousePos(e); - var canvasDiv = document.getElementById('canvasDiv'); - var verticalScrollPosition = canvasDiv.scrollTop; - var horizontlScrollPosition = canvasDiv.scrollLeft; + var canavsDivScrollPos = $scope.getCanavsDivScrollPosition(); - var TransparencyEndX = currentMousePosition.x + horizontlScrollPosition - var TransparencyBoxEndY = currentMousePosition.y + verticalScrollPosition + var TransparencyEndX = currentMousePosition.x + canavsDivScrollPos.horizontlScrollPosition; + var TransparencyBoxEndY = currentMousePosition.y + canavsDivScrollPos.verticalScrollPosition; $scope.isTboxDrwan = true; @@ -3996,7 +3992,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo $scope.TransparencyEndX = TransparencyEndX; $scope.TransparencyBoxEndY = TransparencyBoxEndY; - $scope.layerNumberBeforeTrans = parseInt($('#txtlayerNumber').val()); + $scope.layerNumberBeforeTBDraw = parseInt($('#txtlayerNumber').val()); //draw temp box to store the canvas data with original transparecy if (document.getElementById('tempCanvas') != null) { @@ -4023,18 +4019,19 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo var BodyRegionDictionary = $rootScope.BodyRegionCordinatesData; $scope.IncludedBodyRegions = []; - ////debugger; + $scope.transparencyDrawnRegions = []; + $.each(BodyRegionDictionary, function (index, value) { - // alert(' $.each(BodyRegionDictionary1') - var transparencyBoxHeight = parseInt(TransparencyBoxEndY) - parseInt($scope.TransparencyBoxStartY); - var transparencyBoxWidth = parseInt(TransparencyEndX) - parseInt($scope.TransparencyBoxStartX); - var transparencyBoxBottom = parseInt($scope.TransparencyBoxStartY) + parseInt(transparencyBoxHeight); - var transparencyBoxRight = parseInt($scope.TransparencyBoxStartX) + parseInt(transparencyBoxWidth); - // alert(' $.each(BodyRegionDictionary2. transparencyBoxHeight: ' + transparencyBoxHeight + ',transparencyBoxBottom: ' + transparencyBoxBottom+', transparencyBoxRight: '+transparencyBoxRight) - var bodyRegionRight = parseInt(value.X) + parseInt(value.Width); - var bodyRegionBottom = parseInt(value.Y) + parseInt(value.Height); + + var tBoxDimesions = $scope.getTBoxDimesions($scope.TransparencyBoxStartX, TransparencyEndX, $scope.TransparencyBoxStartY, TransparencyBoxEndY, value.X, value.Y, value.Height, value.Width); + var transparencyBoxHeight = tBoxDimesions.transparencyBoxHeight; + var transparencyBoxWidth = tBoxDimesions.transparencyBoxWidth; + var transparencyBoxBottom = tBoxDimesions.transparencyBoxBottom; + var transparencyBoxRight = tBoxDimesions.transparencyBoxRight; + var bodyRegionRight = tBoxDimesions.bodyRegionRight; + var bodyRegionBottom = tBoxDimesions.bodyRegionBottom; var transparencyCanvas = document.createElement('canvas'); var tBox = document.getElementById('transparencyCanvas'); @@ -4050,7 +4047,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo transparencyCanvas.style.border = "black 1px solid"; transparencyCanvas.style.backgroundColor = "transparent"; transparencyCanvas.style.zIndex = 200; - // transparencyCanvas.style.visibility = 'hidden'; document.getElementById('canvasDiv').appendChild(transparencyCanvas); $scope.transparencyChangeCounter = 0; @@ -4087,14 +4083,15 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo //for modesty if ($rootScope.isModestyOn == true && $scope.modestyImageInfo.length > 0) { $.each($scope.modestyImageInfo, function (index, value) { - // alert(' $.each(BodyRegionDictionary1') - var transparencyBoxHeight = parseInt(TransparencyBoxEndY) - parseInt($scope.TransparencyBoxStartY); - var transparencyBoxWidth = parseInt(TransparencyEndX) - parseInt($scope.TransparencyBoxStartX); - var transparencyBoxBottom = parseInt($scope.TransparencyBoxStartY) + parseInt(transparencyBoxHeight); - var transparencyBoxRight = parseInt($scope.TransparencyBoxStartX) + parseInt(transparencyBoxWidth); - // alert(' $.each(BodyRegionDictionary2. transparencyBoxHeight: ' + transparencyBoxHeight + ',transparencyBoxBottom: ' + transparencyBoxBottom+', transparencyBoxRight: '+transparencyBoxRight) - var bodyRegionRight = parseInt(value.x) + parseInt(value.Width); - var bodyRegionBottom = parseInt(value.y) + parseInt(value.Height); + + var tBoxDimesions = $scope.getTBoxDimesions($scope.TransparencyBoxStartX, TransparencyEndX, $scope.TransparencyBoxStartY, TransparencyBoxEndY, value.x, value.y, value.Height, value.Width); + + var transparencyBoxHeight = tBoxDimesions.transparencyBoxHeight; + var transparencyBoxWidth = tBoxDimesions.transparencyBoxWidth; + var transparencyBoxBottom = tBoxDimesions.transparencyBoxBottom; + var transparencyBoxRight = tBoxDimesions.transparencyBoxRight; + var bodyRegionRight = tBoxDimesions.bodyRegionRight; + var bodyRegionBottom = tBoxDimesions.bodyRegionBottom; if ($scope.TransparencyBoxStartX <= bodyRegionRight && value.x <= transparencyBoxRight && $scope.TransparencyBoxStartY <= bodyRegionBottom && value.y <= transparencyBoxBottom) { @@ -4133,12 +4130,37 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo $('#btnIdentity').addClass('btn-primary'); } - $scope.loadTransparencyImage = function (bodyRegionId, Height, Width, X, Y, IsMirror, TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, scope, isLayerChanged, isTransparencyChanged) { - // debugger; + $scope.getCanavsDivScrollPosition = function () { - // else { + var canvasDiv = document.getElementById('canvasDiv'); + return{ + verticalScrollPosition : canvasDiv.scrollTop, + horizontlScrollPosition : canvasDiv.scrollLeft + } + + } + + $scope.getTBoxDimesions = function (TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, X, Y, Height, Width) { + + var tBoxHeight = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY); + var tBoxWidth = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX); + var tBoxBottom = parseInt(TransparencyBoxStartY) + parseInt(tBoxHeight); + var tBoxRight = parseInt(TransparencyBoxStartX) + parseInt(tBoxWidth); + + return{ + + transparencyBoxHeight: tBoxHeight, + transparencyBoxWidth: tBoxWidth, + transparencyBoxBottom: tBoxBottom, + transparencyBoxRight: tBoxRight, + bodyRegionRight : parseInt(X) + parseInt(Width), + bodyRegionBottom : parseInt(Y) + parseInt(Height) + } + } + + $scope.loadTransparencyImage = function (bodyRegionId, Height, Width, X, Y, IsMirror, TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, scope, isLayerChanged, isTransparencyChanged) { + - var scope1 = angular.element(document.getElementById("DAView")).scope(); var transparencyCanvas = document.getElementById('transparencyCanvas'); TransparencyBoxStartX = parseInt((transparencyCanvas.style.left).replace('px', '')); @@ -4147,140 +4169,16 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo TransparencyBoxEndY = parseInt(transparencyCanvas.height) + parseInt(TransparencyBoxStartY); - var XforCopyImage = 0; - var YforCopyImage = 0; - var WidthforCopyImage = 0; - var HeightforCopyImage = 0; - var XforTransImage = 0; - var WidthforTransImage = 0; - var HeightforTransImage = 0; - var YforTransImage = 0; - var PreviousBodyRegionHeight = 0; - var PreviousBodyRegionY; - var PreviousBodyRegionWidth; - var PreviousBodyRegionX; - var previousBodyRegionId; - var transparencyTempCanvas; - - - - //X ends outside and start outside of bodyregion - if (TransparencyBoxStartX < X && TransparencyEndX > parseInt(X) + parseInt(Width)) { - XforCopyImage = 0; - WidthforCopyImage = Width; - WidthforTransImage = Width; - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { - XforTransImage = 0; - } - else - XforTransImage = parseInt(X) - (parseInt(TransparencyBoxStartX)); - // alert('1') - } - else if (TransparencyBoxStartX < X && TransparencyEndX < parseInt(X) + parseInt(Width)) { - - XforCopyImage = 0; - - WidthforCopyImage = parseInt(TransparencyEndX) - parseInt(X); - - WidthforTransImage = parseInt(TransparencyEndX) - parseInt(X); - - // alert(' scope.WidthforCopyImage: ' + scope.WidthforCopyImage) - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { - XforTransImage = 0; - } - else - XforTransImage = parseInt(X) - (parseInt(TransparencyBoxStartX)); - - // alert('2') - } - else if (TransparencyBoxStartX > X && TransparencyEndX > parseInt(X) + parseInt(Width)) { - // alert('TransparencyEndX: ' + TransparencyEndX + ', X: ' + X + ', Width: ' + Width + 'scope.TransparencyBoxStartX: ' + scope.TransparencyBoxStartX) - - XforCopyImage = parseInt(TransparencyBoxStartX) - parseInt(X); - WidthforCopyImage = parseInt(X) + parseInt(Width) - parseInt(TransparencyBoxStartX); - WidthforTransImage = parseInt(X) + parseInt(Width) - parseInt(TransparencyBoxStartX); - - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { - - XforTransImage = parseInt(TransparencyBoxStartX) - parseInt(X); - } - else - XforTransImage = 0; - // alert('3') - } - else if (TransparencyBoxStartX > X && TransparencyEndX < parseInt(X) + parseInt(Width)) { - // alert('startX inside & endX inside') - XforCopyImage = parseInt(TransparencyBoxStartX) - parseInt(X);//parseInt(X) + parseInt(Width) - parseInt(scope.TransparencyBoxStartX)// scope.TransparencyBoxStartX ; - WidthforCopyImage = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX); - WidthforTransImage = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX); - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { - - XforTransImage = parseInt(TransparencyBoxStartX) - parseInt(X); - } - else - XforTransImage = 0; - // alert('4. TransparencyBoxStartX: ' + TransparencyBoxStartX + ',X: ' + parseInt(X) + ',TransparencyEndX: ' + TransparencyEndX + ',XforCopyImage: ' + XforCopyImage) - } - - //calculate Y and height for tempTranparency box from where to cut the image - - - if (TransparencyBoxStartY < Y && TransparencyBoxEndY > parseInt(Y) + parseInt(Height)) { - - // alert('start Y outside and end Y outside'); - - YforCopyImage = 0; - HeightforCopyImage = Height; - - HeightforTransImage = Height; - //alert('Y ' + Y) - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { - YforTransImage = 0; - } - else - YforTransImage = parseFloat(Y) - parseInt(TransparencyBoxStartY)//parseFloat(Y) - (24.4); - // alert('5') - } - else if (TransparencyBoxStartY < Y && TransparencyBoxEndY < (parseInt(Y) + parseInt(Height))) { - - YforCopyImage = 0; - HeightforCopyImage = (parseInt(TransparencyBoxEndY)) - parseInt(Y)//(parseInt(Height) + parseInt(Y)) - (parseInt(TransparencyBoxEndY) - parseInt(scope.TransparencyBoxStartY)); - - HeightforTransImage = (parseInt(TransparencyBoxEndY)) - parseInt(Y)// - parseInt(scope.TransparencyBoxStartY)); - - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { - YforTransImage = 0; - } - else - YforTransImage = parseFloat(Y) - parseInt(TransparencyBoxStartY);// - (24.4); - - } - else if (TransparencyBoxStartY > Y && TransparencyBoxEndY > parseInt(Y) + parseInt(Height)) { - - YforCopyImage = parseInt(TransparencyBoxStartY) - parseInt(Y); - HeightforCopyImage = parseInt(Y) + parseInt(Height) - parseInt(TransparencyBoxStartY); - HeightforTransImage = parseInt(Y) + parseInt(Height) - parseInt(TransparencyBoxStartY); - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { - YforTransImage = parseInt(TransparencyBoxStartY) - parseInt(Y); - - } - else - YforTransImage = 0; - - } - else if (TransparencyBoxStartY > Y && TransparencyBoxEndY < parseInt(Y) + parseInt(Height)) { - - YforCopyImage = parseInt(TransparencyBoxStartY) - parseInt(Y); - HeightforCopyImage = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY); - HeightforTransImage = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY); - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { - YforTransImage = parseInt(TransparencyBoxStartY) - parseInt(Y); - - } - else - YforTransImage = 0; - } + var TBImageDimensions = $scope.calculateDimensionsForTBImage(Height, Width, X, Y, IsMirror, TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, bodyRegionId); + var XforCopyImage = TBImageDimensions.XforCopyImageTB; + var YforCopyImage = TBImageDimensions.YforCopyImageTB; + var WidthforCopyImage = TBImageDimensions.WidthforCopyImageTB; + var HeightforCopyImage = TBImageDimensions.HeightforCopyImageTB; + var XforTransImage = TBImageDimensions.XforTransImageTB; + var WidthforTransImage = TBImageDimensions.WidthforTransImageTB; + var HeightforTransImage = TBImageDimensions.HeightforTransImageTB; + var YforTransImage = TBImageDimensions.YforTransImageTB; //0. get current layer number if ($scope.isResized) { @@ -4288,14 +4186,12 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } else if (isLayerChanged) { - } else { - - + var tranparencyLayer; - var currentLayer = $scope.layerNumberBeforeTrans; + var currentLayer = $scope.layerNumberBeforeTBDraw; if (currentLayer == $rootScope.totalLayers) { @@ -4315,11 +4211,11 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo $('#txtlayerNumber').val($scope.layerNumber); - //dedebugger; + var tranparencyImgSrc; var tranparencyMaskImgSrc; - //for modesty image - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg')))// == "2" || bodyRegionId == "3")) { + + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { var modestyBodyRegionData = new jinqJs() .from($scope.modestyImageInfo) @@ -4327,52 +4223,42 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo .select(); tranparencyImgSrc = modestyBodyRegionData[0].SRC; } - - //modesty end - - //1. get the image source - else { tranparencyImgSrc = $scope.GetImageSource(bodyRegionId); tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc); } - // var tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc); - // debugger; + + //remove old canvases var oldCanvas; - - if (IsMirror == 'Yes') { - oldCanvas = document.getElementById('transparencyTempCanvas_MR_' + bodyRegionId) - } - else { - - oldCanvas = document.getElementById('transparencyTempCanvas_' + bodyRegionId) - - } - - if (oldCanvas != null) { - document.getElementById('canvasDiv').removeChild(oldCanvas); - } - - //remove tempmask canvas var oldtempTransCanvasMask; var oldtempTransCanvasMaskMR; + if (IsMirror == 'Yes') { + oldCanvas = document.getElementById('transparencyTempCanvas_MR_' + bodyRegionId); oldtempTransCanvasMaskMR = document.getElementById('transparencyTempCanvasMask_MR' + bodyRegionId + '_mci'); oldtempTransCanvasMask = document.getElementById('transparencyTempCanvasMask_' + bodyRegionId + '_mci'); if (oldtempTransCanvasMaskMR != null) { document.getElementById('canvasDiv').removeChild(oldtempTransCanvasMaskMR); } + } else { + + oldCanvas = document.getElementById('transparencyTempCanvas_' + bodyRegionId) oldtempTransCanvasMask = document.getElementById('transparencyTempCanvasMask_' + bodyRegionId + '_mci'); } + + if (oldCanvas != null) { + document.getElementById('canvasDiv').removeChild(oldCanvas); + } if (oldtempTransCanvasMask != null) { document.getElementById('canvasDiv').removeChild(oldtempTransCanvasMask); } - - transparencyTempCanvas = document.createElement('canvas'); + + + var transparencyTempCanvas = document.createElement('canvas'); var transparencyTempcanavsMask = document.createElement('canvas'); //if mirror then draw mask image for non mirrored body region for annotation if (IsMirror == 'Yes') { @@ -4382,8 +4268,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo else { if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { transparencyTempCanvas.id = 'transparencyTempCanvas_' + bodyRegionId; - // transparencyTempCanvas.style.visibility = 'visible'; - //transparencyTempCanvas.style.zIndex = '1000' + } else { transparencyTempCanvas.id = 'transparencyTempCanvas_' + bodyRegionId; @@ -4396,14 +4281,9 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo transparencyTempCanvas.style.position = "absolute"; transparencyTempCanvas.style.left = X + 'px' // x + "px"; transparencyTempCanvas.style.top = Y + "px"//y + "px"; - //if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { - // transparencyTempCanvas.style.visibility = 'visible'; - //} - //else { + transparencyTempCanvas.style.visibility = 'hidden'; - // } - //transparencyTempCanvas.style.visibility = 'visible'; - // transparencyCanvas.style.zIndex = 4000; + document.getElementById('canvasDiv').appendChild(transparencyTempCanvas); //create temp mask canvas @@ -4415,8 +4295,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo transparencyTempcanavsMask.style.left = X + 'px' // x + "px"; transparencyTempcanavsMask.style.top = Y + "px"//y + "px"; transparencyTempcanavsMask.style.visibility = 'hidden'; - //transparencyTempCanvas.style.visibility = 'visible'; - // transparencyCanvas.style.border = "black 1px solid"; + document.getElementById('canvasDiv').appendChild(transparencyTempcanavsMask); } @@ -4432,7 +4311,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo if (document.getElementById(modestyTransTempCanvasId) == null || document.getElementById(modestyTransTempCanvasId) == undefined) { var tempCanvasModesty = document.createElement('canvas'); tempCanvasModesty.id = modestyTransTempCanvasId; - // $scope.tempCanvas = transparencyCanvas.id; tempCanvasModesty.height = Height; tempCanvasModesty.width = Width; tempCanvasModesty.style.position = "absolute"; @@ -4450,18 +4328,15 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo if (document.getElementById(modestyTransCanvasId) == null || document.getElementById(modestyTransCanvasId) == undefined) { var canvasModesty = document.createElement('canvas'); canvasModesty.id = modestyTransCanvasId; - // $scope.tempCanvas = transparencyCanvas.id; canvasModesty.height = Height; canvasModesty.width = Width; canvasModesty.style.position = "absolute"; canvasModesty.style.left = X + 'px'; canvasModesty.style.top = Y + 'px'; - //canvasModesty.style.backgroundColor = "transparent"; canvasModesty.style.visibility = 'visible'; canvasModesty.style.zIndex = '2000'; canvasModesty.addEventListener('click', OnClickModestyTransCanvas); - // tempcanvasModestyCanvasModesty.style.border = "black 1px solid"; document.getElementById('canvasDiv').appendChild(canvasModesty); } } @@ -4469,8 +4344,21 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo if (tranparencyImgSrc != undefined) { var tempImg = new Image(); + var tempCanvasID; + + if (IsMirror == 'Yes') { + tempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId; + } + else { + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { + tempCanvasID = 'transparencyTempCanvas_' + bodyRegionId;//bodyRegionId; + } + else + tempCanvasID = 'transparencyTempCanvas_' + bodyRegionId; + } tempImg.onload = function () { + var tempCtx = transparencyTempCanvas.getContext('2d'); if (IsMirror == 'Yes') { @@ -4479,126 +4367,53 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo tempCtx.translate(Width, 0); tempCtx.scale(-1, 1); tempCtx.drawImage(tempImg, 0, 0); - } - else { - tempCtx.drawImage(tempImg, 0, 0); - - } - // debugger; - var tempCanvasID; - - if (IsMirror == 'Yes') { - tempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId; - } - else { - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { - tempCanvasID = 'transparencyTempCanvas_' + bodyRegionId;//bodyRegionId; - } - else - tempCanvasID = 'transparencyTempCanvas_' + bodyRegionId; - } - - - //check if transparency is activated - - - var transNumber = $scope.transNumber;//txtTransparencyChange.value; - // debugger; - //this changes the transparency when transparency is already activated and user resizes or chage the layer - - var imageD = tempCtx.getImageData(0, 0, Width, Height); - - - var tempCtx = document.getElementById(tempCanvasID).getContext('2d'); - - //keep the original image on temp canavs to use it in changing transparency - - - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { - var modestyTempCanvasId = 'tempCanvasModesty_' + bodyRegionId; - if (document.getElementById(modestyTempCanvasId) != undefined || document.getElementById(modestyTempCanvasId) != null) { - var contxModesty = document.getElementById(modestyTempCanvasId).getContext('2d'); - var tbTempCanvas = document.getElementById(tempCanvasID) - contxModesty.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage); + if ($rootScope.isHighLight == true) { + // var tempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId; + $scope.highlightTempTransparencyCanvas(tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, + XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId); } } else { - if (document.getElementById('tempCanvas') != null && document.getElementById('tempCanvas') != undefined) { - var contx = document.getElementById('tempCanvas').getContext('2d'); - var tbTempCanvas = document.getElementById(tempCanvasID) - contx.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage); - - } - } + tempCtx.drawImage(tempImg, 0, 0); - // get the image data values + if ($rootScope.isHighLight == true) { + $scope.highlightTempTransparencyCanvas(tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, + YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId); - var imageData = imageD.data; - var length = imageData.length; + } - //change background of image from transparent to white + } + - // set every fourth value to 50 - for (var i = 3; i < length; i += 4) { - //NIKITA - if ($scope.voId == "9" || $scope.voId == "11") { + + if ($rootScope.isHighLight != true) { + - if (imageData[i] == 0) { + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { + var modestyTempCanvasId = 'tempCanvasModesty_' + bodyRegionId; + if (document.getElementById(modestyTempCanvasId) != undefined || document.getElementById(modestyTempCanvasId) != null) { + var contxModestyTemp = document.getElementById(modestyTempCanvasId).getContext('2d'); + var tbTempCanvas = document.getElementById(tempCanvasID) + contxModestyTemp.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage); } - else { - imageData[i] = ((255) * (parseInt(transNumber))) / 100; - } } else { - if (imageData[i] == 0) { - - } - else { - imageData[i] = ((255) * (parseInt(transNumber))) / 100; - } - } - } + if (document.getElementById('tempCanvas') != null && document.getElementById('tempCanvas') != undefined) { + var contx = document.getElementById('tempCanvas').getContext('2d'); + var tbTempCanvas = document.getElementById(tempCanvasID) + contx.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage); - tempCtx.putImageData(imageD, 0, 0); - - var ctx; - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { - ctx = document.getElementById(modestyTransCanvasId).getContext('2d'); - } - else - ctx = transparencyCanvas.getContext('2d'); + } + } + $scope.DrawOnTBWithSelectedTransparency(tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId); - var TrtempCanvasID - if (IsMirror == 'Yes') { - TrtempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId; - } - else { - //if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { - // TrtempCanvasID = 'modestyTransparencyTempCanvas_' + bodyRegionId; - //} - //else - TrtempCanvasID = 'transparencyTempCanvas_' + bodyRegionId; } - - var tmpCanvasContext = document.getElementById(TrtempCanvasID);//.getContext('2d'); - - ctx.drawImage(tmpCanvasContext, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage) - - - XforCopyImage = 0; - YforCopyImage = 0; - WidthforCopyImage = 0; - HeightforCopyImage = 0; - XforTransImage = 0; - WidthforTransImage = 0; - HeightforTransImage = 0; - YforTransImage = 0; - PreviousBodyRegionHeight = 0; + } tempImg.src = tranparencyImgSrc;//"http://localhost/AIA/" + tranparencyImgSrc; @@ -4606,7 +4421,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } - //mask image code //draw mask for annotation var tempMaskImg = new Image(); @@ -4631,14 +4445,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } - - PreviousBodyRegionHeight = HeightforTransImage; - PreviousBodyRegionY = YforTransImage; - PreviousBodyRegionWidth = WidthforTransImage; - PreviousBodyRegionX = XforTransImage; - previousBodyRegionId = bodyRegionId; - - //set modesty image visiblility true/false as per layer @@ -4676,6 +4482,263 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } + + $scope.calculateDimensionsForTBImage = function (Height, Width, X, Y, IsMirror, TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, bodyRegionId) { + + var XforCopyImage = 0; + var YforCopyImage = 0; + var WidthforCopyImage = 0; + var HeightforCopyImage = 0; + var XforTransImage = 0; + var WidthforTransImage = 0; + var HeightforTransImage = 0; + var YforTransImage = 0; + + + //X ends outside and start outside of bodyregion + if (TransparencyBoxStartX < X && TransparencyEndX > parseInt(X) + parseInt(Width)) { + XforCopyImage = 0; + WidthforCopyImage = Width; + WidthforTransImage = Width; + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { + XforTransImage = 0; + } + else + XforTransImage = parseInt(X) - (parseInt(TransparencyBoxStartX)); + } + else if (TransparencyBoxStartX < X && TransparencyEndX < parseInt(X) + parseInt(Width)) { + + XforCopyImage = 0; + + WidthforCopyImage = parseInt(TransparencyEndX) - parseInt(X); + + WidthforTransImage = parseInt(TransparencyEndX) - parseInt(X); + + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { + XforTransImage = 0; + } + else + XforTransImage = parseInt(X) - (parseInt(TransparencyBoxStartX)); + + } + else if (TransparencyBoxStartX > X && TransparencyEndX > parseInt(X) + parseInt(Width)) { + + XforCopyImage = parseInt(TransparencyBoxStartX) - parseInt(X); + WidthforCopyImage = parseInt(X) + parseInt(Width) - parseInt(TransparencyBoxStartX); + WidthforTransImage = parseInt(X) + parseInt(Width) - parseInt(TransparencyBoxStartX); + + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { + + XforTransImage = parseInt(TransparencyBoxStartX) - parseInt(X); + } + else + XforTransImage = 0; + } + else if (TransparencyBoxStartX > X && TransparencyEndX < parseInt(X) + parseInt(Width)) { + XforCopyImage = parseInt(TransparencyBoxStartX) - parseInt(X);//parseInt(X) + parseInt(Width) - parseInt(scope.TransparencyBoxStartX)// scope.TransparencyBoxStartX ; + WidthforCopyImage = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX); + WidthforTransImage = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX); + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { + + XforTransImage = parseInt(TransparencyBoxStartX) - parseInt(X); + } + else + XforTransImage = 0; + } + + //calculate Y and height for tempTranparency box from where to cut the image + + + if (TransparencyBoxStartY < Y && TransparencyBoxEndY > parseInt(Y) + parseInt(Height)) { + + YforCopyImage = 0; + HeightforCopyImage = Height; + + HeightforTransImage = Height; + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { + YforTransImage = 0; + } + else + YforTransImage = parseFloat(Y) - parseInt(TransparencyBoxStartY)//parseFloat(Y) - (24.4); + } + else if (TransparencyBoxStartY < Y && TransparencyBoxEndY < (parseInt(Y) + parseInt(Height))) { + + YforCopyImage = 0; + HeightforCopyImage = (parseInt(TransparencyBoxEndY)) - parseInt(Y)//(parseInt(Height) + parseInt(Y)) - (parseInt(TransparencyBoxEndY) - parseInt(scope.TransparencyBoxStartY)); + + HeightforTransImage = (parseInt(TransparencyBoxEndY)) - parseInt(Y)// - parseInt(scope.TransparencyBoxStartY)); + + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { + YforTransImage = 0; + } + else + YforTransImage = parseFloat(Y) - parseInt(TransparencyBoxStartY);// - (24.4); + + } + else if (TransparencyBoxStartY > Y && TransparencyBoxEndY > parseInt(Y) + parseInt(Height)) { + + YforCopyImage = parseInt(TransparencyBoxStartY) - parseInt(Y); + HeightforCopyImage = parseInt(Y) + parseInt(Height) - parseInt(TransparencyBoxStartY); + HeightforTransImage = parseInt(Y) + parseInt(Height) - parseInt(TransparencyBoxStartY); + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { + YforTransImage = parseInt(TransparencyBoxStartY) - parseInt(Y); + + } + else + YforTransImage = 0; + + } + else if (TransparencyBoxStartY > Y && TransparencyBoxEndY < parseInt(Y) + parseInt(Height)) { + + YforCopyImage = parseInt(TransparencyBoxStartY) - parseInt(Y); + HeightforCopyImage = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY); + HeightforTransImage = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY); + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { + YforTransImage = parseInt(TransparencyBoxStartY) - parseInt(Y); + + } + else + YforTransImage = 0; + } + + return { + + + XforCopyImageTB : XforCopyImage, + YforCopyImageTB: YforCopyImage, + WidthforCopyImageTB: WidthforCopyImage, + HeightforCopyImageTB: HeightforCopyImage, + XforTransImageTB: XforTransImage, + WidthforTransImageTB: WidthforTransImage, + HeightforTransImageTB: HeightforTransImage, + YforTransImageTB: YforTransImage + + } + } + + $scope.highlightTempTransparencyCanvas = function (tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId) { + + var tempTransCanvas = document.getElementById(tempCanvasID); + var tempCanvasContext = tempTransCanvas.getContext('2d'); + + var dataURL = tempTransCanvas.toDataURL(); + + var img = new Image(); + img.src = dataURL; + + img.onload = function () { + + var DAData = new BitmapData(parseInt(tempTransCanvas.width), parseInt(tempTransCanvas.height)); + DAData.draw(img); + + var colorMode = $scope.applyGrayMatrix(img, tempCanvasContext); + + if (colorMode != undefined || colorMode != null) { + + var zeroPoint = new Point(); + + DAData.applyFilter(DAData, DAData.rect, zeroPoint, colorMode); + + + tempCanvasContext.putImageData(DAData.data, 0, 0); + + //keep the original image on temp canavs to use it in changing transparency + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { + var modestyTempCanvasId = 'tempCanvasModesty_' + bodyRegionId; + if (document.getElementById(modestyTempCanvasId) != undefined || document.getElementById(modestyTempCanvasId) != null) { + var contxModestyTemp = document.getElementById(modestyTempCanvasId).getContext('2d'); + var tbTempCanvas = document.getElementById(tempCanvasID) + contxModestyTemp.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage); + + } + } + else { + if (document.getElementById('tempCanvas') != null) { + + var contx = document.getElementById('tempCanvas').getContext('2d'); + var tbTempCanvas = document.getElementById(tempCanvasID) + contx.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage); + + } + } + + $scope.DrawOnTBWithSelectedTransparency(tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId); + } + } + } + + + $scope.DrawOnTBWithSelectedTransparency = function (tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId) { + + var transNumber = $scope.transNumber;//txtTransparencyChange.value; + //this changes the transparency when transparency is already activated and user resizes or chage the layer + + var tempCtx = document.getElementById(tempCanvasID).getContext('2d'); + + var imageD = tempCtx.getImageData(0, 0, Width, Height); + var imageData = imageD.data; + var length = imageData.length; + + + // set every fourth value to the desired number of transparency + for (var i = 3; i < length; i += 4) { + if ($scope.voId == "9" || $scope.voId == "11") { + + if (imageData[i] == 0) { + + } + else { + imageData[i] = ((255) * (parseInt(transNumber))) / 100; + } + } + else { + imageData[i] = ((255) * (parseInt(transNumber))) / 100; + } + } + + + tempCtx.putImageData(imageD, 0, 0); + + + $scope.widthOfImage = WidthforTransImage; + $scope.heightOfImage = HeightforTransImage; + $scope.xOfImage = XforTransImage; + $scope.yOfImage = YforTransImage; + + var ctx = transparencyCanvas.getContext('2d'); + + + var tmpCanvasContext = document.getElementById(tempCanvasID);//.getContext('2d'); + + + + var ctx; + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { + var modestyTransCanvasId = 'modestyTransCanavs_' + bodyRegionId + ctx = document.getElementById(modestyTransCanvasId).getContext('2d'); + } + else + ctx = transparencyCanvas.getContext('2d'); + + // var ctx = transparencyCanvas.getContext('2d'); + ctx.drawImage(tmpCanvasContext, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage) + + $scope.transparencyDrawnRegions.push(bodyRegionId); + + + $rootScope.isLoading = false; + $('#spinner').css('visibility', 'hidden'); + + if ($scope.transparencyDrawnRegions.length == $scope.IncludedBodyRegions.length) { + + transparencyCanvas.style.visibility = 'visible'; + $('.rectangle').remove(); + + + } + } + + $scope.changeTransparency = function () { //this changes the transparency when user click on transparency scale(we have already set the original //data on tras canvas irrespective of the trans number, so we can chnage the transparnecy of original data not the manipulated) @@ -4973,6 +5036,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo var BodyRegionDictionary = $rootScope.BodyRegionCordinatesData; $scope.IncludedBodyRegions = []; + $scope.transparencyDrawnRegions = []; // $scope.layerNo = parseInt(document.getElementById('')) var counter = 0; $.each(BodyRegionDictionary, function (index, value) { @@ -5482,7 +5546,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo ctx.putImageData(originalTransparencyData, 0, 0); - + $scope.transparencyDrawnRegions = []; //for modesty if ($rootScope.isModestyOn == true && $scope.modestyImageInfo.length > 0) { $.each($scope.modestyImageInfo, function (index, value) {