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.
Files changed (280) hide show
  1. package/README.md +4 -0
  2. package/dist/Annotation/logic/Annotation.d.ts +17 -0
  3. package/dist/Annotation/logic/Annotation.js +1 -0
  4. package/dist/Annotation/ui/AnnotationComponent.d.ts +24 -0
  5. package/dist/Annotation/ui/AnnotationComponent.js +1 -0
  6. package/dist/Annotation/ui/atoms/AnnoBar.d.ts +15 -0
  7. package/dist/Annotation/ui/atoms/AnnoBar.js +1 -0
  8. package/dist/Annotation/ui/atoms/DaviIcon.d.ts +9 -0
  9. package/dist/Annotation/ui/atoms/DaviIcon.js +19 -0
  10. package/dist/Annotation/ui/atoms/Edge.d.ts +17 -0
  11. package/dist/Annotation/ui/atoms/Edge.js +1 -0
  12. package/dist/Annotation/ui/atoms/Node.d.ts +17 -0
  13. package/dist/Annotation/ui/atoms/Node.js +1 -0
  14. package/dist/Annotation/ui/atoms/PolygonArea.d.ts +16 -0
  15. package/dist/Annotation/ui/atoms/PolygonArea.js +1 -0
  16. package/dist/Annotation/ui/tools/BBox.d.ts +21 -0
  17. package/dist/Annotation/ui/tools/BBox.js +1 -0
  18. package/dist/Annotation/ui/tools/Line.d.ts +21 -0
  19. package/dist/Annotation/ui/tools/Line.js +1 -0
  20. package/dist/Annotation/ui/tools/Point.d.ts +16 -0
  21. package/dist/Annotation/ui/tools/Point.js +1 -0
  22. package/dist/Annotation/ui/tools/Polygon.d.ts +23 -0
  23. package/dist/Annotation/ui/tools/Polygon.js +1 -0
  24. package/dist/Canvas/Canvas.d.ts +31 -0
  25. package/dist/Canvas/Canvas.js +1 -0
  26. package/dist/Canvas/LabelInput.d.ts +11 -0
  27. package/dist/Canvas/LabelInput.js +1 -0
  28. package/dist/IconButton.d.ts +25 -0
  29. package/dist/IconButton.js +1 -0
  30. package/dist/Sia.d.ts +33 -0
  31. package/dist/Sia.js +1 -0
  32. package/dist/Toolbar/Toolbar.d.ts +21 -0
  33. package/dist/Toolbar/Toolbar.js +1 -0
  34. package/dist/Toolbar/ToolbarItems/AccessibilityTools.d.ts +7 -0
  35. package/dist/Toolbar/ToolbarItems/AccessibilityTools.js +1 -0
  36. package/dist/Toolbar/ToolbarItems/AnnoToolSelector.d.ts +11 -0
  37. package/dist/Toolbar/ToolbarItems/AnnoToolSelector.js +1 -0
  38. package/dist/Toolbar/ToolbarItems/ImageToolItems/ImageLabelInput.d.ts +11 -0
  39. package/dist/Toolbar/ToolbarItems/ImageToolItems/ImageLabelInput.js +1 -0
  40. package/dist/Toolbar/ToolbarItems/ImageToolItems/TagLabel.d.ts +11 -0
  41. package/dist/Toolbar/ToolbarItems/ImageToolItems/TagLabel.js +1 -0
  42. package/dist/Toolbar/ToolbarItems/ImageTools.d.ts +13 -0
  43. package/dist/Toolbar/ToolbarItems/ImageTools.js +1 -0
  44. package/dist/Toolbar/ToolbarItems/Instructions.d.ts +2 -0
  45. package/dist/Toolbar/ToolbarItems/Instructions.js +1 -0
  46. package/dist/Toolbar/ToolbarItems/InstructionsModal.d.ts +6 -0
  47. package/dist/Toolbar/ToolbarItems/InstructionsModal.js +1 -0
  48. package/dist/assets/SIA-BV1tYu3P.css +1 -0
  49. package/dist/assets/brand-icons-Cu_C0hZ4.svg +1008 -0
  50. package/dist/assets/brand-icons-F3SPCeH1.woff +0 -0
  51. package/dist/assets/brand-icons-XL9sxUpA.woff2 +0 -0
  52. package/dist/assets/brand-icons-sqJ2Pg7a.eot +0 -0
  53. package/dist/assets/brand-icons-ubhWoxly.ttf +0 -0
  54. package/dist/assets/flags-DOLqOU7Y.png +0 -0
  55. package/dist/assets/icons-BOCtAERH.woff +0 -0
  56. package/dist/assets/icons-CHzK1VD9.eot +0 -0
  57. package/dist/assets/icons-D29ZQHHw.ttf +0 -0
  58. package/dist/assets/icons-Du6TOHnR.woff2 +0 -0
  59. package/dist/assets/icons-RwhydX30.svg +1518 -0
  60. package/dist/assets/node_modules/semantic-ui-css/semantic.min-Bvulf91l.css +346 -0
  61. package/dist/assets/outline-icons-BfdLr8tr.svg +366 -0
  62. package/dist/assets/outline-icons-DD8jm0uy.ttf +0 -0
  63. package/dist/assets/outline-icons-DInHoiqI.woff2 +0 -0
  64. package/dist/assets/outline-icons-LX8adJ4n.eot +0 -0
  65. package/dist/assets/outline-icons-aQ88nltS.woff +0 -0
  66. package/dist/index.d.ts +5 -0
  67. package/dist/index.js +1 -0
  68. package/dist/models/AnnotationMode.d.ts +11 -0
  69. package/dist/models/AnnotationMode.js +1 -0
  70. package/dist/models/AnnotationStatus.d.ts +8 -0
  71. package/dist/models/AnnotationStatus.js +1 -0
  72. package/dist/models/AnnotationTool.d.ts +7 -0
  73. package/dist/models/AnnotationTool.js +1 -0
  74. package/dist/models/CanvasAction.d.ts +28 -0
  75. package/dist/models/CanvasAction.js +1 -0
  76. package/dist/models/Direction.d.ts +7 -0
  77. package/dist/models/Direction.js +1 -0
  78. package/dist/models/EditorModes.d.ts +11 -0
  79. package/dist/models/EditorModes.js +1 -0
  80. package/dist/models/KeyAction.d.ts +22 -0
  81. package/dist/models/KeyAction.js +1 -0
  82. package/dist/models/NotificationType.d.ts +7 -0
  83. package/dist/models/NotificationType.js +1 -0
  84. package/dist/models/index.d.ts +6 -0
  85. package/dist/models/index.js +1 -0
  86. package/dist/stories/AnnotationTools.stories.d.ts +40 -0
  87. package/dist/stories/Canvas/Canvas.stories.d.ts +50 -0
  88. package/dist/stories/Canvas/CanvasOffset.d.ts +13 -0
  89. package/dist/stories/Canvas/CanvasWithOffset.stories.d.ts +36 -0
  90. package/dist/stories/FilterDropdown.stories.d.ts +19 -0
  91. package/dist/stories/MinimalSia.stories.d.ts +66 -0
  92. package/dist/stories/SIA/DemoWrapper.d.ts +8 -0
  93. package/dist/stories/SIA/DemoWrapper.stories.d.ts +27 -0
  94. package/dist/stories/SIA/SIA.stories.d.ts +72 -0
  95. package/dist/stories/Toolbar/ImageTools/TagLabel.stories.d.ts +21 -0
  96. package/dist/stories/Toolbar/Instructions.stories.d.ts +11 -0
  97. package/dist/stories/Toolbar/Toolbar.stories.d.ts +37 -0
  98. package/dist/stories/exampleData/exampleAnnotations.d.ts +8 -0
  99. package/dist/stories/exampleData/exampleExternalAnnotations.d.ts +8 -0
  100. package/dist/stories/exampleData/exampleImage.d.ts +2 -0
  101. package/dist/stories/exampleData/exampleLabels.d.ts +6 -0
  102. package/dist/types.d.ts +57 -0
  103. package/dist/types.js +1 -0
  104. package/dist/utils/KeyMapper.d.ts +9 -0
  105. package/dist/utils/KeyMapper.js +1 -0
  106. package/dist/utils/TimeUtils.d.ts +4 -0
  107. package/dist/utils/TimeUtils.js +1 -0
  108. package/dist/utils/color.d.ts +2 -0
  109. package/dist/utils/color.js +1 -0
  110. package/dist/utils/index.d.ts +2 -0
  111. package/dist/utils/index.js +1 -0
  112. package/dist/utils/mouse.d.ts +6 -0
  113. package/dist/utils/mouse.js +1 -0
  114. package/dist/utils/siaIcons.js +12 -0
  115. package/dist/utils/transform.d.ts +28 -0
  116. package/dist/utils/transform.js +1 -0
  117. package/dist/utils/uiConfig.js +1 -0
  118. package/dist/utils/windowViewport.d.ts +22 -0
  119. package/dist/utils/windowViewport.js +1 -0
  120. package/package.json +19 -16
  121. package/src/AnnoExampleViewer.jsx +18 -18
  122. package/src/Annotation/logic/Annotation.ts +24 -26
  123. package/src/Annotation/ui/AnnotationComponent.tsx +115 -86
  124. package/src/Annotation/ui/atoms/AnnoBar.tsx +51 -53
  125. package/src/Annotation/ui/atoms/DaviIcon.tsx +12 -22
  126. package/src/Annotation/ui/atoms/Edge.tsx +25 -22
  127. package/src/Annotation/ui/atoms/Node.tsx +56 -50
  128. package/src/Annotation/ui/atoms/PolygonArea.tsx +30 -35
  129. package/src/Annotation/ui/tools/BBox.tsx +136 -150
  130. package/src/Annotation/ui/tools/Line.tsx +94 -91
  131. package/src/Annotation/ui/tools/Point.tsx +19 -17
  132. package/src/Annotation/ui/tools/Polygon.tsx +126 -95
  133. package/src/Canvas/Canvas.tsx +748 -594
  134. package/src/Canvas/LabelInput.tsx +68 -45
  135. package/src/IconButton.tsx +119 -0
  136. package/src/InfoBoxes/AnnoDetails.jsx +53 -53
  137. package/src/InfoBoxes/AnnoStats.jsx +41 -41
  138. package/src/InfoBoxes/InfoBox.jsx +16 -16
  139. package/src/InfoBoxes/InfoBoxArea.jsx +32 -34
  140. package/src/InfoBoxes/LabelInfo.jsx +30 -30
  141. package/src/SIASettingButton.jsx +25 -25
  142. package/src/Sia.tsx +484 -0
  143. package/src/Toolbar/Toolbar.tsx +38 -31
  144. package/src/Toolbar/ToolbarItems/AccessibilityTools.tsx +26 -46
  145. package/src/Toolbar/ToolbarItems/AnnoToolSelector.tsx +53 -46
  146. package/src/Toolbar/ToolbarItems/ImageToolItems/ImageLabelInput.tsx +127 -0
  147. package/src/Toolbar/ToolbarItems/ImageToolItems/TagLabel.tsx +29 -28
  148. package/src/Toolbar/ToolbarItems/ImageTools.tsx +43 -40
  149. package/src/Toolbar/ToolbarItems/Instructions.tsx +47 -50
  150. package/src/Toolbar/ToolbarItems/InstructionsModal.tsx +8 -8
  151. package/src/index.ts +9 -13
  152. package/src/models/{AnnotationMode.tsx → AnnotationMode.ts} +1 -1
  153. package/src/models/{AnnotationStatus.tsx → AnnotationStatus.ts} +1 -1
  154. package/src/models/{AnnotationTool.tsx → AnnotationTool.ts} +1 -1
  155. package/src/models/{CanvasAction.tsx → CanvasAction.ts} +1 -1
  156. package/src/models/{Direction.tsx → Direction.ts} +1 -1
  157. package/src/models/{EditorModes.tsx → EditorModes.ts} +1 -1
  158. package/src/models/{KeyAction.tsx → KeyAction.ts} +3 -1
  159. package/src/models/NotificationType.ts +8 -0
  160. package/src/models/index.ts +6 -7
  161. package/src/siaDummyData.js +71 -71
  162. package/src/stories/AnnotationTools.mdx +27 -0
  163. package/src/stories/AnnotationTools.stories.tsx +104 -0
  164. package/src/stories/Canvas/Canvas.stories.tsx +59 -113
  165. package/src/stories/Canvas/CanvasOffset.tsx +54 -38
  166. package/src/stories/Canvas/CanvasWithOffset.stories.tsx +42 -113
  167. package/src/stories/FilterDropdown.stories.ts +13 -11
  168. package/src/stories/MinimalSIA.mdx +20 -0
  169. package/src/stories/MinimalSia.stories.tsx +90 -0
  170. package/src/stories/SIA/DemoWrapper.stories.tsx +71 -0
  171. package/src/stories/SIA/DemoWrapper.tsx +55 -0
  172. package/src/stories/SIA/SIA.stories.tsx +79 -45
  173. package/src/stories/Toolbar/ImageTools/TagLabel.stories.tsx +11 -12
  174. package/src/stories/Toolbar/Instructions.stories.tsx +11 -11
  175. package/src/stories/Toolbar/Toolbar.stories.tsx +32 -47
  176. package/src/stories/Welcome.mdx +5 -0
  177. package/src/stories/development/CoordinateSystems.mdx +25 -0
  178. package/src/stories/exampleData/exampleAnnotations.ts +65 -0
  179. package/src/stories/exampleData/exampleExternalAnnotations.ts +115 -0
  180. package/src/stories/{siaDummyData2.ts → exampleData/exampleImage.ts} +3 -264
  181. package/src/stories/exampleData/exampleLabels.ts +146 -0
  182. package/src/stories/main.scss +6 -0
  183. package/src/styles/style.scss +1 -26
  184. package/src/types.ts +67 -0
  185. package/src/utils/KeyMapper.ts +76 -74
  186. package/src/utils/TimeUtils.ts +11 -0
  187. package/src/utils/color.ts +25 -25
  188. package/src/utils/hist.js +22 -22
  189. package/src/utils/index.ts +2 -3
  190. package/src/utils/mouse.ts +45 -0
  191. package/src/utils/siaIcons.jsx +5 -7
  192. package/src/utils/transform.ts +186 -0
  193. package/src/utils/uiConfig.js +19 -22
  194. package/src/utils/windowViewport.ts +34 -0
  195. package/src/AnnoLabelInput.jsx +0 -109
  196. package/src/AnnoToolBar.jsx +0 -153
  197. package/src/Annotation/AnnoBar.jsx +0 -154
  198. package/src/Annotation/Annotation.jsx +0 -395
  199. package/src/Annotation/Annotation.scss +0 -47
  200. package/src/Annotation/BBox.jsx +0 -299
  201. package/src/Annotation/Edge.jsx +0 -92
  202. package/src/Annotation/InfSelectionArea.jsx +0 -72
  203. package/src/Annotation/Line.jsx +0 -68
  204. package/src/Annotation/Node.jsx +0 -282
  205. package/src/Annotation/Point.jsx +0 -200
  206. package/src/Annotation/Polygon.jsx +0 -404
  207. package/src/Annotation/logic/AnnotationUtils.ts +0 -30
  208. package/src/Canvas.jsx +0 -2194
  209. package/src/ImgBar.jsx +0 -131
  210. package/src/LabelInput.jsx +0 -238
  211. package/src/Prompt.jsx +0 -45
  212. package/src/SIAFilterButton.jsx +0 -186
  213. package/src/Sia.jsx +0 -478
  214. package/src/Sia2.tsx +0 -392
  215. package/src/SiaPopup.jsx +0 -15
  216. package/src/ToolBar.jsx +0 -463
  217. package/src/Toolbar/NavigationButtons.tsx +0 -21
  218. package/src/Toolbar/ToolbarItem.jsx +0 -30
  219. package/src/Toolbar/ToolbarItems/ImageToolItems/ImageLabel.tsx +0 -62
  220. package/src/Toolbar.css +0 -13
  221. package/src/ToolbarItem.jsx +0 -31
  222. package/src/filterTools.js +0 -5
  223. package/src/models/AllowedTools.tsx +0 -9
  224. package/src/models/AnnotationSettings.tsx +0 -9
  225. package/src/models/ExternalAnnotation.ts +0 -15
  226. package/src/models/Label.tsx +0 -8
  227. package/src/models/UiConfig.tsx +0 -6
  228. package/src/stories/Button.jsx +0 -54
  229. package/src/stories/Button.stories.js +0 -48
  230. package/src/stories/Header.jsx +0 -69
  231. package/src/stories/Header.stories.js +0 -28
  232. package/src/stories/Page.jsx +0 -87
  233. package/src/stories/Page.stories.js +0 -28
  234. package/src/stories/SIA2/DemoWrapper.stories.tsx +0 -167
  235. package/src/stories/SIA2/DemoWrapper.tsx +0 -54
  236. package/src/stories/SIA2/Sia2.stories.tsx +0 -62
  237. package/src/stories/Toolbar/ImageTools/ImageLabel.stories.tsx +0 -32
  238. package/src/stories/assets/accessibility.png +0 -0
  239. package/src/stories/assets/accessibility.svg +0 -5
  240. package/src/stories/assets/addon-library.png +0 -0
  241. package/src/stories/assets/assets.png +0 -0
  242. package/src/stories/assets/avif-test-image.avif +0 -0
  243. package/src/stories/assets/context.png +0 -0
  244. package/src/stories/assets/discord.svg +0 -15
  245. package/src/stories/assets/docs.png +0 -0
  246. package/src/stories/assets/figma-plugin.png +0 -0
  247. package/src/stories/assets/github.svg +0 -3
  248. package/src/stories/assets/share.png +0 -0
  249. package/src/stories/assets/styling.png +0 -0
  250. package/src/stories/assets/testing.png +0 -0
  251. package/src/stories/assets/theming.png +0 -0
  252. package/src/stories/assets/tutorials.svg +0 -12
  253. package/src/stories/assets/youtube.svg +0 -4
  254. package/src/stories/button.css +0 -30
  255. package/src/stories/header.css +0 -32
  256. package/src/stories/lost.js +0 -54
  257. package/src/stories/page.css +0 -69
  258. package/src/stories/siaDummyData.js +0 -263
  259. package/src/stories/store.js +0 -18
  260. package/src/test.js +0 -7
  261. package/src/types/annoStatus.js +0 -4
  262. package/src/types/canvasActions.js +0 -58
  263. package/src/types/cursorstyles.js +0 -3
  264. package/src/types/modes.js +0 -9
  265. package/src/types/notificationType.js +0 -11
  266. package/src/types/toolbarEvents.js +0 -35
  267. package/src/types/tools.js +0 -17
  268. package/src/types.tsx +0 -11
  269. package/src/utils/annoConversion.js +0 -145
  270. package/src/utils/annoConversion2.ts +0 -145
  271. package/src/utils/colorlut.js +0 -68
  272. package/src/utils/constraints.js +0 -81
  273. package/src/utils/index.js +0 -1
  274. package/src/utils/keyActions.js +0 -113
  275. package/src/utils/mouse.js +0 -14
  276. package/src/utils/mouse2.ts +0 -35
  277. package/src/utils/transform.js +0 -336
  278. package/src/utils/transform2.ts +0 -343
  279. package/src/utils/windowViewport.js +0 -34
  280. package/src/utils/windowViewport2.ts +0 -50
