kfb-view 2.3.1 → 2.3.2
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 +23 -21
- package/example/index.js +2 -2
- package/lib/kfb-view.js +1 -1
- package/package.json +1 -1
- package/src/components/area/index.js +10 -7
- package/src/components/common/common.js +3 -5
- package/src/components/shape/index.js +10 -10
package/package.json
CHANGED
|
@@ -671,7 +671,8 @@ export class Area extends ViewerCommon {
|
|
|
671
671
|
}
|
|
672
672
|
|
|
673
673
|
showLabelMeasure() {
|
|
674
|
-
const bounds = this.viewport.
|
|
674
|
+
const bounds = this.viewport.viewportToImageRectangle(
|
|
675
|
+
this.viewport.getBounds());
|
|
675
676
|
const currentScale = this.getImageZoom(true);
|
|
676
677
|
if (currentScale * this.options.scale < this.options.measure.scale) {
|
|
677
678
|
const label = this.labelList.find((item) => item.select);
|
|
@@ -681,17 +682,19 @@ export class Area extends ViewerCommon {
|
|
|
681
682
|
this[label.tool].drawMeasureInfo.call(this, label,
|
|
682
683
|
this.getMeasureContent(label));
|
|
683
684
|
} else {
|
|
685
|
+
console.log(1);
|
|
684
686
|
this.labelList.forEach((label) => {
|
|
685
687
|
if (label.show === false) return;
|
|
686
|
-
if (label.
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
} else if (this.options.measure.defaultShow) {
|
|
688
|
+
if (label.select && label.measure) {
|
|
689
|
+
this[label.tool].drawMeasureInfo.call(this, label,
|
|
690
|
+
this.getMeasureContent(label));
|
|
691
|
+
} else if (this.options.measure.defaultShow && label.measure) {
|
|
691
692
|
if (!this.isInCanvas(label.region, bounds)) return false;
|
|
692
|
-
this[label.tool].drawMeasureInfo.call(this, label,
|
|
693
|
+
this[label.tool].drawMeasureInfo.call(this, label,
|
|
694
|
+
this.getMeasureContent(label));
|
|
693
695
|
}
|
|
694
696
|
if (this.options.labelDrawing) {
|
|
697
|
+
if (!this.isInCanvas(label.region, bounds)) return false;
|
|
695
698
|
this.options.labelDrawing(this.canvas, label,
|
|
696
699
|
this.imageToViewerElementRectangle(label.region));
|
|
697
700
|
}
|
|
@@ -413,12 +413,10 @@ export class ViewerCommon extends EventEmitter {
|
|
|
413
413
|
* @return {boolean}
|
|
414
414
|
*/
|
|
415
415
|
isInCanvas(region, bounds) {
|
|
416
|
-
const
|
|
417
|
-
region.width, region.height);
|
|
418
|
-
const startPoint = {x: viewReact.x, y: viewReact.y};
|
|
416
|
+
const startPoint = {x: region.x, y: region.y};
|
|
419
417
|
const endPoint = {
|
|
420
|
-
x:
|
|
421
|
-
y:
|
|
418
|
+
x: region.x + region.width,
|
|
419
|
+
y: region.y + region.height,
|
|
422
420
|
};
|
|
423
421
|
return !(startPoint.x > (bounds.x + bounds.width) || startPoint.y >
|
|
424
422
|
(bounds.y + bounds.height) || endPoint.x < bounds.x || endPoint.y <
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HAS_REGION_TYPES, IMAGE,
|
|
3
|
-
MARKS,
|
|
3
|
+
MARKS, POINT_TYPES, POLYGON, REGION_TYPES,
|
|
4
4
|
} from '../../const/mark';
|
|
5
5
|
import {ViewerCommon} from '../common/common';
|
|
6
6
|
import * as Tools from '../../tool';
|
|
@@ -49,12 +49,14 @@ export class Shape extends ViewerCommon {
|
|
|
49
49
|
*/
|
|
50
50
|
change() {
|
|
51
51
|
this.clearCanvas();
|
|
52
|
-
const bounds = this.viewport.
|
|
52
|
+
const bounds = this.viewport.viewportToImageRectangle(
|
|
53
|
+
this.viewport.getBounds());
|
|
53
54
|
// 区域标注列表
|
|
54
55
|
const regionLabelList = [];
|
|
55
56
|
const labelList = this.labelList.filter((item) => {
|
|
56
57
|
if (item.show === false) return false;
|
|
57
58
|
if (!this[item.tool]) return false;
|
|
59
|
+
if (!this.isInCanvas(item.region, bounds)) return false;
|
|
58
60
|
if ((REGION_TYPES.includes(item.tool) || item.isClose && item.tool ===
|
|
59
61
|
POLYGON) && item.fillStyle) {
|
|
60
62
|
regionLabelList.push({
|
|
@@ -70,6 +72,7 @@ export class Shape extends ViewerCommon {
|
|
|
70
72
|
const sameNormalLabel = {};
|
|
71
73
|
const imageLabel = [];
|
|
72
74
|
labelList.forEach((item) => {
|
|
75
|
+
item.viewerElementPoints = this.imageToViewerElementPoints(item.points);
|
|
73
76
|
if (item.tool === IMAGE) {
|
|
74
77
|
imageLabel.push(item);
|
|
75
78
|
return;
|
|
@@ -104,13 +107,12 @@ export class Shape extends ViewerCommon {
|
|
|
104
107
|
}
|
|
105
108
|
this.deepDrawLabel(sameFixWidthLabel, sameNormalLabel, 1, bounds);
|
|
106
109
|
regionLabelList.forEach((item) => {
|
|
107
|
-
if (!this.isInCanvas(item.region, bounds)) return false;
|
|
108
110
|
this.combination.setContent(this.canvas, item);
|
|
109
111
|
this.combination.draw({
|
|
110
|
-
points:
|
|
112
|
+
points: item.viewerElementPoints,
|
|
111
113
|
tool: item.tool,
|
|
112
|
-
}, item.child.map(({
|
|
113
|
-
points:
|
|
114
|
+
}, item.child.map(({viewerElementPoints, tool}) => ({
|
|
115
|
+
points: viewerElementPoints,
|
|
114
116
|
tool,
|
|
115
117
|
})), this.viewport.getRotation());
|
|
116
118
|
});
|
|
@@ -134,7 +136,6 @@ export class Shape extends ViewerCommon {
|
|
|
134
136
|
remainFixLabel[key] = [item];
|
|
135
137
|
}
|
|
136
138
|
} else {
|
|
137
|
-
if (!this.isInCanvas(item.region, bounds)) return false;
|
|
138
139
|
this.drawLabel(item);
|
|
139
140
|
}
|
|
140
141
|
currentDrawCount++;
|
|
@@ -159,7 +160,6 @@ export class Shape extends ViewerCommon {
|
|
|
159
160
|
remainNormalLabel[key] = [item];
|
|
160
161
|
}
|
|
161
162
|
} else {
|
|
162
|
-
if (!this.isInCanvas(item.region, bounds)) return false;
|
|
163
163
|
this.drawLabel(item);
|
|
164
164
|
}
|
|
165
165
|
currentDrawCount++;
|
|
@@ -182,9 +182,9 @@ export class Shape extends ViewerCommon {
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
drawLabel(item) {
|
|
185
|
-
const points =
|
|
185
|
+
const points = item.viewerElementPoints;
|
|
186
186
|
this[item.tool].setContent(this.canvas, item);
|
|
187
|
-
if (
|
|
187
|
+
if (REGION_TYPES.includes(item.tool)) {
|
|
188
188
|
this[item.tool].draw(points, this.viewport.getRotation(),
|
|
189
189
|
this.imageToViewerElementRectangle(item.region));
|
|
190
190
|
} else {
|