kfb-view 3.3.5 → 3.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/kfb-view.cjs.js +1 -1
- package/lib/kfb-view.cjs.js.LICENSE.txt +10 -0
- package/lib/kfb-view.es.js +1 -1
- package/lib/kfb-view.es.js.LICENSE.txt +10 -0
- package/lib/kfb-view.umd.js +1 -1
- package/lib/kfb-view.umd.js.LICENSE.txt +10 -0
- package/package.json +4 -3
- package/src/components/board/index.js +6 -5
- package/src/components/common/common.js +6 -7
- package/src/components/shape/index.js +13 -12
- package/src/components/tailoring/index.js +3 -6
- package/src/const/event.js +2 -0
- package/src/model/label.model.js +2 -4
- package/src/plugin/zrender/zrender.js +17727 -0
- package/src/plugin/zrender/zrender.min.js +1 -0
- package/src/tool/Image.js +7 -26
- package/src/view.js +35 -24
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ZRender, a high performance 2d drawing library.
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2013, Baidu Inc.
|
|
5
|
+
* All rights reserved.
|
|
6
|
+
*
|
|
7
|
+
* LICENSE
|
|
8
|
+
* https://github.com/ecomfe/zrender/blob/master/LICENSE.txt
|
|
9
|
+
*/
|
|
10
|
+
|
|
1
11
|
//! Built on 2024-04-01
|
|
2
12
|
|
|
3
13
|
//! Git commit: v4.1.1-1-f90d9814
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kfb-view",
|
|
3
3
|
"description": "一个在线kfb的阅片软件",
|
|
4
|
-
"version": "3.3.
|
|
4
|
+
"version": "3.3.6",
|
|
5
5
|
"author": "qifeng.fan <qifeng.fan@hzztai.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "lib/kfb-view.cjs.js",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"axios": "^1.6.5",
|
|
50
50
|
"babel-eslint": "^10.1.0",
|
|
51
51
|
"babel-loader": "^10.0.0",
|
|
52
|
+
"compression-webpack-plugin": "^6.1.2",
|
|
52
53
|
"copy-webpack-plugin": "^4.5.2",
|
|
53
54
|
"core-js": "^3.6.5",
|
|
54
55
|
"css-loader": "^7.1.2",
|
|
@@ -57,12 +58,12 @@
|
|
|
57
58
|
"eslint-friendly-formatter": "^4.0.1",
|
|
58
59
|
"eslint-plugin-html": "^4.0.5",
|
|
59
60
|
"html-loader": "^5.1.0",
|
|
60
|
-
"html-webpack-plugin": "^5.6.
|
|
61
|
+
"html-webpack-plugin": "^5.6.5",
|
|
61
62
|
"mini-css-extract-plugin": "^2.9.2",
|
|
62
|
-
"sass": "^1.89.1",
|
|
63
63
|
"postcss-import": "^16.1.1",
|
|
64
64
|
"postcss-loader": "^8.1.1",
|
|
65
65
|
"rimraf": "^2.6.2",
|
|
66
|
+
"sass": "^1.89.1",
|
|
66
67
|
"sass-loader": "^16.0.5",
|
|
67
68
|
"style-loader": "^4.0.0",
|
|
68
69
|
"terser-webpack-plugin": "^4.2.2",
|
|
@@ -167,11 +167,12 @@ export class Board extends ViewerCommon {
|
|
|
167
167
|
onCanvasDrag(e) {
|
|
168
168
|
const {x, y} = e.position;
|
|
169
169
|
const point = this.viewerElementToImageCoordinates(x, y);
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
170
|
+
//去掉限制,支持框选roi以外的
|
|
171
|
+
// if (!this.isInROI(point)) {
|
|
172
|
+
// this.points = [];
|
|
173
|
+
// this.clearCanvas();
|
|
174
|
+
// return;
|
|
175
|
+
// }
|
|
175
176
|
e.preventDefaultAction = true;
|
|
176
177
|
const tool = this.tool;
|
|
177
178
|
if (REGION_TYPES.includes(tool)) {
|
|
@@ -271,7 +271,7 @@ export class ViewerCommon {
|
|
|
271
271
|
`${this.translate('long_axis')}:${this.getUnitNumber(a)}`,
|
|
272
272
|
`${this.translate('short_axis')}:${this.getUnitNumber(b)}`,
|
|
273
273
|
`${this.translate('perimeter')}:${this.getUnitNumber(4 * (a - b) + 2 * Math.PI * b)}`,
|
|
274
|
-
`${this.translate('area')}:${this.getUnitNumber(Math.PI * a * b
|
|
274
|
+
`${this.translate('area')}:${this.getUnitNumber(Math.PI * a * b / this.options.binary)}²`],
|
|
275
275
|
};
|
|
276
276
|
}
|
|
277
277
|
break;
|
|
@@ -279,7 +279,7 @@ export class ViewerCommon {
|
|
|
279
279
|
const w = Math.abs(endPoint.x - startPoint.x) * this.options.imageCapRes;
|
|
280
280
|
const h = Math.abs(endPoint.y - startPoint.y) * this.options.imageCapRes;
|
|
281
281
|
const pt = (w + h) * 2;
|
|
282
|
-
const ac = w * h;
|
|
282
|
+
const ac = w * h / this.options.binary;
|
|
283
283
|
const rightTop = getRectPoint(startPoint, endPoint)[2];
|
|
284
284
|
const p = this.imageToViewerElementCoordinates(rightTop.x,
|
|
285
285
|
rightTop.y);
|
|
@@ -291,7 +291,7 @@ export class ViewerCommon {
|
|
|
291
291
|
`${this.translate('length')}:${this.getUnitNumber(w)}`,
|
|
292
292
|
`${this.translate('width')}:${this.getUnitNumber(h)}`,
|
|
293
293
|
`${this.translate('perimeter')}:${this.getUnitNumber(pt)}`,
|
|
294
|
-
`${this.translate('area')}:${this.getUnitNumber(ac
|
|
294
|
+
`${this.translate('area')}:${this.getUnitNumber(ac)}²`],
|
|
295
295
|
};
|
|
296
296
|
}
|
|
297
297
|
break;
|
|
@@ -312,7 +312,7 @@ export class ViewerCommon {
|
|
|
312
312
|
texts: [
|
|
313
313
|
`${this.translate('perimeter')}:${this.getUnitNumber((pt * this.options.imageCapRes).toFixed(2))}`,
|
|
314
314
|
`${this.translate('area')}:${this.getUnitNumber(
|
|
315
|
-
calculatePolygonArea(points, this.options.imageCapRes)
|
|
315
|
+
calculatePolygonArea(points, this.options.imageCapRes) / this.options.binary)}²`],
|
|
316
316
|
};
|
|
317
317
|
}
|
|
318
318
|
break;
|
|
@@ -335,9 +335,8 @@ export class ViewerCommon {
|
|
|
335
335
|
};
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
-
getUnitNumber(number, index
|
|
339
|
-
|
|
340
|
-
return getUnitNumber(number, this.options.units, binary);
|
|
338
|
+
getUnitNumber(number, index) {
|
|
339
|
+
return getUnitNumber(number, this.options.units, this.options.binary, index);
|
|
341
340
|
}
|
|
342
341
|
|
|
343
342
|
/**
|
|
@@ -60,7 +60,6 @@ export class Shape extends ViewerCommon {
|
|
|
60
60
|
// 区域标注列表
|
|
61
61
|
const labelList = this.labelList.filter((item) => {
|
|
62
62
|
if (item.show === false) return false;
|
|
63
|
-
if (item.custom) return false;
|
|
64
63
|
if (!this[item.tool]) return false;
|
|
65
64
|
if (!this.isInCanvas(item.region, bounds)) return false;
|
|
66
65
|
if ((REGION_TYPES.includes(item.tool) || item.isClose && item.tool ===
|
|
@@ -106,14 +105,12 @@ export class Shape extends ViewerCommon {
|
|
|
106
105
|
clearTimeout(this.delaytimer);
|
|
107
106
|
this.delaytimer = undefined;
|
|
108
107
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
this.drawLabel(item);
|
|
112
|
-
});
|
|
113
|
-
this.deepDrawLabel(sameFixWidthLabel, sameNormalLabel, regionLabelList, 1, bounds);
|
|
108
|
+
this.deepDrawLabel(sameFixWidthLabel, sameNormalLabel, regionLabelList,
|
|
109
|
+
imageLabel, 1, bounds);
|
|
114
110
|
}
|
|
115
111
|
|
|
116
|
-
deepDrawLabel(sameFixWidthLabel, sameNormalLabel, regionLabelList,
|
|
112
|
+
deepDrawLabel(sameFixWidthLabel, sameNormalLabel, regionLabelList,
|
|
113
|
+
imageLabel, count, bounds) {
|
|
117
114
|
let currentDrawCount = 0; // 当前已绘制数量
|
|
118
115
|
const ctx = this.canvas.getContext('2d');
|
|
119
116
|
const remainFixLabel = {};
|
|
@@ -121,7 +118,7 @@ export class Shape extends ViewerCommon {
|
|
|
121
118
|
const labels = sameFixWidthLabel[key];
|
|
122
119
|
ctx.beginPath();
|
|
123
120
|
labels.forEach((item) => {
|
|
124
|
-
if (currentDrawCount >=
|
|
121
|
+
if (currentDrawCount >= 2000) { // 一次最多绘制2000个标注,多余标注延迟绘制
|
|
125
122
|
if (remainFixLabel[key]) {
|
|
126
123
|
remainFixLabel[key].push(item);
|
|
127
124
|
} else {
|
|
@@ -130,7 +127,7 @@ export class Shape extends ViewerCommon {
|
|
|
130
127
|
} else {
|
|
131
128
|
this.drawLabel(item);
|
|
132
129
|
}
|
|
133
|
-
currentDrawCount
|
|
130
|
+
currentDrawCount++;
|
|
134
131
|
});
|
|
135
132
|
const firstLabel = labels?.[0];
|
|
136
133
|
if (firstLabel?.fillStyle) {
|
|
@@ -145,7 +142,7 @@ export class Shape extends ViewerCommon {
|
|
|
145
142
|
const labels = sameNormalLabel[key];
|
|
146
143
|
ctx.beginPath();
|
|
147
144
|
labels.forEach((item) => {
|
|
148
|
-
if (currentDrawCount >=
|
|
145
|
+
if (currentDrawCount >= 2000) { // 一次最多绘制2000个标注,多余标注延迟绘制
|
|
149
146
|
if (remainNormalLabel[key]) {
|
|
150
147
|
remainNormalLabel[key].push(item);
|
|
151
148
|
} else {
|
|
@@ -154,7 +151,7 @@ export class Shape extends ViewerCommon {
|
|
|
154
151
|
} else {
|
|
155
152
|
this.drawLabel(item);
|
|
156
153
|
}
|
|
157
|
-
currentDrawCount
|
|
154
|
+
currentDrawCount++;
|
|
158
155
|
});
|
|
159
156
|
const firstLabel = labels?.[0];
|
|
160
157
|
ctx.lineWidth = firstLabel.lineWidth;
|
|
@@ -165,6 +162,9 @@ export class Shape extends ViewerCommon {
|
|
|
165
162
|
Object.keys(remainNormalLabel).length === 0) {
|
|
166
163
|
console.log(`end deep draw label, draw count: ${count}`);
|
|
167
164
|
this.delaytimer = undefined;
|
|
165
|
+
imageLabel.forEach((item) => {
|
|
166
|
+
this.drawLabel(item);
|
|
167
|
+
});
|
|
168
168
|
regionLabelList.forEach((item) => {
|
|
169
169
|
this.combination.setContent(this.canvas, item);
|
|
170
170
|
this.combination.draw({
|
|
@@ -177,7 +177,8 @@ export class Shape extends ViewerCommon {
|
|
|
177
177
|
});
|
|
178
178
|
} else {
|
|
179
179
|
this.delaytimer = setTimeout(() => {
|
|
180
|
-
this.deepDrawLabel(remainFixLabel, remainNormalLabel, regionLabelList,
|
|
180
|
+
this.deepDrawLabel(remainFixLabel, remainNormalLabel, regionLabelList,
|
|
181
|
+
imageLabel, count + 1,
|
|
181
182
|
bounds);
|
|
182
183
|
}, 100);
|
|
183
184
|
}
|
|
@@ -37,7 +37,6 @@ export class Tailoring extends ViewerCommon {
|
|
|
37
37
|
shape: true,
|
|
38
38
|
...this.options,
|
|
39
39
|
};
|
|
40
|
-
this.custom = undefined;
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
init({
|
|
@@ -48,7 +47,7 @@ export class Tailoring extends ViewerCommon {
|
|
|
48
47
|
color,
|
|
49
48
|
now = false,
|
|
50
49
|
contents = [],
|
|
51
|
-
}
|
|
50
|
+
}) {
|
|
52
51
|
this.isInTailoring = true;
|
|
53
52
|
this.movePointIndex = -1;
|
|
54
53
|
const pointList = getRectPoint({x: left, y: top},
|
|
@@ -58,7 +57,6 @@ export class Tailoring extends ViewerCommon {
|
|
|
58
57
|
pointList[2],
|
|
59
58
|
pointList[6],
|
|
60
59
|
pointList[8]];
|
|
61
|
-
this.custom = custom;
|
|
62
60
|
if (now) {
|
|
63
61
|
this.emitScreenShot();
|
|
64
62
|
this.stopTailoring();
|
|
@@ -324,7 +322,6 @@ export class Tailoring extends ViewerCommon {
|
|
|
324
322
|
width: this.tailoringPoints[3].x - this.tailoringPoints[0].x,
|
|
325
323
|
height: this.tailoringPoints[3].y - this.tailoringPoints[0].y,
|
|
326
324
|
}),
|
|
327
|
-
custom: this.custom,
|
|
328
325
|
});
|
|
329
326
|
}
|
|
330
327
|
|
|
@@ -386,8 +383,8 @@ export class Tailoring extends ViewerCommon {
|
|
|
386
383
|
copyCtx.putImageData(imageData, 0, 0, 0, 0, disWidth, disHeight);
|
|
387
384
|
const shapeCanvas = this.kv.shape?.canvas;
|
|
388
385
|
if (shapeCanvas && this.options.shape) {
|
|
389
|
-
copyCtx.drawImage(shapeCanvas, startPoint.x,
|
|
390
|
-
startPoint.y
|
|
386
|
+
copyCtx.drawImage(shapeCanvas, startPoint.x * radioX,
|
|
387
|
+
startPoint.y * radioY, disWidth, disHeight, 0, 0, disWidth,
|
|
391
388
|
disHeight);
|
|
392
389
|
}
|
|
393
390
|
if (copyCanvas.width > this.options.resolution) {
|
package/src/const/event.js
CHANGED
|
@@ -19,3 +19,5 @@ export const EVENT_DELETE_POLYGON_POINT = 'delete-polygon-point';
|
|
|
19
19
|
export const EVENT_ADD_POLYGON_POINT = 'add-polygon-point';
|
|
20
20
|
export const EVENT_NAVIGATOR_VESTIGE = 'navigator-vestige';
|
|
21
21
|
export const EVENT_GRADUATION_CHANGE = 'graduation-change';
|
|
22
|
+
export const EVENT_INIT_COMPLETE = 'init-complete';
|
|
23
|
+
export const EVENT_UPDATE_ZRENDER = 'update-zrender';
|
package/src/model/label.model.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {DOT, FLAG,
|
|
1
|
+
import {DOT, FLAG, STAR} from '../const/mark';
|
|
2
2
|
|
|
3
3
|
export class LabelModel {
|
|
4
4
|
constructor(data = {}) {
|
|
@@ -25,13 +25,11 @@ export class LabelModel {
|
|
|
25
25
|
this.resize = data.resize; // 是否可拖动大小
|
|
26
26
|
this.isROI = data.isROI ?? false; // 是否是ROI
|
|
27
27
|
this.isClose = data.isClose ?? true; // 是否是闭合标注
|
|
28
|
-
this.custom = data.custom ?? false; // 是否是自定义的标注
|
|
29
28
|
this.select = data.select ?? false; // 是否是选中状态
|
|
30
29
|
this.show = data.show ?? true; // 是否显示
|
|
31
|
-
this.subType = data.subType; // 自定义类型
|
|
32
30
|
this.__other__ = data.__other__ || {}; // 其他信息
|
|
33
31
|
this.__data__ = data.__data__ ?? data; // 记录原始数据
|
|
34
|
-
if (this.src
|
|
32
|
+
if (this.src) {
|
|
35
33
|
this.img = new Image();
|
|
36
34
|
this.img.src = this.src;
|
|
37
35
|
this.imgLoadSuccess = false;
|