From a25b9c51f29ac99ae8a379f0f6cd22c1ef032b16 Mon Sep 17 00:00:00 2001
From: cpfcls <1105965053@qq.com>
Date: Thu, 14 Apr 2022 10:19:31 +0800
Subject: [PATCH] =?UTF-8?q?=E6=A0=87=E7=BB=98=E5=8A=9F=E8=83=BD=E5=AF=B9?=
=?UTF-8?q?=E6=8E=A5=E5=AE=8C=E6=95=B4=E6=93=8D=E4=BD=9C=E6=B5=81=E7=A8=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../image-label2/image-label2.component.html | 10 ++-
.../image-label2/image-label2.component.scss | 1 +
.../image-label2/image-label2.component.ts | 62 +++++++++++++------
3 files changed, 53 insertions(+), 20 deletions(-)
diff --git a/src/app/system-management/image-label2/image-label2.component.html b/src/app/system-management/image-label2/image-label2.component.html
index 9011f94..1cd5b6b 100644
--- a/src/app/system-management/image-label2/image-label2.component.html
+++ b/src/app/system-management/image-label2/image-label2.component.html
@@ -1,8 +1,14 @@
-
-
+
+
+
+
+
+
+
+
diff --git a/src/app/system-management/image-label2/image-label2.component.scss b/src/app/system-management/image-label2/image-label2.component.scss
index 9db4d42..4a7f5e2 100644
--- a/src/app/system-management/image-label2/image-label2.component.scss
+++ b/src/app/system-management/image-label2/image-label2.component.scss
@@ -24,6 +24,7 @@
button {
margin-right: 6px;
}
+ .leftTitle{ line-height: 32px; padding: 0 20px; }
}
.imgbox,
diff --git a/src/app/system-management/image-label2/image-label2.component.ts b/src/app/system-management/image-label2/image-label2.component.ts
index 065637f..fdd9424 100644
--- a/src/app/system-management/image-label2/image-label2.component.ts
+++ b/src/app/system-management/image-label2/image-label2.component.ts
@@ -29,6 +29,18 @@ export class ImageLabel2Component implements OnInit {
}, 0)
}
+ //保存
+ save() {
+ if (this.markType === 1) {
+ console.log("多边形",this.points)
+ } else if (this.markType === 3) {
+ console.log("箭头",this.arrowPoints)
+ console.log("矩形",this.oblongPoints)
+ } else if (this.markType === 4) {
+ console.log("箭头",this.arrowPoints)
+ }
+ }
+
//初始化背景图
initBackgroundImg() {
let canvas = document.getElementById('canvas') as any;
@@ -75,13 +87,19 @@ export class ImageLabel2Component implements OnInit {
- isDrawArrow: boolean = true; //绘制 箭头/矩形
+ markType: number = 3; //1=进出口,3=卸油区,4=便利店,
+ isDrawArrow: boolean = true; //绘制type 箭头/矩形
+ oilUnloadingArea: boolean = true; //卸油区type 泄油管区域/静电接地仪
//记录鼠标点击位置
downx = 0;
downy = 0;
//清空画布
clearCanvas() {
+ let istrue = confirm("清除属于不可逆操作,你是否继续?");
+ if (!istrue) {
+ return
+ }
// 清空标绘箭头
this.arrowPoints = [];
// 清空标绘箭头
@@ -100,7 +118,7 @@ export class ImageLabel2Component implements OnInit {
this.copyCanvas? context.putImageData(this.copyCanvas, 0, 0) : null;
}
- //初始化 canvas画布 点击事件
+ //初始化 canvas画布 监听事件
initCanvasEvent(canvas) {
let context = canvas.getContext('2d');
canvas.onmousedown = (e)=>{ //鼠标按下事件
@@ -108,30 +126,37 @@ export class ImageLabel2Component implements OnInit {
var clickY = e.pageY - canvas.offsetTop;
this.downx = clickX
this.downy = clickY
- //this.drawPolygon(clickX,clickY,canvas,context); //绘制多边形
- //开始绘制
- context.beginPath();
- context.moveTo(clickX,clickY);
- context.strokeStyle = "green";
- context.lineWidth = 3;
- canvas.onmousemove = (ev)=>{ //鼠标移动事件
- var moveX = ev.pageX - canvas.offsetLeft;
- var moveY = ev.pageY - canvas.offsetTop;
- if (this.isDrawArrow) { //绘制 箭头
- context.lineTo(moveX,moveY);
- context.stroke();
- } else { //绘制 矩形
- this.drawOblong(this.oblongPoints,context)
- let element = this.getOblongInfo(this.downx,this.downy,moveX,moveY)
- context.strokeRect(element.x,element.y,element.width,element.height);
+ if (this.markType === 1) { //进出口
+ this.drawPolygon(clickX,clickY,canvas,context); //绘制多边形
+ } else if (this.markType === 3 || this.markType === 4) { //卸油区/便利店
+ //开始绘制
+ context.beginPath();
+ context.moveTo(clickX,clickY);
+ context.strokeStyle = "green";
+ context.lineWidth = 3;
+ canvas.onmousemove = (ev)=>{ //鼠标移动事件
+ var moveX = ev.pageX - canvas.offsetLeft;
+ var moveY = ev.pageY - canvas.offsetTop;
+ if (this.isDrawArrow) { //绘制 箭头
+ context.lineTo(moveX,moveY);
+ context.stroke();
+ } else { //绘制 矩形
+ this.drawOblong(this.oblongPoints,context)
+ let element = this.getOblongInfo(this.downx,this.downy,moveX,moveY)
+ context.strokeRect(element.x,element.y,element.width,element.height);
+ }
}
}
}
+
canvas.onmouseup = (e)=>{ //鼠标松开事件
canvas.onmousemove = (ev)=>{ //鼠标移动事件
return false;
}
+ if (this.markType != 3 && this.markType != 4) {
+ return
+ }
var upX = e.pageX - canvas.offsetLeft;
var upY = e.pageY - canvas.offsetTop;
if (this.isDrawArrow) { //绘制 箭头
@@ -225,6 +250,7 @@ export class ImageLabel2Component implements OnInit {
y: 0,
width: 0,
height: 0,
+ oilUnloadingArea: this.oilUnloadingArea,
}
if (startX > endX) {
point.x = endX