kfb-view 3.0.9 → 3.1.0

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": "3.0.9",
4
+ "version": "3.1.0",
5
5
  "author": "qifeng.fan <qifeng.fan@hzztai.com>",
6
6
  "license": "MIT",
7
7
  "main": "lib/kfb-view.js",
@@ -3,7 +3,7 @@ import * as Tools from '../../tool';
3
3
  import {
4
4
  POLYGON, DOT, FLAG, MARKS,
5
5
  NO_NORMAL_REGION_TYPES,
6
- POINT_TYPES, STAR,
6
+ POINT_TYPES, STAR, ELLIPSE,
7
7
  } from '../../const/mark';
8
8
  import {
9
9
  EVENT_START_PAINTING,
@@ -142,6 +142,8 @@ export class Board extends ViewerCommon {
142
142
  const tool = this.tool;
143
143
  if (tool === POLYGON) {
144
144
  this.points.push(point);
145
+ } else if (ELLIPSE === tool) {
146
+ this.points = [point, point];
145
147
  } else {
146
148
  this.points = [point];
147
149
  }
@@ -172,7 +174,15 @@ export class Board extends ViewerCommon {
172
174
  }
173
175
  e.preventDefaultAction = true;
174
176
  const tool = this.tool;
175
- if (!NO_NORMAL_REGION_TYPES.includes(tool)) {
177
+ if (ELLIPSE === tool) {
178
+ const _x = point.x - this.points[1].x;
179
+ const _y = point.y - this.points[1].y;
180
+ const _point = {
181
+ x: this.points[1].x - _x,
182
+ y: this.points[1].y - _y,
183
+ };
184
+ this.points = [_point, this.points[1], point];
185
+ } else if (!NO_NORMAL_REGION_TYPES.includes(tool)) {
176
186
  this.points = [this.points[0] || point, point];
177
187
  } else if (tool === POLYGON) {
178
188
  this.points.push(point);
@@ -207,7 +217,23 @@ export class Board extends ViewerCommon {
207
217
  return;
208
218
  }
209
219
  const tool = this.tool;
210
- if (!NO_NORMAL_REGION_TYPES.includes(tool)) {
220
+ if (ELLIPSE === tool) {
221
+ const _x = point.x - this.points[1].x;
222
+ const _y = point.y - this.points[1].y;
223
+ const _point = {
224
+ x: this.points[1].x - _x,
225
+ y: this.points[1].y - _y,
226
+ };
227
+ this.points = [_point, point];
228
+ const firstPoint = this.imageToViewerElementCoordinates(this.points[0].x,
229
+ this.points[0].y);
230
+ const dist = getDistance(firstPoint, {x, y});
231
+ if (Math.abs(dist) < 10) {
232
+ this.points = [];
233
+ this.clearCanvas();
234
+ return;
235
+ }
236
+ } else if (!NO_NORMAL_REGION_TYPES.includes(tool)) {
211
237
  const firstPoint = this.imageToViewerElementCoordinates(this.points[0].x,
212
238
  this.points[0].y);
213
239
  const dist = getDistance(firstPoint, {x, y});