lost-sia 1.2.0 → 2.0.0-alpha0
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/LICENSE +21 -0
- package/README.md +0 -0
- package/package.json +60 -47
- package/src/AnnoExampleViewer.jsx +57 -0
- package/src/AnnoLabelInput.jsx +99 -0
- package/src/AnnoToolBar.jsx +132 -0
- package/src/Annotation/AnnoBar.jsx +148 -0
- package/src/Annotation/Annotation.jsx +358 -0
- package/src/Annotation/Annotation.scss +47 -0
- package/src/Annotation/BBox.jsx +291 -0
- package/src/Annotation/Edge.jsx +82 -0
- package/src/Annotation/InfSelectionArea.jsx +71 -0
- package/src/Annotation/Line.jsx +60 -0
- package/src/Annotation/Node.jsx +278 -0
- package/src/Annotation/Point.jsx +196 -0
- package/src/Annotation/Polygon.jsx +361 -0
- package/src/Canvas.jsx +1839 -0
- package/src/ImgBar.jsx +123 -0
- package/src/InfoBoxes/AnnoDetails.jsx +166 -0
- package/src/InfoBoxes/AnnoStats.jsx +104 -0
- package/src/InfoBoxes/InfoBox.jsx +78 -0
- package/src/InfoBoxes/InfoBoxArea.jsx +155 -0
- package/src/InfoBoxes/LabelInfo.jsx +95 -0
- package/src/LabelInput.jsx +224 -0
- package/src/Prompt.jsx +46 -0
- package/src/SIA.scss +10 -0
- package/src/SIAFilterButton.jsx +178 -0
- package/src/SIASettingButton.jsx +122 -0
- package/src/Sia.jsx +485 -0
- package/src/SiaPopup.jsx +10 -0
- package/src/ToolBar.jsx +399 -0
- package/src/Toolbar.css +13 -0
- package/src/ToolbarItem.jsx +25 -0
- package/src/filterTools.js +3 -0
- package/src/index.js +17 -0
- package/src/siaDummyData.js +265 -0
- package/src/test.js +7 -0
- package/src/types/annoStatus.js +4 -0
- package/src/types/canvasActions.js +57 -0
- package/src/types/cursorstyles.js +3 -0
- package/src/types/modes.js +8 -0
- package/src/types/notificationType.js +4 -0
- package/src/types/toolbarEvents.js +33 -0
- package/src/types/tools.js +11 -0
- package/src/utils/annoConversion.js +115 -0
- package/src/utils/colorlut.js +67 -0
- package/src/utils/constraints.js +75 -0
- package/src/utils/hist.js +67 -0
- package/src/utils/keyActions.js +107 -0
- package/src/utils/mouse.js +14 -0
- package/src/utils/siaIcons.jsx +95 -0
- package/src/utils/transform.js +318 -0
- package/src/utils/uiConfig.js +57 -0
- package/src/utils/windowViewport.js +35 -0
- package/CHANGELOG.md +0 -163
- package/dist/index.css +0 -24823
- package/dist/index.es.js +0 -10431
- package/dist/index.es.js.map +0 -1
- package/dist/index.js +0 -10446
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const TOOL_SELECTED = 'toolSelected'
|
|
2
|
+
export const GET_NEXT_IMAGE = 'getNextImage'
|
|
3
|
+
export const GET_PREV_IMAGE = 'getPrevImage'
|
|
4
|
+
export const TASK_FINISHED = 'taskFinished'
|
|
5
|
+
export const SHOW_IMAGE_LABEL_INPUT = 'showImageLabelInput'
|
|
6
|
+
export const IMG_IS_JUNK = 'imageIsJunk'
|
|
7
|
+
export const DELETE_ALL_ANNOS = 'deleteAllAnnos'
|
|
8
|
+
export const SET_FULLSCREEN = 'setFullscreen'
|
|
9
|
+
export const SHOW_ANNO_DETAILS = 'showAnnoDetails'
|
|
10
|
+
export const SHOW_LABEL_INFO = 'showLabelInfo'
|
|
11
|
+
export const SHOW_ANNO_STATS = 'showAnnoStats'
|
|
12
|
+
export const EDIT_STROKE_WIDTH = 'editStrokeWidth'
|
|
13
|
+
export const EDIT_NODE_RADIUS = 'editNodeRadius'
|
|
14
|
+
export const APPLY_FILTER = 'applyFilter'
|
|
15
|
+
export const SAVE = 'save'
|
|
16
|
+
|
|
17
|
+
export default {
|
|
18
|
+
TOOL_SELECTED,
|
|
19
|
+
GET_NEXT_IMAGE,
|
|
20
|
+
GET_PREV_IMAGE,
|
|
21
|
+
TASK_FINISHED,
|
|
22
|
+
SHOW_IMAGE_LABEL_INPUT,
|
|
23
|
+
IMG_IS_JUNK,
|
|
24
|
+
DELETE_ALL_ANNOS,
|
|
25
|
+
SET_FULLSCREEN,
|
|
26
|
+
SHOW_ANNO_DETAILS,
|
|
27
|
+
SHOW_LABEL_INFO,
|
|
28
|
+
SHOW_ANNO_STATS,
|
|
29
|
+
EDIT_STROKE_WIDTH,
|
|
30
|
+
EDIT_NODE_RADIUS,
|
|
31
|
+
APPLY_FILTER,
|
|
32
|
+
SAVE
|
|
33
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import * as transform from './transform'
|
|
2
|
+
import * as annoStatus from '../types/annoStatus'
|
|
3
|
+
import * as modes from '../types/modes'
|
|
4
|
+
import _ from 'lodash'
|
|
5
|
+
|
|
6
|
+
function _fixBackendAnnoElement(element) {
|
|
7
|
+
return {
|
|
8
|
+
...element,
|
|
9
|
+
id: element.id ? element.id : _.uniqueId('new'),
|
|
10
|
+
annoTime: element.annoTime ? element.annoTime : 0.0,
|
|
11
|
+
mode: element.mode ? element.mode : modes.VIEW,
|
|
12
|
+
status: element.status ? element.status : annoStatus.DATABASE,
|
|
13
|
+
labelIds: element.labelIds ? element.labelIds : []
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function fixBackendAnnos(backendAnnos) {
|
|
18
|
+
let annos = {
|
|
19
|
+
bBoxes: [...backendAnnos.bBoxes.map((element) => {
|
|
20
|
+
return _fixBackendAnnoElement(element)
|
|
21
|
+
})],
|
|
22
|
+
lines: [...backendAnnos.lines.map((element) => {
|
|
23
|
+
return _fixBackendAnnoElement(element)
|
|
24
|
+
})],
|
|
25
|
+
polygons: [...backendAnnos.polygons.map((element) => {
|
|
26
|
+
return _fixBackendAnnoElement(element)
|
|
27
|
+
})],
|
|
28
|
+
points: [...backendAnnos.points.map((element) => {
|
|
29
|
+
return _fixBackendAnnoElement(element)
|
|
30
|
+
})],
|
|
31
|
+
}
|
|
32
|
+
console.log('fixBackendAnnos', annos)
|
|
33
|
+
return annos
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function backendAnnosToCanvas(backendAnnos, imgSize, imgOffset) {
|
|
37
|
+
let annos = [
|
|
38
|
+
...backendAnnos.bBoxes.map((element) => {
|
|
39
|
+
return {
|
|
40
|
+
...element, type: 'bBox',
|
|
41
|
+
mode: element.mode ? element.mode : modes.VIEW,
|
|
42
|
+
status: element.status ? element.status : annoStatus.DATABASE
|
|
43
|
+
}
|
|
44
|
+
}),
|
|
45
|
+
...backendAnnos.lines.map((element) => {
|
|
46
|
+
return {
|
|
47
|
+
...element, type: 'line',
|
|
48
|
+
mode: element.mode ? element.mode : modes.VIEW,
|
|
49
|
+
status: element.status ? element.status : annoStatus.DATABASE
|
|
50
|
+
}
|
|
51
|
+
}),
|
|
52
|
+
...backendAnnos.polygons.map((element) => {
|
|
53
|
+
return {
|
|
54
|
+
...element, type: 'polygon',
|
|
55
|
+
mode: element.mode ? element.mode : modes.VIEW,
|
|
56
|
+
status: element.status ? element.status : annoStatus.DATABASE
|
|
57
|
+
}
|
|
58
|
+
}),
|
|
59
|
+
...backendAnnos.points.map((element) => {
|
|
60
|
+
return {
|
|
61
|
+
...element, type: 'point',
|
|
62
|
+
mode: element.mode ? element.mode : modes.VIEW,
|
|
63
|
+
status: element.status ? element.status : annoStatus.DATABASE
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
]
|
|
67
|
+
annos = annos.map((el) => {
|
|
68
|
+
return {
|
|
69
|
+
...el,
|
|
70
|
+
data: transform.toSia(el.data, imgSize, el.type, imgOffset)
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
// this.setState({annos: [...annos]})
|
|
74
|
+
return annos
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function canvasToBackendSingleAnno(anno, imgSize, removeFrontedId = false, imgOffset = { x: 0, y: 0 }) {
|
|
78
|
+
var annoId
|
|
79
|
+
if (removeFrontedId) {
|
|
80
|
+
// If an annotation will be send to backend,
|
|
81
|
+
// ids of new created annoations need to be set to
|
|
82
|
+
// undefined.
|
|
83
|
+
annoId = (typeof anno.id) === "string" ? undefined : anno.id
|
|
84
|
+
} else {
|
|
85
|
+
annoId = anno.id
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
...anno,
|
|
89
|
+
id: annoId,
|
|
90
|
+
mode: modes.VIEW,
|
|
91
|
+
data: transform.toBackend(anno.data, imgSize, anno.type, imgOffset)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function canvasToBackendAnnos(annos, imgSize, forBackendPost = false, imgOffset = { x: 0, y: 0 }) {
|
|
96
|
+
let myAnnos = annos
|
|
97
|
+
const bAnnos = myAnnos.map(el => {
|
|
98
|
+
return canvasToBackendSingleAnno(el, imgSize, forBackendPost, imgOffset)
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
const backendFormat = {
|
|
102
|
+
bBoxes: bAnnos.filter((el) => { return el.type === 'bBox' }),
|
|
103
|
+
lines: bAnnos.filter((el) => { return el.type === 'line' }),
|
|
104
|
+
points: bAnnos.filter((el) => { return el.type === 'point' }),
|
|
105
|
+
polygons: bAnnos.filter((el) => { return el.type === 'polygon' }),
|
|
106
|
+
}
|
|
107
|
+
return backendFormat
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export default {
|
|
111
|
+
fixBackendAnnos,
|
|
112
|
+
backendAnnosToCanvas,
|
|
113
|
+
canvasToBackendSingleAnno,
|
|
114
|
+
canvasToBackendAnnos
|
|
115
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// const colors30 = ["#dc9769",
|
|
2
|
+
// "#5c69d6",
|
|
3
|
+
// "#51a630",
|
|
4
|
+
// "#9a59cc",
|
|
5
|
+
// "#a1bb37",
|
|
6
|
+
// "#c043a6",
|
|
7
|
+
// "#5fc666",
|
|
8
|
+
// "#de4282",
|
|
9
|
+
// "#58c699",
|
|
10
|
+
// "#d2404e",
|
|
11
|
+
// "#42c0c7",
|
|
12
|
+
// "#d95130",
|
|
13
|
+
// "#598cdd",
|
|
14
|
+
// "#df8830",
|
|
15
|
+
// "#50a2d1",
|
|
16
|
+
// "#c8a73f",
|
|
17
|
+
// "#d87ed5",
|
|
18
|
+
// "#3e7f38",
|
|
19
|
+
// "#af94d8",
|
|
20
|
+
// "#7b8b2d",
|
|
21
|
+
// "#635ea2",
|
|
22
|
+
// "#a1b56d",
|
|
23
|
+
// "#a93e62",
|
|
24
|
+
// "#3e8d68",
|
|
25
|
+
// "#df82ab",
|
|
26
|
+
// "#616c2c",
|
|
27
|
+
// "#955282",
|
|
28
|
+
// "#91692d",
|
|
29
|
+
// "#d47776",
|
|
30
|
+
// "#a94e2c"]
|
|
31
|
+
|
|
32
|
+
const colors20 = ["#46aed7",
|
|
33
|
+
"#e28f81",
|
|
34
|
+
"#50b897",
|
|
35
|
+
"#88712f",
|
|
36
|
+
"#9cb067",
|
|
37
|
+
"#a4527d",
|
|
38
|
+
"#a55046",
|
|
39
|
+
"#6e90da",
|
|
40
|
+
"#487b3b",
|
|
41
|
+
"#6360a7",
|
|
42
|
+
"#cd8fd3",
|
|
43
|
+
"#d5a442",
|
|
44
|
+
"#cf7635",
|
|
45
|
+
"#da4971",
|
|
46
|
+
"#a4b137",
|
|
47
|
+
"#d44da4",
|
|
48
|
+
"#aa54be",
|
|
49
|
+
"#5ab74d",
|
|
50
|
+
"#7166d9",
|
|
51
|
+
"#d14734"]
|
|
52
|
+
|
|
53
|
+
const colors = colors20
|
|
54
|
+
const nColors = 20
|
|
55
|
+
|
|
56
|
+
export function getColor(n){
|
|
57
|
+
if (n){
|
|
58
|
+
return colors[n%nColors]
|
|
59
|
+
}
|
|
60
|
+
else{
|
|
61
|
+
return getDefaultColor()
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function getDefaultColor(){
|
|
66
|
+
return colors[0]
|
|
67
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as annoStatus from '../types/annoStatus'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Check if labels can be changed for a specific annotation
|
|
5
|
+
*
|
|
6
|
+
* @param allowedActions Actions that are allowed, read from config
|
|
7
|
+
* @param anno Annotation that should be checked
|
|
8
|
+
* @returns {Boolean}
|
|
9
|
+
*/
|
|
10
|
+
export function allowedToLabel(allowedActions, anno){
|
|
11
|
+
if (allowedActions.label){
|
|
12
|
+
return true
|
|
13
|
+
// const status = anno.status
|
|
14
|
+
// if (!status) return true
|
|
15
|
+
// if (status !== annoStatus.NEW){
|
|
16
|
+
// if (allowedActions.edit.label){
|
|
17
|
+
// return true
|
|
18
|
+
// } else {
|
|
19
|
+
// console.warn('You may not edit the label of this annotation as defined by config!', anno)
|
|
20
|
+
// return false
|
|
21
|
+
// }
|
|
22
|
+
// } else {
|
|
23
|
+
// // Return always true if labeling is allowed in general
|
|
24
|
+
// // and annotation was not edited (it was NEW)
|
|
25
|
+
// return true
|
|
26
|
+
// }
|
|
27
|
+
} else {
|
|
28
|
+
console.warn('You may not edit the label of this annotation as defined by config!', anno)
|
|
29
|
+
return false
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// /**
|
|
34
|
+
// * Check if config allows to delete a specific annotation.
|
|
35
|
+
// *
|
|
36
|
+
// * @param allowedActions Actions that are allowed, read from config
|
|
37
|
+
// * @param anno Annotation that should be checked
|
|
38
|
+
// * @returns {Boolean}
|
|
39
|
+
// */
|
|
40
|
+
// export function allowedToDelete(allowedActions, anno){
|
|
41
|
+
// const status = anno.status
|
|
42
|
+
// if (!status) return true
|
|
43
|
+
// if (status !== annoStatus.NEW){
|
|
44
|
+
// if(allowedActions.edit.delete){
|
|
45
|
+
// return true
|
|
46
|
+
// } else {
|
|
47
|
+
// console.warn('You may not delete this annotation as defined by config!', anno)
|
|
48
|
+
// return false
|
|
49
|
+
// }
|
|
50
|
+
// } else {
|
|
51
|
+
// return true
|
|
52
|
+
// }
|
|
53
|
+
// }
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Check if config allows to edit a specific annotation.
|
|
57
|
+
*
|
|
58
|
+
* @param allowedActions Actions that are allowed, read from config
|
|
59
|
+
* @param anno Annotation that should be checked
|
|
60
|
+
* @returns {Boolean}
|
|
61
|
+
*/
|
|
62
|
+
export function allowedToEdit(allowedActions, anno){
|
|
63
|
+
const status = anno.status
|
|
64
|
+
if (!status) return true
|
|
65
|
+
if (status !== annoStatus.NEW){
|
|
66
|
+
if(allowedActions.edit){
|
|
67
|
+
return true
|
|
68
|
+
} else {
|
|
69
|
+
console.warn('You may not edit bounds of this annotation as defined by config!', anno)
|
|
70
|
+
return false
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
return true
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
class UndoRedo{
|
|
2
|
+
constructor(maxElements=100){
|
|
3
|
+
this.hist = []
|
|
4
|
+
this.pointer = 0
|
|
5
|
+
this.maxElements = maxElements
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
push(entry, description='No description'){
|
|
9
|
+
const histEl = {
|
|
10
|
+
entry,
|
|
11
|
+
description
|
|
12
|
+
}
|
|
13
|
+
if (this.pointer !== 0){
|
|
14
|
+
while (this.pointer !== 0){
|
|
15
|
+
this.pointer--
|
|
16
|
+
this.hist.shift()
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
this.hist.unshift(histEl)
|
|
20
|
+
if (this.hist.length > this.maxElements){
|
|
21
|
+
this.hist.pop()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
undo(){
|
|
26
|
+
if (this.pointer+1 < this.hist.length){
|
|
27
|
+
// const element =
|
|
28
|
+
this.pointer++
|
|
29
|
+
return this.hist[this.pointer]
|
|
30
|
+
} else {
|
|
31
|
+
return this.hist[this.hist.length-1]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
undoMia(){
|
|
36
|
+
if (this.pointer+1 < this.hist.length){
|
|
37
|
+
this.pointer++
|
|
38
|
+
return this.hist[this.pointer-1]
|
|
39
|
+
} else {
|
|
40
|
+
return this.hist[this.hist.length-1]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
redo(){
|
|
45
|
+
if (this.pointer-1 >= 0){
|
|
46
|
+
this.pointer--
|
|
47
|
+
return this.hist[this.pointer]
|
|
48
|
+
} else {
|
|
49
|
+
return this.hist[0]
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
getHist(){
|
|
54
|
+
return this.hist
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
clearHist(){
|
|
58
|
+
this.hist = []
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
isEmpty(){
|
|
62
|
+
return this.hist.length === 0
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export default UndoRedo
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
export const EDIT_LABEL='editLabel'
|
|
2
|
+
export const DELETE_ANNO='deleteAnno'
|
|
3
|
+
export const ENTER_ANNO_ADD_MODE='enterAnnoAddMode'
|
|
4
|
+
export const LEAVE_ANNO_ADD_MODE='leaveAnnoAddMode'
|
|
5
|
+
export const UNDO='undo'
|
|
6
|
+
export const REDO='redo'
|
|
7
|
+
export const TRAVERSE_ANNOS='traverseAnnos'
|
|
8
|
+
export const CAM_MOVE_UP='camMoveUp'
|
|
9
|
+
export const CAM_MOVE_DOWN='camMoveDown'
|
|
10
|
+
export const CAM_MOVE_LEFT='camMoveLeft'
|
|
11
|
+
export const CAM_MOVE_RIGHT='camMoveRight'
|
|
12
|
+
export const CAM_MOVE_STOP='camMoveStop'
|
|
13
|
+
export const COPY_ANNOTATION='copyAnnotation'
|
|
14
|
+
export const PASTE_ANNOTATION='pasteAnnotation'
|
|
15
|
+
export const RECREATE_ANNO='recreateAnnotation'
|
|
16
|
+
export const DELETE_ANNO_IN_CREATION='deleteAnnoInCreation'
|
|
17
|
+
export const TOGGLE_ANNO_COMMENT_INPUT='toggleAnnoCommentInput'
|
|
18
|
+
|
|
19
|
+
class KeyMapper{
|
|
20
|
+
constructor(keyActionHandler=undefined){
|
|
21
|
+
this.controlDown = false
|
|
22
|
+
this.keyActionHandler = keyActionHandler
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
keyDown(key){
|
|
26
|
+
switch (key){
|
|
27
|
+
case 'Enter':
|
|
28
|
+
this.triggerKeyAction(EDIT_LABEL)
|
|
29
|
+
break
|
|
30
|
+
case 'Delete':
|
|
31
|
+
this.triggerKeyAction(DELETE_ANNO)
|
|
32
|
+
break
|
|
33
|
+
case 'Backspace':
|
|
34
|
+
this.triggerKeyAction(DELETE_ANNO)
|
|
35
|
+
break
|
|
36
|
+
case 'Control':
|
|
37
|
+
this.controlDown = true
|
|
38
|
+
this.triggerKeyAction(ENTER_ANNO_ADD_MODE)
|
|
39
|
+
break
|
|
40
|
+
case 'z':
|
|
41
|
+
if (this.controlDown){
|
|
42
|
+
this.triggerKeyAction(UNDO)
|
|
43
|
+
}
|
|
44
|
+
break
|
|
45
|
+
case 'r':
|
|
46
|
+
if (this.controlDown){
|
|
47
|
+
this.triggerKeyAction(REDO)
|
|
48
|
+
}
|
|
49
|
+
break
|
|
50
|
+
case 'Tab':
|
|
51
|
+
this.triggerKeyAction(TRAVERSE_ANNOS)
|
|
52
|
+
break
|
|
53
|
+
case 'w':
|
|
54
|
+
this.triggerKeyAction(CAM_MOVE_UP)
|
|
55
|
+
break
|
|
56
|
+
case 's':
|
|
57
|
+
this.triggerKeyAction(CAM_MOVE_DOWN)
|
|
58
|
+
break
|
|
59
|
+
case 'a':
|
|
60
|
+
this.triggerKeyAction(CAM_MOVE_LEFT)
|
|
61
|
+
break
|
|
62
|
+
case 'd':
|
|
63
|
+
this.triggerKeyAction(CAM_MOVE_RIGHT)
|
|
64
|
+
break
|
|
65
|
+
case 'e':
|
|
66
|
+
this.triggerKeyAction(RECREATE_ANNO)
|
|
67
|
+
break
|
|
68
|
+
case 'c':
|
|
69
|
+
if (this.controlDown){
|
|
70
|
+
this.triggerKeyAction(COPY_ANNOTATION)
|
|
71
|
+
} else {
|
|
72
|
+
this.triggerKeyAction(TOGGLE_ANNO_COMMENT_INPUT)
|
|
73
|
+
}
|
|
74
|
+
break
|
|
75
|
+
case 'v':
|
|
76
|
+
if (this.controlDown){
|
|
77
|
+
this.triggerKeyAction(PASTE_ANNOTATION)
|
|
78
|
+
}
|
|
79
|
+
break
|
|
80
|
+
case 'Escape':
|
|
81
|
+
this.triggerKeyAction(DELETE_ANNO_IN_CREATION)
|
|
82
|
+
break
|
|
83
|
+
default:
|
|
84
|
+
break
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
keyUp(key){
|
|
89
|
+
switch (key){
|
|
90
|
+
case 'Control':
|
|
91
|
+
this.controlDown = false
|
|
92
|
+
this.triggerKeyAction(LEAVE_ANNO_ADD_MODE)
|
|
93
|
+
break
|
|
94
|
+
default:
|
|
95
|
+
break
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
triggerKeyAction(keyAction){
|
|
100
|
+
if (this.keyActionHandler){
|
|
101
|
+
this.keyActionHandler(keyAction)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export default KeyMapper
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function getMousePosition(e, svg){
|
|
2
|
+
const absPos = getMousePositionAbs(e, svg)
|
|
3
|
+
return {
|
|
4
|
+
x: (absPos.x )/svg.scale - svg.translateX,
|
|
5
|
+
y: (absPos.y )/svg.scale - svg.translateY
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function getMousePositionAbs(e, svg){
|
|
10
|
+
return {
|
|
11
|
+
x: (e.pageX - svg.left),
|
|
12
|
+
y: (e.pageY - svg.top)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
export function textIcon(){
|
|
4
|
+
return <svg version="1.1" xmlns="http://www.w3.org/2000/svg"
|
|
5
|
+
// x="0px" y="0px"
|
|
6
|
+
// width="1190.549px" height="841.891px"
|
|
7
|
+
viewBox="0 0 1190.549 841.891"
|
|
8
|
+
width="17px"
|
|
9
|
+
// onClick={e => this.handleClick(e)}
|
|
10
|
+
>
|
|
11
|
+
<path id="T" fillRule="evenodd" clipRule="evenodd" fill="currentColor" d="M925.876,172.939c-0.172-13.004,0.161-26.013,0.116-39.019
|
|
12
|
+
c-0.021-4.017-5.046-9.053-9.037-9.087c-7.948-0.068-15.897-0.051-23.848-0.051c-73.526,0.006-147.051,0.02-220.578,0.032
|
|
13
|
+
c-8.095,0.001-11.969,3.776-11.969,11.742c-0.009,154.998-0.009,309.997-0.009,464.998c0,44.257-0.002,88.519,0.009,132.778
|
|
14
|
+
c0,7.553,4.173,11.736,11.651,11.747c21.677,0.018,30.288-0.227,65.032,0.018c34.743,0.239,46.295,27.955,46.295,46.43
|
|
15
|
+
c-0.005,18.477-13.856,42.722-46.792,43.747c-42.993,0.197-85.989-0.057-128.979-0.05c-47.697,0.014-95.387,0.009-143.078,0.074
|
|
16
|
+
c-13.712-0.278-44.888-9.133-44.888-44.159c0-35.025,20.399-44.646,42.975-46.192c16.293,0.115,45.164,0.179,67.743,0.16
|
|
17
|
+
c5.553-0.006,10.175-5.03,10.178-11.005c0.008-45.524-0.016-91.049-0.018-136.569c0-99.001,0-197.997,0.008-296.994
|
|
18
|
+
c0.001-55.278,0.018-110.559,0.007-165.837c0-6.513-4.521-10.917-11.118-10.917c-81.116-0.005-162.229-0.005-243.34-0.001
|
|
19
|
+
c-6.977,0-11.061,3.995-11.069,10.825c-0.016,12.286-0.033,24.569,0.019,36.855c-0.076,20.742-10.042,43.007-40.763,43.007
|
|
20
|
+
c-30.724,0-46.917-15.208-48.805-43.296c-0.419-14.084,0.01-28.181,0.01-42.272c0-27.46,0-54.917,0-82.379
|
|
21
|
+
c0-1.048,0.747-16.871,13.391-30.357c12.642-13.485,26.225-12.505,27.633-12.505c84.544,0.015,169.091,0.009,253.635,0.009
|
|
22
|
+
c153.191,0.001,459.578,0.004,459.578,0.004s20.149-0.287,35.766-0.17c0.983-0.023,18.696,1.188,30.027,13.07
|
|
23
|
+
c11.333,11.885,9.972,27.513,9.972,28.256c-0.024,42.091,0.255,84.183-0.007,126.274c-0.247,26.341-22.705,41.944-44.85,42.037
|
|
24
|
+
C948.049,214.236,926.687,199.643,925.876,172.939z"/>
|
|
25
|
+
</svg>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function lineIcon(){
|
|
29
|
+
return (
|
|
30
|
+
<svg version="1.1" id="Linie" xmlns="http://www.w3.org/2000/svg"
|
|
31
|
+
// xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
32
|
+
// width="1190.549px" height="841.891px"
|
|
33
|
+
viewBox="0 0 1190.549 841.891"
|
|
34
|
+
width="17px"
|
|
35
|
+
// enable-background="new 0 0 1190.549 841.891"
|
|
36
|
+
// xml:space="preserve"
|
|
37
|
+
>
|
|
38
|
+
<path fill="currentColor" d="M986.331,109.582c7.141-10.669,28.926-51.179-2.968-85.299S891.011,8.972,891.011,8.972L539.125,133.474
|
|
39
|
+
L63.239,302.022c-21.503,7.998-53.586,30.072-60.956,61.716s-2.116,58.538,22.414,96.79S211.33,752.213,228.564,777.28
|
|
40
|
+
c26.453,36.868,62.16,58.042,105.507,57.154s365.665-7.485,365.665-7.485l331.7-8.325l89.453-2.293c0,0,70.998-7.179,69.861-60.287
|
|
41
|
+
c-1.135-53.108-74.618-62.721-74.618-62.721s-733.215,15.553-749.148,15.576c-22.688,0.201-45.355-15.278-54.146-28.928
|
|
42
|
+
s-175.79-272.956-175.79-272.956l600.587-212.338c0,0-73.179,67.087-99.315,100.041s-30.56,74.565-5.053,95.237
|
|
43
|
+
c31.188,24.081,91.974-3.708,123.127-39.312C782.35,323.912,979.191,120.251,986.331,109.582z"/>
|
|
44
|
+
</svg>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function bBoxIcon(){
|
|
49
|
+
return (
|
|
50
|
+
<svg version="1.1" id="Linie" xmlns="http://www.w3.org/2000/svg"
|
|
51
|
+
// xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
52
|
+
// width="1190.549px" height="841.891px"
|
|
53
|
+
viewBox="0 0 1190.549 841.891"
|
|
54
|
+
width="17px"
|
|
55
|
+
// enable-background="new 0 0 1190.549 841.891"
|
|
56
|
+
// xml:space="preserve"
|
|
57
|
+
>
|
|
58
|
+
<path fill="none" stroke="currentColor" strokeWidth="120" strokeMiterlimit="10" d="M929.775,710.655
|
|
59
|
+
c0,23.386-19.134,42.52-42.52,42.52H278.991c-23.386,0-42.52-19.134-42.52-42.52V102.392c0-23.386,19.134-42.52,42.52-42.52
|
|
60
|
+
h608.264c23.386,0,42.52,19.134,42.52,42.52V710.655z"/>
|
|
61
|
+
</svg>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function polygonIcon(){
|
|
66
|
+
return (
|
|
67
|
+
<svg version="1.1" id="Linie" xmlns="http://www.w3.org/2000/svg"
|
|
68
|
+
// xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
69
|
+
// width="1190.549px" height="841.891px"
|
|
70
|
+
viewBox="0 0 1190.549 841.891"
|
|
71
|
+
width="17px"
|
|
72
|
+
// enable-background="new 0 0 1190.549 841.891"
|
|
73
|
+
// xml:space="preserve"
|
|
74
|
+
>
|
|
75
|
+
<path fill="none" stroke="currentColor" strokeWidth="120" strokeMiterlimit="10" d="M342.327,769.938
|
|
76
|
+
c-23.379,0.548-52.922-15.056-65.65-34.674L65.479,409.738c-12.729-19.619-5.085-41.998,16.984-49.732L917.331,67.421
|
|
77
|
+
c22.07-7.734,26.86-0.275,10.645,16.576L691.761,329.475c-16.216,16.852-14.503,42.542,3.807,57.092l425.212,337.901
|
|
78
|
+
c18.31,14.549,14.16,26.901-9.219,27.449L342.327,769.938z"/>
|
|
79
|
+
</svg>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function pointIcon(){
|
|
84
|
+
return (
|
|
85
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
|
|
86
|
+
// x="0px" y="0px"
|
|
87
|
+
// width="1190.549px" height="841.891px"
|
|
88
|
+
viewBox="0 0 1190.549 841.891"
|
|
89
|
+
width="17px"
|
|
90
|
+
>
|
|
91
|
+
<path fill="currentColor" d="M748.197,408.286c0,151.355-122.699,274.058-274.059,274.058c-151.357,0-274.057-122.703-274.057-274.058
|
|
92
|
+
c0-151.356,122.7-274.057,274.057-274.057C625.497,134.229,748.197,256.929,748.197,408.286z"/>
|
|
93
|
+
</svg>
|
|
94
|
+
)
|
|
95
|
+
}
|