lost-sia 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import React, { Component, useEffect, useState, useRef } from 'react';
2
- import { Dropdown, Ref, Popup, Header, Menu, Dimmer, Message, Divider, List, Button, TextArea, Form, Label, Icon, Card, Image, Loader } from 'semantic-ui-react';
2
+ import { Dropdown, Ref, Popup, Header, Menu, Dimmer, Message, Divider, List, Button, TextArea, Form, Label, Icon, Card, Image, Loader, Checkbox } from 'semantic-ui-react';
3
3
  import _ from 'lodash';
4
4
  import reactDom from 'react-dom';
5
5
 
@@ -102,6 +102,18 @@ function toBackend(data, svg, type) {
102
102
  }
103
103
  }
104
104
 
105
+ function getMinMaxPoints(data) {
106
+ var xList = data.map(function (e) {
107
+ return e.x;
108
+ });
109
+ var yList = data.map(function (e) {
110
+ return e.y;
111
+ });
112
+ var minPoint = { x: Math.min.apply(Math, _toConsumableArray(xList)), y: Math.min.apply(Math, _toConsumableArray(yList)) };
113
+ var maxPoint = { x: Math.max.apply(Math, _toConsumableArray(xList)), y: Math.max.apply(Math, _toConsumableArray(yList)) };
114
+ return [minPoint, maxPoint];
115
+ }
116
+
105
117
  /**
106
118
  * Get area relative to the image
107
119
  *
@@ -146,6 +158,51 @@ function move(data, movementX, movementY) {
146
158
  });
147
159
  }
148
160
 
161
+ function getBox(data, type) {
162
+
163
+ switch (type) {
164
+ case 'bBox':
165
+ return data;
166
+ case 'point':
167
+ case 'line':
168
+ case 'polygon':
169
+ var maxX = 0;
170
+ var maxY = 0;
171
+ var minX = Infinity;
172
+ var minY = Infinity;
173
+ data.forEach(function (el) {
174
+ if (el.x > maxX) maxX = el.x;
175
+ if (el.y > maxY) maxY = el.y;
176
+ if (el.x < minX) minX = el.x;
177
+ if (el.y < minY) minY = el.y;
178
+ });
179
+ return [{ x: minX, y: minY }, { x: maxX, y: minY }, { x: minX, y: maxY }, { x: maxX, y: maxY }];
180
+ default:
181
+ break;
182
+
183
+ }
184
+ }
185
+
186
+ function getCenter(data, type) {
187
+ var box = undefined;
188
+ switch (type) {
189
+ case 'point':
190
+ return data[0];
191
+ case 'line':
192
+ case 'polygon':
193
+ case 'bBox':
194
+ box = getBox(data, type);
195
+ var w = box[1].x - box[0].x;
196
+ var h = box[3].y - box[0].y;
197
+ return {
198
+ x: box[0].x + w / 2.0,
199
+ y: box[0].y + h / 2.0
200
+ };
201
+ default:
202
+
203
+ }
204
+ }
205
+
149
206
  /**
150
207
  * Get point that is closest to the left browser side.
151
208
  *
@@ -218,6 +275,55 @@ function correctAnnotation(data, image, imageOffset) {
218
275
  return corrected;
219
276
  }
220
277
 
278
+ /**
279
+ * Rotate annotation around center.
280
+ * @param {*} data list of points {x:int,y:int}
281
+ * @param {*} center Center to rotate point
282
+ * @param {*} angle Rotation angle
283
+ */
284
+ function rotateAnnotation(data, center, angle) {
285
+ angle = angle * (Math.PI / 180); // Convert to radians
286
+ var rotated = data.map(function (point) {
287
+ return {
288
+ x: Math.round(Math.cos(angle) * (point.x - center.x) - Math.sin(angle) * (point.y - center.y) + center.x),
289
+ y: Math.round(Math.sin(angle) * (point.x - center.x) + Math.cos(angle) * (point.y - center.y) + center.y)
290
+ };
291
+ });
292
+ return rotated;
293
+ }
294
+
295
+ /**
296
+ * Resize annotation data in canvas format to new image size
297
+ * @param {*} data Annotation data in canvas format [{x:int, y:int},...]
298
+ * @param {*} sizeOld Size of old image {width:int, height:int}
299
+ * @param {*} sizeNew Size of new image {width:int, height:int}
300
+ */
301
+ function resizeAnnoData(data, sizeOld, sizeNew) {
302
+ var xRatio = sizeNew.width / sizeOld.width;
303
+ var yRatio = sizeNew.height / sizeOld.height;
304
+ return data.map(function (e) {
305
+ return {
306
+ x: parseInt(e.x * xRatio),
307
+ y: parseInt(e.y * yRatio)
308
+ };
309
+ });
310
+ }
311
+
312
+ var transform = /*#__PURE__*/Object.freeze({
313
+ toSia: toSia,
314
+ toBackend: toBackend,
315
+ getMinMaxPoints: getMinMaxPoints,
316
+ getArea: getArea,
317
+ move: move,
318
+ getBox: getBox,
319
+ getCenter: getCenter,
320
+ getMostLeftPoint: getMostLeftPoint,
321
+ getTopPoint: getTopPoint,
322
+ correctAnnotation: correctAnnotation,
323
+ rotateAnnotation: rotateAnnotation,
324
+ resizeAnnoData: resizeAnnoData
325
+ });
326
+
221
327
  var VIEW = 'view';
222
328
  var EDIT = 'edit';
223
329
  var CREATE = 'create';
@@ -889,6 +995,31 @@ var CANVAS_IMGBAR_CLOSE = 'canvasImgbarClose';
889
995
  //Image actions
890
996
  var IMG_LABEL_UPDATE = 'imgLabelUpdate';
891
997
 
998
+ var canvasActions = /*#__PURE__*/Object.freeze({
999
+ ANNO_DELETED: ANNO_DELETED,
1000
+ ANNO_SELECTED: ANNO_SELECTED,
1001
+ ANNO_CREATED: ANNO_CREATED,
1002
+ ANNO_MOVED: ANNO_MOVED,
1003
+ ANNO_ENTER_MOVE_MODE: ANNO_ENTER_MOVE_MODE,
1004
+ ANNO_EDITED: ANNO_EDITED,
1005
+ ANNO_ENTER_EDIT_MODE: ANNO_ENTER_EDIT_MODE,
1006
+ ANNO_ADDED_NODE: ANNO_ADDED_NODE,
1007
+ ANNO_REMOVED_NODE: ANNO_REMOVED_NODE,
1008
+ ANNO_LABEL_UPDATE: ANNO_LABEL_UPDATE,
1009
+ ANNO_CREATED_NODE: ANNO_CREATED_NODE,
1010
+ ANNO_CREATED_FINAL_NODE: ANNO_CREATED_FINAL_NODE,
1011
+ ANNO_START_CREATING: ANNO_START_CREATING,
1012
+ ANNO_COMMENT_UPDATE: ANNO_COMMENT_UPDATE,
1013
+ ANNO_MARK_EXAMPLE: ANNO_MARK_EXAMPLE,
1014
+ CANVAS_SVG_UPDATE: CANVAS_SVG_UPDATE,
1015
+ CANVAS_UI_CONFIG_UPDATE: CANVAS_UI_CONFIG_UPDATE,
1016
+ CANVAS_AUTO_SAVE: CANVAS_AUTO_SAVE,
1017
+ CANVAS_LABEL_INPUT_CLOSE: CANVAS_LABEL_INPUT_CLOSE,
1018
+ CANVAS_IMG_LOADED: CANVAS_IMG_LOADED,
1019
+ CANVAS_IMGBAR_CLOSE: CANVAS_IMGBAR_CLOSE,
1020
+ IMG_LABEL_UPDATE: IMG_LABEL_UPDATE
1021
+ });
1022
+
892
1023
  var _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
893
1024
 
894
1025
  var _createClass$3 = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -3538,6 +3669,12 @@ function canvasToBackendAnnos(annos, imgSize) {
3538
3669
  return backendFormat;
3539
3670
  }
3540
3671
 
3672
+ var annoConversion = /*#__PURE__*/Object.freeze({
3673
+ fixBackendAnnos: fixBackendAnnos,
3674
+ backendAnnosToCanvas: backendAnnosToCanvas,
3675
+ canvasToBackendAnnos: canvasToBackendAnnos
3676
+ });
3677
+
3541
3678
  var _createClass$e = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
3542
3679
 
