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
dc5af89b
Commit
dc5af89b
authored
Jan 24, 2024
by
Samuel Jugnet
Browse files
Options
Downloads
Patches
Plain Diff
polygon + get latest shape after delete
parent
ede3d6f5
Branches
Branches containing commit
No related tags found
1 merge request
!10
Draft: MigratingAnnotationCreation to MUI5.
Pipeline
#1761
failed
Jan 24, 2024
Stage: test
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/AnnotationDrawing.js
+21
-19
21 additions, 19 deletions
src/AnnotationDrawing.js
src/shapes/ParentComponent.js
+4
-3
4 additions, 3 deletions
src/shapes/ParentComponent.js
src/shapes/Polygon.js
+4
-2
4 additions, 2 deletions
src/shapes/Polygon.js
with
29 additions
and
24 deletions
src/AnnotationDrawing.js
+
21
−
19
View file @
dc5af89b
...
@@ -100,9 +100,12 @@ function AnnotationDrawing(props) {
...
@@ -100,9 +100,12 @@ function AnnotationDrawing(props) {
const
newShapes
=
shapes
.
filter
((
shape
)
=>
shape
.
id
!==
currentShape
.
id
);
const
newShapes
=
shapes
.
filter
((
shape
)
=>
shape
.
id
!==
currentShape
.
id
);
setShapes
(
newShapes
);
setShapes
(
newShapes
);
setCurrentShape
(
null
);
// get latest shape in the list
const
newCurrentShape
=
newShapes
[
newShapes
.
length
-
1
];
setCurrentShape
(
newShapes
.
length
>
0
?
newCurrentShape
:
null
);
window
.
removeEventListener
(
'
keydown
'
,
handleKeyPress
);
// window.removeEventListener('keydown', handleKeyPress);
return
;
return
;
}
}
...
@@ -220,20 +223,21 @@ function AnnotationDrawing(props) {
...
@@ -220,20 +223,21 @@ function AnnotationDrawing(props) {
// window.addEventListener('keydown', handleKeyPress);
// window.addEventListener('keydown', handleKeyPress);
break
;
break
;
case
'
freehand
'
:
case
'
polygon
'
:
setIsDrawing
(
true
);
setIsDrawing
(
true
);
// eslint-disable-next-line no-case-declarations
// eslint-disable-next-line no-case-declarations
const
tool
=
'
pen
'
;
shape
=
{
shape
=
{
fill
:
props
.
fillColor
,
fill
:
props
.
fillColor
,
height
:
10
,
stroke
:
props
.
strokeColor
,
id
:
uuidv4
(),
id
:
uuidv4
(),
lines
:
[
pos
.
x
,
pos
.
y
],
points
:
[
0
,
0
,
0
,
0
,
0
,
0
],
points
:
[
pos
.
x
,
pos
.
y
],
type
:
'
freehand
'
,
type
:
'
polygon
'
,
width
:
10
,
x
:
pos
.
x
,
x
:
0
,
y
:
pos
.
y
,
y
:
0
,
};
};
// shape = {
// shape = {
// fill: props.fillColor,
// fill: props.fillColor,
...
@@ -341,18 +345,16 @@ function AnnotationDrawing(props) {
...
@@ -341,18 +345,16 @@ function AnnotationDrawing(props) {
updateCurrentShapeInShapes
();
updateCurrentShapeInShapes
();
break
;
break
;
case
'
freehand
'
:
case
'
polygon
'
:
const
freehand
Shape
=
{...
currentShape
}
const
polygon
Shape
=
{...
currentShape
}
freehandShape
.
points
.
push
(
pos
.
x
);
polygonShape
.
points
[
2
]
=
pos
.
x
;
freehandShape
.
points
.
push
(
pos
.
y
);
polygonShape
.
points
[
3
]
=
pos
.
y
;
setCurrentShape
(
polygonShape
);
setCurrentShape
(
freehandShape
);
// setShapes(shapes.map((shape) => (shape.id === currentShape.id
// ? { ...shape, points: [...shape.points, e.evt.clientX, e.evt.clientY] }
// : shape)));
updateCurrentShapeInShapes
();
updateCurrentShapeInShapes
();
...
...
This diff is collapsed.
Click to expand it.
src/shapes/ParentComponent.js
+
4
−
3
View file @
dc5af89b
...
@@ -2,12 +2,13 @@ import React, { useState, useEffect } from 'react';
...
@@ -2,12 +2,13 @@ import React, { useState, useEffect } from 'react';
import
PropTypes
from
'
prop-types
'
;
import
PropTypes
from
'
prop-types
'
;
import
{
Layer
}
from
'
react-konva
'
;
import
{
Layer
}
from
'
react-konva
'
;
import
FreeHand
from
'
./FreeHand
'
;
import
Rectangle
from
'
./Rectangle
'
;
import
Rectangle
from
'
./Rectangle
'
;
import
EllipseNode
from
'
./EllipseNode
'
;
import
EllipseNode
from
'
./EllipseNode
'
;
import
TextNode
from
'
./TextNode
'
;
import
TextNode
from
'
./TextNode
'
;
import
LineNode
from
'
./LineNode
'
;
import
LineNode
from
'
./LineNode
'
;
import
ArrowNode
from
'
./ArrowNode
'
;
import
ArrowNode
from
'
./ArrowNode
'
;
import
Polygon
from
'
./Polygon
'
;
/** Loads Konva and display in function of their type */
/** Loads Konva and display in function of their type */
...
@@ -80,9 +81,9 @@ function ParentComponent({
...
@@ -80,9 +81,9 @@ function ParentComponent({
key
=
{
i
}
key
=
{
i
}
/
>
/
>
);
);
case
'
line
'
:
case
'
polygon
'
:
return
(
return
(
<
LineNode
<
Polygon
{...{
{...{
...
shape
,
activeTool
,
isSelected
,
onShapeClick
:
handleShapeClick
,
shape
,
...
shape
,
activeTool
,
isSelected
,
onShapeClick
:
handleShapeClick
,
shape
,
}}
}}
...
...
This diff is collapsed.
Click to expand it.
src/shapes/
FreeHand
.js
→
src/shapes/
Polygon
.js
+
4
−
2
View file @
dc5af89b
...
@@ -25,12 +25,13 @@ function FreeHand({
...
@@ -25,12 +25,13 @@ function FreeHand({
};
};
return
(
return
(
console
.
log
(
"
FreeHand shape
"
,
shape
),
<>
<>
<
Line
<
Line
ref
=
{
shapeRef
}
ref
=
{
shapeRef
}
id
=
{
shape
.
id
}
id
=
{
shape
.
id
}
points
=
{
shape
.
l
in
e
s
}
points
=
{
shape
.
po
in
t
s
}
stroke
=
"
#df4b26
"
stroke
=
{
shape
.
stroke
||
'
black
'
}
strokeWidth
=
{
5
}
strokeWidth
=
{
5
}
tension
=
{
0.5
}
tension
=
{
0.5
}
lineCap
=
"
round
"
lineCap
=
"
round
"
...
@@ -38,6 +39,7 @@ function FreeHand({
...
@@ -38,6 +39,7 @@ function FreeHand({
closed
=
{
false
}
closed
=
{
false
}
onClick
=
{
handleClick
}
onClick
=
{
handleClick
}
fill
=
{
fill
||
'
red
'
}
fill
=
{
fill
||
'
red
'
}
draggable
=
{
activeTool
===
'
cursor
'
||
activeTool
===
'
edit
'
}
globalCompositeOperation
=
"
source-over
"
globalCompositeOperation
=
"
source-over
"
/>
/>
...
...
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