kfb-view 2.3.0 → 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 +63 -46
- package/example/index.js +2 -2
- package/lib/kfb-view.js +1 -1
- package/package.json +1 -1
- package/src/components/area/index.js +19 -8
- package/src/components/common/common.js +21 -7
- package/src/components/shape/index.js +10 -10
- package/src/model/label.model.js +1 -0
package/package.json
CHANGED
|
@@ -573,7 +573,15 @@ export class Area extends ViewerCommon {
|
|
|
573
573
|
}, position === 4);
|
|
574
574
|
this.drawPoint(points[1], position === 7);
|
|
575
575
|
} else if (type === RECTANGLE) {
|
|
576
|
-
|
|
576
|
+
const sp = {
|
|
577
|
+
x: points[0].x < points[1].x ? points[0].x : points[1].x,
|
|
578
|
+
y: points[0].y < points[1].y ? points[0].y : points[1].y,
|
|
579
|
+
};
|
|
580
|
+
const ep = {
|
|
581
|
+
x: points[0].x > points[1].x ? points[0].x : points[1].x,
|
|
582
|
+
y: points[0].y > points[1].y ? points[0].y : points[1].y,
|
|
583
|
+
};
|
|
584
|
+
getRectPoint(sp, ep).forEach((point, i) => {
|
|
577
585
|
this.drawLine(point, i, position === i);
|
|
578
586
|
});
|
|
579
587
|
} else if (REGION_TYPES.includes(type)) {
|
|
@@ -663,7 +671,8 @@ export class Area extends ViewerCommon {
|
|
|
663
671
|
}
|
|
664
672
|
|
|
665
673
|
showLabelMeasure() {
|
|
666
|
-
const bounds = this.viewport.
|
|
674
|
+
const bounds = this.viewport.viewportToImageRectangle(
|
|
675
|
+
this.viewport.getBounds());
|
|
667
676
|
const currentScale = this.getImageZoom(true);
|
|
668
677
|
if (currentScale * this.options.scale < this.options.measure.scale) {
|
|
669
678
|
const label = this.labelList.find((item) => item.select);
|
|
@@ -673,17 +682,19 @@ export class Area extends ViewerCommon {
|
|
|
673
682
|
this[label.tool].drawMeasureInfo.call(this, label,
|
|
674
683
|
this.getMeasureContent(label));
|
|
675
684
|
} else {
|
|
685
|
+
console.log(1);
|
|
676
686
|
this.labelList.forEach((label) => {
|
|
677
687
|
if (label.show === false) return;
|
|
678
|
-
if (label.
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
} 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) {
|
|
683
692
|
if (!this.isInCanvas(label.region, bounds)) return false;
|
|
684
|
-
this[label.tool].drawMeasureInfo.call(this, label,
|
|
693
|
+
this[label.tool].drawMeasureInfo.call(this, label,
|
|
694
|
+
this.getMeasureContent(label));
|
|
685
695
|
}
|
|
686
696
|
if (this.options.labelDrawing) {
|
|
697
|
+
if (!this.isInCanvas(label.region, bounds)) return false;
|
|
687
698
|
this.options.labelDrawing(this.canvas, label,
|
|
688
699
|
this.imageToViewerElementRectangle(label.region));
|
|
689
700
|
}
|
|
@@ -190,14 +190,30 @@ export class ViewerCommon extends EventEmitter {
|
|
|
190
190
|
if (label.points.length <= 1) return content;
|
|
191
191
|
const scale = this.getImageZoom(true) / label.scale;
|
|
192
192
|
const region = pointsToRegion(label.points);
|
|
193
|
-
const
|
|
194
|
-
const
|
|
193
|
+
const _startPoint = {x: region.x, y: region.y};
|
|
194
|
+
const _endPoint = {x: region.x + region.width, y: region.y + region.height};
|
|
195
|
+
const startPoint = {
|
|
196
|
+
x: _startPoint.x < _endPoint.x ? _startPoint.x : _endPoint.x,
|
|
197
|
+
y: _startPoint.y < _endPoint.y ? _startPoint.y : _endPoint.y,
|
|
198
|
+
};
|
|
199
|
+
const endPoint = {
|
|
200
|
+
x: _startPoint.x > _endPoint.x ? _startPoint.x : _endPoint.x,
|
|
201
|
+
y: _startPoint.y > _endPoint.y ? _startPoint.y : _endPoint.y,
|
|
202
|
+
};
|
|
195
203
|
/* const p1 = label.points[0];
|
|
196
204
|
const p2 = label.points[label.points.length - 1];*/
|
|
197
205
|
switch (label.tool) {
|
|
198
206
|
case ARROW:
|
|
199
207
|
case BILATERAL:
|
|
200
208
|
case LINE: {
|
|
209
|
+
const startPoint = {
|
|
210
|
+
x: _startPoint.x < _endPoint.x ? _startPoint.x : _endPoint.x,
|
|
211
|
+
y: _startPoint.x < _endPoint.x ? _startPoint.y : _endPoint.y,
|
|
212
|
+
};
|
|
213
|
+
const endPoint = {
|
|
214
|
+
x: _startPoint.x > _endPoint.x ? _startPoint.x : _endPoint.x,
|
|
215
|
+
y: _startPoint.x > _endPoint.x ? _startPoint.y : _endPoint.y,
|
|
216
|
+
};
|
|
201
217
|
const w = Math.abs(endPoint.x - startPoint.x);
|
|
202
218
|
const h = Math.abs(endPoint.y - startPoint.y);
|
|
203
219
|
const center = {
|
|
@@ -397,12 +413,10 @@ export class ViewerCommon extends EventEmitter {
|
|
|
397
413
|
* @return {boolean}
|
|
398
414
|
*/
|
|
399
415
|
isInCanvas(region, bounds) {
|
|
400
|
-
const
|
|
401
|
-
region.width, region.height);
|
|
402
|
-
const startPoint = {x: viewReact.x, y: viewReact.y};
|
|
416
|
+
const startPoint = {x: region.x, y: region.y};
|
|
403
417
|
const endPoint = {
|
|
404
|
-
x:
|
|
405
|
-
y:
|
|
418
|
+
x: region.x + region.width,
|
|
419
|
+
y: region.y + region.height,
|
|
406
420
|
};
|
|
407
421
|
return !(startPoint.x > (bounds.x + bounds.width) || startPoint.y >
|
|
408
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 {
|
package/src/model/label.model.js
CHANGED
|
@@ -4,6 +4,7 @@ export class LabelModel {
|
|
|
4
4
|
constructor(data = {}) {
|
|
5
5
|
if (!data) data = {};
|
|
6
6
|
this.id = data.id; // id标识
|
|
7
|
+
this.parent_id = data.parent_id; // 父id标识
|
|
7
8
|
this.lineWidth = !data.lineWidth ?
|
|
8
9
|
(data.tool === STAR ? 15 :
|
|
9
10
|
data.tool === FLAG ? 30 : data.tool === DOT ? 10 : 2) :
|