|
|
|
@ -89,6 +89,10 @@ export class ImageLabel2Component implements OnInit {
|
|
|
|
|
this.camerasData.dimensionedPoints = { |
|
|
|
|
polygon: [], |
|
|
|
|
arrow: [], |
|
|
|
|
arrowOfSouth: [], |
|
|
|
|
arrowOfWest: [], |
|
|
|
|
arrowOfEast: [], |
|
|
|
|
arrowOfNorth: [], |
|
|
|
|
rectangle: [], |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -104,6 +108,12 @@ export class ImageLabel2Component implements OnInit {
|
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
this.camerasData.dimensionedPoints.arrow = this.arrowPoints |
|
|
|
|
|
|
|
|
|
this.camerasData.dimensionedPoints.arrowOfSouth = this.arrowPointsOfSouth |
|
|
|
|
this.camerasData.dimensionedPoints.arrowOfWest = this.arrowPointsOfWest |
|
|
|
|
this.camerasData.dimensionedPoints.arrowOfEast = this.arrowPointsOfEast |
|
|
|
|
this.camerasData.dimensionedPoints.arrowOfNorth = this.arrowPointsOfNorth |
|
|
|
|
|
|
|
|
|
this.camerasData.dimensionedPoints.rectangle = this.oblongPoints |
|
|
|
|
} else if (this.markType === 3) { |
|
|
|
|
if (this.arrowPoints.length != 2) { |
|
|
|
@ -111,9 +121,11 @@ export class ImageLabel2Component implements OnInit {
|
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
this.camerasData.dimensionedPoints.arrow = this.arrowPoints |
|
|
|
|
this.camerasData.dimensionedPoints.arrowOfSouth = this.arrowPointsOfSouth |
|
|
|
|
} |
|
|
|
|
let paramsData = JSON.parse(JSON.stringify(this.camerasData)) |
|
|
|
|
paramsData.dimensionedPoints = JSON.stringify(paramsData.dimensionedPoints) |
|
|
|
|
console.log('标点结果', this.camerasData.dimensionedPoints) |
|
|
|
|
this.http.put(`/api/Cameras/${this.camerasData.id}/DimensionedPoints`, paramsData).subscribe(data => { |
|
|
|
|
this.message.create('success', '保存成功!'); |
|
|
|
|
const isFullScreen = document.fullscreenElement |
|
|
|
@ -183,11 +195,28 @@ export class ImageLabel2Component implements OnInit {
|
|
|
|
|
}); |
|
|
|
|
} else if (this.markType === 2) { |
|
|
|
|
this.arrowPoints = this.camerasData.dimensionedPoints.arrow |
|
|
|
|
if (this.camerasData.dimensionedPoints.arrowOfSouth && this.camerasData.dimensionedPoints.arrowOfSouth.length != 0) { |
|
|
|
|
this.arrowPointsOfSouth = this.camerasData.dimensionedPoints.arrowOfSouth |
|
|
|
|
} |
|
|
|
|
if (this.camerasData.dimensionedPoints.arrowOfWest && this.camerasData.dimensionedPoints.arrowOfWest.length != 0) { |
|
|
|
|
this.arrowPointsOfWest = this.camerasData.dimensionedPoints.arrowOfWest |
|
|
|
|
} |
|
|
|
|
if (this.camerasData.dimensionedPoints.arrowOfEast && this.camerasData.dimensionedPoints.arrowOfEast.length != 0) { |
|
|
|
|
this.arrowPointsOfEast = this.camerasData.dimensionedPoints.arrowOfEast |
|
|
|
|
} |
|
|
|
|
if (this.camerasData.dimensionedPoints.arrowOfNorth && this.camerasData.dimensionedPoints.arrowOfNorth.length != 0) { |
|
|
|
|
this.arrowPointsOfNorth = this.camerasData.dimensionedPoints.arrowOfNorth |
|
|
|
|
} |
|
|
|
|
this.oblongPoints = this.camerasData.dimensionedPoints.rectangle |
|
|
|
|
this.drawLine(this.arrowPoints, context) |
|
|
|
|
let arr = [this.arrowPoints, this.arrowPointsOfSouth, this.arrowPointsOfWest, this.arrowPointsOfEast, this.arrowPointsOfNorth] |
|
|
|
|
this.drawLine(arr, context) |
|
|
|
|
} else if (this.markType === 3) { |
|
|
|
|
this.arrowPoints = this.camerasData.dimensionedPoints.arrow |
|
|
|
|
this.drawLine(this.arrowPoints, context) |
|
|
|
|
if (this.camerasData.dimensionedPoints.arrowOfSouth && this.camerasData.dimensionedPoints.arrowOfSouth.length != 0) { |
|
|
|
|
this.arrowPointsOfSouth = this.camerasData.dimensionedPoints.arrowOfSouth |
|
|
|
|
} |
|
|
|
|
let arr = [this.arrowPoints, this.arrowPointsOfSouth] |
|
|
|
|
this.drawLine(arr, context) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -195,6 +224,7 @@ export class ImageLabel2Component implements OnInit {
|
|
|
|
|
|
|
|
|
|
markType: number = 0; //0=进出口,2=卸油区,3=便利店,
|
|
|
|
|
isDrawArrow: boolean = true; //绘制type 箭头/矩形
|
|
|
|
|
arrowDirection = null |
|
|
|
|
oilUnloadingArea: boolean = true; //卸油区type 泄油管区域/静电接地仪
|
|
|
|
|
//记录鼠标点击位置
|
|
|
|
|
downx = 0; |
|
|
|
@ -204,6 +234,10 @@ export class ImageLabel2Component implements OnInit {
|
|
|
|
|
clearCanvas() { |
|
|
|
|
// 清空标绘箭头
|
|
|
|
|
this.arrowPoints = []; |
|
|
|
|
this.arrowPointsOfSouth = []; //南 箭头的点的集合
|
|
|
|
|
this.arrowPointsOfWest = []; //西 箭头的点的集合
|
|
|
|
|
this.arrowPointsOfEast = []; //东 箭头的点的集合
|
|
|
|
|
this.arrowPointsOfNorth = []; //北 箭头的点的集合
|
|
|
|
|
// 清空标绘箭头
|
|
|
|
|
// 清空标绘矩形
|
|
|
|
|
this.oblongPoints = []; |
|
|
|
@ -240,12 +274,36 @@ export class ImageLabel2Component implements OnInit {
|
|
|
|
|
canvas.onmousemove = (ev) => { //鼠标移动事件
|
|
|
|
|
var moveX = ev.pageX - canvas.offsetLeft; |
|
|
|
|
var moveY = ev.pageY - canvas.offsetTop; |
|
|
|
|
if (this.isDrawArrow) { //绘制 箭头
|
|
|
|
|
if (this.isDrawArrow && !this.arrowDirection) { //绘制 箭头
|
|
|
|
|
if (this.arrowPoints.length === 2) { //限制数量
|
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
context.lineTo(moveX, moveY); |
|
|
|
|
context.stroke(); |
|
|
|
|
} else if (this.isDrawArrow && this.arrowDirection == 'South') { |
|
|
|
|
if (this.arrowPointsOfSouth.length === 2) { //限制数量
|
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
context.lineTo(moveX, moveY); |
|
|
|
|
context.stroke(); |
|
|
|
|
} else if (this.isDrawArrow && this.arrowDirection == 'West') { |
|
|
|
|
if (this.arrowPointsOfWest.length === 2) { //限制数量
|
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
context.lineTo(moveX, moveY); |
|
|
|
|
context.stroke(); |
|
|
|
|
} else if (this.isDrawArrow && this.arrowDirection == 'East') { |
|
|
|
|
if (this.arrowPointsOfEast.length === 2) { //限制数量
|
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
context.lineTo(moveX, moveY); |
|
|
|
|
context.stroke(); |
|
|
|
|
} else if (this.isDrawArrow && this.arrowDirection == 'North') { |
|
|
|
|
if (this.arrowPointsOfNorth.length === 2) { //限制数量
|
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
context.lineTo(moveX, moveY); |
|
|
|
|
context.stroke(); |
|
|
|
|
} else { //绘制 矩形
|
|
|
|
|
if (this.oblongPoints.length === 2) { //限制数量
|
|
|
|
|
return |
|
|
|
@ -268,7 +326,7 @@ export class ImageLabel2Component implements OnInit {
|
|
|
|
|
} |
|
|
|
|
var upX = e.pageX - canvas.offsetLeft; |
|
|
|
|
var upY = e.pageY - canvas.offsetTop; |
|
|
|
|
if (this.isDrawArrow) { //绘制 箭头
|
|
|
|
|
if (this.isDrawArrow && !this.arrowDirection) { //绘制 箭头
|
|
|
|
|
if (this.arrowPoints.length === 2) { //限制数量
|
|
|
|
|
this.message.create('warning', '绘制数量已达上限!'); |
|
|
|
|
return |
|
|
|
@ -280,7 +338,68 @@ export class ImageLabel2Component implements OnInit {
|
|
|
|
|
endY: upY, |
|
|
|
|
} |
|
|
|
|
this.arrowPoints.push(point); |
|
|
|
|
this.drawLine(this.arrowPoints, context) |
|
|
|
|
let arr = [this.arrowPoints, this.arrowPointsOfSouth, this.arrowPointsOfWest, this.arrowPointsOfEast, this.arrowPointsOfNorth] |
|
|
|
|
this.drawLine(arr, context) |
|
|
|
|
} else if (this.isDrawArrow && this.arrowDirection == 'South') { |
|
|
|
|
console.log('South') |
|
|
|
|
if (this.arrowPointsOfSouth.length === 2) { //限制数量
|
|
|
|
|
this.message.create('warning', '绘制数量已达上限!'); |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
let point = { |
|
|
|
|
startX: this.downx, |
|
|
|
|
startY: this.downy, |
|
|
|
|
endX: upX, |
|
|
|
|
endY: upY, |
|
|
|
|
} |
|
|
|
|
this.arrowPointsOfSouth.push(point); |
|
|
|
|
let arr = [this.arrowPoints, this.arrowPointsOfSouth, this.arrowPointsOfWest, this.arrowPointsOfEast, this.arrowPointsOfNorth] |
|
|
|
|
this.drawLine(arr, context) |
|
|
|
|
} else if (this.isDrawArrow && this.arrowDirection == 'West') { |
|
|
|
|
console.log('West') |
|
|
|
|
if (this.arrowPointsOfWest.length === 2) { //限制数量
|
|
|
|
|
this.message.create('warning', '绘制数量已达上限!'); |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
let point = { |
|
|
|
|
startX: this.downx, |
|
|
|
|
startY: this.downy, |
|
|
|
|
endX: upX, |
|
|
|
|
endY: upY, |
|
|
|
|
} |
|
|
|
|
this.arrowPointsOfWest.push(point); |
|
|
|
|
let arr = [this.arrowPoints, this.arrowPointsOfSouth, this.arrowPointsOfWest, this.arrowPointsOfEast, this.arrowPointsOfNorth] |
|
|
|
|
this.drawLine(arr, context) |
|
|
|
|
} else if (this.isDrawArrow && this.arrowDirection == 'East') { |
|
|
|
|
console.log('East') |
|
|
|
|
if (this.arrowPointsOfEast.length === 2) { //限制数量
|
|
|
|
|
this.message.create('warning', '绘制数量已达上限!'); |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
let point = { |
|
|
|
|
startX: this.downx, |
|
|
|
|
startY: this.downy, |
|
|
|
|
endX: upX, |
|
|
|
|
endY: upY, |
|
|
|
|
} |
|
|
|
|
this.arrowPointsOfEast.push(point); |
|
|
|
|
let arr = [this.arrowPoints, this.arrowPointsOfSouth, this.arrowPointsOfWest, this.arrowPointsOfEast, this.arrowPointsOfNorth] |
|
|
|
|
this.drawLine(arr, context) |
|
|
|
|
} else if (this.isDrawArrow && this.arrowDirection == 'North') { |
|
|
|
|
console.log('North') |
|
|
|
|
if (this.arrowPointsOfNorth.length === 2) { //限制数量
|
|
|
|
|
this.message.create('warning', '绘制数量已达上限!'); |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
let point = { |
|
|
|
|
startX: this.downx, |
|
|
|
|
startY: this.downy, |
|
|
|
|
endX: upX, |
|
|
|
|
endY: upY, |
|
|
|
|
} |
|
|
|
|
this.arrowPointsOfNorth.push(point); |
|
|
|
|
let arr = [this.arrowPoints, this.arrowPointsOfSouth, this.arrowPointsOfWest, this.arrowPointsOfEast, this.arrowPointsOfNorth] |
|
|
|
|
this.drawLine(arr, context) |
|
|
|
|
} else { //绘制 矩形
|
|
|
|
|
if (this.oblongPoints.length === 2) { //限制数量
|
|
|
|
|
this.message.create('warning', '绘制数量已达上限!'); |
|
|
|
@ -296,6 +415,13 @@ export class ImageLabel2Component implements OnInit {
|
|
|
|
|
|
|
|
|
|
arrowPoints = []; //箭头的点的集合
|
|
|
|
|
|
|
|
|
|
arrowPointsOfSouth = []; //南 箭头的点的集合
|
|
|
|
|
arrowPointsOfWest = []; //西 箭头的点的集合
|
|
|
|
|
arrowPointsOfEast = []; //东 箭头的点的集合
|
|
|
|
|
arrowPointsOfNorth = []; //北 箭头的点的集合
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//canvas 绘制直线
|
|
|
|
|
drawLine(pointsList, context, isRepeat: boolean = false) { |
|
|
|
|
context.clearRect(0, 0, this.canvasWidth, this.canvasHeight); |
|
|
|
@ -307,18 +433,26 @@ export class ImageLabel2Component implements OnInit {
|
|
|
|
|
context.strokeRect(element.x, element.y, element.width, element.height); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
pointsList.forEach((item, index) => { |
|
|
|
|
if ((index + 1) % 2 === 0) { |
|
|
|
|
this.drawArrow(item.startX, item.startY, item.endX, item.endY, 30, 10, 3, 'green', context) |
|
|
|
|
} else { |
|
|
|
|
context.beginPath(); |
|
|
|
|
context.moveTo(item.startX, item.startY); |
|
|
|
|
context.strokeStyle = "green"; |
|
|
|
|
context.lineWidth = 3; |
|
|
|
|
context.lineTo(item.endX, item.endY); |
|
|
|
|
context.stroke(); |
|
|
|
|
// console.log(789, pointsList)
|
|
|
|
|
pointsList.forEach(element => { |
|
|
|
|
if (element.length != 0) { |
|
|
|
|
element.forEach((item, index) => { |
|
|
|
|
if ((index + 1) % 2 === 0) { |
|
|
|
|
this.drawArrow(item.startX, item.startY, item.endX, item.endY, 30, 10, 3, 'green', context) |
|
|
|
|
} else { |
|
|
|
|
context.beginPath(); |
|
|
|
|
context.moveTo(item.startX, item.startY); |
|
|
|
|
context.strokeStyle = "green"; |
|
|
|
|
context.lineWidth = 3; |
|
|
|
|
context.lineTo(item.endX, item.endY); |
|
|
|
|
context.stroke(); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//canvas 绘制箭头
|
|
|
|
@ -398,7 +532,8 @@ export class ImageLabel2Component implements OnInit {
|
|
|
|
|
context.clearRect(0, 0, this.canvasWidth, this.canvasHeight); |
|
|
|
|
this.copyCanvas ? context.putImageData(this.copyCanvas, 0, 0) : null; |
|
|
|
|
if (this.markType === 2) { //同时绘制 直线箭头
|
|
|
|
|
this.drawLine(this.arrowPoints, context, true) |
|
|
|
|
let arr = [this.arrowPoints, this.arrowPointsOfSouth, this.arrowPointsOfWest, this.arrowPointsOfEast, this.arrowPointsOfNorth] |
|
|
|
|
this.drawLine(arr, context, true) |
|
|
|
|
} |
|
|
|
|
oblongList.forEach(element => { |
|
|
|
|
context.strokeStyle = element.oilUnloadingArea ? "green" : "red"; |
|
|
|
|