Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mirador annotations
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
IIIF
Mirador
Mirador annotations
Commits
153d518f
Commit
153d518f
authored
Jan 26, 2024
by
Anthony
Browse files
Options
Downloads
Patches
Plain Diff
Fix bug on freehand
parent
56b062f7
No related branches found
No related tags found
1 merge request
!10
Draft: MigratingAnnotationCreation to MUI5.
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/AnnotationDrawing.js
+6
-7
6 additions, 7 deletions
src/AnnotationDrawing.js
src/KonvaDrawing/shapes/Freehand.js
+64
-77
64 additions, 77 deletions
src/KonvaDrawing/shapes/Freehand.js
src/KonvaDrawing/shapes/ParentComponent.js
+62
-38
62 additions, 38 deletions
src/KonvaDrawing/shapes/ParentComponent.js
with
132 additions
and
122 deletions
src/AnnotationDrawing.js
+
6
−
7
View file @
153d518f
...
@@ -12,7 +12,7 @@ import { v4 as uuidv4 } from 'uuid';
...
@@ -12,7 +12,7 @@ import { v4 as uuidv4 } from 'uuid';
import
{
OSDReferences
}
from
'
mirador/dist/es/src/plugins/OSDReferences
'
;
import
{
OSDReferences
}
from
'
mirador/dist/es/src/plugins/OSDReferences
'
;
// eslint-disable-next-line import/no-extraneous-dependencies
// eslint-disable-next-line import/no-extraneous-dependencies
import
{
VideosReferences
}
from
'
mirador/dist/es/src/plugins/VideosReferences
'
;
import
{
VideosReferences
}
from
'
mirador/dist/es/src/plugins/VideosReferences
'
;
import
ParentComponent
from
'
./shapes/ParentComponent
'
;
import
ParentComponent
from
'
./
KonvaDrawing/
shapes/ParentComponent
'
;
/** All the stuff to draw on the canvas */
/** All the stuff to draw on the canvas */
...
@@ -225,10 +225,8 @@ function AnnotationDrawing(props) {
...
@@ -225,10 +225,8 @@ function AnnotationDrawing(props) {
setShapes
([...
shapes
,
shape
]);
setShapes
([...
shapes
,
shape
]);
setCurrentShape
(
shape
);
setCurrentShape
(
shape
);
break
;
break
;
case
'
freehand
'
:
case
'
freehand
'
:
// Not totally functionnal
// Not totally functionnal
// TODO Not sure for this one
setIsDrawing
(
true
);
setIsDrawing
(
true
);
shape
=
{
shape
=
{
fill
:
props
.
fillColor
,
fill
:
props
.
fillColor
,
...
@@ -245,6 +243,8 @@ function AnnotationDrawing(props) {
...
@@ -245,6 +243,8 @@ function AnnotationDrawing(props) {
rotation
:
0
,
rotation
:
0
,
scaleX
:
1
,
scaleX
:
1
,
scaleY
:
1
,
scaleY
:
1
,
stroke
:
props
.
strokeColor
,
strokeWidth
:
props
.
strokeWidth
,
type
:
'
freehand
'
,
type
:
'
freehand
'
,
x
:
0
,
x
:
0
,
y
:
0
,
y
:
0
,
...
@@ -272,7 +272,7 @@ function AnnotationDrawing(props) {
...
@@ -272,7 +272,7 @@ function AnnotationDrawing(props) {
case
'
arrow
'
:
case
'
arrow
'
:
setIsDrawing
(
true
);
setIsDrawing
(
true
);
shape
=
{
shape
=
{
fill
:
props
.
fillColor
||
'
red
'
,
fill
:
props
.
fillColor
,
id
:
uuidv4
(),
id
:
uuidv4
(),
pointerLength
:
20
,
pointerLength
:
20
,
pointerWidth
:
20
,
pointerWidth
:
20
,
...
@@ -280,10 +280,9 @@ function AnnotationDrawing(props) {
...
@@ -280,10 +280,9 @@ function AnnotationDrawing(props) {
rotation
:
0
,
rotation
:
0
,
scaleX
:
1
,
scaleX
:
1
,
scaleY
:
1
,
scaleY
:
1
,
stroke
:
props
.
fillColor
||
'
red
'
,
stroke
:
props
.
strokeColor
,
type
:
'
arrow
'
,
type
:
'
arrow
'
,
};
};
setShapes
([...
shapes
,
shape
]);
setShapes
([...
shapes
,
shape
]);
setCurrentShape
(
shape
);
setCurrentShape
(
shape
);
case
'
debug
'
:
case
'
debug
'
:
...
@@ -459,7 +458,7 @@ AnnotationDrawing.propTypes = {
...
@@ -459,7 +458,7 @@ AnnotationDrawing.propTypes = {
AnnotationDrawing
.
defaultProps
=
{
AnnotationDrawing
.
defaultProps
=
{
activeTool
:
null
,
activeTool
:
null
,
closed
:
true
,
closed
:
true
,
fillColor
:
null
,
fillColor
:
'
red
'
,
selectedShapeId
:
null
,
selectedShapeId
:
null
,
strokeColor
:
'
#00BFFF
'
,
strokeColor
:
'
#00BFFF
'
,
strokeWidth
:
1
,
strokeWidth
:
1
,
...
...
This diff is collapsed.
Click to expand it.
src/KonvaDrawing/shapes/Freehand.js
+
64
−
77
View file @
153d518f
import
React
,
{
useEffect
,
useRef
}
from
'
react
'
;
import
React
,
{
useEffect
,
useRef
}
from
'
react
'
;
import
PropTypes
from
'
prop-types
'
;
import
PropTypes
from
'
prop-types
'
;
import
{
import
{
Transformer
,
Line
,
Group
}
from
'
react-konva
'
;
Transformer
,
Shape
,
Line
,
Layer
,
Group
}
from
'
react-konva
'
;
/** FreeHand shape displaying */
/** FreeHand shape displaying */
function
Freehand
({
function
Freehand
({
activeTool
,
fill
,
height
,
onShapeClick
,
points
,
isSelected
,
shape
,
stroke
,
strokeWidth
,
width
,
x
,
y
,
onTransformEnd
,
handleDragEnd
activeTool
,
fill
,
height
,
onShapeClick
,
points
,
isSelected
,
shape
,
stroke
,
strokeWidth
,
width
,
x
,
y
,
onTransformEnd
,
handleDragEnd
,
})
{
})
{
// TODO check if selectedShapeId is needed
// TODO check if selectedShapeId is needed
const
shapeRef
=
useRef
();
const
shapeRef
=
useRef
();
...
@@ -20,22 +17,15 @@ function Freehand({
...
@@ -20,22 +17,15 @@ function Freehand({
}
}
},
[
isSelected
,
shape
]);
},
[
isSelected
,
shape
]);
/** */
/** */
const
handleClick
=
()
=>
{
const
handleClick
=
()
=>
{
onShapeClick
(
shape
);
onShapeClick
(
shape
);
};
};
return
(
return
(
<>
<>
<
Group
<
Group
ref
=
{
shapeRef
}
ref
=
{
shapeRef
}
// x={ 0}
// y={ 0}
onClick
=
{
handleClick
}
onClick
=
{
handleClick
}
onTransformEnd
=
{
onTransformEnd
}
onTransformEnd
=
{
onTransformEnd
}
scaleX
=
{
shape
.
scaleX
}
scaleX
=
{
shape
.
scaleX
}
...
@@ -46,22 +36,19 @@ function Freehand({
...
@@ -46,22 +36,19 @@ function Freehand({
width
=
{
shape
.
width
||
1920
}
width
=
{
shape
.
width
||
1920
}
height
=
{
shape
.
height
||
1080
}
height
=
{
shape
.
height
||
1080
}
onDragEnd
=
{
handleDragEnd
}
onDragEnd
=
{
handleDragEnd
}
>
>
{
shape
.
lines
.
map
((
line
,
i
)
=>
(
{
shape
.
lines
.
map
((
line
,
i
)
=>
(
<
Line
<
Line
key
=
{
i
}
key
=
{
i
}
fill
=
{
shape
.
fill
||
'
black
'
}
points
=
{
line
.
points
}
points
=
{
line
.
points
}
stroke
=
{
lin
e
.
stroke
||
'
black
'
}
stroke
=
{
shap
e
.
stroke
||
'
black
'
}
strokeWidth
=
{
15
}
strokeWidth
=
{
15
}
tension
=
{
0.5
}
tension
=
{
0.5
}
lineCap
=
"
round
"
lineCap
=
"
round
"
lineJoin
=
"
round
"
lineJoin
=
"
round
"
/>
/>
))}
))}
<
/Group
>
<
/Group
>
<
Transformer
<
Transformer
ref
=
{
trRef
}
ref
=
{
trRef
}
...
...
This diff is collapsed.
Click to expand it.
src/KonvaDrawing/shapes/ParentComponent.js
+
62
−
38
View file @
153d518f
...
@@ -15,7 +15,7 @@ import ImageShape from './Image';
...
@@ -15,7 +15,7 @@ import ImageShape from './Image';
function
ParentComponent
({
function
ParentComponent
({
shapes
,
onShapeClick
,
selectedShapeId
,
activeTool
,
shapes
,
onShapeClick
,
selectedShapeId
,
activeTool
,
scale
,
width
,
height
,
onTransformEnd
,
handleDragEnd
scale
,
width
,
height
,
onTransformEnd
,
handleDragEnd
,
})
{
})
{
// TODO Simplify these state
// TODO Simplify these state
const
[
selectedShape
,
setSelectedShape
]
=
useState
(
null
);
const
[
selectedShape
,
setSelectedShape
]
=
useState
(
null
);
...
@@ -37,8 +37,6 @@ function ParentComponent({
...
@@ -37,8 +37,6 @@ function ParentComponent({
const
handleShapeClick
=
(
shape
)
=>
{
const
handleShapeClick
=
(
shape
)
=>
{
onShapeClick
(
shape
);
onShapeClick
(
shape
);
setSelectedShape
(
shape
);
setSelectedShape
(
shape
);
};
};
return
(
return
(
...
@@ -47,18 +45,21 @@ function ParentComponent({
...
@@ -47,18 +45,21 @@ function ParentComponent({
height
=
{
height
}
height
=
{
height
}
scaleX
=
{
scale
}
scaleX
=
{
scale
}
scaleY
=
{
scale
}
scaleY
=
{
scale
}
>
>
{
shapes
.
map
((
shape
,
i
)
=>
{
{
shapes
.
map
((
shape
,
i
)
=>
{
const
isSelected
=
selectedShapeId
===
shape
.
id
;
const
isSelected
=
selectedShapeId
===
shape
.
id
;
switch
(
shape
.
type
)
{
switch
(
shape
.
type
)
{
case
'
rectangle
'
:
case
'
rectangle
'
:
return
(
return
(
<
Rectangle
<
Rectangle
{...{
{...{
...
shape
,
activeTool
,
isSelected
,
onShapeClick
:
handleShapeClick
,
shape
,
...
shape
,
onTransformEnd
,
handleDragEnd
activeTool
,
isSelected
,
onShapeClick
:
handleShapeClick
,
shape
,
onTransformEnd
,
handleDragEnd
,
}}
}}
key
=
{
i
}
key
=
{
i
}
/
>
/
>
...
@@ -67,8 +68,13 @@ function ParentComponent({
...
@@ -67,8 +68,13 @@ function ParentComponent({
return
(
return
(
<
TextNode
<
TextNode
{...{
{...{
...
shape
,
activeTool
,
isSelected
,
onShapeClick
:
handleShapeClick
,
shape
,
...
shape
,
onTransformEnd
,
handleDragEnd
activeTool
,
isSelected
,
onShapeClick
:
handleShapeClick
,
shape
,
onTransformEnd
,
handleDragEnd
,
}}
}}
key
=
{
i
}
key
=
{
i
}
/
>
/
>
...
@@ -77,8 +83,13 @@ function ParentComponent({
...
@@ -77,8 +83,13 @@ function ParentComponent({
return
(
return
(
<
EllipseNode
<
EllipseNode
{...{
{...{
...
shape
,
activeTool
,
isSelected
,
onShapeClick
:
handleShapeClick
,
shape
,
...
shape
,
onTransformEnd
,
handleDragEnd
activeTool
,
isSelected
,
onShapeClick
:
handleShapeClick
,
shape
,
onTransformEnd
,
handleDragEnd
,
}}
}}
key
=
{
i
}
key
=
{
i
}
/
>
/
>
...
@@ -87,8 +98,13 @@ function ParentComponent({
...
@@ -87,8 +98,13 @@ function ParentComponent({
return
(
return
(
<
Freehand
<
Freehand
{...{
{...{
...
shape
,
activeTool
,
isSelected
,
onShapeClick
:
handleShapeClick
,
shape
,
...
shape
,
onTransformEnd
,
handleDragEnd
activeTool
,
isSelected
,
onShapeClick
:
handleShapeClick
,
shape
,
onTransformEnd
,
handleDragEnd
,
}}
}}
key
=
{
i
}
key
=
{
i
}
/
>
/
>
...
@@ -97,13 +113,17 @@ function ParentComponent({
...
@@ -97,13 +113,17 @@ function ParentComponent({
return
(
return
(
<
Polygon
<
Polygon
{...{
{...{
...
shape
,
activeTool
,
isSelected
,
onShapeClick
:
handleShapeClick
,
shape
,
...
shape
,
onTransformEnd
,
handleDragEnd
activeTool
,
isSelected
,
onShapeClick
:
handleShapeClick
,
shape
,
onTransformEnd
,
handleDragEnd
,
}}
}}
key
=
{
i
}
key
=
{
i
}
/
>
/
>
);
);
case
'
arrow
'
:
case
'
arrow
'
:
return
(
return
(
<
ArrowNode
<
ArrowNode
...
@@ -113,19 +133,23 @@ function ParentComponent({
...
@@ -113,19 +133,23 @@ function ParentComponent({
isSelected
,
isSelected
,
onShapeClick
:
handleShapeClick
,
onShapeClick
:
handleShapeClick
,
shape
,
shape
,
onTransformEnd
,
handleDragEnd
onTransformEnd
,
handleDragEnd
,
}}
}}
key
=
{
i
}
key
=
{
i
}
/
>
/
>
);
);
case
'
image
'
:
case
'
image
'
:
return
(
return
(
<
ImageShape
<
ImageShape
{...{
{...{
...
shape
,
activeTool
,
isSelected
,
onShapeClick
:
handleShapeClick
,
shape
,
...
shape
,
onTransformEnd
,
handleDragEnd
,
activeTool
,
isSelected
,
onShapeClick
:
handleShapeClick
,
shape
,
onTransformEnd
,
handleDragEnd
,
src
:
shape
.
src
,
src
:
shape
.
src
,
}}
}}
key
=
{
i
}
key
=
{
i
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment