HomeController.js
5.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
'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.ClearIframe = function () {
if ($('#daImagePanel') != null)
$('#daImagePanel').remove();
$rootScope.hideScrollbar();
}
$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("visibility", "hidden");
$rootScope.isAnnotationWindowClose = true;
}
$rootScope.OnIdentifyClick = function () {
$rootScope.isIdetifyClicked = true;
$rootScope.isDrawingToolSelected = false;
}
//draw line on canvas
$rootScope.DrawLine = function () {
$rootScope.isIdetifyClicked = false;
$rootScope.isDrawingToolSelected = true;
$rootScope.isLineDrawSelecyed = true;
}
$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;
}
$rootScope.EraseDrawing = function () {
document.getElementById('paintCanvas').getContext('2d').setTransform(1, 0, 0, 1, 0, 0);
document.getElementById('paintCanvas').getContext('2d').clearRect(0, 0, document.getElementById('paintCanvas').getContext('2d').canvas.width, document.getElementById('paintCanvas').getContext('2d').canvas.height);
}
}]
);