'use strict'; AIA.controller("HomeController", ["$rootScope", "Modules", "$log", "$location", "$timeout", "DataService", function ($rootScope, Modules, $log, $location, $timeout, DataService) { //$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.setListManagerZindex = 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; $rootScope.disableMenuannotation = "disableMenuannotation"; $rootScope.disableMenuoption = "disableMenuoption"; $rootScope.menuLabExer; $rootScope.menuLabExer = 0; $rootScope.fontSizes; $rootScope.fontWeight; $rootScope.fontStyle; $rootScope.textAlignmt; $rootScope.fontColor; $rootScope.underlineText; $rootScope.textArea; $rootScope.fontFamily; $rootScope.TextPropertyArray = []; $rootScope.modifySavedText = []; $rootScope.TextRectangleArr = []; $rootScope.rectDimension = []; $rootScope.isEraseToolSelected = false; $rootScope.isMousedownOnPaintCanvas = false; $rootScope.$on("$locationChangeSuccess", function () { if (($location.url() == "/da-body-view") || ($location.url() == "/clinical-illustrations-detail") || ($location.url() == "/clinical-animations-detail")) { $rootScope.disableMenuannotation = " "; $rootScope.disableMenuoption = " "; } else { $rootScope.disableMenuannotation = "disableMenuannotation"; $rootScope.disableMenuoption = "disableMenuoption"; $rootScope.CloseAnnotationTool(); $rootScope.CloseListManager(); angular.element('#modal-settings').modal('hide'); if ($location.url() == "/lab-exercises") { $rootScope.menuLabExer = 0; } if ($rootScope.menuLabExer == 1) { $rootScope.disableMenuoption = " "; } } }); //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, "bodyView": 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" }); } $rootScope.isFontFamilyLoaded = false; //annotation tool custom events $rootScope.ShowAnnotationWindow = function () { //7904 if ($rootScope.MenuModuleName == "DA") { if ($rootScope.disableAnnotationtoolOnListManager == true) { $('#AnnotaionPopupDiv').find('input, textarea, button, select,img,div').attr('disabled', 'disabled'); $('#slider-range-min-2').slider('disable'); // $rootScope.disableAnnotationTB = false; } else { $('#AnnotaionPopupDiv').find('input, textarea, button, select,img,div').removeAttr('disabled', 'disabled'); $('#slider-range-min-2').slider('enable'); } // document.getElementById('modelbackground').style.display = "block"; // document.getElementById('modeleditstyle').style.display = "block"; } $("#OnIdentify").addClass("annotationtoolbartab"); $("#annotationToolBarOptions").addClass("active"); $("#annotationButton").addClass("active"); $rootScope.isAnnotationWindowOpen = true; $(".annotationTollbar").css("display", "block"); $rootScope.$broadcast('annotationToolEvent', true); $("#canvasPaint").css("display", "none"); $("#canvas").css("display", "none"); var FontFamilyJson = '~/../content/data/json/settings/fontstyle.json'; if ($rootScope.isFontFamilyLoaded == false) { DataService.getJson(FontFamilyJson) .then( function (result) { $rootScope.AnnotationFontFamily = result; // alert($rootScope.AnnotationFontFamily.FontStyle.length); for (var i = 0; i <= $rootScope.AnnotationFontFamily.FontFamily.length - 1; i++) { $("#selected-font-family").append(""); } $rootScope.isFontFamilyLoaded = true; }, function (error) { console.log(error.statusText) } ) } } $rootScope.CloseAnnotationTool = function () { console.log('close'); $("#OnIdentify").removeClass("annotationtoolbartab"); $("#DrawMode").removeClass("annotationtoolbartab"); $('.btnCursor').removeClass('activebtncolor'); $("#annotationButton").removeClass("active"); $("#annotationToolBarOptions").removeClass("active"); $(".annotationTollbar").css("display", "none"); $rootScope.isAnnotationWindowClose = true; $("#canvasPaint").css("display", "none"); $("#canvas").css("display", "none"); $('.btnCursor').removeClass('activebtncolor'); $(".btn-annotation").removeClass("activebtncolor"); } $rootScope.CIAnotationIdentifyModeOff = false; $rootScope.OnIdentifyClick = function () { $("#OnIdentify").addClass("annotationtoolbartab"); $("#DrawMode").removeClass("annotationtoolbartab"); // $rootScope.isIdetifyClicked = true; // $rootScope.isDrawingToolSelected = false; // debugger; if ($rootScope.CIAnotationIdentifyModeOff == true) { $('.btnCursor').removeClass('activebtncolor'); } else { $("#canvasPaint").css("display", "none"); $("#canvas").css("display", "none"); // $("#canvasPaint").css("z-index", "0"); // $("#canvas").css("z-index", "0"); $('.btnCursor').removeClass('activebtncolor'); } } $rootScope.DrawingMode = function () { $("#OnIdentify").removeClass("annotationtoolbartab"); $("#DrawMode").addClass("annotationtoolbartab"); $('.btnCursor').addClass('activebtncolor'); $rootScope.switchCanvas(); $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); } // Dissectible Anatomy > Settings should be disable if Annotation is Open. $rootScope.ShowSettingWindow = function () { if ($(".annotationTollbar").css("display") == "block") { // alert("already open"); } else { $('#modal-settings').modal('toggle'); } } //----Annotation Toolbar: Jcanvas----- $rootScope.DrLine = function (e) { $rootScope.setListManagerZindex = true; $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); $rootScope.switchCanvas(); $rootScope.shapeType = "Line"; $('.btnCursor').removeClass('activebtncolor'); $(".btn-annotation").removeClass("activebtncolor"); $(".btn-annotation-line").addClass("activebtncolor"); } $rootScope.DrPin = function (e) { $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); $rootScope.switchCanvas(); $rootScope.switchCanvas(); $rootScope.setListManagerZindex = true; $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.setListManagerZindex = true; $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); $rootScope.switchCanvas(); $rootScope.shapeType = "Rectangle"; $('.btnCursor').removeClass('activebtncolor'); $(".btn-annotation").removeClass("activebtncolor"); $(".btn-annotation-rectangle").addClass("activebtncolor"); } $rootScope.paintBrush = function () { // debugger; // $('.btnCursor').addClass('activebtncolor'); $rootScope.setListManagerZindex = true; $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); $rootScope.switchCanvasToPaintCanvas(); $rootScope.shapeType = "FreeStylePaint"; var btnBrushSizeValue = $("#btnBrushSize").val(); $rootScope.shapeSize = parseInt(btnBrushSizeValue); $("#annotationpaintbrushsize").attr("data-size", $rootScope.shapeSize); $("#annotationpaintbrushsize").attr("data-color", $rootScope.shapestyleFillColor); if ($rootScope.shapeSize == '') { $('#canvasPaint').sketch({ defaultSize: 1 }); } else { $('#canvasPaint').sketch(); } // $('#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.setListManagerZindex = true; $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); $rootScope.switchCanvas(); $rootScope.shapeType = "Circle"; $('.btnCursor').removeClass('activebtncolor'); $(".btn-annotation").removeClass("activebtncolor"); $(".btn-annotation-circle").addClass("activebtncolor"); } $rootScope.DrawArrow = function (e) { $rootScope.setListManagerZindex = true; $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); $rootScope.switchCanvas(); $rootScope.shapeType = "Arrow"; $('.btnCursor').removeClass('activebtncolor'); $(".btn-annotation").removeClass("activebtncolor"); $(".btn-annotation-arrow").addClass("activebtncolor"); } $rootScope.DrawText = function () { $rootScope.setListManagerZindex = true; $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); $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.setListManagerZindex = true; $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); $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.switchCanvas(); $rootScope.isEraseToolSelected = true; //$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) { // debugger; document.getElementById('modelbackground').style.display = "none"; document.getElementById('modeleditstyle').style.display = "none"; $rootScope.shapestyleOpacity = $("#" + id).css('opacity'); $("#shapeStyleDiv").parent().css("opacity", $rootScope.shapestyleOpacity); $rootScope.shapestyleFillColor = $("#" + id).css('background-color'); $("#shapeStyleDiv").css("background-color", $rootScope.shapestyleFillColor); $rootScope.shapestyleborderColor = $("#" + id).parent().css("border-top-color"); $("#shapeStyleDiv").parent().css("border-color", $rootScope.shapestyleborderColor); $rootScope.shapestyleborderWidthSeparatingPixel = $("#" + id).parent().css("border-top-width"); $("#shapeStyleDiv").parent().css("border-width", $rootScope.shapestyleborderWidthSeparatingPixel); var pixelSeparation = $rootScope.shapestyleborderWidthSeparatingPixel; var intPart = pixelSeparation.split("p"); $rootScope.shapestyleborderWidth = intPart[0]; $rootScope.shapestyleborderStyles = "solid"; $('#editshapestyle').modal('hide'); // name: 'Circle_' + $rootScope.resetCircle, // $("#canvas").removeLayer("TextRect_" + $rootScope.resetTextRect).drawLayers(); //Edit Shape Style popup should open at it's default position $("#modeleditstyle").css({ "left": "40%", "right": "0", "top": "70px" }); } $rootScope.enableAnnotationToolBar = function () { if ($rootScope.disableAnnotationTB == true) { document.getElementById('modelbackground').style.display = "none"; //$("#editshapestyle").modal('show'); document.getElementById('modeleditstyle').style.display = "none"; } else { document.getElementById('modelbackground').style.display = "block"; //$("#editshapestyle").modal('show'); document.getElementById('modeleditstyle').style.display = "block"; if ($('#modeleditstyle').css("display") == "block") { //Check if the modal is already showing var previewOpacity = $('#imgOpacity').css("opacity"); $('#slider-range-min-4 div.ui-slider-range-min').css("width", (previewOpacity * 100) + "%"); $('#slider-range-min-4 span.ui-slider-handle').css("left", (previewOpacity * 100) + "%"); }; } } $rootScope.enableEditShapeTooltip = function () { $("#edit-block").addClass("custom-tooltip-annotation"); $(".custom-tooltip-annotation").css('display', 'block'); } $rootScope.disableEditShapeTooltip = function () { $(".custom-tooltip-annotation").css('display', 'none'); $("#edit-block").removeClass("custom-tooltip-annotation"); } $rootScope.disableAnnotationToolBar = function () { document.getElementById('modelbackground').style.display = "none"; document.getElementById('modeleditstyle').style.display = "none"; //Edit Shape Style popup should open at it's default position $("#modeleditstyle").css({ "left": "40%", "right": "0", "top": "70px" }); } //----End------------- //--Common code of Annotation Toolbar for CI and DA------- $rootScope.LineFn = function (canvasId, LineNumber, shapestyleborderColor, shapestyleborderWidth, offsetX1, offsetY1, x, y) { if ($rootScope.islineMoved == true) { $rootScope.islineMoved = false; $(canvasId).addLayer({ name: 'Line_' + LineNumber, layer: true, type: 'line', draggable: true, strokeStyle: shapestyleborderColor, strokeWidth: shapestyleborderWidth, rounded: true, x1: offsetX1, y1: offsetY1, x2: x, y2: y, click: function (layer) { $rootScope.canvasLayerNameCollection = []; $rootScope.canvasLayerNameCollection.push(layer.name); $(canvasId).setLayer(layer.name, { handle: { type: 'arc', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 2, radius: 3 } }).drawLayers(); }, mouseout: function (layer) { $rootScope.canvasLayerNameCollection = []; $(canvasId).setLayer(layer.name, { handle: { type: 'arc', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 0, radius: 0 } }).drawLayers(); }, mouseover: function (layer) { $(canvasId).setLayer(layer.name, { handle: { type: 'arc', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 2, radius: 3 } }).drawLayers(); } }).drawLayers(); } $('.btnCursor').trigger('click'); $(".btn-annotation").removeClass("activebtncolor"); $('.btnCursor').addClass('activebtncolor'); } $rootScope.RectangleFn = function (canvasId, RectNumber, shapestyleFillColor, shapestyleborderColor, shapestyleOpacity, shapestyleborderWidth, offsetX1, offsetY1, x, y) { if ($rootScope.isrectangleMoved == true) { $rootScope.isrectangleMoved = false; $(canvasId).addLayer({ layer: true, name: 'Rect_' + RectNumber, fillStyle: shapestyleFillColor, type: 'rectangle', draggable: true, strokeStyle: shapestyleborderColor, opacity: shapestyleOpacity, strokeWidth: shapestyleborderWidth, fromCenter: false, x: offsetX1, y: offsetY1, width: (x - offsetX1), height: (y - offsetY1), resizeFromCenter: false, dblclick: function () { // $rootScope.backOpacity(); }, click: function (layer) { $rootScope.canvasLayerNameCollection = []; $rootScope.canvasLayerNameCollection.push(layer.name); $(canvasId).setLayer(layer.name, { handle: { type: 'rectangle', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 2, width: 5, height: 5, cornerRadius: 3 } }).drawLayers(); }, mouseout: function (layer) { $rootScope.canvasLayerNameCollection = []; $(canvasId).setLayer(layer.name, { handle: { type: 'rectangle', fillStyle: 'pink', strokeStyle: 'yellow', strokeWidth: 0, width: 0, height: 0, cornerRadius: 0 } }).drawLayers(); }, mouseover: function (layer) { $(canvasId).setLayer(layer.name, { handle: { type: 'rectangle', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 2, width: 5, height: 5, cornerRadius: 3 } }).drawLayers(); } }).drawLayers(); } $('.btnCursor').trigger('click'); $(".btn-annotation").removeClass("activebtncolor"); $('.btnCursor').addClass('activebtncolor'); } $rootScope.CircleFn = function (canvasId, CircleNumber, shapestyleOpacity, shapestyleborderColor, shapestyleborderWidth, shapestyleFillColor, offsetX1, offsetY1, x, y) { // console.log("up"+ offsetX1 + " " + offsetY1 + " " + (x - offsetX1) + " " + (y - offsetY1)); if ($rootScope.iscircleMoved == true) { $rootScope.iscircleMoved = false; $(canvasId).addLayer({ layer: true, name: 'Circle_' + CircleNumber, type: 'ellipse', opacity: shapestyleOpacity, draggable: true, strokeStyle: shapestyleborderColor, strokeWidth: shapestyleborderWidth, fillStyle: shapestyleFillColor, fromCenter: false, x: (offsetX1), y: (offsetY1), width: (x - offsetX1), height: (y - offsetY1), // Place a handle at each side and each corner handlePlacement: 'both', click: function (layer) { $rootScope.canvasLayerNameCollection = []; $rootScope.canvasLayerNameCollection.push(layer.name); $(canvasId).setLayer(layer.name, { handle: { type: 'arc', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 2, radius: 3 } }).drawLayers(); }, mouseout: function (layer) { $rootScope.canvasLayerNameCollection = []; $(canvasId).setLayer(layer.name, { handle: { type: 'arc', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 0, // width: 0, height: 0, radius: 0 } }).drawLayers(); }, mouseover: function (layer) { $(canvasId).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'); } $rootScope.ArrowFn = function (canvasId, ArrowNumber, shapestyleborderColor, shapestyleborderWidth, offsetX1, offsetY1, x, y) { if ($rootScope.isarrowMoved == true) { $rootScope.isarrowMoved = false; $('#canvas').drawLine({ layer: true, name: 'Arrow_' + ArrowNumber, draggable: true, strokeStyle: shapestyleborderColor, strokeWidth: shapestyleborderWidth, rounded: true, startArrow: true, arrowRadius: 7, arrowAngle: 90, x1: offsetX1, y1: offsetY1, x2: x, y2: y, click: function (layer) { $rootScope.canvasLayerNameCollection = []; $rootScope.canvasLayerNameCollection.push(layer.name); $(canvasId).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 = []; $(canvasId).setLayer(layer.name, { handle: { type: 'arc', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 0, // width: 0, height: 0, radius: 0 } }).drawLayers(); }, mouseover: function (layer) { $(canvasId).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'); } $rootScope.PinFn = function (canvasId, PinNumber, offsetX1, offsetY1, x, y, PinArcNumber) { if ($rootScope.isPinMoved == true) { $rootScope.isPinMoved = false; var radial = $('#canvas').createGradient({ x1: 50, y1: 50, x2: 50, y2: 50, r1: 10, r2: 30, c1: 'rgba(100, 50, 0,0)', c2: 'grey' }); $(canvasId).drawLine({ draggable: true, layer: true, name: "Pin_" + PinNumber, groups: ["Pin_" + PinNumber], dragGroups: ["Pin_" + PinNumber], strokeStyle: 'black', strokeWidth: 2, x1: offsetX1, y1: offsetY1, x2: x, y2: y, click: function (layer) { $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 }); $(canvasId).setLayer(layer.name, { handle: { type: 'arc', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 2, // width: 5, height: 5, radius: 3 } }).drawLayers(); }, mouseout: function (layer) { $rootScope.canvasLayerNameCollection = []; $(canvasId).setLayer(layer.name, { handle: { type: 'arc', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 0, // width: 0, height: 0, radius: 0 } }).drawLayers(); }, mouseover: function (layer) { $(canvasId).setLayer(layer.name, { handle: { type: 'arc', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 2, // width: 5, height: 5, radius: 3 } }).drawLayers(); } }).drawArc({ draggable: true, name: "ArcPin_" + PinArcNumber, // name: "Pin_" + $rootScope.resetPin, layer: true, groups: ["Pin_" + PinNumber], dragGroups: ["Pin_" + PinNumber], strokeStyle: 'grey', strokeWidth: 2, fillStyle: radial, x: offsetX1, y: offsetY1, radius: 5, //handle: { // type: 'arc', // fillStyle: '#fff', // strokeStyle: '#c33', // strokeWidth: 2, // radius: 3 //}, add: function (layer) { $rootScope.PinArcNumber = layer.name; // $scope.arr = []; }, }).drawLayers(); } $('.btnCursor').trigger('click'); $(".btn-annotation").removeClass("activebtncolor"); $('.btnCursor').addClass('activebtncolor'); } $rootScope.TextAreaFn = function (canvasId, TextNumber, offsetX1, offsetY1, resetTextRect, shapestyleOpacity, shapestyleborderColor, shapestyleborderWidth, shapestyleFillColor, x, y) { if ($rootScope.istextAreaMoved == true) { $rootScope.istextAreaMoved = false; $('#canvas').drawText({ layer: true, draggable: true, // opacity: $rootScope.shapestyleOpacity, name: 'TextArea_' + $rootScope.TextNumber, groups: ['TextArea_' + $rootScope.TextNumber], dragGroups: ['TextArea_' + $rootScope.TextNumber], fillStyle: '#36c', strokeWidth: 0, x: $rootScope.offsetX1, y: $rootScope.offsetY1, fromCenter: false, fontSize: '14pt', align: "left", fontFamily: 'Verdana, sans-serif', text: '', add: function (layer) { $rootScope.TextID = layer.name; } }) // Draw rect as wide as the text .drawRect({ layer: true, name: "TextRect_" + $rootScope.TextNumber, dragGroups: ['shapes'], opacity: $rootScope.shapestyleOpacity, strokeStyle: $rootScope.shapestyleborderColor, fromCenter: false, strokeWidth: $rootScope.shapestyleborderWidth, fillStyle: $rootScope.shapestyleFillColor, x: $rootScope.offsetX1, y: $rootScope.offsetY1, width: ($rootScope.x - $rootScope.offsetX1), height: ($rootScope.y - $rootScope.offsetY1), add: function (layer) { $rootScope.TextAreaRectID = layer.name; $rootScope.rectDimension.push({ width: layer.width, height: layer.height, x: layer.x, y: layer.y }); // $rootScope.CurrentWidth = layer.width; // $rootScope.CurrentHeight = layer.height; }, 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(); }, dblclick: function (layer) { $rootScope.IsTextAlreadySave = false; var RectNameArray = (layer.name).split("_"); var TextAreaRectangleName = "TextArea_"; var TextAreaRectNameConcat = TextAreaRectangleName.concat(RectNameArray[1]); $rootScope.TextAreaRectID = layer.name; $rootScope.TextID = TextAreaRectNameConcat; $rootScope.rectDimension.push({ width: layer.width, height: layer.height, x: layer.x, y: layer.y }); $("#annotationTextModal").css("padding-right", "0px"); document.getElementById('modelbackground').style.display = "block"; $("#annotationTextModal").modal("toggle"); $("#text_area").val(''); $("#text_area").css({ "font-family": "Arial", "font-size": "14px", "font-weight": "normal", "font-style": "normal", "color": "#000", "text-align": "left", "text-decoration": "none" }); $("#font-color .minicolors .minicolors-swatch .minicolors-swatch-color").css({ "background-color": "#000000" }); // $("#font-color .minicolors .minicolors-swatch .minicolors-swatch-color").addClass("ActiveDefaultColorAnnotation"); $("#selected-font-family option:eq(0)").prop('selected', true); $("#selected-font-size option:eq(0)").prop('selected', true); $("#text-italic").removeClass("ActiveFormattingButtonClass"); $("#text-bold").removeClass("ActiveFormattingButtonClass"); $("#text-underline").removeClass("ActiveFormattingButtonClass"); $("#text-left").removeClass("ActiveFormattingButtonClass"); $("#text-right").removeClass("ActiveFormattingButtonClass"); $("#text-center").removeClass("ActiveFormattingButtonClass"); }, 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(); } }); // Annotation: Edit Text option is missing. $("#annotationTextModal").css("padding-right", "0px"); $("#annotationTextModal").modal("toggle"); document.getElementById('modelbackground').style.display = "block"; } $('.btnCursor').trigger('click'); $("#font-color .minicolors .minicolors-swatch .minicolors-swatch-color").css({ "background-color": "#000000" }); $("#text_area").val(''); $("#text_area").css({ "font-family": "Arial", "font-size": "14px", "font-weight": "normal", "font-style": "normal", "color": "#000", "text-align": "left", "text-decoration": "none" }); $("#selected-font-family option:eq(0)").prop('selected', true); $("#selected-font-size option:eq(0)").prop('selected', true); // $("#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" }); $("#text-italic").removeClass("ActiveFormattingButtonClass"); $("#text-bold").removeClass("ActiveFormattingButtonClass"); $("#text-underline").removeClass("ActiveFormattingButtonClass"); $("#text-left").removeClass("ActiveFormattingButtonClass"); $("#text-right").removeClass("ActiveFormattingButtonClass"); $("#text-center").removeClass("ActiveFormattingButtonClass"); $(".btn-annotation").removeClass("activebtncolor"); $('.btnCursor').addClass('activebtncolor'); } $rootScope.clicked = true; $rootScope.offsetX1 = 0; $rootScope.offsetY1 = 0; $rootScope.x = 0; $rootScope.y = 0; $rootScope.mousePressed = false; $rootScope.lastX; $rootScope.lastY; var ctx; $rootScope.OnPaintCanvasMouseDown = function (event) { var canvasElement = document.getElementById("canvas"); var ctx = canvasElement.getContext("2d"); // var x = event.clientX; // var y = event.clientY; $rootScope.offsetX1 = 0; $rootScope.offsetY1 = 0; var canvasDiv = document.getElementById('canvasDiv'); var verticalScrollPosition = canvasDiv.scrollTop; var horizontlScrollPosition = canvasDiv.scrollLeft; $rootScope.offsetX1 = event.offsetX; $rootScope.offsetY1 = event.offsetY; ctx.clearRect(0, 0, 2277, 3248); $rootScope.clicked = true; // alert("x:"+$rootScope.offsetX1 + " y:" + $rootScope.offsetY1); canvasElement.addEventListener('mousemove', $rootScope.OnPaintCanvasMouseMove, false); } $rootScope.rectNumber = 0; $rootScope.LineNumber = 0; $rootScope.CircleNumber = 0; $rootScope.ArrowNumber = 0; $rootScope.PinNumber = 0; $rootScope.PinArcNumber = 0; $rootScope.ObjectIndex = 0; $rootScope.ArcObjectIndex = 0; $rootScope.PinObjectIndex = 0; $rootScope.TextNumber = 0; $rootScope.resetTextSave = 0; $rootScope.ObjectIndexSave = 0; var arrayRect = {}; var storeLine = ''; $rootScope.OnPaintCanvasMouseUp = function (event) { if (!$rootScope.clicked) { return; } var AnnotationCanvas = document.getElementById('canvas'); AnnotationCanvas.removeEventListener('mousemove', $rootScope.OnPaintCanvasMouseMove, false); $(".line").remove(); $(".arrow").remove(); $(".pin").remove(); $(".circle").remove(); $(".rectangle").remove(); $(".textarea").remove(); $rootScope.clicked = false; $rootScope.x = 0; $rootScope.y = 0; var canvasDiv = document.getElementById('canvasDiv'); var verticalScrollPosition = canvasDiv.scrollTop; var horizontlScrollPosition = canvasDiv.scrollLeft; $rootScope.x = event.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left; $rootScope.y = event.pageY + verticalScrollPosition - $('#canvasDiv').offset().top; var canvasElement = document.getElementById("canvas"); var ctx = canvasElement.getContext("2d"); var canvasPaintElement = document.getElementById("canvasPaint"); var PaintCanvasctx = canvasPaintElement.getContext("2d"); switch ($rootScope.shapeType) { case "cursor": ctx.beginPath(); PaintCanvasctx.beginPath(); break; case "Line": $rootScope.LineNumber = $rootScope.ObjectIndex++; $rootScope.LineFn('#canvas', $rootScope.LineNumber, $rootScope.shapestyleborderColor, $rootScope.shapestyleborderWidth, $rootScope.offsetX1, $rootScope.offsetY1, $rootScope.x, $rootScope.y) break; case "Rectangle": $rootScope.rectNumber = $rootScope.ObjectIndex++; $rootScope.RectangleFn('#canvas', $rootScope.rectNumber, $rootScope.shapestyleFillColor, $rootScope.shapestyleborderColor, $rootScope.shapestyleOpacity, $rootScope.shapestyleborderWidth, $rootScope.offsetX1, $rootScope.offsetY1, $rootScope.x, $rootScope.y); break; case "Circle": $rootScope.CircleNumber = $rootScope.ObjectIndex++; $rootScope.CircleFn('#canvas', $rootScope.CircleNumber, $rootScope.shapestyleOpacity, $rootScope.shapestyleborderColor, $rootScope.shapestyleborderWidth, $rootScope.shapestyleFillColor, $rootScope.offsetX1, $rootScope.offsetY1, $rootScope.x, $rootScope.y); break; case "Arrow": $rootScope.ArrowNumber = $rootScope.ObjectIndex++; $rootScope.ArrowFn('#canvas', $rootScope.ArrowNumber, $rootScope.shapestyleborderColor, $rootScope.shapestyleborderWidth, $rootScope.offsetX1, $rootScope.offsetY1, $rootScope.x, $rootScope.y); break; case "Pin": $rootScope.PinNumber = $rootScope.PinObjectIndex++; $rootScope.PinArcNumber = $rootScope.ArcObjectIndex++; $rootScope.PinFn('#canvas', $rootScope.PinNumber, $rootScope.offsetX1, $rootScope.offsetY1, $rootScope.x, $rootScope.y, $rootScope.PinArcNumber); break; case "TextArea": $rootScope.IsTextAlreadySave = false; $("#text_area").val(''); // Draw text $rootScope.resetTextRect = $rootScope.ObjectIndex++; $rootScope.TextNumber = $rootScope.ObjectIndex++; $rootScope.TextAreaFn('#canvas', $rootScope.TextNumber, $rootScope.offsetX1, $rootScope.offsetY1, $rootScope.resetTextRect, $rootScope.shapestyleOpacity, $rootScope.shapestyleborderColor, $rootScope.shapestyleborderWidth, $rootScope.shapestyleFillColor, $rootScope.x, $rootScope.y); break; case "DrawPolygon": break; } //} } $rootScope.OnPaintCanvasMouseMove = function (event) { var canvasDiv = document.getElementById('canvasDiv'); var verticalScrollPosition = canvasDiv.scrollTop; var horizontlScrollPosition = canvasDiv.scrollLeft; $rootScope.MouseMoveXAxis = event.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left; $rootScope.MouseMoveYAxis = event.pageY + verticalScrollPosition - $('#canvasDiv').offset().top; switch ($rootScope.shapeType) { case "Line": $(".line").remove(); $rootScope.islineMoved = true; // console.log($rootScope.MouseMoveXAxis - $rootScope.offsetX1); $("#canvasDiv").append("
"); $rootScope.Annotationangle(); break; case "Arrow": $(".arrow").remove(); $rootScope.isarrowMoved = true; $("#canvasDiv").append("