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.js CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
6
 
5
7
  var React = require('react');
@@ -107,6 +109,18 @@ function toBackend(data, svg, type) {
107
109
  }
108
110
  }
109
111
 
112
+ function getMinMaxPoints(data) {
113
+ var xList = data.map(function (e) {
114
+ return e.x;
115
+ });
116
+ var yList = data.map(function (e) {
117
+ return e.y;
118
+ });
119
+ var minPoint = { x: Math.min.apply(Math, _toConsumableArray(xList)), y: Math.min.apply(Math, _toConsumableArray(yList)) };
120
+ var maxPoint = { x: Math.max.apply(Math, _toConsumableArray(xList)), y: Math.max.apply(Math, _toConsumableArray(yList)) };
121
+ return [minPoint, maxPoint];
122
+ }
123
+
110
124
  /**
111
125
  * Get area relative to the image
112
126
  *
@@ -151,6 +165,51 @@ function move(data, movementX, movementY) {
151
165
  });
152
166
  }
153
167
 
168
+ function getBox(data, type) {
169
+
170
+ switch (type) {
171
+ case 'bBox':
172
+ return data;
173
+ case 'point':
174
+ case 'line':
175
+ case 'polygon':
176
+ var maxX = 0;
177
+ var maxY = 0;
178
+ var minX = Infinity;
179
+ var minY = Infinity;
180
+ data.forEach(function (el) {
181
+ if (el.x > maxX) maxX = el.x;
182
+ if (el.y > maxY) maxY = el.y;
183
+ if (el.x < minX) minX = el.x;
184
+ if (el.y < minY) minY = el.y;
185
+ });
186
+ return [{ x: minX, y: minY }, { x: maxX, y: minY }, { x: minX, y: maxY }, { x: maxX, y: maxY }];
187
+ default:
188
+ break;
189
+
190
+ }
191
+ }
192
+
193
+ function getCenter(data, type) {
194
+ var box = undefined;
195
+ switch (type) {
196
+ case 'point':
197
+ return data[0];
198
+ case 'line':
199
+ case 'polygon':
200
+ case 'bBox':
201
+ box = getBox(data, type);
202
+ var w = box[1].x - box[0].x;
203
+ var h = box[3].y - box[0].y;
204
+ return {
205
+ x: box[0].x + w / 2.0,
206
+ y: box[0].y + h / 2.0
207
+ };
208
+ default:
209
+
210
+ }
211
+ }
212
+
154
213
  /**
155
214
  * Get point that is closest to the left browser side.
156
215
  *
@@ -223,6 +282,55 @@ function correctAnnotation(data, image, imageOffset) {
223
282
  return corrected;
224
283
  }
225
284
 
285
+ /**
286
+ * Rotate annotation around center.
287
+ * @param {*} data list of points {x:int,y:int}
288
+ * @param {*} center Center to rotate point
289
+ * @param {*} angle Rotation angle
290
+ */
291
+ function rotateAnnotation(data, center, angle) {
292
+ angle = angle * (Math.PI / 180); // Convert to radians
293
+ var rotated = data.map(function (point) {
294
+ return {
295
+ x: Math.round(Math.cos(angle) * (point.x - center.x) - Math.sin(angle) * (point.y - center.y) + center.x),
296
+ y: Math.round(Math.sin(angle) * (point.x - center.x) + Math.cos(angle) * (point.y - center.y) + center.y)
297
+ };
298
+ });
299
+ return rotated;
300
+ }
301
+
302
+ /**
303
+ * Resize annotation data in canvas format to new image size
304
+ * @param {*} data Annotation data in canvas format [{x:int, y:int},...]
305
+ * @param {*} sizeOld Size of old image {width:int, height:int}
306
+ * @param {*} sizeNew Size of new image {width:int, height:int}
307
+ */
308
+ function resizeAnnoData(data, sizeOld, sizeNew) {
309
+ var xRatio = sizeNew.width / sizeOld.width;
310
+ var yRatio = sizeNew.height / sizeOld.height;
311
+ return data.map(function (e) {
312
+ return {
313
+ x: parseInt(e.x * xRatio),
314
+ y: parseInt(e.y * yRatio)
315
+ };
316
+ });
317
+ }
318
+
319
+ var transform = /*#__PURE__*/Object.freeze({
320
+ toSia: toSia,
321
+ toBackend: toBackend,
322
+ getMinMaxPoints: getMinMaxPoints,
323
+ getArea: getArea,
324
+ move: move,
325
+ getBox: getBox,
326
+ getCenter: getCenter,
327
+ getMostLeftPoint: getMostLeftPoint,
328
+ getTopPoint: getTopPoint,
329
+ correctAnnotation: correctAnnotation,
330
+ rotateAnnotation: rotateAnnotation,
331
+ resizeAnnoData: resizeAnnoData
332
+ });
333
+
226
334
  var VIEW = 'view';
227
335
  var EDIT = 'edit';
228
336
  var CREATE = 'create';
@@ -894,6 +1002,31 @@ var CANVAS_IMGBAR_CLOSE = 'canvasImgbarClose';
894
1002
  //Image actions
895
1003
  var IMG_LABEL_UPDATE = 'imgLabelUpdate';
896
1004
 
1005
+ var canvasActions = /*#__PURE__*/Object.freeze({
1006
+ ANNO_DELETED: ANNO_DELETED,
1007
+ ANNO_SELECTED: ANNO_SELECTED,
1008
+ ANNO_CREATED: ANNO_CREATED,
1009
+ ANNO_MOVED: ANNO_MOVED,
1010
+ ANNO_ENTER_MOVE_MODE: ANNO_ENTER_MOVE_MODE,
1011
+ ANNO_EDITED: ANNO_EDITED,
1012
+ ANNO_ENTER_EDIT_MODE: ANNO_ENTER_EDIT_MODE,
1013
+ ANNO_ADDED_NODE: ANNO_ADDED_NODE,
1014
+ ANNO_REMOVED_NODE: ANNO_REMOVED_NODE,
1015
+ ANNO_LABEL_UPDATE: ANNO_LABEL_UPDATE,
1016
+ ANNO_CREATED_NODE: ANNO_CREATED_NODE,
1017
+ ANNO_CREATED_FINAL_NODE: ANNO_CREATED_FINAL_NODE,
1018
+ ANNO_START_CREATING: ANNO_START_CREATING,
1019
+ ANNO_COMMENT_UPDATE: ANNO_COMMENT_UPDATE,
1020
+ ANNO_MARK_EXAMPLE: ANNO_MARK_EXAMPLE,
1021
+ CANVAS_SVG_UPDATE: CANVAS_SVG_UPDATE,
1022
+ CANVAS_UI_CONFIG_UPDATE: CANVAS_UI_CONFIG_UPDATE,
1023
+ CANVAS_AUTO_SAVE: CANVAS_AUTO_SAVE,
1024
+ CANVAS_LABEL_INPUT_CLOSE: CANVAS_LABEL_INPUT_CLOSE,
1025
+ CANVAS_IMG_LOADED: CANVAS_IMG_LOADED,
1026
+ CANVAS_IMGBAR_CLOSE: CANVAS_IMGBAR_CLOSE,
1027
+ IMG_LABEL_UPDATE: IMG_LABEL_UPDATE
1028
+ });
1029
+
897
1030
  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; };
898
1031
 
899
1032
  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; }; }();
@@ -3543,6 +3676,12 @@ function canvasToBackendAnnos(annos, imgSize) {
3543
3676
  return backendFormat;
3544
3677
  }
3545
3678
 
3679
+ var annoConversion = /*#__PURE__*/Object.freeze({
3680
+ fixBackendAnnos: fixBackendAnnos,
3681
+ backendAnnosToCanvas: backendAnnosToCanvas,
3682
+ canvasToBackendAnnos: canvasToBackendAnnos
3683
+ });
3684
+
3546
3685
  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; }; }();
3547
3686
 
3548
3687
  function _classCallCheck$e(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -3665,6 +3804,15 @@ var KeyMapper = function () {
3665
3804
 
3666
3805
  var POINT = 'point';
3667
3806
  var BBOX = 'bBox';
3807
+ var LINE = 'line';
3808
+ var POLYGON = 'polygon';
3809
+
3810
+ var tools = /*#__PURE__*/Object.freeze({
3811
+ POINT: POINT,
3812
+ BBOX: BBOX,
3813
+ LINE: LINE,
3814
+ POLYGON: POLYGON
3815
+ });
3668
3816
 
3669
3817
  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; }; }();
3670
3818
 
