From 102f1c1ec7c0126c76cf6c1ddee865f85ede7263 Mon Sep 17 00:00:00 2001
From: cpfcls <1105965053@qq.com>
Date: Tue, 12 Apr 2022 14:53:11 +0800
Subject: [PATCH 1/4] =?UTF-8?q?=E7=BB=98=E5=88=B6=E5=A4=9A=E8=BE=B9?=
=?UTF-8?q?=E5=BD=A2=E5=AE=8C=E5=96=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../image-label2/image-label2.component.html | 2 -
.../image-label2/image-label2.component.ts | 145 +++++++++++-------
2 files changed, 88 insertions(+), 59 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 fd0032c..9011f94 100644
--- a/src/app/system-management/image-label2/image-label2.component.html
+++ b/src/app/system-management/image-label2/image-label2.component.html
@@ -2,8 +2,6 @@
-
-
+
+
+
+
+
+
+
+
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
From 3073311e88e20afbdb8c21fda85e2975fd0666af Mon Sep 17 00:00:00 2001
From: cpfcls <1105965053@qq.com>
Date: Thu, 14 Apr 2022 11:09:35 +0800
Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=A4=E7=A7=8D?=
=?UTF-8?q?=E7=BB=98=E5=88=B6=E5=8A=9F=E8=83=BD=E6=95=B0=E6=8D=AE=E5=8A=A0?=
=?UTF-8?q?=E8=BD=BD=E4=B8=8D=E6=AD=A3=E7=A1=AEbug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../image-label2/image-label2.component.ts | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
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 fdd9424..d9f498e 100644
--- a/src/app/system-management/image-label2/image-label2.component.ts
+++ b/src/app/system-management/image-label2/image-label2.component.ts
@@ -143,6 +143,7 @@ export class ImageLabel2Component implements OnInit {
context.stroke();
} else { //绘制 矩形
this.drawOblong(this.oblongPoints,context)
+ context.strokeStyle = this.oilUnloadingArea? "green" : "red";
let element = this.getOblongInfo(this.downx,this.downy,moveX,moveY)
context.strokeRect(element.x,element.y,element.width,element.height);
}
@@ -180,9 +181,16 @@ export class ImageLabel2Component implements OnInit {
arrowPoints = []; //箭头的点的集合
//canvas 绘制直线
- drawLine(pointsList, context) {
+ drawLine(pointsList, context, isRepeat: boolean = false) {
context.clearRect(0, 0, this.canvasWidth, this.canvasHeight);
this.copyCanvas? context.putImageData(this.copyCanvas, 0, 0) : null;
+ if (this.markType === 3 && !isRepeat) { //同时绘制 矩形
+ this.oblongPoints.forEach(element => {
+ context.strokeStyle = element.oilUnloadingArea? "green" : "red";
+ context.lineWidth = 3;
+ 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)
@@ -273,8 +281,11 @@ export class ImageLabel2Component implements OnInit {
drawOblong(oblongList, context) {
context.clearRect(0, 0, this.canvasWidth, this.canvasHeight);
this.copyCanvas? context.putImageData(this.copyCanvas, 0, 0) : null;
+ if (this.markType === 3) { //同时绘制 直线箭头
+ this.drawLine(this.arrowPoints,context,true)
+ }
oblongList.forEach(element => {
- context.strokeStyle = "green";
+ context.strokeStyle = element.oilUnloadingArea? "green" : "red";
context.lineWidth = 3;
context.strokeRect(element.x,element.y,element.width,element.height);
});