diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js index cf77512..d727321 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js @@ -742,7 +742,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo $rootScope.isLoading = true; $('#spinner').css('visibility', 'visible'); - + $scope.modestyImageInfo = []; // annotation toolbar canvas if ($("#canvasDiv").find("canvas[id='canvasPaint']").length == 0) { @@ -964,7 +964,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo if (($rootScope.globalSetting.modesty == 'Y')) { if ($('.modestyImg') != null) { - $('.modestyImg').css('visibility', 'visible'); + // $('.modestyImg').css('visibility', 'visible'); } } //set scrollbars on canvas and hide loading label @@ -1835,7 +1835,18 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo if (isMaskImage == 'N') { if (bodyRegionId == 'modestyImg3' || bodyRegionId == 'modestyImg2') { - //do nothing + $scope.modestyImageInfo.push( + + { + "bodyRegionId": bodyRegionId, "SRC": src, + "Height": h, + "Width": w, + "x": x, + "y": y, + "haveMirror": 'false' + } + + ); } else { @@ -3824,7 +3835,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo if (document.getElementById('tempCanvas') != null) { $('#tempCanvas').remove(); } - if (document.getElementById('tempCanvas') == null) { + if (document.getElementById('tempCanvas') == null || document.getElementById('tempCanvas') == undefined) { var tempCanvas = document.createElement('canvas'); tempCanvas.id = 'tempCanvas'; // $scope.tempCanvas = transparencyCanvas.id; @@ -3839,6 +3850,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo document.getElementById('canvasDiv').appendChild(tempCanvas); } + $scope.isTransparencyActivated = true; var BodyRegionDictionary = $rootScope.BodyRegionCordinatesData; @@ -3870,6 +3882,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo transparencyCanvas.style.top = $scope.startY + "px"//y + "px"; 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; @@ -3884,27 +3897,10 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo $(".ui-wrapper").css("z-index", "600"); - // $('#transparencyScale').modal('show'); - - //canvasDiv.removeEventListener('mouseup', arguments.callee); - //canvasDiv.removeEventListener('mousedown', arguments.callee); - //canvasDiv.removeEventListener('mousemove', arguments.callee); } if ($scope.TransparencyBoxStartX <= bodyRegionRight && value.X <= transparencyBoxRight && $scope.TransparencyBoxStartY <= bodyRegionBottom && value.Y <= transparencyBoxBottom) { - //if ($rootScope.voId != "9") { - // if ($rootScope.voId != "11") { - // $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.X, value.Y, value.IsMirror, $scope.TransparencyBoxStartX, TransparencyEndX, $scope.TransparencyBoxStartY, TransparencyBoxEndY, $scope, false, false); - - // } - - //} - //else { - // if (value.bodyRegionId == "6") { - // $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.X, value.Y, value.IsMirror, $scope.TransparencyBoxStartX, TransparencyEndX, $scope.TransparencyBoxStartY, TransparencyBoxEndY, $scope, false, false); - // } - //} if (($rootScope.voId == "9" || $rootScope.voId == "11")) { if (value.bodyRegionId == "6") { $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.X, value.Y, value.IsMirror, $scope.TransparencyBoxStartX, TransparencyEndX, $scope.TransparencyBoxStartY, TransparencyBoxEndY, $scope, false, false); @@ -3920,6 +3916,29 @@ 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); + + if ($scope.TransparencyBoxStartX <= bodyRegionRight && value.x <= transparencyBoxRight && $scope.TransparencyBoxStartY <= bodyRegionBottom && value.y <= transparencyBoxBottom) { + + $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.x, value.y, value.IsMirror, $scope.TransparencyBoxStartX, TransparencyEndX, $scope.TransparencyBoxStartY, TransparencyBoxEndY, $scope, false, false); + + } + }) + } + + + // + // $('#transparencyScale').modal('show'); $('#transparencyScale').css('position', 'fixed') $('#transparencyScale').css('top', $scope.TBDrawStartY - 10) @@ -3929,8 +3948,8 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo - document.getElementById('canvasDiv').removeEventListener("mousedown", mouseUpListener); - document.getElementById('canvasDiv').removeEventListener("mousemove", mouseUpListener); + document.getElementById('canvasDiv').removeEventListener("mousedown", mouseDownListener); + document.getElementById('canvasDiv').removeEventListener("mousemove", mouseMoveListener); document.getElementById('canvasDiv').removeEventListener("mouseup", mouseUpListener); // document.getElementById('canvasDiv').removeEventListener("mousemove", mouseMoveListener); @@ -3948,6 +3967,9 @@ 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'); @@ -3973,11 +3995,16 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo 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') } @@ -3990,6 +4017,10 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo 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') @@ -4000,6 +4031,12 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo 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') } @@ -4008,7 +4045,12 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo XforCopyImage = parseInt(TransparencyBoxStartX) - parseInt(X);//parseInt(X) + parseInt(Width) - parseInt(scope.TransparencyBoxStartX)// scope.TransparencyBoxStartX ; WidthforCopyImage = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX); WidthforTransImage = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX); - XforTransImage = 0 + 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) } @@ -4042,7 +4084,12 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo YforCopyImage = parseInt(TransparencyBoxStartY) - parseInt(Y); HeightforCopyImage = parseInt(Y) + parseInt(Height) - parseInt(TransparencyBoxStartY); HeightforTransImage = parseInt(Y) + parseInt(Height) - parseInt(TransparencyBoxStartY); - YforTransImage = 0; + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { + YforTransImage = parseInt(TransparencyBoxStartY) - parseInt(Y); + + } + else + YforTransImage = 0; } else if (TransparencyBoxStartY > Y && TransparencyBoxEndY < parseInt(Y) + parseInt(Height)) { @@ -4050,149 +4097,139 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo YforCopyImage = parseInt(TransparencyBoxStartY) - parseInt(Y); HeightforCopyImage = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY); HeightforTransImage = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY); - YforTransImage = 0; - } - - - //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) - if (isTransparencyChanged == true) { - - // var txtTransparencyChange = document.getElementById("txtTransparencyChange"); - - var transNumber = $scope.transNumber; - - var ctx = document.getElementById('transparencyCanvas').getContext('2d'); - - var imageDa = ctx.getImageData(XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage); + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { + YforTransImage = parseInt(TransparencyBoxStartY) - parseInt(Y); - // get the image data values - var imageData = imageDa.data; - var length = imageData.length; - // set every fourth value to 50 - for (var i = 3; i < length; i += 4) { - //NIKITA - 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; - } - - // imageData[i] = ((255) * (parseInt(transNumber))) / 100; } - // after the manipulation, reset the data - // imageDa.data = imageData; - // and put the imagedata back to the canvas - ctx.putImageData(imageDa, XforTransImage, YforTransImage); + else + YforTransImage = 0; + } + //0. get current layer number + if ($scope.isResized) { + //do nothing } - else { + else if (isLayerChanged) { - //0. get current layer number - if ($scope.isResized) { - //do nothing - } - else if (isLayerChanged) { - // alert('isMousUp on isLayerChanged'); + } + else { - //$scope.layerNumber = parseInt($('#txtlayerNumber').val()); - } - else { - //var currentLayer = parseInt($('#txtlayerNumber').val()); + var tranparencyLayer; - //var tranparencyLayer = currentLayer + 1; - //$scope.layerNumber = tranparencyLayer; + var currentLayer = $scope.layerNumberBeforeTrans; - var tranparencyLayer; + if (currentLayer == $rootScope.totalLayers) { - //var currentLayer = parseInt($('#txtlayerNumber').val()); - var currentLayer = $scope.layerNumberBeforeTrans; + tranparencyLayer = currentLayer; - if (currentLayer == $rootScope.totalLayers) { + } - tranparencyLayer = currentLayer; + else { - } + tranparencyLayer = currentLayer + 1; - else { + } - tranparencyLayer = currentLayer + 1; + $scope.layerNumber = tranparencyLayer; - } + } - $scope.layerNumber = tranparencyLayer; + $('#txtlayerNumber').val($scope.layerNumber); - } + //dedebugger; + var tranparencyImgSrc; + var tranparencyMaskImgSrc; + //for modesty image + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg')))// == "2" || bodyRegionId == "3")) { + { + var modestyBodyRegionData = new jinqJs() + .from($scope.modestyImageInfo) + .where('bodyRegionId == ' + bodyRegionId) + .select(); + tranparencyImgSrc = modestyBodyRegionData[0].SRC; + } - $('#txtlayerNumber').val($scope.layerNumber); + //modesty end - //dedebugger; //1. get the image source - var tranparencyImgSrc; + else { tranparencyImgSrc = $scope.GetImageSource(bodyRegionId); - var tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc); - // debugger; - var oldCanvas; - - if (IsMirror == 'Yes') { - oldCanvas = document.getElementById('transparencyTempCanvas_MR_' + bodyRegionId) - } - else { - oldCanvas = document.getElementById('transparencyTempCanvas_' + bodyRegionId) + tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc); + } + // var tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc); + // debugger; + var oldCanvas; - } + if (IsMirror == 'Yes') { + oldCanvas = document.getElementById('transparencyTempCanvas_MR_' + bodyRegionId) + } + else { + //if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { + // oldCanvas = document.getElementById('modestyTransparencyTempCanvas_' + bodyRegionId); + //} + //else { + oldCanvas = document.getElementById('transparencyTempCanvas_' + bodyRegionId) + //} + } - if (oldCanvas != null) { - document.getElementById('canvasDiv').removeChild(oldCanvas); - } + if (oldCanvas != null) { + document.getElementById('canvasDiv').removeChild(oldCanvas); + } - //remove tempmask canvas - var oldtempTransCanvasMask; - if (IsMirror == 'Yes') { - oldtempTransCanvasMask = document.getElementById('transparencyTempCanvasMask_MR_' + bodyRegionId + '_mci'); - } - else { - oldtempTransCanvasMask = document.getElementById('transparencyTempCanvasMask_' + bodyRegionId + '_mci'); + //remove tempmask canvas + var oldtempTransCanvasMask; + if (IsMirror == 'Yes') { + oldtempTransCanvasMask = document.getElementById('transparencyTempCanvasMask_MR_' + bodyRegionId + '_mci'); + } + else { + oldtempTransCanvasMask = document.getElementById('transparencyTempCanvasMask_' + bodyRegionId + '_mci'); - } - if (oldtempTransCanvasMask != null) { - document.getElementById('canvasDiv').removeChild(oldtempTransCanvasMask); - } + } + if (oldtempTransCanvasMask != null) { + document.getElementById('canvasDiv').removeChild(oldtempTransCanvasMask); + } - 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') { - transparencyTempCanvas.id = 'transparencyTempCanvas_MR_' + bodyRegionId; - transparencyTempcanavsMask.id = 'transparencyTempCanvasMask_MR' + bodyRegionId + '_mci'; + 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') { + transparencyTempCanvas.id = 'transparencyTempCanvas_MR_' + bodyRegionId; + transparencyTempcanavsMask.id = 'transparencyTempCanvasMask_MR' + bodyRegionId + '_mci'; + } + 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; transparencyTempcanavsMask.id = 'transparencyTempCanvasMask_' + bodyRegionId + '_mci'; - } - transparencyTempCanvas.height = Height; - transparencyTempCanvas.width = Width; - transparencyTempCanvas.style.position = "absolute"; - transparencyTempCanvas.style.left = X + 'px' // x + "px"; - transparencyTempCanvas.style.top = Y + "px"//y + "px"; - transparencyTempCanvas.style.visibility = 'hidden'; - //transparencyTempCanvas.style.visibility = 'visible'; - // transparencyCanvas.style.zIndex = 4000; - document.getElementById('canvasDiv').appendChild(transparencyTempCanvas); - //create temp mask canvas + } + transparencyTempCanvas.height = Height; + transparencyTempCanvas.width = Width; + 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 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { } + else { transparencyTempcanavsMask.height = Height; transparencyTempcanavsMask.width = Width; transparencyTempcanavsMask.style.position = "absolute"; @@ -4202,14 +4239,58 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo //transparencyTempCanvas.style.visibility = 'visible'; // transparencyCanvas.style.border = "black 1px solid"; document.getElementById('canvasDiv').appendChild(transparencyTempcanavsMask); + } + //for modesty canvas + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { + var modestyTransTempCanvasId = 'tempCanvasModesty_' + bodyRegionId; + var modestyTransCanvasId = 'modestyTransCanavs_' + bodyRegionId; + if (document.getElementById(modestyTransTempCanvasId) != null) { + document.getElementById(modestyTransTempCanvasId).parentNode.removeChild(document.getElementById(modestyTransTempCanvasId)); + } + + 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"; + tempCanvasModesty.style.left = 10 + 'px'; + tempCanvasModesty.style.top = 10 + 'px'; + tempCanvasModesty.style.backgroundColor = "transparent"; + tempCanvasModesty.style.visibility = 'hidden'; + tempCanvasModesty.style.border = "black 1px solid"; + document.getElementById('canvasDiv').appendChild(tempCanvasModesty); + } + if (document.getElementById(modestyTransCanvasId) != null) { + document.getElementById(modestyTransCanvasId).parentNode.removeChild(document.getElementById(modestyTransCanvasId)); + } + + 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 = '10000' + // tempcanvasModestyCanvasModesty.style.border = "black 1px solid"; + document.getElementById('canvasDiv').appendChild(canvasModesty); + } + } + + if (tranparencyImgSrc != undefined) { var tempImg = new Image(); - tempImg.src = tranparencyImgSrc;//"http://localhost/AIA/" + tranparencyImgSrc; tempImg.onload = function () { - // debugger; + debugger; var tempCtx = transparencyTempCanvas.getContext('2d'); if (IsMirror == 'Yes') { @@ -4230,14 +4311,18 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo tempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId; } else { - tempCanvasID = 'transparencyTempCanvas_' + bodyRegionId; + 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; + var transNumber = 50;//$scope.transNumber;//txtTransparencyChange.value; // debugger; //this changes the transparency when transparency is already activated and user resizes or chage the layer @@ -4248,11 +4333,31 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo //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); + + //if (document.getElementById(modestyTransTempCanvasId) != undefined || document.getElementById(modestyTransTempCanvasId) != null) { + // var contxModesty = document.getElementById(modestyTransTempCanvasId).getContext('2d'); + // var tbTempCanvas = document.getElementById(tempCanvasID) + // contx.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage); + + //} + 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 @@ -4275,15 +4380,24 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } } else { - imageData[i] = ((255) * (parseInt(transNumber))) / 100; + if (imageData[i] == 0) { + + } + else { + imageData[i] = ((255) * (parseInt(transNumber))) / 100; + } } } tempCtx.putImageData(imageD, 0, 0); - - var ctx = transparencyCanvas.getContext('2d'); + var ctx; + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { + ctx = document.getElementById(modestyTransCanvasId).getContext('2d'); + } + else + ctx = transparencyCanvas.getContext('2d'); var TrtempCanvasID @@ -4291,6 +4405,10 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo TrtempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId; } else { + //if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { + // TrtempCanvasID = 'modestyTransparencyTempCanvas_' + bodyRegionId; + //} + //else TrtempCanvasID = 'transparencyTempCanvas_' + bodyRegionId; } @@ -4310,47 +4428,105 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo PreviousBodyRegionHeight = 0; } + tempImg.src = tranparencyImgSrc;//"http://localhost/AIA/" + tranparencyImgSrc; + } - //mask image code - //draw mask for annotation - var tempMaskImg = new Image(); - var tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc); - tempMaskImg.src = tranparencyMaskImgSrc;//"http://localhost/AIA/" + tranparencyMaskImgSrc; - tempMaskImg.onload = function () { - // debugger; - var tempmaskCtx = transparencyTempcanavsMask.getContext('2d'); - - if (IsMirror == 'Yes') { - //debugger; - tempmaskCtx.save(); - tempmaskCtx.translate(Width, 0); - tempmaskCtx.scale(-1, 1); - tempmaskCtx.drawImage(tempMaskImg, 0, 0); - } - else { - tempmaskCtx.drawImage(tempMaskImg, 0, 0); - } + //mask image code + //draw mask for annotation + var tempMaskImg = new Image(); + var tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc); + tempMaskImg.src = tranparencyMaskImgSrc;//"http://localhost/AIA/" + tranparencyMaskImgSrc; + tempMaskImg.onload = function () { + // debugger; + var tempmaskCtx = transparencyTempcanavsMask.getContext('2d'); + if (IsMirror == 'Yes') { + //debugger; + tempmaskCtx.save(); + tempmaskCtx.translate(Width, 0); + tempmaskCtx.scale(-1, 1); + tempmaskCtx.drawImage(tempMaskImg, 0, 0); + } + else { + tempmaskCtx.drawImage(tempMaskImg, 0, 0); } - PreviousBodyRegionHeight = HeightforTransImage; - PreviousBodyRegionY = YforTransImage; - PreviousBodyRegionWidth = WidthforTransImage; - PreviousBodyRegionX = XforTransImage; - previousBodyRegionId = bodyRegionId; + } - // $scope.layerNumber = parseInt($scope.layerNumber - 1); - } + PreviousBodyRegionHeight = HeightforTransImage; + PreviousBodyRegionY = YforTransImage; + PreviousBodyRegionWidth = WidthforTransImage; + PreviousBodyRegionX = XforTransImage; + previousBodyRegionId = bodyRegionId; + + // $scope.layerNumber = parseInt($scope.layerNumber - 1); + + //} } + $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) + // if (isTransparencyChanged == true) { + + // var txtTransparencyChange = document.getElementById("txtTransparencyChange"); + //var modestyTransCanvases = $("canvas[id*='modestyTransCanavs']"); + //if (modestyTransCanvases != null || modestyTransCanvases != undefined && modestyTransCanvases.length > 0) { + // debugger + // for (var j = 0; j < modestyTransCanvases.length; j++) { + // var ctx = document.getElementById(modestyTransCanvases[j]).getContext('2d'); + // var ImgData = ctx.getImageData(XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage); + // //modestyTransCanvases[j].parentNode.removeChild(modestyTransCanvases[j]); + // } + //} + var transNumber = $scope.transNumber; + var ctx = document.getElementById('transparencyCanvas').getContext('2d'); + + // var imageDa = ctx.getImageData(XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage); + var imageDa = ctx.getImageData(0, 0, $scope.transparencyCanvasWidth, $scope.transparencyCanvasHeight); + + // get the image data values + var imageData = imageDa.data; + var length = imageData.length; + // set every fourth value to 50 + for (var i = 3; i < length; i += 4) { + //NIKITA + if ($scope.voId == "9" || $scope.voId == "11") { + + if (imageData[i] == 0) { + + } + else { + imageData[i] = ((255) * (parseInt(transNumber))) / 100; + } + } + else { + if (imageData[i] == 0) { + + } + else + imageData[i] = ((255) * (parseInt(transNumber))) / 100; + } + + // imageData[i] = ((255) * (parseInt(transNumber))) / 100; + } + // after the manipulation, reset the data + // imageDa.data = imageData; + // and put the imagedata back to the canvas + //ctx.putImageData(imageDa, XforTransImage, YforTransImage); + ctx.putImageData(imageDa, 0, 0); + + + //} + } @@ -4380,6 +4556,22 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } + var modestyTransCanvases = $("canvas[id*='modestyTransCanavs']"); + if (modestyTransCanvases != null || modestyTransCanvases != undefined && modestyTransCanvases.length > 0) { + for (var j = 0; j < modestyTransCanvases.length; j++) { + + modestyTransCanvases[j].parentNode.removeChild(modestyTransCanvases[j]); + } + } + + var modestyTempCanvases = $("canvas[id*='tempCanvasModesty_']"); + if (modestyTempCanvases != null || modestyTransCanvases != undefined && modestyTransCanvases.length > 0) { + for (var j = 0; j < modestyTempCanvases.length; j++) { + + modestyTempCanvases[j].parentNode.removeChild(modestyTempCanvases[j]); + } + } + $scope.isResized = true; @@ -4395,10 +4587,16 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo transparencyCanvas.style.left = tCanvas.style.left; // x + "px"; transparencyCanvas.style.top = tCanvas.style.top//y + "px"; transparencyCanvas.style.border = "black 1px solid"; + transparencyCanvas.style.zIndex = 200; + + document.getElementById('canvasDiv').appendChild(transparencyCanvas); $('#transparencyCanvas').resizable({ handles: "e,s,se,w,n,ne,nw,sw", stop: function (event, ui) { resizeCanvas(); }, start: function (event, ui) { clearTransCanvas(); } }); + $(".ui-wrapper").css("z-index", "600"); + //bind click listener + transparencyCanvas.addEventListener('click', TransparencyCanvasClickListener); } $scope.transparencyCanvasHeight = tCanvasHeight; $scope.transparencyCanvasWidth = tCanvasWidth; @@ -4449,17 +4647,39 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo }) - //bind click listener - //bind click listener - transparencyCanvas.addEventListener('click', TransparencyCanvasClickListener); + + + //for modesty + if ($rootScope.isModestyOn == true && $scope.modestyImageInfo.length > 0) { + $.each($scope.modestyImageInfo, function (index, value) { + // alert(' $.each(BodyRegionDictionary1') + + + var bodyRegionRight = parseInt(value.x) + parseInt(value.Width); + var bodyRegionBottom = parseInt(value.y) + parseInt(value.Height); + var TBRight = parseInt((document.getElementById('transparencyCanvas').style.left).replace('px', '')) + parseInt((document.getElementById('transparencyCanvas').style.width).replace('px', '')); + var TBBottom = parseInt((document.getElementById('transparencyCanvas').style.top).replace('px', '')) + parseInt((document.getElementById('transparencyCanvas').style.height).replace('px', '')); + var TBStartX = parseInt((document.getElementById('transparencyCanvas').style.left).replace('px', '')); + var TBStartY = parseInt((document.getElementById('transparencyCanvas').style.top).replace('px', '')); + + if (TBStartX <= bodyRegionRight && value.x <= TBRight && TBStartY <= bodyRegionBottom && value.y <= TBBottom) { + + + $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.x, value.y, value.IsMirror, $scope.TransparencyBoxStartX, $scope.TransparencyEndX, $scope.TransparencyBoxStartY, $scope.TransparencyBoxEndY, $scope, false, false); + + } + }) + } + // }); - $(".ui-wrapper").css("z-index", "600"); + //$(".ui-wrapper").css("z-index", "600"); $scope.isResized = false; } + function TransparencyCanvasClickListener(evt) { //alert('tb clicked') // debugger; @@ -4841,9 +5061,9 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo $scope.CloseTransparencyBox = function () { - + //To enable extract button - $scope.isTransparencyActivated = false; + $scope.isTransparencyActivated = false; $("#btnExtract").removeClass("disabled"); //$('.com_anno').css('display', 'none'); @@ -4887,7 +5107,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo //var scope = angular.element(document.getElementById("DAView")).scope(); //scope.$apply(function () { // $scope.layerNumber = 0; - // $scope.isTransparencyActivated = false; + // $scope.isTransparencyActivated = false; //}) @@ -4904,6 +5124,16 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo $scope.transNumber = 50; $(".slider").slider({ value: 50 }) } + + + var modestyTransCanvases = $("canvas[id*='modestyTransCanavs']"); + if (modestyTransCanvases != null || modestyTransCanvases != undefined && modestyTransCanvases.length > 0) { + for (var j = 0; j < modestyTransCanvases.length; j++) { + + modestyTransCanvases[j].parentNode.removeChild(modestyTransCanvases[j]); + } + } + $('#transparencyScale').css('visibility', 'hidden'); //$scope.isTransparencyActivated = false; @@ -4960,6 +5190,48 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo }) }; + $scope.createSpeechBubbleOnTransparencyBox = function (event, text1, text2, x, y) { + + $('#canvasDiv').css('cursor', 'pointer'); + $('