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,148 +1,154 @@
|
|
|
1
|
-
import React, { Component } from
|
|
2
|
-
import * as transform from
|
|
3
|
-
import * as modes from
|
|
1
|
+
import React, { Component } from "react";
|
|
2
|
+
import * as transform from "../utils/transform";
|
|
3
|
+
import * as modes from "../types/modes";
|
|
4
4
|
|
|
5
|
-
const defaultFontSize = 10
|
|
6
|
-
const defaultRectHeight = 15
|
|
5
|
+
const defaultFontSize = 10;
|
|
6
|
+
const defaultRectHeight = 15;
|
|
7
7
|
|
|
8
8
|
class AnnoBar extends Component {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
this.state = {
|
|
12
|
+
top: 0,
|
|
13
|
+
left: 0,
|
|
14
|
+
width: 50,
|
|
15
|
+
height: defaultRectHeight,
|
|
16
|
+
fontSize: defaultFontSize,
|
|
17
|
+
};
|
|
18
|
+
this.textRef = React.createRef();
|
|
19
|
+
}
|
|
9
20
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
height: defaultRectHeight,
|
|
17
|
-
fontSize: defaultFontSize,
|
|
18
|
-
}
|
|
19
|
-
this.textRef = React.createRef()
|
|
20
|
-
}
|
|
21
|
+
/*************
|
|
22
|
+
* EVENTS *
|
|
23
|
+
**************/
|
|
24
|
+
componentWillMount() {
|
|
25
|
+
if (this.props.mode !== modes.CREATE) this.setPosition();
|
|
26
|
+
}
|
|
21
27
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
componentWillMount() {
|
|
26
|
-
if (this.props.mode !== modes.CREATE) this.setPosition()
|
|
28
|
+
componentDidUpdate() {
|
|
29
|
+
if (this.props.mode !== modes.CREATE) {
|
|
30
|
+
this.setPosition();
|
|
27
31
|
}
|
|
32
|
+
}
|
|
28
33
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
handleClick(e) {
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
if (this.props.onClick) {
|
|
37
|
+
this.props.onClick(e);
|
|
33
38
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
}
|
|
40
|
+
/*************
|
|
41
|
+
* LOGIC *
|
|
42
|
+
*************/
|
|
43
|
+
setPosition() {
|
|
44
|
+
// const center = transform.getCenter(this.props.anno.data, this.props.anno.type)
|
|
45
|
+
// const top = center.y
|
|
46
|
+
// const left = center.x
|
|
47
|
+
// if (this.state.top !== top || this.state.left !== left){
|
|
48
|
+
// this.setState({
|
|
49
|
+
// top,
|
|
50
|
+
// left
|
|
51
|
+
// })
|
|
52
|
+
// }
|
|
53
|
+
let topPoint = transform.getTopPoint(this.props.anno.data);
|
|
54
|
+
topPoint = transform.getMostLeftPoint(topPoint)[0];
|
|
55
|
+
if (this.textRef.current) {
|
|
56
|
+
const text = this.textRef.current.getBoundingClientRect();
|
|
57
|
+
const textPadding = 2;
|
|
58
|
+
let rectWidth = (text.width + textPadding) / this.props.svg.scale;
|
|
59
|
+
if (rectWidth !== this.state.width) {
|
|
60
|
+
this.setState({
|
|
61
|
+
width: rectWidth,
|
|
62
|
+
fontSize: Math.ceil(defaultFontSize / this.props.svg.scale),
|
|
63
|
+
// height: Math.ceil(defaultFontSize/this.props.svg.scale)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
40
66
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
// top,
|
|
51
|
-
// left
|
|
52
|
-
// })
|
|
53
|
-
// }
|
|
54
|
-
let topPoint = transform.getTopPoint(this.props.anno.data)
|
|
55
|
-
topPoint = transform.getMostLeftPoint(topPoint)[0]
|
|
56
|
-
if (this.textRef.current) {
|
|
57
|
-
const text = this.textRef.current.getBoundingClientRect()
|
|
58
|
-
const textPadding = 2
|
|
59
|
-
let rectWidth = (text.width + textPadding) / this.props.svg.scale
|
|
60
|
-
if (rectWidth !== this.state.width) {
|
|
61
|
-
this.setState({
|
|
62
|
-
width: rectWidth,
|
|
63
|
-
fontSize: Math.ceil(defaultFontSize / this.props.svg.scale),
|
|
64
|
-
// height: Math.ceil(defaultFontSize/this.props.svg.scale)
|
|
65
|
-
})
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
let top = topPoint.y - 10
|
|
69
|
-
let left = topPoint.x + 7
|
|
70
|
-
if (top < 0) top = topPoint.y + 10
|
|
71
|
-
if (this.state.top !== top || this.state.left !== left) {
|
|
72
|
-
this.setState({
|
|
73
|
-
top,
|
|
74
|
-
left,
|
|
75
|
-
// width: annoBox[1].x - annoBox[0].x
|
|
76
|
-
})
|
|
77
|
-
}
|
|
67
|
+
let top = topPoint.y - 10;
|
|
68
|
+
let left = topPoint.x + 7;
|
|
69
|
+
if (top < 0) top = topPoint.y + 10;
|
|
70
|
+
if (this.state.top !== top || this.state.left !== left) {
|
|
71
|
+
this.setState({
|
|
72
|
+
top,
|
|
73
|
+
left,
|
|
74
|
+
// width: annoBox[1].x - annoBox[0].x
|
|
75
|
+
});
|
|
78
76
|
}
|
|
77
|
+
}
|
|
79
78
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
/*************
|
|
80
|
+
* RENDERING *
|
|
81
|
+
**************/
|
|
84
82
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
83
|
+
render() {
|
|
84
|
+
let label = "";
|
|
85
|
+
if (!this.props.possibleLabels) return null;
|
|
86
|
+
let labelObject;
|
|
87
|
+
if (this.props.anno.labelIds && this.props.anno.labelIds.length > 0) {
|
|
88
|
+
this.props.anno.labelIds.forEach((lbl, idx) => {
|
|
89
|
+
labelObject = this.props.possibleLabels.find((el) => {
|
|
90
|
+
return el.id === lbl;
|
|
91
|
+
});
|
|
92
|
+
if (idx > 0) label += ", ";
|
|
93
|
+
label += labelObject.label;
|
|
94
|
+
});
|
|
95
|
+
} else {
|
|
96
|
+
if (this.props.defaultLabel) {
|
|
97
|
+
if (Number.isInteger(this.props.defaultLabel)) {
|
|
98
|
+
labelObject = this.props.possibleLabels.find((el) => {
|
|
99
|
+
return el.id === this.props.defaultLabel;
|
|
100
|
+
});
|
|
101
|
+
label = labelObject.label;
|
|
97
102
|
} else {
|
|
98
|
-
|
|
99
|
-
if (Number.isInteger(this.props.defaultLabel)) {
|
|
100
|
-
labelObject = this.props.possibleLabels.find(el => {
|
|
101
|
-
return el.id === this.props.defaultLabel
|
|
102
|
-
})
|
|
103
|
-
label = labelObject.label
|
|
104
|
-
} else {
|
|
105
|
-
label = this.props.defaultLabel
|
|
106
|
-
}
|
|
107
|
-
} else {
|
|
108
|
-
label = 'no label'
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
switch (this.props.mode) {
|
|
112
|
-
case modes.VIEW:
|
|
113
|
-
return (<g>
|
|
114
|
-
<rect x={this.state.left} y={this.state.top - 6}
|
|
115
|
-
width={this.state.width} height={this.state.height} rx="5"
|
|
116
|
-
opacity='0.5'
|
|
117
|
-
style={this.props.style}
|
|
118
|
-
/>
|
|
119
|
-
<text x={this.state.left} y={this.state.top}
|
|
120
|
-
fill="white"
|
|
121
|
-
onClick={e => this.handleClick(e)}
|
|
122
|
-
textAnchor="start"
|
|
123
|
-
alignmentBaseline="central"
|
|
124
|
-
ref={this.textRef}
|
|
125
|
-
fontSize={this.state.fontSize + "pt"}
|
|
126
|
-
// textLength="50"
|
|
127
|
-
// style={{...this.props.style, strokeWidth:1}}
|
|
128
|
-
>
|
|
129
|
-
{label}
|
|
130
|
-
</text>
|
|
131
|
-
{/* This second rect is to prevent text from getting marked */}
|
|
132
|
-
<rect x={this.state.left} y={this.state.top - 6}
|
|
133
|
-
width={this.state.width}
|
|
134
|
-
height={this.state.height} rx="5"
|
|
135
|
-
opacity='0.01'
|
|
136
|
-
style={this.props.style}
|
|
137
|
-
/>
|
|
138
|
-
</g>
|
|
139
|
-
)
|
|
140
|
-
default:
|
|
141
|
-
return null
|
|
103
|
+
label = this.props.defaultLabel;
|
|
142
104
|
}
|
|
143
|
-
|
|
105
|
+
} else {
|
|
106
|
+
label = "no label";
|
|
107
|
+
}
|
|
144
108
|
}
|
|
145
|
-
|
|
109
|
+
switch (this.props.mode) {
|
|
110
|
+
case modes.VIEW:
|
|
111
|
+
return (
|
|
112
|
+
<g>
|
|
113
|
+
<rect
|
|
114
|
+
x={this.state.left}
|
|
115
|
+
y={this.state.top - 6}
|
|
116
|
+
width={this.state.width}
|
|
117
|
+
height={this.state.height}
|
|
118
|
+
rx="5"
|
|
119
|
+
opacity="0.5"
|
|
120
|
+
style={this.props.style}
|
|
121
|
+
/>
|
|
122
|
+
<text
|
|
123
|
+
x={this.state.left}
|
|
124
|
+
y={this.state.top}
|
|
125
|
+
fill="white"
|
|
126
|
+
onClick={(e) => this.handleClick(e)}
|
|
127
|
+
textAnchor="start"
|
|
128
|
+
alignmentBaseline="central"
|
|
129
|
+
ref={this.textRef}
|
|
130
|
+
fontSize={this.state.fontSize + "pt"}
|
|
131
|
+
// textLength="50"
|
|
132
|
+
// style={{...this.props.style, strokeWidth:1}}
|
|
133
|
+
>
|
|
134
|
+
{label}
|
|
135
|
+
</text>
|
|
136
|
+
{/* This second rect is to prevent text from getting marked */}
|
|
137
|
+
<rect
|
|
138
|
+
x={this.state.left}
|
|
139
|
+
y={this.state.top - 6}
|
|
140
|
+
width={this.state.width}
|
|
141
|
+
height={this.state.height}
|
|
142
|
+
rx="5"
|
|
143
|
+
opacity="0.01"
|
|
144
|
+
style={this.props.style}
|
|
145
|
+
/>
|
|
146
|
+
</g>
|
|
147
|
+
);
|
|
148
|
+
default:
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
146
152
|
}
|
|
147
153
|
|
|
148
|
-
export default AnnoBar
|
|
154
|
+
export default AnnoBar;
|