lost-sia 2.0.0-alpha0 → 2.0.0-alpha10
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 +21 -4
- 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 +6 -3
- 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.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lost-sia",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-alpha10",
|
|
4
4
|
"description": "Single Image Annotation Tool",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "l3p-cv/lost-sia",
|
|
@@ -32,7 +32,10 @@
|
|
|
32
32
|
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
33
33
|
"preview": "vite preview",
|
|
34
34
|
"publishpkg": "npm publish",
|
|
35
|
-
"test": "vitest run"
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"storybook": "storybook dev -p 6006",
|
|
37
|
+
"build-storybook": "storybook build",
|
|
38
|
+
"format": "prettier --write src/"
|
|
36
39
|
},
|
|
37
40
|
"dependencies": {
|
|
38
41
|
"@coreui/react": "^5.0.0",
|
|
@@ -53,6 +56,15 @@
|
|
|
53
56
|
"react-dom": "^18.0.0"
|
|
54
57
|
},
|
|
55
58
|
"devDependencies": {
|
|
59
|
+
"@chromatic-com/storybook": "^1.5.0",
|
|
60
|
+
"@storybook/addon-essentials": "^8.1.5",
|
|
61
|
+
"@storybook/addon-interactions": "^8.1.5",
|
|
62
|
+
"@storybook/addon-links": "^8.1.5",
|
|
63
|
+
"@storybook/addon-onboarding": "^8.1.5",
|
|
64
|
+
"@storybook/blocks": "^8.1.5",
|
|
65
|
+
"@storybook/react": "^8.1.5",
|
|
66
|
+
"@storybook/react-vite": "^8.1.5",
|
|
67
|
+
"@storybook/test": "^8.1.5",
|
|
56
68
|
"@vitejs/plugin-react": "^4.3.0",
|
|
57
69
|
"cross-env": "^7.0.3",
|
|
58
70
|
"eslint": "^8.0.1",
|
|
@@ -63,14 +75,19 @@
|
|
|
63
75
|
"eslint-plugin-promise": "^6.2.0",
|
|
64
76
|
"eslint-plugin-react": "^7.34.2",
|
|
65
77
|
"eslint-plugin-standard": "^5.0.0",
|
|
78
|
+
"eslint-plugin-storybook": "^0.8.0",
|
|
66
79
|
"glob": "^10.4.1",
|
|
80
|
+
"prettier": "^3.3.3",
|
|
81
|
+
"prop-types": "^15.8.1",
|
|
82
|
+
"react-redux": "^9.1.2",
|
|
83
|
+
"redux": "^5.0.1",
|
|
84
|
+
"storybook": "^8.1.5",
|
|
67
85
|
"vite": "^5.2.12",
|
|
68
86
|
"vitest": "^1.6.0"
|
|
69
87
|
},
|
|
70
88
|
"eslintConfig": {
|
|
71
89
|
"extends": [
|
|
72
|
-
"plugin:storybook/recommended",
|
|
73
90
|
"plugin:storybook/recommended"
|
|
74
91
|
]
|
|
75
92
|
}
|
|
76
|
-
}
|
|
93
|
+
}
|
|
@@ -1,57 +1,70 @@
|
|
|
1
|
-
import Prompt from
|
|
2
|
-
import React from
|
|
3
|
-
import { Card, Divider, Header, Image } from
|
|
1
|
+
import Prompt from "./Prompt";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Card, Divider, Header, Image } from "semantic-ui-react";
|
|
4
4
|
|
|
5
5
|
const LabelExampleViewer = (props) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
props.onRequestExample()
|
|
11
|
-
}
|
|
6
|
+
const requestExample = (e) => {
|
|
7
|
+
e.stopPropagation();
|
|
8
|
+
if (props.onRequestExample) {
|
|
9
|
+
props.onRequestExample();
|
|
12
10
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
</
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
{
|
|
11
|
+
};
|
|
12
|
+
const renderContent = () => {
|
|
13
|
+
if (!props.lbl) return null;
|
|
14
|
+
if (!props.exampleImg) return null;
|
|
15
|
+
const description = (
|
|
16
|
+
<div>
|
|
17
|
+
{/* <Divider horizontal> Description </Divider> */}
|
|
18
|
+
{props.lbl.description}
|
|
19
|
+
<Divider horizontal> comment </Divider>
|
|
20
|
+
{props.exampleImg.anno ? props.exampleImg.anno.comment : "no comment"}
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
return (
|
|
24
|
+
<div>
|
|
25
|
+
<Card
|
|
26
|
+
|
|
27
|
+
// image={props.exampleImg.img}
|
|
28
|
+
// description={props.lbl.description}
|
|
29
|
+
// header={props.lbl.label}
|
|
30
|
+
// // description={props.exampleImg.anno.comment}
|
|
31
|
+
// extra={props.exampleImg.anno.comment}
|
|
32
|
+
>
|
|
33
|
+
<Image
|
|
34
|
+
onClick={(e) => requestExample(e)}
|
|
35
|
+
src={props.exampleImg.img}
|
|
36
|
+
wrapped
|
|
37
|
+
ui={false}
|
|
38
|
+
/>
|
|
39
|
+
<Card.Content>
|
|
40
|
+
<Card.Header>{props.lbl.label}</Card.Header>
|
|
41
|
+
{/* <Card.Description>{props.lbl.description}</Card.Description> */}
|
|
42
|
+
<Card.Description>{description}</Card.Description>
|
|
43
|
+
{/* <Card.Description>{props.exampleImg.anno.comment}</Card.Description> */}
|
|
44
|
+
</Card.Content>
|
|
45
|
+
</Card>
|
|
46
|
+
{/* <Header inverted>{props.lbl.label}</Header>
|
|
40
47
|
{props.lbl.description}
|
|
41
48
|
<Image src={props.exampleImg.img} centered size='medium'></Image> */}
|
|
42
|
-
|
|
43
|
-
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
44
52
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
53
|
+
const handlePromptClick = () => {
|
|
54
|
+
if (props.onClose) {
|
|
55
|
+
props.onClose();
|
|
49
56
|
}
|
|
57
|
+
};
|
|
50
58
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
59
|
+
return (
|
|
60
|
+
<Prompt
|
|
61
|
+
onClick={() => {
|
|
62
|
+
handlePromptClick();
|
|
63
|
+
}}
|
|
64
|
+
active={props.active}
|
|
65
|
+
content={renderContent()}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
56
69
|
|
|
57
|
-
export default LabelExampleViewer
|
|
70
|
+
export default LabelExampleViewer;
|
package/src/AnnoLabelInput.jsx
CHANGED
|
@@ -1,99 +1,109 @@
|
|
|
1
|
-
import React, { Component } from
|
|
2
|
-
import LabelInput from
|
|
3
|
-
import * as constraints from
|
|
4
|
-
import * as annoStatus from
|
|
1
|
+
import React, { Component } from "react";
|
|
2
|
+
import LabelInput from "./LabelInput";
|
|
3
|
+
import * as constraints from "./utils/constraints";
|
|
4
|
+
import * as annoStatus from "./types/annoStatus";
|
|
5
5
|
|
|
6
6
|
class AnnoLabelInput extends Component {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super(props);
|
|
9
|
+
this.state = {
|
|
10
|
+
top: 400,
|
|
11
|
+
left: 100,
|
|
12
|
+
label: undefined,
|
|
13
|
+
visibility: "hidden",
|
|
14
|
+
possibleLabels: [],
|
|
15
|
+
};
|
|
16
|
+
this.inputGroupRef = React.createRef();
|
|
17
|
+
}
|
|
7
18
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
top: 400,
|
|
12
|
-
left: 100,
|
|
13
|
-
label: undefined,
|
|
14
|
-
visibility: 'hidden',
|
|
15
|
-
possibleLabels: []
|
|
16
|
-
}
|
|
17
|
-
this.inputGroupRef = React.createRef()
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
componentWillMount() {
|
|
21
|
-
this.setPosition()
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
componentDidUpdate(prevProps) {
|
|
25
|
-
if (this.props.visible) {
|
|
26
|
-
this.setPosition()
|
|
27
|
-
}
|
|
28
|
-
|
|
19
|
+
componentWillMount() {
|
|
20
|
+
this.setPosition();
|
|
21
|
+
}
|
|
29
22
|
|
|
23
|
+
componentDidUpdate(prevProps) {
|
|
24
|
+
if (this.props.visible) {
|
|
25
|
+
this.setPosition();
|
|
30
26
|
}
|
|
27
|
+
}
|
|
31
28
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
onClose() {
|
|
50
|
-
if (this.props.onClose) {
|
|
51
|
-
this.props.onClose()
|
|
52
|
-
}
|
|
29
|
+
/*************
|
|
30
|
+
* LOGIC *
|
|
31
|
+
*************/
|
|
32
|
+
setPosition() {
|
|
33
|
+
if (this.props.mousePos) {
|
|
34
|
+
const top = this.props.mousePos.y + this.props.svg.top - 10;
|
|
35
|
+
const left = this.props.mousePos.x + this.props.svg.left - 10;
|
|
36
|
+
if (this.state.top !== top || this.state.left !== left) {
|
|
37
|
+
this.setState({
|
|
38
|
+
top: top,
|
|
39
|
+
left: left,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
53
42
|
}
|
|
43
|
+
}
|
|
54
44
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
45
|
+
onClose() {
|
|
46
|
+
if (this.props.onClose) {
|
|
47
|
+
this.props.onClose();
|
|
59
48
|
}
|
|
49
|
+
}
|
|
60
50
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
this.annoLabelUpdate({
|
|
65
|
-
...this.props.selectedAnno,
|
|
66
|
-
labelIds: label,
|
|
67
|
-
status: this.props.selectedAnno.status !== annoStatus.NEW ? annoStatus.CHANGED : annoStatus.NEW
|
|
68
|
-
})
|
|
51
|
+
annoLabelUpdate(anno) {
|
|
52
|
+
if (this.props.onLabelUpdate) {
|
|
53
|
+
this.props.onLabelUpdate(anno);
|
|
69
54
|
}
|
|
55
|
+
}
|
|
70
56
|
|
|
57
|
+
updateAnnoLabel(label) {
|
|
58
|
+
if (
|
|
59
|
+
!constraints.allowedToLabel(
|
|
60
|
+
this.props.allowedActions,
|
|
61
|
+
this.props.selectedAnno,
|
|
62
|
+
)
|
|
63
|
+
)
|
|
64
|
+
return;
|
|
65
|
+
this.annoLabelUpdate({
|
|
66
|
+
...this.props.selectedAnno,
|
|
67
|
+
labelIds: label,
|
|
68
|
+
status:
|
|
69
|
+
this.props.selectedAnno.status !== annoStatus.NEW
|
|
70
|
+
? annoStatus.CHANGED
|
|
71
|
+
: annoStatus.NEW,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
71
74
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
75
|
+
/*************
|
|
76
|
+
* RENDERING *
|
|
77
|
+
**************/
|
|
78
|
+
render() {
|
|
79
|
+
if (!this.props.visible) return null;
|
|
80
|
+
return (
|
|
81
|
+
<div
|
|
82
|
+
ref={this.inputGroupRef}
|
|
83
|
+
style={{
|
|
84
|
+
position: "fixed",
|
|
85
|
+
top: this.state.top,
|
|
86
|
+
left: this.state.left,
|
|
87
|
+
}}
|
|
88
|
+
>
|
|
89
|
+
<LabelInput
|
|
90
|
+
svg={this.props.svg}
|
|
91
|
+
onClose={() => this.onClose()}
|
|
92
|
+
initLabelIds={this.props.selectedAnno.labelIds}
|
|
93
|
+
relatedId={this.props.selectedAnno.id}
|
|
94
|
+
visible={this.props.visible}
|
|
95
|
+
onLabelUpdate={(label) => this.updateAnnoLabel(label)}
|
|
96
|
+
possibleLabelsProp={this.props.possibleLabels}
|
|
97
|
+
multilabels={this.props.multilabels}
|
|
98
|
+
disabled={!this.props.allowedActions.label}
|
|
99
|
+
renderPopup
|
|
100
|
+
focusOnRender
|
|
101
|
+
open={true}
|
|
102
|
+
defaultLabel={this.props.defaultLabel}
|
|
103
|
+
/>
|
|
104
|
+
</div>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
97
107
|
}
|
|
98
108
|
|
|
99
|
-
export default AnnoLabelInput
|
|
109
|
+
export default AnnoLabelInput;
|
package/src/AnnoToolBar.jsx
CHANGED
|
@@ -1,89 +1,108 @@
|
|
|
1
|
-
import React, {Component} from
|
|
1
|
+
import React, { Component } from "react";
|
|
2
2
|
|
|
3
|
-
import * as transform from
|
|
3
|
+
import * as transform from "./utils/transform";
|
|
4
4
|
|
|
5
|
-
class AnnoToolBar extends Component{
|
|
5
|
+
class AnnoToolBar extends Component {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
super(props);
|
|
8
|
+
this.state = {
|
|
9
|
+
top: 400,
|
|
10
|
+
left: 100,
|
|
11
|
+
width: 50,
|
|
12
|
+
label: undefined,
|
|
13
|
+
visibility: "hidden",
|
|
14
|
+
possibleLabels: [],
|
|
15
|
+
};
|
|
16
|
+
this.inputGroupRef = React.createRef();
|
|
17
|
+
}
|
|
6
18
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
top: 400,
|
|
11
|
-
left: 100,
|
|
12
|
-
width: 50,
|
|
13
|
-
label: undefined,
|
|
14
|
-
visibility: 'hidden',
|
|
15
|
-
possibleLabels: []
|
|
16
|
-
}
|
|
17
|
-
this.inputGroupRef = React.createRef()
|
|
18
|
-
}
|
|
19
|
+
componentWillMount() {
|
|
20
|
+
this.setPosition();
|
|
21
|
+
}
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
componentDidUpdate(prevProps) {
|
|
24
|
+
if (this.props.visible) {
|
|
25
|
+
this.setPosition();
|
|
22
26
|
}
|
|
23
|
-
|
|
24
|
-
componentDidUpdate(prevProps){
|
|
25
|
-
if (this.props.visible){
|
|
26
|
-
this.setPosition()
|
|
27
|
-
}
|
|
27
|
+
}
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
/*************
|
|
30
|
+
* LOGIC *
|
|
31
|
+
*************/
|
|
32
|
+
setPosition() {
|
|
33
|
+
if (this.props.selectedAnno) {
|
|
34
|
+
// const center = transform.getCenter(this.props.selectedAnno.data, this.props.selectedAnno.type)
|
|
35
|
+
// const annoBox = transform.getBox(this.props.selectedAnno.data, this.props.selectedAnno.type)
|
|
36
|
+
let topPoint = transform.getTopPoint(this.props.selectedAnno.data);
|
|
37
|
+
topPoint = transform.getMostLeftPoint(topPoint)[0];
|
|
38
|
+
const inputRect = this.inputGroupRef.current.getBoundingClientRect();
|
|
39
|
+
let top =
|
|
40
|
+
this.props.svg.top +
|
|
41
|
+
(topPoint.y + this.props.svg.translateY) * this.props.svg.scale -
|
|
42
|
+
44;
|
|
43
|
+
let left =
|
|
44
|
+
this.props.svg.left +
|
|
45
|
+
(topPoint.x + this.props.svg.translateX) * this.props.svg.scale -
|
|
46
|
+
inputRect.width / 2.0 -
|
|
47
|
+
1;
|
|
48
|
+
// if (left < this.props.svg.left) left = this.props.svg.left
|
|
49
|
+
// if (left+inputRect.width > this.props.svg.left+this.props.svg.width){
|
|
50
|
+
// left = this.props.svg.left+this.props.svg.width - inputRect.width
|
|
51
|
+
// }
|
|
52
|
+
if (top < 0)
|
|
53
|
+
top =
|
|
54
|
+
this.props.svg.top +
|
|
55
|
+
(topPoint.y + this.props.svg.translateY + 10) * this.props.svg.scale;
|
|
56
|
+
if (this.state.top !== top || this.state.left !== left) {
|
|
57
|
+
this.setState({
|
|
58
|
+
top,
|
|
59
|
+
left,
|
|
60
|
+
// width: annoBox[1].x - annoBox[0].x
|
|
61
|
+
});
|
|
62
|
+
}
|
|
30
63
|
}
|
|
64
|
+
}
|
|
31
65
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
setPosition(){
|
|
36
|
-
if (this.props.selectedAnno){
|
|
37
|
-
// const center = transform.getCenter(this.props.selectedAnno.data, this.props.selectedAnno.type)
|
|
38
|
-
// const annoBox = transform.getBox(this.props.selectedAnno.data, this.props.selectedAnno.type)
|
|
39
|
-
let topPoint = transform.getTopPoint(this.props.selectedAnno.data)
|
|
40
|
-
topPoint = transform.getMostLeftPoint(topPoint)[0]
|
|
41
|
-
const inputRect = this.inputGroupRef.current.getBoundingClientRect()
|
|
42
|
-
let top = this.props.svg.top + (topPoint.y + this.props.svg.translateY) *this.props.svg.scale - 44
|
|
43
|
-
let left = this.props.svg.left + (topPoint.x + this.props.svg.translateX) *this.props.svg.scale - inputRect.width /2.0 - 1
|
|
44
|
-
// if (left < this.props.svg.left) left = this.props.svg.left
|
|
45
|
-
// if (left+inputRect.width > this.props.svg.left+this.props.svg.width){
|
|
46
|
-
// left = this.props.svg.left+this.props.svg.width - inputRect.width
|
|
47
|
-
// }
|
|
48
|
-
if (top < 0) top = this.props.svg.top + (topPoint.y + this.props.svg.translateY + 10) *this.props.svg.scale
|
|
49
|
-
if (this.state.top !== top || this.state.left !== left){
|
|
50
|
-
this.setState({
|
|
51
|
-
top,
|
|
52
|
-
left,
|
|
53
|
-
// width: annoBox[1].x - annoBox[0].x
|
|
54
|
-
})
|
|
55
|
-
}
|
|
56
|
-
}
|
|
66
|
+
onClose() {
|
|
67
|
+
if (this.props.onClose) {
|
|
68
|
+
this.props.onClose();
|
|
57
69
|
}
|
|
70
|
+
}
|
|
58
71
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
72
|
+
handleClick(e) {
|
|
73
|
+
if (this.props.onClick) {
|
|
74
|
+
this.props.onClick(e);
|
|
63
75
|
}
|
|
76
|
+
}
|
|
64
77
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
renderDaviIcon() {
|
|
79
|
+
return (
|
|
80
|
+
<svg
|
|
81
|
+
version="1.1"
|
|
82
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
83
|
+
// x="0px" y="0px"
|
|
84
|
+
// width="1190.549px" height="841.891px"
|
|
85
|
+
viewBox="0 0 1190.549 841.891"
|
|
86
|
+
width="60px"
|
|
87
|
+
onClick={(e) => this.handleClick(e)}
|
|
88
|
+
>
|
|
89
|
+
<g id="Info">
|
|
90
|
+
<path
|
|
91
|
+
id="Maps"
|
|
92
|
+
fill={this.props.color}
|
|
93
|
+
d="M620.561,817.217c-1.568-3.62-3.771-7.101-4.611-10.885
|
|
81
94
|
c-24.452-109.811-74.341-207.569-139.215-298.675c-27.507-38.628-55.814-77.404-77.438-119.371
|
|
82
95
|
C324.363,242.85,402.696,58.71,574.209,26.508c145.509-27.32,282.953,75.871,296.543,222.773
|
|
83
96
|
c4.659,50.356-7.471,97.96-32.152,141.022c-27.812,48.526-58.75,95.364-90.073,141.758
|
|
84
97
|
c-50.917,75.411-91.062,155.558-113.421,244.091c-2.438,9.652-3.936,19.543-6.271,29.227c-0.992,4.104-3.023,7.961-4.584,11.93
|
|
85
|
-
C623.021,817.277,621.789,817.247,620.561,817.217z"
|
|
86
|
-
|
|
98
|
+
C623.021,817.277,621.789,817.247,620.561,817.217z"
|
|
99
|
+
/>
|
|
100
|
+
<path
|
|
101
|
+
id="Text"
|
|
102
|
+
fillRule="evenodd"
|
|
103
|
+
clipRule="evenodd"
|
|
104
|
+
fill="#FFFFFF"
|
|
105
|
+
d="M724.709,250.898
|
|
87
106
|
c-0.055-3.974,0.047-7.949,0.033-11.923c-0.007-1.228-1.54-2.767-2.76-2.777c-2.428-0.021-4.862-0.015-7.29-0.015
|
|
88
107
|
c-22.466,0.001-44.934,0.005-67.404,0.009c-2.475,0.001-3.658,1.154-3.658,3.588c-0.001,47.365-0.001,94.73-0.001,142.096
|
|
89
108
|
c0,13.526,0,27.05,0.001,40.577c0,2.305,1.274,3.584,3.562,3.59c6.623,0.004,9.256-0.07,19.873,0.004
|
|
@@ -96,37 +115,39 @@ class AnnoToolBar extends Component{
|
|
|
96
115
|
c0-8.392,0-16.781,0-25.173c0-0.321,0.228-5.156,4.091-9.277c3.864-4.122,8.014-3.822,8.445-3.822
|
|
97
116
|
c25.835,0.003,51.672,0.002,77.507,0.002c46.813,0.001,140.443,0.001,140.443,0.001s6.153-0.088,10.926-0.052
|
|
98
117
|
c0.3-0.008,5.713,0.363,9.178,3.994c3.46,3.631,3.046,8.407,3.046,8.635c-0.007,12.862,0.079,25.725-0.003,38.587
|
|
99
|
-
c-0.074,8.051-6.938,12.819-13.703,12.847C731.482,263.519,724.956,259.059,724.709,250.898z"
|
|
100
|
-
|
|
101
|
-
</
|
|
102
|
-
|
|
118
|
+
c-0.074,8.051-6.938,12.819-13.703,12.847C731.482,263.519,724.956,259.059,724.709,250.898z"
|
|
119
|
+
/>
|
|
120
|
+
</g>
|
|
121
|
+
</svg>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
103
124
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
125
|
+
/*************
|
|
126
|
+
* RENDERING *
|
|
127
|
+
**************/
|
|
128
|
+
render() {
|
|
129
|
+
if (!this.props.visible) return null;
|
|
130
|
+
return (
|
|
131
|
+
<div
|
|
132
|
+
ref={this.inputGroupRef}
|
|
133
|
+
style={{
|
|
134
|
+
position: "fixed",
|
|
135
|
+
top: this.state.top,
|
|
136
|
+
left: this.state.left,
|
|
137
|
+
cursor: "pointer",
|
|
138
|
+
}}
|
|
139
|
+
>
|
|
140
|
+
{/* <Button icon circular basic
|
|
119
141
|
onClick={e => this.handleClick(e)}
|
|
120
142
|
> */}
|
|
121
|
-
|
|
143
|
+
{/* <Icon name="pencil"
|
|
122
144
|
onClick={e => this.handleClick(e)}
|
|
123
145
|
/> */}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
146
|
+
{/* </Button> */}
|
|
147
|
+
{this.renderDaviIcon()}
|
|
148
|
+
</div>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
130
151
|
}
|
|
131
152
|
|
|
132
|
-
export default AnnoToolBar
|
|
153
|
+
export default AnnoToolBar;
|