kfb-view 2.2.8 → 2.2.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/.idea/workspace.xml +56 -41
- package/example/index.js +18 -5
- package/lib/kfb-view.js +1 -1
- package/package.json +1 -1
- package/src/components/area/index.js +28 -2
- package/src/components/board/index.js +4 -1
- package/src/components/common/common.js +4 -3
- package/src/tool/Brush.js +3 -0
- package/src/view.js +7 -0
package/package.json
CHANGED
|
@@ -517,6 +517,7 @@ export class Area extends ViewerCommon {
|
|
|
517
517
|
*/
|
|
518
518
|
change() {
|
|
519
519
|
this.clearCanvas();
|
|
520
|
+
this.showLabelMeasure();
|
|
520
521
|
const label = this.labelList.find((item) => item.select);
|
|
521
522
|
if (!label) return;
|
|
522
523
|
if (label.show === false) return;
|
|
@@ -572,9 +573,34 @@ export class Area extends ViewerCommon {
|
|
|
572
573
|
}
|
|
573
574
|
}
|
|
574
575
|
this[label.tool].setContent(this.canvas, {...label});
|
|
575
|
-
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
showLabelMeasure() {
|
|
579
|
+
const bounds = this.viewport.getBounds();
|
|
580
|
+
const currentScale = this.getImageZoom(true);
|
|
581
|
+
if (currentScale * this.options.scale < this.options.measure.scale) {
|
|
582
|
+
const label = this.labelList.find((item) => item.select);
|
|
583
|
+
if (!label) return;
|
|
584
|
+
if (label.show === false) return;
|
|
585
|
+
if (label.measure === false) return;
|
|
576
586
|
this[label.tool].drawMeasureInfo.call(this, label,
|
|
577
|
-
this.getMeasureContent(label)
|
|
587
|
+
this.getMeasureContent(label));
|
|
588
|
+
} else {
|
|
589
|
+
this.labelList.forEach((label) => {
|
|
590
|
+
if (label.show === false) return;
|
|
591
|
+
if (label.measure === false) return;
|
|
592
|
+
const content = this.getMeasureContent(label);
|
|
593
|
+
if (label.select) {
|
|
594
|
+
this[label.tool].drawMeasureInfo.call(this, label, content);
|
|
595
|
+
} else if (this.options.measure.defaultShow) {
|
|
596
|
+
if (!this.isInCanvas(label.region, bounds)) return false;
|
|
597
|
+
this[label.tool].drawMeasureInfo.call(this, label, content);
|
|
598
|
+
}
|
|
599
|
+
if (this.options.labelDrawing) {
|
|
600
|
+
this.options.labelDrawing(this.canvas, label,
|
|
601
|
+
this.imageToViewerElementRectangle(label.region));
|
|
602
|
+
}
|
|
603
|
+
});
|
|
578
604
|
}
|
|
579
605
|
}
|
|
580
606
|
|
|
@@ -383,7 +383,10 @@ export class Board extends ViewerCommon {
|
|
|
383
383
|
});
|
|
384
384
|
if (form.measure) {
|
|
385
385
|
this[this.tool].drawMeasureInfo.call(this, form,
|
|
386
|
-
this.getMeasureContent(
|
|
386
|
+
this.getMeasureContent({
|
|
387
|
+
...form,
|
|
388
|
+
select: true,
|
|
389
|
+
}));
|
|
387
390
|
}
|
|
388
391
|
return form;
|
|
389
392
|
}
|
|
@@ -314,11 +314,12 @@ export class ViewerCommon extends EventEmitter {
|
|
|
314
314
|
}
|
|
315
315
|
break;
|
|
316
316
|
}
|
|
317
|
+
const handler = label.select ?
|
|
318
|
+
(this.options.measure.selectHandler || this.options.measure.handler) :
|
|
319
|
+
this.options.measure.handler;
|
|
317
320
|
return {
|
|
318
321
|
...content,
|
|
319
|
-
texts:
|
|
320
|
-
this.options.measure.handler(content.texts, label) :
|
|
321
|
-
content.texts,
|
|
322
|
+
texts: handler ? handler(content.texts, label) : content.texts,
|
|
322
323
|
};
|
|
323
324
|
}
|
|
324
325
|
|
package/src/tool/Brush.js
CHANGED
package/src/view.js
CHANGED
|
@@ -66,9 +66,13 @@ export default class KfbView extends EventEmitter {
|
|
|
66
66
|
* @param {boolean=} config.grid.show 是否显示网格线
|
|
67
67
|
* @param {boolean=} config.grid.ruler 是否启用标尺
|
|
68
68
|
* @param {function=} config.measure.handler 标注信息的回调处理
|
|
69
|
+
* @param {function=} config.measure.selectHandler 标注信息选中时的回调处理
|
|
69
70
|
* @param {boolean=} config.measure.color 标注注释颜色
|
|
70
71
|
* @param {boolean=} config.measure.backgroundColor 标注注释背景色
|
|
71
72
|
* @param {boolean=} config.measure.fontSize 标注注释文字大小
|
|
73
|
+
* @param {boolean=} config.measure.defaultShow 标注是否默认永久显示,false表示只在选中时显示
|
|
74
|
+
* @param {boolean=} config.measure.scale 标注默认永久显示时的倍率,
|
|
75
|
+
* @param {boolean=} config.labelDrawing 标注绘制回调,
|
|
72
76
|
* @param {array} config.labelList 标注列表
|
|
73
77
|
*/
|
|
74
78
|
constructor(config) {
|
|
@@ -272,10 +276,13 @@ function initComponentsOptions(kv, type) {
|
|
|
272
276
|
canvas: createCanvas(kv),
|
|
273
277
|
options: {
|
|
274
278
|
scale: config.scale,
|
|
279
|
+
labelDrawing: config.labelDrawing,
|
|
275
280
|
measure: {
|
|
276
281
|
backgroundColor: 'rgba(0,0,0,.5)',
|
|
277
282
|
color: '#FFF',
|
|
278
283
|
fontSize: 14,
|
|
284
|
+
scale: 10,
|
|
285
|
+
defaultShow: false,
|
|
279
286
|
...(config.measure || {}),
|
|
280
287
|
},
|
|
281
288
|
...config[type],
|