Enhance ROI editing (#1357)

* add labels to ROIs

* .

* fix naming check

* .

* .

Co-authored-by: CaCO3 <caco@ruinelli.ch>
This commit is contained in:
CaCO3
2022-11-16 18:32:53 +01:00
committed by GitHub
parent 9e4332314a
commit e15ea561bc
3 changed files with 124 additions and 29 deletions

View File

@@ -482,10 +482,31 @@ function removeNumber(){
}
function drawTextBG(context, txt, x, y, padding) {
context.font = "15px Arial";
context.textAlign = "center";
context.fillStyle = 'rgba(255, 0, 0, 0.5)';
var width = context.measureText(txt).width;
context.fillRect(x-(width+padding)/2, y-12, width + padding*2, parseInt(context.font, 10) + padding);
context.fillStyle = "black";
context.fillText(txt, x + padding / 2, y + padding / 2);
}
function draw() {
if (typeof ROIInfo === 'undefined') { // During init, ROIInfo is not defined yet
return;
}
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
context.drawImage(imageObj, 0, 0);
context.font = "15px Arial";
context.fillStyle = "red";
context.textAlign = "center";
if (document.getElementById("Category_Analog_enabled").checked)
{
var sel = document.getElementById("index");
@@ -515,6 +536,7 @@ function removeNumber(){
var dx = parseInt(ROIInfo[_nb].dx) + parseInt(lw);
var dy = parseInt(ROIInfo[_nb].dy) + parseInt(lw);
context.strokeRect(x0, y0, dx, dy);
drawTextBG(context, ROIInfo[_nb]["name"], x0+dx/2-0.5, y0-13, 5);
}
}
@@ -529,6 +551,7 @@ function removeNumber(){
var dx = parseInt(rect.w) + parseInt(lw);
var dy = parseInt(rect.h) + parseInt(lw);
context.strokeRect(x0, y0, dx, dy);
drawTextBG(context, ROIInfo[aktindex]["name"], x0+dx/2, y0-11, 5);
context.lineWidth = 1;
context.beginPath();
context.arc(x0+dx/2, y0+dy/2, dx/2, 0, 2 * Math.PI);