Commit d623ff518ab277c8d6043ddfef9f78ba11a9fb2e
1 parent
a778af24
working merged code for noraml and highlight mode. Issue in modesty
Showing
1 changed file
with
299 additions
and
259 deletions
400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js
... | ... | @@ -3967,6 +3967,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
3967 | 3967 | var BodyRegionDictionary = $rootScope.BodyRegionCordinatesData; |
3968 | 3968 | |
3969 | 3969 | $scope.IncludedBodyRegions = []; |
3970 | + $scope.transparencyDrawnRegions = []; | |
3970 | 3971 | ////debugger; |
3971 | 3972 | $.each(BodyRegionDictionary, function (index, value) { |
3972 | 3973 | // alert(' $.each(BodyRegionDictionary1') |
... | ... | @@ -4078,11 +4079,8 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
4078 | 4079 | } |
4079 | 4080 | |
4080 | 4081 | $scope.loadTransparencyImage = function (bodyRegionId, Height, Width, X, Y, IsMirror, TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, scope, isLayerChanged, isTransparencyChanged) { |
4081 | - // debugger; | |
4082 | - | |
4083 | - // else { | |
4082 | + | |
4084 | 4083 | |
4085 | - var scope1 = angular.element(document.getElementById("DAView")).scope(); | |
4086 | 4084 | var transparencyCanvas = document.getElementById('transparencyCanvas'); |
4087 | 4085 | |
4088 | 4086 | TransparencyBoxStartX = parseInt((transparencyCanvas.style.left).replace('px', '')); |
... | ... | @@ -4091,140 +4089,16 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
4091 | 4089 | TransparencyBoxEndY = parseInt(transparencyCanvas.height) + parseInt(TransparencyBoxStartY); |
4092 | 4090 | |
4093 | 4091 | |
4094 | - var XforCopyImage = 0; | |
4095 | - var YforCopyImage = 0; | |
4096 | - var WidthforCopyImage = 0; | |
4097 | - var HeightforCopyImage = 0; | |
4098 | - var XforTransImage = 0; | |
4099 | - var WidthforTransImage = 0; | |
4100 | - var HeightforTransImage = 0; | |
4101 | - var YforTransImage = 0; | |
4102 | - var PreviousBodyRegionHeight = 0; | |
4103 | - var PreviousBodyRegionY; | |
4104 | - var PreviousBodyRegionWidth; | |
4105 | - var PreviousBodyRegionX; | |
4106 | - var previousBodyRegionId; | |
4107 | - var transparencyTempCanvas; | |
4108 | - | |
4109 | - | |
4110 | - | |
4111 | - //X ends outside and start outside of bodyregion | |
4112 | - if (TransparencyBoxStartX < X && TransparencyEndX > parseInt(X) + parseInt(Width)) { | |
4113 | - XforCopyImage = 0; | |
4114 | - WidthforCopyImage = Width; | |
4115 | - WidthforTransImage = Width; | |
4116 | - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { | |
4117 | - XforTransImage = 0; | |
4118 | - } | |
4119 | - else | |
4120 | - XforTransImage = parseInt(X) - (parseInt(TransparencyBoxStartX)); | |
4121 | - // alert('1') | |
4122 | - } | |
4123 | - else if (TransparencyBoxStartX < X && TransparencyEndX < parseInt(X) + parseInt(Width)) { | |
4124 | - | |
4125 | - XforCopyImage = 0; | |
4126 | - | |
4127 | - WidthforCopyImage = parseInt(TransparencyEndX) - parseInt(X); | |
4128 | - | |
4129 | - WidthforTransImage = parseInt(TransparencyEndX) - parseInt(X); | |
4130 | - | |
4131 | - // alert(' scope.WidthforCopyImage: ' + scope.WidthforCopyImage) | |
4132 | - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { | |
4133 | - XforTransImage = 0; | |
4134 | - } | |
4135 | - else | |
4136 | - XforTransImage = parseInt(X) - (parseInt(TransparencyBoxStartX)); | |
4137 | - | |
4138 | - // alert('2') | |
4139 | - } | |
4140 | - else if (TransparencyBoxStartX > X && TransparencyEndX > parseInt(X) + parseInt(Width)) { | |
4141 | - // alert('TransparencyEndX: ' + TransparencyEndX + ', X: ' + X + ', Width: ' + Width + 'scope.TransparencyBoxStartX: ' + scope.TransparencyBoxStartX) | |
4142 | - | |
4143 | - XforCopyImage = parseInt(TransparencyBoxStartX) - parseInt(X); | |
4144 | - WidthforCopyImage = parseInt(X) + parseInt(Width) - parseInt(TransparencyBoxStartX); | |
4145 | - WidthforTransImage = parseInt(X) + parseInt(Width) - parseInt(TransparencyBoxStartX); | |
4146 | - | |
4147 | - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { | |
4148 | - | |
4149 | - XforTransImage = parseInt(TransparencyBoxStartX) - parseInt(X); | |
4150 | - } | |
4151 | - else | |
4152 | - XforTransImage = 0; | |
4153 | - // alert('3') | |
4154 | - } | |
4155 | - else if (TransparencyBoxStartX > X && TransparencyEndX < parseInt(X) + parseInt(Width)) { | |
4156 | - // alert('startX inside & endX inside') | |
4157 | - XforCopyImage = parseInt(TransparencyBoxStartX) - parseInt(X);//parseInt(X) + parseInt(Width) - parseInt(scope.TransparencyBoxStartX)// scope.TransparencyBoxStartX ; | |
4158 | - WidthforCopyImage = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX); | |
4159 | - WidthforTransImage = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX); | |
4160 | - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { | |
4161 | - | |
4162 | - XforTransImage = parseInt(TransparencyBoxStartX) - parseInt(X); | |
4163 | - } | |
4164 | - else | |
4165 | - XforTransImage = 0; | |
4166 | - // alert('4. TransparencyBoxStartX: ' + TransparencyBoxStartX + ',X: ' + parseInt(X) + ',TransparencyEndX: ' + TransparencyEndX + ',XforCopyImage: ' + XforCopyImage) | |
4167 | - } | |
4168 | - | |
4169 | - //calculate Y and height for tempTranparency box from where to cut the image | |
4170 | - | |
4171 | - | |
4172 | - if (TransparencyBoxStartY < Y && TransparencyBoxEndY > parseInt(Y) + parseInt(Height)) { | |
4173 | - | |
4174 | - // alert('start Y outside and end Y outside'); | |
4175 | - | |
4176 | - YforCopyImage = 0; | |
4177 | - HeightforCopyImage = Height; | |
4178 | - | |
4179 | - HeightforTransImage = Height; | |
4180 | - //alert('Y ' + Y) | |
4181 | - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { | |
4182 | - YforTransImage = 0; | |
4183 | - } | |
4184 | - else | |
4185 | - YforTransImage = parseFloat(Y) - parseInt(TransparencyBoxStartY)//parseFloat(Y) - (24.4); | |
4186 | - // alert('5') | |
4187 | - } | |
4188 | - else if (TransparencyBoxStartY < Y && TransparencyBoxEndY < (parseInt(Y) + parseInt(Height))) { | |
4189 | - | |
4190 | - YforCopyImage = 0; | |
4191 | - HeightforCopyImage = (parseInt(TransparencyBoxEndY)) - parseInt(Y)//(parseInt(Height) + parseInt(Y)) - (parseInt(TransparencyBoxEndY) - parseInt(scope.TransparencyBoxStartY)); | |
4192 | - | |
4193 | - HeightforTransImage = (parseInt(TransparencyBoxEndY)) - parseInt(Y)// - parseInt(scope.TransparencyBoxStartY)); | |
4194 | - | |
4195 | - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { | |
4196 | - YforTransImage = 0; | |
4197 | - } | |
4198 | - else | |
4199 | - YforTransImage = parseFloat(Y) - parseInt(TransparencyBoxStartY);// - (24.4); | |
4200 | - | |
4201 | - } | |
4202 | - else if (TransparencyBoxStartY > Y && TransparencyBoxEndY > parseInt(Y) + parseInt(Height)) { | |
4203 | - | |
4204 | - YforCopyImage = parseInt(TransparencyBoxStartY) - parseInt(Y); | |
4205 | - HeightforCopyImage = parseInt(Y) + parseInt(Height) - parseInt(TransparencyBoxStartY); | |
4206 | - HeightforTransImage = parseInt(Y) + parseInt(Height) - parseInt(TransparencyBoxStartY); | |
4207 | - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { | |
4208 | - YforTransImage = parseInt(TransparencyBoxStartY) - parseInt(Y); | |
4209 | - | |
4210 | - } | |
4211 | - else | |
4212 | - YforTransImage = 0; | |
4213 | - | |
4214 | - } | |
4215 | - else if (TransparencyBoxStartY > Y && TransparencyBoxEndY < parseInt(Y) + parseInt(Height)) { | |
4216 | - | |
4217 | - YforCopyImage = parseInt(TransparencyBoxStartY) - parseInt(Y); | |
4218 | - HeightforCopyImage = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY); | |
4219 | - HeightforTransImage = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY); | |
4220 | - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { | |
4221 | - YforTransImage = parseInt(TransparencyBoxStartY) - parseInt(Y); | |
4222 | - | |
4223 | - } | |
4224 | - else | |
4225 | - YforTransImage = 0; | |
4226 | - } | |
4092 | + var dimensions = $scope.calculateCoordinatesAndDimensionsForTB(Height, Width, X, Y, IsMirror, TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, bodyRegionId); | |
4227 | 4093 | |
4094 | + var XforCopyImage = dimensions.XforCopyImageTB; | |
4095 | + var YforCopyImage = dimensions.YforCopyImageTB; | |
4096 | + var WidthforCopyImage = dimensions.WidthforCopyImageTB; | |
4097 | + var HeightforCopyImage = dimensions.HeightforCopyImageTB; | |
4098 | + var XforTransImage = dimensions.XforTransImageTB; | |
4099 | + var WidthforTransImage = dimensions.WidthforTransImageTB; | |
4100 | + var HeightforTransImage = dimensions.HeightforTransImageTB; | |
4101 | + var YforTransImage = dimensions.YforTransImageTB; | |
4228 | 4102 | |
4229 | 4103 | //0. get current layer number |
4230 | 4104 | if ($scope.isResized) { |
... | ... | @@ -4235,8 +4109,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
4235 | 4109 | |
4236 | 4110 | } |
4237 | 4111 | else { |
4238 | - | |
4239 | - | |
4112 | + | |
4240 | 4113 | var tranparencyLayer; |
4241 | 4114 | |
4242 | 4115 | var currentLayer = $scope.layerNumberBeforeTrans; |
... | ... | @@ -4259,7 +4132,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
4259 | 4132 | |
4260 | 4133 | $('#txtlayerNumber').val($scope.layerNumber); |
4261 | 4134 | |
4262 | - //dedebugger; | |
4135 | + | |
4263 | 4136 | var tranparencyImgSrc; |
4264 | 4137 | var tranparencyMaskImgSrc; |
4265 | 4138 | //for modesty image |
... | ... | @@ -4280,8 +4153,8 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
4280 | 4153 | tranparencyImgSrc = $scope.GetImageSource(bodyRegionId); |
4281 | 4154 | tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc); |
4282 | 4155 | } |
4283 | - // var tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc); | |
4284 | - // debugger; | |
4156 | + | |
4157 | + | |
4285 | 4158 | var oldCanvas; |
4286 | 4159 | |
4287 | 4160 | if (IsMirror == 'Yes') { |
... | ... | @@ -4316,7 +4189,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
4316 | 4189 | document.getElementById('canvasDiv').removeChild(oldtempTransCanvasMask); |
4317 | 4190 | } |
4318 | 4191 | |
4319 | - transparencyTempCanvas = document.createElement('canvas'); | |
4192 | + var transparencyTempCanvas = document.createElement('canvas'); | |
4320 | 4193 | var transparencyTempcanavsMask = document.createElement('canvas'); |
4321 | 4194 | //if mirror then draw mask image for non mirrored body region for annotation |
4322 | 4195 | if (IsMirror == 'Yes') { |
... | ... | @@ -4326,8 +4199,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
4326 | 4199 | else { |
4327 | 4200 | if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { |
4328 | 4201 | transparencyTempCanvas.id = 'transparencyTempCanvas_' + bodyRegionId; |
4329 | - // transparencyTempCanvas.style.visibility = 'visible'; | |
4330 | - //transparencyTempCanvas.style.zIndex = '1000' | |
4202 | + | |
4331 | 4203 | } |
4332 | 4204 | else { |
4333 | 4205 | transparencyTempCanvas.id = 'transparencyTempCanvas_' + bodyRegionId; |
... | ... | @@ -4340,14 +4212,9 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
4340 | 4212 | transparencyTempCanvas.style.position = "absolute"; |
4341 | 4213 | transparencyTempCanvas.style.left = X + 'px' // x + "px"; |
4342 | 4214 | transparencyTempCanvas.style.top = Y + "px"//y + "px"; |
4343 | - //if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { | |
4344 | - // transparencyTempCanvas.style.visibility = 'visible'; | |
4345 | - //} | |
4346 | - //else { | |
4215 | + | |
4347 | 4216 | transparencyTempCanvas.style.visibility = 'hidden'; |
4348 | - // } | |
4349 | - //transparencyTempCanvas.style.visibility = 'visible'; | |
4350 | - // transparencyCanvas.style.zIndex = 4000; | |
4217 | + | |
4351 | 4218 | document.getElementById('canvasDiv').appendChild(transparencyTempCanvas); |
4352 | 4219 | |
4353 | 4220 | //create temp mask canvas |
... | ... | @@ -4359,8 +4226,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
4359 | 4226 | transparencyTempcanavsMask.style.left = X + 'px' // x + "px"; |
4360 | 4227 | transparencyTempcanavsMask.style.top = Y + "px"//y + "px"; |
4361 | 4228 | transparencyTempcanavsMask.style.visibility = 'hidden'; |
4362 | - //transparencyTempCanvas.style.visibility = 'visible'; | |
4363 | - // transparencyCanvas.style.border = "black 1px solid"; | |
4229 | + | |
4364 | 4230 | document.getElementById('canvasDiv').appendChild(transparencyTempcanavsMask); |
4365 | 4231 | } |
4366 | 4232 | |
... | ... | @@ -4376,7 +4242,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
4376 | 4242 | if (document.getElementById(modestyTransTempCanvasId) == null || document.getElementById(modestyTransTempCanvasId) == undefined) { |
4377 | 4243 | var tempCanvasModesty = document.createElement('canvas'); |
4378 | 4244 | tempCanvasModesty.id = modestyTransTempCanvasId; |
4379 | - // $scope.tempCanvas = transparencyCanvas.id; | |
4380 | 4245 | tempCanvasModesty.height = Height; |
4381 | 4246 | tempCanvasModesty.width = Width; |
4382 | 4247 | tempCanvasModesty.style.position = "absolute"; |
... | ... | @@ -4394,18 +4259,15 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
4394 | 4259 | if (document.getElementById(modestyTransCanvasId) == null || document.getElementById(modestyTransCanvasId) == undefined) { |
4395 | 4260 | var canvasModesty = document.createElement('canvas'); |
4396 | 4261 | canvasModesty.id = modestyTransCanvasId; |
4397 | - // $scope.tempCanvas = transparencyCanvas.id; | |
4398 | 4262 | canvasModesty.height = Height; |
4399 | 4263 | canvasModesty.width = Width; |
4400 | 4264 | canvasModesty.style.position = "absolute"; |
4401 | 4265 | canvasModesty.style.left = X + 'px'; |
4402 | 4266 | canvasModesty.style.top = Y + 'px'; |
4403 | - //canvasModesty.style.backgroundColor = "transparent"; | |
4404 | 4267 | canvasModesty.style.visibility = 'visible'; |
4405 | 4268 | canvasModesty.style.zIndex = '2000'; |
4406 | 4269 | canvasModesty.addEventListener('click', OnClickModestyTransCanvas); |
4407 | 4270 | |
4408 | - // tempcanvasModestyCanvasModesty.style.border = "black 1px solid"; | |
4409 | 4271 | document.getElementById('canvasDiv').appendChild(canvasModesty); |
4410 | 4272 | } |
4411 | 4273 | } |
... | ... | @@ -4418,17 +4280,29 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
4418 | 4280 | var tempCtx = transparencyTempCanvas.getContext('2d'); |
4419 | 4281 | |
4420 | 4282 | if (IsMirror == 'Yes') { |
4421 | - //debugger; | |
4422 | 4283 | tempCtx.save(); |
4423 | 4284 | tempCtx.translate(Width, 0); |
4424 | 4285 | tempCtx.scale(-1, 1); |
4425 | 4286 | tempCtx.drawImage(tempImg, 0, 0); |
4287 | + | |
4288 | + if ($rootScope.isHighLight == true) { | |
4289 | + var tempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId; | |
4290 | + $scope.highlightTempTransparencyCanvas(tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, | |
4291 | + XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId); | |
4292 | + } | |
4426 | 4293 | } |
4427 | 4294 | else { |
4428 | 4295 | tempCtx.drawImage(tempImg, 0, 0); |
4429 | 4296 | |
4297 | + var tempCanvasID = 'transparencyTempCanvas_' + bodyRegionId; | |
4298 | + | |
4299 | + if ($rootScope.isHighLight == true) { | |
4300 | + $scope.highlightTempTransparencyCanvas(tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, | |
4301 | + YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId); | |
4302 | + | |
4303 | + } | |
4304 | + | |
4430 | 4305 | } |
4431 | - // debugger; | |
4432 | 4306 | var tempCanvasID; |
4433 | 4307 | |
4434 | 4308 | if (IsMirror == 'Yes') { |
... | ... | @@ -4443,106 +4317,33 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
4443 | 4317 | } |
4444 | 4318 | |
4445 | 4319 | |
4446 | - //check if transparency is activated | |
4447 | - | |
4448 | - | |
4449 | - var transNumber = $scope.transNumber;//txtTransparencyChange.value; | |
4450 | - // debugger; | |
4451 | - //this changes the transparency when transparency is already activated and user resizes or chage the layer | |
4452 | - | |
4453 | - var imageD = tempCtx.getImageData(0, 0, Width, Height); | |
4454 | - | |
4455 | - | |
4456 | - var tempCtx = document.getElementById(tempCanvasID).getContext('2d'); | |
4457 | - | |
4458 | - //keep the original image on temp canavs to use it in changing transparency | |
4459 | - | |
4460 | - | |
4461 | - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { | |
4462 | - var modestyTempCanvasId = 'tempCanvasModesty_' + bodyRegionId; | |
4463 | - if (document.getElementById(modestyTempCanvasId) != undefined || document.getElementById(modestyTempCanvasId) != null) { | |
4464 | - var contxModesty = document.getElementById(modestyTempCanvasId).getContext('2d'); | |
4465 | - var tbTempCanvas = document.getElementById(tempCanvasID) | |
4466 | - contxModesty.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage); | |
4467 | - | |
4468 | - } | |
4469 | - } | |
4470 | - else { | |
4471 | - | |
4472 | - if (document.getElementById('tempCanvas') != null && document.getElementById('tempCanvas') != undefined) { | |
4473 | - var contx = document.getElementById('tempCanvas').getContext('2d'); | |
4474 | - var tbTempCanvas = document.getElementById(tempCanvasID) | |
4475 | - contx.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage); | |
4476 | - | |
4477 | - } | |
4478 | - } | |
4479 | - | |
4480 | - // get the image data values | |
4481 | - | |
4482 | - var imageData = imageD.data; | |
4483 | - var length = imageData.length; | |
4484 | - | |
4485 | - //change background of image from transparent to white | |
4486 | - | |
4487 | - // set every fourth value to 50 | |
4488 | - for (var i = 3; i < length; i += 4) { | |
4489 | - //NIKITA | |
4490 | - if ($scope.voId == "9" || $scope.voId == "11") { | |
4320 | + | |
4321 | + if ($rootScope.isHighLight != true) { | |
4322 | + | |
4491 | 4323 | |
4492 | - if (imageData[i] == 0) { | |
4324 | + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { | |
4325 | + var modestyTempCanvasId = 'tempCanvasModesty_' + bodyRegionId; | |
4326 | + if (document.getElementById(modestyTempCanvasId) != undefined || document.getElementById(modestyTempCanvasId) != null) { | |
4327 | + var contxModesty = document.getElementById(modestyTempCanvasId).getContext('2d'); | |
4328 | + var tbTempCanvas = document.getElementById(tempCanvasID) | |
4329 | + contxModesty.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage); | |
4493 | 4330 | |
4494 | 4331 | } |
4495 | - else { | |
4496 | - imageData[i] = ((255) * (parseInt(transNumber))) / 100; | |
4497 | - } | |
4498 | 4332 | } |
4499 | 4333 | else { |
4500 | - if (imageData[i] == 0) { | |
4501 | 4334 | |
4502 | - } | |
4503 | - else { | |
4504 | - imageData[i] = ((255) * (parseInt(transNumber))) / 100; | |
4335 | + if (document.getElementById('tempCanvas') != null && document.getElementById('tempCanvas') != undefined) { | |
4336 | + var contx = document.getElementById('tempCanvas').getContext('2d'); | |
4337 | + var tbTempCanvas = document.getElementById(tempCanvasID) | |
4338 | + contx.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage); | |
4339 | + | |
4505 | 4340 | } |
4506 | 4341 | } |
4507 | - } | |
4508 | - | |
4509 | - | |
4510 | - tempCtx.putImageData(imageD, 0, 0); | |
4511 | - | |
4512 | - var ctx; | |
4513 | - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { | |
4514 | - ctx = document.getElementById(modestyTransCanvasId).getContext('2d'); | |
4515 | - } | |
4516 | - else | |
4517 | - ctx = transparencyCanvas.getContext('2d'); | |
4518 | 4342 | |
4343 | + $scope.DrawOnTBWithSelectedTransparency(tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId); | |
4519 | 4344 | |
4520 | - var TrtempCanvasID | |
4521 | - if (IsMirror == 'Yes') { | |
4522 | - TrtempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId; | |
4523 | - } | |
4524 | - else { | |
4525 | - //if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { | |
4526 | - // TrtempCanvasID = 'modestyTransparencyTempCanvas_' + bodyRegionId; | |
4527 | - //} | |
4528 | - //else | |
4529 | - TrtempCanvasID = 'transparencyTempCanvas_' + bodyRegionId; | |
4530 | 4345 | } |
4531 | - | |
4532 | - var tmpCanvasContext = document.getElementById(TrtempCanvasID);//.getContext('2d'); | |
4533 | - | |
4534 | - ctx.drawImage(tmpCanvasContext, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage) | |
4535 | - | |
4536 | - | |
4537 | - XforCopyImage = 0; | |
4538 | - YforCopyImage = 0; | |
4539 | - WidthforCopyImage = 0; | |
4540 | - HeightforCopyImage = 0; | |
4541 | - XforTransImage = 0; | |
4542 | - WidthforTransImage = 0; | |
4543 | - HeightforTransImage = 0; | |
4544 | - YforTransImage = 0; | |
4545 | - PreviousBodyRegionHeight = 0; | |
4346 | + | |
4546 | 4347 | |
4547 | 4348 | } |
4548 | 4349 | tempImg.src = tranparencyImgSrc;//"http://localhost/AIA/" + tranparencyImgSrc; |
... | ... | @@ -4550,7 +4351,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
4550 | 4351 | |
4551 | 4352 | } |
4552 | 4353 | |
4553 | - | |
4554 | 4354 | //mask image code |
4555 | 4355 | //draw mask for annotation |
4556 | 4356 | var tempMaskImg = new Image(); |
... | ... | @@ -4575,14 +4375,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
4575 | 4375 | |
4576 | 4376 | } |
4577 | 4377 | |
4578 | - | |
4579 | - PreviousBodyRegionHeight = HeightforTransImage; | |
4580 | - PreviousBodyRegionY = YforTransImage; | |
4581 | - PreviousBodyRegionWidth = WidthforTransImage; | |
4582 | - PreviousBodyRegionX = XforTransImage; | |
4583 | - previousBodyRegionId = bodyRegionId; | |
4584 | - | |
4585 | - | |
4586 | 4378 | //set modesty image visiblility true/false as per layer |
4587 | 4379 | |
4588 | 4380 | |
... | ... | @@ -4620,6 +4412,253 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
4620 | 4412 | |
4621 | 4413 | } |
4622 | 4414 | |
4415 | + | |
4416 | + $scope.calculateCoordinatesAndDimensionsForTB = function (Height, Width, X, Y, IsMirror, TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, bodyRegionId) { | |
4417 | + | |
4418 | + var XforCopyImage = 0; | |
4419 | + var YforCopyImage = 0; | |
4420 | + var WidthforCopyImage = 0; | |
4421 | + var HeightforCopyImage = 0; | |
4422 | + var XforTransImage = 0; | |
4423 | + var WidthforTransImage = 0; | |
4424 | + var HeightforTransImage = 0; | |
4425 | + var YforTransImage = 0; | |
4426 | + | |
4427 | + | |
4428 | + //X ends outside and start outside of bodyregion | |
4429 | + if (TransparencyBoxStartX < X && TransparencyEndX > parseInt(X) + parseInt(Width)) { | |
4430 | + XforCopyImage = 0; | |
4431 | + WidthforCopyImage = Width; | |
4432 | + WidthforTransImage = Width; | |
4433 | + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { | |
4434 | + XforTransImage = 0; | |
4435 | + } | |
4436 | + else | |
4437 | + XforTransImage = parseInt(X) - (parseInt(TransparencyBoxStartX)); | |
4438 | + } | |
4439 | + else if (TransparencyBoxStartX < X && TransparencyEndX < parseInt(X) + parseInt(Width)) { | |
4440 | + | |
4441 | + XforCopyImage = 0; | |
4442 | + | |
4443 | + WidthforCopyImage = parseInt(TransparencyEndX) - parseInt(X); | |
4444 | + | |
4445 | + WidthforTransImage = parseInt(TransparencyEndX) - parseInt(X); | |
4446 | + | |
4447 | + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { | |
4448 | + XforTransImage = 0; | |
4449 | + } | |
4450 | + else | |
4451 | + XforTransImage = parseInt(X) - (parseInt(TransparencyBoxStartX)); | |
4452 | + | |
4453 | + } | |
4454 | + else if (TransparencyBoxStartX > X && TransparencyEndX > parseInt(X) + parseInt(Width)) { | |
4455 | + | |
4456 | + XforCopyImage = parseInt(TransparencyBoxStartX) - parseInt(X); | |
4457 | + WidthforCopyImage = parseInt(X) + parseInt(Width) - parseInt(TransparencyBoxStartX); | |
4458 | + WidthforTransImage = parseInt(X) + parseInt(Width) - parseInt(TransparencyBoxStartX); | |
4459 | + | |
4460 | + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { | |
4461 | + | |
4462 | + XforTransImage = parseInt(TransparencyBoxStartX) - parseInt(X); | |
4463 | + } | |
4464 | + else | |
4465 | + XforTransImage = 0; | |
4466 | + } | |
4467 | + else if (TransparencyBoxStartX > X && TransparencyEndX < parseInt(X) + parseInt(Width)) { | |
4468 | + XforCopyImage = parseInt(TransparencyBoxStartX) - parseInt(X);//parseInt(X) + parseInt(Width) - parseInt(scope.TransparencyBoxStartX)// scope.TransparencyBoxStartX ; | |
4469 | + WidthforCopyImage = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX); | |
4470 | + WidthforTransImage = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX); | |
4471 | + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { | |
4472 | + | |
4473 | + XforTransImage = parseInt(TransparencyBoxStartX) - parseInt(X); | |
4474 | + } | |
4475 | + else | |
4476 | + XforTransImage = 0; | |
4477 | + } | |
4478 | + | |
4479 | + //calculate Y and height for tempTranparency box from where to cut the image | |
4480 | + | |
4481 | + | |
4482 | + if (TransparencyBoxStartY < Y && TransparencyBoxEndY > parseInt(Y) + parseInt(Height)) { | |
4483 | + | |
4484 | + YforCopyImage = 0; | |
4485 | + HeightforCopyImage = Height; | |
4486 | + | |
4487 | + HeightforTransImage = Height; | |
4488 | + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { | |
4489 | + YforTransImage = 0; | |
4490 | + } | |
4491 | + else | |
4492 | + YforTransImage = parseFloat(Y) - parseInt(TransparencyBoxStartY)//parseFloat(Y) - (24.4); | |
4493 | + } | |
4494 | + else if (TransparencyBoxStartY < Y && TransparencyBoxEndY < (parseInt(Y) + parseInt(Height))) { | |
4495 | + | |
4496 | + YforCopyImage = 0; | |
4497 | + HeightforCopyImage = (parseInt(TransparencyBoxEndY)) - parseInt(Y)//(parseInt(Height) + parseInt(Y)) - (parseInt(TransparencyBoxEndY) - parseInt(scope.TransparencyBoxStartY)); | |
4498 | + | |
4499 | + HeightforTransImage = (parseInt(TransparencyBoxEndY)) - parseInt(Y)// - parseInt(scope.TransparencyBoxStartY)); | |
4500 | + | |
4501 | + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { | |
4502 | + YforTransImage = 0; | |
4503 | + } | |
4504 | + else | |
4505 | + YforTransImage = parseFloat(Y) - parseInt(TransparencyBoxStartY);// - (24.4); | |
4506 | + | |
4507 | + } | |
4508 | + else if (TransparencyBoxStartY > Y && TransparencyBoxEndY > parseInt(Y) + parseInt(Height)) { | |
4509 | + | |
4510 | + YforCopyImage = parseInt(TransparencyBoxStartY) - parseInt(Y); | |
4511 | + HeightforCopyImage = parseInt(Y) + parseInt(Height) - parseInt(TransparencyBoxStartY); | |
4512 | + HeightforTransImage = parseInt(Y) + parseInt(Height) - parseInt(TransparencyBoxStartY); | |
4513 | + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { | |
4514 | + YforTransImage = parseInt(TransparencyBoxStartY) - parseInt(Y); | |
4515 | + | |
4516 | + } | |
4517 | + else | |
4518 | + YforTransImage = 0; | |
4519 | + | |
4520 | + } | |
4521 | + else if (TransparencyBoxStartY > Y && TransparencyBoxEndY < parseInt(Y) + parseInt(Height)) { | |
4522 | + | |
4523 | + YforCopyImage = parseInt(TransparencyBoxStartY) - parseInt(Y); | |
4524 | + HeightforCopyImage = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY); | |
4525 | + HeightforTransImage = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY); | |
4526 | + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { | |
4527 | + YforTransImage = parseInt(TransparencyBoxStartY) - parseInt(Y); | |
4528 | + | |
4529 | + } | |
4530 | + else | |
4531 | + YforTransImage = 0; | |
4532 | + } | |
4533 | + | |
4534 | + return { | |
4535 | + | |
4536 | + | |
4537 | + XforCopyImageTB : XforCopyImage, | |
4538 | + YforCopyImageTB: YforCopyImage, | |
4539 | + WidthforCopyImageTB: WidthforCopyImage, | |
4540 | + HeightforCopyImageTB: HeightforCopyImage, | |
4541 | + XforTransImageTB: XforTransImage, | |
4542 | + WidthforTransImageTB: WidthforTransImage, | |
4543 | + HeightforTransImageTB: HeightforTransImage, | |
4544 | + YforTransImageTB: YforTransImage | |
4545 | + | |
4546 | + } | |
4547 | + } | |
4548 | + | |
4549 | + $scope.highlightTempTransparencyCanvas = function (tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId) { | |
4550 | + | |
4551 | + var tempTransCanvas = document.getElementById(tempCanvasID); | |
4552 | + var tempCanvasContext = tempTransCanvas.getContext('2d'); | |
4553 | + | |
4554 | + var dataURL = tempTransCanvas.toDataURL(); | |
4555 | + | |
4556 | + var img = new Image(); | |
4557 | + img.src = dataURL; | |
4558 | + | |
4559 | + img.onload = function () { | |
4560 | + | |
4561 | + var DAData = new BitmapData(parseInt(tempTransCanvas.width), parseInt(tempTransCanvas.height)); | |
4562 | + DAData.draw(img); | |
4563 | + | |
4564 | + var colorMode = $scope.applyGrayMatrix(img, tempCanvasContext); | |
4565 | + | |
4566 | + if (colorMode != undefined || colorMode != null) { | |
4567 | + | |
4568 | + var zeroPoint = new Point(); | |
4569 | + | |
4570 | + DAData.applyFilter(DAData, DAData.rect, zeroPoint, colorMode); | |
4571 | + | |
4572 | + | |
4573 | + tempCanvasContext.putImageData(DAData.data, 0, 0); | |
4574 | + | |
4575 | + //keep the original image on temp canavs to use it in changing transparency | |
4576 | + | |
4577 | + if (document.getElementById('tempCanvas') != null) { | |
4578 | + | |
4579 | + var contx = document.getElementById('tempCanvas').getContext('2d'); | |
4580 | + var tbTempCanvas = document.getElementById(tempCanvasID) | |
4581 | + contx.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage); | |
4582 | + | |
4583 | + } | |
4584 | + | |
4585 | + $scope.DrawOnTBWithSelectedTransparency(tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId); | |
4586 | + } | |
4587 | + } | |
4588 | + } | |
4589 | + | |
4590 | + | |
4591 | + $scope.DrawOnTBWithSelectedTransparency = function (tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId) { | |
4592 | + | |
4593 | + var transNumber = $scope.transNumber;//txtTransparencyChange.value; | |
4594 | + //this changes the transparency when transparency is already activated and user resizes or chage the layer | |
4595 | + | |
4596 | + var tempCtx = document.getElementById(tempCanvasID).getContext('2d'); | |
4597 | + | |
4598 | + var imageD = tempCtx.getImageData(0, 0, Width, Height); | |
4599 | + var imageData = imageD.data; | |
4600 | + var length = imageData.length; | |
4601 | + | |
4602 | + | |
4603 | + // set every fourth value to the desired number of transparency | |
4604 | + for (var i = 3; i < length; i += 4) { | |
4605 | + if ($scope.voId == "9" || $scope.voId == "11") { | |
4606 | + | |
4607 | + if (imageData[i] == 0) { | |
4608 | + | |
4609 | + } | |
4610 | + else { | |
4611 | + imageData[i] = ((255) * (parseInt(transNumber))) / 100; | |
4612 | + } | |
4613 | + } | |
4614 | + else { | |
4615 | + imageData[i] = ((255) * (parseInt(transNumber))) / 100; | |
4616 | + } | |
4617 | + } | |
4618 | + | |
4619 | + | |
4620 | + tempCtx.putImageData(imageD, 0, 0); | |
4621 | + | |
4622 | + | |
4623 | + $scope.widthOfImage = WidthforTransImage; | |
4624 | + $scope.heightOfImage = HeightforTransImage; | |
4625 | + $scope.xOfImage = XforTransImage; | |
4626 | + $scope.yOfImage = YforTransImage; | |
4627 | + | |
4628 | + var ctx = transparencyCanvas.getContext('2d'); | |
4629 | + | |
4630 | + | |
4631 | + var tmpCanvasContext = document.getElementById(tempCanvasID);//.getContext('2d'); | |
4632 | + | |
4633 | + | |
4634 | + | |
4635 | + var ctx; | |
4636 | + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) { | |
4637 | + var modestyTransCanvasId = 'modestyTransCanavs_' + bodyRegionId | |
4638 | + ctx = document.getElementById(modestyTransCanvasId).getContext('2d'); | |
4639 | + } | |
4640 | + else | |
4641 | + ctx = transparencyCanvas.getContext('2d'); | |
4642 | + | |
4643 | + // var ctx = transparencyCanvas.getContext('2d'); | |
4644 | + ctx.drawImage(tmpCanvasContext, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage) | |
4645 | + | |
4646 | + $scope.transparencyDrawnRegions.push(bodyRegionId); | |
4647 | + | |
4648 | + | |
4649 | + $rootScope.isLoading = false; | |
4650 | + $('#spinner').css('visibility', 'hidden'); | |
4651 | + | |
4652 | + if ($scope.transparencyDrawnRegions.length == $scope.IncludedBodyRegions.length) { | |
4653 | + | |
4654 | + transparencyCanvas.style.visibility = 'visible'; | |
4655 | + $('.rectangle').remove(); | |
4656 | + | |
4657 | + | |
4658 | + } | |
4659 | + } | |
4660 | + | |
4661 | + | |
4623 | 4662 | $scope.changeTransparency = function () { |
4624 | 4663 | //this changes the transparency when user click on transparency scale(we have already set the original |
4625 | 4664 | //data on tras canvas irrespective of the trans number, so we can chnage the transparnecy of original data not the manipulated) |
... | ... | @@ -4917,6 +4956,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
4917 | 4956 | var BodyRegionDictionary = $rootScope.BodyRegionCordinatesData; |
4918 | 4957 | |
4919 | 4958 | $scope.IncludedBodyRegions = []; |
4959 | + $scope.transparencyDrawnRegions = []; | |
4920 | 4960 | // $scope.layerNo = parseInt(document.getElementById('')) |
4921 | 4961 | var counter = 0; |
4922 | 4962 | $.each(BodyRegionDictionary, function (index, value) { |
... | ... | @@ -5426,7 +5466,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
5426 | 5466 | ctx.putImageData(originalTransparencyData, 0, 0); |
5427 | 5467 | |
5428 | 5468 | |
5429 | - | |
5469 | + $scope.transparencyDrawnRegions = []; | |
5430 | 5470 | //for modesty |
5431 | 5471 | if ($rootScope.isModestyOn == true && $scope.modestyImageInfo.length > 0) { |
5432 | 5472 | $.each($scope.modestyImageInfo, function (index, value) { | ... | ... |