lost-sia 2.0.1-alpha12 → 2.0.1-alpha14
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/AnnotationComponent.js +1 -1
- package/dist/Annotation/ui/atoms/AnnoBar.js +1 -1
- package/dist/Annotation/ui/atoms/DaviIcon.d.ts +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/IconButton.d.ts +25 -0
- package/dist/IconButton.js +1 -0
- package/dist/Sia.js +1 -1
- package/dist/Toolbar/ToolbarItems/AccessibilityTools.js +1 -1
- package/dist/Toolbar/ToolbarItems/AnnoToolSelector.js +1 -1
- package/dist/Toolbar/ToolbarItems/ImageToolItems/ImageLabelInput.js +1 -1
- package/dist/Toolbar/ToolbarItems/ImageTools.js +1 -1
- package/dist/index.d.ts +1 -9
- package/dist/index.js +1 -1
- package/dist/models/KeyAction.d.ts +2 -1
- package/dist/models/KeyAction.js +1 -1
- package/dist/models/index.d.ts +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 +11 -9
- package/src/AnnoExampleViewer.jsx +18 -18
- package/src/Annotation/logic/Annotation.ts +24 -24
- package/src/Annotation/ui/AnnotationComponent.tsx +89 -96
- package/src/Annotation/ui/atoms/AnnoBar.tsx +46 -46
- package/src/Annotation/ui/atoms/DaviIcon.tsx +12 -22
- package/src/Annotation/ui/atoms/Edge.tsx +23 -23
- package/src/Annotation/ui/atoms/Node.tsx +51 -51
- package/src/Annotation/ui/atoms/PolygonArea.tsx +35 -35
- package/src/Annotation/ui/tools/BBox.tsx +129 -145
- package/src/Annotation/ui/tools/Line.tsx +81 -87
- package/src/Annotation/ui/tools/Point.tsx +17 -17
- package/src/Annotation/ui/tools/Polygon.tsx +92 -95
- package/src/Canvas/Canvas.tsx +400 -405
- package/src/Canvas/LabelInput.tsx +27 -34
- package/src/IconButton.tsx +119 -0
- package/src/InfoBoxes/AnnoDetails.jsx +53 -53
- package/src/InfoBoxes/AnnoStats.jsx +41 -41
- package/src/InfoBoxes/InfoBox.jsx +16 -16
- package/src/InfoBoxes/InfoBoxArea.jsx +32 -34
- package/src/InfoBoxes/LabelInfo.jsx +30 -30
- package/src/SIASettingButton.jsx +25 -25
- package/src/{Sia2.tsx → Sia.tsx} +181 -183
- package/src/Toolbar/Toolbar.tsx +25 -25
- package/src/Toolbar/ToolbarItems/AccessibilityTools.tsx +23 -43
- package/src/Toolbar/ToolbarItems/AnnoToolSelector.tsx +53 -43
- package/src/Toolbar/ToolbarItems/ImageToolItems/ImageLabelInput.tsx +71 -71
- package/src/Toolbar/ToolbarItems/ImageToolItems/TagLabel.tsx +24 -24
- package/src/Toolbar/ToolbarItems/ImageTools.tsx +28 -30
- package/src/Toolbar/ToolbarItems/Instructions.tsx +47 -50
- package/src/Toolbar/ToolbarItems/InstructionsModal.tsx +8 -8
- package/src/index.ts +7 -17
- package/src/models/AnnotationMode.ts +1 -1
- package/src/models/AnnotationStatus.ts +1 -1
- package/src/models/AnnotationTool.ts +1 -1
- package/src/models/CanvasAction.ts +1 -1
- package/src/models/Direction.ts +1 -1
- package/src/models/EditorModes.ts +1 -1
- package/src/models/KeyAction.ts +2 -1
- package/src/models/NotificationType.ts +1 -1
- package/src/models/index.ts +6 -12
- package/src/siaDummyData.js +71 -71
- package/src/stories/AnnotationTools.stories.tsx +21 -21
- package/src/stories/Button.jsx +11 -15
- package/src/stories/Button.stories.js +17 -17
- package/src/stories/Canvas/Canvas.stories.tsx +31 -26
- package/src/stories/Canvas/CanvasOffset.tsx +23 -25
- package/src/stories/Canvas/CanvasWithOffset.stories.tsx +25 -25
- package/src/stories/FilterDropdown.stories.ts +10 -10
- package/src/stories/Header.jsx +8 -13
- package/src/stories/Header.stories.js +9 -9
- package/src/stories/MinimalSia.stories.tsx +22 -22
- package/src/stories/Page.jsx +21 -26
- package/src/stories/Page.stories.js +14 -14
- package/src/stories/SIA2/DemoWrapper.stories.tsx +22 -22
- package/src/stories/SIA2/DemoWrapper.tsx +20 -24
- package/src/stories/SIA2/Sia2.stories.tsx +24 -24
- package/src/stories/Toolbar/ImageTools/TagLabel.stories.tsx +11 -11
- package/src/stories/Toolbar/Instructions.stories.tsx +11 -11
- package/src/stories/Toolbar/Toolbar.stories.tsx +20 -20
- package/src/stories/siaDummyData.js +71 -71
- package/src/stories/siaDummyData2.ts +72 -72
- package/src/types.ts +47 -47
- package/src/utils/KeyMapper.ts +56 -58
- package/src/utils/TimeUtils.ts +7 -10
- package/src/utils/color.ts +25 -25
- package/src/utils/hist.js +22 -22
- package/src/utils/index.ts +3 -3
- package/src/utils/keyActions.js +81 -81
- package/src/utils/{mouse2.ts → mouse.ts} +9 -9
- package/src/utils/siaIcons.jsx +5 -7
- package/src/utils/{transform2.ts → transform.ts} +66 -72
- package/src/utils/uiConfig.js +19 -22
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as G,jsx as
|
|
1
|
+
import{jsxs as G,jsx as l}from"react/jsx-runtime";import h from"../../models/AnnotationTool.js";import{getDefaultColor as L}from"../../utils/color.js";import H from"./tools/Point.js";import J from"./tools/Line.js";import K from"./atoms/AnnoBar.js";import Q from"../../models/CanvasAction.js";import X from"./tools/BBox.js";import Y from"./tools/Polygon.js";import{useState as I,useRef as x,useEffect as M}from"react";import e from"../../models/AnnotationMode.js";import Z from"../../utils/TimeUtils.js";const lo=({scaledAnnotation:r,annotationSettings:m,possibleLabels:b,svgScale:i,svgTranslation:f,pageToStageOffset:a,strokeWidth:B,nodeRadius:P,isSelected:c,isDisabled:V=!1,onFinishAnnoCreate:w,onLabelIconClicked:W,onAction:k=(n,C)=>{},onAnnoChanged:A=n=>{},onAnnotationModeChange:F=n=>{},onNotification:O=n=>{}})=>{const[n,C]=I(r.coordinates),[t,d]=I(r.mode),[j,D]=I(!1),R=x(void 0),[_,U]=I();M(()=>{R.current=_},[_]);const y=x(n);M(()=>{y.current=n},[n]);const N=()=>{d(e.VIEW);const o={...r,coordinates:y.current};w(o)},q=o=>b.find(s=>s.id===o),T=(()=>{if(!r.labelIds||r.labelIds.length==0)return L();const o=q(r.labelIds[0]);return o===void 0||o.color===void 0||o.color===null?L():o.color})(),u={stroke:T,fill:T,strokeWidth:B/i,r:P/i},p=o=>{C(o);let s=o;[e.ADD,e.MOVE].includes(t)&&(s=o.slice(0,-1)),A({...r,coordinates:s})},g=o=>{[e.ADD,e.CREATE,e.MOVE].includes(t)||(d(e.MOVE),U(performance.now())),C(o)},E=()=>{d(e.VIEW);const o=Z.getRoundedDuration(R.current,performance.now()),s=isNaN(r.annoTime)||r.annoTime===null?o:r.annoTime+o;A({...r,coordinates:y.current,annoTime:s})};M(()=>{F(t)},[t]),M(()=>{t===e.CREATE||t===e.ADD||C(r.coordinates)},[r]);const z=()=>{switch(r.type){case h.Point:return l(H,{isSelected:c,annotationSettings:m,coordinates:n[0],pageToStageOffset:a,svgScale:i,svgTranslation:f,style:u,onMoving:o=>g([o]),onMoved:E,onIsDraggingStateChanged:D});case h.Line:return l(J,{annotationSettings:m,coordinates:n,isSelected:c,pageToStageOffset:a,annotationMode:t,setAnnotationMode:d,svgScale:i,svgTranslation:f,style:u,onAddNode:p,onDeleteNode:p,onMoving:g,onMoved:E,onIsDraggingStateChanged:D,onFinishAnnoCreate:N});case h.BBox:return l(X,{annotationMode:t,annotationSettings:m,startCoords:n[0],endCoords:n[1],isSelected:c,pageToStageOffset:a,style:u,svgScale:i,svgTranslation:f,onDeleteNode:()=>{console.log("TODO")},onIsDraggingStateChanged:D,onFinishAnnoCreate:N,onMoving:g,onMoved:E});case h.Polygon:return l(Y,{annotationSettings:m,coordinates:n,isSelected:c,isDisabled:V,pageToStageOffset:a,annotationMode:t,setAnnotationMode:d,svgScale:i,svgTranslation:f,style:u,onAddNode:p,onDeleteNode:p,onMoving:g,onMoved:E,onNotification:O,onIsDraggingStateChanged:D,onFinishAnnoCreate:N})}};return G("g",{onClick:o=>{o.stopPropagation(),k(r,Q.ANNO_SELECTED)},children:[!j&&t!==e.CREATE&&l(K,{annotationCoordinates:n,canLabel:m.canLabel,labels:b,color:T,isSelected:c,selectedLabelIds:r.labelIds,style:u,svgScale:i,onLabelIconClicked:W}),z()]})};export{lo as default};
|
|
@@ -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};
|
|
@@ -5,5 +5,5 @@ type DaviIconProps = {
|
|
|
5
5
|
size: number;
|
|
6
6
|
onClick?: () => void;
|
|
7
7
|
};
|
|
8
|
-
declare const DaviIcon: ({ x, y, color, size, onClick
|
|
8
|
+
declare const DaviIcon: ({ x, y, color, size, onClick }: DaviIconProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
export default DaviIcon;
|
|
@@ -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 W,jsx as x,Fragment as Qe}from"react/jsx-runtime";import{useState as E,useRef as Z,useEffect as M}from"react";import w from"../models/AnnotationTool.js";import i from"../models/EditorModes.js";import Ze from"../utils/KeyMapper.js";import a from"../models/KeyAction.js";import me from"../Annotation/logic/Annotation.js";import qe from"../models/CanvasAction.js";import et from"../Annotation/ui/AnnotationComponent.js";import pe from"../utils/mouse.js";import N from"../models/AnnotationMode.js";import tt from"./LabelInput.js";import{FontAwesomeIcon as nt}from"@fortawesome/react-fontawesome";import{faBan as ot}from"@fortawesome/free-solid-svg-icons";import D from"../models/AnnotationStatus.js";import C from"../utils/transform.js";import rt from"../models/NotificationType.js";import st from"../utils/TimeUtils.js";import xe from"../utils/windowViewport.js";const wt=({annotations:O=[],annotationSettings:B,defaultLabelId:q,image:ee,isFullscreen:Ce=!1,isImageJunk:K=!1,isPolygonSelectionMode:F=!1,polygonOperationResult:X={annotationsToDelete:[],polygonsToCreate:[]},possibleLabels:te,preventScrolling:ne=!0,selectedAnnotation:r,selectedAnnoTool:R,toolbarHeight:U=0,uiConfig:z,onAnnoCreated:Oe,onAnnoCreationFinished:oe,onAnnoChanged:re,onAnnoEditing:Te=g=>{},onNotification:se=g=>{},onRequestNewAnnoId:k,onSelectAnnotation:A,onSetIsImageJunk:ve,onSetSelectedTool:Ae=g=>{},onShouldDeleteAnno:ie})=>{const[g,T]=E(i.VIEW),[Me,Ie]=E(),[ce,we]=E(q),[V,De]=E({x:-1,y:-1}),[ae,de]=E(0),L={x:V.x,y:V.y},[u,Y]=E({x:-1,y:-1}),[l,G]=E({x:-1,y:-1}),[h,le]=E({x:-1,y:-1}),[d,P]=E(1),[c,S]=E({x:0,y:0}),H={x:c.x+ae,y:c.y},[m,$]=E(),[j,_]=E(!1),fe=Z(null),p=Z(null),y=Z(null),v=((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),Se=()=>{if((y==null?void 0:y.current)===null)return{x:0,y:0};const e=u.x*v;if(z.imageCentered&&l.x>e){const f=(l.x-e)/2;de(f)}else de(0);const{top:t,left:n}=p.current.getBoundingClientRect(),o={x:n+window.scrollX,y:t+window.scrollY};De(o)},_e=new Ze(e=>Pe(e)),be=e=>{T(i.CREATE);const t=C.convertStageCoordinatesToPercentaged([e],v,u);R===w.BBox&&t.push(t[0]);const n=k(),o=new me(n,R,t);if(Ie(performance.now()),ce!==void 0&&(o.labelIds=[ce]),Oe(o),R===w.Point){const s={...o,coordinates:[e],annoTime:0};Q(s)}},Ne=()=>{if(r&&![w.Line,w.Polygon].includes(r.type))return;const e=O.find(n=>n.internalId===(r==null?void 0:r.internalId));if(e===void 0)return;T(i.CREATE),Ae(e.type);const t={...e,mode:N.CREATE,status:D.CREATING,internalId:k(),selectedNode:e.coordinates.length-1};Te(t)},Re=()=>{const e=r?r.internalId:0,t=O.find(n=>n.internalId>e);if(t)return A(t);if(O.length>0)return A(O[0])},ke=()=>{const e=r?r.internalId:0,t=[...O];t.sort((o,s)=>s.internalId-o.internalId);const n=t.find(o=>o.internalId<e);if(n)return A(n);if(O.length>0)return A(O[O.length-1])},Ve=()=>{if(r){const e=JSON.stringify(r);localStorage.setItem("lostAnnotationClipboard",e);const t={title:"Success",message:"Annotation copied",type:rt.SUCCESS};se(t)}},Le=()=>{const e=localStorage.getItem("lostAnnotationClipboard");if(e==null)return;const t=JSON.parse(e);t.internalId=k(),t.externalId="",oe(t,!0),A(t)},Pe=e=>{switch(e){case a.EDIT_LABEL:r&&_(!0);break;case a.DELETE_ANNO:r&&ie(r.internalId);break;case a.DELETE_ANNO_IN_CREATION:g===i.CREATE&&(ie(r.internalId),T(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:Re();break;case a.TRAVERSE_ANNOS_BACKWARDS:ke();break;case a.CAM_MOVE_LEFT:b(20*d,0);break;case a.CAM_MOVE_RIGHT:b(-20*d,0);break;case a.CAM_MOVE_UP:b(0,20*d);break;case a.CAM_MOVE_DOWN:b(0,-20*d);break;case a.CAM_MOVE_STOP:console.log("KeyAction TODO: CAM_MOVE_STOP");break;case a.COPY_ANNOTATION:Ve();break;case a.PASTE_ANNOTATION:Le();break;case a.RECREATE_ANNO:console.log("KeyAction TODO: RECREATE_ANNO"),Ne();break;case a.TOGGLE_IMAGE_JUNK:if(g===i.ADD||g===i.CREATE)return;ve(!K);break;default:console.log("Unknown KeyAction",e);break}},b=(e,t)=>{let n=c.x+e/d,o=c.y+t/d;const s=l.x*.45,f=l.x*.55,I=l.y*.45,je=l.y*.55,Je={x:0,y:0},Ee=xe.getViewportCoordinates(c,l,d,Je),he=xe.getViewportCoordinates(c,l,d,l);Ee.vX>=s?n=c.x-5:he.vX<=f?n=c.x+5:Ee.vY>=I?o=c.y-5:he.vY<=je&&(o=c.y+5),S({x:n,y:o})},J=(e=>h.x<=0||h.y<=0||u.x<=0||u.y<=0?[]:O.map(n=>({...n,coordinates:C.convertPercentagedCoordinatesToStage(n.coordinates,u,h)})))(),We=()=>{if(T(i.VIEW),le({x:-1,y:-1}),y.current!==null){const{width:e,height:t}=y.current.getBoundingClientRect();Y({x:e,y:t})}P(1),S({x:0,y:0}),$(void 0),_(!1)};M(()=>{var e;(e=fe.current)==null||e.focus()},[]),M(()=>{if((p==null?void 0:p.current)!==void 0){const{width:e,height:t}=p.current.getBoundingClientRect(),n=t-U;G({x:e,y:n});const o=new ResizeObserver(()=>{const{width:s,height:f}=p.current.getBoundingClientRect(),I=f-U;G({x:s,y:I})});return o.observe(p.current),()=>o.disconnect()}We()},[ee,Ce]),M(()=>{Se()},[y,c,l]),M(()=>{if(p.current===null)return;const{width:e,height:t}=p.current.getBoundingClientRect(),n=t-U;G({x:e,y:n})},[p]),M(()=>{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]),M(()=>{if(v===0)return;const e={x:u.x*v,y:u.y*v};le(e)},[v,u]),M(()=>{F&&X.polygonsToCreate!==void 0&&X.polygonsToCreate.forEach(e=>{const t=k(),n=new me(t,e.type,C.convertPercentagedCoordinatesToStage(e.coordinates,u,h),N.VIEW,D.CREATED);Q(n)})},[X]);const Q=e=>{T(i.VIEW);const t={...e,mode:N.VIEW};if(e.type!==w.Point){const s=st.getRoundedDuration(Me,performance.now());t.annoTime=s}const n=C.convertStageCoordinatesToPercentaged(e.coordinates,v,u);t.coordinates=n,re(t);const o=R===w.Point||F;oe(t,o)},Be=e=>{e.preventDefault(),_e.keyDown(e.key,e.shiftKey,e.ctrlKey)},Ke=e=>{e.preventDefault()},Fe=e=>{if(e.button!==0){if(e.button===1)T(i.CAMERA_MOVE);else if(e.button===2){if(!B.canCreate||g===i.ADD||g===i.CREATE)return;const t=pe.getAntiScaledMouseStagePosition(e,L,d,c),n={x:t.x-ae,y:t.y};be(n)}}},Xe=()=>{ne&&(document.body.style.overflow="hidden")},Ue=e=>{switch(e.button){case 1:T(i.VIEW);break}},ue=(e,t)=>{g===i.CAMERA_MOVE&&b(e,t)},ze=()=>{ne&&(document.body.style.overflow="")},Ye=e=>{const o=(e.deltaY<0?1:-1)>0?d*1.25:d/1.25,s=pe.getAntiScaledMouseStagePosition(e,L,d,c),f=d/o,I={x:f*(s.x+c.x)-s.x,y:f*(s.y+c.y)-s.y};o<1?(P(1),(c.x!=0||c.y!=0)&&S({x:0,y:0})):o>200?(P(200),S(I)):(P(o),S(I))},Ge=(e,t)=>{if(t!==qe.ANNO_SELECTED){console.log("Unknown Canvas Action:",t);return}const n={...e,coordinates:C.convertStageCoordinatesToPercentaged([...e.coordinates],v,u)};A(n);const o=C.getMostLeftPoints(e.coordinates),s=C.getTopPoint(o)[0],f=C.convertStageToPage(s,L,d,c);$(f)},ge=e=>{const t=C.convertStageCoordinatesToPercentaged(e.coordinates,v,u),n={...e,coordinates:t};n.status===D.LOADED&&(n.status=D.CHANGED),re(n)},He=()=>{if(g===i.CAMERA_MOVE)return x(Qe,{});const t=[i.CREATE,i.ADD,i.MOVE].includes(g),n=J.map(o=>{const s=o.internalId===(r==null?void 0:r.internalId);return t&&!s?x("g",{},`annotationComponent_${o.internalId}`):x(et,{scaledAnnotation:o,annotationSettings:B,possibleLabels:te,svgScale:d,svgTranslation:H,pageToStageOffset:L,nodeRadius:z.nodeRadius,strokeWidth:z.strokeWidth,isSelected:s,isDisabled:F&&s,onFinishAnnoCreate:Q,onLabelIconClicked:()=>_(!0),onAction:Ge,onAnnoChanged:ge,onAnnotationModeChange:f=>{f===N.MOVE&&T(i.MOVE),g===i.MOVE&&f===N.VIEW&&T(i.VIEW)},onNotification:se},`annotationComponent_${o.internalId}`)});if(r){const o=J.find(f=>f.internalId===(r==null?void 0:r.internalId)),s=J.indexOf(o);n.push(n.splice(s,1)[0])}return x("g",{children:n})},$e=()=>x("circle",{cx:h.x/2,cy:h.y/2,r:"100%",style:{opacity:0},onContextMenu:e=>e.preventDefault(),onClick:()=>{_(!1)}}),ye={x:V.x+l.x/2,y:V.y+l.y/2};return W("div",{ref:p,style:{width:"100%",height:"100%"},children:[x("div",{style:{position:"absolute",left:(m==null?void 0:m.x)!==void 0?m.x:0,top:(m==null?void 0:m.y)!==void 0?m.y:0,display:(m==null?void 0:m.y)!==void 0?"inherit":"none",zIndex:j?7e3:-1},children:x(tt,{defaultLabelId:q,isVisible:j,selectedLabelsIds:r==null?void 0:r.labelIds,possibleLabels:te,isMultilabel:B.canHaveMultipleLabels,onLabelSelect:e=>{if(_(!1),e.length>0){const o=e.filter(s=>!r.labelIds.includes(s));o.length>0&&we(o[0])}const t=r.status===D.LOADED?D.CHANGED:r.status,n={...r,coordinates:C.convertPercentagedCoordinatesToStage(r.coordinates,u,h),labelIds:[...e],status:t};ge(n)}})}),K&&W("div",{style:{position:"absolute",left:ye.x,top:ye.y,transform:"translate(-50%, -50%)",textAlign:"center",color:"white"},children:[x(nt,{icon:ot,size:"5x",style:{marginBottom:15}}),x("h2",{children:"Marked as Junk"})]}),W("svg",{ref:fe,width:"100%",height:"100%",onKeyDown:Be,onKeyUp:Ke,onMouseMove:e=>ue(e.movementX,e.movementY),tabIndex:0,onMouseDown:e=>Fe(e),children:[W("g",{transform:`scale(${d}) translate(${H.x}, ${H.y})`,onMouseOver:Xe,onMouseLeave:ze,onMouseUp:Ue,onWheel:Ye,onMouseMove:e=>ue(e.movementX,e.movementY),onClick:()=>{A(void 0)},children:[x("image",{onContextMenu:e=>e.preventDefault(),href:ee,ref:y,width:h.x>0?h.x:void 0,height:h.y>0?h.y:void 0}),He()]}),j&&$e(),K&&x("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};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IconDefinition } from '@fortawesome/free-solid-svg-icons';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
3
|
+
import { SizeProp } from '@fortawesome/fontawesome-svg-core';
|
|
4
|
+
type IconButtonProps = {
|
|
5
|
+
loadingSize?: SizeProp;
|
|
6
|
+
isLoading?: boolean;
|
|
7
|
+
margin?: number;
|
|
8
|
+
icon?: IconDefinition;
|
|
9
|
+
text?: string;
|
|
10
|
+
size?: 'sm' | 'lg' | undefined;
|
|
11
|
+
isTextLeft?: boolean;
|
|
12
|
+
style?: CSSProperties;
|
|
13
|
+
id?: string;
|
|
14
|
+
type?: 'button' | 'submit' | 'reset' | undefined;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
onClick?: () => void;
|
|
17
|
+
className?: string;
|
|
18
|
+
color?: string;
|
|
19
|
+
isOutline?: boolean;
|
|
20
|
+
tooltip?: string;
|
|
21
|
+
ttipPlacement?: 'top' | 'left' | 'right' | 'auto' | 'bottom' | undefined;
|
|
22
|
+
shape?: string;
|
|
23
|
+
};
|
|
24
|
+
declare const IconButton: ({ loadingSize, isLoading, margin, icon, text, size, isTextLeft, style, id, type, disabled, onClick, className, color, isOutline, tooltip, ttipPlacement, shape, }: IconButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export default IconButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as t,jsxs as w}from"react/jsx-runtime";import{faSync as A}from"@fortawesome/free-solid-svg-icons";import{FontAwesomeIcon as v}from"@fortawesome/react-fontawesome";import{CTooltip as F,CButton as y}from"@coreui/react";const D=({loadingSize:o="1x",isLoading:n=!1,margin:c=5,icon:B,text:i="",size:s,isTextLeft:j=!1,style:a={},id:I=void 0,type:N="button",disabled:e=!1,onClick:u,className:l="",color:m="primary",isOutline:C=!0,tooltip:f="",ttipPlacement:T="top",shape:b=""})=>{const r=B,p=C?"outline":void 0,x=()=>{if(n)return w("div",{className:"flex justify-center items-center",children:[t(v,{className:"mr-3",size:o||"2x",icon:A,spin:!0}),t("span",{className:"text-center",children:"Loading"})]});const d=r&&r.iconName&&r.prefix?t(v,{icon:r,size:o||"2x"},"icon"):null,h=i?t("span",{style:{marginLeft:c,marginRight:c},children:i},"text"):null;return j?[h,d]:[d,h]};return f!=""?t(F,{content:f,placement:T,children:t(y,{id:I,size:s,className:l,style:a,variant:p,disabled:e||n,onClick:u,color:e||n?"secondary":m,shape:b,children:x()})}):t(y,{size:s,type:N,className:l,style:a,variant:p,disabled:e||n,onClick:u,color:e||n?"secondary":m,children:x()})};export{D as default};
|
package/dist/Sia.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{jsx as l,jsxs as q}from"react/jsx-runtime";import{useRef as cn,useState as s,useEffect as u}from"react";import{CSpinner as z}from"@coreui/react";import fn from"./Canvas/Canvas.js";import un from"./models/AnnotationTool.js";import In from"./Toolbar/Toolbar.js";import mn from"./models/AnnotationMode.js";import hn from"./models/AnnotationStatus.js";const yn=({additionalButtons:H,allowedTools:S,polygonOperationResult:c={annotationsToDelete:[],polygonsToCreate:[]},annotationSettings:x,uiConfig:g,defaultAnnotationTool:w,defaultLabelId:M,image:I,isLoading:y=!1,isPolygonSelectionMode:b=!1,initialAnnotations:_=[],initialImageLabelIds:C=[],initialIsImageJunk:V=!1,possibleLabels:k,onAnnoCreated:G=(f,m)=>{},onAnnoCreationFinished:K=(f,m)=>{},onAnnoChanged:Q=(f,m)=>{},onAnnoDeleted:E=(f,m)=>{},onImageLabelsChanged:X=()=>{},onIsImageJunk:Y=()=>{},onNotification:Z=f=>{},onSelectAnnotation:$=f=>{}})=>{const m=cn(null),[D,p]=s(),[i,r]=s([]),[j,R]=s(),[O,nn]=s(),[d,h]=s(),[N,B]=s(w!==void 0?w:un.Point),[en,Sn]=s({height:"100%"}),[tn,F]=s(C),[J,L]=s(),[T,on]=s(!1),[U,P]=s([]),v=n=>{const e=i.findIndex(a=>a.internalId===n),t=[...i],o=t.splice(e,1)[0];r(t),h(void 0),E(o,t)},sn=()=>{d!==void 0&&v(d.internalId)},an=()=>{let n=0;const e=_.map(t=>({...t,internalId:n++,mode:mn.VIEW,selectedNode:1,status:t.status,annoTime:t.annoTime!==void 0?t.annoTime:0}));P([...Array(n).keys()]),r(e)},rn=()=>{let n=0;for(;U.includes(n);)n++;const e=[...U];return e.push(n),P(e),n},dn=n=>{const e=[...i],t=e.findIndex(A=>A.internalId===(d==null?void 0:d.internalId));if(t===-1)return;const o=e.splice(t,1)[0];E(o,e);const a=[...e];a.push(n),r(a),h(n)},W=n=>{L(n),Y(n)};u(()=>{I===void 0&&(r([]),h(void 0))},[I]),u(()=>{L(V),!(I!==void 0||_.length===0)&&an()},[_]),u(()=>{F(C)},[C]),u(()=>{const e={...{canCreate:!0,canEdit:!0,canHaveMultipleLabels:!1,canLabel:!0,minimalArea:250},...x};R(e)},[x]),u(()=>{const e={...{nodeRadius:4,strokeWidth:4,imageCentered:!1},...g};nn(e)},[g]),u(()=>{const n={bbox:!0,point:!0,line:!0,junk:!0,polygon:!0};if(S===void 0)return p(n);p(S)},[S]);const ln={position:"fixed",top:0,left:0,zIndex:6e3,backgroundColor:"#ffff",width:"100%",height:"100%",padding:15};return D===void 0?l("div",{className:"d-flex justify-content-center",children:l(z,{color:"primary",style:{width:"5rem",height:"5rem"}})}):q("div",{style:{...T?ln:{},width:"100%",height:"100%"},children:[l("div",{ref:m,style:{marginBottom:10},children:l(In,{annotationSettings:j,allowedTools:D,additionalButtons:H,isDisabled:y,isFullscreen:T,isImageJunk:J,imageLabelIds:tn,possibleLabels:k,selectedTool:N,onImageLabelsChanged:n=>{F(n),X(n)},onSetIsFullscreen:on,onSetIsImageJunk:W,onSetSelectedTool:B,onShouldDeleteSelectedAnnotation:sn})}),q("div",{style:en,children:[y&&l("div",{className:"d-flex justify-content-center",children:l(z,{color:"primary",style:{width:"5rem",height:"5rem",marginTop:200}})}),I&&i&&l(fn,{annotations:i,annotationSettings:j,defaultLabelId:M,image:I,isFullscreen:T,isImageJunk:J,isPolygonSelectionMode:b,selectedAnnotation:d,selectedAnnoTool:N,polygonOperationResult:c,possibleLabels:k,uiConfig:O,onAnnoCreated:n=>{const e=[...i];e.push(n),r(e),h(n),G(n,e)},onAnnoChanged:n=>{const e=i.findIndex(o=>o.internalId===n.internalId);if(e===-1)return;const t=[...i];t[e]=n,r(t),Q(n,t)},onAnnoCreationFinished:(n,e)=>{const t=[...i];if(b&&(c==null?void 0:c.annotationsToDelete)!==void 0&&(c.annotationsToDelete.push(d),c.annotationsToDelete.forEach(o=>{v(o.internalId);const a=t.findIndex(A=>A.internalId===o.internalId);t.splice(a,1)})),e)t.push(n);else{const o=i.findIndex(a=>a.internalId===n.internalId);t[o]=n}r(t),n.status=hn.CREATED,K(n,t)},onAnnoEditing:dn,onSetIsImageJunk:W,onNotification:Z,onRequestNewAnnoId:rn,onSelectAnnotation:n=>{h(n),$(n)},onSetSelectedTool:B,onShouldDeleteAnno:v})]})]})};export{yn as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as n,jsx as o}from"react/jsx-runtime";import{CButtonGroup as a}from"@coreui/react";import{faMaximize as c,faQuestion as p}from"@fortawesome/free-solid-svg-icons";import{useState as m}from"react";import u from"./InstructionsModal.js";import s from"../../IconButton.js";const M=({isDisabled:i=!1,isFullscreen:t=!1,onSetIsFullscreen:e=()=>{}})=>{const[l,r]=m(!1);return n(a,{role:"group","aria-label":"Basic example",children:[o(s,{color:"primary",icon:c,isOutline:!t,disabled:i,onClick:()=>e(!t),tooltip:"Toggle fullscreen"}),o(s,{color:"primary",icon:p,isOutline:!0,disabled:i,onClick:()=>r(!0),tooltip:"Open instructions"}),o(u,{isOpen:l,setIsOpen:r})]})};export{M as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as l,jsx as i}from"react/jsx-runtime";import{CButtonGroup as e}from"@coreui/react";import{pointIcon as c,lineIcon as x,bBoxIcon as u,polygonIcon as g}from"../../utils/siaIcons.js";import o from"../../models/AnnotationTool.js";import{faTrash as y}from"@fortawesome/free-solid-svg-icons";import t from"../../IconButton.js";const k=({allowedTools:r,isDisabled:n=!1,selectedTool:a,onSetSelectedTool:p,onShouldDeleteSelectedAnnotation:m=()=>{}})=>l(e,{role:"group","aria-label":"Basic example",children:[r.point&&i(t,{color:"primary",text:c(),isOutline:a!=o.Point,disabled:n,onClick:()=>p(o.Point),tooltip:"Create Point Annotation",margin:0}),r.line&&i(t,{color:"primary",text:x(),isOutline:a!=o.Line,disabled:n,onClick:()=>p(o.Line),tooltip:"Create Line Annotation",margin:0}),r.bbox&&i(t,{color:"primary",text:u(),isOutline:a!=o.BBox,disabled:n,onClick:()=>p(o.BBox),tooltip:"Create BBox Annotation",margin:0}),r.polygon&&i(t,{color:"primary",text:g(),isOutline:a!=o.Polygon,disabled:n,onClick:()=>p(o.Polygon),tooltip:"Create Polygon Annotation",margin:0}),i(t,{color:"primary",icon:y,isOutline:!0,disabled:n,onClick:m,tooltip:"Delete selected annotation",margin:0})]});export{k as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{jsx as r,jsxs as s}from"react/jsx-runtime";import{useState as C}from"react";import{CTooltip as L,CDropdown as w,CDropdownToggle as v,CDropdownMenu as T,CFormInput as x,CDropdownDivider as y,CDropdownItem as d}from"@coreui/react";import{FontAwesomeIcon as D}from"@fortawesome/react-fontawesome";import{faTag as b}from"@fortawesome/free-solid-svg-icons";import F from"./TagLabel.js";const M=({isDisabled:c,isVisible:m,selectedLabelsIds:t,possibleLabels:n,isMultilabel:p=!1,onLabelSelect:u})=>{const[i,f]=C(""),a=n.filter(e=>e.name.toLowerCase().includes(i.toLowerCase())),g=e=>{let o=[];if(p){o=[...t];const l=t.indexOf(e.id);l!==-1?o.splice(l,1):o.push(e.id)}else o=[e.id];u(o)},h=()=>n.filter(o=>t.includes(o.id));return r(L,{content:"Add Image Label",children:s(w,{visible:m,autoClose:!1,children:[r(v,{variant:"outline",caret:!1,color:c?"secondary":"primary",style:{paddingTop:0,paddingBottom:0},as:"div",children:t.length===0?r("div",{style:{marginTop:6},children:r(D,{icon:b})}):h().map(o=>r(F,{name:o.name,color:o.color,size:25,triangleSize:17,style:{marginLeft:1,marginTop:5}},o.name))}),s(T,{children:[r("div",{className:"px-3 py-2",children:r(x,{placeholder:"Filter label...",value:i,onChange:e=>f(e.target.value),autoFocus:!0})}),r(y,{}),a.length>0?a.map(e=>r(d,{onClick:()=>g(e),children:e.name},e.id)):r(d,{disabled:!0,children:"No results"})]})]})})};export{M as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as n,jsx as r}from"react/jsx-runtime";import{CButtonGroup as c}from"@coreui/react";import{faBan as b}from"@fortawesome/free-solid-svg-icons";import{useState as I,useEffect as d}from"react";import g from"./ImageToolItems/ImageLabelInput.js";import L from"../../IconButton.js";const S=({canJunk:a,isDisabled:e=!1,isFullscreen:s=!1,isImageJunk:o=!1,imageLabelIds:i=[],possibleLabels:l,onImageLabelsChanged:f=()=>{},onSetIsImageJunk:m=()=>{}})=>{const[p,t]=I(!1);return d(()=>{t(!1)},[s]),n(c,{role:"group","aria-label":"Image Tools",children:[l&&r(g,{isDisabled:e,isMultilabel:!0,isVisible:p,selectedLabelsIds:i,possibleLabels:l,onLabelSelect:u=>{t(!1),f(u)}}),a&&r(L,{color:"primary",icon:b,isOutline:!o,disabled:e,onClick:()=>m(!o),tooltip:"Junk image"})]})};export{S as default};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
export * from './types';
|
|
2
|
-
export { default as
|
|
2
|
+
export { default as IconButton } from './IconButton';
|
|
3
3
|
export { default as Sia } from './Sia';
|
|
4
|
-
export { default as Sia2 } from './Sia2';
|
|
5
|
-
export { default as dummyData } from './siaDummyData';
|
|
6
4
|
export { default as transform } from './utils/transform';
|
|
7
|
-
export { default as annoConversion } from './utils/annoConversion';
|
|
8
|
-
export { default as canvasActions } from './types/canvasActions';
|
|
9
5
|
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"./IconButton.js";import{default as m}from"./Sia.js";import{default as l}from"./utils/transform.js";import{default as u}from"./Toolbar/ToolbarItems/ImageToolItems/TagLabel.js";export{e as IconButton,m as Sia,u as TagLabel,l 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};
|
package/dist/models/index.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ import { default as AnnotationMode } from './AnnotationMode';
|
|
|
3
3
|
import { default as AnnotationStatus } from './AnnotationStatus';
|
|
4
4
|
import { default as AnnotationTool } from './AnnotationTool';
|
|
5
5
|
import { default as NotificationType } from './NotificationType';
|
|
6
|
-
export { Annotation, AnnotationMode, AnnotationStatus, AnnotationTool, NotificationType
|
|
6
|
+
export { Annotation, AnnotationMode, AnnotationStatus, AnnotationTool, NotificationType };
|
|
@@ -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-alpha14",
|
|
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"
|
|
@@ -54,7 +53,8 @@
|
|
|
54
53
|
"start": "storybook dev -p 6006",
|
|
55
54
|
"storybook": "storybook dev -p 6006",
|
|
56
55
|
"build-storybook": "storybook build",
|
|
57
|
-
"format": "prettier --write src/"
|
|
56
|
+
"format": "prettier --write src/",
|
|
57
|
+
"pretty": "prettier --write \"./**/*.{js,jsx,mjs,cjs,ts,tsx,json}\""
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@fortawesome/free-regular-svg-icons": "^6.7.2",
|
|
@@ -74,6 +74,8 @@
|
|
|
74
74
|
"react-dom": "^18.0.0"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
78
|
+
"@eslint/js": "^9.39.1",
|
|
77
79
|
"@microsoft/api-extractor": "^7.52.13",
|
|
78
80
|
"@storybook/addon-docs": "^9.1.10",
|
|
79
81
|
"@storybook/addon-links": "^9.0.12",
|
|
@@ -85,16 +87,16 @@
|
|
|
85
87
|
"@typescript-eslint/parser": "^8.46.1",
|
|
86
88
|
"@vitejs/plugin-react": "^4.3.0",
|
|
87
89
|
"cross-env": "^7.0.3",
|
|
88
|
-
"eslint": "^
|
|
90
|
+
"eslint": "^9.39.1",
|
|
89
91
|
"eslint-config-standard": "^17.1.0",
|
|
90
92
|
"eslint-config-standard-react": "^13.0.0",
|
|
91
93
|
"eslint-plugin-import": "^2.29.1",
|
|
92
94
|
"eslint-plugin-node": "^11.1.0",
|
|
93
|
-
"eslint-plugin-promise": "^
|
|
94
|
-
"eslint-plugin-react": "^7.
|
|
95
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
96
|
+
"eslint-plugin-react": "^7.37.5",
|
|
95
97
|
"eslint-plugin-standard": "^5.0.0",
|
|
96
|
-
"eslint-plugin-storybook": "^
|
|
97
|
-
"glob": "^
|
|
98
|
+
"eslint-plugin-storybook": "^10.0.7",
|
|
99
|
+
"glob": "^11.0.3",
|
|
98
100
|
"lodash-es": "^4.17.21",
|
|
99
101
|
"prettier": "^3.3.3",
|
|
100
102
|
"react-redux": "^9.1.2",
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import Prompt from
|
|
2
|
-
import React from
|
|
3
|
-
import { Card, Image } from
|
|
1
|
+
import Prompt from './Prompt'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { Card, Image } from 'semantic-ui-react'
|
|
4
4
|
|
|
5
5
|
const LabelExampleViewer = (props) => {
|
|
6
6
|
const requestExample = (e) => {
|
|
7
|
-
e.stopPropagation()
|
|
7
|
+
e.stopPropagation()
|
|
8
8
|
if (props.onRequestExample) {
|
|
9
|
-
props.onRequestExample()
|
|
9
|
+
props.onRequestExample()
|
|
10
10
|
}
|
|
11
|
-
}
|
|
11
|
+
}
|
|
12
12
|
const renderContent = () => {
|
|
13
|
-
if (!props.lbl) return null
|
|
14
|
-
if (!props.exampleImg) return null
|
|
13
|
+
if (!props.lbl) return null
|
|
14
|
+
if (!props.exampleImg) return null
|
|
15
15
|
const description = (
|
|
16
16
|
<div>
|
|
17
17
|
{props.lbl.description}
|
|
18
18
|
<h4>Comment:</h4>
|
|
19
|
-
{props.exampleImg.anno ? props.exampleImg.anno.comment :
|
|
19
|
+
{props.exampleImg.anno ? props.exampleImg.anno.comment : 'no comment'}
|
|
20
20
|
</div>
|
|
21
|
-
)
|
|
21
|
+
)
|
|
22
22
|
return (
|
|
23
23
|
<div>
|
|
24
24
|
<Card
|
|
@@ -46,24 +46,24 @@ const LabelExampleViewer = (props) => {
|
|
|
46
46
|
{props.lbl.description}
|
|
47
47
|
<Image src={props.exampleImg.img} centered size='medium'></Image> */}
|
|
48
48
|
</div>
|
|
49
|
-
)
|
|
50
|
-
}
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
51
|
|
|
52
52
|
const handlePromptClick = () => {
|
|
53
53
|
if (props.onClose) {
|
|
54
|
-
props.onClose()
|
|
54
|
+
props.onClose()
|
|
55
55
|
}
|
|
56
|
-
}
|
|
56
|
+
}
|
|
57
57
|
|
|
58
58
|
return (
|
|
59
59
|
<Prompt
|
|
60
60
|
onClick={() => {
|
|
61
|
-
handlePromptClick()
|
|
61
|
+
handlePromptClick()
|
|
62
62
|
}}
|
|
63
63
|
active={props.active}
|
|
64
64
|
content={renderContent()}
|
|
65
65
|
/>
|
|
66
|
-
)
|
|
67
|
-
}
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
68
|
|
|
69
|
-
export default LabelExampleViewer
|
|
69
|
+
export default LabelExampleViewer
|