Commit 719175ecbdb164c033c4bf17556852e052e330f7

Authored by Amrita Vishnoi
1 parent d7a2de7a

Refs: #4463

Single Highlight is extracting well in all body view and Body System also working fine along with extract.
400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js
... ... @@ -47,6 +47,8 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
47 47 $scope.multiAnnotationIsON = false;
48 48 $scope.previousGrayImageDataVar;
49 49 $scope.previousGrayCanvas;
  50 + $rootScope.updatedImageDataList = [];
  51 + $rootScope.updatedImageMRDataList = [];
50 52  
51 53 $scope.previousSelectedTermList = [];
52 54 $scope.runningWorkers = [];
... ... @@ -1377,6 +1379,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1377 1379  
1378 1380 }
1379 1381  
  1382 +
1380 1383  
1381 1384 $scope.highLightBodyBasedOnIcolor = function (RGBColor) {
1382 1385  
... ... @@ -1442,52 +1445,29 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1442 1445 var white;
1443 1446 if (canvasId.match('_MR')) {
1444 1447 coloredImageDataVar = $rootScope.coloredImageMRCanvasList[bodyRegionId];
1445   -
1446   - if ($rootScope.isExtract == true) {
1447   - if ($scope.multiAnnotationIsON == true) {
1448   -
1449   - grayImageDataVar = $rootScope.grayImageMRDataListCurrent[bodyRegionId]
1450   - }
1451   - else
1452   - white = $rootScope.whiteImageMRDataList[bodyRegionId];
1453   - }
1454   - else {
  1448 +
1455 1449 if ($scope.multiAnnotationIsON == true) {
1456 1450  
1457   - grayImageDataVar = $rootScope.grayImageMRDataListCurrent[bodyRegionId]
  1451 + white = $rootScope.updatedImageMRDataList[bodyRegionId]
1458 1452 }
1459 1453 else
1460   - grayImageDataVar = $rootScope.grayImageMRDataList[bodyRegionId];
1461   -
1462   - }
1463   -
  1454 + white = $rootScope.whiteImageMRDataList[bodyRegionId];
1464 1455 }
1465 1456  
1466 1457 else {
1467 1458  
1468 1459 coloredImageDataVar = $rootScope.coloredImageCanvasList[bodyRegionId - 1];
1469   -
1470   - if ($rootScope.isExtract == true) {
  1460 +
1471 1461 if ($scope.multiAnnotationIsON == true) {
1472 1462  
1473   - grayImageDataVar = $rootScope.grayImageDataListCurrent[bodyRegionId - 1]
  1463 + grayImageDataVar = $rootScope.updatedImageDataList[bodyRegionId - 1]
1474 1464 }
1475 1465 else
  1466 + {
1476 1467 white = $rootScope.whiteImageDataList[bodyRegionId - 1];
1477   - }
1478   - else {
1479   - if ($scope.multiAnnotationIsON == true) {
1480   - grayImageDataVar = $rootScope.grayImageDataListCurrent[bodyRegionId - 1]
1481 1468 }
1482   - else
1483   - grayImageDataVar = $rootScope.grayImageDataList[bodyRegionId - 1];
1484   -
1485   - }
1486   -
1487   -
  1469 +
1488 1470 }
1489   -
1490   - if ($rootScope.isExtract == true) {
1491 1471 var worker = new Worker('extract-wp.js');
1492 1472  
1493 1473 //push workers in array to further used the refernece to delete the workers
... ... @@ -1504,28 +1484,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1504 1484 'canvasId': canvasId
1505 1485  
1506 1486 });
1507   - }
1508   - else {
1509   -
1510   - var worker = new Worker('term-number-wp.js');
1511   -
1512   - //push workers in array to further used the refernece to delete the workers
1513   - $scope.runningWorkers.push({ 'workerName': worker })
1514   -
1515   - // console.log('for bodyRegionId = ' + bodyRegionId+ ', time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"))
1516   - worker.postMessage({
1517   -
1518   - 'termList': TermList,
1519   - 'maskCanvasData': maskData,
1520   - 'coloredImageData': coloredImageDataVar,
1521   - 'grayImageData': grayImageDataVar,
1522   - 'bodyRegionId': bodyRegionId,
1523   - 'canvasId': canvasId
1524   -
1525   - });
1526   - }
1527   -
1528   -
  1487 +
