'
+ '

'
@@ -265,7 +265,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
$scope.openView = function ($event) {
- // debugger;
+
$rootScope.isLoading = true;
$('#spinner').css('visibility', 'visible');
@@ -682,8 +682,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
$scope.LoadDefaultLayerImage = function () {
- // debugger;
-
+
$rootScope.isNormalMode = true;
$scope.layerNumber = 0;
@@ -5916,7 +5915,8 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
$rootScope.Object1Index = 0;
$rootScope.Object2Index = 0;
$rootScope.resetText = 0;
-
+ $rootScope.resetTextSave = 0;
+ $rootScope.ObjectIndexSave = 0;
var arrayRect = {};
@@ -6045,6 +6045,10 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
resizeFromCenter: false,
+ dblclick: function () {
+ $rootScope.backOpacity();
+
+ },
click: function (layer) {
$rootScope.canvasLayerNameCollection = [];
@@ -6121,6 +6125,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
click: function (layer) {
+ // alert(layer.name);
$rootScope.canvasLayerNameCollection = [];
$rootScope.canvasLayerNameCollection.push(layer.name);
$('#canvas').setLayer(layer.name, {
@@ -6136,6 +6141,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
},
mouseout: function (layer) {
$rootScope.canvasLayerNameCollection = [];
+
$('#canvas').setLayer(layer.name, {
handle: {
type: 'arc',
@@ -6262,7 +6268,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
x2: $scope.x, y2: $scope.y,
click: function (layer) {
- // debugger;
+
$rootScope.shapeTypePin = "Pin";
$rootScope.canvasLayerNameCollection = [];
var pinLine_layer = layer.name;
@@ -6286,9 +6292,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
},
mouseout: function (layer) {
- // $rootScope.resetPinArc = "";
- // ax = "";
-
+
$rootScope.canvasLayerNameCollection = [];
$('#canvas').setLayer(layer.name, {
handle: {
@@ -6351,7 +6355,8 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
$('.btnCursor').addClass('activebtncolor');
break;
case "TextArea":
-
+ $rootScope.IsTextAlreadySave = false;
+ $("#text_area").val('');
// Draw text
$rootScope.resetTextRect = $rootScope.ObjectIndex++;
$rootScope.resetText = $rootScope.ObjectIndex++;
@@ -6369,9 +6374,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
align: "left",
fontFamily: 'Verdana, sans-serif',
text: ''
-
-
-
+
})
// Draw rect as wide as the text
.drawRect({
@@ -6435,6 +6438,8 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
$("#annotationTextModal").modal("toggle");
$('.btnCursor').trigger('click');
+ $("#text_area").val('');
+ $("#text_area").css({ " font-family": 'Verdana, sans-serif', "font-size": "14px", "font-weight": "normal", "font-style": "normal", "color": "#000", "text-align": "left", "text-decoration": "none" });
$(".btn-annotation").removeClass("activebtncolor");
$('.btnCursor').addClass('activebtncolor');
break;
@@ -6458,129 +6463,275 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
$rootScope.underlineText;
$rootScope.textArea;
$rootScope.fontFamily;
- $rootScope.saveText = function () {
-
- $rootScope.fontSizes = $("#text_area").css("font-size");
- $rootScope.fontWeight = $("#text_area").css("font-weight");
- $rootScope.fontStyle = $("#text_area").css("font-style");
- $rootScope.textAlignmt = $("#text_area").css("text-align");
- $rootScope.fontColor = $("#text_area").css("color");
- $rootScope.fontFamily = $("#text_area").css("font-family");
- $rootScope.underlineText = $("#text_area").css("text-decoration");
- $rootScope.textArea = $("#text_area").val();
- $("#canvas").removeLayer('TextArea_' + $rootScope.resetText).drawLayers();
- $("#canvas").removeLayer("TextRect_" + $rootScope.resetTextRect).drawLayers();
-
- $('#canvas').drawText({
- layer: true,
- draggable: true,
- name: 'TextArea_' + $rootScope.resetText,
- groups: ['TextArea_' + $rootScope.resetText],
- dragGroups: ['TextArea_' + $rootScope.resetText],
- fillStyle: $rootScope.fontColor,
- fontStyle: $rootScope.fontStyle,
- fontSize: $rootScope.fontSizes,
- fontFamily: $rootScope.fontFamily,
- align: $rootScope.textAlignmt,
- strokeWidth: 0,
- text: $rootScope.textArea,
- x: $scope.offsetX1, y: $scope.offsetY1,
- maxWidth: $scope.x - $scope.offsetX1,
- maxHeight: $scope.y - $scope.offsetY1,
-
-
- click: function (layer) {
-
-
-
- },
- change: function (layer, props) {
-
- }
+ $rootScope.TextPropertyArray = [];
+ $rootScope.modifySavedText = [];
+ $rootScope.TextRectangleArr = [];
+ $rootScope.rectDimension = [];
+
- })
- // Draw rect as wide as the text
- .drawRect({
- name: 'TextArea1_' + $rootScope.resetText,
- layer: true,
- draggable: true,
- groups: ['TextArea_' + $rootScope.resetText],
- dragGroups: ['TextArea_' + $rootScope.resetText],
- opacity: $rootScope.shapestyleOpacity,
- // strokeStyle: 'black',
- // strokeWidth: 2,
- strokeStyle: $rootScope.shapestyleborderColor,
- strokeWidth: $rootScope.shapestyleborderWidth,
- // fillStyle: $rootScope.shapestyleFillColor,
- x: $scope.offsetX1, y: $scope.offsetY1,
- width: $scope.x - $scope.offsetX1,
- height: $scope.y - $scope.offsetY1,
-
- click: function (layer) {
- $rootScope.shapeTypeText = "textAreaRect";
-
- var layerNameSplit = layer.name;
-
- var splitedName = layerNameSplit.split("_");
-
- var textValName = "TextArea_";
-
- var concatinateResult = textValName.concat(splitedName[1]);
-
- $rootScope.canvasLayerNameCollection = [];
- $rootScope.canvasLayerNameCollection.push({ textareaRectangle: layer.name, textareaString: concatinateResult });
-
-
-
- $('#canvas').setLayer(layer.name, {
- handle: {
- type: 'rectangle',
- fillStyle: '#fff',
- strokeStyle: '#c33',
- strokeWidth: 2,
- width: 5, height: 5,
- cornerRadius: 3
- }
- }).drawLayers();
-
- },
- mouseout: function (layer) {
-
- $rootScope.canvasLayerNameCollection = [];
- $('#canvas').setLayer(layer.name, {
- handle: {
- type: 'rectangle',
- fillStyle: 'pink',
- strokeStyle: 'yellow',
- strokeWidth: 0,
- width: 0, height: 0,
- cornerRadius: 0
- }
-
- }).drawLayers();
-
- },
- mouseover: function (layer) {
-
- $('#canvas').setLayer(layer.name, {
- handle: {
- type: 'rectangle',
- fillStyle: '#fff',
- strokeStyle: '#c33',
- strokeWidth: 2,
- width: 5, height: 5,
- cornerRadius: 3
- }
- }).drawLayers();
-
- }
- });
- $("#text_area").val('');
-
- $("#text_area").css({ " font-family": "'Verdana, sans-serif'", "font-size": "14px", "font-weight": "normal", "font-style": "normal", "color": "#000", "text-align": "left", "text-decoration": "none" });
+ // will refactor this code later
+
+ $rootScope.saveText = function () {
+ // this part will work first time when save button will be clicked
+ if ($rootScope.IsTextAlreadySave == false) {
+ // getting textarea style properties
+ $rootScope.fontSizes = $("#text_area").css("font-size");
+ $rootScope.fontWeight = $("#text_area").css("font-weight");
+ $rootScope.fontStyle = $("#text_area").css("font-style");
+ $rootScope.textAlignmt = $("#text_area").css("text-align");
+ $rootScope.fontColor = $("#text_area").css("color");
+ $rootScope.fontFamily = $("#text_area").css("font-family");
+ $rootScope.underlineText = $("#text_area").css("text-decoration");
+ $rootScope.textArea = $("#text_area").val();
+
+ // deleting previous text area
+
+ $("#canvas").removeLayer('TextArea_' + $rootScope.resetText).drawLayers();
+ $("#canvas").removeLayer("TextRect_" + $rootScope.resetTextRect).drawLayers();
+
+ // Text After Saving in Rectangle
+ $('#canvas').drawText({
+ layer: true,
+ draggable: true,
+ name: 'TextArea_' + $rootScope.resetText,
+ groups: ['TextArea_' + $rootScope.resetText],
+ dragGroups: ['TextArea_' + $rootScope.resetText],
+ fillStyle: $rootScope.fontColor,
+ fontStyle: $rootScope.fontStyle,
+ fontSize: $rootScope.fontSizes,
+ fontFamily: $rootScope.fontFamily,
+ align: $rootScope.textAlignmt,
+ strokeWidth: 0,
+ text: $rootScope.textArea,
+ x: $scope.offsetX1, y: $scope.offsetY1,
+ maxWidth: $scope.x - $scope.offsetX1,
+ maxHeight: $scope.y - $scope.offsetY1,
+ add: function (layer) {
+ $rootScope.TextPropertyArray.push({ Text1: '', Align: '', FontColor: '', FontSize: '', FontStyle: '', FontFamily: '' });
+ $rootScope.TextPropertyArray.push({ Text1: layer.text, Align: layer.align, FontColor: layer.fillStyle, FontSize: layer.fontSize, FontStyle: layer.fontStyle, FontFamily: layer.fontFamily });
+ }
+ })
+ // Draw rectangle
+ .drawRect({
+ name: 'TextArea1_' + $rootScope.resetText,
+ layer: true,
+ draggable: true,
+ groups: ['TextArea_' + $rootScope.resetText],
+ dragGroups: ['TextArea_' + $rootScope.resetText],
+ opacity: $rootScope.shapestyleOpacity,
+ strokeStyle: $rootScope.shapestyleborderColor,
+ strokeWidth: $rootScope.shapestyleborderWidth,
+ x: $scope.offsetX1, y: $scope.offsetY1,
+ width: $scope.x - $scope.offsetX1,
+ height: $scope.y - $scope.offsetY1,
+ click: function (layer) {
+ $rootScope.shapeTypeText = "textAreaRect";
+
+ var layerNameSplit = layer.name;
+ var splitedName = layerNameSplit.split("_");
+ var textValName = "TextArea_";
+ var concatinateResult = textValName.concat(splitedName[1]);
+ $rootScope.canvasLayerNameCollection = [];
+ $rootScope.canvasLayerNameCollection.push({ textareaRectangle: layer.name, textareaString: concatinateResult });
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ width: 5, height: 5,
+ cornerRadius: 3
+ }
+ }).drawLayers();
+ },
+ dblclick: function (layer) {
+ $rootScope.IsTextAlreadySave = true;
+
+ var _rectLayerOnSave = layer.name;
+ var _rectLayerOnSaveSplit = _rectLayerOnSave.split("_");
+ var TextAreaRectName = "TextArea_";
+ var TextAreaRectNameConcatenated = TextAreaRectName.concat(_rectLayerOnSaveSplit[1]);
+ $rootScope.modifySavedText.push({ TextName: layer.name, RectText: TextAreaRectNameConcatenated });
+ $rootScope.rectDimension.push({ width: layer.width, height: layer.height, x: layer.x, y: layer.y });
+ var _rectLayerOnSaveSplitInt;
+ if (_rectLayerOnSaveSplit[1] >= 3)
+ _rectLayerOnSaveSplitInt = parseInt(_rectLayerOnSaveSplit[1] - 2);
+ else
+ _rectLayerOnSaveSplitInt = parseInt(_rectLayerOnSaveSplit[1]);
+ var b = $rootScope.TextPropertyArray[_rectLayerOnSaveSplitInt].Text1;
+ $("#text_area").val(b);
+ $("#text_area").css("font-size", $rootScope.TextPropertyArray[_rectLayerOnSaveSplitInt].FontSize);
+ $("#text_area").css("font-weight", $rootScope.TextPropertyArray[_rectLayerOnSaveSplitInt].FontStyle);
+ $("#text_area").css("font-style", $rootScope.TextPropertyArray[_rectLayerOnSaveSplitInt].FontStyle);
+ $("#text_area").css("text-align", $rootScope.TextPropertyArray[_rectLayerOnSaveSplitInt].Align);
+ $("#text_area").css("color", $rootScope.TextPropertyArray[_rectLayerOnSaveSplitInt].FontColor);
+ $("#text_area").css("font-family", $rootScope.TextPropertyArray[_rectLayerOnSaveSplitInt].FontFamily);
+ $("#text_area").css("text-decoration", $rootScope.underlineText);
+ _rectLayerOnSaveSplitInt = ''; b = '';
+ $("#annotationTextModal").modal("toggle");
+ },
+ mouseout: function (layer) {
+ $rootScope.canvasLayerNameCollection = [];
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: 'pink',
+ strokeStyle: 'yellow',
+ strokeWidth: 0,
+ width: 0, height: 0,
+ cornerRadius: 0
+ }
+ }).drawLayers();
+ },
+ mouseover: function (layer) {
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ width: 5, height: 5,
+ cornerRadius: 3
+ }
+ }).drawLayers();
+
+ }
+ });
+ $("#text_area").val('');
+ $("#text_area").css({ " font-family": "'Verdana, sans-serif'", "font-size": "14px", "font-weight": "normal", "font-style": "normal", "color": "#000", "text-align": "left", "text-decoration": "none" });
+
+ }
+
+// this part will work second time when save button will be clicked
+ else {
+ // getting textarea style properties
+ var _modifiedText = $("#text_area").val();
+ var _modifiedFontSize = $("#text_area").css("font-size");
+ var _modifiedFontWeight = $("#text_area").css("font-weight");
+ var _modifiedFontStyle = $("#text_area").css("font-style");
+ var _modifiedTextAlign = $("#text_area").css("text-align");
+ var _modifiedFontColor = $("#text_area").css("color");
+ var _modifiedFontFamily = $("#text_area").css("font-family");
+ var _modifiedFontDecoration = $("#text_area").css("text-decoration");
+
+ // deleting previous textarea
+ $("#canvas").removeLayer($rootScope.modifySavedText[0].RectText).drawLayers();
+ $("#canvas").removeLayer($rootScope.modifySavedText[0].TextName).drawLayers();
+ $rootScope.resetTextRectSave = $rootScope.ObjectIndexSave++;
+ $rootScope.resetTextSave = $rootScope.ObjectIndexSave++;
+
+ // generating new text area
+ $('#canvas').drawText({
+ layer: true,
+ draggable: true,
+ name: 'TextAreaAfterEdit_' + $rootScope.resetTextSave,
+ groups: ['TextAreaAfterEdit_' + $rootScope.resetTextSave],
+ dragGroups: ['TextAreaAfterEdit_' + $rootScope.resetTextSave],
+ fillStyle: _modifiedFontColor,
+ fontStyle: _modifiedFontStyle,
+ fontSize: _modifiedFontSize,
+ fontFamily: _modifiedFontFamily,
+ align: _modifiedTextAlign,
+ strokeWidth: 0,
+ text: _modifiedText,
+ x: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].x, y: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].y,
+ maxWidth: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].width,
+ maxHeight: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].height
+
+ })
+ // Draw rect as wide as the text
+ .drawRect({
+ name: 'TextAreaAfterEditRect_' + $rootScope.resetTextSave,
+ layer: true,
+ draggable: true,
+ groups: ['TextAreaAfterEdit_' + $rootScope.resetTextSave],
+ dragGroups: ['TextAreaAfterEdit_' + $rootScope.resetTextSave],
+ opacity: $rootScope.shapestyleOpacity,
+ strokeStyle: $rootScope.shapestyleborderColor,
+ strokeWidth: $rootScope.shapestyleborderWidth,
+ x: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].x, y: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].y,
+ width: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].width,
+ height: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].height,
+ click: function (layer) {
+ $rootScope.shapeTypeText = "textAreaRect";
+ var layerNameSplit = layer.name;
+ var splitedName = layerNameSplit.split("_");
+ var textValName = "TextAreaAfterEdit_";
+ var concatinateResult = textValName.concat(splitedName[1]);
+ $rootScope.canvasLayerNameCollection = [];
+ $rootScope.canvasLayerNameCollection.push({ textareaRectangle: layer.name, textareaString: concatinateResult });
+
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ width: 5, height: 5,
+ cornerRadius: 3
+ }
+ }).drawLayers();
+
+ },
+ dblclick: function (layer) {
+
+ $rootScope.IsTextAlreadySave = true;
+ var _rectLayerOnSave = layer.name;
+ var _rectLayerOnSaveSplit = _rectLayerOnSave.split("_");
+ var RectNameAfterEdit = "TextAreaAfterEdit_";
+ var RectNameAfterEditResult = RectNameAfterEdit.concat(_rectLayerOnSaveSplit[1]);
+ $rootScope.modifySavedText.push({ TextName: layer.name, RectText: RectNameAfterEditResult });
+ $rootScope.rectDimension.push({ width: layer.width, height: layer.height, x: layer.x, y: layer.y });
+ $("#text_area").val(_modifiedText);
+ $("#text_area").css("font-size", _modifiedFontSize);
+ $("#text_area").css("font-weight", _modifiedFontWeight);
+ $("#text_area").css("font-style", _modifiedFontStyle);
+ $("#text_area").css("text-align", _modifiedTextAlign);
+ $("#text_area").css("color", _modifiedFontColor);
+ $("#text_area").css("font-family", _modifiedFontFamily);
+ $("#text_area").css("text-decoration", _modifiedFontDecoration);
+ $("#annotationTextModal").modal("toggle");
+ },
+ mouseout: function (layer) {
+ $rootScope.canvasLayerNameCollection = [];
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: 'pink',
+ strokeStyle: 'yellow',
+ strokeWidth: 0,
+ width: 0, height: 0,
+ cornerRadius: 0
+ }
+ }).drawLayers();
+ },
+ mouseover: function (layer) {
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ width: 5, height: 5,
+ cornerRadius: 3
+ }
+ }).drawLayers();
+
+ }
+ });
+ $rootScope.modifySavedText = [];
+
+ }
}
+
+ // deleting text area on close button
+ $rootScope.closeModal = function () {
+ $("#canvas").removeLayer('TextArea_' + $rootScope.resetText).drawLayers();
+ $("#canvas").removeLayer("TextRect_" + $rootScope.resetTextRect).drawLayers();
+
+ }
function OnPaintCanvasMouseMove(event) {
@@ -6589,13 +6740,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
}
$rootScope.FreeStylePaint = function (e) {
- // debugger;
-
-
- // $rootScope.shapeType = "FreeStylePaint";
- canvasPaint.addEventListener('mouseup', $scope.OnPaintBrushCanvasMouseUp, false);
- canvasPaint.addEventListener('mousedown', $scope.OnPaintBrushCanvasMouseDown, false);
-
+
}
$scope.OnPaintBrushCanvasMouseDown = function (event) {
@@ -6603,19 +6748,22 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
case "FreeStylePaint":
- debugger;
- $('#canvasPaint').sketch({ defaultSize: 1 });
- //if ($("#amount-2").val() == '') {
- // $('#canvasPaint').sketch({ defaultSize: $scope.shapesize });
- //}
- //else {
+
- // var a = $("#amount-2").val();
- // $scope.shapesize = parseInt(a);
- // // alert(JSON.stringify({ defaultSize: $scope.shapesize }));
- // $('#canvasPaint').sketch({ defaultSize: $scope.shapesize });
+ // $('#canvasPaint').sketch();
+ // $('#canvasPaint').sketch({ defaultSize: 1 });
+ // if ($("#amount-2").val() == '') {
+ // //$('#canvasPaint').sketch({ defaultSize: $scope.shapesize });
+ // $('#canvasPaint').sketch();
+ // }
+ // else {
- //}
+ // // var a = $("#amount-2").val();
+ //// $scope.shapesize = parseInt(a);
+ // // $('#canvasPaint').sketch({ defaultSize: $rootScope.shapeSize });
+ // // $('#canvasPaint').sketch({ defaultSize: $scope.shapesize });
+
+ // }
break;
@@ -6633,8 +6781,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
// case "FreeStylePaint":
- // debugger;
-
+
// if ($("#amount-2").val() == '')
// {
// $('#canvasPaint').sketch({ defaultSize: $scope.shapesize });
@@ -6662,7 +6809,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
if (event.which == 46) {
- //debugger;
+
if ($rootScope.shapeTypePin == "Pin") {
@@ -7052,7 +7199,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
//list manager
$scope.$on('listManagerEvent', function (event, data) {
- // debugger;
+
$('#spinner').css('visibility', 'visible');
console.log('listManagerEvent')
if ($rootScope.islistManagerEventAlredayDispachted == true) {
diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js.orig b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js.orig
new file mode 100644
index 0000000..b3c3af4
--- /dev/null
+++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js.orig
@@ -0,0 +1,7938 @@
+
+'use strict';
+
+AIA.controller("DAController", ["$scope", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "DA", "Modules", "$routeParams", "DataService",
+function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Modules, $routeParam, DataService) {
+
+
+ $scope.genderId = "";
+ $scope.BodyViewData;
+ $scope.selectedGenderBodyViewData;
+ $scope.imagePath = "";
+ $rootScope.BodyRegionData;
+ $rootScope.BodyRegionCordinatesData;
+ $scope.isTransparencyActivated;
+ $rootScope.BodyLayerData;
+ $rootScope.VocabTermData;
+
+ $scope.VocabTermTxt;
+ $scope.CommonData
+ $rootScope.TermNumberData;
+ $rootScope.BodySystemData
+ $scope.bodyViewId = 0;
+ $rootScope.bgartData;
+ $scope.drawnBodyRegions;
+ //view specific constants
+ $rootScope.voId;
+ $scope.layerNumber;
+ $scope.daCounter = 1;
+ $scope.bagartDetails;
+ $scope.transNumber = 50;
+
+ //for transarency scale
+ $scope.TBDrawStartX;
+ $scope.TBDrawStartY;
+ $rootScope.path = "~/../content/images/speeachBubbleClose.png";
+ $rootScope.isHighLight = false;
+ $rootScope.coloredImageCanvasList = [];
+ $rootScope.coloredImageMRCanvasList = [];
+ $rootScope.ColoredCanvasData = [];
+ $rootScope.grayImageDataList = [];
+ $rootScope.grayImageMRDataList = [];
+ $rootScope.updatedGrayDataList = [];
+ $rootScope.updatedGrayMRDataList = [];
+ $scope.isEligibleForHighlight = false;
+ $scope.doHighlightOrExtract = false;
+ $scope.isEligibleForHighlightBodyByTermList = false;
+
+ $scope.AnteriorView = "active";
+
+ $scope.zoomInOut = 75;
+ $scope.speechBubbleCounter = 0;
+ $scope.j = 0;
+ $scope.speechbubbleList = [];
+ $scope.speachBubbleArrayAnnotation = [];
+ $rootScope.multiAnnotationIsON = false;
+ $scope.previousGrayImageDataVar;
+ $scope.previousGrayCanvas;
+ $rootScope.updatedImageDataList = [];
+ $rootScope.updatedImageMRDataList = [];
+
+ $scope.previousSelectedTermList = [];
+ $scope.runningWorkers = [];
+ $scope.runningSearchWorkers = [];
+ $scope.runningBodyViewWorkers = [];
+
+ // This variable is used for unhighlight previously highlighted body portion, if multiAnnotation is false.
+ $scope.machedIcolorInBodyRegion = [];
+
+ $rootScope.MaskCanvasData = [];
+
+ //extract
+ $rootScope.isExtract = false;
+
+
+ $rootScope.whiteImageDataList = [];
+ $rootScope.whiteImageMRDataList = [];
+ $rootScope.previousHighlightList = [];
+
+ $rootScope.isViewChange = false;
+ $rootScope.isGenderChnage = false;
+
+ // to do it is setting but not using. need to check
+ $rootScope.updatedWhiteImageDataList = [];
+ $rootScope.updatedWhiteImageMRDataList = [];
+
+ //normal mode
+ $rootScope.isNormalMode = false;
+ $rootScope.isZoomed = false;
+
+ //navigator man functionality
+ $scope.navigatorImage;
+ $scope.NavigatorData;
+ $scope.navimgsrc;
+
+ $scope.dragdivleft = 0;
+ $scope.dragdivtop = 0;
+
+ $scope.IsSearchVisible = false;
+ $scope.shapesize = 1;
+ $scope.dragdivposition = {
+ "left": $scope.dragdivleft,
+ "top": $scope.dragdivtop
+ };
+
+
+ //array for bodyviewid correspoing to male female(used for gender change)
+ $scope.correspondingBodyViewIds = {
+ '1': '5',
+ '2': '6',
+ '3': '7',
+ '4': '8',
+ '9': '11',
+ '10': '12',
+
+ '5': '1',
+ '6': '2',
+ '7': '3',
+ '8': '4',
+ '11': '9',
+ '12': '10',
+
+ }
+
+ $scope.bodyViews = {
+ 'Anterior': '1',
+ 'Lateral': '2',
+ 'Medial': '3',
+ 'Posterior': '4',
+ 'Lateral Arm': '5',
+ 'Medial Arm': '6'
+ }
+
+ $scope.isBodylayerdataLoaded = false;
+ $scope.isBodyRegionDataLoaded = false;
+ //currentTitleFromJson shows the current BodyView Title
+ $scope.currentTitleFromJson;
+ $scope.showme = false;
+ $scope.IsVisible = function () {
+ $scope.scroll();
+
+ }
+
+ $scope.scroll = function () {
+ // $window.scrollTo(0, 0);
+ $("html,body").scrollTop(0);
+ //alert("scroll");
+ }
+
+
+ $scope.switchGender = function () {
+
+ var retrievedObject = localStorage.getItem('currentViewTitle');
+
+ if (retrievedObject == "Male Anterior") {
+ $scope.male = "active";
+ $scope.female = "";
+ }
+ else if (retrievedObject == "Female Anterior") {
+ $scope.male = "";
+ $scope.female = "active";
+ }
+ }
+
+ //get the DA body view list based on selected gender
+ //get the DA body view list based on selected gender
+ $scope.getDAViewList = function ($event) {
+
+ // debugger;
+ if ($('#MainImage') != null) {
+ $('#MainImage').remove();
+ }
+ $rootScope.currentActiveModuleTitle = Modules[0].Name;
+ $("#bodyViewList").empty();
+ //for default load
+ if ($event == null || $event == undefined) {
+ //if ((localStorage.getItem("genderId") != "")||(localStorage.getItem("genderId")!="null")) {
+ // $scope.genderId = localStorage.getItem("genderId");
+ //}
+ var selectedGender = localStorage.getItem("genderId");
+ if ((selectedGender == null)) {
+ $scope.genderId = "Male";
+ }
+ else
+ $scope.genderId = localStorage.getItem("genderId");
+
+ }
+ else {
+ $scope.genderId = $event.currentTarget.id;
+ }
+
+ localStorage.setItem("genderId", $scope.genderId);
+
+ var selectedGender = localStorage.getItem("genderId");
+
+ if (selectedGender != null) {
+ if (selectedGender == "Male") {
+ $('#Male').addClass('active');
+ $('#Female').removeClass("active");
+ }
+ else {
+ $('#Female').addClass('active');
+ $('#Male').removeClass("active");
+ }
+
+ }
+
+ $scope.selectedGenderBodyViewData = new jinqJs()
+ .from($scope.BodyViewData.BodyViews.view)
+ .where('_gender == ' + $scope.genderId)
+ .select();
+
+ if ($scope.selectedGenderBodyViewData != null || $scope.selectedGenderBodyViewData != undefined) {
+ angular.forEach($scope.selectedGenderBodyViewData, function (value, key) {
+
+
+ var userEthnicity;
+ var userModestysettings;
+ var curentEthnicity = localStorage.getItem("globalEthnicity");
+ if (typeof (curentEthnicity) !== "undefined" && curentEthnicity !== null) {
+ userEthnicity = curentEthnicity;
+ }
+ else {
+ userEthnicity = $rootScope.globalSetting.ethnicity;
+ }
+
+ var curentmodesty = localStorage.getItem("globalModesty");
+ if (typeof (curentmodesty) !== "undefined" && curentmodesty !== null) {
+ userModestysettings = curentmodesty;
+ }
+ else {
+ userModestysettings = $rootScope.globalSetting.modesty;
+ }
+
+
+
+ //var userSelectedSkintone = 'W';
+ //$scope.userModestySetting = 'Y'
+ var thumbnailImage;
+ if ((value._id == 1) || (value._id == 3) || (value._id == 5) || (value._id == 6) || (value._id == 7) || (value._id == 11))
+ thumbnailImage = ((value._thumbnailImage).replace('.jpg', '_' + userEthnicity + userModestysettings)) + '.jpg';
+ else {
+ thumbnailImage = ((value._thumbnailImage).replace('.jpg', '_' + userEthnicity)) + '.jpg';
+
+ }
+
+ $scope.imagePath = "~/../content/images/DA/" + $scope.zoomInOut + "/body-views/" + value._id + '/skintone/' + userEthnicity + '/' + thumbnailImage;
+ // debugger;
+
+ var $el = $('
'
+ + '

'
+ + '
').appendTo('#bodyViewList');
+
+
+ $compile($el)($scope);
+ $(".sidebar").mCustomScrollbar({
+ autoHideScrollbar: true,
+ //theme:"rounded"
+ });
+
+ });
+ }
+
+ };
+
+
+
+ $scope.openView = function ($event) {
+ // debugger;
+ $rootScope.isLoading = true;
+ $('#spinner').css('visibility', 'visible');
+
+ $rootScope.currentBodyViewId = $event.currentTarget.id;
+ $rootScope.ViewTitle = $event.currentTarget.textContent;
+
+ localStorage.setItem("currentViewTitleFromJson", $event.currentTarget.textContent);
+ localStorage.setItem("currentBodyViewId", $event.currentTarget.id);
+
+ var u = $location.url();
+ $location.url('/da-body-view');
+
+ var view_list = angular.element($event.currentTarget);
+ var view_list_male_female = view_list.attr('title');
+
+ //$rootScope.Normal = "LeftButtonsDefaultState";
+
+ if (view_list_male_female == "Male") {
+
+ $rootScope.male = "active";
+ $rootScope.female = "";
+ }
+ else {
+
+ $rootScope.male = "";
+ $rootScope.female = "active";
+ }
+
+
+ }
+
+
+ //load json data for body view
+ $scope.loadDissectibleAnatomyData = function () {
+
+ $rootScope.ClearIframe();
+
+ //load common data
+ var commondataJsonPath = '~/../content/data/json/da/da_dat_common.json';
+
+ DataService.getAnotherJson(commondataJsonPath)
+ .then(
+ function (result) {
+
+ $rootScope.CommonData = result;
+ $http({ method: 'GET', url: '~/../content/data/json/da/da_dat_contentlist.json' }).success(function (data) {
+
+ $scope.BodyViewData = data;
+
+ $scope.getDAViewList();
+
+ })
+ .error(function (data, status, headers, config) {
+ console.log(data);
+ });
+
+
+ },
+ function (error) {
+ console.log(error.statusText)
+ }
+ )
+ //load body-views data
+
+
+ // $('#daLoaderLabel').css('visibility', 'hidden')
+ $rootScope.isLoading = false;
+
+
+
+ //push the details of open module in array $rootScope.openModules
+ $rootScope.openModules.push({ "ModuleId": 1 });
+
+
+ }
+
+
+ //da-body-views functions
+
+ $scope.openBodyView = function () {
+
+ //0. we will initially append container to load body
+
+ //check if localstorage has any settings
+ var curentEthnicity = localStorage.getItem("globalEthnicity");
+ if (typeof (curentEthnicity) !== "undefined" && curentEthnicity !== null) {
+ $rootScope.globalSetting.ethnicity = curentEthnicity;
+ }
+
+ var curentmodesty = localStorage.getItem("globalModesty");
+ if (typeof (curentmodesty) !== "undefined" && curentmodesty !== null) {
+ $rootScope.globalSetting.modesty = curentmodesty
+ }
+
+ //0.1
+ var currentBodyViewId = localStorage.getItem("currentBodyViewId");
+
+ console.log('currentBodyViewId pickjed from localStorage: ' + currentBodyViewId);
+
+ var openViews;
+ if ($rootScope.openViews != null || $rootScope.openViews != undefined) {
+ if ($rootScope.openViews.length > 0) {
+ openViews = new jinqJs()
+ .from($rootScope.openViews)
+ .where("BodyViewId == " + currentBodyViewId)
+ .select();
+ }
+ }
+
+ // 0.2 getting corresponding body view title
+ var counter = 1;
+ var tittle = localStorage.getItem("currentViewTitleFromJson");
+
+ if (openViews != null && openViews != undefined) {
+ angular.forEach(openViews, function (value, key) {
+
+ if (value.body - views == tittle) {
+ tittle = localStorage.getItem("currentViewTitleFromJson") + counter++;
+ $rootScope.currentActiveViewTitle = tittle;
+ localStorage.setItem("currentViewTitle", tittle);
+ }
+
+ });
+ }
+ else {
+ localStorage.setItem("currentViewTitle", tittle);
+ }
+
+ //0.3
+
+ $.jsPanel({
+ id: 'daImagePanel',
+ selector: '.daBodyView',
+ theme: 'success',
+ currentController: 'DAController',
+ parentSlug: 'da-view-list',
+ ajax: {
+ url: 'app/views/da/da-view.html'
+ },
+ title: localStorage.getItem("currentViewTitle"),
+ position: {
+ top: 70,
+ left: 1,
+ },
+
+ size: { width: $(window).outerWidth() - 10, height: $(window).outerHeight() - 110 },
+
+ });
+
+ //0.1
+ $rootScope.currentSlug = 'da-body-view';
+
+ //0.2
+ $rootScope.openViews.push(
+ {
+ "module": $rootScope.currentActiveModuleTitle, "body-views": tittle, "state": 'max', "BodyViewId": $rootScope.currentBodyViewId,
+ "slug": $rootScope.currentSlug
+ }
+ );
+
+ //0.3
+ var daBodyviewElement = angular.element(document.getElementById("daBodyview"));
+
+ $timeout(function () { $compile(daBodyviewElement.contents())($scope) }, 250);
+
+
+ //0.4 added some stylesheets
+ $('#daBodyview').css("height", $(window).outerHeight());
+
+ $('#daBodyview').css("width", $(window).outerWidth());
+
+ //1. load navigator man first
+ $scope.LoadBodyViewNavigatorImage();
+
+ $scope.loadSearchDataForBodyView();
+
+ $scope.currentTitleFromJson = localStorage.getItem("currentViewTitle");
+
+ $scope.layerNumber = 0;
+
+ //2.
+
+ console.log('currentBodyViewId just before sending: ' + currentBodyViewId);
+ $scope.loadBodyViewData(currentBodyViewId);
+
+ //2. load bodyRegion data
+ $rootScope.isLoading = true;
+ $rootScope.voId = localStorage.getItem("currentBodyViewId");
+
+ $('#daBodyview').css("height", $(window).outerHeight());
+
+ $('#daBodyview').css("width", $(window).outerWidth());
+ }
+
+ angular.element(document).ready(function () {
+
+ })
+
+
+ $scope.loadSearchDataForBodyView = function () {
+
+ console.log('loadSearchDataForBodyView');
+
+ var currentBodyViewId = localStorage.getItem("currentBodyViewId");
+
+
+ var searchWorker = new Worker('search-wp.js');
+
+ //push workers in array to further used the refernece to delete the workers
+ $scope.runningSearchWorkers.push({ 'workerName': searchWorker })
+
+ //console.log('for bodyRegionId = ' + bodyRegionId + ', time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"))
+
+ searchWorker.postMessage({
+ 'currentBodyViewId': currentBodyViewId,
+ })
+
+ searchWorker.onmessage = function (e) {
+ //console.log('callback searchWorker , time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"));
+
+
+
+ $rootScope.TermNumberData = e.data.TermNumberData,
+ $rootScope.VocabTermData = e.data.VocabTermData,
+ $scope.vocabTermTxt = e.data.vocabTermTxt
+
+
+ $scope.VocabTermTxt = new jinqJs()
+ .from($scope.vocabTermTxt)
+ .distinct('_TermText', '_ActualTermNumber')
+ .orderBy([{ field: '_TermText', sort: 'asc' }])
+ .select('_ActualTermNumber', '_TermText', '_cdId');
+
+
+ console.log('JlinqActivity , time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"));
+
+ if ($scope.runningSearchWorkers != null || $scope.runningSearchWorkers != undefined) {
+
+ var workerCount = $scope.runningSearchWorkers.length;
+ if (workerCount > 0) {
+ for (var i = workerCount - 1; i >= 0; i--) {
+
+
+
+ var runningWorker = $scope.runningSearchWorkers[i].workerName;
+ runningWorker.terminate();
+ $scope.runningSearchWorkers.splice(i, 1);
+ // workerCount--;
+ }
+ }
+ }
+ }
+
+ }
+
+ $scope.loadBodyViewData = function (currentVoid) {
+ console.log('caller of worker sending currentVoid: ' + currentVoid);
+
+ var bodyViewWorker = new Worker('body-view-wp.js');
+
+ //push workers in array to further used the refernece to delete the workers
+ $scope.runningBodyViewWorkers.push({ 'workerName': bodyViewWorker })
+
+ bodyViewWorker.postMessage({
+
+ 'currentViewId': currentVoid
+
+ });
+
+ bodyViewWorker.onmessage = function (e) {
+ //console.log('callback in extr');
+
+ $rootScope.BodyRegionData = e.data.bodyRegionData;
+ $rootScope.bgartData = e.data.bodyArtData;
+ $rootScope.BodyLayerData = e.data.bodyLayerData;
+
+ $scope.isBodylayerdataLoaded = true;
+
+ $scope.LoadDefaultLayerImage();
+
+
+
+ }
+ bodyViewWorker.onerror = function (e) {
+ alert('Error: Line ' + e.lineno + ' in ' + e.filename + ': ' + e.message);
+ };
+ }
+
+
+ //Code for displaying NavigatorImage for BodyView
+ $scope.LoadBodyViewNavigatorImage = function () {
+ var NavigatorManJsonPath = '~/../content/data/json/da/da_dat_orient_image.json';
+
+ $http({ method: 'GET', url: NavigatorManJsonPath })
+ .success(function (data) {
+ $scope.NavigatorData = data;
+
+ $scope.skinTone = $rootScope.globalSetting.ethnicity;
+
+ var navigatorManData = new jinqJs()
+ .from($scope.NavigatorData.Navigtor.ViewOrientation)
+ .where("_ViewOrientationId == " + $rootScope.currentBodyViewId)
+ .select();
+
+ if ((navigatorManData != null || navigatorManData != undefined) && (navigatorManData.length > 0)) {
+
+
+ var imageInfoForNavigator = new jinqJs()
+ .from(navigatorManData[0].ImageInfo)
+ .where("_Ethnicity == " + $scope.skinTone)
+ .select();
+ }
+ else {
+ console.log('NAVIGATOR.DATA.NOT.FOUND FOR BODY VIEW: ' + $rootScope.currentBodyViewId);
+ }
+
+ if (imageInfoForNavigator != null || imageInfoForNavigator != undefined) {
+ $scope.navigatorImage = imageInfoForNavigator;
+
+
+ var navImageModesty;
+
+ if (($scope.navigatorImage != null || $scope.navigatorImage != undefined) && ($scope.navigatorImage.length > 0)) {
+ angular.forEach($scope.navigatorImage, function (value, key) {
+
+ if (value._HaveModesty === $rootScope.globalSetting.modesty) {
+ navImageModesty = value._ImageName;
+ }
+ })
+ }
+ if (typeof (navImageModesty) === "undefined" || navImageModesty === null) {
+
+ navImageModesty = $scope.navigatorImage[0]._ImageName;
+ }
+
+ $scope.navimgsrc = "~/../content/images/DA/ethnicity/body-views/" + $scope.voId + '/' + $scope.skinTone + '/navigator_images/' + navImageModesty;
+
+ $('#navigatorDiv').css('visibility', 'visible');
+
+ $('#containment - wrapper').css('visibility', 'visible');
+ }
+
+ else {
+ console.log('NAVIGATOR.IMAGE.NOT.FOUND FOR BODY VIEW: ' + $rootScope.currentBodyViewId);
+ }
+ })
+
+ .error(function (data, status, headers, config) {
+ //1.
+ console.log('DATA.NOT.LOADED FOR:' + NavigatorManJsonPath + ', ERROR: ' + data);
+ //2.
+ // $scope.LoadBodyViewNavigatorImage()
+ });
+ }
+
+
+ $scope.LoadDefaultLayerImage = function () {
+ // debugger;
+
+ $rootScope.isNormalMode = true;
+
+ $scope.layerNumber = 0;
+ $scope.skinTone = $rootScope.globalSetting.ethnicity;
+
+ $rootScope.viewOrientationId = $rootScope.voId;
+ if ($rootScope.voId == 5) {
+ $rootScope.viewOrientationId = 1;
+ }
+ else if ($rootScope.voId == 6) {
+ $rootScope.viewOrientationId = 2;
+ }
+ else if ($rootScope.voId == 7) {
+ $rootScope.viewOrientationId = 3;
+ }
+ else if ($rootScope.voId == 8) {
+ $rootScope.viewOrientationId = 4;
+ }
+ else if ($rootScope.voId == 9) {
+ $rootScope.viewOrientationId = 5;
+ }
+ else if ($rootScope.voId == 10) {
+ $rootScope.viewOrientationId = 6;
+ }
+ else if ($rootScope.voId == 11) {
+ $rootScope.viewOrientationId = 5;
+ }
+ else if ($rootScope.voId == 12) {
+ $rootScope.viewOrientationId = 6;
+ }
+
+ $scope.CalculateImageCordinates($rootScope.viewOrientationId);
+
+
+ };
+
+
+ //calculate coordinates for body region images
+ $scope.CalculateImageCordinates = function (viewOrientationId) {
+
+ $scope.terminateCurrentlyRunningWPs();
+
+ var drawnBodyRegionCount = [];
+
+ if ($rootScope.MaskCanvasData != null || $rootScope.MaskCanvasData != undefined) {
+ var n = $rootScope.MaskCanvasData.length;
+
+ if (n > 0) {
+ for (var i = n - 1; i >= 0; i--) {
+
+ $rootScope.MaskCanvasData.splice(i, 1);
+ // workerCount--;
+ }
+
+ $rootScope.MaskCanvasData = null;
+ $rootScope.MaskCanvasData = [];
+ }
+ }
+
+ //set height of canvas div and left tool bar as per window size
+ $rootScope.BodyRegionCordinatesData = []; // create an empty array
+
+ $('#daBodyview').css('width', '100%');
+ $('#canvasDiv').css('height', $('#daImagePanel').outerHeight() - 104)
+ //$('#canvasDiv').css('width', $('#daImagePanel').outerWidth() - 100)
+ $('#leftToolBar').css('height', $('#daImagePanel').outerHeight())
+
+
+
+ //calculate image coordinates and draw image
+ var bodyRegionCoordinates = $rootScope.BodyRegionData.BodyRegionViews;
+ // var viewOrientationId = String($rootScope.voId);
+
+
+ $scope.bodyRegionCoordinates = new jinqJs()
+ .from($rootScope.BodyRegionData.BodyRegionViews.BodyRegionCordinates)
+ .where('_ViewOrientationId == ' + viewOrientationId)
+ .select();
+
+ console.log('viewOrientationId= ' + viewOrientationId + ', $scope.bodyRegionCoordinates length= ' + $scope.bodyRegionCoordinates.length)
+ // if ($rootScope.voId == 9 || $rootScope.voId == 11) {
+
+ $scope.bagartDetails = new jinqJs()
+ .from($rootScope.bgartData.BackgroundArts.BackgroundArtDetail)
+ .where('_ViewOrientationId == ' + viewOrientationId)
+ .select();
+
+ if ($scope.ColoredImageSRC != null && $scope.ColoredImageSRC.length > 0) {
+ $scope.ColoredImageSRC = null;
+ $scope.ColoredImageSRC = [];
+ $scope.flushCanvas();
+ }
+ else {
+ $scope.ColoredImageSRC = [];
+ }
+
+ if ($scope.bodyRegionCoordinates != null || $scope.bodyRegionCoordinates != undefined) {
+ angular.forEach($scope.bodyRegionCoordinates, function (value, key) {
+
+ if (value._HaveMirrorImage == 'Y') {
+
+ //DrawMirroredImage
+
+ //0. Scaling as per default zoom
+ var rectangle = scaleRectangle(value._X, value._Y, value._Height, value._Width, value._MirrorValue);
+
+ //1.Get image source
+ var src = $scope.GetImageSource(value._BodyRegionId);
+
+ $scope.imageSource = src;
+
+ //2.Draw mirror image
+ $scope.DrawMirroredImage(Math.round(rectangle.scaledHeight), Math.round(rectangle.scaledWidth), Math.round(rectangle.scaledX), Math.round(rectangle.scaledY), src, value._BodyRegionId, 'N');
+ // debugger;
+ $rootScope.BodyRegionCordinatesData.push(
+ {
+ "bodyRegionId": value._BodyRegionId, "Height": Math.round(rectangle.scaledHeight), "Width": Math.round(rectangle.scaledWidth),
+ "X": Math.round(rectangle.scaledX), "Y": Math.round(rectangle.scaledY), "IsMirror": 'Yes'
+ }
+ );
+
+ //3.GetMaskImageSource
+ var maskImageSrc = $scope.GetMaskImageSource($scope.imageSource);
+ // debugger;
+ //4 Draw Mask Mirror Image
+ $scope.DrawMirroredImage(Math.round(rectangle.scaledHeight), Math.round(rectangle.scaledWidth), Math.round(rectangle.scaledX), Math.round(rectangle.scaledY), maskImageSrc, value._BodyRegionId, 'Y');
+
+
+ //Draw Normal Image
+
+ //0. Scaling as per default zoom
+ var rectangle = scaleRectangle(value._X, value._Y, value._Height, value._Width, 0);
+
+
+ //1.Draw body region which have mirror image
+ $scope.DrawImage(Math.round(rectangle.scaledHeight), Math.round(rectangle.scaledWidth), Math.round(rectangle.scaledX), Math.round(rectangle.scaledY), src, value._BodyRegionId, 'N');
+ $scope.BodyRegionCordinatesData.push(
+ {
+ "bodyRegionId": value._BodyRegionId, "Height": Math.round(rectangle.scaledHeight), "Width": Math.round(rectangle.scaledWidth),
+ "X": Math.round(rectangle.scaledX), "Y": Math.round(rectangle.scaledY), "IsMirror": 'No'
+ }
+ );
+
+ //2.Draw body region for mask image
+ $scope.DrawImage(Math.round(rectangle.scaledHeight), Math.round(rectangle.scaledWidth), Math.round(rectangle.scaledX), Math.round(rectangle.scaledY), maskImageSrc, value._BodyRegionId, 'Y');
+
+
+ }
+ else {
+
+ //0.Scaling as per default zoom
+ var rectangle = scaleRectangle(value._X, value._Y, value._Height, value._Width, value._MirrorValue);
+
+ //1.Get image source
+ if (value._IsPrimary == 'N') {
+ var src = $scope.GetBackgroundImgSource(value._BodyRegionId);
+ $scope.imageSource = src;
+ }
+ else {
+ var src = $scope.GetImageSource(value._BodyRegionId);
+ $scope.imageSource = src;
+ }
+
+ //2.Draw body region which don't have mirror image
+ $scope.DrawImage(Math.round(rectangle.scaledHeight), Math.round(rectangle.scaledWidth), Math.round(rectangle.scaledX), Math.round(rectangle.scaledY), src, value._BodyRegionId, 'N');
+
+ $scope.BodyRegionCordinatesData.push(
+ {
+ "bodyRegionId": value._BodyRegionId, "Height": Math.round(rectangle.scaledHeight), "Width": Math.round(rectangle.scaledWidth),
+ "X": Math.round(rectangle.scaledX), "Y": Math.round(rectangle.scaledY), "IsMirror": 'No'
+ }
+ );
+
+ //3.GetMaskImageSource
+ var maskSRC = $scope.GetMaskImageSource($scope.imageSource);
+
+ //4.Draw body region for mask image
+ $scope.DrawImage(Math.round(rectangle.scaledHeight), Math.round(rectangle.scaledWidth), Math.round(rectangle.scaledX), Math.round(rectangle.scaledY), maskSRC, value._BodyRegionId, 'Y');
+
+
+ //draw figLeaf for modesty
+
+ $scope.figLaefImageName;
+ $scope.figLaefX;
+ $scope.figLaefY;
+ var gender;
+ if (localStorage.getItem("genderId") == 'Female') {
+ gender = 'F';
+
+ }
+ else {
+ gender = 'M';
+ }
+ if (((localStorage.getItem("genderId") == 'Female') && (value._BodyRegionId == 2)) || (value._BodyRegionId == 3)) {
+
+ if ($scope.bagartDetails != null || $scope.bagartDetails != undefined) {
+ var dtlOfBr = new jinqJs()
+ .from($scope.bagartDetails)
+ .where('_BodyRegionId == ' + value._BodyRegionId)
+ .select();
+ if (dtlOfBr != null || dtlOfBr != undefined) {
+
+ var dtlOfGender = new jinqJs()
+ .from(dtlOfBr)
+ .where('_Gender == ' + gender)
+ .select();
+ if (dtlOfGender != null || dtlOfGender != undefined) {
+
+ var dtlOfSktn = new jinqJs()
+ .from(dtlOfGender)
+ .where('_Skintone == +')
+ .select();
+
+ //multiple conditions are not working in where clause of JinQ so need multiple filtered variables
+
+
+ if ((dtlOfSktn != null || dtlOfSktn != undefined) && (dtlOfSktn.length > 0)) {
+
+ if ((parseInt(dtlOfSktn[0]._lns) <= parseInt($scope.layerNumber)) && (parseInt(dtlOfSktn[0]._lne) > parseInt($scope.layerNumber)) && (dtlOfSktn[0]._isfr == 'Y')) {
+ $scope.figLaefImageName = dtlOfSktn[0]._ImageId;
+ //$scope.figLaefX = filtereddata[0]._X;
+ //$scope.figLaefY = filtereddata[0]._Y;
+
+ var rectangle = scaleRectangle(value._X, value._Y, value._Height, value._Width, value._MirrorValue);
+
+
+ var src = "content/images/DA/" + $scope.zoomInOut + "/body-views/" + $rootScope.voId + "/layers/0/" + value._BodyRegionId + "/" + $scope.figLaefImageName;
+
+ $scope.DrawImage(rectangle.scaledHeight, rectangle.scaledWidth, rectangle.scaledX, rectangle.scaledY, src, 'modestyImg' + value._BodyRegionId, 'N')
+
+ }
+ }
+ }
+ }
+
+ }
+
+
+ }
+ }
+
+
+ });
+
+ $rootScope.isLoading = false;
+ $('#spinner').css('visibility', 'hidden');
+ }
+
+ if (($rootScope.globalSetting.modesty == 'Y')) {
+ if ($('.modestyImg') != null) {
+ $('.modestyImg').css('visibility', 'visible');
+ }
+ }
+ //set scrollbars on canvas and hide loading label
+ // debugger;
+ // var isiOSSafari = (navigator.userAgent.match(/like Mac OS X/i)) ? true : false;
+ var isiOSSafari = (navigator.userAgent.match(/iPad/i)) ? true : false;
+
+ //set scrollbars on canvas and hide loading label
+ // $('#daLoaderLabel').css('visibility', 'hidden')
+
+ $('#canvasDiv').css('overflow', 'scroll')
+ if (isiOSSafari) {
+ $('#canvasDiv').scrollLeft($('#canvasDiv').width() + 150)
+
+ }
+ else {
+ $('#canvasDiv').scrollLeft($('#canvasDiv').width() / 2)
+ }
+ // $('#canvasDiv').scrollLeft($scope.imageHorizontlScrollPosition)
+ $('#canvasDiv').scrollTop(50)
+ var abc = $rootScope.BodyRegionCordinatesData;
+ //debugger;
+ $('#layerChangeSlider').slider("option", "value", parseInt($scope.totalLayers) - parseInt($scope.layerNumber));
+ // $('#spinner').css('visibility', 'hidden');
+ $rootScope.isLoading = false;
+ //Dated:16-07-2016 Issue #4957 :While selecting the Zoom-in\Zoom-out button scroll should be go on top.
+ // #4976 :While changing gender male to female scroll bar is going on top.
+ var canvasDiv = document.getElementById('canvasDiv');
+ canvasDiv.scrollTop = 0;
+
+ //Navigator Code for dynamically calculating the height and width of Dragable Div on Navigator Image
+
+ var dragdivh = Math.floor(($('#canvasDiv').height() / $('#canvasDiv')[0].scrollHeight) * 119) //119px is the height of the image
+
+ if ($('#canvasDiv')[0].scrollWidth > $('#canvasDiv')[0].clientWidth) {
+
+ var dragdivw = 42
+ $scope.dragdivleft = 21;
+ $scope.dragdivtop = 0;
+
+ $scope.dragdivposition = {
+ "left": 21,
+ "top": 0
+ };
+ }
+ else {
+ var dragdivw = 83;
+
+ $scope.dragdivleft = 0;
+ $scope.dragdivtop = 0;
+
+ $scope.dragdivposition = {
+ "left": 0,
+ "top": 0
+
+ };
+ }
+
+ $('#draggable').css('width', dragdivw);
+ $('#draggable').css('height', dragdivh)
+ }
+
+ function scaleRectangle(x, y, height, width, mirrorValue) {
+ var nzoom = $scope.zoomInOut;
+ var existingZoon = 100;
+
+ var X = 0;
+ var scaledY = 0;
+ var scaledHeight = 0;
+ var scaledWidth = 0;
+
+ if (mirrorValue != 0) {
+ var mirroredX = parseInt(mirrorValue) + parseInt(x);
+ var newX = (mirroredX * nzoom);
+ mirroredX = (newX / existingZoon);
+ X = mirroredX;
+ }
+ else {
+ var newX = (x * nzoom);
+ X = (newX / existingZoon);
+ }
+
+ var newY = (y * nzoom);
+ var Y = (newY / existingZoon);
+
+ var newHeight = (height * nzoom);
+ var ht = (newHeight / existingZoon);
+
+ var newWidth = (width * nzoom);
+ var wt = (newWidth / existingZoon);
+
+ return {
+ scaledX: X,
+ scaledY: Y,
+ scaledHeight: ht,
+ scaledWidth: wt
+ }
+ }
+
+ $scope.GetMaskImageSource = function (src) {
+
+ if (src != null || src != undefined) {
+ if (src.match('.png')) {
+ var mciImage = src.replace('.png', '_mci.png')
+ }
+ else {
+ var mciImage = src.replace('.jpg', '_mci.png')
+ }
+ return mciImage;
+
+ }
+ else {
+ console.log('IMAGE.SOURCE.NOLT.FOUND');
+ }
+ }
+
+
+
+ $scope.GetImageSource = function (bodyRegionId) {
+ // debugger;
+ var dataLength = $rootScope.BodyLayerData.Layers.DataLayer.length;
+
+ //set max for LayerNumber input
+ $scope.totalLayers = dataLength - 1;
+ // debugger
+ $('#txtLayerNumber').attr('max', $scope.totalLayers);
+ $('#layerChangeSlider').slider("option", "max", $scope.totalLayers);
+ // $('#layerChangeSlider').slider("option", "value",parseInt($scope.totalLayers)-parseInt($scope.layerNumber));
+
+ $scope.one = 1;
+
+ if ($rootScope.isListManagerSelected == true) {
+ $scope.layerNumber = $('#txtlayerNumber').val();
+ }
+
+ $scope.userInput = parseInt($scope.layerNumber);
+
+
+ $scope.skinTone = $rootScope.globalSetting.ethnicity;
+
+ var SelectedLayerData = [];
+ SelectedLayerData = $rootScope.BodyLayerData.Layers.DataLayer[dataLength - $scope.userInput - 1];
+ if ((SelectedLayerData != null || SelectedLayerData != undefined))
+
+ if ($scope.layerNumber == 0) {
+ console.log('lNo: ' + $scope.layerNumber + ' and BodyRegion.length: ' + SelectedLayerData.BodyRegion.length);
+
+ if (SelectedLayerData.BodyRegion.length > 0) {
+ for (var z = 0; z < SelectedLayerData.BodyRegion.length; z++) {
+
+ var bodyRegion = SelectedLayerData.BodyRegion[z]._BodyRegionId;
+ var bodyRegionSkinTone = SelectedLayerData.BodyRegion[z].Image._SkintTone;
+
+ if ($rootScope.viewOrientationId == 3 && bodyRegionId == 1) {
+ console.log('$rootScope.voId: ' + $rootScope.voId);
+ if (bodyRegion == bodyRegionId && bodyRegionSkinTone == 'W') {
+ return "content/images/DA/" + $scope.zoomInOut + "/body-views/" + $rootScope.voId + "/layers/" + $scope.layerNumber + "/" + bodyRegionId + "/W/" + SelectedLayerData.BodyRegion[z].Image._ImageName;
+ }
+ }
+
+ else {
+
+ if (bodyRegion == bodyRegionId && bodyRegionSkinTone == $scope.skinTone) {
+
+ return "content/images/DA/" + $scope.zoomInOut + "/body-views/" + $rootScope.voId + "/layers/" + $scope.layerNumber + "/" + bodyRegionId + "/" + $scope.skinTone + "/" + SelectedLayerData.BodyRegion[z].Image._ImageName;
+ }
+ }
+ }
+ }
+ }
+ else {
+ // debugger;
+ //below 4 bodyviews have only single body region
+ if (($rootScope.voId == '9') || ($rootScope.voId == '11') || ($rootScope.voId == '10') || ($rootScope.voId == '12')) {
+ var bodyRegion = SelectedLayerData.BodyRegion._BodyRegionId;
+
+ return "content/images/DA/" + $scope.zoomInOut + "/body-views/" + $rootScope.voId + "/layers/" + $scope.layerNumber + "/" + bodyRegionId + "/" + SelectedLayerData.BodyRegion.Image._ImageName;
+
+ }
+ else // it is for other body view which have multiple body regions and layer no > 0
+ {
+ // debugger;
+ if (SelectedLayerData.BodyRegion.length > 0) {
+ for (var z = 0; z <= SelectedLayerData.BodyRegion.length; z++) {
+ var bodyRegion = SelectedLayerData.BodyRegion[z]._BodyRegionId;
+ if (bodyRegion == bodyRegionId) {
+
+ return "content/images/DA/" + $scope.zoomInOut + "/body-views/" + $rootScope.voId + "/layers/" + $scope.layerNumber + "/" + bodyRegionId + "/" + SelectedLayerData.BodyRegion[z].Image._ImageName;
+
+
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+ $scope.GetBackgroundImgSource = function (bodyRegionId) {
+ // debugger;
+
+ var selectedGender;
+ if (localStorage.getItem("genderId") == "Male") {
+ selectedGender = 'M';
+ }
+ else {
+ selectedGender = 'F';
+
+ }
+ //filter data based on bodyRegion
+ $scope.bagartBodyRegionDetails = new jinqJs()
+ .from($scope.bagartDetails)
+ .where('_BodyRegionId == ' + bodyRegionId)
+ .select();
+ if ($scope.bagartBodyRegionDetails != null || $scope.bagartBodyRegionDetails != undefined) {
+
+ //filter bodyRegion data basd on skintone
+ $scope.bagartDetailsOnSktn = new jinqJs()
+ .from($scope.bagartBodyRegionDetails)
+ .where('_Skintone == ' + $scope.skinTone)
+ .select();
+
+ if ($scope.bagartDetailsOnSktn != null || $scope.bagartDetailsOnSktn != undefined) {
+ //only brid=2 is having different male,female image, other bodr region have common images for male, female
+ if (bodyRegionId == 2) {
+ for (var z = 0; z <= $scope.bagartDetailsOnSktn.length; z++) {
+ var gender = $scope.bagartDetailsOnSktn[z]._Gender;
+ if (gender == selectedGender) {
+ return "content/images/DA/" + $scope.zoomInOut + "/body-views/" + $rootScope.voId + "/layers/0/" + bodyRegionId + "/" + $scope.skinTone + "/" + $scope.bagartDetailsOnSktn[z]._ImageId;
+ }
+ }
+ }
+
+ else {
+ return "content/images/DA/" + $scope.zoomInOut + "/body-views/" + $rootScope.voId + "/layers/0/" + bodyRegionId + "/" + $scope.skinTone + "/" + $scope.bagartDetailsOnSktn[0]._ImageId;
+
+ }
+ }
+ }
+ }
+
+
+ $scope.DrawMirroredImage = function (h, w, x, y, src, bodyRegionId, isMaskImage) {
+
+ var FlipedImgCanvas = document.createElement('canvas');
+ FlipedImgCanvas.height = h;
+ FlipedImgCanvas.width = w;
+ FlipedImgCanvas.setAttribute("data-IsMirrored", "Y")
+ FlipedImgCanvas.style.position = "absolute";
+ FlipedImgCanvas.style.left = x + "px";
+ FlipedImgCanvas.style.top = y + "px";
+
+
+
+ if (isMaskImage == 'Y') {
+ FlipedImgCanvas.id = 'imageCanvas' + bodyRegionId + '_MR_mci';
+ FlipedImgCanvas.style.visibility = 'hidden'
+
+ }
+ else {
+ FlipedImgCanvas.id = 'imageCanvas' + bodyRegionId + '_MR';
+
+
+ if ($rootScope.isExtract == true) {
+ FlipedImgCanvas.style.visibility = 'visible'
+ }
+ else {
+ if ($rootScope.isHighLight == true && $rootScope.isZoomed == false) {
+ FlipedImgCanvas.style.visibility = 'hidden';
+ }
+ }
+ }
+
+
+
+ FlipedImgCanvas.addEventListener('click', function (evt) {
+
+ //to get correct data on multihighlight highlight
+ if ($scope.isLayerChange == true) {
+ $scope.isLayerChange = false;
+ }
+
+ if (evt.ctrlKey) {
+ $rootScope.multiAnnotationIsON = true;
+ }
+ else {
+ if (($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined) && ($rootScope.previousHighlightList.length > 0)) {
+ $rootScope.previousHighlightList = [];
+ }
+
+ $rootScope.multiAnnotationIsON = false;
+ }
+
+ //get mouse coordinate of mirror image click
+ var mousePos = $scope.getMousePos(evt);
+
+ var context = FlipedImgCanvas.getContext("2d");
+ var canvasId = context.canvas.getAttribute('id');
+
+
+ var mirrorCanvasX = context.canvas.offsetLeft;
+ var mirrorCanvasWidth = context.canvas.clientWidth;
+
+ var maskCanvasId = (canvasId.replace('_MR', '')) + '_mci';
+ var maskCanvas = document.getElementById(maskCanvasId);
+ var maskCanvasContext = maskCanvas.getContext("2d");
+
+
+ var canvasDiv = document.getElementById('canvasDiv');
+ var verticalScrollPosition = canvasDiv.scrollTop;
+ var horizontlScrollPosition = canvasDiv.scrollLeft;
+
+ var distanceXOnMirrorImage = (parseInt(mirrorCanvasX) + parseInt(mirrorCanvasWidth)) - (parseInt(mousePos.x) + horizontlScrollPosition);// - 135);
+
+ var mirrorXOnNormalImage = parseInt(maskCanvasContext.canvas.offsetLeft) + parseInt(distanceXOnMirrorImage);
+
+ var actulalX = mirrorXOnNormalImage
+ var actualY = mousePos.y + verticalScrollPosition
+
+
+ var pixelData = maskCanvasContext.getImageData(Math.round(actulalX - parseInt(maskCanvasContext.canvas.offsetLeft)), Math.round(actualY - y), 1, 1);
+
+ pixelData.data[0] = pixelData.data[0] - 9;
+ pixelData.data[1] = pixelData.data[1] - 9;
+ pixelData.data[2] = pixelData.data[2] - 9
+
+ var Red;
+ var Green;
+ var Blue;
+ var zero = "0";
+
+ if ((pixelData.data[0]).toString().length != 2) {
+ Red = zero.concat((pixelData.data[0]).toString())
+ }
+ else {
+ Red = (pixelData.data[0]).toString()
+ }
+ if ((pixelData.data[1]).toString().length != 2) {
+ Green = zero.concat((pixelData.data[1]).toString())
+ }
+ else {
+ Green = (pixelData.data[1]).toString()
+
+ }
+ if ((pixelData.data[2]).toString().length != 2) {
+ Blue = zero.concat((pixelData.data[2]).toString())
+ }
+ else {
+ Blue = (pixelData.data[2]).toString()
+
+ }
+ var RGBColor = (Red + Green + Blue);
+
+ if ($rootScope.isHighLight) {
+
+ if ($scope.machedIcolorInBodyRegion != null || $scope.machedIcolorInBodyRegion != undefined) {
+ if ($scope.machedIcolorInBodyRegion.length > 0) {
+ if ($rootScope.multiAnnotationIsON == false) {
+ for (var i = 0; i < $scope.machedIcolorInBodyRegion.length; i++) {
+ var bodyRegionId = $scope.machedIcolorInBodyRegion[i];
+
+ var grayCanvasID = 'imageCanvas' + bodyRegionId;
+ var grayCanvas = document.getElementById(grayCanvasID);
+
+ var grayCanvasContext = grayCanvas.getContext("2d");
+
+ if ($rootScope.grayImageDataList[bodyRegionId - 1] != null || $rootScope.grayImageDataList[bodyRegionId - 1] != undefined) {
+ var grayImageData = $rootScope.grayImageDataList[bodyRegionId - 1];
+ grayCanvasContext.putImageData(grayImageData, 0, 0);
+ }
+
+ // for mirrored canvas
+
+ if (bodyRegionId == 4 || bodyRegionId == 5 || bodyRegionId == 6) {
+ var grayCanvasID = 'imageCanvas' + bodyRegionId + '_MR';
+ var grayCanvasMR = document.getElementById(grayCanvasID);
+
+ var grayCanvasContextMR = grayCanvasMR.getContext("2d");
+ if ($rootScope.grayImageMRDataList[bodyRegionId] != null || grayImageMRDataList[bodyRegionId] != undefined) {
+ var grayImageDataMR = $rootScope.grayImageMRDataList[bodyRegionId];
+
+ grayCanvasContextMR.putImageData(grayImageDataMR, 0, 0);
+ }
+ }
+
+ }
+ }
+ }
+ }
+
+ $rootScope.previousHighlightList.push(RGBColor);
+
+ $scope.highLightBodyBasedOnIcolor(RGBColor);
+ }
+
+ if ($rootScope.isNormalMode == true) {
+
+
+ $rootScope.previousHighlightList.push(RGBColor);
+ }
+
+ var annotationText = $scope.GetAnnotationText(parseInt(RGBColor));
+
+ if ($('#speechBubbleTrns').length > 0)
+ $('#speechBubbleTrns').remove();
+
+ if ($rootScope.multiAnnotationIsON == true) {
+
+ // $scope.createDynamicSpeechBubble(evt, annotationText, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top);
+ $scope.MultiLanguageAnnationArray = [];
+ $scope.MultiLanguageAnnationArray.push(annotationText);
+ $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, true);
+ }
+ else {
+
+ if ($('#dot').length > 0) {
+ $('#dot').remove();
+ }
+
+ if ($('#sppeachBubble').length > 0) {
+ $('#sppeachBubble').remove();
+
+
+ // $scope.createDynamicSpeechBubble(evt, annotationText, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top);
+ $scope.MultiLanguageAnnationArray = [];
+ $scope.MultiLanguageAnnationArray.push(annotationText);
+ $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, true);
+ }
+ else {
+
+ // $scope.createDynamicSpeechBubble(evt, annotationText, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top);
+ $scope.MultiLanguageAnnationArray = [];
+ $scope.MultiLanguageAnnationArray.push(annotationText);
+ $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, true);
+ }
+
+
+ }
+ }, false);
+
+ FlipedImgCanvas.addEventListener('mousedown', function (evt) {
+
+ //alert('mousedown')
+ }, false);
+
+
+ FlipedImgCanvas.addEventListener('mouseup', function (evt) {
+ //alert('mouseup')
+
+
+ }, false);
+
+ var context = FlipedImgCanvas.getContext("2d");
+
+ var PI = Math.PI;
+ var PI2 = PI * 2;
+ var cw, ch, imgW, imgH, mouseX, mouseY;
+ var scaleFactor = 1.00;
+
+ //$scaler = $("#scaler");
+ //$scaler.val(scaleFactor);
+ //$scaler.hide();
+
+ var img = new Image();
+ img.onload = start;
+
+ // img.src = "~/../content/images/" + src;;
+ img.src = src;
+
+
+ function start() {
+ context.save();
+ context.translate(w, 0);
+ context.scale(-1, 1);
+ context.drawImage(img, 0, 0);
+ context.restore();
+
+
+ if (isMaskImage == 'N') {
+ $scope.ColoredImageSRC.push(
+ {
+ "bodyRegionId": bodyRegionId, "SRC": src,
+ "Height": h,
+ "Width": w,
+ "x": x,
+ "y": y,
+ "haveMirror": 'true'
+ }
+ );
+
+ // console.log('$rootScope.isListManagerSelected= ' + $rootScope.isListManagerSelected + ' length= ' + $scope.ColoredImageSRC.length)
+
+
+ if (($scope.ColoredImageSRC != null || $scope.ColoredImageSRC != undefined)) {
+
+ if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.ColoredImageSRC.length == 9)) {
+ $scope.isEligibleForHighlight = true;
+ }
+ else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.ColoredImageSRC.length == 5)) {
+ $scope.isEligibleForHighlight = true;
+ }
+ else if (($rootScope.viewOrientationId == '5') && ($scope.ColoredImageSRC.length == 4)) {
+ $scope.isEligibleForHighlight = true;
+ }
+ else if (($rootScope.viewOrientationId == '6') && ($scope.ColoredImageSRC.length == 1)) {
+ $scope.isEligibleForHighlight = true;
+ }
+ else {
+ $scope.isEligibleForHighlight = false;
+ }
+
+ if ($scope.isEligibleForHighlight == true) {
+ if ($rootScope.isHighLight == true || ($rootScope.isListManagerSelected == true) || (($rootScope.isGenderChnage == true) && ($rootScope.isHighLight == true)) || (($rootScope.isViewChange == true) && ($rootScope.isHighLight == true))) {
+
+ $rootScope.isLoading = false;
+ $('#spinner').css('visibility', 'hidden');
+
+
+ $rootScope.isLoading = true;
+ $('#spinner').css('visibility', 'visible');
+ //$timeout(function () {
+ console.log('inside start of flipped. $scope.ColoredImageSRC.length= ' + $scope.ColoredImageSRC.length)
+ $rootScope.isHighLight = true;
+ console.log('just before highLightBody call');
+ $scope.highLightBody();
+ console.log('just after highLightBody call');
+ //}, 500);
+ }
+ }
+ }
+
+ // console.log('ColoredImageSRC. pushed and length: ' + $scope.ColoredImageSRC.length);
+ }
+
+ if (FlipedImgCanvas.id.match('_mci')) {
+
+ var maskImgData = context.getImageData(0, 0, w, h);
+
+ $rootScope.MaskCanvasData.push(
+ {
+ "bodyRegionId": bodyRegionId,
+ "canvasId": FlipedImgCanvas.id,
+ "maskData": maskImgData,
+
+ }
+ );
+ }
+ };
+
+ if (document.getElementById('canvasDiv') != null)
+ document.getElementById('canvasDiv').appendChild(FlipedImgCanvas);
+
+
+
+ }
+
+ $scope.DrawImage = function (h, w, x, y, src, bodyRegionId, isMaskImage) {
+
+ var imgCanvas = document.createElement('canvas');
+
+ imgCanvas.height = h;
+ imgCanvas.width = w;
+ imgCanvas.setAttribute("data-IsMirrored", "N")
+ imgCanvas.style.position = "absolute";
+ imgCanvas.style.left = x + "px";
+ imgCanvas.style.top = y + "px";
+
+ if (isMaskImage == 'Y') {
+ imgCanvas.style.visibility = 'hidden'
+ imgCanvas.id = 'imageCanvas' + bodyRegionId + '_mci';
+
+ }
+ else {
+ imgCanvas.id = 'imageCanvas' + bodyRegionId;
+
+ if (bodyRegionId == 3) {
+ //set z index of hip canavs to fix the issue caused by overlapping of arm canavs on hip canavs.
+ imgCanvas.style.zIndex = "100";
+ }
+ if (bodyRegionId.match('modestyImg')) {
+ //added class to further access this canavs to show and hide leaf as per modesty seting
+ imgCanvas.className = 'modestyImg'
+ imgCanvas.style.visibility = 'hidden'
+ //set z index to make leaf canvas on top of hip canavs
+ imgCanvas.style.zIndex = "200";
+ }
+ if (($rootScope.voId == 11 || $rootScope.voId == 9) && bodyRegionId == 6) {
+ imgCanvas.style.zIndex = "500";
+ }
+
+ if ($rootScope.isExtract == true) {
+ imgCanvas.style.visibility = 'visible'
+ }
+ else {
+
+ if ($rootScope.isHighLight == true && $rootScope.isZoomed == false) {
+ imgCanvas.style.visibility = 'hidden';
+ }
+ }
+
+ }
+
+ imgCanvas.addEventListener('click', function (evt) {
+
+
+ if ($scope.isLayerChange == true) {
+ $scope.isLayerChange = false;
+ }
+
+ if (evt.ctrlKey) {
+ $rootScope.multiAnnotationIsON = true;
+ }
+ else {
+ if (($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined) && ($rootScope.previousHighlightList.length > 0)) {
+ $rootScope.previousHighlightList = [];
+ }
+ $rootScope.multiAnnotationIsON = false;
+ }
+
+ var annotationText;
+ var context = imgCanvas.getContext("2d");
+
+
+ var canvasId = context.canvas.getAttribute('id');
+ var maskCanvasId;
+ //for leaf canvas
+ if (canvasId.match('modestyImg')) {
+ maskCanvasId = canvasId;
+ }
+ else {
+ maskCanvasId = canvasId + '_mci';
+ }
+ var maskCanvas = document.getElementById(maskCanvasId);
+ var maskCanvasContext = maskCanvas.getContext("2d");
+
+ var mousePos = $scope.getMousePos(evt);
+ // alert(mousePos.x + ',' + mousePos.y);
+
+ var canvasDiv = document.getElementById('canvasDiv');
+ var verticalScrollPosition = canvasDiv.scrollTop;
+ var horizontlScrollPosition = canvasDiv.scrollLeft;
+
+
+ //We substracted 135, as the difference between flex and html coordinates for same organ is 135
+ var actulalX = mousePos.x + horizontlScrollPosition;
+ var actualY = mousePos.y + verticalScrollPosition;
+ var RGBColor = $scope.GetRGBColor(maskCanvasContext, actulalX, actualY, x, y);
+
+
+ //Modesty ON
+ if (maskCanvasId.match('modestyImg') && RGBColor != '000000') {
+ RGBColor = DA[0].figLeafTermId;
+ annotationText = $scope.GetAnnotationBasedOnActualTermNo(RGBColor);
+ }
+ //Modesty On but clicked somewhre else, we did modesty check because the modesty image covers whole body region so if user will click to
+ //see the annotation apart from leaf then the actual click will be on modesty canvas, but for annotation er
+ //
+ else if (maskCanvasId.match('modestyImg') && RGBColor == '000000') {
+ //if ($rootScope.voId == 11) {
+ // maskCanvasId = 'imageCanvas6_mci';
+ // x = $('#imageCanvas6_mci').left;
+ // y = $('#imageCanvas6_mci').top;
+ //}
+ //else {
+ bodyRegionId = maskCanvasId.slice(-1);
+ maskCanvasId = 'imageCanvas' + bodyRegionId + '_mci';
+ // }
+ var maskCanvas = document.getElementById(maskCanvasId);
+ var maskCanvasContext = maskCanvas.getContext("2d");
+ RGBColor = $scope.GetRGBColor(maskCanvasContext, actulalX, actualY, x, y);
+ annotationText = $scope.GetAnnotationText(parseInt(RGBColor));
+ }
+ else {
+ RGBColor = $scope.GetRGBColor(maskCanvasContext, actulalX, actualY, x, y);
+ annotationText = $scope.GetAnnotationText(parseInt(RGBColor));
+
+ }
+
+
+ if ($rootScope.isHighLight == true) {
+ if ($scope.machedIcolorInBodyRegion != null || $scope.machedIcolorInBodyRegion != undefined) {
+ if ($scope.machedIcolorInBodyRegion.length > 0) {
+ if ($rootScope.multiAnnotationIsON == false) {
+ for (var i = 0; i < $scope.machedIcolorInBodyRegion.length; i++) {
+ var bodyRegionId = $scope.machedIcolorInBodyRegion[i];
+
+ var grayCanvasID = 'imageCanvas' + bodyRegionId;
+ var grayCanvas = document.getElementById(grayCanvasID);
+
+ var grayCanvasContext = grayCanvas.getContext("2d");
+ if ($rootScope.grayImageDataList[bodyRegionId - 1] != null || $rootScope.grayImageDataList[bodyRegionId - 1] != undefined) {
+ var grayImageData = $rootScope.grayImageDataList[bodyRegionId - 1];
+ grayCanvasContext.putImageData(grayImageData, 0, 0);
+ }
+
+ // for unhighlight the mirrored body region
+ if (bodyRegionId == 4 || bodyRegionId == 5 || bodyRegionId == 6) {
+ var grayCanvasID = 'imageCanvas' + bodyRegionId + '_MR';
+ var grayCanvasMR = document.getElementById(grayCanvasID);
+
+ var grayCanvasContextMR = grayCanvasMR.getContext("2d");
+
+ if ($rootScope.grayImageMRDataList[bodyRegionId] != null || $rootScope.grayImageMRDataList[bodyRegionId] != undefined) {
+
+ var grayImageDataMR = $rootScope.grayImageMRDataList[bodyRegionId];
+
+ grayCanvasContextMR.putImageData(grayImageDataMR, 0, 0);
+
+ }
+ }
+
+ }
+ }
+ }
+ }
+
+ $rootScope.previousHighlightList.push(RGBColor);
+
+
+ if (maskCanvasId.match('modestyImg') && RGBColor != '000000') { }
+ else
+ {
+ $scope.highLightBodyBasedOnIcolor(RGBColor);
+ }
+
+ }
+
+ if ($rootScope.isNormalMode == true) {
+ $rootScope.previousHighlightList.push(RGBColor);
+ }
+
+ if ($('#speechBubbleTrns').length > 0)
+ $('#speechBubbleTrns').remove();
+
+ if ($rootScope.multiAnnotationIsON == true) {
+
+ // $scope.createDynamicSpeechBubble(evt, annotationText, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top);
+ $scope.MultiLanguageAnnationArray = [];
+ $scope.MultiLanguageAnnationArray.push(annotationText);
+ $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, true);
+ }
+ else {
+
+ $scope.MultiLanguageAnnationArray = [];
+
+ console.log('1. annotationText: ' + annotationText);
+
+ if ($('#dot').length > 0) {
+ $('#dot').remove();
+
+ if ($('#sppeachBubble').length > 0) {
+ $('#sppeachBubble').remove();
+ }
+
+
+
+ // $scope.createDynamicSpeechBubble(evt, annotationText, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top);
+
+
+ $scope.MultiLanguageAnnationArray.push(annotationText);
+
+ console.log('2. annotationText: ' + annotationText + ' , length: ' + $scope.MultiLanguageAnnationArray.length);
+
+ $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, true);
+
+ }
+ else {
+
+
+
+ $scope.MultiLanguageAnnationArray = [];
+ $scope.MultiLanguageAnnationArray.push(annotationText);
+
+ console.log('3. annotationText: ' + annotationText + ' , length: ' + $scope.MultiLanguageAnnationArray.length);
+ $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, true);
+ }
+
+
+ }
+ }, false);
+
+ var PI = Math.PI;
+ var PI2 = PI * 2;
+ var cw, ch, imgW, imgH, mouseX, mouseY;
+ var scaleFactor = 1.00;
+
+ var context = imgCanvas.getContext('2d');
+ var img = new Image();
+ img.onload = start;
+
+ img.src = src;
+
+ function start() {
+ //debugger;
+ context.drawImage(img, 0, 0);
+
+ if (isMaskImage == 'N') {
+ if (bodyRegionId == 'modestyImg3' || bodyRegionId == 'modestyImg2') {
+ //do nothing
+ }
+ else {
+ $scope.ColoredImageSRC.push(
+ {
+ "bodyRegionId": bodyRegionId, "SRC": src,
+ "Height": h,
+ "Width": w,
+ "x": x,
+ "y": y,
+ "haveMirror": 'false'
+ }
+
+ );
+
+ if (($scope.ColoredImageSRC != null || $scope.ColoredImageSRC != undefined)) {
+
+ if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.ColoredImageSRC.length == 9)) {
+ $scope.isEligibleForHighlight = true;
+ }
+ else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.ColoredImageSRC.length == 5)) {
+ $scope.isEligibleForHighlight = true;
+ }
+ else if (($rootScope.viewOrientationId == '5') && ($scope.ColoredImageSRC.length == 4)) {
+ $scope.isEligibleForHighlight = true;
+ }
+ else if (($rootScope.viewOrientationId == '6') && ($scope.ColoredImageSRC.length == 1)) {
+ $scope.isEligibleForHighlight = true;
+ }
+ else {
+ $scope.isEligibleForHighlight = false;
+ }
+
+ if ($scope.isEligibleForHighlight == true) {
+ if ($rootScope.isHighLight == true || ($rootScope.isListManagerSelected == true) || (($rootScope.isGenderChnage == true) && ($rootScope.isHighLight == true)) || (($rootScope.isViewChange == true) && ($rootScope.isHighLight == true))) {
+
+ $rootScope.isLoading = false;
+ $('#spinner').css('visibility', 'hidden');
+
+
+ $rootScope.isLoading = true;
+ $('#spinner').css('visibility', 'visible');
+ //$timeout(function () {
+ console.log('inside start of non flipped. $scope.ColoredImageSRC.length= ' + $scope.ColoredImageSRC.length)
+ $rootScope.isHighLight = true;
+ console.log('just before highLightBody call');
+ $scope.highLightBody();
+ console.log('just after highLightBody call');
+ //}, 500);
+ }
+ }
+ }
+
+ console.log('ColoredImageSRC. pushed and length: ' + $scope.ColoredImageSRC.length);
+ }
+ }
+
+ if (imgCanvas.id.match('_mci')) {
+ var maskImgData = context.getImageData(0, 0, w, h);
+ $rootScope.MaskCanvasData.push(
+ {
+ "bodyRegionId": bodyRegionId,
+ "canvasId": imgCanvas.id,
+ "maskData": maskImgData,
+
+ }
+ );
+ }
+
+ };
+
+ if (document.getElementById('canvasDiv') != null)
+ document.getElementById('canvasDiv').appendChild(imgCanvas);
+ }
+
+
+
+ $scope.highLightBodyBasedOnIcolor = function (RGBColor) {
+
+
+ //2. Find Actul Term No Based on Icolor.
+ var ActualTermNo = $scope.getActualTermNumber(RGBColor);
+
+ if (ActualTermNo != null) {
+
+ //3. Find Term No List Based on ActualTermNo
+ var TermList = $scope.getTermNumberList(ActualTermNo);
+ if (TermList != null) {
+
+ //4.
+ $scope.HighlightBodyByTermList(TermList);
+ }
+ }
+
+
+ }
+
+
+ $scope.HighlightBodyOnExtract = function () {
+
+
+ var multiTermList = [];
+ var CallBackBodyRegion = [];
+
+ if ($rootScope.isListManagerSelected) {
+
+ multiTermList = $scope.AllTerms;
+
+ }
+ else if (($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined) && ($rootScope.previousHighlightList.length > 0)) {
+ angular.forEach($rootScope.previousHighlightList, function (value, key) {
+
+ var ActualTermNo = $scope.getActualTermNumber(value);
+ if (ActualTermNo != null) {
+ var TermList = $scope.getTermNumberList(ActualTermNo);
+ if (TermList != null) {
+ for (var i = 0; i < TermList.length; i++) {
+ multiTermList.push(TermList[i]);
+ }
+ }
+ }
+
+ // to do
+ });
+ }
+
+ //2. Find Actul Term No Based on Icolor.
+ //var ActualTermNo = $scope.getActualTermNumber(RGBColor);
+
+ ////3. Find Term No List Based on ActualTermNo
+ //var TermList = $scope.getTermNumberList(ActualTermNo);
+
+
+ //terminate previous running workers to create space for new workers
+
+ $scope.terminateCurrentlyRunningWPs();
+
+ $timeout(function () {
+
+ var loopLength = 0;
+ if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.ColoredImageSRC.length == 9)) {
+ loopLength = 9;
+ }
+ else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.ColoredImageSRC.length == 5)) {
+ loopLength = 5;
+ }
+ else if (($rootScope.viewOrientationId == '5') && ($scope.ColoredImageSRC.length == 4)) {
+ loopLength = 4;
+ }
+ else if (($rootScope.viewOrientationId == '6') && ($scope.ColoredImageSRC.length == 1)) {
+ loopLength = 1;
+ }
+
+ if (loopLength !== 0) {
+ for (var x = 0; x < loopLength; x++) {
+ if ($rootScope.MaskCanvasData[x] != null || $rootScope.MaskCanvasData[x] != undefined) {
+ var bodyRegionId = $rootScope.MaskCanvasData[x].bodyRegionId;
+ var canvasId = $rootScope.MaskCanvasData[x].canvasId;
+ var maskData = null;
+ maskData = $rootScope.MaskCanvasData[x].maskData;
+
+ var coloredImageDataVar = null;
+ var grayImageDataVar = null;
+
+ var white = null;
+ if (canvasId.match('_MR')) {
+ if ($rootScope.coloredImageMRCanvasList[bodyRegionId] != null || $rootScope.coloredImageMRCanvasList[bodyRegionId] != undefined) {
+
+ coloredImageDataVar = $rootScope.coloredImageMRCanvasList[bodyRegionId];
+
+ }
+
+ if ($rootScope.whiteImageMRDataList[bodyRegionId] != null || $rootScope.whiteImageMRDataList[bodyRegionId] != undefined) {
+ white = $rootScope.whiteImageMRDataList[bodyRegionId];
+ }
+
+ }
+
+ else {
+
+ if ($rootScope.coloredImageCanvasList[bodyRegionId - 1] != null || $rootScope.coloredImageCanvasList[bodyRegionId - 1] != undefined) {
+ coloredImageDataVar = $rootScope.coloredImageCanvasList[bodyRegionId - 1];
+ }
+ if ($rootScope.whiteImageDataList[bodyRegionId - 1] != null || $rootScope.whiteImageDataList[bodyRegionId - 1] != undefined) {
+ white = $rootScope.whiteImageDataList[bodyRegionId - 1];
+
+ }
+ }
+
+
+ var worker = new Worker('extract-wp.js');
+
+ //push workers in array to further used the refernece to delete the workers
+ $scope.runningWorkers.push({ 'workerName': worker })
+
+ console.log('for BRID = ' + bodyRegionId + ', coloredImageDataVar: ' + coloredImageDataVar + ', maskData= ' + maskData + ', white= ' + white)
+
+ if (coloredImageDataVar != null && maskData != null && white != null) {
+ worker.postMessage({
+
+ 'termList': multiTermList,
+ 'maskCanvasData': maskData,
+ 'coloredImageData': coloredImageDataVar,
+ 'grayImageData': white,
+ 'bodyRegionId': bodyRegionId,
+ 'canvasId': canvasId
+
+ });
+ }
+
+ //}
+
+ worker.onmessage = function (e) {
+ console.log('callback in extract for e.data.bodyRegionId: ' + e.data.bodyRegionId + ', time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"));
+
+
+ var updatedData = e.data.value;
+
+ var bodyRegionId = e.data.bodyRegionId;
+
+
+ var canvasId = (e.data.canvasId).replace('_mci', '');
+ //debugger;
+ //for (var i = 1; i <= updatedData.length; i++) {
+ var grayCanvasID = canvasId;
+
+ // var grayCanvasID = 'imageCanvas' + bodyRegionId;
+ var grayCanvas = document.getElementById(grayCanvasID);
+ var grayCanvasContext = grayCanvas.getContext("2d");
+
+
+
+ grayCanvasContext.putImageData(updatedData, 0, 0);
+
+
+ //to resolve lateral arm black issue in highlight mode
+
+ if ($rootScope.viewOrientationId == 5 && (bodyRegionId == 6 || bodyRegionId == 4)) {
+
+ var canavsWidth = parseInt(grayCanvas.width);
+ var canavsHeight = parseInt(grayCanvas.height);
+
+ console.log('canavsWidth= ' + canavsWidth + ', canavsHeight= ' + canavsHeight)
+
+ var imgData = grayCanvasContext.getImageData(0, 0, canavsWidth, canavsHeight);
+ var data = imgData.data;
+ var c = 0;
+ for (var i = 0; i < data.length; i += 4) {
+ if (data[i] == data[i + 1] && data[i + 1] == data[i + 2] && data[i + 2] === 0) {
+ data[i + 3] = 0;
+ }
+
+ }
+ grayCanvasContext.putImageData(imgData, 0, 0);
+ }
+
+
+ if ($rootScope.multiAnnotationIsON == true) {
+ //debugger;
+ if (canvasId.match('_MR'))
+ $rootScope.updatedWhiteImageMRDataList[bodyRegionId] = updatedData;
+ else
+ $rootScope.updatedWhiteImageDataList[bodyRegionId - 1] = updatedData;
+
+
+ }
+ else {
+
+ if (canvasId.match('_MR'))
+ $rootScope.whiteImageMRDataList[bodyRegionId] = e.data.value;
+ else {
+ if ($rootScope.whiteImageDataList[bodyRegionId - 1] != null || $rootScope.whiteImageDataList[bodyRegionId - 1] != undefined)
+ $rootScope.whiteImageDataList[bodyRegionId - 1] = e.data.value;
+ }
+ }
+
+ //if ((CallBackBodyRegion != null || CallBackBodyRegion[i] != undefined) && (CallBackBodyRegion.length > 0)) {
+ // if (CallBackBodyRegion.length == 6) {
+ // $rootScope.isLoading = false;
+ // $('#spinner').css('visibility', 'hidden');
+ // }
+ //}
+
+
+ $timeout(function () { $scope.DisableProgressBar() }, 1000);
+
+ };
+ worker.onerror = function (e) {
+ alert('Error: Line ' + e.lineno + ' in ' + e.filename + ': ' + e.message);
+ };
+ }
+ }
+ }
+ }, 500)
+
+ }
+
+ $scope.HighlightBodyByTermList = function (TermList) {
+
+ //if (($rootScope.updatedGrayMRDataList != null || $rootScope.updatedGrayMRDataList != undefined) && $rootScope.updatedGrayMRDataList.length > 0) {
+ // $rootScope.updatedGrayMRDataList = null;
+ // $rootScope.updatedGrayMRDataList = [];
+ //}
+ //if (($rootScope.updatedGrayDataList != null || $rootScope.updatedGrayDataList != undefined) && $rootScope.updatedGrayDataList.length > 0) {
+ // $rootScope.updatedGrayDataList = null;
+ // $rootScope.updatedGrayDataList = [];
+ //}
+
+ if ($rootScope.isHighLight == true) {
+ false;
+ }
+
+ console.log('HighlightBodyByTermList is called');
+
+ // $scope.highlightedBR = null;
+ $scope.highlightedBR = [];
+
+ $scope.terminateCurrentlyRunningWPs();
+
+
+
+ $timeout(function () {
+ var loopLength = 0;
+ if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.ColoredImageSRC.length == 9)) {
+ loopLength = 9;
+ }
+ else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.ColoredImageSRC.length == 5)) {
+ loopLength = 5;
+ }
+ else if (($rootScope.viewOrientationId == '5') && ($scope.ColoredImageSRC.length == 4)) {
+ loopLength = 4;
+ }
+ else if (($rootScope.viewOrientationId == '6') && ($scope.ColoredImageSRC.length == 1)) {
+ loopLength = 1;
+ }
+
+ for (var x = 0; x < loopLength; x++) {
+ if ($rootScope.MaskCanvasData[x] != null || $rootScope.MaskCanvasData[x] != undefined) {
+
+ var bodyRegionId = $rootScope.MaskCanvasData[x].bodyRegionId;
+ var canvasId = $rootScope.MaskCanvasData[x].canvasId;
+ var maskData = null;
+ maskData = $rootScope.MaskCanvasData[x].maskData;
+
+ var coloredImageDataVar = null;
+ var grayImageDataVar = null;
+
+ var white;
+ if (canvasId.match('_MR')) {
+ if ($rootScope.coloredImageMRCanvasList[bodyRegionId] != null || $rootScope.coloredImageMRCanvasList[bodyRegionId] != undefined) {
+ coloredImageDataVar = $rootScope.coloredImageMRCanvasList[bodyRegionId];
+ }
+
+
+ if ($rootScope.multiAnnotationIsON == true) {
+ //on layer change we need the fresh data not the updated one
+ if ($scope.isLayerChange == true) {
+ if ($rootScope.grayImageMRDataList[bodyRegionId] != null || $rootScope.grayImageMRDataList[bodyRegionId] != undefined) {
+ grayImageDataVar = $rootScope.grayImageMRDataList[bodyRegionId];
+ }
+ }
+ else {
+ if ($rootScope.updatedGrayDataList[bodyRegionId - 1] == null || $rootScope.updatedGrayDataList[bodyRegionId - 1] == undefined) {
+
+ if ($rootScope.grayImageMRDataList[bodyRegionId] != null || $rootScope.grayImageMRDataList[bodyRegionId] != undefined) {
+ grayImageDataVar = $rootScope.grayImageMRDataList[bodyRegionId];
+ }
+ }
+ else {
+ if ($rootScope.updatedGrayMRDataList[bodyRegionId] != null || $rootScope.updatedGrayMRDataList[bodyRegionId] != undefined) {
+ grayImageDataVar = $rootScope.updatedGrayMRDataList[bodyRegionId]
+ }
+ }
+ }
+ }
+ else {
+ if ($rootScope.grayImageMRDataList[bodyRegionId] != null || $rootScope.grayImageMRDataList[bodyRegionId] != undefined) {
+ grayImageDataVar = $rootScope.grayImageMRDataList[bodyRegionId];
+ }
+ }
+
+
+ }
+
+ else {
+
+ if ($rootScope.coloredImageCanvasList[bodyRegionId - 1] != null || $rootScope.coloredImageCanvasList[bodyRegionId - 1] != undefined) {
+ coloredImageDataVar = $rootScope.coloredImageCanvasList[bodyRegionId - 1];
+ }
+
+
+
+ if ($rootScope.multiAnnotationIsON == true) {
+
+ //on layer change we need the fresh data not the updated one
+ if ($scope.isLayerChange == true) {
+ if ($rootScope.grayImageDataList[bodyRegionId - 1] != null || $rootScope.grayImageDataList[bodyRegionId - 1] != undefined) {
+ grayImageDataVar = $rootScope.grayImageDataList[bodyRegionId - 1];
+
+ }
+
+ } else {
+ // this code is for the case where user first click on normal mode then extract then again highlight then we need to call highlight body in gray mode
+ //and then highlight the previously selected body regions at the time of normal mode.
+ if ($rootScope.updatedGrayDataList[bodyRegionId - 1] == null || $rootScope.updatedGrayDataList[bodyRegionId - 1] == undefined) {
+
+ if ($rootScope.grayImageDataList[bodyRegionId - 1] != null || $rootScope.grayImageDataList[bodyRegionId - 1] != undefined) {
+ grayImageDataVar = $rootScope.grayImageDataList[bodyRegionId - 1];
+ }
+
+ }
+ else {
+ if ($rootScope.updatedGrayDataList[bodyRegionId - 1] != null || $rootScope.updatedGrayDataList[bodyRegionId - 1] != undefined) {
+ // for normal case means without interdepency button case.
+ grayImageDataVar = $rootScope.updatedGrayDataList[bodyRegionId - 1];
+ }
+ }
+ }
+ }
+ else
+ if ($rootScope.grayImageDataList[bodyRegionId - 1] != null || $rootScope.grayImageDataList[bodyRegionId - 1] != undefined) {
+ grayImageDataVar = $rootScope.grayImageDataList[bodyRegionId - 1];
+ }
+
+
+ }
+
+ var worker = new Worker('term-number-wp.js');
+
+ //push workers in array to further used the refernece to delete the workers
+ $scope.runningWorkers.push({ 'workerName': worker })
+
+ // console.log('for bodyRegionId = ' + bodyRegionId+ ', time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"))
+ console.log('before worker call BRID: ' + bodyRegionId)
+
+ if (grayImageDataVar != null && coloredImageDataVar != null && maskData != null) {
+ worker.postMessage({
+
+ 'termList': TermList,
+ 'maskCanvasData': maskData,
+ 'coloredImageData': coloredImageDataVar,
+ 'grayImageData': grayImageDataVar,
+ 'bodyRegionId': bodyRegionId,
+ 'canvasId': canvasId
+
+ });
+ }
+
+
+
+ worker.onmessage = function (e) {
+ console.log('callback for e.data.bodyRegionId: ' + e.data.bodyRegionId + ', time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"));
+
+ var updatedData = e.data.value;
+
+ var bodyRegionId = e.data.bodyRegionId;
+ var canvasId = (e.data.canvasId).replace('_mci', '');
+ //debugger;
+ //for (var i = 1; i <= updatedData.length; i++) {
+ var grayCanvasID = canvasId;
+
+ //to do
+ var grayCanvas = document.getElementById(grayCanvasID);
+ if (grayCanvas != null) {
+ var grayCanvasContext = grayCanvas.getContext("2d");
+
+ //Niki remove previous data from canvas
+ var canvasHeight = grayCanvas.height + 'px';
+ var canvasWidth = grayCanvas.width + 'px';
+ //alert('height= ' + canvasHeight + ', width= ' + canvasWidth)
+ grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth)
+
+ grayCanvasContext.putImageData(updatedData, 0, 0);
+ $scope.highlightedBR.push({ 'bodyRegionId': bodyRegionId });
+
+ }
+
+ //debugger;
+
+ if (canvasId.match('_MR')) {
+ $rootScope.updatedGrayMRDataList[bodyRegionId] = updatedData;
+
+ //alert('HighlightBodyByTermList, is mutiAnnotation on= ' + $rootScope.multiAnnotationIsON);
+
+ //$rootScope.updatedWhiteImageMRDataList[bodyRegionId] = updatedData;
+ }
+ else
+ $rootScope.updatedGrayDataList[bodyRegionId - 1] = updatedData;
+
+ //$scope.highlightedBR.push({ 'bodyRegionId': bodyRegionId });
+
+ console.log('$scope.highlightedBR.length= ' + $scope.highlightedBR.length)
+
+ if ($scope.highlightedBR != null || $scope.highlightedBR != undefined) {
+
+ if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.highlightedBR.length == 9)) {
+ $scope.doAligneCanvasWithTerm = true;
+ }
+ else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.highlightedBR.length == 5)) {
+ $scope.doAligneCanvasWithTerm = true;
+ }
+ else if ((($rootScope.viewOrientationId == '5')) && ($scope.highlightedBR.length == 4)) {
+ $scope.doAligneCanvasWithTerm = true;
+ }
+ else if ((($rootScope.viewOrientationId == '6')) && ($scope.highlightedBR.length == 1)) {
+ $scope.doAligneCanvasWithTerm = true;
+ }
+
+ if ($scope.doAligneCanvasWithTerm == true) {
+ //debugger;
+ if ($scope.isHighlightBodyByBodySystem == true || $rootScope.isListManagerSelected == true)
+
+ $rootScope.isLoading = false;
+
+ $('#spinner').css('visibility', 'hidden');
+
+ $scope.isHighlightBodyByBodySystem = false;
+
+ if ($rootScope.isListManagerSelected == true)
+ $scope.aligneCanvasWithTerm();
+ }
+ }
+ //
+
+ };
+ worker.onerror = function (e) {
+ alert('Error: Line ' + e.lineno + ' in ' + e.filename + ': ' + e.message);
+ };
+ }
+ }
+ }, 100)
+ }
+
+
+
+ $scope.createTermListByPreviousTermsAndHighlight = function () {
+
+
+ var multiTermList = [];
+ angular.forEach($rootScope.previousHighlightList, function (value, key) {
+
+ //debugger;
+
+ var ActualTermNo = $scope.getActualTermNumber(value);
+ if (ActualTermNo != null) {
+ var TermList = $scope.getTermNumberList(ActualTermNo);
+ if (TermList != null) {
+ for (var i = 0; i < TermList.length; i++) {
+
+ multiTermList.push(TermList[i]);
+ }
+ }
+ }
+
+ });
+
+ console.log('createTermListByPreviousTermsAndHighlight is called');
+
+ if ((multiTermList != undefined || multiTermList != null) && multiTermList.length > 0) {
+
+ $timeout(function () { $scope.HighlightBodyByTermList(multiTermList); }, 50);
+ }
+ }
+
+
+ $scope.GetRGBColor = function (maskCanvasContext, actulalX, actualY, x, y) {
+ var pixelData = maskCanvasContext.getImageData(Math.round(actulalX - x), Math.round(actualY - y), 1, 1);
+
+ pixelData.data[0] = pixelData.data[0] - 9;
+ pixelData.data[1] = pixelData.data[1] - 9;
+ pixelData.data[2] = pixelData.data[2] - 9;
+ var Red;
+ var Green;
+ var Blue;
+ var zero = "0";
+
+ if ((pixelData.data[0]).toString().length != 2) {
+ Red = zero.concat((pixelData.data[0]).toString())
+ }
+ else {
+ Red = (pixelData.data[0]).toString()
+ }
+ if ((pixelData.data[1]).toString().length != 2) {
+ Green = zero.concat((pixelData.data[1]).toString())
+ }
+ else {
+ Green = (pixelData.data[1]).toString()
+
+ }
+ if ((pixelData.data[2]).toString().length != 2) {
+ Blue = zero.concat((pixelData.data[2]).toString())
+ }
+ else {
+ Blue = (pixelData.data[2]).toString()
+
+ }
+ var RGBColor = (Red + Green + Blue);
+ return RGBColor;
+ }
+
+
+ //get annotation from term number
+ $scope.GetAnnotationText = function (termNumber) {
+ //debugger;
+
+ var annotationText;
+ //0
+ var figLeafTermNo = 5868; // to do declare constant for this
+
+ if (parseInt(termNumber) != parseInt(figLeafTermNo)) {
+ $scope.TermNumber = termNumber;
+ if ($rootScope.TermNumberData != null || $rootScope.TermNumberData != undefined) {
+ $scope.matchedTermNoData = new jinqJs()
+ .from($rootScope.TermNumberData.TermData.Term)
+ .where('_TermNumber == ' + termNumber)
+ .select();
+
+ if ($scope.matchedTermNoData != null || $scope.matchedTermNoData != undefined) {
+ //1.
+ var actualTermNo = 0;
+ for (var z = 0; z < $scope.matchedTermNoData.length; z++) {
+ //send actual term no to get the term text.
+ actualTermNo = $scope.matchedTermNoData[0]._ActualTermNumber;
+ annotationText = $scope.GetAnnotationBasedOnActualTermNo(actualTermNo);
+ break;
+ };
+
+ //2.
+
+ }
+ else {
+ // send term no to vocab json data to get the text
+ }
+ }
+ }
+ return annotationText;
+ }
+
+ $scope.GetAnnotationBasedOnActualTermNo = function (actualTermNo) {
+ // debugger;
+
+ var Annotation;
+ $scope.ActualTermNo = actualTermNo;
+ if ($rootScope.VocabTermData != null || $rootScope.VocabTermData != undefined) {
+ $scope.matchedActualTermData = new jinqJs()
+ .from($rootScope.VocabTermData.VocabTerms.Term)
+ .where('_ActualTermNumber == ' + actualTermNo)
+ .select();
+
+ if ($scope.matchedActualTermData != null || $scope.matchedActualTermData != undefined) {
+ for (var z = 0; z <= $scope.matchedActualTermData.length; z++) {
+ //send actual term no to get the term text.
+ Annotation = $scope.matchedActualTermData[0]._TermText;
+ // alert("Annotation : " + Annotation);
+ break;
+ };
+ }
+ return Annotation;
+ }
+ else {
+ return null;
+ }
+ }
+
+
+ //layer change function
+ $scope.LayerChange = function () {
+
+
+ //if listanager is visisble then close it
+ $rootScope.isListManagerSelected = false;
+
+ $rootScope.CloseListManager();
+
+
+
+ $scope.isLayerChange = true;
+ $rootScope.isLoading = true;
+ $('#spinner').css('visibility', 'visible');
+
+ //1.
+ $scope.terminateCurrentlyRunningWPs();
+
+ var canvasDiv = document.getElementById('canvasDiv');
+ $scope.imageVerticalScrollPosition = canvasDiv.scrollTop;
+ $scope.imageHorizontlScrollPosition = canvasDiv.scrollLeft;
+
+ // debugger;
+ // $('#daLoaderLabel').css('visibility', 'visible');
+
+
+
+ if ($scope.isTransparencyActivated) {
+
+ //crete temp canavs to store the original data which will be used to chnange the transparency
+ if (document.getElementById('tempCanvas') != null) {
+ $('#tempCanvas').remove();
+ }
+
+ if ($('#speechBubbleTrns').length > 0) {
+ $('#speechBubbleTrns').remove();
+ }
+ var tempCanvas = document.createElement('canvas');
+ tempCanvas.id = 'tempCanvas';
+ $scope.tempCanvas = tempCanvas.id;
+ tempCanvas.height = $scope.transparencyCanvasHeight;
+ tempCanvas.width = $scope.transparencyCanvasWidth;
+ tempCanvas.style.position = "absolute";
+ tempCanvas.style.left = 200 + 'px';
+ tempCanvas.style.backgroundColor = "transparent";
+ tempCanvas.style.visibility = 'hidden';
+
+ if (document.getElementById('canvasDiv') != null)
+ document.getElementById('canvasDiv').appendChild(tempCanvas);
+
+ // //debugger;
+
+ var tCanvas = document.getElementById('transparencyCanvas');
+ var tCanvasContext = tCanvas.getContext('2d');
+
+ var tCanvasHeight = parseInt((tCanvas.style.height).replace('px', ''));
+
+ var tCanvasWidth = parseInt((tCanvas.style.width).replace('px', ''));
+
+
+ // var tCanvas = document.getElementById('transparencyCanvas');
+ if (tCanvas != null) {
+ clearTransCanvas();
+ }
+ var TransparencyBoxStartX = parseInt((tCanvas.style.left).replace('px', ''));
+ var TransparencyEndX = parseInt((tCanvas.style.left).replace('px', '')) + parseInt((tCanvas.style.width.replace('px', '')));
+ var TransparencyBoxStartY = parseInt((tCanvas.style.top).replace('px', ''));
+ var TransparencyBoxEndY = parseInt((tCanvas.style.top).replace('px', '')) + parseInt((tCanvas.style.height).replace('px', ''));
+ var transparencyBoxBottom = parseInt(TransparencyBoxStartY) + parseInt(tCanvasHeight);
+ var transparencyBoxRight = parseInt(TransparencyBoxStartX) + parseInt(tCanvasWidth);
+
+ var BodyRegionDictionary = $rootScope.BodyRegionCordinatesData;
+
+ $.each(BodyRegionDictionary, function (index, value) {
+ //debugger;
+ // alert(' $.each(BodyRegionDictionary1')
+
+ var bodyRegionRight = parseInt(value.X) + parseInt(value.Width);
+ var bodyRegionBottom = parseInt(value.Y) + parseInt(value.Height);
+
+
+ // alert(' $.each(BodyRegionDictionary3. bodyRegionRight: ' + bodyRegionRight + ', bodyRegionBottom: ' + bodyRegionBottom)
+ if (TransparencyBoxStartX <= bodyRegionRight && value.X <= transparencyBoxRight && TransparencyBoxStartY <= bodyRegionBottom && value.Y <= transparencyBoxBottom) {
+ //var transNumber = parseInt(document.getElementById("txtTransparencyChange").value);
+ // debugger;
+ $scope.layerNumber = parseInt(txtlayerNumber.value);
+
+
+ $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.X, value.Y, value.IsMirror, TransparencyBoxStartX, transparencyBoxRight, TransparencyBoxStartY, transparencyBoxBottom, $scope, true, false);
+ }
+
+
+ })
+ }
+
+ else {
+ //1. Dated:13-07-2016 Issue #4965 : The layer number should not extend beyond its level through layer text box.
+ var dataLength = $rootScope.BodyLayerData.Layers.DataLayer.length;
+ if (parseInt($('#txtlayerNumber').val()) > (dataLength - 1)) {
+ $('#txtlayerNumber').val(dataLength - 1);
+ $scope.currentLayerNumber = parseInt(dataLength - 1);
+ $scope.layerNumber = parseInt(dataLength - 1);
+ }
+ else
+ $scope.currentLayerNumber = parseInt($('#txtlayerNumber').val());
+
+ $rootScope.isLoading = true;
+ $('#spinner').css('visibility', 'visible');
+ var canDiv = document.getElementById('canvasDiv');
+ var canDivChildCount = canDiv.childElementCount;
+ if (canDivChildCount > 0) {
+ canDiv.innerHTML = '';
+ }
+
+ //2.
+ $scope.CalculateImageCordinates($rootScope.viewOrientationId);
+
+ //3.
+ $('#canvasDiv').scrollLeft($scope.imageHorizontlScrollPosition)
+ $('#canvasDiv').scrollTop($scope.imageVerticalScrollPosition)
+
+ if ($scope.isHighlightBodyByBodySystem) {
+ $timeout(function () { $scope.DisableProgressBar() }, 20000);
+ }
+ else
+ {
+ $timeout(function () { $scope.DisableProgressBar() }, 2000);
+ }
+ }
+
+ $('#layerChangeSlider').slider("option", "value", parseInt($scope.totalLayers) - parseInt($scope.layerNumber));
+ }
+
+ $scope.DisableProgressBar = function () {
+
+ // alert('Disabled wait cursor is called');
+
+
+ if ($rootScope.isHighLight) {
+ //alert('isHighlight: ' + $scope.isHighLight);
+
+ //$('#btnHighLight').removeClass('btn btn-black');
+ //$('#btnHighLight').addClass('btn-primary');
+
+ $("#btnHighLight").addClass("btn-primary");
+ $("#btnHighLight").removeClass("btn-black");
+
+ if (!$("#btnNormalMode").hasClass("btn-black")) {
+ $("#btnNormalMode").addClass("btn-black");
+ }
+
+ if (!$("#btnExtract").hasClass("btn-black")) {
+ $("#btnExtract").addClass("btn-black");
+ }
+
+ if ($("#btnExtract").hasClass("btn-primary")) {
+ $("#btnExtract").removeClass("btn-primary");
+ }
+
+
+ if ($("#btnNormalMode").hasClass("btn-primary")) {
+ $("#btnNormalMode").removeClass("btn-primary");
+ }
+
+ console.log('highLightBody call from DisableProgressBar')
+ // $scope.highLightBody();
+
+
+
+ }
+
+ $rootScope.isLoading = false;
+ $('#spinner').css('visibility', 'hidden');
+
+ //alert('Disabled wait cursor is done.See val :' + $rootScope.isLoading);
+ }
+
+
+ $scope.changeLayer = function () {
+ //console.log('changeLayer');
+ // alert('slide')
+ }
+
+ $('layerChangeSlider').slider().on('slideStop', function (ev) {
+
+ var newVal = $('.span2').data('slider').getValue();
+ if (originalVal != newVal) {
+
+ }
+ });
+
+
+ $scope.getMousePos = function (evt) {
+
+ return {
+ x: Math.round(evt.pageX - $('#canvasDiv').offset().left),
+ y: Math.round(evt.pageY - $('#canvasDiv').offset().top)
+ }
+ }
+
+
+
+ $scope.createDynamicSpeechBubble = function (event, x, y, isAnnotationForTBox) {
+
+ if (isAnnotationForTBox == true) {
+ //1. In transparency box we shows two annotation at a time, so we need to decide the max length of annotation in btween two annotation because based on that
+ // we decide the size of speech bubble
+ $scope.longestAnnotation = $scope.MultiLanguageAnnationArray.reduce(function (firstAnnotation, seconAnnotation) { return firstAnnotation.length > seconAnnotation.length ? firstAnnotation : seconAnnotation; });
+
+ //2.
+ if (event.ctrlKey) {
+
+ console.log('ctrl pressed');
+
+ $scope.multiAnnotationIsON = true;
+
+ //2.1 create unique speech bubbles
+ $scope.speechBubbleCounter = $scope.speechBubbleCounter + 1;
+ var id = "speechBubble" + $scope.speechBubbleCounter;
+
+ //2.2 Get clicked locationa and find if it is already clicked earlier too on same location
+ var pointClicked = parseInt(x) + parseInt(y);
+
+ var isClickedOnSamePoint = $("#canvasDiv").find("div[id=" + pointClicked + "]").length;
+
+ console.log('isClickedOnSamePoint: ' + isClickedOnSamePoint);
+
+ // if user has not clciked on smae point then create speech bubble otherwise not
+ if (isClickedOnSamePoint == 0) {
+ console.log('not clicked on same point')
+ $scope.createSpeechBubbleBasedOnAnnotationLength(pointClicked, x, y, id);
+
+ $scope.speechbubbleList.push({ xaxis: x, yaxis: y, ids: id });
+
+ }
+
+
+ $('.appendDragg').draggable({
+ drag: function (evt) {
+ $(this).prev('div').css("display", "none");
+ var bor_id = $(this).next('div').attr('id');
+ var sub_id1 = $(this).attr('id');
+ var verticalScrollPosition = canvasDiv.scrollTop;
+ var horizontlScrollPosition = canvasDiv.scrollLeft;
+
+ if ($scope.speechbubbleList != null || $scope.speechbubbleList != undefined) {
+ for (var m = 0; m <= $scope.speechbubbleList.length - 1; m++) {
+ if ($scope.speechbubbleList[m].ids == sub_id1) {
+
+ $scope.angle1($scope.speechbubbleList[m].xaxis, $scope.speechbubbleList[m].yaxis, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, bor_id);
+ break;
+
+ }
+ }
+ }
+
+ },
+ });
+
+
+
+ $('.dynCross').on('click', function (evt) {
+ $(this).parent().parent().parent().css('display', 'none');
+
+ });
+
+ }
+
+
+ else {
+ $scope.multiAnnotationIsON = false;
+
+ $(".com").css("display", "none");
+ $("#bord").css({ "width": "0px", "display": "none" });
+ var sppechBubbleDotHTML = '
'
+ + '
'
+ + '
'
+ + '
'
+
+ + '
'
+ + '
';
+ $('#canvasDiv').append(sppechBubbleDotHTML);
+
+ if ($scope.MultiLanguageAnnationArray.length > 0) {
+ for (var i = 0; i <= $scope.MultiLanguageAnnationArray.length - 1; i++) {
+ var MultipleLanguage = $scope.MultiLanguageAnnationArray[i];
+ $("#sppeachBubble").append("
" + MultipleLanguage + "
");
+ }
+ }
+ else {
+ console.log('MultiLanguageAnnationArray.length is :' + $scope.MultiLanguageAnnationArray.length)
+ }
+ if ($scope.longestAnnotation != null || $scope.longestAnnotation != undefined) {
+ if ($scope.longestAnnotation.length <= 10) {
+
+
+ $("#sppeachBubble").css("width", "100px");
+
+ }
+
+ else if ($scope.longestAnnotation.length > 10 && $scope.longestAnnotation.length <= 17) {
+
+
+
+ $("#sppeachBubble").css("width", "140px");
+
+ }
+ else if ($scope.longestAnnotation.length > 17 && $scope.longestAnnotation.length <= 26) {
+
+
+ $("#sppeachBubble").css("width", "195px");
+
+ }
+ else if ($scope.longestAnnotation.length > 26 && $scope.longestAnnotation.length <= 34) {
+
+ $("#sppeachBubble").css("width", "248px");
+
+ }
+ else if ($scope.longestAnnotation.length > 34 && $scope.longestAnnotation.length <= 44) {
+
+
+ $("#sppeachBubble").css("width", "300px");
+ }
+
+ else if ($scope.longestAnnotation.length > 44 && $scope.longestAnnotation.length <= 54) {
+
+ $("#sppeachBubble").css("width", "370px");
+
+ }
+
+ else if ($scope.longestAnnotation.length > 54 && $scope.longestAnnotation.length <= 69) {
+
+
+ $("#sppeachBubble").css("width", "450px");
+
+ }
+
+ else if ($scope.longestAnnotation.length > 69 && $scope.longestAnnotation.length <= 75) {
+
+
+ $("#sppeachBubble").css("width", "510px");
+
+ }
+
+ else {
+
+
+ $("#sppeachBubble").css("width", ($scope.longestAnnotation.length) + "%");
+
+
+ }
+
+ }
+ var Globe = [];
+ Globe.push({ currentX: x, currentY: y });
+
+ document.getElementById('dot').style.display = 'block';
+ document.getElementById('dot').style.left = ((Globe[0].currentX) - 10) + 'px';
+ document.getElementById('dot').style.top = ((Globe[0].currentY) + 10) + 'px';
+ document.getElementById('sppeachBubble').style.display = 'block';
+ document.getElementById('sppeachBubble').style.left = (Globe[0].currentX) + 'px';
+ document.getElementById('sppeachBubble').style.top = (Globe[0].currentY) + 'px';
+
+ $('#sppeachBubble').draggable(
+ {
+ drag: function (evt) {
+
+ $("#dot").css("display", "none");
+ var verticalScrollPosition = canvasDiv.scrollTop;
+ var horizontlScrollPosition = canvasDiv.scrollLeft;
+ $scope.angle(x, y, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, true);
+
+
+ },
+ });
+
+
+ $('.crossDiv_temp').on('click', function (evt) {
+ $('#sppeachBubble').css('display', 'none');
+
+ $("#bord").css("display", "none");
+ $("#dot").css("display", "none");
+
+
+ });
+
+ }
+ }
+
+ else {
+
+ // alert("false");
+ $scope.longest_annotationT1 = $scope.annotationTextArrayT1.reduce(function (a, b) { return a.length > b.length ? a : b; });
+ $scope.longest_annotationT2 = $scope.annotationTextArrayT2.reduce(function (a, b) { return a.length > b.length ? a : b; });
+
+ if (event.ctrlKey) {
+
+ // $scope.multiAnnotationIsON = true;
+
+ $scope.j = $scope.j + 1;
+
+ var sub_id_annotation = "black_annotation" + $scope.j;
+ // alert(sub_id_annotation);
+ var pointClicked_annotation = parseInt(x) + parseInt(y);
+ var Exists_annotation = $("#canvasDiv").find("div[id=" + pointClicked_annotation + "]").length;
+ // alert(Exists_annotation);
+ // alert(pointClicked_annotation);
+ var sppechBubbleHTML_annotation = "
";
+ if ($scope.longest_annotationT1.length > $scope.longest_annotationT2.length) {
+ if (Exists_annotation == 0) {
+ $("#canvasDiv").append(sppechBubbleHTML_annotation);
+
+ for (var l = 0; l <= $scope.annotationTextArrayT1.length - 1; l++) {
+ var MultipleLang_annotation_T1 = $scope.annotationTextArrayT1[l];
+ // alert(MultipleLang_annotation_T1);
+ // alert(sub_id_annotation);
+ $("#" + sub_id_annotation).append("
" + MultipleLang_annotation_T1 + "
");
+ }
+
+ $("#" + sub_id_annotation).append("
");
+
+ for (var k = 0; k <= $scope.annotationTextArrayT2.length - 1; k++) {
+ // alert(MultipleLang_annotation_T2);
+ var MultipleLang_annotation_T2 = $scope.annotationTextArrayT2[k];
+ $("#" + sub_id_annotation).append("
" + MultipleLang_annotation_T2 + "
");
+ }
+
+
+
+ if ($scope.longest_annotationT1.length <= 10) {
+
+
+ $("#" + sub_id_annotation).css("width", "100px");
+
+
+ }
+
+ else if ($scope.longest_annotationT1.length > 10 && $scope.longest_annotationT1.length <= 17) {
+
+
+ $("#" + sub_id_annotation).css("width", "140px");
+
+
+ }
+
+ else if ($scope.longest_annotationT1.length > 17 && $scope.longest_annotationT1.length <= 26) {
+
+
+
+ $("#" + sub_id_annotation).css("width", "195px");
+
+ }
+ else if ($scope.longest_annotationT1.length > 26 && $scope.longest_annotationT1.length <= 34) {
+
+
+
+ $("#" + sub_id_annotation).css("width", "248px");
+ }
+ else if ($scope.longest_annotationT1.length > 34 && $scope.longest_annotationT1.length <= 44) {
+
+
+
+ $("#" + sub_id_annotation).css("width", "300px");
+ }
+
+ else if ($scope.longest_annotationT1.length > 44 && $scope.longest_annotationT1.length <= 54) {
+
+
+
+ $("#" + sub_id_annotation).css("width", "370px");
+ }
+ else if ($scope.longest_annotationT1.length > 54 && $scope.longest_annotationT1.length <= 69) {
+
+
+
+ $("#" + sub_id_annotation).css("width", "450px");
+ }
+ else if ($scope.longest_annotationT1.length > 69 && $scope.longest_annotationT1.length <= 75) {
+
+
+ $("#" + sub_id_annotation).css("width", "510px");
+
+ }
+ else {
+
+
+ $("#" + sub_id_annotation).css("width", ($scope.longest_annotationT1.length) + "%");
+ }
+ }
+ else {
+
+ $("#canvasDiv").find("div[id=" + pointClicked_annotation + "]").css("display", "block");
+
+ }
+
+ }
+ else {
+
+ if (Exists_annotation == 0) {
+
+
+
+ $("#canvasDiv").append(sppechBubbleHTML_annotation);
+
+ for (var l = 0; l <= $scope.annotationTextArrayT1.length - 1; l++) {
+ var MultipleLang_annotation_T1 = $scope.annotationTextArrayT1[l];
+ // alert(MultipleLang_annotation_T1);
+ $("#" + sub_id_annotation).append("
" + MultipleLang_annotation_T1 + "
");
+ }
+
+ $("#" + sub_id_annotation).append("
");
+
+ for (var k = 0; k <= $scope.annotationTextArrayT2.length - 1; k++) {
+ var MultipleLang_annotation_T2 = $scope.annotationTextArrayT2[k];
+ // alert(MultipleLang_annotation_T2);
+ $("#" + sub_id_annotation).append("
" + MultipleLang_annotation_T2 + "
");
+ }
+
+ if ($scope.longest_annotationT2.length <= 10) {
+
+
+ $("#" + sub_id_annotation).css("width", "100px");
+
+
+ }
+
+ else if ($scope.longest_annotationT2.length > 10 && $scope.longest_annotationT2.length <= 17) {
+
+
+ $("#" + sub_id_annotation).css("width", "140px");
+
+
+ }
+
+ else if ($scope.longest_annotationT2.length > 17 && $scope.longest_annotationT2.length <= 26) {
+
+
+
+ $("#" + sub_id_annotation).css("width", "195px");
+
+ }
+ else if ($scope.longest_annotationT2.length > 26 && $scope.longest_annotationT2.length <= 34) {
+
+
+
+ $("#" + sub_id_annotation).css("width", "248px");
+ }
+ else if ($scope.longest_annotationT2.length > 34 && $scope.longest_annotationT2.length <= 44) {
+
+
+
+ $("#" + sub_id_annotation).css("width", "300px");
+ }
+
+ else if ($scope.longest_annotationT2.length > 44 && $scope.longest_annotationT2.length <= 54) {
+
+
+
+ $("#" + sub_id_annotation).css("width", "370px");
+ }
+ else if ($scope.longest_annotationT2.length > 54 && $scope.longest_annotationT2.length <= 69) {
+
+
+
+ $("#" + sub_id_annotation).css("width", "450px");
+ }
+ else if ($scope.longest_annotationT2.length > 69 && $scope.longest_annotationT2.length <= 75) {
+
+
+ $("#" + sub_id_annotation).css("width", "510px");
+
+ }
+ else {
+
+
+ $("#" + sub_id_annotation).css("width", ($scope.longest_annotationT2.length) + "%");
+ }
+ }
+ else {
+
+ $("#canvasDiv").find("div[id=" + pointClicked_annotation + "]").css("display", "block");
+
+ }
+
+ }
+
+ $scope.speachBubbleArrayAnnotation.push({ xaxis: x, yaxis: y, ids: sub_id_annotation });
+
+ $('.appendDragg_annotation').draggable({
+ drag: function (evt) {
+ $(this).prev('div').css("display", "none");
+ var bor_id_anno = $(this).next('div').attr('id');
+ var sub_id1_anno = $(this).attr('id');
+ var verticalScrollPosition = canvasDiv.scrollTop;
+ var horizontlScrollPosition = canvasDiv.scrollLeft;
+
+ if ($scope.speachBubbleArrayAnnotation != null || $scope.speachBubbleArrayAnnotation != undefined) {
+ for (var m = 0; m <= $scope.speachBubbleArrayAnnotation.length - 1; m++) {
+ if ($scope.speachBubbleArrayAnnotation[m].ids == sub_id1_anno) {
+
+ $scope.angle1($scope.speachBubbleArrayAnnotation[m].xaxis, $scope.speachBubbleArrayAnnotation[m].yaxis, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, bor_id_anno);
+ break;
+
+ }
+ }
+ }
+
+ },
+ });
+
+
+
+ $('.dynCross_anno').on('click', function (evt) {
+ $(this).parent().parent().parent().css('display', 'none');
+
+ // $("#bord").css("display", "none");
+ // $("#dot").css("display", "none");
+
+
+ });
+
+
+
+ }
+
+ else {
+
+ $scope.multiAnnotationIsON = false;
+
+ $(".com_annotation").css("display", "none");
+ $("#bord_annotation").css({ "width": "0px", "display": "none" });
+
+ var sppechBubbleDotHTML_annotation = '
'
+ + '
'
+ + '
'
+ + '
'
+
+ + '
'
+ + '
';
+
+
+
+ if ($scope.longest_annotationT1.length > $scope.longest_annotationT2.length) {
+
+ $("#sppeachBubble_annotation p").remove();
+ $('#canvasDiv').append(sppechBubbleDotHTML_annotation);
+ for (var l = 0; l <= $scope.annotationTextArrayT1.length - 1; l++) {
+ var MultipleLang_annotation_T1 = $scope.annotationTextArrayT1[l];
+ $("#sppeachBubble_annotation").append("
" + MultipleLang_annotation_T1 + "
");
+ }
+
+ $("#sppeachBubble_annotation").append("
");
+
+ for (var k = 0; k <= $scope.annotationTextArrayT2.length - 1; k++) {
+ var MultipleLang_annotation_T2 = $scope.annotationTextArrayT2[k];
+ $("#sppeachBubble_annotation").append("
" + MultipleLang_annotation_T2 + "
");
+ }
+
+ if ($scope.longest_annotationT1.length <= 10) {
+
+
+ $("#sppeachBubble_annotation").css("width", "100px");
+
+
+ }
+
+ else if ($scope.longest_annotationT1.length > 10 && $scope.longest_annotationT1.length <= 17) {
+
+
+ $("#sppeachBubble_annotation").css("width", "140px");
+
+
+ }
+
+ else if ($scope.longest_annotationT1.length > 17 && $scope.longest_annotationT1.length <= 26) {
+
+
+
+ $("#sppeachBubble_annotation").css("width", "195px");
+
+ }
+ else if ($scope.longest_annotationT1.length > 26 && $scope.longest_annotationT1.length <= 34) {
+
+
+
+ $("#sppeachBubble_annotation").css("width", "248px");
+ }
+ else if ($scope.longest_annotationT1.length > 34 && $scope.longest_annotationT1.length <= 44) {
+
+
+
+ $("#sppeachBubble_annotation").css("width", "300px");
+ }
+
+ else if ($scope.longest_annotationT1.length > 44 && $scope.longest_annotationT1.length <= 54) {
+
+
+
+ $("#sppeachBubble_annotation").css("width", "370px");
+ }
+ else if ($scope.longest_annotationT1.length > 54 && $scope.longest_annotationT1.length <= 69) {
+
+
+
+ $("#sppeachBubble_annotation").css("width", "450px");
+ }
+ else if ($scope.longest_annotationT1.length > 69 && $scope.longest_annotationT1.length <= 75) {
+
+
+ $("#sppeachBubble_annotation").css("width", "510px");
+
+ }
+ else {
+
+
+ $("#sppeachBubble_annotation").css("width", ($scope.longest_annotationT1.length) + "%");
+ }
+ }
+
+
+ else {
+ $("#sppeachBubble_annotation p").remove();
+ $('#canvasDiv').append(sppechBubbleDotHTML_annotation);
+ for (var l = 0; l <= $scope.annotationTextArrayT1.length - 1; l++) {
+ var MultipleLang_annotation_T1 = $scope.annotationTextArrayT1[l];
+ $("#sppeachBubble_annotation").append("
" + MultipleLang_annotation_T1 + "
");
+ }
+
+ $("#sppeachBubble_annotation").append("
");
+
+ for (var k = 0; k <= $scope.annotationTextArrayT2.length - 1; k++) {
+ var MultipleLang_annotation_T2 = $scope.annotationTextArrayT2[k];
+ $("#sppeachBubble_annotation").append("
" + MultipleLang_annotation_T2 + "
");
+ }
+
+ if ($scope.longest_annotationT2.length <= 10) {
+
+
+ $("#sppeachBubble_annotation").css("width", "100px");
+
+
+ }
+
+ else if ($scope.longest_annotationT2.length > 10 && $scope.longest_annotationT2.length <= 17) {
+
+
+ $("#sppeachBubble_annotation").css("width", "140px");
+
+
+ }
+
+ else if ($scope.longest_annotationT2.length > 17 && $scope.longest_annotationT2.length <= 26) {
+
+
+
+ $("#sppeachBubble_annotation").css("width", "195px");
+
+ }
+ else if ($scope.longest_annotationT2.length > 26 && $scope.longest_annotationT2.length <= 34) {
+
+
+
+ $("#sppeachBubble_annotation").css("width", "248px");
+ }
+ else if ($scope.longest_annotationT2.length > 34 && $scope.longest_annotationT2.length <= 44) {
+
+
+
+ $("#sppeachBubble_annotation").css("width", "300px");
+ }
+
+ else if ($scope.longest_annotationT2.length > 44 && $scope.longest_annotationT2.length <= 54) {
+
+
+
+ $("#sppeachBubble_annotation").css("width", "370px");
+ }
+ else if ($scope.longest_annotationT2.length > 54 && $scope.longest_annotationT2.length <= 69) {
+
+
+
+ $("#sppeachBubble_annotation").css("width", "450px");
+ }
+ else if ($scope.longest_annotationT2.length > 69 && $scope.longest_annotationT2.length <= 75) {
+
+
+ $("#sppeachBubble_annotation").css("width", "510px");
+
+ }
+ else {
+
+
+ $("#sppeachBubble_annotation").css("width", ($scope.longest_annotationT2.length) + "%");
+ }
+ var Globe = [];
+ Globe.push({ currentX: x, currentY: y });
+
+ document.getElementById('dot_annotation').style.display = 'block';
+ document.getElementById('dot_annotation').style.left = ((Globe[0].currentX) - 10) + 'px';
+ document.getElementById('dot_annotation').style.top = ((Globe[0].currentY) + 10) + 'px';
+ document.getElementById('sppeachBubble_annotation').style.display = 'block';
+ document.getElementById('sppeachBubble_annotation').style.left = (Globe[0].currentX) + 'px';
+ document.getElementById('sppeachBubble_annotation').style.top = (Globe[0].currentY) + 'px';
+
+ $('#sppeachBubble_annotation').draggable(
+ {
+ drag: function (evt) {
+
+ $("#dot_annotation").css("display", "none");
+ var verticalScrollPosition = canvasDiv.scrollTop;
+ var horizontlScrollPosition = canvasDiv.scrollLeft;
+ $scope.angle(x, y, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, false);
+
+
+ },
+ });
+
+
+ $('.crossDiv_temp_annotation').on('click', function (evt) {
+ $('#sppeachBubble_annotation').css('display', 'none');
+
+ $("#bord_annotation").css("display", "none");
+ $("#dot_annotation").css("display", "none");
+
+
+ });
+ }
+
+
+
+ }
+
+
+ }
+
+ }
+
+ $scope.createSpeechBubbleBasedOnAnnotationLength = function (pointClicked, x, y, id) {
+ var sppechBubbleHTML = "
";
+ $("#canvasDiv").append(sppechBubbleHTML);
+
+ for (var i = 0; i <= $scope.MultiLanguageAnnationArray.length - 1; i++) {
+ var annotation = $scope.MultiLanguageAnnationArray[i];
+
+ $("#" + id).append("
" + annotation + "
");
+ }
+
+ if ($scope.longestAnnotation.length <= 10) {
+ $("#" + id).css("width", "100px");
+ }
+
+ else if ($scope.longestAnnotation.length > 10 && $scope.longestAnnotation.length <= 17) {
+ $("#" + id).css("width", "140px");
+ }
+ else if ($scope.longestAnnotation.length > 17 && $scope.longestAnnotation.length <= 26) {
+ $("#" + id).css("width", "195px");
+
+ }
+ else if ($scope.longestAnnotation.length > 26 && $scope.longestAnnotation.length <= 34) {
+ $("#" + id).css("width", "248px");
+ }
+ else if ($scope.longestAnnotation.length > 34 && $scope.longestAnnotation.length <= 44) {
+ $("#" + id).css("width", "300px");
+ }
+
+ else if ($scope.longestAnnotation.length > 44 && $scope.longestAnnotation.length <= 54) {
+ $("#" + id).css("width", "370px");
+ }
+ else if ($scope.longestAnnotation.length > 54 && $scope.longestAnnotation.length <= 69) {
+ $("#" + id).css("width", "450px");
+ }
+ else if ($scope.longestAnnotation.length > 69 && $scope.longestAnnotation.length <= 75) {
+ $("#" + id).css("width", "510px");
+
+ }
+ else {
+ $("#" + id).css("width", ($scope.longestAnnotation.length) + "%");
+ }
+ }
+
+ $scope.angle1 = function (cx1, cy1, ex1, ey1, id, id2) {
+
+ // console.log(cx1 + " " + cy1);
+ var dy = ey1 - cy1;
+ var dx = ex1 - cx1;
+ var theta = 0;
+ if (dx < 0) {
+ theta = Math.atan(dy / dx) * (180 / Math.PI);
+ theta = theta + 180;
+
+ }
+ else if (dy < 0) {
+ theta = Math.atan(dy / dx) * (180 / Math.PI);
+ theta = theta + 360;
+
+ }
+ else {
+ theta = Math.atan(dy / dx) * (180 / Math.PI);
+ }
+
+ var g = Math.sqrt((cx1 - ex1) * (cx1 - ex1) + (cy1 - ey1) * (cy1 - ey1));
+ var e = cy1;
+ var f = cx1;
+
+ $('#' + id).css({ 'display': 'block', 'width': g + 'px', 'top': e + 'px', 'left': f + 'px', 'transform': 'rotate(' + theta + 'deg)', '-moz-transform': 'rotate(' + theta + 'deg)', '-webkit-transform': 'rotate(' + theta + 'deg)', 'transform-origin': '0% 0%' });
+
+ }
+
+ function myFunction(crossId) {
+ // alert(crossId);
+ $('#' + crossId).parent().parent().parent().css("display", "none");
+
+ }
+
+
+ $scope.angle = function (cx, cy, ex, ey, BoolValues) {
+
+
+ var dy = ey - cy;
+ var dx = ex - cx;
+ var theta = 0;
+ if (dx < 0) {
+ theta = Math.atan(dy / dx) * (180 / Math.PI);
+ theta = theta + 180;
+
+ }
+ else if (dy < 0) {
+ theta = Math.atan(dy / dx) * (180 / Math.PI);
+ theta = theta + 360;
+
+ }
+ else {
+ theta = Math.atan(dy / dx) * (180 / Math.PI);
+ }
+
+ var d = Math.sqrt((cx - ex) * (cx - ex) + (cy - ey) * (cy - ey));
+ var e = cy;
+ var f = cx;
+
+ if (BoolValues == true) {
+ $("#bord").css({ 'display': 'block', 'width': d + 'px', 'top': e + 'px', 'left': f + 'px', 'transform': 'rotate(' + theta + 'deg)', '-moz-transform': 'rotate(' + theta + 'deg)', '-webkit-transform': 'rotate(' + theta + 'deg)', 'transform-origin': '0% 0%' });
+
+ }
+ else {
+ $("#bord_annotation").css({ 'display': 'block', 'width': d + 'px', 'top': e + 'px', 'left': f + 'px', 'transform': 'rotate(' + theta + 'deg)', '-moz-transform': 'rotate(' + theta + 'deg)', '-webkit-transform': 'rotate(' + theta + 'deg)', 'transform-origin': '0% 0%' });
+ }
+
+
+
+ }
+
+
+ $scope.createSpeechBubble = function (event, text, x, y) {
+ //set z index to make annoation speech buble on top others
+ $('#canvasDiv').css('cursor', 'pointer');
+ $('
'
+ + '
'
+ + '
' + text + '
'
+ //+'
+ + '
').appendTo('#canvasDiv');
+
+ $('#speechBubble').on('click', '.BubbleCloseBtn', function (evt) {
+ $('#speechBubble').css('display', 'none');
+ });
+
+ $('#canvasDiv').attr("data-bubbleid", "speechBubble")
+
+
+ };
+
+
+ $scope.createTransparencyBox = function () {
+
+
+ //if listanager is visisble then close it
+
+ $rootScope.isListManagerSelected = false;
+ $rootScope.CloseListManager();
+
+
+ $scope.isTransparencyActivated = true;
+ // alert('transparencyClicked' + $scope.isTransparencyActivated)
+ $('#btnTranparency').addClass('tButtonActive');
+ $('#btnIdentity').removeClass(' btn-primary');
+ $('#btnIdentity').addClass('btn-black');
+
+ var canvasDiv = document.getElementById('canvasDiv');
+ $scope.verticalScrollPosition = canvasDiv.scrollTop;
+ $scope.horizontlScrollPosition = canvasDiv.scrollLeft;
+
+ var canvasDiv = document.getElementById('canvasDiv');
+ canvasDiv.addEventListener("mousedown", mouseDownListener);
+
+ canvasDiv.addEventListener("mousemove", mouseMoveListener);
+
+ canvasDiv.addEventListener("mouseup", mouseUpListener)
+
+ }
+
+ function mouseDownListener(e) {
+ //Dated:18-07-2016 Issue#4975: Transparency box should not be clickable if it is already selected.
+ var tCanvas = document.getElementById('transparencyCanvas');
+ if ($('#transparencyScale').css("visibility") == 'visible') {
+ $('#transparencyScale').css('visibility', 'hidden');
+ $('#transparencyCanvas').remove();
+ }
+ var $container = document.getElementById('canvasDiv');
+ var $selection = $('
').addClass('rectangle');
+ document.getElementById("DAView")
+ $selection.css({
+ 'position': 'absolute',
+ //'background': 'transparent',
+ 'border': '1px dotted #000'
+ });
+
+ var currentMousePosition = $scope.getMousePos(e);
+
+ $scope.TBDrawStartX = currentMousePosition.x;
+ $scope.TBDrawStartY = currentMousePosition.y;
+
+
+ var actulalX = currentMousePosition.x + $scope.horizontlScrollPosition
+ var actualY = currentMousePosition.y + $scope.verticalScrollPosition
+
+ //alert('$scope.TransparencyBoxStartX in mouseDown: ' + $scope.TransparencyBoxStartX + ' & Y= ' + $scope.TransparencyBoxStartY);
+ $scope.TransparencyBoxStartX = actulalX;
+ $scope.TransparencyBoxStartY = actualY
+ $scope.startX = actulalX;
+ $scope.startY = actualY;
+ var tBox = document.getElementById('transparencyCanvas');
+
+ if (tBox == null) {
+ //// canvasDiv.style.cursor = "crosshair";
+ $selection.css({
+ 'top': actualY,
+ 'left': actulalX,
+ 'width': 0,
+ 'height': 0,
+ 'z-index': 1000
+ //'background': 'transparent',
+ });
+ $selection.appendTo($container);
+ }
+
+ document.getElementById('canvasDiv').removeEventListener("mousedown", mouseDownListener);
+ //Dated:19-07-2016 Issue#4975: Transparency box should not be clickable if it is already selected.
+ if ($("#txtlayerNumber").val() != 0) {
+ $('#layerChangeSlider').slider("option", "value", parseInt($scope.totalLayers) - parseInt($scope.currentLayerNumber));
+ $("#txtlayerNumber").val(parseInt($scope.currentLayerNumber));
+ }
+ }
+
+ function mouseMoveListener(e) {
+
+ var currentMousePosition = $scope.getMousePos(e);
+ var move_x = currentMousePosition.x + $scope.horizontlScrollPosition,
+ move_y = currentMousePosition.y + $scope.verticalScrollPosition,
+
+ width = move_x - $scope.TransparencyBoxStartX,
+ height = move_y - $scope.TransparencyBoxStartY,
+ new_x, new_y;
+
+ new_x = (move_x < $scope.TransparencyBoxStartX) ? ($scope.TransparencyBoxStartX - width) : $scope.TransparencyBoxStartX;
+ new_y = (move_y < $scope.TransparencyBoxStartY) ? ($scope.TransparencyBoxStartY - height) : $scope.TransparencyBoxStartY;
+
+ $('.rectangle').css({
+ 'width': width,
+ 'height': height,
+ //'background': 'transparent'
+
+ });
+
+
+
+ }
+
+
+ function mouseUpListener(e) {
+ // $selection.remove();
+ // debugger;
+
+ $scope.currentLayerNumber = parseInt($('#txtlayerNumber').val());
+ $('.rectangle').remove();
+
+ var currentMousePosition = $scope.getMousePos(e);
+
+
+ var canvasDiv = document.getElementById('canvasDiv');
+ var verticalScrollPosition = canvasDiv.scrollTop;
+ var horizontlScrollPosition = canvasDiv.scrollLeft;
+
+ var TransparencyEndX = currentMousePosition.x + horizontlScrollPosition
+ var TransparencyBoxEndY = currentMousePosition.y + verticalScrollPosition
+
+
+ $scope.isTboxDrwan = true;
+ $scope.TbEndX = TransparencyEndX;
+ $scope.TbEndY = TransparencyBoxEndY;
+ $scope.TransparencyEndX = TransparencyEndX;
+ $scope.TransparencyBoxEndY = TransparencyBoxEndY;
+
+
+
+ //draw temp box to store the canvas data with original transparecy
+ if (document.getElementById('tempCanvas') != null) {
+ $('#tempCanvas').remove();
+ }
+ if (document.getElementById('tempCanvas') == null) {
+ var tempCanvas = document.createElement('canvas');
+ tempCanvas.id = 'tempCanvas';
+ // $scope.tempCanvas = transparencyCanvas.id;
+ tempCanvas.height = TransparencyBoxEndY - $scope.startY;
+ tempCanvas.width = TransparencyEndX - $scope.startX;
+ tempCanvas.style.position = "absolute";
+ tempCanvas.style.left = 200 + 'px';
+ tempCanvas.style.top = 200 + 'px';
+ tempCanvas.style.backgroundColor = "transparent";
+ tempCanvas.style.visibility = 'hidden';
+ tempCanvas.style.border = "black 1px solid";
+ document.getElementById('canvasDiv').appendChild(tempCanvas);
+ }
+
+
+ var BodyRegionDictionary = $rootScope.BodyRegionCordinatesData;
+
+ $scope.IncludedBodyRegions = [];
+ ////debugger;
+ $.each(BodyRegionDictionary, function (index, value) {
+ // alert(' $.each(BodyRegionDictionary1')
+ var transparencyBoxHeight = parseInt(TransparencyBoxEndY) - parseInt($scope.TransparencyBoxStartY);
+ var transparencyBoxWidth = parseInt(TransparencyEndX) - parseInt($scope.TransparencyBoxStartX);
+ var transparencyBoxBottom = parseInt($scope.TransparencyBoxStartY) + parseInt(transparencyBoxHeight);
+ var transparencyBoxRight = parseInt($scope.TransparencyBoxStartX) + parseInt(transparencyBoxWidth);
+ // alert(' $.each(BodyRegionDictionary2. transparencyBoxHeight: ' + transparencyBoxHeight + ',transparencyBoxBottom: ' + transparencyBoxBottom+', transparencyBoxRight: '+transparencyBoxRight)
+ var bodyRegionRight = parseInt(value.X) + parseInt(value.Width);
+ var bodyRegionBottom = parseInt(value.Y) + parseInt(value.Height);
+
+
+
+ var transparencyCanvas = document.createElement('canvas');
+ var tBox = document.getElementById('transparencyCanvas');
+ if (tBox == null) {
+
+ transparencyCanvas.id = 'transparencyCanvas';
+ $scope.transparencyCanvasId = transparencyCanvas.id;
+ transparencyCanvas.height = TransparencyBoxEndY - $scope.startY;
+ transparencyCanvas.width = TransparencyEndX - $scope.startX;
+ transparencyCanvas.style.position = "absolute";
+ transparencyCanvas.style.left = $scope.startX + 'px' // x + "px";
+ transparencyCanvas.style.top = $scope.startY + "px"//y + "px";
+ transparencyCanvas.style.border = "black 1px solid";
+ transparencyCanvas.style.backgroundColor = "transparent";
+ // transparencyCanvas.style.visibility = 'hidden';
+ document.getElementById('canvasDiv').appendChild(transparencyCanvas);
+ $scope.transparencyChangeCounter = 0;
+
+ $('#transparencyCanvas').resizable({ handles: "e,s,se,w,n,ne,nw,sw", stop: function (event, ui) { resizeCanvas(); }, start: function (event, ui) { clearTransCanvas(); } });
+
+ $scope.transparencyCanvasHeight = transparencyCanvas.height;
+ $scope.transparencyCanvasWidth = transparencyCanvas.width;
+
+ //bind click listener
+ transparencyCanvas.addEventListener('click', TransparencyCanvasClickListener);
+
+ $(".ui-wrapper").css("z-index", "600");
+
+ // $('#transparencyScale').modal('show');
+
+ //canvasDiv.removeEventListener('mouseup', arguments.callee);
+ //canvasDiv.removeEventListener('mousedown', arguments.callee);
+ //canvasDiv.removeEventListener('mousemove', arguments.callee);
+ }
+ if ($scope.TransparencyBoxStartX <= bodyRegionRight && value.X <= transparencyBoxRight && $scope.TransparencyBoxStartY <= bodyRegionBottom && value.Y <= transparencyBoxBottom) {
+
+ //if ($rootScope.voId != "9") {
+ // if ($rootScope.voId != "11") {
+ // $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.X, value.Y, value.IsMirror, $scope.TransparencyBoxStartX, TransparencyEndX, $scope.TransparencyBoxStartY, TransparencyBoxEndY, $scope, false, false);
+
+ // }
+
+ //}
+
+ //else {
+ // if (value.bodyRegionId == "6") {
+ // $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.X, value.Y, value.IsMirror, $scope.TransparencyBoxStartX, TransparencyEndX, $scope.TransparencyBoxStartY, TransparencyBoxEndY, $scope, false, false);
+ // }
+ //}
+ if (($rootScope.voId == "9" || $rootScope.voId == "11")) {
+ if (value.bodyRegionId == "6") {
+ $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.X, value.Y, value.IsMirror, $scope.TransparencyBoxStartX, TransparencyEndX, $scope.TransparencyBoxStartY, TransparencyBoxEndY, $scope, false, false);
+ }
+ else {
+
+ }
+ }
+ else {
+ $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.X, value.Y, value.IsMirror, $scope.TransparencyBoxStartX, TransparencyEndX, $scope.TransparencyBoxStartY, TransparencyBoxEndY, $scope, false, false);
+
+ }
+ }
+ })
+
+ // $('#transparencyScale').modal('show');
+ $('#transparencyScale').css('position', 'fixed')
+ $('#transparencyScale').css('top', $scope.TBDrawStartY - 10)
+ $('#transparencyScale').css('left', $scope.TBDrawStartX + 130)
+ $('#transparencyScale').css('visibility', 'visible')
+ $('#transparencyScale').css("z-index", "100000") //Dated:16-07-2016 Issue#4962:Transparency box should be on top.
+
+
+
+ document.getElementById('canvasDiv').removeEventListener("mousedown", mouseUpListener);
+ document.getElementById('canvasDiv').removeEventListener("mousemove", mouseUpListener);
+
+ document.getElementById('canvasDiv').removeEventListener("mouseup", mouseUpListener);
+ // document.getElementById('canvasDiv').removeEventListener("mousemove", mouseMoveListener);
+ $('#btnTranparency').removeClass('btn-black');
+
+ $('#btnTranparency').addClass('tButtonActive');
+ //debugger;
+ $('#txtlayerNumber').val((parseInt($scope.currentLayerNumber)) + 1);
+ //Dated:18-07-2016 Issue#4975: Transparency box should not be clickable if it is already selected.
+ $('#btnTranparency').removeClass('tButtonActive');
+ $('#btnTranparency').addClass('btn-black');
+ $('#btnIdentity').removeClass('btn-black');
+ $('#btnIdentity').addClass('btn-primary');
+ }
+
+ $scope.loadTransparencyImage = function (bodyRegionId, Height, Width, X, Y, IsMirror, TransparencyBoxStartX, TransparencyEndX, TransparencyBoxStartY, TransparencyBoxEndY, scope, isLayerChanged, isTransparencyChanged) {
+ // debugger;
+ var scope1 = angular.element(document.getElementById("DAView")).scope();
+ var transparencyCanvas = document.getElementById('transparencyCanvas');
+
+ TransparencyBoxStartX = parseInt((transparencyCanvas.style.left).replace('px', ''));
+ TransparencyBoxStartY = parseInt((transparencyCanvas.style.top).replace('px', ''));
+ TransparencyEndX = parseInt(transparencyCanvas.width) + parseInt(TransparencyBoxStartX);
+ TransparencyBoxEndY = parseInt(transparencyCanvas.height) + parseInt(TransparencyBoxStartY);
+
+
+ var XforCopyImage = 0;
+ var YforCopyImage = 0;
+ var WidthforCopyImage = 0;
+ var HeightforCopyImage = 0;
+ var XforTransImage = 0;
+ var WidthforTransImage = 0;
+ var HeightforTransImage = 0;
+ var YforTransImage = 0;
+ var PreviousBodyRegionHeight = 0;
+ var PreviousBodyRegionY;
+ var PreviousBodyRegionWidth;
+ var PreviousBodyRegionX;
+ var previousBodyRegionId;
+ var transparencyTempCanvas;
+
+
+ //X ends outside and start outside of bodyregion
+ if (TransparencyBoxStartX < X && TransparencyEndX > parseInt(X) + parseInt(Width)) {
+ XforCopyImage = 0;
+ WidthforCopyImage = Width;
+ WidthforTransImage = Width;
+ XforTransImage = parseInt(X) - (parseInt(TransparencyBoxStartX));
+ // alert('1')
+ }
+ else if (TransparencyBoxStartX < X && TransparencyEndX < parseInt(X) + parseInt(Width)) {
+
+ XforCopyImage = 0;
+
+ WidthforCopyImage = parseInt(TransparencyEndX) - parseInt(X);
+
+ WidthforTransImage = parseInt(TransparencyEndX) - parseInt(X);
+
+ // alert(' scope.WidthforCopyImage: ' + scope.WidthforCopyImage)
+ XforTransImage = parseInt(X) - (parseInt(TransparencyBoxStartX));
+
+ // alert('2')
+ }
+ else if (TransparencyBoxStartX > X && TransparencyEndX > parseInt(X) + parseInt(Width)) {
+ // alert('TransparencyEndX: ' + TransparencyEndX + ', X: ' + X + ', Width: ' + Width + 'scope.TransparencyBoxStartX: ' + scope.TransparencyBoxStartX)
+
+ XforCopyImage = parseInt(TransparencyBoxStartX) - parseInt(X);
+ WidthforCopyImage = parseInt(X) + parseInt(Width) - parseInt(TransparencyBoxStartX);
+ WidthforTransImage = parseInt(X) + parseInt(Width) - parseInt(TransparencyBoxStartX);
+ XforTransImage = 0;
+ // alert('3')
+ }
+ else if (TransparencyBoxStartX > X && TransparencyEndX < parseInt(X) + parseInt(Width)) {
+ // alert('startX inside & endX inside')
+ XforCopyImage = parseInt(TransparencyBoxStartX) - parseInt(X);//parseInt(X) + parseInt(Width) - parseInt(scope.TransparencyBoxStartX)// scope.TransparencyBoxStartX ;
+ WidthforCopyImage = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX);
+ WidthforTransImage = parseInt(TransparencyEndX) - parseInt(TransparencyBoxStartX);
+ XforTransImage = 0
+ // alert('4. TransparencyBoxStartX: ' + TransparencyBoxStartX + ',X: ' + parseInt(X) + ',TransparencyEndX: ' + TransparencyEndX + ',XforCopyImage: ' + XforCopyImage)
+ }
+
+ //calculate Y and height for tempTranparency box from where to cut the image
+
+
+ if (TransparencyBoxStartY < Y && TransparencyBoxEndY > parseInt(Y) + parseInt(Height)) {
+
+ // alert('start Y outside and end Y outside');
+
+ YforCopyImage = 0;
+ HeightforCopyImage = Height;
+
+ HeightforTransImage = Height;
+ //alert('Y ' + Y)
+ YforTransImage = parseFloat(Y) - parseInt(TransparencyBoxStartY)//parseFloat(Y) - (24.4);
+ // alert('5')
+ }
+ else if (TransparencyBoxStartY < Y && TransparencyBoxEndY < (parseInt(Y) + parseInt(Height))) {
+
+ YforCopyImage = 0;
+ HeightforCopyImage = (parseInt(TransparencyBoxEndY)) - parseInt(Y)//(parseInt(Height) + parseInt(Y)) - (parseInt(TransparencyBoxEndY) - parseInt(scope.TransparencyBoxStartY));
+
+ HeightforTransImage = (parseInt(TransparencyBoxEndY)) - parseInt(Y)// - parseInt(scope.TransparencyBoxStartY));
+
+ YforTransImage = parseFloat(Y) - parseInt(TransparencyBoxStartY);// - (24.4);
+
+ }
+ else if (TransparencyBoxStartY > Y && TransparencyBoxEndY > parseInt(Y) + parseInt(Height)) {
+
+ YforCopyImage = parseInt(TransparencyBoxStartY) - parseInt(Y);
+ HeightforCopyImage = parseInt(Y) + parseInt(Height) - parseInt(TransparencyBoxStartY);
+ HeightforTransImage = parseInt(Y) + parseInt(Height) - parseInt(TransparencyBoxStartY);
+ YforTransImage = 0;
+
+ }
+ else if (TransparencyBoxStartY > Y && TransparencyBoxEndY < parseInt(Y) + parseInt(Height)) {
+
+ YforCopyImage = parseInt(TransparencyBoxStartY) - parseInt(Y);
+ HeightforCopyImage = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY);
+ HeightforTransImage = parseInt(TransparencyBoxEndY) - parseInt(TransparencyBoxStartY);
+ YforTransImage = 0;
+ }
+
+
+ //this changes the transparency when user click on transparency scale(we have already set the original
+ //data on tras canvas irrespective of the trans number, so we can chnage the transparnecy of original data not the manipulated)
+ if (isTransparencyChanged == true) {
+
+ // var txtTransparencyChange = document.getElementById("txtTransparencyChange");
+
+ var transNumber = $scope.transNumber;
+
+ var ctx = document.getElementById('transparencyCanvas').getContext('2d');
+
+ var imageDa = ctx.getImageData(XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage);
+
+ // get the image data values
+ var imageData = imageDa.data;
+ var length = imageData.length;
+ // set every fourth value to 50
+ for (var i = 3; i < length; i += 4) {
+ //NIKITA
+ if ($scope.voId == "9" || $scope.voId == "11") {
+
+ if (imageData[i] == 0) {
+
+ }
+ else {
+ imageData[i] = ((255) * (parseInt(transNumber))) / 100;
+ }
+ }
+ else {
+ imageData[i] = ((255) * (parseInt(transNumber))) / 100;
+ }
+
+ // imageData[i] = ((255) * (parseInt(transNumber))) / 100;
+ }
+ // after the manipulation, reset the data
+ // imageDa.data = imageData;
+ // and put the imagedata back to the canvas
+ ctx.putImageData(imageDa, XforTransImage, YforTransImage);
+
+
+ }
+ else {
+
+ //0. get current layer number
+ if ($scope.isResized) {
+ //do nothing
+ }
+ else if (isLayerChanged) {
+ // debugger
+ $scope.layerNumber = parseInt($('#txtlayerNumber').val());
+
+ }
+ else {
+ var currentLayer = parseInt($('#txtlayerNumber').val());
+
+ var tranparencyLayer = currentLayer + 1;
+ $scope.layerNumber = tranparencyLayer;
+ }
+
+ //dedebugger;
+ //1. get the image source
+ var tranparencyImgSrc;
+
+ tranparencyImgSrc = $scope.GetImageSource(bodyRegionId);
+ var tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc);
+ // debugger;
+ var oldCanvas;
+
+ if (IsMirror == 'Yes') {
+ oldCanvas = document.getElementById('transparencyTempCanvas_MR_' + bodyRegionId)
+ }
+ else {
+ oldCanvas = document.getElementById('transparencyTempCanvas_' + bodyRegionId)
+
+ }
+
+ if (oldCanvas != null) {
+ document.getElementById('canvasDiv').removeChild(oldCanvas);
+ }
+
+ //remove tempmask canvas
+ var oldtempTransCanvasMask;
+ if (IsMirror == 'Yes') {
+ oldtempTransCanvasMask = document.getElementById('transparencyTempCanvasMask_MR_' + bodyRegionId + '_mci');
+ }
+ else {
+ oldtempTransCanvasMask = document.getElementById('transparencyTempCanvasMask_' + bodyRegionId + '_mci');
+
+ }
+ if (oldtempTransCanvasMask != null) {
+ document.getElementById('canvasDiv').removeChild(oldtempTransCanvasMask);
+ }
+
+ transparencyTempCanvas = document.createElement('canvas');
+ var transparencyTempcanavsMask = document.createElement('canvas');
+ //if mirror then draw mask image for non mirrored body region for annotation
+ if (IsMirror == 'Yes') {
+ transparencyTempCanvas.id = 'transparencyTempCanvas_MR_' + bodyRegionId;
+ transparencyTempcanavsMask.id = 'transparencyTempCanvasMask_MR' + bodyRegionId + '_mci';
+ }
+ else {
+ transparencyTempCanvas.id = 'transparencyTempCanvas_' + bodyRegionId;
+ transparencyTempcanavsMask.id = 'transparencyTempCanvasMask_' + bodyRegionId + '_mci';
+
+ }
+ transparencyTempCanvas.height = Height;
+ transparencyTempCanvas.width = Width;
+ transparencyTempCanvas.style.position = "absolute";
+ transparencyTempCanvas.style.left = X + 'px' // x + "px";
+ transparencyTempCanvas.style.top = Y + "px"//y + "px";
+ transparencyTempCanvas.style.visibility = 'hidden';
+ //transparencyTempCanvas.style.visibility = 'visible';
+ // transparencyCanvas.style.zIndex = 4000;
+ document.getElementById('canvasDiv').appendChild(transparencyTempCanvas);
+
+ //create temp mask canvas
+ transparencyTempcanavsMask.height = Height;
+ transparencyTempcanavsMask.width = Width;
+ transparencyTempcanavsMask.style.position = "absolute";
+ transparencyTempcanavsMask.style.left = X + 'px' // x + "px";
+ transparencyTempcanavsMask.style.top = Y + "px"//y + "px";
+ transparencyTempcanavsMask.style.visibility = 'hidden';
+ //transparencyTempCanvas.style.visibility = 'visible';
+ // transparencyCanvas.style.border = "black 1px solid";
+ document.getElementById('canvasDiv').appendChild(transparencyTempcanavsMask);
+
+
+ var tempImg = new Image();
+ tempImg.src = tranparencyImgSrc;//"http://localhost/AIA/" + tranparencyImgSrc;
+
+
+ tempImg.onload = function () {
+ // debugger;
+ var tempCtx = transparencyTempCanvas.getContext('2d');
+
+ if (IsMirror == 'Yes') {
+ //debugger;
+ tempCtx.save();
+ tempCtx.translate(Width, 0);
+ tempCtx.scale(-1, 1);
+ tempCtx.drawImage(tempImg, 0, 0);
+ }
+ else {
+ tempCtx.drawImage(tempImg, 0, 0);
+
+ }
+ // debugger;
+ var tempCanvasID;
+
+ if (IsMirror == 'Yes') {
+ tempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId;
+ }
+ else {
+ tempCanvasID = 'transparencyTempCanvas_' + bodyRegionId;
+ }
+
+
+ //check if transparency is activated
+
+
+ var transNumber = $scope.transNumber;//txtTransparencyChange.value;
+ // debugger;
+ //this changes the transparency when transparency is already activated and user resizes or chage the layer
+
+ var imageD = tempCtx.getImageData(0, 0, Width, Height);
+
+
+ var tempCtx = document.getElementById(tempCanvasID).getContext('2d');
+
+ //keep the original image on temp canavs to use it in changing transparency
+
+ if (document.getElementById('tempCanvas') != null) {
+ var contx = document.getElementById('tempCanvas').getContext('2d');
+ var tbTempCanvas = document.getElementById(tempCanvasID)
+ contx.drawImage(tbTempCanvas, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage);
+
+ }
+
+ // get the image data values
+
+ var imageData = imageD.data;
+ var length = imageData.length;
+
+ //change background of image from transparent to white
+
+ // set every fourth value to 50
+ for (var i = 3; i < length; i += 4) {
+ //NIKITA
+ if ($scope.voId == "9" || $scope.voId == "11") {
+
+ if (imageData[i] == 0) {
+
+ }
+ else {
+ imageData[i] = ((255) * (parseInt(transNumber))) / 100;
+ }
+ }
+ else {
+ imageData[i] = ((255) * (parseInt(transNumber))) / 100;
+ }
+ }
+
+
+ tempCtx.putImageData(imageD, 0, 0);
+
+
+ var ctx = transparencyCanvas.getContext('2d');
+
+
+ var TrtempCanvasID
+ if (IsMirror == 'Yes') {
+ TrtempCanvasID = 'transparencyTempCanvas_MR_' + bodyRegionId;
+ }
+ else {
+ TrtempCanvasID = 'transparencyTempCanvas_' + bodyRegionId;
+ }
+
+ var tmpCanvasContext = document.getElementById(TrtempCanvasID);//.getContext('2d');
+
+ ctx.drawImage(tmpCanvasContext, XforCopyImage, YforCopyImage, WidthforCopyImage, HeightforCopyImage, XforTransImage, YforTransImage, WidthforTransImage, HeightforTransImage)
+
+
+ XforCopyImage = 0;
+ YforCopyImage = 0;
+ WidthforCopyImage = 0;
+ HeightforCopyImage = 0;
+ XforTransImage = 0;
+ WidthforTransImage = 0;
+ HeightforTransImage = 0;
+ YforTransImage = 0;
+ PreviousBodyRegionHeight = 0;
+
+ }
+
+
+ //mask image code
+ //draw mask for annotation
+ var tempMaskImg = new Image();
+ var tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc);
+ tempMaskImg.src = tranparencyMaskImgSrc;//"http://localhost/AIA/" + tranparencyMaskImgSrc;
+ tempMaskImg.onload = function () {
+ // debugger;
+ var tempmaskCtx = transparencyTempcanavsMask.getContext('2d');
+
+ if (IsMirror == 'Yes') {
+ //debugger;
+ tempmaskCtx.save();
+ tempmaskCtx.translate(Width, 0);
+ tempmaskCtx.scale(-1, 1);
+ tempmaskCtx.drawImage(tempMaskImg, 0, 0);
+ }
+ else {
+ tempmaskCtx.drawImage(tempMaskImg, 0, 0);
+
+ }
+
+
+ }
+
+
+ PreviousBodyRegionHeight = HeightforTransImage;
+ PreviousBodyRegionY = YforTransImage;
+ PreviousBodyRegionWidth = WidthforTransImage;
+ PreviousBodyRegionX = XforTransImage;
+ previousBodyRegionId = bodyRegionId;
+
+ // $scope.layerNumber = parseInt($scope.layerNumber - 1);
+
+ }
+
+ }
+
+
+
+
+
+
+ function resizeCanvas() {
+ //debugger;
+ // alert('reload')
+ clearTransCanvas();
+ if ($('#speechBubbleTrns').length > 0) {
+ $('#speechBubbleTrns').remove();
+ }
+ var tCanvas = document.getElementById('transparencyCanvas');
+ var tCanvasContext = tCanvas.getContext('2d');
+
+ var tCanvasHeight = parseInt((tCanvas.style.height).replace('px', ''));
+
+ var tCanvasWidth = parseInt((tCanvas.style.width).replace('px', ''));
+
+ var tBoxStartX = parseInt((tCanvas.style.left).replace('px', ''));
+ var tBoxEndX = parseInt((tCanvas.style.left).replace('px', '')) + parseInt((tCanvas.style.width.replace('px', '')));
+ var tBoxStartY = parseInt((tCanvas.style.top).replace('px', ''));
+ var tBoxEndY = parseInt((tCanvas.style.top).replace('px', '')) + parseInt((tCanvas.style.height).replace('px', ''));
+ var transparencyBoxBottom = parseInt(tBoxStartY) + parseInt(tCanvasHeight);
+ var transparencyBoxRight = parseInt(tBoxStartX) + parseInt(tCanvasWidth);
+
+ if (tCanvas != null) {
+ $('#transparencyCanvas').remove();
+ }
+
+
+ $scope.isResized = true;
+
+
+ if (tCanvasHeight != $scope.transparencyCanvasHeight || tCanvasWidth != $scope.transparencyCanvasWidth) {
+
+
+ var transparencyCanvas = document.createElement('canvas');
+ transparencyCanvas.id = 'transparencyCanvas';
+ $scope.transparencyCanvas = tCanvas.id;
+ transparencyCanvas.height = tCanvasHeight;
+ transparencyCanvas.width = tCanvasWidth;
+ transparencyCanvas.style.position = "absolute";
+ transparencyCanvas.style.left = tCanvas.style.left; // x + "px";
+ transparencyCanvas.style.top = tCanvas.style.top//y + "px";
+ transparencyCanvas.style.border = "black 1px solid";
+ document.getElementById('canvasDiv').appendChild(transparencyCanvas);
+
+ $('#transparencyCanvas').resizable({ handles: "e,s,se,w,n,ne,nw,sw", stop: function (event, ui) { resizeCanvas(); }, start: function (event, ui) { clearTransCanvas(); } });
+
+ }
+ $scope.transparencyCanvasHeight = tCanvasHeight;
+ $scope.transparencyCanvasWidth = tCanvasWidth;
+
+ // debugger;
+ //create temp cavas to retain the original anavs data for use in transparency change as
+ //if u use original canvas data for transprency change then at 0 transparency all data will become transparent and if u increase transparency with this data then the canavs will be blank
+ if (document.getElementById('tempCanvas') != null) {
+ $('#tempCanvas').remove();
+ }
+ var tempCanvas = document.createElement('canvas');
+ tempCanvas.id = 'tempCanvas';
+ $scope.tempCanvas = tempCanvas.id;
+ tempCanvas.height = $scope.transparencyCanvasHeight;
+ tempCanvas.width = $scope.transparencyCanvasWidth;
+ tempCanvas.style.position = "absolute";
+ tempCanvas.style.left = 200 + 'px';
+ tempCanvas.style.backgroundColor = "transparent";
+ tempCanvas.style.visibility = 'hidden';
+ // tempCanvas.style.border = "black 1px solid";
+
+ document.getElementById('canvasDiv').appendChild(tempCanvas);
+
+
+ var BodyRegionDictionary = $rootScope.BodyRegionCordinatesData;
+
+ $scope.IncludedBodyRegions = [];
+ // $scope.layerNo = parseInt(document.getElementById(''))
+ var counter = 0;
+ $.each(BodyRegionDictionary, function (index, value) {
+
+ var bodyRegionRight = parseInt(value.X) + parseInt(value.Width);
+ var bodyRegionBottom = parseInt(value.Y) + parseInt(value.Height);
+ var TBRight = parseInt((document.getElementById('transparencyCanvas').style.left).replace('px', '')) + parseInt((document.getElementById('transparencyCanvas').style.width).replace('px', ''));
+ var TBBottom = parseInt((document.getElementById('transparencyCanvas').style.top).replace('px', '')) + parseInt((document.getElementById('transparencyCanvas').style.height).replace('px', ''));
+ var TBStartX = parseInt((document.getElementById('transparencyCanvas').style.left).replace('px', ''));
+ var TBStartY = parseInt((document.getElementById('transparencyCanvas').style.top).replace('px', ''));
+
+
+
+
+ if (TBStartX <= bodyRegionRight && value.X <= TBRight && TBStartY <= bodyRegionBottom && value.Y <= TBBottom) {
+
+
+ $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.X, value.Y, value.IsMirror, $scope.TransparencyBoxStartX, $scope.TransparencyEndX, $scope.TransparencyBoxStartY, $scope.TransparencyBoxEndY, $scope, false, false);
+
+ }
+
+
+ })
+ //bind click listener
+ //bind click listener
+ transparencyCanvas.addEventListener('click', TransparencyCanvasClickListener);
+
+
+
+ // });
+ $(".ui-wrapper").css("z-index", "600");
+ $scope.isResized = false;
+ }
+
+ function TransparencyCanvasClickListener(evt) {
+ //alert('tb clicked')
+ // debugger;
+ var pixelData;
+ var pixelDataTrans;
+ var mousePos = $scope.getMousePos(evt);
+ // alert(mousePos.x + ',' + mousePos.y);
+
+ var canvasDiv = document.getElementById('canvasDiv');
+ var verticalScrollPosition = canvasDiv.scrollTop;
+ var horizontlScrollPosition = canvasDiv.scrollLeft;
+
+
+ //We substracted 135, as the difference between flex and html coordinates for same organ is 135
+ var actulalX = mousePos.x + horizontlScrollPosition;
+ var actualY = mousePos.y + verticalScrollPosition //- 135; //+ tomenuBarheight + titleBarheight + searchComboheight;
+ var clickedBodyRegion;
+ var x;
+ var y;
+ var isMirror;
+ var width;
+ var BodyRegionDictionary = $rootScope.BodyRegionCordinatesData;
+ $.each(BodyRegionDictionary, function (index, value) {
+
+ var bodyRegionRight = parseInt(value.X) + parseInt(value.Width);
+ var bodyRegionBottom = parseInt(value.Y) + parseInt(value.Height);
+ if (actulalX <= bodyRegionRight && value.X <= actulalX && actualY <= bodyRegionBottom && value.Y <= actualY) {
+
+ clickedBodyRegion = value.bodyRegionId;
+ x = value.X;
+ y = value.Y;
+ width = value.Width;
+ isMirror = value.IsMirror;
+ return false;
+ }
+ })
+
+ if (isMirror == "Yes") {
+
+ var mirrorCanvasX = x;
+ var mirrorCanvasWidth = width;
+
+ var clickedCanvasMaskId = 'imageCanvas' + clickedBodyRegion + '_mci';
+ var clickedCanavs = document.getElementById(clickedCanvasMaskId);
+
+ //if non mirrored canvas does not exist for this irror Body region then draw non mirrored image to get annotation
+ var clickedBodyRegionData = new jinqJs()
+ .from(BodyRegionDictionary)
+ .where('bodyRegionId == ' + clickedBodyRegion)
+ .select();
+ if (clickedBodyRegionData != null || clickedBodyRegionData != undefined) {
+
+ var nomMirroredBodyRegion = new jinqJs()
+ .from(clickedBodyRegionData)
+ .where('IsMirror == No')
+ .select();
+
+
+ //debugger;
+ var oldMirrorMaskId = 'transparencyTempCanvasMask_' + clickedBodyRegion + '_mci';
+ var oldMirrorMask = document.getElementById(oldMirrorMaskId);
+ if (oldMirrorMask != null) {
+ document.getElementById('canvasDiv').removeChild(oldMirrorMask);
+ }
+ var transparencyTempcanavsMask = document.createElement('canvas');
+ transparencyTempcanavsMask.id = 'transparencyTempCanvasMask_' + clickedBodyRegion + '_mci';
+ transparencyTempcanavsMask.height = nomMirroredBodyRegion[0].Height;
+ transparencyTempcanavsMask.width = nomMirroredBodyRegion[0].Width;
+ transparencyTempcanavsMask.style.position = "absolute";
+ transparencyTempcanavsMask.style.left = nomMirroredBodyRegion[0].X + 'px' // x + "px";
+ transparencyTempcanavsMask.style.top = nomMirroredBodyRegion[0].Y + "px"//y + "px";
+ transparencyTempcanavsMask.style.visibility = 'hidden';
+
+ document.getElementById('canvasDiv').appendChild(transparencyTempcanavsMask);
+
+ var tranparencyImgSrc = $scope.GetImageSource(clickedBodyRegion);
+ var tempMaskImg = new Image();
+ var tranparencyMaskImgSrc = $scope.GetMaskImageSource(tranparencyImgSrc);
+ tempMaskImg.onload = function () {
+ var tempmaskCtx = transparencyTempcanavsMask.getContext('2d');
+ tempmaskCtx.drawImage(tempMaskImg, 0, 0);
+
+ //get x,y of non mirrored canvas for this body region
+ x = transparencyTempcanavsMask.style.left;
+ y = transparencyTempcanavsMask.style.top;
+
+ var maskCanvasTransId = 'transparencyTempCanvasMask_' + clickedBodyRegion + '_mci';
+ var maskCanvastrans = document.getElementById(maskCanvasTransId);
+ var maskCanvasContexttrans = maskCanvastrans.getContext("2d");
+
+
+
+
+ var canvasDiv = document.getElementById('canvasDiv');
+ var verticalScrollPosition = canvasDiv.scrollTop;
+ var horizontlScrollPosition = canvasDiv.scrollLeft;
+
+ var distanceXOnMirrorImage = (parseInt(mirrorCanvasX) + parseInt(mirrorCanvasWidth)) - (parseInt(mousePos.x) + horizontlScrollPosition);// - 135);
+
+ var mirrorXOnNormalImage = parseInt(maskCanvasContexttrans.canvas.offsetLeft) + parseInt(distanceXOnMirrorImage);
+
+ var actulalX = mirrorXOnNormalImage
+ var actualY = mousePos.y + verticalScrollPosition
+
+
+
+ var clickedCanvasMaskId = 'imageCanvas' + clickedBodyRegion + '_mci';
+ var maskCanvas = document.getElementById(clickedCanvasMaskId);
+ var maskCanvasContext = maskCanvas.getContext("2d");
+ var imgX = Math.round(actulalX - parseInt(x.replace('px', '')));
+ var imgY = Math.round(actualY - parseInt(y.replace('px', '')));
+ pixelData = maskCanvasContext.getImageData(imgX, imgY, 1, 1);
+
+
+ //trans layer image data
+ pixelDataTrans = maskCanvasContexttrans.getImageData(imgX, imgY, 1, 1);
+ // console.log('at the time' + pixelData.data[0])
+ // debugger;
+ var annotations = $scope.getAnnotationForTransparencyBox(pixelData, pixelDataTrans, $scope);
+ if ($('#speechBubble').length > 0)
+ $('#speechBubble').remove();
+
+
+ if ($('#speechBubbleTrns').length > 0) {
+ $('#speechBubbleTrns').remove();
+
+ // createSpeechBubbleOnTransparencyBox(evt, annotations.annotationT1, annotations.annotationT2, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left + 5, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top - 50)
+
+ $scope.annotationTextArrayT1 = [];
+ $scope.annotationTextArrayT2 = [];
+ $scope.annotationTextArrayT1.push(annotations.annotationT1);
+ $scope.annotationTextArrayT2.push(annotations.annotationT2);
+
+ $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, false);
+ }
+ else
+ // createSpeechBubbleOnTransparencyBox(evt, annotations.annotationT1, annotations.annotationT2, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left + 5, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top - 50)
+
+ $scope.annotationTextArrayT1 = [];
+ $scope.annotationTextArrayT2 = [];
+ $scope.annotationTextArrayT1.push(annotations.annotationT1);
+ $scope.annotationTextArrayT2.push(annotations.annotationT2);
+
+ $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, false);
+ }
+ tempMaskImg.src = "http://localhost/AIAHtml/" + tranparencyMaskImgSrc;
+
+
+ }
+
+ }
+ else {
+
+ var clickedCanvasMaskId = 'imageCanvas' + clickedBodyRegion + '_mci';
+ var maskCanvas = document.getElementById(clickedCanvasMaskId);
+ var maskCanvasContext = maskCanvas.getContext("2d");
+
+ //transparecncy canvas
+ var maskCanvasTransId = 'transparencyTempCanvasMask_' + clickedBodyRegion + '_mci';
+ var maskCanvastrans = document.getElementById(maskCanvasTransId);
+ var maskCanvasContexttrans = maskCanvastrans.getContext("2d");
+
+ pixelData = maskCanvasContext.getImageData(Math.round(actulalX - x), Math.round(actualY - y), 1, 1);
+
+ pixelDataTrans = maskCanvasContexttrans.getImageData(Math.round(actulalX - x), Math.round(actualY - y), 1, 1);
+ var annotations = $scope.getAnnotationForTransparencyBox(pixelData, pixelDataTrans, $scope);
+ //var annotations = $scope.getAnnotationForTransparencyBox(pixelData, pixelDataTrans, $scope);
+
+ if ($('#speechBubble').length > 0)
+ $('#speechBubble').remove();
+
+ if ($('#speechBubbleTrns').length > 0) {
+ $('#speechBubbleTrns').remove();
+
+ // $scope.createSpeechBubbleOnTransparencyBox(evt, annotations.annotationT1, annotations.annotationT2, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left + 5, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top - 50)
+ $scope.annotationTextArrayT1 = [];
+ $scope.annotationTextArrayT2 = [];
+ $scope.annotationTextArrayT1.push(annotations.annotationT1);
+ $scope.annotationTextArrayT2.push(annotations.annotationT2);
+
+ $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, false);
+ }
+ else
+ // $scope.createSpeechBubbleOnTransparencyBox(evt, annotations.annotationT1, annotations.annotationT2, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left + 5, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top - 50)
+
+
+ $scope.annotationTextArrayT1 = [];
+ $scope.annotationTextArrayT2 = [];
+ $scope.annotationTextArrayT1.push(annotations.annotationT1);
+ $scope.annotationTextArrayT2.push(annotations.annotationT2);
+
+ $scope.createDynamicSpeechBubble(evt, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, false);
+
+
+ }
+ //debugger;
+ }
+ function clearTransCanvas() {
+
+ var tCanvas = document.getElementById('transparencyCanvas');
+ if (tCanvas != null) {
+ var tCanvasContext = tCanvas.getContext('2d');
+ tCanvasContext.clearRect(0, 0, parseInt(tCanvas.style.width), parseInt(tCanvas.style.height));
+ }
+
+ }
+
+
+ $scope.getAnnotationForTransparencyBox = function (pixelData, pixelDataTrans, scope) {
+
+
+
+ pixelData.data[0] = pixelData.data[0] - 9;
+ pixelData.data[1] = pixelData.data[1] - 9;
+ pixelData.data[2] = pixelData.data[2] - 9;
+
+ //trans pixel data
+ pixelDataTrans.data[0] = pixelDataTrans.data[0] - 9;
+ pixelDataTrans.data[1] = pixelDataTrans.data[1] - 9;
+ pixelDataTrans.data[2] = pixelDataTrans.data[2] - 9;
+
+ var Red;
+ var Green;
+ var Blue;
+ var zero = "0";
+
+ if ((pixelData.data[0]).toString().length != 2) {
+ Red = zero.concat((pixelData.data[0]).toString())
+ }
+ else {
+ Red = (pixelData.data[0]).toString()
+ }
+ if ((pixelData.data[1]).toString().length != 2) {
+ Green = zero.concat((pixelData.data[1]).toString())
+ }
+ else {
+ Green = (pixelData.data[1]).toString()
+
+ }
+ if ((pixelData.data[2]).toString().length != 2) {
+ Blue = zero.concat((pixelData.data[2]).toString())
+ }
+ else {
+ Blue = (pixelData.data[2]).toString()
+
+ }
+ var RGBColor = (Red + Green + Blue);
+
+
+ var annotationText1 = $scope.GetAnnotationText(parseInt(RGBColor));
+
+ //get annotation for trans canavs
+ var RedTrans;
+ var GreenTrans;
+ var BlueTrans;
+ var zero = "0";
+
+ if ((pixelDataTrans.data[0]).toString().length != 2) {
+ RedTrans = zero.concat((pixelDataTrans.data[0]).toString())
+ }
+ else {
+ RedTrans = (pixelDataTrans.data[0]).toString()
+ }
+ if ((pixelDataTrans.data[1]).toString().length != 2) {
+ GreenTrans = zero.concat((pixelDataTrans.data[1]).toString())
+ }
+ else {
+ GreenTrans = (pixelDataTrans.data[1]).toString()
+
+ }
+ if ((pixelDataTrans.data[2]).toString().length != 2) {
+ BlueTrans = zero.concat((pixelDataTrans.data[2]).toString())
+ }
+ else {
+ BlueTrans = (pixelDataTrans.data[2]).toString()
+
+ }
+ var RGBColorTrans = (RedTrans + GreenTrans + BlueTrans);
+
+
+ var annotationText2 = $scope.GetAnnotationText(parseInt(RGBColorTrans));
+
+ return {
+ annotationT1: annotationText1,
+ annotationT2: annotationText2
+ }
+ }
+
+
+ $scope.onTransparencyChange = function (ev, ui) {
+ //debugger;
+ // alert('t change')
+ $scope.transNumber = ui.value;
+
+ var tCanvas = document.getElementById('transparencyCanvas');
+ var tCanvasContext = tCanvas.getContext('2d');
+
+ var tCanvasHeight = parseInt((tCanvas.style.height).replace('px', ''));
+
+ var tCanvasWidth = parseInt((tCanvas.style.width).replace('px', ''));
+
+ var tBoxStartX = parseInt((tCanvas.style.left).replace('px', ''));
+ var tBoxEndX = parseInt((tCanvas.style.left).replace('px', '')) + parseInt((tCanvas.style.width.replace('px', '')));
+ var tBoxStartY = parseInt((tCanvas.style.top).replace('px', ''));
+ var tBoxEndY = parseInt((tCanvas.style.top).replace('px', '')) + parseInt((tCanvas.style.height).replace('px', ''));
+ var transparencyBoxBottom = parseInt(tBoxStartY) + parseInt(tCanvasHeight);
+ var transparencyBoxRight = parseInt(tBoxStartX) + parseInt(tCanvasWidth);
+
+ //var scope = angular.element(document.getElementById("DAView")).scope();
+ //scope.$apply(function () {
+ var arr = [];
+ $scope.transparencyChangeCounter++;
+ //before changing the transparency of first canvas, hold the orignal canvas data on temp canvas
+
+ //put original data on transcanvas so that it can be used to change transparency properly
+ var tempCanavs = document.getElementById('tempCanvas');
+ var tempCanvasContext = tempCanavs.getContext('2d');
+
+ var originalTransparencyData = tempCanvasContext.getImageData(0, 0, $scope.transparencyCanvasWidth, $scope.transparencyCanvasHeight);
+ var ctx = document.getElementById('transparencyCanvas').getContext('2d');
+ ctx.putImageData(originalTransparencyData, 0, 0);
+
+
+ var BodyRegionDictionary = $rootScope.BodyRegionCordinatesData;
+
+ $scope.IncludedBodyRegions = [];
+ var counter = 0;
+ $.each(BodyRegionDictionary, function (index, value) {
+
+ var bodyRegionRight = parseInt(value.X) + parseInt(value.Width);
+ var bodyRegionBottom = parseInt(value.Y) + parseInt(value.Height);
+
+
+
+ if (tBoxStartX <= bodyRegionRight && value.X <= transparencyBoxRight && tBoxStartY <= bodyRegionBottom && value.Y <= transparencyBoxBottom) {
+
+ $scope.loadTransparencyImage(value.bodyRegionId, value.Height, value.Width, value.X, value.Y, value.IsMirror, $scope.TransparencyBoxStartX, $scope.TransparencyEndX, $scope.TransparencyBoxStartY, $scope.TransparencyBoxEndY, $scope, false, true);
+
+ }
+
+ });
+
+
+
+ // });
+ }
+
+ $scope.CloseTransparencyBox = function () {
+
+ $('.com_anno').css('display', 'none');
+
+ $('#sppeachBubble_annotation').css('display', 'none');
+ $('#dot_annotation').css('display', 'none');
+ $('#bord_annotation').css('display', 'none');
+
+ var tBox = document.getElementById('transparencyCanvas');
+
+
+ if (tBox != null) {
+ tBox.parentNode.removeChild(tBox)
+ var elements = document.getElementsByClassName('ui-icon ui-icon-gripsmall-diagonal-se');
+ while (elements.length > 0) {
+ elements[0].parentNode.removeChild(elements[0]);
+ }
+ //var txtTransparencyChange = document.getElementById("txtTransparencyChange");
+ //txtTransparencyChange.value = 0;
+ // document.getElementById('txtLayerNumber').value = 0;
+ // debugger;
+
+
+ $('#layerChangeSlider').slider("option", "value", parseInt($scope.totalLayers) - parseInt($scope.currentLayerNumber));
+ $("#txtlayerNumber").val(parseInt($scope.currentLayerNumber));
+
+
+ if (document.getElementById('tempCanvas') != null) {
+ $('#tempCanvas').remove();
+ }
+ if ($('#speechBubbleTrns').length > 0) {
+ $('#speechBubbleTrns').remove();
+ }
+ //var scope = angular.element(document.getElementById("DAView")).scope();
+ //scope.$apply(function () {
+ // $scope.layerNumber = 0;
+ $scope.isTransparencyActivated = false;
+ //})
+
+
+ var tempCanvases = $("canvas[id*='transparencyTempCanvas']");
+ for (var i = 0; i < tempCanvases.length; i++) {
+ tempCanvases[i].remove();
+ }
+
+ $('.ui-wrapper').remove();
+
+ //$("canvas[name*='transparencyTempCanvas']").nextUntil($("canvas[name*='transparencyTempCanvas']"))
+ //.remove();
+ $scope.layerNumber = $scope.currentLayerNumber;
+ $scope.transNumber = 50;
+ $(".slider").slider({ value: 50 })
+ }
+ $('#transparencyScale').css('visibility', 'hidden');
+
+ $scope.isTransparencyActivated = false;
+ // document.getElementById('btnTranparency').className = 't-transparency'
+ $('#btnTranparency').removeClass('tButtonActive');
+ $('#btnTranparency').addClass('btn-black');
+ $('#btnIdentity').removeClass('btn-black');
+
+ $('#btnIdentity').addClass('btn-primary');
+
+ document.getElementById('btnTranparency').removeEventListener("click", $scope.createTransparencyBox);
+
+ }
+
+ $scope.createSpeechBubbleOnTransparencyBox = function (event, text1, text2, x, y) {
+
+ $('#canvasDiv').css('cursor', 'pointer');
+ $('
'
+ + '
'
+ + '
' + text1 + '
' + text2 + '
'
+ //+'
+ + '
').appendTo('#canvasDiv');
+
+ $('#speechBubbleTrns').on('click', '.BubbleCloseBtn', function (e) {
+ $('#speechBubbleTrns').css('display', 'none');
+ });
+
+ $('#canvasDiv').attr("data-bubbleid", "speechBubble")
+
+
+ };
+
+
+ function positionTooltip(event, x, y) {
+ // alert('positionTooltip')
+ x = 100,
+ y = 200,
+
+ $('div.speech-bubble').css({
+ 'position': 'absolute', 'top': x, 'left': y, 'background-color': '#f8f8f8',
+ 'border': '2px solid #c8c8c8', 'width': '150px', 'height': '50px'
+ });
+
+
+ $('.arrow').css({
+ 'border-style': 'solid',
+ 'position': 'absolute'
+ });
+
+ $('.bottom').css({
+ 'border-color': '#c8c8c8 transparent transparent transparent',
+ 'border-width': ' 8px 8px 0px 8px',
+ 'bottom': -'8px'
+ })
+ };
+
+
+ $scope.OnIdentityClick = function () {
+
+
+ //if listanager is visisble then close it
+
+ $rootScope.isListManagerSelected = false;
+ $rootScope.CloseListManager();
+ // $('#btnIdentity').addClass('btn-primary');
+
+ if ($scope.isTransparencyActivated == true) {
+
+ $scope.isTransparencyActivated = false;
+
+ var canvasDiv = document.getElementById('canvasDiv');
+ canvasDiv.removeEventListener("mousedown", mouseDownListener);
+
+ canvasDiv.removeEventListener("mousemove", mouseMoveListener);
+
+ canvasDiv.removeEventListener("mouseup", mouseUpListener)
+ $('#btnTranparency').removeClass('tButtonActive');
+ $('#btnTranparency').addClass('btn-black');
+ }
+
+ }
+
+ $scope.enableZoom = function () {
+
+
+ //if listanager is visisble then close it
+
+ $rootScope.isListManagerSelected = false;
+ $rootScope.CloseListManager();
+
+ $('#sppeachBubble').css('display', 'none');
+
+ $("#dot").css("display", "none");
+
+ $scope.terminateCurrentlyRunningWPs();
+
+ if ($scope.isTransparencyActivated) {
+
+ $scope.CloseTransparencyBox();
+
+ }
+
+ $rootScope.isZoomed = true;
+ //1.
+
+ $scope.flushCanvas();
+
+ if ($scope.zoomInOut == 25) {
+ $scope.zoomInOut = 75;
+
+ }
+ else {
+ $scope.zoomInOut = 25;
+ }
+
+ //2.
+ $scope.CalculateImageCordinates($rootScope.viewOrientationId);
+
+ //3.
+ if ($scope.zoomInOut == 25)
+ $('#canvasDiv').scrollLeft(0)
+ else
+ $('#canvasDiv').scrollLeft($('#canvasDiv').width() / 2)
+
+ //remove annotation speech bubble
+ if ($('#dot').length > 0) {
+ $('#dot').remove();
+ }
+
+ if ($('#sppeachBubble').length > 0) {
+ $('#sppeachBubble').remove();
+ }
+
+ //4.
+ if ($rootScope.isHighLight == true) {
+
+ $timeout(function () { $scope.highLightBody() }, 50);
+ }
+ }
+
+
+ $scope.flushCanvas = function () {
+
+ //if ($scope.ColoredImageSRC != null || $scope.ColoredImageSRC != undefined) {
+ // angular.forEach($scope.ColoredImageSRC, function (value, key) {
+
+ // var id;
+ // var maskId;
+ // if (value.haveMirror == 'true') {
+ // id = 'imageCanvas' + value.bodyRegionId + '_MR';
+ // maskId = 'imageCanvas' + value.bodyRegionId + '_MR_mci'
+ // }
+ // else {
+ // id = 'imageCanvas' + value.bodyRegionId;
+ // maskId = 'imageCanvas' + value.bodyRegionId + '_mci';
+ // }
+
+ // var canvas = document.getElementById(id);
+ // if (canvas != null || canvas != undefined) {
+ // document.getElementById('canvasDiv').removeChild(canvas);
+ // }
+
+ // var maskcanvas = document.getElementById(maskId);
+ // if (maskcanvas != null || maskcanvas != undefined) {
+ // document.getElementById('canvasDiv').removeChild(maskcanvas);
+
+ // }
+ // if (i == 4 || i == 5 || i == 6) {
+ // id = 'imageCanvas' + i + '_MR';
+ // maskId = 'imageCanvas' + i + '_MR_mci';
+
+ // var canvas = document.getElementById(id);
+ // if (canvas != null || canvas != undefined)
+ // document.getElementById('canvasDiv').removeChild(canvas);
+
+ // var maskcanvas = document.getElementById(maskId);
+ // if (maskcanvas != null || maskcanvas != undefined)
+ // document.getElementById('canvasDiv').removeChild(maskcanvas);
+ // }
+
+ // var modestyCanvases = $("canvas[id*='imageCanvasmodestyImg']");
+ // for (var i = 0; i < modestyCanvases.length; i++) {
+ // modestyCanvases[i].remove();
+ // }
+ // });
+ // //remove modesty canavs
+ // var modestyCanvases = $("canvas[id*='imageCanvasmodestyImg']");
+ // if (modestyCanvases != null || modestyCanvases != undefined && modestyCanvases.length > 0) {
+ // for (var j = 0; j < modestyCanvases.length; j++) {
+ // modestyCanvases[j].remove();
+ // }
+ // }
+ //}
+
+ for (var i = 1; i < 7; i++) {
+
+ var id;
+ var maskId;
+
+ id = 'imageCanvas' + i;
+ maskId = 'imageCanvas' + i + '_mci';
+
+ var canvas = document.getElementById(id);
+ if (canvas != null || canvas != undefined)
+ document.getElementById('canvasDiv').removeChild(canvas);
+
+ var maskcanvas = document.getElementById(maskId);
+ if (maskcanvas != null || maskcanvas != undefined)
+ document.getElementById('canvasDiv').removeChild(maskcanvas);
+
+ if (i == 4 || i == 5 || i == 6) {
+ id = 'imageCanvas' + i + '_MR';
+ maskId = 'imageCanvas' + i + '_MR_mci';
+
+ var canvas = document.getElementById(id);
+ if (canvas != null || canvas != undefined)
+ document.getElementById('canvasDiv').removeChild(canvas);
+
+ var maskcanvas = document.getElementById(maskId);
+ if (maskcanvas != null || maskcanvas != undefined)
+ document.getElementById('canvasDiv').removeChild(maskcanvas);
+ }
+
+ //remove modesty canavs
+ var modestyCanvases = $("canvas[id*='imageCanvasmodestyImg']");
+ if (modestyCanvases != null || modestyCanvases != undefined && modestyCanvases.length > 0) {
+ for (var j = 0; j < modestyCanvases.length; j++) {
+ modestyCanvases[j].remove();
+ }
+ }
+ }
+ }
+
+ $scope.terminateCurrentlyRunningWPs = function () {
+ if ($scope.runningWorkers != null || $scope.runningWorkers != undefined) {
+ var workerCount = $scope.runningWorkers.length;
+ if (workerCount > 0) {
+ for (var i = workerCount - 1; i >= 0; i--) {
+ var runningWorker = $scope.runningWorkers[i].workerName;
+ runningWorker.terminate();
+ $scope.runningWorkers.splice(i, 1);
+ // workerCount--;
+ }
+ }
+ }
+ }
+
+
+ $scope.enableHighlight = function () {
+
+
+
+
+ //if listanager is visisble then close it
+
+ // $rootScope.isListManagerSelected = false;
+ $rootScope.CloseListManager();
+
+ if ($rootScope.isHighLight == true) {
+
+ }
+ else {
+ $rootScope.isHighLight = true;
+ $rootScope.isNormalMode = false;
+ $rootScope.isZoomed = false;
+
+ if ($rootScope.isExtract == true) {
+ //1.
+ $rootScope.isExtract = false;
+
+ //2.
+ $scope.flushCanvas();
+
+ //3.
+ $scope.CalculateImageCordinates($rootScope.viewOrientationId);
+
+
+ }
+ else {
+ console.log('highLightBody from enableHighlight')
+ $timeout(function () { $scope.highLightBody() }, 50);
+ }
+
+ }
+
+ // unhighlight other
+
+ //$scope.Normal = "";
+ //$scope.Extract = "";
+ //$scope.Highlight = "LeftButtonsDefaultState";
+
+ $("#btnHighLight").addClass("btn-primary");
+ $("#btnHighLight").removeClass("btn-black");
+
+ if (!$("#btnNormalMode").hasClass("btn-black")) {
+ $("#btnNormalMode").addClass("btn-black");
+ }
+
+ if (!$("#btnExtract").hasClass("btn-black")) {
+ $("#btnExtract").addClass("btn-black");
+ }
+
+ if ($("#btnExtract").hasClass("btn-primary")) {
+ $("#btnExtract").removeClass("btn-primary");
+ }
+
+ if ($("#btnNormalMode").hasClass("btn-primary")) {
+ $("#btnNormalMode").removeClass("btn-primary");
+ }
+ }
+
+ $scope.enableNormalMode = function () {
+
+
+ //if listanager is visisble then close it
+
+ // $rootScope.isListManagerSelected = false;
+ $rootScope.CloseListManager();
+
+ if ($rootScope.isNormalMode == true) {
+
+ }
+ else {
+
+ //1.
+ $scope.flushCanvas();
+
+ //2.
+ $rootScope.isNormalMode = true;
+
+ //3.
+ $rootScope.isHighLight = false;
+
+ //4.
+ $rootScope.isExtract = false;
+
+ //5.
+ $rootScope.isZoomed = false;
+
+ //6.
+ $scope.CalculateImageCordinates($rootScope.viewOrientationId);
+
+
+ }
+
+ //$scope.Normal = "LeftButtonsDefaultState";
+ //$scope.Extract = "";
+ //$scope.Highlight = "";
+ $("#btnNormalMode").addClass("btn-primary");
+ $("#btnNormalMode").removeClass("btn-black");
+
+ if (!$("#btnExtract").hasClass("btn-black")) {
+ $("#btnExtract").addClass("btn-black");
+ }
+
+ if (!$("#btnHighLight").hasClass("btn-black")) {
+ $("#btnHighLight").addClass("btn-black");
+ }
+
+ if ($("#btnExtract").hasClass("btn-primary")) {
+ $("#btnExtract").removeClass("btn-primary");
+ }
+
+ if ($("#btnHighLight").hasClass("btn-primary")) {
+ $("#btnHighLight").removeClass("btn-primary");
+ }
+ }
+
+ $scope.enableExtract = function () {
+
+
+
+ //if listanager is visisble then close it
+
+ // $rootScope.isListManagerSelected = false;
+ $rootScope.CloseListManager();
+ //1.
+ $rootScope.isLoading = true;
+ $('#spinner').css('visibility', 'visible');
+
+ //2.
+ $scope.terminateCurrentlyRunningWPs();
+
+ //3.
+ if ($rootScope.isExtract == true) {
+
+ }
+ else {
+ $rootScope.isExtract = true;
+
+
+ if ($rootScope.isNormalMode == true) {
+
+ $rootScope.isHighLight = false;
+ $rootScope.isNormalMode = false;
+ }
+ else {
+ $rootScope.isNormalMode = false;
+ $rootScope.isHighLight = false;
+ }
+
+ //4.
+ console.log('highLightBody from enableExtract')
+ $scope.highLightBody();
+
+
+ }
+
+ //5. unhighlight other
+ //$scope.Normal = "";
+ //$scope.Extract = "LeftButtonsDefaultState";
+ //$scope.Highlight = "";
+
+ $("#btnExtract").addClass("btn-primary");
+ $("#btnExtract").removeClass("btn-black");
+
+ if (!$("#btnNormalMode").hasClass("btn-black")) {
+ $("#btnNormalMode").addClass("btn-black");
+ }
+
+ if (!$("#btnHighLight").hasClass("btn-black")) {
+ $("#btnHighLight").addClass("btn-black");
+ }
+
+ if ($("#btnNormalMode").hasClass("btn-primary")) {
+ $("#btnNormalMode").removeClass("btn-primary");
+ }
+
+ if ($("#btnHighLight").hasClass("btn-primary")) {
+ $("#btnHighLight").removeClass("btn-primary");
+ }
+ }
+
+ $scope.enableShowHideStructureBox = function () {
+
+
+ //if listanager is visisble then close it
+
+ $rootScope.isListManagerSelected = false;
+ $rootScope.CloseListManager();
+
+ $(".com").toggle();
+ $('#dot').toggle();
+ $('#sppeachBubble').toggle()
+ }
+
+
+
+ $scope.highLightBody = function () {
+
+ $scope.Normal = "";
+ $scope.Extract = "";
+ $scope.Highlight = "LeftButtonsDefaultState";
+
+ console.log('highLightBody is called and ColoredImageSRC length: ' + $scope.ColoredImageSRC.length);
+
+ $scope.terminateCurrentlyRunningWPs();
+
+ //different body views have different count of bodyegions so the length of ColoredImageSRC will be different
+ if (($scope.ColoredImageSRC != null || $scope.ColoredImageSRC != undefined)) {
+
+ if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.ColoredImageSRC.length == 9)) {
+ $scope.doHighlightOrExtract = true;
+ }
+ else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.ColoredImageSRC.length == 5)) {
+ $scope.doHighlightOrExtract = true;
+ }
+ else if ((($rootScope.viewOrientationId == '5')) && ($scope.ColoredImageSRC.length == 4)) {
+ $scope.doHighlightOrExtract = true;
+ }
+ else if ((($rootScope.viewOrientationId == '6')) && ($scope.ColoredImageSRC.length == 1)) {
+ $scope.doHighlightOrExtract = true;
+ }
+ else {
+ $scope.doHighlightOrExtract = false;
+ }
+
+
+ if ($scope.doHighlightOrExtract == true) {
+ if ($rootScope.isHighLight == true) {
+
+ $scope.grayedBR = [];
+
+ angular.forEach($scope.ColoredImageSRC, function (value, key) {
+ console.log('$scope.ColoredImageSRC length before gray= ' + $scope.ColoredImageSRC.length)
+ var id;
+ if (value.haveMirror == 'true') {
+ id = 'imageCanvas' + value.bodyRegionId + '_MR';
+ }
+ else {
+ id = 'imageCanvas' + value.bodyRegionId;
+ }
+
+ var imageCanvas = document.getElementById(id);
+
+ var width = value.Width;
+ var ht = value.Height;
+
+ var coloredCanvasContext = imageCanvas.getContext("2d");
+ var coloredImageData = coloredCanvasContext.getImageData(0, 0, width, ht);
+ var coloredImageDataVar = coloredImageData;
+
+
+ if (value.haveMirror == 'true') {
+ $rootScope.coloredImageMRCanvasList[parseInt(value.bodyRegionId)] = coloredImageDataVar;
+ }
+ else {
+
+
+ $rootScope.coloredImageCanvasList[parseInt(value.bodyRegionId - 1)] = coloredImageDataVar;
+
+ }
+
+
+ var context_gray = imageCanvas.getContext('2d');
+
+ var dataURL = imageCanvas.toDataURL();
+
+
+ var img = new Image();
+
+ img.src = dataURL;
+
+ img.onload = function () {
+ console.log('Before BitmapData call, width: ' + Math.max(img.width) + ', height: ' + Math.max(img.height) + ' value.bodyRegionId= '
+ + value.bodyRegionId)
+
+ var DAData = new BitmapData(Math.max(img.width), Math.max(img.height));
+ DAData.draw(img);
+
+ var colorMode;
+
+ if ($scope.isExtract == true) {
+ colorMode = $scope.applyWhiteMatrix(img, context_gray);
+ }
+ else {
+ colorMode = $scope.applyGrayMatrix(img, context_gray);
+ }
+
+ var zeroPoint = new Point();
+
+ DAData.applyFilter(DAData, DAData.rect, zeroPoint, colorMode);
+
+
+ context_gray.putImageData(DAData.data, 0, 0)
+
+ //NIKI- to resolve lateral arm black issue in highlight mode
+
+ if ($rootScope.viewOrientationId == 5 && (value.bodyRegionId == 6 || value.bodyRegionId == 4)) {
+
+ var imgData = context_gray.getImageData(0, 0, width, ht);
+ var data = imgData.data;
+ var c = 0;
+ for (var i = 0; i < data.length; i += 4) {
+ if (data[i] == data[i + 1] && data[i + 1] == data[i + 2] && data[i + 2] === 0) {
+ data[i + 3] = 0;
+ }
+
+ }
+ context_gray.putImageData(imgData, 0, 0);
+ }
+
+ //push BRID into array
+ $scope.grayedBR.push({ 'BRID': value.bodyRegionId });
+
+ var grayImageData = context_gray.getImageData(0, 0, width, ht);
+ var grayImageImageDataVar = grayImageData.data;
+
+ if ($scope.isExtract == true) {
+ if (value.haveMirror == 'true') {
+ $rootScope.whiteImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData;
+ }
+ else {
+
+ $rootScope.whiteImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData;
+ }
+ }
+ else {
+
+ if (value.haveMirror == 'true') {
+ $rootScope.grayImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData;
+ }
+ else {
+
+ $rootScope.grayImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData;
+ }
+ }
+
+
+ if ($scope.grayedBR != null || $scope.grayedBR != undefined) {
+ if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.grayedBR.length == 9)) {
+ $scope.isEligibleForHighlightBodyByTermList = true;
+ $scope.doHighlightOrExtract = false;
+ }
+ else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.grayedBR.length == 5)) {
+ $scope.isEligibleForHighlightBodyByTermList = true;
+ $scope.doHighlightOrExtract = false;
+ }
+ else if ((($rootScope.viewOrientationId == '5')) && ($scope.grayedBR.length == 4)) {
+ $scope.isEligibleForHighlightBodyByTermList = true;
+ $scope.doHighlightOrExtract = false;
+ }
+ else if ((($rootScope.viewOrientationId == '6')) && ($scope.grayedBR.length == 1)) {
+ $scope.isEligibleForHighlightBodyByTermList = true;
+ $scope.doHighlightOrExtract = false;
+ }
+ else {
+
+ $scope.isEligibleForHighlightBodyByTermList = false;
+ }
+
+ if ($scope.isEligibleForHighlightBodyByTermList == true) {
+ //DISABLE PROGERSS BAR FOR GENDER OR VIEW CHANGE
+ // if ($rootScope.isGenderChnage == true || $rootScope.isViewChange == true) {
+ $scope.isLoading = false;
+
+ $('#spinner').css('visibility', 'hidden');
+ //}
+
+
+ if (($scope.isHighlightBodyByBodySystem == true) && ($scope.systemMatchedTermList != null || $scope.systemMatchedTermList != undefined)) {
+
+
+ $scope.isLoading = true;
+
+ $('#spinner').css('visibility', 'visible');
+ $timeout(function () { $scope.HighlightBodyByTermList($scope.systemMatchedTermList) }, 100);
+ }
+ else if ($rootScope.isListManagerSelected == true) {
+
+ // console.log('$scope.grayedBR.length is ' + $scope.grayedBR.length);
+ $timeout(function () {
+
+ $scope.HighlightBodyByTermList($scope.AllTerms)
+ }, 800);
+
+ }
+ else if (($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined) && $rootScope.previousHighlightList.length > 0) {
+ $scope.createTermListByPreviousTermsAndHighlight();
+ }
+
+ }
+
+ }
+
+ }
+
+ $timeout(function () { imageCanvas.style.visibility = 'visible' }, 50);
+
+
+ if ($rootScope.isExtract == true) {
+ if (($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined) && $rootScope.previousHighlightList.length > 0) {
+ console.log('1. $rootScope.isExtract=true and $rootScope.previousHighlightList != null')
+
+ $timeout(function () { $scope.HighlightBodyOnExtract() }, 50);
+ }
+ else if ($rootScope.isListManagerSelected == true) {
+ console.log('1. $rootScope.isExtract=true and $rootScope.isListManagerSelected == true')
+
+ $timeout(function () { $scope.HighlightBodyOnExtract() }, 50);
+
+ }
+ }
+ //else {
+ // // this code is for the case where user first clcik on normal mode then extract then again highlight then we need to call highlight body in gray mode
+ // //and then highlight the previously selected body regions at the time of normal mode.
+ // if ($scope.grayedBR != null || $scope.grayedBR != undefined) {
+ // if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.grayedBR.length == 9)) {
+ // $scope.isEligibleForHighlightBodyByTermList = true;
+ // }
+ // else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.grayedBR.length == 5)) {
+ // $scope.isEligibleForHighlightBodyByTermList = true;
+ // }
+ // else if ((($rootScope.viewOrientationId == '5')) && ($scope.grayedBR.length == 4)) {
+ // $scope.isEligibleForHighlightBodyByTermList = true;
+ // }
+ // else if ((($rootScope.viewOrientationId == '6')) && ($scope.grayedBR.length == 1)) {
+ // $scope.isEligibleForHighlightBodyByTermList = true;
+ // }
+
+
+ // }
+
+ // //
+ //}
+ })
+
+ //if ($scope.isEligibleForHighlightBodyByTermList == true) {
+ // if (($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined) && $rootScope.previousHighlightList.length > 0) {
+
+ // var multiTermList = [];
+ // angular.forEach($rootScope.previousHighlightList, function (value, key) {
+
+ // //debugger;
+
+ // var ActualTermNo = $scope.getActualTermNumber(value);
+ // if (ActualTermNo != null) {
+ // var TermList = $scope.getTermNumberList(ActualTermNo);
+ // if (TermList != null) {
+ // for (var i = 0; i < TermList.length; i++) {
+
+ // multiTermList.push(TermList[i]);
+ // }
+ // }
+ // }
+
+ // });
+ // console.log('HighlightBodyByTermList call with multiTermList')
+
+ // $timeout(function () { $scope.HighlightBodyByTermList(multiTermList) }, 80);
+ // }
+ //}
+
+ }
+
+
+ else {
+ // This code will execute when user will select normal Mode but this time isHighlight will be false
+
+ angular.forEach($scope.ColoredImageSRC, function (value, key) {
+ var id;
+ if (value.haveMirror == 'true') {
+ id = 'imageCanvas' + value.bodyRegionId + '_MR';
+ }
+ else {
+ id = 'imageCanvas' + value.bodyRegionId;
+ }
+
+ var imageCanvas = document.getElementById(id);
+
+ //var coloredCanvasID = 'imageCanvas' + bodyRegionId;
+ //var coloredCanvas = document.getElementById(coloredCanvasID);
+
+ var width = value.Width;
+ var ht = value.Height;
+
+ var coloredCanvasContext = imageCanvas.getContext("2d");
+ var coloredImageData = coloredCanvasContext.getImageData(0, 0, width, ht);
+ var coloredImageDataVar = coloredImageData;
+
+
+ if (value.haveMirror == 'true') {
+ $rootScope.coloredImageMRCanvasList[parseInt(value.bodyRegionId)] = coloredImageDataVar;
+ }
+ else {
+
+ $rootScope.coloredImageCanvasList[parseInt(value.bodyRegionId - 1)] = coloredImageDataVar;
+
+ }
+
+
+ var context = imageCanvas.getContext('2d');
+
+
+ var dataURL = imageCanvas.toDataURL();
+
+
+ var img = new Image();
+
+ img.src = dataURL;
+
+
+
+ img.onload = function () {
+ //console.log(Math.max(img.width) + ', ' + Math.max(img.height))
+
+ var DAData = new BitmapData(Math.max(img.width), Math.max(img.height));
+ DAData.draw(img);
+
+ var colorMode;
+
+ if ($scope.isExtract == true) {
+ colorMode = $scope.applyWhiteMatrix(img, context);
+ }
+
+ var zeroPoint = new Point();
+
+ DAData.applyFilter(DAData, DAData.rect, zeroPoint, colorMode);
+
+ context.putImageData(DAData.data, 0, 0)
+
+ var grayImageData = context.getImageData(0, 0, width, ht);
+ var grayImageImageDataVar = grayImageData.data;
+
+ if ($scope.isExtract == true) {
+ if (value.haveMirror == 'true') {
+ $rootScope.whiteImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData;
+ }
+ else {
+
+ $rootScope.whiteImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData;
+ }
+ }
+ else {
+
+ if (value.haveMirror == 'true') {
+ $rootScope.grayImageMRDataList[parseInt(value.bodyRegionId)] = grayImageData;
+ }
+ else {
+
+ $rootScope.grayImageDataList[parseInt(value.bodyRegionId - 1)] = grayImageData;
+ }
+ }
+ }
+
+ $timeout(function () { imageCanvas.style.visibility = 'visible' }, 50);
+ })
+
+ if ($rootScope.isExtract == true) {
+ if (($rootScope.previousHighlightList != null || $rootScope.previousHighlightList != undefined) && $rootScope.previousHighlightList.length > 0) {
+ console.log('2. $rootScope.isExtract=true and $rootScope.previousHighlightList != null, $rootScope.previousHighlightList.length= ' + $rootScope.previousHighlightList.length)
+
+
+ $timeout(function () { $scope.HighlightBodyOnExtract() }, 50);
+
+ // to do
+
+ }
+ else if ($rootScope.isListManagerSelected == true) {
+ console.log('2. $rootScope.isExtract=true and $rootScope.isListManagerSelected == true')
+ $timeout(function () { $scope.HighlightBodyOnExtract() }, 50);
+
+ }
+ }
+
+ }
+ }
+ }
+ }
+
+
+ $scope.applyGrayMatrix = function (img, context_gray) {
+ var RED = 0.3086; // luminance contrast value for red
+ var GREEN = 0.694; // luminance contrast value for green
+ var BLUE = 0.0820; // luminance contrast value for blue
+
+ var RGB = [RED, GREEN, BLUE, 0, 0];
+ var RGB2 = [RED, GREEN, BLUE, 0, 0];
+ var RGB3 = [RED, GREEN, BLUE, 0, 0];
+ var ALPHA = [0, 0, 0, 1, 0];
+
+ var rgbPx = RGB.concat(RGB2);
+ var rgbPx2 = rgbPx.concat(RGB3);
+ var matrix = rgbPx2.concat(ALPHA);
+
+
+ var grayScale = new ColorMatrixFilter(matrix);
+
+ return grayScale;
+ }
+
+ $scope.applyWhiteMatrix = function (img, context_gray) {
+ var RED = 255; // white color value for red
+ var GREEN = 255; // white color value for green
+ var BLUE = 255; // white color value for blue
+
+ var RGB = [RED, GREEN, BLUE, 0, 0];
+ var RGB2 = [RED, GREEN, BLUE, 0, 0];
+ var RGB3 = [RED, GREEN, BLUE, 0, 0];
+ var ALPHA = [0, 0, 0, 1, 0];
+
+ var rgbPx = RGB.concat(RGB2);
+ var rgbPx2 = rgbPx.concat(RGB3);
+ var matrix = rgbPx2.concat(ALPHA);
+
+
+ var grayScale = new ColorMatrixFilter(matrix);
+
+ return grayScale;
+ }
+
+ $scope.getActualTermNumber = function (iColor) {
+ $scope.actualTermNo = new jinqJs()
+ .from($rootScope.TermNumberData.TermData.Term)
+ .where('_TermNumber == ' + iColor)
+ .select('_ActualTermNumber');
+ if ($scope.actualTermNo != null || actualTermNo != undefined) {
+
+ return $scope.actualTermNo[0]._ActualTermNumber;
+ }
+ else {
+ return null;
+ }
+ }
+
+ $scope.getTermNumberList = function (actualTermNo) {
+ $scope.termList = new jinqJs()
+ .from($rootScope.TermNumberData.TermData.Term)
+ .where('_ActualTermNumber == ' + actualTermNo)
+ .select();
+ if ($scope.termList != null || $scope.termList != undefined) {
+ return $scope.termList;
+ }
+ else {
+ return null;
+ }
+
+ }
+
+
+ $scope.OnGenderChange = function (event) {
+
+ //if listanager is visisble then close it
+
+ $rootScope.isListManagerSelected = false;
+ $rootScope.CloseListManager();
+
+ $rootScope.isLoading = true;
+ $('#spinner').css('visibility', 'visible');
+
+ $rootScope.isGenderChnage = true;
+
+ var viewname = localStorage.getItem("currentViewTitle")
+ var currentBodyViewId = $scope.correspondingBodyViewIds[$rootScope.voId];
+
+ if ((event.currentTarget.attributes[1].value == 'Male') && (localStorage.getItem("genderId") == 'Female')) {
+
+ //1.
+ localStorage.setItem("genderId", 'Male');
+
+ //2 first update the currentbodyviewid in local storage
+ localStorage.setItem("currentBodyViewId", currentBodyViewId);
+
+ //3.
+ $scope.loadSelectedBodyView(currentBodyViewId);
+
+ //4.
+ $scope.loadSelectedBodyViewNavigator(currentBodyViewId);
+
+ //5. change the search terms as per the selected bodyview
+ $scope.loadSearchDataForBodyView();
+
+ //6.
+ $('#daImagePanel')[0].childNodes[0].childNodes[0].innerHTML = localStorage.getItem("currentViewTitle").replace('Female', 'Male');
+
+ localStorage.setItem("currentViewTitle", localStorage.getItem("currentViewTitle").replace('Female', 'Male'));
+
+
+ $rootScope.isLoading = true;
+
+ }
+
+ else if ((event.currentTarget.attributes[1].value == 'Female') && (localStorage.getItem("genderId") == 'Male')) {
+
+ //1.
+ localStorage.setItem("genderId", 'Female');
+
+ //2. first update the currentbodyviewid in local storage
+ localStorage.setItem("currentBodyViewId", currentBodyViewId);
+
+ //3.
+ $scope.loadSelectedBodyView(currentBodyViewId);
+
+ //4.
+ $scope.loadSelectedBodyViewNavigator(currentBodyViewId);
+
+ //5. change the search terms as per the selected bodyview
+ $scope.loadSearchDataForBodyView();
+
+ //6.
+ $('#daImagePanel')[0].childNodes[0].childNodes[0].innerHTML = localStorage.getItem("currentViewTitle").replace('Male', 'Female');
+
+ localStorage.setItem("currentViewTitle", localStorage.getItem("currentViewTitle").replace('Male', 'Female'));
+
+
+ $rootScope.isLoading = true;
+
+ }
+
+ $rootScope.openViews.push(
+ {
+ "module": $rootScope.currentActiveModuleTitle, "body-views": localStorage.getItem("currentViewTitle"), "state": 'max', "BodyViewId": currentBodyViewId,
+ "slug": $rootScope.currentSlug
+ }
+ );
+
+ var target = angular.element(event.currentTarget);
+ var title_male_female = target.attr('title');
+
+ if (title_male_female == "Male") {
+
+ $scope.male = "active";
+ $scope.female = "";
+ }
+ else {
+ $scope.male = "";
+ $scope.female = "active";
+ }
+
+ }
+
+
+ //clsoe worker process
+ $scope.$on('jsPanelCloseEvent', function (event, data) {
+
+
+
+ console.log('terminate worker process')
+ //terminate previous running workers to create space for new workers
+ $scope.terminateCurrentlyRunningWPs();
+
+ $rootScope.isLoading = false;
+ $('#spinner').css('visibility', 'hidden');
+
+ //To fix issue of gray maintained in after closing jspanel after listmanager selection
+ $rootScope.isListManagerSelected = false;
+ $rootScope.isHighLight = false;
+ $rootScope.isNormalMode = false;
+ $rootScope.CloseListManager();
+ })
+
+ $scope.loadSelectedBodyView = function (currentBodyViewId) {
+
+ //remove transaprency scale
+ if ($('#transparencyScale') != null) {
+
+ $('#transparencyScale').css('visibility', 'hidden');
+ }
+
+
+ $rootScope.voId = currentBodyViewId;
+
+ var layerJsonPath = '~/../content/data/json/da/body-views/' + currentBodyViewId + '/da_dat_layer_' + currentBodyViewId + '.json';
+
+ DataService.getJson(layerJsonPath)
+ .then(
+ function (result) {
+ //debugger;
+
+ $rootScope.BodyLayerData = result;
+ $scope.isBodylayerdataLoaded = true;
+
+ //load json for annotations
+ // $http({ method: 'GET', url: '~/../content/data/json/da_dat_tm_sg_1.json' }).success(function (data) {
+ var termJsonPath = '~/../content/data/json/da/body-views/' + currentBodyViewId + '/da_dat_tm_sg_' + currentBodyViewId + '.json';
+ DataService.getAnotherJson(termJsonPath)
+ .then(
+ function (result) {
+ $rootScope.TermNumberData = result;
+
+ var canDiv = document.getElementById('canvasDiv');
+ var canDivChildCount = canDiv.childElementCount;
+ if (canDivChildCount > 0) {
+ canDiv.innerHTML = '';
+ }
+ $scope.CalculateImageCordinates($rootScope.viewOrientationId);
+ $scope.currentTitleFromJson = localStorage.getItem("currentViewTitle");
+ },
+ function (error) {
+ // handle errors here
+ console.log(' $rootScope.TermNumberData= ' + error.statusText);
+ }
+ )
+ },
+
+ function (error) {
+ // handle errors here
+ console.log(' $rootScope.BodyLayerData= ' + error.statusText);
+ }
+ );
+ }
+
+ $scope.OnViewChange = function (event) {
+
+ //if listanager is visisble then close it
+
+ $rootScope.isListManagerSelected = false;
+ $rootScope.CloseListManager();
+
+
+ $rootScope.isLoading = true;
+ $('#spinner').css('visibility', 'visible');
+
+
+ if ($rootScope.openViews.length > 0) {
+ $rootScope.openViews.splice($rootScope.openViews.length - 1);
+ }
+
+ $rootScope.isViewChange = true;
+ $scope.layerNumber = 0;
+ // debugger;
+ var selectedViewId = $scope.bodyViews[event.currentTarget.attributes[1].value];
+ $rootScope.viewOrientationId = selectedViewId;
+ if (localStorage.getItem("genderId") == 'Male') {
+ if ($rootScope.voId != selectedViewId) {
+ if (selectedViewId == 5) {
+ $rootScope.voId = 9;
+ }
+ else if (selectedViewId == 6) {
+ $rootScope.voId = 10;
+ }
+ else
+ $rootScope.voId = selectedViewId;
+ $rootScope.isLoading = true;
+
+ //1. first update the currentbodyviewid in local storage
+ localStorage.setItem("currentBodyViewId", $rootScope.voId);
+
+ //2. Load selected body view
+ $scope.loadSelectedBodyView($rootScope.voId);
+
+ //3. load corresponding navigator man
+ $scope.loadSelectedBodyViewNavigator($rootScope.voId);
+
+ //4. change the search terms as per the selected bodyview
+ $scope.loadSearchDataForBodyView();
+
+ //5.Change the popup title next to search
+ $scope.currentTitleFromJson = localStorage.getItem("currentViewTitle");
+
+ };
+
+
+ //set selected view name as the title of jspanel
+ // $('#daImagePanel')[0].childNodes[0].childNodes[0].innerHTML = localStorage.getItem("genderId") +" "+ event.currentTarget.attributes[1].value;
+
+ }
+ else {
+ if (selectedViewId == 5) {
+ selectedViewId = 11;
+ }
+ else if (selectedViewId == 6) {
+ selectedViewId = 12;
+ }
+ else
+ selectedViewId = $scope.correspondingBodyViewIds[selectedViewId];;
+ if ($rootScope.voId != selectedViewId) {
+ $rootScope.voId = selectedViewId;
+ $rootScope.isLoading = true;
+
+ //1.
+ $scope.loadSelectedBodyView($rootScope.voId);
+
+ //2.
+ $scope.loadSelectedBodyViewNavigator($rootScope.voId);
+ };
+
+
+ // $('#daImagePanel')[0].childNodes[0].childNodes[0].innerHTML = localStorage.getItem("genderId") + " " + $scope.bodyViews[event.currentTarget.attributes[1].value;
+
+ }
+ $('#daImagePanel')[0].childNodes[0].childNodes[0].innerHTML = localStorage.getItem("genderId") + " " + event.currentTarget.attributes[1].value;
+ localStorage.setItem("currentViewTitle", localStorage.getItem("genderId") + " " + event.currentTarget.attributes[1].value);
+
+
+ $rootScope.openViews.push(
+ {
+ "module": $rootScope.currentActiveModuleTitle, "body-views": localStorage.getItem("currentViewTitle"), "state": 'max', "BodyViewId": $rootScope.voId,
+ "slug": $rootScope.currentSlug
+ }
+ );
+
+ var viewtarget = angular.element(event.currentTarget);
+ var title_drop_view = viewtarget.attr('title');
+
+ if (title_drop_view == "Anterior") {
+
+ $scope.AnteriorView = "active";
+ $scope.LateralView = "";
+ $scope.MedialView = "";
+ $scope.PosteriorView = "";
+ $scope.LateralArmView = "";
+ $scope.MedialArmView = "";
+
+ }
+ else if (title_drop_view == "Lateral") {
+
+ $scope.AnteriorView = "";
+ $scope.LateralView = "active";
+ $scope.MedialView = "";
+ $scope.PosteriorView = "";
+ $scope.LateralArmView = "";
+ $scope.MedialArmView = "";
+ }
+ else if (title_drop_view == "Medial") {
+
+ $scope.AnteriorView = "";
+ $scope.LateralView = "";
+ $scope.MedialView = "active";
+ $scope.PosteriorView = "";
+ $scope.LateralArmView = "";
+ $scope.MedialArmView = "";
+ }
+ else if (title_drop_view == "Posterior") {
+
+ $scope.AnteriorView = "";
+ $scope.LateralView = "";
+ $scope.MedialView = "";
+ $scope.PosteriorView = "active";
+ $scope.LateralArmView = "";
+ $scope.MedialArmView = "";
+ }
+ else if (title_drop_view == "Lateral Arm") {
+
+ $scope.AnteriorView = "";
+ $scope.LateralView = "";
+ $scope.MedialView = "";
+ $scope.PosteriorView = "";
+ $scope.LateralArmView = "active";
+ $scope.MedialArmView = "";
+ }
+ else if (title_drop_view == "Medial Arm") {
+
+ $scope.AnteriorView = "";
+ $scope.LateralView = "";
+ $scope.MedialView = "";
+ $scope.PosteriorView = "";
+ $scope.LateralArmView = "";
+ $scope.MedialArmView = "active";
+ }
+ }
+
+ //Reload DA controller event listener after setting change
+ $scope.$on('reloadDAControllerEvent', function (event, data) {
+ console.log('reloadDAControllerEvent');
+
+ $scope.loadDissectibleAnatomyData();
+
+ })
+
+ //Reload DA controller Body View after setting Change
+ $scope.$on('reloadDABodyViewEvent', function (event, data) {
+ //console.log('reloadDABodyViewEvent');
+ $scope.layerNumber = parseInt($('#txtlayerNumber').val());
+ //$scope.ReloadBodyViewId = data.reloadDABodyViewId;
+ // $scope.layerNumber = 0;
+ // debugger;
+
+ //console.log('reloadDABodyViewEvent ' + $scope.ReloadBodyViewId);
+
+ //if ($rootScope.isSettingEventAlredayDispachted == true) {
+
+ $scope.loadSelectedBodyView(data.reloadDABodyViewId);
+
+ $scope.loadSelectedBodyViewNavigator(data.reloadDABodyViewId);
+
+ $scope.currentTitleFromJson = localStorage.getItem("currentViewTitle");
+
+ //$rootScope.isSettingEventAlredayDispachted = false;
+ //}
+
+ })
+
+ $scope.loadSelectedBodyViewNavigator = function (currentBodyViewId) {
+
+ //$rootScope.voId = currentBodyViewId;
+
+ //$scope.skinTone = $rootScope.globalSetting.ethnicity;
+
+ if ($scope.NavigatorData != null || $scope.NavigatorData != undefined) {
+ var navdtlOrient = new jinqJs()
+ .from($scope.NavigatorData.Navigtor.ViewOrientation)
+ .where("_ViewOrientationId == " + currentBodyViewId)
+ .select();
+
+
+ if (navdtlOrient != null || navdtlOrient != undefined) {
+
+ var navOrientationdata = new jinqJs()
+ .from(navdtlOrient[0].ImageInfo)
+ .where("_Ethnicity == " + $rootScope.globalSetting.ethnicity)
+ .select();
+
+ if (navOrientationdata != null || navOrientationdata != undefined) {
+
+ $scope.navigatorImage = navOrientationdata;
+
+
+ var navImageModesty;
+
+ angular.forEach($scope.navigatorImage, function (value, key) {
+ if (value._HaveModesty === $rootScope.globalSetting.modesty) {
+ navImageModesty = value._ImageName;
+ }
+ })
+ if (typeof (navImageModesty) === "undefined" || navImageModesty === null) {
+
+ navImageModesty = $scope.navigatorImage[0]._ImageName;
+
+ }
+
+ $scope.navimgsrc = "~/../content/images/DA/ethnicity/body-views/" + $scope.voId + '/' + $rootScope.globalSetting.ethnicity + '/navigator_images/' + navImageModesty;
+ }
+ }
+
+ }
+
+ }
+
+ //Annotation tool event lsitener
+
+ // $scope.drawing = drawing;
+ // $scope.lastX = lastX;
+ // $scope.lastY = lastY;
+ // $scope.currentX;
+ // $scope.currentY;
+ //----Annotation Toolbar: Jcanvas---
+
+ $scope.$on('annotationToolEvent', function (event, data) {
+ $("#canvas").css("display", "block");
+ $("#canvasPaint").css("display", "block");
+
+ $scope.doClick();
+ $rootScope.FreeStylePaint();
+ });
+ $scope.mousePs;
+ function OnPaintCanvasClick(event) {
+
+
+
+ }
+
+
+ $scope.clicked = true;
+ $scope.offsetX1 = 0;
+ $scope.offsetY1 = 0;
+ $scope.x = 0;
+ $scope.y = 0;
+ $scope.doClick = function (event) {
+
+ $scope.clicked = true;
+ // OnPaintCanvasMouseDown(event);
+ canvas.addEventListener('mousedown', $scope.OnPaintCanvasMouseDown, false);
+ canvas.addEventListener('mouseup', $scope.OnPaintCanvasMouseUp, false);
+ // alert("doclick");
+ };
+
+
+
+
+ $scope.mousePressed = false;
+ $scope.lastX; $scope.lastY;
+ var ctx;
+
+ $scope.OnPaintCanvasMouseDown = function (event) {
+
+ var canvasElement = document.getElementById("canvas");
+ var ctx = canvasElement.getContext("2d");
+
+ // var x = event.clientX;
+ // var y = event.clientY;
+ $scope.offsetX1 = 0;
+ $scope.offsetY1 = 0;
+ $scope.offsetX1 = event.offsetX;
+ $scope.offsetY1 = event.offsetY;
+
+ ctx.clearRect(0, 0, 2277, 3248);
+ $scope.clicked = true;
+ }
+
+
+ $rootScope.resetRect = 0;
+ $rootScope.resetLine = 0;
+ $rootScope.resetCircle = 0;
+ $rootScope.resetArrow = 0;
+ $rootScope.resetPin = 0;
+ $rootScope.resetPinArc = 0;
+ $rootScope.ObjectIndex = 0;
+ $rootScope.Object1Index = 0;
+ $rootScope.Object2Index = 0;
+ $rootScope.resetText = 0;
+ $rootScope.resetTextSave = 0;
+ $rootScope.ObjectIndexSave = 0;
+ var arrayRect = {};
+
+
+ var storeLine = '';
+ $rootScope.canvasLayerNameCollection1 = [];
+ $scope.OnPaintCanvasMouseUp = function (event) {
+
+ if (!$scope.clicked) {
+ return;
+ }
+ $scope.clicked = false;
+ $scope.x = 0;
+ $scope.y = 0;
+ $scope.x = parseInt(event.clientX - ($("#canvas").offset().left));
+ $scope.y = parseInt(event.clientY - ($("#canvas").offset().top));
+
+ var canvasElement = document.getElementById("canvas");
+ var ctx = canvasElement.getContext("2d");
+
+ var canvasElement1 = document.getElementById("canvasPaint");
+ var ctx1 = canvasElement1.getContext("2d");
+
+ /* if ($rootScope.shapeType == "FreeStylePaint") {
+ var canvasPaint_zIndex = $('#canvasPaint').css("z-index");
+ var canvas_zIndex = $('#canvas').css("z-index");
+ if (canvas_zIndex > canvasPaint_zIndex) {
+ canvasPaint_zIndex = parseInt(canvas_zIndex) + 1;
+
+ }
+ else {
+ canvasPaint_zIndex = parseInt(canvasPaint_zIndex) + 1;
+ }
+ $('#canvasPaint').css("z-index", canvasPaint_zIndex);
+ $('#canvasPaint').sketch({ defaultColor: "#000", defaultSize: 1 });
+ }
+ else {*/
+ switch ($rootScope.shapeType) {
+
+ case "cursor":
+ // ctx.clearRect(0, 0, 2277, 3248);
+ ctx.beginPath();
+ ctx1.beginPath();
+
+
+ break;
+
+ case "Line":
+
+ $rootScope.resetLine = $rootScope.ObjectIndex++;
+ $('#canvas').addLayer({
+ name: 'Line_' + $rootScope.resetLine,
+ layer: true,
+ type: 'line',
+ draggable: true,
+ strokeStyle: $rootScope.shapestyleborderColor,
+ strokeWidth: $rootScope.shapestyleborderWidth,
+ rounded: true,
+ x1: $scope.offsetX1, y1: $scope.offsetY1,
+ x2: $scope.x, y2: $scope.y,
+
+ click: function (layer) {
+ $rootScope.canvasLayerNameCollection = [];
+ $rootScope.canvasLayerNameCollection.push(layer.name);
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'arc',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ radius: 3
+ }
+ }).drawLayers();
+
+
+ },
+ mouseout: function (layer) {
+ $rootScope.canvasLayerNameCollection = [];
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'arc',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 0,
+ radius: 0
+ }
+
+ }).drawLayers();
+
+ },
+ mouseover: function (layer) {
+
+
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'arc',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ radius: 3
+ }
+ }).drawLayers();
+
+<<<<<<< HEAD
+ case "Rectangle":
+ $rootScope.resetRect = $rootScope.ObjectIndex++;
+
+ $('#canvas').addLayer({
+ layer: true,
+ name: 'Rect_' + $rootScope.resetRect,
+ fillStyle: $rootScope.shapestyleFillColor,
+ type: 'rectangle',
+ draggable: true,
+ strokeStyle: $rootScope.shapestyleborderColor,
+ opacity: $rootScope.shapestyleOpacity,
+ strokeWidth: $rootScope.shapestyleborderWidth,
+ x: $scope.offsetX1, y: $scope.offsetY1,
+ width: $scope.x - $scope.offsetX1,
+ height: $scope.y - $scope.offsetY1,
+
+ resizeFromCenter: false,
+
+ dblclick: function () {
+ $rootScope.backOpacity();
+
+ },
+
+ click: function (layer) {
+ $rootScope.canvasLayerNameCollection = [];
+ $rootScope.canvasLayerNameCollection.push(layer.name);
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ width: 5, height: 5,
+ cornerRadius: 3
+ }
+ }).drawLayers();
+
+ },
+ mouseout: function (layer) {
+ $rootScope.canvasLayerNameCollection = [];
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: 'pink',
+ strokeStyle: 'yellow',
+ strokeWidth: 0,
+ width: 0, height: 0,
+ cornerRadius: 0
+ }
+=======
+ }
+>>>>>>> db0b2ac40dc61ee08fb471800773516967978732
+
+ }).drawLayers();
+ $('.btnCursor').trigger('click');
+ $(".btn-annotation").removeClass("activebtncolor");
+ $('.btnCursor').addClass('activebtncolor');
+ break;
+
+ case "Rectangle":
+ $rootScope.resetRect = $rootScope.ObjectIndex++;
+
+ $('#canvas').addLayer({
+ layer: true,
+ name: 'Rect_' + $rootScope.resetRect,
+ fillStyle: $rootScope.shapestyleFillColor,
+ type: 'rectangle',
+ draggable: true,
+ strokeStyle: $rootScope.shapestyleborderColor,
+ opacity: $rootScope.shapestyleOpacity,
+ strokeWidth: $rootScope.shapestyleborderWidth,
+ x: $scope.offsetX1, y: $scope.offsetY1,
+ width: $scope.x - $scope.offsetX1,
+ height: $scope.y - $scope.offsetY1,
+
+ resizeFromCenter: false,
+
+
+ click: function (layer) {
+ $rootScope.canvasLayerNameCollection = [];
+ $rootScope.canvasLayerNameCollection.push(layer.name);
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ width: 5, height: 5,
+ cornerRadius: 3
+ }
+ }).drawLayers();
+
+ },
+ mouseout: function (layer) {
+ $rootScope.canvasLayerNameCollection = [];
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: 'pink',
+ strokeStyle: 'yellow',
+ strokeWidth: 0,
+ width: 0, height: 0,
+ cornerRadius: 0
+ }
+
+ }).drawLayers();
+
+ },
+ mouseover: function (layer) {
+
+
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ width: 5, height: 5,
+ cornerRadius: 3
+ }
+ }).drawLayers();
+
+ }
+ }).drawLayers();
+
+
+<<<<<<< HEAD
+ case "Circle":
+ // alert($rootScope.shapestyleborderWidth);
+ $rootScope.resetCircle = $rootScope.ObjectIndex++;
+ $('#canvas').addLayer({
+ layer: true,
+ name: 'Circle_' + $rootScope.resetCircle,
+ type: 'ellipse',
+ opacity: $rootScope.shapestyleOpacity,
+ draggable: true,
+ strokeStyle: $rootScope.shapestyleborderColor,
+ strokeWidth: $rootScope.shapestyleborderWidth,
+ fillStyle: $rootScope.shapestyleFillColor,
+ x: $scope.offsetX1, y: $scope.offsetY1,
+ width: ($scope.x - $scope.offsetX1) * 2, height: ($scope.y - $scope.offsetY1) * 2,
+ // Place a handle at each side and each corner
+ handlePlacement: 'both',
+
+
+
+ click: function (layer) {
+ // alert(layer.name);
+ $rootScope.canvasLayerNameCollection = [];
+ $rootScope.canvasLayerNameCollection.push(layer.name);
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'arc',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ radius: 3
+ }
+ }).drawLayers();
+
+ },
+ mouseout: function (layer) {
+ $rootScope.canvasLayerNameCollection = [];
+
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'arc',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 0,
+ // width: 0, height: 0,
+ radius: 0
+ }
+=======
+>>>>>>> db0b2ac40dc61ee08fb471800773516967978732
+
+ $('.btnCursor').trigger('click');
+ $(".btn-annotation").removeClass("activebtncolor");
+ $('.btnCursor').addClass('activebtncolor');
+
+ break;
+
+ case "Circle":
+ // alert($rootScope.shapestyleborderWidth);
+ $rootScope.resetCircle = $rootScope.ObjectIndex++;
+ $('#canvas').addLayer({
+ layer: true,
+ name: 'Circle_' + $rootScope.resetCircle,
+ type: 'ellipse',
+ opacity: $rootScope.shapestyleOpacity,
+ draggable: true,
+ strokeStyle: $rootScope.shapestyleborderColor,
+ strokeWidth: $rootScope.shapestyleborderWidth,
+ fillStyle: $rootScope.shapestyleFillColor,
+ x: $scope.offsetX1, y: $scope.offsetY1,
+ width: ($scope.x - $scope.offsetX1) * 2, height: ($scope.y - $scope.offsetY1) * 2,
+ // Place a handle at each side and each corner
+ handlePlacement: 'both',
+
+
+
+ click: function (layer) {
+ $rootScope.canvasLayerNameCollection = [];
+ $rootScope.canvasLayerNameCollection.push(layer.name);
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'arc',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ radius: 3
+ }
+ }).drawLayers();
+
+ },
+ mouseout: function (layer) {
+ $rootScope.canvasLayerNameCollection = [];
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'arc',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 0,
+ // width: 0, height: 0,
+ radius: 0
+ }
+
+ }).drawLayers();
+
+ },
+ mouseover: function (layer) {
+
+
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'arc',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ // width: 5, height: 5,
+ radius: 3
+ }
+ }).drawLayers();
+
+ }
+ }).drawLayers();
+ $('.btnCursor').trigger('click');
+ $(".btn-annotation").removeClass("activebtncolor");
+ $('.btnCursor').addClass('activebtncolor');
+ break;
+ case "Arrow":
+ $rootScope.resetArrow = $rootScope.ObjectIndex++;
+
+ $('#canvas').drawLine({
+ layer: true,
+ name: 'Arrow_' + $rootScope.resetArrow,
+ draggable: true,
+ strokeStyle: $rootScope.shapestyleborderColor,
+ strokeWidth: $rootScope.shapestyleborderWidth,
+ rounded: true,
+ startArrow: true,
+ arrowRadius: 7,
+ arrowAngle: 90,
+ x1: $scope.offsetX1, y1: $scope.offsetY1,
+ x2: $scope.x, y2: $scope.y,
+
+ click: function (layer) {
+ $rootScope.canvasLayerNameCollection = [];
+ $rootScope.canvasLayerNameCollection.push(layer.name);
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'arc',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ // width: 5, height: 5,
+ radius: 3
+ }
+ }).drawLayers();
+ // $("#canvas").removeLayer(layer.name).drawLayers();
+
+ },
+ mouseout: function (layer) {
+ $rootScope.canvasLayerNameCollection = [];
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'arc',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 0,
+ // width: 0, height: 0,
+ radius: 0
+ }
+
+ }).drawLayers();
+
+ },
+ mouseover: function (layer) {
+
+
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'arc',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ // width: 5, height: 5,
+ radius: 3
+ }
+ }).drawLayers();
+
+ }
+
+ });
+ $('.btnCursor').trigger('click');
+ $(".btn-annotation").removeClass("activebtncolor");
+ $('.btnCursor').addClass('activebtncolor');
+
+<<<<<<< HEAD
+ }
+ }).drawArc({
+ draggable: true,
+ name: "ArcPin_" + $rootScope.resetPinArc,
+ // name: "Pin_" + $rootScope.resetPin,
+ layer: true,
+ groups: ["Pin_" + $rootScope.resetPin],
+ dragGroups: ["Pin_" + $rootScope.resetPin],
+ strokeStyle: 'grey',
+ strokeWidth: 2,
+ fillStyle: radial,
+ x: $scope.offsetX1, y: $scope.offsetY1,
+ radius: 5,
+ //handle: {
+ // type: 'arc',
+ // fillStyle: '#fff',
+ // strokeStyle: '#c33',
+ // strokeWidth: 2,
+ // radius: 3
+ //},
+ add: function (layer) {
+
+ $rootScope.resetPinArc = layer.name;
+ // $scope.arr = [];
+
+
+ },
+
+ }).drawLayers();
+ $('.btnCursor').trigger('click');
+ $(".btn-annotation").removeClass("activebtncolor");
+ $('.btnCursor').addClass('activebtncolor');
+ break;
+ case "TextArea":
+ $rootScope.isTrue = false;
+ $("#text_area").val('');
+ // Draw text
+ $rootScope.resetTextRect = $rootScope.ObjectIndex++;
+ $rootScope.resetText = $rootScope.ObjectIndex++;
+ $('#canvas').drawText({
+ layer: true,
+ draggable: true,
+ // opacity: $rootScope.shapestyleOpacity,
+ name: 'TextArea_' + $rootScope.resetText,
+ groups: ['TextArea_' + $rootScope.resetText],
+ dragGroups: ['TextArea_' + $rootScope.resetText],
+ fillStyle: '#36c',
+ strokeWidth: 0,
+ x: $scope.offsetX1, y: $scope.offsetY1,
+ fontSize: '14pt',
+ align: "left",
+ fontFamily: 'Verdana, sans-serif',
+ text: ''
+
+ })
+ // Draw rect as wide as the text
+ .drawRect({
+ layer: true,
+ name: "TextRect_" + $rootScope.resetTextRect,
+ dragGroups: ['shapes'],
+ opacity: $rootScope.shapestyleOpacity,
+ strokeStyle: $rootScope.shapestyleborderColor,
+ strokeWidth: $rootScope.shapestyleborderWidth,
+ fillStyle: $rootScope.shapestyleFillColor,
+ x: $scope.offsetX1, y: $scope.offsetY1,
+ width: $scope.x - $scope.offsetX1,
+ height: $scope.y - $scope.offsetY1,
+ click: function (layer) {
+
+ $rootScope.canvasLayerNameCollection = [];
+ $rootScope.canvasLayerNameCollection.push(layer.name);
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ width: 5, height: 5,
+ cornerRadius: 3
+ }
+ }).drawLayers();
+
+ },
+ mouseout: function (layer) {
+ $rootScope.canvasLayerNameCollection = [];
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: 'pink',
+ strokeStyle: 'yellow',
+ strokeWidth: 0,
+ width: 0, height: 0,
+ cornerRadius: 0
+ }
+=======
+ // $scope.resetRect += 1;
+ break;
+ case "Pin":
+
+ $rootScope.resetPin = $rootScope.Object2Index++;
+ $rootScope.resetPinArc = $rootScope.Object1Index++;
+ var radial = $('canvas').createGradient({
+ x1: 50, y1: 50,
+ x2: 50, y2: 50,
+ r1: 10, r2: 30,
+ c1: 'rgba(100, 50, 0,0)',
+ c2: 'grey'
+ });
+ $('#canvas').drawLine({
+ draggable: true,
+ layer: true,
+ name: "Pin_" + $rootScope.resetPin,
+ groups: ["Pin_" + $rootScope.resetPin],
+ dragGroups: ["Pin_" + $rootScope.resetPin],
+ strokeStyle: 'black',
+ strokeWidth: 2,
+ x1: $scope.offsetX1, y1: $scope.offsetY1,
+ x2: $scope.x, y2: $scope.y,
+
+ click: function (layer) {
+ // debugger;
+ $rootScope.shapeTypePin = "Pin";
+ $rootScope.canvasLayerNameCollection = [];
+ var pinLine_layer = layer.name;
+ var pinLine_layer_split = pinLine_layer.split("_");
+ var pinArcName = "ArcPin_";
+ var pinResult = pinArcName.concat(pinLine_layer_split[1]);
+
+ $rootScope.canvasLayerNameCollection.push({ pinName: layer.name, ArcName: pinResult });
+
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'arc',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ // width: 5, height: 5,
+ radius: 3
+ }
+ }).drawLayers();
+
+
+ },
+ mouseout: function (layer) {
+ // $rootScope.resetPinArc = "";
+ // ax = "";
+
+ $rootScope.canvasLayerNameCollection = [];
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'arc',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 0,
+ // width: 0, height: 0,
+ radius: 0
+ }
+
+ }).drawLayers();
+>>>>>>> db0b2ac40dc61ee08fb471800773516967978732
+
+ },
+ mouseover: function (layer) {
+
+
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'arc',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ // width: 5, height: 5,
+ radius: 3
+ }
+ }).drawLayers();
+
+ }
+ }).drawArc({
+ draggable: true,
+ name: "ArcPin_" + $rootScope.resetPinArc,
+ // name: "Pin_" + $rootScope.resetPin,
+ layer: true,
+ groups: ["Pin_" + $rootScope.resetPin],
+ dragGroups: ["Pin_" + $rootScope.resetPin],
+ strokeStyle: 'grey',
+ strokeWidth: 2,
+ fillStyle: radial,
+ x: $scope.offsetX1, y: $scope.offsetY1,
+ radius: 5,
+ //handle: {
+ // type: 'arc',
+ // fillStyle: '#fff',
+ // strokeStyle: '#c33',
+ // strokeWidth: 2,
+ // radius: 3
+ //},
+ add: function (layer) {
+
+ $rootScope.resetPinArc = layer.name;
+ // $scope.arr = [];
+
+
+ },
+
+ }).drawLayers();
+ $('.btnCursor').trigger('click');
+ $(".btn-annotation").removeClass("activebtncolor");
+ $('.btnCursor').addClass('activebtncolor');
+ break;
+ case "TextArea":
+
+ // Draw text
+ $rootScope.resetTextRect = $rootScope.ObjectIndex++;
+ $rootScope.resetText = $rootScope.ObjectIndex++;
+ $('#canvas').drawText({
+ layer: true,
+ draggable: true,
+ // opacity: $rootScope.shapestyleOpacity,
+ name: 'TextArea_' + $rootScope.resetText,
+ groups: ['TextArea_' + $rootScope.resetText],
+ dragGroups: ['TextArea_' + $rootScope.resetText],
+ fillStyle: '#36c',
+ strokeWidth: 0,
+ x: $scope.offsetX1, y: $scope.offsetY1,
+ fontSize: '14pt',
+ align: "left",
+ fontFamily: 'Verdana, sans-serif',
+ text: ''
+
+
+
+ })
+ // Draw rect as wide as the text
+ .drawRect({
+ layer: true,
+ name: "TextRect_" + $rootScope.resetTextRect,
+ dragGroups: ['shapes'],
+ opacity: $rootScope.shapestyleOpacity,
+ strokeStyle: $rootScope.shapestyleborderColor,
+ strokeWidth: $rootScope.shapestyleborderWidth,
+ fillStyle: $rootScope.shapestyleFillColor,
+ x: $scope.offsetX1, y: $scope.offsetY1,
+ width: $scope.x - $scope.offsetX1,
+ height: $scope.y - $scope.offsetY1,
+ click: function (layer) {
+
+ $rootScope.canvasLayerNameCollection = [];
+ $rootScope.canvasLayerNameCollection.push(layer.name);
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ width: 5, height: 5,
+ cornerRadius: 3
+ }
+ }).drawLayers();
+
+ },
+ mouseout: function (layer) {
+ $rootScope.canvasLayerNameCollection = [];
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: 'pink',
+ strokeStyle: 'yellow',
+ strokeWidth: 0,
+ width: 0, height: 0,
+ cornerRadius: 0
+ }
+
+ }).drawLayers();
+
+ },
+ mouseover: function (layer) {
+
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ width: 5, height: 5,
+ cornerRadius: 3
+ }
+ }).drawLayers();
+
+ }
+ });
+
+
+ $("#annotationTextModal").modal("toggle");
+ $('.btnCursor').trigger('click');
+ $(".btn-annotation").removeClass("activebtncolor");
+ $('.btnCursor').addClass('activebtncolor');
+ break;
+
+ case "DrawPolygon":
+
+ break;
+
+ }
+ //}
+
+ }
+
+ //-- TextArea functionality of Annotation toolbar
+
+ $rootScope.fontSizes;
+ $rootScope.fontWeight;
+ $rootScope.fontStyle;
+ $rootScope.textAlignmt;
+ $rootScope.fontColor;
+ $rootScope.underlineText;
+ $rootScope.textArea;
+ $rootScope.fontFamily;
+ $rootScope.TextAreaStyleProp = [];
+ $rootScope.modifySavedText = [];
+ $rootScope.TextRectangleArr = [];
+ $rootScope.rectDimension = [];
+
+ $rootScope.saveText = function () {
+ debugger;
+ if ($rootScope.isTrue == false) {
+ $rootScope.fontSizes = $("#text_area").css("font-size");
+ $rootScope.fontWeight = $("#text_area").css("font-weight");
+ $rootScope.fontStyle = $("#text_area").css("font-style");
+ $rootScope.textAlignmt = $("#text_area").css("text-align");
+ $rootScope.fontColor = $("#text_area").css("color");
+ $rootScope.fontFamily = $("#text_area").css("font-family");
+ $rootScope.underlineText = $("#text_area").css("text-decoration");
+ $rootScope.textArea = $("#text_area").val();
+
+ $("#canvas").removeLayer('TextArea_' + $rootScope.resetText).drawLayers();
+ $("#canvas").removeLayer("TextRect_" + $rootScope.resetTextRect).drawLayers();
+
+ $('#canvas').drawText({
+ layer: true,
+ draggable: true,
+ name: 'TextArea_' + $rootScope.resetText,
+ groups: ['TextArea_' + $rootScope.resetText],
+ dragGroups: ['TextArea_' + $rootScope.resetText],
+ fillStyle: $rootScope.fontColor,
+ fontStyle: $rootScope.fontStyle,
+ fontSize: $rootScope.fontSizes,
+ fontFamily: $rootScope.fontFamily,
+ align: $rootScope.textAlignmt,
+ strokeWidth: 0,
+ text: $rootScope.textArea,
+ x: $scope.offsetX1, y: $scope.offsetY1,
+ maxWidth: $scope.x - $scope.offsetX1,
+ maxHeight: $scope.y - $scope.offsetY1,
+
+ add: function (layer) {
+
+ $rootScope.TextAreaStyleProp.push({ Text1: '', Align: '', FontColor: '', FontSize: '', FontStyle: '', FontFamily: '' });
+ $rootScope.TextAreaStyleProp.push({ Text1: layer.text, Align: layer.align, FontColor: layer.fillStyle, FontSize: layer.fontSize, FontStyle: layer.fontStyle, FontFamily: layer.fontFamily });
+
+ // $rootScope.TextAreaStyleProp.push({ Text: '', Align: '', FontColor: '', FontSize: '', FontStyle: '', FontFamily: '' });
+ // $rootScope.TextAreaStyleProp.push({ Text: layer.text, Align: layer.align, FontColor: layer.fillStyle, FontSize: layer.fontSize, FontStyle: layer.fontStyle, FontFamily: layer.fontFamily });
+
+
+ },
+
+ change: function (layer, props) {
+
+ }
+
+ })
+ // Draw rect as wide as the text
+ .drawRect({
+ name: 'TextArea1_' + $rootScope.resetText,
+ layer: true,
+ draggable: true,
+ groups: ['TextArea_' + $rootScope.resetText],
+ dragGroups: ['TextArea_' + $rootScope.resetText],
+ opacity: $rootScope.shapestyleOpacity,
+ strokeStyle: $rootScope.shapestyleborderColor,
+ strokeWidth: $rootScope.shapestyleborderWidth,
+
+ x: $scope.offsetX1, y: $scope.offsetY1,
+ width: $scope.x - $scope.offsetX1,
+ height: $scope.y - $scope.offsetY1,
+ add: function (layer) {
+
+ },
+ click: function (layer) {
+ $rootScope.shapeTypeText = "textAreaRect";
+
+ var layerNameSplit = layer.name;
+
+ var splitedName = layerNameSplit.split("_");
+
+ var textValName = "TextArea_";
+
+ var concatinateResult = textValName.concat(splitedName[1]);
+
+ $rootScope.canvasLayerNameCollection = [];
+ $rootScope.canvasLayerNameCollection.push({ textareaRectangle: layer.name, textareaString: concatinateResult });
+
+
+
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ width: 5, height: 5,
+ cornerRadius: 3
+ }
+ }).drawLayers();
+
+ },
+ dblclick: function (layer) {
+ // debugger;
+ $rootScope.isTrue = true;
+
+ var _rectLayerOnSave = layer.name;
+ var _rectLayerOnSaveSplit = _rectLayerOnSave.split("_");
+ var str1 = "TextArea_";
+ var res = str1.concat(_rectLayerOnSaveSplit[1]);
+
+ $rootScope.modifySavedText.push({ TextName: layer.name, RectText: res});
+ $rootScope.rectDimension.push({ width: layer.width, height: layer.height, x: layer.x, y: layer.y });
+
+ var _rectLayerOnSaveSplitInt;
+ if (_rectLayerOnSaveSplit[1] >= 3)
+ _rectLayerOnSaveSplitInt = parseInt(_rectLayerOnSaveSplit[1] - 2);
+ else
+ _rectLayerOnSaveSplitInt = parseInt(_rectLayerOnSaveSplit[1]);
+
+ var b = $rootScope.TextAreaStyleProp[_rectLayerOnSaveSplitInt].Text1;
+ $("#text_area").val(b);
+ // alert($rootScope.TextAreaStyleProp[_rectLayerOnSaveSplitInt].FontSize);
+
+ $("#text_area").css("font-size", $rootScope.TextAreaStyleProp[_rectLayerOnSaveSplitInt].FontSize);
+ $("#text_area").css("font-weight", $rootScope.TextAreaStyleProp[_rectLayerOnSaveSplitInt].FontStyle);
+ $("#text_area").css("font-style", $rootScope.TextAreaStyleProp[_rectLayerOnSaveSplitInt].FontStyle);
+ $("#text_area").css("text-align", $rootScope.TextAreaStyleProp[_rectLayerOnSaveSplitInt].Align);
+ $("#text_area").css("color", $rootScope.TextAreaStyleProp[_rectLayerOnSaveSplitInt].FontColor);
+ $("#text_area").css("font-family", $rootScope.TextAreaStyleProp[_rectLayerOnSaveSplitInt].FontFamily);
+ $("#text_area").css("text-decoration", $rootScope.underlineText);
+
+
+ _rectLayerOnSaveSplitInt = ''; b = '';
+ $("#annotationTextModal").modal("toggle");
+
+ },
+ mouseout: function (layer) {
+
+ $rootScope.canvasLayerNameCollection = [];
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: 'pink',
+ strokeStyle: 'yellow',
+ strokeWidth: 0,
+ width: 0, height: 0,
+ cornerRadius: 0
+ }
+
+ }).drawLayers();
+ // $rootScope.textss = '';
+
+ },
+ mouseover: function (layer) {
+
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ width: 5, height: 5,
+ cornerRadius: 3
+ }
+ }).drawLayers();
+
+<<<<<<< HEAD
+ }
+ });
+ $("#text_area").val('');
+ $("#text_area").css({ " font-family": "'Verdana, sans-serif'", "font-size": "14px", "font-weight": "normal", "font-style": "normal", "color": "#000", "text-align": "left", "text-decoration": "none" });
+=======
+ $rootScope.fontSizes = $("#text_area").css("font-size");
+ $rootScope.fontWeight = $("#text_area").css("font-weight");
+ $rootScope.fontStyle = $("#text_area").css("font-style");
+ $rootScope.textAlignmt = $("#text_area").css("text-align");
+ $rootScope.fontColor = $("#text_area").css("color");
+ $rootScope.fontFamily = $("#text_area").css("font-family");
+ $rootScope.underlineText = $("#text_area").css("text-decoration");
+ $rootScope.textArea = $("#text_area").val();
+ $("#canvas").removeLayer('TextArea_' + $rootScope.resetText).drawLayers();
+ $("#canvas").removeLayer("TextRect_" + $rootScope.resetTextRect).drawLayers();
+
+ $('#canvas').drawText({
+ layer: true,
+ draggable: true,
+ name: 'TextArea_' + $rootScope.resetText,
+ groups: ['TextArea_' + $rootScope.resetText],
+ dragGroups: ['TextArea_' + $rootScope.resetText],
+ fillStyle: $rootScope.fontColor,
+ fontStyle: $rootScope.fontStyle,
+ fontSize: $rootScope.fontSizes,
+ fontFamily: $rootScope.fontFamily,
+ align: $rootScope.textAlignmt,
+ strokeWidth: 0,
+ text: $rootScope.textArea,
+ x: $scope.offsetX1, y: $scope.offsetY1,
+ maxWidth: $scope.x - $scope.offsetX1,
+ maxHeight: $scope.y - $scope.offsetY1,
+
+
+ click: function (layer) {
+>>>>>>> db0b2ac40dc61ee08fb471800773516967978732
+
+ }
+ else {
+ // debugger;
+
+
+ var _modifiedText = $("#text_area").val();
+ var _modifiedFontSize = $("#text_area").css("font-size");
+ var _modifiedFontWeight = $("#text_area").css("font-weight");
+ var _modifiedFontStyle = $("#text_area").css("font-style");
+ var _modifiedTextAlign = $("#text_area").css("text-align");
+ var _modifiedFontColor = $("#text_area").css("color");
+ var _modifiedFontFamily = $("#text_area").css("font-family");
+ var _modifiedFontDecoration = $("#text_area").css("text-decoration");
+
+ $("#canvas").removeLayer($rootScope.modifySavedText[0].RectText).drawLayers();
+ $("#canvas").removeLayer($rootScope.modifySavedText[0].TextName).drawLayers();
+
+ $rootScope.resetTextRectSave = $rootScope.ObjectIndexSave++;
+ $rootScope.resetTextSave = $rootScope.ObjectIndexSave++;
+ // alert($rootScope.resetText);
+ // alert('TextArea12_' + $rootScope.resetTextSave);
+ $('#canvas').drawText({
+ layer: true,
+ draggable: true,
+ name: 'TextArea12_' + $rootScope.resetTextSave,
+ groups: ['TextArea12_' + $rootScope.resetTextSave],
+ dragGroups: ['TextArea12_' + $rootScope.resetTextSave],
+ fillStyle: _modifiedFontColor,
+ fontStyle: _modifiedFontStyle,
+ fontSize: _modifiedFontSize,
+ fontFamily: _modifiedFontFamily,
+ align: _modifiedTextAlign,
+ strokeWidth: 0,
+ text: _modifiedText,
+ x: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].x, y: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].y,
+ maxWidth: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].width,
+ maxHeight: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].height,
+
+ add: function (layer) {
+
+
+
+ },
+
+ change: function (layer, props) {
+
+ }
+
+ })
+ // Draw rect as wide as the text
+ .drawRect({
+ name: 'TextArea13_' + $rootScope.resetTextSave,
+ layer: true,
+ draggable: true,
+ groups: ['TextArea12_' + $rootScope.resetTextSave],
+ dragGroups: ['TextArea12_' + $rootScope.resetTextSave],
+ opacity: $rootScope.shapestyleOpacity,
+ strokeStyle: $rootScope.shapestyleborderColor,
+ strokeWidth: $rootScope.shapestyleborderWidth,
+ x: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].x, y: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].y,
+ width: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].width,
+ height: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].height,
+
+ click: function (layer) {
+ $rootScope.shapeTypeText = "textAreaRect";
+
+ var layerNameSplit = layer.name;
+
+ var splitedName = layerNameSplit.split("_");
+
+ var textValName = "TextArea12_";
+
+ var concatinateResult = textValName.concat(splitedName[1]);
+
+ $rootScope.canvasLayerNameCollection = [];
+ $rootScope.canvasLayerNameCollection.push({ textareaRectangle: layer.name, textareaString: concatinateResult });
+
+
+
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ width: 5, height: 5,
+ cornerRadius: 3
+ }
+ }).drawLayers();
+
+ },
+ dblclick: function (layer) {
+
+ $rootScope.isTrue = true;
+
+ var _rectLayerOnSave = layer.name;
+ var _rectLayerOnSaveSplit = _rectLayerOnSave.split("_");
+ var str1 = "TextArea12_";
+ var res = str1.concat(_rectLayerOnSaveSplit[1]);
+
+ $rootScope.modifySavedText.push({ TextName: layer.name, RectText: res });
+ $rootScope.rectDimension.push({ width: layer.width, height: layer.height, x: layer.x, y: layer.y });
+
+ $("#text_area").val(_modifiedText);
+ $("#text_area").css("font-size", _modifiedFontSize);
+ $("#text_area").css("font-weight", _modifiedFontWeight);
+ $("#text_area").css("font-style", _modifiedFontStyle);
+ $("#text_area").css("text-align", _modifiedTextAlign);
+ $("#text_area").css("color", _modifiedFontColor);
+ $("#text_area").css("font-family", _modifiedFontFamily);
+ $("#text_area").css("text-decoration", _modifiedFontDecoration);
+
+
+ $("#annotationTextModal").modal("toggle");
+
+ },
+ mouseout: function (layer) {
+
+ $rootScope.canvasLayerNameCollection = [];
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: 'pink',
+ strokeStyle: 'yellow',
+ strokeWidth: 0,
+ width: 0, height: 0,
+ cornerRadius: 0
+ }
+
+ }).drawLayers();
+
+ },
+ mouseover: function (layer) {
+
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ width: 5, height: 5,
+ cornerRadius: 3
+ }
+ }).drawLayers();
+
+<<<<<<< HEAD
+ }
+ });
+ $rootScope.modifySavedText = [];
+=======
+ })
+ // Draw rect as wide as the text
+ .drawRect({
+ name: 'TextArea1_' + $rootScope.resetText,
+ layer: true,
+ draggable: true,
+ groups: ['TextArea_' + $rootScope.resetText],
+ dragGroups: ['TextArea_' + $rootScope.resetText],
+ opacity: $rootScope.shapestyleOpacity,
+ // strokeStyle: 'black',
+ // strokeWidth: 2,
+ strokeStyle: $rootScope.shapestyleborderColor,
+ strokeWidth: $rootScope.shapestyleborderWidth,
+ // fillStyle: $rootScope.shapestyleFillColor,
+ x: $scope.offsetX1, y: $scope.offsetY1,
+ width: $scope.x - $scope.offsetX1,
+ height: $scope.y - $scope.offsetY1,
+
+ click: function (layer) {
+ $rootScope.shapeTypeText = "textAreaRect";
+
+ var layerNameSplit = layer.name;
+
+ var splitedName = layerNameSplit.split("_");
+
+ var textValName = "TextArea_";
+
+ var concatinateResult = textValName.concat(splitedName[1]);
+
+ $rootScope.canvasLayerNameCollection = [];
+ $rootScope.canvasLayerNameCollection.push({ textareaRectangle: layer.name, textareaString: concatinateResult });
+
+
+
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ width: 5, height: 5,
+ cornerRadius: 3
+ }
+ }).drawLayers();
+
+ },
+ mouseout: function (layer) {
+
+ $rootScope.canvasLayerNameCollection = [];
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: 'pink',
+ strokeStyle: 'yellow',
+ strokeWidth: 0,
+ width: 0, height: 0,
+ cornerRadius: 0
+ }
+
+ }).drawLayers();
+
+ },
+ mouseover: function (layer) {
+
+ $('#canvas').setLayer(layer.name, {
+ handle: {
+ type: 'rectangle',
+ fillStyle: '#fff',
+ strokeStyle: '#c33',
+ strokeWidth: 2,
+ width: 5, height: 5,
+ cornerRadius: 3
+ }
+ }).drawLayers();
+>>>>>>> db0b2ac40dc61ee08fb471800773516967978732
+
+ }
+ }
+
+ $rootScope.closeModal = function () {
+ debugger;
+
+
+
+ $("#canvas").removeLayer('TextArea_' + $rootScope.resetText).drawLayers();
+ $("#canvas").removeLayer("TextRect_" + $rootScope.resetTextRect).drawLayers();
+
+
+ }
+
+
+ function OnPaintCanvasMouseMove(event) {
+
+
+ }
+
+ $rootScope.FreeStylePaint = function (e) {
+ // debugger;
+
+<<<<<<< HEAD
+
+ // $rootScope.shapeType = "FreeStylePaint";
+ // canvasPaint.addEventListener('mouseup', $scope.OnPaintBrushCanvasMouseUp, false);
+ // canvasPaint.addEventListener('mousedown', $scope.OnPaintBrushCanvasMouseDown, false);
+
+
+=======
+
+ // $rootScope.shapeType = "FreeStylePaint";
+ canvasPaint.addEventListener('mouseup', $scope.OnPaintBrushCanvasMouseUp, false);
+ canvasPaint.addEventListener('mousedown', $scope.OnPaintBrushCanvasMouseDown, false);
+
+
+>>>>>>> db0b2ac40dc61ee08fb471800773516967978732
+ }
+ $scope.OnPaintBrushCanvasMouseDown = function (event) {
+ switch ($rootScope.shapeType) {
+
+ case "FreeStylePaint":
+
+ debugger;
+
+ // $('#canvasPaint').sketch();
+ // $('#canvasPaint').sketch({ defaultSize: 1 });
+ // if ($("#amount-2").val() == '') {
+ // //$('#canvasPaint').sketch({ defaultSize: $scope.shapesize });
+ // $('#canvasPaint').sketch();
+ // }
+ // else {
+
+ // // var a = $("#amount-2").val();
+ //// $scope.shapesize = parseInt(a);
+ // // $('#canvasPaint').sketch({ defaultSize: $rootScope.shapeSize });
+ // // $('#canvasPaint').sketch({ defaultSize: $scope.shapesize });
+
+ // }
+
+
+ break;
+
+ }
+ }
+ $scope.OnPaintBrushCanvasMouseUp = function (event) {
+
+
+ // var canvasElement1 = document.getElementById("canvasPaint");
+ // var ctx1 = canvasElement1.getContext("2d");
+
+ //switch($rootScope.shapeType)
+ //{
+
+ // case "FreeStylePaint":
+
+ // debugger;
+
+ // if ($("#amount-2").val() == '')
+ // {
+ // $('#canvasPaint').sketch({ defaultSize: $scope.shapesize });
+ // }
+ // else
+ // {
+
+ // var a = $("#amount-2").val();
+ // $scope.shapesize = parseInt(a);
+ // alert(JSON.stringify({ defaultSize: $scope.shapesize }));
+ // $('#canvasPaint').sketch({ defaultSize: $scope.shapesize });
+
+ // }
+
+
+ // break;
+
+ //}
+
+ }
+
+
+
+ $(document).keydown(function (event) {
+
+
+ if (event.which == 46) {
+ //debugger;
+ if ($rootScope.shapeTypePin == "Pin") {
+
+
+ $("#canvas").removeLayer($rootScope.canvasLayerNameCollection[0].pinName).drawLayers();
+ $("#canvas").removeLayer($rootScope.canvasLayerNameCollection[0].ArcName).drawLayers();
+ $rootScope.shapeTypePin = "";
+
+ }
+ else if ($rootScope.shapeTypeText == "textAreaRect") {
+
+
+
+ $("#canvas").removeLayer($rootScope.canvasLayerNameCollection[0].textareaRectangle).drawLayers();
+ $("#canvas").removeLayer($rootScope.canvasLayerNameCollection[0].textareaString).drawLayers();
+ $rootScope.shapeTypeText = "";
+
+ }
+ else {
+
+ // alert($rootScope.canvasLayerNameCollection);
+ $("#canvas").removeLayer($rootScope.canvasLayerNameCollection).drawLayers();
+ }
+
+
+ }
+
+ });
+
+ //body highlight options functinality
+ $scope.LoadBodySystemData = function () {
+
+ var currentBodyViewId = $rootScope.voId;
+ var systemListHtml = '';
+ $('#bodySystem').append(systemListHtml);
+
+ var bodySystemDataPath = '~/../content/data/json/da/body-views/' + currentBodyViewId + '/da_dat_body_system_term_' + currentBodyViewId + '.json';
+ DataService.getJson(bodySystemDataPath)
+ .then(
+ function (result) {
+
+ $rootScope.BodySystemData = result;
+
+ },
+ function (error) {
+ console.log(error.statusText)
+ }
+ )
+
+ }
+
+ $scope.HighlightBodyByBodySystem = function (event) {
+
+ //if listanager is visisble then close it
+
+ $rootScope.isListManagerSelected = false;
+ $rootScope.CloseListManager();
+
+
+ //NIKITA
+ $scope.isHighlightBodyByBodySystem = true;
+ $scope.systemMatchedTermList = new jinqJs()
+ .from($rootScope.BodySystemData.BodySystem.BodySystemTerm)
+ .where('_SystemNumber == ' + event.currentTarget.id)
+ .select();
+
+ if ($rootScope.isHighLight == false) {
+ //color the body gray
+ $rootScope.isHighLight = true
+ console.log('highLightBody from HighlightBodyByBodySystem')
+ $scope.highLightBody();
+ }
+ //now highlight the selected body system in whole body
+
+
+ //$rootScope.isLoading = true;
+ $('#spinner').css('visibility', 'visible');
+
+ //NIKITA
+ // $scope.isHighlightBodyByBodySystem = true;
+
+ //if (systemMatchedTermList != null || systemMatchedTermList != undefined) {
+
+ // $timeout(function () { $scope.HighlightBodyByTermList(systemMatchedTermList) }, 100);
+ //}
+
+
+ var viewtarget_highlightbody = angular.element(event.currentTarget);
+ var title_highlightbody = viewtarget_highlightbody.attr('title');
+
+ if (title_highlightbody == "Cardiovascular") {
+ $scope.CurrentStructure = "";
+ $scope.Cardiovascular = "active";
+ $scope.Digestive = "";
+ $scope.Endocrine = "";
+ $scope.Immune = "";
+ $scope.Integumentary = "";
+ $scope.Lymphatic = "";
+ $scope.Muscular = "";
+ $scope.Nervous = "";
+ $scope.Reproductive = "";
+ $scope.Respiratory = "";
+ $scope.Skeletal = "";
+ $scope.Urinary = "";
+ }
+
+ if (title_highlightbody == "Digestive") {
+ $scope.CurrentStructure = "";
+ $scope.Cardiovascular = "";
+ $scope.Digestive = "active";
+ $scope.Endocrine = "";
+ $scope.Immune = "";
+ $scope.Integumentary = "";
+ $scope.Lymphatic = "";
+ $scope.Muscular = "";
+ $scope.Nervous = "";
+ $scope.Reproductive = "";
+ $scope.Respiratory = "";
+ $scope.Skeletal = "";
+ $scope.Urinary = "";
+ }
+
+ if (title_highlightbody == "Endocrine") {
+ $scope.CurrentStructure = "";
+ $scope.Cardiovascular = "";
+ $scope.Digestive = "";
+ $scope.Endocrine = "active";
+ $scope.Immune = "";
+ $scope.Integumentary = "";
+ $scope.Lymphatic = "";
+ $scope.Muscular = "";
+ $scope.Nervous = "";
+ $scope.Reproductive = "";
+ $scope.Respiratory = "";
+ $scope.Skeletal = "";
+ $scope.Urinary = "";
+ }
+ if (title_highlightbody == "Immune") {
+
+ $scope.CurrentStructure = "";
+ $scope.Cardiovascular = "";
+ $scope.Digestive = "";
+ $scope.Endocrine = "";
+ $scope.Immune = "active";
+ $scope.Integumentary = "";
+ $scope.Lymphatic = "";
+ $scope.Muscular = "";
+ $scope.Nervous = "";
+ $scope.Reproductive = "";
+ $scope.Respiratory = "";
+ $scope.Skeletal = "";
+ $scope.Urinary = "";
+ }
+ if (title_highlightbody == "Integumentary") {
+ $scope.CurrentStructure = "";
+ $scope.Cardiovascular = "";
+ $scope.Digestive = "";
+ $scope.Endocrine = "";
+ $scope.Immune = "";
+ $scope.Integumentary = "active";
+ $scope.Lymphatic = "";
+ $scope.Muscular = "";
+ $scope.Nervous = "";
+ $scope.Reproductive = "";
+ $scope.Respiratory = "";
+ $scope.Skeletal = "";
+ $scope.Urinary = "";
+ }
+ if (title_highlightbody == "Lymphatic") {
+ $scope.CurrentStructure = "";
+ $scope.Cardiovascular = "";
+ $scope.Digestive = "";
+ $scope.Endocrine = "";
+ $scope.Immune = "";
+ $scope.Integumentary = "";
+ $scope.Lymphatic = "active";
+ $scope.Muscular = "";
+ $scope.Nervous = "";
+ $scope.Reproductive = "";
+ $scope.Respiratory = "";
+ $scope.Skeletal = "";
+ $scope.Urinary = "";
+ }
+ if (title_highlightbody == "Muscular") {
+ $scope.CurrentStructure = "";
+ $scope.Cardiovascular = "";
+ $scope.Digestive = "";
+ $scope.Endocrine = "";
+ $scope.Immune = "";
+ $scope.Integumentary = "";
+ $scope.Lymphatic = "";
+ $scope.Muscular = "active";
+ $scope.Nervous = "";
+ $scope.Reproductive = "";
+ $scope.Respiratory = "";
+ $scope.Skeletal = "";
+ $scope.Urinary = "";
+ }
+ if (title_highlightbody == "Nervous") {
+ $scope.CurrentStructure = "";
+ $scope.Cardiovascular = "";
+ $scope.Digestive = "";
+ $scope.Endocrine = "";
+ $scope.Immune = "";
+ $scope.Integumentary = "";
+ $scope.Lymphatic = "";
+ $scope.Muscular = "";
+ $scope.Nervous = "active";
+ $scope.Reproductive = "";
+ $scope.Respiratory = "";
+ $scope.Skeletal = "";
+ $scope.Urinary = "";
+ }
+ if (title_highlightbody == "Reproductive") {
+ $scope.CurrentStructure = "";
+ $scope.Cardiovascular = "";
+ $scope.Digestive = "";
+ $scope.Endocrine = "";
+ $scope.Immune = "";
+ $scope.Integumentary = "";
+ $scope.Lymphatic = "";
+ $scope.Muscular = "";
+ $scope.Nervous = "";
+ $scope.Reproductive = "active";
+ $scope.Respiratory = "";
+ $scope.Skeletal = "";
+ $scope.Urinary = "";
+ }
+ if (title_highlightbody == "Respiratory") {
+ $scope.CurrentStructure = "";
+ $scope.Cardiovascular = "";
+ $scope.Digestive = "";
+ $scope.Endocrine = "";
+ $scope.Immune = "";
+ $scope.Integumentary = "";
+ $scope.Lymphatic = "";
+ $scope.Muscular = "";
+ $scope.Nervous = "";
+ $scope.Reproductive = "";
+ $scope.Respiratory = "active";
+ $scope.Skeletal = "";
+ $scope.Urinary = "";
+ }
+ if (title_highlightbody == "Skeletal") {
+ $scope.CurrentStructure = "";
+ $scope.Cardiovascular = "";
+ $scope.Digestive = "";
+ $scope.Endocrine = "";
+ $scope.Immune = "";
+ $scope.Integumentary = "";
+ $scope.Lymphatic = "";
+ $scope.Muscular = "";
+ $scope.Nervous = "";
+ $scope.Reproductive = "";
+ $scope.Respiratory = "";
+ $scope.Skeletal = "active";
+ $scope.Urinary = "";
+ }
+ if (title_highlightbody == "Urinary") {
+ $scope.CurrentStructure = "";
+ $scope.Cardiovascular = "";
+ $scope.Digestive = "";
+ $scope.Endocrine = "";
+ $scope.Immune = "";
+ $scope.Integumentary = "";
+ $scope.Lymphatic = "";
+ $scope.Muscular = "";
+ $scope.Nervous = "";
+ $scope.Reproductive = "";
+ $scope.Respiratory = "";
+ $scope.Skeletal = "";
+ $scope.Urinary = "active";
+ }
+
+ //Highlight button should be active
+ $("#btnHighLight").addClass("btn-primary");
+ $("#btnHighLight").removeClass("btn-black");
+
+ if (!$("#btnNormalMode").hasClass("btn-black")) {
+ $("#btnNormalMode").addClass("btn-black");
+ }
+
+ if (!$("#btnExtract").hasClass("btn-black")) {
+ $("#btnExtract").addClass("btn-black");
+ }
+
+ if ($("#btnExtract").hasClass("btn-primary")) {
+ $("#btnExtract").removeClass("btn-primary");
+ }
+
+ if ($("#btnNormalMode").hasClass("btn-primary")) {
+ $("#btnNormalMode").removeClass("btn-primary");
+ }
+
+ }
+
+ $scope.ShowSearch = function () {
+
+ console.log('ShowSearch is called');
+
+ $timeout(function () {
+ $scope.IsSearchVisible = true;
+
+ document.getElementById("termlistfilter").style.display = "block";
+ }, 1000);
+
+ //$scope.IsSearchVisible = true;
+
+ //document.getElementById("termlistfilter").style.display = "block";
+ }
+
+ $scope.HideSearch = function () {
+ if ($("#backdrop").is(":hover") || $("#termlistfilter").is(":hover") || $("#typedtermname").is(":focus")) {
+ $scope.IsSearchVisible = true;
+ document.getElementById("termlistfilter").style.display = "block";
+ }
+ else {
+ $scope.IsSearchVisible = false;
+ document.getElementById("termlistfilter").style.display = "none";
+ $scope.searchFilter = "";
+ }
+
+ }
+
+ $scope.jumpToTerm = function (event) {
+ $scope.searchFilter = event.currentTarget.innerHTML;
+ $scope.HighlightBodyOnListManagerSelection(event);
+
+ $scope.IsSearchVisible = false;
+
+ //Highlight only Highlight button
+
+ $("#btnHighLight").addClass("btn-primary");
+ $("#btnHighLight").removeClass("btn-black");
+
+ if (!$("#btnNormalMode").hasClass("btn-black")) {
+ $("#btnNormalMode").addClass("btn-black");
+ }
+
+ if (!$("#btnExtract").hasClass("btn-black")) {
+ $("#btnExtract").addClass("btn-black");
+ }
+
+ if ($("#btnExtract").hasClass("btn-primary")) {
+ $("#btnExtract").removeClass("btn-primary");
+ }
+
+ if ($("#btnNormalMode").hasClass("btn-primary")) {
+ $("#btnNormalMode").removeClass("btn-primary");
+ }
+
+ }
+
+ //Function to set the vertical and horizontal scroll position of CanvasDiv as per the Navigator
+ $scope.ScrollCanvasDiv = function () {
+
+ var x = $("#draggable").position();
+ var can = $('#canvasDiv');
+ var canheight = can[0].scrollHeight;
+ var canwidth = can[0].scrollWidth;
+
+ var scrolly = (x.top / ($('#containment-wrapper').height())) * (canheight);
+
+ var scrollx = (x.left / $('#containment-wrapper').width()) * (canwidth);
+
+ $("#canvasDiv").scrollTop(scrolly);
+ $("#canvasDiv").scrollLeft(scrollx);
+
+ if (($scope.isHighlightBodyByBodySystem == true) && ($scope.systemMatchedTermList != null || $scope.systemMatchedTermList != undefined)) {
+ $timeout(function () { $scope.HighlightBodyByTermList(systemMatchedTermList) }, 100);
+ }
+
+ }
+
+ //list manager
+ $scope.$on('listManagerEvent', function (event, data) {
+ // debugger;
+ $('#spinner').css('visibility', 'visible');
+ console.log('listManagerEvent')
+ if ($rootScope.islistManagerEventAlredayDispachted == true) {
+
+
+ var systemList = $rootScope.CommonData.DACommonData.BodySystems.Item;
+
+ $('#bodySystems').empty();
+
+
+ var $all = $('
').appendTo('#bodySystems');
+ $compile($all)($scope);
+
+ angular.forEach(systemList, function (value, key) {
+
+ var $elem = $('
').appendTo('#bodySystems');
+ $compile($elem)($scope);
+ })
+
+
+
+
+ var currentView = localStorage.getItem("currentViewTitle");
+ var viewNmeHtml = '
'
+ $('#viewName').append(viewNmeHtml);
+
+ var len = $rootScope.openModules.length;
+ var openViewLen = $rootScope.openViews.length;
+
+ var currentOpenModuleId = $rootScope.openModules[len - 1].ModuleId;
+ var currentOpenViewId = $rootScope.openViews[openViewLen - 1].BodyViewId;
+ $rootScope.viewOrientationId = currentOpenViewId;
+ //confirm that this is DA module which is last open
+ if (currentOpenModuleId == 1) {
+
+
+ $('#termList').empty();
+ $scope.loadListManger();
+
+
+ //})
+ // .error(function (data, status, headers, config) {
+
+ // console.log(data);
+
+ // });
+
+
+
+ $rootScope.islistManagerEventAlredayDispachted = false;
+ var jj;
+ }
+
+ }
+
+
+
+ });
+
+ $scope.loadListManger = function () {
+
+
+
+ //var path = '~/../content/data/json/da/vocab/english/cm_dat_vocabterm_1.json'
+
+ //$http({ method: 'GET', url: '~/../content/data/json/da/vocab/english/cm_dat_vocabterm_1.json' }).success(function (data) {
+
+ //var VocabTermData = data;
+
+ var vocabTermTxt = [];
+
+ angular.forEach($rootScope.TermNumberData.TermData.Term, function (value1, key1) {
+
+ angular.forEach($rootScope.VocabTermData.VocabTerms.Term, function (value2, key2) {
+
+
+ if (value1._ActualTermNumber === value2._ActualTermNumber) {
+ vocabTermTxt.push(
+
+ {
+
+ "_ActualTermNumber": value2._ActualTermNumber,
+ "_TermText": value2._TermText,
+ "_cdId": value2._cdId
+
+ }
+
+ );
+
+ }
+
+ })
+
+
+
+ })
+
+
+
+ $scope.VocabTermTxt = new jinqJs()
+ .from(vocabTermTxt)
+ .distinct('_TermText', '_ActualTermNumber')
+ .orderBy([{ field: '_TermText', sort: 'asc' }])
+ .select('_ActualTermNumber', '_TermText', '_cdId');
+
+ if ($scope.VocabTermTxt != null || $scope.VocabTermTxt != undefined) {
+
+
+ for (var j = 0; j < $scope.VocabTermTxt.length; j++) {
+ var $el = $('
').appendTo('#termList')
+ $compile($el)($scope);
+ $rootScope.isLoading = false;
+ $('#spinner').css('visibility', 'hidden');
+ }
+ var termsTotal = '
' + $scope.VocabTermTxt.length + ' Structures';
+ $("#totalTerms").empty();
+ $('#totalTerms').append(termsTotal);
+
+
+ }
+ // })
+
+
+ //.error(function (data, status, headers, config) {
+
+ // console.log(data);
+
+ //});
+ }
+
+
+ $scope.HighlightBodyOnListManagerSelection = function (event) {
+
+ $scope.terminateCurrentlyRunningWPs();
+ //debugger
+ $rootScope.isListManagerSelected = true;
+ $rootScope.isLoading = true;
+
+ $('#spinner').css('visibility', 'visible');
+ //1.
+ var actualTermNumber = event.currentTarget.id;//attributes[0].value;
+ $scope.TermList = $scope.getTermNumberList(actualTermNumber);
+
+ //2.
+ var internalLayerNumberList = [];
+ for (var i = 0; i < $scope.TermList.length; i++) {
+ var layerNumber = $scope.TermList[i]._InternalLayerNumber
+
+ internalLayerNumberList[i] = parseInt(layerNumber);
+ }
+
+ internalLayerNumberList.sort(function (a, b) { return a - b })
+ var internalLayerNumber = internalLayerNumberList[0]//.replace('00', '');
+
+ //3. get layer number
+ if (internalLayerNumber >= DA[0].SKIN_START_INTERNAL_LAYER && internalLayerNumber <= DA[0].SKIN_END_INTERNAL_LAYER) {
+
+ internalLayerNumber = DA[0].SKIN_DEFAULT_INTERNAL_LAYER;
+ }
+
+ var layerNumber;
+ var matchedLayerNumber = new jinqJs()
+ .from($rootScope.BodyLayerData.Layers.DataLayer)
+ .where("_lni == " + internalLayerNumber)
+ .select('_LayerNumber');
+
+ if (matchedLayerNumber == null || matchedLayerNumber.length == 0) {
+ layerNumber = 0;
+ }
+ else {
+ layerNumber = matchedLayerNumber[0]._LayerNumber
+ }
+
+ if (layerNumber == 0) {
+ layerNumber = $scope.totalLayers;
+ }
+ else {
+ layerNumber = parseInt(layerNumber) - 1;
+ }
+
+ $scope.layerNumber = layerNumber;
+
+ //4.get scroll position
+ if (actualTermNumber != DA[0].SKIN_TERM_ID) {
+
+ $scope.termCoordinate = $scope.getTermCoordinate(actualTermNumber);
+
+ }
+
+ //5.
+ $scope.matchdedDataOnLayer = new jinqJs()
+ .from($rootScope.TermNumberData.TermData.Term)
+ .where('_InternalLayerNumber == ' + internalLayerNumber)
+ .select();
+
+ if ($scope.matchdedDataOnLayer != null || $scope.matchdedDataOnLayer != undefined) {
+
+ //6.
+ var matchedDataonActualTerm = new jinqJs()
+ .from($scope.matchdedDataOnLayer)
+ .where('_ActualTermNumber == ' + actualTermNumber)
+ .select('_TermNumber');
+
+ if (matchedDataonActualTerm != null || matchedDataonActualTerm != undefined) {
+
+ var termNo = matchedDataonActualTerm[0]._TermNumber.toString();
+
+ //7.get termList
+ $scope.fullTermlist = [];
+ $scope.AllTerms = [];
+
+ if (termNo != DA[0].figLeafTermId) {
+
+ $scope.getChildTermList(termNo);
+ // $timeout(function () { $scope.getSiblings(termNo) }, 50);
+ $scope.getSiblings(termNo)
+ }
+
+ }
+ }
+
+ $('#txtlayerNumber').val((parseInt($scope.layerNumber)));
+ $('#layerChangeSlider').slider("option", "value", parseInt($scope.totalLayers) - parseInt($scope.layerNumber));
+
+ //8.remove current layer canavses
+ $scope.flushCanvas();
+
+
+
+ //9.
+ $timeout(function () {
+ $rootScope.isHighLight = false;
+ $('#sppeachBubble').css('display', 'none');
+ $("#dot").css("display", "none");
+
+ //redraw body of respective layer
+ $scope.CalculateImageCordinates($rootScope.viewOrientationId)
+ }, 500);
+
+
+
+ }
+
+ $scope.getChildTermList = function (termNo) {
+
+
+ var data = new jinqJs()
+ .from($scope.matchdedDataOnLayer)
+ .where("_ParentTermNumber == " + termNo)
+ .select();
+
+ if (data != null || data != undefined) {
+
+
+ var data2 = new jinqJs()
+ .from(data)
+ .where("_TermNumber != " + termNo)
+ .select();
+
+
+ var k;
+ if ((data2 != null || data2 != undefined) && (data2.length > 0)) {
+ for (var i = 0; i < data2.length; i++) {
+
+ var serachTerm = data2[i]._TermNumber;
+ var isFound = jQuery.inArray(serachTerm, $scope.fullTermlist)
+ if (isFound == -1) {
+ $scope.fullTermlist.push(serachTerm);
+ $scope.AllTerms.push({ '_TermNumber': serachTerm })
+ $scope.getChildTermList(serachTerm);
+ }
+ }
+ }
+ }
+ }
+
+ $scope.getSiblings = function (termNo) {
+
+ var data = new jinqJs()
+ .from($scope.matchdedDataOnLayer)
+ .where("_TermNumber == " + termNo)
+ .select();
+
+ if (data != null || data != undefined) {
+
+ var termNo = data[0]._ActualTermNumber;
+
+ var data2 = new jinqJs()
+ .from($scope.matchdedDataOnLayer)
+ .where("_ActualTermNumber == " + termNo)
+ .select();
+
+ if ((data2 != null || data2 != undefined) && (data2.length > 0)) {
+ for (var i = 0; i < data2.length; i++) {
+ $scope.fullTermlist.push(data2[i]._TermNumber);
+ $scope.AllTerms.push({ '_TermNumber': data2[i]._TermNumber })
+ $scope.getChildTermList(data2[i]._TermNumber);
+ }
+ }
+ }
+ }
+
+ $scope.getTermCoordinate = function (actualTermNumber) {
+
+ return {
+ x: $scope.TermList[0]._CenterX,
+ y: $scope.TermList[0]._CenterY
+ }
+ }
+
+ $scope.aligneCanvasWithTerm = function () {
+ console.log('aligneCanvasWithTerm')
+ var newX = parseInt($scope.scaleValue($scope.termCoordinate.x, $scope.zoomInOut, DA[0].ZOOM_TERM_DATA));
+ var newY = parseInt($scope.scaleValue($scope.termCoordinate.y, $scope.zoomInOut, DA[0].ZOOM_TERM_DATA));
+
+ var canvasX = parseInt($('#canvasDiv').css('left'));
+ var canvasY = parseInt($('#canvasDiv').css('top'));
+ var canvasWidth = parseInt($('#canvasDiv').css('width'));
+ var canvasHeight = parseInt($('#canvasDiv').css('height'));
+ var canvasBottom = canvasY + canvasHeight;
+ var canvasRight = canvasX + canvasWidth
+
+
+ if (newX >= canvasX && newX <= canvasRight && newY >= canvasY && newY <= canvasBottom) {
+
+ }
+ else {
+ newX = newX - canvasWidth / 2;
+ newY = newY - canvasHeight / 2;
+
+ }
+
+
+
+ console.log('newX =' + newX + ',newY= ' + newY)
+ $('#canvasDiv').scrollLeft(newX);
+ $('#canvasDiv').scrollTop(newY);
+
+
+ }
+
+ $scope.scaleValue = function (nValue, nNewZoom, nExistingZoom) {
+
+ var iReturnValue = nValue * nNewZoom;
+ return Math.round(iReturnValue / nExistingZoom);
+ }
+
+ $scope.refreshTermListOnSystemSelection = function (event) {
+
+ $('#termList').empty();
+ // $('#termList').innerHTML = '';
+
+ if (event.currentTarget.id == 0) {
+ $scope.loadListManger();
+ }
+ else {
+ var bodySystemDataPath = '~/../content/data/json/da/body-views/' + localStorage.getItem("currentBodyViewId") + '/da_dat_body_system_term_' + localStorage.getItem("currentBodyViewId") + '.json';
+ DataService.getJson(bodySystemDataPath)
+ .then(
+ function (result) {
+
+ $rootScope.BodySystemData = result;
+ var systemMatchedTermList = new jinqJs()
+ .from($rootScope.BodySystemData.BodySystem.BodySystemTerm)
+ .where('_SystemNumber == ' + event.currentTarget.id)
+ .select();
+ if (systemMatchedTermList != null || systemMatchedTermList != undefined) {
+
+ $scope.refreshTerms(systemMatchedTermList);
+ }
+ },
+ function (error) {
+ console.log(error.statusText)
+ }
+ )
+
+ }
+ }
+
+ $scope.refreshTerms = function (termList) {
+
+ var path = '~/../content/data/json/da/vocab/english/cm_dat_vocabterm_1.json'
+
+ $http({ method: 'GET', url: '~/../content/data/json/da/vocab/english/cm_dat_vocabterm_1.json' }).success(function (data) {
+
+ var VocabTermData = data;
+
+ var vocabTermTxt = [];
+
+ for (var i = 0; i < termList.length; i++) {
+
+ var actulaTermNumber = new jinqJs()
+ .from($rootScope.TermNumberData.TermData.Term)
+ .where('_TermNumber == ' + termList[i]._TermNumber)
+ .select('_ActualTermNumber');
+
+ if (actulaTermNumber != null || actulaTermNumber != undefined) {
+
+
+ angular.forEach(VocabTermData.VocabTerms.Term, function (value2, key2) {
+
+
+ if (actulaTermNumber[0]._ActualTermNumber == value2._ActualTermNumber) {
+ vocabTermTxt.push(
+
+ {
+
+ "_ActualTermNumber": value2._ActualTermNumber,
+
+ "_TermText": value2._TermText,
+
+ "_cdId": value2._cdId
+
+ }
+
+ );
+
+ }
+
+ })
+
+ }
+ }
+
+ $scope.VocabTermTxt = new jinqJs()
+ .from(vocabTermTxt)
+ .distinct('_TermText', '_ActualTermNumber')
+ .orderBy([{ field: '_TermText', sort: 'asc' }])
+ .select('_ActualTermNumber', '_TermText', '_cdId');
+
+ if ($scope.VocabTermTxt != null || $scope.VocabTermTxt != undefined) {
+
+
+ for (var j = 0; j < $scope.VocabTermTxt.length; j++) {
+ var $el = $('
').appendTo('#termList')
+ $compile($el)($scope);
+ }
+
+ var termsTotal = '
' + $scope.VocabTermTxt.length + ' Structures';
+ $("#totalTerms").empty();
+ //$('#totalTerms').innerHTML = '';
+
+ $('#totalTerms').append(termsTotal);
+ $rootScope.isLoading = false;
+ $('#spinner').css('visibility', 'hidden');
+ }
+ })
+
+ .error(function (data, status, headers, config) {
+ console.log(data);
+
+ });
+
+ }
+
+
+}]
+
+);
\ No newline at end of file
diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
index a62431a..591f38d 100644
--- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
+++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
@@ -130,10 +130,30 @@ AIA.controller("HomeController", ["$rootScope", "Modules", "$log", "$location",
}
$rootScope.OnIdentifyClick = function () {
- $rootScope.isIdetifyClicked = true;
- $rootScope.isDrawingToolSelected = false;
+ // $rootScope.isIdetifyClicked = true;
+ // $rootScope.isDrawingToolSelected = false;
+ $("#canvasPaint").css("display", "none");
+ $("#canvas").css("display", "none");
+
+ // $("#canvasPaint").css("z-index", "0");
+ // $("#canvas").css("z-index", "0");
+ $('.btnCursor').removeClass('activebtncolor');
+
}
+
+
+ $rootScope.DrawingMode = function () {
+
+ $('.btnCursor').addClass('activebtncolor');
+ $rootScope.switchCanvas();
+ $("#canvasPaint").css("display", "block");
+ $("#canvas").css("display", "block");
+
+ }
+
+
+
//----Annotation Toolbar: Jcanvas-----
$rootScope.DrawLine = function (e) {
@@ -175,13 +195,27 @@ AIA.controller("HomeController", ["$rootScope", "Modules", "$log", "$location",
$(".btn-annotation-rectangle").addClass("activebtncolor");
}
$rootScope.paintBrush = function () {
-
- $('.btnCursor').addClass('activebtncolor');
+ // debugger;
+ // $('.btnCursor').addClass('activebtncolor');
$rootScope.switchCanvasToPaintCanvas();
-
$rootScope.shapeType = "FreeStylePaint";
- //alert($rootScope.shapeType);
+ var a = $("#amount-2").val();
+ $rootScope.shapeSize = parseInt(a);
+ if ($rootScope.shapeSize == '')
+ {
+ $('#canvasPaint').sketch({ defaultSize: 1 });
+ }
+ else
+ {
+ $('#canvasPaint').sketch({ defaultSize: $rootScope.shapeSize });
+
+ }
+
+ // $('#canvasPaint').sketch();
+
+
+
}
$rootScope.switchCanvasToPaintCanvas = function (e) {
@@ -219,7 +253,8 @@ AIA.controller("HomeController", ["$rootScope", "Modules", "$log", "$location",
$('.btnCursor').removeClass('activebtncolor');
$(".btn-annotation").removeClass("activebtncolor");
$(".btn-annotation-Text").addClass("activebtncolor");
-
+ // $("#text_area").val('');
+ // $("#text_area").css({ " font-family": 'Verdana, sans-serif', "font-size": "14px", "font-weight": "normal", "font-style": "normal", "color": "#000", "text-align": "left", "text-decoration": "none" });
}
$rootScope.DrawPolygon = function () {
@@ -276,7 +311,18 @@ AIA.controller("HomeController", ["$rootScope", "Modules", "$log", "$location",
$rootScope.shapestyleborderWidth = intPart[0];
$rootScope.shapestyleborderStyles = "solid";
+<<<<<<< HEAD
// $('#editshapestyle').modal('hide');
+=======
+
+ $('#editshapestyle').modal('hide');
+ // name: 'Circle_' + $rootScope.resetCircle,
+
+
+ // $("#canvas").removeLayer("TextRect_" + $rootScope.resetTextRect).drawLayers();
+
+
+>>>>>>> Textarea_Text_Alignment
}
$rootScope.enableAnnotationToolBar = function () {
diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js.orig b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js.orig
new file mode 100644
index 0000000..749d001
--- /dev/null
+++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js.orig
@@ -0,0 +1,637 @@
+'use strict';
+
+AIA.controller("HomeController", ["$rootScope", "Modules", "$log", "$location", "$timeout",
+ function ($rootScope, Modules, $log, $location, $timeout) {
+
+ //$scope.pageToOpen = {
+ // name: 'MainMenu'
+ //};
+ $rootScope.pageToOpen = 'app/widget/MainMenu.html';
+ $rootScope.currentBodyViewId;
+ $rootScope.currentActiveModuleTitle = 'Welcome to A.D.A.M. Interactive Anatomy';//Modules[0].Name;
+ $rootScope.currentActiveViewTitle;
+ $rootScope.cuurentActiveModuleId;
+ $rootScope.openModules = [];
+ $rootScope.openViews = [];
+ $rootScope.currentSlug;
+ $rootScope.jsPanelTitle;
+ $rootScope.ViewTitle;
+ $rootScope.isLoading = false;
+ $rootScope.isAnnotationWindowOpen = false;
+ $rootScope.isDrawingToolSelected = false;
+ $rootScope.isIdetifyClicked = true;
+ $rootScope.paint = false;
+ $rootScope.clickX = new Array();
+ $rootScope.clickY = new Array();
+ $rootScope.clickDrag = new Array();
+ $rootScope.isLineDrawSelecyed = false;
+ $rootScope.isAnnotationWindowClose = false;
+ $rootScope.lastX;
+ $rootScope.lastY;
+ $rootScope.CommonData;
+ $rootScope.shapeType;
+ $rootScope.globalSetting = {
+ ethnicity: 'W',
+ modesty: 'Y',
+ };
+ $rootScope.formsetting = {
+ ethnicity: null,
+ modesty: null
+ };
+
+ $rootScope.isModestyOn;
+ $rootScope.isModestyOff;
+ $rootScope.SetSettingActiveTab;
+
+ //jspanel functionality..
+
+ $rootScope.openParent = function (slug) {
+ // debugger;
+ var openViews = $rootScope.openViews;
+ if (openViews.length > 0) {
+ $rootScope.openViews.splice(openViews.length - 1);
+ }
+ if (openViews.length > 0) {
+ var lastOpenMoudle = $rootScope.openViews[openViews.length - 1];
+ }
+ $('#daImagePanel').remove();
+ $location.url('/' + slug);
+
+ $rootScope.$broadcast('jsPanelCloseEvent', true);
+ }
+
+ //called on jsanel minimize
+ $rootScope.setState = function (state, title) {
+
+
+ var alreadyOpenThisView = new jinqJs()
+ .from($rootScope.openViews)
+ .where("body-views == " + title)
+ .select();
+ var k = 0;
+ if (alreadyOpenThisView != null) {
+ for (var i = 0; i < $rootScope.openViews.length; i++) {
+ k++;
+ if ($rootScope.openViews[i].body-views == title) {
+ $rootScope.openViews.splice((k - 1), 1);
+
+ $rootScope.openViews.push(
+ {
+ "module": $rootScope.currentActiveModuleTitle, "body-views": title, "state": state, "BodyViewId": $rootScope.currentBodyViewId,
+ "slug": $rootScope.currentSlug
+ }
+ );
+ }
+ }
+ }
+ if (state == 'max') {
+ $('#daBodyview').css('width', '100%')
+ }
+ }
+
+ $rootScope.DrawLine = function () {
+ //$rootScope.isIdetifyClicked = false;
+ //$rootScope.isDrawingToolSelected = true;
+ //$rootScope.isLineDrawSelecyed = true;
+ $rootScope.shapeType = "Line";
+ // alert($rootScope.shapeType);
+
+
+ }
+
+ $rootScope.ClearIframe = function () {
+ if ($('#daImagePanel') != null)
+ $('#daImagePanel').remove();
+
+ $rootScope.hideScrollbar();
+ }
+
+ //ends
+
+ $rootScope.hideScrollbar = function () {
+ $(".sidebar").mCustomScrollbar({
+ autoHideScrollbar: true,
+ //theme:"rounded"
+ });
+ }
+
+ //annotation tool custom events
+ $rootScope.ShowAnnotationWindow = function () {
+ $rootScope.isAnnotationWindowOpen = true;
+ $(".annotationTollbar").css("display", "block");
+ $rootScope.$broadcast('annotationToolEvent', true);
+
+ }
+
+ $rootScope.CloseAnnotationTool = function () {
+ console.log('close')
+ $(".annotationTollbar").css("display", "none");
+ $rootScope.isAnnotationWindowClose = true;
+ }
+
+ $rootScope.OnIdentifyClick = function () {
+ // $rootScope.isIdetifyClicked = true;
+ // $rootScope.isDrawingToolSelected = false;
+ $("#canvasPaint").css("display", "none");
+ $("#canvas").css("display", "none");
+
+ // $("#canvasPaint").css("z-index", "0");
+ // $("#canvas").css("z-index", "0");
+ $('.btnCursor').removeClass('activebtncolor');
+
+ }
+
+
+
+ $rootScope.DrawingMode = function () {
+
+ $('.btnCursor').addClass('activebtncolor');
+ $rootScope.switchCanvas();
+ $("#canvasPaint").css("display", "block");
+ $("#canvas").css("display", "block");
+
+ }
+
+
+
+ //----Annotation Toolbar: Jcanvas-----
+
+ $rootScope.DrawLine = function (e) {
+ $rootScope.switchCanvas();
+ $rootScope.shapeType = "Line";
+
+
+ $('.btnCursor').removeClass('activebtncolor');
+ $(".btn-annotation").removeClass("activebtncolor");
+ $(".btn-annotation-line").addClass("activebtncolor");
+
+
+ }
+
+
+ $rootScope.DrawPin = function (e) {
+ $rootScope.switchCanvas();
+ $rootScope.shapeType = "Pin";
+
+ $('.btnCursor').removeClass('activebtncolor');
+ $(".btn-annotation").removeClass("activebtncolor");
+ $(".btn-annotation-pin").addClass("activebtncolor");
+ }
+
+ $rootScope.Cursor = function () {
+ $rootScope.switchCanvas();
+ $rootScope.shapeType = "cursor";
+
+ $(".btn-annotation").removeClass("activebtncolor");
+ // $("#" + e.currentTarget.id).removeClass("activebtncolor");
+ $('.btnCursor').addClass('activebtncolor');
+ }
+
+ $rootScope.DrawRectangle = function (e) {
+ $rootScope.switchCanvas();
+ $rootScope.shapeType = "Rectangle";
+ $('.btnCursor').removeClass('activebtncolor');
+ $(".btn-annotation").removeClass("activebtncolor");
+ $(".btn-annotation-rectangle").addClass("activebtncolor");
+ }
+ $rootScope.paintBrush = function () {
+<<<<<<< HEAD
+ // debugger;
+ // $('.btnCursor').addClass('activebtncolor');
+=======
+
+ $('.btnCursor').addClass('activebtncolor');
+>>>>>>> db0b2ac40dc61ee08fb471800773516967978732
+ $rootScope.switchCanvasToPaintCanvas();
+ $rootScope.shapeType = "FreeStylePaint";
+ var a = $("#amount-2").val();
+ $rootScope.shapeSize = parseInt(a);
+ if ($rootScope.shapeSize == '')
+ {
+ $('#canvasPaint').sketch({ defaultSize: 1 });
+ }
+ else
+ {
+ $('#canvasPaint').sketch({ defaultSize: $rootScope.shapeSize });
+
+ }
+
+
+ // $('#canvasPaint').sketch();
+
+
+
+ }
+
+ $rootScope.switchCanvasToPaintCanvas = function (e) {
+ var canvasPaint_zIndex = $('#canvasPaint').css("z-index");
+ var canvas_zIndex = $('#canvas').css("z-index");
+ if (canvas_zIndex > canvasPaint_zIndex) {
+ canvasPaint_zIndex = parseInt(canvas_zIndex) + 1;
+
+ }
+ else {
+ canvasPaint_zIndex = parseInt(canvasPaint_zIndex) + 1;
+ }
+ $('#canvasPaint').css("z-index", canvasPaint_zIndex);
+ }
+
+ $rootScope.DrawCircle = function (e) {
+ $rootScope.switchCanvas();
+ $rootScope.shapeType = "Circle";
+ $('.btnCursor').removeClass('activebtncolor');
+ $(".btn-annotation").removeClass("activebtncolor");
+ $(".btn-annotation-circle").addClass("activebtncolor");
+ }
+
+ $rootScope.DrawArrow = function (e) {
+ $rootScope.switchCanvas();
+ $rootScope.shapeType = "Arrow";
+ $('.btnCursor').removeClass('activebtncolor');
+ $(".btn-annotation").removeClass("activebtncolor");
+ $(".btn-annotation-arrow").addClass("activebtncolor");
+ }
+ $rootScope.DrawText = function () {
+ $rootScope.switchCanvas();
+
+ $rootScope.shapeType = "TextArea";
+ $('.btnCursor').removeClass('activebtncolor');
+ $(".btn-annotation").removeClass("activebtncolor");
+ $(".btn-annotation-Text").addClass("activebtncolor");
+ // $("#text_area").val('');
+ // $("#text_area").css({ " font-family": 'Verdana, sans-serif', "font-size": "14px", "font-weight": "normal", "font-style": "normal", "color": "#000", "text-align": "left", "text-decoration": "none" });
+ }
+
+ $rootScope.DrawPolygon = function () {
+ $rootScope.shapeType = "DrawPolygon";
+
+ }
+
+
+ $rootScope.OpacityModal = function () {
+
+
+ }
+ $rootScope.switchCanvas = function () {
+ var x = $('#canvasPaint').css("z-index");
+
+ var y = $('#canvas').css("z-index");
+ if (x > y) {
+ y = parseInt(x) + 1;
+ } else {
+ y = parseInt(y) + 1;
+ }
+ $('#canvas').css("z-index", y);
+ }
+ $rootScope.EraseDrawing = function () {
+ $rootScope.switchCanvasToPaintCanvas();
+ // $('#canvasPaint').sketch({ defaultColor: "yellow", defaultSize: 1 });
+ var sktch = $('#canvasPaint').sketch();
+ $('#canvasPaint').sketch().actions = []; // this line empties the actions.
+ var myCanvas = document.getElementById("canvasPaint");
+ var ctx = myCanvas.getContext('2d');
+ ctx.clearRect(0, 0, myCanvas.width, myCanvas.height);
+ $rootScope.switchCanvas();
+
+ }
+
+ //opacity code
+ $rootScope.shapestyleOpacity = 1;
+ $rootScope.shapestyleFillColor = "#fff";
+ $rootScope.shapestyleFillBorderColor = "black";
+ $rootScope.shapestyleborderWidth = 2;
+ $rootScope.shapestyleborderStyles = "solid";
+ $rootScope.shapestyle = function (id) {
+
+ document.getElementById('modelbackground').style.display = "none";
+
+ $rootScope.shapestyleOpacity = $("#" + id).css('opacity');
+ $rootScope.shapestyleFillColor = $("#" + id).parent().css('background-color');
+ $rootScope.shapestyleborderColor = $("#" + id).parent().css("border-top-color");
+ $rootScope.shapestyleborderWidthSeparatingPixel = $("#" + id).parent().css("border-top-width");
+ var pixelSeparation = $rootScope.shapestyleborderWidthSeparatingPixel;
+ var intPart = pixelSeparation.split("p");
+
+ $rootScope.shapestyleborderWidth = intPart[0];
+ $rootScope.shapestyleborderStyles = "solid";
+
+<<<<<<< HEAD
+
+ $('#editshapestyle').modal('hide');
+ // name: 'Circle_' + $rootScope.resetCircle,
+
+
+ // $("#canvas").removeLayer("TextRect_" + $rootScope.resetTextRect).drawLayers();
+
+
+=======
+ $('#editshapestyle').modal('hide');
+>>>>>>> db0b2ac40dc61ee08fb471800773516967978732
+ }
+
+ $rootScope.enableAnnotationToolBar = function () {
+
+ document.getElementById('modelbackground').style.display = "block";
+ $("#editshapestyle").modal('show');
+
+ }
+
+ $rootScope.disableAnnotationToolBar = function () {
+
+ document.getElementById('modelbackground').style.display = "none";
+
+ }
+
+
+ //----End-------------
+
+ $rootScope.AddClick = function (x, y, dragging) {
+ $rootScope.clickX.push(x);
+ $rootScope.clickY.push(y);
+ $rootScope.clickDrag.push(dragging);
+ }
+
+ $rootScope.Redraw = function () {
+ var context = document.getElementById('paintCanvas').getContext('2d');
+
+ context.clearRect(0, 0, context.canvas.width, context.canvas.height); // Clears the canvas
+
+ context.strokeStyle = "#FFFFFF";
+ context.lineJoin = "round";
+ context.lineWidth = 5;
+
+
+ for (var i = 0; i < $rootScope.clickX.length; i++) {
+ context.beginPath();
+ if ($rootScope.clickDrag[i] && i) {
+ context.moveTo($rootScope.clickX[i - 1], $rootScope.clickY[i - 1]);
+ } else {
+ context.moveTo($rootScope.clickX[i] - 1, $rootScope.clickY[i]);
+ }
+ context.lineTo($rootScope.clickX[i], $rootScope.clickY[i]);
+ context.closePath();
+ context.stroke();
+ }
+ }
+
+ $rootScope.PaintCanvasMousedownListener = function (canvasContext, x, y) {
+ if ($rootScope.isLineDrawSelecyed == true) {
+
+ canvasContext.lineWidth = 0.1;
+ //$scope.paintCanvasContext.lineJoin = 'round';
+ //$scope.paintCanvasContext.lineCap = 'round';
+ canvasContext.strokeStyle = 'red';
+
+
+ canvasContext.beginPath();
+
+ //var canvasOffset = $("#myCanvas").offset();
+ //var offsetX = canvasOffset.left;
+ //var offsetY = canvasOffset.top;
+ canvasContext.moveTo(x, y);
+ }
+
+ }
+
+ $rootScope.PaintCanvasMouseupListener = function (canvasContext) {
+ if ($scope.isLineDrawSelecyed == true) {
+
+ }
+ }
+
+ $rootScope.PaintCanvasMousemoveListener = function (canvasContext, x, y) {
+ if ($rootScope.isLineDrawSelecyed == true) {
+ console.log('hm moving')
+ canvasContext.lineTo(x, y);
+ canvasContext.stroke();
+ }
+ }
+
+ $rootScope.Draw = function (x, y, isDown, context) {
+ if (isDown) {
+ context.beginPath();
+ context.strokeStyle = '#000000';
+ context.lineWidth = 1//$('#selWidth').val();
+ context.lineJoin = "round";
+ context.moveTo($rootScope.lastX, $rootScope.lastY);
+ context.lineTo(x, y);
+ context.closePath();
+ context.stroke();
+ }
+ $rootScope.lastX = x; $rootScope.lastY = y;
+ }
+
+
+
+
+ //list manager function
+
+ //list manager function
+
+ $rootScope.ShowListManager = function () {
+ console.log('ShowListManager')
+
+ $rootScope.isLoading = true;
+ $('#spinner').css('visibility', 'visible');
+
+ $('#listManager').css('display', 'block');
+ $("#listManager").css("visibility", "visible");
+ $('#listManager').draggable();
+
+
+ $rootScope.islistManagerEventAlredayDispachted = true;
+
+ $rootScope.$broadcast('listManagerEvent', true);
+ }
+
+ $rootScope.CloseListManager = function () {
+ console.log('close')
+ //$rootScope.isListManagerSelected = false;
+ $('#listManager').css('display', 'none');
+ $("#listManager").css("visibility", "hidden");
+ // $rootScope.isAnnotationWindowClose = true;
+ // if('#termList')
+ if ($('#termList option').length > 0) {
+ //$('#termList option') = null;
+ //$('#termList').innerHTML='';
+ $('#termList')
+ .find('option')
+ .remove()
+ .end()
+ if ($('#termList option').length > 0) {
+
+ }
+ }
+
+
+ }
+
+ function fillListManagerTerms() {
+
+ var len = $rootScope.openModules.length;
+ var openViewLen = $rootScope.openViews.length;
+
+ var currentOpenModuleId = $rootScope.openModules[len - 1].ModuleId;
+ var currentOpenViewId = $rootScope.openViews[openViewLen - 1].BodyViewId;
+ if (currentOpenModuleId == 1) {
+
+ }
+
+ }
+
+ //setrtings
+ $rootScope.SetSettingActiveTab = function (tabToSet) {
+ $rootScope.SettingsTab = tabToSet;
+ };
+
+ $rootScope.loadsettings = function () {
+
+ //1. For now we are by default opening DA settings tab
+ $rootScope.SettingsTab = 3;
+
+ //2.
+ var curentEthnicity = localStorage.getItem("globalEthnicity");
+ if (typeof (curentEthnicity) !== "undefined" && curentEthnicity !== null) {
+ $rootScope.globalSetting.ethnicity = curentEthnicity;
+ }
+ else {
+ localStorage.setItem("globalEthnicity", $rootScope.globalSetting.ethnicity);
+ }
+
+ var curentmodesty = localStorage.getItem("globalModesty");
+ if (typeof (curentmodesty) !== "undefined" && curentmodesty !== null) {
+ $rootScope.globalSetting.modesty = curentmodesty
+ }
+ else {
+ localStorage.setItem("globalModesty", $rootScope.globalSetting.modesty);
+ }
+
+ //3.
+ $rootScope.setModestySettings($rootScope.globalSetting.modesty);
+
+ //4.
+ $rootScope.setEthncitySettings($rootScope.globalSetting.ethnicity);
+
+
+ };
+
+ $rootScope.setModestySettings = function (currentmodsetting) {
+
+ if (currentmodsetting == 'Y') {
+ $rootScope.isModestyOn = true;
+ $rootScope.isModestyOff = false;
+ }
+ else {
+ $rootScope.isModestyOn = false;
+ $rootScope.isModestyOff = true;
+ }
+ }
+
+ $rootScope.setEthncitySettings = function (currentEthncitysetting) {
+
+ // this code is used for maintaing the currently selected Ethencity.
+ if (currentEthncitysetting == 'L') {
+ $("#btnEthnicA").addClass("skindefault");
+ if ($("#btnEthnicB").hasClass("skindefault")) { $("#btnEthnicB").removeClass("skindefault"); }
+ if ($("#btnEthnicL").hasClass("skindefault")) { $("#btnEthnicL").removeClass("skindefault"); }
+ if ($("#btnEthnicW").hasClass("skindefault")) { $("#btnEthnicW").removeClass("skindefault"); }
+ }
+ if (currentEthncitysetting == 'B') {
+ $("#btnEthnicB").addClass("skindefault");
+ if ($("#btnEthnicL").hasClass("skindefault")) { $("#btnEthnicL").removeClass("skindefault"); }
+ if ($("#btnEthnicW").hasClass("skindefault")) { $("#btnEthnicW").removeClass("skindefault"); }
+ if ($("#btnEthnicA").hasClass("skindefault")) { $("#btnEthnicA").removeClass("skindefault"); }
+ }
+ if (currentEthncitysetting == 'A') {
+ $("#btnEthnicL").addClass("skindefault");
+ if ($("#btnEthnicB").hasClass("skindefault")) { $("#btnEthnicB").removeClass("skindefault"); }
+ if ($("#btnEthnicW").hasClass("skindefault")) { $("#btnEthnicW").removeClass("skindefault"); }
+ if ($("#btnEthnicA").hasClass("skindefault")) { $("#btnEthnicA").removeClass("skindefault"); }
+ }
+ if (currentEthncitysetting == 'W') {
+ $("#btnEthnicW").addClass("skindefault");
+ if ($("#btnEthnicB").hasClass("skindefault")) { $("#btnEthnicB").removeClass("skindefault"); }
+ if ($("#btnEthnicL").hasClass("skindefault")) { $("#btnEthnicL").removeClass("skindefault"); }
+ if ($("#btnEthnicA").hasClass("skindefault")) { $("#btnEthnicA").removeClass("skindefault"); }
+ }
+ }
+
+ $rootScope.ChangeEthnicity = function (formsetting, skintone) {
+ formsetting.ethnicity = skintone;
+ $rootScope.setEthncitySettings(formsetting.ethnicity);
+
+ }
+
+ $rootScope.ChangeModesty = function (formsetting, modestyValue) {
+ formsetting.modesty = modestyValue;
+ $rootScope.setModestySettings(formsetting.modesty);
+
+ }
+
+ $rootScope.CloseSetting = function () {
+
+ $rootScope.setEthncitySettings($rootScope.globalSetting.ethnicity);
+ $rootScope.setModestySettings($rootScope.globalSetting.modesty);
+ $('#modal-settings').modal('hide');
+ }
+
+ $rootScope.UpdateAndCloseSetting = function (setting) {
+
+ $rootScope.UpdateSetting(setting);
+ $('#modal-settings').modal('hide');
+
+ };
+
+ $rootScope.UpdateSetting = function (setting) {
+
+ //1.
+ if (typeof (setting.ethnicity) !== "undefined" && setting.ethnicity !== null) {
+ $rootScope.ChangeEthnicity(setting, setting.ethnicity);
+ $rootScope.globalSetting.ethnicity = setting.ethnicity;
+ localStorage.setItem("globalEthnicity", $rootScope.globalSetting.ethnicity);
+ $rootScope.setEthncitySettings($rootScope.globalSetting.ethnicity);
+ }
+ if (typeof (setting.modesty) !== "undefined" && setting.modesty !== null) {
+ $rootScope.ChangeModesty(setting, setting.modesty);
+ $rootScope.globalSetting.modesty = setting.modesty;
+ localStorage.setItem("globalModesty", $rootScope.globalSetting.modesty);
+ $rootScope.setModestySettings($rootScope.globalSetting.modesty);
+ }
+
+ //2.
+ //localStorage.setItem("globalEthnicity", $rootScope.globalSetting.ethnicity);
+
+ //3.
+ //localStorage.setItem("globalModesty", $rootScope.globalSetting.modesty);
+
+ //4.
+ $rootScope.reloadChildController();
+
+ };
+
+ $rootScope.reloadChildController = function () {
+
+ var len = $rootScope.openModules.length;
+
+ var currentOpenModuleId = $rootScope.openModules[len - 1].ModuleId;
+
+ //checking is DA module is opend.
+ if (currentOpenModuleId == 1) {
+
+ //Check that what current bodyview is open
+ if ($rootScope.openViews.length > 0) {
+ var openViewLen = $rootScope.openViews.length;
+ var currentOpenViewId = $rootScope.openViews[openViewLen - 1].BodyViewId;
+ //$rootScope.isSettingEventAlredayDispachted = true;
+ $rootScope.$broadcast('reloadDABodyViewEvent', { reloadDABodyViewId: currentOpenViewId }, true);
+ }
+ else {
+ $rootScope.$broadcast('reloadDAControllerEvent', true);
+
+ }
+ }
+ };
+
+
+ }]
+);
\ No newline at end of file
diff --git a/400-SOURCECODE/AIAHTML5.Web/index.html b/400-SOURCECODE/AIAHTML5.Web/index.html
index 186a81f..8441b69 100644
--- a/400-SOURCECODE/AIAHTML5.Web/index.html
+++ b/400-SOURCECODE/AIAHTML5.Web/index.html
@@ -391,7 +391,7 @@
-
+
Mode
@@ -399,7 +399,7 @@
-
+
@@ -428,7 +428,7 @@
-
-
-
-
-
-