3543
3680
  function _classCallCheck$e(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -3660,6 +3797,15 @@ var KeyMapper = function () {
3660
3797
 
3661
3798
  var POINT = 'point';
3662
3799
  var BBOX = 'bBox';
3800
+ var LINE = 'line';
3801
+ var POLYGON = 'polygon';
3802
+
3803
+ var tools = /*#__PURE__*/Object.freeze({
3804
+ POINT: POINT,
3805
+ BBOX: BBOX,
3806
+ LINE: LINE,
3807
+ POLYGON: POLYGON
3808
+ });
3663
3809
 
3664
3810
  var _createClass$f = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
3665
3811
 
@@ -6854,6 +7000,11 @@ function _inherits$g(subClass, superClass) { if (typeof superClass !== "function
6854
7000
  * action -> CANVAS_IMG_LOADED
6855
7001
  * action -> CANVAS_IMGBAR_CLOSE
6856
7002
  * @event onImgBarClose - Fires when close button on ImgBar was hit.
7003
+ * @event onGetFunction - Get special canvas functions for manipulation from outside canvas
7004
+ * deleteAllAnnos()
7005
+ * unloadImage()
7006
+ * resetZoom()
7007
+ * getAnnos(annos,removeFrontendIds)
6857
7008
  */
6858
7009
 
6859
7010
  var Canvas = function (_Component) {
@@ -8530,5 +8681,1497 @@ var Canvas = function (_Component) {
8530
8681
  return Canvas;
8531
8682
  }(Component);
8532
8683
 
8533
- export default Canvas;
8684
+ var TOOL_SELECTED = 'toolSelected';
8685
+ var GET_NEXT_IMAGE = 'getNextImage';
8686
+ var GET_PREV_IMAGE = 'getPrevImage';
8687
+ var TASK_FINISHED = 'taskFinished';
8688
+ var SHOW_IMAGE_LABEL_INPUT = 'showImageLabelInput';
8689
+ var IMG_IS_JUNK = 'imageIsJunk';
8690
+ var DELETE_ALL_ANNOS = 'deleteAllAnnos';
8691
+ var SET_FULLSCREEN = 'setFullscreen';
8692
+ var SHOW_ANNO_DETAILS = 'showAnnoDetails';
8693
+ var SHOW_LABEL_INFO = 'showLabelInfo';
8694
+ var SHOW_ANNO_STATS = 'showAnnoStats';
8695
+ var EDIT_STROKE_WIDTH = 'editStrokeWidth';
8696
+ var EDIT_NODE_RADIUS = 'editNodeRadius';
8697
+ var APPLY_FILTER = 'applyFilter';
8698
+ var SAVE = 'save';
8699
+
8700
+ var toolbarEvents = /*#__PURE__*/Object.freeze({
8701
+ TOOL_SELECTED: TOOL_SELECTED,
8702
+ GET_NEXT_IMAGE: GET_NEXT_IMAGE,
8703
+ GET_PREV_IMAGE: GET_PREV_IMAGE,
8704
+ TASK_FINISHED: TASK_FINISHED,
8705
+ SHOW_IMAGE_LABEL_INPUT: SHOW_IMAGE_LABEL_INPUT,
8706
+ IMG_IS_JUNK: IMG_IS_JUNK,
8707
+ DELETE_ALL_ANNOS: DELETE_ALL_ANNOS,
8708
+ SET_FULLSCREEN: SET_FULLSCREEN,
8709
+ SHOW_ANNO_DETAILS: SHOW_ANNO_DETAILS,
8710
+ SHOW_LABEL_INFO: SHOW_LABEL_INFO,
8711
+ SHOW_ANNO_STATS: SHOW_ANNO_STATS,
8712
+ EDIT_STROKE_WIDTH: EDIT_STROKE_WIDTH,
8713
+ EDIT_NODE_RADIUS: EDIT_NODE_RADIUS,
8714
+ APPLY_FILTER: APPLY_FILTER,
8715
+ SAVE: SAVE
8716
+ });
8717
+
8718
+ var _createClass$j = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8719
+
8720
+ function _classCallCheck$j(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8721
+
8722
+ function _possibleConstructorReturn$h(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8723
+
8724
+ function _inherits$h(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
8725
+
8726
+ var SIASettingButton = function (_Component) {
8727
+ _inherits$h(SIASettingButton, _Component);
8728
+
8729
+ function SIASettingButton(props) {
8730
+ _classCallCheck$j(this, SIASettingButton);
8731
+
8732
+ var _this = _possibleConstructorReturn$h(this, (SIASettingButton.__proto__ || Object.getPrototypeOf(SIASettingButton)).call(this, props));
8733
+
8734
+ _this.state = {};
8735
+ return _this;
8736
+ }
8737
+
8738
+ _createClass$j(SIASettingButton, [{
8739
+ key: 'triggerEvent',
8740
+ value: function triggerEvent(e, data) {
8741
+ if (this.props.onSettingEvent) {
8742
+ this.props.onSettingEvent(e, data);
8743
+ }
8744
+ }
8745
+ }, {
8746
+ key: 'toggleAnnoDetails',
8747
+ value: function toggleAnnoDetails() {
8748
+ this.triggerEvent(SHOW_ANNO_DETAILS);
8749
+ }
8750
+ }, {
8751
+ key: 'toggleLabelInfo',
8752
+ value: function toggleLabelInfo() {
8753
+ this.triggerEvent(SHOW_LABEL_INFO);
8754
+ }
8755
+ }, {
8756
+ key: 'toggleAnnoStats',
8757
+ value: function toggleAnnoStats() {
8758
+ this.triggerEvent(SHOW_ANNO_STATS);
8759
+ }
8760
+ }, {
8761
+ key: 'handleStrokeWidthChange',
8762
+ value: function handleStrokeWidthChange(e) {
8763
+ this.triggerEvent(EDIT_STROKE_WIDTH, parseInt(e.target.value));
8764
+ }
8765
+ }, {
8766
+ key: 'handleNodeRadiusChange',
8767
+ value: function handleNodeRadiusChange(e) {
8768
+ this.triggerEvent(EDIT_NODE_RADIUS, parseInt(e.target.value));
8769
+ }
8770
+ }, {
8771
+ key: 'renderInfoBoxContent',
8772
+ value: function renderInfoBoxContent() {
8773
+ var _this2 = this;
8774
+
8775
+ return React.createElement(
8776
+ 'div',
8777
+ null,
8778
+ React.createElement(
8779
+ Divider,
8780
+ { horizontal: true },
8781
+ 'Info Boxes'
8782
+ ),
8783
+ React.createElement(Checkbox, {
8784
+ checked: this.props.uiConfig.annoDetails.visible,
8785
+ label: 'Annotation Details', toggle: true,
8786
+ onClick: function onClick() {
8787
+ return _this2.toggleAnnoDetails();
8788
+ }
8789
+ }),
8790
+ React.createElement(Checkbox, {
8791
+ checked: this.props.uiConfig.labelInfo.visible,
8792
+ label: 'Label Info', toggle: true,
8793
+ onClick: function onClick() {
8794
+ return _this2.toggleLabelInfo();
8795
+ }
8796
+ }),
8797
+ React.createElement(Checkbox, {
8798
+ checked: this.props.uiConfig.annoStats.visible,
8799
+ label: 'Anno Stats', toggle: true,
8800
+ onClick: function onClick() {
8801
+ return _this2.toggleAnnoStats();
8802
+ }
8803
+ })
8804
+ );
8805
+ }
8806
+ }, {
8807
+ key: 'renderInfoBoxes',
8808
+ value: function renderInfoBoxes() {
8809
+ if (!this.props.enabled) return null;
8810
+ if (this.props.enabled == true) {
8811
+ return this.renderInfoBoxContent();
8812
+ } else {
8813
+ if (this.props.enabled.infoBoxes) {
8814
+ return this.renderInfoBoxContent();
8815
+ }
8816
+ }
8817
+ }
8818
+ }, {
8819
+ key: 'renderAnnoStyle',
8820
+ value: function renderAnnoStyle() {
8821
+ if (!this.props.enabled) return null;
8822
+ if (this.props.enabled == true) {
8823
+ return this.renderAnnoStyleContent();
8824
+ } else {
8825
+ if (this.props.enabled.annoStyle) {
8826
+ return this.renderAnnoStyleContent();
8827
+ }
8828
+ }
8829
+ }
8830
+ }, {
8831
+ key: 'renderAnnoStyleContent',
8832
+ value: function renderAnnoStyleContent() {
8833
+ var _this3 = this;
8834
+
8835
+ return React.createElement(
8836
+ 'div',
8837
+ null,
8838
+ React.createElement(
8839
+ Divider,
8840
+ { horizontal: true },
8841
+ 'Anno Appearance'
8842
+ ),
8843
+ React.createElement(
8844
+ 'div',
8845
+ null,
8846
+ 'Stroke width: ',
8847
+ this.props.uiConfig.strokeWidth
8848
+ ),
8849
+ React.createElement('input', {
8850
+ type: 'range',
8851
+ min: 1,
8852
+ max: 10,
8853
+ value: this.props.uiConfig.strokeWidth,
8854
+ onChange: function onChange(e) {
8855
+ return _this3.handleStrokeWidthChange(e);
8856
+ }
8857
+ }),
8858
+ React.createElement(
8859
+ 'div',
8860
+ null,
8861
+ 'Node radius: ',
8862
+ this.props.uiConfig.nodeRadius
8863
+ ),
8864
+ React.createElement('input', {
8865
+ type: 'range',
8866
+ min: 1,
8867
+ max: 10,
8868
+ value: this.props.uiConfig.nodeRadius,
8869
+ onChange: function onChange(e) {
8870
+ return _this3.handleNodeRadiusChange(e);
8871
+ }
8872
+ })
8873
+ );
8874
+ }
8875
+ }, {
8876
+ key: 'render',
8877
+ value: function render() {
8878
+
8879
+ if (!this.props.uiConfig) return null;
8880
+ var popupContent = React.createElement(
8881
+ 'div',
8882
+ null,
8883
+ this.renderInfoBoxes(),
8884
+ this.renderAnnoStyle()
8885
+ );
8886
+ return React.createElement(Popup, { trigger: React.createElement(
8887
+ Menu.Item,
8888
+ { name: 'setting' },
8889
+ React.createElement(Icon, { name: 'setting' })
8890
+ ),
8891
+ content: popupContent,
8892
+ position: "right center",
8893
+ pinned: true,
8894
+ on: 'click',
8895
+ style: { zIndex: 7000 }
8896
+ });
8897
+ }
8898
+ }]);
8899
+
8900
+ return SIASettingButton;
8901
+ }(Component);
8902
+
8903
+ function active(filter) {
8904
+ return filter.clahe.active || filter.rotate.active;
8905
+ }
8906
+
8907
+ var _extends$c = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
8908
+
8909
+ var _createClass$k = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8910
+
8911
+ function _classCallCheck$k(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8912
+
8913
+ function _possibleConstructorReturn$i(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8914
+
8915
+ function _inherits$i(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
8916
+
8917
+ var SIAFilterButton = function (_Component) {
8918
+ _inherits$i(SIAFilterButton, _Component);
8919
+
8920
+ function SIAFilterButton(props) {
8921
+ _classCallCheck$k(this, SIAFilterButton);
8922
+
8923
+ var _this = _possibleConstructorReturn$i(this, (SIAFilterButton.__proto__ || Object.getPrototypeOf(SIAFilterButton)).call(this, props));
8924
+
8925
+ _this.state = {
8926
+ clipLimit: 3,
8927
+ active: false,
8928
+ color: undefined
8929
+ };
8930
+ return _this;
8931
+ }
8932
+
8933
+ _createClass$k(SIAFilterButton, [{
8934
+ key: 'componentDidUpdate',
8935
+ value: function componentDidUpdate(prevProps) {
8936
+ if (prevProps.filter.clahe.clipLimit !== this.props.filter.clahe.clipLimit) {
8937
+ this.setState({ clipLimit: this.props.filter.clahe.clipLimit });
8938
+ }
8939
+ if (this.props.filter !== prevProps.filter) {
8940
+ if (active(this.props.filter)) {
8941
+ this.setState({ color: 'red', active: true });
8942
+ } else {
8943
+ this.setState({ color: 'white', active: false });
8944
+ }
8945
+ }
8946
+ }
8947
+ }, {
8948
+ key: 'triggerEvent',
8949
+ value: function triggerEvent(e, data) {
8950
+ if (this.props.onFilterEvent) {
8951
+ this.props.onFilterEvent(e, data);
8952
+ }
8953
+ }
8954
+ }, {
8955
+ key: 'handleClipLimitChange',
8956
+ value: function handleClipLimitChange(e) {
8957
+ var cl = parseInt(e.target.value);
8958
+ this.setState({ clipLimit: cl });
8959
+ // this.claheFilter(cl)
8960
+ }
8961
+ }, {
8962
+ key: 'rotateImg',
8963
+ value: function rotateImg(angle) {
8964
+ var active$$1 = !(this.props.filter.rotate.active && this.props.filter.rotate.angle === angle);
8965
+ var myAngle = active$$1 ? angle : 0;
8966
+ this.triggerEvent(APPLY_FILTER, _extends$c({}, this.props.filter, {
8967
+ rotate: { angle: myAngle, active: active$$1 }
8968
+ }));
8969
+
8970
+ // this.props.siaApplyFilter({
8971
+ // ...this.props.filter,
8972
+ // rotate: {angle:myAngle, active:active}
8973
+ // })
8974
+ }
8975
+ }, {
8976
+ key: 'claheFilter',
8977
+ value: function claheFilter(clipLimit) {
8978
+ var filter = {
8979
+ 'clahe': {
8980
+ 'clipLimit': clipLimit,
8981
+ active: !this.props.filter.clahe.active
8982
+ }
8983
+ };
8984
+ this.triggerEvent(APPLY_FILTER, _extends$c({}, this.props.filter, {
8985
+ clahe: filter.clahe
8986
+ }));
8987
+ // this.props.siaApplyFilter({
8988
+ // ...this.props.filter,
8989
+ // clahe: filter.clahe
8990
+ // })
8991
+ }
8992
+ }, {
8993
+ key: 'releaseCLAHESlider',
8994
+ value: function releaseCLAHESlider(e) {
8995
+ var filter = {
8996
+ 'clahe': {
8997
+ 'clipLimit': parseInt(e.target.value),
8998
+ active: true
8999
+ }
9000
+ };
9001
+ this.triggerEvent(APPLY_FILTER, _extends$c({}, this.props.filter, {
9002
+ clahe: filter.clahe
9003
+ }));
9004
+ // this.props.siaApplyFilter({
9005
+ // ...this.props.filter,
9006
+ // clahe: filter.clahe
9007
+ // })
9008
+ }
9009
+ }, {
9010
+ key: 'renderRotateContent',
9011
+ value: function renderRotateContent() {
9012
+ var _this2 = this;
9013
+
9014
+ var filter = this.props.filter;
9015
+ return React.createElement(
9016
+ 'div',
9017
+ null,
9018
+ React.createElement(
9019
+ Divider,
9020
+ { horizontal: true },
9021
+ 'Rotate'
9022
+ ),
9023
+ React.createElement(Checkbox, {
9024
+ checked: filter.rotate.active && filter.rotate.angle === 90,
9025
+ label: 'Rotate 90', toggle: true,
9026
+ onClick: function onClick() {
9027
+ return _this2.rotateImg(90);
9028
+ }
9029
+ }),
9030
+ React.createElement(Checkbox, {
9031
+ checked: filter.rotate.active && filter.rotate.angle === -90,
9032
+ label: 'Rotate -90', toggle: true,
9033
+ onClick: function onClick() {
9034
+ return _this2.rotateImg(-90);
9035
+ }
9036
+ }),
9037
+ React.createElement(Checkbox, {
9038
+ checked: filter.rotate.active && filter.rotate.angle === 180,
9039
+ label: 'Rotate 180', toggle: true,
9040
+ onClick: function onClick() {
9041
+ return _this2.rotateImg(180);
9042
+ }
9043
+ })
9044
+ );
9045
+ }
9046
+ }, {
9047
+ key: 'renderRotate',
9048
+ value: function renderRotate() {
9049
+ if (!this.props.enabled) return null;
9050
+ if (this.props.enabled === true) {
9051
+ return this.renderRotateContent();
9052
+ } else {
9053
+ if (this.props.enabled.rotate) {
9054
+ return this.renderRotateContent();
9055
+ }
9056
+ }
9057
+ }
9058
+ }, {
9059
+ key: 'renderClaheContent',
9060
+ value: function renderClaheContent() {
9061
+ var _this3 = this;
9062
+
9063
+ var filter = this.props.filter;
9064
+ return React.createElement(
9065
+ 'div',
9066
+ null,
9067
+ React.createElement(
9068
+ Divider,
9069
+ { horizontal: true },
9070
+ 'Histogram equalization'
9071
+ ),
9072
+ React.createElement(Checkbox, {
9073
+ checked: filter.clahe.active,
9074
+ label: 'Histogram equalization', toggle: true,
9075
+ onClick: function onClick() {
9076
+ return _this3.claheFilter(_this3.state.clipLimit);
9077
+ }
9078
+ }),
9079
+ React.createElement(
9080
+ 'div',
9081
+ null,
9082
+ 'Cliplimit: ',
9083
+ this.state.clipLimit
9084
+ ),
9085
+ React.createElement('input', {
9086
+ type: 'range',
9087
+ min: 0,
9088
+ max: 40,
9089
+ value: this.state.clipLimit,
9090
+ onChange: function onChange(e) {
9091
+ return _this3.handleClipLimitChange(e);
9092
+ },
9093
+ onMouseUp: function onMouseUp(e) {
9094
+ return _this3.releaseCLAHESlider(e);
9095
+ }
9096
+ })
9097
+ );
9098
+ }
9099
+ }, {
9100
+ key: 'renderClahe',
9101
+ value: function renderClahe() {
9102
+ if (!this.props.enabled) return null;
9103
+ if (this.props.enabled === true) {
9104
+ return this.renderClaheContent();
9105
+ } else {
9106
+ if (this.props.enabled.clahe) {
9107
+ return this.renderClaheContent();
9108
+ }
9109
+ }
9110
+ }
9111
+ }, {
9112
+ key: 'render',
9113
+ value: function render() {
9114
+ if (!this.props.imageMeta) return null;
9115
+ var popupContent = React.createElement(
9116
+ 'div',
9117
+ null,
9118
+ this.renderRotate(),
9119
+ this.renderClahe()
9120
+ );
9121
+ return React.createElement(Popup, { trigger: React.createElement(
9122
+ Menu.Item,
9123
+ { name: 'filter', active: this.state.active },
9124
+ React.createElement(Icon, { name: 'filter', color: this.state.color })
9125
+ ),
9126
+ content: popupContent,
9127
+ position: "right center",
9128
+ pinned: true,
9129
+ on: 'click',
9130
+ style: { zIndex: 7000 }
9131
+ });
9132
+ }
9133
+ }]);
9134
+
9135
+ return SIAFilterButton;
9136
+ }(Component);
9137
+
9138
+ function textIcon() {
9139
+ return React.createElement(
9140
+ "svg",
9141
+ { version: "1.1", xmlns: "http://www.w3.org/2000/svg"
9142
+ // x="0px" y="0px"
9143
+ // width="1190.549px" height="841.891px"
9144
+ , viewBox: "0 0 1190.549 841.891",
9145
+ width: "17px"
9146
+ // onClick={e => this.handleClick(e)}
9147
+ },
9148
+ React.createElement("path", { id: "T", fillRule: "evenodd", clipRule: "evenodd", fill: "currentColor", d: "M925.876,172.939c-0.172-13.004,0.161-26.013,0.116-39.019 c-0.021-4.017-5.046-9.053-9.037-9.087c-7.948-0.068-15.897-0.051-23.848-0.051c-73.526,0.006-147.051,0.02-220.578,0.032 c-8.095,0.001-11.969,3.776-11.969,11.742c-0.009,154.998-0.009,309.997-0.009,464.998c0,44.257-0.002,88.519,0.009,132.778 c0,7.553,4.173,11.736,11.651,11.747c21.677,0.018,30.288-0.227,65.032,0.018c34.743,0.239,46.295,27.955,46.295,46.43 c-0.005,18.477-13.856,42.722-46.792,43.747c-42.993,0.197-85.989-0.057-128.979-0.05c-47.697,0.014-95.387,0.009-143.078,0.074 c-13.712-0.278-44.888-9.133-44.888-44.159c0-35.025,20.399-44.646,42.975-46.192c16.293,0.115,45.164,0.179,67.743,0.16 c5.553-0.006,10.175-5.03,10.178-11.005c0.008-45.524-0.016-91.049-0.018-136.569c0-99.001,0-197.997,0.008-296.994 c0.001-55.278,0.018-110.559,0.007-165.837c0-6.513-4.521-10.917-11.118-10.917c-81.116-0.005-162.229-0.005-243.34-0.001 c-6.977,0-11.061,3.995-11.069,10.825c-0.016,12.286-0.033,24.569,0.019,36.855c-0.076,20.742-10.042,43.007-40.763,43.007 c-30.724,0-46.917-15.208-48.805-43.296c-0.419-14.084,0.01-28.181,0.01-42.272c0-27.46,0-54.917,0-82.379 c0-1.048,0.747-16.871,13.391-30.357c12.642-13.485,26.225-12.505,27.633-12.505c84.544,0.015,169.091,0.009,253.635,0.009 c153.191,0.001,459.578,0.004,459.578,0.004s20.149-0.287,35.766-0.17c0.983-0.023,18.696,1.188,30.027,13.07 c11.333,11.885,9.972,27.513,9.972,28.256c-0.024,42.091,0.255,84.183-0.007,126.274c-0.247,26.341-22.705,41.944-44.85,42.037 C948.049,214.236,926.687,199.643,925.876,172.939z" })
9149
+ );
9150
+ }
9151
+
9152
+ function lineIcon() {
9153
+ return React.createElement(
9154
+ "svg",
9155
+ { version: "1.1", id: "Linie", xmlns: "http://www.w3.org/2000/svg"
9156
+ // xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
9157
+ // width="1190.549px" height="841.891px"
9158
+ , viewBox: "0 0 1190.549 841.891",
9159
+ width: "17px"
9160
+ // enable-background="new 0 0 1190.549 841.891"
9161
+ // xml:space="preserve"
9162
+ },
9163
+ React.createElement("path", { fill: "currentColor", d: "M986.331,109.582c7.141-10.669,28.926-51.179-2.968-85.299S891.011,8.972,891.011,8.972L539.125,133.474 L63.239,302.022c-21.503,7.998-53.586,30.072-60.956,61.716s-2.116,58.538,22.414,96.79S211.33,752.213,228.564,777.28 c26.453,36.868,62.16,58.042,105.507,57.154s365.665-7.485,365.665-7.485l331.7-8.325l89.453-2.293c0,0,70.998-7.179,69.861-60.287 c-1.135-53.108-74.618-62.721-74.618-62.721s-733.215,15.553-749.148,15.576c-22.688,0.201-45.355-15.278-54.146-28.928 s-175.79-272.956-175.79-272.956l600.587-212.338c0,0-73.179,67.087-99.315,100.041s-30.56,74.565-5.053,95.237 c31.188,24.081,91.974-3.708,123.127-39.312C782.35,323.912,979.191,120.251,986.331,109.582z" })
9164
+ );
9165
+ }
9166
+
9167
+ function bBoxIcon() {
9168
+ return React.createElement(
9169
+ "svg",
9170
+ { version: "1.1", id: "Linie", xmlns: "http://www.w3.org/2000/svg"
9171
+ // xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
9172
+ // width="1190.549px" height="841.891px"
9173
+ , viewBox: "0 0 1190.549 841.891",
9174
+ width: "17px"
9175
+ // enable-background="new 0 0 1190.549 841.891"
9176
+ // xml:space="preserve"
9177
+ },
9178
+ React.createElement("path", { fill: "none", stroke: "currentColor", strokeWidth: "120", strokeMiterlimit: "10", d: "M929.775,710.655 c0,23.386-19.134,42.52-42.52,42.52H278.991c-23.386,0-42.52-19.134-42.52-42.52V102.392c0-23.386,19.134-42.52,42.52-42.52 h608.264c23.386,0,42.52,19.134,42.52,42.52V710.655z" })
9179
+ );
9180
+ }
9181
+
9182
+ function polygonIcon() {
9183
+ return React.createElement(
9184
+ "svg",
9185
+ { version: "1.1", id: "Linie", xmlns: "http://www.w3.org/2000/svg"
9186
+ // xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
9187
+ // width="1190.549px" height="841.891px"
9188
+ , viewBox: "0 0 1190.549 841.891",
9189
+ width: "17px"
9190
+ // enable-background="new 0 0 1190.549 841.891"
9191
+ // xml:space="preserve"
9192
+ },
9193
+ React.createElement("path", { fill: "none", stroke: "currentColor", strokeWidth: "120", strokeMiterlimit: "10", d: "M342.327,769.938 c-23.379,0.548-52.922-15.056-65.65-34.674L65.479,409.738c-12.729-19.619-5.085-41.998,16.984-49.732L917.331,67.421 c22.07-7.734,26.86-0.275,10.645,16.576L691.761,329.475c-16.216,16.852-14.503,42.542,3.807,57.092l425.212,337.901 c18.31,14.549,14.16,26.901-9.219,27.449L342.327,769.938z" })
9194
+ );
9195
+ }
9196
+
9197
+ function pointIcon() {
9198
+ return React.createElement(
9199
+ "svg",
9200
+ { version: "1.1", xmlns: "http://www.w3.org/2000/svg"
9201
+ // x="0px" y="0px"
9202
+ // width="1190.549px" height="841.891px"
9203
+ , viewBox: "0 0 1190.549 841.891",
9204
+ width: "17px"
9205
+ },
9206
+ React.createElement("path", { fill: "currentColor", d: "M748.197,408.286c0,151.355-122.699,274.058-274.059,274.058c-151.357,0-274.057-122.703-274.057-274.058 c0-151.356,122.7-274.057,274.057-274.057C625.497,134.229,748.197,256.929,748.197,408.286z" })
9207
+ );
9208
+ }
9209
+
9210
+ var _extends$d = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
9211
+
9212
+ var _createClass$l = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
9213
+
9214
+ function _classCallCheck$l(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9215
+
9216
+ function _possibleConstructorReturn$j(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
9217
+
9218
+ function _inherits$j(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
9219
+
9220
+ var ToolBar = function (_Component) {
9221
+ _inherits$j(ToolBar, _Component);
9222
+
9223
+ function ToolBar(props) {
9224
+ _classCallCheck$l(this, ToolBar);
9225
+
9226
+ var _this = _possibleConstructorReturn$j(this, (ToolBar.__proto__ || Object.getPrototypeOf(ToolBar)).call(this, props));
9227
+
9228
+ _this.state = {
9229
+ // fullscreenMode: false,
9230
+ position: {
9231
+ left: 0,
9232
+ top: 5,
9233
+ width: 40
9234
+ },
9235
+ showFinishPrompt: false,
9236
+ showHelp: false
9237
+ };
9238
+ _this.toolBarGroup = React.createRef();
9239
+ return _this;
9240
+ }
9241
+
9242
+ _createClass$l(ToolBar, [{
9243
+ key: 'componentDidMount',
9244
+ value: function componentDidMount() {}
9245
+ }, {
9246
+ key: 'componentDidUpdate',
9247
+ value: function componentDidUpdate(prevProps, prevState) {
9248
+ // if (prevState.fullscreenMode !== this.state.fullscreenMode){
9249
+ // this.props.siaSetFullscreen(this.state.fullscreenMode)
9250
+ // }
9251
+
9252
+ if (this.props.layoutUpdate !== prevProps.layoutUpdate) {
9253
+ this.calcPosition();
9254
+ }
9255
+ if (this.props.svg !== prevProps.svg) {
9256
+ this.calcPosition();
9257
+ }
9258
+ }
9259
+ }, {
9260
+ key: 'onClick',
9261
+ value: function onClick(e, tool) {
9262
+ this.triggerToolBarEvent(TOOL_SELECTED, tool);
9263
+ }
9264
+ }, {
9265
+ key: 'calcPosition',
9266
+ value: function calcPosition() {
9267
+ if (!this.props.enabled) return;
9268
+ var tb = this.toolBarGroup.current.getBoundingClientRect();
9269
+ if (tb) {
9270
+ if (this.props.svg) {
9271
+ var toolBarTop = undefined;
9272
+ toolBarTop = this.props.svg.top + this.props.svg.height / 6;
9273
+ this.setState({
9274
+ position: _extends$d({}, this.state.position, {
9275
+ left: this.props.svg.left - 55,
9276
+ top: toolBarTop
9277
+ })
9278
+ });
9279
+ }
9280
+ }
9281
+ }
9282
+ }, {
9283
+ key: 'getNextImg',
9284
+ value: function getNextImg() {
9285
+ // this.props.siaGetNextImage(this.props.imageMeta.id)
9286
+ this.triggerToolBarEvent(GET_NEXT_IMAGE);
9287
+ }
9288
+ }, {
9289
+ key: 'getPrevImg',
9290
+ value: function getPrevImg() {
9291
+ // this.props.siaGetPrevImage(this.props.imageMeta.id)
9292
+ this.triggerToolBarEvent(GET_PREV_IMAGE);
9293
+ }
9294
+ }, {
9295
+ key: 'setFinished',
9296
+ value: function setFinished() {
9297
+ // this.props.siaSetTaskFinished()
9298
+ this.triggerToolBarEvent(TASK_FINISHED);
9299
+ }
9300
+ }, {
9301
+ key: 'toggleFinishPrompt',
9302
+ value: function toggleFinishPrompt() {
9303
+ this.setState({
9304
+ showFinishPrompt: !this.state.showFinishPrompt
9305
+ });
9306
+ }
9307
+ }, {
9308
+ key: 'toggleFullscreen',
9309
+ value: function toggleFullscreen() {
9310
+ // this.setState({
9311
+ // fullscreenMode: !this.state.fullscreenMode
9312
+ // })
9313
+ this.triggerToolBarEvent(SET_FULLSCREEN);
9314
+ }
9315
+ }, {
9316
+ key: 'toggleImgLabelInput',
9317
+ value: function toggleImgLabelInput() {
9318
+ // this.props.siaShowImgLabelInput(!this.props.imgLabelInput.show)
9319
+ this.triggerToolBarEvent(SHOW_IMAGE_LABEL_INPUT);
9320
+ }
9321
+ }, {
9322
+ key: 'toggleJunk',
9323
+ value: function toggleJunk() {
9324
+ // this.props.siaImgIsJunk(!this.props.isJunk)
9325
+ this.triggerToolBarEvent(IMG_IS_JUNK);
9326
+ }
9327
+ }, {
9328
+ key: 'toggleHelp',
9329
+ value: function toggleHelp() {
9330
+ this.setState({ showHelp: !this.state.showHelp });
9331
+ }
9332
+ }, {
9333
+ key: 'handleOnDeleteAllAnnos',
9334
+ value: function handleOnDeleteAllAnnos() {
9335
+ this.triggerToolBarEvent(DELETE_ALL_ANNOS);
9336
+ }
9337
+ }, {
9338
+ key: 'handleSave',
9339
+ value: function handleSave() {
9340
+ this.triggerToolBarEvent(SAVE);
9341
+ }
9342
+ }, {
9343
+ key: 'triggerToolBarEvent',
9344
+ value: function triggerToolBarEvent(event, data) {
9345
+ if (this.props.onToolBarEvent) {
9346
+ this.props.onToolBarEvent(event, data);
9347
+ }
9348
+ }
9349
+ }, {
9350
+ key: 'renderToolButtons',
9351
+ value: function renderToolButtons() {
9352
+ var _this2 = this;
9353
+
9354
+ if (!this.props.canvasConfig) return null;
9355
+ if (!this.props.enabled.toolSelection) return null;
9356
+ if (!this.props.canvasConfig.annos.actions.draw) return null;
9357
+ var btns = [];
9358
+ if (this.props.canvasConfig.tools.point) {
9359
+ btns.push(React.createElement(
9360
+ Menu.Item,
9361
+ { name: 'dot circle', key: POINT,
9362
+ active: this.props.active.selectedTool === POINT,
9363
+ onClick: function onClick(e) {
9364
+ return _this2.onClick(e, POINT);
9365
+ }
9366
+ },
9367
+ pointIcon()
9368
+ ));
9369
+ }
9370
+ if (this.props.canvasConfig.tools.line) {
9371
+ btns.push(React.createElement(
9372
+ Menu.Item,
9373
+ { name: 'paint brush', key: LINE,
9374
+ active: this.props.active.selectedTool === LINE,
9375
+ onClick: function onClick(e) {
9376
+ return _this2.onClick(e, LINE);
9377
+ }
9378
+ },
9379
+ lineIcon()
9380
+ ));
9381
+ }
9382
+ if (this.props.canvasConfig.tools.bbox) {
9383
+ btns.push(React.createElement(
9384
+ Menu.Item,
9385
+ { name: 'square outline', key: BBOX,
9386
+ active: this.props.active.selectedTool === BBOX,
9387
+ onClick: function onClick(e) {
9388
+ return _this2.onClick(e, BBOX);
9389
+ }
9390
+ },
9391
+ bBoxIcon()
9392
+ ));
9393
+ }
9394
+ if (this.props.canvasConfig.tools.polygon) {
9395
+ btns.push(React.createElement(
9396
+ Menu.Item,
9397
+ { name: 'pencil alternate', key: POLYGON,
9398
+ active: this.props.active.selectedTool === POLYGON,
9399
+ onClick: function onClick(e) {
9400
+ return _this2.onClick(e, POLYGON);
9401
+ }
9402
+ },
9403
+ polygonIcon()
9404
+ ));
9405
+ }
9406
+ return btns;
9407
+ }
9408
+ }, {
9409
+ key: 'renderFinishPrompt',
9410
+ value: function renderFinishPrompt() {
9411
+ var _this3 = this;
9412
+
9413
+ return React.createElement(Prompt, { active: this.state.showFinishPrompt,
9414
+ header: React.createElement(
9415
+ 'div',
9416
+ null,
9417
+ React.createElement(Icon, { name: 'paper plane outline' }),
9418
+ 'Do you wish to FINISH this SIA Task?'
9419
+ ),
9420
+ content: React.createElement(
9421
+ 'div',
9422
+ null,
9423
+ React.createElement(
9424
+ Button,
9425
+ { basic: true, color: 'green', inverted: true,
9426
+ onClick: function onClick() {
9427
+ return _this3.setFinished();
9428
+ }
9429
+ },
9430
+ React.createElement(Icon, { name: 'check' }),
9431
+ 'Yes'
9432
+ ),
9433
+ React.createElement(
9434
+ Button,
9435
+ { basic: true, color: 'red', inverted: true,
9436
+ onClick: function onClick() {
9437
+ return _this3.toggleFinishPrompt();
9438
+ }
9439
+ },
9440
+ React.createElement(Icon, { name: 'ban' }),
9441
+ ' No'
9442
+ )
9443
+ )
9444
+ });
9445
+ }
9446
+ /**
9447
+ * Render next and prev image buttons
9448
+ *
9449
+ */
9450
+
9451
+ }, {
9452
+ key: 'renderNavigation',
9453
+ value: function renderNavigation() {
9454
+ var _this4 = this;
9455
+
9456
+ var btns = [];
9457
+ if (!this.props.enabled.nextPrev) return null;
9458
+ if (this.props.imageMeta) {
9459
+ if (this.props.imageMeta.isLast) {
9460
+ btns.push(React.createElement(
9461
+ Menu.Item,
9462
+ { name: 'paper plane outline', key: 'finish',
9463
+ active: false,
9464
+ onClick: function onClick() {
9465
+ return _this4.toggleFinishPrompt();
9466
+ }
9467
+ },
9468
+ React.createElement(Icon, { name: 'paper plane outline' }),
9469
+ this.renderFinishPrompt()
9470
+ ));
9471
+ } else {
9472
+ btns.push(React.createElement(
9473
+ Menu.Item,
9474
+ { name: 'arrow right', key: 'next',
9475
+ active: false,
9476
+ onClick: function onClick() {
9477
+ return _this4.getNextImg();
9478
+ }
9479
+ },
9480
+ React.createElement(Icon, { name: 'arrow right' })
9481
+ ));
9482
+ }
9483
+ btns.push(React.createElement(
9484
+ Menu.Item,
9485
+ { name: 'arrow left', key: 'prev',
9486
+ active: false,
9487
+ onClick: function onClick() {
9488
+ return _this4.getPrevImg();
9489
+ },
9490
+ disabled: this.props.imageMeta.isFirst
9491
+ },
9492
+ React.createElement(Icon, { name: 'arrow left' })
9493
+ ));
9494
+ }
9495
+ return btns;
9496
+ }
9497
+ }, {
9498
+ key: 'renderJunkButton',
9499
+ value: function renderJunkButton() {
9500
+ var _this5 = this;
9501
+
9502
+ if (!this.props.enabled.junk) return null;
9503
+ return React.createElement(
9504
+ Menu.Item,
9505
+ { name: 'ban', key: 'junk',
9506
+ active: this.props.active.isJunk,
9507
+ onClick: function onClick() {
9508
+ return _this5.toggleJunk();
9509
+ }
9510
+ },
9511
+ React.createElement(Icon, { name: 'ban' })
9512
+ );
9513
+ }
9514
+ }, {
9515
+ key: 'renderDeleteAllAnnosButton',
9516
+ value: function renderDeleteAllAnnosButton() {
9517
+ var _this6 = this;
9518
+
9519
+ if (!this.props.enabled.deleteAll) return null;
9520
+ return React.createElement(
9521
+ Menu.Item,
9522
+ { name: 'trash alternate outline', key: 'deleteAllAnnos',
9523
+ onClick: function onClick() {
9524
+ return _this6.handleOnDeleteAllAnnos();
9525
+ }
9526
+ },
9527
+ React.createElement(Icon, { name: 'trash alternate outline' })
9528
+ );
9529
+ }
9530
+ }, {
9531
+ key: 'renderSaveButton',
9532
+ value: function renderSaveButton() {
9533
+ var _this7 = this;
9534
+
9535
+ if (!this.props.enabled.save) return null;
9536
+ return React.createElement(
9537
+ Menu.Item,
9538
+ { name: 'save', key: 'save',
9539
+ onClick: function onClick() {
9540
+ return _this7.handleSave();
9541
+ }
9542
+ },
9543
+ React.createElement(Icon, { name: 'save' })
9544
+ );
9545
+ }
9546
+ }, {
9547
+ key: 'renderHelpButton',
9548
+ value: function renderHelpButton() {
9549
+ var _this8 = this;
9550
+
9551
+ if (!this.props.enabled.help) return null;
9552
+ return React.createElement(
9553
+ Menu.Item,
9554
+ { name: 'help', key: 'help',
9555
+ active: false,
9556
+ onClick: function onClick() {
9557
+ return _this8.toggleHelp();
9558
+ }
9559
+ },
9560
+ React.createElement(Icon, { name: 'help' }),
9561
+ React.createElement(Prompt, { active: this.state.showHelp,
9562
+ content: React.createElement(
9563
+ 'div',
9564
+ null,
9565
+ React.createElement(
9566
+ Card.Group,
9567
+ null,
9568
+ React.createElement(
9569
+ Card,
9570
+ null,
9571
+ React.createElement(Card.Content, { header: 'How to draw?' }),
9572
+ React.createElement(Card.Content, { description: '1.) Select a Tool in the toolbar 2.) Draw with RIGHT CLICK on Canvas' })
9573
+ ),
9574
+ React.createElement(
9575
+ Card,
9576
+ null,
9577
+ React.createElement(Card.Content, { header: 'How to delete an annotation?' }),
9578
+ React.createElement(Card.Content, { description: '1.) Select an annotation with LEFT CLICK 2.) Press DELETE or BACKSPACE' })
9579
+ ),
9580
+ React.createElement(
9581
+ Card,
9582
+ null,
9583
+ React.createElement(Card.Content, { header: 'How to assign a label?' }),
9584
+ React.createElement(Card.Content, { description: '1.) Select an annotation with LEFT CLICK 2.) Hit ENTER 3.) Type into the input field 4.) Hit ENTER to confirm 5.) Hit ESCAPE to close the input field' })
9585
+ ),
9586
+ React.createElement(
9587
+ Card,
9588
+ null,
9589
+ React.createElement(Card.Content, { header: 'Undo/ Redo' }),
9590
+ React.createElement(Card.Content, { description: 'Undo: Hit STRG + Z' }),
9591
+ React.createElement(Card.Content, { description: 'Redo: Hit STRG + R' })
9592
+ ),
9593
+ React.createElement(
9594
+ Card,
9595
+ null,
9596
+ React.createElement(Card.Content, { header: 'Add a node to Line/Polygon' }),
9597
+ React.createElement(Card.Content, { description: 'Hit STRG + Click left on the line' })
9598
+ ),
9599
+ React.createElement(
9600
+ Card,
9601
+ null,
9602
+ React.createElement(Card.Content, { header: 'Remove a node from Line/Polygon in create mode' }),
9603
+ React.createElement(Card.Content, { description: 'Press DELETE or BACKSPACE' })
9604
+ ),
9605
+ React.createElement(
9606
+ Card,
9607
+ null,
9608
+ React.createElement(Card.Content, { header: 'Edit Line/Polygon' }),
9609
+ React.createElement(Card.Content, { description: '1.) Click on the Annotation you want to edit.' }),
9610
+ React.createElement(Card.Content, { description: '2.) Press "e". New nodes can now be added using right click' })
9611
+ ),
9612
+ React.createElement(
9613
+ Card,
9614
+ null,
9615
+ React.createElement(Card.Content, { header: 'Zoom/ Move Canvas' }),
9616
+ React.createElement(Card.Content, { description: 'Zoom: Use MOUSE WHEEL to zoom in/out' }),
9617
+ React.createElement(Card.Content, { description: 'Move: Hold MOUSE WHEEL and move mouse. Or Use W/A/S/D keys to move camera up/left/down/right' })
9618
+ ),
9619
+ React.createElement(
9620
+ Card,
9621
+ null,
9622
+ React.createElement(Card.Content, { header: 'TAB navigation' }),
9623
+ React.createElement(Card.Content, { description: 'You can traverse all visible annotation by hitting TAB.' })
9624
+ ),
9625
+ React.createElement(
9626
+ Card,
9627
+ null,
9628
+ React.createElement(Card.Content, { header: 'Next/Prev image navigation' }),
9629
+ React.createElement(Card.Content, { description: 'Get next image by hitting ARROW_RIGHT key. Get previous image by hitting ARROW_LEFT key.' })
9630
+ ),
9631
+ React.createElement(
9632
+ Card,
9633
+ null,
9634
+ React.createElement(Card.Content, { header: 'Copy and Paste annotations' }),
9635
+ React.createElement(Card.Content, { description: 'Copy: 1.) Select annotation 2.) Hit STRG + C' }),
9636
+ React.createElement(Card.Content, { description: 'Paste: STRG + V' })
9637
+ ),
9638
+ React.createElement(
9639
+ Card,
9640
+ null,
9641
+ React.createElement(Card.Content, { header: 'Mark image as junk' }),
9642
+ React.createElement(Card.Content, { description: '1.) Press J key' })
9643
+ ),
9644
+ React.createElement(
9645
+ Card,
9646
+ null,
9647
+ React.createElement(Card.Content, { header: 'Assign a comment to a 2D annoation' }),
9648
+ React.createElement(Card.Content, { description: '1.) Select annotation 2.) Hit C key' })
9649
+ )
9650
+ )
9651
+ )
9652
+ })
9653
+ );
9654
+ }
9655
+ }, {
9656
+ key: 'renderImgLabelInput',
9657
+ value: function renderImgLabelInput() {
9658
+ var _this9 = this;
9659
+
9660
+ if (!this.props.enabled.imgLabel) return null;
9661
+ if (this.props.canvasConfig.img.actions.label) {
9662
+ return React.createElement(
9663
+ Menu.Item,
9664
+ { name: 'img label input'
9665
+ // active={this.props.imgLabelInput.show}
9666
+ , onClick: function onClick() {
9667
+ return _this9.toggleImgLabelInput();
9668
+ }
9669
+ },
9670
+ textIcon()
9671
+ );
9672
+ }
9673
+ }
9674
+ }, {
9675
+ key: 'renderFullscreenBtn',
9676
+ value: function renderFullscreenBtn() {
9677
+ var _this10 = this;
9678
+
9679
+ if (!this.props.enabled.fullscreen) return null;
9680
+ return React.createElement(
9681
+ Menu.Item,
9682
+ { name: 'expand arrows alternate',
9683
+ active: this.props.active.fullscreen,
9684
+ onClick: function onClick() {
9685
+ return _this10.toggleFullscreen();
9686
+ }
9687
+ },
9688
+ React.createElement(Icon, { name: 'expand arrows alternate' })
9689
+ );
9690
+ }
9691
+ }, {
9692
+ key: 'renderSettingBtn',
9693
+ value: function renderSettingBtn() {
9694
+ var _this11 = this;
9695
+
9696
+ if (!this.props.enabled.settings) return null;
9697
+ return React.createElement(SIASettingButton, {
9698
+ enabled: this.props.enabled.settings,
9699
+ uiConfig: this.props.uiConfig,
9700
+ onSettingEvent: function onSettingEvent(e, data) {
9701
+ return _this11.triggerToolBarEvent(e, data);
9702
+ } });
9703
+ }
9704
+ }, {
9705
+ key: 'renderFilterBtn',
9706
+ value: function renderFilterBtn() {
9707
+ var _this12 = this;
9708
+
9709
+ if (!this.props.enabled.filter) return null;
9710
+ return React.createElement(SIAFilterButton, {
9711
+ enabled: this.props.enabled.filter,
9712
+ onFilterEvent: function onFilterEvent(e, data) {
9713
+ return _this12.triggerToolBarEvent(e, data);
9714
+ },
9715
+ filter: this.props.filter,
9716
+ imageMeta: this.props.imageMeta
9717
+ });
9718
+ }
9719
+ }, {
9720
+ key: 'render',
9721
+ value: function render() {
9722
+ if (!this.props.enabled) return null;
9723
+ return React.createElement(
9724
+ 'div',
9725
+ {
9726
+ ref: this.toolBarGroup,
9727
+ style: { position: 'fixed', top: this.state.position.top, left: this.state.position.left } },
9728
+ React.createElement(
9729
+ Menu,
9730
+ { icon: true, inverted: true, vertical: true },
9731
+ this.renderSaveButton(),
9732
+ this.renderImgLabelInput(),
9733
+ this.renderNavigation(),
9734
+ this.renderToolButtons(),
9735
+ this.renderFullscreenBtn(),
9736
+ this.renderJunkButton(),
9737
+ this.renderDeleteAllAnnosButton(),
9738
+ this.renderHelpButton(),
9739
+ this.renderSettingBtn(),
9740
+ this.renderFilterBtn()
9741
+ )
9742
+ );
9743
+ }
9744
+ }]);
9745
+
9746
+ return ToolBar;
9747
+ }(Component);
9748
+
9749
+ var _extends$e = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
9750
+
9751
+ var _slicedToArray$3 = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
9752
+
9753
+ /**
9754
+ * SIA element that handles annotations within an image
9755
+ *
9756
+ * @param {object} annos - A json object containing all annotation
9757
+ * information for an image
9758
+ * {
9759
+ * image : {
9760
+ * id: int,
9761
+ * number: int,
9762
+ * amount: int,
9763
+ * isFirst: bool,
9764
+ * isLast: bool,
9765
+ * description: string, // -> optional
9766
+ * },
9767
+ * annotations: {
9768
+ * bBoxes: [{
9769
+ * id: int, // -> Not required if status === annoStatus.NEW
9770
+ * data: {},
9771
+ * labelIds: list of int, // -> optional
9772
+ * status: see annoStatus, // -> optional
9773
+ * annoTime: float, // -> optional
9774
+ * },...],
9775
+ * points: []
9776
+ * lines: []
9777
+ * polygons: []
9778
+ * }
9779
+ * }
9780
+ * @param {object} possibleLabels - Possible labels that can be assigned to
9781
+ * an annotation.
9782
+ * [{
9783
+ * id: int,
9784
+ * description: str,
9785
+ * label: str, (name of the label)
9786
+ * color: str (color is optional)
9787
+ * }, ...]
9788
+ * @param {blob} imageBlob - The actual image blob that will be displayed
9789
+ * @param {object} imageMeta - Meta information for the current image
9790
+ * {
9791
+ * "id": int,
9792
+ * "number": int, // -> number of image in current annotask
9793
+ * "amount": int, // -> total number of images in current annotask
9794
+ * "isFirst": bool, // -> True if this image is the first image
9795
+ * "isLast": bool, // -> True if current image is the last image in annotask
9796
+ * "labelIds": list of int, // -> List of label for the current image
9797
+ * "isJunk": bool, // -> Indicates wether current image is a junk image
9798
+ * "annoTime": float, // -> Total annotation time for the current image
9799
+ * "description": str or null // -> Description or comment for the current image
9800
+ * }
9801
+ * @param {object} exampleImg - Example for a selected label
9802
+ * {
9803
+ * "anno": {
9804
+ * "id": int, // -> ID of the example annotation
9805
+ * "comment": null or str // -> Comment that has been assigned to this example
9806
+ * },
9807
+ * "img": image blob
9808
+ * }
9809
+ * @param {bool} isJunk - Indicates wether the current image is junk or not
9810
+ * @param {object} uiConfig - User interface configs
9811
+ * {
9812
+ * nodesRadius: int, strokeWidth: int,
9813
+ * layoutOffset: {left:int, top:int, right:int, bottom:int}, -> Offset of the canvas inside the container
9814
+ * imgBarVisible: bool,
9815
+ * imgLabelInputVisible: bool,
9816
+ * centerCanvasInContainer: bool, -> Center the canvas in the middle of the container.
9817
+ * maxCanvas: bool -> Maximize Canvas Size. Do not fit canvas to image size.
9818
+ * }
9819
+ * @param {int} layoutUpdate - A counter that triggers a layout update
9820
+ * everytime it is incremented.
9821
+ * @param {string} selectedTool - The tool that is selected to draw an
9822
+ * annotation. Possible choices are: 'bBox', 'point', 'line', 'polygon'
9823
+ * @param {object} canvasConfig - Configuration for this canvas
9824
+ * {
9825
+ * annos:{
9826
+ * tools: {
9827
+ * point: bool,
9828
+ * line: bool,
9829
+ * polygon: bool,
9830
+ * bbox: bool
9831
+ * },
9832
+ * multilabels: bool,
9833
+ * actions: {
9834
+ * draw: bool,
9835
+ * label: bool,
9836
+ * edit: bool,
9837
+ * },
9838
+ * maxAnnos: null or int,
9839
+ * minArea: int
9840
+ * },
9841
+ * img: {
9842
+ * multilabels: bool,
9843
+ * actions: {
9844
+ * label: bool,
9845
+ * }
9846
+ * },
9847
+ * allowedToMarkExample: bool, -> Indicates wether the current user is allowed to mark an annotation as example.
9848
+ * autoSaveInterval: int -> Interval in seconds when an autosave will be requested by canvas
9849
+ * }
9850
+ * @param {str or int} defaultLabel (optional) - Name or ID of the default label that is used
9851
+ * when no label was selected by the annotator. If not set "no label" will be used.
9852
+ * If ID is used, it needs to be one of the possible label ids.
9853
+ * @param {bool} blocked Block canvas view with loading dimmer.
9854
+ * @param {int} nextAnnoId Id that will be used for the next annotation that
9855
+ * will be created. If undefined, the canvas will create its own ids.
9856
+ * @param {bool} lockedAnnos A list of AnnoIds of annos that should only be displayed.
9857
+ * Such annos can not be edited in any way.
9858
+ * @param {object} filter Information for the filter Popup
9859
+ * {
9860
+ * "clahe": {
9861
+ * "clipLimit": int,
9862
+ * "active": bool
9863
+ * },
9864
+ * "rotate": {
9865
+ * "angle": 90 | -90 | 180,
9866
+ * "active": bool
9867
+ * }
9868
+ * }
9869
+ * @param {bool | object} toolbarEnabled Defines which toolbar buttons are
9870
+ * displayed or if toolbar is shown at all.
9871
+ * false | {
9872
+ * imgLabel: bool,
9873
+ * nextPrev: bool,
9874
+ * toolSelection: bool,
9875
+ * fullscreen: bool,
9876
+ * junk: bool,
9877
+ * deleteAll: bool,
9878
+ * settings: bool | {infoBoxes: bool, annoStyle: bool},
9879
+ * filter: bool | {rotate: bool, clahe:bool},
9880
+ * help: bool
9881
+ * }
9882
+ * @event onNotification - Callback for Notification messages
9883
+ * args: {title: str, message: str, type: str}
9884
+ * @event onCanvasKeyDown - Fires for keyDown on canvas
9885
+ * @event onAnnoEvent - Fires when an anno performed an action
9886
+ * args: {anno: annoObject, newAnnos: list of annoObjects, pAction: str}
9887
+ * @event onGetAnnoExample - Fires when anno example is requested by canvas
9888
+ * {
9889
+ * id: int, // -> ID of the annotation that will be requested as example
9890
+ * comment: null or str
9891
+ * }
9892
+ * @event onCanvasEvent - Fires on canvas event
9893
+ * args: {action: action, data: dataObject}
9894
+ * action -> CANVAS_SVG_UPDATE
9895
+ * data: {width: int, height: int, scale: float, translateX: float,
9896
+ * translateY:float}
9897
+ * action -> CANVAS_UI_CONFIG_UPDATE
9898
+ * action -> CANVAS_LABEL_INPUT_CLOSE
9899
+ * action -> CANVAS_IMG_LOADED
9900
+ * action -> CANVAS_IMGBAR_CLOSE
9901
+ * @event onToolBarEvent - Fires on Toolbar event
9902
+ * args: {e: event, data: data object}
9903
+ *
9904
+ * e -> DELETE_ALL_ANNOS
9905
+ * e -> TOOL_SELECTED
9906
+ * data: 'bbox', 'point', 'line', 'polygon'
9907
+ * e -> GET_NEXT_IMAGE
9908
+ * data: int // -> Image ID
9909
+ * e -> GET_PREV_IMAGE
9910
+ * data: int // -> Image ID
9911
+ * e -> TASK_FINISHED
9912
+ * data: null
9913
+ * e -> SHOW_IMAGE_LABEL_INPUT
9914
+ * data: null
9915
+ * e -> IMG_IS_JUNK
9916
+ * data: null
9917
+ * e -> APPLY_FILTER
9918
+ * data: {
9919
+ * "clahe": {
9920
+ * "clipLimit": int,
9921
+ * "active": bool
9922
+ * },
9923
+ * "rotate": {
9924
+ * "angle": 90 | -90 | 180,
9925
+ * "active": bool
9926
+ * }
9927
+ * }
9928
+ * e -> SHOW_ANNO_DETAILS
9929
+ * data: null
9930
+ * e -> SHOW_LABEL_INFO
9931
+ * data: null
9932
+ * e -> SHOW_ANNO_STATS
9933
+ * data: null
9934
+ * e -> EDIT_STROKE_WIDTH
9935
+ * data: int // -> Stroke width
9936
+ * e -> EDIT_NODE_RADIUS
9937
+ * data: int // -> Radius
9938
+ * @event onGetFunction - Get special canvas functions for manipulation from outside canvas
9939
+ * deleteAllAnnos()
9940
+ * unloadImage()
9941
+ * resetZoom()
9942
+ * getAnnos(annos,removeFrontendIds)
9943
+ */
9944
+ var Sia = function Sia(props) {
9945
+ var _useState = useState(''),
9946
+ _useState2 = _slicedToArray$3(_useState, 2),
9947
+ fullscreenCSS = _useState2[0],
9948
+ setFullscreenCSS = _useState2[1];
9949
+
9950
+ var _useState3 = useState(0),
9951
+ _useState4 = _slicedToArray$3(_useState3, 2),
9952
+ layoutUpdate = _useState4[0],
9953
+ setLayoutUpdate = _useState4[1];
9954
+
9955
+ var _useState5 = useState(),
9956
+ _useState6 = _slicedToArray$3(_useState5, 2),
9957
+ svg = _useState6[0],
9958
+ setSvg = _useState6[1];
9959
+
9960
+ var _useState7 = useState(false),
9961
+ _useState8 = _slicedToArray$3(_useState7, 2),
9962
+ externalConfigUpdate = _useState8[0],
9963
+ setExternalConfigUpdate = _useState8[1];
9964
+
9965
+ var _useState9 = useState({
9966
+ "nodeRadius": 4,
9967
+ "strokeWidth": 4,
9968
+ "annoDetails": {
9969
+ "visible": false
9970
+ },
9971
+ "labelInfo": {
9972
+ "visible": false
9973
+ },
9974
+ "annoStats": {
9975
+ "visible": false
9976
+ },
9977
+ "layoutOffset": {
9978
+ "left": 20,
9979
+ "top": 0,
9980
+ "bottom": 5,
9981
+ "right": 5
9982
+ },
9983
+ "imgBarVisible": true,
9984
+ "imgLabelInputVisible": false,
9985
+ "centerCanvasInContainer": true,
9986
+ "maxCanvas": true
9987
+ }),
9988
+ _useState10 = _slicedToArray$3(_useState9, 2),
9989
+ uiConfig = _useState10[0],
9990
+ setUiConfig = _useState10[1];
9991
+
9992
+ var containerRef = useRef();
9993
+
9994
+ useEffect(function () {
9995
+ doLayoutUpdate();
9996
+ }, [props.layoutUpdate]);
9997
+
9998
+ useEffect(function () {
9999
+ setExternalConfigUpdate(true);
10000
+ setUiConfig(_extends$e({}, uiConfig, props.uiConfig));
10001
+ }, [props.uiConfig]);
10002
+
10003
+ useEffect(function () {
10004
+ if (externalConfigUpdate) {
10005
+ setExternalConfigUpdate(false);
10006
+ } else {
10007
+ if (props.onCanvasEvent) {
10008
+ props.onCanvasEvent(CANVAS_UI_CONFIG_UPDATE, uiConfig);
10009
+ }
10010
+ }
10011
+ }, [uiConfig]);
10012
+
10013
+ var doLayoutUpdate = function doLayoutUpdate() {
10014
+ setLayoutUpdate(layoutUpdate + 1);
10015
+ };
10016
+
10017
+ var handleAnnoEvent = function handleAnnoEvent(anno, annos, action) {
10018
+ if (props.onAnnoEvent) {
10019
+ props.onAnnoEvent(anno, annos, action);
10020
+ }
10021
+ };
10022
+
10023
+ var handleNotification = function handleNotification(msg) {
10024
+ if (props.onNotification) {
10025
+ props.onNotification(msg);
10026
+ }
10027
+ };
10028
+
10029
+ var handleCanvasKeyDown = function handleCanvasKeyDown(e) {
10030
+ if (props.onCanvasKeyDown) {
10031
+ props.onCanvasKeyDown(e);
10032
+ }
10033
+ };
10034
+
10035
+ var handleCanvasEvent = function handleCanvasEvent(e, data) {
10036
+ switch (e) {
10037
+ case CANVAS_SVG_UPDATE:
10038
+ setSvg(data);
10039
+ break;
10040
+ case CANVAS_UI_CONFIG_UPDATE:
10041
+ setUiConfig(_extends$e({}, uiConfig, data));
10042
+ break;
10043
+ default:
10044
+ break;
10045
+ }
10046
+ if (props.onCanvasEvent) {
10047
+ props.onCanvasEvent(e, data);
10048
+ }
10049
+ };
10050
+
10051
+ var handleGetFunction = function handleGetFunction(deleteAll) {
10052
+ if (props.onGetFunction) {
10053
+ props.onGetFunction(deleteAll);
10054
+ }
10055
+ };
10056
+
10057
+ var handleToolBarEvent = function handleToolBarEvent(e, data) {
10058
+ switch (e) {
10059
+ case SET_FULLSCREEN:
10060
+ if (fullscreenCSS === '') {
10061
+ setFullscreenCSS('sia-fullscreen');
10062
+ setUiConfig(_extends$e({}, uiConfig, {
10063
+ layoutOffset: _extends$e({}, uiConfig.layoutOffset, {
10064
+ left: 50,
10065
+ top: 5
10066
+ })
10067
+ }));
10068
+ doLayoutUpdate();
10069
+ } else {
10070
+ setFullscreenCSS('');
10071
+ setUiConfig(_extends$e({}, uiConfig, {
10072
+ layoutOffset: _extends$e({}, uiConfig.layoutOffset, {
10073
+ left: 20,
10074
+ top: 0
10075
+ })
10076
+ }));
10077
+ doLayoutUpdate();
10078
+ }
10079
+ break;
10080
+ case SHOW_ANNO_DETAILS:
10081
+ setUiConfig(_extends$e({}, uiConfig, {
10082
+ annoDetails: _extends$e({}, uiConfig.annoDetails, {
10083
+ visible: !uiConfig.annoDetails.visible
10084
+ })
10085
+ }));
10086
+ break;
10087
+ case SHOW_LABEL_INFO:
10088
+ setUiConfig(_extends$e({}, uiConfig, {
10089
+ labelInfo: _extends$e({}, uiConfig.labelInfo, {
10090
+ visible: !uiConfig.labelInfo.visible
10091
+ })
10092
+ }));
10093
+ break;
10094
+ case SHOW_ANNO_STATS:
10095
+ setUiConfig(_extends$e({}, uiConfig, {
10096
+ annoStats: _extends$e({}, uiConfig.annoStats, {
10097
+ visible: !uiConfig.annoStats.visible
10098
+ })
10099
+ }));
10100
+ break;
10101
+ case EDIT_STROKE_WIDTH:
10102
+ setUiConfig(_extends$e({}, uiConfig, { strokeWidth: data }));
10103
+ break;
10104
+ case EDIT_NODE_RADIUS:
10105
+ setUiConfig(_extends$e({}, uiConfig, { nodeRadius: data }));
10106
+ break;
10107
+ default:
10108
+ break;
10109
+ }
10110
+ if (props.onToolBarEvent) {
10111
+ props.onToolBarEvent(e, data);
10112
+ }
10113
+ };
10114
+
10115
+ return React.createElement(
10116
+ 'div',
10117
+ { className: fullscreenCSS, ref: containerRef },
10118
+ React.createElement(Canvas, {
10119
+ container: containerRef,
10120
+
10121
+ onAnnoEvent: function onAnnoEvent(anno, annos, action) {
10122
+ return handleAnnoEvent(anno, annos, action);
10123
+ },
10124
+ onNotification: function onNotification(messageObj) {
10125
+ return handleNotification(messageObj);
10126
+ },
10127
+ onKeyDown: function onKeyDown(e) {
10128
+ return handleCanvasKeyDown(e);
10129
+ },
10130
+ onCanvasEvent: function onCanvasEvent(action, data) {
10131
+ return handleCanvasEvent(action, data);
10132
+ },
10133
+ onGetAnnoExample: function onGetAnnoExample(exampleArgs) {
10134
+ return props.onGetAnnoExample ? props.onGetAnnoExample(exampleArgs) : {};
10135
+ },
10136
+ onGetFunction: function onGetFunction(canvasFunc) {
10137
+ return handleGetFunction(canvasFunc);
10138
+ },
10139
+
10140
+ canvasConfig: props.canvasConfig,
10141
+ uiConfig: uiConfig,
10142
+
10143
+ nextAnnoId: props.nextAnnoId,
10144
+ annos: props.annos,
10145
+ imageMeta: props.imageMeta,
10146
+ imageBlob: props.imageBlob,
10147
+ possibleLabels: props.possibleLabels,
10148
+ exampleImg: props.exampleImg,
10149
+ lockedAnnos: props.lockedAnnos,
10150
+ layoutUpdate: layoutUpdate,
10151
+ selectedTool: props.selectedTool,
10152
+ isJunk: props.isJunk,
10153
+ blocked: props.blockCanvas,
10154
+ defaultLabel: props.defaultLabel
10155
+ }),
10156
+ React.createElement(ToolBar, {
10157
+ onToolBarEvent: function onToolBarEvent(e, data) {
10158
+ return handleToolBarEvent(e, data);
10159
+ },
10160
+ imageMeta: props.imageMeta,
10161
+ layoutUpdate: layoutUpdate,
10162
+ svg: svg,
10163
+ active: {
10164
+ isJunk: props.isJunk,
10165
+ selectedTool: props.selectedTool,
10166
+ fullscreen: props.fullscreenMode
10167
+ },
10168
+ enabled: props.toolbarEnabled,
10169
+ canvasConfig: props.canvasConfig,
10170
+ uiConfig: uiConfig,
10171
+ filter: props.filter
10172
+ })
10173
+ );
10174
+ };
10175
+
10176
+ export { transform, annoConversion, canvasActions, toolbarEvents, tools, Canvas, Sia, ToolBar as Toolbar };
8534
10177
  //# sourceMappingURL=index.es.js.map