kfb-view 3.0.8 → 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.
Files changed (38) hide show
  1. package/lib/kfb-view.js +1 -1
  2. package/lib/kfb-view.js.LICENSE.txt +3 -3
  3. package/package.json +3 -2
  4. package/src/components/area/index.js +38 -48
  5. package/src/components/board/index.js +1 -1
  6. package/src/components/common/common.js +0 -67
  7. package/src/plugin/openseadragon/openseadragon.js +667 -126
  8. package/src/util/calculate.js +79 -35
  9. package/src/util/imageData.js +0 -5
  10. package/src/view.js +6 -6
  11. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  12. package/.idea/git_toolbox_prj.xml +0 -20
  13. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  14. package/.idea/inspectionProfiles/profiles_settings.xml +0 -5
  15. package/.idea/kfb-view.iml +0 -12
  16. package/.idea/misc.xml +0 -86
  17. package/.idea/modules.xml +0 -8
  18. package/.idea/vcs.xml +0 -6
  19. package/.idea/watcherTasks.xml +0 -4
  20. package/.idea/workspace.xml +0 -874
  21. package/config/utils.js +0 -77
  22. package/config/webpack.base.conf.js +0 -95
  23. package/config/webpack.dev.conf.js +0 -80
  24. package/config/webpack.lib.conf.js +0 -92
  25. package/config/webpack.prod.conf.js +0 -102
  26. package/config/webpack.test.conf.js +0 -0
  27. package/example/index.js +0 -547
  28. package/example/label/check.svg +0 -8
  29. package/example/label/check_empty.svg +0 -9
  30. package/example/label/cross.svg +0 -6
  31. package/example/label/cross_empty.svg +0 -6
  32. package/example/label/delete.svg +0 -8
  33. package/example/label/delete_empty.svg +0 -8
  34. package/example/label/hasAudit.svg +0 -26
  35. package/example/style/index.css +0 -153
  36. package/example/worker/canvas.worker.js +0 -28
  37. package/test.html +0 -246
  38. package/yarn.lock +0 -7508
@@ -1,9 +1,9 @@
1
- //! Built on 2022-12-16
1
+ //! Built on 2023-05-25
2
2
 
3
- //! Git commit: v4.0.0-0-8e6196a
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.0.0
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.8",
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
- baseNumber, getAngle, getDistance, getPoint,
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 = (item.lineWidth || 7) < 8 ? 8 : item.lineWidth;
193
- pointList[0] = {
194
- x: startPoint.x + dist * baseNumber(startPoint.x - endPoint.x) *
195
- baseNumber(startPoint.y - endPoint.y),
196
- y: startPoint.y - dist,
197
- };
198
- pointList[1] = startPoint;
199
- pointList[2] = {
200
- x: endPoint.x + dist * baseNumber(startPoint.x - endPoint.x) *
201
- baseNumber(startPoint.y - endPoint.y), y: endPoint.y - dist,
202
- };
203
- pointList[4] = {
204
- x: (startPoint.x + endPoint.x) / 2,
205
- y: (startPoint.y + endPoint.y) / 2,
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 ((item.tool !== POLYGON &&
259
- isPointInMatrix(pointList[0], pointList[2], pointList[6], pointList[8],
260
- {x, y})) ||
261
- (item.tool === POLYGON && isPointInPolygon({x, y}, pointList))) {
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>LINE>RECT>POLYGON
267
- // 如果是LINE或RECT或ELLIPSE或CURVE则优先显示范围小的
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
- if (selectLabel = selectList.find((draw) => draw.tool === DOT)) {
275
- //
276
- } else if (selectLabel = selectList.find((draw) => draw.tool === FONT)) {
277
- //
278
- } else if (selectLabel = selectList.find((draw) => draw.tool === STAR)) {
279
- //
280
- } else if (selectLabel = selectList.find((draw) => draw.tool === FLAG)) {
281
- //
282
- } else {
283
- selectList.sort((a, b) =>
284
- Math.abs(a.region.width) - Math.abs(b.region.width));
285
- selectLabel = selectList[0];
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 ?
@@ -234,7 +234,7 @@ export class Board extends ViewerCommon {
234
234
  }
235
235
  } else {
236
236
  this.setEnablePoints();
237
- // 如果点小于5个,任务标注不符合规范
237
+ // 如果点小于5个,表示标注不符合规范
238
238
  if (this.points.length < 5) {
239
239
  this.points = [];
240
240
  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