Commit d351f192f01fdc9495be21a7d0f303f5294586ba

Authored by Nikita Kulshreshtha
1 parent 01ffa18f

used timeout to resolve delay issue in highlight but its not perfect

350-UTILITIES/Parser/XMLtoJSON_utility/XMLtoJSON_utility.v12.suo
No preview for this file type
400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js
@@ -1331,39 +1331,227 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -1331,39 +1331,227 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1331 //4. 1331 //4.
1332 1332
1333 $scope.machedTermNoLocation = []; 1333 $scope.machedTermNoLocation = [];
  1334 + console.log(' TermList.length= ' + TermList.length)
  1335 +
1334 for (var i = 0; i < TermList.length; i++) { 1336 for (var i = 0; i < TermList.length; i++) {
1335 1337
1336 - var termNumber = parseInt(TermList[i]._TermNumber); 1338 + $timeout(callHight(TermList[i]._TermNumber), 5)
  1339 +
1337 1340
1338 - //Match Term No List in each bodyRegion  
1339 - $scope.getLocationsForMatchedTermsInWholeBody(termNumber);  
1340 } 1341 }
1341 } 1342 }
1342 1343
1343 - $scope.getLocationsForMatchedTermsInWholeBody = function (termNo) {  
1344 1344
1345 - for (var x = 0; x < $scope.ColoredImageSRC.length; x++) {  
1346 - // alert('called for bodyRegionId: ' + $scope.MaskImageSRC[x].bodyRegionId);  
1347 - var bodyRegionId = $scope.ColoredImageSRC[x].bodyRegionId; 1345 + function callHight(termNumber) {
1348 1346
1349 - {  
1350 - var scaledWidth = $scope.ColoredImageSRC[x].Width;  
1351 - var scaledHeight = $scope.ColoredImageSRC[x].Height; 1347 + console.log('timeout function call. termNumber = ' + termNumber + ' -time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"));
  1348 + // var termNumber = parseInt(TermList[i]._TermNumber);
  1349 +
  1350 + //Match Term No List in each bodyRegion
  1351 + $timeout($scope.getLocationsForMatchedTermsInWholeBody(termNumber, 1), 5);
  1352 + $timeout($scope.getLocationsForMatchedTermsInWholeBody(termNumber, 2), 5);
  1353 +
  1354 + $timeout($scope.getLocationsForMatchedTermsInWholeBody(termNumber, 3), 5);
  1355 +
  1356 + $timeout($scope.getLocationsForMatchedTermsInWholeBody(termNumber, 4), 5);
  1357 +
  1358 + $timeout($scope.getLocationsForMatchedTermsInWholeBody(termNumber, 5), 5);
  1359 +
  1360 + $timeout($scope.getLocationsForMatchedTermsInWholeBody(termNumber, 6), 5);
  1361 + }
  1362 + //$scope.getLocationsForMatchedTermsInWholeBody = function (termNo) {
  1363 +
  1364 + // for (var x = 0; x < $scope.ColoredImageSRC.length; x++) {
  1365 + // // alert('called for bodyRegionId: ' + $scope.MaskImageSRC[x].bodyRegionId);
  1366 + // var bodyRegionId = $scope.ColoredImageSRC[x].bodyRegionId;
  1367 +
  1368 + // {
  1369 + // var scaledWidth = $scope.ColoredImageSRC[x].Width;
  1370 + // var scaledHeight = $scope.ColoredImageSRC[x].Height;
  1371 + // //var maskImg = $scope.ColoredImageSRC[x].SRC;
  1372 +
  1373 +
  1374 + // var coloredImg = $scope.ColoredImageSRC[x].SRC;
  1375 +
  1376 + // var maskImg = $scope.GetMaskImageSource(coloredImg);
  1377 +
  1378 +
  1379 + // var scledX = $scope.ColoredImageSRC[x].x;
  1380 + // var scledY = $scope.ColoredImageSRC[x].y;
  1381 +
  1382 +
  1383 + // // 1. get mask canvas for this body region.
  1384 + // var maskCanvasID;
  1385 + // if ($scope.ColoredImageSRC[x].haveMirror == 'true') {
  1386 + // maskCanvasID = 'imageCanvas' + bodyRegionId + '_MR_mci';
  1387 + // }
  1388 + // else {
  1389 + // maskCanvasID = 'imageCanvas' + bodyRegionId + '_mci';
  1390 +
  1391 + // }
  1392 + // var maskCanvas = document.getElementById(maskCanvasID);
  1393 + // var maskCanvasContext = maskCanvas.getContext("2d");
  1394 + // var maskImgData = maskCanvasContext.getImageData(0, 0, scaledWidth, scaledHeight);
  1395 +
  1396 + // // 2. get coloured canvas for this body region.
  1397 +
  1398 +
  1399 + // var coloredImageDataVar;
  1400 + // var coloredImageDataMRVar
  1401 +
  1402 + // if ($scope.ColoredImageSRC[x].haveMirror == 'true') {
  1403 +
  1404 + // coloredImageDataVar = $rootScope.coloredImageMRCanvasList[parseInt(bodyRegionId)];
  1405 + // }
  1406 + // else {
  1407 + // coloredImageDataVar = $rootScope.coloredImageCanvasList[parseInt(bodyRegionId - 1)];
  1408 + // }
  1409 + // var grayImageDataVar;
  1410 + // var grayCanvas;
  1411 + // if ($scope.ColoredImageSRC[x].haveMirror == 'true') {
  1412 +
  1413 + // //// 3. get mask canvas for this body region._MR
  1414 + // var grayCanvasID = 'imageCanvas' + bodyRegionId + '_MR';
  1415 + // grayCanvas = document.getElementById(grayCanvasID);
  1416 + // var grayCanvasContext = grayCanvas.getContext("2d");
  1417 + // var grayImageData = grayCanvasContext.getImageData(0, 0, scaledWidth, scaledHeight);
  1418 + // grayImageDataVar = grayImageData.data;
  1419 + // }
  1420 +
  1421 + // else {
  1422 + // var grayCanvasID = 'imageCanvas' + bodyRegionId;
  1423 + // grayCanvas = document.getElementById(grayCanvasID);
  1424 + // var grayCanvasContext = grayCanvas.getContext("2d");
  1425 + // var grayImageData = grayCanvasContext.getImageData(0, 0, scaledWidth, scaledHeight);
  1426 + // grayImageDataVar = grayImageData.data;
  1427 + // }
  1428 +
  1429 + // var coloredImageDataVarMR;
  1430 + // var coloredImageDataMR
  1431 +
  1432 +
  1433 + // var counter = 0;
  1434 +
  1435 + // var imageDataVar = maskImgData.data;
  1436 +
  1437 + // // var previousBRID;
  1438 +
  1439 + // var counter = 0;
  1440 +
  1441 +
  1442 + // var n = maskImgData.data.length;
  1443 +
  1444 + // for (var i = 0; i < n; i += 4) {
  1445 +
  1446 +
  1447 + // var RED = imageDataVar[i] - 9;
  1448 + // var GREEN = imageDataVar[i + 1] - 9;
  1449 + // var BLUE = imageDataVar[i + 2] - 9;
  1450 +
  1451 + // var Red;
  1452 + // var Green;
  1453 + // var Blue;
  1454 + // var zero = "0";
  1455 +
  1456 + // if ((RED).toString().length != 2) {
  1457 + // Red = zero.concat((RED).toString())
  1458 + // }
  1459 + // else {
  1460 + // Red = (RED).toString()
  1461 + // }
  1462 + // if ((GREEN).toString().length != 2) {
  1463 + // Green = zero.concat((GREEN).toString())
  1464 + // }
  1465 + // else {
  1466 + // Green = (GREEN).toString()
  1467 +
  1468 + // }
  1469 + // if ((BLUE).toString().length != 2) {
  1470 + // Blue = zero.concat((BLUE).toString())
  1471 + // }
  1472 + // else {
  1473 + // Blue = (BLUE).toString()
  1474 +
  1475 + // }
  1476 +
  1477 + // var Icolor = (Red + Green + Blue);
  1478 + // // alert('Icolor: ' + Icolor)
  1479 +
  1480 + // if (parseInt(termNo) == parseInt(Icolor)) {
  1481 +
  1482 + // counter++;
  1483 + // var have = $scope.machedIcolorInBodyRegion.indexOf(bodyRegionId);
  1484 +
  1485 +
  1486 + // if (have == -1) {
  1487 + // $scope.machedIcolorInBodyRegion.push(bodyRegionId);
  1488 + // }
  1489 + // else {
  1490 +
  1491 + // }
  1492 +
  1493 +
  1494 + // //previousGrayColoredData = i;
  1495 + // if (coloredImageDataVar != null) {
  1496 +
  1497 +
  1498 + // var RED_coloredImage = coloredImageDataVar[i];
  1499 +
  1500 + // grayImageDataVar[i] = RED_coloredImage;
  1501 +
  1502 +
  1503 + // var GREEN_coloredImage = coloredImageDataVar[i + 1];
  1504 + // grayImageDataVar[i + 1] = GREEN_coloredImage;
  1505 +
  1506 + // var BLUE_coloredImage = coloredImageDataVar[i + 2];
  1507 + // grayImageDataVar[i + 2] = BLUE_coloredImage;
  1508 +
  1509 +
  1510 + // var ALPHA_coloredImage = coloredImageDataVar[i + 3];
  1511 + // grayImageDataVar[i + 3] = ALPHA_coloredImage;
  1512 +
  1513 +
  1514 + // }
  1515 +
  1516 + // }
  1517 +
  1518 +
  1519 + // }
  1520 +
  1521 + // grayCanvasContext.putImageData(grayImageData, 0, 0);
  1522 + // }
  1523 + // }
  1524 +
  1525 +
  1526 + //}
  1527 +
  1528 +
  1529 + $scope.getLocationsForMatchedTermsInWholeBody = function (termNo, bodyRegionId) {
  1530 + // debugger;
  1531 + //console.log('bodyRegionId = ' + bodyRegionId + '-time: ' + new Date().getTime());
  1532 + console.log('bodyRegionId = ' + bodyRegionId + '-time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"));
  1533 + var bodyRegionIdDetails = new jinqJs()
  1534 + .from($scope.ColoredImageSRC)
  1535 + .where('bodyRegionId == ' + bodyRegionId)
  1536 + .select();
  1537 +
  1538 + var scaledWidth = bodyRegionIdDetails[0].Width;
  1539 + var scaledHeight = bodyRegionIdDetails[0].Height;
1352 //var maskImg = $scope.ColoredImageSRC[x].SRC; 1540 //var maskImg = $scope.ColoredImageSRC[x].SRC;
1353 1541
1354 1542
1355 - var coloredImg = $scope.ColoredImageSRC[x].SRC; 1543 + var coloredImg = bodyRegionIdDetails[0].SRC;
1356 1544
1357 var maskImg = $scope.GetMaskImageSource(coloredImg); 1545 var maskImg = $scope.GetMaskImageSource(coloredImg);
1358 1546
1359 1547
1360 - var scledX = $scope.ColoredImageSRC[x].x;  
1361 - var scledY = $scope.ColoredImageSRC[x].y; 1548 + var scledX = bodyRegionIdDetails[0].x;
  1549 + var scledY = bodyRegionIdDetails[0].y;
1362 1550
1363 1551
1364 // 1. get mask canvas for this body region. 1552 // 1. get mask canvas for this body region.
1365 var maskCanvasID; 1553 var maskCanvasID;
1366 - if ($scope.ColoredImageSRC[x].haveMirror == 'true') { 1554 + if (bodyRegionIdDetails[0].haveMirror == 'true') {
1367 maskCanvasID = 'imageCanvas' + bodyRegionId + '_MR_mci'; 1555 maskCanvasID = 'imageCanvas' + bodyRegionId + '_MR_mci';
1368 } 1556 }
1369 else { 1557 else {
@@ -1380,7 +1568,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -1380,7 +1568,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1380 var coloredImageDataVar; 1568 var coloredImageDataVar;
1381 var coloredImageDataMRVar 1569 var coloredImageDataMRVar
1382 1570
1383 - if ($scope.ColoredImageSRC[x].haveMirror == 'true') { 1571 + if (bodyRegionIdDetails[0].haveMirror == 'true') {
1384 1572
1385 coloredImageDataVar = $rootScope.coloredImageMRCanvasList[parseInt(bodyRegionId)]; 1573 coloredImageDataVar = $rootScope.coloredImageMRCanvasList[parseInt(bodyRegionId)];
1386 } 1574 }
@@ -1389,7 +1577,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -1389,7 +1577,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1389 } 1577 }
1390 var grayImageDataVar; 1578 var grayImageDataVar;
1391 var grayCanvas; 1579 var grayCanvas;
1392 - if ($scope.ColoredImageSRC[x].haveMirror == 'true') { 1580 + if (bodyRegionIdDetails[0].haveMirror == 'true') {
1393 1581
1394 //// 3. get mask canvas for this body region._MR 1582 //// 3. get mask canvas for this body region._MR
1395 var grayCanvasID = 'imageCanvas' + bodyRegionId + '_MR'; 1583 var grayCanvasID = 'imageCanvas' + bodyRegionId + '_MR';
@@ -1459,7 +1647,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -1459,7 +1647,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1459 // alert('Icolor: ' + Icolor) 1647 // alert('Icolor: ' + Icolor)
1460 1648
1461 if (parseInt(termNo) == parseInt(Icolor)) { 1649 if (parseInt(termNo) == parseInt(Icolor)) {
1462 - 1650 +
1463 counter++; 1651 counter++;
1464 var have = $scope.machedIcolorInBodyRegion.indexOf(bodyRegionId); 1652 var have = $scope.machedIcolorInBodyRegion.indexOf(bodyRegionId);
1465 1653
@@ -1500,11 +1688,11 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -1500,11 +1688,11 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1500 } 1688 }
1501 1689
1502 grayCanvasContext.putImageData(grayImageData, 0, 0); 1690 grayCanvasContext.putImageData(grayImageData, 0, 0);
1503 - } 1691 +
1504 } 1692 }
1505 1693
1506 1694
1507 - } 1695 +
1508 1696
1509 $scope.GetRGBColor = function (maskCanvasContext, actulalX, actualY, x, y) { 1697 $scope.GetRGBColor = function (maskCanvasContext, actulalX, actualY, x, y) {
1510 1698
@@ -3301,6 +3489,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -3301,6 +3489,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
3301 //alert('previousSelectedTermList length: ' + $scope.previousSelectedTermList.length); 3489 //alert('previousSelectedTermList length: ' + $scope.previousSelectedTermList.length);
3302 3490
3303 for (var i = 0; i < $scope.previousSelectedTermList.length; i++) { 3491 for (var i = 0; i < $scope.previousSelectedTermList.length; i++) {
  3492 +
3304 $scope.highLightBodyBasedOnIcolor($scope.previousSelectedTermList[i]); 3493 $scope.highLightBodyBasedOnIcolor($scope.previousSelectedTermList[i]);
3305 3494
3306 } 3495 }
@@ -3653,8 +3842,10 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -3653,8 +3842,10 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
3653 3842
3654 var termNumber = parseInt(systemMatchedTermList[0]._TermNumber); 3843 var termNumber = parseInt(systemMatchedTermList[0]._TermNumber);
3655 3844
  3845 + $scope.highLightBodyBasedOnIcolor(termNumber);
  3846 +
3656 //Match Term No List in each bodyRegion 3847 //Match Term No List in each bodyRegion
3657 - $scope.getLocationsForMatchedTermsInWholeBody(termNumber); 3848 + //$scope.getLocationsForMatchedTermsInWholeBody(termNumber);
3658 //for (var i = 0; i < systemMatchedTermList.length; i++) { 3849 //for (var i = 0; i < systemMatchedTermList.length; i++) {
3659 3850
3660 // var termNumber = parseInt(systemMatchedTermList[i]._TermNumber); 3851 // var termNumber = parseInt(systemMatchedTermList[i]._TermNumber);