diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js index 6b58486..c5e2236 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js @@ -20,7 +20,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo $scope.layerNumber; $scope.daCounter = 1; $scope.bagartDetails; - + $scope.transNumber = 50; $scope.isBodylayerdataLoaded = false; $scope.isBodyRegionDataLoaded = false; @@ -1518,6 +1518,9 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } }) + + $('#transparencyScale').modal('show'); + document.getElementById('canvasDiv').removeEventListener("mouseup", mouseUpListener); } @@ -1633,9 +1636,9 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo //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 txtTransparencyChange = document.getElementById("txtTransparencyChange"); - var transNumber = txtTransparencyChange.value; + var transNumber = $scope.transNumber; var ctx = document.getElementById('transparencyCanvas').getContext('2d'); @@ -1768,22 +1771,22 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } + // niki 3june + //var txtTransparencyChange = document.getElementById("txtTransparencyChange"); + ////for first time, the transparency should be 50% + //if ($scope.isTboxDrwan) { - var txtTransparencyChange = document.getElementById("txtTransparencyChange"); - //for first time, the transparency should be 50% - if ($scope.isTboxDrwan) { + // if (txtTransparencyChange != null) + // txtTransparencyChange.value = 50; - if (txtTransparencyChange != null) - txtTransparencyChange.value = 50; + // $scope.isTboxDrwan = false; - $scope.isTboxDrwan = false; - - } + //} //check if transparency is activated - var transNumber = 50;//txtTransparencyChange.value; + var transNumber = $scope.transNumber;//txtTransparencyChange.value; // debugger; //this changes the transparency when transparency is already activated(on scale the value is >0) and user resizes or chage the layer @@ -2264,6 +2267,94 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } + $scope.onTransparencyChange = function(ev, ui){ + debugger; + alert('t change') + $scope.transNumber = ui.value; + + var tCanvas = document.getElementById('transparencyCanvas'); + var tCanvasContext = tCanvas.getContext('2d'); + + var tCanvasHeight = parseInt((tCanvas.style.height).replace('px', '')); + + var tCanvasWidth = parseInt((tCanvas.style.width).replace('px', '')); + + var tBoxStartX = parseInt((tCanvas.style.left).replace('px', '')); + var tBoxEndX = parseInt((tCanvas.style.left).replace('px', '')) + parseInt((tCanvas.style.width.replace('px', ''))); + var tBoxStartY = parseInt((tCanvas.style.top).replace('px', '')); + var tBoxEndY = parseInt((tCanvas.style.top).replace('px', '')) + parseInt((tCanvas.style.height).replace('px', '')); + var transparencyBoxBottom = parseInt(tBoxStartY) + parseInt(tCanvasHeight); + var transparencyBoxRight = parseInt(tBoxStartX) + parseInt(tCanvasWidth); + + //var scope = angular.element(document.getElementById("DAView")).scope(); + //scope.$apply(function () { + var arr = []; + $scope.transparencyChangeCounter++; + //before changing the transparency of first canvas, hold the orignal canvas data on temp canvas + + //put original data on transcanvas so that it can be used to change transparency properly + var tempCanavs = document.getElementById('tempCanvas'); + var tempCanvasContext = tempCanavs.getContext('2d'); + + var originalTransparencyData = tempCanvasContext.getImageData(0, 0, $scope.transparencyCanvasWidth, $scope.transparencyCanvasHeight); + var ctx = document.getElementById('transparencyCanvas').getContext('2d'); + ctx.putImageData(originalTransparencyData, 0, 0); + + + var BodyRegionDictionary = $scope.BodyRegionCordinatesData; + + $scope.IncludedBodyRegions = []; + var counter = 0; + $.each(BodyRegionDictionary, function (index, value) { + + var bodyRegionRight = parseInt(value.X) + parseInt(value.Width); + var bodyRegionBottom = parseInt(value.Y) + parseInt(value.Height); + + + + if (tBoxStartX <= bodyRegionRight && value.X <= transparencyBoxRight && tBoxStartY <= bodyRegionBottom && value.Y <= transparencyBoxBottom) { + + $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.X, value.Y, value.IsMirror, $scope.TransparencyBoxStartX, $scope.TransparencyEndX, $scope.TransparencyBoxStartY, $scope.TransparencyBoxEndY, $scope, false, true); + + } + + }); + + + + // }); + } + + $scope.CloseTransparencyBox = function () { + var tBox = document.getElementById('transparencyCanvas'); + + // alert('mouseDown is called'); + if (tBox != null) { + tBox.parentNode.removeChild(tBox) + var elements = document.getElementsByClassName('ui-icon ui-icon-gripsmall-diagonal-se'); + while (elements.length > 0) { + elements[0].parentNode.removeChild(elements[0]); + } + var txtTransparencyChange = document.getElementById("txtTransparencyChange"); + txtTransparencyChange.value = 0; + document.getElementById('txtLayerNumber').value = 0; + $('#sliderHandle').tabindex = 0; + if (document.getElementById('tempCanvas') != null) { + $('#tempCanvas').remove(); + } + if ($('#speechBubbleTrns').length > 0) { + $('#speechBubbleTrns').remove(); + } + //var scope = angular.element(document.getElementById("DAView")).scope(); + //scope.$apply(function () { + $scope.layerNumber = 0; + $scope.isTransparencyActivated = false; + //}) + } + document.getElementById('btnTranparency').removeEventListener("click", onTransparencyButtonClick); + document.getElementById('btnTranparency').className = 't-transparency' + } + $scope.createSpeechBubbleOnTransparencyBox = function (event, text1, text2, x, y) { $('#canvasDiv').css('cursor', 'pointer'); diff --git a/400-SOURCECODE/AIAHTML5.Web/app/views/da/da-view.html b/400-SOURCECODE/AIAHTML5.Web/app/views/da/da-view.html index 9d6ea02..a7d9595 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/views/da/da-view.html +++ b/400-SOURCECODE/AIAHTML5.Web/app/views/da/da-view.html @@ -1,4 +1,19 @@ -