Commit 0b7b51bfdaa791d6f1cb7fa21950eb9b5cd7bf97

Authored by Nikita Kulshreshtha
1 parent ef914dff

trying approch of canvas click and getting some range on click

400-SOURCECODE/AIAHTML5.Web/app/controllers/TileViewListController.js
@@ -176,7 +176,11 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -176,7 +176,11 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
176 canvas.style.left = '0px'; 176 canvas.style.left = '0px';
177 canvas.style.top = '0px'; 177 canvas.style.top = '0px';
178 canvas.style.position = "absolute"; 178 canvas.style.position = "absolute";
179 - 179 + canvas.addEventListener('click', function () {
  180 + alert('canvas clicked');
  181 + var clickedPint = $scope.getMousePos(event);
  182 + alert('x: ' + clickedPint.x + ', y:' + clickedPint.y);
  183 + })
180 $("#canvasDiv").append(canvas); 184 $("#canvasDiv").append(canvas);
181 $scope.context = canvas.getContext("2d") 185 $scope.context = canvas.getContext("2d")
182 186
@@ -226,7 +230,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -226,7 +230,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
226 }) 230 })
227 231
228 $scope.showAllPins = function () { 232 $scope.showAllPins = function () {
229 - 233 +
230 var promise = ModuleService.getPinDataForImage($rootScope.imageName) 234 var promise = ModuleService.getPinDataForImage($rootScope.imageName)
231 235
232 .then( 236 .then(
@@ -903,6 +907,97 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -903,6 +907,97 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
903 907
904 $scope.drawStaticPinsOnImage = function (canvasId, PinId, offsetX1, offsetY1, x, y) { 908 $scope.drawStaticPinsOnImage = function (canvasId, PinId, offsetX1, offsetY1, x, y) {
905 909
  910 + if ($rootScope.isSliderChanged == true) {
  911 + var radial = $('#' + canvasId).createGradient({
  912 + x1: 50, y1: 50,
  913 + x2: 50, y2: 50,
  914 + r1: 10, r2: 30,
  915 + c1: 'rgba(100, 50, 0,0)',
  916 + c2: 'rgb(216, 216, 216)'
  917 + });
  918 + $('#' + canvasId).drawLine({
  919 +
  920 + layer: true,
  921 + name: "Pin_" + PinId,
  922 + groups: ["Pin_" + PinId],
  923 + strokeStyle: 'black',
  924 + strokeWidth: 2,
  925 + visible: true,
  926 + x1: offsetX1, y1: offsetY1,
  927 + x2: x * 0.85, y2: y * 0.85,
  928 +
  929 + }).drawArc({
  930 + name: "PinArc_" + PinId,
  931 + layer: true,
  932 + groups: ["Pin_" + PinId],
  933 + strokeStyle: 'grey',
  934 + strokeWidth: 2,
  935 + visible: true,
  936 + fillStyle: radial,
  937 + x: x * 0.85, y: y * 0.85,
  938 + radius: 5 * 0.85,
  939 +
  940 + click: function (clickedPin) {
  941 + alert('pin clciked = ' + clickedPin.name)
  942 + //change the head color to green
  943 + var radialAfterClick = $('#aaDetailViewCanvas').createGradient({
  944 + x1: 50, y1: 50,
  945 + x2: 50, y2: 50,
  946 + r1: 10, r2: 30,
  947 + c1: 'rgba(100, 50, 0,0)',
  948 + c2: 'rgb(126, 187, 83)'
  949 + });
  950 +
  951 + clickedPin.fillStyle = radialAfterClick;
  952 +
  953 + var pinID = (clickedPin.name).substring(7, (clickedPin.name).length);
  954 + // alert('pinId: ' + pinID);
  955 + //showAnnotation();
  956 +
  957 + var pinData = new jinqJs()
  958 + .from($scope.aaPinData)
  959 + .where("_PinId == " + pinID)
  960 + .select();
  961 +
  962 +
  963 + var pinTermNumber = pinData[0]._TermId;
  964 +
  965 + var pinWithSameTerm = new jinqJs()
  966 +
  967 + .from($scope.aaPinData)
  968 + .where("_TermId == " + pinTermNumber)
  969 + .select();
  970 +
  971 +
  972 + if (pinWithSameTerm != undefined && pinWithSameTerm != null && pinWithSameTerm.length > 0) {
  973 +
  974 + for (var i = 0; i < pinWithSameTerm.length; i++) {
  975 +
  976 + $scope.clickedPins.push({ 'id': pinWithSameTerm[i]._PinId })
  977 + }
  978 +
  979 + }
  980 +
  981 + var selectedPinData = new jinqJs()
  982 + .from($scope.aaPinData)
  983 + .where("_PinId == " + pinID)
  984 + .select();
  985 + if (clickedPin.event.ctrlKey == true) {
  986 + $scope.showAnnotation(selectedPinData, true, true, false);
  987 +
  988 + }
  989 + else {
  990 + $scope.showAnnotation(selectedPinData, false, true, false);
  991 +
  992 + }
  993 +
  994 +
  995 + }
  996 +
  997 + }).drawLayers();
  998 + }
  999 + else
  1000 + {
906 var radial = $('#' + canvasId).createGradient({ 1001 var radial = $('#' + canvasId).createGradient({
907 x1: 50, y1: 50, 1002 x1: 50, y1: 50,
908 x2: 50, y2: 50, 1003 x2: 50, y2: 50,
@@ -930,11 +1025,10 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -930,11 +1025,10 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
930 visible: true, 1025 visible: true,
931 fillStyle: radial, 1026 fillStyle: radial,
932 x: x, y: y, 1027 x: x, y: y,
933 - radius: 5, 1028 + radius: 2,
934 1029
935 click: function (clickedPin) { 1030 click: function (clickedPin) {
936 -  
937 - //change the head color to green 1031 + alert('pin clciked = ' + clickedPin.name) //change the head color to green
938 var radialAfterClick = $('#aaDetailViewCanvas').createGradient({ 1032 var radialAfterClick = $('#aaDetailViewCanvas').createGradient({
939 x1: 50, y1: 50, 1033 x1: 50, y1: 50,
940 x2: 50, y2: 50, 1034 x2: 50, y2: 50,
@@ -990,10 +1084,19 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -990,10 +1084,19 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
990 } 1084 }
991 1085
992 }).drawLayers(); 1086 }).drawLayers();
  1087 + }
993 1088
994 } 1089 }
995 1090
996 1091
  1092 + $scope.getMousePos = function (evt) {
  1093 +
  1094 + return {
  1095 + x: Math.round(evt.pageX - $('#canvasDiv').offset().left),
  1096 + y: Math.round(evt.pageY - $('#canvasDiv').offset().top)
  1097 + }
  1098 + }
  1099 +
997 $scope.removePin = function (canvasId, pinId) { 1100 $scope.removePin = function (canvasId, pinId) {
998 1101
999 // var pinName = 'Pin_' + pinId; 1102 // var pinName = 'Pin_' + pinId;