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,47 +1,47 @@
|
|
|
1
1
|
//*******************
|
|
2
2
|
//* General styling *
|
|
3
3
|
//*******************
|
|
4
|
-
.sel-area-off{
|
|
5
|
-
|
|
4
|
+
.sel-area-off {
|
|
5
|
+
fill: none;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
.sel-area-on{
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
.sel-area-on {
|
|
9
|
+
fill: blue;
|
|
10
|
+
fill-opacity: 0.001;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
//**********************
|
|
14
14
|
//* Annotation styling *
|
|
15
15
|
//**********************
|
|
16
|
-
.selected{
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
.selected {
|
|
17
|
+
fill-opacity: 0.01;
|
|
18
|
+
cursor: grab;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
circle.selected{
|
|
22
|
-
|
|
21
|
+
circle.selected {
|
|
22
|
+
fill-opacity: 1;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
.not-selected{
|
|
26
|
-
|
|
25
|
+
.not-selected {
|
|
26
|
+
fill-opacity: 0.3;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
circle.not-selected{
|
|
30
|
-
|
|
29
|
+
circle.not-selected {
|
|
30
|
+
fill-opacity: 1;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
//****************
|
|
34
34
|
//* Node styling *
|
|
35
35
|
//****************
|
|
36
|
-
.node-halo-on{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
.node-halo-on {
|
|
37
|
+
fill: orange;
|
|
38
|
+
stroke: orange;
|
|
39
|
+
fill-opacity: 0.1;
|
|
40
|
+
stroke-opacity: 0.2;
|
|
41
|
+
cursor: grab;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
.node-halo-off{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
44
|
+
.node-halo-off {
|
|
45
|
+
fill: none;
|
|
46
|
+
stroke: none;
|
|
47
|
+
}
|
package/src/Annotation/BBox.jsx
CHANGED
|
@@ -1,291 +1,299 @@
|
|
|
1
|
-
import React, {Component} from
|
|
2
|
-
import
|
|
3
|
-
import * as modes from
|
|
4
|
-
import * as transform from
|
|
5
|
-
import * as canvasActions from
|
|
6
|
-
import * as mouse from
|
|
7
|
-
import InfSelectionArea from
|
|
8
|
-
import Node from
|
|
1
|
+
import React, { Component } from "react";
|
|
2
|
+
import "./Annotation.scss";
|
|
3
|
+
import * as modes from "../types/modes";
|
|
4
|
+
import * as transform from "../utils/transform";
|
|
5
|
+
import * as canvasActions from "../types/canvasActions";
|
|
6
|
+
import * as mouse from "../utils/mouse";
|
|
7
|
+
import InfSelectionArea from "./InfSelectionArea";
|
|
8
|
+
import Node from "./Node";
|
|
9
9
|
|
|
10
|
-
class BBox extends Component{
|
|
10
|
+
class BBox extends Component {
|
|
11
|
+
/*************
|
|
12
|
+
* LIFECYCLE *
|
|
13
|
+
**************/
|
|
14
|
+
constructor(props) {
|
|
15
|
+
super(props);
|
|
16
|
+
this.state = {
|
|
17
|
+
anno: undefined,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
11
20
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
componentDidMount(prevProps) {
|
|
22
|
+
if (this.props.anno.mode === modes.CREATE) {
|
|
23
|
+
const data = this.props.anno.data[0];
|
|
24
|
+
const newAnno = {
|
|
25
|
+
...this.props.anno,
|
|
26
|
+
data: [
|
|
27
|
+
{ x: data.x, y: data.y },
|
|
28
|
+
{ x: data.x + 1, y: data.y },
|
|
29
|
+
{ x: data.x + 1, y: data.y + 1 },
|
|
30
|
+
{ x: data.x, y: data.y + 1 },
|
|
31
|
+
],
|
|
32
|
+
selectedNode: 2,
|
|
33
|
+
};
|
|
34
|
+
this.setState({
|
|
35
|
+
anno: newAnno,
|
|
36
|
+
});
|
|
37
|
+
// this.performedAction(newAnno, canvasActions.ANNO_START_CREATING)
|
|
38
|
+
} else {
|
|
39
|
+
this.setState({ anno: { ...this.props.anno } });
|
|
20
40
|
}
|
|
41
|
+
}
|
|
21
42
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const newAnno = {
|
|
26
|
-
...this.props.anno,
|
|
27
|
-
data: [
|
|
28
|
-
{x: data.x, y: data.y},
|
|
29
|
-
{x: data.x+1, y: data.y},
|
|
30
|
-
{x: data.x+1, y: data.y+1},
|
|
31
|
-
{x: data.x, y: data.y+1}
|
|
32
|
-
],
|
|
33
|
-
selectedNode: 2
|
|
34
|
-
}
|
|
35
|
-
this.setState({
|
|
36
|
-
anno: newAnno
|
|
37
|
-
})
|
|
38
|
-
// this.performedAction(newAnno, canvasActions.ANNO_START_CREATING)
|
|
39
|
-
|
|
40
|
-
} else {
|
|
41
|
-
this.setState({anno: {...this.props.anno}})
|
|
42
|
-
}
|
|
43
|
+
componentDidUpdate(prevProps) {
|
|
44
|
+
if (prevProps.anno !== this.props.anno) {
|
|
45
|
+
this.setState({ anno: { ...this.props.anno } });
|
|
43
46
|
}
|
|
47
|
+
}
|
|
44
48
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
/*************
|
|
50
|
+
* EVENTS *
|
|
51
|
+
**************/
|
|
52
|
+
onNodeMouseMove(e, idx) {
|
|
53
|
+
switch (this.state.anno.mode) {
|
|
54
|
+
case modes.CREATE:
|
|
55
|
+
case modes.EDIT:
|
|
56
|
+
const mousePos = mouse.getMousePosition(e, this.props.svg);
|
|
57
|
+
const idxMinus = idx - 1 < 0 ? 3 : idx - 1;
|
|
58
|
+
const idxPlus = idx + 1 > 3 ? 0 : idx + 1;
|
|
59
|
+
let newAnnoData = [...this.state.anno.data];
|
|
60
|
+
if (idx % 2 === 0) {
|
|
61
|
+
newAnnoData[idxMinus].x = mousePos.x;
|
|
62
|
+
newAnnoData[idx].x = mousePos.x;
|
|
63
|
+
newAnnoData[idx].y = mousePos.y;
|
|
64
|
+
newAnnoData[idxPlus].y = mousePos.y;
|
|
65
|
+
} else {
|
|
66
|
+
newAnnoData[idxMinus].y = mousePos.y;
|
|
67
|
+
newAnnoData[idx].x = mousePos.x;
|
|
68
|
+
newAnnoData[idx].y = mousePos.y;
|
|
69
|
+
newAnnoData[idxPlus].x = mousePos.x;
|
|
48
70
|
}
|
|
71
|
+
this.setState({
|
|
72
|
+
anno: {
|
|
73
|
+
...this.state.anno,
|
|
74
|
+
data: newAnnoData,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
break;
|
|
49
80
|
}
|
|
81
|
+
}
|
|
50
82
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const idxMinus = idx - 1 < 0 ? 3 : idx -1
|
|
60
|
-
const idxPlus = idx + 1 > 3 ? 0 : idx +1
|
|
61
|
-
let newAnnoData = [...this.state.anno.data]
|
|
62
|
-
if (idx % 2 === 0){
|
|
63
|
-
newAnnoData[idxMinus].x = mousePos.x
|
|
64
|
-
newAnnoData[idx].x = mousePos.x
|
|
65
|
-
newAnnoData[idx].y = mousePos.y
|
|
66
|
-
newAnnoData[idxPlus].y = mousePos.y
|
|
67
|
-
} else {
|
|
68
|
-
newAnnoData[idxMinus].y = mousePos.y
|
|
69
|
-
newAnnoData[idx].x = mousePos.x
|
|
70
|
-
newAnnoData[idx].y = mousePos.y
|
|
71
|
-
newAnnoData[idxPlus].x = mousePos.x
|
|
72
|
-
}
|
|
73
|
-
this.setState({
|
|
74
|
-
anno: {
|
|
75
|
-
...this.state.anno,
|
|
76
|
-
data: newAnnoData
|
|
77
|
-
}
|
|
78
|
-
})
|
|
79
|
-
break
|
|
80
|
-
default:
|
|
81
|
-
break
|
|
83
|
+
onNodeMouseDown(e, idx) {
|
|
84
|
+
switch (this.state.anno.mode) {
|
|
85
|
+
case modes.VIEW:
|
|
86
|
+
if (e.button === 0) {
|
|
87
|
+
this.requestModeChange(
|
|
88
|
+
{ ...this.state.anno, selectedNode: idx },
|
|
89
|
+
modes.EDIT,
|
|
90
|
+
);
|
|
82
91
|
}
|
|
92
|
+
break;
|
|
93
|
+
default:
|
|
94
|
+
break;
|
|
83
95
|
}
|
|
96
|
+
}
|
|
84
97
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
modes.EDIT
|
|
92
|
-
)
|
|
93
|
-
}
|
|
94
|
-
break
|
|
95
|
-
default:
|
|
96
|
-
break
|
|
98
|
+
onNodeMouseUp(e, idx) {
|
|
99
|
+
switch (this.state.anno.mode) {
|
|
100
|
+
case modes.EDIT:
|
|
101
|
+
if (e.button === 0) {
|
|
102
|
+
this.requestModeChange(this.state.anno, modes.VIEW);
|
|
103
|
+
this.performedAction(this.state.anno, canvasActions.ANNO_EDITED);
|
|
97
104
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (e.button === 0){
|
|
104
|
-
this.requestModeChange(this.state.anno, modes.VIEW)
|
|
105
|
-
this.performedAction(this.state.anno, canvasActions.ANNO_EDITED)
|
|
106
|
-
}
|
|
107
|
-
break
|
|
108
|
-
case modes.CREATE:
|
|
109
|
-
if (e.button === 2){
|
|
110
|
-
this.requestModeChange(this.state.anno, modes.VIEW)
|
|
111
|
-
this.performedAction(this.state.anno, canvasActions.ANNO_CREATED)
|
|
112
|
-
}
|
|
113
|
-
break
|
|
114
|
-
default:
|
|
115
|
-
break
|
|
105
|
+
break;
|
|
106
|
+
case modes.CREATE:
|
|
107
|
+
if (e.button === 2) {
|
|
108
|
+
this.requestModeChange(this.state.anno, modes.VIEW);
|
|
109
|
+
this.performedAction(this.state.anno, canvasActions.ANNO_CREATED);
|
|
116
110
|
}
|
|
111
|
+
break;
|
|
112
|
+
default:
|
|
113
|
+
break;
|
|
117
114
|
}
|
|
115
|
+
}
|
|
118
116
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
117
|
+
handleNodeMouseLeave(e, idx) {
|
|
118
|
+
switch (this.state.anno.mode) {
|
|
119
|
+
//if mouse left Canvas in create mode, transit to VIEW mode
|
|
120
|
+
case modes.CREATE:
|
|
121
|
+
this.requestModeChange(this.state.anno, modes.VIEW);
|
|
122
|
+
this.performedAction(this.state.anno, canvasActions.ANNO_CREATED);
|
|
123
|
+
break;
|
|
124
|
+
default:
|
|
125
|
+
break;
|
|
129
126
|
}
|
|
127
|
+
}
|
|
130
128
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
129
|
+
/**************
|
|
130
|
+
* ANNO EVENTS *
|
|
131
|
+
***************/
|
|
132
|
+
onMouseMove(e) {
|
|
133
|
+
switch (this.state.anno.mode) {
|
|
134
|
+
case modes.MOVE:
|
|
135
|
+
this.move(
|
|
136
|
+
e.movementX / this.props.svg.scale,
|
|
137
|
+
e.movementY / this.props.svg.scale,
|
|
138
|
+
);
|
|
139
|
+
break;
|
|
140
|
+
default:
|
|
141
|
+
break;
|
|
145
142
|
}
|
|
143
|
+
}
|
|
146
144
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
break
|
|
155
|
-
default:
|
|
156
|
-
break
|
|
145
|
+
onMouseUp(e) {
|
|
146
|
+
switch (this.state.anno.mode) {
|
|
147
|
+
case modes.MOVE:
|
|
148
|
+
if (e.button === 0) {
|
|
149
|
+
this.requestModeChange(this.state.anno, modes.VIEW);
|
|
150
|
+
this.performedAction(this.state.anno, canvasActions.ANNO_MOVED);
|
|
157
151
|
}
|
|
152
|
+
break;
|
|
153
|
+
default:
|
|
154
|
+
break;
|
|
158
155
|
}
|
|
156
|
+
}
|
|
159
157
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
break
|
|
169
|
-
default:
|
|
170
|
-
break
|
|
158
|
+
onMouseDown(e) {
|
|
159
|
+
switch (this.state.anno.mode) {
|
|
160
|
+
case modes.VIEW:
|
|
161
|
+
if (e.button === 0) {
|
|
162
|
+
if (this.props.isSelected) {
|
|
163
|
+
this.requestModeChange(this.state.anno, modes.MOVE);
|
|
164
|
+
}
|
|
171
165
|
}
|
|
166
|
+
break;
|
|
167
|
+
default:
|
|
168
|
+
break;
|
|
172
169
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
requestModeChange(anno, mode){
|
|
181
|
-
this.props.onModeChangeRequest(anno, mode)
|
|
182
|
-
}
|
|
170
|
+
}
|
|
171
|
+
/*************
|
|
172
|
+
* LOGIC *
|
|
173
|
+
**************/
|
|
174
|
+
getResult() {
|
|
175
|
+
return this.state.anno;
|
|
176
|
+
}
|
|
183
177
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
}
|
|
178
|
+
requestModeChange(anno, mode) {
|
|
179
|
+
this.props.onModeChangeRequest(anno, mode);
|
|
180
|
+
}
|
|
189
181
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
})).join(' ')
|
|
194
|
-
|
|
182
|
+
performedAction(anno, pAction) {
|
|
183
|
+
if (this.props.onAction) {
|
|
184
|
+
this.props.onAction(anno, pAction);
|
|
195
185
|
}
|
|
186
|
+
}
|
|
196
187
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}
|
|
188
|
+
toPolygonStr(data) {
|
|
189
|
+
return data
|
|
190
|
+
.map((e) => {
|
|
191
|
+
return `${e.x},${e.y}`;
|
|
192
|
+
})
|
|
193
|
+
.join(" ");
|
|
194
|
+
}
|
|
205
195
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
196
|
+
move(movementX, movementY) {
|
|
197
|
+
this.setState({
|
|
198
|
+
anno: {
|
|
199
|
+
...this.state.anno,
|
|
200
|
+
data: transform.move(this.state.anno.data, movementX, movementY),
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
}
|
|
209
204
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
return <polygon
|
|
214
|
-
points={this.toPolygonStr(this.state.anno.data)}
|
|
215
|
-
fill='none' stroke="purple"
|
|
216
|
-
style={this.props.style}
|
|
217
|
-
className={this.props.className}
|
|
218
|
-
onMouseDown={e => this.onMouseDown(e)}
|
|
219
|
-
onMouseUp={e => this.onMouseUp(e)}
|
|
220
|
-
/>
|
|
221
|
-
}
|
|
222
|
-
}
|
|
205
|
+
/*************
|
|
206
|
+
* RENDERING *
|
|
207
|
+
**************/
|
|
223
208
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
mode={this.state.anno.mode}
|
|
239
|
-
svg={this.props.svg}
|
|
240
|
-
onMouseDown={(e, idx) => this.onNodeMouseDown(e,idx)}
|
|
241
|
-
onMouseUp={(e, idx) => this.onNodeMouseUp(e, idx)}
|
|
242
|
-
onMouseMove={(e, idx) => this.onNodeMouseMove(e, idx)}
|
|
243
|
-
onMouseLeave={(e, idx) => this.handleNodeMouseLeave(e, idx)}
|
|
244
|
-
/>
|
|
245
|
-
default:
|
|
246
|
-
return this.state.anno.data.map((e, idx) => {
|
|
247
|
-
return <Node anno={this.state.anno.data} idx={idx}
|
|
248
|
-
key={idx} style={this.props.style}
|
|
249
|
-
className={this.props.className}
|
|
250
|
-
isSelected={this.props.isSelected}
|
|
251
|
-
mode={this.state.anno.mode}
|
|
252
|
-
svg={this.props.svg}
|
|
253
|
-
onMouseDown={(e, idx) => this.onNodeMouseDown(e,idx)}
|
|
254
|
-
onMouseUp={(e, idx) => this.onNodeMouseUp(e, idx)}
|
|
255
|
-
onMouseLeave={(e, idx) => this.handleNodeMouseLeave(e, idx)}
|
|
256
|
-
/>
|
|
257
|
-
})
|
|
258
|
-
}
|
|
209
|
+
renderPolygon() {
|
|
210
|
+
switch (this.state.anno.mode) {
|
|
211
|
+
default:
|
|
212
|
+
return (
|
|
213
|
+
<polygon
|
|
214
|
+
points={this.toPolygonStr(this.state.anno.data)}
|
|
215
|
+
fill="none"
|
|
216
|
+
stroke="purple"
|
|
217
|
+
style={this.props.style}
|
|
218
|
+
className={this.props.className}
|
|
219
|
+
onMouseDown={(e) => this.onMouseDown(e)}
|
|
220
|
+
onMouseUp={(e) => this.onMouseUp(e)}
|
|
221
|
+
/>
|
|
222
|
+
);
|
|
259
223
|
}
|
|
224
|
+
}
|
|
260
225
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
226
|
+
renderNodes() {
|
|
227
|
+
if (!this.props.isSelected) return null;
|
|
228
|
+
switch (this.state.anno.mode) {
|
|
229
|
+
case modes.MOVE:
|
|
230
|
+
case modes.EDIT_LABEL:
|
|
231
|
+
return null;
|
|
232
|
+
case modes.EDIT:
|
|
233
|
+
case modes.CREATE:
|
|
234
|
+
return (
|
|
235
|
+
<Node
|
|
236
|
+
anno={this.state.anno.data}
|
|
237
|
+
key={this.state.anno.selectedNode}
|
|
238
|
+
idx={this.state.anno.selectedNode}
|
|
239
|
+
style={this.props.style}
|
|
240
|
+
className={this.props.className}
|
|
241
|
+
isSelected={this.props.isSelected}
|
|
242
|
+
mode={this.state.anno.mode}
|
|
243
|
+
svg={this.props.svg}
|
|
244
|
+
onMouseDown={(e, idx) => this.onNodeMouseDown(e, idx)}
|
|
245
|
+
onMouseUp={(e, idx) => this.onNodeMouseUp(e, idx)}
|
|
246
|
+
onMouseMove={(e, idx) => this.onNodeMouseMove(e, idx)}
|
|
247
|
+
onMouseLeave={(e, idx) => this.handleNodeMouseLeave(e, idx)}
|
|
248
|
+
/>
|
|
249
|
+
);
|
|
250
|
+
default:
|
|
251
|
+
return this.state.anno.data.map((e, idx) => {
|
|
252
|
+
return (
|
|
253
|
+
<Node
|
|
254
|
+
anno={this.state.anno.data}
|
|
255
|
+
idx={idx}
|
|
256
|
+
key={idx}
|
|
257
|
+
style={this.props.style}
|
|
258
|
+
className={this.props.className}
|
|
259
|
+
isSelected={this.props.isSelected}
|
|
260
|
+
mode={this.state.anno.mode}
|
|
261
|
+
svg={this.props.svg}
|
|
262
|
+
onMouseDown={(e, idx) => this.onNodeMouseDown(e, idx)}
|
|
263
|
+
onMouseUp={(e, idx) => this.onNodeMouseUp(e, idx)}
|
|
264
|
+
onMouseLeave={(e, idx) => this.handleNodeMouseLeave(e, idx)}
|
|
265
|
+
/>
|
|
266
|
+
);
|
|
267
|
+
});
|
|
270
268
|
}
|
|
269
|
+
}
|
|
271
270
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
onMouseDown={e => this.onMouseDown(e)}
|
|
279
|
-
>
|
|
280
|
-
{this.renderPolygon()}
|
|
281
|
-
{this.renderNodes()}
|
|
282
|
-
{this.renderInfSelectionArea()}
|
|
283
|
-
</g>)
|
|
284
|
-
} else {
|
|
285
|
-
return null
|
|
286
|
-
}
|
|
271
|
+
renderInfSelectionArea() {
|
|
272
|
+
switch (this.state.anno.mode) {
|
|
273
|
+
case modes.MOVE:
|
|
274
|
+
return <InfSelectionArea enable={true} svg={this.props.svg} />;
|
|
275
|
+
default:
|
|
276
|
+
return null;
|
|
287
277
|
}
|
|
278
|
+
}
|
|
288
279
|
|
|
280
|
+
render() {
|
|
281
|
+
if (this.state.anno) {
|
|
282
|
+
return (
|
|
283
|
+
<g
|
|
284
|
+
onMouseMove={(e) => this.onMouseMove(e)}
|
|
285
|
+
onMouseUp={(e) => this.onMouseUp(e)}
|
|
286
|
+
onMouseDown={(e) => this.onMouseDown(e)}
|
|
287
|
+
>
|
|
288
|
+
{this.renderPolygon()}
|
|
289
|
+
{this.renderNodes()}
|
|
290
|
+
{this.renderInfSelectionArea()}
|
|
291
|
+
</g>
|
|
292
|
+
);
|
|
293
|
+
} else {
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
289
297
|
}
|
|
290
298
|
|
|
291
|
-
export default BBox;
|
|
299
|
+
export default BBox;
|