1529 1488 //}
1530 1489  
1531 1490 worker.onmessage = function (e) {
... ... @@ -1648,7 +1607,10 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1648 1607 worker.onmessage = function (e) {
1649 1608 console.log('callback for e.data.bodyRegionId: ' + e.data.bodyRegionId + ', time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"));
1650 1609  
  1610 + debugger;
1651 1611  
  1612 + var highlightedPortion;
  1613 +
1652 1614 var updatedData = e.data.value;
1653 1615  
1654 1616 var bodyRegionId = e.data.bodyRegionId;
... ... @@ -1664,15 +1626,17 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1664 1626  
1665 1627  
1666 1628 grayCanvasContext.putImageData(updatedData, 0, 0);
1667   - // }
1668 1629  
1669 1630  
1670 1631 // worker.terminate();
1671 1632  
1672   - if (canvasId.match('_MR'))
  1633 + if (canvasId.match('_MR')) {
1673 1634 $rootScope.grayImageMRDataListCurrent[bodyRegionId] = updatedData;
  1635 + $rootScope.whiteImageMRDataList[bodyRegionId] = updatedData;
  1636 + }
1674 1637 else
1675 1638 $rootScope.grayImageDataListCurrent[bodyRegionId - 1] = updatedData;
  1639 + $rootScope.whiteImageDataList[bodyRegionId - 1] = updatedData;
1676 1640  
1677 1641 };
1678 1642 worker.onerror = function (e) {
... ... @@ -3770,14 +3734,14 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
3770 3734  
3771 3735 var colorMode;
3772 3736  
3773   - //if ($scope.isExtract == true)
3774   - //{
3775   - // colorMode = $scope.applyWhiteMatrix(img,context_gray);
3776   - //}
3777   - //else
3778   - //{
  3737 + if ($scope.isExtract == true)
  3738 + {
  3739 + colorMode = $scope.applyWhiteMatrix(img,context_gray);
  3740 + }
  3741 + else
  3742 + {
3779 3743 colorMode = $scope.applyGrayMatrix(img, context_gray);
3780   - //}
  3744 + }
3781 3745  
3782 3746 var zeroPoint = new Point();
3783 3747  
... ... @@ -3788,152 +3752,49 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
3788 3752 var grayImageData = context_gray.getImageData(0, 0, width, ht);
3789 3753 var grayImageImageDataVar = grayImageData.data;
3790 3754  
3791   - if (value.haveMirror == 'true') {
3792   - $rootScope.grayImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData;
  3755 + if ($scope.isExtract == true) {
  3756 + if (value.haveMirror == 'true') {
  3757 + $rootScope.whiteImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData;
  3758 + }
  3759 + else {
  3760 + //$rootScope.coloredImageMRCanvasList[parseInt(value.bodyRegionId - 1)] = 1;
  3761 +
  3762 + $rootScope.whiteImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData;
  3763 + }
3793 3764 }
3794 3765 else {
3795   - //$rootScope.coloredImageMRCanvasList[parseInt(value.bodyRegionId - 1)] = 1;
3796 3766  
3797   - $rootScope.grayImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData;
  3767 + if (value.haveMirror == 'true') {
  3768 + $rootScope.grayImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData;
  3769 + }
  3770 + else {
  3771 + //$rootScope.coloredImageMRCanvasList[parseInt(value.bodyRegionId - 1)] = 1;
  3772 +
  3773 + $rootScope.grayImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData;
  3774 + }
3798 3775 }
3799 3776 }
3800 3777  
3801 3778 $timeout(function () { imageCanvas.style.visibility = 'visible' }, 50);
3802 3779 })
3803 3780  
  3781 + if ($rootScope.isExtract == true) {
  3782 + if ($rootScope.previousHighlightList.length > 0)
  3783 + {
  3784 + angular.forEach($rootScope.previousHighlightList, function (value, key)
  3785 + {
  3786 + $timeout(function () { $scope.HighlightBodyOnExtract(value) }, 50);
  3787 +
  3788 + // to do
  3789 + });
  3790 + }
  3791 + }
3804 3792  
3805   - //if ($scope.previousSelectedTermList.length > 0) {
3806   -
3807   - // //alert('previousSelectedTermList length: ' + $scope.previousSelectedTermList.length);
3808   -
3809   - // for (var i = 0; i < $scope.previousSelectedTermList.length; i++) {
3810   - // $scope.highLightBodyBasedOnIcolor($scope.previousSelectedTermList[i]);
3811   -
3812   - // }
3813   - //}
3814   -
3815   - }
3816   - }
3817   -
3818   - // have extract code as well
3819   - //$scope.highLightBody = function () {
3820   -
3821   -
3822   - // if ($rootScope.isHighLight == true) {
3823   -
3824   - // angular.forEach($scope.ColoredImageSRC, function (value, key) {
3825   - // var id;
3826   - // if (value.haveMirror == 'true') {
3827   - // id = 'imageCanvas' + value.bodyRegionId + '_MR';
3828   - // }
3829   - // else {
3830   - // id = 'imageCanvas' + value.bodyRegionId;
3831   - // }
3832   -
3833   - // var imageCanvas = document.getElementById(id);
3834   -
3835   - // //var coloredCanvasID = 'imageCanvas' + bodyRegionId;
3836   - // //var coloredCanvas = document.getElementById(coloredCanvasID);
3837   -
3838   - // var width = value.Width;
3839   - // var ht = value.Height;
3840   -
3841   - // var coloredCanvasContext = imageCanvas.getContext("2d");
3842   - // var coloredImageData = coloredCanvasContext.getImageData(0, 0, width, ht);
3843   - // var coloredImageDataVar = coloredImageData;
3844   -
3845   -
3846   - // if (value.haveMirror == 'true') {
3847   - // $rootScope.coloredImageMRCanvasList[parseInt(value.bodyRegionId)] = coloredImageDataVar;
3848   - // }
3849   - // else {
3850   - // //$rootScope.coloredImageMRCanvasList[parseInt(value.bodyRegionId - 1)] = 1;
3851   -
3852   - // $rootScope.coloredImageCanvasList[parseInt(value.bodyRegionId - 1)] = coloredImageDataVar;
3853   -
3854   - // }
3855   -
3856   -
3857   - // var context_gray = imageCanvas.getContext('2d');
3858   -
3859   -
3860   - // var dataURL = imageCanvas.toDataURL();
3861   -
3862   -
3863   - // var img = new Image();
3864   -
3865   - // img.src = dataURL;
3866   -
3867   -
3868   -
3869   - // img.onload = function () {
3870   - // //console.log(Math.max(img.width) + ', ' + Math.max(img.height))
3871   -
3872   - // var DAData = new BitmapData(Math.max(img.width), Math.max(img.height));
3873   - // DAData.draw(img);
3874   -
3875   - // var colorMode;
3876   -
3877   - // if ($rootScope.isExtract == true) {
3878   - // colorMode = $scope.applyWhiteMatrix();
3879   - // }
3880   - // else {
3881   - // colorMode = $scope.applyGrayMatrix();
3882   - // }
3883   - // // debugger;
3884   -
3885   - // var zeroPoint = new Point();
3886   - // DAData.applyFilter(DAData, DAData.rect, zeroPoint, colorMode);
3887   -
3888   - // context_gray.putImageData(DAData.data, 0, 0);
3889   -
3890   - // //2.
3891   - // var grayImageData = context_gray.getImageData(0, 0, width, ht);
3892   - // var grayImageImageDataVar = grayImageData.data;
3893   -
3894   - // if ($rootScope.isExtract == true) {
3895   -
3896   - // if (value.haveMirror == 'true') {
3897   - // $rootScope.whiteImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData;
3898   - // }
3899   - // else {
3900   - // //$rootScope.coloredImageMRCanvasList[parseInt(value.bodyRegionId - 1)] = 1;
3901   -
3902   - // $rootScope.whiteImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData;
3903   -
3904   - // }
3905   - // }
3906   -
3907   - // else {
3908   - // if (value.haveMirror == 'true') {
3909   - // $rootScope.grayImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData;
3910   - // }
3911   - // else {
3912   - // //$rootScope.coloredImageMRCanvasList[parseInt(value.bodyRegionId - 1)] = 1;
3913   -
3914   - // $rootScope.grayImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData;
3915   - // }
3916   - // }
3917   - // }
3918   -
3919   - // $timeout(function () { imageCanvas.style.visibility = 'visible' }, 50);
3920   - // })
3921   -
3922   - // if ($rootScope.isExtract == true) {
3923   - // if ($rootScope.previousHighlightList.length > 0)
3924   - // {
3925   - // angular.forEach($rootScope.previousHighlightList, function (value, key)
3926   - // {
3927   - // $timeout(function () { $scope.highLightBodyBasedOnIcolor(value) }, 50);
3928   -
3929   - // // to do
3930   - // });
3931   - // }
3932   - // }
3933   -
3934   - // }
3935   - //}
  3793 + }
  3794 + }
3936 3795  
  3796 +
  3797 +
3937 3798  
3938 3799  
3939 3800 $scope.applyGrayMatrix = function (img, context_gray) {
... ...