@@ -1,20 +1,18 @@
1
- import { CButton, CButtonGroup } from "@coreui/react";
2
- import * as siaIcons from "../../utils/siaIcons";
3
- import { useState } from "react";
1
+ import { CButtonGroup } from '@coreui/react'
2
+ import * as siaIcons from '../../utils/siaIcons'
4
3
 
5
- import AnnotationTool from "../../models/AnnotationTool";
6
- import AllowedTools from "../../models/AllowedTools";
7
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
8
- import { IconProp } from "@fortawesome/fontawesome-svg-core";
9
- import { faTrash } from "@fortawesome/free-solid-svg-icons";
4
+ import AnnotationTool from '../../models/AnnotationTool'
5
+ import { faTrash } from '@fortawesome/free-solid-svg-icons'
6
+ import { AllowedTools } from '../../types'
7
+ import IconButton from '../../IconButton'
10
8
 
11
9
  type AnnoToolSelectorProps = {
12
- allowedTools: AllowedTools;
13
- isDisabled?: boolean;
14
- selectedTool: AnnotationTool;
15
- onSetSelectedTool: (selectedTool: AnnotationTool) => void;
16
- onShouldDeleteSelectedAnnotation?: () => void;
17
- };
10
+ allowedTools: AllowedTools
11
+ isDisabled?: boolean
12
+ selectedTool: AnnotationTool
13
+ onSetSelectedTool: (selectedTool: AnnotationTool) => void
14
+ onShouldDeleteSelectedAnnotation?: () => void
15
+ }
18
16
 
19
17
  const AnnoToolSelector = ({
20
18
  allowedTools,
@@ -23,66 +21,75 @@ const AnnoToolSelector = ({
23
21
  onSetSelectedTool,
24
22
  onShouldDeleteSelectedAnnotation = () => {},
25
23
  }: AnnoToolSelectorProps) => {
26
- // const [selectedTool, setSelectedTool] = useState<AnnotationTool>(defaultTool);
27
-
28
24
  return (
29
25
  <CButtonGroup role="group" aria-label="Basic example">
30
26
  {allowedTools.point && (
31
- <CButton
27
+ // <CButton
28
+ // color="primary"
29
+ // disabled={isDisabled}
30
+ // variant={selectedTool == AnnotationTool.Point ? undefined : 'outline'}
31
+ // onClick={() => onSetSelectedTool(AnnotationTool.Point)}
32
+ // >
33
+ // {siaIcons.pointIcon()}
34
+ // </CButton>
35
+ <IconButton
32
36
  color="primary"
37
+ text={siaIcons.pointIcon()}
38
+ isOutline={selectedTool != AnnotationTool.Point}
33
39
  disabled={isDisabled}
34
- variant={selectedTool == AnnotationTool.Point ? undefined : "outline"}
35
40
  onClick={() => onSetSelectedTool(AnnotationTool.Point)}
36
- >
37
- {siaIcons.pointIcon()}
38
- </CButton>
41
+ tooltip="Create Point Annotation"
42
+ margin={0}
43
+ />
39
44
  )}
40
45
 
41
46
  {allowedTools.line && (
42
- <CButton
47
+ <IconButton
43
48
  color="primary"
49
+ text={siaIcons.lineIcon()}
50
+ isOutline={selectedTool != AnnotationTool.Line}
44
51
  disabled={isDisabled}
45
- variant={selectedTool == AnnotationTool.Line ? undefined : "outline"}
46
52
  onClick={() => onSetSelectedTool(AnnotationTool.Line)}
47
- >
48
- {siaIcons.lineIcon()}
49
- </CButton>
53
+ tooltip="Create Line Annotation"
54
+ margin={0}
55
+ />
50
56
  )}
51
57
 
52
58
  {allowedTools.bbox && (
53
- <CButton
59
+ <IconButton
54
60
  color="primary"
61
+ text={siaIcons.bBoxIcon()}
62
+ isOutline={selectedTool != AnnotationTool.BBox}
55
63
  disabled={isDisabled}
56
- variant={selectedTool == AnnotationTool.BBox ? undefined : "outline"}
57
64
  onClick={() => onSetSelectedTool(AnnotationTool.BBox)}
58
- >
59
- {siaIcons.bBoxIcon()}
60
- </CButton>
65
+ tooltip="Create BBox Annotation"
66
+ margin={0}
67
+ />
61
68
  )}
62
69
 
63
70
  {allowedTools.polygon && (
64
- <CButton
71
+ <IconButton
65
72
  color="primary"
73
+ text={siaIcons.polygonIcon()}
74
+ isOutline={selectedTool != AnnotationTool.Polygon}
66
75
  disabled={isDisabled}
67
- variant={
68
- selectedTool == AnnotationTool.Polygon ? undefined : "outline"
69
- }
70
76
  onClick={() => onSetSelectedTool(AnnotationTool.Polygon)}
71
- >
72
- {siaIcons.polygonIcon()}
73
- </CButton>
77
+ tooltip="Create Polygon Annotation"
78
+ margin={0}
79
+ />
74
80
  )}
75
81
 
76
- <CButton
82
+ <IconButton
77
83
  color="primary"
78
- variant="outline"
84
+ icon={faTrash}
85
+ isOutline={true}
79
86
  disabled={isDisabled}
80
87
  onClick={onShouldDeleteSelectedAnnotation}
81
- >
82
- <FontAwesomeIcon icon={faTrash as IconProp} size="lg" />
83
- </CButton>
88
+ tooltip="Delete selected annotation"
89
+ margin={0}
90
+ />
84
91
  </CButtonGroup>
85
- );
86
- };
92
+ )
93
+ }
87
94
 
