lost-sia 2.0.1-alpha11 → 2.0.1-alpha13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Annotation/ui/atoms/AnnoBar.js +1 -1
- package/dist/Annotation/ui/atoms/Edge.js +1 -1
- package/dist/Annotation/ui/atoms/Node.js +1 -1
- package/dist/Annotation/ui/tools/BBox.js +1 -1
- package/dist/Annotation/ui/tools/Line.js +1 -1
- package/dist/Annotation/ui/tools/Polygon.js +1 -1
- package/dist/Canvas/Canvas.d.ts +2 -1
- package/dist/Canvas/Canvas.js +1 -1
- package/dist/Sia.js +1 -1
- package/dist/Toolbar/Toolbar.js +1 -1
- package/dist/index.d.ts +0 -9
- package/dist/index.js +1 -1
- package/dist/models/KeyAction.d.ts +2 -1
- package/dist/models/KeyAction.js +1 -1
- package/dist/stories/Canvas/Canvas.stories.d.ts +2 -1
- package/dist/utils/KeyMapper.js +1 -1
- package/dist/utils/mouse.js +1 -1
- package/dist/utils/siaIcons.js +5 -5
- package/dist/utils/transform.js +1 -1
- package/dist/utils/windowViewport.d.ts +22 -0
- package/dist/utils/windowViewport.js +1 -1
- package/package.json +9 -8
- package/src/Annotation/ui/atoms/AnnoBar.tsx +46 -46
- package/src/Annotation/ui/atoms/Edge.tsx +23 -23
- package/src/Annotation/ui/atoms/Node.tsx +51 -51
- package/src/Annotation/ui/tools/BBox.tsx +129 -145
- package/src/Annotation/ui/tools/Line.tsx +81 -87
- package/src/Annotation/ui/tools/Polygon.tsx +92 -95
- package/src/Canvas/Canvas.tsx +369 -397
- package/src/InfoBoxes/AnnoStats.jsx +1 -1
- package/src/InfoBoxes/InfoBoxArea.jsx +32 -34
- package/src/{Sia2.tsx → Sia.tsx} +156 -175
- package/src/Toolbar/Toolbar.tsx +4 -4
- package/src/index.ts +6 -17
- package/src/models/KeyAction.ts +1 -0
- package/src/stories/AnnotationTools.stories.tsx +21 -21
- package/src/stories/Canvas/Canvas.stories.tsx +31 -26
- package/src/stories/Canvas/CanvasOffset.tsx +23 -25
- package/src/stories/MinimalSia.stories.tsx +22 -22
- package/src/stories/SIA2/DemoWrapper.tsx +20 -24
- package/src/stories/SIA2/Sia2.stories.tsx +24 -24
- package/src/utils/KeyMapper.ts +3 -0
- package/src/utils/siaIcons.jsx +5 -7
- package/src/utils/windowViewport.ts +34 -0
- package/dist/AnnoExampleViewer.js +0 -1
- package/dist/AnnoLabelInput.js +0 -1
- package/dist/AnnoToolBar.js +0 -19
- package/dist/Annotation/AnnoBar.js +0 -1
- package/dist/Annotation/Annotation.js +0 -1
- package/dist/Annotation/BBox.js +0 -1
- package/dist/Annotation/Edge.js +0 -1
- package/dist/Annotation/InfSelectionArea.js +0 -1
- package/dist/Annotation/Line.js +0 -1
- package/dist/Annotation/Node.js +0 -1
- package/dist/Annotation/Point.js +0 -1
- package/dist/Annotation/Polygon.js +0 -1
- package/dist/Canvas.js +0 -1
- package/dist/ImgBar.js +0 -1
- package/dist/InfoBoxes/AnnoDetails.js +0 -1
- package/dist/InfoBoxes/AnnoStats.js +0 -1
- package/dist/InfoBoxes/InfoBox.js +0 -1
- package/dist/InfoBoxes/InfoBoxArea.js +0 -1
- package/dist/InfoBoxes/LabelInfo.js +0 -1
- package/dist/LabelInput.js +0 -1
- package/dist/Prompt.js +0 -1
- package/dist/SIAFilterButton.js +0 -1
- package/dist/SIASettingButton.js +0 -1
- package/dist/Sia2.js +0 -1
- package/dist/SiaPopup.js +0 -1
- package/dist/ToolBar.js +0 -1
- package/dist/ToolbarItem.js +0 -1
- package/dist/_virtual/_commonjsHelpers.js +0 -1
- package/dist/_virtual/lodash.js +0 -1
- package/dist/assets/Annotation/Annotation-Cd5Ua5TG.css +0 -1
- package/dist/assets/Toolbar-Cp1xyYeH.css +0 -1
- package/dist/filterTools.js +0 -1
- package/dist/siaDummyData.js +0 -7
- package/dist/stories/Canvas/CanvasOffset.js +0 -1
- package/dist/stories/FilterDropdown.stories.js +0 -1
- package/dist/stories/SIA/SIA.stories.d.ts +0 -36
- package/dist/stories/SIA2/DemoWrapper.js +0 -1
- package/dist/stories/Toolbar/ImageTools/ImageLabel.stories.d.ts +0 -13
- package/dist/stories/siaDummyData.js +0 -1
- package/dist/stories/siaDummyData2.js +0 -7
- package/dist/types/annoStatus.js +0 -1
- package/dist/types/canvasActions.js +0 -1
- package/dist/types/cursorstyles.js +0 -1
- package/dist/types/modes.js +0 -1
- package/dist/types/notificationType.js +0 -1
- package/dist/types/toolbarEvents.js +0 -1
- package/dist/types/tools.js +0 -1
- package/dist/utils/annoConversion.js +0 -1
- package/dist/utils/annoConversion2.d.ts +0 -27
- package/dist/utils/annoConversion2.js +0 -1
- package/dist/utils/colorlut.js +0 -1
- package/dist/utils/constraints.js +0 -1
- package/dist/utils/hist.js +0 -1
- package/dist/utils/keyActions.js +0 -1
- package/dist/utils/mouse2.js +0 -1
- package/dist/utils/transform2.js +0 -1
- package/src/AnnoLabelInput.jsx +0 -109
- package/src/AnnoToolBar.jsx +0 -153
- package/src/Annotation/AnnoBar.jsx +0 -154
- package/src/Annotation/Annotation.jsx +0 -395
- package/src/Annotation/Annotation.scss +0 -47
- package/src/Annotation/BBox.jsx +0 -299
- package/src/Annotation/Edge.jsx +0 -92
- package/src/Annotation/InfSelectionArea.jsx +0 -72
- package/src/Annotation/Line.jsx +0 -68
- package/src/Annotation/Node.jsx +0 -282
- package/src/Annotation/Point.jsx +0 -200
- package/src/Annotation/Polygon.jsx +0 -404
- package/src/Canvas.jsx +0 -2194
- package/src/ImgBar.jsx +0 -131
- package/src/LabelInput.jsx +0 -238
- package/src/Prompt.jsx +0 -45
- package/src/SIAFilterButton.jsx +0 -186
- package/src/Sia.jsx +0 -478
- package/src/SiaPopup.jsx +0 -15
- package/src/ToolBar.jsx +0 -463
- package/src/Toolbar/ToolbarItem.jsx +0 -30
- package/src/Toolbar.css +0 -13
- package/src/ToolbarItem.jsx +0 -31
- package/src/filterTools.js +0 -5
- package/src/stories/SIA/SIA.stories.tsx +0 -64
- package/src/stories/Toolbar/ImageTools/ImageLabel.stories.tsx +0 -31
- package/src/stories/lost.js +0 -54
- package/src/stories/store.js +0 -18
- package/src/test.js +0 -7
- package/src/types/annoStatus.js +0 -4
- package/src/types/canvasActions.js +0 -58
- package/src/types/cursorstyles.js +0 -3
- package/src/types/modes.js +0 -9
- package/src/types/notificationType.js +0 -11
- package/src/types/toolbarEvents.js +0 -35
- package/src/types/tools.js +0 -17
- package/src/utils/annoConversion.js +0 -145
- package/src/utils/annoConversion2.ts +0 -145
- package/src/utils/colorlut.js +0 -68
- package/src/utils/constraints.js +0 -81
- package/src/utils/mouse.js +0 -14
- package/src/utils/transform.js +0 -336
- package/src/utils/windowViewport.js +0 -34
- /package/dist/{Sia2.d.ts → Sia.d.ts} +0 -0
- /package/dist/utils/{mouse2.d.ts → mouse.d.ts} +0 -0
- /package/dist/utils/{transform2.d.ts → transform.d.ts} +0 -0
- /package/src/utils/{mouse2.ts → mouse.ts} +0 -0
- /package/src/utils/{transform2.ts → transform.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as _,jsx as x}from"react/jsx-runtime";import{useState as r,useRef as C,useEffect as f}from"react";import T from"../../../utils/
|
|
1
|
+
import{jsxs as _,jsx as x}from"react/jsx-runtime";import{useState as r,useRef as C,useEffect as f}from"react";import T from"../../../utils/transform.js";import H from"./DaviIcon.js";const R=10,a=15,j=3,U=({annotationCoordinates:u,canLabel:y,color:b,labels:E,selectedLabelIds:h=[],isSelected:L,svgScale:t,style:d,onLabelIconClicked:P})=>{const[c,w]=r({x:0,y:0}),e={x:c.x+7/t,y:c.y-10/t},[p,D]=r(0),[z,A]=r(0),[l,B]=r(0),[m,F]=r(""),s=C(null);f(()=>{F(W())},[h]),f(()=>{const o=T.getTopPoint(u),i=T.getMostLeftPoints(o)[0];w(i);const n=Math.ceil(R/t);B(n),A(a/t)},[t]),f(()=>{if(s===void 0)return;const n=(s.current.getBoundingClientRect().width+j)/t;D(n)},[s,m,l]);const W=()=>{const i=E.filter(n=>h.includes(n.id)).map(n=>n.name).join(", ");return i.length?i:"no label"};return _("g",{children:[L&&y&&x(H,{x:e.x-33/t,y:e.y-30/t,color:b,size:60/t,onClick:()=>P(c)}),x("rect",{x:e.x,y:e.y-6/(t*1.2),width:p,height:z,rx:5/t,opacity:"0.5",style:d}),x("text",{x:e.x+1/t,y:e.y+6/t,fill:"white",textAnchor:"start",alignmentBaseline:"central",ref:s,fontSize:`${l}pt`,children:m}),x("rect",{x:e.x,y:e.y-6/(t*1.2),width:p,height:a,rx:5/t,opacity:"0.01",style:d,onContextMenu:o=>o.preventDefault()})]})};export{U as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as i}from"react/jsx-runtime";import d from"../../../utils/
|
|
1
|
+
import{jsx as i}from"react/jsx-runtime";import d from"../../../utils/mouse.js";const S=({startCoordinate:o,endCoordinate:t,isDisabled:s=!1,pageToStageOffset:r,style:n,svgScale:a,svgTranslation:l,onAddNode:u=()=>{},onDoubleClick:x=()=>{},onMouseDown:c,onMouseMove:m})=>{const y=e=>{const f=d.getAntiScaledMouseStagePosition(e,r,a,l);u(f)};return i("line",{x1:o.x,y1:o.y,x2:t.x,y2:t.y,style:n,onClick:e=>e.ctrlKey&&y(e),onDoubleClick:x,onMouseDown:c,onMouseMove:m,onContextMenu:e=>e.preventDefault(),strokeDasharray:s?"10,5":"0"})};export{S as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as H,jsx as u}from"react/jsx-runtime";import{useState as c,useRef as h,useEffect as m}from"react";import L from"../../../utils/
|
|
1
|
+
import{jsxs as H,jsx as u}from"react/jsx-runtime";import{useState as c,useRef as h,useEffect as m}from"react";import L from"../../../utils/mouse.js";const K=({index:v,coordinates:t,annotationSettings:o,pageToStageOffset:x,svgScale:r,svgTranslation:y,style:p,onDeleteNode:D,onMoving:I,onMoved:g,onIsDraggingStateChanged:A})=>{const[E,i]=c(!1),[n,l]=c(!1),[s,a]=c(!1),f=h(s);m(()=>{f.current=s},[s]);const M=e=>{if(!n)return;const C=L.getAntiScaledMouseStagePosition(e,x,r,y);(e.movementX!==0||e.movementY!==0)&&(a(!0),I(v,C))};m(()=>{if(A(n),!n)return;const e=()=>{l(!1),f.current&&g(),a(!1)};return window.addEventListener("mouseup",e),()=>{window.removeEventListener("mouseup",e)}},[n]);const d=e=>{o.canEdit&&(e.ctrlKey?D():l(!0))},w=()=>u("circle",{cx:t.x,cy:t.y,r:12/r,onMouseLeave:e=>o.canEdit&&i(!1),onMouseDown:d,onContextMenu:e=>e.preventDefault()});return H("g",{children:[n&&u("circle",{cx:t.x,cy:t.y,r:"100%",style:{opacity:0},onMouseMove:e=>M(e),onContextMenu:e=>e.preventDefault()}),E&&w(),u("circle",{cx:t.x,cy:t.y,r:10/r,style:p,onMouseOver:()=>{o.canEdit&&i(!0)},onMouseDown:d,onMouseMove:e=>M(e),onContextMenu:e=>e.preventDefault()})]})};export{K as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as H,jsx as v}from"react/jsx-runtime";import{useState as l,useRef as J,useEffect as x}from"react";import K from"../atoms/Node.js";import d from"../../../models/AnnotationMode.js";import Q from"../../../utils/
|
|
1
|
+
import{jsxs as H,jsx as v}from"react/jsx-runtime";import{useState as l,useRef as J,useEffect as x}from"react";import K from"../atoms/Node.js";import d from"../../../models/AnnotationMode.js";import Q from"../../../utils/mouse.js";import V from"../atoms/PolygonArea.js";import W from"../atoms/Edge.js";const re=({annotationMode:m,annotationSettings:i,pageToStageOffset:w,startCoords:R,endCoords:b,svgScale:s,svgTranslation:C,isSelected:E,style:M,onDeleteNode:j,onFinishAnnoCreate:z,onIsDraggingStateChanged:p,onMoving:A,onMoved:k})=>{const n=[R,{x:R.x,y:b.y},b,{x:b.x,y:R.y}],[L,B]=l(m===d.CREATE),[a,N]=l(!1),[f,X]=l(!1),[_,$]=l(0),[D,y]=l(!1),g=J(D);x(()=>{g.current=D},[D]);const Y=e=>{i.canEdit!==!1&&E&&m!==d.CREATE&&e.button===0&&N(!0)},T=e=>{i.canEdit!==!1&&E&&m!==d.CREATE&&e.button===0&&X(!0)},h=e=>{if(a){const r=[{...n[0]},{...n[2]}].map(t=>({x:t.x+=e.movementX/s,y:t.y+=e.movementY/s}));(e.movementX!==0||e.movementY!==0)&&(y(!0),A(r))}if(m===d.CREATE){const o=Q.getAntiScaledMouseStagePosition(e,w,s,C),t=[[...n][0],o];A(t)}};x(()=>{if(!L)return;const e=o=>{o.button===2&&(z(),B(!1))};return window.addEventListener("mouseup",e),()=>{window.removeEventListener("mouseup",e)}},[L]),x(()=>{if(p(a),!a)return;const e=()=>{N(!1),g.current&&k(),y(!1)};return window.addEventListener("mouseup",e),()=>{window.removeEventListener("mouseup",e)}},[a]),x(()=>{if(p(f),!f)return;const e=()=>{X(!1),g.current&&k(),y(!1)};return window.addEventListener("mouseup",e),()=>{window.removeEventListener("mouseup",e)}},[f]);const q=()=>n.map((o,r)=>v(K,{index:r,annotationSettings:i,coordinates:o,pageToStageOffset:w,svgScale:s,svgTranslation:C,style:M,onDeleteNode:()=>{const t=[...n];t.splice(r,1),j(t)},onMoving:(t,c)=>{const u=[n[0],n[2]];switch(t){case 0:u[0]=c;break;case 1:u[0].x=c.x,u[1].y=c.y;break;case 2:u[1]=c;break;case 3:u[1].x=c.x,u[0].y=c.y;break}A(u)},onMoved:()=>k(),onIsDraggingStateChanged:p},`node_${r}`)),I=(e,o)=>{const r=[n[0],n[2]];switch(e){case 0:r[0].x+=o.movementX/s;break;case 1:r[1].y+=o.movementY/s;break;case 2:r[1].x+=o.movementX/s;break;case 3:r[0].y+=o.movementY/s;break}(o.movementX!==0||o.movementY!==0)&&(y(!0),A(r))},G=()=>n.map((o,r)=>{const t=r+1<n.length?n[r+1]:n[0],c=r%2===0?"ew-resize":"ns-resize";return v(W,{startCoordinate:o,endCoordinate:t,pageToStageOffset:w,svgScale:s,svgTranslation:C,style:{...M,cursor:c},onMouseDown:T,onMouseMove:u=>{$(r),f&&I(r,u)}},`edge_${r}`)}),U=e=>v("circle",{cx:n[0].x,cy:n[0].y,r:"100%",style:{opacity:0},onMouseDown:Y,onMouseMove:o=>{e&&f&&I(_,o),e||h(o)},onContextMenu:o=>o.preventDefault()});return H("g",{children:[(a||m===d.CREATE)&&U(!1),v(V,{annotationSettings:i,coordinates:n,isSelected:E,annotationMode:m,pageToStageOffset:w,style:M,svgScale:s,onIsDraggingStateChanged:p,onMouseDown:Y,onMouseMove:h}),f&&U(!0),E&&i.canEdit&&G(),E&&m!==d.CREATE&&q()]})};export{re as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as k,jsx as A}from"react/jsx-runtime";import{useState as b,useRef as U,useEffect as x}from"react";import q from"../atoms/Node.js";import m from"../../../models/AnnotationMode.js";import z from"../atoms/Edge.js";import I from"../../../utils/
|
|
1
|
+
import{jsxs as k,jsx as A}from"react/jsx-runtime";import{useState as b,useRef as U,useEffect as x}from"react";import q from"../atoms/Node.js";import m from"../../../models/AnnotationMode.js";import z from"../atoms/Edge.js";import I from"../../../utils/mouse.js";const Q=({annotationSettings:p,coordinates:n,isSelected:C,annotationMode:r,pageToStageOffset:c,svgScale:s,svgTranslation:f,style:w,onAddNode:R,onDeleteNode:L,onFinishAnnoCreate:j,onMoving:E,onMoved:v,onIsDraggingStateChanged:y})=>{const[i,D]=b(!1),[d,M]=b(!1),N=U(d);x(()=>{N.current=d},[d]);const h=t=>{if(p.canEdit!==!1&&(C&&r!==m.CREATE&&t.button===0&&D(!0),t.button===2&&r==m.CREATE)){const o=I.getAntiScaledMouseStagePosition(t,c,s,f),e=[...n];e.push(o),R(e)}},g=t=>{if(i){const o=n.map(e=>({x:e.x+=t.movementX/s,y:e.y+=t.movementY/s}));(t.movementX!==0||t.movementY!==0)&&(M(!0),E(o))}if(r===m.CREATE){const o=I.getAntiScaledMouseStagePosition(t,c,s,f);let e=[...n];n.length>1&&(e=n.slice(0,-1)),e.push(o),E(e)}};x(()=>{if(y(i),!i)return;const t=()=>{D(!1),N.current&&v(),M(!1)};return window.addEventListener("mouseup",t),()=>{window.removeEventListener("mouseup",t)}},[i]);const X=()=>A("circle",{cx:n[0].x,cy:n[0].y,r:"100%",style:{opacity:0},onMouseDown:h,onMouseMove:g,onContextMenu:t=>t.preventDefault()}),Y=()=>n.map((o,e)=>A(q,{index:e,annotationSettings:p,coordinates:o,pageToStageOffset:c,svgScale:s,svgTranslation:f,style:w,onDeleteNode:()=>{const u=[...n];u.splice(e,1),L(u)},onMoving:(u,l)=>{const P=[...n];P[u]=l,E(P)},onMoved:()=>v(),onIsDraggingStateChanged:y},`node_${e}`)),_=()=>n.map((o,e)=>{if(!(e+1>=n.length))return A(z,{startCoordinate:o,endCoordinate:n[e+1],pageToStageOffset:c,svgScale:s,svgTranslation:f,style:w,onAddNode:u=>{const l=[...n];l.splice(e+1,0,u),R(l)},onDoubleClick:()=>r===m.CREATE&&j(),onMouseDown:h,onMouseMove:g},`edge_${e}`)}),$=C&&r!==m.CREATE;return k("g",{children:[(i||r===m.CREATE)&&X(),_(),$&&Y()]})};export{Q as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as q,jsx as C}from"react/jsx-runtime";import{useState as j,useRef as z,useEffect as F}from"react";import B from"../atoms/Node.js";import G from"../atoms/PolygonArea.js";import s from"../../../models/AnnotationMode.js";import H from"../atoms/Edge.js";import I from"../../../utils/
|
|
1
|
+
import{jsxs as q,jsx as C}from"react/jsx-runtime";import{useState as j,useRef as z,useEffect as F}from"react";import B from"../atoms/Node.js";import G from"../atoms/PolygonArea.js";import s from"../../../models/AnnotationMode.js";import H from"../atoms/Edge.js";import I from"../../../utils/mouse.js";import L from"../../../models/NotificationType.js";const a=({annotationSettings:i,coordinates:e,isSelected:E,isDisabled:P=!1,annotationMode:t,pageToStageOffset:f,svgScale:u,svgTranslation:p,style:c,onAddNode:v,onDeleteNode:X,onFinishAnnoCreate:Y,onIsDraggingStateChanged:y,onMoving:R,onMoved:g,onNotification:N=m=>{}})=>{const[m,b]=j(!1),[d,x]=j(!1),M=z(d),_=()=>{if(e.length<3)return N({message:"Polygons must have at least 3 nodes",title:"Polygon Error",type:L.ERROR});Y()};F(()=>{M.current=d},[d]);const h=o=>{if(i.canEdit!==!1&&(E&&t!==s.CREATE&&t!==s.ADD&&o.button===0&&b(!0),o.button===2&&[s.CREATE,s.ADD].includes(t))){const n=I.getAntiScaledMouseStagePosition(o,f,u,p),r=[...e];r.push(n),v(r)}},D=o=>{if(m){const n=e.map(r=>({x:r.x+=o.movementX/u,y:r.y+=o.movementY/u}));(o.movementX!==0||o.movementY!==0)&&(x(!0),R(n))}if(t===s.CREATE){const n=I.getAntiScaledMouseStagePosition(o,f,u,p);let r=[...e];e.length>1&&(r=e.slice(0,-1)),r.push(n),R(r)}};F(()=>{if(y(m),!m)return;const o=()=>{b(!1),M.current&&g(),x(!1)};return window.addEventListener("mouseup",o),()=>{window.removeEventListener("mouseup",o)}},[m]);const $=()=>e.map((n,r)=>C(B,{index:r,annotationSettings:i,coordinates:n,pageToStageOffset:f,svgScale:u,svgTranslation:p,style:c,onDeleteNode:()=>{if(e.length<4)return N({message:"Polygons must have at least 3 nodes",title:"Polygon Error",type:L.ERROR});const l=[...e];l.splice(r,1),X(l)},onMoving:(l,w)=>{const A=[...e];A[l]=w,R(A)},onMoved:()=>g(),onIsDraggingStateChanged:y},`node_${r}`)),k=()=>e.map((n,r)=>{const l=r+1<e.length?e[r+1]:e[0];return C(H,{startCoordinate:n,endCoordinate:l,isDisabled:P&&E,pageToStageOffset:f,svgScale:u,svgTranslation:p,style:c,onAddNode:w=>{const A=[...e];A.splice(r+1,0,w),v(A)},onDoubleClick:()=>t===s.CREATE&&_(),onMouseDown:h,onMouseMove:D},`edge_${r}`)}),U=()=>C("circle",{cx:e[0].x,cy:e[0].y,r:"100%",style:{opacity:0},onMouseDown:h,onMouseMove:D,onContextMenu:o=>o.preventDefault()});return q("g",{children:[(m||t===s.CREATE||t===s.ADD)&&U(),C(G,{annotationSettings:i,coordinates:e,isSelected:E,isDisabled:P,annotationMode:t,pageToStageOffset:f,style:c,svgScale:u,onFinishAnnoCreate:_,onIsDraggingStateChanged:y,onMouseDown:h,onMouseMove:D}),E&&i.canEdit&&k(),E&&t!==s.CREATE&&$()]})};export{a as default};
|
package/dist/Canvas/Canvas.d.ts
CHANGED
|
@@ -23,8 +23,9 @@ type CanvasProps = {
|
|
|
23
23
|
onNotification?: (notification: SIANotification) => void;
|
|
24
24
|
onRequestNewAnnoId: () => number;
|
|
25
25
|
onSelectAnnotation: (annotation?: Annotation) => void;
|
|
26
|
+
onSetIsImageJunk: (newJunkState: boolean) => void;
|
|
26
27
|
onSetSelectedTool: (tool: AnnotationTool) => void;
|
|
27
28
|
onShouldDeleteAnno: (internalAnnoId: number) => void;
|
|
28
29
|
};
|
|
29
|
-
declare const Canvas: ({ annotations, annotationSettings, defaultLabelId, image, isFullscreen, isImageJunk, isPolygonSelectionMode, polygonOperationResult, possibleLabels, preventScrolling, selectedAnnotation, selectedAnnoTool, toolbarHeight, uiConfig, onAnnoCreated, onAnnoCreationFinished, onAnnoChanged, onAnnoEditing, onNotification, onRequestNewAnnoId, onSelectAnnotation, onSetSelectedTool, onShouldDeleteAnno, }: CanvasProps) => import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
declare const Canvas: ({ annotations, annotationSettings, defaultLabelId, image, isFullscreen, isImageJunk, isPolygonSelectionMode, polygonOperationResult, possibleLabels, preventScrolling, selectedAnnotation, selectedAnnoTool, toolbarHeight, uiConfig, onAnnoCreated, onAnnoCreationFinished, onAnnoChanged, onAnnoEditing, onNotification, onRequestNewAnnoId, onSelectAnnotation, onSetIsImageJunk, onSetSelectedTool, onShouldDeleteAnno, }: CanvasProps) => import("react/jsx-runtime").JSX.Element;
|
|
30
31
|
export default Canvas;
|
package/dist/Canvas/Canvas.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as P,jsx as C,Fragment as Je}from"react/jsx-runtime";import{useState as E,useRef as ye,useEffect as w}from"react";import D from"../models/AnnotationTool.js";import i from"../models/EditorModes.js";import Qe from"../utils/KeyMapper.js";import a from"../models/KeyAction.js";import Ee from"../Annotation/logic/Annotation.js";import Ze from"../models/CanvasAction.js";import qe from"../Annotation/ui/AnnotationComponent.js";import me from"../utils/mouse.js";import N from"../models/AnnotationMode.js";import et from"./LabelInput.js";import{FontAwesomeIcon as tt}from"@fortawesome/react-fontawesome";import{faBan as nt}from"@fortawesome/free-solid-svg-icons";import I from"../models/AnnotationStatus.js";import x from"../utils/transform.js";import ot from"../models/NotificationType.js";import rt from"../utils/TimeUtils.js";import he from"../utils/windowViewport.js";const wt=({annotations:A=[],annotationSettings:W,defaultLabelId:Q,image:Z,isFullscreen:pe=!1,isImageJunk:B=!1,isPolygonSelectionMode:K=!1,polygonOperationResult:F={annotationsToDelete:[],polygonsToCreate:[]},possibleLabels:q,preventScrolling:ee=!0,selectedAnnotation:r,selectedAnnoTool:R,toolbarHeight:X=0,uiConfig:U,onAnnoCreated:Ce,onAnnoCreationFinished:te,onAnnoChanged:ne,onAnnoEditing:xe=g=>{},onNotification:oe=g=>{},onRequestNewAnnoId:z,onSelectAnnotation:v,onSetIsImageJunk:Ae,onSetSelectedTool:Oe=g=>{},onShouldDeleteAnno:re})=>{const[g,O]=E(i.VIEW),[Te,ve]=E(),[se,Me]=E(Q),[k,we]=E({x:-1,y:-1}),[ie,ce]=E(0),V={x:k.x,y:k.y},[u,Y]=E({x:-1,y:-1}),[l,G]=E({x:-1,y:-1}),[m,ae]=E({x:-1,y:-1}),[d,L]=E(1),[c,S]=E({x:0,y:0}),H={x:c.x+ie,y:c.y},[h,$]=E(),[j,b]=E(!1),p=ye(null),y=ye(null),T=((e,t)=>{if(e.x===0||e.y===0||t.x===0||t.y===0)return 0;const n=t.x/e.x,o=t.y/e.y;return Math.min(n,o)})(u,l),De=()=>{if((y==null?void 0:y.current)===null)return{x:0,y:0};const e=u.x*T;if(U.imageCentered&&l.x>e){const f=(l.x-e)/2;ce(f)}else ce(0);const{top:t,left:n}=p.current.getBoundingClientRect(),o={x:n+window.scrollX,y:t+window.scrollY};we(o)},Ie=new Qe(e=>Ve(e)),Se=e=>{O(i.CREATE);const t=x.convertStageCoordinatesToPercentaged([e],T,u);R===D.BBox&&t.push(t[0]);const n=z(),o=new Ee(n,R,t);if(ve(performance.now()),se!==void 0&&(o.labelIds=[se]),Ce(o),R===D.Point){const s={...o,coordinates:[e],annoTime:0};J(s)}},be=()=>{if(r&&![D.Line,D.Polygon].includes(r.type))return;const e=A.find(t=>t.internalId===(r==null?void 0:r.internalId));e!==void 0&&(e.mode=N.CREATE,e.status=I.CREATING,e.selectedNode=e.coordinates.length-1,O(i.ADD),Oe(e.type),xe(e))},_e=()=>{const e=r?r.internalId:0,t=A.find(n=>n.internalId>e);if(t)return v(t);if(A.length>0)return v(A[0])},Ne=()=>{const e=r?r.internalId:0,t=[...A];t.sort((o,s)=>s.internalId-o.internalId);const n=t.find(o=>o.internalId<e);if(n)return v(n);if(A.length>0)return v(A[A.length-1])},Re=()=>{if(r){const e=JSON.stringify(r);localStorage.setItem("lostAnnotationClipboard",e);const t={title:"Success",message:"Annotation copied",type:ot.SUCCESS};oe(t)}},ke=()=>{const e=localStorage.getItem("lostAnnotationClipboard");if(e==null)return;const t=JSON.parse(e);t.internalId=z(),t.externalId="",te(t,!0),v(t)},Ve=e=>{switch(e){case a.EDIT_LABEL:r&&b(!0);break;case a.DELETE_ANNO:r&&re(r.internalId);break;case a.DELETE_ANNO_IN_CREATION:g===i.CREATE&&(re(r.internalId),O(i.VIEW));break;case a.ENTER_ANNO_ADD_MODE:console.log("KeyAction TODO: ENTER_ANNO_ADD_MODE");break;case a.LEAVE_ANNO_ADD_MODE:console.log("KeyAction TODO: LEAVE_ANNO_ADD_MODE");break;case a.UNDO:console.log("KeyAction TODO: UNDO");break;case a.REDO:console.log("KeyAction TODO: REDO");break;case a.TRAVERSE_ANNOS:_e();break;case a.TRAVERSE_ANNOS_BACKWARDS:Ne();break;case a.CAM_MOVE_LEFT:_(20*d,0);break;case a.CAM_MOVE_RIGHT:_(-20*d,0);break;case a.CAM_MOVE_UP:_(0,20*d);break;case a.CAM_MOVE_DOWN:_(0,-20*d);break;case a.CAM_MOVE_STOP:console.log("KeyAction TODO: CAM_MOVE_STOP");break;case a.COPY_ANNOTATION:Re();break;case a.PASTE_ANNOTATION:ke();break;case a.RECREATE_ANNO:console.log("KeyAction TODO: RECREATE_ANNO"),be();break;case a.TOGGLE_IMAGE_JUNK:if(g===i.ADD||g===i.CREATE)return;Ae(!B);break;default:console.log("Unknown KeyAction",e);break}},_=(e,t)=>{let n=c.x+e/d,o=c.y+t/d;const s=l.x*.45,f=l.x*.55,M=l.y*.45,$e=l.y*.55,je={x:0,y:0},fe=he.getViewportCoordinates(c,l,d,je),ge=he.getViewportCoordinates(c,l,d,l);fe.vX>=s?n=c.x-5:ge.vX<=f?n=c.x+5:fe.vY>=M?o=c.y-5:ge.vY<=$e&&(o=c.y+5),S({x:n,y:o})},Le=(e=>m.x<=0||m.y<=0||u.x<=0||u.y<=0?[]:A.map(n=>({...n,coordinates:x.convertPercentagedCoordinatesToStage(n.coordinates,u,m)})))(),Pe=()=>{if(O(i.VIEW),ae({x:-1,y:-1}),y.current!==null){const{width:e,height:t}=y.current.getBoundingClientRect();Y({x:e,y:t})}L(1),S({x:0,y:0}),$(void 0),b(!1)};w(()=>{if((p==null?void 0:p.current)!==void 0){const{width:e,height:t}=p.current.getBoundingClientRect(),n=t-X;G({x:e,y:n});const o=new ResizeObserver(()=>{const{width:s,height:f}=p.current.getBoundingClientRect(),M=f-X;G({x:s,y:M})});return o.observe(p.current),()=>o.disconnect()}Pe()},[Z,pe]),w(()=>{De()},[y,c,l]),w(()=>{if(p.current===null)return;const{width:e,height:t}=p.current.getBoundingClientRect(),n=t-X;G({x:e,y:n})},[p]),w(()=>{if(y.current===null)return;const{width:e,height:t}=y.current.getBoundingClientRect();Y({x:e,y:t});const n=new ResizeObserver(()=>{const{width:o,height:s}=y.current.getBoundingClientRect();Y({x:o,y:s})});return n.observe(y.current),()=>n.disconnect()},[y]),w(()=>{if(T===0)return;const e={x:u.x*T,y:u.y*T};ae(e)},[T,u]),w(()=>{K&&F.polygonsToCreate!==void 0&&F.polygonsToCreate.forEach(e=>{const t=z(),n=new Ee(t,e.type,x.convertPercentagedCoordinatesToStage(e.coordinates,u,m),N.VIEW,I.CREATED);J(n)})},[F]);const J=e=>{O(i.VIEW);const t={...e,mode:N.VIEW};if(e.type!==D.Point){const s=rt.getRoundedDuration(Te,performance.now());t.annoTime=s}const n=x.convertStageCoordinatesToPercentaged(e.coordinates,T,u);t.coordinates=n,ne(t);const o=R===D.Point||K;te(t,o)},We=e=>{e.preventDefault(),Ie.keyDown(e.key,e.shiftKey,e.ctrlKey)},Be=e=>{e.preventDefault()},Ke=e=>{if(e.button!==0){if(e.button===1)O(i.CAMERA_MOVE);else if(e.button===2){if(!W.canCreate||g===i.ADD||g===i.CREATE)return;const t=me.getAntiScaledMouseStagePosition(e,V,d,c),n={x:t.x-ie,y:t.y};Se(n)}}},Fe=()=>{ee&&(document.body.style.overflow="hidden")},Xe=e=>{switch(e.button){case 1:O(i.VIEW);break}},de=(e,t)=>{g===i.CAMERA_MOVE&&_(e,t)},Ue=()=>{ee&&(document.body.style.overflow="")},ze=e=>{const o=(e.deltaY<0?1:-1)>0?d*1.25:d/1.25,s=me.getAntiScaledMouseStagePosition(e,V,d,c),f=d/o,M={x:f*(s.x+c.x)-s.x,y:f*(s.y+c.y)-s.y};o<1?(L(1),(c.x!=0||c.y!=0)&&S({x:0,y:0})):o>200?(L(200),S(M)):(L(o),S(M))},Ye=(e,t)=>{if(t!==Ze.ANNO_SELECTED){console.log("Unknown Canvas Action:",t);return}const n={...e,coordinates:x.convertStageCoordinatesToPercentaged([...e.coordinates],T,u)};v(n);const o=x.getMostLeftPoints(e.coordinates),s=x.getTopPoint(o)[0],f=x.convertStageToPage(s,V,d,c);$(f)},le=e=>{const t=x.convertStageCoordinatesToPercentaged(e.coordinates,T,u),n={...e,coordinates:t};n.status===I.LOADED&&(n.status=I.CHANGED),ne(n)},Ge=()=>{if(g===i.CAMERA_MOVE)return C(Je,{});const t=[i.CREATE,i.ADD,i.MOVE].includes(g),n=Le.map(o=>{const s=o.internalId===(r==null?void 0:r.internalId);return t&&!s?C("g",{},`annotationComponent_${o.internalId}`):C(qe,{scaledAnnotation:o,annotationSettings:W,possibleLabels:q,svgScale:d,svgTranslation:H,pageToStageOffset:V,nodeRadius:U.nodeRadius,strokeWidth:U.strokeWidth,isSelected:s,isDisabled:K&&s,onFinishAnnoCreate:J,onLabelIconClicked:()=>b(!0),onAction:Ye,onAnnoChanged:le,onAnnotationModeChange:f=>{f===N.MOVE&&O(i.MOVE),g===i.MOVE&&f===N.VIEW&&O(i.VIEW)},onNotification:oe},`annotationComponent_${o.internalId}`)});return C("g",{children:n})},He=()=>C("circle",{cx:m.x/2,cy:m.y/2,r:"100%",style:{opacity:0},onContextMenu:e=>e.preventDefault(),onClick:()=>{b(!1)}}),ue={x:k.x+l.x/2,y:k.y+l.y/2};return P("div",{ref:p,style:{width:"100%",height:"100%"},children:[C("div",{style:{position:"absolute",left:(h==null?void 0:h.x)!==void 0?h.x:0,top:(h==null?void 0:h.y)!==void 0?h.y:0,display:(h==null?void 0:h.y)!==void 0?"inherit":"none",zIndex:j?7e3:-1},children:C(et,{defaultLabelId:Q,isVisible:j,selectedLabelsIds:r==null?void 0:r.labelIds,possibleLabels:q,isMultilabel:W.canHaveMultipleLabels,onLabelSelect:e=>{if(b(!1),e.length>0){const o=e.filter(s=>!r.labelIds.includes(s));o.length>0&&Me(o[0])}const t=r.status===I.LOADED?I.CHANGED:r.status,n={...r,coordinates:x.convertPercentagedCoordinatesToStage(r.coordinates,u,m),labelIds:[...e],status:t};le(n)}})}),B&&P("div",{style:{position:"absolute",left:ue.x,top:ue.y,transform:"translate(-50%, -50%)",textAlign:"center",color:"white"},children:[C(tt,{icon:nt,size:"5x",style:{marginBottom:15}}),C("h2",{children:"Marked as Junk"})]}),P("svg",{width:"100%",height:"100%",onKeyDown:We,onKeyUp:Be,onMouseMove:e=>de(e.movementX,e.movementY),tabIndex:0,onMouseDown:e=>Ke(e),children:[P("g",{transform:`scale(${d}) translate(${H.x}, ${H.y})`,onMouseOver:Fe,onMouseLeave:Ue,onMouseUp:Xe,onWheel:ze,onMouseMove:e=>de(e.movementX,e.movementY),onClick:()=>{v(void 0)},children:[C("image",{onContextMenu:e=>e.preventDefault(),href:Z,ref:y,width:m.x>0?m.x:void 0,height:m.y>0?m.y:void 0}),Ge()]}),j&&He(),B&&C("rect",{x:"0",y:"0",width:l.x,height:l.y,style:{opacity:.8},onContextMenu:e=>e.preventDefault(),onClick:()=>{$(void 0)}})]})]})};export{wt as default};
|
package/dist/Sia.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{jsx as d,jsxs as P}from"react/jsx-runtime";import{useRef as ln,useState as s,useEffect as f}from"react";import{CSpinner as W}from"@coreui/react";import cn from"./Canvas/Canvas.js";import fn from"./models/AnnotationTool.js";import un from"./Toolbar/Toolbar.js";import In from"./models/AnnotationMode.js";import mn from"./models/AnnotationStatus.js";const wn=({additionalButtons:q,allowedTools:h,polygonOperationResult:l={annotationsToDelete:[],polygonsToCreate:[]},annotationSettings:A,uiConfig:x,defaultAnnotationTool:g,defaultLabelId:z,image:u,isLoading:w=!1,isPolygonSelectionMode:y=!1,initialAnnotations:S=[],initialImageLabelIds:_=[],initialIsImageJunk:H=!1,possibleLabels:b,onAnnoCreated:M=(c,I)=>{},onAnnoCreationFinished:V=(c,I)=>{},onAnnoChanged:G=(c,I)=>{},onAnnoDeleted:K=(c,I)=>{},onImageLabelsChanged:Q=()=>{},onIsImageJunk:X=()=>{},onNotification:Y=c=>{},onSelectAnnotation:Z=c=>{}})=>{const I=ln(null),[k,D]=s(),[i,a]=s([]),[E,$]=s(),[R,O]=s(),[r,C]=s(),[j,N]=s(g!==void 0?g:fn.Point),[nn,hn]=s({height:"100%"}),[en,p]=s(_),[B,F]=s(),[T,tn]=s(!1),[J,L]=s([]),v=n=>{const e=i.findIndex(m=>m.internalId===n),t=[...i],o=t.splice(e,1)[0];a(t),K(o,t)},on=()=>{r!==void 0&&v(r.internalId)},sn=()=>{let n=0;const e=S.map(t=>({...t,internalId:n++,mode:In.VIEW,selectedNode:1,status:t.status,annoTime:t.annoTime!==void 0?t.annoTime:0}));L([...Array(n).keys()]),a(e)},an=()=>{let n=0;for(;J.includes(n);)n++;const e=[...J];return e.push(n),L(e),n},U=n=>{F(n),X(n)};f(()=>{u===void 0&&(a([]),C(void 0))},[u]),f(()=>{F(H),!(u!==void 0||S.length===0)&&sn()},[S]),f(()=>{p(_)},[_]),f(()=>{const e={...{canCreate:!0,canEdit:!0,canHaveMultipleLabels:!1,canLabel:!0,minimalArea:250},...A};$(e)},[A]),f(()=>{const e={...{nodeRadius:4,strokeWidth:4,imageCentered:!1},...x};O(e)},[x]),f(()=>{const n={bbox:!0,point:!0,line:!0,junk:!0,polygon:!0};if(h===void 0)return D(n);D(h)},[h]);const rn={position:"fixed",top:0,left:0,zIndex:6e3,backgroundColor:"#ffff",width:"100%",height:"100%",padding:15};return k===void 0?d("div",{className:"d-flex justify-content-center",children:d(W,{color:"primary",style:{width:"5rem",height:"5rem"}})}):P("div",{style:{...T?rn:{},width:"100%",height:"100%"},children:[d("div",{ref:I,style:{marginBottom:10},children:d(un,{annotationSettings:E,allowedTools:k,additionalButtons:q,isDisabled:w,isFullscreen:T,isImageJunk:B,imageLabelIds:en,possibleLabels:b,selectedTool:j,onImageLabelsChanged:n=>{p(n),Q(n)},onSetIsFullscreen:tn,onSetIsImageJunk:U,onSetSelectedTool:N,onShouldDeleteSelectedAnnotation:on})}),P("div",{style:nn,children:[w&&d("div",{className:"d-flex justify-content-center",children:d(W,{color:"primary",style:{width:"5rem",height:"5rem",marginTop:200}})}),u&&i&&d(cn,{annotations:i,annotationSettings:E,defaultLabelId:z,image:u,isFullscreen:T,isImageJunk:B,isPolygonSelectionMode:y,selectedAnnotation:r,selectedAnnoTool:j,polygonOperationResult:l,possibleLabels:b,uiConfig:R,onAnnoCreated:n=>{const e=[...i];e.push(n),a(e),C(n),M(n,e)},onAnnoChanged:n=>{const e=i.findIndex(o=>o.internalId===n.internalId);if(e===-1)return;const t=[...i];t[e]=n,a(t),G(n,t)},onAnnoCreationFinished:(n,e)=>{const t=[...i];if(y&&(l==null?void 0:l.annotationsToDelete)!==void 0&&(l.annotationsToDelete.push(r),l.annotationsToDelete.forEach(o=>{v(o.internalId);const m=t.findIndex(dn=>dn.internalId===o.internalId);t.splice(m,1)})),e)t.push(n);else{const o=i.findIndex(m=>m.internalId===n.internalId);t[o]=n}a(t),n.status=mn.CREATED,V(n,t)},onAnnoEditing:n=>{const e=[...i],t=e.findIndex(o=>o.internalId===(r==null?void 0:r.internalId));e[t]=n,a(e)},onSetIsImageJunk:U,onNotification:Y,onRequestNewAnnoId:an,onSelectAnnotation:n=>{C(n),Z(n)},onSetSelectedTool:N,onShouldDeleteAnno:v})]})]})};export{wn as default};
|
package/dist/Toolbar/Toolbar.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as j,jsx as o}from"react/jsx-runtime";import{CRow as C,CCol as e}from"@coreui/react";import g from"./ToolbarItems/AnnoToolSelector.js";import y from"./ToolbarItems/ImageTools.js";import T from"./ToolbarItems/AccessibilityTools.js";const J=({annotationSettings:c,allowedTools:t,additionalButtons:n,isImageJunk:m=!1,imageLabelIds:f=[],isDisabled:r=!1,isFullscreen:a=!1,possibleLabels:l,selectedTool:s,onImageLabelsChanged:p=()=>{},onSetIsFullscreen:x=()=>{},onSetIsImageJunk:i=()=>{},onSetSelectedTool:u=()=>{},onShouldDeleteSelectedAnnotation:h=()=>{}})=>j(C,{className:"d-flex justify-content-center flex-wrap align-items-center gap-0 py-2 px-4",children:[o(e,{xs:"auto",children:o(y,{canJunk:t.junk,isImageJunk:m,imageLabelIds:f,isDisabled:r,isFullscreen:a,possibleLabels:l,onImageLabelsChanged:p,onSetIsImageJunk:i})}),o(e,{xs:"auto",children:o(T,{isDisabled:r,isFullscreen:a,onSetIsFullscreen:x})}),c.canCreate&&o(e,{xs:"auto",children:o(g,{allowedTools:t,isDisabled:r,selectedTool:s,onSetSelectedTool:u,onShouldDeleteSelectedAnnotation:h})}),n&&n]});export{J as default};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
export * from './types';
|
|
2
|
-
export { default as Canvas } from './Canvas.jsx';
|
|
3
2
|
export { default as Sia } from './Sia';
|
|
4
|
-
export { default as Sia2 } from './Sia2';
|
|
5
|
-
export { default as dummyData } from './siaDummyData';
|
|
6
3
|
export { default as transform } from './utils/transform';
|
|
7
|
-
export { default as annoConversion } from './utils/annoConversion';
|
|
8
|
-
export { default as canvasActions } from './types/canvasActions';
|
|
9
4
|
export { default as TagLabel } from './Toolbar/ToolbarItems/ImageToolItems/TagLabel';
|
|
10
|
-
export { default as tools } from './types/tools';
|
|
11
|
-
export { default as filterTools } from './filterTools.js';
|
|
12
|
-
export { default as toolbarEvents } from './types/toolbarEvents';
|
|
13
|
-
export { default as notificationType } from './types/notificationType';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
/* empty css *//* empty css */import{default as e}from"./
|
|
1
|
+
/* empty css *//* empty css */import{default as e}from"./Sia.js";import{default as m}from"./utils/transform.js";import{default as l}from"./Toolbar/ToolbarItems/ImageToolItems/TagLabel.js";export{e as Sia,l as TagLabel,m as transform};
|
package/dist/models/KeyAction.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var _=(E=>(E[E.EDIT_LABEL=0]="EDIT_LABEL",E[E.DELETE_ANNO=1]="DELETE_ANNO",E[E.ENTER_ANNO_ADD_MODE=2]="ENTER_ANNO_ADD_MODE",E[E.LEAVE_ANNO_ADD_MODE=3]="LEAVE_ANNO_ADD_MODE",E[E.UNDO=4]="UNDO",E[E.REDO=5]="REDO",E[E.TRAVERSE_ANNOS=6]="TRAVERSE_ANNOS",E[E.TRAVERSE_ANNOS_BACKWARDS=7]="TRAVERSE_ANNOS_BACKWARDS",E[E.CAM_MOVE_UP=8]="CAM_MOVE_UP",E[E.CAM_MOVE_DOWN=9]="CAM_MOVE_DOWN",E[E.CAM_MOVE_LEFT=10]="CAM_MOVE_LEFT",E[E.CAM_MOVE_RIGHT=11]="CAM_MOVE_RIGHT",E[E.CAM_MOVE_STOP=12]="CAM_MOVE_STOP",E[E.COPY_ANNOTATION=13]="COPY_ANNOTATION",E[E.PASTE_ANNOTATION=14]="PASTE_ANNOTATION",E[E.RECREATE_ANNO=15]="RECREATE_ANNO",E[E.DELETE_ANNO_IN_CREATION=16]="DELETE_ANNO_IN_CREATION",E[E.TOGGLE_ANNO_COMMENT_INPUT=17]="TOGGLE_ANNO_COMMENT_INPUT",E))(_||{});export{_ as default};
|
|
1
|
+
var _=(E=>(E[E.EDIT_LABEL=0]="EDIT_LABEL",E[E.DELETE_ANNO=1]="DELETE_ANNO",E[E.ENTER_ANNO_ADD_MODE=2]="ENTER_ANNO_ADD_MODE",E[E.LEAVE_ANNO_ADD_MODE=3]="LEAVE_ANNO_ADD_MODE",E[E.UNDO=4]="UNDO",E[E.REDO=5]="REDO",E[E.TRAVERSE_ANNOS=6]="TRAVERSE_ANNOS",E[E.TRAVERSE_ANNOS_BACKWARDS=7]="TRAVERSE_ANNOS_BACKWARDS",E[E.CAM_MOVE_UP=8]="CAM_MOVE_UP",E[E.CAM_MOVE_DOWN=9]="CAM_MOVE_DOWN",E[E.CAM_MOVE_LEFT=10]="CAM_MOVE_LEFT",E[E.CAM_MOVE_RIGHT=11]="CAM_MOVE_RIGHT",E[E.CAM_MOVE_STOP=12]="CAM_MOVE_STOP",E[E.COPY_ANNOTATION=13]="COPY_ANNOTATION",E[E.PASTE_ANNOTATION=14]="PASTE_ANNOTATION",E[E.RECREATE_ANNO=15]="RECREATE_ANNO",E[E.DELETE_ANNO_IN_CREATION=16]="DELETE_ANNO_IN_CREATION",E[E.TOGGLE_ANNO_COMMENT_INPUT=17]="TOGGLE_ANNO_COMMENT_INPUT",E[E.TOGGLE_IMAGE_JUNK=18]="TOGGLE_IMAGE_JUNK",E))(_||{});export{_ as default};
|
|
@@ -9,7 +9,7 @@ export declare const ActionsData: {
|
|
|
9
9
|
};
|
|
10
10
|
declare const meta: {
|
|
11
11
|
title: string;
|
|
12
|
-
component: ({ annotations, annotationSettings, defaultLabelId, image, isFullscreen, isImageJunk, isPolygonSelectionMode, polygonOperationResult, possibleLabels, preventScrolling, selectedAnnotation, selectedAnnoTool, toolbarHeight, uiConfig, onAnnoCreated, onAnnoCreationFinished, onAnnoChanged, onAnnoEditing, onNotification, onRequestNewAnnoId, onSelectAnnotation, onSetSelectedTool, onShouldDeleteAnno, }: {
|
|
12
|
+
component: ({ annotations, annotationSettings, defaultLabelId, image, isFullscreen, isImageJunk, isPolygonSelectionMode, polygonOperationResult, possibleLabels, preventScrolling, selectedAnnotation, selectedAnnoTool, toolbarHeight, uiConfig, onAnnoCreated, onAnnoCreationFinished, onAnnoChanged, onAnnoEditing, onNotification, onRequestNewAnnoId, onSelectAnnotation, onSetIsImageJunk, onSetSelectedTool, onShouldDeleteAnno, }: {
|
|
13
13
|
annotations?: Annotation[];
|
|
14
14
|
annotationSettings: AnnotationSettings;
|
|
15
15
|
defaultLabelId?: number;
|
|
@@ -31,6 +31,7 @@ declare const meta: {
|
|
|
31
31
|
onNotification?: (notification: import('../..').SIANotification) => void;
|
|
32
32
|
onRequestNewAnnoId: () => number;
|
|
33
33
|
onSelectAnnotation: (annotation?: Annotation) => void;
|
|
34
|
+
onSetIsImageJunk: (newJunkState: boolean) => void;
|
|
34
35
|
onSetSelectedTool: (tool: AnnotationTool) => void;
|
|
35
36
|
onShouldDeleteAnno: (internalAnnoId: number) => void;
|
|
36
37
|
}) => import("react/jsx-runtime").JSX.Element;
|
package/dist/utils/KeyMapper.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var a=Object.defineProperty;var s=(t,i,r)=>i in t?a(t,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[i]=r;var c=(t,i,r)=>s(t,typeof i!="symbol"?i+"":i,r);import e from"../models/KeyAction.js";class n{constructor(i=void 0){c(this,"isControlDown");c(this,"keyActionHandler");this.isControlDown=!1,this.keyActionHandler=i}keyDown(i,r=!1,A){switch(i){case"Enter":this.triggerKeyAction(e.EDIT_LABEL);break;case"Delete":this.triggerKeyAction(e.DELETE_ANNO);break;case"Backspace":this.triggerKeyAction(e.DELETE_ANNO);break;case"z":A&&this.triggerKeyAction(e.UNDO);break;case"y":A&&this.triggerKeyAction(e.REDO);break;case"Tab":r?this.triggerKeyAction(e.TRAVERSE_ANNOS_BACKWARDS):this.triggerKeyAction(e.TRAVERSE_ANNOS);break;case"w":this.triggerKeyAction(e.CAM_MOVE_UP);break;case"s":this.triggerKeyAction(e.CAM_MOVE_DOWN);break;case"a":this.triggerKeyAction(e.CAM_MOVE_LEFT);break;case"d":this.triggerKeyAction(e.CAM_MOVE_RIGHT);break;case"e":this.triggerKeyAction(e.RECREATE_ANNO);break;case"c":A?this.triggerKeyAction(e.COPY_ANNOTATION):this.triggerKeyAction(e.TOGGLE_ANNO_COMMENT_INPUT);break;case"v":A&&this.triggerKeyAction(e.PASTE_ANNOTATION);break;case"Escape":this.triggerKeyAction(e.DELETE_ANNO_IN_CREATION);break}}triggerKeyAction(i){this.keyActionHandler&&this.keyActionHandler(i)}}export{n as default};
|
|
1
|
+
var a=Object.defineProperty;var s=(t,i,r)=>i in t?a(t,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[i]=r;var c=(t,i,r)=>s(t,typeof i!="symbol"?i+"":i,r);import e from"../models/KeyAction.js";class n{constructor(i=void 0){c(this,"isControlDown");c(this,"keyActionHandler");this.isControlDown=!1,this.keyActionHandler=i}keyDown(i,r=!1,A){switch(i){case"Enter":this.triggerKeyAction(e.EDIT_LABEL);break;case"Delete":this.triggerKeyAction(e.DELETE_ANNO);break;case"Backspace":this.triggerKeyAction(e.DELETE_ANNO);break;case"z":A&&this.triggerKeyAction(e.UNDO);break;case"y":A&&this.triggerKeyAction(e.REDO);break;case"Tab":r?this.triggerKeyAction(e.TRAVERSE_ANNOS_BACKWARDS):this.triggerKeyAction(e.TRAVERSE_ANNOS);break;case"w":this.triggerKeyAction(e.CAM_MOVE_UP);break;case"s":this.triggerKeyAction(e.CAM_MOVE_DOWN);break;case"a":this.triggerKeyAction(e.CAM_MOVE_LEFT);break;case"d":this.triggerKeyAction(e.CAM_MOVE_RIGHT);break;case"e":this.triggerKeyAction(e.RECREATE_ANNO);break;case"j":this.triggerKeyAction(e.TOGGLE_IMAGE_JUNK);break;case"c":A?this.triggerKeyAction(e.COPY_ANNOTATION):this.triggerKeyAction(e.TOGGLE_ANNO_COMMENT_INPUT);break;case"v":A&&this.triggerKeyAction(e.PASTE_ANNOTATION);break;case"Escape":this.triggerKeyAction(e.DELETE_ANNO_IN_CREATION);break}}triggerKeyAction(i){this.keyActionHandler&&this.keyActionHandler(i)}}export{n as default};
|
package/dist/utils/mouse.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const d=(o,t,e,s)=>{const a={x:o.pageX,y:o.pageY},n={x:a.x-t.x,y:a.y-t.y},x={x:n.x/e,y:n.y/e};return{x:x.x-s.x,y:x.y-s.y}},y={getAntiScaledMouseStagePosition:d};export{y as default};
|
package/dist/utils/siaIcons.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import{jsx as n}from"react/jsx-runtime";
|
|
1
|
+
import{jsx as n}from"react/jsx-runtime";function o(){return n("svg",{version:"1.1",id:"Linie",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1190.549 841.891",width:"17px",children:n("path",{fill:"currentColor",d:`M986.331,109.582c7.141-10.669,28.926-51.179-2.968-85.299S891.011,8.972,891.011,8.972L539.125,133.474
|
|
2
2
|
L63.239,302.022c-21.503,7.998-53.586,30.072-60.956,61.716s-2.116,58.538,22.414,96.79S211.33,752.213,228.564,777.28
|
|
3
3
|
c26.453,36.868,62.16,58.042,105.507,57.154s365.665-7.485,365.665-7.485l331.7-8.325l89.453-2.293c0,0,70.998-7.179,69.861-60.287
|
|
4
4
|
c-1.135-53.108-74.618-62.721-74.618-62.721s-733.215,15.553-749.148,15.576c-22.688,0.201-45.355-15.278-54.146-28.928
|
|
5
5
|
s-175.79-272.956-175.79-272.956l600.587-212.338c0,0-73.179,67.087-99.315,100.041s-30.56,74.565-5.053,95.237
|
|
6
|
-
c31.188,24.081,91.974-3.708,123.127-39.312C782.35,323.912,979.191,120.251,986.331,109.582z`})})}function
|
|
6
|
+
c31.188,24.081,91.974-3.708,123.127-39.312C782.35,323.912,979.191,120.251,986.331,109.582z`})})}function r(){return n("svg",{version:"1.1",id:"Linie",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1190.549 841.891",width:"17px",children:n("path",{fill:"none",stroke:"currentColor",strokeWidth:"120",strokeMiterlimit:"10",d:`M929.775,710.655
|
|
7
7
|
c0,23.386-19.134,42.52-42.52,42.52H278.991c-23.386,0-42.52-19.134-42.52-42.52V102.392c0-23.386,19.134-42.52,42.52-42.52
|
|
8
|
-
h608.264c23.386,0,42.52,19.134,42.52,42.52V710.655z`})})}function
|
|
8
|
+
h608.264c23.386,0,42.52,19.134,42.52,42.52V710.655z`})})}function t(){return n("svg",{version:"1.1",id:"Linie",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1190.549 841.891",width:"17px",children:n("path",{fill:"none",stroke:"currentColor",strokeWidth:"120",strokeMiterlimit:"10",d:`M342.327,769.938
|
|
9
9
|
c-23.379,0.548-52.922-15.056-65.65-34.674L65.479,409.738c-12.729-19.619-5.085-41.998,16.984-49.732L917.331,67.421
|
|
10
10
|
c22.07-7.734,26.86-0.275,10.645,16.576L691.761,329.475c-16.216,16.852-14.503,42.542,3.807,57.092l425.212,337.901
|
|
11
|
-
c18.31,14.549,14.16,26.901-9.219,27.449L342.327,769.938z`})})}function
|
|
12
|
-
c0-151.356,122.7-274.057,274.057-274.057C625.497,134.229,748.197,256.929,748.197,408.286z`})})}export{
|
|
11
|
+
c18.31,14.549,14.16,26.901-9.219,27.449L342.327,769.938z`})})}function c(){return n("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1190.549 841.891",width:"17px",children:n("path",{fill:"currentColor",d:`M748.197,408.286c0,151.355-122.699,274.058-274.059,274.058c-151.357,0-274.057-122.703-274.057-274.058
|
|
12
|
+
c0-151.356,122.7-274.057,274.057-274.057C625.497,134.229,748.197,256.929,748.197,408.286z`})})}export{r as bBoxIcon,o as lineIcon,c as pointIcon,t as polygonIcon};
|
package/dist/utils/transform.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const c=(r,o,t)=>{const e=t.x/o.x;return r.map(s=>({x:s.x*e,y:s.y*e}))},d=(r,o)=>r.map(e=>({x:e.x*o.x,y:e.y*o.y})),y=(r,o,t)=>{const e=d(r,o);return c(e,o,t)},x=(r,o)=>r.map(e=>({x:e.x/o,y:e.y/o})),C=(r,o,t)=>x(r,o).map(n=>(n.x<0&&(n.x=0),n.y<0&&(n.y=0),n.x>t.x&&(n.x=t.x),n.y>t.y&&(n.y=t.y),n)).map(n=>({x:n.x/t.x,y:n.y/t.y})),g=(r,o,t,e)=>{const a={x:r.x+e.x,y:r.y+e.y},s={x:a.x*t,y:a.y*t};return{x:s.x+o.x,y:s.y+o.y}},u=r=>{let o=1/0,t=[];return r.forEach(e=>{e.x<o?(o=e.x,t=[],t.push(e)):e.x===o&&t.push(e)}),t},m=r=>{let o=1/0,t=[];return r.forEach(e=>{e.y<o?(o=e.y,t=[],t.push(e)):e.y===o&&t.push(e)}),t},f={convertImageCoordinatesToStage:c,convertPercentagedCoordinatesToImage:d,convertPercentagedCoordinatesToStage:y,convertStageCoordinatesToImage:x,convertStageCoordinatesToPercentaged:C,convertStageToPage:g,getMostLeftPoints:u,getTopPoint:m};export{f as default,u as getMostLeftPoints,m as getTopPoint};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Point, Vector2 } from '../types';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
getViewportCoordinates: (svgTranslation: Vector2, canvasSize: Vector2, svgScale: number, pointInViewport: Point) => {
|
|
4
|
+
window: {
|
|
5
|
+
xMin: number;
|
|
6
|
+
xMax: number;
|
|
7
|
+
yMin: number;
|
|
8
|
+
yMax: number;
|
|
9
|
+
};
|
|
10
|
+
viewport: {
|
|
11
|
+
xMin: number;
|
|
12
|
+
xMax: number;
|
|
13
|
+
yMin: number;
|
|
14
|
+
yMax: number;
|
|
15
|
+
};
|
|
16
|
+
vX: number;
|
|
17
|
+
vY: number;
|
|
18
|
+
scaleX: number;
|
|
19
|
+
scaleY: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const d=(y,n,o,t)=>{const x={xMin:-1*y.x,xMax:-1*y.x+n.x/o,yMin:-1*y.y,yMax:-1*y.y+n.y/o},M={xMin:0,xMax:n.x,yMin:0,yMax:n.y},i=(M.xMax-M.xMin)/(x.xMax-x.xMin),c=(M.yMax-M.yMin)/(x.yMax-x.yMin),w=M.xMin+(t.x-x.xMin)*i,e=M.yMin+(t.y-x.yMin)*c;return{window:x,viewport:M,vX:w,vY:e,scaleX:i,scaleY:c}},r={getViewportCoordinates:d};export{r as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lost-sia",
|
|
3
|
-
"version": "2.0.1-
|
|
3
|
+
"version": "2.0.1-alpha13",
|
|
4
4
|
"description": "Single Image Annotation Tool",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "l3p-cv/lost-sia",
|
|
@@ -25,13 +25,12 @@
|
|
|
25
25
|
"require": "./dist/index.js"
|
|
26
26
|
},
|
|
27
27
|
"./utils": {
|
|
28
|
-
"development": "./src/utils/index.js",
|
|
29
28
|
"types": "./dist/utils/index.d.ts",
|
|
30
29
|
"import": "./dist/utils/index.js",
|
|
31
30
|
"require": "./dist/utils/index.js"
|
|
32
31
|
},
|
|
33
32
|
"./models": {
|
|
34
|
-
"
|
|
33
|
+
"bun": "./src/models/index.js",
|
|
35
34
|
"types": "./dist/models/index.d.ts",
|
|
36
35
|
"import": "./dist/models/index.js",
|
|
37
36
|
"require": "./dist/models/index.js"
|
|
@@ -74,6 +73,8 @@
|
|
|
74
73
|
"react-dom": "^18.0.0"
|
|
75
74
|
},
|
|
76
75
|
"devDependencies": {
|
|
76
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
77
|
+
"@eslint/js": "^9.39.1",
|
|
77
78
|
"@microsoft/api-extractor": "^7.52.13",
|
|
78
79
|
"@storybook/addon-docs": "^9.1.10",
|
|
79
80
|
"@storybook/addon-links": "^9.0.12",
|
|
@@ -85,16 +86,16 @@
|
|
|
85
86
|
"@typescript-eslint/parser": "^8.46.1",
|
|
86
87
|
"@vitejs/plugin-react": "^4.3.0",
|
|
87
88
|
"cross-env": "^7.0.3",
|
|
88
|
-
"eslint": "^
|
|
89
|
+
"eslint": "^9.39.1",
|
|
89
90
|
"eslint-config-standard": "^17.1.0",
|
|
90
91
|
"eslint-config-standard-react": "^13.0.0",
|
|
91
92
|
"eslint-plugin-import": "^2.29.1",
|
|
92
93
|
"eslint-plugin-node": "^11.1.0",
|
|
93
|
-
"eslint-plugin-promise": "^
|
|
94
|
-
"eslint-plugin-react": "^7.
|
|
94
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
95
|
+
"eslint-plugin-react": "^7.37.5",
|
|
95
96
|
"eslint-plugin-standard": "^5.0.0",
|
|
96
|
-
"eslint-plugin-storybook": "^
|
|
97
|
-
"glob": "^
|
|
97
|
+
"eslint-plugin-storybook": "^10.0.7",
|
|
98
|
+
"glob": "^11.0.3",
|
|
98
99
|
"lodash-es": "^4.17.21",
|
|
99
100
|
"prettier": "^3.3.3",
|
|
100
101
|
"react-redux": "^9.1.2",
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { CSSProperties, useEffect, useRef, useState } from
|
|
2
|
-
import { Label, Point } from
|
|
3
|
-
import transform from
|
|
4
|
-
import DaviIcon from
|
|
1
|
+
import { CSSProperties, useEffect, useRef, useState } from 'react'
|
|
2
|
+
import { Label, Point } from '../../../types'
|
|
3
|
+
import transform from '../../../utils/transform'
|
|
4
|
+
import DaviIcon from './DaviIcon'
|
|
5
5
|
|
|
6
|
-
const DEFAULT_FONT_SIZE = 10
|
|
7
|
-
const DEFAULT_RECT_HEIGHT = 15
|
|
8
|
-
const TEXT_PADDING = 3
|
|
6
|
+
const DEFAULT_FONT_SIZE = 10
|
|
7
|
+
const DEFAULT_RECT_HEIGHT = 15
|
|
8
|
+
const TEXT_PADDING = 3
|
|
9
9
|
|
|
10
10
|
type AnnoBarProps = {
|
|
11
|
-
annotationCoordinates: Point[]
|
|
12
|
-
canLabel: boolean
|
|
13
|
-
color: string
|
|
14
|
-
labels: Label[]
|
|
15
|
-
selectedLabelIds: number[]
|
|
16
|
-
isSelected: boolean
|
|
17
|
-
svgScale: number
|
|
18
|
-
style: CSSProperties
|
|
19
|
-
onLabelIconClicked: (markerPosition: Point) => void
|
|
20
|
-
}
|
|
11
|
+
annotationCoordinates: Point[]
|
|
12
|
+
canLabel: boolean
|
|
13
|
+
color: string
|
|
14
|
+
labels: Label[]
|
|
15
|
+
selectedLabelIds: number[]
|
|
16
|
+
isSelected: boolean
|
|
17
|
+
svgScale: number
|
|
18
|
+
style: CSSProperties
|
|
19
|
+
onLabelIconClicked: (markerPosition: Point) => void
|
|
20
|
+
}
|
|
21
21
|
const AnnoBar = ({
|
|
22
22
|
annotationCoordinates,
|
|
23
23
|
canLabel,
|
|
@@ -29,56 +29,56 @@ const AnnoBar = ({
|
|
|
29
29
|
style,
|
|
30
30
|
onLabelIconClicked,
|
|
31
31
|
}: AnnoBarProps) => {
|
|
32
|
-
const [topLeftPoint, setTopLeftPoint] = useState<Point>({ x: 0, y: 0 })
|
|
32
|
+
const [topLeftPoint, setTopLeftPoint] = useState<Point>({ x: 0, y: 0 })
|
|
33
33
|
const barPosition: Point = {
|
|
34
34
|
x: topLeftPoint.x + 7 / svgScale,
|
|
35
35
|
y: topLeftPoint.y - 10 / svgScale,
|
|
36
|
-
}
|
|
37
|
-
const [barWidth, setBarWidth] = useState<number>(0)
|
|
38
|
-
const [barHeight, setBarHeight] = useState<number>(0)
|
|
39
|
-
const [fontSize, setFontSize] = useState<number>(0)
|
|
40
|
-
const [labelText, setLabelText] = useState<string>(
|
|
36
|
+
}
|
|
37
|
+
const [barWidth, setBarWidth] = useState<number>(0)
|
|
38
|
+
const [barHeight, setBarHeight] = useState<number>(0)
|
|
39
|
+
const [fontSize, setFontSize] = useState<number>(0)
|
|
40
|
+
const [labelText, setLabelText] = useState<string>('')
|
|
41
41
|
|
|
42
|
-
const textRef = useRef(null)
|
|
42
|
+
const textRef = useRef(null)
|
|
43
43
|
|
|
44
44
|
useEffect(() => {
|
|
45
|
-
setLabelText(getLabelText())
|
|
46
|
-
}, [selectedLabelIds])
|
|
45
|
+
setLabelText(getLabelText())
|
|
46
|
+
}, [selectedLabelIds])
|
|
47
47
|
|
|
48
48
|
useEffect(() => {
|
|
49
49
|
// get the most top left point from the annotation
|
|
50
|
-
const topPoints: Point[] = transform.getTopPoint(annotationCoordinates)
|
|
51
|
-
const newTopLeftPoint: Point = transform.getMostLeftPoints(topPoints)[0]
|
|
50
|
+
const topPoints: Point[] = transform.getTopPoint(annotationCoordinates)
|
|
51
|
+
const newTopLeftPoint: Point = transform.getMostLeftPoints(topPoints)[0]
|
|
52
52
|
|
|
53
|
-
setTopLeftPoint(newTopLeftPoint)
|
|
53
|
+
setTopLeftPoint(newTopLeftPoint)
|
|
54
54
|
|
|
55
55
|
// calculate scaled font size
|
|
56
|
-
const newFontSize = Math.ceil(DEFAULT_FONT_SIZE / svgScale)
|
|
57
|
-
setFontSize(newFontSize)
|
|
56
|
+
const newFontSize = Math.ceil(DEFAULT_FONT_SIZE / svgScale)
|
|
57
|
+
setFontSize(newFontSize)
|
|
58
58
|
|
|
59
|
-
setBarHeight(DEFAULT_RECT_HEIGHT / svgScale)
|
|
60
|
-
}, [svgScale])
|
|
59
|
+
setBarHeight(DEFAULT_RECT_HEIGHT / svgScale)
|
|
60
|
+
}, [svgScale])
|
|
61
61
|
|
|
62
62
|
useEffect(() => {
|
|
63
|
-
if (textRef === undefined) return
|
|
63
|
+
if (textRef === undefined) return
|
|
64
64
|
|
|
65
65
|
// calculate size of box around label text
|
|
66
|
-
const textElement: DOMRect = textRef.current.getBoundingClientRect()
|
|
67
|
-
const textWidth: number = textElement.width
|
|
68
|
-
const rectWidth = (textWidth + TEXT_PADDING) / svgScale
|
|
66
|
+
const textElement: DOMRect = textRef.current.getBoundingClientRect()
|
|
67
|
+
const textWidth: number = textElement.width
|
|
68
|
+
const rectWidth = (textWidth + TEXT_PADDING) / svgScale
|
|
69
69
|
|
|
70
|
-
setBarWidth(rectWidth)
|
|
71
|
-
}, [textRef, labelText, fontSize])
|
|
70
|
+
setBarWidth(rectWidth)
|
|
71
|
+
}, [textRef, labelText, fontSize])
|
|
72
72
|
|
|
73
73
|
const getLabelText = () => {
|
|
74
74
|
const selectedLabels: Label[] = labels.filter((label: Label) =>
|
|
75
75
|
selectedLabelIds.includes(label.id),
|
|
76
|
-
)
|
|
76
|
+
)
|
|
77
77
|
|
|
78
|
-
const labelText = selectedLabels.map((l) => l.name).join(
|
|
78
|
+
const labelText = selectedLabels.map((l) => l.name).join(', ')
|
|
79
79
|
|
|
80
|
-
return labelText.length ? labelText :
|
|
81
|
-
}
|
|
80
|
+
return labelText.length ? labelText : 'no label'
|
|
81
|
+
}
|
|
82
82
|
|
|
83
83
|
return (
|
|
84
84
|
<g>
|
|
@@ -124,7 +124,7 @@ const AnnoBar = ({
|
|
|
124
124
|
onContextMenu={(e) => e.preventDefault()}
|
|
125
125
|
/>
|
|
126
126
|
</g>
|
|
127
|
-
)
|
|
128
|
-
}
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
129
|
|
|
130
|
-
export default AnnoBar
|
|
130
|
+
export default AnnoBar
|