lost-sia 2.0.1-alpha8 → 3.0.0
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/README.md +4 -0
- package/dist/Annotation/logic/Annotation.d.ts +17 -0
- package/dist/Annotation/logic/Annotation.js +1 -0
- package/dist/Annotation/ui/AnnotationComponent.d.ts +24 -0
- package/dist/Annotation/ui/AnnotationComponent.js +1 -0
- package/dist/Annotation/ui/atoms/AnnoBar.d.ts +15 -0
- package/dist/Annotation/ui/atoms/AnnoBar.js +1 -0
- package/dist/Annotation/ui/atoms/DaviIcon.d.ts +9 -0
- package/dist/Annotation/ui/atoms/DaviIcon.js +19 -0
- package/dist/Annotation/ui/atoms/Edge.d.ts +17 -0
- package/dist/Annotation/ui/atoms/Edge.js +1 -0
- package/dist/Annotation/ui/atoms/Node.d.ts +17 -0
- package/dist/Annotation/ui/atoms/Node.js +1 -0
- package/dist/Annotation/ui/atoms/PolygonArea.d.ts +16 -0
- package/dist/Annotation/ui/atoms/PolygonArea.js +1 -0
- package/dist/Annotation/ui/tools/BBox.d.ts +21 -0
- package/dist/Annotation/ui/tools/BBox.js +1 -0
- package/dist/Annotation/ui/tools/Line.d.ts +21 -0
- package/dist/Annotation/ui/tools/Line.js +1 -0
- package/dist/Annotation/ui/tools/Point.d.ts +16 -0
- package/dist/Annotation/ui/tools/Point.js +1 -0
- package/dist/Annotation/ui/tools/Polygon.d.ts +23 -0
- package/dist/Annotation/ui/tools/Polygon.js +1 -0
- package/dist/Canvas/Canvas.d.ts +31 -0
- package/dist/Canvas/Canvas.js +1 -0
- package/dist/Canvas/LabelInput.d.ts +11 -0
- package/dist/Canvas/LabelInput.js +1 -0
- package/dist/IconButton.d.ts +25 -0
- package/dist/IconButton.js +1 -0
- package/dist/Sia.d.ts +33 -0
- package/dist/Sia.js +1 -0
- package/dist/Toolbar/Toolbar.d.ts +21 -0
- package/dist/Toolbar/Toolbar.js +1 -0
- package/dist/Toolbar/ToolbarItems/AccessibilityTools.d.ts +7 -0
- package/dist/Toolbar/ToolbarItems/AccessibilityTools.js +1 -0
- package/dist/Toolbar/ToolbarItems/AnnoToolSelector.d.ts +11 -0
- package/dist/Toolbar/ToolbarItems/AnnoToolSelector.js +1 -0
- package/dist/Toolbar/ToolbarItems/ImageToolItems/ImageLabelInput.d.ts +11 -0
- package/dist/Toolbar/ToolbarItems/ImageToolItems/ImageLabelInput.js +1 -0
- package/dist/Toolbar/ToolbarItems/ImageToolItems/TagLabel.d.ts +11 -0
- package/dist/Toolbar/ToolbarItems/ImageToolItems/TagLabel.js +1 -0
- package/dist/Toolbar/ToolbarItems/ImageTools.d.ts +13 -0
- package/dist/Toolbar/ToolbarItems/ImageTools.js +1 -0
- package/dist/Toolbar/ToolbarItems/Instructions.d.ts +2 -0
- package/dist/Toolbar/ToolbarItems/Instructions.js +1 -0
- package/dist/Toolbar/ToolbarItems/InstructionsModal.d.ts +6 -0
- package/dist/Toolbar/ToolbarItems/InstructionsModal.js +1 -0
- package/dist/assets/SIA-BV1tYu3P.css +1 -0
- package/dist/assets/brand-icons-Cu_C0hZ4.svg +1008 -0
- package/dist/assets/brand-icons-F3SPCeH1.woff +0 -0
- package/dist/assets/brand-icons-XL9sxUpA.woff2 +0 -0
- package/dist/assets/brand-icons-sqJ2Pg7a.eot +0 -0
- package/dist/assets/brand-icons-ubhWoxly.ttf +0 -0
- package/dist/assets/flags-DOLqOU7Y.png +0 -0
- package/dist/assets/icons-BOCtAERH.woff +0 -0
- package/dist/assets/icons-CHzK1VD9.eot +0 -0
- package/dist/assets/icons-D29ZQHHw.ttf +0 -0
- package/dist/assets/icons-Du6TOHnR.woff2 +0 -0
- package/dist/assets/icons-RwhydX30.svg +1518 -0
- package/dist/assets/node_modules/semantic-ui-css/semantic.min-Bvulf91l.css +346 -0
- package/dist/assets/outline-icons-BfdLr8tr.svg +366 -0
- package/dist/assets/outline-icons-DD8jm0uy.ttf +0 -0
- package/dist/assets/outline-icons-DInHoiqI.woff2 +0 -0
- package/dist/assets/outline-icons-LX8adJ4n.eot +0 -0
- package/dist/assets/outline-icons-aQ88nltS.woff +0 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1 -0
- package/dist/models/AnnotationMode.d.ts +11 -0
- package/dist/models/AnnotationMode.js +1 -0
- package/dist/models/AnnotationStatus.d.ts +8 -0
- package/dist/models/AnnotationStatus.js +1 -0
- package/dist/models/AnnotationTool.d.ts +7 -0
- package/dist/models/AnnotationTool.js +1 -0
- package/dist/models/CanvasAction.d.ts +28 -0
- package/dist/models/CanvasAction.js +1 -0
- package/dist/models/Direction.d.ts +7 -0
- package/dist/models/Direction.js +1 -0
- package/dist/models/EditorModes.d.ts +11 -0
- package/dist/models/EditorModes.js +1 -0
- package/dist/models/KeyAction.d.ts +22 -0
- package/dist/models/KeyAction.js +1 -0
- package/dist/models/NotificationType.d.ts +7 -0
- package/dist/models/NotificationType.js +1 -0
- package/dist/models/index.d.ts +6 -0
- package/dist/models/index.js +1 -0
- package/dist/stories/AnnotationTools.stories.d.ts +40 -0
- package/dist/stories/Canvas/Canvas.stories.d.ts +50 -0
- package/dist/stories/Canvas/CanvasOffset.d.ts +13 -0
- package/dist/stories/Canvas/CanvasWithOffset.stories.d.ts +36 -0
- package/dist/stories/FilterDropdown.stories.d.ts +19 -0
- package/dist/stories/MinimalSia.stories.d.ts +66 -0
- package/dist/stories/SIA/DemoWrapper.d.ts +8 -0
- package/dist/stories/SIA/DemoWrapper.stories.d.ts +27 -0
- package/dist/stories/SIA/SIA.stories.d.ts +72 -0
- package/dist/stories/Toolbar/ImageTools/TagLabel.stories.d.ts +21 -0
- package/dist/stories/Toolbar/Instructions.stories.d.ts +11 -0
- package/dist/stories/Toolbar/Toolbar.stories.d.ts +37 -0
- package/dist/stories/exampleData/exampleAnnotations.d.ts +8 -0
- package/dist/stories/exampleData/exampleExternalAnnotations.d.ts +8 -0
- package/dist/stories/exampleData/exampleImage.d.ts +2 -0
- package/dist/stories/exampleData/exampleLabels.d.ts +6 -0
- package/dist/types.d.ts +57 -0
- package/dist/types.js +1 -0
- package/dist/utils/KeyMapper.d.ts +9 -0
- package/dist/utils/KeyMapper.js +1 -0
- package/dist/utils/TimeUtils.d.ts +4 -0
- package/dist/utils/TimeUtils.js +1 -0
- package/dist/utils/color.d.ts +2 -0
- package/dist/utils/color.js +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/mouse.d.ts +6 -0
- package/dist/utils/mouse.js +1 -0
- package/dist/utils/siaIcons.js +12 -0
- package/dist/utils/transform.d.ts +28 -0
- package/dist/utils/transform.js +1 -0
- package/dist/utils/uiConfig.js +1 -0
- package/dist/utils/windowViewport.d.ts +22 -0
- package/dist/utils/windowViewport.js +1 -0
- package/package.json +19 -16
- package/src/AnnoExampleViewer.jsx +18 -18
- package/src/Annotation/logic/Annotation.ts +24 -26
- package/src/Annotation/ui/AnnotationComponent.tsx +115 -86
- package/src/Annotation/ui/atoms/AnnoBar.tsx +51 -53
- package/src/Annotation/ui/atoms/DaviIcon.tsx +12 -22
- package/src/Annotation/ui/atoms/Edge.tsx +25 -22
- package/src/Annotation/ui/atoms/Node.tsx +56 -50
- package/src/Annotation/ui/atoms/PolygonArea.tsx +30 -35
- package/src/Annotation/ui/tools/BBox.tsx +136 -150
- package/src/Annotation/ui/tools/Line.tsx +94 -91
- package/src/Annotation/ui/tools/Point.tsx +19 -17
- package/src/Annotation/ui/tools/Polygon.tsx +126 -95
- package/src/Canvas/Canvas.tsx +748 -594
- package/src/Canvas/LabelInput.tsx +68 -45
- package/src/IconButton.tsx +119 -0
- package/src/InfoBoxes/AnnoDetails.jsx +53 -53
- package/src/InfoBoxes/AnnoStats.jsx +41 -41
- package/src/InfoBoxes/InfoBox.jsx +16 -16
- package/src/InfoBoxes/InfoBoxArea.jsx +32 -34
- package/src/InfoBoxes/LabelInfo.jsx +30 -30
- package/src/SIASettingButton.jsx +25 -25
- package/src/Sia.tsx +484 -0
- package/src/Toolbar/Toolbar.tsx +38 -31
- package/src/Toolbar/ToolbarItems/AccessibilityTools.tsx +26 -46
- package/src/Toolbar/ToolbarItems/AnnoToolSelector.tsx +53 -46
- package/src/Toolbar/ToolbarItems/ImageToolItems/ImageLabelInput.tsx +127 -0
- package/src/Toolbar/ToolbarItems/ImageToolItems/TagLabel.tsx +29 -28
- package/src/Toolbar/ToolbarItems/ImageTools.tsx +43 -40
- package/src/Toolbar/ToolbarItems/Instructions.tsx +47 -50
- package/src/Toolbar/ToolbarItems/InstructionsModal.tsx +8 -8
- package/src/index.ts +9 -13
- package/src/models/{AnnotationMode.tsx → AnnotationMode.ts} +1 -1
- package/src/models/{AnnotationStatus.tsx → AnnotationStatus.ts} +1 -1
- package/src/models/{AnnotationTool.tsx → AnnotationTool.ts} +1 -1
- package/src/models/{CanvasAction.tsx → CanvasAction.ts} +1 -1
- package/src/models/{Direction.tsx → Direction.ts} +1 -1
- package/src/models/{EditorModes.tsx → EditorModes.ts} +1 -1
- package/src/models/{KeyAction.tsx → KeyAction.ts} +3 -1
- package/src/models/NotificationType.ts +8 -0
- package/src/models/index.ts +6 -7
- package/src/siaDummyData.js +71 -71
- package/src/stories/AnnotationTools.mdx +27 -0
- package/src/stories/AnnotationTools.stories.tsx +104 -0
- package/src/stories/Canvas/Canvas.stories.tsx +59 -113
- package/src/stories/Canvas/CanvasOffset.tsx +54 -38
- package/src/stories/Canvas/CanvasWithOffset.stories.tsx +42 -113
- package/src/stories/FilterDropdown.stories.ts +13 -11
- package/src/stories/MinimalSIA.mdx +20 -0
- package/src/stories/MinimalSia.stories.tsx +90 -0
- package/src/stories/SIA/DemoWrapper.stories.tsx +71 -0
- package/src/stories/SIA/DemoWrapper.tsx +55 -0
- package/src/stories/SIA/SIA.stories.tsx +79 -45
- package/src/stories/Toolbar/ImageTools/TagLabel.stories.tsx +11 -12
- package/src/stories/Toolbar/Instructions.stories.tsx +11 -11
- package/src/stories/Toolbar/Toolbar.stories.tsx +32 -47
- package/src/stories/Welcome.mdx +5 -0
- package/src/stories/development/CoordinateSystems.mdx +25 -0
- package/src/stories/exampleData/exampleAnnotations.ts +65 -0
- package/src/stories/exampleData/exampleExternalAnnotations.ts +115 -0
- package/src/stories/{siaDummyData2.ts → exampleData/exampleImage.ts} +3 -264
- package/src/stories/exampleData/exampleLabels.ts +146 -0
- package/src/stories/main.scss +6 -0
- package/src/styles/style.scss +1 -26
- package/src/types.ts +67 -0
- package/src/utils/KeyMapper.ts +76 -74
- package/src/utils/TimeUtils.ts +11 -0
- package/src/utils/color.ts +25 -25
- package/src/utils/hist.js +22 -22
- package/src/utils/index.ts +2 -3
- package/src/utils/mouse.ts +45 -0
- package/src/utils/siaIcons.jsx +5 -7
- package/src/utils/transform.ts +186 -0
- package/src/utils/uiConfig.js +19 -22
- package/src/utils/windowViewport.ts +34 -0
- package/src/AnnoLabelInput.jsx +0 -109
- package/src/AnnoToolBar.jsx +0 -153
- package/src/Annotation/AnnoBar.jsx +0 -154
- package/src/Annotation/Annotation.jsx +0 -395
- package/src/Annotation/Annotation.scss +0 -47
- package/src/Annotation/BBox.jsx +0 -299
- package/src/Annotation/Edge.jsx +0 -92
- package/src/Annotation/InfSelectionArea.jsx +0 -72
- package/src/Annotation/Line.jsx +0 -68
- package/src/Annotation/Node.jsx +0 -282
- package/src/Annotation/Point.jsx +0 -200
- package/src/Annotation/Polygon.jsx +0 -404
- package/src/Annotation/logic/AnnotationUtils.ts +0 -30
- package/src/Canvas.jsx +0 -2194
- package/src/ImgBar.jsx +0 -131
- package/src/LabelInput.jsx +0 -238
- package/src/Prompt.jsx +0 -45
- package/src/SIAFilterButton.jsx +0 -186
- package/src/Sia.jsx +0 -478
- package/src/Sia2.tsx +0 -392
- package/src/SiaPopup.jsx +0 -15
- package/src/ToolBar.jsx +0 -463
- package/src/Toolbar/NavigationButtons.tsx +0 -21
- package/src/Toolbar/ToolbarItem.jsx +0 -30
- package/src/Toolbar/ToolbarItems/ImageToolItems/ImageLabel.tsx +0 -62
- package/src/Toolbar.css +0 -13
- package/src/ToolbarItem.jsx +0 -31
- package/src/filterTools.js +0 -5
- package/src/models/AllowedTools.tsx +0 -9
- package/src/models/AnnotationSettings.tsx +0 -9
- package/src/models/ExternalAnnotation.ts +0 -15
- package/src/models/Label.tsx +0 -8
- package/src/models/UiConfig.tsx +0 -6
- package/src/stories/Button.jsx +0 -54
- package/src/stories/Button.stories.js +0 -48
- package/src/stories/Header.jsx +0 -69
- package/src/stories/Header.stories.js +0 -28
- package/src/stories/Page.jsx +0 -87
- package/src/stories/Page.stories.js +0 -28
- package/src/stories/SIA2/DemoWrapper.stories.tsx +0 -167
- package/src/stories/SIA2/DemoWrapper.tsx +0 -54
- package/src/stories/SIA2/Sia2.stories.tsx +0 -62
- package/src/stories/Toolbar/ImageTools/ImageLabel.stories.tsx +0 -32
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +0 -5
- 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 +0 -15
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +0 -3
- 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 +0 -12
- package/src/stories/assets/youtube.svg +0 -4
- package/src/stories/button.css +0 -30
- package/src/stories/header.css +0 -32
- package/src/stories/lost.js +0 -54
- package/src/stories/page.css +0 -69
- package/src/stories/siaDummyData.js +0 -263
- package/src/stories/store.js +0 -18
- package/src/test.js +0 -7
- package/src/types/annoStatus.js +0 -4
- package/src/types/canvasActions.js +0 -58
- package/src/types/cursorstyles.js +0 -3
- package/src/types/modes.js +0 -9
- package/src/types/notificationType.js +0 -11
- package/src/types/toolbarEvents.js +0 -35
- package/src/types/tools.js +0 -17
- package/src/types.tsx +0 -11
- package/src/utils/annoConversion.js +0 -145
- package/src/utils/annoConversion2.ts +0 -145
- package/src/utils/colorlut.js +0 -68
- package/src/utils/constraints.js +0 -81
- package/src/utils/index.js +0 -1
- package/src/utils/keyActions.js +0 -113
- package/src/utils/mouse.js +0 -14
- package/src/utils/mouse2.ts +0 -35
- package/src/utils/transform.js +0 -336
- package/src/utils/transform2.ts +0 -343
- package/src/utils/windowViewport.js +0 -34
- package/src/utils/windowViewport2.ts +0 -50
|
@@ -1,74 +1,97 @@
|
|
|
1
|
-
import { useState } from
|
|
1
|
+
import { useState } from 'react'
|
|
2
2
|
import {
|
|
3
3
|
CDropdown,
|
|
4
4
|
CDropdownMenu,
|
|
5
5
|
CDropdownItem,
|
|
6
6
|
CFormInput,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
CDropdownDivider,
|
|
8
|
+
CDropdownToggle,
|
|
9
|
+
CPopover,
|
|
10
|
+
} from '@coreui/react'
|
|
11
|
+
import { Label } from '../types'
|
|
9
12
|
|
|
10
13
|
type LabelInputProps = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
defaultLabelId?: number
|
|
15
|
+
isVisible: boolean
|
|
16
|
+
selectedLabelsIds: number[]
|
|
17
|
+
possibleLabels: Label[]
|
|
18
|
+
isMultilabel?: boolean
|
|
19
|
+
onLabelSelect: (selectedLabelIds: number[]) => void
|
|
20
|
+
}
|
|
16
21
|
|
|
17
22
|
const LabelInput = ({
|
|
23
|
+
defaultLabelId,
|
|
24
|
+
isVisible,
|
|
18
25
|
selectedLabelsIds,
|
|
19
26
|
possibleLabels,
|
|
20
27
|
isMultilabel = false,
|
|
21
28
|
onLabelSelect,
|
|
22
29
|
}: LabelInputProps) => {
|
|
23
|
-
const [filter, setFilter] = useState(
|
|
30
|
+
const [filter, setFilter] = useState('')
|
|
24
31
|
|
|
25
32
|
const filteredLabels: Label[] = possibleLabels.filter((label: Label) =>
|
|
26
33
|
label.name.toLowerCase().includes(filter.toLowerCase()),
|
|
27
|
-
)
|
|
34
|
+
)
|
|
28
35
|
|
|
29
36
|
const updateSelectedLabels = (clickedLabel: Label) => {
|
|
30
|
-
let newLabelIds: number[] = []
|
|
37
|
+
let newLabelIds: number[] = []
|
|
31
38
|
|
|
32
39
|
if (isMultilabel) {
|
|
33
|
-
newLabelIds = [...selectedLabelsIds]
|
|
40
|
+
newLabelIds = [...selectedLabelsIds]
|
|
34
41
|
// check if item in list (get its index if so)
|
|
35
|
-
const foundIndex: number = selectedLabelsIds.indexOf(clickedLabel.id)
|
|
42
|
+
const foundIndex: number = selectedLabelsIds.indexOf(clickedLabel.id)
|
|
36
43
|
// add label if not in list, remove label if in list
|
|
37
|
-
if (foundIndex
|
|
38
|
-
|
|
44
|
+
if (foundIndex === -1) {
|
|
45
|
+
newLabelIds.push(clickedLabel.id)
|
|
46
|
+
} else {
|
|
47
|
+
newLabelIds.splice(foundIndex, 1)
|
|
48
|
+
}
|
|
39
49
|
}
|
|
40
50
|
// single-label: just replace list with clicked item
|
|
41
|
-
else newLabelIds = [clickedLabel.id]
|
|
51
|
+
else newLabelIds = [clickedLabel.id]
|
|
42
52
|
|
|
43
|
-
onLabelSelect(newLabelIds)
|
|
44
|
-
}
|
|
53
|
+
onLabelSelect(newLabelIds)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const defaultLabel: Label | undefined = defaultLabelId
|
|
57
|
+
? possibleLabels.find((label: Label) => label.id === defaultLabelId)
|
|
58
|
+
: undefined
|
|
45
59
|
|
|
46
60
|
return (
|
|
47
|
-
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
61
|
+
<>
|
|
62
|
+
<CPopover
|
|
63
|
+
content={`Default Label: ${defaultLabel?.name}`}
|
|
64
|
+
visible={isVisible && defaultLabel !== undefined}
|
|
65
|
+
>
|
|
66
|
+
<div style={{ marginLeft: 80 }} />
|
|
67
|
+
</CPopover>
|
|
68
|
+
|
|
69
|
+
<CDropdown visible={isVisible} autoClose={false} style={{ marginTop: -25 }}>
|
|
70
|
+
{/* this invisible toggle has to be here, othervise the menu is not showing as intended */}
|
|
71
|
+
<CDropdownToggle style={{ display: 'none' }} />
|
|
72
|
+
<CDropdownMenu>
|
|
73
|
+
<div className="px-3 py-2">
|
|
74
|
+
<CFormInput
|
|
75
|
+
placeholder="Filter label..."
|
|
76
|
+
value={filter}
|
|
77
|
+
onChange={(e) => setFilter(e.target.value)}
|
|
78
|
+
autoFocus
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
<CDropdownDivider />
|
|
82
|
+
{filteredLabels.length > 0 ? (
|
|
83
|
+
filteredLabels.map((label: Label) => (
|
|
84
|
+
<CDropdownItem key={label.id} onClick={() => updateSelectedLabels(label)}>
|
|
85
|
+
{label.name}
|
|
86
|
+
</CDropdownItem>
|
|
87
|
+
))
|
|
88
|
+
) : (
|
|
89
|
+
<CDropdownItem disabled>No results</CDropdownItem>
|
|
90
|
+
)}
|
|
91
|
+
</CDropdownMenu>
|
|
92
|
+
</CDropdown>
|
|
93
|
+
</>
|
|
94
|
+
)
|
|
95
|
+
}
|
|
73
96
|
|
|
74
|
-
export default LabelInput
|
|
97
|
+
export default LabelInput
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { faSync, IconDefinition } from '@fortawesome/free-solid-svg-icons'
|
|
2
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
|
3
|
+
import { CButton, CTooltip } from '@coreui/react'
|
|
4
|
+
import { CSSProperties } from 'react'
|
|
5
|
+
import { SizeProp } from '@fortawesome/fontawesome-svg-core'
|
|
6
|
+
|
|
7
|
+
type IconButtonProps = {
|
|
8
|
+
loadingSize?: SizeProp
|
|
9
|
+
isLoading?: boolean
|
|
10
|
+
margin?: number
|
|
11
|
+
icon?: IconDefinition
|
|
12
|
+
text?: string
|
|
13
|
+
size?: 'sm' | 'lg'
|
|
14
|
+
isTextLeft?: boolean
|
|
15
|
+
style?: CSSProperties
|
|
16
|
+
id?: string
|
|
17
|
+
type?: 'button' | 'submit' | 'reset'
|
|
18
|
+
disabled?: boolean
|
|
19
|
+
onClick?: () => void
|
|
20
|
+
className?: string
|
|
21
|
+
color?: string
|
|
22
|
+
isOutline?: boolean
|
|
23
|
+
tooltip?: string
|
|
24
|
+
ttipPlacement?: 'top' | 'left' | 'right' | 'auto' | 'bottom'
|
|
25
|
+
shape?: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const IconButton = ({
|
|
29
|
+
loadingSize = '1x',
|
|
30
|
+
isLoading = false,
|
|
31
|
+
margin = 5,
|
|
32
|
+
icon,
|
|
33
|
+
text = '',
|
|
34
|
+
size,
|
|
35
|
+
isTextLeft = false,
|
|
36
|
+
style = {},
|
|
37
|
+
id = undefined,
|
|
38
|
+
type = 'button',
|
|
39
|
+
disabled = false,
|
|
40
|
+
onClick,
|
|
41
|
+
className = '',
|
|
42
|
+
color = 'primary',
|
|
43
|
+
isOutline = true,
|
|
44
|
+
tooltip = '',
|
|
45
|
+
ttipPlacement = 'top',
|
|
46
|
+
shape = '',
|
|
47
|
+
}: IconButtonProps) => {
|
|
48
|
+
const iconButtonIcon: IconDefinition | undefined = icon
|
|
49
|
+
|
|
50
|
+
const buttonVariant: 'ghost' | 'outline' | undefined = isOutline ? 'outline' : undefined
|
|
51
|
+
|
|
52
|
+
const renderContent = () => {
|
|
53
|
+
if (isLoading) {
|
|
54
|
+
return (
|
|
55
|
+
<div className="flex justify-center items-center">
|
|
56
|
+
<FontAwesomeIcon
|
|
57
|
+
className="mr-3"
|
|
58
|
+
size={loadingSize || '2x'}
|
|
59
|
+
icon={faSync}
|
|
60
|
+
spin
|
|
61
|
+
/>
|
|
62
|
+
<span className="text-center">Loading</span>
|
|
63
|
+
</div>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
const ic =
|
|
67
|
+
iconButtonIcon?.iconName && iconButtonIcon.prefix ? (
|
|
68
|
+
<FontAwesomeIcon key="icon" icon={iconButtonIcon} size={loadingSize || '2x'} />
|
|
69
|
+
) : null
|
|
70
|
+
const iconButtonText = text ? (
|
|
71
|
+
<span key="text" style={{ marginLeft: margin, marginRight: margin }}>
|
|
72
|
+
{text}
|
|
73
|
+
</span>
|
|
74
|
+
) : null
|
|
75
|
+
if (isTextLeft) {
|
|
76
|
+
return [iconButtonText, ic]
|
|
77
|
+
}
|
|
78
|
+
return [ic, iconButtonText]
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// because visible=false does not seem to work...
|
|
82
|
+
if (tooltip != '') {
|
|
83
|
+
return (
|
|
84
|
+
<CTooltip content={tooltip} placement={ttipPlacement}>
|
|
85
|
+
<CButton
|
|
86
|
+
id={id}
|
|
87
|
+
size={size}
|
|
88
|
+
// type={type}
|
|
89
|
+
className={className}
|
|
90
|
+
style={style}
|
|
91
|
+
variant={buttonVariant}
|
|
92
|
+
disabled={disabled || isLoading}
|
|
93
|
+
onClick={onClick}
|
|
94
|
+
color={disabled || isLoading ? 'secondary' : color}
|
|
95
|
+
shape={shape}
|
|
96
|
+
>
|
|
97
|
+
{renderContent()}
|
|
98
|
+
</CButton>
|
|
99
|
+
</CTooltip>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<CButton
|
|
105
|
+
size={size}
|
|
106
|
+
type={type}
|
|
107
|
+
className={className}
|
|
108
|
+
style={style}
|
|
109
|
+
variant={buttonVariant}
|
|
110
|
+
disabled={disabled || isLoading}
|
|
111
|
+
onClick={onClick}
|
|
112
|
+
color={disabled || isLoading ? 'secondary' : color}
|
|
113
|
+
>
|
|
114
|
+
{renderContent()}
|
|
115
|
+
</CButton>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export default IconButton
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef } from
|
|
2
|
-
import { List, TextArea, Form, Label, Icon } from
|
|
3
|
-
import InfoBox from
|
|
4
|
-
import PopUp from
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react'
|
|
2
|
+
import { List, TextArea, Form, Label, Icon } from 'semantic-ui-react'
|
|
3
|
+
import InfoBox from './InfoBox'
|
|
4
|
+
import PopUp from '../SiaPopup'
|
|
5
5
|
|
|
6
6
|
const AnnoDetails = (props) => {
|
|
7
|
-
const [comment, setComment] = useState(
|
|
8
|
-
const [example, setExample] = useState(false)
|
|
9
|
-
const [showSaveBtn, setShowSaveBtn] = useState(false)
|
|
10
|
-
const tARef = useRef()
|
|
7
|
+
const [comment, setComment] = useState('')
|
|
8
|
+
const [example, setExample] = useState(false)
|
|
9
|
+
const [showSaveBtn, setShowSaveBtn] = useState(false)
|
|
10
|
+
const tARef = useRef()
|
|
11
11
|
useEffect(() => {
|
|
12
12
|
if (props.anno) {
|
|
13
13
|
if (props.anno.comment) {
|
|
14
|
-
setComment(props.anno.comment)
|
|
14
|
+
setComment(props.anno.comment)
|
|
15
15
|
} else {
|
|
16
|
-
setComment(
|
|
16
|
+
setComment('')
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
}, [props.anno])
|
|
19
|
+
}, [props.anno])
|
|
20
20
|
|
|
21
21
|
useEffect(() => {
|
|
22
22
|
if (tARef.current) {
|
|
23
|
-
tARef.current.focus()
|
|
23
|
+
tARef.current.focus()
|
|
24
24
|
}
|
|
25
|
-
}, [props.commentInputTrigger])
|
|
25
|
+
}, [props.commentInputTrigger])
|
|
26
26
|
|
|
27
27
|
const onDismiss = () => {
|
|
28
28
|
if (props.onDismiss) {
|
|
29
|
-
props.onDismiss()
|
|
29
|
+
props.onDismiss()
|
|
30
30
|
}
|
|
31
|
-
}
|
|
31
|
+
}
|
|
32
32
|
|
|
33
33
|
const onCommentUpdate = () => {
|
|
34
34
|
if (props.onCommentUpdate) {
|
|
35
|
-
props.onCommentUpdate(comment)
|
|
35
|
+
props.onCommentUpdate(comment)
|
|
36
36
|
}
|
|
37
|
-
setShowSaveBtn(false)
|
|
38
|
-
}
|
|
37
|
+
setShowSaveBtn(false)
|
|
38
|
+
}
|
|
39
39
|
|
|
40
40
|
const onMarkExampleClick = () => {
|
|
41
41
|
// setExample(!example)
|
|
42
42
|
if (props.onMarkExample) {
|
|
43
|
-
props.onMarkExample(props.anno)
|
|
43
|
+
props.onMarkExample(props.anno)
|
|
44
44
|
}
|
|
45
|
-
}
|
|
45
|
+
}
|
|
46
46
|
|
|
47
47
|
const renderSaveBtn = () => {
|
|
48
48
|
if (showSaveBtn) {
|
|
49
|
-
return <Label as="a" corner="right" icon="save" color="red"></Label
|
|
49
|
+
return <Label as="a" corner="right" icon="save" color="red"></Label>
|
|
50
50
|
}
|
|
51
|
-
}
|
|
51
|
+
}
|
|
52
52
|
|
|
53
53
|
const renderComment = () => {
|
|
54
54
|
return (
|
|
@@ -66,36 +66,36 @@ const AnnoDetails = (props) => {
|
|
|
66
66
|
></TextArea>
|
|
67
67
|
</Form>
|
|
68
68
|
</div>
|
|
69
|
-
)
|
|
70
|
-
}
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
71
|
const renderLabels = () => {
|
|
72
72
|
if (props.anno) {
|
|
73
|
-
const selectedLabelIds = props.anno.labelIds
|
|
74
|
-
if (!selectedLabelIds) return
|
|
73
|
+
const selectedLabelIds = props.anno.labelIds
|
|
74
|
+
if (!selectedLabelIds) return 'No Label'
|
|
75
75
|
|
|
76
|
-
let lbls =
|
|
76
|
+
let lbls = ''
|
|
77
77
|
props.anno.labelIds.forEach((lbl, idx) => {
|
|
78
78
|
const labelObject = props.possibleLabels.find((el) => {
|
|
79
|
-
return el.id === lbl
|
|
80
|
-
})
|
|
81
|
-
if (idx > 0) lbls +=
|
|
82
|
-
lbls += labelObject.label
|
|
83
|
-
})
|
|
84
|
-
if (!lbls) return
|
|
85
|
-
return lbls
|
|
79
|
+
return el.id === lbl
|
|
80
|
+
})
|
|
81
|
+
if (idx > 0) lbls += ', '
|
|
82
|
+
lbls += labelObject.label
|
|
83
|
+
})
|
|
84
|
+
if (!lbls) return 'No Label'
|
|
85
|
+
return lbls
|
|
86
86
|
} else {
|
|
87
|
-
return
|
|
87
|
+
return 'No Label'
|
|
88
88
|
}
|
|
89
|
-
}
|
|
89
|
+
}
|
|
90
90
|
|
|
91
91
|
const renderExampleMark = () => {
|
|
92
|
-
if (!props.allowedToMarkExample) return null
|
|
93
|
-
let color =
|
|
94
|
-
let iconName =
|
|
92
|
+
if (!props.allowedToMarkExample) return null
|
|
93
|
+
let color = 'grey'
|
|
94
|
+
let iconName = 'bookmark outline'
|
|
95
95
|
if (props.anno) {
|
|
96
96
|
if (props.anno.isExample) {
|
|
97
|
-
color =
|
|
98
|
-
iconName =
|
|
97
|
+
color = 'yellow'
|
|
98
|
+
iconName = 'bookmark'
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
const mark = (
|
|
@@ -106,19 +106,19 @@ const AnnoDetails = (props) => {
|
|
|
106
106
|
size="medium"
|
|
107
107
|
corner="left"
|
|
108
108
|
onClick={() => {
|
|
109
|
-
onMarkExampleClick()
|
|
109
|
+
onMarkExampleClick()
|
|
110
110
|
}}
|
|
111
111
|
>
|
|
112
112
|
<Icon name={iconName} />
|
|
113
113
|
</Label>
|
|
114
|
-
)
|
|
114
|
+
)
|
|
115
115
|
return (
|
|
116
116
|
<PopUp
|
|
117
117
|
content="Mark this annotation as example for other annotators"
|
|
118
118
|
trigger={mark}
|
|
119
119
|
/>
|
|
120
|
-
)
|
|
121
|
-
}
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
122
|
|
|
123
123
|
const renderDescription = () => {
|
|
124
124
|
if (props.anno) {
|
|
@@ -136,7 +136,7 @@ const AnnoDetails = (props) => {
|
|
|
136
136
|
<List.Item icon="tag" content={renderLabels()} />
|
|
137
137
|
<List.Item
|
|
138
138
|
icon="time"
|
|
139
|
-
content={`${props.anno.annoTime.toLocaleString(
|
|
139
|
+
content={`${props.anno.annoTime.toLocaleString('us', {
|
|
140
140
|
minimumFractionDigits: 2,
|
|
141
141
|
maximumFractionDigits: 2,
|
|
142
142
|
})} seconds`}
|
|
@@ -145,21 +145,21 @@ const AnnoDetails = (props) => {
|
|
|
145
145
|
</List>
|
|
146
146
|
{renderComment()}
|
|
147
147
|
</div>
|
|
148
|
-
)
|
|
148
|
+
)
|
|
149
149
|
} else {
|
|
150
|
-
return
|
|
150
|
+
return 'No annotation selected!'
|
|
151
151
|
}
|
|
152
|
-
}
|
|
152
|
+
}
|
|
153
153
|
|
|
154
154
|
return (
|
|
155
155
|
<InfoBox
|
|
156
|
-
header={
|
|
156
|
+
header={'Annotation Details'}
|
|
157
157
|
content={renderDescription()}
|
|
158
158
|
visible={props.visible}
|
|
159
159
|
defaultPos={props.defaultPos}
|
|
160
160
|
onDismiss={(e) => onDismiss()}
|
|
161
161
|
/>
|
|
162
|
-
)
|
|
163
|
-
}
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
164
|
|
|
165
|
-
export default AnnoDetails
|
|
165
|
+
export default AnnoDetails
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import React, { useState, useEffect } from
|
|
2
|
-
import { List, Label } from
|
|
3
|
-
import InfoBox from
|
|
4
|
-
import * as colorlut from
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import { List, Label } from 'semantic-ui-react'
|
|
3
|
+
import InfoBox from './InfoBox'
|
|
4
|
+
import * as colorlut from '../utils/color'
|
|
5
5
|
// import actions from '../../../../actions'
|
|
6
6
|
// import * as transform from '../utils/transform'
|
|
7
7
|
// const { siaShowImgBar } = actions
|
|
8
8
|
|
|
9
9
|
const AnnoStats = (props) => {
|
|
10
|
-
const [hideList, setHideList] = useState([])
|
|
10
|
+
const [hideList, setHideList] = useState([])
|
|
11
11
|
|
|
12
12
|
useEffect(() => {
|
|
13
|
-
setHideList([])
|
|
14
|
-
}, [props.imgLoadCount])
|
|
13
|
+
setHideList([])
|
|
14
|
+
}, [props.imgLoadCount])
|
|
15
15
|
|
|
16
16
|
const onDismiss = () => {
|
|
17
17
|
if (props.onDismiss) {
|
|
18
|
-
props.onDismiss()
|
|
18
|
+
props.onDismiss()
|
|
19
19
|
}
|
|
20
|
-
}
|
|
20
|
+
}
|
|
21
21
|
|
|
22
22
|
const onLblClick = (lbl) => {
|
|
23
|
-
let hideLbl = false
|
|
23
|
+
let hideLbl = false
|
|
24
24
|
if (hideList.includes(lbl.id)) {
|
|
25
|
-
setHideList(hideList.filter((e) => e !== lbl.id))
|
|
26
|
-
hideLbl = false
|
|
25
|
+
setHideList(hideList.filter((e) => e !== lbl.id))
|
|
26
|
+
hideLbl = false
|
|
27
27
|
} else {
|
|
28
28
|
// hideList.push(lbl.id)
|
|
29
|
-
setHideList([...hideList, lbl.id])
|
|
30
|
-
hideLbl = true
|
|
29
|
+
setHideList([...hideList, lbl.id])
|
|
30
|
+
hideLbl = true
|
|
31
31
|
}
|
|
32
32
|
if (props.onHideLbl) {
|
|
33
|
-
props.onHideLbl(lbl, hideLbl)
|
|
33
|
+
props.onHideLbl(lbl, hideLbl)
|
|
34
34
|
}
|
|
35
|
-
}
|
|
35
|
+
}
|
|
36
36
|
|
|
37
37
|
const renderRow = (s) => {
|
|
38
|
-
const opacity = hideList.includes(s.id) ? 0.5 : 1.0
|
|
38
|
+
const opacity = hideList.includes(s.id) ? 0.5 : 1.0
|
|
39
39
|
return (
|
|
40
40
|
<List.Item key={s.id}>
|
|
41
41
|
<List.Content>
|
|
@@ -50,57 +50,57 @@ const AnnoStats = (props) => {
|
|
|
50
50
|
</Label>
|
|
51
51
|
</List.Content>
|
|
52
52
|
</List.Item>
|
|
53
|
-
)
|
|
54
|
-
}
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
55
|
|
|
56
56
|
const renderRows = () => {
|
|
57
|
-
let stats = {}
|
|
57
|
+
let stats = {}
|
|
58
58
|
props.annos.forEach((a) => {
|
|
59
59
|
// // console.log('render rows', a)
|
|
60
|
-
if (a.status !==
|
|
60
|
+
if (a.status !== 'deleted') {
|
|
61
61
|
a.labelIds.forEach((lblId) => {
|
|
62
62
|
if (lblId in stats) {
|
|
63
|
-
stats[lblId] += 1
|
|
63
|
+
stats[lblId] += 1
|
|
64
64
|
} else {
|
|
65
|
-
stats[lblId] = 1
|
|
65
|
+
stats[lblId] = 1
|
|
66
66
|
}
|
|
67
|
-
})
|
|
67
|
+
})
|
|
68
68
|
if (a.labelIds.length === 0) {
|
|
69
69
|
if ((-1) in stats) {
|
|
70
|
-
stats[-1] += 1
|
|
70
|
+
stats[-1] += 1
|
|
71
71
|
} else {
|
|
72
|
-
stats[-1] = 1
|
|
72
|
+
stats[-1] = 1
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
})
|
|
76
|
+
})
|
|
77
77
|
const res = Object.entries(stats).map(([key, value]) => {
|
|
78
78
|
let lbl = props.possibleLabels.find((e) => {
|
|
79
|
-
return e.id === parseInt(key)
|
|
80
|
-
})
|
|
79
|
+
return e.id === parseInt(key)
|
|
80
|
+
})
|
|
81
81
|
if (!lbl) {
|
|
82
|
-
lbl = { id: -1, label:
|
|
82
|
+
lbl = { id: -1, label: 'No Label', color: colorlut.getDefaultColor() }
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
lbl.amount = value
|
|
85
|
+
lbl.amount = value
|
|
86
86
|
// return renderRow({class:idToLbl[key], amount:value, color:idToColor[key]})
|
|
87
|
-
return renderRow(lbl)
|
|
88
|
-
})
|
|
89
|
-
return res
|
|
90
|
-
}
|
|
87
|
+
return renderRow(lbl)
|
|
88
|
+
})
|
|
89
|
+
return res
|
|
90
|
+
}
|
|
91
91
|
const renderDescription = () => {
|
|
92
|
-
return <List>{renderRows()}</List
|
|
93
|
-
}
|
|
92
|
+
return <List>{renderRows()}</List>
|
|
93
|
+
}
|
|
94
94
|
|
|
95
95
|
return (
|
|
96
96
|
<InfoBox
|
|
97
|
-
header={
|
|
97
|
+
header={'Annotations per Label'}
|
|
98
98
|
content={renderDescription()}
|
|
99
99
|
visible={props.visible}
|
|
100
100
|
defaultPos={props.defaultPos}
|
|
101
101
|
onDismiss={(e) => onDismiss()}
|
|
102
102
|
/>
|
|
103
|
-
)
|
|
104
|
-
}
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
105
|
|
|
106
|
-
export default AnnoStats
|
|
106
|
+
export default AnnoStats
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import React, { Component } from
|
|
2
|
-
import { Header, Message } from
|
|
3
|
-
import Draggable from
|
|
1
|
+
import React, { Component } from 'react'
|
|
2
|
+
import { Header, Message } from 'semantic-ui-react'
|
|
3
|
+
import Draggable from 'react-draggable'
|
|
4
4
|
|
|
5
5
|
class InfoBox extends Component {
|
|
6
6
|
constructor(props) {
|
|
7
|
-
super(props)
|
|
7
|
+
super(props)
|
|
8
8
|
this.state = {
|
|
9
9
|
style: {
|
|
10
|
-
position:
|
|
10
|
+
position: 'fixed',
|
|
11
11
|
top: 200,
|
|
12
12
|
left: 200,
|
|
13
13
|
width: 250,
|
|
14
14
|
},
|
|
15
|
-
}
|
|
15
|
+
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
componentDidMount() {
|
|
19
|
-
this.updateStyle()
|
|
19
|
+
this.updateStyle()
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
componentDidUpdate(prevProps) {
|
|
23
23
|
if (this.props.defaultPos !== prevProps.defaultPos) {
|
|
24
|
-
this.updateStyle()
|
|
24
|
+
this.updateStyle()
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
handleOnStop(e) {
|
|
29
29
|
if (this.props.onStop) {
|
|
30
|
-
this.props.onStop(e)
|
|
30
|
+
this.props.onStop(e)
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
updateStyle() {
|
|
35
35
|
this.setState({
|
|
36
36
|
style: { ...this.state.style, ...this.props.defaultPos },
|
|
37
|
-
})
|
|
37
|
+
})
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
onDismiss(e) {
|
|
41
41
|
if (this.props.onDismiss) {
|
|
42
|
-
this.props.onDismiss(e)
|
|
42
|
+
this.props.onDismiss(e)
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
render() {
|
|
47
|
-
if (!this.props.visible) return null
|
|
47
|
+
if (!this.props.visible) return null
|
|
48
48
|
return (
|
|
49
49
|
<Draggable handle=".handle" onStop={(e) => this.handleOnStop(e)}>
|
|
50
50
|
<div style={this.state.style}>
|
|
51
51
|
<Message
|
|
52
52
|
style={{ opacity: 0.98 }}
|
|
53
53
|
onDismiss={(e) => {
|
|
54
|
-
this.onDismiss(e)
|
|
54
|
+
this.onDismiss(e)
|
|
55
55
|
}}
|
|
56
56
|
size="small"
|
|
57
57
|
>
|
|
@@ -59,7 +59,7 @@ class InfoBox extends Component {
|
|
|
59
59
|
textAlign="center"
|
|
60
60
|
as="h5"
|
|
61
61
|
className="handle"
|
|
62
|
-
style={{ cursor:
|
|
62
|
+
style={{ cursor: 'grab' }}
|
|
63
63
|
>
|
|
64
64
|
{this.props.header}
|
|
65
65
|
</Header>
|
|
@@ -69,8 +69,8 @@ class InfoBox extends Component {
|
|
|
69
69
|
</Message>
|
|
70
70
|
</div>
|
|
71
71
|
</Draggable>
|
|
72
|
-
)
|
|
72
|
+
)
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
export default InfoBox
|
|
76
|
+
export default InfoBox
|