Skip to content
Snippets Groups Projects
Commit 91da490b authored by Samuel Jugnet's avatar Samuel Jugnet
Browse files

fix polygon

parent dc5af89b
Branches
No related tags found
1 merge request!10Draft: MigratingAnnotationCreation to MUI5.
Pipeline #1762 failed
...@@ -80,10 +80,19 @@ function AnnotationDrawing(props) { ...@@ -80,10 +80,19 @@ function AnnotationDrawing(props) {
/** */ /** */
const onShapeClick = async (shape) => { const onShapeClick = async (shape) => {
setSelectedShapeId(shape.id); setSelectedShapeId(shape.id);
// find shape by id // find shape by id
setCurrentShape(shapes.find((s) => s.id === shape.id)); setCurrentShape(shapes.find((s) => s.id === shape.id));
props.setShapeProperties(shape); props.setShapeProperties(shape);
// place shape on top
const newShapes = shapes.filter((s) => s.id !== shape.id); // remove shape from the list
newShapes.push(shape); // add shape to the end of the list
}; };
/** */ /** */
......
...@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; ...@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import {Transformer, Shape, Line} from 'react-konva'; import {Transformer, Shape, Line} from 'react-konva';
/** FreeHand shape displaying */ /** FreeHand shape displaying */
function FreeHand({ function Polygon({
activeTool, fill, height, onShapeClick, points, isSelected, shape, stroke, strokeWidth, width, x, y, activeTool, fill, height, onShapeClick, points, isSelected, shape, stroke, strokeWidth, width, x, y,
}) { }) {
// TODO check if selectedShapeId is needed // TODO check if selectedShapeId is needed
...@@ -25,7 +25,7 @@ function FreeHand({ ...@@ -25,7 +25,7 @@ function FreeHand({
}; };
return ( return (
console.log("FreeHand shape", shape),
<> <>
<Line <Line
ref={shapeRef} ref={shapeRef}
...@@ -51,7 +51,7 @@ function FreeHand({ ...@@ -51,7 +51,7 @@ function FreeHand({
); );
} }
FreeHand.propTypes = { Polygon.propTypes = {
activeTool: PropTypes.string.isRequired, activeTool: PropTypes.string.isRequired,
fill: PropTypes.string, fill: PropTypes.string,
height: PropTypes.number, height: PropTypes.number,
...@@ -63,7 +63,7 @@ FreeHand.propTypes = { ...@@ -63,7 +63,7 @@ FreeHand.propTypes = {
width: PropTypes.number, width: PropTypes.number,
}; };
FreeHand.defaultProps = { Polygon.defaultProps = {
fill: 'red', fill: 'red',
height: 1080, height: 1080,
points: [0, 0, 100, 0, 100, 100], points: [0, 0, 100, 0, 100, 100],
...@@ -72,4 +72,4 @@ FreeHand.defaultProps = { ...@@ -72,4 +72,4 @@ FreeHand.defaultProps = {
width: 1920, width: 1920,
}; };
export default FreeHand; export default Polygon;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment