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
package/src/Annotation/Point.jsx
CHANGED
|
@@ -1,196 +1,200 @@
|
|
|
1
|
-
import React, {Component} from
|
|
2
|
-
import InfSelectionArea from
|
|
3
|
-
import Node from
|
|
4
|
-
import * as modes from
|
|
5
|
-
import * as transform from
|
|
6
|
-
import * as canvasActions from
|
|
7
|
-
|
|
8
|
-
class Point extends Component{
|
|
9
|
-
|
|
10
|
-
/*************
|
|
11
|
-
* LIFECYCLE *
|
|
12
|
-
**************/
|
|
13
|
-
constructor(props){
|
|
14
|
-
super(props)
|
|
15
|
-
this.state = {
|
|
16
|
-
anno: undefined,
|
|
17
|
-
}
|
|
18
|
-
}
|
|
1
|
+
import React, { Component } from "react";
|
|
2
|
+
import InfSelectionArea from "./InfSelectionArea";
|
|
3
|
+
import Node from "./Node";
|
|
4
|
+
import * as modes from "../types/modes";
|
|
5
|
+
import * as transform from "../utils/transform";
|
|
6
|
+
import * as canvasActions from "../types/canvasActions";
|
|
19
7
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this.setState({
|
|
31
|
-
anno: newAnno
|
|
32
|
-
})
|
|
33
|
-
} else {
|
|
34
|
-
this.setState({anno: {...this.props.anno}})
|
|
35
|
-
}
|
|
36
|
-
}
|
|
8
|
+
class Point extends Component {
|
|
9
|
+
/*************
|
|
10
|
+
* LIFECYCLE *
|
|
11
|
+
**************/
|
|
12
|
+
constructor(props) {
|
|
13
|
+
super(props);
|
|
14
|
+
this.state = {
|
|
15
|
+
anno: undefined,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
37
18
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
19
|
+
componentDidMount(prevProps) {
|
|
20
|
+
if (this.props.anno.mode === modes.CREATE) {
|
|
21
|
+
const data = this.props.anno.data[0];
|
|
22
|
+
const newAnno = {
|
|
23
|
+
...this.props.anno,
|
|
24
|
+
data: [{ x: data.x, y: data.y }],
|
|
25
|
+
selectedNode: 0,
|
|
26
|
+
};
|
|
27
|
+
this.setState({
|
|
28
|
+
anno: newAnno,
|
|
29
|
+
});
|
|
30
|
+
} else {
|
|
31
|
+
this.setState({ anno: { ...this.props.anno } });
|
|
42
32
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
switch (this.state.anno.mode){
|
|
49
|
-
case modes.MOVE:
|
|
50
|
-
this.move(
|
|
51
|
-
e.movementX/this.props.svg.scale,
|
|
52
|
-
e.movementY/this.props.svg.scale
|
|
53
|
-
)
|
|
54
|
-
break
|
|
55
|
-
default:
|
|
56
|
-
break
|
|
57
|
-
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
componentDidUpdate(prevProps) {
|
|
36
|
+
if (prevProps.anno !== this.props.anno) {
|
|
37
|
+
this.setState({ anno: { ...this.props.anno } });
|
|
58
38
|
}
|
|
39
|
+
}
|
|
59
40
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
default:
|
|
74
|
-
break
|
|
75
|
-
}
|
|
41
|
+
/**************
|
|
42
|
+
* ANNO EVENTS *
|
|
43
|
+
***************/
|
|
44
|
+
onMouseMove(e) {
|
|
45
|
+
switch (this.state.anno.mode) {
|
|
46
|
+
case modes.MOVE:
|
|
47
|
+
this.move(
|
|
48
|
+
e.movementX / this.props.svg.scale,
|
|
49
|
+
e.movementY / this.props.svg.scale,
|
|
50
|
+
);
|
|
51
|
+
break;
|
|
52
|
+
default:
|
|
53
|
+
break;
|
|
76
54
|
}
|
|
55
|
+
}
|
|
77
56
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
break
|
|
87
|
-
default:
|
|
88
|
-
break
|
|
57
|
+
onMouseUp(e) {
|
|
58
|
+
switch (this.state.anno.mode) {
|
|
59
|
+
case modes.MOVE:
|
|
60
|
+
if (e.button === 0) {
|
|
61
|
+
this.requestModeChange(this.state.anno, modes.VIEW);
|
|
62
|
+
this.performedAction(this.state.anno, canvasActions.ANNO_MOVED);
|
|
89
63
|
}
|
|
90
|
-
|
|
64
|
+
break;
|
|
65
|
+
case modes.CREATE:
|
|
66
|
+
this.requestModeChange(this.state.anno, modes.VIEW);
|
|
91
67
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return this.state.anno
|
|
68
|
+
this.performedAction(this.state.anno, canvasActions.ANNO_CREATED);
|
|
69
|
+
break;
|
|
70
|
+
default:
|
|
71
|
+
break;
|
|
97
72
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
onNodeMouseDown(e, idx) {
|
|
76
|
+
switch (this.state.anno.mode) {
|
|
77
|
+
case modes.VIEW:
|
|
78
|
+
if (e.button === 0) {
|
|
79
|
+
if (this.props.isSelected) {
|
|
80
|
+
this.requestModeChange(this.state.anno, modes.MOVE);
|
|
81
|
+
}
|
|
102
82
|
}
|
|
83
|
+
break;
|
|
84
|
+
default:
|
|
85
|
+
break;
|
|
103
86
|
}
|
|
87
|
+
}
|
|
104
88
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
89
|
+
/*************
|
|
90
|
+
* LOGIC *
|
|
91
|
+
**************/
|
|
92
|
+
getResult() {
|
|
93
|
+
return this.state.anno;
|
|
94
|
+
}
|
|
108
95
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
...this.state.anno,
|
|
113
|
-
data: transform.move(this.state.anno.data, movementX, movementY)
|
|
114
|
-
}
|
|
115
|
-
})
|
|
96
|
+
performedAction(anno, pAction) {
|
|
97
|
+
if (this.props.onAction) {
|
|
98
|
+
this.props.onAction(anno, pAction);
|
|
116
99
|
}
|
|
100
|
+
}
|
|
117
101
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return <InfSelectionArea enable={true}
|
|
122
|
-
svg={this.props.svg}
|
|
123
|
-
/>
|
|
124
|
-
default:
|
|
125
|
-
return null
|
|
126
|
-
}
|
|
127
|
-
}
|
|
102
|
+
requestModeChange(anno, mode) {
|
|
103
|
+
this.props.onModeChangeRequest(anno, mode);
|
|
104
|
+
}
|
|
128
105
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
svg={this.props.svg}
|
|
145
|
-
onMouseDown={(e, idx) => this.onNodeMouseDown(e,idx)}
|
|
146
|
-
isPoint={true}
|
|
147
|
-
/>
|
|
148
|
-
default:
|
|
149
|
-
return this.state.anno.data.map((e, idx) => {
|
|
150
|
-
return <Node anno={this.state.anno.data} idx={idx}
|
|
151
|
-
key={idx} style={this.props.style}
|
|
152
|
-
className={this.props.className}
|
|
153
|
-
isSelected={this.props.isSelected}
|
|
154
|
-
mode={this.state.anno.mode}
|
|
155
|
-
svg={this.props.svg}
|
|
156
|
-
onMouseDown={(e, idx) => this.onNodeMouseDown(e,idx)}
|
|
157
|
-
isPoint={true}
|
|
158
|
-
/>
|
|
159
|
-
})
|
|
160
|
-
}
|
|
106
|
+
move(movementX, movementY) {
|
|
107
|
+
this.setState({
|
|
108
|
+
anno: {
|
|
109
|
+
...this.state.anno,
|
|
110
|
+
data: transform.move(this.state.anno.data, movementX, movementY),
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
renderInfSelectionArea() {
|
|
116
|
+
switch (this.state.anno.mode) {
|
|
117
|
+
case modes.MOVE:
|
|
118
|
+
return <InfSelectionArea enable={true} svg={this.props.svg} />;
|
|
119
|
+
default:
|
|
120
|
+
return null;
|
|
161
121
|
}
|
|
122
|
+
}
|
|
162
123
|
|
|
163
|
-
|
|
124
|
+
renderNode() {
|
|
125
|
+
if (!this.props.isSelected) return null;
|
|
126
|
+
switch (this.state.anno.mode) {
|
|
127
|
+
case modes.EDIT_LABEL:
|
|
128
|
+
case modes.MOVE:
|
|
129
|
+
return null;
|
|
130
|
+
case modes.EDIT:
|
|
131
|
+
case modes.CREATE:
|
|
132
|
+
return (
|
|
133
|
+
<Node
|
|
134
|
+
anno={this.state.anno.data}
|
|
135
|
+
key={this.state.selectedNode}
|
|
136
|
+
idx={this.state.anno.selectedNode}
|
|
137
|
+
style={this.props.style}
|
|
138
|
+
className={this.props.className}
|
|
139
|
+
isSelected={this.props.isSelected}
|
|
140
|
+
mode={this.state.anno.mode}
|
|
141
|
+
svg={this.props.svg}
|
|
142
|
+
onMouseDown={(e, idx) => this.onNodeMouseDown(e, idx)}
|
|
143
|
+
isPoint={true}
|
|
144
|
+
/>
|
|
145
|
+
);
|
|
146
|
+
default:
|
|
164
147
|
return this.state.anno.data.map((e, idx) => {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
148
|
+
return (
|
|
149
|
+
<Node
|
|
150
|
+
anno={this.state.anno.data}
|
|
151
|
+
idx={idx}
|
|
152
|
+
key={idx}
|
|
153
|
+
style={this.props.style}
|
|
154
|
+
className={this.props.className}
|
|
155
|
+
isSelected={this.props.isSelected}
|
|
156
|
+
mode={this.state.anno.mode}
|
|
157
|
+
svg={this.props.svg}
|
|
158
|
+
onMouseDown={(e, idx) => this.onNodeMouseDown(e, idx)}
|
|
159
|
+
isPoint={true}
|
|
160
|
+
/>
|
|
161
|
+
);
|
|
162
|
+
});
|
|
176
163
|
}
|
|
164
|
+
}
|
|
177
165
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
166
|
+
renderPoint() {
|
|
167
|
+
return this.state.anno.data.map((e, idx) => {
|
|
168
|
+
return (
|
|
169
|
+
<circle
|
|
170
|
+
key={idx}
|
|
171
|
+
cx={e.x}
|
|
172
|
+
cy={e.y}
|
|
173
|
+
r={10}
|
|
174
|
+
fill="red"
|
|
175
|
+
style={this.props.style}
|
|
176
|
+
className={this.props.className}
|
|
177
|
+
/>
|
|
178
|
+
);
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
render() {
|
|
183
|
+
if (this.state.anno) {
|
|
184
|
+
return (
|
|
185
|
+
<g
|
|
186
|
+
onMouseMove={(e) => this.onMouseMove(e)}
|
|
187
|
+
onMouseUp={(e) => this.onMouseUp(e)}
|
|
188
|
+
>
|
|
189
|
+
{this.renderPoint()}
|
|
190
|
+
{this.renderNode()}
|
|
191
|
+
{this.renderInfSelectionArea()}
|
|
192
|
+
</g>
|
|
193
|
+
);
|
|
194
|
+
} else {
|
|
195
|
+
return null;
|
|
193
196
|
}
|
|
197
|
+
}
|
|
194
198
|
}
|
|
195
199
|
|
|
196
|
-
export default Point;
|
|
200
|
+
export default Point;
|