88
- export default AnnoToolSelector;
95
+ export default AnnoToolSelector
@@ -0,0 +1,127 @@
1
+ import { useState } from 'react'
2
+ import {
3
+ CDropdown,
4
+ CDropdownMenu,
5
+ CDropdownItem,
6
+ CFormInput,
7
+ CDropdownDivider,
8
+ CDropdownToggle,
9
+ CTooltip,
10
+ } from '@coreui/react'
11
+ import { Label } from '../../../types'
12
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
13
+ import { faTag } from '@fortawesome/free-solid-svg-icons'
14
+ import { IconProps } from 'semantic-ui-react'
15
+ import TagLabel from './TagLabel'
16
+
17
+ type ImageLabelInputProps = {
18
+ isDisabled: boolean
19
+ isVisible: boolean
20
+ selectedLabelsIds: number[]
21
+ possibleLabels: Label[]
22
+ isMultilabel?: boolean
23
+ onLabelSelect: (selectedLabelIds: number[]) => void
24
+ }
25
+
26
+ const ImageLabelInput = ({
27
+ isDisabled,
28
+ isVisible,
29
+ selectedLabelsIds,
30
+ possibleLabels,
31
+ isMultilabel = false,
32
+ onLabelSelect,
33
+ }: ImageLabelInputProps) => {
34
+ const [filter, setFilter] = useState('')
35
+
36
+ const filteredLabels: Label[] = possibleLabels.filter((label: Label) =>
37
+ label.name.toLowerCase().includes(filter.toLowerCase()),
38
+ )
39
+
40
+ const updateSelectedLabels = (clickedLabel: Label) => {
41
+ let newLabelIds: number[] = []
42
+
43
+ if (isMultilabel) {
44
+ newLabelIds = [...selectedLabelsIds]
45
+ // check if item in list (get its index if so)
46
+ const foundIndex: number = selectedLabelsIds.indexOf(clickedLabel.id)
47
+ // add label if not in list, remove label if in list
48
+ if (foundIndex === -1) {
49
+ newLabelIds.push(clickedLabel.id)
50
+ } else {
51
+ newLabelIds.splice(foundIndex, 1)
52
+ }
53
+ }
54
+ // single-label: just replace list with clicked item
55
+ else newLabelIds = [clickedLabel.id]
56
+
57
+ onLabelSelect(newLabelIds)
58
+ }
59
+
60
+ const getSelectedLabels = () => {
61
+ const selectedLabels: Label[] = possibleLabels.filter((label: Label) =>
62
+ selectedLabelsIds.includes(label.id),
63
+ )
64
+
65
+ return selectedLabels
66
+ }
67
+
68
+ const renderLabels = () => {
69
+ if (selectedLabelsIds.length === 0)
70
+ return (
71
+ <div style={{ marginTop: 6 }}>
72
+ <FontAwesomeIcon icon={faTag as IconProps} />
73
+ </div>
74
+ )
75
+
76
+ const selectedLabels = getSelectedLabels()
77
+ return selectedLabels.map((label: Label) => (
78
+ <TagLabel
79
+ key={label.name}
80
+ name={label.name}
81
+ color={label.color}
82
+ size={25}
83
+ triangleSize={17}
84
+ style={{ marginLeft: 1, marginTop: 5 }}
85
+ />
86
+ ))
87
+ }
88
+
89
+ return (
90
+ <CTooltip content="Add Image Label">
91
+ <CDropdown visible={isVisible} autoClose={false}>
92
+ {/* this invisible toggle has to be here, othervise the menu is not showing as intended */}
93
+ <CDropdownToggle
94
+ variant="outline"
95
+ caret={false}
96
+ color={isDisabled ? 'secondary' : 'primary'}
97
+ style={{ paddingTop: 0, paddingBottom: 0 }}
98
+ as="div"
99
+ >
100
+ {renderLabels()}
101
+ </CDropdownToggle>
102
+ <CDropdownMenu>
103
+ <div className="px-3 py-2">
104
+ <CFormInput
105
+ placeholder="Filter label..."
106
+ value={filter}
107
+ onChange={(e) => setFilter(e.target.value)}
108
+ autoFocus
109
+ />
110
+ </div>
111
+ <CDropdownDivider />
112
+ {filteredLabels.length > 0 ? (
113
+ filteredLabels.map((label: Label) => (
114
+ <CDropdownItem key={label.id} onClick={() => updateSelectedLabels(label)}>
115
+ {label.name}
116
+ </CDropdownItem>
117
+ ))
118
+ ) : (
119
+ <CDropdownItem disabled>No results</CDropdownItem>
120
+ )}
121
+ </CDropdownMenu>
122
+ </CDropdown>
123
+ </CTooltip>
124
+ )
125
+ }
126
+
127
+ export default ImageLabelInput
@@ -1,56 +1,57 @@
1
- import React from "react";
1
+ import type { CSSProperties } from 'react'
2
2
 
