From a14ab6db52ca6d1203545786c9629223ee14f510 Mon Sep 17 00:00:00 2001
From: Antoine <antoine.roy@tetras-libre.fr>
Date: Fri, 2 Feb 2024 18:48:48 +0100
Subject: [PATCH] wip-wip-positionement-annot

---
 src/AnnotationCreation.js               | 14 +++++++++++++-
 src/annotationForm/AnnotationDrawing.js |  7 ++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/AnnotationCreation.js b/src/AnnotationCreation.js
index 0dc620f..9b06ae4 100644
--- a/src/AnnotationCreation.js
+++ b/src/AnnotationCreation.js
@@ -115,6 +115,7 @@ function AnnotationCreation(props) {
       valueTime: [0, 1],
       valuetextTime: '',
       textBody: '',
+      xywh: annoState.xywh ? annoState.xywh: 'undefined',
     };
   });
 
@@ -124,7 +125,7 @@ function AnnotationCreation(props) {
 
   const [viewTool, setViewTool] = useState(TARGET_VIEW);
   const { height, width } = props.mediaVideo ? props.mediaVideo : 0;
-
+  const [shape, setShape ] = useState({})
   // TODO Check the effect to keep and remove the other
   // Add a state to trigger redraw
   const [windowSize, setWindowSize] = useState({
@@ -134,6 +135,7 @@ function AnnotationCreation(props) {
 
   // Listen to window resize event
   useEffect(() => {
+    console.log(state)
     const handleResize = () => {
       setWindowSize({
         width: window.innerWidth,
@@ -304,6 +306,9 @@ function AnnotationCreation(props) {
     }
   };*/
 
+ const setMyShape = (shape) =>{
+    setShape(shape);
+  }
   /**
      * Validate form and save annotation
      */
@@ -345,6 +350,12 @@ function AnnotationCreation(props) {
       image,
       konvaThing,
     } = state;
+    console.log(shape)
+    // if(xywh === "undefined"){
+    //   setState({...state.xywh = {x: state.shape[0].x, y: state.shape[0].y, w: state.shape[0].width, h: state.shape[0].height}})
+    // }
+console.log('SUBMITFORM XYWH',state.xywh)
+    console.log('xywh',xywh)
     // TODO rename variable for better comprenhension
     const svg = await getSvg();
     const t = (tstart && tend) ? `${tstart},${tend}` : null;
@@ -478,6 +489,7 @@ function AnnotationCreation(props) {
         isMouseOverSave={isMouseOverSave}
         mediaVideo={props.mediaVideo}
         setDrawingState={setDrawingState}
+        setMyShape={setMyShape()}
       />
       <StyledForm
         onSubmit={submitForm}
diff --git a/src/annotationForm/AnnotationDrawing.js b/src/annotationForm/AnnotationDrawing.js
index e214bcf..d74bd8f 100644
--- a/src/annotationForm/AnnotationDrawing.js
+++ b/src/annotationForm/AnnotationDrawing.js
@@ -83,7 +83,12 @@ function AnnotationDrawing({ drawingState, setDrawingState, ...props }) {
           strokeWidth: drawingState.currentShape.strokeWidth,
         },
       );
-
+      let previousShapes
+      if (drawingState.shapes !== previousShapes) {
+        props.setMyShape(drawingState.shapes);
+      console.log(props.shape, 'ANNOT D')
+        previousShapes = drawingState.shapes
+      }
       return () => {
         window.removeEventListener('keydown', handleKeyPress);
       };
-- 
GitLab