Commit 625f3c3d47458c034387e633078bde51c3244e61

Authored by Nikita Kulshreshtha
1 parent d623ff51

everthing is drawn at appropraite location.

Black/ gray issue in modesty image
400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js
... ... @@ -3913,8 +3913,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
3913 3913 function mouseUpListener(e) {
3914 3914  
3915 3915 $scope.isTBDrawnOnBodyRegion = false;
3916   - //alert('mouse up');
3917   - console.log('MOUSE UP');
  3916 +
3918 3917 $(".com").remove();
3919 3918 $('#dot').remove();
3920 3919 $('#bord').remove();
... ... @@ -3926,12 +3925,10 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
3926 3925 var currentMousePosition = $scope.getMousePos(e);
3927 3926  
3928 3927  
3929   - var canvasDiv = document.getElementById('canvasDiv');
3930   - var verticalScrollPosition = canvasDiv.scrollTop;
3931   - var horizontlScrollPosition = canvasDiv.scrollLeft;
  3928 + var canavsDivScrollPos = $scope.getCanavsDivScrollPosition();
3932 3929  
3933   - var TransparencyEndX = currentMousePosition.x + horizontlScrollPosition
3934   - var TransparencyBoxEndY = currentMousePosition.y + verticalScrollPosition
  3930 + var TransparencyEndX = currentMousePosition.x + canavsDivScrollPos.horizontlScrollPosition;
  3931 + var TransparencyBoxEndY = currentMousePosition.y + canavsDivScrollPos.verticalScrollPosition;
3935 3932  
3936 3933  
3937 3934 $scope.isTboxDrwan = true;
... ... @@ -3940,7 +3937,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
3940 3937 $scope.TransparencyEndX = TransparencyEndX;
3941 3938 $scope.TransparencyBoxEndY = TransparencyBoxEndY;
3942 3939  
3943   - $scope.layerNumberBeforeTrans = parseInt($('#txtlayerNumber').val());
  3940 + $scope.layerNumberBeforeTBDraw = parseInt($('#txtlayerNumber').val());
3944 3941  
3945 3942 //draw temp box to store the canvas data with original transparecy
3946 3943 if (document.getElementById('tempCanvas') != null) {
... ... @@ -3968,18 +3965,18 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
3968 3965  
3969 3966 $scope.IncludedBodyRegions = [];
3970 3967 $scope.transparencyDrawnRegions = [];
3971   - ////debugger;
  3968 +
3972 3969 $.each(BodyRegionDictionary, function (index, value) {
3973   - // alert(' $.each(BodyRegionDictionary1')
3974   - var transparencyBoxHeight = parseInt(TransparencyBoxEndY) - parseInt($scope.TransparencyBoxStartY);
3975   - var transparencyBoxWidth = parseInt(TransparencyEndX) - parseInt($scope.TransparencyBoxStartX);
3976   - var transparencyBoxBottom = parseInt($scope.TransparencyBoxStartY) + parseInt(transparencyBoxHeight);
3977   - var transparencyBoxRight = parseInt($scope.TransparencyBoxStartX) + parseInt(transparencyBoxWidth);
3978   - // alert(' $.each(BodyRegionDictionary2. transparencyBoxHeight: ' + transparencyBoxHeight + ',transparencyBoxBottom: ' + transparencyBoxBottom+', transparencyBoxRight: '+transparencyBoxRight)
3979   - var bodyRegionRight = parseInt(value.X) + parseInt(value.Width);
3980   - var bodyRegionBottom = parseInt(value.Y) + parseInt(value.Height);
  3970 +
3981 3971  
  3972 + var tBoxDimesions = $scope.getTBoxDimesions($scope.TransparencyBoxStartX, TransparencyEndX, $scope.TransparencyBoxStartY, TransparencyBoxEndY, value.X, value.Y, value.Height, value.Width);
3982 3973  
  3974 + var transparencyBoxHeight = tBoxDimesions.transparencyBoxHeight;
  3975 + var transparencyBoxWidth = tBoxDimesions.transparencyBoxWidth;
  3976 + var transparencyBoxBottom = tBoxDimesions.transparencyBoxBottom;
  3977 + var transparencyBoxRight = tBoxDimesions.transparencyBoxRight;
  3978 + var bodyRegionRight = tBoxDimesions.bodyRegionRight;
  3979 + var bodyRegionBottom = tBoxDimesions.bodyRegionBottom;
3983 3980  
3984 3981 var transparencyCanvas = document.createElement('canvas');
3985 3982 var tBox = document.getElementById('transparencyCanvas');
... ... @@ -3995,7 +3992,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
3995 3992 transparencyCanvas.style.border = "black 1px solid";
3996 3993 transparencyCanvas.style.backgroundColor = "transparent";
3997 3994 transparencyCanvas.style.zIndex = 200;
3998   - // transparencyCanvas.style.visibility = 'hidden';
3999 3995 document.getElementById('canvasDiv').appendChild(transparencyCanvas);
4000 3996 $scope.transparencyChangeCounter = 0;
4001 3997  
... ... @@ -4032,14 +4028,15 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4032 4028 //for modesty
4033 4029 if ($rootScope.isModestyOn == true && $scope.modestyImageInfo.length > 0) {
4034 4030 $.each($scope.modestyImageInfo, function (index, value) {
4035   - // alert(' $.each(BodyRegionDictionary1')
4036   - var transparencyBoxHeight = parseInt(TransparencyBoxEndY) - parseInt($scope.TransparencyBoxStartY);
4037   - var transparencyBoxWidth = parseInt(TransparencyEndX) - parseInt($scope.TransparencyBoxStartX);
4038   - var transparencyBoxBottom = parseInt($scope.TransparencyBoxStartY) + parseInt(transparencyBoxHeight);
4039   - var transparencyBoxRight = parseInt($scope.TransparencyBoxStartX) + parseInt(transparencyBoxWidth);
4040   - // alert(' $.each(BodyRegionDictionary2. transparencyBoxHeight: ' + transparencyBoxHeight + ',transparencyBoxBottom: ' + transparencyBoxBottom+', transparencyBoxRight: '+transparencyBoxRight)
4041   - var bodyRegionRight = parseInt(value.x) + parseInt(value.Width);
4042   - var bodyRegionBottom = parseInt(value.y) + parseInt(value.Height);
  4031 +
  4032 + var tBoxDimesions = $scope.getTBoxDimesions($scope.TransparencyBoxStartX, TransparencyEndX, $scope.TransparencyBoxStartY, TransparencyBoxEndY, value.x, value.y, value.Height, value.Width);
  4033 +
  4034 + var transparencyBoxHeight = tBoxDimesions.transparencyBoxHeight;
  4035 + var transparencyBoxWidth = tBoxDimesions.transparencyBoxWidth;
  4036 + var transparencyBoxBottom = tBoxDimesions.transparencyBoxBottom;
  4037 + var transparencyBoxRight = tBoxDimesions.transparencyBoxRight;
  4038 + var bodyRegionRight = tBoxDimesions.bodyRegionRight;
  4039 + var bodyRegionBottom = tBoxDimesions.bodyRegionBottom;
4043 4040  
4044 4041 if ($scope.TransparencyBoxStartX <= bodyRegionRight && value.x <= transparencyBoxRight && $scope.TransparencyBoxStartY <= bodyRegionBottom && value.y <= transparencyBoxBottom) {
4045 4042  
... ... @@ -4078,6 +4075,34 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4078 4075 $('#btnIdentity').addClass('btn-primary');
4079 4076 }
4080 4077  
  4078 + $scope.getCanavsDivScrollPosition = function () {
  4079 +
  4080 + var canvasDiv = document.getElementById('canvasDiv');
  4081 + return{
  4082 + verticalScrollPosition : canvasDiv.scrollTop,
  4083 + horizontlScrollPosition : canvasDiv.scrollLeft
  4084 + }
  4085 +
  4086 + }
  4087 +
  4088 + $scope.getTBoxDimesions = function (TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, X, Y, Height, Width) {
  4089 +
  4090 + var tBoxHeight = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY);
  4091 + var tBoxWidth = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX);
  4092 + var tBoxBottom = parseInt(TransparencyBoxStartY) + parseInt(tBoxHeight);
  4093 + var tBoxRight = parseInt(TransparencyBoxStartX) + parseInt(tBoxWidth);
  4094 +
  4095 + return{
  4096 +
  4097 + transparencyBoxHeight: tBoxHeight,
  4098 + transparencyBoxWidth: tBoxWidth,
  4099 + transparencyBoxBottom: tBoxBottom,
  4100 + transparencyBoxRight: tBoxRight,
  4101 + bodyRegionRight : parseInt(X) + parseInt(Width),
  4102 + bodyRegionBottom : parseInt(Y) + parseInt(Height)
  4103 + }
  4104 + }
  4105 +
4081 4106 $scope.loadTransparencyImage = function (bodyRegionId, Height, Width, X, Y, IsMirror, TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, scope, isLayerChanged, isTransparencyChanged) {
4082 4107  
4083 4108  
... ... @@ -4089,16 +4114,16 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4089 4114 TransparencyBoxEndY = parseInt(transparencyCanvas.height) + parseInt(TransparencyBoxStartY);
4090 4115  
4091 4116  
4092   - var dimensions = $scope.calculateCoordinatesAndDimensionsForTB(Height, Width, X, Y, IsMirror, TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, bodyRegionId);
  4117 + var TBImageDimensions = $scope.calculateDimensionsForTBImage(Height, Width, X, Y, IsMirror, TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, bodyRegionId);
4093 4118  
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;
  4119 + var XforCopyImage = TBImageDimensions.XforCopyImageTB;
  4120 + var YforCopyImage = TBImageDimensions.YforCopyImageTB;
  4121 + var WidthforCopyImage = TBImageDimensions.WidthforCopyImageTB;
  4122 + var HeightforCopyImage = TBImageDimensions.HeightforCopyImageTB;
  4123 + var XforTransImage = TBImageDimensions.XforTransImageTB;
  4124 + var WidthforTransImage = TBImageDimensions.WidthforTransImageTB;
  4125 + var HeightforTransImage = TBImageDimensions.HeightforTransImageTB;
  4126 + var YforTransImage = TBImageDimensions.YforTransImageTB;
4102 4127  
4103 4128 //0. get current layer number
4104 4129 if ($scope.isResized) {
... ... @@ -4106,13 +4131,12 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4106 4131 }
4107 4132 else if (isLayerChanged) {
4108 4133  
4109   -
4110 4134 }
4111 4135 else {
4112 4136  
4113 4137 var tranparencyLayer;
4114 4138  
4115   - var currentLayer = $scope.layerNumberBeforeTrans;
  4139 + var currentLayer = $scope.layerNumberBeforeTBDraw;
4116 4140  
4117 4141 if (currentLayer == $rootScope.totalLayers) {
4118 4142  
... ... @@ -4135,8 +4159,8 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4135 4159  
4136 4160 var tranparencyImgSrc;
4137 4161 var tranparencyMaskImgSrc;
4138   - //for modesty image
4139   - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg')))// == "2" || bodyRegionId == "3")) {
  4162 +
  4163 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg')))
4140 4164 {
4141 4165 var modestyBodyRegionData = new jinqJs()
4142 4166 .from($scope.modestyImageInfo)
... ... @@ -4144,51 +4168,41 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4144 4168 .select();
4145 4169 tranparencyImgSrc = modestyBodyRegionData[0].SRC;
4146 4170 }
4147   -
4148   - //modesty end
4149   -
4150   - //1. get the image source
4151   -
4152 4171 else {
4153 4172 tranparencyImgSrc = $scope.GetImageSource(bodyRegionId);
4154 4173 tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc);
4155 4174 }
4156 4175  
4157   -
  4176 + //remove old canvases
4158 4177 var oldCanvas;
4159   -
4160   - if (IsMirror == 'Yes') {
4161   - oldCanvas = document.getElementById('transparencyTempCanvas_MR_' + bodyRegionId)
4162   - }
4163   - else {
4164   -
4165   - oldCanvas = document.getElementById('transparencyTempCanvas_' + bodyRegionId)
4166   -
4167   - }
4168   -
4169   - if (oldCanvas != null) {
4170   - document.getElementById('canvasDiv').removeChild(oldCanvas);
4171   - }
4172   -
4173   - //remove tempmask canvas
4174 4178 var oldtempTransCanvasMask;
4175 4179 var oldtempTransCanvasMaskMR;
  4180 +
4176 4181 if (IsMirror == 'Yes') {
  4182 + oldCanvas = document.getElementById('transparencyTempCanvas_MR_' + bodyRegionId);
4177 4183 oldtempTransCanvasMaskMR = document.getElementById('transparencyTempCanvasMask_MR' + bodyRegionId + '_mci');
4178 4184 oldtempTransCanvasMask = document.getElementById('transparencyTempCanvasMask_' + bodyRegionId + '_mci');
4179 4185  
4180 4186 if (oldtempTransCanvasMaskMR != null) {
4181 4187 document.getElementById('canvasDiv').removeChild(oldtempTransCanvasMaskMR);
4182 4188 }
  4189 +
4183 4190 }
4184 4191 else {
  4192 +
  4193 + oldCanvas = document.getElementById('transparencyTempCanvas_' + bodyRegionId)
4185 4194 oldtempTransCanvasMask = document.getElementById('transparencyTempCanvasMask_' + bodyRegionId + '_mci');
4186 4195  
4187 4196 }
  4197 +
  4198 + if (oldCanvas != null) {
  4199 + document.getElementById('canvasDiv').removeChild(oldCanvas);
  4200 + }
4188 4201 if (oldtempTransCanvasMask != null) {
4189 4202 document.getElementById('canvasDiv').removeChild(oldtempTransCanvasMask);
4190 4203 }
4191   -
  4204 +
  4205 +
4192 4206 var transparencyTempCanvas = document.createElement('canvas');
4193 4207 var transparencyTempcanavsMask = document.createElement('canvas');
4194 4208 //if mirror then draw mask image for non mirrored body region for annotation
... ... @@ -4275,27 +4289,40 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4275 4289 if (tranparencyImgSrc != undefined) {
4276 4290 var tempImg = new Image();
4277 4291  
  4292 + var tempCanvasID;
  4293 +
  4294 + if (IsMirror == 'Yes') {
  4295 + tempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId;
  4296 + }
  4297 + else {
  4298 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4299 + tempCanvasID = 'transparencyTempCanvas_' + bodyRegionId;//bodyRegionId;
  4300 + }
  4301 + else
  4302 + tempCanvasID = 'transparencyTempCanvas_' + bodyRegionId;
  4303 + }
4278 4304  
4279 4305 tempImg.onload = function () {
  4306 +
4280 4307 var tempCtx = transparencyTempCanvas.getContext('2d');
4281 4308  
4282 4309 if (IsMirror == 'Yes') {
  4310 + //debugger;
4283 4311 tempCtx.save();
4284 4312 tempCtx.translate(Width, 0);
4285 4313 tempCtx.scale(-1, 1);
4286 4314 tempCtx.drawImage(tempImg, 0, 0);
4287 4315  
4288 4316 if ($rootScope.isHighLight == true) {
4289   - var tempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId;
  4317 + // var tempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId;
4290 4318 $scope.highlightTempTransparencyCanvas(tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage,
4291 4319 XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId);
4292 4320 }
4293 4321 }
4294 4322 else {
  4323 +
4295 4324 tempCtx.drawImage(tempImg, 0, 0);
4296 4325  
4297   - var tempCanvasID = 'transparencyTempCanvas_' + bodyRegionId;
4298   -
4299 4326 if ($rootScope.isHighLight == true) {
4300 4327 $scope.highlightTempTransparencyCanvas(tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage,
4301 4328 YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId);
... ... @@ -4303,19 +4330,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4303 4330 }
4304 4331  
4305 4332 }
4306   - var tempCanvasID;
4307   -
4308   - if (IsMirror == 'Yes') {
4309   - tempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId;
4310   - }
4311   - else {
4312   - if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
4313   - tempCanvasID = 'transparencyTempCanvas_' + bodyRegionId;//bodyRegionId;
4314   - }
4315   - else
4316   - tempCanvasID = 'transparencyTempCanvas_' + bodyRegionId;
4317   - }
4318   -
  4333 +
4319 4334  
4320 4335  
4321 4336 if ($rootScope.isHighLight != true) {
... ... @@ -4324,9 +4339,9 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4324 4339 if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
4325 4340 var modestyTempCanvasId = 'tempCanvasModesty_' + bodyRegionId;
4326 4341 if (document.getElementById(modestyTempCanvasId) != undefined || document.getElementById(modestyTempCanvasId) != null) {
4327   - var contxModesty = document.getElementById(modestyTempCanvasId).getContext('2d');
  4342 + var contxModestyTemp = document.getElementById(modestyTempCanvasId).getContext('2d');
4328 4343 var tbTempCanvas = document.getElementById(tempCanvasID)
4329   - contxModesty.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage);
  4344 + contxModestyTemp.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage);
4330 4345  
4331 4346 }
4332 4347 }
... ... @@ -4338,7 +4353,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4338 4353 contx.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage);
4339 4354  
4340 4355 }
4341   - }
  4356 + }
4342 4357  
4343 4358 $scope.DrawOnTBWithSelectedTransparency(tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId);
4344 4359  
... ... @@ -4413,7 +4428,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4413 4428 }
4414 4429  
4415 4430  
4416   - $scope.calculateCoordinatesAndDimensionsForTB = function (Height, Width, X, Y, IsMirror, TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, bodyRegionId) {
  4431 + $scope.calculateDimensionsForTBImage = function (Height, Width, X, Y, IsMirror, TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, bodyRegionId) {
4417 4432  
4418 4433 var XforCopyImage = 0;
4419 4434 var YforCopyImage = 0;
... ... @@ -4573,13 +4588,23 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
4573 4588 tempCanvasContext.putImageData(DAData.data, 0, 0);
4574 4589  
4575 4590 //keep the original image on temp canavs to use it in changing transparency
  4591 + if ($rootScope.isModestyOn == true && (bodyRegionId.match('modestyImg'))) {
  4592 + var modestyTempCanvasId = 'tempCanvasModesty_' + bodyRegionId;
  4593 + if (document.getElementById(modestyTempCanvasId) != undefined || document.getElementById(modestyTempCanvasId) != null) {
  4594 + var contxModestyTemp = document.getElementById(modestyTempCanvasId).getContext('2d');
  4595 + var tbTempCanvas = document.getElementById(tempCanvasID)
  4596 + contxModestyTemp.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage);
4576 4597  
4577   - if (document.getElementById('tempCanvas') != null) {
  4598 + }
  4599 + }
  4600 + else {
  4601 + if (document.getElementById('tempCanvas') != null) {
4578 4602  
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);
  4603 + var contx = document.getElementById('tempCanvas').getContext('2d');
  4604 + var tbTempCanvas = document.getElementById(tempCanvasID)
  4605 + contx.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage);
4582 4606  
  4607 + }
4583 4608 }
4584 4609  
4585 4610 $scope.DrawOnTBWithSelectedTransparency(tempCanvasID, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage, Height, Width, bodyRegionId);
... ...