3
3
  type TagLabelProps = {
4
- name: string;
5
- color?: string;
6
- size?: number;
7
- style?: any;
8
- triangleSize?: number;
9
- onClick?: () => void;
10
- };
4
+ name: string
5
+ color?: string
6
+ size?: number
7
+ style?: CSSProperties
8
+ triangleSize?: number
9
+ onClick?: () => void
10
+ }
11
11
 
12
12
  const TagLabel = ({
13
13
  name,
14
- color = "#2185d0",
14
+ color = '#2185d0',
15
15
  size: bodySize = 32,
16
16
  style = {},
17
17
  triangleSize = 22,
18
18
  onClick,
19
19
  }: TagLabelProps) => {
20
- const containerStyle = {
21
- display: "inline-flex",
22
- alignItems: "center",
20
+ const containerStyle: CSSProperties = {
21
+ display: 'inline-flex',
22
+ alignItems: 'center',
23
23
  backgroundColor: color,
24
- color: "#000",
24
+ color: '#000',
25
25
  height: `${bodySize}px`,
26
26
  fontSize: `${bodySize * 0.45}px`,
27
27
  padding: `0 1rem 0 0.75rem`,
28
- borderRadius: "0 0.25rem 0.25rem 0",
28
+ border: 0,
29
+ borderRadius: '0 0.25rem 0.25rem 0',
29
30
  marginLeft: `${triangleSize / 1.4}px`, // hypothenuse of the halfed square
30
- position: "relative",
31
- overflow: "visible", // allow triangle to stick out
32
- cursor: onClick ? "pointer" : "default",
31
+ position: 'relative',
32
+ overflow: 'visible', // allow triangle to stick out
33
+ cursor: onClick ? 'pointer' : 'default',
33
34
  ...style,
34
- };
35
+ }
35
36
 
36
37
  // A rotated square to simulate a triangle
37
- const triangleStyle = {
38
- position: "absolute",
38
+ const triangleStyle: CSSProperties = {
39
+ position: 'absolute',
39
40
  left: `-${triangleSize / 2}px`,
40
41
  width: `${triangleSize}px`,
41
42
  height: `${triangleSize}px`,
42
43
  backgroundColor: color,
43
- transform: "rotate(45deg)",
44
+ transform: 'rotate(45deg)',
44
45
  zIndex: -1, // push behind text
45
- pointerEvents: "none",
46
- };
46
+ pointerEvents: 'none',
47
+ }
47
48
 
48
49
  return (
49
- <span style={containerStyle} onClick={onClick}>
50
+ <button style={containerStyle} onClick={onClick}>
50
51
  <span style={triangleStyle} />
51
52
  {name}
52
- </span>
53
- );
54
- };
53
+ </button>
54
+ )
55
+ }
55
56
 
