Commit a770c1076a68fff5fa75e6e40da535628fd74c80

Authored by Amrita Vishnoi
1 parent 99ad4ac4

Implemented reset canvas.

400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js
@@ -46,6 +46,9 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -46,6 +46,9 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
46 $rootScope.coloredImageMRCanvasList = []; 46 $rootScope.coloredImageMRCanvasList = [];
47 $rootScope.ColoredCanvasData = []; 47 $rootScope.ColoredCanvasData = [];
48 $rootScope.grayImageDataList = []; 48 $rootScope.grayImageDataList = [];
  49 +
  50 + $rootScope.rawGrayImageDataList = [];
  51 +
49 $rootScope.grayImageMRDataList = []; 52 $rootScope.grayImageMRDataList = [];
50 $rootScope.updatedGrayDataList = []; 53 $rootScope.updatedGrayDataList = [];
51 $rootScope.updatedGrayMRDataList = []; 54 $rootScope.updatedGrayMRDataList = [];
@@ -2646,71 +2649,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -2646,71 +2649,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
2646 2649
2647 if ($scope.layerNumber == 224) 2650 if ($scope.layerNumber == 224)
2648 { 2651 {
2649 - //debugger;  
2650 -  
2651 - //var matchedTermListPath = '~/../content/data/json/da/body-views/1/bodyLayers-CardioVascular.json';  
2652 -  
2653 - //DataService.getJson(matchedTermListPath)  
2654 - //.then(  
2655 - // function (result)  
2656 - // {  
2657 - // $rootScope.macthedTermList = result;  
2658 - // var termNo=0;  
2659 - // var pixcelLocation = 0;  
2660 -  
2661 - // if ($rootScope.macthedTermList.length > 0) {  
2662 - // angular.forEach($rootScope.macthedTermList, function (value, key) {  
2663 -  
2664 - // debugger;  
2665 -  
2666 - // var TermExistInBodyRegionId = value.bodyRegionId;  
2667 - // var grayImageDataVar = $rootScope.grayImageDataList[TermExistInBodyRegionId - 1];  
2668 - // var coloredImageDataVar = $rootScope.coloredImageCanvasList[TermExistInBodyRegionId - 1];  
2669 -  
2670 - // var grayImageDataValue = grayImageDataVar.data;  
2671 - // var coloredImageDataValue = coloredImageDataVar.data;  
2672 -  
2673 - // $rootScope.termListWithLocation = value.terms;  
2674 -  
2675 - // angular.forEach($rootScope.termListWithLocation[0].PixelLocations, function (value1, key1)  
2676 - // {  
2677 - // //debugger;  
2678 -  
2679 - // var coloredImageData = coloredImageDataValue[value1];  
2680 - // grayImageDataValue[value1] = coloredImageData;  
2681 -  
2682 -  
2683 - // })  
2684 -  
2685 - // var grayCanvasID = 'imageCanvas' + TermExistInBodyRegionId;  
2686 - // var grayCanvas = document.getElementById(grayCanvasID);  
2687 - // if (grayCanvas != null)  
2688 - // {  
2689 - // debugger;  
2690 - // var grayCanvasContext = grayCanvas.getContext("2d");  
2691 -  
2692 - // var canvasHeight = grayCanvas.height + 'px';  
2693 - // var canvasWidth = grayCanvas.width + 'px';  
2694 - // grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth)  
2695 -  
2696 - // grayCanvasContext.putImageData(grayImageDataVar, 0, 0);  
2697 -  
2698 -  
2699 - // }  
2700 - // $('#spinner').css('visibility', 'hidden')  
2701 - // $rootScope.isLoading = false;  
2702 -  
2703 - // })  
2704 - // }  
2705 -  
2706 -  
2707 -  
2708 - // },  
2709 - // function (error) {  
2710 - // console.log(' Error in getting term data = ' + error.statusText);  
2711 -  
2712 - // });  
2713 -  
2714 } 2652 }
2715 else { 2653 else {
2716 2654
@@ -2846,71 +2784,117 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -2846,71 +2784,117 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
2846 } 2784 }
2847 }, 100) 2785 }, 100)
2848 2786
  2787 +
  2788 + }
  2789 +
  2790 +
  2791 +
  2792 + $scope.HighlightBodyByTermListForBodySystem = function (TermList) {
  2793 +
  2794 + $("#btnTranparency").attr('disabled', 'disabled');
  2795 + $scope.currentLayerNumber = $scope.layerNumber;
  2796 +
  2797 + $scope.layerNumber = $('#txtlayerNumber').val();
  2798 +
  2799 + $rootScope.isLoading = true;
  2800 + $('#spinner').css('visibility', 'visible');
  2801 +
  2802 +
  2803 + if ($rootScope.isHighLight == true) {
  2804 + false;
  2805 + }
  2806 +
  2807 + console.log('HighlightBodyByTermList is called');
  2808 +
  2809 + $scope.highlightedBR = [];
  2810 +
2849 if ($scope.layerNumber == 224) { 2811 if ($scope.layerNumber == 224) {
2850 - // debugger;  
2851 2812
2852 var matchedTermListPath = '~/../content/data/json/da/body-views/1/BodySystem_' + $rootScope.systemNumber + '.json'; 2813 var matchedTermListPath = '~/../content/data/json/da/body-views/1/BodySystem_' + $rootScope.systemNumber + '.json';
2853 - 2814 + var grayImageDataVar = null;
  2815 +
2854 DataService.getJson(matchedTermListPath) 2816 DataService.getJson(matchedTermListPath)
2855 .then( 2817 .then(
2856 function (result) { 2818 function (result) {
2857 $rootScope.macthedTermList = result; 2819 $rootScope.macthedTermList = result;
2858 var termNo = 0; 2820 var termNo = 0;
2859 var pixcelLocation = 0; 2821 var pixcelLocation = 0;
2860 - 2822 + var prevBRID = 0;
2861 if ($rootScope.macthedTermList.length > 0) { 2823 if ($rootScope.macthedTermList.length > 0) {
2862 2824
2863 -  
2864 -  
2865 angular.forEach($rootScope.macthedTermList, function (value, key) { 2825 angular.forEach($rootScope.macthedTermList, function (value, key) {
2866 - // debugger;  
2867 - var TermExistInBodyRegionId = value.bodyRegionId;  
2868 2826
2869 -  
2870 - var grayImageDataVar = $rootScope.grayImageDataList[parseInt(TermExistInBodyRegionId) - 1];  
2871 -  
2872 - var coloredImageDataVar = $rootScope.coloredImageCanvasList[parseInt(TermExistInBodyRegionId) - 1];  
2873 2827
2874 - var grayImageDataValue = grayImageDataVar.data;  
2875 - var coloredImageDataValue = coloredImageDataVar.data; 2828 + var TermExistInBodyRegionId = value.bodyRegionId;
2876 2829
2877 - $rootScope.termListWithLocation = value.terms; 2830 + if (prevBRID != TermExistInBodyRegionId) {
  2831 + var grayCanvasID = 'imageCanvas' + TermExistInBodyRegionId;
  2832 + var grayCanvas = document.getElementById(grayCanvasID);
  2833 +
  2834 + if (grayCanvas != null) {
  2835 + var grayCanvasContext = grayCanvas.getContext("2d");
2878 2836
2879 - angular.forEach($rootScope.termListWithLocation.PixelLocations, function (value1, key1) {  
2880 - //debugger; 2837 + var canvasHeight = grayCanvas.height;
  2838 + var canvasWidth = grayCanvas.width;
  2839 + grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth)
  2840 + grayCanvasContext.putImageData($rootScope.grayImageDataList[parseInt(TermExistInBodyRegionId) - 1], 0, 0);
2881 2841
2882 - var RED = coloredImageDataValue[value1];  
2883 - var GREEN = coloredImageDataValue[value1 + 1];  
2884 - var BLUE = coloredImageDataValue[value1 + 2]; 2842 + var gData = grayCanvasContext.getImageData(0, 0, canvasWidth,canvasHeight )
2885 2843
2886 - grayImageDataValue[value1] = RED;  
2887 - grayImageDataValue[value1+1] = GREEN;  
2888 - grayImageDataValue[value1+2] = BLUE;  
2889 - }) 2844 + grayImageDataVar = null;
  2845 + var macthedData = new jinqJs()
  2846 + .from($rootScope.macthedTermList)
  2847 + .where('bodyRegionId == ' + TermExistInBodyRegionId)
  2848 + .select();
2890 2849
2891 - var grayCanvasID = 'imageCanvas' + TermExistInBodyRegionId;  
2892 - var grayCanvas = document.getElementById(grayCanvasID);  
2893 - if (grayCanvas != null) {  
2894 - debugger;  
2895 - var grayCanvasContext = grayCanvas.getContext("2d"); 2850 + //grayImageDataVar = $rootScope.grayImageDataList[parseInt(TermExistInBodyRegionId) - 1]
  2851 +
  2852 +
  2853 + var coloredImageDataVar = $rootScope.coloredImageCanvasList[parseInt(TermExistInBodyRegionId) - 1];
2896 2854
2897 - //var canvasHeight = grayCanvas.height + 'px';  
2898 - //var canvasWidth = grayCanvas.width + 'px'; 2855 + var grayImageDataValue = gData.data;
  2856 + var coloredImageDataValue = coloredImageDataVar.data;
2899 2857
  2858 + // $rootScope.termListWithLocation = value.terms;
2900 2859
2901 - var canvasHeight = grayCanvas.height;  
2902 - var canvasWidth = grayCanvas.width; 2860 + angular.forEach(macthedData, function (value2, key) {
  2861 + $rootScope.termListWithLocation = value2.terms;
  2862 + angular.forEach($rootScope.termListWithLocation.PixelLocations, function (value1, key1) {
2903 2863
2904 - grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth) 2864 + var RED = coloredImageDataValue[value1];
  2865 + var GREEN = coloredImageDataValue[value1 + 1];
  2866 + var BLUE = coloredImageDataValue[value1 + 2];
2905 2867
2906 - grayCanvasContext.putImageData(grayImageDataVar, 0, 0); 2868 + grayImageDataValue[value1] = RED;
  2869 + grayImageDataValue[value1 + 1] = GREEN;
  2870 + grayImageDataValue[value1 + 2] = BLUE;
  2871 + })
2907 2872
  2873 + var grayCanvasID = 'imageCanvas' + TermExistInBodyRegionId;
  2874 + var grayCanvas = document.getElementById(grayCanvasID);
  2875 + if (grayCanvas != null) {
  2876 + var grayCanvasContext = grayCanvas.getContext("2d");
2908 2877
2909 - }  
2910 - $('#spinner').css('visibility', 'hidden')  
2911 - $rootScope.isLoading = false; 2878 + var canvasHeight = grayCanvas.height;
  2879 + var canvasWidth = grayCanvas.width;
  2880 +
  2881 + //grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth)
2912 2882
  2883 + grayCanvasContext.putImageData(gData, 0, 0);
  2884 +
  2885 + // grayCanvasContext.putImageData($rootScope.rawGrayImageDataList[parseInt(TermExistInBodyRegionId) - 1], 0, 0);
  2886 +
  2887 +
  2888 + }
  2889 + $('#spinner').css('visibility', 'hidden')
  2890 + $rootScope.isLoading = false;
  2891 +
  2892 + prevBRID = TermExistInBodyRegionId;
  2893 + })
  2894 + }
  2895 + }
2913 }) 2896 })
  2897 +
2914 } 2898 }
2915 2899
2916 2900
@@ -2925,7 +2909,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -2925,7 +2909,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
2925 } 2909 }
2926 2910
2927 2911
2928 -  
2929 $scope.createTermListByPreviousTermsAndHighlight = function () { 2912 $scope.createTermListByPreviousTermsAndHighlight = function () {
2930 2913
2931 2914
@@ -6922,7 +6905,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -6922,7 +6905,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
6922 $scope.isLoading = true; 6905 $scope.isLoading = true;
6923 6906
6924 $('#spinner').css('visibility', 'visible'); 6907 $('#spinner').css('visibility', 'visible');
6925 - $timeout(function () { $scope.HighlightBodyByTermList($scope.systemMatchedTermList) }, 100); 6908 + $timeout(function () { $scope.HighlightBodyByTermListForBodySystem($scope.systemMatchedTermList) }, 100);
6926 } 6909 }
6927 else if (($rootScope.isListManagerSelected == true) || ($rootScope.previousHighlightList != null && $rootScope.previousHighlightList.length > 0) && ($rootScope.isGenderChnage == true || $rootScope.isViewChange == true) || $rootScope.isListManagerAlreadySelected == true) { 6910 else if (($rootScope.isListManagerSelected == true) || ($rootScope.previousHighlightList != null && $rootScope.previousHighlightList.length > 0) && ($rootScope.isGenderChnage == true || $rootScope.isViewChange == true) || $rootScope.isListManagerAlreadySelected == true) {
6928 6911
@@ -7808,7 +7791,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -7808,7 +7791,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
7808 $scope.isLoading = true; 7791 $scope.isLoading = true;
7809 7792
7810 $('#spinner').css('visibility', 'visible'); 7793 $('#spinner').css('visibility', 'visible');
7811 - $timeout(function () { $scope.HighlightBodyByTermList($scope.systemMatchedTermList) }, 100); 7794 + $timeout(function () { $scope.HighlightBodyByTermListForBodySystem($scope.systemMatchedTermList) }, 100);
7812 } 7795 }
7813 } 7796 }
7814 } 7797 }
@@ -8872,7 +8855,10 @@ function OnViewChange(event) { @@ -8872,7 +8855,10 @@ function OnViewChange(event) {
8872 function OnBodySystemSelection(event) { 8855 function OnBodySystemSelection(event) {
8873 console.log('OnBodySystem chnaged is called outside '); 8856 console.log('OnBodySystem chnaged is called outside ');
8874 var scope = angular.element(document.getElementById("daView")).scope(); 8857 var scope = angular.element(document.getElementById("daView")).scope();
8875 - scope.$apply(function () { 8858 +
  8859 +
  8860 + scope.$apply(function ()
  8861 + {
8876 scope.HighlightBodyByBodySystem(event); 8862 scope.HighlightBodyByBodySystem(event);
8877 }); 8863 });
8878 } 8864 }