sg-labeler-vue2 1.0.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.
@@ -0,0 +1,3197 @@
1
+ module.exports =
2
+ /******/ (function(modules) { // webpackBootstrap
3
+ /******/ // The module cache
4
+ /******/ var installedModules = {};
5
+ /******/
6
+ /******/ // The require function
7
+ /******/ function __webpack_require__(moduleId) {
8
+ /******/
9
+ /******/ // Check if module is in cache
10
+ /******/ if(installedModules[moduleId]) {
11
+ /******/ return installedModules[moduleId].exports;
12
+ /******/ }
13
+ /******/ // Create a new module (and put it into the cache)
14
+ /******/ var module = installedModules[moduleId] = {
15
+ /******/ i: moduleId,
16
+ /******/ l: false,
17
+ /******/ exports: {}
18
+ /******/ };
19
+ /******/
20
+ /******/ // Execute the module function
21
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22
+ /******/
23
+ /******/ // Flag the module as loaded
24
+ /******/ module.l = true;
25
+ /******/
26
+ /******/ // Return the exports of the module
27
+ /******/ return module.exports;
28
+ /******/ }
29
+ /******/
30
+ /******/
31
+ /******/ // expose the modules object (__webpack_modules__)
32
+ /******/ __webpack_require__.m = modules;
33
+ /******/
34
+ /******/ // expose the module cache
35
+ /******/ __webpack_require__.c = installedModules;
36
+ /******/
37
+ /******/ // define getter function for harmony exports
38
+ /******/ __webpack_require__.d = function(exports, name, getter) {
39
+ /******/ if(!__webpack_require__.o(exports, name)) {
40
+ /******/ Object.defineProperty(exports, name, {
41
+ /******/ configurable: false,
42
+ /******/ enumerable: true,
43
+ /******/ get: getter
44
+ /******/ });
45
+ /******/ }
46
+ /******/ };
47
+ /******/
48
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
49
+ /******/ __webpack_require__.n = function(module) {
50
+ /******/ var getter = module && module.__esModule ?
51
+ /******/ function getDefault() { return module['default']; } :
52
+ /******/ function getModuleExports() { return module; };
53
+ /******/ __webpack_require__.d(getter, 'a', getter);
54
+ /******/ return getter;
55
+ /******/ };
56
+ /******/
57
+ /******/ // Object.prototype.hasOwnProperty.call
58
+ /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
59
+ /******/
60
+ /******/ // __webpack_public_path__
61
+ /******/ __webpack_require__.p = "";
62
+ /******/
63
+ /******/ // Load entry module and return exports
64
+ /******/ return __webpack_require__(__webpack_require__.s = 4);
65
+ /******/ })
66
+ /************************************************************************/
67
+ /******/ ([
68
+ /* 0 */
69
+ /***/ (function(module, exports) {
70
+
71
+ module.exports = require("fabric");
72
+
73
+ /***/ }),
74
+ /* 1 */
75
+ /***/ (function(module, exports) {
76
+
77
+ module.exports = require("core-js/modules/web.dom.iterable");
78
+
79
+ /***/ }),
80
+ /* 2 */
81
+ /***/ (function(module, exports) {
82
+
83
+ module.exports = require("core-js/modules/es7.object.values");
84
+
85
+ /***/ }),
86
+ /* 3 */
87
+ /***/ (function(module, exports) {
88
+
89
+ module.exports = require("core-js/modules/es6.array.fill");
90
+
91
+ /***/ }),
92
+ /* 4 */
93
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
94
+
95
+ "use strict";
96
+ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
97
+
98
+ // EXTERNAL MODULE: external "core-js/modules/es6.number.constructor"
99
+ var es6_number_constructor_ = __webpack_require__(6);
100
+ var es6_number_constructor__default = /*#__PURE__*/__webpack_require__.n(es6_number_constructor_);
101
+
102
+ // EXTERNAL MODULE: external "core-js/modules/es6.array.find"
103
+ var es6_array_find_ = __webpack_require__(7);
104
+ var es6_array_find__default = /*#__PURE__*/__webpack_require__.n(es6_array_find_);
105
+
106
+ // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
107
+ function _arrayLikeToArray(r, a) {
108
+ (null == a || a > r.length) && (a = r.length);
109
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
110
+ return n;
111
+ }
112
+
113
+ // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
114
+
115
+ function _arrayWithoutHoles(r) {
116
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
117
+ }
118
+
119
+ // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js
120
+ function _iterableToArray(r) {
121
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
122
+ }
123
+
124
+ // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
125
+
126
+ function _unsupportedIterableToArray(r, a) {
127
+ if (r) {
128
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
129
+ var t = {}.toString.call(r).slice(8, -1);
130
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
131
+ }
132
+ }
133
+
134
+ // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
135
+ function _nonIterableSpread() {
136
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
137
+ }
138
+
139
+ // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
140
+
141
+
142
+
143
+
144
+ function _toConsumableArray(r) {
145
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
146
+ }
147
+
148
+ // EXTERNAL MODULE: external "core-js/modules/es7.object.values"
149
+ var es7_object_values_ = __webpack_require__(2);
150
+ var es7_object_values__default = /*#__PURE__*/__webpack_require__.n(es7_object_values_);
151
+
152
+ // EXTERNAL MODULE: external "core-js/modules/es6.array.fill"
153
+ var es6_array_fill_ = __webpack_require__(3);
154
+ var es6_array_fill__default = /*#__PURE__*/__webpack_require__.n(es6_array_fill_);
155
+
156
+ // EXTERNAL MODULE: external "core-js/modules/web.dom.iterable"
157
+ var web_dom_iterable_ = __webpack_require__(1);
158
+ var web_dom_iterable__default = /*#__PURE__*/__webpack_require__.n(web_dom_iterable_);
159
+
160
+ // EXTERNAL MODULE: external "fabric"
161
+ var external__fabric_ = __webpack_require__(0);
162
+ var external__fabric__default = /*#__PURE__*/__webpack_require__.n(external__fabric_);
163
+
164
+ // EXTERNAL MODULE: external "lodash.clonedeep"
165
+ var external__lodash_clonedeep_ = __webpack_require__(8);
166
+ var external__lodash_clonedeep__default = /*#__PURE__*/__webpack_require__.n(external__lodash_clonedeep_);
167
+
168
+ // EXTERNAL MODULE: external "core-js/modules/es6.math.sign"
169
+ var es6_math_sign_ = __webpack_require__(9);
170
+ var es6_math_sign__default = /*#__PURE__*/__webpack_require__.n(es6_math_sign_);
171
+
172
+ // EXTERNAL MODULE: external "core-js/modules/es7.array.includes"
173
+ var es7_array_includes_ = __webpack_require__(10);
174
+ var es7_array_includes__default = /*#__PURE__*/__webpack_require__.n(es7_array_includes_);
175
+
176
+ // EXTERNAL MODULE: external "core-js/modules/es6.string.includes"
177
+ var es6_string_includes_ = __webpack_require__(11);
178
+ var es6_string_includes__default = /*#__PURE__*/__webpack_require__.n(es6_string_includes_);
179
+
180
+ // CONCATENATED MODULE: ./src/components/labeler/model/drawType.js
181
+ /* harmony default export */ var drawType = ({
182
+ // 自由绘制
183
+ free: 'free',
184
+ // 直线
185
+ line: 'line',
186
+ // 圆
187
+ circle: 'circle',
188
+ // 矩形
189
+ rectangle: 'rectangle',
190
+ // 三角形
191
+ triangle: 'triangle',
192
+ // 文字
193
+ textbox: 'textbox',
194
+ // 多边形
195
+ polygon: 'polygon',
196
+ // 点
197
+ point: 'point'
198
+ });
199
+ // CONCATENATED MODULE: ./src/components/labeler/model/message.js
200
+ var notEditableMsg = '当前模式不可编辑,请切换至编辑模式';
201
+ var setDataErrorMsg = '当前图片未加载完成,请在onImageLoad回调中使用setData设置标注';
202
+ // EXTERNAL MODULE: external "core-js/modules/es6.regexp.to-string"
203
+ var es6_regexp_to_string_ = __webpack_require__(12);
204
+ var es6_regexp_to_string__default = /*#__PURE__*/__webpack_require__.n(es6_regexp_to_string_);
205
+
206
+ // CONCATENATED MODULE: ./src/components/labeler/function/label.js
207
+
208
+ // eslint-disable-next-line no-unused-vars
209
+
210
+
211
+ /**
212
+ * 为添加的图形绑定标签
213
+ *
214
+ * @author pangyafei
215
+ * @date 2021-01-18
216
+ * @param {any} _this
217
+ * @returns {any}
218
+ */
219
+ var shapeBindLabel = function shapeBindLabel(_this) {
220
+ // console.log('shape bind label')
221
+ // console.log(_this.drawingObject)
222
+ var shape = _this.drawingObject;
223
+ shape.objectCaching = false;
224
+ _this.canvas.remove(shape);
225
+ if (shape) {
226
+ shape.id = uuid();
227
+ shape.label = _this.label;
228
+ shape.description = _this.description;
229
+ }
230
+ _this.canvas.add(shape);
231
+ _this.canvas.requestRenderAll();
232
+
233
+ // const label = document.createElement('div')
234
+ // label.style.position = 'absolute'
235
+ // label.style.top = 0
236
+ // label.style.left = 0
237
+ // label.style.width = '60px'
238
+ // label.style.height = '18px'
239
+ // label.style.backgroundColor = 'red'
240
+ // document.body.appendChild(label)
241
+
242
+ // console.log(label)
243
+ // shape.on('moving', function() { positionLabel(_this, shape, label) })
244
+ // shape.on('scaling', function() { positionLabel(_this, shape, label) })
245
+ // shape.on('mousewheel', function() { positionLabel(_this, shape, label) })
246
+
247
+ // positionLabel(_this, shape, label)
248
+ };
249
+
250
+ /**
251
+ * 为文字绑定标签
252
+ *
253
+ * @author pangyafei
254
+ * @date 2021-01-28
255
+ * @param {any} _this
256
+ * @returns {any}
257
+ */
258
+ var textBindLabel = function textBindLabel(_this) {
259
+ var textbox = _this.textObject;
260
+ textbox.objectCaching = false;
261
+ _this.canvas.remove(textbox);
262
+ if (textbox) {
263
+ textbox.id = uuid();
264
+ textbox.label = _this.label;
265
+ textbox.description = _this.description;
266
+ }
267
+ _this.canvas.add(textbox);
268
+ _this.canvas.requestRenderAll();
269
+ };
270
+
271
+ /**
272
+ * 构造一个textbox标签组件
273
+ *
274
+ * @author pangyafei
275
+ * @date 2021-03-15
276
+ * @param {any} _this
277
+ * @param {any} shape
278
+ * @returns {any}
279
+ */
280
+ var getTextboxLabel = function getTextboxLabel(_this, shape) {
281
+ // const bound = shape.getBoundingRect()
282
+
283
+ // const textbox = new fabric.Textbox('test', {
284
+ // top: bound.top + 0.5,
285
+ // left: bound.left + 0.5,
286
+ // width: 80,
287
+ // height: 30,
288
+ // fontSize: 16,
289
+ // editable: false
290
+ // })
291
+
292
+ // _this.canvas.add(textbox)
293
+ // new fabric.Group([shape, textbox], {
294
+ // top: bound.top + 0.5,
295
+ // left: bound.left + 0.5
296
+ // })
297
+
298
+ // console.log('container rect')
299
+
300
+ // _this.canvas.contextContainer.strokeRect(
301
+ // bound.left + 0.5,
302
+ // bound.top + 0.5,
303
+ // 60,
304
+ // 30
305
+ // )
306
+ };
307
+
308
+ // eslint-disable-next-line no-unused-vars
309
+ var positionLabel = function positionLabel(_this, shape, label) {
310
+ // console.log(_this.canvas)
311
+ // var absCoords = _this.canvas.getAbsoluteCoords(shape)
312
+ var absCoords = getAbsoluteCoords(_this, shape);
313
+ // console.log(absCoords)
314
+ // console.log(shape.aCoords)
315
+ // console.log(shape.lineCoords)
316
+
317
+ label.style.top = absCoords.top + 'px';
318
+ label.style.left = absCoords.left + 'px';
319
+ };
320
+ function getAbsoluteCoords(_this, shape) {
321
+ // console.log(_this.canvas._offset.left)
322
+ // console.log(_this.canvas._offset.top)
323
+ return {
324
+ left: shape.left + _this.canvas._offset.left,
325
+ top: shape.top + _this.canvas._offset.top
326
+ };
327
+ }
328
+ function uuid() {
329
+ // return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
330
+ // var r = Math.random() * 16 | 0
331
+ // var v = c === 'x' ? r : (r & 0x3 | 0x8)
332
+ // return v.toString(16)
333
+ // })
334
+
335
+ function s4() {
336
+ return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
337
+ }
338
+ return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
339
+
340
+ // var s = []
341
+ // var hexDigits = '0123456789abcdef'
342
+ // for (var i = 0; i < 36; i++) {
343
+ // s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1)
344
+ // }
345
+ // s[14] = '4'
346
+ // s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1)
347
+ // s[8] = s[13] = s[18] = s[23] = '-'
348
+
349
+ // var uuid = s.join('')
350
+ // return uuid
351
+ }
352
+ // CONCATENATED MODULE: ./src/components/labeler/event/shape.js
353
+ // eslint-disable-next-line no-unused-vars
354
+
355
+
356
+
357
+
358
+ /**
359
+ * 对象添加监听(fabric.js)
360
+ *
361
+ * @author pangyafei
362
+ * @date 2021-01-18
363
+ * @param {any} _this
364
+ * @param {any} options
365
+ * @returns {any}
366
+ */
367
+ var shapeadded = function shapeadded(_this, options) {
368
+ if (_this.atDrawing === false) {
369
+ // console.log('object added')
370
+ // console.log(options)
371
+ }
372
+
373
+ // _this.historyObjects = []
374
+ };
375
+
376
+ /**
377
+ * 自由绘制线监听
378
+ *
379
+ * @author pangyafei
380
+ * @date 2021-02-04
381
+ * @param {any} _this
382
+ * @param {any} options
383
+ * @returns {any}
384
+ */
385
+ var shape_pathcreated = function pathcreated(_this, options) {
386
+ _this.drawingObject = options.path;
387
+ _this.drawingObject.type = drawType.free;
388
+ _this.drawingObject.hoverCursor = 'default';
389
+ _this.drawingObject.transparentCorners = false;
390
+ _this.drawingObject.setControlVisible('mtr', false);
391
+ shapeBindLabel(_this);
392
+ };
393
+ var shapemove = function shapemove(_this) {};
394
+
395
+ /**
396
+ * 对象缩放监听事件
397
+ *
398
+ * @author pangyafei
399
+ * @date 2021-01-19
400
+ * @param {any} _this
401
+ * @param {any} options
402
+ * @returns {any}
403
+ */
404
+ var shapescaling = function shapescaling(_this, options) {
405
+ var o = options.target;
406
+ // 重新计算图形的边
407
+ if (!o.strokeWidthUnscaled && o.strokeWidth) {
408
+ o.strokeWidthUnscaled = o.strokeWidth;
409
+ }
410
+ if (o.strokeWidthUnscaled) {
411
+ o.strokeWidth = o.strokeWidthUnscaled / o.scaleX;
412
+ }
413
+ };
414
+
415
+ /**
416
+ * 对象缩放完成监听事件
417
+ *
418
+ * @author pangyafei
419
+ * @date 2021-03-16
420
+ * @param {any} _this
421
+ * @param {any} options
422
+ * @returns {any}
423
+ */
424
+ var shape_shapescaled = function shapescaled(_this, options) {
425
+ var o = options.target;
426
+ var shape = data_getData(_this, o.id);
427
+ if (shape.type === drawType.point || shape.type === drawType.rectangle || shape.type === drawType.polygon) {
428
+ // 重新设置被缩放的对象,以重置标签的大小
429
+ _this.canvas.remove(o);
430
+ data_setData(_this, shape, true);
431
+ }
432
+ };
433
+ // CONCATENATED MODULE: ./src/components/labeler/model/modeType.js
434
+ /* harmony default export */ var modeType = ({
435
+ // 编辑模式
436
+ edit: 'edit',
437
+ // 浏览模式
438
+ view: 'view'
439
+ });
440
+ // CONCATENATED MODULE: ./src/components/labeler/function/init.js
441
+
442
+
443
+
444
+
445
+
446
+
447
+
448
+
449
+
450
+ /**
451
+ * init fabric
452
+ *
453
+ * @author pangyafei
454
+ * @date 2021-01-18
455
+ * @param {any} _this imageLabeler
456
+ * @returns {any}
457
+ */
458
+ var init_initFabric = function initFabric(_this) {
459
+ if (_this.width) {
460
+ _this.$refs.canvas.width = _this.width;
461
+ _this.$refs.container.style.width = _this.width + 'px';
462
+ } else {
463
+ _this.$refs.canvas.width = _this.$refs.container.offsetWidth;
464
+ }
465
+ if (_this.height) {
466
+ _this.$refs.canvas.height = _this.height;
467
+ _this.$refs.container.style.height = _this.height + 'px';
468
+ } else {
469
+ _this.$refs.canvas.height = _this.$refs.container.offsetHeight;
470
+ }
471
+ _this.canvas = new external__fabric_["fabric"].Canvas(_this.id);
472
+ init_initCanvasEvents(_this);
473
+ init_initBackgroundImage(_this);
474
+ if (_this.mode === modeType.edit) {
475
+ _this.canvas.skipTargetFind = false;
476
+ } else {
477
+ _this.canvas.skipTargetFind = true;
478
+ }
479
+
480
+ // initCustomControl(_this)
481
+
482
+ // var rect = new fabric.Rect({
483
+ // top: 100,
484
+ // left: 100,
485
+ // width: 60,
486
+ // height: 70,
487
+ // fill: 'red'
488
+ // })
489
+ // _this.canvas.add(rect)
490
+ };
491
+
492
+ /**
493
+ * 初始化背景图片(标注图片)
494
+ *
495
+ * @author pangyafei
496
+ * @date 2021-01-18
497
+ * @param {any} _this imageLabeler
498
+ * @param {any} noFire 为true时不触发图片加载回调
499
+ * @returns {any}
500
+ */
501
+ var init_initBackgroundImage = function initBackgroundImage(_this, noFire) {
502
+ console.log('init background image');
503
+ var image = new external__fabric_["fabric"].Image(_this.image, {
504
+ top: 0,
505
+ left: 0,
506
+ hoverCursor: 'default',
507
+ selectable: false
508
+ });
509
+ console.log('background init ');
510
+ console.log(image.width);
511
+ console.log(image.height);
512
+ var scale = _this.canvas.width / image.width < _this.canvas.height / image.height ? _this.canvas.width / image.width : _this.canvas.height / image.height;
513
+ var imageInfo = {
514
+ width: _this.image.width,
515
+ height: _this.image.height,
516
+ // 下面这两行以宽度为基准将图片进行合适尺寸的渲染,不变形不拉伸
517
+ scaleX: scale,
518
+ scaleY: scale
519
+ // 下面这两行 是图片适应画布大小
520
+ // scaleX: _this.canvas.width / image.width,
521
+ // scaleY: _this.canvas.height / image.height
522
+ };
523
+
524
+ // _this.canvas.add(image)
525
+ _this.canvas.setBackgroundImage(image, _this.canvas.renderAll.bind(_this.canvas), imageInfo);
526
+ if (noFire) {
527
+ // do nothing
528
+ } else {
529
+ _this.fireImageLoad(imageInfo);
530
+ }
531
+ };
532
+
533
+ /**
534
+ * 初始化canvas监听事件
535
+ *
536
+ * @author pangyafei
537
+ * @date 2021-01-18
538
+ * @param {any} _this imageLabeler
539
+ * @returns {any}
540
+ */
541
+ var init_initCanvasEvents = function initCanvasEvents(_this) {
542
+ console.log('init canvas events');
543
+ // 鼠标按下
544
+ _this.canvas.on('mouse:down', function (options) {
545
+ mouse_mousedown(_this, options);
546
+ });
547
+ // 鼠标移动
548
+ _this.canvas.on('mouse:move', function (options) {
549
+ mouse_mousemove(_this, options);
550
+ });
551
+ // 鼠标抬起
552
+ _this.canvas.on('mouse:up', function (options) {
553
+ mouse_mouseup(_this, options);
554
+ });
555
+ // 鼠标双击
556
+ _this.canvas.on('mouse:dblclick', function (options) {
557
+ mouse_mousedblclick(_this, options);
558
+ });
559
+ // 鼠标滚轮监听
560
+ _this.canvas.on('mouse:wheel', function (options) {
561
+ mouse_mousewheel(_this, options);
562
+ });
563
+ // 鼠标移出画布监听
564
+ _this.canvas.on('mouse:out', function (options) {
565
+ mouse_mouseout(_this, options);
566
+ });
567
+ // 对象添加监听
568
+ _this.canvas.on('object:added', function (options) {
569
+ shapeadded(_this, options);
570
+ });
571
+ // 对象缩放监听
572
+ _this.canvas.on('object:scaling', function (options) {
573
+ shapescaling(_this, options);
574
+ });
575
+ // 对象缩放完成监听
576
+ _this.canvas.on('object:scaled', function (options) {
577
+ shape_shapescaled(_this, options);
578
+ });
579
+ // 自由绘制监听
580
+ _this.canvas.on('path:created', function (options) {
581
+ shape_pathcreated(_this, options);
582
+ });
583
+ };
584
+ var deleteIcon = "data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3C!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3E%3Csvg version='1.1' id='Ebene_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' width='595.275px' height='595.275px' viewBox='200 215 230 470' xml:space='preserve'%3E%3Ccircle style='fill:%23F44336;' cx='299.76' cy='439.067' r='218.516'/%3E%3Cg%3E%3Crect x='267.162' y='307.978' transform='matrix(0.7071 -0.7071 0.7071 0.7071 -222.6202 340.6915)' style='fill:white;' width='65.545' height='262.18'/%3E%3Crect x='266.988' y='308.153' transform='matrix(0.7071 0.7071 -0.7071 0.7071 398.3889 -83.3116)' style='fill:white;' width='65.544' height='262.179'/%3E%3C/g%3E%3C/svg%3E";
585
+ // const deleteIcon = '<svg t="1611035558221" class="icon" viewBox="0 0 1025 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1133" width="32" height="32"><path d="M513.852 144.914c-203.711 0-368.936 165.192-368.936 368.936 0 203.756 165.203 368.936 368.936 368.936 203.756 0 368.936-165.143 368.936-368.936 0.005-203.711-165.177-368.936-368.936-368.936zM665.109 616.241c6.27 6.218 10.153 14.838 10.153 24.363 0 0.025 0 0.050 0 0.076 0 0.003 0 0.008 0 0.017 0 19.086-15.472 34.558-34.558 34.558-9.555 0-18.204-3.877-24.46-10.146l-102.39-102.331-102.319 102.364c-6.255 6.272-14.905 10.153-24.462 10.153-0.016 0-0.031 0-0.046 0-19.061 0-34.558-15.463-34.558-34.598 0-0.018 0-0.037 0-0.056 0-9.517 3.866-18.129 10.115-24.354l102.379-102.435-102.355-102.349c-6.25-6.245-10.117-14.875-10.117-24.408 0-0.021 0-0.042 0-0.063 0-19.093 15.486-34.583 34.586-34.583 0.010 0 0.023 0 0.036 0 9.533 0 18.162 3.865 24.409 10.116l102.319 102.378 102.39-102.352c6.256-6.25 14.896-10.116 24.438-10.116 19.098 0 34.579 15.482 34.579 34.579 0 0.003 0 0.007 0 0.007 0 0.020 0 0.044 0 0.067 0 9.537-3.882 18.168-10.15 24.398l-102.321 102.321 102.33 102.396z" fill="#1296db" p-id="1134"></path></svg>'
586
+
587
+ var deleteImage = document.createElement('img');
588
+ deleteImage.src = deleteIcon;
589
+ // deleteImage.src = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(deleteIcon)))
590
+
591
+ /**
592
+ * 构造图形删除控件
593
+ *
594
+ * @author pangyafei
595
+ * @date 2021-01-19
596
+ * @param {any} _this
597
+ * @returns {any}
598
+ */
599
+ var init_getDeleteControl = function getDeleteControl(_this) {
600
+ var deleteControl = new external__fabric_["fabric"].Control({
601
+ x: 0.5,
602
+ y: -0.5,
603
+ offsetY: -16,
604
+ offsetX: 16,
605
+ cursorStyle: 'pointer',
606
+ mouseUpHandler: init_getDeleteShapeFunction(_this),
607
+ render: renderControlIcon(deleteImage),
608
+ cornerSize: 24
609
+ });
610
+ return deleteControl;
611
+ };
612
+
613
+ /**
614
+ * 渲染自定义控制点图标的方法
615
+ *
616
+ * @author pangyafei
617
+ * @date 2021-01-19
618
+ * @param {any} icon
619
+ * @returns {any}
620
+ */
621
+ function renderControlIcon(icon) {
622
+ return function renderIcon(ctx, left, top, styleOverride, fabricObject) {
623
+ var size = this.cornerSize;
624
+ ctx.save();
625
+ ctx.translate(left, top);
626
+ ctx.rotate(external__fabric_["fabric"].util.degreesToRadians(fabricObject.angle));
627
+ ctx.drawImage(icon, -size / 2, -size / 2, size, size);
628
+ ctx.restore();
629
+ };
630
+ }
631
+
632
+ /**
633
+ * 返回删除图形方法,带vue对象的回调操作
634
+ *
635
+ * @author pangyafei
636
+ * @date 2021-01-19
637
+ * @param {any} _this
638
+ * @returns {any}
639
+ */
640
+ var init_getDeleteShapeFunction = function getDeleteShapeFunction(_this) {
641
+ return function deleteShape(eventData, options) {
642
+ // console.log('delete shape')
643
+ // console.log(eventData)
644
+ // console.log(options)
645
+ _this.fireShapeDelete(data_getData(_this, options.target.id));
646
+ var canvas = options.target.canvas;
647
+ canvas.remove(options.target);
648
+ canvas.requestRenderAll();
649
+ };
650
+ };
651
+
652
+ /**
653
+ * 构造标签交互控件
654
+ *
655
+ * @author pangyafei
656
+ * @date 2021-02-18
657
+ * @param {any} label
658
+ * @returns {any}
659
+ */
660
+ var init_getLabelControl = function getLabelControl(label) {
661
+ var labelIcon = '<svg width="80" height="18" version="1.1" xmlns="http://www.w3.org/2000/svg"> <rect x="0" y="0" height="18" width="80" style="fill: #B2CCFF;"/> <text x="4" y="14" style="font-size:14px; fill:#333;">' + label + '</text> </svg>';
662
+ var labelImage = document.createElement('img');
663
+ labelImage._label = label;
664
+ labelImage.src = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(labelIcon)));
665
+ // 这个 control 居然是全局的,设置一次之后会影响所有的object,十分不人性化,理论上只需要执行一次即可,但此处还是在每一处需要添加的地方都调用了
666
+ // 这里在render中实时刷新control的内容重新进行绘制,以解决全局问题
667
+ var labelControl = new external__fabric_["fabric"].Control({
668
+ x: 0.5,
669
+ y: -0.5,
670
+ offsetY: -26,
671
+ offsetX: -80,
672
+ cursorStyle: 'default',
673
+ render: function render(ctx, left, top, styleOverride, fabricObject) {
674
+ console.log('label render', styleOverride);
675
+ if (fabricObject.label == null || fabricObject.label === '') {
676
+ return;
677
+ }
678
+ var newLabelIcon = '<svg width="80" height="18" version="1.1" xmlns="http://www.w3.org/2000/svg"> <rect x="0" y="0" height="18" width="80" style="fill: #B2CCFF;"/> <text x="4" y="14" style="font-size:14px; fill:#333;">' + fabricObject.label + '</text> </svg>';
679
+ labelImage = document.createElement('img');
680
+ labelImage._label = label;
681
+ labelImage.src = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(newLabelIcon)));
682
+ ctx.save();
683
+ ctx.translate(left, top);
684
+ ctx.rotate(external__fabric_["fabric"].util.degreesToRadians(fabricObject.angle));
685
+ ctx.drawImage(labelImage, 0, 0, 80, 18);
686
+ ctx.restore();
687
+ }
688
+ });
689
+ return labelControl;
690
+ };
691
+
692
+ /**
693
+ * 重置鼠标移动对象
694
+ *
695
+ * @author pangyafei
696
+ * @date 2021-01-18
697
+ * @param {any} _this
698
+ * @returns {any}
699
+ */
700
+ var resetMouseMove = function resetMouseMove(_this) {
701
+ _this.mouseFrom = {};
702
+ _this.mouseTo = {};
703
+ };
704
+
705
+ /**
706
+ * 添加辅助线
707
+ *
708
+ * @author pangyafei
709
+ * @date 2021-02-04
710
+ * @param {any} _this
711
+ * @param {any} center 辅助线的center point
712
+ * @returns {any}
713
+ */
714
+ var init_addHelpLines = function addHelpLines(_this, center) {
715
+ clearHelpLines(_this);
716
+ var points = Object.values(_this.canvas.backgroundImage.aCoords);
717
+ var maxX = Math.max.apply(Math, _toConsumableArray(points.map(function (p) {
718
+ return p.x;
719
+ })));
720
+ var minX = Math.min.apply(Math, _toConsumableArray(points.map(function (p) {
721
+ return p.x;
722
+ })));
723
+ var maxY = Math.max.apply(Math, _toConsumableArray(points.map(function (p) {
724
+ return p.y;
725
+ })));
726
+ var minY = Math.min.apply(Math, _toConsumableArray(points.map(function (p) {
727
+ return p.y;
728
+ })));
729
+ var width = maxX - minX;
730
+ var height = maxY - minY;
731
+ if (center.y >= 0 && center.y <= height && center.x >= 0 && center.x <= width) {
732
+ var helpLineProps = {
733
+ stroke: '#333',
734
+ strokeWidth: 1 / _this.canvas.getZoom(),
735
+ hoverCursor: 'default',
736
+ transparentCorners: false,
737
+ selectable: false,
738
+ strokeUniform: true,
739
+ type: 'help',
740
+ strokeDashArray: [5, 3]
741
+ };
742
+
743
+ // console.log(Object.values(_this.canvas.backgroundImage.aCoords))
744
+ var h = new external__fabric_["fabric"].Line([0, center.y, _this.width, center.y], helpLineProps);
745
+ _this.canvas.add(h);
746
+ _this.helpLines.h = h;
747
+ var v = new external__fabric_["fabric"].Line([center.x, 0, center.x, height], helpLineProps);
748
+ _this.canvas.add(v);
749
+ _this.helpLines.v = v;
750
+ }
751
+ };
752
+
753
+ /**
754
+ * 清除辅助线
755
+ *
756
+ * @author pangyafei
757
+ * @date 2021-02-05
758
+ * @param {any} _this
759
+ * @returns {any}
760
+ */
761
+ var clearHelpLines = function clearHelpLines(_this) {
762
+ if (_this.helpLines) {
763
+ if (_this.helpLines.h) {
764
+ _this.canvas.remove(_this.helpLines.h);
765
+ _this.helpLines.h = null;
766
+ }
767
+ if (_this.helpLines.v) {
768
+ _this.canvas.remove(_this.helpLines.v);
769
+ _this.helpLines.v = null;
770
+ }
771
+ } else {
772
+ _this.helpLines = {};
773
+ }
774
+ };
775
+ // CONCATENATED MODULE: ./src/components/labeler/shape/labeled_shapes.js
776
+
777
+
778
+
779
+
780
+ // 带标注的矩形
781
+ var LabeledRectangle = external__fabric_["fabric"].util.createClass(external__fabric_["fabric"].Rect, {
782
+ type: 'LabeledRectangle',
783
+ initialize: function initialize(options) {
784
+ options || (options = {});
785
+ this.callSuper('initialize', options);
786
+ this.set('label', options.label || '');
787
+ },
788
+ toObject: function toObject() {
789
+ return external__fabric_["fabric"].util.object.extend(this.callSuper('toObject'), {
790
+ label: this.get('label'),
791
+ labelFillColor: this.get('labelFillColor')
792
+ });
793
+ },
794
+ _render: function _render(ctx) {
795
+ this.callSuper('_render', ctx);
796
+ if (this.label != null && this.label.trim() !== '') {
797
+ var fontsize = 26;
798
+ var font = fontsize + 'px Arial';
799
+ ctx.font = font;
800
+ var left = -this.width / 2;
801
+ var top = -this.height / 2;
802
+ var width = Math.round(ctx.measureText(this.label).width);
803
+ ctx.fillStyle = this.labelFillColor || '#ff000099';
804
+ ctx.fillRect(left + 1, top + 1, width + 8, fontsize);
805
+ ctx.fillStyle = '#fff';
806
+ ctx.fillText(this.label, left + 4, top + 22);
807
+ }
808
+ }
809
+ });
810
+
811
+ // 带标注的多边形
812
+ var LabeledPolygon = external__fabric_["fabric"].util.createClass(external__fabric_["fabric"].Polygon, {
813
+ type: 'LabeledPolygon',
814
+ initialize: function initialize(points, options) {
815
+ options || (options = {});
816
+ this.callSuper('initialize', points, options);
817
+ this.set('label', options.label || '');
818
+ },
819
+ toObject: function toObject() {
820
+ return external__fabric_["fabric"].util.object.extend(this.callSuper('toObject'), {
821
+ label: this.get('label'),
822
+ labelFillColor: this.get('labelFillColor')
823
+ });
824
+ },
825
+ _render: function _render(ctx) {
826
+ var _this = this;
827
+ this.callSuper('_render', ctx);
828
+ if (this.label != null && this.label.trim() !== '') {
829
+ var fontsize = 26;
830
+ var font = fontsize + 'px Arial';
831
+ ctx.font = font;
832
+ console.log(this);
833
+ // console.log(this.top)
834
+
835
+ var tempd = 9999999;
836
+ var tempp = null;
837
+ this.points.forEach(function (point) {
838
+ var d = point.y - _this.top + point.x - _this.left;
839
+ if (d < tempd) {
840
+ tempd = d;
841
+ tempp = point;
842
+ }
843
+ });
844
+ var left = -this.width / 2 + tempp.x - this.left;
845
+ var top = -this.height / 2 + tempp.y - this.top;
846
+ var width = Math.round(ctx.measureText(this.label).width);
847
+ ctx.fillStyle = this.labelFillColor || '#ff000099';
848
+ ctx.fillRect(left, top, width + 8, fontsize);
849
+ ctx.fillStyle = '#fff';
850
+ ctx.fillText(this.label, left + 4, top + 22);
851
+ }
852
+ }
853
+ });
854
+ // 带标注的点
855
+ var LabeledPoint = external__fabric_["fabric"].util.createClass(external__fabric_["fabric"].Circle, {
856
+ type: 'LabeledPoint',
857
+ initialize: function initialize(options) {
858
+ options || (options = {});
859
+ this.set('label', options.label || '');
860
+ this.set('radius', options.radius || 0);
861
+ this.set('scaleX', options.scaleX || 1);
862
+ this.set('scaleY', options.scaleY || 1);
863
+ this.set('left', options.left || 0);
864
+ this.set('top', options.top || 0);
865
+ this.set('fill', options.fill);
866
+ this.set('id', options.id);
867
+ this.set('type', options.type);
868
+ this.set('visible', options.visible);
869
+ this.set('selectable', options.selectable);
870
+ this.set('stroke', options.stroke);
871
+ this.set('strokeWidth', options.strokeWidth);
872
+ this.set('originX', options.originX);
873
+ this.set('originY', options.originY);
874
+ this.set('centeredScaling', options.centeredScaling);
875
+ this.set('crosshair', options.crosshair);
876
+ this.set('crosshairColor', options.crosshairColor);
877
+ this.set('crosshairWidth', options.crosshairWidth);
878
+ this.set('description', options.description);
879
+ this.set('labelSize', options.labelSize);
880
+
881
+ // 解决在设置 point 标注对象时,缩放画布导致标签显示异常的问题
882
+ this.objectCaching = false;
883
+ },
884
+ toObject: function toObject() {
885
+ return external__fabric_["fabric"].util.object.extend(this.callSuper('toObject'), {
886
+ label: this.get('label')
887
+ });
888
+ },
889
+ _render: function _render(ctx) {
890
+ this.callSuper('_render', ctx);
891
+ if (this.label != null && this.label.trim() !== '') {
892
+ var fontsize = this.labelSize || 20;
893
+ var font = fontsize + 'px Arial';
894
+ ctx.font = font;
895
+ var width = Math.round(ctx.measureText(this.label).width);
896
+ var left = -this.width / 2 + this.radius - width / 2 - 1;
897
+ var top = -this.height / 2 - 3;
898
+
899
+ // ctx.fillStyle =
900
+ // ctx.fillRect(left - 1, top, width + 8, fontsize)
901
+
902
+ ctx.fillStyle = this.stroke;
903
+ ctx.fillText(this.label, left, top);
904
+
905
+ // origin is center & center
906
+ if (this.crosshair) {
907
+ ctx.beginPath();
908
+ ctx.lineWidth = this.crosshairWidth;
909
+ ctx.strokeStyle = this.crosshairColor;
910
+ ctx.moveTo(-1, 0);
911
+ ctx.lineTo(-this.radius - 2, 0);
912
+ ctx.stroke();
913
+ ctx.beginPath();
914
+ ctx.lineWidth = this.crosshairWidth;
915
+ ctx.strokeStyle = this.crosshairColor;
916
+ ctx.moveTo(1, 0);
917
+ ctx.lineTo(this.radius + 2, 0);
918
+ ctx.stroke();
919
+ ctx.beginPath();
920
+ ctx.lineWidth = this.crosshairWidth;
921
+ ctx.strokeStyle = this.crosshairColor;
922
+ ctx.moveTo(0, -1);
923
+ ctx.lineTo(0, -this.radius - 2);
924
+ ctx.stroke();
925
+ ctx.beginPath();
926
+ ctx.lineWidth = this.crosshairWidth;
927
+ ctx.strokeStyle = this.crosshairColor;
928
+ ctx.moveTo(0, 1);
929
+ ctx.lineTo(0, this.radius + 2);
930
+ ctx.stroke();
931
+ }
932
+ }
933
+ }
934
+ });
935
+ // CONCATENATED MODULE: ./src/components/labeler/function/draw.js
936
+
937
+
938
+
939
+
940
+ // eslint-disable-next-line no-unused-vars
941
+
942
+
943
+ // eslint-disable-next-line no-unused-vars
944
+
945
+
946
+ /**
947
+ * 开启绘制
948
+ *
949
+ * @author pangyafei
950
+ * @date 2021-01-18
951
+ * @param {any} _this imageLabeler
952
+ * @param {any} type drawType
953
+ * @returns {any}
954
+ */
955
+ var draw_startDraw = function startDraw(_this, type) {
956
+ if (_this.drawingObject != null) {
957
+ // 当前正在绘制中,先清除
958
+ _this.stopDraw(_this);
959
+ }
960
+ if (_this.textObject != null) {
961
+ console.log('start other type draw, clear text object');
962
+ _this.stopDraw(_this);
963
+ }
964
+ _this.isDrawing = true;
965
+ _this.canvas.skipTargetFind = true;
966
+ _this.currentDrawType = drawType[type];
967
+
968
+ // 改switch
969
+
970
+ switch (type) {
971
+ case drawType.rectangle:
972
+ // 画矩形
973
+ draw_drawRectangle(_this);
974
+ break;
975
+ case drawType.polygon:
976
+ // 画多边形
977
+ draw_drawPolygon(_this);
978
+ break;
979
+ case drawType.circle:
980
+ // 画圆形
981
+ draw_drawCircle(_this);
982
+ break;
983
+ case drawType.triangle:
984
+ // 画三角形
985
+ draw_drawTriangle(_this);
986
+ break;
987
+ case drawType.line:
988
+ // 画直线
989
+ draw_drawLine(_this);
990
+ break;
991
+ case drawType.free:
992
+ // 自由绘制
993
+ drawPath(_this);
994
+ break;
995
+ case drawType.point:
996
+ // 绘制点
997
+ break;
998
+ case drawType.textbox:
999
+ // 添加文字
1000
+ break;
1001
+ default:
1002
+ _this.canvas.skipTargetFind = false;
1003
+ break;
1004
+ }
1005
+ };
1006
+
1007
+ /**
1008
+ * 停止绘制
1009
+ *
1010
+ * @author pangyafei
1011
+ * @date 2021-01-18
1012
+ * @param {any} _this
1013
+ * @returns {any}
1014
+ */
1015
+ var draw_stopDraw = function stopDraw(_this) {
1016
+ _this.isDrawing = false;
1017
+ _this.currentDrawType = null;
1018
+ _this.canvas.selection = true;
1019
+ _this.canvas.selectable = true;
1020
+ _this.canvas.skipTargetFind = false;
1021
+ _this.canvas.isDrawingMode = false;
1022
+ clearDrawingObject(_this);
1023
+ clearVirtualObject(_this);
1024
+ resetMouseMove(_this);
1025
+ };
1026
+
1027
+ /**
1028
+ * 画矩形
1029
+ *
1030
+ * @author pangyafei
1031
+ * @date 2021-01-18
1032
+ * @param {any} _this
1033
+ * @returns {any}
1034
+ */
1035
+ var draw_drawRectangle = function drawRectangle(_this) {
1036
+ var left = Math.min(_this.mouseFrom.x, _this.mouseTo.x);
1037
+ var top = Math.min(_this.mouseFrom.y, _this.mouseTo.y);
1038
+ var width = Math.abs(_this.mouseTo.x - _this.mouseFrom.x);
1039
+ var height = Math.abs(_this.mouseTo.y - _this.mouseFrom.y);
1040
+ var canvasObject = new LabeledRectangle({
1041
+ // const canvasObject = new fabric.Rect({
1042
+ left: left,
1043
+ top: top,
1044
+ width: width,
1045
+ height: height,
1046
+ fill: _this.fillColor,
1047
+ stroke: _this.lineColor,
1048
+ strokeWidth: _this.lineWidth,
1049
+ hoverCursor: 'default',
1050
+ transparentCorners: false,
1051
+ noScaleCache: false
1052
+ });
1053
+ // canvasObject.setControlVisible('mtr', false)
1054
+ changeDrawingObject(_this, canvasObject);
1055
+ };
1056
+
1057
+ /**
1058
+ * 画多边形
1059
+ *
1060
+ * @author pangyafei
1061
+ * @date 2021-01-18
1062
+ * @param {any} _this
1063
+ * @returns {any}
1064
+ */
1065
+ var draw_drawPolygon = function drawPolygon(_this) {
1066
+ if (!_this.drawingPoints) {
1067
+ _this.drawingPoints = [];
1068
+ }
1069
+ if (_this.mouseFrom.x != null && _this.mouseFrom.y != null) {
1070
+ _this.drawingPoints.push({
1071
+ x: _this.mouseFrom.x,
1072
+ y: _this.mouseFrom.y
1073
+ });
1074
+ }
1075
+ var canvasObject = new LabeledPolygon(_this.drawingPoints, {
1076
+ // const canvasObject = new fabric.Polygon(_this.drawingPoints, {
1077
+ fill: _this.fillColor,
1078
+ stroke: _this.lineColor,
1079
+ strokeWidth: _this.lineWidth,
1080
+ // scaleX: 1,
1081
+ // scaleY: 1,
1082
+ objectCaching: false,
1083
+ transparentCorners: false
1084
+ // cornerColor: 'blue'
1085
+ });
1086
+ changeDrawingObject(_this, canvasObject);
1087
+ };
1088
+
1089
+ /**
1090
+ * 绘制多边形虚拟线
1091
+ *
1092
+ * @author pangyafei
1093
+ * @date 2021-01-18
1094
+ * @param {any} _this
1095
+ * @returns {any}
1096
+ */
1097
+ var draw_drawPolygonVirtualLine = function drawPolygonVirtualLine(_this) {
1098
+ // console.log('draw virtual line', this.drawingPoints)
1099
+ clearVirtualObject(_this);
1100
+ _this.virtualObject = {
1101
+ a: null,
1102
+ b: null
1103
+ };
1104
+ if (_this.drawingPoints != null && _this.drawingPoints.length > 0) {
1105
+ _this.virtualObject.a = new external__fabric_["fabric"].Line([_this.drawingPoints[0].x, _this.drawingPoints[0].y, _this.mouseTo.x, _this.mouseTo.y], {
1106
+ stroke: _this.lineColor,
1107
+ strokeWidth: _this.lineWidth,
1108
+ strokeDashArray: [4, 3]
1109
+ });
1110
+ _this.canvas.add(_this.virtualObject.a);
1111
+ if (_this.drawingPoints.length > 1) {
1112
+ // console.log(_this.drawingPoints)
1113
+ _this.virtualObject.b = new external__fabric_["fabric"].Line([_this.drawingPoints[_this.drawingPoints.length - 1].x, _this.drawingPoints[_this.drawingPoints.length - 1].y, _this.mouseTo.x, _this.mouseTo.y], {
1114
+ stroke: _this.lineColor,
1115
+ strokeWidth: _this.lineWidth,
1116
+ strokeDashArray: [4, 3]
1117
+ });
1118
+ _this.canvas.add(_this.virtualObject.b);
1119
+ }
1120
+ }
1121
+ };
1122
+
1123
+ /**
1124
+ * 画圆形
1125
+ *
1126
+ * @author pangyafei
1127
+ * @date 2021-02-02
1128
+ * @param {any} _this
1129
+ * @returns {any}
1130
+ */
1131
+ var draw_drawCircle = function drawCircle(_this) {
1132
+ var left = Math.min(_this.mouseFrom.x, _this.mouseTo.x);
1133
+ var top = Math.min(_this.mouseFrom.y, _this.mouseTo.y);
1134
+ var width = Math.abs(_this.mouseFrom.x - _this.mouseTo.x);
1135
+ var height = Math.abs(_this.mouseFrom.y - _this.mouseTo.y);
1136
+ var radius = Math.sqrt(width * width + height * height) / 2;
1137
+ var circle = new external__fabric_["fabric"].Circle({
1138
+ left: left,
1139
+ top: top,
1140
+ scaleX: 1,
1141
+ scaleY: 1,
1142
+ stroke: _this.lineColor,
1143
+ fill: _this.fillColor,
1144
+ radius: radius,
1145
+ strokeWidth: _this.lineWidth,
1146
+ hoverCursor: 'default',
1147
+ transparentCorners: false,
1148
+ description: _this.description,
1149
+ objectCaching: false,
1150
+ originX: 'center',
1151
+ originY: 'center',
1152
+ centeredScaling: true,
1153
+ type: drawType.circle
1154
+ });
1155
+ circle.setControlVisible('mtr', false);
1156
+ changeDrawingObject(_this, circle);
1157
+ };
1158
+
1159
+ /**
1160
+ * 绘制三角形
1161
+ *
1162
+ * @author pangyafei
1163
+ * @date 2021-02-02
1164
+ * @param {any} _this
1165
+ * @returns {any}
1166
+ */
1167
+ var draw_drawTriangle = function drawTriangle(_this) {
1168
+ var left = _this.mouseFrom.x;
1169
+ var top = _this.mouseFrom.y;
1170
+ var height = _this.mouseTo.y - _this.mouseFrom.y;
1171
+ var width = Math.sqrt(Math.pow(height, 2) + Math.pow(height / 2.0, 2));
1172
+ var triangle = new external__fabric_["fabric"].Triangle({
1173
+ left: left,
1174
+ top: top,
1175
+ width: width,
1176
+ height: height,
1177
+ stroke: _this.lineColor,
1178
+ fill: _this.fillColor,
1179
+ strokeWidth: _this.lineWidth,
1180
+ hoverCursor: 'default',
1181
+ transparentCorners: false
1182
+ });
1183
+ triangle.setControlVisible('mtr', false);
1184
+ changeDrawingObject(_this, triangle);
1185
+ };
1186
+
1187
+ /**
1188
+ * 绘制直线
1189
+ *
1190
+ * @author pangyafei
1191
+ * @date 2021-02-03
1192
+ * @param {any} _this
1193
+ * @returns {any}
1194
+ */
1195
+ var draw_drawLine = function drawLine(_this) {
1196
+ var canvasObject = new external__fabric_["fabric"].Line([_this.mouseFrom.x, _this.mouseFrom.y, _this.mouseTo.x, _this.mouseTo.y], {
1197
+ scaleX: 1,
1198
+ scaleY: 1,
1199
+ stroke: _this.lineColor,
1200
+ fill: _this.fillColor,
1201
+ strokeWidth: _this.lineWidth,
1202
+ hoverCursor: 'default',
1203
+ transparentCorners: false
1204
+ });
1205
+ canvasObject.setControlVisible('mtr', false);
1206
+ changeDrawingObject(_this, canvasObject);
1207
+ };
1208
+
1209
+ /**
1210
+ * 绘制点,用圆形实现
1211
+ *
1212
+ * @author pangyafei
1213
+ * @date 2021-02-05
1214
+ * @param {any} _this
1215
+ * @returns {any}
1216
+ */
1217
+ var draw_drawPoint = function drawPoint(_this) {
1218
+ _this.canvas.selection = false;
1219
+ _this.canvas.selectable = false;
1220
+ var left = _this.mouseFrom.x - _this.pointRadius;
1221
+ var top = _this.mouseFrom.y - _this.pointRadius;
1222
+ var point = new LabeledPoint(Object.assign({
1223
+ left: left,
1224
+ top: top,
1225
+ radius: _this.pointRadius,
1226
+ fill: _this.pointFillColor,
1227
+ stroke: _this.pointLineColor,
1228
+ strokeWidth: _this.pointLineWidth,
1229
+ crosshair: _this.pointCrosshair,
1230
+ crosshairColor: _this.pointCrosshairColor,
1231
+ crosshairWidth: _this.pointCrosshairWidth,
1232
+ description: _this.description,
1233
+ hoverCursor: 'default',
1234
+ transparentCorners: false,
1235
+ visible: true,
1236
+ selectable: true,
1237
+ originX: 'center',
1238
+ originY: 'center',
1239
+ centeredScaling: true,
1240
+ type: drawType.point
1241
+ }, {}));
1242
+ _this.drawingObject = point;
1243
+
1244
+ // 添加删除按钮
1245
+ if (_this.showDeleteIcon) {
1246
+ point.controls.deleteControl = init_getDeleteControl(_this);
1247
+ }
1248
+ // 添加标签
1249
+ if (_this.showLabel && point.label && point.label !== '') {
1250
+ // point.controls.labelControl = getLabelControl(point.label)
1251
+ }
1252
+ point.setControlsVisibility({
1253
+ bl: false,
1254
+ br: false,
1255
+ mb: false,
1256
+ ml: false,
1257
+ mr: false,
1258
+ mt: false,
1259
+ tl: false,
1260
+ tr: false,
1261
+ mtr: false
1262
+ });
1263
+ _this.canvas.add(point);
1264
+ };
1265
+
1266
+ /**
1267
+ * 自由绘制
1268
+ *
1269
+ * @author pangyafei
1270
+ * @date 2021-02-03
1271
+ * @param {any} _this
1272
+ * @returns {any}
1273
+ */
1274
+ var drawPath = function drawPath(_this) {
1275
+ _this.canvas.freeDrawingBrush.color = _this.lineColor;
1276
+ _this.canvas.freeDrawingBrush.width = _this.lineWidth;
1277
+ _this.canvas.isDrawingMode = true;
1278
+ };
1279
+
1280
+ /**
1281
+ * 添加文字
1282
+ *
1283
+ * @author pangyafei
1284
+ * @date 2021-01-27
1285
+ * @param {any} _this
1286
+ * @returns {any}
1287
+ */
1288
+ var draw_drawTextbox = function drawTextbox(_this) {
1289
+ // 只能单次添加文字
1290
+ _this.currentDrawType = null;
1291
+ _this.canvas.selection = false;
1292
+ _this.canvas.selectable = false;
1293
+ var textObject = new external__fabric_["fabric"].Textbox('', {
1294
+ left: _this.mouseFrom.x,
1295
+ top: _this.mouseFrom.y,
1296
+ scaleX: 1,
1297
+ scaleY: 1,
1298
+ fontSize: _this.fontSize,
1299
+ fill: _this.fontColor,
1300
+ hasControls: true,
1301
+ transparentCorners: false
1302
+ // lockScalingFlip: true,
1303
+ // lockScalingX: true,
1304
+ // lockScalingY: true,
1305
+ // lockUniScaling: true,
1306
+ // lockSkewingX: true,
1307
+ // lockSkewingY: true
1308
+ });
1309
+ _this.canvas.add(textObject);
1310
+ textObject.on('editing:exited', function (options) {
1311
+ // 退出编辑时恢复正常操作,且不可再次编辑
1312
+ textBindLabel(_this);
1313
+ textObject.editable = false;
1314
+ textObject.setControlVisible('mtr', false);
1315
+
1316
+ // 添加删除按钮
1317
+ if (_this.showDeleteIcon) {
1318
+ textObject.controls.deleteControl = init_getDeleteControl(_this);
1319
+ }
1320
+ // 添加标签
1321
+ if (_this.showLabel && textObject.label && textObject.label !== '') {
1322
+ // textObject.controls.labelControl = getLabelControl(textObject.label)
1323
+ }
1324
+ _this.textObject = null;
1325
+ draw_stopDraw(_this);
1326
+ });
1327
+ textObject.enterEditing();
1328
+ textObject.hiddenTextarea.focus();
1329
+ _this.textObject = textObject;
1330
+ };
1331
+
1332
+ /**
1333
+ * 清除画布标注
1334
+ *
1335
+ * @author pangyafei
1336
+ * @date 2021-01-18
1337
+ * @param {any} _this
1338
+ * @param {any} id 标注元素的id
1339
+ * @returns {any}
1340
+ */
1341
+ var draw_clearDraw = function clearDraw(_this, id) {
1342
+ if (_this.canvas) {
1343
+ if (id) {
1344
+ // 根据id清除指定标注
1345
+ _this.canvas._objects.forEach(function (item) {
1346
+ console.log(item.id);
1347
+ if (id === item.id) {
1348
+ _this.canvas.remove(item);
1349
+ }
1350
+ });
1351
+ } else {
1352
+ // 清除画布所有的标注
1353
+ _this.canvas.clear();
1354
+ resetMouseMove(_this);
1355
+ _this.historyObjects = [];
1356
+ init_initBackgroundImage(_this, true);
1357
+ }
1358
+ }
1359
+ };
1360
+ /**
1361
+ * @description: 设置标注的显示与影藏
1362
+ * @author: miaochan
1363
+ * @date: 2023-06-07 13:50:40
1364
+ * @param:
1365
+ * @return:
1366
+ */
1367
+ var draw_setVisible = function setVisible(_this, id, flag) {
1368
+ if (_this.canvas) {
1369
+ if (id) {
1370
+ // 根据id清除指定标注
1371
+ _this.canvas._objects.forEach(function (item) {
1372
+ console.log(item.id);
1373
+ if (id === item.id) {
1374
+ item.visible = flag;
1375
+ _this.canvas.renderAll();
1376
+ }
1377
+ });
1378
+ }
1379
+ }
1380
+ };
1381
+ /**
1382
+ * @description: 设置标注是否可以移动
1383
+ * @author: miaochan
1384
+ * @date: 2023-06-07 14:11:54
1385
+ * @param:
1386
+ * @return:
1387
+ */
1388
+ var draw_setSelectable = function setSelectable(_this, id, flag) {
1389
+ if (_this.canvas) {
1390
+ if (id) {
1391
+ // 根据id清除指定标注
1392
+ _this.canvas._objects.forEach(function (item) {
1393
+ console.log(item.id);
1394
+ if (id === item.id) {
1395
+ item.selectable = flag;
1396
+ _this.canvas.renderAll();
1397
+ }
1398
+ });
1399
+ }
1400
+ }
1401
+ };
1402
+
1403
+ /**
1404
+ * 提示不可编辑
1405
+ *
1406
+ * @author pangyafei
1407
+ * @date 2021-01-19
1408
+ * @param {any} _this
1409
+ * @returns {any}
1410
+ */
1411
+ var draw_notEditable = function notEditable(_this) {
1412
+ throw Error(notEditableMsg);
1413
+ };
1414
+
1415
+ /**
1416
+ * 根据鼠标的移动实时改变绘制的对象
1417
+ *
1418
+ * @author pangyafei
1419
+ * @date 2021-01-18
1420
+ * @param {any} _this
1421
+ * @param {any} canvasObject
1422
+ * @returns {any}
1423
+ */
1424
+ var changeDrawingObject = function changeDrawingObject(_this, canvasObject) {
1425
+ _this.canvas.isDrawingMode = false;
1426
+ _this.canvas.selectable = false;
1427
+ _this.canvas.selection = false;
1428
+ canvasObject.selectable = true;
1429
+ if (_this.drawingObject) {
1430
+ _this.canvas.remove(_this.drawingObject);
1431
+ }
1432
+ _this.canvas.add(canvasObject);
1433
+ _this.drawingObject = canvasObject;
1434
+ };
1435
+
1436
+ /**
1437
+ * 清除正在绘制的图形
1438
+ *
1439
+ * @author pangyafei
1440
+ * @date 2021-01-18
1441
+ * @param {any} _this
1442
+ * @returns {any}
1443
+ */
1444
+ var clearDrawingObject = function clearDrawingObject(_this) {
1445
+ if (_this.drawingObject) {
1446
+ _this.canvas.remove(_this.drawingObject);
1447
+ }
1448
+ if (_this.textObject) {
1449
+ _this.textObject.exitEditing();
1450
+ // 下面两句不起作用,exit editing 的时候 textObject已经为null
1451
+ // _this.canvas.remove(_this.textObject)
1452
+ // _this.textObject = null
1453
+ }
1454
+ _this.drawingObject = null;
1455
+ _this.drawingPoints = null;
1456
+ };
1457
+
1458
+ /**
1459
+ * 清除正在绘制的虚线辅助线
1460
+ *
1461
+ * @author pangyafei
1462
+ * @date 2021-01-18
1463
+ * @param {any} _this
1464
+ * @returns {any}
1465
+ */
1466
+ var clearVirtualObject = function clearVirtualObject(_this) {
1467
+ if (_this.virtualObject) {
1468
+ if (_this.virtualObject.a) {
1469
+ _this.canvas.remove(_this.virtualObject.a);
1470
+ }
1471
+ if (_this.virtualObject.b) {
1472
+ _this.canvas.remove(_this.virtualObject.b);
1473
+ }
1474
+ }
1475
+ _this.virtualObject = null;
1476
+ };
1477
+
1478
+ /**
1479
+ * 撤销最近一次绘制或添加的图形
1480
+ *
1481
+ * @author pangyafei
1482
+ * @date 2021-02-05
1483
+ * @param {any} _this
1484
+ * @returns {any}
1485
+ */
1486
+ var draw_undo = function undo(_this) {
1487
+ if (_this.canvas._objects.length > 0) {
1488
+ _this.canvas.discardActiveObject();
1489
+ _this.historyObjects.push(_this.canvas._objects.pop());
1490
+ _this.canvas.renderAll();
1491
+ }
1492
+ };
1493
+
1494
+ /**
1495
+ * 将最近一次撤销绘制的图形还原到画布中
1496
+ *
1497
+ * @author pangyafei
1498
+ * @date 2021-02-05
1499
+ * @param {any} _this
1500
+ * @returns {any}
1501
+ */
1502
+ var draw_redo = function redo(_this) {
1503
+ if (_this.historyObjects.length > 0) {
1504
+ _this.canvas.add(_this.historyObjects.pop());
1505
+ _this.canvas.renderAll();
1506
+ }
1507
+ };
1508
+ // CONCATENATED MODULE: ./src/components/labeler/event/mouse.js
1509
+
1510
+
1511
+
1512
+
1513
+
1514
+
1515
+
1516
+
1517
+ // eslint-disable-next-line no-unused-vars
1518
+
1519
+
1520
+
1521
+
1522
+
1523
+ /**
1524
+ * 鼠标按下事件监听
1525
+ *
1526
+ * @author pangyafei
1527
+ * @date 2021-01-18
1528
+ * @param {any} _this
1529
+ * @param {any} options
1530
+ * @returns {any}
1531
+ */
1532
+ var mouse_mousedown = function mousedown(_this, options) {
1533
+ // console.log('draw type : ' + _this.currentDrawType)
1534
+ // console.log('mouse down : ', options)
1535
+ // const scrollTop = Math.floor(document.body.scrollTop || document.documentElement.scrollTop || window.pageYOffset)
1536
+ // const scrollLeft = Math.floor(document.body.scrollLeft || document.documentElement.scrollLeft || window.pageXOffset)
1537
+ // console.log(scrollTop)
1538
+ // console.log(scrollLeft)
1539
+ // console.log(_this.currentDrawType in Object.values(drawType))
1540
+
1541
+ if (_this.isDrawing === false && options.target == null) {
1542
+ _this.atDragging = true;
1543
+ _this.canvas.selection = false;
1544
+ // _this.canvas.selectable = false
1545
+ } else if (_this.isDrawing === false && options.target != null) {
1546
+ _this.fireShapeSelect(data_getData(_this, options.target.id));
1547
+ } else if (Object.values(drawType).includes(_this.currentDrawType)) {
1548
+ // console.log('mouse down')
1549
+
1550
+ // console.log(options)
1551
+
1552
+ _this.mouseFrom.x = options.absolutePointer.x;
1553
+ _this.mouseFrom.y = options.absolutePointer.y;
1554
+
1555
+ // _this.mouseFrom.x = options.e.clientX - _this.left + scrollLeft
1556
+ // _this.mouseFrom.y = options.e.clientY - _this.top + scrollTop
1557
+ _this.atDrawing = true;
1558
+ switch (_this.currentDrawType) {
1559
+ case drawType.textbox:
1560
+ draw_drawTextbox(_this);
1561
+ break;
1562
+ case drawType.polygon:
1563
+ draw_drawPolygon(_this);
1564
+ break;
1565
+ case drawType.point:
1566
+ draw_drawPoint(_this);
1567
+ break;
1568
+ default:
1569
+ break;
1570
+ }
1571
+ }
1572
+ };
1573
+
1574
+ /**
1575
+ * 鼠标移动事件监听
1576
+ *
1577
+ * @author pangyafei
1578
+ * @date 2021-01-18
1579
+ * @param {any} _this
1580
+ * @param {any} options
1581
+ * @returns {any}
1582
+ */
1583
+ var mouse_mousemove = function mousemove(_this, options) {
1584
+ if (_this.showHelpLines) {
1585
+ // 实时绘制参考线
1586
+ init_addHelpLines(_this, {
1587
+ x: options.absolutePointer.x,
1588
+ y: options.absolutePointer.y
1589
+ });
1590
+ }
1591
+ if (_this.atDragging && options && options.e) {
1592
+ // 正在拖动背景画布
1593
+ var delta = new external__fabric_["fabric"].Point(options.e.movementX, options.e.movementY);
1594
+ _this.canvas.relativePan(delta);
1595
+ _this.fireBgImageDrag(delta);
1596
+ return;
1597
+ }
1598
+ if (_this.atDrawing && Object.values(drawType).includes(_this.currentDrawType)) {
1599
+ // 正在绘制需要鼠标按下拖动绘制出的图形
1600
+
1601
+ // console.log('mouse move')
1602
+ // const scrollTop = Math.floor(document.body.scrollTop || document.documentElement.scrollTop || window.pageYOffset)
1603
+ // const scrollLeft = Math.floor(document.body.scrollLeft || document.documentElement.scrollLeft || window.pageXOffset)
1604
+ // _this.mouseTo.x = options.e.clientX - _this.left + scrollLeft
1605
+ // _this.mouseTo.y = options.e.clientY - _this.top + scrollTop
1606
+ // console.log(options)
1607
+ _this.mouseTo.x = options.absolutePointer.x;
1608
+ _this.mouseTo.y = options.absolutePointer.y;
1609
+ switch (_this.currentDrawType) {
1610
+ case drawType.line:
1611
+ draw_drawLine(_this);
1612
+ break;
1613
+ case drawType.circle:
1614
+ draw_drawCircle(_this);
1615
+ break;
1616
+ case drawType.rectangle:
1617
+ draw_drawRectangle(_this);
1618
+ break;
1619
+ case drawType.triangle:
1620
+ draw_drawTriangle(_this);
1621
+ break;
1622
+ case drawType.polygon:
1623
+ draw_drawPolygonVirtualLine(_this);
1624
+ break;
1625
+ default:
1626
+ break;
1627
+ }
1628
+ }
1629
+ };
1630
+
1631
+ /**
1632
+ * 鼠标抬起事件监听
1633
+ *
1634
+ * @author pangyafei
1635
+ * @date 2021-01-18
1636
+ * @param {any} _this
1637
+ * @param {any} options
1638
+ * @returns {any}
1639
+ */
1640
+ var mouse_mouseup = function mouseup(_this, options) {
1641
+ if (_this.atDragging) {
1642
+ _this.atDragging = false;
1643
+ _this.canvas.selection = true;
1644
+ // _this.canvas.selectable = true
1645
+ } else if (Object.values(drawType).includes(_this.currentDrawType) && _this.currentDrawType !== drawType.polygon) {
1646
+ // console.log('mouse up')
1647
+ // _this.mouseTo.x = options.e.clientX - _this.left
1648
+ // _this.mouseTo.y = options.e.clientY - _this.top
1649
+
1650
+ if (_this.drawingObject == null) {
1651
+ return;
1652
+ }
1653
+ if (isNaN(_this.drawingObject.left)) {
1654
+ return;
1655
+ }
1656
+ _this.drawingObject.type = _this.currentDrawType;
1657
+ // 图形绑定标签
1658
+ shapeBindLabel(_this);
1659
+ var drawData = data_getData(_this, _this.drawingObject.id);
1660
+
1661
+ // 添加删除图标
1662
+ if (_this.showDeleteIcon) {
1663
+ _this.drawingObject.controls.deleteControl = init_getDeleteControl(_this);
1664
+ }
1665
+ // 添加标签控件
1666
+ if (_this.showLabel && _this.drawingObject.label && _this.drawingObject.label !== '') {
1667
+ // _this.drawingObject.controls.labelControl = getLabelControl(_this.drawingObject.label)
1668
+
1669
+ if (_this.currentDrawType === drawType.rectangle) {
1670
+ getTextboxLabel(_this, _this.drawingObject);
1671
+ }
1672
+ // console.log('draw with control', _this.drawingObject.controls)
1673
+ }
1674
+ _this.drawingObject = null;
1675
+ // console.log('fire shape id :' + _this.drawingObject.id)
1676
+ // console.log(getData(_this, _this.drawingObject.id))
1677
+ _this.fireShapeDraw(drawData);
1678
+ _this.mouseFrom.x = options.absolutePointer.x;
1679
+ _this.mouseFrom.y = options.absolutePointer.y;
1680
+ _this.atDrawing = false;
1681
+ resetMouseMove(_this);
1682
+ } else if (_this.isDrawing === false && options.target) {
1683
+ _this.fireShapeDrag(data_getData(_this, options.target.id));
1684
+ }
1685
+ };
1686
+
1687
+ /**
1688
+ * 鼠标双击事件监听
1689
+ *
1690
+ * @author pangyafei
1691
+ * @date 2021-01-18
1692
+ * @param {any} _this
1693
+ * @param {any} options
1694
+ * @returns {any}
1695
+ */
1696
+ var mouse_mousedblclick = function mousedblclick(_this, options) {
1697
+ if (Object.values(drawType).includes(_this.currentDrawType) && _this.currentDrawType === drawType.polygon) {
1698
+ // console.log('mouse dblclick')
1699
+ // 移除最后一个多边形的点
1700
+ // console.log(_this.drawingObject)
1701
+ _this.drawingPoints.pop();
1702
+
1703
+ // const canvasObject = new fabric.Polygon(_this.drawingPoints, {
1704
+ var canvasObject = new LabeledPolygon(_this.drawingPoints, {
1705
+ fill: _this.fillColor,
1706
+ stroke: _this.lineColor,
1707
+ strokeWidth: _this.lineWidth,
1708
+ // scaleX: 1,
1709
+ // scaleY: 1,
1710
+ objectCaching: false,
1711
+ transparentCorners: false,
1712
+ type: drawType.polygon,
1713
+ lockMovementX: true,
1714
+ lockMovementY: true,
1715
+ hoverCursor: 'default'
1716
+ // cornerColor: 'blue'
1717
+ });
1718
+ canvasObject.selectable = true;
1719
+ if (_this.drawingObject) {
1720
+ _this.canvas.remove(_this.drawingObject);
1721
+ }
1722
+ _this.canvas.add(canvasObject);
1723
+ _this.drawingObject = canvasObject;
1724
+
1725
+ // 图形绑定标签
1726
+ shapeBindLabel(_this);
1727
+
1728
+ // 为多边形定义控制事件
1729
+ // _this.drawingObject.connerStyle = 'circle'
1730
+ addPolygonControl(_this.drawingObject);
1731
+
1732
+ // 添加删除图标
1733
+ if (_this.showDeleteIcon) {
1734
+ _this.drawingObject.controls.deleteControl = init_getDeleteControl(_this);
1735
+ }
1736
+ // 添加标签控件
1737
+ if (_this.showLabel && _this.drawingObject.label && _this.drawingObject.label !== '') {
1738
+ // _this.drawingObject.controls.labelControl = getLabelControl(_this.drawingObject.label)
1739
+ }
1740
+
1741
+ // _this.canvas.requestRenderAll()
1742
+ var id = _this.drawingObject.id;
1743
+ _this.drawingObject = null;
1744
+ _this.drawingPoints = null;
1745
+ _this.atDrawing = false;
1746
+ if (_this.virtualObject.a != null) {
1747
+ _this.canvas.remove(_this.virtualObject.a);
1748
+ }
1749
+ if (_this.virtualObject.b != null) {
1750
+ _this.canvas.remove(_this.virtualObject.b);
1751
+ }
1752
+ _this.virtualObject = null;
1753
+ resetMouseMove(_this);
1754
+ _this.fireShapeDraw(data_getData(_this, id));
1755
+ }
1756
+ };
1757
+
1758
+ /**
1759
+ * 鼠标移出画布事件监听
1760
+ *
1761
+ * @author pangyafei
1762
+ * @date 2021-02-05
1763
+ * @param {any} _this
1764
+ * @param {any} options
1765
+ * @returns {any}
1766
+ */
1767
+ var mouse_mouseout = function mouseout(_this, options) {
1768
+ if (_this.showHelpLines) {
1769
+ clearHelpLines(_this);
1770
+ }
1771
+ };
1772
+
1773
+ /**
1774
+ * 鼠标滚轮事件监听
1775
+ *
1776
+ * @author pangyafei
1777
+ * @date 2021-01-18
1778
+ * @param {any} _this
1779
+ * @param {any} options
1780
+ * @returns {any}
1781
+ */
1782
+ var mouse_mousewheel = function mousewheel(_this, options) {
1783
+ var delta = options.e.deltaY / -1000;
1784
+ var lastZoom = _this.canvas.getZoom();
1785
+ var zoom = Math.pow(Math.log(Math.abs(delta) + 1) + 1, Math.sign(delta)) * lastZoom;
1786
+ // let zoom = (options.e.deltaY > 0 ? -0.1 : 0.1) + _this.canvas.getZoom()
1787
+ // zoom = Math.max(0.1, zoom) // 最小为原来的1/10
1788
+ // zoom = Math.min(10, zoom) // 最大是原来的10倍
1789
+ var zoomPoint = new external__fabric_["fabric"].Point(options.e.layerX, options.e.layerY);
1790
+ _this.canvas.zoomToPoint(zoomPoint, zoom);
1791
+ _this.canvas._objects.forEach(function (item) {
1792
+ // console.log('visit wheel: ', item)
1793
+
1794
+ // 点缩放处理
1795
+ if (!_this.pointZoom && item.type === drawType.point) {
1796
+ // console.log('point radius: ', item.getRadiusX())
1797
+ // console.log('point radius: ', item.getRadiusY())
1798
+ // console.log('point radius: ', item.getScaledWidth())
1799
+
1800
+ // console.log('point scaleX: ', item.scaleX)
1801
+ // console.log('point centeredScaling: ', item.centeredScaling)
1802
+ // console.log('point originX: ', item.originX)
1803
+ // console.log('point originY: ', item.originY)
1804
+
1805
+ // item.setRadius(item.getRadiusX() / zoom * lastZoom)
1806
+
1807
+ // scaleX == scaleY
1808
+ item.scale(item.scaleX / zoom * lastZoom);
1809
+ }
1810
+ // if (id === item.id) {
1811
+ // _this.canvas.remove(item)
1812
+ // }
1813
+ });
1814
+ var imageInfo = {
1815
+ width: _this.image.width,
1816
+ height: _this.image.height,
1817
+ scaleX: _this.canvas.backgroundImage.scaleX * _this.canvas.getZoom(),
1818
+ scaleY: _this.canvas.backgroundImage.scaleX * _this.canvas.getZoom()
1819
+ };
1820
+ _this.fireMouseWheel(imageInfo);
1821
+ };
1822
+
1823
+ // 多边形控制点操控相关方法
1824
+
1825
+ function addPolygonControl(polygon) {
1826
+ var lastIndex = polygon.points.length - 1;
1827
+ polygon.controls = polygon.points.reduce(function (acc, point, index) {
1828
+ acc['p' + index] = new external__fabric_["fabric"].Control({
1829
+ positionHandler: polygonPositionHandler,
1830
+ actionHandler: anchorWrapper(index > 0 ? index - 1 : lastIndex, actionHandler),
1831
+ actionName: 'modifyPolygon',
1832
+ pointIndex: index
1833
+ });
1834
+ return acc;
1835
+ }, {});
1836
+ }
1837
+
1838
+ // define a function that can locate the controls.
1839
+ // this function will be used both for drawing and for interaction.
1840
+ function polygonPositionHandler(dim, finalMatrix, fabricObject) {
1841
+ var x = fabricObject.points[this.pointIndex].x - fabricObject.pathOffset.x;
1842
+ var y = fabricObject.points[this.pointIndex].y - fabricObject.pathOffset.y;
1843
+ return external__fabric_["fabric"].util.transformPoint({
1844
+ x: x,
1845
+ y: y
1846
+ }, external__fabric_["fabric"].util.multiplyTransformMatrices(fabricObject.canvas.viewportTransform, fabricObject.calcTransformMatrix()));
1847
+ }
1848
+
1849
+ // define a function that will define what the control does
1850
+ // this function will be called on every mouse move after a control has been
1851
+ // clicked and is being dragged.
1852
+ // The function receive as argument the mouse event, the current trasnform object
1853
+ // and the current position in canvas coordinate
1854
+ // transform.target is a reference to the current object being transformed,
1855
+ function actionHandler(eventData, transform, x, y) {
1856
+ var polygon = transform.target;
1857
+ var currentControl = polygon.controls[polygon.__corner];
1858
+ var mouseLocalPosition = polygon.toLocalPoint(new external__fabric_["fabric"].Point(x, y), 'center', 'center');
1859
+ var polygonBaseSize = polygon._getNonTransformedDimensions();
1860
+ var size = polygon._getTransformedDimensions(0, 0);
1861
+ var finalPointPosition = {
1862
+ x: mouseLocalPosition.x * polygonBaseSize.x / size.x + polygon.pathOffset.x,
1863
+ y: mouseLocalPosition.y * polygonBaseSize.y / size.y + polygon.pathOffset.y
1864
+ };
1865
+ polygon.points[currentControl.pointIndex] = finalPointPosition;
1866
+ return true;
1867
+ }
1868
+
1869
+ // define a function that can keep the polygon in the same position when we change its
1870
+ // width/height/top/left.
1871
+ function anchorWrapper(anchorIndex, fn) {
1872
+ return function (eventData, transform, x, y) {
1873
+ var fabricObject = transform.target;
1874
+ var absolutePoint = external__fabric_["fabric"].util.transformPoint({
1875
+ x: fabricObject.points[anchorIndex].x - fabricObject.pathOffset.x,
1876
+ y: fabricObject.points[anchorIndex].y - fabricObject.pathOffset.y
1877
+ }, fabricObject.calcTransformMatrix());
1878
+ var actionPerformed = fn(eventData, transform, x, y);
1879
+ fabricObject._setPositionDimensions({});
1880
+ var polygonBaseSize = fabricObject._getNonTransformedDimensions();
1881
+ var newX = (fabricObject.points[anchorIndex].x - fabricObject.pathOffset.x) / polygonBaseSize.x;
1882
+ var newY = (fabricObject.points[anchorIndex].y - fabricObject.pathOffset.y) / polygonBaseSize.y;
1883
+ fabricObject.setPositionByOrigin(absolutePoint, newX + 0.5, newY + 0.5);
1884
+ return actionPerformed;
1885
+ };
1886
+ }
1887
+ // CONCATENATED MODULE: ./src/components/labeler/function/data.js
1888
+
1889
+
1890
+
1891
+
1892
+
1893
+
1894
+ // eslint-disable-next-line no-unused-vars
1895
+
1896
+
1897
+
1898
+
1899
+
1900
+
1901
+ // eslint-disable-next-line no-unused-vars
1902
+
1903
+
1904
+ /**
1905
+ * 获取所有的标注图形信息
1906
+ *
1907
+ * @author pangyafei
1908
+ * @date 2021-01-19
1909
+ * @param {any} _this
1910
+ * @param {any} id
1911
+ * @param {any} label
1912
+ * @returns {any}
1913
+ */
1914
+ var data_getData = function getData(_this, id, label) {
1915
+ // console.log(_this.canvas)
1916
+ // console.log(_this.canvas.getObjects())
1917
+ var shapes = _this.canvas.getObjects();
1918
+ var data = [];
1919
+ var imageInfo = data_getImageInfo(_this);
1920
+ var scaleX = imageInfo.scaleX;
1921
+ var scaleY = imageInfo.scaleY;
1922
+ // console.log(imageInfo)
1923
+
1924
+ shapes.forEach(function (shape) {
1925
+ // 此处的shape有可能是text
1926
+ // console.log(shape.type)
1927
+ // console.log(shape)
1928
+ var item = {
1929
+ id: shape.id,
1930
+ label: shape.label,
1931
+ description: shape.description,
1932
+ lineColor: shape.stroke,
1933
+ lineWidth: shape.strokeWidthUnscaled || shape.strokeWidth,
1934
+ fillColor: shape.fill,
1935
+ type: shape.type,
1936
+ top: shape.top,
1937
+ left: shape.left,
1938
+ points: []
1939
+ };
1940
+ // console.log('shape : ', shape)
1941
+
1942
+ switch (shape.type) {
1943
+ case drawType.rectangle:
1944
+ // item.points = clonedeep(Object.values(shape.aCoords))
1945
+ item.points = [{
1946
+ x: shape.left / scaleX,
1947
+ y: (shape.top + shape.getScaledHeight() - 2) / scaleY
1948
+ }, {
1949
+ x: (shape.left + shape.getScaledWidth() - 2) / scaleX,
1950
+ y: (shape.top + shape.getScaledHeight() - 2) / scaleY
1951
+ }, {
1952
+ x: shape.left / scaleX,
1953
+ y: shape.top / scaleY
1954
+ }, {
1955
+ x: (shape.left + shape.getScaledWidth() - 2) / scaleX,
1956
+ y: shape.top / scaleY
1957
+ }];
1958
+ break;
1959
+ case drawType.polygon:
1960
+ item.points = Object.values(shape.points).map(function (p) {
1961
+ return {
1962
+ x: p.x / scaleX,
1963
+ y: p.y / scaleY
1964
+ };
1965
+ });
1966
+ break;
1967
+ case drawType.circle:
1968
+ // points from top & left
1969
+ // item.points = [{ x: (shape.left + shape.radius) / scaleX, y: (shape.top + shape.radius) / scaleY }]
1970
+
1971
+ // points from center & center
1972
+ item.points = [{
1973
+ x: shape.left / scaleX,
1974
+ y: shape.top / scaleY
1975
+ }];
1976
+ item.radius = shape.radius / scaleX;
1977
+ item.scaleX = shape.scaleX;
1978
+ item.scaleY = shape.scaleY;
1979
+ // console.log('get circle radius: ' + item.radius + ' & scale : ' + scaleX)
1980
+ break;
1981
+ case drawType.triangle:
1982
+ // item.points = Object.values(shape.aCoords)
1983
+ item.points = [{
1984
+ x: shape.left / scaleX,
1985
+ y: (shape.top + shape.getScaledHeight() - 2) / scaleY
1986
+ }, {
1987
+ x: (shape.left + shape.getScaledWidth() - 2) / scaleX,
1988
+ y: (shape.top + shape.getScaledHeight() - 2) / scaleY
1989
+ }, {
1990
+ x: shape.left / scaleX,
1991
+ y: shape.top / scaleY
1992
+ }, {
1993
+ x: (shape.left + shape.getScaledWidth() - 2) / scaleX,
1994
+ y: shape.top / scaleY
1995
+ }];
1996
+ break;
1997
+ case drawType.line:
1998
+ item.points = [{
1999
+ x: shape.x1 / scaleX,
2000
+ y: shape.y1 / scaleY
2001
+ }, {
2002
+ x: shape.x2 / scaleX,
2003
+ y: shape.y2 / scaleY
2004
+ }];
2005
+ item.scaleX = shape.scaleX;
2006
+ item.scaleY = shape.scaleY;
2007
+ break;
2008
+ case drawType.point:
2009
+ console.log('shape', shape);
2010
+
2011
+ // points from top & left
2012
+ // item.points = [{ x: (shape.left + shape.radius) / scaleX, y: (shape.top + shape.radius) / scaleY }]
2013
+
2014
+ // points from center & center
2015
+ item.points = [{
2016
+ x: shape.left / scaleX,
2017
+ y: shape.top / scaleY
2018
+ }];
2019
+ item.radius = shape.radius / scaleX;
2020
+ item.scaleX = shape.scaleX ? shape.scaleX : 1;
2021
+ item.scaleY = shape.scaleY ? shape.scaleY : 1;
2022
+ break;
2023
+ case drawType.free:
2024
+ item.points = external__lodash_clonedeep__default()(Object.values(shape.path));
2025
+ console.log(item.points);
2026
+ item.points.forEach(function (e) {
2027
+ if (e[0] === 'M') {
2028
+ e[1] /= scaleX;
2029
+ e[2] /= scaleY;
2030
+ } else if (e[0] === 'Q') {
2031
+ e[1] /= scaleX;
2032
+ e[2] /= scaleY;
2033
+ e[3] /= scaleX;
2034
+ e[4] /= scaleY;
2035
+ } else {
2036
+ // e[0] === 'L'
2037
+ e[1] /= scaleX;
2038
+ e[2] /= scaleY;
2039
+ }
2040
+ });
2041
+ item.scaleX = shape.scaleX;
2042
+ item.scaleY = shape.scaleY;
2043
+ break;
2044
+ case drawType.textbox:
2045
+ if (shape.text != null && shape.text.trim() !== '') {
2046
+ item.text = shape.text;
2047
+ item.points = [{
2048
+ x: shape.left / scaleX,
2049
+ y: (shape.top + shape.getScaledHeight() - 2) / scaleY
2050
+ }, {
2051
+ x: (shape.left + shape.getScaledWidth() - 2) / scaleX,
2052
+ y: (shape.top + shape.getScaledHeight() - 2) / scaleY
2053
+ }, {
2054
+ x: shape.left / scaleX,
2055
+ y: shape.top / scaleY
2056
+ }, {
2057
+ x: (shape.left + shape.getScaledWidth() - 2) / scaleX,
2058
+ y: shape.top / scaleY
2059
+ }];
2060
+ item.scaleX = shape.scaleX;
2061
+ item.scaleY = shape.scaleY;
2062
+ item.fontSize = shape.fontSize;
2063
+ } else {
2064
+ item = null;
2065
+ }
2066
+ break;
2067
+ default:
2068
+ item = null;
2069
+ break;
2070
+ }
2071
+
2072
+ // console.log(item.points)
2073
+ // console.log('-----')
2074
+ // console.log(shape.aCoords)
2075
+ // item.points.forEach(point => {
2076
+ // point.x /= imageInfo.scaleX
2077
+ // point.y /= imageInfo.scaleY
2078
+ // })
2079
+
2080
+ if (item) {
2081
+ if (id) {
2082
+ if (shape.id === id) {
2083
+ data.push(item);
2084
+ }
2085
+ } else if (label) {
2086
+ if (shape.label === label) {
2087
+ data.push(item);
2088
+ }
2089
+ } else {
2090
+ data.push(item);
2091
+ }
2092
+ }
2093
+ });
2094
+ if (id) {
2095
+ if (data.length > 0) {
2096
+ return data[0];
2097
+ } else {
2098
+ return null;
2099
+ }
2100
+ } else {
2101
+ return data;
2102
+ }
2103
+ };
2104
+
2105
+ /**
2106
+ * 根据图形信息设置标注图形
2107
+ *
2108
+ * @author pangyafei
2109
+ * @date 2021-01-19
2110
+ * @param {any} _this
2111
+ * @param {any} data
2112
+ * @param {any} append 是否追加
2113
+ * @returns {any}
2114
+ */
2115
+ var data_setData = function setData(_this, data, append) {
2116
+ // 先清空图形
2117
+ if (append) {
2118
+ // do nothing
2119
+ } else {
2120
+ draw_clearDraw(_this);
2121
+ }
2122
+ if (data == null) {
2123
+ return;
2124
+ }
2125
+ if (!(data instanceof Array)) {
2126
+ data = [data];
2127
+ }
2128
+ // 再渲染图形
2129
+ var imageInfo = data_getImageInfo(_this);
2130
+ if (imageInfo == null) {
2131
+ throw Error(setDataErrorMsg);
2132
+ }
2133
+ var scaleX = imageInfo.scaleX;
2134
+ var scaleY = imageInfo.scaleY;
2135
+ data.forEach(function (item) {
2136
+ switch (item.type) {
2137
+ case drawType.rectangle:
2138
+ data_addRectangle(_this, item, scaleX, scaleY);
2139
+ break;
2140
+ case drawType.polygon:
2141
+ data_addPolygon(_this, item, scaleX, scaleY);
2142
+ break;
2143
+ case drawType.circle:
2144
+ data_addCircle(_this, item, scaleX, scaleY);
2145
+ break;
2146
+ case drawType.triangle:
2147
+ data_addTriangle(_this, item, scaleX, scaleY);
2148
+ break;
2149
+ case drawType.line:
2150
+ data_addLine(_this, item, scaleX, scaleY);
2151
+ break;
2152
+ case drawType.point:
2153
+ data_addPoint(_this, item, scaleX, scaleY);
2154
+ break;
2155
+ case drawType.free:
2156
+ data_addPath(_this, item, scaleX, scaleY);
2157
+ break;
2158
+ case drawType.textbox:
2159
+ data_addTextbox(_this, item, scaleX, scaleY);
2160
+ break;
2161
+ default:
2162
+ break;
2163
+ }
2164
+ });
2165
+ };
2166
+
2167
+ /**
2168
+ * 向画布中添加一个矩形
2169
+ *
2170
+ * @author pangyafei
2171
+ * @date 2021-01-19
2172
+ * @param {any} _this
2173
+ * @param {any} data
2174
+ * @param {any} scaleX
2175
+ * @param {any} scaleY
2176
+ * @returns {any}
2177
+ */
2178
+ var data_addRectangle = function addRectangle(_this, data, scaleX, scaleY) {
2179
+ // console.log(data)
2180
+ var maxX = Math.max.apply(Math, _toConsumableArray(data.points.map(function (p) {
2181
+ return p.x;
2182
+ }))) * scaleX;
2183
+ var minX = Math.min.apply(Math, _toConsumableArray(data.points.map(function (p) {
2184
+ return p.x;
2185
+ }))) * scaleX;
2186
+ var maxY = Math.max.apply(Math, _toConsumableArray(data.points.map(function (p) {
2187
+ return p.y;
2188
+ }))) * scaleY;
2189
+ var minY = Math.min.apply(Math, _toConsumableArray(data.points.map(function (p) {
2190
+ return p.y;
2191
+ }))) * scaleY;
2192
+
2193
+ // console.log(maxX + ';' + minX + ';' + maxY + ';' + minY)
2194
+ // const rectangle = new fabric.Rect(Object.assign(getBaseShapeInfo(data, _this), {
2195
+ var rectangle = new LabeledRectangle(Object.assign(getBaseShapeInfo(data, _this), {
2196
+ top: minY,
2197
+ left: minX,
2198
+ width: maxX - minX,
2199
+ height: maxY - minY
2200
+ }));
2201
+ rectangle.setControlVisible('mtr', false);
2202
+ if (_this.showDeleteIcon) {
2203
+ // 添加删除图标
2204
+ rectangle.controls.deleteControl = init_getDeleteControl(_this);
2205
+ }
2206
+ if (_this.showLabel && rectangle.label && rectangle.label !== '') {
2207
+ // 添加标签
2208
+ // rectangle.controls.labelControl = getLabelControl(rectangle.label)
2209
+ }
2210
+ _this.canvas.add(rectangle);
2211
+ };
2212
+
2213
+ /**
2214
+ * 向画布中添加一个矩形
2215
+ *
2216
+ * @author pangyafei
2217
+ * @date 2021-01-19
2218
+ * @param {any} _this
2219
+ * @param {any} data
2220
+ * @param {any} scaleX
2221
+ * @param {any} scaleY
2222
+ * @returns {any}
2223
+ */
2224
+ var data_addPolygon = function addPolygon(_this, data, scaleX, scaleY) {
2225
+ var points = data.points.map(function (item) {
2226
+ return {
2227
+ x: item.x * scaleX,
2228
+ y: item.y * scaleY
2229
+ };
2230
+ });
2231
+ // const polygon = new fabric.Polygon(points, getBaseShapeInfo(data, _this))
2232
+ var polygon = new LabeledPolygon(points, Object.assign(getBaseShapeInfo(data, _this), {
2233
+ lockMovementX: true,
2234
+ lockMovementY: true,
2235
+ hoverCursor: 'default'
2236
+ }));
2237
+ _this.canvas.add(polygon);
2238
+ // 添加多边形控制点
2239
+ addPolygonControl(polygon);
2240
+ if (_this.showDeleteIcon) {
2241
+ // 添加删除图标
2242
+ polygon.controls.deleteControl = init_getDeleteControl(_this);
2243
+ }
2244
+ if (_this.showLabel && polygon.label && polygon.label !== '') {
2245
+ // 添加标签
2246
+ // polygon.controls.labelControl = getLabelControl(polygon.label)
2247
+ }
2248
+ };
2249
+
2250
+ /**
2251
+ * 向画布中添加一个圆形
2252
+ *
2253
+ * @author pangyafei
2254
+ * @date 2021-02-02
2255
+ * @param {any} _this
2256
+ * @param {any} data
2257
+ * @param {any} scaleX
2258
+ * @param {any} scaleY
2259
+ * @returns {any}
2260
+ */
2261
+ var data_addCircle = function addCircle(_this, data, scaleX, scaleY) {
2262
+ // const minX = Math.min(...data.points.map(p => p.x))
2263
+ // const minY = Math.min(...data.points.map(p => p.y))
2264
+
2265
+ var circle = new external__fabric_["fabric"].Circle(Object.assign(getBaseShapeInfo(data, _this), {
2266
+ left: data.points[0].x * scaleX,
2267
+ top: data.points[0].y * scaleY,
2268
+ scaleX: data.scaleX,
2269
+ scaleY: data.scaleY,
2270
+ radius: data.radius * scaleX,
2271
+ strokeWidth: data.lineWidth,
2272
+ description: data.description,
2273
+ hoverCursor: 'default',
2274
+ transparentCorners: false,
2275
+ objectCaching: false,
2276
+ originX: 'center',
2277
+ originY: 'center',
2278
+ centeredScaling: true,
2279
+ type: drawType.circle
2280
+ }));
2281
+ // circle.radius = data.radius
2282
+ circle.setControlVisible('mtr', false);
2283
+ if (_this.showDeleteIcon) {
2284
+ // 添加删除图标
2285
+ circle.controls.deleteControl = init_getDeleteControl(_this);
2286
+ }
2287
+ if (_this.showLabel && circle.label && circle.label !== '') {
2288
+ // 添加标签
2289
+ // circle.controls.labelControl = getLabelControl(circle.label)
2290
+ }
2291
+ _this.canvas.add(circle);
2292
+ };
2293
+
2294
+ /**
2295
+ * 向画布中添加一个三角形
2296
+ *
2297
+ * @author pangyafei
2298
+ * @date 2021-02-05
2299
+ * @param {any} _this
2300
+ * @param {any} data
2301
+ * @param {any} scaleX
2302
+ * @param {any} scaleY
2303
+ * @returns {any}
2304
+ */
2305
+ var data_addTriangle = function addTriangle(_this, data, scaleX, scaleY) {
2306
+ var maxX = Math.max.apply(Math, _toConsumableArray(data.points.map(function (p) {
2307
+ return p.x;
2308
+ }))) * scaleX;
2309
+ var minX = Math.min.apply(Math, _toConsumableArray(data.points.map(function (p) {
2310
+ return p.x;
2311
+ }))) * scaleX;
2312
+ var maxY = Math.max.apply(Math, _toConsumableArray(data.points.map(function (p) {
2313
+ return p.y;
2314
+ }))) * scaleY;
2315
+ var minY = Math.min.apply(Math, _toConsumableArray(data.points.map(function (p) {
2316
+ return p.y;
2317
+ }))) * scaleY;
2318
+ var triangle = new external__fabric_["fabric"].Triangle(Object.assign(getBaseShapeInfo(data, _this), {
2319
+ top: minY,
2320
+ left: minX,
2321
+ width: maxX - minX,
2322
+ height: maxY - minY
2323
+ }));
2324
+ triangle.setControlVisible('mtr', false);
2325
+ if (_this.showDeleteIcon) {
2326
+ // 添加删除图标
2327
+ triangle.controls.deleteControl = init_getDeleteControl(_this);
2328
+ }
2329
+ if (_this.showLabel && triangle.label && triangle.label !== '') {
2330
+ // 添加标签
2331
+ // triangle.controls.labelControl = getLabelControl(triangle.label)
2332
+ }
2333
+ _this.canvas.add(triangle);
2334
+ };
2335
+
2336
+ /**
2337
+ * 向画布中添加线
2338
+ *
2339
+ * @author pangyafei
2340
+ * @date 2021-02-03
2341
+ * @param {any} _this
2342
+ * @param {any} data
2343
+ * @param {any} scaleX
2344
+ * @param {any} scaleY
2345
+ * @returns {any}
2346
+ */
2347
+ var data_addLine = function addLine(_this, data, scaleX, scaleY) {
2348
+ var line = new external__fabric_["fabric"].Line([data.points[0].x * scaleX, data.points[0].y * scaleY, data.points[1].x * scaleX, data.points[1].y * scaleY], Object.assign(getBaseShapeInfo(data, _this), {
2349
+ scaleX: data.scaleX,
2350
+ scaleY: data.scaleY
2351
+ }));
2352
+ line.setControlVisible('mtr', false);
2353
+ if (_this.showDeleteIcon) {
2354
+ // 添加删除图标
2355
+ line.controls.deleteControl = init_getDeleteControl(_this);
2356
+ }
2357
+ if (_this.showLabel && line.label && line.label !== '') {
2358
+ // 添加标签
2359
+ // line.controls.labelControl = getLabelControl(line.label)
2360
+ }
2361
+ _this.canvas.add(line);
2362
+ };
2363
+
2364
+ /**
2365
+ * 向画布中添加点
2366
+ *
2367
+ * @author pangyafei
2368
+ * @date 2021-02-05
2369
+ * @param {any} _this
2370
+ * @param {any} data
2371
+ * @param {any} scaleX
2372
+ * @param {any} scaleY
2373
+ * @returns {any}
2374
+ */
2375
+ var data_addPoint = function addPoint(_this, data, scaleX, scaleY) {
2376
+ var point = new LabeledPoint(Object.assign({
2377
+ left: data.points[0].x * scaleX,
2378
+ top: data.points[0].y * scaleY,
2379
+ radius: data.radius * scaleX,
2380
+ scaleX: data.scaleX,
2381
+ scaleY: data.scaleY,
2382
+ stroke: data.pointLineColor ? data.pointLineColor : _this.pointLineColor,
2383
+ fill: data.pointFillColor ? data.pointFillColor : _this.pointFillColor,
2384
+ strokeWidth: data.pointLineWidth ? data.pointLineWidth : _this.pointLineWidth,
2385
+ crosshair: data.pointCrosshair ? data.pointCrosshair : _this.pointCrosshair,
2386
+ crosshairColor: data.pointCrosshairColor ? data.pointCrosshairColor : _this.pointCrosshairColor,
2387
+ crosshairWidth: data.pointCrosshairWidth ? data.pointCrosshairWidth : _this.pointCrosshairWidth,
2388
+ description: data.description,
2389
+ label: data.label,
2390
+ hoverCursor: 'default',
2391
+ transparentCorners: false,
2392
+ visible: data.visible !== false,
2393
+ selectable: data.selectable !== false,
2394
+ originX: 'center',
2395
+ originY: 'center',
2396
+ centeredScaling: true,
2397
+ type: drawType.point,
2398
+ id: data.id
2399
+ }, {}));
2400
+
2401
+ // const point = new fabric.Circle({
2402
+ // left: (data.points[0].x - data.radius) * scaleX,
2403
+ // top: (data.points[0].y - data.radius) * scaleY,
2404
+ // radius: data.radius * scaleX,
2405
+ // stroke: data.lineColor ? data.lineColor : _this.lineColor,
2406
+ // fill: data.lineColor ? data.lineColor : _this.lineColor,
2407
+ // strokeWidth: 0,
2408
+ // hoverCursor: 'default',
2409
+ // transparentCorners: false,
2410
+ // type: drawType.point,
2411
+ // id: data.id
2412
+ // })
2413
+
2414
+ if (_this.showDeleteIcon) {
2415
+ // 添加删除按钮
2416
+ point.controls.deleteControl = init_getDeleteControl(_this);
2417
+ }
2418
+ if (_this.showLabel && point.label && point.label !== '') {
2419
+ // 添加标签
2420
+ // point.controls.labelControl = getLabelControl(point.label)
2421
+ }
2422
+ point.setControlsVisibility({
2423
+ bl: false,
2424
+ br: false,
2425
+ mb: false,
2426
+ ml: false,
2427
+ mr: false,
2428
+ mt: false,
2429
+ tl: false,
2430
+ tr: false,
2431
+ mtr: false
2432
+ });
2433
+ _this.canvas.add(point);
2434
+ };
2435
+
2436
+ /**
2437
+ * 添加自由绘制线
2438
+ *
2439
+ * @author pangyafei
2440
+ * @date 2021-02-04
2441
+ * @param {any} _this
2442
+ * @param {any} data
2443
+ * @param {any} scaleX
2444
+ * @param {any} scaleY
2445
+ * @returns {any}
2446
+ */
2447
+ var data_addPath = function addPath(_this, data, scaleX, scaleY) {
2448
+ data.points.forEach(function (e) {
2449
+ if (e[0] === 'M') {
2450
+ e[1] *= scaleX;
2451
+ e[2] *= scaleY;
2452
+ } else if (e[0] === 'Q') {
2453
+ e[1] *= scaleX;
2454
+ e[2] *= scaleY;
2455
+ e[3] *= scaleX;
2456
+ e[4] *= scaleY;
2457
+ } else {
2458
+ // e[0] === 'L'
2459
+ e[1] *= scaleX;
2460
+ e[2] *= scaleY;
2461
+ }
2462
+ });
2463
+ var path = new external__fabric_["fabric"].Path(data.points, Object.assign(getBaseShapeInfo(data, _this), {
2464
+ scaleX: data.scaleX,
2465
+ scaleY: data.scaleY
2466
+ }));
2467
+ path.setControlVisible('mtr', false);
2468
+ if (_this.showDeleteIcon) {
2469
+ // 添加删除图标
2470
+ path.controls.deleteControl = init_getDeleteControl(_this);
2471
+ }
2472
+ if (_this.showLabel && path.label && path.label !== '') {
2473
+ // 添加标签
2474
+ // path.controls.labelControl = getLabelControl(path.label)
2475
+ }
2476
+ _this.canvas.add(path);
2477
+ };
2478
+
2479
+ /**
2480
+ * 向画布中添加文字
2481
+ *
2482
+ * @author pangyafei
2483
+ * @date 2021-02-02
2484
+ * @param {any} _this
2485
+ * @param {any} data
2486
+ * @param {any} scaleX
2487
+ * @param {any} scaleY
2488
+ * @returns {any}
2489
+ */
2490
+ var data_addTextbox = function addTextbox(_this, data, scaleX, scaleY) {
2491
+ // const maxX = Math.max(...data.points.map(p => p.x)) * scaleX
2492
+ var minX = Math.min.apply(Math, _toConsumableArray(data.points.map(function (p) {
2493
+ return p.x;
2494
+ }))) * scaleY;
2495
+ // const maxY = Math.max(...data.points.map(p => p.y)) * scaleX
2496
+ var minY = Math.min.apply(Math, _toConsumableArray(data.points.map(function (p) {
2497
+ return p.y;
2498
+ }))) * scaleY;
2499
+ var textbox = new external__fabric_["fabric"].Textbox('', Object.assign(getBaseShapeInfo(data, _this), {
2500
+ top: minY,
2501
+ left: minX,
2502
+ scaleX: data.scaleX,
2503
+ scaleY: data.scaleY,
2504
+ // width: maxX - minX,
2505
+ // height: maxY - minY,
2506
+ text: data.text,
2507
+ fontSize: data.fontSize,
2508
+ editable: false
2509
+ }));
2510
+ textbox.setControlVisible('mtr', false);
2511
+ if (_this.showDeleteIcon) {
2512
+ // 添加删除图标
2513
+ textbox.controls.deleteControl = init_getDeleteControl(_this);
2514
+ }
2515
+ if (_this.showLabel && textbox.label && textbox.label !== '') {
2516
+ // 添加标签
2517
+ // textbox.controls.labelControl = getLabelControl(textbox.label)
2518
+ }
2519
+ _this.canvas.add(textbox);
2520
+ };
2521
+
2522
+ /**
2523
+ * 构造渲染图形的基础配置信息
2524
+ *
2525
+ * @author pangyafei
2526
+ * @date 2021-01-19
2527
+ * @param {any} data
2528
+ * @returns {any}
2529
+ */
2530
+ var getBaseShapeInfo = function getBaseShapeInfo(data, _this) {
2531
+ return {
2532
+ id: data.id,
2533
+ label: data.label,
2534
+ description: data.description,
2535
+ type: data.type,
2536
+ objectCaching: false,
2537
+ fill: data.fillColor ? data.fillColor : _this.fillColor,
2538
+ stroke: data.lineColor ? data.lineColor : _this.lineColor,
2539
+ strokeWidth: data.lineWidth ? data.lineWidth : _this.lineWidth,
2540
+ hoverCursor: 'default',
2541
+ transparentCorners: false,
2542
+ strokeWidthUnscaled: data.lineWidth,
2543
+ top: data.top,
2544
+ left: data.left,
2545
+ labelFillColor: data.labelFillColor
2546
+ };
2547
+ };
2548
+
2549
+ /**
2550
+ * 获取canvas加载的图片信息
2551
+ *
2552
+ * @author pangyafei
2553
+ * @date 2021-03-08
2554
+ * @param {any} _this
2555
+ * @returns {any}
2556
+ */
2557
+ var data_getImageInfo = function getImageInfo(_this) {
2558
+ if (_this.canvas && _this.canvas.backgroundImage) {
2559
+ var image = _this.canvas.backgroundImage;
2560
+ var info = {
2561
+ width: image.width,
2562
+ height: image.height,
2563
+ scaleX: image.scaleX,
2564
+ scaleY: image.scaleY
2565
+ };
2566
+ return info;
2567
+ } else {
2568
+ return null;
2569
+ }
2570
+ };
2571
+ /**
2572
+ * @description:根据id删除图形
2573
+ * @author: miaochan
2574
+ * @date: 2023-05-31 11:36:43
2575
+ * @param:
2576
+ * @return:
2577
+ */
2578
+ var data_deleteShapeById = function deleteShapeById(_this, id) {
2579
+ var shapes = _this.canvas.getObjects();
2580
+ var shape = shapes.find(function (s) {
2581
+ return s.id === id;
2582
+ });
2583
+ if (shape) {
2584
+ _this.canvas.remove(shape);
2585
+ }
2586
+ };
2587
+ // CONCATENATED MODULE: ./src/components/labeler/function/load.js
2588
+
2589
+ // eslint-disable-next-line no-unused-vars
2590
+
2591
+ // eslint-disable-next-line no-unused-vars
2592
+
2593
+
2594
+ /**
2595
+ * 加载图片
2596
+ *
2597
+ * @author pangyafei
2598
+ * @date 2021-01-18
2599
+ * @param {any} _this
2600
+ * @param {any} src
2601
+ * @returns {any}
2602
+ */
2603
+ var load_load = function load(_this, src) {
2604
+ _this.image = new Image();
2605
+ _this.image.src = src;
2606
+ _this.image.setAttribute('crossOrigin', 'Anonymous'); // 解决图片跨域问题
2607
+ console.log(src);
2608
+ // const zoomPoint = new fabric.Point(0, 0)
2609
+ if (_this.canvas != null) {
2610
+ console.log('reload image');
2611
+ // _this.canvas.zoomToPoint(zoomPoint, 1)
2612
+ _this.image.onload = function () {
2613
+ _this.canvas.clear();
2614
+ // _this.canvas == null
2615
+ // _this.canvas.setZoom(1)
2616
+ var vpt = _this.canvas.viewportTransform;
2617
+ vpt[0] = 1;
2618
+ vpt[3] = 1;
2619
+ vpt[5] = 0;
2620
+ _this.canvas.setViewportTransform(vpt);
2621
+ resetMouseMove(_this);
2622
+ // initFabric(_this)
2623
+ _this.historyObjects = [];
2624
+ init_initBackgroundImage(_this);
2625
+ load_centerBackgroundImage(_this);
2626
+ };
2627
+ } else {
2628
+ console.log('init image');
2629
+ _this.image.onload = function () {
2630
+ init_initFabric(_this);
2631
+ // _this.canvas.zoomToPoint(zoomPoint, 1)
2632
+ load_centerBackgroundImage(_this);
2633
+ console.log('zoom', _this.canvas.viewportTransform);
2634
+ // _this.canvas.setZoom(1)
2635
+ };
2636
+ }
2637
+ };
2638
+
2639
+ /**
2640
+ * 如果是高比大于宽比的图片,做居中处理
2641
+ *
2642
+ * @author pangyafei
2643
+ * @date 2021-03-09
2644
+ * @param {any} _this
2645
+ * @returns {any}
2646
+ */
2647
+ var load_centerBackgroundImage = function centerBackgroundImage(_this) {
2648
+ var imageInfo = data_getImageInfo(_this);
2649
+ var imageCurrentWidth = imageInfo.width * imageInfo.scaleX;
2650
+ var imageCurrentHeight = imageInfo.height * imageInfo.scaleY;
2651
+ var canvasWidth = _this.canvas.width;
2652
+ var canvasHeight = _this.canvas.height;
2653
+ // console.log('-----')
2654
+ // console.log(imageCurrentWidth / canvasWidth)
2655
+ // console.log(imageCurrentHeight / canvasHeight)
2656
+ // console.log(_this.canvas.viewportTransform)
2657
+
2658
+ if (imageCurrentWidth / canvasWidth < imageCurrentHeight / canvasHeight) {
2659
+ var vpt = _this.canvas.viewportTransform;
2660
+ vpt[4] = (canvasWidth - imageCurrentWidth) / 2.0;
2661
+ vpt[5] = 0;
2662
+ _this.canvas.setViewportTransform(vpt);
2663
+ } else {
2664
+ var _vpt = _this.canvas.viewportTransform;
2665
+ _vpt[4] = 0;
2666
+ _vpt[5] = (canvasHeight - imageCurrentHeight) / 2.0;
2667
+ _this.canvas.setViewportTransform(_vpt);
2668
+ }
2669
+ };
2670
+ // EXTERNAL MODULE: external "shortid"
2671
+ var external__shortid_ = __webpack_require__(13);
2672
+ var external__shortid__default = /*#__PURE__*/__webpack_require__.n(external__shortid_);
2673
+
2674
+ // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/components/labeler/imageLabeler.vue
2675
+
2676
+ //
2677
+ //
2678
+ //
2679
+ //
2680
+ //
2681
+ //
2682
+ //
2683
+ //
2684
+ //
2685
+ //
2686
+ //
2687
+ //
2688
+
2689
+ // canvas初始化
2690
+
2691
+ // canvas绘制交互
2692
+
2693
+ // canvas数据交互
2694
+
2695
+ // canvas交互模式
2696
+
2697
+
2698
+ /* harmony default export */ var imageLabeler = ({
2699
+ name: 'SgLabeler',
2700
+ props: {
2701
+ // 图片资源路径
2702
+ src: {
2703
+ type: String,
2704
+ default: null
2705
+ },
2706
+ // 交互模式('edit' -> 编辑模式, 'view' -> 浏览模式)
2707
+ mode: {
2708
+ type: String,
2709
+ default: modeType.edit
2710
+ },
2711
+ // 画布宽
2712
+ width: {
2713
+ type: Number,
2714
+ default: null
2715
+ },
2716
+ // 画布高
2717
+ height: {
2718
+ type: Number,
2719
+ default: null
2720
+ },
2721
+ // 标注线颜色
2722
+ lineColor: {
2723
+ type: String,
2724
+ default: '#3e3e3e'
2725
+ },
2726
+ // 标注线宽
2727
+ lineWidth: {
2728
+ type: Number,
2729
+ default: 2
2730
+ },
2731
+ // 标注填充色
2732
+ fillColor: {
2733
+ type: String,
2734
+ default: '#cccccc66'
2735
+ },
2736
+ // 文字颜色
2737
+ fontColor: {
2738
+ type: String,
2739
+ default: '#333'
2740
+ },
2741
+ // 文字大小
2742
+ fontSize: {
2743
+ type: Number,
2744
+ default: 40
2745
+ },
2746
+ // 点半径
2747
+ pointRadius: {
2748
+ type: Number,
2749
+ default: 10
2750
+ },
2751
+ // 点是否随画布缩放
2752
+ pointZoom: {
2753
+ type: Boolean,
2754
+ default: true
2755
+ },
2756
+ // 点的边线宽度
2757
+ pointLineWidth: {
2758
+ type: Number,
2759
+ default: 2
2760
+ },
2761
+ // 点的边线颜色
2762
+ pointLineColor: {
2763
+ type: String,
2764
+ default: '#3e3e3e'
2765
+ },
2766
+ // 点的填充颜色
2767
+ pointFillColor: {
2768
+ type: String,
2769
+ default: '#333'
2770
+ },
2771
+ // 点是否开启准心线
2772
+ pointCrosshair: {
2773
+ type: Boolean,
2774
+ default: false
2775
+ },
2776
+ // 点准心线颜色
2777
+ pointCrosshairColor: {
2778
+ type: String,
2779
+ default: '#333'
2780
+ },
2781
+ // 点准心线宽度
2782
+ pointCrosshairWidth: {
2783
+ type: Number,
2784
+ default: 1
2785
+ },
2786
+ // 是否显示图形删除按钮
2787
+ showDeleteIcon: {
2788
+ type: Boolean,
2789
+ default: true
2790
+ },
2791
+ // 是否显示标签控件
2792
+ showLabel: {
2793
+ type: Boolean,
2794
+ default: true
2795
+ },
2796
+ // 标注标签名称
2797
+ label: {
2798
+ type: String,
2799
+ default: null
2800
+ },
2801
+ // 标注描述
2802
+ description: {
2803
+ type: String,
2804
+ default: null
2805
+ },
2806
+ // 组件背景色
2807
+ bgColor: {
2808
+ type: String,
2809
+ default: '#f5f5f5'
2810
+ },
2811
+ // 是否显示绘制辅助线
2812
+ showHelpLines: {
2813
+ type: Boolean,
2814
+ default: false
2815
+ }
2816
+ },
2817
+ data: function data() {
2818
+ return {
2819
+ id: 'canvas' + external__shortid__default.a.generate(),
2820
+ // 图片
2821
+ image: null,
2822
+ // 背景图片dom
2823
+ // 画布
2824
+ canvas: null,
2825
+ // fabric canvas
2826
+ // 图形参数
2827
+ drawingObject: null,
2828
+ // 正在绘制的图形
2829
+ drawingPoints: null,
2830
+ // 正在绘制的多边形点集
2831
+ virtualObject: null,
2832
+ // 正在绘制的多边形辅助线
2833
+ textObject: null,
2834
+ // 正在添加的文字
2835
+ mouseFrom: {},
2836
+ mouseTo: {},
2837
+ // 交互参数
2838
+ currentDrawType: null,
2839
+ // 当前正在绘制的图形类型
2840
+ isDrawing: false,
2841
+ // 当前是否开始绘制(startDraw -> true, stopDraw -> false)
2842
+ atDrawing: false,
2843
+ // 当前是否正在绘制(部分图形绘制需要按下鼠标拖动绘制,该参数记录鼠标已处于按下拖动绘制状态)
2844
+ atDragging: false,
2845
+ // 当前是否正在拖动画布
2846
+ historyObjects: [],
2847
+ // 被撤销的图形集合
2848
+ helpLines: null // 辅助线
2849
+ };
2850
+ },
2851
+ watch: {
2852
+ // 监听组件交互模式变化
2853
+ mode: {
2854
+ handler: function handler(val) {
2855
+ if (this.canvas != null) {
2856
+ if (val === modeType.edit) {
2857
+ this.canvas.skipTargetFind = false;
2858
+ } else {
2859
+ this.canvas.skipTargetFind = true;
2860
+ }
2861
+ }
2862
+ }
2863
+ },
2864
+ // 监听组件图片资源变化
2865
+ src: {
2866
+ handler: function handler(val) {
2867
+ load_load(this, val);
2868
+ }
2869
+ }
2870
+ },
2871
+ /**
2872
+ * 标注组件初始化
2873
+ *
2874
+ * @author pangyafei
2875
+ * @date 2021-01-18
2876
+ * @returns {any}
2877
+ */
2878
+ mounted: function mounted() {
2879
+ if (this.src != null) {
2880
+ load_load(this, this.src);
2881
+ } else {
2882
+ load_load(this, __webpack_require__(14));
2883
+ }
2884
+ },
2885
+ methods: {
2886
+ // ------------------------方法--------------------------
2887
+ // 开启绘制
2888
+ startDraw: function startDraw(type) {
2889
+ this.mode === modeType.edit ? draw_startDraw(this, type) : draw_notEditable();
2890
+ },
2891
+ // 停止绘制
2892
+ stopDraw: function stopDraw() {
2893
+ this.mode === modeType.edit ? draw_stopDraw(this) : draw_notEditable();
2894
+ },
2895
+ // 清空画布
2896
+ clearDraw: function clearDraw(id) {
2897
+ draw_clearDraw(this, id);
2898
+ },
2899
+ // 清除标注(根据id)
2900
+ clearDrawById: function clearDrawById(id) {
2901
+ this.mode === modeType.edit ? this.clearDraw(id) : draw_notEditable();
2902
+ },
2903
+ // 撤销
2904
+ undo: function undo() {
2905
+ this.mode === modeType.edit ? draw_undo(this) : draw_notEditable();
2906
+ },
2907
+ // 回退
2908
+ redo: function redo() {
2909
+ this.mode === modeType.edit ? draw_redo(this) : draw_notEditable();
2910
+ },
2911
+ // 获取数据(根据id获取)
2912
+ getData: function getData(id) {
2913
+ return data_getData(this, id);
2914
+ },
2915
+ // 获取数据(根据标签名称)
2916
+ getDataByLabel: function getDataByLabel(label) {
2917
+ return data_getData(this, null, label);
2918
+ },
2919
+ // 获取所有数据
2920
+ getAllData: function getAllData() {
2921
+ return data_getData(this);
2922
+ },
2923
+ // 设置数据
2924
+ setData: function setData(data) {
2925
+ data_setData(this, data);
2926
+ },
2927
+ // 添加数据
2928
+ addData: function addData(data) {
2929
+ data_setData(this, data, true);
2930
+ },
2931
+ // 获取图片信息
2932
+ getImageInfo: function getImageInfo() {
2933
+ return data_getImageInfo(this);
2934
+ },
2935
+ // 根据id删除形状
2936
+ deleteShapeById: function deleteShapeById(id) {
2937
+ data_deleteShapeById(this, id);
2938
+ },
2939
+ // 根据id设置形状的显隐状态
2940
+ setVisible: function setVisible(id, flag) {
2941
+ draw_setVisible(this, id, flag);
2942
+ },
2943
+ // 根据id设置形状的可选择状态
2944
+ setSelectable: function setSelectable(id, flag) {
2945
+ draw_setSelectable(this, id, flag);
2946
+ },
2947
+ // ------------------------回调--------------------------
2948
+ // 图片加载成功回调
2949
+ fireImageLoad: function fireImageLoad(info) {
2950
+ this.mode === this.$emit('onImageLoad', info);
2951
+ },
2952
+ // 绘制成功回调
2953
+ fireShapeDraw: function fireShapeDraw(shape) {
2954
+ this.$emit('onShapeDraw', shape);
2955
+ },
2956
+ // 图形删除回调
2957
+ fireShapeDelete: function fireShapeDelete(shape) {
2958
+ this.$emit('onShapeDelete', shape);
2959
+ },
2960
+ // 图形选择回调
2961
+ fireShapeSelect: function fireShapeSelect(shape) {
2962
+ this.$emit('onShapeSelect', shape);
2963
+ },
2964
+ // 图像移动完成回调
2965
+ fireShapeDrag: function fireShapeDrag(shape) {
2966
+ this.$emit('onShapeDrag', shape);
2967
+ },
2968
+ // 鼠标滚动回调,返回图片信息
2969
+ fireMouseWheel: function fireMouseWheel(info) {
2970
+ this.$emit('onMouseWheel', info);
2971
+ },
2972
+ // 背景图拖动回调事件
2973
+ fireBgImageDrag: function fireBgImageDrag(delta) {
2974
+ this.$emit('onBgImageDrag', delta);
2975
+ }
2976
+ }
2977
+ });
2978
+ // CONCATENATED MODULE: ./node_modules/babel-loader/lib?sourceMap!./node_modules/vue-loader/lib/template-compiler?{"id":"data-v-d3420bfc","hasScoped":true,"optionsId":"0","buble":{"transforms":{}}}!./node_modules/vue-loader/lib/selector.js?type=template&index=0!./src/components/labeler/imageLabeler.vue
2979
+ var imageLabeler_render = function render() {
2980
+ var _vm = this;
2981
+ var _h = _vm.$createElement;
2982
+ var _c = _vm._self._c || _h;
2983
+ return _c('div', {
2984
+ ref: "container",
2985
+ staticClass: "container",
2986
+ style: {
2987
+ 'background-color': _vm.bgColor
2988
+ }
2989
+ }, [_c('canvas', {
2990
+ ref: "canvas",
2991
+ staticClass: "canvas",
2992
+ attrs: {
2993
+ "id": _vm.id
2994
+ }
2995
+ })]);
2996
+ };
2997
+ var staticRenderFns = [];
2998
+
2999
+ // CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/component-normalizer.js
3000
+ /* globals __VUE_SSR_CONTEXT__ */
3001
+
3002
+ // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
3003
+ // This module is a runtime utility for cleaner component module output and will
3004
+ // be included in the final webpack user bundle.
3005
+
3006
+ function normalizeComponent (
3007
+ scriptExports,
3008
+ render,
3009
+ staticRenderFns,
3010
+ functionalTemplate,
3011
+ injectStyles,
3012
+ scopeId,
3013
+ moduleIdentifier, /* server only */
3014
+ shadowMode /* vue-cli only */
3015
+ ) {
3016
+ scriptExports = scriptExports || {}
3017
+
3018
+ // ES6 modules interop
3019
+ var type = typeof scriptExports.default
3020
+ if (type === 'object' || type === 'function') {
3021
+ scriptExports = scriptExports.default
3022
+ }
3023
+
3024
+ // Vue.extend constructor export interop
3025
+ var options = typeof scriptExports === 'function'
3026
+ ? scriptExports.options
3027
+ : scriptExports
3028
+
3029
+ // render functions
3030
+ if (render) {
3031
+ options.render = render
3032
+ options.staticRenderFns = staticRenderFns
3033
+ options._compiled = true
3034
+ }
3035
+
3036
+ // functional template
3037
+ if (functionalTemplate) {
3038
+ options.functional = true
3039
+ }
3040
+
3041
+ // scopedId
3042
+ if (scopeId) {
3043
+ options._scopeId = scopeId
3044
+ }
3045
+
3046
+ var hook
3047
+ if (moduleIdentifier) { // server build
3048
+ hook = function (context) {
3049
+ // 2.3 injection
3050
+ context =
3051
+ context || // cached call
3052
+ (this.$vnode && this.$vnode.ssrContext) || // stateful
3053
+ (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
3054
+ // 2.2 with runInNewContext: true
3055
+ if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
3056
+ context = __VUE_SSR_CONTEXT__
3057
+ }
3058
+ // inject component styles
3059
+ if (injectStyles) {
3060
+ injectStyles.call(this, context)
3061
+ }
3062
+ // register component module identifier for async chunk inferrence
3063
+ if (context && context._registeredComponents) {
3064
+ context._registeredComponents.add(moduleIdentifier)
3065
+ }
3066
+ }
3067
+ // used by ssr in case component is cached and beforeCreate
3068
+ // never gets called
3069
+ options._ssrRegister = hook
3070
+ } else if (injectStyles) {
3071
+ hook = shadowMode
3072
+ ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
3073
+ : injectStyles
3074
+ }
3075
+
3076
+ if (hook) {
3077
+ if (options.functional) {
3078
+ // for template-only hot-reload because in that case the render fn doesn't
3079
+ // go through the normalizer
3080
+ options._injectStyles = hook
3081
+ // register for functioal component in vue file
3082
+ var originalRender = options.render
3083
+ options.render = function renderWithStyleInjection (h, context) {
3084
+ hook.call(context)
3085
+ return originalRender(h, context)
3086
+ }
3087
+ } else {
3088
+ // inject component registration as beforeCreate hook
3089
+ var existing = options.beforeCreate
3090
+ options.beforeCreate = existing
3091
+ ? [].concat(existing, hook)
3092
+ : [hook]
3093
+ }
3094
+ }
3095
+
3096
+ return {
3097
+ exports: scriptExports,
3098
+ options: options
3099
+ }
3100
+ }
3101
+
3102
+ // CONCATENATED MODULE: ./src/components/labeler/imageLabeler.vue
3103
+ function injectStyle (context) {
3104
+ __webpack_require__(5)
3105
+ }
3106
+ /* script */
3107
+
3108
+
3109
+ /* template */
3110
+
3111
+ /* template functional */
3112
+ var __vue_template_functional__ = false
3113
+ /* styles */
3114
+ var __vue_styles__ = injectStyle
3115
+ /* scopeId */
3116
+ var __vue_scopeId__ = "data-v-d3420bfc"
3117
+ /* moduleIdentifier (server only) */
3118
+ var __vue_module_identifier__ = null
3119
+
3120
+ var Component = normalizeComponent(
3121
+ imageLabeler,
3122
+ imageLabeler_render,
3123
+ staticRenderFns,
3124
+ __vue_template_functional__,
3125
+ __vue_styles__,
3126
+ __vue_scopeId__,
3127
+ __vue_module_identifier__
3128
+ )
3129
+
3130
+ /* harmony default export */ var labeler_imageLabeler = (Component.exports);
3131
+
3132
+ // CONCATENATED MODULE: ./src/components/labeler/index.js
3133
+
3134
+ /* harmony default export */ var labeler = __webpack_exports__["default"] = (labeler_imageLabeler);
3135
+
3136
+ /***/ }),
3137
+ /* 5 */
3138
+ /***/ (function(module, exports) {
3139
+
3140
+ // removed by extract-text-webpack-plugin
3141
+
3142
+ /***/ }),
3143
+ /* 6 */
3144
+ /***/ (function(module, exports) {
3145
+
3146
+ module.exports = require("core-js/modules/es6.number.constructor");
3147
+
3148
+ /***/ }),
3149
+ /* 7 */
3150
+ /***/ (function(module, exports) {
3151
+
3152
+ module.exports = require("core-js/modules/es6.array.find");
3153
+
3154
+ /***/ }),
3155
+ /* 8 */
3156
+ /***/ (function(module, exports) {
3157
+
3158
+ module.exports = require("lodash.clonedeep");
3159
+
3160
+ /***/ }),
3161
+ /* 9 */
3162
+ /***/ (function(module, exports) {
3163
+
3164
+ module.exports = require("core-js/modules/es6.math.sign");
3165
+
3166
+ /***/ }),
3167
+ /* 10 */
3168
+ /***/ (function(module, exports) {
3169
+
3170
+ module.exports = require("core-js/modules/es7.array.includes");
3171
+
3172
+ /***/ }),
3173
+ /* 11 */
3174
+ /***/ (function(module, exports) {
3175
+
3176
+ module.exports = require("core-js/modules/es6.string.includes");
3177
+
3178
+ /***/ }),
3179
+ /* 12 */
3180
+ /***/ (function(module, exports) {
3181
+
3182
+ module.exports = require("core-js/modules/es6.regexp.to-string");
3183
+
3184
+ /***/ }),
3185
+ /* 13 */
3186
+ /***/ (function(module, exports) {
3187
+
3188
+ module.exports = require("shortid");
3189
+
3190
+ /***/ }),
3191
+ /* 14 */
3192
+ /***/ (function(module, exports, __webpack_require__) {
3193
+
3194
+ module.exports = __webpack_require__.p + "24fb23bb518c44e106570789bdf4a9c0.png";
3195
+
3196
+ /***/ })
3197
+ /******/ ]);