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
acf3fc87
Commit
acf3fc87
authored
Jan 24, 2024
by
Anthony
Browse files
Options
Downloads
Plain Diff
Merge branch 'wip-konvas-2' into mui5-tetras-main-stable
# Conflicts: # src/AnnotationDrawing.js
parents
97aa926c
b6e6288e
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!10
Draft: MigratingAnnotationCreation to MUI5.
Pipeline
#1766
failed
Jan 24, 2024
Stage: test
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/AnnotationDrawing.js
+95
-82
95 additions, 82 deletions
src/AnnotationDrawing.js
src/shapes/ParentComponent.js
+4
-3
4 additions, 3 deletions
src/shapes/ParentComponent.js
src/shapes/Polygon.js
+8
-6
8 additions, 6 deletions
src/shapes/Polygon.js
with
107 additions
and
91 deletions
src/AnnotationDrawing.js
+
95
−
82
View file @
acf3fc87
...
...
@@ -27,7 +27,7 @@ function AnnotationDrawing(props) {
/** Debug function facility */
const
debug
=
(
command
)
=>
{
if
(
config
.
debugMode
)
{
//
if(config.debugMode) {
console
.
debug
(
'
***************************
'
);
console
.
debug
(
command
);
console
.
debug
(
'
shapes
'
,
shapes
);
...
...
@@ -36,7 +36,7 @@ function AnnotationDrawing(props) {
console
.
debug
(
'
isDrawing
'
,
isDrawing
);
console
.
debug
(
'
props.activeTool
'
,
props
.
activeTool
);
console
.
debug
(
'
-----------------------------
'
);
}
//
}
};
/** */
...
...
@@ -100,9 +100,14 @@ function AnnotationDrawing(props) {
const
newShapes
=
shapes
.
filter
((
shape
)
=>
shape
.
id
!==
currentShape
.
id
);
setShapes
(
newShapes
);
setCurrentShape
(
null
);
// get latest shape in the list
const
newCurrentShape
=
newShapes
[
newShapes
.
length
-
1
];
setCurrentShape
(
newShapes
.
length
>
0
?
newCurrentShape
:
null
);
updateCurrentShapeInShapes
();
window
.
removeEventListener
(
'
keydown
'
,
handleKeyPress
);
// window.removeEventListener('keydown', handleKeyPress);
return
;
}
...
...
@@ -148,6 +153,10 @@ function AnnotationDrawing(props) {
const
handleMouseDown
=
(
e
)
=>
{
try
{
const
pos
=
e
.
target
.
getStage
().
getPointerPosition
();
const
relativePos
=
e
.
target
.
getStage
().
getRelativePointerPosition
();
// debug('mouse down debut');
...
...
@@ -216,20 +225,21 @@ function AnnotationDrawing(props) {
// window.addEventListener('keydown', handleKeyPress);
break
;
case
'
freehand
'
:
case
'
polygon
'
:
setIsDrawing
(
true
);
// eslint-disable-next-line no-case-declarations
const
tool
=
'
pen
'
;
shape
=
{
fill
:
props
.
fillColor
,
height
:
10
,
stroke
:
props
.
strokeColor
,
id
:
uuidv4
(),
lines
:
[
pos
.
x
,
pos
.
y
],
points
:
[
0
,
0
,
0
,
0
,
0
,
0
],
type
:
'
freehand
'
,
width
:
10
,
x
:
pos
.
x
,
y
:
pos
.
y
,
points
:
[
pos
.
x
,
pos
.
y
],
type
:
'
polygon
'
,
x
:
0
,
y
:
0
,
};
// shape = {
// fill: props.fillColor,
...
...
@@ -253,6 +263,7 @@ function AnnotationDrawing(props) {
case
"
arrow
"
:
setIsDrawing
(
true
);
shape
=
{
fill
:
props
.
fillColor
||
"
red
"
,
stroke
:
props
.
fillColor
||
"
red
"
,
...
...
@@ -260,9 +271,11 @@ function AnnotationDrawing(props) {
pointerWidth
:
20
,
id
:
uuidv4
(),
points
:
[
pos
.
x
,
pos
.
y
,
pos
.
x
,
pos
.
y
],
type
:
'
arrow
'
,
type
:
'
arrow
'
};
setShapes
([...
shapes
,
shape
]);
setCurrentShape
(
shape
);
...
...
@@ -334,18 +347,16 @@ function AnnotationDrawing(props) {
updateCurrentShapeInShapes
();
break
;
case
'
freehand
'
:
case
'
polygon
'
:
const
freehand
Shape
=
{...
currentShape
}
const
polygon
Shape
=
{
...
currentShape
}
freehandShape
.
points
.
push
(
pos
.
x
);
freehandShape
.
points
.
push
(
pos
.
y
);
polygonShape
.
points
[
2
]
=
pos
.
x
;
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
();
...
...
@@ -367,6 +378,9 @@ function AnnotationDrawing(props) {
updateCurrentShapeInShapes
();
break
;
break
;
default
:
break
;
}
...
...
@@ -393,7 +407,6 @@ function AnnotationDrawing(props) {
// updateCurrentShapeInShapes();
//setCurrentShape(null);
}
catch
(
error
)
{
...
...
This diff is collapsed.
Click to expand it.
src/shapes/ParentComponent.js
+
4
−
3
View file @
acf3fc87
...
...
@@ -2,12 +2,13 @@ import React, { useState, useEffect } from 'react';
import
PropTypes
from
'
prop-types
'
;
import
{
Layer
}
from
'
react-konva
'
;
import
FreeHand
from
'
./FreeHand
'
;
import
Rectangle
from
'
./Rectangle
'
;
import
EllipseNode
from
'
./EllipseNode
'
;
import
TextNode
from
'
./TextNode
'
;
import
LineNode
from
'
./LineNode
'
;
import
ArrowNode
from
'
./ArrowNode
'
;
import
Polygon
from
'
./Polygon
'
;
/** Loads Konva and display in function of their type */
...
...
@@ -80,9 +81,9 @@ function ParentComponent({
key
=
{
i
}
/
>
);
case
'
line
'
:
case
'
polygon
'
:
return
(
<
LineNode
<
Polygon
{...{
...
shape
,
activeTool
,
isSelected
,
onShapeClick
:
handleShapeClick
,
shape
,
}}
...
...
This diff is collapsed.
Click to expand it.
src/shapes/
FreeHand
.js
→
src/shapes/
Polygon
.js
+
8
−
6
View file @
acf3fc87
...
...
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import
{
Transformer
,
Shape
,
Line
}
from
'
react-konva
'
;
/** FreeHand shape displaying */
function
FreeHand
({
function
Polygon
({
activeTool
,
fill
,
height
,
onShapeClick
,
points
,
isSelected
,
shape
,
stroke
,
strokeWidth
,
width
,
x
,
y
,
})
{
// TODO check if selectedShapeId is needed
...
...
@@ -25,12 +25,13 @@ function FreeHand({
};
return
(
<>
<
Line
ref
=
{
shapeRef
}
id
=
{
shape
.
id
}
points
=
{
shape
.
l
in
e
s
}
stroke
=
"
#df4b26
"
points
=
{
shape
.
po
in
t
s
}
stroke
=
{
shape
.
stroke
||
'
black
'
}
strokeWidth
=
{
5
}
tension
=
{
0.5
}
lineCap
=
"
round
"
...
...
@@ -38,6 +39,7 @@ function FreeHand({
closed
=
{
false
}
onClick
=
{
handleClick
}
fill
=
{
fill
||
'
red
'
}
draggable
=
{
activeTool
===
'
cursor
'
||
activeTool
===
'
edit
'
}
globalCompositeOperation
=
"
source-over
"
/>
...
...
@@ -49,7 +51,7 @@ function FreeHand({
);
}
FreeHand
.
propTypes
=
{
Polygon
.
propTypes
=
{
activeTool
:
PropTypes
.
string
.
isRequired
,
fill
:
PropTypes
.
string
,
height
:
PropTypes
.
number
,
...
...
@@ -61,7 +63,7 @@ FreeHand.propTypes = {
width
:
PropTypes
.
number
,
};
FreeHand
.
defaultProps
=
{
Polygon
.
defaultProps
=
{
fill
:
'
red
'
,
height
:
1080
,
points
:
[
0
,
0
,
100
,
0
,
100
,
100
],
...
...
@@ -70,4 +72,4 @@ FreeHand.defaultProps = {
width
:
1920
,
};
export
default
FreeHand
;
export
default
Polygon
;
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