kfb-view 3.0.7 → 3.0.9
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.js +1 -1
- package/lib/kfb-view.js.LICENSE.txt +3 -3
- package/package.json +3 -2
- package/src/components/area/index.js +38 -48
- package/src/components/board/index.js +1 -1
- package/src/components/common/common.js +0 -67
- package/src/components/grid/index.js +8 -3
- package/src/plugin/openseadragon/openseadragon.js +667 -126
- package/src/util/calculate.js +79 -35
- package/src/util/imageData.js +0 -5
- package/src/view.js +7 -6
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/git_toolbox_prj.xml +0 -20
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/inspectionProfiles/profiles_settings.xml +0 -5
- package/.idea/kfb-view.iml +0 -12
- package/.idea/misc.xml +0 -86
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/.idea/watcherTasks.xml +0 -4
- package/.idea/workspace.xml +0 -870
- package/config/utils.js +0 -77
- package/config/webpack.base.conf.js +0 -95
- package/config/webpack.dev.conf.js +0 -80
- package/config/webpack.lib.conf.js +0 -92
- package/config/webpack.prod.conf.js +0 -102
- package/config/webpack.test.conf.js +0 -0
- package/example/index.js +0 -546
- package/example/label/check.svg +0 -8
- package/example/label/check_empty.svg +0 -9
- package/example/label/cross.svg +0 -6
- package/example/label/cross_empty.svg +0 -6
- package/example/label/delete.svg +0 -8
- package/example/label/delete_empty.svg +0 -8
- package/example/label/hasAudit.svg +0 -26
- package/example/style/index.css +0 -153
- package/example/worker/canvas.worker.js +0 -28
- package/test.html +0 -246
- package/yarn.lock +0 -7508
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
//! Built on
|
|
1
|
+
//! Built on 2023-05-25
|
|
2
2
|
|
|
3
|
-
//! Git commit: v4.
|
|
3
|
+
//! Git commit: v4.1.0-0-8849681
|
|
4
4
|
|
|
5
5
|
//! License: http://openseadragon.github.io/license/
|
|
6
6
|
|
|
7
7
|
//! http://openseadragon.github.io
|
|
8
8
|
|
|
9
|
-
//! openseadragon 4.
|
|
9
|
+
//! openseadragon 4.1.0
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kfb-view",
|
|
3
3
|
"description": "一个在线kfb的阅片软件",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.9",
|
|
5
5
|
"author": "qifeng.fan <qifeng.fan@hzztai.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "lib/kfb-view.js",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@babel/polyfill": "^7.0.0",
|
|
26
|
-
"axios": "^0.19.2"
|
|
26
|
+
"axios": "^0.19.2",
|
|
27
|
+
"openseadragon": "^4.1.0"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"@babel/core": "^7.0.0",
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
STAR, IMAGE, RECTANGLE,
|
|
10
10
|
} from '../../const/mark';
|
|
11
11
|
import {
|
|
12
|
-
|
|
12
|
+
getAngle, getDistance, getPoint,
|
|
13
13
|
getRectPoint,
|
|
14
14
|
isPointInMatrix,
|
|
15
15
|
pointInOtherPoint, isPointInPolygon, pointsToRegion, isPointInLine,
|
|
@@ -189,34 +189,20 @@ export class Area extends ViewerCommon {
|
|
|
189
189
|
(point) => point.canMove && pointInOtherPoint(point, {x, y}));
|
|
190
190
|
} else if (LINE_TYPES.includes(item.tool)) {
|
|
191
191
|
// 直线类型的图形有3个可移动的点
|
|
192
|
-
const dist =
|
|
193
|
-
pointList
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
};
|
|
207
|
-
pointList[6] = {
|
|
208
|
-
x: startPoint.x - dist * baseNumber(startPoint.x - endPoint.x) *
|
|
209
|
-
baseNumber(startPoint.y - endPoint.y), y: startPoint.y + dist,
|
|
210
|
-
};
|
|
211
|
-
pointList[7] = endPoint;
|
|
212
|
-
pointList[8] = {
|
|
213
|
-
x: endPoint.x - dist * baseNumber(startPoint.x - endPoint.x) *
|
|
214
|
-
baseNumber(startPoint.y - endPoint.y), y: endPoint.y + dist,
|
|
215
|
-
};
|
|
216
|
-
moveIndex = pointList.findIndex((point, index) =>
|
|
217
|
-
point && pointInOtherPoint(point, {x, y}) &&
|
|
218
|
-
(index === 1 || index === 4 || index === 7),
|
|
219
|
-
);
|
|
192
|
+
const dist = item.lineWidth || 2;
|
|
193
|
+
pointList = [startPoint, endPoint];
|
|
194
|
+
if (pointInOtherPoint(startPoint, {x, y}, 10 + dist)) {
|
|
195
|
+
moveIndex = 1;
|
|
196
|
+
} else if (pointInOtherPoint(endPoint, {x, y}, 10 + dist)) {
|
|
197
|
+
moveIndex = 7;
|
|
198
|
+
} else if (pointInOtherPoint({
|
|
199
|
+
x: (endPoint.x + startPoint.x) / 2,
|
|
200
|
+
y: (endPoint.y + startPoint.y) / 2,
|
|
201
|
+
}, {x, y}, 10 + dist)) {
|
|
202
|
+
moveIndex = 4;
|
|
203
|
+
} else {
|
|
204
|
+
moveIndex = -1;
|
|
205
|
+
}
|
|
220
206
|
} else if (item.tool === FONT) {
|
|
221
207
|
const fontWidth = this.getFontWidth(item.text, item.fontSize);
|
|
222
208
|
pointList =
|
|
@@ -255,35 +241,39 @@ export class Area extends ViewerCommon {
|
|
|
255
241
|
if (~moveIndex) {
|
|
256
242
|
this.movePoint = {position: moveIndex, label: item};
|
|
257
243
|
this.currentPressPoint = {x, y};
|
|
258
|
-
} else if (
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
(
|
|
244
|
+
} else if (item.tool === POLYGON) {
|
|
245
|
+
isPointInPolygon({x, y}, pointList) ? selectList.push(item) : undefined;
|
|
246
|
+
} else if (LINE_TYPES.includes(item.tool)) {
|
|
247
|
+
isPointInLine({x, y}, pointList) ? selectList.push(item) : undefined;
|
|
248
|
+
} else if (isPointInMatrix(pointList[0], pointList[2], pointList[6],
|
|
249
|
+
pointList[8], {x, y})) {
|
|
262
250
|
selectList.push(item);
|
|
263
251
|
}
|
|
264
252
|
});
|
|
265
253
|
// 如果点击canvas,同时选中了多个标签,那么显示规则为,
|
|
266
|
-
// 优先级FONT>STAR>FLAG
|
|
267
|
-
// 如果是LINE或RECT或ELLIPSE或
|
|
254
|
+
// 优先级DOT>FONT>STAR>FLAG
|
|
255
|
+
// 如果是LINE或RECT或ELLIPSE或POLYGON则优先显示范围小的
|
|
268
256
|
if (this.movePoint) {
|
|
269
257
|
this.movePoint.label.select = true;
|
|
270
258
|
this.$emit(EVENT_SELECT_LABEL, this.movePoint.label);
|
|
271
259
|
this.$emit(EVENT_AREA_MOVE_START, this.movePoint.label);
|
|
272
260
|
this.draging = true;
|
|
273
261
|
} else if (selectList.length > 0) {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
262
|
+
selectList.sort((a, b) => {
|
|
263
|
+
if (a.tool === DOT) {
|
|
264
|
+
return -1;
|
|
265
|
+
} else if (a.tool === FONT) {
|
|
266
|
+
return b.tool === DOT ? 1 : -1;
|
|
267
|
+
} else if (a.tool === STAR) {
|
|
268
|
+
return (b.tool === DOT || b.tool === FONT) ? 1 : -1;
|
|
269
|
+
} else if (a.tool === FLAG) {
|
|
270
|
+
return (b.tool === DOT || b.tool === FONT || b.tool === STAR) ?
|
|
271
|
+
1 : -1;
|
|
272
|
+
} else {
|
|
273
|
+
return Math.abs(a.region.width) - Math.abs(b.region.width);
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
selectLabel = selectList[0];
|
|
287
277
|
selectLabel.select = true;
|
|
288
278
|
}
|
|
289
279
|
selectLabel ?
|
|
@@ -339,73 +339,6 @@ export class ViewerCommon extends EventEmitter {
|
|
|
339
339
|
};
|
|
340
340
|
}
|
|
341
341
|
|
|
342
|
-
/**
|
|
343
|
-
* 获取区域像素点信息
|
|
344
|
-
* @param {Object} region
|
|
345
|
-
* @param {Object} canvas
|
|
346
|
-
* @return {{points, imageData}}
|
|
347
|
-
*/
|
|
348
|
-
getImageData(region, canvas) {
|
|
349
|
-
const ctx = canvas.getContext('2d');
|
|
350
|
-
const imageData =
|
|
351
|
-
ctx.getImageData(region.x, region.y, region.width, region.height);
|
|
352
|
-
// let points = [];
|
|
353
|
-
/* return {
|
|
354
|
-
points,
|
|
355
|
-
imageData: {
|
|
356
|
-
data,
|
|
357
|
-
width,
|
|
358
|
-
height,
|
|
359
|
-
},
|
|
360
|
-
};*/
|
|
361
|
-
// 转换成10倍下的像素
|
|
362
|
-
return this.changeImageData(imageData);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* 转换imageData像素点信息
|
|
367
|
-
* @param {Object} imageData
|
|
368
|
-
* @return {*}
|
|
369
|
-
*/
|
|
370
|
-
changeImageData(imageData) {
|
|
371
|
-
const {data, width, height} = imageData;
|
|
372
|
-
const zoom =
|
|
373
|
-
this.viewport.viewportToImageZoom(
|
|
374
|
-
this.viewport.getZoom(true));
|
|
375
|
-
if (zoom <= 10) {
|
|
376
|
-
return {
|
|
377
|
-
points: [],
|
|
378
|
-
imageData: {
|
|
379
|
-
data,
|
|
380
|
-
width,
|
|
381
|
-
height,
|
|
382
|
-
},
|
|
383
|
-
};
|
|
384
|
-
} else {
|
|
385
|
-
const changeWidth = (10 / zoom * width >> 0);
|
|
386
|
-
const changeHeight = (10 / zoom * height >> 0);
|
|
387
|
-
const canvas = document.createElement('canvas');
|
|
388
|
-
const ctx = canvas.getContext('2d');
|
|
389
|
-
canvas.width = width;
|
|
390
|
-
canvas.height = height;
|
|
391
|
-
ctx.putImageData(imageData, 0, 0, 0, 0, canvas.width, canvas.height);
|
|
392
|
-
const cv = document.createElement('canvas');
|
|
393
|
-
const context = cv.getContext('2d');
|
|
394
|
-
cv.width = changeWidth;
|
|
395
|
-
cv.height = changeHeight;
|
|
396
|
-
context.drawImage(canvas, 0, 0, changeWidth, changeHeight);
|
|
397
|
-
const _imageData = context.getImageData(0, 0, changeWidth, changeHeight);
|
|
398
|
-
return {
|
|
399
|
-
points: [],
|
|
400
|
-
imageData: {
|
|
401
|
-
data: _imageData.data,
|
|
402
|
-
width: _imageData.width,
|
|
403
|
-
height: _imageData.height,
|
|
404
|
-
},
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
|
|
409
342
|
/**
|
|
410
343
|
* 判断region是否在canvas中
|
|
411
344
|
* @param {Object} region
|
|
@@ -26,7 +26,11 @@ export class Grid extends ViewerCommon {
|
|
|
26
26
|
const imageViewYEndPoint = this.viewerElementToImageCoordinates(0,
|
|
27
27
|
this.canvas.height);
|
|
28
28
|
let currentZoom = this.getImageZoom(true) * this.options.scale;
|
|
29
|
-
|
|
29
|
+
const pxConversion = this.options.pxConversion ?
|
|
30
|
+
this.options.imageCapRes : 1;
|
|
31
|
+
let baseScale = this.options.scale === 40 ?
|
|
32
|
+
(this.options.pxConversion ? 1600 / this.options.imageCapRes : 3200) :
|
|
33
|
+
(this.options.pxConversion ? 800 / this.options.imageCapRes : 1600);
|
|
30
34
|
let twoCount = 0;
|
|
31
35
|
if (currentZoom >= 1) {
|
|
32
36
|
while (currentZoom / 2 >= 1) {
|
|
@@ -91,7 +95,8 @@ export class Grid extends ViewerCommon {
|
|
|
91
95
|
ctx.moveTo(point.x + (basePx / 5) * j, 16);
|
|
92
96
|
ctx.lineTo(point.x + (basePx / 5) * j, 20);
|
|
93
97
|
if (i !== minX) {
|
|
94
|
-
ctx.fillText(i * baseScale, point.x + 5,
|
|
98
|
+
ctx.fillText((i * baseScale * pxConversion).toFixed(0), point.x + 5,
|
|
99
|
+
13);
|
|
95
100
|
}
|
|
96
101
|
}
|
|
97
102
|
}
|
|
@@ -106,7 +111,7 @@ export class Grid extends ViewerCommon {
|
|
|
106
111
|
ctx.save();
|
|
107
112
|
ctx.translate(3, point.y + 5);
|
|
108
113
|
ctx.rotate(Math.PI / 2);
|
|
109
|
-
ctx.fillText(i * baseScale, 0, 0);
|
|
114
|
+
ctx.fillText((i * baseScale * pxConversion).toFixed(0), 0, 0);
|
|
110
115
|
ctx.restore();
|
|
111
116
|
}
|
|
112
117
|
}
|