kfb-view 3.1.0 → 3.1.1

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kfb-view",
3
3
  "description": "一个在线kfb的阅片软件",
4
- "version": "3.1.0",
4
+ "version": "3.1.1",
5
5
  "author": "qifeng.fan <qifeng.fan@hzztai.com>",
6
6
  "license": "MIT",
7
7
  "main": "lib/kfb-view.js",
@@ -698,9 +698,11 @@ export class Area extends ViewerCommon {
698
698
  this[label.tool].drawMeasureInfo.call(this, label,
699
699
  this.getMeasureContent(label));
700
700
  }
701
- if (this.options.labelDrawing) {
701
+ if (this.options.labelDrawing || this.options.label?.drawing) {
702
702
  if (!this.isInCanvas(label.region, bounds)) return false;
703
- this.options.labelDrawing(this.canvas, label,
703
+ const drawingFunc = this.options.label?.drawing ||
704
+ this.options.labelDrawing;
705
+ drawingFunc(this.canvas, label,
704
706
  this.imageToViewerElementRectangle(label.region));
705
707
  }
706
708
  });
@@ -715,11 +717,12 @@ export class Area extends ViewerCommon {
715
717
  setPointsMove(label) {
716
718
  const movePoints = this.imageToViewerElementPoints(label.points);
717
719
  let lastPoint = movePoints[0];
720
+ const dist = this.options.label?.polygonWidth || 30;
718
721
  movePoints.forEach((point, index) => {
719
722
  point.canMove = false;
720
723
  label.points[index].canMove = false;
721
- if (index === 0 || (!pointInOtherPoint(lastPoint, point, 30) &&
722
- !pointInOtherPoint(movePoints[0], point, 30)) ||
724
+ if (index === 0 || (!pointInOtherPoint(lastPoint, point, dist) &&
725
+ !pointInOtherPoint(movePoints[0], point, dist)) ||
723
726
  (index === movePoints.length - 1)) {
724
727
  lastPoint = point;
725
728
  point.canMove = true;
@@ -368,11 +368,12 @@ export class Board extends ViewerCommon {
368
368
  const points = this.imageToViewerElementPoints(this.points);
369
369
  let firstPoint = points[0];
370
370
  // 过滤曲线的点,点之间的距离小于10默认为一个点,取第一个
371
+ const dist = this.options.label?.polygonWidth || 30;
371
372
  this.points = this.points.filter((p, index) => {
372
373
  const _p = points[index];
373
374
  if (index === 0) return true;
374
375
  if (index === this.points.length - 1) return true;
375
- if (pointInOtherPoint(firstPoint, _p, 30)) {
376
+ if (pointInOtherPoint(firstPoint, _p, dist)) {
376
377
  const nextPoint = points[index + 1];
377
378
  if (nextPoint) {
378
379
  const deg = Math.abs(getAngle(_p, firstPoint, nextPoint));
package/src/view.js CHANGED
@@ -76,7 +76,10 @@ export default class KfbView extends EventEmitter {
76
76
  * @param {boolean=} config.measure.fontSize 标注注释文字大小
77
77
  * @param {boolean=} config.measure.defaultShow 标注是否默认永久显示,false表示只在选中时显示
78
78
  * @param {boolean=} config.measure.scale 标注默认永久显示时的倍率,
79
- * @param {boolean=} config.labelDrawing 标注绘制回调,
79
+ * @param {Object} config.label 标注配置
80
+ * @param {number=} config.label.polygonWidth 曲线点识别宽度,
81
+ * @param {function=} config.label.drawing 标注绘制回调,
82
+ * @param {function=} config.labelDrawing 标注绘制回调 @deprecated Use label.drawing instead
80
83
  * @param {array} config.labelList 标注列表
81
84
  */
82
85
  constructor(config) {
@@ -282,6 +285,7 @@ function initComponentsOptions(kv, type) {
282
285
  options: {
283
286
  scale: config.scale,
284
287
  labelDrawing: config.labelDrawing,
288
+ label: config.label || {},
285
289
  measure: {
286
290
  backgroundColor: 'rgba(0,0,0,.5)',
287
291
  color: '#FFF',