Commit 0c2414b6b6cd0f072c1c3495b19c4e4d0ca9155c

Authored by Nikita Kulshreshtha
2 parents 8a21167f 625f3c3d

Merge branch 'TBHighlight5' of http://52.6.196.163/ADAM/AIAHTML5 into TBhighlight5Merge

400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js
@@ -3968,8 +3968,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -3968,8 +3968,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
3968 function mouseUpListener(e) { 3968 function mouseUpListener(e) {
3969 3969
3970 $scope.isTBDrawnOnBodyRegion = false; 3970 $scope.isTBDrawnOnBodyRegion = false;
3971 - //alert('mouse up');  
3972 - console.log('MOUSE UP'); 3971 +
3973 $(".com").remove(); 3972 $(".com").remove();
3974 $('#dot').remove(); 3973 $('#dot').remove();
3975 $('#bord').remove(); 3974 $('#bord').remove();
@@ -3981,12 +3980,10 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -3981,12 +3980,10 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
3981 var currentMousePosition = $scope.getMousePos(e); 3980 var currentMousePosition = $scope.getMousePos(e);
3982 3981
3983 3982
3984 - var canvasDiv = document.getElementById('canvasDiv');  
3985 - var verticalScrollPosition = canvasDiv.scrollTop;  
3986 - var horizontlScrollPosition = canvasDiv.scrollLeft; 3983 + var canavsDivScrollPos = $scope.getCanavsDivScrollPosition();
3987 3984
3988 - var TransparencyEndX = currentMousePosition.x + horizontlScrollPosition  
3989 - var TransparencyBoxEndY = currentMousePosition.y + verticalScrollPosition 3985 + var TransparencyEndX = currentMousePosition.x + canavsDivScrollPos.horizontlScrollPosition;
  3986 + var TransparencyBoxEndY = currentMousePosition.y + canavsDivScrollPos.verticalScrollPosition;
3990 3987
3991 3988
3992 $scope.isTboxDrwan = true; 3989 $scope.isTboxDrwan = true;
@@ -3995,7 +3992,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -3995,7 +3992,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
3995 $scope.TransparencyEndX = TransparencyEndX; 3992 $scope.TransparencyEndX = TransparencyEndX;
3996 $scope.TransparencyBoxEndY = TransparencyBoxEndY; 3993 $scope.TransparencyBoxEndY = TransparencyBoxEndY;
3997 3994
3998 - $scope.layerNumberBeforeTrans = parseInt($('#txtlayerNumber').val()); 3995 + $scope.layerNumberBeforeTBDraw = parseInt($('#txtlayerNumber').val());
3999 3996
4000 //draw temp box to store the canvas data with original transparecy 3997 //draw temp box to store the canvas data with original transparecy
4001 if (document.getElementById('tempCanvas') != null) { 3998 if (document.getElementById('tempCanvas') != null) {
@@ -4022,18 +4019,19 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -4022,18 +4019,19 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4022 var BodyRegionDictionary = $rootScope.BodyRegionCordinatesData; 4019 var BodyRegionDictionary = $rootScope.BodyRegionCordinatesData;
4023 4020
4024 $scope.IncludedBodyRegions = []; 4021 $scope.IncludedBodyRegions = [];
4025 - ////debugger; 4022 + $scope.transparencyDrawnRegions = [];
  4023 +
4026 $.each(BodyRegionDictionary, function (index, value) { 4024 $.each(BodyRegionDictionary, function (index, value) {
4027 - // alert(' $.each(BodyRegionDictionary1')  
4028 - var transparencyBoxHeight = parseInt(TransparencyBoxEndY) - parseInt($scope.TransparencyBoxStartY);  
4029 - var transparencyBoxWidth = parseInt(TransparencyEndX) - parseInt($scope.TransparencyBoxStartX);  
4030 - var transparencyBoxBottom = parseInt($scope.TransparencyBoxStartY) + parseInt(transparencyBoxHeight);  
4031 - var transparencyBoxRight = parseInt($scope.TransparencyBoxStartX) + parseInt(transparencyBoxWidth);  
4032 - // alert(' $.each(BodyRegionDictionary2. transparencyBoxHeight: ' + transparencyBoxHeight + ',transparencyBoxBottom: ' + transparencyBoxBottom+', transparencyBoxRight: '+transparencyBoxRight)  
4033 - var bodyRegionRight = parseInt(value.X) + parseInt(value.Width);  
4034 - var bodyRegionBottom = parseInt(value.Y) + parseInt(value.Height); 4025 +
4035 4026
  4027 + var tBoxDimesions = $scope.getTBoxDimesions($scope.TransparencyBoxStartX, TransparencyEndX, $scope.TransparencyBoxStartY, TransparencyBoxEndY, value.X, value.Y, value.Height, value.Width);
4036 4028
  4029 + var transparencyBoxHeight = tBoxDimesions.transparencyBoxHeight;
  4030 + var transparencyBoxWidth = tBoxDimesions.transparencyBoxWidth;
  4031 + var transparencyBoxBottom = tBoxDimesions.transparencyBoxBottom;
  4032 + var transparencyBoxRight = tBoxDimesions.transparencyBoxRight;
  4033 + var bodyRegionRight = tBoxDimesions.bodyRegionRight;
  4034 + var bodyRegionBottom = tBoxDimesions.bodyRegionBottom;
4037 4035
4038 var transparencyCanvas = document.createElement('canvas'); 4036 var transparencyCanvas = document.createElement('canvas');
4039 var tBox = document.getElementById('transparencyCanvas'); 4037 var tBox = document.getElementById('transparencyCanvas');
@@ -4049,7 +4047,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -4049,7 +4047,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4049 transparencyCanvas.style.border = "black 1px solid"; 4047 transparencyCanvas.style.border = "black 1px solid";
4050 transparencyCanvas.style.backgroundColor = "transparent"; 4048 transparencyCanvas.style.backgroundColor = "transparent";
4051 transparencyCanvas.style.zIndex = 200; 4049 transparencyCanvas.style.zIndex = 200;
4052 - // transparencyCanvas.style.visibility = 'hidden';  
4053 document.getElementById('canvasDiv').appendChild(transparencyCanvas); 4050 document.getElementById('canvasDiv').appendChild(transparencyCanvas);
4054 $scope.transparencyChangeCounter = 0; 4051 $scope.transparencyChangeCounter = 0;
4055 4052
@@ -4086,14 +4083,15 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -4086,14 +4083,15 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4086 //for modesty 4083 //for modesty
4087 if ($rootScope.isModestyOn == true && $scope.modestyImageInfo.length > 0) { 4084 if ($rootScope.isModestyOn == true && $scope.modestyImageInfo.length > 0) {
4088 $.each($scope.modestyImageInfo, function (index, value) { 4085 $.each($scope.modestyImageInfo, function (index, value) {
4089 - // alert(' $.each(BodyRegionDictionary1')  
4090 - var transparencyBoxHeight = parseInt(TransparencyBoxEndY) - parseInt($scope.TransparencyBoxStartY);  
4091 - var transparencyBoxWidth = parseInt(TransparencyEndX) - parseInt($scope.TransparencyBoxStartX);  
4092 - var transparencyBoxBottom = parseInt($scope.TransparencyBoxStartY) + parseInt(transparencyBoxHeight);  
4093 - var transparencyBoxRight = parseInt($scope.TransparencyBoxStartX) + parseInt(transparencyBoxWidth);  
4094 - // alert(' $.each(BodyRegionDictionary2. transparencyBoxHeight: ' + transparencyBoxHeight + ',transparencyBoxBottom: ' + transparencyBoxBottom+', transparencyBoxRight: '+transparencyBoxRight)  
4095 - var bodyRegionRight = parseInt(value.x) + parseInt(value.Width);  
4096 - var bodyRegionBottom = parseInt(value.y) + parseInt(value.Height); 4086 +
  4087 + var tBoxDimesions = $scope.getTBoxDimesions($scope.TransparencyBoxStartX, TransparencyEndX, $scope.TransparencyBoxStartY, TransparencyBoxEndY, value.x, value.y, value.Height, value.Width);
  4088 +
  4089 + var transparencyBoxHeight = tBoxDimesions.transparencyBoxHeight;
  4090 + var transparencyBoxWidth = tBoxDimesions.transparencyBoxWidth;
  4091 + var transparencyBoxBottom = tBoxDimesions.transparencyBoxBottom;
  4092 + var transparencyBoxRight = tBoxDimesions.transparencyBoxRight;
  4093 + var bodyRegionRight = tBoxDimesions.bodyRegionRight;
  4094 + var bodyRegionBottom = tBoxDimesions.bodyRegionBottom;
4097 4095
4098 if ($scope.TransparencyBoxStartX <= bodyRegionRight && value.x <= transparencyBoxRight && $scope.TransparencyBoxStartY <= bodyRegionBottom && value.y <= transparencyBoxBottom) { 4096 if ($scope.TransparencyBoxStartX <= bodyRegionRight && value.x <= transparencyBoxRight && $scope.TransparencyBoxStartY <= bodyRegionBottom && value.y <= transparencyBoxBottom) {
4099 4097
@@ -4132,12 +4130,37 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -4132,12 +4130,37 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4132 $('#btnIdentity').addClass('btn-primary'); 4130 $('#btnIdentity').addClass('btn-primary');
4133 } 4131 }
4134 4132
4135 - $scope.loadTransparencyImage = function (bodyRegionId, Height, Width, X, Y, IsMirror, TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, scope, isLayerChanged, isTransparencyChanged) {  
4136 - // debugger; 4133 + $scope.getCanavsDivScrollPosition = function () {
4137 4134
4138 - // else { 4135 + var canvasDiv = document.getElementById('canvasDiv');
  4136 + return{
  4137 + verticalScrollPosition : canvasDiv.scrollTop,
  4138 + horizontlScrollPosition : canvasDiv.scrollLeft
  4139 + }
  4140 +
  4141 + }
  4142 +
  4143 + $scope.getTBoxDimesions = function (TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, X, Y, Height, Width) {
  4144 +
  4145 + var tBoxHeight = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY);
  4146 + var tBoxWidth = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX);
  4147 + var tBoxBottom = parseInt(TransparencyBoxStartY) + parseInt(tBoxHeight);
  4148 + var tBoxRight = parseInt(TransparencyBoxStartX) + parseInt(tBoxWidth);
  4149 +
  4150 + return{
  4151 +
  4152 + transparencyBoxHeight: tBoxHeight,
  4153 + transparencyBoxWidth: tBoxWidth,
  4154 + transparencyBoxBottom: tBoxBottom,
  4155 + transparencyBoxRight: tBoxRight,
  4156 + bodyRegionRight : parseInt(X) + parseInt(Width),
  4157 + bodyRegionBottom : parseInt(Y) + parseInt(Height)
  4158 + }
  4159 + }
  4160 +
  4161 + $scope.loadTransparencyImage = function (bodyRegionId, Height, Width, X, Y, IsMirror, TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, scope, isLayerChanged, isTransparencyChanged) {
  4162 +
4139 4163
4140 - var scope1 = angular.element(document.getElementById("DAView")).scope();  
4141 var transparencyCanvas = document.getElementById('transparencyCanvas'); 4164 var transparencyCanvas = document.getElementById('transparencyCanvas');
4142 4165
4143 TransparencyBoxStartX = parseInt((transparencyCanvas.style.left).replace('px', '')); 4166 TransparencyBoxStartX = parseInt((transparencyCanvas.style.left).replace('px', ''));
@@ -4146,140 +4169,16 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -4146,140 +4169,16 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4146 TransparencyBoxEndY = parseInt(transparencyCanvas.height) + parseInt(TransparencyBoxStartY); 4169 TransparencyBoxEndY = parseInt(transparencyCanvas.height) + parseInt(TransparencyBoxStartY);
4147 4170
4148 4171
4149 - var XforCopyImage = 0;  
4150 - var YforCopyImage = 0;  
4151 - var WidthforCopyImage = 0;  
4152 - var HeightforCopyImage = 0;  
4153 - var XforTransImage = 0;  
4154 - var WidthforTransImage = 0;  
4155 - var HeightforTransImage = 0;  
4156 - var YforTransImage = 0;  
4157 - var PreviousBodyRegionHeight = 0;  
4158 - var PreviousBodyRegionY;  
4159 - var PreviousBodyRegionWidth;  
4160 - var PreviousBodyRegionX;  
4161 - var previousBodyRegionId;  
4162 - var transparencyTempCanvas;  
4163 -  
4164 -  
4165 -  
4166 - //X ends outside and start outside of bodyregion  
4167 - if (TransparencyBoxStartX < X && TransparencyEndX > parseInt(X) + parseInt(Width)) {  
4168 - XforCopyImage = 0;  
4169 - WidthforCopyImage = Width;  
4170 - WidthforTransImage = Width;  
4171 - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {  
4172 - XforTransImage = 0;  
4173 - }  
4174 - else  
4175 - XforTransImage = parseInt(X) - (parseInt(TransparencyBoxStartX));  
4176 - // alert('1')  
4177 - }  
4178 - else if (TransparencyBoxStartX < X && TransparencyEndX < parseInt(X) + parseInt(Width)) {  
4179 -  
4180 - XforCopyImage = 0;  
4181 -  
4182 - WidthforCopyImage = parseInt(TransparencyEndX) - parseInt(X);  
4183 -  
4184 - WidthforTransImage = parseInt(TransparencyEndX) - parseInt(X);  
4185 -  
4186 - // alert(' scope.WidthforCopyImage: ' + scope.WidthforCopyImage)  
4187 - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {  
4188 - XforTransImage = 0;  
4189 - }  
4190 - else  
4191 - XforTransImage = parseInt(X) - (parseInt(TransparencyBoxStartX));  
4192 -  
4193 - // alert('2')  
4194 - }  
4195 - else if (TransparencyBoxStartX > X && TransparencyEndX > parseInt(X) + parseInt(Width)) {  
4196 - // alert('TransparencyEndX: ' + TransparencyEndX + ', X: ' + X + ', Width: ' + Width + 'scope.TransparencyBoxStartX: ' + scope.TransparencyBoxStartX)  
4197 -  
4198 - XforCopyImage = parseInt(TransparencyBoxStartX) - parseInt(X);  
4199 - WidthforCopyImage = parseInt(X) + parseInt(Width) - parseInt(TransparencyBoxStartX);  
4200 - WidthforTransImage = parseInt(X) + parseInt(Width) - parseInt(TransparencyBoxStartX);  
4201 -  
4202 - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {  
4203 -  
4204 - XforTransImage = parseInt(TransparencyBoxStartX) - parseInt(X);  
4205 - }  
4206 - else  
4207 - XforTransImage = 0;  
4208 - // alert('3')  
4209 - }  
4210 - else if (TransparencyBoxStartX > X && TransparencyEndX < parseInt(X) + parseInt(Width)) {  
4211 - // alert('startX inside & endX inside')  
4212 - XforCopyImage = parseInt(TransparencyBoxStartX) - parseInt(X);//parseInt(X) + parseInt(Width) - parseInt(scope.TransparencyBoxStartX)// scope.TransparencyBoxStartX ;  
4213 - WidthforCopyImage = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX);  
4214 - WidthforTransImage = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX);  
4215 - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {  
4216 -  
4217 - XforTransImage = parseInt(TransparencyBoxStartX) - parseInt(X);  
4218 - }  
4219 - else  
4220 - XforTransImage = 0;  
4221 - // alert('4. TransparencyBoxStartX: ' + TransparencyBoxStartX + ',X: ' + parseInt(X) + ',TransparencyEndX: ' + TransparencyEndX + ',XforCopyImage: ' + XforCopyImage)  
4222 - }  
4223 -  
4224 - //calculate Y and height for tempTranparency box from where to cut the image  
4225 -  
4226 -  
4227 - if (TransparencyBoxStartY < Y && TransparencyBoxEndY > parseInt(Y) + parseInt(Height)) {  
4228 -  
4229 - // alert('start Y outside and end Y outside');  
4230 -  
4231 - YforCopyImage = 0;  
4232 - HeightforCopyImage = Height;  
4233 -  
4234 - HeightforTransImage = Height;  
4235 - //alert('Y ' + Y)  
4236 - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {  
4237 - YforTransImage = 0;  
4238 - }  
4239 - else  
4240 - YforTransImage = parseFloat(Y) - parseInt(TransparencyBoxStartY)//parseFloat(Y) - (24.4);  
4241 - // alert('5')  
4242 - }  
4243 - else if (TransparencyBoxStartY < Y && TransparencyBoxEndY < (parseInt(Y) + parseInt(Height))) {  
4244 -  
4245 - YforCopyImage = 0;  
4246 - HeightforCopyImage = (parseInt(TransparencyBoxEndY)) - parseInt(Y)//(parseInt(Height) + parseInt(Y)) - (parseInt(TransparencyBoxEndY) - parseInt(scope.TransparencyBoxStartY));  
4247 -  
4248 - HeightforTransImage = (parseInt(TransparencyBoxEndY)) - parseInt(Y)// - parseInt(scope.TransparencyBoxStartY));  
4249 -  
4250 - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {  
4251 - YforTransImage = 0;  
4252 - }  
4253 - else  
4254 - YforTransImage = parseFloat(Y) - parseInt(TransparencyBoxStartY);// - (24.4);  
4255 -  
4256 - }  
4257 - else if (TransparencyBoxStartY > Y && TransparencyBoxEndY > parseInt(Y) + parseInt(Height)) {  
4258 -  
4259 - YforCopyImage = parseInt(TransparencyBoxStartY) - parseInt(Y);  
4260 - HeightforCopyImage = parseInt(Y) + parseInt(Height) - parseInt(TransparencyBoxStartY);  
4261 - HeightforTransImage = parseInt(Y) + parseInt(Height) - parseInt(TransparencyBoxStartY);  
4262 - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {  
4263 - YforTransImage = parseInt(TransparencyBoxStartY) - parseInt(Y);  
4264 -  
4265 - }  
4266 - else  
4267 - YforTransImage = 0;  
4268 -  
4269 - }  
4270 - else if (TransparencyBoxStartY > Y && TransparencyBoxEndY < parseInt(Y) + parseInt(Height)) {  
4271 -  
4272 - YforCopyImage = parseInt(TransparencyBoxStartY) - parseInt(Y);  
4273 - HeightforCopyImage = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY);  
4274 - HeightforTransImage = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY);  
4275 - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {  
4276 - YforTransImage = parseInt(TransparencyBoxStartY) - parseInt(Y);  
4277 -  
4278 - }  
4279 - else  
4280 - YforTransImage = 0;  
4281 - } 4172 + var TBImageDimensions = $scope.calculateDimensionsForTBImage(Height, Width, X, Y, IsMirror, TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, bodyRegionId);
4282 4173
  4174 + var XforCopyImage = TBImageDimensions.XforCopyImageTB;
  4175 + var YforCopyImage = TBImageDimensions.YforCopyImageTB;
  4176 + var WidthforCopyImage = TBImageDimensions.WidthforCopyImageTB;
  4177 + var HeightforCopyImage = TBImageDimensions.HeightforCopyImageTB;
  4178 + var XforTransImage = TBImageDimensions.XforTransImageTB;
  4179 + var WidthforTransImage = TBImageDimensions.WidthforTransImageTB;
  4180 + var HeightforTransImage = TBImageDimensions.HeightforTransImageTB;
  4181 + var YforTransImage = TBImageDimensions.YforTransImageTB;
4283 4182
4284 //0. get current layer number 4183 //0. get current layer number
4285 if ($scope.isResized) { 4184 if ($scope.isResized) {
@@ -4287,14 +4186,12 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -4287,14 +4186,12 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4287 } 4186 }
4288 else if (isLayerChanged) { 4187 else if (isLayerChanged) {
4289 4188
4290 -  
4291 } 4189 }
4292 else { 4190 else {
4293 -  
4294 - 4191 +
4295 var tranparencyLayer; 4192 var tranparencyLayer;
4296 4193
4297 - var currentLayer = $scope.layerNumberBeforeTrans; 4194 + var currentLayer = $scope.layerNumberBeforeTBDraw;
4298 4195
4299 if (currentLayer == $rootScope.totalLayers) { 4196 if (currentLayer == $rootScope.totalLayers) {
4300 4197
@@ -4314,11 +4211,11 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -4314,11 +4211,11 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4314 4211
4315 $('#txtlayerNumber').val($scope.layerNumber); 4212 $('#txtlayerNumber').val($scope.layerNumber);
4316 4213
4317 - //dedebugger; 4214 +
4318 var tranparencyImgSrc; 4215 var tranparencyImgSrc;
4319 var tranparencyMaskImgSrc; 4216 var tranparencyMaskImgSrc;
4320 - //for modesty image  
4321 - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg')))// == "2" || bodyRegionId == "3")) { 4217 +
  4218 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg')))
4322 { 4219 {
4323 var modestyBodyRegionData = new jinqJs() 4220 var modestyBodyRegionData = new jinqJs()
4324 .from($scope.modestyImageInfo) 4221 .from($scope.modestyImageInfo)
@@ -4326,52 +4223,42 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -4326,52 +4223,42 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4326 .select(); 4223 .select();
4327 tranparencyImgSrc = modestyBodyRegionData[0].SRC; 4224 tranparencyImgSrc = modestyBodyRegionData[0].SRC;
4328 } 4225 }
4329 -  
4330 - //modesty end  
4331 -  
4332 - //1. get the image source  
4333 -  
4334 else { 4226 else {
4335 tranparencyImgSrc = $scope.GetImageSource(bodyRegionId); 4227 tranparencyImgSrc = $scope.GetImageSource(bodyRegionId);
4336 tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc); 4228 tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc);
4337 } 4229 }
4338 - // var tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc);  
4339 - // debugger; 4230 +
  4231 + //remove old canvases
4340 var oldCanvas; 4232 var oldCanvas;
4341 -  
4342 - if (IsMirror == 'Yes') {  
4343 - oldCanvas = document.getElementById('transparencyTempCanvas_MR_' + bodyRegionId)  
4344 - }  
4345 - else {  
4346 -  
4347 - oldCanvas = document.getElementById('transparencyTempCanvas_' + bodyRegionId)  
4348 -  
4349 - }  
4350 -  
4351 - if (oldCanvas != null) {  
4352 - document.getElementById('canvasDiv').removeChild(oldCanvas);  
4353 - }  
4354 -  
4355 - //remove tempmask canvas  
4356 var oldtempTransCanvasMask; 4233 var oldtempTransCanvasMask;
4357 var oldtempTransCanvasMaskMR; 4234 var oldtempTransCanvasMaskMR;
  4235 +
4358 if (IsMirror == 'Yes') { 4236 if (IsMirror == 'Yes') {
  4237 + oldCanvas = document.getElementById('transparencyTempCanvas_MR_' + bodyRegionId);
4359 oldtempTransCanvasMaskMR = document.getElementById('transparencyTempCanvasMask_MR' + bodyRegionId + '_mci'); 4238 oldtempTransCanvasMaskMR = document.getElementById('transparencyTempCanvasMask_MR' + bodyRegionId + '_mci');
4360 oldtempTransCanvasMask = document.getElementById('transparencyTempCanvasMask_' + bodyRegionId + '_mci'); 4239 oldtempTransCanvasMask = document.getElementById('transparencyTempCanvasMask_' + bodyRegionId + '_mci');
4361 4240
4362 if (oldtempTransCanvasMaskMR != null) { 4241 if (oldtempTransCanvasMaskMR != null) {
4363 document.getElementById('canvasDiv').removeChild(oldtempTransCanvasMaskMR); 4242 document.getElementById('canvasDiv').removeChild(oldtempTransCanvasMaskMR);
4364 } 4243 }
  4244 +
4365 } 4245 }
4366 else { 4246 else {
  4247 +
  4248 + oldCanvas = document.getElementById('transparencyTempCanvas_' + bodyRegionId)
4367 oldtempTransCanvasMask = document.getElementById('transparencyTempCanvasMask_' + bodyRegionId + '_mci'); 4249 oldtempTransCanvasMask = document.getElementById('transparencyTempCanvasMask_' + bodyRegionId + '_mci');
4368 4250
4369 } 4251 }
  4252 +
  4253 + if (oldCanvas != null) {
  4254 + document.getElementById('canvasDiv').removeChild(oldCanvas);
  4255 + }
4370 if (oldtempTransCanvasMask != null) { 4256 if (oldtempTransCanvasMask != null) {
4371 document.getElementById('canvasDiv').removeChild(oldtempTransCanvasMask); 4257 document.getElementById('canvasDiv').removeChild(oldtempTransCanvasMask);
4372 } 4258 }
4373 -  
4374 - transparencyTempCanvas = document.createElement('canvas'); 4259 +
  4260 +
  4261 + var transparencyTempCanvas = document.createElement('canvas');
4375 var transparencyTempcanavsMask = document.createElement('canvas'); 4262 var transparencyTempcanavsMask = document.createElement('canvas');
4376 //if mirror then draw mask image for non mirrored body region for annotation 4263 //if mirror then draw mask image for non mirrored body region for annotation
4377 if (IsMirror == 'Yes') { 4264 if (IsMirror == 'Yes') {
@@ -4381,8 +4268,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -4381,8 +4268,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4381 else { 4268 else {
4382 if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { 4269 if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
4383 transparencyTempCanvas.id = 'transparencyTempCanvas_' + bodyRegionId; 4270 transparencyTempCanvas.id = 'transparencyTempCanvas_' + bodyRegionId;
4384 - // transparencyTempCanvas.style.visibility = 'visible';  
4385 - //transparencyTempCanvas.style.zIndex = '1000' 4271 +
4386 } 4272 }
4387 else { 4273 else {
4388 transparencyTempCanvas.id = 'transparencyTempCanvas_' + bodyRegionId; 4274 transparencyTempCanvas.id = 'transparencyTempCanvas_' + bodyRegionId;
@@ -4395,14 +4281,9 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -4395,14 +4281,9 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4395 transparencyTempCanvas.style.position = "absolute"; 4281 transparencyTempCanvas.style.position = "absolute";
4396 transparencyTempCanvas.style.left = X + 'px' // x + "px"; 4282 transparencyTempCanvas.style.left = X + 'px' // x + "px";
4397 transparencyTempCanvas.style.top = Y + "px"//y + "px"; 4283 transparencyTempCanvas.style.top = Y + "px"//y + "px";
4398 - //if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {  
4399 - // transparencyTempCanvas.style.visibility = 'visible';  
4400 - //}  
4401 - //else { 4284 +
4402 transparencyTempCanvas.style.visibility = 'hidden'; 4285 transparencyTempCanvas.style.visibility = 'hidden';
4403 - // }  
4404 - //transparencyTempCanvas.style.visibility = 'visible';  
4405 - // transparencyCanvas.style.zIndex = 4000; 4286 +
4406 document.getElementById('canvasDiv').appendChild(transparencyTempCanvas); 4287 document.getElementById('canvasDiv').appendChild(transparencyTempCanvas);
4407 4288
4408 //create temp mask canvas 4289 //create temp mask canvas
@@ -4414,8 +4295,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -4414,8 +4295,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4414 transparencyTempcanavsMask.style.left = X + 'px' // x + "px"; 4295 transparencyTempcanavsMask.style.left = X + 'px' // x + "px";
4415 transparencyTempcanavsMask.style.top = Y + "px"//y + "px"; 4296 transparencyTempcanavsMask.style.top = Y + "px"//y + "px";
4416 transparencyTempcanavsMask.style.visibility = 'hidden'; 4297 transparencyTempcanavsMask.style.visibility = 'hidden';
4417 - //transparencyTempCanvas.style.visibility = 'visible';  
4418 - // transparencyCanvas.style.border = "black 1px solid"; 4298 +
4419 document.getElementById('canvasDiv').appendChild(transparencyTempcanavsMask); 4299 document.getElementById('canvasDiv').appendChild(transparencyTempcanavsMask);
4420 } 4300 }
4421 4301
@@ -4431,7 +4311,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -4431,7 +4311,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4431 if (document.getElementById(modestyTransTempCanvasId) == null || document.getElementById(modestyTransTempCanvasId) == undefined) { 4311 if (document.getElementById(modestyTransTempCanvasId) == null || document.getElementById(modestyTransTempCanvasId) == undefined) {
4432 var tempCanvasModesty = document.createElement('canvas'); 4312 var tempCanvasModesty = document.createElement('canvas');
4433 tempCanvasModesty.id = modestyTransTempCanvasId; 4313 tempCanvasModesty.id = modestyTransTempCanvasId;
4434 - // $scope.tempCanvas = transparencyCanvas.id;  
4435 tempCanvasModesty.height = Height; 4314 tempCanvasModesty.height = Height;
4436 tempCanvasModesty.width = Width; 4315 tempCanvasModesty.width = Width;
4437 tempCanvasModesty.style.position = "absolute"; 4316 tempCanvasModesty.style.position = "absolute";
@@ -4449,18 +4328,15 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -4449,18 +4328,15 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4449 if (document.getElementById(modestyTransCanvasId) == null || document.getElementById(modestyTransCanvasId) == undefined) { 4328 if (document.getElementById(modestyTransCanvasId) == null || document.getElementById(modestyTransCanvasId) == undefined) {
4450 var canvasModesty = document.createElement('canvas'); 4329 var canvasModesty = document.createElement('canvas');
4451 canvasModesty.id = modestyTransCanvasId; 4330 canvasModesty.id = modestyTransCanvasId;
4452 - // $scope.tempCanvas = transparencyCanvas.id;  
4453 canvasModesty.height = Height; 4331 canvasModesty.height = Height;
4454 canvasModesty.width = Width; 4332 canvasModesty.width = Width;
4455 canvasModesty.style.position = "absolute"; 4333 canvasModesty.style.position = "absolute";
4456 canvasModesty.style.left = X + 'px'; 4334 canvasModesty.style.left = X + 'px';
4457 canvasModesty.style.top = Y + 'px'; 4335 canvasModesty.style.top = Y + 'px';
4458 - //canvasModesty.style.backgroundColor = "transparent";  
4459 canvasModesty.style.visibility = 'visible'; 4336 canvasModesty.style.visibility = 'visible';
4460 canvasModesty.style.zIndex = '2000'; 4337 canvasModesty.style.zIndex = '2000';
4461 canvasModesty.addEventListener('click', OnClickModestyTransCanvas); 4338 canvasModesty.addEventListener('click', OnClickModestyTransCanvas);
4462 4339
4463 - // tempcanvasModestyCanvasModesty.style.border = "black 1px solid";  
4464 document.getElementById('canvasDiv').appendChild(canvasModesty); 4340 document.getElementById('canvasDiv').appendChild(canvasModesty);
4465 } 4341 }
4466 } 4342 }
@@ -4468,8 +4344,21 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -4468,8 +4344,21 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4468 if (tranparencyImgSrc != undefined) { 4344 if (tranparencyImgSrc != undefined) {
4469 var tempImg = new Image(); 4345 var tempImg = new Image();
4470 4346
  4347 + var tempCanvasID;
  4348 +
  4349 + if (IsMirror == 'Yes') {
  4350 + tempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId;
  4351 + }
  4352 + else {
  4353 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4354 + tempCanvasID = 'transparencyTempCanvas_' + bodyRegionId;//bodyRegionId;
  4355 + }
  4356 + else
  4357 + tempCanvasID = 'transparencyTempCanvas_' + bodyRegionId;
  4358 + }
4471 4359
4472 tempImg.onload = function () { 4360 tempImg.onload = function () {
  4361 +
4473 var tempCtx = transparencyTempCanvas.getContext('2d'); 4362 var tempCtx = transparencyTempCanvas.getContext('2d');
4474 4363
4475 if (IsMirror == 'Yes') { 4364 if (IsMirror == 'Yes') {
@@ -4478,126 +4367,53 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -4478,126 +4367,53 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4478 tempCtx.translate(Width, 0); 4367 tempCtx.translate(Width, 0);
4479 tempCtx.scale(-1, 1); 4368 tempCtx.scale(-1, 1);
4480 tempCtx.drawImage(tempImg, 0, 0); 4369 tempCtx.drawImage(tempImg, 0, 0);
4481 - }  
4482 - else {  
4483 - tempCtx.drawImage(tempImg, 0, 0);  
4484 -  
4485 - }  
4486 - // debugger;  
4487 - var tempCanvasID;  
4488 -  
4489 - if (IsMirror == 'Yes') {  
4490 - tempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId;  
4491 - }  
4492 - else {  
4493 - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {  
4494 - tempCanvasID = 'transparencyTempCanvas_' + bodyRegionId;//bodyRegionId;  
4495 - }  
4496 - else  
4497 - tempCanvasID = 'transparencyTempCanvas_' + bodyRegionId;  
4498 - }  
4499 -  
4500 -  
4501 - //check if transparency is activated  
4502 -  
4503 -  
4504 - var transNumber = $scope.transNumber;//txtTransparencyChange.value;  
4505 - // debugger;  
4506 - //this changes the transparency when transparency is already activated and user resizes or chage the layer  
4507 -  
4508 - var imageD = tempCtx.getImageData(0, 0, Width, Height);  
4509 -  
4510 -  
4511 - var tempCtx = document.getElementById(tempCanvasID).getContext('2d');  
4512 -  
4513 - //keep the original image on temp canavs to use it in changing transparency  
4514 -  
4515 -  
4516 - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {  
4517 - var modestyTempCanvasId = 'tempCanvasModesty_' + bodyRegionId;  
4518 - if (document.getElementById(modestyTempCanvasId) != undefined || document.getElementById(modestyTempCanvasId) != null) {  
4519 - var contxModesty = document.getElementById(modestyTempCanvasId).getContext('2d');  
4520 - var tbTempCanvas = document.getElementById(tempCanvasID)  
4521 - contxModesty.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage);  
4522 4370
  4371 + if ($rootScope.isHighLight == true) {
  4372 + // var tempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId;
  4373 + $scope.highlightTempTransparencyCanvas(tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage,
  4374 + XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId);
4523 } 4375 }
4524 } 4376 }
4525 else { 4377 else {
4526 4378
4527 - if (document.getElementById('tempCanvas') != null && document.getElementById('tempCanvas') != undefined) {  
4528 - var contx = document.getElementById('tempCanvas').getContext('2d');  
4529 - var tbTempCanvas = document.getElementById(tempCanvasID)  
4530 - contx.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage);  
4531 -  
4532 - }  
4533 - } 4379 + tempCtx.drawImage(tempImg, 0, 0);
4534 4380
4535 - // get the image data values 4381 + if ($rootScope.isHighLight == true) {
  4382 + $scope.highlightTempTransparencyCanvas(tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage,
  4383 + YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId);
4536 4384
4537 - var imageData = imageD.data;  
4538 - var length = imageData.length; 4385 + }
4539 4386
4540 - //change background of image from transparent to white 4387 + }
  4388 +
4541 4389
4542 - // set every fourth value to 50  
4543 - for (var i = 3; i < length; i += 4) {  
4544 - //NIKITA  
4545 - if ($scope.voId == "9" || $scope.voId == "11") { 4390 +
  4391 + if ($rootScope.isHighLight != true) {
  4392 +
4546 4393
4547 - if (imageData[i] == 0) { 4394 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4395 + var modestyTempCanvasId = 'tempCanvasModesty_' + bodyRegionId;
  4396 + if (document.getElementById(modestyTempCanvasId) != undefined || document.getElementById(modestyTempCanvasId) != null) {
  4397 + var contxModestyTemp = document.getElementById(modestyTempCanvasId).getContext('2d');
  4398 + var tbTempCanvas = document.getElementById(tempCanvasID)
  4399 + contxModestyTemp.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage);
4548 4400
4549 } 4401 }
4550 - else {  
4551 - imageData[i] = ((255) * (parseInt(transNumber))) / 100;  
4552 - }  
4553 } 4402 }
4554 else { 4403 else {
4555 - if (imageData[i] == 0) {  
4556 4404
4557 - }  
4558 - else {  
4559 - imageData[i] = ((255) * (parseInt(transNumber))) / 100;  
4560 - }  
4561 - }  
4562 - } 4405 + if (document.getElementById('tempCanvas') != null && document.getElementById('tempCanvas') != undefined) {
  4406 + var contx = document.getElementById('tempCanvas').getContext('2d');
  4407 + var tbTempCanvas = document.getElementById(tempCanvasID)
  4408 + contx.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage);
4563 4409
  4410 + }
  4411 + }
4564 4412
4565 - tempCtx.putImageData(imageD, 0, 0);  
4566 -  
4567 - var ctx;  
4568 - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {  
4569 - ctx = document.getElementById(modestyTransCanvasId).getContext('2d');  
4570 - }  
4571 - else  
4572 - ctx = transparencyCanvas.getContext('2d');  
4573 - 4413 + $scope.DrawOnTBWithSelectedTransparency(tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId);
4574 4414
4575 - var TrtempCanvasID  
4576 - if (IsMirror == 'Yes') {  
4577 - TrtempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId;  
4578 } 4415 }
4579 - else {  
4580 - //if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {  
4581 - // TrtempCanvasID = 'modestyTransparencyTempCanvas_' + bodyRegionId;  
4582 - //}  
4583 - //else  
4584 - TrtempCanvasID = 'transparencyTempCanvas_' + bodyRegionId;  
4585 - }  
4586 -  
4587 - var tmpCanvasContext = document.getElementById(TrtempCanvasID);//.getContext('2d');  
4588 -  
4589 - ctx.drawImage(tmpCanvasContext, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage)  
4590 -  
4591 -  
4592 - XforCopyImage = 0;  
4593 - YforCopyImage = 0;  
4594 - WidthforCopyImage = 0;  
4595 - HeightforCopyImage = 0;  
4596 - XforTransImage = 0;  
4597 - WidthforTransImage = 0;  
4598 - HeightforTransImage = 0;  
4599 - YforTransImage = 0;  
4600 - PreviousBodyRegionHeight = 0; 4416 +
4601 4417
4602 } 4418 }
4603 tempImg.src = tranparencyImgSrc;//"http://localhost/AIA/" + tranparencyImgSrc; 4419 tempImg.src = tranparencyImgSrc;//"http://localhost/AIA/" + tranparencyImgSrc;
@@ -4605,7 +4421,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -4605,7 +4421,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4605 4421
4606 } 4422 }
4607 4423
4608 -  
4609 //mask image code 4424 //mask image code
4610 //draw mask for annotation 4425 //draw mask for annotation
4611 var tempMaskImg = new Image(); 4426 var tempMaskImg = new Image();
@@ -4630,14 +4445,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -4630,14 +4445,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4630 4445
4631 } 4446 }
4632 4447
4633 -  
4634 - PreviousBodyRegionHeight = HeightforTransImage;  
4635 - PreviousBodyRegionY = YforTransImage;  
4636 - PreviousBodyRegionWidth = WidthforTransImage;  
4637 - PreviousBodyRegionX = XforTransImage;  
4638 - previousBodyRegionId = bodyRegionId;  
4639 -  
4640 -  
4641 //set modesty image visiblility true/false as per layer 4448 //set modesty image visiblility true/false as per layer
4642 4449
4643 4450
@@ -4675,6 +4482,263 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -4675,6 +4482,263 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4675 4482
4676 } 4483 }
4677 4484
  4485 +
  4486 + $scope.calculateDimensionsForTBImage = function (Height, Width, X, Y, IsMirror, TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, bodyRegionId) {
  4487 +
  4488 + var XforCopyImage = 0;
  4489 + var YforCopyImage = 0;
  4490 + var WidthforCopyImage = 0;
  4491 + var HeightforCopyImage = 0;
  4492 + var XforTransImage = 0;
  4493 + var WidthforTransImage = 0;
  4494 + var HeightforTransImage = 0;
  4495 + var YforTransImage = 0;
  4496 +
  4497 +
  4498 + //X ends outside and start outside of bodyregion
  4499 + if (TransparencyBoxStartX < X && TransparencyEndX > parseInt(X) + parseInt(Width)) {
  4500 + XforCopyImage = 0;
  4501 + WidthforCopyImage = Width;
  4502 + WidthforTransImage = Width;
  4503 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4504 + XforTransImage = 0;
  4505 + }
  4506 + else
  4507 + XforTransImage = parseInt(X) - (parseInt(TransparencyBoxStartX));
  4508 + }
  4509 + else if (TransparencyBoxStartX < X && TransparencyEndX < parseInt(X) + parseInt(Width)) {
  4510 +
  4511 + XforCopyImage = 0;
  4512 +
  4513 + WidthforCopyImage = parseInt(TransparencyEndX) - parseInt(X);
  4514 +
  4515 + WidthforTransImage = parseInt(TransparencyEndX) - parseInt(X);
  4516 +
  4517 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4518 + XforTransImage = 0;
  4519 + }
  4520 + else
  4521 + XforTransImage = parseInt(X) - (parseInt(TransparencyBoxStartX));
  4522 +
  4523 + }
  4524 + else if (TransparencyBoxStartX > X && TransparencyEndX > parseInt(X) + parseInt(Width)) {
  4525 +
  4526 + XforCopyImage = parseInt(TransparencyBoxStartX) - parseInt(X);
  4527 + WidthforCopyImage = parseInt(X) + parseInt(Width) - parseInt(TransparencyBoxStartX);
  4528 + WidthforTransImage = parseInt(X) + parseInt(Width) - parseInt(TransparencyBoxStartX);
  4529 +
  4530 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4531 +
  4532 + XforTransImage = parseInt(TransparencyBoxStartX) - parseInt(X);
  4533 + }
  4534 + else
  4535 + XforTransImage = 0;
  4536 + }
  4537 + else if (TransparencyBoxStartX > X && TransparencyEndX < parseInt(X) + parseInt(Width)) {
  4538 + XforCopyImage = parseInt(TransparencyBoxStartX) - parseInt(X);//parseInt(X) + parseInt(Width) - parseInt(scope.TransparencyBoxStartX)// scope.TransparencyBoxStartX ;
  4539 + WidthforCopyImage = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX);
  4540 + WidthforTransImage = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX);
  4541 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4542 +
  4543 + XforTransImage = parseInt(TransparencyBoxStartX) - parseInt(X);
  4544 + }
  4545 + else
  4546 + XforTransImage = 0;
  4547 + }
  4548 +
  4549 + //calculate Y and height for tempTranparency box from where to cut the image
  4550 +
  4551 +
  4552 + if (TransparencyBoxStartY < Y && TransparencyBoxEndY > parseInt(Y) + parseInt(Height)) {
  4553 +
  4554 + YforCopyImage = 0;
  4555 + HeightforCopyImage = Height;
  4556 +
  4557 + HeightforTransImage = Height;
  4558 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4559 + YforTransImage = 0;
  4560 + }
  4561 + else
  4562 + YforTransImage = parseFloat(Y) - parseInt(TransparencyBoxStartY)//parseFloat(Y) - (24.4);
  4563 + }
  4564 + else if (TransparencyBoxStartY < Y && TransparencyBoxEndY < (parseInt(Y) + parseInt(Height))) {
  4565 +
  4566 + YforCopyImage = 0;
  4567 + HeightforCopyImage = (parseInt(TransparencyBoxEndY)) - parseInt(Y)//(parseInt(Height) + parseInt(Y)) - (parseInt(TransparencyBoxEndY) - parseInt(scope.TransparencyBoxStartY));
  4568 +
  4569 + HeightforTransImage = (parseInt(TransparencyBoxEndY)) - parseInt(Y)// - parseInt(scope.TransparencyBoxStartY));
  4570 +
  4571 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4572 + YforTransImage = 0;
  4573 + }
  4574 + else
  4575 + YforTransImage = parseFloat(Y) - parseInt(TransparencyBoxStartY);// - (24.4);
  4576 +
  4577 + }
  4578 + else if (TransparencyBoxStartY > Y && TransparencyBoxEndY > parseInt(Y) + parseInt(Height)) {
  4579 +
  4580 + YforCopyImage = parseInt(TransparencyBoxStartY) - parseInt(Y);
  4581 + HeightforCopyImage = parseInt(Y) + parseInt(Height) - parseInt(TransparencyBoxStartY);
  4582 + HeightforTransImage = parseInt(Y) + parseInt(Height) - parseInt(TransparencyBoxStartY);
  4583 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4584 + YforTransImage = parseInt(TransparencyBoxStartY) - parseInt(Y);
  4585 +
  4586 + }
  4587 + else
  4588 + YforTransImage = 0;
  4589 +
  4590 + }
  4591 + else if (TransparencyBoxStartY > Y && TransparencyBoxEndY < parseInt(Y) + parseInt(Height)) {
  4592 +
  4593 + YforCopyImage = parseInt(TransparencyBoxStartY) - parseInt(Y);
  4594 + HeightforCopyImage = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY);
  4595 + HeightforTransImage = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY);
  4596 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4597 + YforTransImage = parseInt(TransparencyBoxStartY) - parseInt(Y);
  4598 +
  4599 + }
  4600 + else
  4601 + YforTransImage = 0;
  4602 + }
  4603 +
  4604 + return {
  4605 +
  4606 +
  4607 + XforCopyImageTB : XforCopyImage,
  4608 + YforCopyImageTB: YforCopyImage,
  4609 + WidthforCopyImageTB: WidthforCopyImage,
  4610 + HeightforCopyImageTB: HeightforCopyImage,
  4611 + XforTransImageTB: XforTransImage,
  4612 + WidthforTransImageTB: WidthforTransImage,
  4613 + HeightforTransImageTB: HeightforTransImage,
  4614 + YforTransImageTB: YforTransImage
  4615 +
  4616 + }
  4617 + }
  4618 +
  4619 + $scope.highlightTempTransparencyCanvas = function (tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId) {
  4620 +
  4621 + var tempTransCanvas = document.getElementById(tempCanvasID);
  4622 + var tempCanvasContext = tempTransCanvas.getContext('2d');
  4623 +
  4624 + var dataURL = tempTransCanvas.toDataURL();
  4625 +
  4626 + var img = new Image();
  4627 + img.src = dataURL;
  4628 +
  4629 + img.onload = function () {
  4630 +
  4631 + var DAData = new BitmapData(parseInt(tempTransCanvas.width), parseInt(tempTransCanvas.height));
  4632 + DAData.draw(img);
  4633 +
  4634 + var colorMode = $scope.applyGrayMatrix(img, tempCanvasContext);
  4635 +
  4636 + if (colorMode != undefined || colorMode != null) {
  4637 +
  4638 + var zeroPoint = new Point();
  4639 +
  4640 + DAData.applyFilter(DAData, DAData.rect, zeroPoint, colorMode);
  4641 +
  4642 +
  4643 + tempCanvasContext.putImageData(DAData.data, 0, 0);
  4644 +
  4645 + //keep the original image on temp canavs to use it in changing transparency
  4646 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4647 + var modestyTempCanvasId = 'tempCanvasModesty_' + bodyRegionId;
  4648 + if (document.getElementById(modestyTempCanvasId) != undefined || document.getElementById(modestyTempCanvasId) != null) {
  4649 + var contxModestyTemp = document.getElementById(modestyTempCanvasId).getContext('2d');
  4650 + var tbTempCanvas = document.getElementById(tempCanvasID)
  4651 + contxModestyTemp.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage);
  4652 +
  4653 + }
  4654 + }
  4655 + else {
  4656 + if (document.getElementById('tempCanvas') != null) {
  4657 +
  4658 + var contx = document.getElementById('tempCanvas').getContext('2d');
  4659 + var tbTempCanvas = document.getElementById(tempCanvasID)
  4660 + contx.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage);
  4661 +
  4662 + }
  4663 + }
  4664 +
  4665 + $scope.DrawOnTBWithSelectedTransparency(tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId);
  4666 + }
  4667 + }
  4668 + }
  4669 +
  4670 +
  4671 + $scope.DrawOnTBWithSelectedTransparency = function (tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId) {
  4672 +
  4673 + var transNumber = $scope.transNumber;//txtTransparencyChange.value;
  4674 + //this changes the transparency when transparency is already activated and user resizes or chage the layer
  4675 +
  4676 + var tempCtx = document.getElementById(tempCanvasID).getContext('2d');
  4677 +
  4678 + var imageD = tempCtx.getImageData(0, 0, Width, Height);
  4679 + var imageData = imageD.data;
  4680 + var length = imageData.length;
  4681 +
  4682 +
  4683 + // set every fourth value to the desired number of transparency
  4684 + for (var i = 3; i < length; i += 4) {
  4685 + if ($scope.voId == "9" || $scope.voId == "11") {
  4686 +
  4687 + if (imageData[i] == 0) {
  4688 +
  4689 + }
  4690 + else {
  4691 + imageData[i] = ((255) * (parseInt(transNumber))) / 100;
  4692 + }
  4693 + }
  4694 + else {
  4695 + imageData[i] = ((255) * (parseInt(transNumber))) / 100;
  4696 + }
  4697 + }
  4698 +
  4699 +
  4700 + tempCtx.putImageData(imageD, 0, 0);
  4701 +
  4702 +
  4703 + $scope.widthOfImage = WidthforTransImage;
  4704 + $scope.heightOfImage = HeightforTransImage;
  4705 + $scope.xOfImage = XforTransImage;
  4706 + $scope.yOfImage = YforTransImage;
  4707 +
  4708 + var ctx = transparencyCanvas.getContext('2d');
  4709 +
  4710 +
  4711 + var tmpCanvasContext = document.getElementById(tempCanvasID);//.getContext('2d');
  4712 +
  4713 +
  4714 +
  4715 + var ctx;
  4716 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4717 + var modestyTransCanvasId = 'modestyTransCanavs_' + bodyRegionId
  4718 + ctx = document.getElementById(modestyTransCanvasId).getContext('2d');
  4719 + }
  4720 + else
  4721 + ctx = transparencyCanvas.getContext('2d');
  4722 +
  4723 + // var ctx = transparencyCanvas.getContext('2d');
  4724 + ctx.drawImage(tmpCanvasContext, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage)
  4725 +
  4726 + $scope.transparencyDrawnRegions.push(bodyRegionId);
  4727 +
  4728 +
  4729 + $rootScope.isLoading = false;
  4730 + $('#spinner').css('visibility', 'hidden');
  4731 +
  4732 + if ($scope.transparencyDrawnRegions.length == $scope.IncludedBodyRegions.length) {
  4733 +
  4734 + transparencyCanvas.style.visibility = 'visible';
  4735 + $('.rectangle').remove();
  4736 +
  4737 +
  4738 + }
  4739 + }
  4740 +
  4741 +
