kfb-view 2.1.18 → 2.1.19

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": "2.1.18",
4
+ "version": "2.1.19",
5
5
  "author": "qifeng.fan <qifeng.fan@hzztai.com>",
6
6
  "license": "MIT",
7
7
  "main": "lib/kfb-view.js",
@@ -74,6 +74,7 @@ export class Board extends ViewerCommon {
74
74
  measure: true,
75
75
  clear: true,
76
76
  isClose: true,
77
+ showStartPoint: true,
77
78
  ...options,
78
79
  lineWidth: !options.lineWidth ?
79
80
  (this.tool === STAR ? 15 :
@@ -103,6 +104,7 @@ export class Board extends ViewerCommon {
103
104
  text: '',
104
105
  measure: true,
105
106
  clear: true,
107
+ showStartPoint: true,
106
108
  ...options,
107
109
  lineWidth: !options.lineWidth ?
108
110
  (this.tool === STAR ? 15 :
@@ -143,6 +145,11 @@ export class Board extends ViewerCommon {
143
145
  this[tool].startDraw();
144
146
  this[tool].draw(this.imageToViewerElementPoints(this.points));
145
147
  this[tool].endDraw();
148
+ if (tool === POLYGON) {
149
+ const point = this.imageToViewerElementCoordinates(this.points[0].x,
150
+ this.points[0].y);
151
+ this[tool].drawPoint(point);
152
+ }
146
153
  this.$emit(EVENT_START_PAINTING, this.getPaintOptions());
147
154
  }
148
155
 
@@ -171,6 +178,11 @@ export class Board extends ViewerCommon {
171
178
  this[tool].startDraw();
172
179
  this[tool].draw(this.imageToViewerElementPoints(this.points));
173
180
  this[tool].endDraw();
181
+ if (tool === POLYGON) {
182
+ const point = this.imageToViewerElementCoordinates(this.points[0].x,
183
+ this.points[0].y);
184
+ this[tool].drawPoint(point);
185
+ }
174
186
  this.$emit(EVENT_IN_PAINTING, this.getPaintOptions());
175
187
  }
176
188
 
@@ -249,8 +261,10 @@ export class Board extends ViewerCommon {
249
261
  this.points.push(point);
250
262
  this.clearCanvas();
251
263
  this[tool].startDraw();
252
- this[tool].draw(this.imageToViewerElementPoints(this.points));
264
+ const points = this.imageToViewerElementPoints(this.points);
265
+ this[tool].draw(points);
253
266
  this[tool].endDraw();
267
+ this[tool].drawPoint(points[0]);
254
268
  this.$emit(EVENT_IN_PAINTING, this.getPaintOptions());
255
269
  }
256
270
  }
@@ -59,8 +59,12 @@ export class Shape extends ViewerCommon {
59
59
  this.clearCanvas();
60
60
  // 区域标注列表
61
61
  const regionLabelList = [];
62
+ const polygonLabelList = [];
62
63
  this.labelList.forEach(
63
64
  (item) => {
65
+ if (item.tool === POLYGON) {
66
+ polygonLabelList.push(item);
67
+ }
64
68
  if (REGION_TYPES.includes(item.tool) || item.isClose && item.tool ===
65
69
  POLYGON) {
66
70
  regionLabelList.push({
@@ -149,6 +153,16 @@ export class Shape extends ViewerCommon {
149
153
  tool,
150
154
  })), this.viewport.getRotation());
151
155
  });
156
+
157
+ polygonLabelList.forEach((item) => {
158
+ if (item.show === false) return;
159
+ if (!this[item.tool]) return;
160
+ if (!this.isInCanvas(item.region)) return;
161
+ const point = this.imageToViewerElementCoordinates(item.points[0].x,
162
+ item.points[0].y);
163
+ this[item.tool].setContent(this.canvas, item);
164
+ this[item.tool].drawPoint(point);
165
+ });
152
166
  }
153
167
 
154
168
  drawLabel(item) {
@@ -23,6 +23,7 @@ export class LabelModel {
23
23
  this.resize = data.resize; // 是否可拖动大小
24
24
  this.isROI = data.isROI ?? false; // 是否是ROI
25
25
  this.isClose = data.isClose ?? true; // 是否是闭合标注
26
+ this.showStartPoint = data.showStartPoint ?? true; // 是否默认显示开始点,只针对曲线
26
27
  this.select = data.select ?? false; // 是否是选中状态
27
28
  this.show = data.show ?? true; // 是否显示
28
29
  this.__other__ = data.__other__ || {}; // 其他信息
@@ -26,6 +26,23 @@ class Polygon extends Brush {
26
26
  }
27
27
  }
28
28
  }
29
+
30
+ drawPoint(point) {
31
+ if (this.options.showStartPoint) {
32
+ const ctx = this.canvas.getContext('2d');
33
+ ctx.beginPath();
34
+ ctx.fillStyle = '#0000008d';
35
+ ctx.fillRect(point.x - 20, point.y - 25, 40, 20);
36
+ ctx.beginPath();
37
+ ctx.font = `14px Arial`;
38
+ ctx.fillStyle = '#ffffff';
39
+ ctx.fillText('起点', point.x - 15, point.y - 10);
40
+ this.thumb.draw(point, {
41
+ thumbRadius: this.options.thumbRadius ?? 5,
42
+ strokeStyle: this.options.thumbColor,
43
+ });
44
+ }
45
+ }
29
46
  }
30
47
 
31
48
  export {