@@ -6859,6 +7007,11 @@ function _inherits$g(subClass, superClass) { if (typeof superClass !== "function
6859
7007
  * action -> CANVAS_IMG_LOADED
6860
7008
  * action -> CANVAS_IMGBAR_CLOSE
6861
7009
  * @event onImgBarClose - Fires when close button on ImgBar was hit.
7010
+ * @event onGetFunction - Get special canvas functions for manipulation from outside canvas
7011
+ * deleteAllAnnos()
7012
+ * unloadImage()
7013
+ * resetZoom()
7014
+ * getAnnos(annos,removeFrontendIds)
6862
7015
  */
6863
7016
 
6864
7017
  var Canvas = function (_Component) {
@@ -8535,5 +8688,1504 @@ var Canvas = function (_Component) {
8535
8688
  return Canvas;
8536
8689
  }(React.Component);
8537
8690
 
8538
- module.exports = Canvas;
8691
+ var TOOL_SELECTED = 'toolSelected';
8692
+ var GET_NEXT_IMAGE = 'getNextImage';
8693
+ var GET_PREV_IMAGE = 'getPrevImage';
8694
+ var TASK_FINISHED = 'taskFinished';
8695
+ var SHOW_IMAGE_LABEL_INPUT = 'showImageLabelInput';
8696
+ var IMG_IS_JUNK = 'imageIsJunk';
8697
+ var DELETE_ALL_ANNOS = 'deleteAllAnnos';
8698
+ var SET_FULLSCREEN = 'setFullscreen';
8699
+ var SHOW_ANNO_DETAILS = 'showAnnoDetails';
8700
+ var SHOW_LABEL_INFO = 'showLabelInfo';
8701
+ var SHOW_ANNO_STATS = 'showAnnoStats';
8702
+ var EDIT_STROKE_WIDTH = 'editStrokeWidth';
8703
+ var EDIT_NODE_RADIUS = 'editNodeRadius';
8704
+ var APPLY_FILTER = 'applyFilter';
8705
+ var SAVE = 'save';
8706
+
8707
+ var toolbarEvents = /*#__PURE__*/Object.freeze({
8708
+ TOOL_SELECTED: TOOL_SELECTED,
8709
+ GET_NEXT_IMAGE: GET_NEXT_IMAGE,
8710
+ GET_PREV_IMAGE: GET_PREV_IMAGE,
8711
+ TASK_FINISHED: TASK_FINISHED,
8712
+ SHOW_IMAGE_LABEL_INPUT: SHOW_IMAGE_LABEL_INPUT,
8713
+ IMG_IS_JUNK: IMG_IS_JUNK,
8714
+ DELETE_ALL_ANNOS: DELETE_ALL_ANNOS,
8715
+ SET_FULLSCREEN: SET_FULLSCREEN,
8716
+ SHOW_ANNO_DETAILS: SHOW_ANNO_DETAILS,
8717
+ SHOW_LABEL_INFO: SHOW_LABEL_INFO,
8718
+ SHOW_ANNO_STATS: SHOW_ANNO_STATS,
8719
+ EDIT_STROKE_WIDTH: EDIT_STROKE_WIDTH,
8720
+ EDIT_NODE_RADIUS: EDIT_NODE_RADIUS,
8721
+ APPLY_FILTER: APPLY_FILTER,
8722
+ SAVE: SAVE
8723
+ });
8724
+
8725
+ 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; }; }();
8726
+
8727
+ function _classCallCheck$j(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8728
+
8729
+ 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; }
8730
+
8731
+ 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; }
8732
+
8733
+ var SIASettingButton = function (_Component) {
8734
+ _inherits$h(SIASettingButton, _Component);
8735
+
8736
+ function SIASettingButton(props) {
8737
+ _classCallCheck$j(this, SIASettingButton);
8738
+
8739
+ var _this = _possibleConstructorReturn$h(this, (SIASettingButton.__proto__ || Object.getPrototypeOf(SIASettingButton)).call(this, props));
8740
+
8741
+ _this.state = {};
8742
+ return _this;
8743
+ }
8744
+
8745
+ _createClass$j(SIASettingButton, [{
8746
+ key: 'triggerEvent',
8747
+ value: function triggerEvent(e, data) {
8748
+ if (this.props.onSettingEvent) {
8749
+ this.props.onSettingEvent(e, data);
8750
+ }
8751
+ }
8752
+ }, {
8753
+ key: 'toggleAnnoDetails',
8754
+ value: function toggleAnnoDetails() {
8755
+ this.triggerEvent(SHOW_ANNO_DETAILS);
8756
+ }
8757
+ }, {
8758
+ key: 'toggleLabelInfo',
8759
+ value: function toggleLabelInfo() {
8760
+ this.triggerEvent(SHOW_LABEL_INFO);
8761
+ }
8762
+ }, {
8763
+ key: 'toggleAnnoStats',
8764
+ value: function toggleAnnoStats() {
8765
+ this.triggerEvent(SHOW_ANNO_STATS);
8766
+ }
8767
+ }, {
8768
+ key: 'handleStrokeWidthChange',
8769
+ value: function handleStrokeWidthChange(e) {
8770
+ this.triggerEvent(EDIT_STROKE_WIDTH, parseInt(e.target.value));
8771
+ }
8772
+ }, {
8773
+ key: 'handleNodeRadiusChange',
8774
+ value: function handleNodeRadiusChange(e) {
8775
+ this.triggerEvent(EDIT_NODE_RADIUS, parseInt(e.target.value));
8776
+ }
8777
+ }, {
8778
+ key: 'renderInfoBoxContent',
8779
+ value: function renderInfoBoxContent() {
8780
+ var _this2 = this;
8781
+
8782
+ return React__default.createElement(
8783
+ 'div',
8784
+ null,
8785
+ React__default.createElement(
8786
+ semanticUiReact.Divider,
8787
+ { horizontal: true },
8788
+ 'Info Boxes'
8789
+ ),
8790
+ React__default.createElement(semanticUiReact.Checkbox, {
8791
+ checked: this.props.uiConfig.annoDetails.visible,
8792
+ label: 'Annotation Details', toggle: true,
8793
+ onClick: function onClick() {
8794
+ return _this2.toggleAnnoDetails();
8795
+ }
8796
+ }),
8797
+ React__default.createElement(semanticUiReact.Checkbox, {
8798
+ checked: this.props.uiConfig.labelInfo.visible,
8799
+ label: 'Label Info', toggle: true,
8800
+ onClick: function onClick() {
8801
+ return _this2.toggleLabelInfo();
8802
+ }
8803
+ }),
8804
+ React__default.createElement(semanticUiReact.Checkbox, {
8805
+ checked: this.props.uiConfig.annoStats.visible,
8806
+ label: 'Anno Stats', toggle: true,
8807
+ onClick: function onClick() {
8808
+ return _this2.toggleAnnoStats();
8809
+ }
8810
+ })
8811
+ );
8812
+ }
8813
+ }, {
8814
+ key: 'renderInfoBoxes',
8815
+ value: function renderInfoBoxes() {
8816
+ if (!this.props.enabled) return null;
8817
+ if (this.props.enabled == true) {
8818
+ return this.renderInfoBoxContent();
8819
+ } else {
8820
+ if (this.props.enabled.infoBoxes) {
8821
+ return this.renderInfoBoxContent();
8822
+ }
8823
+ }
8824
+ }
8825
+ }, {
8826
+ key: 'renderAnnoStyle',
8827
+ value: function renderAnnoStyle() {
8828
+ if (!this.props.enabled) return null;
8829
+ if (this.props.enabled == true) {
8830
+ return this.renderAnnoStyleContent();
8831
+ } else {
8832
+ if (this.props.enabled.annoStyle) {
8833
+ return this.renderAnnoStyleContent();
8834
+ }
8835
+ }
8836
+ }
8837
+ }, {
8838
+ key: 'renderAnnoStyleContent',
8839
+ value: function renderAnnoStyleContent() {
8840
+ var _this3 = this;
8841
+
8842
+ return React__default.createElement(
8843
+ 'div',
8844
+ null,
8845
+ React__default.createElement(
8846
+ semanticUiReact.Divider,
8847
+ { horizontal: true },
8848
+ 'Anno Appearance'
8849
+ ),
8850
+ React__default.createElement(
8851
+ 'div',
8852
+ null,
8853
+ 'Stroke width: ',
8854
+ this.props.uiConfig.strokeWidth
8855
+ ),
8856
+ React__default.createElement('input', {
8857
+ type: 'range',
8858
+ min: 1,
8859
+ max: 10,
8860
+ value: this.props.uiConfig.strokeWidth,
8861
+ onChange: function onChange(e) {
8862
+ return _this3.handleStrokeWidthChange(e);
8863
+ }
8864
+ }),
8865
+ React__default.createElement(
8866
+ 'div',
8867
+ null,
8868
+ 'Node radius: ',
8869
+ this.props.uiConfig.nodeRadius
8870
+ ),
8871
+ React__default.createElement('input', {
8872
+ type: 'range',
8873
+ min: 1,
8874
+ max: 10,
8875
+ value: this.props.uiConfig.nodeRadius,
8876
+ onChange: function onChange(e) {
8877
+ return _this3.handleNodeRadiusChange(e);
8878
+ }
8879
+ })
8880
+ );
8881
+ }
8882
+ }, {
8883
+ key: 'render',
8884
+ value: function render() {
8885
+
8886
+ if (!this.props.uiConfig) return null;
8887
+ var popupContent = React__default.createElement(
8888
+ 'div',
8889
+ null,
8890
+ this.renderInfoBoxes(),
8891
+ this.renderAnnoStyle()
8892
+ );
8893
+ return React__default.createElement(semanticUiReact.Popup, { trigger: React__default.createElement(
8894
+ semanticUiReact.Menu.Item,
8895
+ { name: 'setting' },
8896
+ React__default.createElement(semanticUiReact.Icon, { name: 'setting' })
8897
+ ),
8898
+ content: popupContent,
8899
+ position: "right center",
8900
+ pinned: true,
8901
+ on: 'click',
8902
+ style: { zIndex: 7000 }
8903
+ });
8904
+ }
8905
+ }]);
8906
+
8907
+ return SIASettingButton;
8908
+ }(React.Component);
8909
+
8910
+ function active(filter) {
8911
+ return filter.clahe.active || filter.rotate.active;
8912
+ }
8913
+
8914
+ 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; };
8915
+
8916
+ 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; }; }();
8917
+
8918
+ function _classCallCheck$k(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8919
+
8920
+ 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; }
8921
+
8922
+ 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; }
8923
+
8924
+ var SIAFilterButton = function (_Component) {
8925
+ _inherits$i(SIAFilterButton, _Component);
8926
+
8927
+ function SIAFilterButton(props) {
8928
+ _classCallCheck$k(this, SIAFilterButton);
8929
+
8930
+ var _this = _possibleConstructorReturn$i(this, (SIAFilterButton.__proto__ || Object.getPrototypeOf(SIAFilterButton)).call(this, props));
8931
+
8932
+ _this.state = {
8933
+ clipLimit: 3,
8934
+ active: false,
8935
+ color: undefined
8936
+ };
8937
+ return _this;
8938
+ }
8939
+
8940
+ _createClass$k(SIAFilterButton, [{
8941
+ key: 'componentDidUpdate',
8942
+ value: function componentDidUpdate(prevProps) {
8943
+ if (prevProps.filter.clahe.clipLimit !== this.props.filter.clahe.clipLimit) {
8944
+ this.setState({ clipLimit: this.props.filter.clahe.clipLimit });
8945
+ }
8946
+ if (this.props.filter !== prevProps.filter) {
8947
+ if (active(this.props.filter)) {
8948
+ this.setState({ color: 'red', active: true });
8949
+ } else {
8950
+ this.setState({ color: 'white', active: false });
8951
+ }
8952
+ }
8953
+ }
8954
+ }, {
8955
+ key: 'triggerEvent',
8956
+ value: function triggerEvent(e, data) {
8957
+ if (this.props.onFilterEvent) {
8958
+ this.props.onFilterEvent(e, data);
8959
+ }
8960
+ }
8961
+ }, {
8962
+ key: 'handleClipLimitChange',
8963
+ value: function handleClipLimitChange(e) {
8964
+ var cl = parseInt(e.target.value);
8965
+ this.setState({ clipLimit: cl });
8966
+ // this.claheFilter(cl)
8967
+ }
8968
+ }, {
8969
+ key: 'rotateImg',
8970
+ value: function rotateImg(angle) {
8971
+ var active$$1 = !(this.props.filter.rotate.active && this.props.filter.rotate.angle === angle);
8972
+ var myAngle = active$$1 ? angle : 0;
8973
+ this.triggerEvent(APPLY_FILTER, _extends$c({}, this.props.filter, {
8974
+ rotate: { angle: myAngle, active: active$$1 }
8975
+ }));
8976
+
8977
+ // this.props.siaApplyFilter({
8978
+ // ...this.props.filter,
8979
+ // rotate: {angle:myAngle, active:active}
8980
+ // })
8981
+ }
8982
+ }, {
8983
+ key: 'claheFilter',
8984
+ value: function claheFilter(clipLimit) {
8985
+ var filter = {
8986
+ 'clahe': {
8987
+ 'clipLimit': clipLimit,
8988
+ active: !this.props.filter.clahe.active
8989
+ }
8990
+ };
8991
+ this.triggerEvent(APPLY_FILTER, _extends$c({}, this.props.filter, {
8992
+ clahe: filter.clahe
8993
+ }));
8994
+ // this.props.siaApplyFilter({
8995
+ // ...this.props.filter,
8996
+ // clahe: filter.clahe
8997
+ // })
8998
+ }
8999
+ }, {
9000
+ key: 'releaseCLAHESlider',
9001
+ value: function releaseCLAHESlider(e) {
9002
+ var filter = {
9003
+ 'clahe': {
9004
+ 'clipLimit': parseInt(e.target.value),
9005
+ active: true
9006
+ }
9007
+ };
9008
+ this.triggerEvent(APPLY_FILTER, _extends$c({}, this.props.filter, {
9009
+ clahe: filter.clahe
9010
+ }));
9011
+ // this.props.siaApplyFilter({
9012
+ // ...this.props.filter,
9013
+ // clahe: filter.clahe
9014
+ // })
9015
+ }
9016
+ }, {
9017
+ key: 'renderRotateContent',
9018
+ value: function renderRotateContent() {
9019
+ var _this2 = this;
9020
+
9021
+ var filter = this.props.filter;
9022
+ return React__default.createElement(
9023
+ 'div',
9024
+ null,
9025
+ React__default.createElement(
9026
+ semanticUiReact.Divider,
9027
+ { horizontal: true },
9028
+ 'Rotate'
9029
+ ),
9030
+ React__default.createElement(semanticUiReact.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__default.createElement(semanticUiReact.Checkbox, {
9038
+ checked: filter.rotate.active && filter.rotate.angle === -90,
9039
+ label: 'Rotate -90', toggle: true,
9040
+ onClick: function onClick() {
9041
+ return _this2.rotateImg(-90);
9042
+ }
9043
+ }),
9044
+ React__default.createElement(semanticUiReact.Checkbox, {
9045
+ checked: filter.rotate.active && filter.rotate.angle === 180,
9046
+ label: 'Rotate 180', toggle: true,
9047
+ onClick: function onClick() {
9048
+ return _this2.rotateImg(180);
9049
+ }
9050
+ })
9051
+ );
9052
+ }
9053
+ }, {
9054
+ key: 'renderRotate',
9055
+ value: function renderRotate() {
9056
+ if (!this.props.enabled) return null;
9057
+ if (this.props.enabled === true) {
9058
+ return this.renderRotateContent();
9059
+ } else {
9060
+ if (this.props.enabled.rotate) {
9061
+ return this.renderRotateContent();
9062
+ }
9063
+ }
9064
+ }
9065
+ }, {
9066
+ key: 'renderClaheContent',
9067
+ value: function renderClaheContent() {
9068
+ var _this3 = this;
9069
+
9070
+ var filter = this.props.filter;
9071
+ return React__default.createElement(
9072
+ 'div',
9073
+ null,
9074
+ React__default.createElement(
9075
+ semanticUiReact.Divider,
9076
+ { horizontal: true },
9077
+ 'Histogram equalization'
9078
+ ),
9079
+ React__default.createElement(semanticUiReact.Checkbox, {
9080
+ checked: filter.clahe.active,
9081
+ label: 'Histogram equalization', toggle: true,
9082
+ onClick: function onClick() {
9083
+ return _this3.claheFilter(_this3.state.clipLimit);
9084
+ }
9085
+ }),
9086
+ React__default.createElement(
9087
+ 'div',
9088
+ null,
9089
+ 'Cliplimit: ',
9090
+ this.state.clipLimit
9091
+ ),
9092
+ React__default.createElement('input', {
9093
+ type: 'range',
9094
+ min: 0,
9095
+ max: 40,
9096
+ value: this.state.clipLimit,
9097
+ onChange: function onChange(e) {
9098
+ return _this3.handleClipLimitChange(e);
9099
+ },
9100
+ onMouseUp: function onMouseUp(e) {
9101
+ return _this3.releaseCLAHESlider(e);
9102
+ }
9103
+ })
9104
+ );
9105
+ }
9106
+ }, {
9107
+ key: 'renderClahe',
9108
+ value: function renderClahe() {
9109
+ if (!this.props.enabled) return null;
9110
+ if (this.props.enabled === true) {
9111
+ return this.renderClaheContent();
9112
+ } else {
9113
+ if (this.props.enabled.clahe) {
9114
+ return this.renderClaheContent();
9115
+ }
9116
+ }
9117
+ }
9118
+ }, {
9119
+ key: 'render',
9120
+ value: function render() {
9121
+ if (!this.props.imageMeta) return null;
9122
+ var popupContent = React__default.createElement(
9123
+ 'div',
9124
+ null,
9125
+ this.renderRotate(),
9126
+ this.renderClahe()
9127
+ );
9128
+ return React__default.createElement(semanticUiReact.Popup, { trigger: React__default.createElement(
9129
+ semanticUiReact.Menu.Item,
9130
+ { name: 'filter', active: this.state.active },
9131
+ React__default.createElement(semanticUiReact.Icon, { name: 'filter', color: this.state.color })
9132
+ ),
9133
+ content: popupContent,
9134
+ position: "right center",
9135
+ pinned: true,
9136
+ on: 'click',
9137
+ style: { zIndex: 7000 }
9138
+ });
9139
+ }
9140
+ }]);
9141
+
9142
+ return SIAFilterButton;
9143
+ }(React.Component);
9144
+
9145
+ function textIcon() {
9146
+ return React__default.createElement(
9147
+ "svg",
9148
+ { version: "1.1", xmlns: "http://www.w3.org/2000/svg"
9149
+ // x="0px" y="0px"
9150
+ // width="1190.549px" height="841.891px"
9151
+ , viewBox: "0 0 1190.549 841.891",
9152
+ width: "17px"
9153
+ // onClick={e => this.handleClick(e)}
9154
+ },
9155
+ React__default.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" })
9156
+ );
9157
+ }
9158
+
9159
+ function lineIcon() {
9160
+ return React__default.createElement(
9161
+ "svg",
9162
+ { version: "1.1", id: "Linie", xmlns: "http://www.w3.org/2000/svg"
9163
+ // xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
9164
+ // width="1190.549px" height="841.891px"
9165
+ , viewBox: "0 0 1190.549 841.891",
9166
+ width: "17px"
9167
+ // enable-background="new 0 0 1190.549 841.891"
9168
+ // xml:space="preserve"
9169
+ },
9170
+ React__default.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" })
9171
+ );
9172
+ }
9173
+
9174
+ function bBoxIcon() {
9175
+ return React__default.createElement(
9176
+ "svg",
9177
+ { version: "1.1", id: "Linie", xmlns: "http://www.w3.org/2000/svg"
9178
+ // xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
9179
+ // width="1190.549px" height="841.891px"
9180
+ , viewBox: "0 0 1190.549 841.891",
9181
+ width: "17px"
9182
+ // enable-background="new 0 0 1190.549 841.891"
9183
+ // xml:space="preserve"
9184
+ },
9185
+ React__default.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" })
9186
+ );
9187
+ }
9188
+
9189
+ function polygonIcon() {
9190
+ return React__default.createElement(
9191
+ "svg",
9192
+ { version: "1.1", id: "Linie", xmlns: "http://www.w3.org/2000/svg"
9193
+ // xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
9194
+ // width="1190.549px" height="841.891px"
9195
+ , viewBox: "0 0 1190.549 841.891",
9196
+ width: "17px"
9197
+ // enable-background="new 0 0 1190.549 841.891"
9198
+ // xml:space="preserve"
9199
+ },
9200
+ React__default.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" })
9201
+ );
9202
+ }
9203
+
9204
+ function pointIcon() {
9205
+ return React__default.createElement(
9206
+ "svg",
9207
+ { version: "1.1", xmlns: "http://www.w3.org/2000/svg"
9208
+ // x="0px" y="0px"
9209
+ // width="1190.549px" height="841.891px"
9210
+ , viewBox: "0 0 1190.549 841.891",
9211
+ width: "17px"
9212
+ },
9213
+ React__default.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" })
9214
+ );
9215
+ }
9216
+
9217
+ 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; };
9218
+
9219
+ 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; }; }();
9220
+
9221
+ function _classCallCheck$l(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9222
+
9223
+ 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; }
9224
+
9225
+ 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; }
9226
+
9227
+ var ToolBar = function (_Component) {
9228
+ _inherits$j(ToolBar, _Component);
9229
+
9230
+ function ToolBar(props) {
9231
+ _classCallCheck$l(this, ToolBar);
9232
+
9233
+ var _this = _possibleConstructorReturn$j(this, (ToolBar.__proto__ || Object.getPrototypeOf(ToolBar)).call(this, props));
9234
+
9235
+ _this.state = {
9236
+ // fullscreenMode: false,
9237
+ position: {
9238
+ left: 0,
9239
+ top: 5,
9240
+ width: 40
9241
+ },
9242
+ showFinishPrompt: false,
9243
+ showHelp: false
9244
+ };
9245
+ _this.toolBarGroup = React__default.createRef();
9246
+ return _this;
9247
+ }
9248
+
9249
+ _createClass$l(ToolBar, [{
9250
+ key: 'componentDidMount',
9251
+ value: function componentDidMount() {}
9252
+ }, {
9253
+ key: 'componentDidUpdate',
9254
+ value: function componentDidUpdate(prevProps, prevState) {
9255
+ // if (prevState.fullscreenMode !== this.state.fullscreenMode){
9256
+ // this.props.siaSetFullscreen(this.state.fullscreenMode)
9257
+ // }
9258
+
9259
+ if (this.props.layoutUpdate !== prevProps.layoutUpdate) {
9260
+ this.calcPosition();
9261
+ }
9262
+ if (this.props.svg !== prevProps.svg) {
9263
+ this.calcPosition();
9264
+ }
9265
+ }
9266
+ }, {
9267
+ key: 'onClick',
9268
+ value: function onClick(e, tool) {
9269
+ this.triggerToolBarEvent(TOOL_SELECTED, tool);
9270
+ }
9271
+ }, {
9272
+ key: 'calcPosition',
9273
+ value: function calcPosition() {
9274
+ if (!this.props.enabled) return;
9275
+ var tb = this.toolBarGroup.current.getBoundingClientRect();
9276
+ if (tb) {
9277
+ if (this.props.svg) {
9278
+ var toolBarTop = undefined;
9279
+ toolBarTop = this.props.svg.top + this.props.svg.height / 6;
9280
+ this.setState({
9281
+ position: _extends$d({}, this.state.position, {
9282
+ left: this.props.svg.left - 55,
9283
+ top: toolBarTop
9284
+ })
9285
+ });
9286
+ }
9287
+ }
9288
+ }
9289
+ }, {
9290
+ key: 'getNextImg',
9291
+ value: function getNextImg() {
9292
+ // this.props.siaGetNextImage(this.props.imageMeta.id)
9293
+ this.triggerToolBarEvent(GET_NEXT_IMAGE);
9294
+ }
9295
+ }, {
9296
+ key: 'getPrevImg',
9297
+ value: function getPrevImg() {
9298
+ // this.props.siaGetPrevImage(this.props.imageMeta.id)
9299
+ this.triggerToolBarEvent(GET_PREV_IMAGE);
9300
+ }
9301
+ }, {
9302
+ key: 'setFinished',
9303
+ value: function setFinished() {
9304
+ // this.props.siaSetTaskFinished()
9305
+ this.triggerToolBarEvent(TASK_FINISHED);
9306
+ }
9307
+ }, {
9308
+ key: 'toggleFinishPrompt',
9309
+ value: function toggleFinishPrompt() {
9310
+ this.setState({
9311
+ showFinishPrompt: !this.state.showFinishPrompt
9312
+ });
9313
+ }
9314
+ }, {
9315
+ key: 'toggleFullscreen',
9316
+ value: function toggleFullscreen() {
9317
+ // this.setState({
9318
+ // fullscreenMode: !this.state.fullscreenMode
9319
+ // })
9320
+ this.triggerToolBarEvent(SET_FULLSCREEN);
9321
+ }
9322
+ }, {
9323
+ key: 'toggleImgLabelInput',
9324
+ value: function toggleImgLabelInput() {
9325
+ // this.props.siaShowImgLabelInput(!this.props.imgLabelInput.show)
9326
+ this.triggerToolBarEvent(SHOW_IMAGE_LABEL_INPUT);
9327
+ }
9328
+ }, {
9329
+ key: 'toggleJunk',
9330
+ value: function toggleJunk() {
9331
+ // this.props.siaImgIsJunk(!this.props.isJunk)
9332
+ this.triggerToolBarEvent(IMG_IS_JUNK);
9333
+ }
9334
+ }, {
9335
+ key: 'toggleHelp',
9336
+ value: function toggleHelp() {
9337
+ this.setState({ showHelp: !this.state.showHelp });
9338
+ }
9339
+ }, {
9340
+ key: 'handleOnDeleteAllAnnos',
9341
+ value: function handleOnDeleteAllAnnos() {
9342
+ this.triggerToolBarEvent(DELETE_ALL_ANNOS);
9343
+ }
9344
+ }, {
9345
+ key: 'handleSave',
9346
+ value: function handleSave() {
9347
+ this.triggerToolBarEvent(SAVE);
9348
+ }
9349
+ }, {
9350
+ key: 'triggerToolBarEvent',
9351
+ value: function triggerToolBarEvent(event, data) {
9352
+ if (this.props.onToolBarEvent) {
9353
+ this.props.onToolBarEvent(event, data);
9354
+ }
9355
+ }
9356
+ }, {
9357
+ key: 'renderToolButtons',
9358
+ value: function renderToolButtons() {
9359
+ var _this2 = this;
9360
+
9361
+ if (!this.props.canvasConfig) return null;
9362
+ if (!this.props.enabled.toolSelection) return null;
9363
+ if (!this.props.canvasConfig.annos.actions.draw) return null;
9364
+ var btns = [];
9365
+ if (this.props.canvasConfig.tools.point) {
9366
+ btns.push(React__default.createElement(
9367
+ semanticUiReact.Menu.Item,
9368
+ { name: 'dot circle', key: POINT,
9369
+ active: this.props.active.selectedTool === POINT,
9370
+ onClick: function onClick(e) {
9371
+ return _this2.onClick(e, POINT);
9372
+ }
9373
+ },
9374
+ pointIcon()
9375
+ ));
9376
+ }
9377
+ if (this.props.canvasConfig.tools.line) {
9378
+ btns.push(React__default.createElement(
9379
+ semanticUiReact.Menu.Item,
9380
+ { name: 'paint brush', key: LINE,
9381
+ active: this.props.active.selectedTool === LINE,
9382
+ onClick: function onClick(e) {
9383
+ return _this2.onClick(e, LINE);
9384
+ }
9385
+ },
9386
+ lineIcon()
9387
+ ));
9388
+ }
9389
+ if (this.props.canvasConfig.tools.bbox) {
9390
+ btns.push(React__default.createElement(
9391
+ semanticUiReact.Menu.Item,
9392
+ { name: 'square outline', key: BBOX,
9393
+ active: this.props.active.selectedTool === BBOX,
9394
+ onClick: function onClick(e) {
9395
+ return _this2.onClick(e, BBOX);
9396
+ }
9397
+ },
9398
+ bBoxIcon()
9399
+ ));
9400
+ }
9401
+ if (this.props.canvasConfig.tools.polygon) {
9402
+ btns.push(React__default.createElement(
9403
+ semanticUiReact.Menu.Item,
9404
+ { name: 'pencil alternate', key: POLYGON,
9405
+ active: this.props.active.selectedTool === POLYGON,
9406
+ onClick: function onClick(e) {
9407
+ return _this2.onClick(e, POLYGON);
9408
+ }
9409
+ },
9410
+ polygonIcon()
9411
+ ));
9412
+ }
9413
+ return btns;
9414
+ }
9415
+ }, {
9416
+ key: 'renderFinishPrompt',
9417
+ value: function renderFinishPrompt() {
9418
+ var _this3 = this;
9419
+
9420
+ return React__default.createElement(Prompt, { active: this.state.showFinishPrompt,
9421
+ header: React__default.createElement(
9422
+ 'div',
9423
+ null,
9424
+ React__default.createElement(semanticUiReact.Icon, { name: 'paper plane outline' }),
9425
+ 'Do you wish to FINISH this SIA Task?'
9426
+ ),
9427
+ content: React__default.createElement(
9428
+ 'div',
9429
+ null,
9430
+ React__default.createElement(
9431
+ semanticUiReact.Button,
9432
+ { basic: true, color: 'green', inverted: true,
9433
+ onClick: function onClick() {
9434
+ return _this3.setFinished();
9435
+ }
9436
+ },
9437
+ React__default.createElement(semanticUiReact.Icon, { name: 'check' }),
9438
+ 'Yes'
9439
+ ),
9440
+ React__default.createElement(
9441
+ semanticUiReact.Button,
9442
+ { basic: true, color: 'red', inverted: true,
9443
+ onClick: function onClick() {
9444
+ return _this3.toggleFinishPrompt();
9445
+ }
9446
+ },
9447
+ React__default.createElement(semanticUiReact.Icon, { name: 'ban' }),
9448
+ ' No'
9449
+ )
9450
+ )
9451
+ });
9452
+ }
9453
+ /**
9454
+ * Render next and prev image buttons
9455
+ *
9456
+ */
9457
+
9458
+ }, {
9459
+ key: 'renderNavigation',
9460
+ value: function renderNavigation() {
9461
+ var _this4 = this;
9462
+
9463
+ var btns = [];
9464
+ if (!this.props.enabled.nextPrev) return null;
9465
+ if (this.props.imageMeta) {
9466
+ if (this.props.imageMeta.isLast) {
9467
+ btns.push(React__default.createElement(
9468
+ semanticUiReact.Menu.Item,
9469
+ { name: 'paper plane outline', key: 'finish',
9470
+ active: false,
9471
+ onClick: function onClick() {
9472
+ return _this4.toggleFinishPrompt();
9473
+ }
9474
+ },
9475
+ React__default.createElement(semanticUiReact.Icon, { name: 'paper plane outline' }),
9476
+ this.renderFinishPrompt()
9477
+ ));
9478
+ } else {
9479
+ btns.push(React__default.createElement(
9480
+ semanticUiReact.Menu.Item,
9481
+ { name: 'arrow right', key: 'next',
9482
+ active: false,
9483
+ onClick: function onClick() {
9484
+ return _this4.getNextImg();
9485
+ }
9486
+ },
9487
+ React__default.createElement(semanticUiReact.Icon, { name: 'arrow right' })
9488
+ ));
9489
+ }
9490
+ btns.push(React__default.createElement(
9491
+ semanticUiReact.Menu.Item,
9492
+ { name: 'arrow left', key: 'prev',
9493
+ active: false,
9494
+ onClick: function onClick() {
9495
+ return _this4.getPrevImg();
9496
+ },
9497
+ disabled: this.props.imageMeta.isFirst
9498
+ },
9499
+ React__default.createElement(semanticUiReact.Icon, { name: 'arrow left' })
9500
+ ));
9501
+ }
9502
+ return btns;
9503
+ }
9504
+ }, {
9505
+ key: 'renderJunkButton',
9506
+ value: function renderJunkButton() {
9507
+ var _this5 = this;
9508
+
9509
+ if (!this.props.enabled.junk) return null;
9510
+ return React__default.createElement(
9511
+ semanticUiReact.Menu.Item,
9512
+ { name: 'ban', key: 'junk',
9513
+ active: this.props.active.isJunk,
9514
+ onClick: function onClick() {
9515
+ return _this5.toggleJunk();
9516
+ }
9517
+ },
9518
+ React__default.createElement(semanticUiReact.Icon, { name: 'ban' })
9519
+ );
9520
+ }
9521
+ }, {
9522
+ key: 'renderDeleteAllAnnosButton',
9523
+ value: function renderDeleteAllAnnosButton() {
9524
+ var _this6 = this;
9525
+
9526
+ if (!this.props.enabled.deleteAll) return null;
9527
+ return React__default.createElement(
9528
+ semanticUiReact.Menu.Item,
9529
+ { name: 'trash alternate outline', key: 'deleteAllAnnos',
9530
+ onClick: function onClick() {
9531
+ return _this6.handleOnDeleteAllAnnos();
9532
+ }
9533
+ },
9534
+ React__default.createElement(semanticUiReact.Icon, { name: 'trash alternate outline' })
9535
+ );
9536
+ }
9537
+ }, {
9538
+ key: 'renderSaveButton',
9539
+ value: function renderSaveButton() {
9540
+ var _this7 = this;
9541
+
9542
+ if (!this.props.enabled.save) return null;
9543
+ return React__default.createElement(
9544
+ semanticUiReact.Menu.Item,
9545
+ { name: 'save', key: 'save',
9546
+ onClick: function onClick() {
9547
+ return _this7.handleSave();
9548
+ }
9549
+ },
9550
+ React__default.createElement(semanticUiReact.Icon, { name: 'save' })
9551
+ );
9552
+ }
9553
+ }, {
9554
+ key: 'renderHelpButton',
9555
+ value: function renderHelpButton() {
9556
+ var _this8 = this;
9557
+
9558
+ if (!this.props.enabled.help) return null;
9559
+ return React__default.createElement(
9560
+ semanticUiReact.Menu.Item,
9561
+ { name: 'help', key: 'help',
9562
+ active: false,
9563
+ onClick: function onClick() {
9564
+ return _this8.toggleHelp();
9565
+ }
9566
+ },
9567
+ React__default.createElement(semanticUiReact.Icon, { name: 'help' }),
9568
+ React__default.createElement(Prompt, { active: this.state.showHelp,
9569
+ content: React__default.createElement(
9570
+ 'div',
9571
+ null,
9572
+ React__default.createElement(
9573
+ semanticUiReact.Card.Group,
9574
+ null,
9575
+ React__default.createElement(
9576
+ semanticUiReact.Card,
9577
+ null,
9578
+ React__default.createElement(semanticUiReact.Card.Content, { header: 'How to draw?' }),
9579
+ React__default.createElement(semanticUiReact.Card.Content, { description: '1.) Select a Tool in the toolbar 2.) Draw with RIGHT CLICK on Canvas' })
9580
+ ),
9581
+ React__default.createElement(
9582
+ semanticUiReact.Card,
9583
+ null,
9584
+ React__default.createElement(semanticUiReact.Card.Content, { header: 'How to delete an annotation?' }),
9585
+ React__default.createElement(semanticUiReact.Card.Content, { description: '1.) Select an annotation with LEFT CLICK 2.) Press DELETE or BACKSPACE' })
9586
+ ),
9587
+ React__default.createElement(
9588
+ semanticUiReact.Card,
9589
+ null,
9590
+ React__default.createElement(semanticUiReact.Card.Content, { header: 'How to assign a label?' }),
9591
+ React__default.createElement(semanticUiReact.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' })
9592
+ ),
9593
+ React__default.createElement(
9594
+ semanticUiReact.Card,
9595
+ null,
9596
+ React__default.createElement(semanticUiReact.Card.Content, { header: 'Undo/ Redo' }),
9597
+ React__default.createElement(semanticUiReact.Card.Content, { description: 'Undo: Hit STRG + Z' }),
9598
+ React__default.createElement(semanticUiReact.Card.Content, { description: 'Redo: Hit STRG + R' })
9599
+ ),
9600
+ React__default.createElement(
9601
+ semanticUiReact.Card,
9602
+ null,
9603
+ React__default.createElement(semanticUiReact.Card.Content, { header: 'Add a node to Line/Polygon' }),
9604
+ React__default.createElement(semanticUiReact.Card.Content, { description: 'Hit STRG + Click left on the line' })
9605
+ ),
9606
+ React__default.createElement(
9607
+ semanticUiReact.Card,
9608
+ null,
9609
+ React__default.createElement(semanticUiReact.Card.Content, { header: 'Remove a node from Line/Polygon in create mode' }),
9610
+ React__default.createElement(semanticUiReact.Card.Content, { description: 'Press DELETE or BACKSPACE' })
9611
+ ),
9612
+ React__default.createElement(
9613
+ semanticUiReact.Card,
9614
+ null,
9615
+ React__default.createElement(semanticUiReact.Card.Content, { header: 'Edit Line/Polygon' }),
9616
+ React__default.createElement(semanticUiReact.Card.Content, { description: '1.) Click on the Annotation you want to edit.' }),
9617
+ React__default.createElement(semanticUiReact.Card.Content, { description: '2.) Press "e". New nodes can now be added using right click' })
9618
+ ),
9619
+ React__default.createElement(
9620
+ semanticUiReact.Card,
9621
+ null,
9622
+ React__default.createElement(semanticUiReact.Card.Content, { header: 'Zoom/ Move Canvas' }),
9623
+ React__default.createElement(semanticUiReact.Card.Content, { description: 'Zoom: Use MOUSE WHEEL to zoom in/out' }),
9624
+ React__default.createElement(semanticUiReact.Card.Content, { description: 'Move: Hold MOUSE WHEEL and move mouse. Or Use W/A/S/D keys to move camera up/left/down/right' })
9625
+ ),
9626
+ React__default.createElement(
9627
+ semanticUiReact.Card,
9628
+ null,
9629
+ React__default.createElement(semanticUiReact.Card.Content, { header: 'TAB navigation' }),
9630
+ React__default.createElement(semanticUiReact.Card.Content, { description: 'You can traverse all visible annotation by hitting TAB.' })
9631
+ ),
9632
+ React__default.createElement(
9633
+ semanticUiReact.Card,
9634
+ null,
9635
+ React__default.createElement(semanticUiReact.Card.Content, { header: 'Next/Prev image navigation' }),
9636
+ React__default.createElement(semanticUiReact.Card.Content, { description: 'Get next image by hitting ARROW_RIGHT key. Get previous image by hitting ARROW_LEFT key.' })
9637
+ ),
9638
+ React__default.createElement(
9639
+ semanticUiReact.Card,
9640
+ null,
9641
+ React__default.createElement(semanticUiReact.Card.Content, { header: 'Copy and Paste annotations' }),
9642
+ React__default.createElement(semanticUiReact.Card.Content, { description: 'Copy: 1.) Select annotation 2.) Hit STRG + C' }),
9643
+ React__default.createElement(semanticUiReact.Card.Content, { description: 'Paste: STRG + V' })
9644
+ ),
9645
+ React__default.createElement(
9646
+ semanticUiReact.Card,
9647
+ null,
9648
+ React__default.createElement(semanticUiReact.Card.Content, { header: 'Mark image as junk' }),
9649
+ React__default.createElement(semanticUiReact.Card.Content, { description: '1.) Press J key' })
9650
+ ),
9651
+ React__default.createElement(
9652
+ semanticUiReact.Card,
9653
+ null,
9654
+ React__default.createElement(semanticUiReact.Card.Content, { header: 'Assign a comment to a 2D annoation' }),
9655
+ React__default.createElement(semanticUiReact.Card.Content, { description: '1.) Select annotation 2.) Hit C key' })
9656
+ )
9657
+ )
9658
+ )
9659
+ })
9660
+ );
9661
+ }
9662
+ }, {
9663
+ key: 'renderImgLabelInput',
9664
+ value: function renderImgLabelInput() {
9665
+ var _this9 = this;
9666
+
9667
+ if (!this.props.enabled.imgLabel) return null;
9668
+ if (this.props.canvasConfig.img.actions.label) {
9669
+ return React__default.createElement(
9670
+ semanticUiReact.Menu.Item,
9671
+ { name: 'img label input'
9672
+ // active={this.props.imgLabelInput.show}
9673
+ , onClick: function onClick() {
9674
+ return _this9.toggleImgLabelInput();
9675
+ }
9676
+ },
9677
+ textIcon()
9678
+ );
9679
+ }
9680
+ }
9681
+ }, {
9682
+ key: 'renderFullscreenBtn',
9683
+ value: function renderFullscreenBtn() {
9684
+ var _this10 = this;
9685
+
9686
+ if (!this.props.enabled.fullscreen) return null;
9687
+ return React__default.createElement(
9688
+ semanticUiReact.Menu.Item,
9689
+ { name: 'expand arrows alternate',
9690
+ active: this.props.active.fullscreen,
9691
+ onClick: function onClick() {
9692
+ return _this10.toggleFullscreen();
9693
+ }
9694
+ },
9695
+ React__default.createElement(semanticUiReact.Icon, { name: 'expand arrows alternate' })
9696
+ );
9697
+ }
9698
+ }, {
9699
+ key: 'renderSettingBtn',
9700
+ value: function renderSettingBtn() {
9701
+ var _this11 = this;
9702
+
9703
+ if (!this.props.enabled.settings) return null;
9704
+ return React__default.createElement(SIASettingButton, {
9705
+ enabled: this.props.enabled.settings,
9706
+ uiConfig: this.props.uiConfig,
9707
+ onSettingEvent: function onSettingEvent(e, data) {
9708
+ return _this11.triggerToolBarEvent(e, data);
9709
+ } });
9710
+ }
9711
+ }, {
9712
+ key: 'renderFilterBtn',
9713
+ value: function renderFilterBtn() {
9714
+ var _this12 = this;
9715
+
9716
+ if (!this.props.enabled.filter) return null;
9717
+ return React__default.createElement(SIAFilterButton, {
9718
+ enabled: this.props.enabled.filter,
9719
+ onFilterEvent: function onFilterEvent(e, data) {
9720
+ return _this12.triggerToolBarEvent(e, data);
9721
+ },
9722
+ filter: this.props.filter,
9723
+ imageMeta: this.props.imageMeta
9724
+ });
9725
+ }
9726
+ }, {
9727
+ key: 'render',
9728
+ value: function render() {
9729
+ if (!this.props.enabled) return null;
9730
+ return React__default.createElement(
9731
+ 'div',
9732
+ {
9733
+ ref: this.toolBarGroup,
9734
+ style: { position: 'fixed', top: this.state.position.top, left: this.state.position.left } },
9735
+ React__default.createElement(
9736
+ semanticUiReact.Menu,
9737
+ { icon: true, inverted: true, vertical: true },
9738
+ this.renderSaveButton(),
9739
+ this.renderImgLabelInput(),
9740
+ this.renderNavigation(),
9741
+ this.renderToolButtons(),
9742
+ this.renderFullscreenBtn(),
9743
+ this.renderJunkButton(),
9744
+ this.renderDeleteAllAnnosButton(),
9745
+ this.renderHelpButton(),
9746
+ this.renderSettingBtn(),
9747
+ this.renderFilterBtn()
9748
+ )
9749
+ );
9750
+ }
9751
+ }]);
9752
+
9753
+ return ToolBar;
9754
+ }(React.Component);
9755
+
9756
+ 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; };
9757
+
9758
+ 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"); } }; }();
9759
+
9760
+ /**
9761
+ * SIA element that handles annotations within an image
9762
+ *
9763
+ * @param {object} annos - A json object containing all annotation
9764
+ * information for an image
9765
+ * {
9766
+ * image : {
9767
+ * id: int,
9768
+ * number: int,
9769
+ * amount: int,
9770
+ * isFirst: bool,
9771
+ * isLast: bool,
9772
+ * description: string, // -> optional
9773
+ * },
9774
+ * annotations: {
9775
+ * bBoxes: [{
9776
+ * id: int, // -> Not required if status === annoStatus.NEW
9777
+ * data: {},
9778
+ * labelIds: list of int, // -> optional
9779
+ * status: see annoStatus, // -> optional
9780
+ * annoTime: float, // -> optional
9781
+ * },...],
9782
+ * points: []
9783
+ * lines: []
9784
+ * polygons: []
9785
+ * }
9786
+ * }
9787
+ * @param {object} possibleLabels - Possible labels that can be assigned to
9788
+ * an annotation.
9789
+ * [{
9790
+ * id: int,
9791
+ * description: str,
9792
+ * label: str, (name of the label)
9793
+ * color: str (color is optional)
9794
+ * }, ...]
9795
+ * @param {blob} imageBlob - The actual image blob that will be displayed
9796
+ * @param {object} imageMeta - Meta information for the current image
9797
+ * {
9798
+ * "id": int,
9799
+ * "number": int, // -> number of image in current annotask
9800
+ * "amount": int, // -> total number of images in current annotask
9801
+ * "isFirst": bool, // -> True if this image is the first image
9802
+ * "isLast": bool, // -> True if current image is the last image in annotask
9803
+ * "labelIds": list of int, // -> List of label for the current image
9804
+ * "isJunk": bool, // -> Indicates wether current image is a junk image
9805
+ * "annoTime": float, // -> Total annotation time for the current image
9806
+ * "description": str or null // -> Description or comment for the current image
9807
+ * }
9808
+ * @param {object} exampleImg - Example for a selected label
9809
+ * {
9810
+ * "anno": {
9811
+ * "id": int, // -> ID of the example annotation
9812
+ * "comment": null or str // -> Comment that has been assigned to this example
9813
+ * },
9814
+ * "img": image blob
9815
+ * }
9816
+ * @param {bool} isJunk - Indicates wether the current image is junk or not
9817
+ * @param {object} uiConfig - User interface configs
9818
+ * {
9819
+ * nodesRadius: int, strokeWidth: int,
9820
+ * layoutOffset: {left:int, top:int, right:int, bottom:int}, -> Offset of the canvas inside the container
9821
+ * imgBarVisible: bool,
9822
+ * imgLabelInputVisible: bool,
9823
+ * centerCanvasInContainer: bool, -> Center the canvas in the middle of the container.
9824
+ * maxCanvas: bool -> Maximize Canvas Size. Do not fit canvas to image size.
9825
+ * }
9826
+ * @param {int} layoutUpdate - A counter that triggers a layout update
9827
+ * everytime it is incremented.
9828
+ * @param {string} selectedTool - The tool that is selected to draw an
9829
+ * annotation. Possible choices are: 'bBox', 'point', 'line', 'polygon'
9830
+ * @param {object} canvasConfig - Configuration for this canvas
9831
+ * {
9832
+ * annos:{
9833
+ * tools: {
9834
+ * point: bool,
9835
+ * line: bool,
9836
+ * polygon: bool,
9837
+ * bbox: bool
9838
+ * },
9839
+ * multilabels: bool,
9840
+ * actions: {
9841
+ * draw: bool,
9842
+ * label: bool,
9843
+ * edit: bool,
9844
+ * },
9845
+ * maxAnnos: null or int,
9846
+ * minArea: int
9847
+ * },
9848
+ * img: {
9849
+ * multilabels: bool,
9850
+ * actions: {
9851
+ * label: bool,
9852
+ * }
9853
+ * },
9854
+ * allowedToMarkExample: bool, -> Indicates wether the current user is allowed to mark an annotation as example.
9855
+ * autoSaveInterval: int -> Interval in seconds when an autosave will be requested by canvas
9856
+ * }
9857
+ * @param {str or int} defaultLabel (optional) - Name or ID of the default label that is used
9858
+ * when no label was selected by the annotator. If not set "no label" will be used.
9859
+ * If ID is used, it needs to be one of the possible label ids.
9860
+ * @param {bool} blocked Block canvas view with loading dimmer.
9861
+ * @param {int} nextAnnoId Id that will be used for the next annotation that
9862
+ * will be created. If undefined, the canvas will create its own ids.
9863
+ * @param {bool} lockedAnnos A list of AnnoIds of annos that should only be displayed.
9864
+ * Such annos can not be edited in any way.
9865
+ * @param {object} filter Information for the filter Popup
9866
+ * {
9867
+ * "clahe": {
9868
+ * "clipLimit": int,
9869
+ * "active": bool
9870
+ * },
9871
+ * "rotate": {
9872
+ * "angle": 90 | -90 | 180,
9873
+ * "active": bool
9874
+ * }
9875
+ * }
9876
+ * @param {bool | object} toolbarEnabled Defines which toolbar buttons are
9877
+ * displayed or if toolbar is shown at all.
9878
+ * false | {
9879
+ * imgLabel: bool,
9880
+ * nextPrev: bool,
9881
+ * toolSelection: bool,
9882
+ * fullscreen: bool,
9883
+ * junk: bool,
9884
+ * deleteAll: bool,
9885
+ * settings: bool | {infoBoxes: bool, annoStyle: bool},
9886
+ * filter: bool | {rotate: bool, clahe:bool},
9887
+ * help: bool
9888
+ * }
9889
+ * @event onNotification - Callback for Notification messages
9890
+ * args: {title: str, message: str, type: str}
9891
+ * @event onCanvasKeyDown - Fires for keyDown on canvas
9892
+ * @event onAnnoEvent - Fires when an anno performed an action
9893
+ * args: {anno: annoObject, newAnnos: list of annoObjects, pAction: str}
9894
+ * @event onGetAnnoExample - Fires when anno example is requested by canvas
9895
+ * {
9896
+ * id: int, // -> ID of the annotation that will be requested as example
9897
+ * comment: null or str
9898
+ * }
9899
+ * @event onCanvasEvent - Fires on canvas event
9900
+ * args: {action: action, data: dataObject}
9901
+ * action -> CANVAS_SVG_UPDATE
9902
+ * data: {width: int, height: int, scale: float, translateX: float,
9903
+ * translateY:float}
9904
+ * action -> CANVAS_UI_CONFIG_UPDATE
9905
+ * action -> CANVAS_LABEL_INPUT_CLOSE
9906
+ * action -> CANVAS_IMG_LOADED
9907
+ * action -> CANVAS_IMGBAR_CLOSE
9908
+ * @event onToolBarEvent - Fires on Toolbar event
9909
+ * args: {e: event, data: data object}
9910
+ *
9911
+ * e -> DELETE_ALL_ANNOS
9912
+ * e -> TOOL_SELECTED
9913
+ * data: 'bbox', 'point', 'line', 'polygon'
9914
+ * e -> GET_NEXT_IMAGE
9915
+ * data: int // -> Image ID
9916
+ * e -> GET_PREV_IMAGE
9917
+ * data: int // -> Image ID
9918
+ * e -> TASK_FINISHED
9919
+ * data: null
9920
+ * e -> SHOW_IMAGE_LABEL_INPUT
9921
+ * data: null
9922
+ * e -> IMG_IS_JUNK
9923
+ * data: null
9924
+ * e -> APPLY_FILTER
9925
+ * data: {
9926
+ * "clahe": {
9927
+ * "clipLimit": int,
9928
+ * "active": bool
9929
+ * },
9930
+ * "rotate": {
9931
+ * "angle": 90 | -90 | 180,
9932
+ * "active": bool
9933
+ * }
9934
+ * }
9935
+ * e -> SHOW_ANNO_DETAILS
9936
+ * data: null
9937
+ * e -> SHOW_LABEL_INFO
9938
+ * data: null
9939
+ * e -> SHOW_ANNO_STATS
9940
+ * data: null
9941
+ * e -> EDIT_STROKE_WIDTH
9942
+ * data: int // -> Stroke width
9943
+ * e -> EDIT_NODE_RADIUS
9944
+ * data: int // -> Radius
9945
+ * @event onGetFunction - Get special canvas functions for manipulation from outside canvas
9946
+ * deleteAllAnnos()
9947
+ * unloadImage()
9948
+ * resetZoom()
9949
+ * getAnnos(annos,removeFrontendIds)
9950
+ */
9951
+ var Sia = function Sia(props) {
9952
+ var _useState = React.useState(''),
9953
+ _useState2 = _slicedToArray$3(_useState, 2),
9954
+ fullscreenCSS = _useState2[0],
9955
+ setFullscreenCSS = _useState2[1];
9956
+
9957
+ var _useState3 = React.useState(0),
9958
+ _useState4 = _slicedToArray$3(_useState3, 2),
9959
+ layoutUpdate = _useState4[0],
9960
+ setLayoutUpdate = _useState4[1];
9961
+
9962
+ var _useState5 = React.useState(),
9963
+ _useState6 = _slicedToArray$3(_useState5, 2),
9964
+ svg = _useState6[0],
9965
+ setSvg = _useState6[1];
9966
+
9967
+ var _useState7 = React.useState(false),
9968
+ _useState8 = _slicedToArray$3(_useState7, 2),
9969
+ externalConfigUpdate = _useState8[0],
9970
+ setExternalConfigUpdate = _useState8[1];
9971
+
9972
+ var _useState9 = React.useState({
9973
+ "nodeRadius": 4,
9974
+ "strokeWidth": 4,
9975
+ "annoDetails": {
9976
+ "visible": false
9977
+ },
9978
+ "labelInfo": {
9979
+ "visible": false
9980
+ },
9981
+ "annoStats": {
9982
+ "visible": false
9983
+ },
9984
+ "layoutOffset": {
9985
+ "left": 20,
9986
+ "top": 0,
9987
+ "bottom": 5,
9988
+ "right": 5
9989
+ },
9990
+ "imgBarVisible": true,
9991
+ "imgLabelInputVisible": false,
9992
+ "centerCanvasInContainer": true,
9993
+ "maxCanvas": true
9994
+ }),
9995
+ _useState10 = _slicedToArray$3(_useState9, 2),
9996
+ uiConfig = _useState10[0],
9997
+ setUiConfig = _useState10[1];
9998
+
9999
+ var containerRef = React.useRef();
10000
+
10001
+ React.useEffect(function () {
10002
+ doLayoutUpdate();
10003
+ }, [props.layoutUpdate]);
10004
+
10005
+ React.useEffect(function () {
10006
+ setExternalConfigUpdate(true);
10007
+ setUiConfig(_extends$e({}, uiConfig, props.uiConfig));
10008
+ }, [props.uiConfig]);
10009
+
10010
+ React.useEffect(function () {
10011
+ if (externalConfigUpdate) {
10012
+ setExternalConfigUpdate(false);
10013
+ } else {
10014
+ if (props.onCanvasEvent) {
10015
+ props.onCanvasEvent(CANVAS_UI_CONFIG_UPDATE, uiConfig);
10016
+ }
10017
+ }
10018
+ }, [uiConfig]);
10019
+
10020
+ var doLayoutUpdate = function doLayoutUpdate() {
10021
+ setLayoutUpdate(layoutUpdate + 1);
10022
+ };
10023
+
10024
+ var handleAnnoEvent = function handleAnnoEvent(anno, annos, action) {
10025
+ if (props.onAnnoEvent) {
10026
+ props.onAnnoEvent(anno, annos, action);
10027
+ }
10028
+ };
10029
+
10030
+ var handleNotification = function handleNotification(msg) {
10031
+ if (props.onNotification) {
10032
+ props.onNotification(msg);
10033
+ }
10034
+ };
10035
+
10036
+ var handleCanvasKeyDown = function handleCanvasKeyDown(e) {
10037
+ if (props.onCanvasKeyDown) {
10038
+ props.onCanvasKeyDown(e);
10039
+ }
10040
+ };
10041
+
10042
+ var handleCanvasEvent = function handleCanvasEvent(e, data) {
10043
+ switch (e) {
10044
+ case CANVAS_SVG_UPDATE:
10045
+ setSvg(data);
10046
+ break;
10047
+ case CANVAS_UI_CONFIG_UPDATE:
10048
+ setUiConfig(_extends$e({}, uiConfig, data));
10049
+ break;
10050
+ default:
10051
+ break;
10052
+ }
10053
+ if (props.onCanvasEvent) {
10054
+ props.onCanvasEvent(e, data);
10055
+ }
10056
+ };
10057
+
10058
+ var handleGetFunction = function handleGetFunction(deleteAll) {
10059
+ if (props.onGetFunction) {
10060
+ props.onGetFunction(deleteAll);
10061
+ }
10062
+ };
10063
+
10064
+ var handleToolBarEvent = function handleToolBarEvent(e, data) {
10065
+ switch (e) {
10066
+ case SET_FULLSCREEN:
10067
+ if (fullscreenCSS === '') {
10068
+ setFullscreenCSS('sia-fullscreen');
10069
+ setUiConfig(_extends$e({}, uiConfig, {
10070
+ layoutOffset: _extends$e({}, uiConfig.layoutOffset, {
10071
+ left: 50,
10072
+ top: 5
10073
+ })
10074
+ }));
10075
+ doLayoutUpdate();
10076
+ } else {
10077
+ setFullscreenCSS('');
10078
+ setUiConfig(_extends$e({}, uiConfig, {
10079
+ layoutOffset: _extends$e({}, uiConfig.layoutOffset, {
10080
+ left: 20,
10081
+ top: 0
10082
+ })
10083
+ }));
10084
+ doLayoutUpdate();
10085
+ }
10086
+ break;
10087
+ case SHOW_ANNO_DETAILS:
10088
+ setUiConfig(_extends$e({}, uiConfig, {
10089
+ annoDetails: _extends$e({}, uiConfig.annoDetails, {
10090
+ visible: !uiConfig.annoDetails.visible
10091
+ })
10092
+ }));
10093
+ break;
10094
+ case SHOW_LABEL_INFO:
10095
+ setUiConfig(_extends$e({}, uiConfig, {
10096
+ labelInfo: _extends$e({}, uiConfig.labelInfo, {
10097
+ visible: !uiConfig.labelInfo.visible
10098
+ })
10099
+ }));
10100
+ break;
10101
+ case SHOW_ANNO_STATS:
10102
+ setUiConfig(_extends$e({}, uiConfig, {
10103
+ annoStats: _extends$e({}, uiConfig.annoStats, {
10104
+ visible: !uiConfig.annoStats.visible
10105
+ })
10106
+ }));
10107
+ break;
10108
+ case EDIT_STROKE_WIDTH:
10109
+ setUiConfig(_extends$e({}, uiConfig, { strokeWidth: data }));
10110
+ break;
10111
+ case EDIT_NODE_RADIUS:
10112
+ setUiConfig(_extends$e({}, uiConfig, { nodeRadius: data }));
10113
+ break;
10114
+ default:
10115
+ break;
10116
+ }
10117
+ if (props.onToolBarEvent) {
10118
+ props.onToolBarEvent(e, data);
10119
+ }
10120
+ };
10121
+
10122
+ return React__default.createElement(
10123
+ 'div',
10124
+ { className: fullscreenCSS, ref: containerRef },
10125
+ React__default.createElement(Canvas, {
10126
+ container: containerRef,
10127
+
10128
+ onAnnoEvent: function onAnnoEvent(anno, annos, action) {
10129
+ return handleAnnoEvent(anno, annos, action);
10130
+ },
10131
+ onNotification: function onNotification(messageObj) {
10132
+ return handleNotification(messageObj);
10133
+ },
10134
+ onKeyDown: function onKeyDown(e) {
10135
+ return handleCanvasKeyDown(e);
10136
+ },
10137
+ onCanvasEvent: function onCanvasEvent(action, data) {
10138
+ return handleCanvasEvent(action, data);
10139
+ },
10140
+ onGetAnnoExample: function onGetAnnoExample(exampleArgs) {
10141
+ return props.onGetAnnoExample ? props.onGetAnnoExample(exampleArgs) : {};
10142
+ },
10143
+ onGetFunction: function onGetFunction(canvasFunc) {
10144
+ return handleGetFunction(canvasFunc);
10145
+ },
10146
+
10147
+ canvasConfig: props.canvasConfig,
10148
+ uiConfig: uiConfig,
10149
+
10150
+ nextAnnoId: props.nextAnnoId,
10151
+ annos: props.annos,
10152
+ imageMeta: props.imageMeta,
10153
+ imageBlob: props.imageBlob,
10154
+ possibleLabels: props.possibleLabels,
10155
+ exampleImg: props.exampleImg,
10156
+ lockedAnnos: props.lockedAnnos,
10157
+ layoutUpdate: layoutUpdate,
10158
+ selectedTool: props.selectedTool,
10159
+ isJunk: props.isJunk,
10160
+ blocked: props.blockCanvas,
10161
+ defaultLabel: props.defaultLabel
10162
+ }),
10163
+ React__default.createElement(ToolBar, {
10164
+ onToolBarEvent: function onToolBarEvent(e, data) {
10165
+ return handleToolBarEvent(e, data);
10166
+ },
10167
+ imageMeta: props.imageMeta,
10168
+ layoutUpdate: layoutUpdate,
10169
+ svg: svg,
10170
+ active: {
10171
+ isJunk: props.isJunk,
10172
+ selectedTool: props.selectedTool,
10173
+ fullscreen: props.fullscreenMode
10174
+ },
10175
+ enabled: props.toolbarEnabled,
10176
+ canvasConfig: props.canvasConfig,
10177
+ uiConfig: uiConfig,
10178
+ filter: props.filter
10179
+ })
10180
+ );
10181
+ };
10182
+
10183
+ exports.transform = transform;
10184
+ exports.annoConversion = annoConversion;
10185
+ exports.canvasActions = canvasActions;
10186
+ exports.toolbarEvents = toolbarEvents;
10187
+ exports.tools = tools;
10188
+ exports.Canvas = Canvas;
10189
+ exports.Sia = Sia;
10190
+ exports.Toolbar = ToolBar;
8539
10191
  //# sourceMappingURL=index.js.map