|
|
@ -233,24 +233,32 @@ export class GetOutOfLineDetailsComponent implements OnInit { |
|
|
|
ctx; |
|
|
|
ctx; |
|
|
|
canvasLabel() { |
|
|
|
canvasLabel() { |
|
|
|
let imgBg: any = document.getElementById("img" + this.data.id); |
|
|
|
let imgBg: any = document.getElementById("img" + this.data.id); |
|
|
|
imgBg.onload = () => { |
|
|
|
const drawImageAndRect = () => { |
|
|
|
console.log("图片加载完毕..."); |
|
|
|
|
|
|
|
this.canvasWidth = imgBg.offsetWidth; |
|
|
|
this.canvasWidth = imgBg.offsetWidth; |
|
|
|
this.canvasHeight = imgBg.offsetHeight; |
|
|
|
this.canvasHeight = imgBg.offsetHeight; |
|
|
|
const canvas: any = document.getElementById("canvas" + this.data.id); |
|
|
|
const canvas: any = document.getElementById("canvas" + this.data.id); |
|
|
|
this.ctx = canvas.getContext("2d"); |
|
|
|
|
|
|
|
const cWidth = canvas.width, |
|
|
|
|
|
|
|
cHeight = canvas.height; |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
setTimeout(() => { |
|
|
|
console.log("以图画底,描绘预警框..."); |
|
|
|
this.ctx = canvas.getContext("2d"); |
|
|
|
// 以图画底
|
|
|
|
const cWidth = canvas.width, |
|
|
|
|
|
|
|
cHeight = canvas.height; |
|
|
|
|
|
|
|
console.log(1, cWidth, cHeight); |
|
|
|
this.ctx.drawImage(imgBg, 0, 0, cWidth, cHeight); |
|
|
|
this.ctx.drawImage(imgBg, 0, 0, cWidth, cHeight); |
|
|
|
this.strokeRect(this.currentCoordinate); |
|
|
|
this.strokeRect(this.currentCoordinate); |
|
|
|
}, 100); |
|
|
|
}, 0); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
if (imgBg.complete) { |
|
|
|
|
|
|
|
console.log("图片已经加载, 直接绘制..."); |
|
|
|
|
|
|
|
drawImageAndRect(); // 如果图片已加载,直接调用绘制函数
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
imgBg.onload = () => { |
|
|
|
|
|
|
|
console.log("图片加载完毕..."); |
|
|
|
|
|
|
|
drawImageAndRect(); // 图片加载完成后,调用绘制函数
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
strokeRect(data) { |
|
|
|
strokeRect(data) { |
|
|
|
|
|
|
|
console.log(data); |
|
|
|
data.forEach((item) => { |
|
|
|
data.forEach((item) => { |
|
|
|
let startPoint = [ |
|
|
|
let startPoint = [ |
|
|
|
Math.round(this.canvasWidth * item.box[0]), |
|
|
|
Math.round(this.canvasWidth * item.box[0]), |
|
|
@ -261,7 +269,7 @@ export class GetOutOfLineDetailsComponent implements OnInit { |
|
|
|
Math.round(this.canvasHeight * item.box[3]), |
|
|
|
Math.round(this.canvasHeight * item.box[3]), |
|
|
|
]; |
|
|
|
]; |
|
|
|
if (this.isShowAxOtherRegion) { |
|
|
|
if (this.isShowAxOtherRegion) { |
|
|
|
this.ctx.strokeStyle = this.typeArr[item.id].color; |
|
|
|
this.ctx.strokeStyle = this.typeArr[item.id]?.color || "yellow"; |
|
|
|
this.ctx.lineWidth = 3; |
|
|
|
this.ctx.lineWidth = 3; |
|
|
|
this.ctx.strokeRect( |
|
|
|
this.ctx.strokeRect( |
|
|
|
startPoint[0], |
|
|
|
startPoint[0], |
|
|
@ -271,16 +279,16 @@ export class GetOutOfLineDetailsComponent implements OnInit { |
|
|
|
); |
|
|
|
); |
|
|
|
//如果当前矩形区域为错误区域,则左上角增加色块
|
|
|
|
//如果当前矩形区域为错误区域,则左上角增加色块
|
|
|
|
if (item.error) { |
|
|
|
if (item.error) { |
|
|
|
this.ctx.fillStyle = this.typeArr[item.id].color; |
|
|
|
this.ctx.fillStyle = this.typeArr[item.id]?.color || "yellow"; |
|
|
|
this.ctx.fillRect(startPoint[0], startPoint[1], 10, 10); |
|
|
|
this.ctx.fillRect(startPoint[0], startPoint[1], 10, 10); |
|
|
|
} |
|
|
|
} |
|
|
|
this.ctx.fillStyle = this.typeArr[item.id].color; |
|
|
|
this.ctx.fillStyle = this.typeArr[item.id]?.color || "yellow"; |
|
|
|
this.ctx.font = "16px Verdana"; |
|
|
|
this.ctx.font = "16px Verdana"; |
|
|
|
let name = ""; |
|
|
|
let name = ""; |
|
|
|
if (this.isShowAxOtherRegion) { |
|
|
|
if (this.isShowAxOtherRegion) { |
|
|
|
name = this.typeArr[item.id].name + item.scores; |
|
|
|
name = this.typeArr[item.id]?.name || "未定义" + item.scores; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
name = this.typeArr[item.id].name; |
|
|
|
name = this.typeArr[item.id]?.name || "未定义"; |
|
|
|
} |
|
|
|
} |
|
|
|
this.ctx.fillText( |
|
|
|
this.ctx.fillText( |
|
|
|
name, |
|
|
|
name, |
|
|
@ -291,7 +299,7 @@ export class GetOutOfLineDetailsComponent implements OnInit { |
|
|
|
); |
|
|
|
); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (item.error) { |
|
|
|
if (item.error) { |
|
|
|
this.ctx.strokeStyle = this.typeArr[item.id].color; |
|
|
|
this.ctx.strokeStyle = this.typeArr[item.id]?.color || "yellow"; |
|
|
|
this.ctx.lineWidth = 3; |
|
|
|
this.ctx.lineWidth = 3; |
|
|
|
this.ctx.strokeRect( |
|
|
|
this.ctx.strokeRect( |
|
|
|
startPoint[0], |
|
|
|
startPoint[0], |
|
|
@ -299,9 +307,9 @@ export class GetOutOfLineDetailsComponent implements OnInit { |
|
|
|
endPoint[0] - startPoint[0], |
|
|
|
endPoint[0] - startPoint[0], |
|
|
|
endPoint[1] - startPoint[1] |
|
|
|
endPoint[1] - startPoint[1] |
|
|
|
); |
|
|
|
); |
|
|
|
this.ctx.fillStyle = this.typeArr[item.id].color; |
|
|
|
this.ctx.fillStyle = this.typeArr[item.id]?.color || "yellow"; |
|
|
|
this.ctx.fillRect(startPoint[0], startPoint[1], 10, 10); |
|
|
|
this.ctx.fillRect(startPoint[0], startPoint[1], 10, 10); |
|
|
|
this.ctx.fillStyle = this.typeArr[item.id].color; |
|
|
|
this.ctx.fillStyle = this.typeArr[item.id]?.color || "yellow"; |
|
|
|
this.ctx.font = "16px Verdana"; |
|
|
|
this.ctx.font = "16px Verdana"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -422,7 +430,9 @@ export class GetOutOfLineDetailsComponent implements OnInit { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//查看图片
|
|
|
|
//查看图片
|
|
|
|
viewImg(url) { |
|
|
|
viewImg(e) { |
|
|
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
const url = e.target.toDataURL(); |
|
|
|
let dom = document.getElementById(`viewerjs`); |
|
|
|
let dom = document.getElementById(`viewerjs`); |
|
|
|
let pObjs = dom.childNodes; |
|
|
|
let pObjs = dom.childNodes; |
|
|
|
let node = document.createElement("img"); |
|
|
|
let node = document.createElement("img"); |
|
|
|