56
- export default TagLabel;
57
+ export default TagLabel
@@ -1,63 +1,66 @@
1
- import { CButton, CButtonGroup, CPopover } from "@coreui/react";
2
- import { faBan, faTag, faTrash } from "@fortawesome/free-solid-svg-icons";
3
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
4
- import { IconProp } from "@fortawesome/fontawesome-svg-core";
5
- import ImageLabel from "./ImageToolItems/ImageLabel";
6
- import Label from "../../models/Label";
1
+ import { CButtonGroup } from '@coreui/react'
2
+ import { faBan } from '@fortawesome/free-solid-svg-icons'
3
+ import { useEffect, useState } from 'react'
4
+ import { Label } from '../../types'
5
+ import ImageLabelInput from './ImageToolItems/ImageLabelInput'
6
+ import IconButton from '../../IconButton'
7
7
 
8
8
  type ImageToolsProps = {
9
- canJunk: boolean;
10
- imageLabelIds?: number[];
11
- isDisabled?: boolean;
12
- isImageJunk?: boolean;
13
- possibleLabels: Label[];
14
- onImageLabelsChanged?: (selectedImageIds: number[]) => void;
15
- onSetIsImageJunk?: (isImageJunk: boolean) => void;
16
- };
9
+ canJunk: boolean
10
+ imageLabelIds?: number[]
11
+ isDisabled?: boolean
12
+ isFullscreen?: boolean
13
+ isImageJunk?: boolean
14
+ possibleLabels: Label[]
15
+ onImageLabelsChanged?: (selectedImageIds: number[]) => void
16
+ onSetIsImageJunk?: (isImageJunk: boolean) => void
17
+ }
17
18
 