4678 $scope.changeTransparency = function () { 4742 $scope.changeTransparency = function () {
4679 //this changes the transparency when user click on transparency scale(we have already set the original 4743 //this changes the transparency when user click on transparency scale(we have already set the original
4680 //data on tras canvas irrespective of the trans number, so we can chnage the transparnecy of original data not the manipulated) 4744 //data on tras canvas irrespective of the trans number, so we can chnage the transparnecy of original data not the manipulated)
@@ -4972,6 +5036,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -4972,6 +5036,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4972 var BodyRegionDictionary = $rootScope.BodyRegionCordinatesData; 5036 var BodyRegionDictionary = $rootScope.BodyRegionCordinatesData;
4973 5037
4974 $scope.IncludedBodyRegions = []; 5038 $scope.IncludedBodyRegions = [];
  5039 + $scope.transparencyDrawnRegions = [];
4975 // $scope.layerNo = parseInt(document.getElementById('')) 5040 // $scope.layerNo = parseInt(document.getElementById(''))
4976 var counter = 0; 5041 var counter = 0;
4977 $.each(BodyRegionDictionary, function (index, value) { 5042 $.each(BodyRegionDictionary, function (index, value) {
@@ -5481,7 +5546,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -5481,7 +5546,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
5481 ctx.putImageData(originalTransparencyData, 0, 0); 5546 ctx.putImageData(originalTransparencyData, 0, 0);
5482 5547
5483 5548
5484 - 5549 + $scope.transparencyDrawnRegions = [];
5485 //for modesty 5550 //for modesty
5486 if ($rootScope.isModestyOn == true && $scope.modestyImageInfo.length > 0) { 5551 if ($rootScope.isModestyOn == true && $scope.modestyImageInfo.length > 0) {
5487 $.each($scope.modestyImageInfo, function (index, value) { 5552 $.each($scope.modestyImageInfo, function (index, value) {