diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js index d2e93f5..8b9b25c 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js @@ -4809,33 +4809,41 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo //debugger; - var oldMirrorMaskId = 'transparencyTempCanvasMask_' + clickedBodyRegion + '_mci'; - var oldMirrorMask = document.getElementById(oldMirrorMaskId); - if (oldMirrorMask != null) { - document.getElementById('canvasDiv').removeChild(oldMirrorMask); + var maskCanvasId = 'transparencyTempCanvasMask_' + clickedBodyRegion + '_mci'; + var maskCanvas = document.getElementById(maskCanvasId); + //if (oldMirrorMask != null) { + // document.getElementById('canvasDiv').removeChild(oldMirrorMask); + //} + if (maskCanvas != null) { + x = maskCanvas.style.left; + y = maskCanvas.style.top; + } + if (maskCanvas == null) { + var transparencyTempcanavsMask = document.createElement('canvas'); + transparencyTempcanavsMask.id = 'transparencyTempCanvasMask_' + clickedBodyRegion + '_mci'; + transparencyTempcanavsMask.height = nomMirroredBodyRegion[0].Height; + transparencyTempcanavsMask.width = nomMirroredBodyRegion[0].Width; + transparencyTempcanavsMask.style.position = "absolute"; + transparencyTempcanavsMask.style.left = nomMirroredBodyRegion[0].X + 'px' // x + "px"; + transparencyTempcanavsMask.style.top = nomMirroredBodyRegion[0].Y + "px"//y + "px"; + transparencyTempcanavsMask.style.visibility = 'hidden'; + + document.getElementById('canvasDiv').appendChild(transparencyTempcanavsMask); + + var tranparencyImgSrc = $scope.GetImageSource(clickedBodyRegion); + var tempMaskImg = new Image(); + var tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc); + tempMaskImg.onload = function () { + var transparencyTempcanavsMask = document.getElementById(maskCanvasId); + var tempmaskCtx = transparencyTempcanavsMask.getContext('2d'); + tempmaskCtx.drawImage(tempMaskImg, 0, 0); + + //get x,y of non mirrored canvas for this body region + x = transparencyTempcanavsMask.style.left; + y = transparencyTempcanavsMask.style.top; + } + tempMaskImg.src = "http://localhost/AIAHtml/" + tranparencyMaskImgSrc; } - var transparencyTempcanavsMask = document.createElement('canvas'); - transparencyTempcanavsMask.id = 'transparencyTempCanvasMask_' + clickedBodyRegion + '_mci'; - transparencyTempcanavsMask.height = nomMirroredBodyRegion[0].Height; - transparencyTempcanavsMask.width = nomMirroredBodyRegion[0].Width; - transparencyTempcanavsMask.style.position = "absolute"; - transparencyTempcanavsMask.style.left = nomMirroredBodyRegion[0].X + 'px' // x + "px"; - transparencyTempcanavsMask.style.top = nomMirroredBodyRegion[0].Y + "px"//y + "px"; - transparencyTempcanavsMask.style.visibility = 'hidden'; - - document.getElementById('canvasDiv').appendChild(transparencyTempcanavsMask); - - var tranparencyImgSrc = $scope.GetImageSource(clickedBodyRegion); - var tempMaskImg = new Image(); - var tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc); - tempMaskImg.onload = function () { - var tempmaskCtx = transparencyTempcanavsMask.getContext('2d'); - tempmaskCtx.drawImage(tempMaskImg, 0, 0); - - //get x,y of non mirrored canvas for this body region - x = transparencyTempcanavsMask.style.left; - y = transparencyTempcanavsMask.style.top; - var maskCanvasTransId = 'transparencyTempCanvasMask_' + clickedBodyRegion + '_mci'; var maskCanvastrans = document.getElementById(maskCanvasTransId); var maskCanvasContexttrans = maskCanvastrans.getContext("2d"); @@ -4859,8 +4867,8 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo var clickedCanvasMaskId = 'imageCanvas' + clickedBodyRegion + '_mci'; var maskCanvas = document.getElementById(clickedCanvasMaskId); var maskCanvasContext = maskCanvas.getContext("2d"); - var imgX = Math.round(actulalX - parseInt(x.replace('px', ''))); - var imgY = Math.round(actualY - parseInt(y.replace('px', ''))); + var imgX = Math.round(actulalX - parseInt(x));//.replace('px', ''))); + var imgY = Math.round(actualY - parseInt(y));//.replace('px', ''))); pixelData = maskCanvasContext.getImageData(imgX, imgY, 1, 1); @@ -4894,9 +4902,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo $scope.annotationTextArrayT2.push(annotations.annotationT2); $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, false); - } - tempMaskImg.src = "http://localhost/AIAHtml/" + tranparencyMaskImgSrc; - + }