18
19
  const ImageTools = ({
19
20
  canJunk,
20
21
  isDisabled = false,
22
+ isFullscreen = false,
21
23
  isImageJunk = false,
22
24
  imageLabelIds = [],
23
25
  possibleLabels,
24
26
  onImageLabelsChanged = () => {},
25
27
  onSetIsImageJunk = () => {},
26
28
  }: ImageToolsProps) => {
27
- const customPopoverStyle = {
28
- "--cui-popover-max-width": "800px",
29
- };
29
+ const [isLabelPopupVisible, setIsLabelPopupVisible] = useState<boolean>(false)
30
+
31
+ // close modal when the fullscreen state changes
32
+ useEffect(() => {
33
+ setIsLabelPopupVisible(false)
34
+ }, [isFullscreen])
30
35
 
31
36
  return (
32
37
  <CButtonGroup role="group" aria-label="Image Tools">
33
- <CPopover
34
- placement="bottom"
35
- content={
36
- <ImageLabel
37
- selectedLabelIds={imageLabelIds}
38
- possibleLabels={possibleLabels}
39
- onImageLabelsChanged={onImageLabelsChanged}
40
- />
41
- }
42
- style={customPopoverStyle}
43
- >
44
- <CButton color="primary" variant="outline" disabled={isDisabled}>
45
- <FontAwesomeIcon icon={faTag as IconProp} size="lg" />
46
- </CButton>
47
- </CPopover>
38
+ {possibleLabels && (
39
+ <ImageLabelInput
40
+ isDisabled={isDisabled}
41
+ isMultilabel={true}
42
+ isVisible={isLabelPopupVisible}
43
+ selectedLabelsIds={imageLabelIds}
44
+ possibleLabels={possibleLabels}
45
+ onLabelSelect={(selectedLabelIds: number[]) => {
46
+ setIsLabelPopupVisible(false)
47
+ onImageLabelsChanged(selectedLabelIds)
48
+ }}
49
+ />
50
+ )}
48
51
 
49
52
  {canJunk && (
50
- <CButton
53
+ <IconButton
51
54
  color="primary"
52
- variant={isImageJunk ? undefined : "outline"}
55
+ icon={faBan}
56
+ isOutline={!isImageJunk}
53
57
  disabled={isDisabled}
54
58
  onClick={() => onSetIsImageJunk(!isImageJunk)}
55
- >
56
- <FontAwesomeIcon icon={faBan as IconProp} size="lg" />
57
- </CButton>
59
+ tooltip="Junk image"
60
+ />
58
61
  )}
59
62
  </CButtonGroup>
60
- );
61
- };
63
+ )
64
+ }
62
65
 
63
- export default ImageTools;
66
+ export default ImageTools
@@ -6,101 +6,98 @@ import {
6
6
  CCol,
7
7
  CContainer,
8
8
  CRow,
9
- } from "@coreui/react";
9
+ } from '@coreui/react'
10
10
 
11
11
  type Instruction = {
12
- title: string;
13
- description: string[];
14
- };
12
+ title: string
13
+ description: string[]
14
+ }
15
15
 
