lost-sia 2.0.0-alpha0 → 2.0.0-alpha2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +20 -3
- package/src/AnnoExampleViewer.jsx +61 -48
- package/src/AnnoLabelInput.jsx +94 -84
- package/src/AnnoToolBar.jsx +118 -97
- package/src/Annotation/AnnoBar.jsx +137 -131
- package/src/Annotation/Annotation.jsx +364 -328
- package/src/Annotation/Annotation.scss +24 -24
- package/src/Annotation/BBox.jsx +259 -251
- package/src/Annotation/Edge.jsx +79 -69
- package/src/Annotation/InfSelectionArea.jsx +56 -55
- package/src/Annotation/Line.jsx +60 -52
- package/src/Annotation/Node.jsx +242 -238
- package/src/Annotation/Point.jsx +175 -171
- package/src/Annotation/Polygon.jsx +337 -310
- package/src/Canvas.jsx +1910 -1720
- package/src/ImgBar.jsx +115 -107
- package/src/InfoBoxes/AnnoDetails.jsx +141 -141
- package/src/InfoBoxes/AnnoStats.jsx +90 -87
- package/src/InfoBoxes/InfoBox.jsx +63 -65
- package/src/InfoBoxes/InfoBoxArea.jsx +132 -130
- package/src/InfoBoxes/LabelInfo.jsx +103 -83
- package/src/LabelInput.jsx +204 -190
- package/src/Prompt.jsx +37 -38
- package/src/SIA.scss +8 -9
- package/src/SIAFilterButton.jsx +178 -169
- package/src/SIASettingButton.jsx +112 -107
- package/src/Sia.jsx +272 -285
- package/src/SiaPopup.jsx +13 -8
- package/src/ToolBar.jsx +394 -375
- package/src/Toolbar.css +8 -8
- package/src/ToolbarItem.jsx +28 -22
- package/src/filterTools.js +3 -3
- package/src/index.js +9 -11
- package/src/scss/_custom.scss +3 -0
- package/src/scss/_fixes.scss +6 -0
- package/src/scss/_layout.scss +6 -0
- package/src/scss/_variables.scss +4 -0
- package/src/scss/style-wrapper.scss +4 -0
- package/src/scss/style.scss +13 -0
- package/src/siaDummyData.js +241 -243
- package/src/stories/Button.jsx +54 -0
- package/src/stories/Button.stories.js +48 -0
- package/src/stories/Configure.mdx +369 -0
- package/src/stories/Header.jsx +69 -0
- package/src/stories/Header.stories.js +28 -0
- package/src/stories/Page.jsx +87 -0
- package/src/stories/Page.stories.js +28 -0
- package/src/stories/Sia.stories.jsx +61 -0
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +5 -0
- package/src/stories/assets/addon-library.png +0 -0
- package/src/stories/assets/assets.png +0 -0
- package/src/stories/assets/avif-test-image.avif +0 -0
- package/src/stories/assets/context.png +0 -0
- package/src/stories/assets/discord.svg +15 -0
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +3 -0
- package/src/stories/assets/share.png +0 -0
- package/src/stories/assets/styling.png +0 -0
- package/src/stories/assets/testing.png +0 -0
- package/src/stories/assets/theming.png +0 -0
- package/src/stories/assets/tutorials.svg +12 -0
- package/src/stories/assets/youtube.svg +4 -0
- package/src/stories/button.css +30 -0
- package/src/stories/header.css +32 -0
- package/src/stories/lost.js +54 -0
- package/src/stories/page.css +69 -0
- package/src/stories/siaDummyData.js +263 -0
- package/src/stories/store.js +18 -0
- package/src/types/annoStatus.js +4 -4
- package/src/types/canvasActions.js +51 -51
- package/src/types/cursorstyles.js +3 -3
- package/src/types/modes.js +8 -8
- package/src/types/notificationType.js +4 -4
- package/src/types/toolbarEvents.js +31 -31
- package/src/types/tools.js +9 -9
- package/src/utils/annoConversion.js +129 -99
- package/src/utils/colorlut.js +33 -32
- package/src/utils/constraints.js +76 -70
- package/src/utils/hist.js +52 -53
- package/src/utils/keyActions.js +96 -97
- package/src/utils/mouse.js +10 -10
- package/src/utils/siaIcons.jsx +106 -67
- package/src/utils/transform.js +259 -241
- package/src/utils/uiConfig.js +45 -45
- package/src/utils/windowViewport.js +26 -27
|
@@ -1,358 +1,394 @@
|
|
|
1
|
-
import React, { Component } from
|
|
2
|
-
|
|
3
|
-
import AnnoBar from
|
|
4
|
-
import Point from
|
|
5
|
-
import BBox from
|
|
6
|
-
import Line from
|
|
7
|
-
import Polygon from
|
|
8
|
-
import * as modes from
|
|
9
|
-
import * as canvasActions from
|
|
10
|
-
import * as annoStatus from
|
|
11
|
-
import * as colorlut from
|
|
12
|
-
import * as constraints from
|
|
13
|
-
import * as transform from
|
|
14
|
-
import * as notificationType from
|
|
1
|
+
import React, { Component } from "react";
|
|
2
|
+
|
|
3
|
+
import AnnoBar from "./AnnoBar";
|
|
4
|
+
import Point from "./Point";
|
|
5
|
+
import BBox from "./BBox";
|
|
6
|
+
import Line from "./Line";
|
|
7
|
+
import Polygon from "./Polygon";
|
|
8
|
+
import * as modes from "../types/modes";
|
|
9
|
+
import * as canvasActions from "../types/canvasActions";
|
|
10
|
+
import * as annoStatus from "../types/annoStatus";
|
|
11
|
+
import * as colorlut from "../utils/colorlut";
|
|
12
|
+
import * as constraints from "../utils/constraints";
|
|
13
|
+
import * as transform from "../utils/transform";
|
|
14
|
+
import * as notificationType from "../types/notificationType";
|
|
15
15
|
|
|
16
16
|
class Annotation extends Component {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
constructor(props) {
|
|
18
|
+
super(props);
|
|
19
|
+
this.state = {
|
|
20
|
+
// mode: modes.VIEW,
|
|
21
|
+
selAreaCss: "sel-area-off",
|
|
22
|
+
visibility: "visible",
|
|
23
|
+
anno: undefined,
|
|
24
|
+
};
|
|
25
|
+
this.myAnno = React.createRef();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
componentWillMount() {
|
|
29
|
+
this.setState({ anno: { ...this.props.data } });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
componentDidUpdate(prevProps) {
|
|
33
|
+
if (prevProps.data !== this.props.data) {
|
|
34
|
+
this.setState({ anno: { ...this.props.data } });
|
|
32
35
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} else {
|
|
42
|
-
if (this.props.showSingleAnno !== this.props.data.id) {
|
|
43
|
-
this.setVisible(false)
|
|
44
|
-
} else {
|
|
45
|
-
this.setVisible(true)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (this.props.showSingleAnno === undefined) {
|
|
50
|
-
if (this.state.anno.visible !== undefined) {
|
|
51
|
-
if (this.state.anno.visible) {
|
|
52
|
-
this.setVisible(true)
|
|
53
|
-
} else {
|
|
54
|
-
this.setVisible(false)
|
|
55
|
-
}
|
|
56
|
-
}
|
|
36
|
+
if (prevProps.showSingleAnno !== this.props.showSingleAnno) {
|
|
37
|
+
if (this.props.showSingleAnno === undefined) {
|
|
38
|
+
this.setVisible(true);
|
|
39
|
+
} else {
|
|
40
|
+
if (this.props.showSingleAnno !== this.props.data.id) {
|
|
41
|
+
this.setVisible(false);
|
|
42
|
+
} else {
|
|
43
|
+
this.setVisible(true);
|
|
57
44
|
}
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/*************
|
|
62
|
-
* EVENTS *
|
|
63
|
-
**************/
|
|
64
|
-
onClick(e) {
|
|
65
|
-
e.stopPropagation()
|
|
66
|
-
this.performedAction(this.state.anno, canvasActions.ANNO_SELECTED)
|
|
45
|
+
}
|
|
67
46
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
47
|
+
if (this.props.showSingleAnno === undefined) {
|
|
48
|
+
if (this.state.anno.visible !== undefined) {
|
|
49
|
+
if (this.state.anno.visible) {
|
|
50
|
+
this.setVisible(true);
|
|
51
|
+
} else {
|
|
52
|
+
this.setVisible(false);
|
|
73
53
|
}
|
|
54
|
+
}
|
|
74
55
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/*************
|
|
59
|
+
* EVENTS *
|
|
60
|
+
**************/
|
|
61
|
+
onClick(e) {
|
|
62
|
+
e.stopPropagation();
|
|
63
|
+
this.performedAction(this.state.anno, canvasActions.ANNO_SELECTED);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
onMouseDown(e) {
|
|
67
|
+
e.preventDefault();
|
|
68
|
+
if (this.props.onMouseDown) {
|
|
69
|
+
this.props.onMouseDown(e);
|
|
82
70
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
onContextMenu(e) {
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
handleModeChangeRequest(anno, mode) {
|
|
78
|
+
this.setMode(anno, mode);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/*************
|
|
82
|
+
* LOGIC *
|
|
83
|
+
*************/
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Trigger callback when this annotation performed an action
|
|
87
|
+
*
|
|
88
|
+
* @param {String} pAction
|
|
89
|
+
*/
|
|
90
|
+
performedAction(anno, pAction) {
|
|
91
|
+
if (this.props.onAction) {
|
|
92
|
+
this.props.onAction(anno, pAction);
|
|
98
93
|
}
|
|
94
|
+
}
|
|
99
95
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
this.props.onNotification(messageObj)
|
|
104
|
-
}
|
|
96
|
+
notify(messageObj) {
|
|
97
|
+
if (this.props.onNotification) {
|
|
98
|
+
this.props.onNotification(messageObj);
|
|
105
99
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
this.
|
|
145
|
-
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Handle a performed action from a specific annotation
|
|
104
|
+
*
|
|
105
|
+
* @param {list} annoData - Annotation data that define a box, line,
|
|
106
|
+
* polygon, point
|
|
107
|
+
* @param {string} pAction - The performed action
|
|
108
|
+
* @param {int} selectedNode - The node of the annotation that
|
|
109
|
+
* was selected
|
|
110
|
+
*/
|
|
111
|
+
performedAnnoAction(anno, pAction) {
|
|
112
|
+
switch (pAction) {
|
|
113
|
+
case canvasActions.ANNO_CREATED_FINAL_NODE:
|
|
114
|
+
case canvasActions.ANNO_EDITED:
|
|
115
|
+
case canvasActions.ANNO_MOVED:
|
|
116
|
+
case canvasActions.ANNO_CREATED:
|
|
117
|
+
// Check if annoation is within image bounds
|
|
118
|
+
const corrected = transform.correctAnnotation(
|
|
119
|
+
anno.data,
|
|
120
|
+
this.props.svg,
|
|
121
|
+
this.props.imageOffset,
|
|
122
|
+
);
|
|
123
|
+
let newAnno = { ...anno, data: corrected };
|
|
124
|
+
const area = transform.getArea(
|
|
125
|
+
corrected,
|
|
126
|
+
this.props.svg,
|
|
127
|
+
anno.type,
|
|
128
|
+
this.props.image,
|
|
129
|
+
);
|
|
130
|
+
if (area !== undefined) {
|
|
131
|
+
if (area < this.props.canvasConfig.annos.minArea) {
|
|
132
|
+
this.notify({
|
|
133
|
+
title: "Annotation to small",
|
|
134
|
+
message:
|
|
135
|
+
"Annotation area was " +
|
|
136
|
+
Math.round(area) +
|
|
137
|
+
"px but needs to be bigger than " +
|
|
138
|
+
this.props.canvasConfig.annos.minArea +
|
|
139
|
+
" px",
|
|
140
|
+
type: notificationType.WARNING,
|
|
141
|
+
});
|
|
142
|
+
// newAnno = {...newAnno, mode: modes.DELETED}
|
|
143
|
+
this.setMode(newAnno, modes.DELETED);
|
|
144
|
+
} else {
|
|
145
|
+
this.performedAction(newAnno, pAction);
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
this.performedAction(newAnno, pAction);
|
|
146
149
|
}
|
|
150
|
+
break;
|
|
151
|
+
default:
|
|
152
|
+
this.performedAction(anno, pAction);
|
|
153
|
+
break;
|
|
147
154
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
break
|
|
197
|
-
}
|
|
198
|
-
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
setAnnoMode(anno, mode) {
|
|
158
|
+
this.setState({
|
|
159
|
+
anno: {
|
|
160
|
+
...anno,
|
|
161
|
+
mode: mode,
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
setMode(anno, mode) {
|
|
167
|
+
if (anno.mode !== mode) {
|
|
168
|
+
switch (mode) {
|
|
169
|
+
case modes.EDIT_LABEL:
|
|
170
|
+
if (constraints.allowedToLabel(this.props.allowedActions, anno)) {
|
|
171
|
+
this.setAnnoMode(anno, mode);
|
|
172
|
+
}
|
|
173
|
+
break;
|
|
174
|
+
case modes.DELETED:
|
|
175
|
+
// if(constraints.allowedToDelete(
|
|
176
|
+
// this.props.allowedActions,
|
|
177
|
+
// anno
|
|
178
|
+
// )){
|
|
179
|
+
this.setAnnoMode(anno, mode);
|
|
180
|
+
const newAnno = {
|
|
181
|
+
...anno,
|
|
182
|
+
// status: annoStatus.DELETED
|
|
183
|
+
mode: mode.DELETED,
|
|
184
|
+
};
|
|
185
|
+
// this.setState({
|
|
186
|
+
// anno: newAnno
|
|
187
|
+
// })
|
|
188
|
+
this.performedAction(newAnno, canvasActions.ANNO_DELETED);
|
|
189
|
+
// }
|
|
190
|
+
break;
|
|
191
|
+
case modes.MOVE:
|
|
192
|
+
this.setAnnoMode(anno, mode);
|
|
193
|
+
this.performedAction(anno, canvasActions.ANNO_ENTER_MOVE_MODE);
|
|
194
|
+
break;
|
|
195
|
+
case modes.EDIT:
|
|
196
|
+
this.setAnnoMode(anno, mode);
|
|
197
|
+
this.performedAction(anno, canvasActions.ANNO_ENTER_EDIT_MODE);
|
|
198
|
+
break;
|
|
199
|
+
default:
|
|
200
|
+
this.setAnnoMode(anno, mode);
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
199
203
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
setVisible(visible) {
|
|
207
|
+
if (visible) {
|
|
208
|
+
if (this.state.visibility !== "visible") {
|
|
209
|
+
this.setState({ visibility: "visible" });
|
|
210
|
+
}
|
|
211
|
+
} else {
|
|
212
|
+
if (this.state.visibility !== "hidden") {
|
|
213
|
+
this.setState({ visibility: "hidden" });
|
|
214
|
+
}
|
|
211
215
|
}
|
|
216
|
+
}
|
|
212
217
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
218
|
+
isSelected() {
|
|
219
|
+
if (constraints.allowedToEdit(this.props.allowedActions, this.state.anno)) {
|
|
220
|
+
return this.props.selectedAnno === this.props.data.id;
|
|
221
|
+
} else {
|
|
222
|
+
return false;
|
|
219
223
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
getResult() {
|
|
227
|
+
return {
|
|
228
|
+
...this.state.anno,
|
|
229
|
+
data: this.myAnno.current.state.anno,
|
|
230
|
+
createMode: this.myAnno.current.state.mode === modes.CREATE,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
getLabel(lblId) {
|
|
235
|
+
return this.props.possibleLabels.find((e) => {
|
|
236
|
+
return e.id === lblId;
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
getColor() {
|
|
241
|
+
if (this.state.anno.labelIds && this.state.anno.labelIds.length > 0) {
|
|
242
|
+
return this.getLabel(this.state.anno.labelIds[0]).color;
|
|
243
|
+
} else {
|
|
244
|
+
return colorlut.getDefaultColor();
|
|
227
245
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
getStyle() {
|
|
249
|
+
const color = this.getColor();
|
|
250
|
+
if (this.isSelected()) {
|
|
251
|
+
return {
|
|
252
|
+
stroke: color,
|
|
253
|
+
fill: color,
|
|
254
|
+
strokeWidth: this.props.uiConfig.strokeWidth / this.props.svg.scale,
|
|
255
|
+
r: this.props.uiConfig.nodeRadius / this.props.svg.scale,
|
|
256
|
+
};
|
|
257
|
+
} else {
|
|
258
|
+
return {
|
|
259
|
+
stroke: color,
|
|
260
|
+
fill: color,
|
|
261
|
+
strokeWidth: this.props.uiConfig.strokeWidth / this.props.svg.scale,
|
|
262
|
+
r: this.props.uiConfig.nodeRadius / this.props.svg.scale,
|
|
263
|
+
};
|
|
233
264
|
}
|
|
265
|
+
}
|
|
234
266
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
return colorlut.getDefaultColor()
|
|
241
|
-
}
|
|
267
|
+
getCssClass() {
|
|
268
|
+
if (this.isSelected()) {
|
|
269
|
+
return "selected";
|
|
270
|
+
} else {
|
|
271
|
+
return "not-selected";
|
|
242
272
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/*************
|
|
276
|
+
* RENDERING *
|
|
277
|
+
**************/
|
|
278
|
+
renderAnno() {
|
|
279
|
+
const type = this.props.type;
|
|
280
|
+
// const allowedToEdit = constraints.allowedToEditBounds(
|
|
281
|
+
// this.props.allowedActions,
|
|
282
|
+
// this.state.anno
|
|
283
|
+
// )
|
|
284
|
+
switch (type) {
|
|
285
|
+
case "point":
|
|
286
|
+
return (
|
|
287
|
+
<Point
|
|
288
|
+
ref={this.myAnno}
|
|
289
|
+
anno={this.state.anno}
|
|
290
|
+
style={this.getStyle()}
|
|
291
|
+
className={this.getCssClass()}
|
|
292
|
+
isSelected={this.isSelected()}
|
|
293
|
+
svg={this.props.svg}
|
|
294
|
+
onModeChangeRequest={(anno, mode) =>
|
|
295
|
+
this.handleModeChangeRequest(anno, mode)
|
|
253
296
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
stroke: color,
|
|
257
|
-
fill: color,
|
|
258
|
-
strokeWidth: this.props.uiConfig.strokeWidth / this.props.svg.scale,
|
|
259
|
-
r: this.props.uiConfig.nodeRadius / this.props.svg.scale
|
|
297
|
+
onAction={(anno, pAction) =>
|
|
298
|
+
this.performedAnnoAction(anno, pAction)
|
|
260
299
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
} else {
|
|
268
|
-
return 'not-selected'
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
/*************
|
|
273
|
-
* RENDERING *
|
|
274
|
-
**************/
|
|
275
|
-
renderAnno() {
|
|
276
|
-
const type = this.props.type
|
|
277
|
-
// const allowedToEdit = constraints.allowedToEditBounds(
|
|
278
|
-
// this.props.allowedActions,
|
|
279
|
-
// this.state.anno
|
|
280
|
-
// )
|
|
281
|
-
switch (type) {
|
|
282
|
-
case 'point':
|
|
283
|
-
return <Point ref={this.myAnno} anno={this.state.anno}
|
|
284
|
-
style={this.getStyle()}
|
|
285
|
-
className={this.getCssClass()}
|
|
286
|
-
isSelected={this.isSelected()}
|
|
287
|
-
svg={this.props.svg}
|
|
288
|
-
onModeChangeRequest={(anno, mode) => this.handleModeChangeRequest(anno, mode)}
|
|
289
|
-
onAction={(anno, pAction) => this.performedAnnoAction(anno, pAction)}
|
|
290
|
-
/>
|
|
291
|
-
case 'bBox':
|
|
292
|
-
return <BBox ref={this.myAnno} anno={this.state.anno}
|
|
293
|
-
style={this.getStyle()}
|
|
294
|
-
className={this.getCssClass()}
|
|
295
|
-
onNodeClick={(e, idx) => this.onNodeClick(e, idx)}
|
|
296
|
-
onNodeMouseDown={(e, idx) => this.onNodeMouseDown(e, idx)}
|
|
297
|
-
isSelected={this.isSelected()}
|
|
298
|
-
svg={this.props.svg}
|
|
299
|
-
onModeChangeRequest={(anno, mode) => this.handleModeChangeRequest(anno, mode)}
|
|
300
|
-
onAction={(anno, pAction) => this.performedAnnoAction(anno, pAction)}
|
|
301
|
-
/>
|
|
302
|
-
case 'polygon':
|
|
303
|
-
return <Polygon ref={this.myAnno} anno={this.state.anno}
|
|
304
|
-
style={this.getStyle()}
|
|
305
|
-
className={this.getCssClass()}
|
|
306
|
-
onNodeClick={(e, idx) => this.onNodeClick(e, idx)}
|
|
307
|
-
isSelected={this.isSelected()}
|
|
308
|
-
svg={this.props.svg}
|
|
309
|
-
onModeChangeRequest={(anno, mode) => this.handleModeChangeRequest(anno, mode)}
|
|
310
|
-
onAction={(anno, pAction) => this.performedAnnoAction(anno, pAction)}
|
|
311
|
-
/>
|
|
312
|
-
case 'line':
|
|
313
|
-
return <Line ref={this.myAnno} anno={this.state.anno}
|
|
314
|
-
style={this.getStyle()}
|
|
315
|
-
className={this.getCssClass()}
|
|
316
|
-
isSelected={this.isSelected()}
|
|
317
|
-
svg={this.props.svg}
|
|
318
|
-
onAction={(anno, pAction) => this.performedAnnoAction(anno, pAction)}
|
|
319
|
-
onModeChangeRequest={(anno, mode) => this.handleModeChangeRequest(anno, mode)}
|
|
320
|
-
/>
|
|
321
|
-
default:
|
|
322
|
-
console.error("Wrong annoType for annotations: ",
|
|
323
|
-
this.props.annoType)
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
renderAnnoBar() {
|
|
328
|
-
return <AnnoBar
|
|
300
|
+
/>
|
|
301
|
+
);
|
|
302
|
+
case "bBox":
|
|
303
|
+
return (
|
|
304
|
+
<BBox
|
|
305
|
+
ref={this.myAnno}
|
|
329
306
|
anno={this.state.anno}
|
|
330
|
-
mode={this.state.anno.mode}
|
|
331
|
-
possibleLabels={this.props.possibleLabels}
|
|
332
|
-
onClick={e => this.onClick(e)}
|
|
333
307
|
style={this.getStyle()}
|
|
308
|
+
className={this.getCssClass()}
|
|
309
|
+
onNodeClick={(e, idx) => this.onNodeClick(e, idx)}
|
|
310
|
+
onNodeMouseDown={(e, idx) => this.onNodeMouseDown(e, idx)}
|
|
311
|
+
isSelected={this.isSelected()}
|
|
334
312
|
svg={this.props.svg}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
313
|
+
onModeChangeRequest={(anno, mode) =>
|
|
314
|
+
this.handleModeChangeRequest(anno, mode)
|
|
315
|
+
}
|
|
316
|
+
onAction={(anno, pAction) =>
|
|
317
|
+
this.performedAnnoAction(anno, pAction)
|
|
318
|
+
}
|
|
319
|
+
/>
|
|
320
|
+
);
|
|
321
|
+
case "polygon":
|
|
342
322
|
return (
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
323
|
+
<Polygon
|
|
324
|
+
ref={this.myAnno}
|
|
325
|
+
anno={this.state.anno}
|
|
326
|
+
style={this.getStyle()}
|
|
327
|
+
className={this.getCssClass()}
|
|
328
|
+
onNodeClick={(e, idx) => this.onNodeClick(e, idx)}
|
|
329
|
+
isSelected={this.isSelected()}
|
|
330
|
+
svg={this.props.svg}
|
|
331
|
+
onModeChangeRequest={(anno, mode) =>
|
|
332
|
+
this.handleModeChangeRequest(anno, mode)
|
|
333
|
+
}
|
|
334
|
+
onAction={(anno, pAction) =>
|
|
335
|
+
this.performedAnnoAction(anno, pAction)
|
|
336
|
+
}
|
|
337
|
+
/>
|
|
338
|
+
);
|
|
339
|
+
case "line":
|
|
340
|
+
return (
|
|
341
|
+
<Line
|
|
342
|
+
ref={this.myAnno}
|
|
343
|
+
anno={this.state.anno}
|
|
344
|
+
style={this.getStyle()}
|
|
345
|
+
className={this.getCssClass()}
|
|
346
|
+
isSelected={this.isSelected()}
|
|
347
|
+
svg={this.props.svg}
|
|
348
|
+
onAction={(anno, pAction) =>
|
|
349
|
+
this.performedAnnoAction(anno, pAction)
|
|
350
|
+
}
|
|
351
|
+
onModeChangeRequest={(anno, mode) =>
|
|
352
|
+
this.handleModeChangeRequest(anno, mode)
|
|
353
|
+
}
|
|
354
|
+
/>
|
|
355
|
+
);
|
|
356
|
+
default:
|
|
357
|
+
console.error("Wrong annoType for annotations: ", this.props.annoType);
|
|
355
358
|
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
renderAnnoBar() {
|
|
362
|
+
return (
|
|
363
|
+
<AnnoBar
|
|
364
|
+
anno={this.state.anno}
|
|
365
|
+
mode={this.state.anno.mode}
|
|
366
|
+
possibleLabels={this.props.possibleLabels}
|
|
367
|
+
onClick={(e) => this.onClick(e)}
|
|
368
|
+
style={this.getStyle()}
|
|
369
|
+
svg={this.props.svg}
|
|
370
|
+
defaultLabel={this.props.defaultLabel}
|
|
371
|
+
/>
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
render() {
|
|
375
|
+
if (!this.state.anno.data) return null;
|
|
376
|
+
if (!this.props.possibleLabels) return null;
|
|
377
|
+
if (this.state.anno.status === annoStatus.DELETED) return null;
|
|
378
|
+
return (
|
|
379
|
+
<g>
|
|
380
|
+
<g
|
|
381
|
+
visibility={this.state.visibility}
|
|
382
|
+
onClick={(e) => this.onClick(e)}
|
|
383
|
+
onMouseDown={(e) => this.onMouseDown(e)}
|
|
384
|
+
onContextMenu={(e) => this.onContextMenu(e)}
|
|
385
|
+
>
|
|
386
|
+
{this.renderAnnoBar()}
|
|
387
|
+
{this.renderAnno()}
|
|
388
|
+
</g>
|
|
389
|
+
</g>
|
|
390
|
+
);
|
|
391
|
+
}
|
|
356
392
|
}
|
|
357
393
|
|
|
358
|
-
export default Annotation
|
|
394
|
+
export default Annotation;
|