kfb-view 3.0.8 → 3.1.0
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 +30 -4
- package/src/components/common/common.js +0 -67
- 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 +6 -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 -874
- 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 -547
- 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.1.0",
|
|
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 ?
|
|
@@ -3,7 +3,7 @@ import * as Tools from '../../tool';
|
|
|
3
3
|
import {
|
|
4
4
|
POLYGON, DOT, FLAG, MARKS,
|
|
5
5
|
NO_NORMAL_REGION_TYPES,
|
|
6
|
-
POINT_TYPES, STAR,
|
|
6
|
+
POINT_TYPES, STAR, ELLIPSE,
|
|
7
7
|
} from '../../const/mark';
|
|
8
8
|
import {
|
|
9
9
|
EVENT_START_PAINTING,
|
|
@@ -142,6 +142,8 @@ export class Board extends ViewerCommon {
|
|
|
142
142
|
const tool = this.tool;
|
|
143
143
|
if (tool === POLYGON) {
|
|
144
144
|
this.points.push(point);
|
|
145
|
+
} else if (ELLIPSE === tool) {
|
|
146
|
+
this.points = [point, point];
|
|
145
147
|
} else {
|
|
146
148
|
this.points = [point];
|
|
147
149
|
}
|
|
@@ -172,7 +174,15 @@ export class Board extends ViewerCommon {
|
|
|
172
174
|
}
|
|
173
175
|
e.preventDefaultAction = true;
|
|
174
176
|
const tool = this.tool;
|
|
175
|
-
if (
|
|
177
|
+
if (ELLIPSE === tool) {
|
|
178
|
+
const _x = point.x - this.points[1].x;
|
|
179
|
+
const _y = point.y - this.points[1].y;
|
|
180
|
+
const _point = {
|
|
181
|
+
x: this.points[1].x - _x,
|
|
182
|
+
y: this.points[1].y - _y,
|
|
183
|
+
};
|
|
184
|
+
this.points = [_point, this.points[1], point];
|
|
185
|
+
} else if (!NO_NORMAL_REGION_TYPES.includes(tool)) {
|
|
176
186
|
this.points = [this.points[0] || point, point];
|
|
177
187
|
} else if (tool === POLYGON) {
|
|
178
188
|
this.points.push(point);
|
|
@@ -207,7 +217,23 @@ export class Board extends ViewerCommon {
|
|
|
207
217
|
return;
|
|
208
218
|
}
|
|
209
219
|
const tool = this.tool;
|
|
210
|
-
if (
|
|
220
|
+
if (ELLIPSE === tool) {
|
|
221
|
+
const _x = point.x - this.points[1].x;
|
|
222
|
+
const _y = point.y - this.points[1].y;
|
|
223
|
+
const _point = {
|
|
224
|
+
x: this.points[1].x - _x,
|
|
225
|
+
y: this.points[1].y - _y,
|
|
226
|
+
};
|
|
227
|
+
this.points = [_point, point];
|
|
228
|
+
const firstPoint = this.imageToViewerElementCoordinates(this.points[0].x,
|
|
229
|
+
this.points[0].y);
|
|
230
|
+
const dist = getDistance(firstPoint, {x, y});
|
|
231
|
+
if (Math.abs(dist) < 10) {
|
|
232
|
+
this.points = [];
|
|
233
|
+
this.clearCanvas();
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
} else if (!NO_NORMAL_REGION_TYPES.includes(tool)) {
|
|
211
237
|
const firstPoint = this.imageToViewerElementCoordinates(this.points[0].x,
|
|
212
238
|
this.points[0].y);
|
|
213
239
|
const dist = getDistance(firstPoint, {x, y});
|
|
@@ -234,7 +260,7 @@ export class Board extends ViewerCommon {
|
|
|
234
260
|
}
|
|
235
261
|
} else {
|
|
236
262
|
this.setEnablePoints();
|
|
237
|
-
// 如果点小于5
|
|
263
|
+
// 如果点小于5个,表示标注不符合规范
|
|
238
264
|
if (this.points.length < 5) {
|
|
239
265
|
this.points = [];
|
|
240
266
|
this.clearCanvas();
|
|
@@ -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
|