kfb-view 2.3.1 → 2.3.3
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 +57 -45
- package/config/webpack.dev.conf.js +2 -1
- package/example/index.js +112 -22
- package/example/label/check.svg +8 -0
- package/example/label/check_empty.svg +9 -0
- package/example/label/cross.svg +6 -0
- package/example/label/cross_empty.svg +6 -0
- package/example/label/delete.svg +8 -0
- package/example/label/delete_empty.svg +8 -0
- package/example/label/hasAudit.svg +26 -0
- package/lib/kfb-view.js +1 -1
- package/package.json +1 -1
- package/src/components/area/index.js +34 -19
- package/src/components/common/common.js +3 -5
- package/src/components/shape/index.js +10 -10
- package/src/view.js +2 -3
package/package.json
CHANGED
|
@@ -42,6 +42,7 @@ export class Area extends ViewerCommon {
|
|
|
42
42
|
this.currentPressPoint = undefined;
|
|
43
43
|
this.lastPoint = undefined;
|
|
44
44
|
this.draging = false;
|
|
45
|
+
this.isHover = false;
|
|
45
46
|
MARKS.forEach((mark) => {
|
|
46
47
|
this[mark] = new Tools[mark];
|
|
47
48
|
});
|
|
@@ -323,18 +324,29 @@ export class Area extends ViewerCommon {
|
|
|
323
324
|
const selectLabel = this.labelList.find(
|
|
324
325
|
({tool, select}) => tool === RECTANGLE && select);
|
|
325
326
|
if (selectLabel) {
|
|
326
|
-
const region = selectLabel.region;
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
327
|
+
const region = this.imageToViewerElementRectangle(selectLabel.region);
|
|
328
|
+
if (this.isContainerInRegion({x, y}, {
|
|
329
|
+
...selectLabel,
|
|
330
|
+
region,
|
|
331
|
+
})) {
|
|
332
|
+
const startPoint = {
|
|
333
|
+
x: region.x,
|
|
334
|
+
y: region.y,
|
|
335
|
+
};
|
|
336
|
+
const endPoint = {
|
|
337
|
+
x: region.x + region.width,
|
|
338
|
+
y: region.y + region.height,
|
|
339
|
+
};
|
|
340
|
+
const pointList = getRectPoint(startPoint, endPoint);
|
|
341
|
+
const moveIndex = pointList.findIndex(
|
|
342
|
+
(point) => pointInOtherPoint(point, {x, y}));
|
|
343
|
+
if (moveIndex === 4) {
|
|
344
|
+
this.isHover = true;
|
|
345
|
+
this.drawPoint(pointList[4], !!this.movePoint);
|
|
346
|
+
} else if (this.isHover) {
|
|
347
|
+
this.isHover = false;
|
|
348
|
+
this.change();
|
|
349
|
+
}
|
|
338
350
|
}
|
|
339
351
|
}
|
|
340
352
|
}
|
|
@@ -573,6 +585,7 @@ export class Area extends ViewerCommon {
|
|
|
573
585
|
}, position === 4);
|
|
574
586
|
this.drawPoint(points[1], position === 7);
|
|
575
587
|
} else if (type === RECTANGLE) {
|
|
588
|
+
console.log(12);
|
|
576
589
|
const sp = {
|
|
577
590
|
x: points[0].x < points[1].x ? points[0].x : points[1].x,
|
|
578
591
|
y: points[0].y < points[1].y ? points[0].y : points[1].y,
|
|
@@ -671,7 +684,8 @@ export class Area extends ViewerCommon {
|
|
|
671
684
|
}
|
|
672
685
|
|
|
673
686
|
showLabelMeasure() {
|
|
674
|
-
const bounds = this.viewport.
|
|
687
|
+
const bounds = this.viewport.viewportToImageRectangle(
|
|
688
|
+
this.viewport.getBounds());
|
|
675
689
|
const currentScale = this.getImageZoom(true);
|
|
676
690
|
if (currentScale * this.options.scale < this.options.measure.scale) {
|
|
677
691
|
const label = this.labelList.find((item) => item.select);
|
|
@@ -683,15 +697,16 @@ export class Area extends ViewerCommon {
|
|
|
683
697
|
} else {
|
|
684
698
|
this.labelList.forEach((label) => {
|
|
685
699
|
if (label.show === false) return;
|
|
686
|
-
if (label.
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
} else if (this.options.measure.defaultShow) {
|
|
700
|
+
if (label.select && label.measure) {
|
|
701
|
+
this[label.tool].drawMeasureInfo.call(this, label,
|
|
702
|
+
this.getMeasureContent(label));
|
|
703
|
+
} else if (this.options.measure.defaultShow && label.measure) {
|
|
691
704
|
if (!this.isInCanvas(label.region, bounds)) return false;
|
|
692
|
-
this[label.tool].drawMeasureInfo.call(this, label,
|
|
705
|
+
this[label.tool].drawMeasureInfo.call(this, label,
|
|
706
|
+
this.getMeasureContent(label));
|
|
693
707
|
}
|
|
694
708
|
if (this.options.labelDrawing) {
|
|
709
|
+
if (!this.isInCanvas(label.region, bounds)) return false;
|
|
695
710
|
this.options.labelDrawing(this.canvas, label,
|
|
696
711
|
this.imageToViewerElementRectangle(label.region));
|
|
697
712
|
}
|
|
@@ -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 {
|
package/src/view.js
CHANGED
|
@@ -411,15 +411,14 @@ function initEvent(kv) {
|
|
|
411
411
|
new openSeadragon.MouseTracker({
|
|
412
412
|
element: kv.viewer.canvas,
|
|
413
413
|
moveHandler: function(event) {
|
|
414
|
-
if (kv.area?.onCanvasMove) {
|
|
415
|
-
kv.area.onCanvasMove(event.position);
|
|
416
|
-
}
|
|
417
414
|
if (isRightDown && kv.board?.isInDraw) {
|
|
418
415
|
console.log('nonprimary drag');
|
|
419
416
|
let delta = event.position.minus(dragPosition);
|
|
420
417
|
dragPosition = event.position.clone();
|
|
421
418
|
kv.viewer.viewport.panBy(
|
|
422
419
|
kv.viewer.viewport.deltaPointsFromPixels(delta.negate()));
|
|
420
|
+
} else if (kv.area?.onCanvasMove) {
|
|
421
|
+
kv.area.onCanvasMove(event.position);
|
|
423
422
|
}
|
|
424
423
|
},
|
|
425
424
|
});
|