From d623ff518ab277c8d6043ddfef9f78ba11a9fb2e Mon Sep 17 00:00:00 2001 From: nikita Date: Wed, 1 Feb 2017 11:48:00 +0530 Subject: [PATCH] working merged code for noraml and highlight mode. Issue in modesty --- 400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js | 558 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 file changed, 299 insertions(+), 259 deletions(-) diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js index 119a4f5..2374fe9 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js @@ -3967,6 +3967,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo var BodyRegionDictionary = $rootScope.BodyRegionCordinatesData; $scope.IncludedBodyRegions = []; + $scope.transparencyDrawnRegions = []; ////debugger; $.each(BodyRegionDictionary, function (index, value) { // alert(' $.each(BodyRegionDictionary1') @@ -4078,11 +4079,8 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } $scope.loadTransparencyImage = function (bodyRegionId, Height, Width, X, Y, IsMirror, TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, scope, isLayerChanged, isTransparencyChanged) { - // debugger; - - // else { + - var scope1 = angular.element(document.getElementById("DAView")).scope(); var transparencyCanvas = document.getElementById('transparencyCanvas'); TransparencyBoxStartX = parseInt((transparencyCanvas.style.left).replace('px', '')); @@ -4091,140 +4089,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 dimensions = $scope.calculateCoordinatesAndDimensionsForTB(Height, Width, X, Y, IsMirror, TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, bodyRegionId); + var XforCopyImage = dimensions.XforCopyImageTB; + var YforCopyImage = dimensions.YforCopyImageTB; + var WidthforCopyImage = dimensions.WidthforCopyImageTB; + var HeightforCopyImage = dimensions.HeightforCopyImageTB; + var XforTransImage = dimensions.XforTransImageTB; + var WidthforTransImage = dimensions.WidthforTransImageTB; + var HeightforTransImage = dimensions.HeightforTransImageTB; + var YforTransImage = dimensions.YforTransImageTB; //0. get current layer number if ($scope.isResized) { @@ -4235,8 +4109,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } else { - - + var tranparencyLayer; var currentLayer = $scope.layerNumberBeforeTrans; @@ -4259,7 +4132,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo $('#txtlayerNumber').val($scope.layerNumber); - //dedebugger; + var tranparencyImgSrc; var tranparencyMaskImgSrc; //for modesty image @@ -4280,8 +4153,8 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo tranparencyImgSrc = $scope.GetImageSource(bodyRegionId); tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc); } - // var tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc); - // debugger; + + var oldCanvas; if (IsMirror == 'Yes') { @@ -4316,7 +4189,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo 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') { @@ -4326,8 +4199,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; @@ -4340,14 +4212,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 @@ -4359,8 +4226,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); } @@ -4376,7 +4242,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"; @@ -4394,18 +4259,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); } } @@ -4418,17 +4280,29 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo var tempCtx = transparencyTempCanvas.getContext('2d'); if (IsMirror == 'Yes') { - //debugger; tempCtx.save(); tempCtx.translate(Width, 0); tempCtx.scale(-1, 1); tempCtx.drawImage(tempImg, 0, 0); + + if ($rootScope.isHighLight == true) { + var tempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId; + $scope.highlightTempTransparencyCanvas(tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, + XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId); + } } else { tempCtx.drawImage(tempImg, 0, 0); + var tempCanvasID = 'transparencyTempCanvas_' + bodyRegionId; + + if ($rootScope.isHighLight == true) { + $scope.highlightTempTransparencyCanvas(tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, + YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId); + + } + } - // debugger; var tempCanvasID; if (IsMirror == 'Yes') { @@ -4443,106 +4317,33 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } - //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); - - } - } - 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); - - } - } - - // get the image data values - - 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 contxModesty = document.getElementById(modestyTempCanvasId).getContext('2d'); + var tbTempCanvas = document.getElementById(tempCanvasID) + contxModesty.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; @@ -4550,7 +4351,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } - //mask image code //draw mask for annotation var tempMaskImg = new Image(); @@ -4575,14 +4375,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 @@ -4620,6 +4412,253 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } + + $scope.calculateCoordinatesAndDimensionsForTB = 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 (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) @@ -4917,6 +4956,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) { @@ -5426,7 +5466,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) { -- libgit2 0.21.4