16
16
  const Instructions = () => {
17
17
  const instructionContent: Instruction[] = [
18
18
  {
19
- title: "How to draw?",
19
+ title: 'How to draw?',
20
20
  description: [
21
- "1.) Select a Tool in the toolbar",
22
- "2.) Draw with RIGHT CLICK on Canvas",
21
+ '1.) Select a Tool in the toolbar',
22
+ '2.) Draw with RIGHT CLICK on Canvas',
23
23
  ],
24
24
  },
25
25
  {
26
- title: "How to delete an annotation?",
26
+ title: 'How to delete an annotation?',
27
27
  description: [
28
- "1.) Select an annotation with LEFT CLICK",
29
- "2.) Press DELETE or BACKSPACE",
28
+ '1.) Select an annotation with LEFT CLICK',
29
+ '2.) Press DELETE or BACKSPACE',
30
30
  ],
31
31
  },
32
32
  {
33
- title: "How to assign a label?",
33
+ title: 'How to assign a label?',
34
34
  description: [
35
- "1.) Select an annotation with LEFT CLICK ",
36
- "2.) Hit ENTER ",
37
- "3.) Type into the input field ",
38
- "4.) Hit ENTER to confirm ",
39
- "5.) Hit ESCAPE to close the input field",
35
+ '1.) Select an annotation with LEFT CLICK ',
36
+ '2.) Hit ENTER ',
37
+ '3.) Type into the input field ',
38
+ '4.) Hit ENTER to confirm ',
39
+ '5.) Hit ESCAPE to close the input field',
40
40
  ],
41
41
  },
42
42
  {
43
- title: "Undo/ Redo",
44
- description: ["Undo: Hit STRG + Z ", "Redo: Hit STRG + R"],
43
+ title: 'Undo/ Redo',
44
+ description: ['Undo: Hit STRG + Z ', 'Redo: Hit STRG + R'],
45
45
  },
46
46
  {
47
- title: "Add/ Remove a node to Line/Polygon",
47
+ title: 'Add/ Remove a node to Line/Polygon',
48
48
  description: [
49
- "Add: Hit STRG + Click left on the line",
50
- "Remove: Hit STRG + Click left on the node to delete",
49
+ 'Add: Hit STRG + Click left on the line',
50
+ 'Remove: Hit STRG + Click left on the node to delete',
51
51
  ],
52
52
  },
53
53
  {
54
- title: "Remove a node",
55
- description: ["Hold CTRL and left click on the node"],
54
+ title: 'Remove a node',
55
+ description: ['Hold CTRL and left click on the node'],
56
56
  },
57
57
  {
58
- title: "Edit Line/Polygon",
58
+ title: 'Edit Line/Polygon',
59
59
  description: [
60
- "1.) Click on the Annotation you want to edit.",
60
+ '1.) Click on the Annotation you want to edit.',
61
61
  ' 2.) Press "e". New nodes can now be added using right click',
62
62
  ],
63
63
  },
64
64
  {
65
- title: "Zoom/ Move Canvas",
65
+ title: 'Zoom/ Move Canvas',
66
66
  description: [
67
- "Zoom: Use MOUSE WHEEL to zoom in/out",
68
- "Move: Hold MOUSE WHEEL and move mouse. Or Use W/A/S/D keys to move camera up/left/down/right",
67
+ 'Zoom: Use MOUSE WHEEL to zoom in/out',
68
+ 'Move: Hold MOUSE WHEEL and move mouse. Or Use W/A/S/D keys to move camera up/left/down/right',
69
69
  ],
70
70
  },
71
71
  {
72
- title: "TAB navigation",
73
- description: ["You can traverse all visible annotation by hitting TAB."],
72
+ title: 'TAB navigation',
73
+ description: ['You can traverse all visible annotation by hitting TAB.'],
74
74
  },
75
75
  {
76
- title: "Next/Prev image navigation",
76
+ title: 'Next/Prev image navigation',
77
77
  description: [
78
- "Get next image by hitting ARROW_RIGHT key.",
79
- "Get previous image by hitting ARROW_LEFT key.",
78
+ 'Get next image by hitting ARROW_RIGHT key.',
79
+ 'Get previous image by hitting ARROW_LEFT key.',
80
80
  ],
81
81
  },
82
82
  {
83
- title: "Copy and Paste annotations",
84
- description: [
85
- "Copy: 1.) Select annotation 2.) Hit STRG + C",
86
- "Paste: STRG + V",
87
- ],
83
+ title: 'Copy and Paste annotations',
84
+ description: ['Copy: 1.) Select annotation 2.) Hit STRG + C', 'Paste: STRG + V'],
88
85
  },
89
86
  {
90
- title: "Mark image as junk",
91
- description: ["Press J key"],
87
+ title: 'Mark image as junk',
88
+ description: ['Press J key'],
92
89
  },
93
90
  {
94
- title: "Assign a comment to a 2D annoation",
95
- description: ["1.) Select annotation", "2.) Hit C key"],
91
+ title: 'Assign a comment to a 2D annoation',
92
+ description: ['1.) Select annotation', '2.) Hit C key'],
96
93
  },
97
- ];
94
+ ]
98
95
 
99
96
  const renderCards = () => {
100
97
  return instructionContent.map((instruction) => {
101
98
  const stepsContent = instruction.description.map((step) => (
102
99
  <CCardText key={step}>{step}</CCardText>
103
- ));
100
+ ))
104
101
  return (
105
102
  <CCol xs={12} md={4} lg={3} key={instruction.title}>
106
103
  <CCard>
@@ -110,15 +107,15 @@ const Instructions = () => {
110
107
  </CCardBody>
111
108
  </CCard>
112
109
  </CCol>
113
- );
114
- });
115
- };
110
+ )
111
+ })
112
+ }
116
113
 
117
114
  return (
118
115
  <CContainer>
119
116
  <CRow xs={{ gutterY: 2 }}>{renderCards()}</CRow>
120
117
  </CContainer>
121
- );
122
- };
118
+ )
119
+ }
123
120
 
124
- export default Instructions;
121
+ export default Instructions
@@ -1,10 +1,10 @@
1
- import { CModal, CModalBody, CModalHeader } from "@coreui/react";
2
- import Instructions from "./Instructions";
1
+ import { CModal, CModalBody, CModalHeader } from '@coreui/react'
2
+ import Instructions from './Instructions'
3
3
 
4
4
  type InstructionsModalProps = {
5
- isOpen: boolean;
6
- setIsOpen: (boolean) => void;
7
- };
5
+ isOpen: boolean
6
+ setIsOpen: (boolean) => void
7
+ }
8
8
 
9
9
  const InstructionsModal = ({ isOpen, setIsOpen }: InstructionsModalProps) => {
10
10
  return (
@@ -14,7 +14,7 @@ const InstructionsModal = ({ isOpen, setIsOpen }: InstructionsModalProps) => {
14
14
  <Instructions />
15
15
  </CModalBody>
16
16
  </CModal>
17
- );
18
- };
17
+ )
18
+ }
19
19
 
20
- export default InstructionsModal;
20
+ export default InstructionsModal