Commit 3bf57ca9bbe24c7ac3244568707338c389ff48f9

Authored by Amrita Vishnoi
1 parent d5b0ebfb

wait cursor stop if pixel data is not available

400-SOURCECODE/AIAHTML5.API/Models/PixelLocator.cs
... ... @@ -14,6 +14,7 @@ namespace AIAHTML5.API.Models
14 14 {
15 15 try
16 16 {
  17 + //var client = new MongoClient("mongodb://192.168.90.43:27017");
17 18 var client = new MongoClient();
18 19 var db = client.GetDatabase("AIAHTML5");
19 20  
... ...
400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js
... ... @@ -2847,193 +2847,202 @@ AIA.controller("DAController", ["$scope", "$rootScope", "$compile", "$http", "$l
2847 2847  
2848 2848 .then(
2849 2849 function (result) {
2850   - console.log('1. HighlightBodyByTermListForBodySystem is called');
2851   - $rootScope.macthedTermList = result;
2852   - var termNo = 0;
2853   - var pixcelLocation = 0;
2854   - var prevBRID = 0;
2855   - if ($rootScope.macthedTermList.length > 0) {
2856   - console.log('2. HighlightBodyByTermListForBodySystem is called');
2857   - //remove existing data and draw fresh data
2858   - for(var i=0; i<$rootScope.grayImageDataList.length;i++){
2859   - var grayCanvasID = 'imageCanvas' + parseInt(i+1);
2860   - var grayCanvas = document.getElementById(grayCanvasID);
2861   -
2862   - if (grayCanvas != null) {
2863   - var grayCanvasContext = grayCanvas.getContext("2d");
2864   -
2865   - var canvasHeight = grayCanvas.height;
2866   - var canvasWidth = grayCanvas.width;
2867   - grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth)
2868   - grayCanvasContext.putImageData($rootScope.grayImageDataList[parseInt(i)], 0, 0);
  2850 +
  2851 + if (result.length == 0)
  2852 + {
  2853 + $rootScope.isLoading = false;
  2854 + $('#spinner').css('visibility', 'hidden');
  2855 +
  2856 + }
  2857 + else {
  2858 + console.log('1. HighlightBodyByTermListForBodySystem is called');
  2859 + $rootScope.macthedTermList = result;
  2860 + var termNo = 0;
  2861 + var pixcelLocation = 0;
  2862 + var prevBRID = 0;
  2863 + if ($rootScope.macthedTermList.length > 0) {
  2864 + console.log('2. HighlightBodyByTermListForBodySystem is called');
  2865 + //remove existing data and draw fresh data
  2866 + for (var i = 0; i < $rootScope.grayImageDataList.length; i++) {
  2867 + var grayCanvasID = 'imageCanvas' + parseInt(i + 1);
  2868 + var grayCanvas = document.getElementById(grayCanvasID);
  2869 +
  2870 + if (grayCanvas != null) {
  2871 + var grayCanvasContext = grayCanvas.getContext("2d");
  2872 +
  2873 + var canvasHeight = grayCanvas.height;
  2874 + var canvasWidth = grayCanvas.width;
  2875 + grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth)
  2876 + grayCanvasContext.putImageData($rootScope.grayImageDataList[parseInt(i)], 0, 0);
  2877 + }
2869 2878 }
2870   - }
2871   - for (var i = 4; i <= $rootScope.grayImageMRDataList.length; i++) {
2872   - var grayCanvasMRID = 'imageCanvas' + i+'_MR';
2873   - var grayCanvasMR = document.getElementById(grayCanvasMRID);
  2879 + for (var i = 4; i <= $rootScope.grayImageMRDataList.length; i++) {
  2880 + var grayCanvasMRID = 'imageCanvas' + i + '_MR';
  2881 + var grayCanvasMR = document.getElementById(grayCanvasMRID);
2874 2882  
2875   - if (grayCanvasMR != null) {
2876   - var grayCanvasContextMR = grayCanvasMR.getContext("2d");
  2883 + if (grayCanvasMR != null) {
  2884 + var grayCanvasContextMR = grayCanvasMR.getContext("2d");
2877 2885  
2878   - var canvasHeight = grayCanvasMR.height;
2879   - var canvasWidth = grayCanvasMR.width;
2880   - grayCanvasContextMR.clearRect(0, 0, canvasHeight, canvasWidth)
2881   - grayCanvasContextMR.putImageData($rootScope.grayImageMRDataList[parseInt(i)], 0, 0);
  2886 + var canvasHeight = grayCanvasMR.height;
  2887 + var canvasWidth = grayCanvasMR.width;
  2888 + grayCanvasContextMR.clearRect(0, 0, canvasHeight, canvasWidth)
  2889 + grayCanvasContextMR.putImageData($rootScope.grayImageMRDataList[parseInt(i)], 0, 0);
  2890 + }
2882 2891 }
2883   - }
2884 2892  
2885   - angular.forEach($rootScope.macthedTermList, function (value, key) {
  2893 + angular.forEach($rootScope.macthedTermList, function (value, key) {
2886 2894  
2887 2895  
2888   - var TermExistInBodyRegionId = value.bodyRegionId;
2889   - console.log('3. HighlightBodyByTermListForBodySystem is called TermExistInBodyRegionId=' + TermExistInBodyRegionId);
2890   - if (TermExistInBodyRegionId != undefined) {
2891   - if (prevBRID != TermExistInBodyRegionId) {
  2896 + var TermExistInBodyRegionId = value.bodyRegionId;
  2897 + console.log('3. HighlightBodyByTermListForBodySystem is called TermExistInBodyRegionId=' + TermExistInBodyRegionId);
  2898 + if (TermExistInBodyRegionId != undefined) {
  2899 + if (prevBRID != TermExistInBodyRegionId) {
2892 2900  
2893 2901  
2894   - var grayCanvasID = 'imageCanvas' + TermExistInBodyRegionId;
2895   - var grayCanvas = document.getElementById(grayCanvasID);
  2902 + var grayCanvasID = 'imageCanvas' + TermExistInBodyRegionId;
  2903 + var grayCanvas = document.getElementById(grayCanvasID);
2896 2904  
2897   - if (grayCanvas != null) {
  2905 + if (grayCanvas != null) {
2898 2906  
2899   - var grayCanvasContext = grayCanvas.getContext("2d");
  2907 + var grayCanvasContext = grayCanvas.getContext("2d");
2900 2908  
2901   - var canvasHeight = grayCanvas.height;
2902   - var canvasWidth = grayCanvas.width;
2903   - var canvasX = grayCanvas.style.left;
2904   - var canvasY = grayCanvas.style.top;
  2909 + var canvasHeight = grayCanvas.height;
  2910 + var canvasWidth = grayCanvas.width;
  2911 + var canvasX = grayCanvas.style.left;
  2912 + var canvasY = grayCanvas.style.top;
2905 2913  
2906 2914  
2907   - grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth)
2908   - grayCanvasContext.putImageData($rootScope.grayImageDataList[parseInt(TermExistInBodyRegionId) - 1], 0, 0);
  2915 + grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth)
  2916 + grayCanvasContext.putImageData($rootScope.grayImageDataList[parseInt(TermExistInBodyRegionId) - 1], 0, 0);
2909 2917  
2910   - var gData = grayCanvasContext.getImageData(0, 0, canvasWidth, canvasHeight);
  2918 + var gData = grayCanvasContext.getImageData(0, 0, canvasWidth, canvasHeight);
2911 2919  
2912   - //for mirror images
2913   - var grayCanvasMRID = 'imageCanvas' + TermExistInBodyRegionId + '_MR';
2914   - var grayCanvasMR = document.getElementById(grayCanvasMRID);
2915   - var grayCanvasMRX;
2916   - var grayCanvasMRY;
  2920 + //for mirror images
  2921 + var grayCanvasMRID = 'imageCanvas' + TermExistInBodyRegionId + '_MR';
  2922 + var grayCanvasMR = document.getElementById(grayCanvasMRID);
  2923 + var grayCanvasMRX;
  2924 + var grayCanvasMRY;
2917 2925  
2918   - //draw a canvas for same bodyregion wich will be flipped after coloring the body system
2919   - if (TermExistInBodyRegionId == 4 || TermExistInBodyRegionId == 5 || TermExistInBodyRegionId == 6) {
  2926 + //draw a canvas for same bodyregion wich will be flipped after coloring the body system
  2927 + if (TermExistInBodyRegionId == 4 || TermExistInBodyRegionId == 5 || TermExistInBodyRegionId == 6) {
2920 2928  
2921 2929  
2922   - var grayCanvasMRID = 'imageCanvas' + TermExistInBodyRegionId + '_MR';
2923   - var grayCanvasMR = document.getElementById(grayCanvasMRID);
2924   - grayCanvasMRX = grayCanvasMR.style.left;
2925   - grayCanvasMRY = grayCanvasMR.style.top;
  2930 + var grayCanvasMRID = 'imageCanvas' + TermExistInBodyRegionId + '_MR';
  2931 + var grayCanvasMR = document.getElementById(grayCanvasMRID);
  2932 + grayCanvasMRX = grayCanvasMR.style.left;
  2933 + grayCanvasMRY = grayCanvasMR.style.top;
2926 2934  
2927   - var FlipedImgCanvas = document.createElement('canvas');
2928   - FlipedImgCanvas.height = canvasHeight;
2929   - FlipedImgCanvas.width = canvasWidth;
2930   - FlipedImgCanvas.setAttribute("data-IsMirrored", "Y")
2931   - FlipedImgCanvas.style.position = "absolute";
2932   - FlipedImgCanvas.style.left = canvasX + "px";
2933   - FlipedImgCanvas.style.top = canvasY + "px";
2934   - FlipedImgCanvas.style.visibility = 'hidden';
2935   - FlipedImgCanvas.id = 'imageCanvas' + TermExistInBodyRegionId + '_MR';
  2935 + var FlipedImgCanvas = document.createElement('canvas');
  2936 + FlipedImgCanvas.height = canvasHeight;
  2937 + FlipedImgCanvas.width = canvasWidth;
  2938 + FlipedImgCanvas.setAttribute("data-IsMirrored", "Y")
  2939 + FlipedImgCanvas.style.position = "absolute";
  2940 + FlipedImgCanvas.style.left = canvasX + "px";
  2941 + FlipedImgCanvas.style.top = canvasY + "px";
  2942 + FlipedImgCanvas.style.visibility = 'hidden';
  2943 + FlipedImgCanvas.id = 'imageCanvas' + TermExistInBodyRegionId + '_MR';
2936 2944  
2937   - //remove previous canavs
2938   - $('#' + grayCanvasMRID).remove();
  2945 + //remove previous canavs
  2946 + $('#' + grayCanvasMRID).remove();
2939 2947  
2940   - //add new canvas on same location and after flipping it will be added to mirrored position
2941   - document.getElementById('canvasDiv').appendChild(FlipedImgCanvas);
2942   - //put grayData
  2948 + //add new canvas on same location and after flipping it will be added to mirrored position
  2949 + document.getElementById('canvasDiv').appendChild(FlipedImgCanvas);
  2950 + //put grayData
2943 2951  
2944   - var filppedCanvasContx = FlipedImgCanvas.getContext("2d");
2945   - filppedCanvasContx.putImageData(gData, 0, 0);
  2952 + var filppedCanvasContx = FlipedImgCanvas.getContext("2d");
  2953 + filppedCanvasContx.putImageData(gData, 0, 0);
2946 2954  
2947   - }
  2955 + }
2948 2956  
2949   - grayImageDataVar = null;
2950   - var macthedData = new jinqJs()
2951   - .from($rootScope.macthedTermList)
2952   - .where('bodyRegionId == ' + TermExistInBodyRegionId)
2953   - .select();
  2957 + grayImageDataVar = null;
  2958 + var macthedData = new jinqJs()
  2959 + .from($rootScope.macthedTermList)
  2960 + .where('bodyRegionId == ' + TermExistInBodyRegionId)
  2961 + .select();
2954 2962  
2955 2963  
2956 2964  
2957   - var coloredImageDataVar = $rootScope.coloredImageCanvasList[parseInt(TermExistInBodyRegionId) - 1];
  2965 + var coloredImageDataVar = $rootScope.coloredImageCanvasList[parseInt(TermExistInBodyRegionId) - 1];
2958 2966  
2959   - var grayImageDataValue = gData.data;
2960   - var coloredImageDataValue = coloredImageDataVar.data;
  2967 + var grayImageDataValue = gData.data;
  2968 + var coloredImageDataValue = coloredImageDataVar.data;
2961 2969  
2962 2970  
2963   - angular.forEach(macthedData, function (value2, key) {
  2971 + angular.forEach(macthedData, function (value2, key) {
2964 2972  
2965   - $rootScope.termListWithLocation = value2.terms;
  2973 + $rootScope.termListWithLocation = value2.terms;
2966 2974  
2967   - //pick the color from coloredImage data and put on gray imagedata
2968   - angular.forEach($rootScope.termListWithLocation.PixelLocations, function (value1, key1) {
  2975 + //pick the color from coloredImage data and put on gray imagedata
  2976 + angular.forEach($rootScope.termListWithLocation.PixelLocations, function (value1, key1) {
2969 2977  
2970   - var RED = coloredImageDataValue[value1];
2971   - var GREEN = coloredImageDataValue[value1 + 1];
2972   - var BLUE = coloredImageDataValue[value1 + 2];
  2978 + var RED = coloredImageDataValue[value1];
  2979 + var GREEN = coloredImageDataValue[value1 + 1];
  2980 + var BLUE = coloredImageDataValue[value1 + 2];
2973 2981  
2974   - grayImageDataValue[value1] = RED;
2975   - grayImageDataValue[value1 + 1] = GREEN;
2976   - grayImageDataValue[value1 + 2] = BLUE;
2977   - })
  2982 + grayImageDataValue[value1] = RED;
  2983 + grayImageDataValue[value1 + 1] = GREEN;
  2984 + grayImageDataValue[value1 + 2] = BLUE;
  2985 + })
2978 2986  
2979   - //for non mirrored bpdy regions
2980   - var grayCanvasID = 'imageCanvas' + TermExistInBodyRegionId;
2981   - var grayCanvas = document.getElementById(grayCanvasID);
  2987 + //for non mirrored bpdy regions
  2988 + var grayCanvasID = 'imageCanvas' + TermExistInBodyRegionId;
  2989 + var grayCanvas = document.getElementById(grayCanvasID);
2982 2990  
2983   - if (grayCanvas != null) {
  2991 + if (grayCanvas != null) {
2984 2992  
2985   - var grayCanvasContext = grayCanvas.getContext("2d");
  2993 + var grayCanvasContext = grayCanvas.getContext("2d");
2986 2994  
2987   - grayCanvasContext.putImageData(gData, 0, 0);
  2995 + grayCanvasContext.putImageData(gData, 0, 0);
2988 2996  
2989   - }
  2997 + }
2990 2998  
2991   - //for mirror body regions
2992   - if (TermExistInBodyRegionId == 4 || TermExistInBodyRegionId == 5 || TermExistInBodyRegionId == 6) {
  2999 + //for mirror body regions
  3000 + if (TermExistInBodyRegionId == 4 || TermExistInBodyRegionId == 5 || TermExistInBodyRegionId == 6) {
2993 3001  
2994   - var grayCanvasMRID = 'imageCanvas' + TermExistInBodyRegionId + '_MR';
  3002 + var grayCanvasMRID = 'imageCanvas' + TermExistInBodyRegionId + '_MR';
2995 3003  
2996   - var grayCanvasMR = document.getElementById(grayCanvasMRID);
  3004 + var grayCanvasMR = document.getElementById(grayCanvasMRID);
2997 3005  
2998   - if (grayCanvasMR != null) {
  3006 + if (grayCanvasMR != null) {
2999 3007  
3000   - var grayCanvasMRContext = grayCanvasMR.getContext("2d");
  3008 + var grayCanvasMRContext = grayCanvasMR.getContext("2d");
3001 3009  
3002   - grayCanvasMRContext.save();
3003   - grayCanvasMRContext.translate(canvasWidth, 0);
3004   - grayCanvasMRContext.scale(-1, 1);
3005   - //flip does not work with putImageData, that is why we used drawImage
3006   - grayCanvasMRContext.drawImage(grayCanvas, 0, 0, canvasWidth, canvasHeight, 0, 0, canvasWidth, canvasHeight);
3007   - grayCanvasMRContext.restore();
  3010 + grayCanvasMRContext.save();
  3011 + grayCanvasMRContext.translate(canvasWidth, 0);
  3012 + grayCanvasMRContext.scale(-1, 1);
  3013 + //flip does not work with putImageData, that is why we used drawImage
  3014 + grayCanvasMRContext.drawImage(grayCanvas, 0, 0, canvasWidth, canvasHeight, 0, 0, canvasWidth, canvasHeight);
  3015 + grayCanvasMRContext.restore();
3008 3016  
3009   - //set this canavs on the actual posution of mirror image
3010   - grayCanvasMR.style.left = grayCanvasMRX;
3011   - grayCanvasMR.style.top = grayCanvasMRY;
3012   - grayCanvasMR.style.visibility = 'visible';
  3017 + //set this canavs on the actual posution of mirror image
  3018 + grayCanvasMR.style.left = grayCanvasMRX;
  3019 + grayCanvasMR.style.top = grayCanvasMRY;
  3020 + grayCanvasMR.style.visibility = 'visible';
3013 3021  
3014 3022  
  3023 + }
3015 3024 }
3016   - }
3017 3025  
3018   - $('#spinner').css('visibility', 'hidden')
3019   - $rootScope.isLoading = false;
  3026 + $('#spinner').css('visibility', 'hidden')
  3027 + $rootScope.isLoading = false;
3020 3028  
3021   - prevBRID = TermExistInBodyRegionId;
3022   - })
  3029 + prevBRID = TermExistInBodyRegionId;
  3030 + })
  3031 + }
3023 3032 }
3024 3033 }
3025   - }
3026   - else {
3027   - $('#spinner').css('visibility', 'hidden')
3028   - $rootScope.isLoading = false;
3029   - }
  3034 + else {
  3035 + $('#spinner').css('visibility', 'hidden')
  3036 + $rootScope.isLoading = false;
  3037 + }
3030 3038  
3031   - })
  3039 + })
  3040 +
  3041 + }
3032 3042  
3033   - }
3034 3043  
3035   -
3036 3044  
  3045 + }
3037 3046 },
3038 3047 function (error) {
3039 3048 console.log(' Error in getting term data = ' + error.statusText);
... ...