@labelbee/lb-annotation 1.14.0-alpha.0 → 1.14.0-alpha.2
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/constant/defaultConfig.js +1 -1
- package/dist/core/pointCloud/annotation.js +1 -1
- package/dist/core/pointCloud/index.js +2 -2
- package/dist/core/scheduler.js +1 -1
- package/dist/core/toolOperation/LineToolOperation.js +1 -1
- package/dist/core/toolOperation/ViewOperation.js +1 -1
- package/dist/core/toolOperation/cuboidOperation.js +1 -1
- package/dist/core/toolOperation/pointOperation.js +1 -1
- package/dist/index.js +1 -1
- package/dist/types/core/pointCloud/annotation.d.ts +8 -3
- package/dist/types/core/pointCloud/index.d.ts +34 -4
- package/dist/types/core/pointCloud/matrix.d.ts +1 -1
- package/dist/types/core/scheduler.d.ts +12 -1
- package/dist/types/core/toolOperation/LineToolOperation.d.ts +11 -0
- package/dist/types/core/toolOperation/cuboidOperation.d.ts +21 -2
- package/dist/types/core/toolOperation/pointOperation.d.ts +6 -1
- package/dist/types/core/toolOperation/textAttributeClass.d.ts +9 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/utils/tool/CuboidUtils.d.ts +1 -1
- package/dist/types/utils/tool/DrawUtils.d.ts +19 -1
- package/dist/utils/tool/AxisUtils.js +1 -1
- package/dist/utils/tool/CuboidUtils.js +1 -1
- package/dist/utils/tool/DrawUtils.js +3 -3
- package/es/constant/defaultConfig.js +1 -1
- package/es/core/pointCloud/annotation.js +1 -1
- package/es/core/pointCloud/index.js +2 -2
- package/es/core/scheduler.js +1 -1
- package/es/core/toolOperation/LineToolOperation.js +1 -1
- package/es/core/toolOperation/ViewOperation.js +1 -1
- package/es/core/toolOperation/cuboidOperation.js +1 -1
- package/es/core/toolOperation/pointOperation.js +1 -1
- package/es/index.js +1 -1
- package/es/utils/tool/AttributeUtils.js +1 -1
- package/es/utils/tool/AxisUtils.js +1 -1
- package/es/utils/tool/CuboidUtils.js +1 -1
- package/es/utils/tool/DrawUtils.js +3 -3
- package/package.json +3 -3
- package/dist/types/core/pointCloud/segmentation.d.ts +0 -0
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +0 -12
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +0 -7
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +0 -11
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +0 -18
- package/es/core/pointCloud/segmentation.js +0 -50
- package/es/core/toolOperation/scribbleTool2.js +0 -249
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EToolName as p,ELineTypes as k,edgeAdsorptionScope as _,EOperationMode as E}from"../../constant/tool.js";import j from"../../utils/tool/RectUtils.js";import D from"../../utils/tool/PolygonUtils.js";import P from"../../utils/tool/MarkerUtils.js";import z from"../../utils/MathUtils.js";import{EDragStatus as g,ESortDirection as w,DEFAULT_TEXT_OFFSET as N}from"../../constant/annotation.js";import S from"../../constant/keyCode.js";import C from"../../locales/index.js";import{EMessage as A}from"../../locales/constants.js";import I from"../../utils/tool/AttributeUtils.js";import c from"../../utils/tool/AxisUtils.js";import r from"../../utils/tool/CommonToolUtils.js";import x from"../../utils/tool/DrawUtils.js";import B from"../../utils/tool/StyleUtils.js";import Z from"../../utils/uuid.js";import{BasicToolOperation as H}from"./basicToolOperation.js";import W from"./textAttributeClass.js";var F=Object.defineProperty,K=Object.defineProperties,$=Object.getOwnPropertyDescriptors,T=Object.getOwnPropertySymbols,V=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable,R=Math.pow,O=(m,t,e)=>t in m?F(m,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):m[t]=e,L=(m,t)=>{for(var e in t||(t={}))V.call(t,e)&&O(m,e,t[e]);if(T)for(var e of T(t))X.call(t,e)&&O(m,e,t[e]);return m},y=(m,t)=>K(m,$(t));const U=200;class q extends H{constructor(t){super(t);this.setMarkerIndex=e=>{this.markerIndex=e},this.setMarkerIndexAndSelect=e=>{if(!this.config.markerList)return;this.markerIndex=e;const i=this.config.markerList[e].value,s=this.currentPageResult.find(o=>o.label===i);s&&(this.setSelectedID(s.id),this.config.attributeConfigurable===!0&&this.setDefaultAttribute(s.attribute)),this.emit("markIndexChange")},this.textChange=e=>{this.config.textConfigurable!==!0||!this.selectedID||(this.setPointList(I.textChange(e,this.selectedID,this.pointList)),this.emit("selectedChange"),this.render())},this.isMinDistance=e=>{const i=c.changePointByZoom(e,this.zoom);return this.pointList.some(s=>{const o=c.changePointByZoom(s,this.zoom);return z.getLineLength(o,i)<.2})},this.config=r.jsonParser(t.config),this.pointList=[],this.markerIndex=0,this.setStyle(t.style),this.createPoint=this.createPoint.bind(this),this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this),this.setSelectedID=this.setSelectedID.bind(this)}get dataList(){return this.pointList}get drawOutsideTarget(){var t;return(t=this.config.drawOutsideTarget)!=null?t:this.config.drawPointOut}setNextMarker(t=this.pointList){if(this.hasMarkerConfig){const e=r.getNextMarker(this.getCurrentPageResult(t),this.config.markerList);e&&this.setMarkerIndexAndSelect(e.index)}}setResult(t){this.clearActiveStatus(),this.setPointList(t),this.setNextMarker(t),this.recoverOperationMode(),this.render()}setPointList(t,e=!1){const i=this.pointList.length;this.pointList=t,i!==t.length&&this.emit("updatePageNumber"),e&&this.emit("updateResult")}setConfig(t,e=!1){this.config=r.jsonParser(t),e===!0&&this.clearResult()}clearResult(){this.setPointList([]),this.setSelectedID(void 0),this.history.pushHistory([]),this.hoverID="",this.render()}setDefaultAttribute(t=""){const e=this.defaultAttribute;if(this.defaultAttribute=t,e!==t){this.changeStyle(t),this.emit("changeAttributeSidebar");const{selectedID:i}=this;if(i&&(this.pointList.forEach(s=>{s.id===i&&(s.attribute=t)}),this.history.pushHistory(this.pointList),this.render()),this._textAttributInstance){if(this.attributeLockList.length>0&&!this.attributeLockList.includes(t)){this._textAttributInstance.clearTextAttribute();return}this._textAttributInstance.updateIcon(this.getTextIconSvg(t))}}}get selectedText(){var t;return(t=this.pointList.find(e=>e.id===this.selectedID))==null?void 0:t.textAttribute}setStyle(t){var e;super.setStyle(t),this._textAttributInstance&&this.config.attributeConfigurable===!1&&((e=this._textAttributInstance)==null||e.updateIcon(this.getTextIconSvg()))}setSelectedID(t){var e,i;const s=this.selectedID;t!==s&&s&&((e=this._textAttributInstance)==null||e.changeSelected()),t||(i=this._textAttributInstance)==null||i.clearTextAttribute(),this.selectedID=t,this.render(),this.emit("selectedChange")}getTextIconSvg(t=""){return I.getTextIconSvg(t,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}clearActiveStatus(){this.hoverID=void 0,this.dragStatus=g.Wait,this.setSelectedID(void 0)}setBasicResult(t){super.setBasicResult(t),this.setNextMarker(),this.clearActiveStatus()}onDragMoveAll(t){var e,i;!((i=(e=this.dragInfo)==null?void 0:e.originPointList)==null?void 0:i.length)||(this.setPointList(this.dragInfo.originPointList.map(s=>y(L({},s),{x:s.x+t.x/this.zoom,y:s.y+t.y/this.zoom}))),this.render())}onMouseDown(t){if(!(super.onMouseDown(t)||this.forbidMouseOperation)){if(t.button===0&&!this.hoverID){this.recoverOperationMode(),this.createPoint(t),this.render();return}if((this.hoverID===this.selectedID||this.isMultiMoveMode&&this.hoverID)&&t.button===0){this.dragStatus=g.Start,this.isMultiMoveMode&&(this.dragInfo={dragStartCoord:this.getCoordinateUnderZoom(t),originPointList:this.pointList});return}return this.render(),!0}}onMouseMove(t){super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo||(this.hoverID=this.getHoverId(),(this.dragStatus===g.Start||this.dragStatus===g.Move)&&this.onDragMove(t),this.hoverID&&this.render())}onMouseUp(t){if(super.onMouseUp(t)||this.forbidMouseOperation||!this.imgInfo)return!0;t.button===2&&this.rightMouseUp(),this.dragStatus===g.Move&&(this.history.pushHistory(this.pointList),this.dragInfo=void 0),this.dragStatus=g.Wait,this.render()}onDragMove(t){var e,i;if(!this.imgInfo)return;this.dragStatus=g.Move;const s=this.getCoordinateUnderZoom(t);if(this.isMultiMoveMode&&this.dragInfo){const a={x:s.x-this.dragInfo.dragStartCoord.x,y:s.y-this.dragInfo.dragStartCoord.y};this.onDragMoveAll(a);return}const o=c.changeDrawOutsideTarget(s,{x:0,y:0},this.imgInfo,this.drawOutsideTarget,this.basicResult,this.zoom),l=this.drawOutsideTarget?c.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos):c.changePointByZoom(o,1/this.zoom);this.drawOutsideTarget===!1&&this.dependToolName===p.Polygon&&((i=(e=this.basicResult)==null?void 0:e.pointList)==null?void 0:i.length)>0&&!D.isInPolygon(l,this.basicResult.pointList)||(this.pointList.forEach(a=>{a.id===this.selectedID&&(a.x=l.x,a.y=l.y)}),this.render())}onKeyDown(t){if(!r.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case S.Delete:this.deletePoint();break;case S.Tab:{this.onTabKeyDown(t);break}case S.Z:this.setIsHidden(!this.isHidden),this.render();break;default:{if(this.config.attributeConfigurable){const i=I.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}}createPoint(t){var e,i,s,o;if(!this.imgInfo)return;const{upperLimit:l}=this.config;if(l&&this.currentPageResult.length>=l){this.emit("messageInfo",`${C.getMessagesByLocale(A.LowerLimitPoint,this.lang)}`);return}const a=r.getSourceID(this.basicResult),u=this.getCoordinateUnderZoom(t);let d=c.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);if(this.config.edgeAdsorption&&this.referenceData&&[p.Polygon,p.Line].includes((e=this.referenceData)==null?void 0:e.toolName)){const b=((i=this.referenceData)==null?void 0:i.toolName)===p.Polygon,{dropFoot:v,hasClosed:M}=D.getClosestPoint(d,this.referenceData.result,(o=(s=this.referenceData.config)==null?void 0:s.lineType)!=null?o:k.Line,_/this.zoom,{isClose:b});v&&(d=v),M&&this.emit("messageSuccess",`${C.getMessagesByLocale(A.SuccessfulEdgeAdsorption,this.lang)}`)}if(this.drawOutsideTarget===!1){if(this.dependToolName&&this.basicCanvas){let h=!1;switch(this.dependToolName){case p.Rect:{h=!j.isInRect(d,this.basicResult);break}case p.Polygon:{h=!D.isInPolygon(d,this.basicResult.pointList);break}}if(h)return}if(u.x<0||u.y<0||u.x>this.imgInfo.width||u.y>this.imgInfo.height)return}if(this.isMinDistance(d))return;let n=y(L({},d),{attribute:this.defaultAttribute,valid:!t.ctrlKey,id:Z(8,62),sourceID:a,textAttribute:"",order:r.getMaxOrder(this.pointList.filter(h=>r.isSameSourceID(h.sourceID,a)))+1});if(this.config.textConfigurable){let h="";h=I.getTextAttribute(this.pointList.filter(b=>r.isSameSourceID(b.sourceID,a)),this.config.textCheckType),n=y(L({},n),{textAttribute:h})}if(this.hasMarkerConfig){const h=r.getNextMarker(this.currentPageResult,this.config.markerList,this.markerIndex);if(h)n=y(L({},n),{label:h.label}),this.markerIndex=h.index,this.emit("markIndexChange");else{this.emit("messageInfo",C.getMessagesByLocale(A.MarkerFinish,this.lang));return}}this.hoverID=n.id;const f=[...this.pointList,n];this.setPointList(f),this.history.pushHistory(f),this.setSelectedID(n.id)}isInPoint(t,e,i=this.zoom){return(this.style.width+2)/i>=Math.sqrt(R(t.x-e.x,2)+R(t.y-e.y,2))}getHoverId(){var t;const e=c.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos),i=(t=this.pointList)==null?void 0:t.find(s=>this.isInPoint(e,s));return i==null?void 0:i.id}rightMouseUp(){if(this.recoverOperationMode(),this.selectedID===this.hoverID){const e=this.pointList.filter(i=>i.id!==this.selectedID);this.setPointList(e),this.history.pushHistory(e),this.setSelectedID(""),this.hoverID="";return}const t=this.pointList.find(e=>e.id===this.hoverID);if(this.setSelectedID(this.hoverID),this.setDefaultAttribute(t==null?void 0:t.attribute),(t==null?void 0:t.label)&&this.hasMarkerConfig){const e=r.getCurrentMarkerIndex(t.label,this.config.markerList);e>=0&&(this.setMarkerIndex(e),this.emit("markIndexChange"))}}onTabKeyDown(t){if(t.preventDefault(),this.dragStatus===g.Move||this.dragStatus===g.Start)return;let e=w.ascend;t.shiftKey&&(e=w.descend);const[i,s]=r.getRenderResultList(this.pointList,r.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);let o=[...i];s&&(o=[...o,s]);const l=r.getNextSelectedRectID(o,e,this.selectedID);l&&this.setSelectedID(l.id)}get currentPageResult(){const[t]=r.getRenderResultList(this.pointList,r.getSourceID(this.basicResult),[]);return t}getCurrentPageResult(t){const[e]=r.getRenderResultList(t,r.getSourceID(this.basicResult),[]);return e}exportData(){const{pointList:t}=this;return[t,this.basicImgInfo]}deletePoint(){var t;this.selectedID&&(this.setPointList(this.pointList.filter(e=>e.id!==this.selectedID)),this.history.pushHistory(this.pointList),(t=this._textAttributInstance)==null||t.clearTextAttribute(),this.emit("selectedChange"),this.render())}undoAndRedo(t){var e,i;if(this.dragStatus===g.Move||this.dragStatus===g.Start)return;const s=(i=(e=this.history)[t])==null?void 0:i.call(e);(s==null?void 0:s.some(o=>o.id===this.selectedID))||this.setSelectedID(""),s&&(this.setPointList(s,!0),this.render())}undo(){this.undoAndRedo("undo")}redo(){this.undoAndRedo("redo")}getCurrentSelectedData(){var t;if(!this.selectedID)return;const e=(t=this.pointList)==null?void 0:t.find(o=>o.id===this.selectedID),i=this.getColor(e==null?void 0:e.attribute),s=(e==null?void 0:e.valid)?i==null?void 0:i.valid.stroke:i==null?void 0:i.invalid.stroke;return this.dragStatus=g.Wait,{width:U*this.zoom*.6,textAttribute:(e==null?void 0:e.textAttribute)||"",color:s}}updateSelectedTextAttribute(t){if(this._textAttributInstance&&t&&this.selectedID){let e=t;I.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",I.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setPointList(I.textChange(e,this.selectedID,this.pointList)),this.emit("updateTextAttribute"),this.render()}}renderTextAttribute(){var t,e;const i=(t=this.pointList)==null?void 0:t.find(b=>b.id===this.selectedID);if(!this.ctx||this.config.textConfigurable!==!0||!i)return;const{x:s,y:o,attribute:l,valid:a}=i,u=U*this.zoom*.6,d=c.getOffsetCoordinate({x:s,y:o},this.currentPos,this.zoom),n=this.getColor(l),f=a?n==null?void 0:n.valid.stroke:n==null?void 0:n.invalid.stroke,h=4;this._textAttributInstance||(this._textAttributInstance=new W({width:u,container:this.container,icon:this.getTextIconSvg(l),color:f,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributInstance&&!((e=this._textAttributInstance)==null?void 0:e.isExit)&&this._textAttributInstance.appendToContainer(),this._textAttributInstance.update(`${i.textAttribute}`,{left:d.x,top:d.y+h,color:f,width:u})}renderPoint(t,e=!1){var i,s,o;const{textAttribute:l="",attribute:a}=t,u=e||t.id===this.selectedID,d=this.getColor(a),n=c.changePointByZoom(t,this.zoom,this.currentPos),{width:f=2,hiddenText:h=!1}=this.style,b=B.getStrokeAndFill(d,t.valid,{isSelected:u||t.id===this.hoverID});x.drawCircle(this.canvas,n,f,{startAngleDeg:0,endAngleDeg:360,thickness:1,color:b.stroke,fill:b.fill});let v="";(((i=this.config)==null?void 0:i.isShowOrder)||((s=this.config)==null?void 0:s.showOrder))&&t.order&&(t==null?void 0:t.order)>0&&(v=`${t.order}`),t.label&&this.hasMarkerConfig&&(v=`${r.getCurrentMarkerIndex(t.label,this.config.markerList)+1}_${P.getMarkerShowText(t.label,this.config.markerList)}`),t.attribute&&(v=`${v} ${I.getAttributeShowText(t.attribute,(o=this.config)==null?void 0:o.attributeList)}`),h||x.drawText(this.canvas,{x:n.x+f/2,y:n.y-f-4},v,{textAlign:"center",color:b.stroke}),u?this.renderTextAttribute():h||x.drawText(this.canvas,{x:n.x+f,y:n.y+f+24},l,L({color:b.stroke},N))}renderMultiSelectedPoint(){!this.isMultiMoveMode||this.pointList.forEach(t=>{this.renderPoint(t,!0)})}renderPointList(){switch(this.operationMode){case E.MultiMove:this.renderMultiSelectedPoint();break;default:{const[t,e]=r.getRenderResultList(this.pointList,r.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);this.isHidden||t.forEach(i=>{this.renderPoint(i)}),e&&this.renderPoint(e)}}}renderAuxiliaryLine(){var t;if(!this.config.markerConfigurable||!((t=this.config.markerList)==null?void 0:t.length))return;const[e,i]=r.getRenderResultList(this.pointList,r.getSourceID(this.basicResult),this.attributeLockList,this.selectedID),s=e;if(i&&s.push(i),s.length<2)return;const o=P.getAuxiliaryLineByMarkerList(this.config.markerList,"value");P.getAuxiliaryLineCoord(o,s).forEach(a=>{const{start:u,end:d}=a,n=c.changePointListByZoom([u,d],this.zoom,this.currentPos);x.drawLine(this.canvas,n[0],n[1],{color:"#C5C5C5"})})}renderTop(){var t,e,i;const s=this.getLineColor(this.defaultAttribute);if(this.renderCursorLine(s),this.config.edgeAdsorption&&this.referenceData){let o=c.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);const l=((t=this.referenceData)==null?void 0:t.toolName)===p.Polygon,{dropFoot:a}=D.getClosestPoint(o,this.referenceData.result,(i=(e=this.referenceData.config)==null?void 0:e.lineType)!=null?i:k.Line,_/this.zoom,{isClose:l});a&&o!==a&&o!==a&&(o=a,x.drawCircle(this.canvas,c.changePointByZoom(o,this.zoom,this.currentPos),5,{color:"white",fill:"white"}),x.drawCircle(this.canvas,c.changePointByZoom(o,this.zoom,this.currentPos),3,{fill:s,color:s}))}}render(){!this.ctx||(super.render(),this.renderAuxiliaryLine(),this.renderPointList(),this.renderTop())}}export{q as default};
|
|
1
|
+
import{EToolName as p,ELineTypes as _,edgeAdsorptionScope as k,EOperationMode as E}from"../../constant/tool.js";import j from"../../utils/tool/RectUtils.js";import L from"../../utils/tool/PolygonUtils.js";import P from"../../utils/tool/MarkerUtils.js";import z from"../../utils/MathUtils.js";import N from"lodash";import{EDragStatus as f,ESortDirection as w,DEFAULT_TEXT_OFFSET as B}from"../../constant/annotation.js";import S from"../../constant/keyCode.js";import C from"../../locales/index.js";import{EMessage as A}from"../../locales/constants.js";import v from"../../utils/tool/AttributeUtils.js";import c from"../../utils/tool/AxisUtils.js";import h from"../../utils/tool/CommonToolUtils.js";import x from"../../utils/tool/DrawUtils.js";import Z from"../../utils/tool/StyleUtils.js";import H from"../../utils/uuid.js";import{BasicToolOperation as W}from"./basicToolOperation.js";import F from"./textAttributeClass.js";var K=Object.defineProperty,$=Object.defineProperties,V=Object.getOwnPropertyDescriptors,T=Object.getOwnPropertySymbols,X=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable,R=Math.pow,O=(m,t,e)=>t in m?K(m,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):m[t]=e,D=(m,t)=>{for(var e in t||(t={}))X.call(t,e)&&O(m,e,t[e]);if(T)for(var e of T(t))q.call(t,e)&&O(m,e,t[e]);return m},y=(m,t)=>$(m,V(t));const U=200;class G extends W{constructor(t){super(t);this.setMarkerIndex=s=>{this.markerIndex=s},this.setMarkerIndexAndSelect=s=>{if(!this.config.markerList)return;this.markerIndex=s;const o=this.config.markerList[s].value,n=this.currentPageResult.find(r=>r.label===o);n&&(this.setSelectedID(n.id),this.config.attributeConfigurable===!0&&this.setDefaultAttribute(n.attribute)),this.emit("markIndexChange")},this.textChange=s=>{this.config.textConfigurable!==!0||!this.selectedID||(this.setPointList(v.textChange(s,this.selectedID,this.pointList)),this.emit("selectedChange"),this.render())},this.isMinDistance=s=>{const o=c.changePointByZoom(s,this.zoom);return this.pointList.some(n=>{const r=c.changePointByZoom(n,this.zoom);return z.getLineLength(r,o)<.2})};var e,i;this.config=h.jsonParser(t.config),this.pointList=[],this.markerIndex=0,this.setStyle(t.style),this.createPoint=this.createPoint.bind(this),this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this),this.setSelectedID=this.setSelectedID.bind(this),this.forbidAddNew=(e=t.forbidAddNew)!=null?e:!1,this.forbidDelete=(i=t.forbidDelete)!=null?i:!1}get dataList(){return this.pointList}get drawOutsideTarget(){var t;return(t=this.config.drawOutsideTarget)!=null?t:this.config.drawPointOut}setNextMarker(t=this.pointList){if(this.hasMarkerConfig){const e=h.getNextMarker(this.getCurrentPageResult(t),this.config.markerList);e&&this.setMarkerIndexAndSelect(e.index)}}setResult(t){this.clearActiveStatus(),this.setPointList(t),this.setNextMarker(t),this.recoverOperationMode(),this.render()}setPointList(t,e=!1){const i=this.pointList.length;this.pointList=t,i!==t.length&&this.emit("updatePageNumber"),e&&this.emit("updateResult")}setConfig(t,e=!1){this.config=h.jsonParser(t),e===!0&&this.clearResult()}clearResult(){this.setPointList([]),this.setSelectedID(void 0),this.history.pushHistory([]),this.hoverID="",this.render()}setDefaultAttribute(t=""){const e=this.defaultAttribute;if(this.defaultAttribute=t,e!==t){this.changeStyle(t),this.emit("changeAttributeSidebar");const{selectedID:i}=this;if(i&&(this.pointList.forEach(s=>{s.id===i&&(s.attribute=t)}),this.history.pushHistory(this.pointList),this.render()),this._textAttributInstance){if(this.attributeLockList.length>0&&!this.attributeLockList.includes(t)){this._textAttributInstance.clearTextAttribute();return}this._textAttributInstance.updateIcon(this.getTextIconSvg(t))}}}get selectedText(){var t;return(t=this.pointList.find(e=>e.id===this.selectedID))==null?void 0:t.textAttribute}setStyle(t){var e;super.setStyle(t),this._textAttributInstance&&this.config.attributeConfigurable===!1&&((e=this._textAttributInstance)==null||e.updateIcon(this.getTextIconSvg()))}setSelectedID(t){var e,i;const s=this.selectedID;t!==s&&s&&((e=this._textAttributInstance)==null||e.changeSelected()),t||(i=this._textAttributInstance)==null||i.clearTextAttribute(),this.selectedID=t,this.render(),this.emit("selectedChange")}getTextIconSvg(t=""){return v.getTextIconSvg(t,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}clearActiveStatus(){this.hoverID=void 0,this.dragStatus=f.Wait,this.setSelectedID(void 0)}setBasicResult(t){super.setBasicResult(t),this.setNextMarker(),this.clearActiveStatus()}onDragMoveAll(t){var e,i;!((i=(e=this.dragInfo)==null?void 0:e.originPointList)==null?void 0:i.length)||(this.setPointList(this.dragInfo.originPointList.map(s=>y(D({},s),{x:s.x+t.x/this.zoom,y:s.y+t.y/this.zoom}))),this.render())}onMouseDown(t){if(!(super.onMouseDown(t)||this.forbidMouseOperation)){if(t.button===0&&!this.hoverID){this.recoverOperationMode(),this.createPoint(t),this.render();return}if((this.hoverID===this.selectedID||this.isMultiMoveMode&&this.hoverID)&&t.button===0){this.dragStatus=f.Start,this.dragInfo={dragStartCoord:this.getCoordinateUnderZoom(t),originPointList:N.cloneDeep(this.pointList)};return}return this.render(),!0}}onMouseMove(t){super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo||(this.hoverID=this.getHoverId(),(this.dragStatus===f.Start||this.dragStatus===f.Move)&&this.onDragMove(t),this.hoverID&&this.render())}onMouseUp(t){var e;if(super.onMouseUp(t)||this.forbidMouseOperation||!this.imgInfo)return!0;t.button===2&&this.rightMouseUp(),this.dragStatus===f.Move&&(this.history.pushHistory(this.pointList),this.emit("updatePointByDrag",this.pointList.find(i=>(i==null?void 0:i.id)===this.selectedID),(e=this.dragInfo)==null?void 0:e.originPointList),this.dragInfo=void 0),this.dragStatus=f.Wait,this.render()}onDragMove(t){var e,i;if(!this.imgInfo)return;this.dragStatus=f.Move;const s=this.getCoordinateUnderZoom(t);if(this.isMultiMoveMode&&this.dragInfo){const r={x:s.x-this.dragInfo.dragStartCoord.x,y:s.y-this.dragInfo.dragStartCoord.y};this.onDragMoveAll(r);return}const o=c.changeDrawOutsideTarget(s,{x:0,y:0},this.imgInfo,this.drawOutsideTarget,this.basicResult,this.zoom),n=this.drawOutsideTarget?c.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos):c.changePointByZoom(o,1/this.zoom);this.drawOutsideTarget===!1&&this.dependToolName===p.Polygon&&((i=(e=this.basicResult)==null?void 0:e.pointList)==null?void 0:i.length)>0&&!L.isInPolygon(n,this.basicResult.pointList)||(this.pointList.forEach(r=>{r.id===this.selectedID&&(r.x=n.x,r.y=n.y)}),this.render())}onKeyDown(t){if(!h.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case S.Delete:this.deletePoint();break;case S.Tab:{this.onTabKeyDown(t);break}case S.Z:this.setIsHidden(!this.isHidden),this.render();break;default:{if(this.config.attributeConfigurable){const i=v.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}}createPoint(t){var e,i,s,o;if(!this.imgInfo||this.forbidAddNew)return;const{upperLimit:n}=this.config;if(n&&this.currentPageResult.length>=n){this.emit("messageInfo",`${C.getMessagesByLocale(A.LowerLimitPoint,this.lang)}`);return}const r=h.getSourceID(this.basicResult),u=this.getCoordinateUnderZoom(t);let d=c.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);if(this.config.edgeAdsorption&&this.referenceData&&[p.Polygon,p.Line].includes((e=this.referenceData)==null?void 0:e.toolName)){const b=((i=this.referenceData)==null?void 0:i.toolName)===p.Polygon,{dropFoot:I,hasClosed:M}=L.getClosestPoint(d,this.referenceData.result,(o=(s=this.referenceData.config)==null?void 0:s.lineType)!=null?o:_.Line,k/this.zoom,{isClose:b});I&&(d=I),M&&this.emit("messageSuccess",`${C.getMessagesByLocale(A.SuccessfulEdgeAdsorption,this.lang)}`)}if(this.drawOutsideTarget===!1){if(this.dependToolName&&this.basicCanvas){let l=!1;switch(this.dependToolName){case p.Rect:{l=!j.isInRect(d,this.basicResult);break}case p.Polygon:{l=!L.isInPolygon(d,this.basicResult.pointList);break}}if(l)return}if(u.x<0||u.y<0||u.x>this.imgInfo.width||u.y>this.imgInfo.height)return}if(this.isMinDistance(d))return;let a=y(D({},d),{attribute:this.defaultAttribute,valid:!t.ctrlKey,id:H(8,62),sourceID:r,textAttribute:"",order:h.getMaxOrder(this.pointList.filter(l=>h.isSameSourceID(l.sourceID,r)))+1});if(this.config.textConfigurable){let l="";l=v.getTextAttribute(this.pointList.filter(b=>h.isSameSourceID(b.sourceID,r)),this.config.textCheckType),a=y(D({},a),{textAttribute:l})}if(this.hasMarkerConfig){const l=h.getNextMarker(this.currentPageResult,this.config.markerList,this.markerIndex);if(l)a=y(D({},a),{label:l.label}),this.markerIndex=l.index,this.emit("markIndexChange");else{this.emit("messageInfo",C.getMessagesByLocale(A.MarkerFinish,this.lang));return}}this.hoverID=a.id;const g=[...this.pointList,a];this.setPointList(g),this.emit("pointCreated",a,this.zoom),this.history.pushHistory(g),this.setSelectedID(a.id)}isInPoint(t,e,i=this.zoom){return(this.style.width+2)/i>=Math.sqrt(R(t.x-e.x,2)+R(t.y-e.y,2))}getHoverId(){var t;const e=c.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos),i=(t=this.pointList)==null?void 0:t.find(s=>this.isInPoint(e,s));return i==null?void 0:i.id}get selectedPoint(){return this.pointList.find(t=>t.id===this.selectedID)}rightMouseUp(){if(this.recoverOperationMode(),this.selectedID===this.hoverID){if(this.forbidDelete)return;const e=this.pointList.filter(i=>i.id!==this.selectedID);this.setPointList(e),this.history.pushHistory(e),this.emit("pointDeleted",this.selectedID),this.setSelectedID(""),this.hoverID="";return}const t=this.pointList.find(e=>e.id===this.hoverID);if(this.setSelectedID(this.hoverID),this.emit("pointSelected",this.hoverID),this.setDefaultAttribute(t==null?void 0:t.attribute),(t==null?void 0:t.label)&&this.hasMarkerConfig){const e=h.getCurrentMarkerIndex(t.label,this.config.markerList);e>=0&&(this.setMarkerIndex(e),this.emit("markIndexChange"))}}onTabKeyDown(t){if(t.preventDefault(),this.dragStatus===f.Move||this.dragStatus===f.Start)return;let e=w.ascend;t.shiftKey&&(e=w.descend);const[i,s]=h.getRenderResultList(this.pointList,h.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);let o=[...i];s&&(o=[...o,s]);const n=h.getNextSelectedRectID(o,e,this.selectedID);n&&this.setSelectedID(n.id)}get currentPageResult(){const[t]=h.getRenderResultList(this.pointList,h.getSourceID(this.basicResult),[]);return t}getCurrentPageResult(t){const[e]=h.getRenderResultList(t,h.getSourceID(this.basicResult),[]);return e}exportData(){const{pointList:t}=this;return[t,this.basicImgInfo]}deletePoint(){var t;this.selectedID&&(this.setPointList(this.pointList.filter(e=>e.id!==this.selectedID)),this.history.pushHistory(this.pointList),(t=this._textAttributInstance)==null||t.clearTextAttribute(),this.emit("selectedChange"),this.emit("pointDeleted",this.selectedID),this.render())}undoAndRedo(t){var e,i;if(this.dragStatus===f.Move||this.dragStatus===f.Start)return;const s=(i=(e=this.history)[t])==null?void 0:i.call(e);(s==null?void 0:s.some(o=>o.id===this.selectedID))||this.setSelectedID(""),s&&(this.setPointList(s,!0),this.render())}undo(){this.undoAndRedo("undo")}redo(){this.undoAndRedo("redo")}getCurrentSelectedData(){var t;if(!this.selectedID)return;const e=(t=this.pointList)==null?void 0:t.find(o=>o.id===this.selectedID),i=this.getColor(e==null?void 0:e.attribute),s=(e==null?void 0:e.valid)?i==null?void 0:i.valid.stroke:i==null?void 0:i.invalid.stroke;return this.dragStatus=f.Wait,{width:U*this.zoom*.6,textAttribute:(e==null?void 0:e.textAttribute)||"",color:s}}updateSelectedTextAttribute(t){if(this._textAttributInstance&&t&&this.selectedID){let e=t;v.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",v.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setPointList(v.textChange(e,this.selectedID,this.pointList)),this.emit("updateTextAttribute"),this.render()}}renderTextAttribute(){var t,e;const i=(t=this.pointList)==null?void 0:t.find(b=>b.id===this.selectedID);if(!this.ctx||this.config.textConfigurable!==!0||!i)return;const{x:s,y:o,attribute:n,valid:r}=i,u=U*this.zoom*.6,d=c.getOffsetCoordinate({x:s,y:o},this.currentPos,this.zoom),a=this.getColor(n),g=r?a==null?void 0:a.valid.stroke:a==null?void 0:a.invalid.stroke,l=4;this._textAttributInstance||(this._textAttributInstance=new F({width:u,container:this.container,icon:this.getTextIconSvg(n),color:g,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributInstance&&!((e=this._textAttributInstance)==null?void 0:e.isExit)&&this._textAttributInstance.appendToContainer(),this._textAttributInstance.update(`${i.textAttribute}`,{left:d.x,top:d.y+l,color:g,width:u})}renderPoint(t,e=!1){var i,s,o;const{textAttribute:n="",attribute:r}=t,u=e||t.id===this.selectedID,d=this.getColor(r),a=c.changePointByZoom(t,this.zoom,this.currentPos),{width:g=2,hiddenText:l=!1}=this.style,b=Z.getStrokeAndFill(d,t.valid,{isSelected:u||t.id===this.hoverID});x.drawCircle(this.canvas,a,g,{startAngleDeg:0,endAngleDeg:360,thickness:1,color:b.stroke,fill:b.fill});let I="";(((i=this.config)==null?void 0:i.isShowOrder)||((s=this.config)==null?void 0:s.showOrder))&&t.order&&(t==null?void 0:t.order)>0&&(I=`${t.order}`),t.label&&this.hasMarkerConfig&&(I=`${h.getCurrentMarkerIndex(t.label,this.config.markerList)+1}_${P.getMarkerShowText(t.label,this.config.markerList)}`),t.attribute&&!this.config.hideAttribute&&(I=`${I} ${v.getAttributeShowText(t.attribute,(o=this.config)==null?void 0:o.attributeList)}`),l||x.drawText(this.canvas,{x:a.x+g/2,y:a.y-g-4},I,{textAlign:"center",color:b.stroke}),u?this.renderTextAttribute():l||x.drawText(this.canvas,{x:a.x+g,y:a.y+g+24},n,D({color:b.stroke},B))}renderMultiSelectedPoint(){!this.isMultiMoveMode||this.pointList.forEach(t=>{this.renderPoint(t,!0)})}renderPointList(){switch(this.operationMode){case E.MultiMove:this.renderMultiSelectedPoint();break;default:{const[t,e]=h.getRenderResultList(this.pointList,h.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);this.isHidden||t.forEach(i=>{this.renderPoint(i)}),e&&this.renderPoint(e)}}}renderAuxiliaryLine(){var t;if(!this.config.markerConfigurable||!((t=this.config.markerList)==null?void 0:t.length))return;const[e,i]=h.getRenderResultList(this.pointList,h.getSourceID(this.basicResult),this.attributeLockList,this.selectedID),s=e;if(i&&s.push(i),s.length<2)return;const o=P.getAuxiliaryLineByMarkerList(this.config.markerList,"value");P.getAuxiliaryLineCoord(o,s).forEach(r=>{const{start:u,end:d}=r,a=c.changePointListByZoom([u,d],this.zoom,this.currentPos);x.drawLine(this.canvas,a[0],a[1],{color:"#C5C5C5"})})}renderTop(){var t,e,i;const s=this.getLineColor(this.defaultAttribute);if(this.renderCursorLine(s),this.config.edgeAdsorption&&this.referenceData){let o=c.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);const n=((t=this.referenceData)==null?void 0:t.toolName)===p.Polygon,{dropFoot:r}=L.getClosestPoint(o,this.referenceData.result,(i=(e=this.referenceData.config)==null?void 0:e.lineType)!=null?i:_.Line,k/this.zoom,{isClose:n});r&&o!==r&&o!==r&&(o=r,x.drawCircle(this.canvas,c.changePointByZoom(o,this.zoom,this.currentPos),5,{color:"white",fill:"white"}),x.drawCircle(this.canvas,c.changePointByZoom(o,this.zoom,this.currentPos),3,{fill:s,color:s}))}}render(){!this.ctx||(super.render(),this.renderAuxiliaryLine(),this.renderPointList(),this.renderTop())}}export{G as default};
|
package/es/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{RectOperation}from"./core/toolOperation/rectOperation.js";export{default as TagOperation}from"./core/toolOperation/tagOperation.js";export{default as PointOperation}from"./core/toolOperation/pointOperation.js";export{default as LineToolOperation}from"./core/toolOperation/LineToolOperation.js";export{default as TextToolOperation}from"./core/toolOperation/TextToolOperation.js";export{default as PolygonOperation}from"./core/toolOperation/polygonOperation.js";export{default as MeasureOperation}from"./core/toolOperation/measureOperation.js";export{BasicToolOperation}from"./core/toolOperation/basicToolOperation.js";export{default as ViewOperation}from"./core/toolOperation/ViewOperation.js";export{default as ScribbleTool}from"./core/toolOperation/ScribbleTool.js";export{default as PointCloud2dOperation}from"./core/toolOperation/pointCloud2dOperation.js";import*as t from"./constant/annotation.js";export{t as cAnnotation};import*as e from"./constant/annotationTask.js";export{e as cAnnotationTask};import*as r from"./constant/keyCode.js";export{r as cKeyCode};import*as a from"./constant/style.js";export{a as cStyle};import*as i from"./constant/tool.js";export{i as cTool};export{CLIENT_TOOL_HEAD_TYPE,CLIENT_TOOL_NAME,DEFAULT_FONT,DEFAULT_TEXT_MAX_WIDTH,EAnnotationMode,EAuditStatus,ECheckModel,EDependPattern,EDragTarget,EDrawPointPattern,EFilterToolOperation,ELineColor,ELineTypes,EOperationMode,EPageOperator,EPointCloudName,EPolygonPattern,ERectPattern,EScribblePattern,ESelectedType,ETextType,EThumbnailOption,EToolName,EToolType,EVideoToolName,OPERATION_LIST,SEGMENT_NUMBER,TEXT_ATTRIBUTE_LINE_HEIGHT,TEXT_ATTRIBUTE_MAX_LENGTH,TEXT_TYPE,TOOL_NAME,TOOL_NAME_EN,edgeAdsorptionScope,editStepWidth}from"./constant/tool.js";export{default as TagUtils}from"./utils/tool/TagUtils.js";export{default as uuid}from"./utils/uuid.js";import o from"./utils/tool/EnhanceCommonToolUtils.js";export{default as MarkerUtils}from"./utils/tool/MarkerUtils.js";export{default as RectUtils}from"./utils/tool/RectUtils.js";export{default as AxisUtils}from"./utils/tool/AxisUtils.js";export{default as DrawUtils}from"./utils/tool/DrawUtils.js";export{default as ImgUtils}from"./utils/ImgUtils.js";export{default as MathUtils}from"./utils/MathUtils.js";export{default as AttributeUtils}from"./utils/tool/AttributeUtils.js";export{default as ActionsHistory}from"./utils/ActionsHistory.js";export{default as DblClickEventListener}from"./utils/tool/DblClickEventListener.js";export{default as AnnotationEngine}from"./core/index.js";export{default as UnitUtils}from"./utils/tool/UnitUtils.js";export{CanvasScheduler}from"./newCore/CanvasScheduler.js";export{PointCloud}from"./core/pointCloud/index.js";export{createThreeMatrix4,getCuboidFromPointCloudBox,lidar2image,pointCloudLidar2image,rotatePoint,transferKitti2Matrix}from"./core/pointCloud/matrix.js";export{PointCloudAnnotation}from"./core/pointCloud/annotation.js";const s=o,
|
|
1
|
+
export{RectOperation}from"./core/toolOperation/rectOperation.js";export{default as TagOperation}from"./core/toolOperation/tagOperation.js";export{default as PointOperation}from"./core/toolOperation/pointOperation.js";export{default as LineToolOperation}from"./core/toolOperation/LineToolOperation.js";export{default as TextToolOperation}from"./core/toolOperation/TextToolOperation.js";export{default as PolygonOperation}from"./core/toolOperation/polygonOperation.js";export{default as MeasureOperation}from"./core/toolOperation/measureOperation.js";export{BasicToolOperation}from"./core/toolOperation/basicToolOperation.js";export{default as ViewOperation}from"./core/toolOperation/ViewOperation.js";export{default as ScribbleTool}from"./core/toolOperation/ScribbleTool.js";export{default as PointCloud2dOperation}from"./core/toolOperation/pointCloud2dOperation.js";import*as t from"./constant/annotation.js";export{t as cAnnotation};import*as e from"./constant/annotationTask.js";export{e as cAnnotationTask};import*as r from"./constant/keyCode.js";export{r as cKeyCode};import*as a from"./constant/style.js";export{a as cStyle};import*as i from"./constant/tool.js";export{i as cTool};export{CLIENT_TOOL_HEAD_TYPE,CLIENT_TOOL_NAME,DEFAULT_FONT,DEFAULT_TEXT_MAX_WIDTH,EAnnotationMode,EAuditStatus,ECheckModel,EDependPattern,EDragTarget,EDrawPointPattern,EFilterToolOperation,ELineColor,ELineTypes,EOperationMode,EPageOperator,EPointCloudName,EPolygonPattern,ERectPattern,EScribblePattern,ESelectedType,ETextType,EThumbnailOption,EToolName,EToolType,EVideoToolName,OPERATION_LIST,SEGMENT_NUMBER,TEXT_ATTRIBUTE_LINE_HEIGHT,TEXT_ATTRIBUTE_MAX_LENGTH,TEXT_TYPE,TOOL_NAME,TOOL_NAME_EN,edgeAdsorptionScope,editStepWidth}from"./constant/tool.js";export{default as TagUtils}from"./utils/tool/TagUtils.js";export{default as uuid}from"./utils/uuid.js";import o from"./utils/tool/EnhanceCommonToolUtils.js";export{default as MarkerUtils}from"./utils/tool/MarkerUtils.js";export{default as RectUtils}from"./utils/tool/RectUtils.js";export{default as AxisUtils}from"./utils/tool/AxisUtils.js";export{default as DrawUtils}from"./utils/tool/DrawUtils.js";export{default as ImgUtils}from"./utils/ImgUtils.js";export{default as MathUtils}from"./utils/MathUtils.js";export{default as AttributeUtils}from"./utils/tool/AttributeUtils.js";export{default as ActionsHistory}from"./utils/ActionsHistory.js";export{default as DblClickEventListener}from"./utils/tool/DblClickEventListener.js";export{default as AnnotationEngine}from"./core/index.js";export{default as UnitUtils}from"./utils/tool/UnitUtils.js";export{default as StyleUtils}from"./utils/tool/StyleUtils.js";export{CanvasScheduler}from"./newCore/CanvasScheduler.js";export{PointCloud}from"./core/pointCloud/index.js";export{createThreeMatrix4,getCuboidFromPointCloudBox,lidar2image,pointCloudLidar2image,rotatePoint,transferKitti2Matrix}from"./core/pointCloud/matrix.js";export{PointCloudAnnotation}from"./core/pointCloud/annotation.js";const s=o,l=o;export{s as CommonToolUtils,l as toolUtils};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isNumber as I}from"lodash";import{ToolStyleUtils as O}from"@labelbee/lb-utils";import{
|
|
1
|
+
import{isNumber as I}from"lodash";import{ToolStyleUtils as O}from"@labelbee/lb-utils";import{ICON_ARRAY as c,NULL_ICON as E,NULL_COLOR as f,COLORS_ARRAY as d}from"../../constant/style.js";import{ETextType as s}from"../../constant/tool.js";import g from"../../locales/index.js";import{EMessage as p}from"../../locales/constants.js";import h from"../MathUtils.js";import y from"../../assets/attributeIcon/icon_canvasEdit_miss.svg.js";var w=Object.defineProperty,N=Object.defineProperties,P=Object.getOwnPropertyDescriptors,v=Object.getOwnPropertySymbols,R=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable,x=(l,t,r)=>t in l?w(l,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):l[t]=r,b=(l,t)=>{for(var r in t||(t={}))R.call(t,r)&&x(l,r,t[r]);if(v)for(var r of v(t))T.call(t,r)&&x(l,r,t[r]);return l},m=(l,t)=>N(l,P(t));const _="^[0-9]+$",A="^[A-Za-z]+$";class M{static getAttributeIcon(t,r,e=!0){var n;const a=r.findIndex(o=>o.value===t);let i=(n=c[a%c.length])!=null?n:E;e||(i=y),i="";const u=new Image;return u.src=i,u}static checkString(t,r){let e="";switch(t){case s.Order:case s.NumberOnly:e=_;break;case s.EnglishOnly:e=A;break;case s.CustomFormat:e=r;break}return e}static checkTextAttibute(t,r){if(t===void 0||t==="")return!0;try{return new RegExp(r).test(t)}catch(e){return!1}}static getAttributeShowText(t,r=[]){var e,n;try{const a=r.findIndex(i=>i.value===t);return(n=(e=r[a])==null?void 0:e.key)!=null?n:t}catch(a){return t}}static getAttributeIndex(t,r){try{const e=r.findIndex(n=>n.value===t);return e>=8?e%8:e}catch(e){return-1}}static getAttributeColor(t,r){try{const e=this.getAttributeIndex(t,r);return e===-1?f:d[e%d.length]}catch(e){return f}}static getTextAttribute(t,r){try{if(r===s.Order){const e=t.map(a=>parseInt(a.textAttribute,10)).filter(a=>I(a)&&a<Number.MAX_SAFE_INTEGER&&a>=0);return e.sort((a,i)=>a-i),`${(e.pop()||0)+1}`}return""}catch(e){return""}}static textChange(t,r,e){return e.map(n=>n.id===r?m(b({},n),{textAttribute:t}):n)}static getErrorNotice(t,r){switch(t){case s.Order:case s.NumberOnly:return g.getMessagesByLocale(p.TextCheckNumberErrorNotice,r);case s.EnglishOnly:return g.getMessagesByLocale(p.TextCheckEnglishErrorNotice,r);case s.CustomFormat:return g.getMessagesByLocale(p.TextCheckCustomErrorNotice,r);default:return""}}static textAttributeValidate(t,r,e){try{return new RegExp(this.checkString(t,r)).test(e)}catch(n){}}static checkTextAttribute(t,r,e,n){let a=!1;return e.forEach(i=>{(i==null?void 0:i.textAttribute)===void 0||(i==null?void 0:i.textAttribute)===""||(n?i.id===n:!0)&&!this.textAttributeValidate(t,r,i.textAttribute)&&(a=!0)}),!!a}static changeTextAttributeInLog(t,r){return t==null?void 0:t.map(e=>e==null?void 0:e.map(n=>{if((r==null?void 0:r.findIndex(a=>(a==null?void 0:a.id)===(n==null?void 0:n.id)))>-1){const a=r==null?void 0:r.find(i=>(i==null?void 0:i.id)===(n==null?void 0:n.id));return m(b({},n),{textAttribute:a==null?void 0:a.textAttribute})}return n}))}static getTextIconSvg(t="",r,e=!1,n){var a;if(e===!0){const i=(r==null?void 0:r.findIndex(o=>(o==null?void 0:o.value)===t))%d.length+1,u=(a=r==null?void 0:r.find(o=>o.value===t))==null?void 0:a.color;if(u){const o=O.rgbaStringToHex(u);return this.generateIconAttribute({fill:o})}return c[i]}return n}static generateIconAttribute({fill:t,width:r=16,height:e=16,xmlns:n="http://www.w3.org/2000/svg",xlink:a="http://www.w3.org/1999/xlink"}){return`<span style={color:${t}}><svg xmlns=${n} xmlns:xlink=${a} width=${r} height=${e} viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill='currentColor'/></g></g></svg></span>`}static getAttributeByKeycode(t,r){var e;let n;return h.isInRange(t,[48,57])&&(n=t-48),h.isInRange(t,[96,105])&&(n=t-96),n===0?"":n?(e=r[n-1])==null?void 0:e.value:void 0}}export{A as REGEXP_ENGLISH,_ as REGEXP_NUMBER,M as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EToolName as u,ELineTypes as C}from"../../constant/tool.js";import y from"../MathUtils.js";import x from"./PolygonUtils.js";import
|
|
1
|
+
import{EToolName as u,ELineTypes as C}from"../../constant/tool.js";import y from"../MathUtils.js";import x from"./PolygonUtils.js";import v,{POINT_RADIUS as _}from"./LineToolUtils.js";import{getHighlightPoints as P,getHighlightLines as m,getCuboidHoverRange as B}from"./CuboidUtils.js";var L=Object.defineProperty,R=Object.defineProperties,D=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,T=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable,w=(a,t,e)=>t in a?L(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,f=(a,t)=>{for(var e in t||(t={}))T.call(t,e)&&w(a,e,t[e]);if(O)for(var e of O(t))Z.call(t,e)&&w(a,e,t[e]);return a},c=(a,t)=>R(a,D(t));class I{static getOffsetCoordinate(t,e,i){return{x:t.x*i+e.x,y:t.y*i+e.y}}static changeDrawOutsideTarget(t,e,i,s,n,o){return typeof s=="boolean"&&!s&&(n&&o?(t.x-e.x>(n.x+n.width)*o&&(t.x=(n.x+n.width)*o+e.x),t.x-e.x<n.x*o&&(t.x=n.x*o+e.x),t.y-e.y>(n.y+n.height)*o&&(t.y=(n.y+n.height)*o+e.y),t.y-e.y<n.y*o&&(t.y=n.y*o+e.y)):(t.x-e.x>i.width&&(t.x=i.width+e.x),t.x-e.x<0&&(t.x=e.x),t.y-e.y>i.height&&(t.y=i.height+e.y),t.y-e.y<0&&(t.y=e.y))),t}static changeCoordinateByRotate(t,e,i){const{width:s,height:n}=i,{x:o,y:r}=t;switch(e%360){case 90:return{x:n-r,y:o};case 180:return{x:s-o,y:n-r};case 270:return{x:r,y:s-o};default:return t}}static changeRectByZoom(t,e,i={x:0,y:0}){return c(f({},t),{x:t.x*e+i.x,y:t.y*e+i.y,width:t.width*e,height:t.height*e})}static changePointByZoom(t,e,i={x:0,y:0}){return c(f({},t),{x:t.x*e+i.x,y:t.y*e+i.y})}static changePointListByZoom(t,e,i={x:0,y:0}){return t==null?void 0:t.map(s=>this.changePointByZoom(s,e,i))}static changePlanePointByZoom(t,e,i={x:0,y:0}){return Object.entries(t).reduce((s,[n,o])=>{const r=I.changePointByZoom(o,e,i);return c(f({},s),{[n]:r})},{})}static changeCuboidByZoom(t,e,i={x:0,y:0}){return c(f({},t),{frontPoints:this.changePlanePointByZoom(t.frontPoints,e,i),backPoints:t.backPoints?this.changePlanePointByZoom(t.backPoints,e,i):t.backPoints})}static transformPlain2PointList({tl:t,tr:e,br:i,bl:s}){return[t,e,i,s]}static axisArea(t,e=3){const{x:i,y:s}=t,n=[];for(let o=i-e;o<i+e;o+=e/3)for(let r=s-e;r<s+e;r+=e/3)n.push({x:o,y:r});return n}static getOriginCoordinateWithOffsetCoordinate(t,e=1,i={x:0,y:0}){return{x:(t.x-i.x)/e,y:(t.y-i.y)/e}}static returnClosePointIndex(t,e,i=3){let s=-1;for(let n=0;n<e.length;n++){const o=e[n];this.getIsInScope(t,o,i)&&(s=n)}return s}static isCloseCuboid(t,e,i={scope:5,zoom:1}){const s=P(e),{scope:n=5}=i;for(let r=0;r<s.length;r++){const l=s[r];if(this.getIsInScope(t,l.point,n))return!0}const o=m(e);for(let r=0;r<o.length;r++){const l=o[r],{length:p}=y.getFootOfPerpendicular(t,l.p1,l.p2,!0);if(p<n)return!0}return!!x.isInPolygon(t,B(e))}static isCloseCuboidList(t,e,i={scope:5,zoom:1}){return e.some(s=>this.isCloseCuboid(t,s,i))}static returnClosePointOrLineInCuboid(t,e,i={scope:5,zoom:1}){const s=P(e),{scope:n=5,zoom:o=1}=i;for(let h=0;h<s.length;h++){const g=s[h];if(this.getIsInScope(t,g.point,n))return[{type:"point",points:[this.changePointByZoom(s[h].point,o)],originCuboid:e,positions:g.positions}]}let r=n;const l=m(e);let p;for(let h=0;h<l.length;h++){const g=l[h],{length:d}=y.getFootOfPerpendicular(t,g.p1,g.p2,!0);d<r&&(r=d,p=[{type:"line",points:this.changePointListByZoom([g.p1,g.p2],o),originCuboid:e,positions:g.positions}])}if(p)return p}static getIsInScope(t,e,i){return Math.abs(t.x-e.x)<i&&Math.abs(t.y-e.y)<i}}class b{constructor(t){this.currentPos=t.currentPos,this.zoom=t.zoom,this.basicImgInfo=t.basicImgInfo,this.dependToolName=""}get isDependPolygon(){return this.dependToolName===u.Polygon}get isDependRect(){return this.dependToolName===u.Rect}get isDependOriginalImage(){return this.dependToolName===""}getAbsCoord(t){return{x:(t.x-this.currentPos.x)/this.zoom,y:(t.y-this.currentPos.y)/this.zoom}}getRenderCoord(t){return{x:t.x*this.zoom+this.currentPos.x,y:t.y*this.zoom+this.currentPos.y}}coordInsideRect(t,e){const{x:i,y:s,width:n,height:o}=e;return{x:y.withinRange(t.x,[i,i+n]),y:y.withinRange(t.y,[s,s+o])}}getPolygonPointList(t,e){return t===C.Curve?x.createSmoothCurvePointsFromPointList(e):e}getIntersection(t,e,i){const s=this.getRenderCoord(e),n=this.getRenderCoord(t),o={pointA:s,pointB:n};return v.calcOptimalIntersection(i,o,s,_,this.zoom)}coordInsidePolygon(t,e,i,s){const{pointList:n}=i,o=s==null?void 0:s.lineType;if(n.length===0)return t;const r=this.getPolygonPointList(o,n);if(x.isInPolygon(t,r))return t;const p=r.concat(r[0]).map(g=>this.getRenderCoord(g)),h=this.getIntersection(t,e,p);return h?this.getAbsCoord(h==null?void 0:h.point):t}coordInsideImage(t){return this.coordInsideRect(t,c(f({},this.basicImgInfo),{x:0,y:0}))}getNextCoordByDependTool(t,e){if(this.isDependRect)return this.coordInsideRect(t,this.basicResult);if(this.isDependPolygon)return this.coordInsidePolygon(t,e,this.basicResult,this.dependToolConfig);if(this.isDependOriginalImage)return this.coordInsideImage(t)}setDependInfo(t,e){this.dependToolName=t!=null?t:"",this.dependToolConfig=t?e:void 0}setBasicImgInfo(t){this.basicImgInfo=t}setBasicResult(t){this.basicResult=t}setZoomAndCurrentPos(t,e){this.zoom=t,this.currentPos=e}isCoordInsideTarget(t){if(this.isDependPolygon)return this.isInBasicPolygon(t);if(this.isDependRect){const{x:e,y:i,width:s,height:n}=this.basicResult,o=[e,e+s],r=[i,i+n];return y.isInRange(t.x,o)&&y.isInRange(t.y,r)}return y.isInRange(t.x,[0,this.basicImgInfo.width])&&y.isInRange(t.y,[0,this.basicImgInfo.height])}isInBasicPolygon(t){var e,i;return x.isInPolygon(t,((e=this.basicResult)==null?void 0:e.pointList)||[],(i=this.dependToolConfig)==null?void 0:i.lineType)}}export{b as CoordinateUtils,I as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cloneDeep as
|
|
1
|
+
import{cloneDeep as D}from"lodash";import{ECuboidPlain as a,ECuboidPosition as p,ECuboidDirection as B,EDragTarget as L,DIAGONAL_POINT as U,ECuboidLineDirection as P,CUBOID_ROW as X,CUBOID_COLUMN as Y}from"../../constant/annotation.js";import v from"./AxisUtils.js";import G from"../VectorUtils.js";import _ from"./LineToolUtils.js";var V=Object.defineProperty,z=Object.defineProperties,Q=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable,S=(n,t,i)=>t in n?V(n,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[t]=i,f=(n,t)=>{for(var i in t||(t={}))q.call(t,i)&&S(n,i,t[i]);if(I)for(var i of I(t))J.call(t,i)&&S(n,i,t[i]);return n},w=(n,t)=>z(n,Q(t));function m({tr:n,tl:t,br:i}){return{width:Math.abs(n.x-t.x),height:Math.abs(i.y-n.y),centerPoints:{x:(t.x+i.x)/2,y:(t.y+i.y)/2}}}function x({frontPoints:n,backPoints:t}){const{width:i,height:e,centerPoints:r}=m(n),{width:o,height:s,centerPoints:l}=m(t);return{frontCenter:r,backCenter:l,frontWidth:i,frontHeight:e,backWidth:o,backHeight:s,isLeftSide:l.x<r.x}}function k(n,t){return{tl:{x:Math.min(n.x,t.x),y:Math.min(n.y,t.y)},tr:{x:Math.max(n.x,t.x),y:Math.min(n.y,t.y)},bl:{x:Math.min(n.x,t.x),y:Math.max(n.y,t.y)},br:{x:Math.max(n.x,t.x),y:Math.max(n.y,t.y)}}}function F(n){const t=Object.values(n).reduce((o,s)=>s.x<o?s.x:o,Number.MAX_SAFE_INTEGER),i=Object.values(n).reduce((o,s)=>s.x>o?s.x:o,0),e=Object.values(n).reduce((o,s)=>s.y<o?s.y:o,Number.MAX_SAFE_INTEGER),r=Object.values(n).reduce((o,s)=>s.y>o?s.y:o,0);return{tl:{x:t,y:e},tr:{x:i,y:e},bl:{x:t,y:r},br:{x:i,y:r}}}function N(n){const[t,i]=n;if(X[t.position]===i.position)return P.Row;if(Y[t.position]===i.position)return P.Column}function M({coord:n,points:t}){const{width:i,height:e}=m(t);return{br:n,tr:{x:n.x,y:n.y-e},tl:{x:n.x-i,y:n.y-e},bl:{x:n.x-i,y:n.y}}}function j({coord:n,points:t}){const{width:i,height:e}=m(t);return{bl:n,tr:{x:n.x+i,y:n.y-e},tl:{x:n.x,y:n.y-e},br:{x:n.x+i,y:n.y}}}function H({frontPoints:n,backPoints:t}){const{isLeftSide:i}=x({frontPoints:n,backPoints:t});return i?{top:{p1:n.tl,p2:t.tl},bottom:{p1:n.bl,p2:t.bl}}:{top:{p1:n.tr,p2:t.tr},bottom:{p1:n.br,p2:t.br}}}function R({frontPoints:n,backPoints:t}){const{isLeftSide:i}=x({frontPoints:n,backPoints:t});let e=f({},t);const r=H({frontPoints:n,backPoints:t}),o=_.lineIntersection({pointA:r.bottom.p1,pointB:r.bottom.p2},{pointA:r.top.p1,pointB:r.top.p2});if(i){const s=_.lineIntersection({pointA:t.bl,pointB:t.br},{pointA:n.br,pointB:o});s&&(e=w(f({},t),{br:s,tr:{x:s.x,y:t.tl.y}}))}else{const s=_.lineIntersection({pointA:t.bl,pointB:t.br},{pointA:n.bl,pointB:o});s&&(e=w(f({},t),{bl:s,tl:{x:s.x,y:t.tr.y}}))}return{backPoints:e}}function T({frontPoints:n,backPoints:t}){const{isLeftSide:i,frontHeight:e,backHeight:r}=x({frontPoints:n,backPoints:t});let o=f({},t);return i?o=j({coord:t.bl,points:n}):o=M({coord:t.br,points:n}),e>r&&(o=R({frontPoints:n,backPoints:t}).backPoints),{frontPoints:n,backPoints:o}}function A({frontPoints:n,backPoints:t}){const{isLeftSide:i,frontHeight:e,backHeight:r,frontWidth:o,backWidth:s}=x({frontPoints:n,backPoints:t});let l=f({},n),c=t;return i||s>o?l=j({coord:n.bl,points:t}):l=M({coord:n.br,points:t}),e>r&&(l.tl.y=n.tl.y,l.tr.y=n.tr.y,c=R({backPoints:t,frontPoints:n}).backPoints),o>=s&&Object.keys(l).forEach(u=>{l[u].x=n[u].x}),{frontPoints:l,backPoints:c}}function K({frontPoints:n,backPoints:t}){return[{p1:n.bl,p2:t.bl},{p1:n.tl,p2:t.tl},{p1:n.tr,p2:t.tr},{p1:n.br,p2:t.br}]}function Z(n){const{frontPoints:t,backPoints:i}=n,{isLeftSide:e}=x(n),r=[{p1:t.tl,p2:t.tr,positions:[{plain:a.Front,position:p.TL},{plain:a.Front,position:p.TR}]},{p1:t.tr,p2:t.br,plain:a.Front,positions:[{plain:a.Front,position:p.TR},{plain:a.Front,position:p.BR}]},{p1:t.br,p2:t.bl,plain:a.Front,positions:[{plain:a.Front,position:p.BR},{plain:a.Front,position:p.BL}]},{p1:t.bl,p2:t.tl,plain:a.Front,positions:[{plain:a.Front,position:p.BL},{plain:a.Front,position:p.TL}]}];return e?[...r,{p1:i.tl,p2:i.bl,positions:[{plain:a.Back,position:p.TL},{plain:a.Back,position:p.BL}]}]:[...r,{p1:i.tr,p2:i.br,positions:[{plain:a.Back,position:p.TR},{plain:a.Back,position:p.BR}]}]}function $(n){const{backPoints:t}=n,{isLeftSide:i}=x(n),e=Object.entries(n.frontPoints).map(([r,o])=>({positions:[{plain:a.Front,position:r}],point:o}));return i?[{point:t.tl,positions:[{position:p.TL,plain:a.Back}]},{point:t.bl,positions:[{position:p.BL,plain:a.Back}]},...e]:[{point:t.tr,positions:[{position:p.TR,plain:a.Back}]},{point:t.br,positions:[{position:p.BR,plain:a.Back}]},...e]}function tt(n){const{frontPoints:t,backPoints:i}=n,{backCenter:e,frontCenter:r,frontHeight:o,frontWidth:s,backHeight:l,backWidth:c,isLeftSide:u}=x(n),h=Math.abs(s-c),y=Math.abs(o-l),g=Math.abs(r.x-e.x),O=Math.abs(r.y-e.y),d=g>h,b=O>y;return d||b?b&&!d?[t.tl,i.tl,i.tr,t.tr,t.br,t.bl]:d&&!b?u?[t.tl,t.tr,t.br,t.bl,i.bl,i.tl]:[t.tl,t.tr,i.tr,i.br,t.br,t.bl]:d&&b?u?[i.tl,i.tr,t.tr,t.br,t.bl,i.bl]:[t.tl,i.tl,i.tr,i.br,t.br,t.bl]:[]:[t.tl,t.tr,t.br,t.bl]}function W({offset:n,frontPoints:t,backPoints:i,positions:e}){let r=D(t),o=D(i);if((e==null?void 0:e.length)===2){const s=e.every(b=>b.plain===a.Front),l=!s,c=N([e[0],e[1]]),u=c===P.Row,h=c===P.Column;let y=n;u&&(y={x:0,y:n.y}),h&&(y={y:0,x:n.x}),s&&(e==null||e.forEach(({position:b})=>{const C=r,E=C[b];C[b]={x:E.x+y.x,y:E.y+y.y}}),r=F(r),o=F(o)),l&&Object.keys(o).forEach(b=>{o[b]={x:o[b].x+y.x,y:o[b].y+y.y}});const g=s?T:A,{frontPoints:O,backPoints:d}=g({frontPoints:r,backPoints:o});r=O,o=d}return{frontPoints:r,backPoints:o}}function nt({offset:n,cuboid:t}){const{frontPoints:i,backPoints:e}=t,r=Object.entries(i).reduce((s,[l,c])=>w(f({},s),{[l]:{x:c.x+n.x,y:c.y+n.y}}),{}),o=Object.entries(e).reduce((s,[l,c])=>w(f({},s),{[l]:{x:c.x+n.x,y:c.y+n.y}}),{});return{frontPoints:r,backPoints:o}}function it({offset:n,cuboid:t,positions:i}){const{frontPoints:e,backPoints:r}=t;return W({offset:n,frontPoints:e,backPoints:r,positions:i})}function et({offset:n,cuboid:t,positions:i}){if(!(i==null?void 0:i[0]))return;const{frontPoints:e,backPoints:r}=t,o=i[0],s=o.plain===a.Front,l=s?e:r;let c=l[o.position];const u=l[U[o.position]];if(!c||!u)return;c=G.add(c,n);const h=k(c,u),y=s?T:A;let g={frontPoints:e,backPoints:h};return s&&(g={frontPoints:h,backPoints:r}),y(g)}function ot({offset:n,cuboid:t,dragTarget:i,positions:e}){switch(i){case L.Cuboid:{const r=nt({offset:n,cuboid:t});return f(f({},t),r)}case L.Line:{const r=it({offset:n,cuboid:t,positions:e});return f(f({},t),r)}case L.Point:{const r=et({cuboid:t,offset:n,positions:e});if(r)return f(f({},t),r);break}default:{console.error("No DragTarget");break}}}function rt({direction:n,frontPoints:t,backPoints:i}){if(n&&t&&i){let e=t;switch(n){case B.Back:e=i;break;case B.Left:e={bl:i.bl,br:t.bl,tl:i.tl,tr:t.tl};break;case B.Right:e={bl:i.br,br:t.br,tl:i.tr,tr:t.tr};break;case B.Top:e={bl:i.tl,br:t.tl,tl:i.tr,tr:t.tr};break;default:e=t;break}return v.transformPlain2PointList(e)}}function st({cuboid:n,currentPos:t,zoom:i}){const{frontPoints:e}=n,r={width:40,height:74},o={x:(e.bl.x+e.tl.x)/2,y:(e.bl.y+e.tl.y)/2},s=r.width+10,l=r.height/2,c={x:o.x,y:o.y},u=v.getOffsetCoordinate(c,t,i);return{left:u.x-s,top:u.y-l}}function lt({cuboid:n,currentPos:t,zoom:i,leftOffset:e=16,topOffset:r=2}){const{frontPoints:o}=n,s={x:o.bl.x,y:o.bl.y},l=v.getOffsetCoordinate(s,t,i);return{left:l.x+e,top:l.y+r}}function at({cuboid:n,config:t}){const{minHeight:i,minWidth:e}=t,{width:r,height:o}=m(n.frontPoints);return r>=e&&o>=i}export{T as getBackPointsByFrontPoints,K as getCuboidAllSideLine,x as getCuboidBasicInfo,ot as getCuboidDragMove,tt as getCuboidHoverRange,H as getCuboidShowingSideLine,lt as getCuboidTextAttributeOffset,A as getFrontPointsByBackPoints,Z as getHighlightLines,$ as getHighlightPoints,F as getMaxExternalQuadrilateral,W as getNewPointsAfterOffset,k as getPlainPointsByDiagonalPoints,m as getPlanePointsBasicInfo,rt as getPointListsByDirection,j as getPointsByBottomLeftPoint,M as getPointsByBottomRightPoint,R as getPointsByIntersection,st as getToggleDirectionButtonOffset,at as isCuboidWithInLimits,N as judgeCuboidLineIsRowOrColumn};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{ELineTypes as
|
|
2
|
-
`,""))!=null?i:"",l.setAttribute("id","tagToolTag"),e==null||e.appendChild(l),l}static drawLineWithPointList(r,t,i={}){if(t.length<2)return;const e=r.getContext("2d"),{color:o=
|
|
3
|
-
`);for(let
|
|
1
|
+
import{ELineTypes as P,SEGMENT_NUMBER as p,DEFAULT_FONT as O}from"../../constant/tool.js";import b from"./PolygonUtils.js";import T from"./UnitUtils.js";import S from"./AxisUtils.js";import{getCuboidAllSideLine as D,getPointListsByDirection as W,getCuboidTextAttributeOffset as F}from"./CuboidUtils.js";import M from"./AttributeUtils.js";var U=Object.defineProperty,I=Object.defineProperties,R=Object.getOwnPropertyDescriptors,v=Object.getOwnPropertySymbols,$=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable,k=(r,t,i)=>t in r?U(r,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[t]=i,m=(r,t)=>{for(var i in t||(t={}))$.call(t,i)&&k(r,i,t[i]);if(v)for(var i of v(t))L.call(t,i)&&k(r,i,t[i]);return r},A=(r,t)=>I(r,R(t));const j=1,B={x:0,y:0},X=0,u="",x=class{static drawLine(r,t,i,e={}){const o=r.getContext("2d"),{color:l=u,thickness:s=1,lineCap:a="round",lineDash:d}=e;o.save(),o.strokeStyle=l,o.lineWidth=s,o.lineCap=a,d&&o.setLineDash(d),o.beginPath(),o.moveTo(t.x,t.y),o.lineTo(i.x+1,i.y+1),o.stroke(),o.restore()}static drawRect(r,t,i={}){const e=r.getContext("2d"),{color:o=u,thickness:l=1,lineCap:s="round",hiddenText:a=!1,lineDash:d}=i;if(e.save(),e.strokeStyle=o,e.lineWidth=l,e.lineCap=s,Array.isArray(d)&&e.setLineDash(d),e.fillStyle=o,e.strokeRect(t.x,t.y,t.width,t.height),a===!1){let n="";if(t.attribute&&(n=`${n} ${t.attribute}`),this.drawText(r,{x:t.x,y:t.y-5},n),t.textAttribute){const c=`${~~t.width} * ${~~t.height}`.length*7,w=0,y=Math.max(20,t.width-c);this.drawText(r,{x:t.x,y:t.y+t.height+20+w},t.textAttribute,{textMaxWidth:y})}}e.restore()}static drawRectWithFill(r,t,i={}){const e=r.getContext("2d"),{color:o=u}=i;e.save(),e.fillStyle=o,e.fillRect(t.x,t.y,t.width,t.height),e.restore()}static drawTagByDom(r,t,i){const e=r;if(!((t==null?void 0:t.length)>0))return;const o=document.createElement("div");return o.innerHTML=t,o.setAttribute("id",i),e==null||e.appendChild(o),o}static drawTag(r,t){var i;const e=r==null?void 0:r.parentNode,o=window.self.document.getElementById("tagToolTag");if(o&&e&&e.contains(o)&&(e==null||e.removeChild(o)),!((t==null?void 0:t.length)>0))return;const l=document.createElement("div");return l.innerHTML=(i=t.reduce((s,a)=>`${s}${a.keyName}: ${a.value.join(" \u3001 ")}
|
|
2
|
+
`,""))!=null?i:"",l.setAttribute("id","tagToolTag"),e==null||e.appendChild(l),l}static drawLineWithPointList(r,t,i={}){if(t.length<2)return;const e=r.getContext("2d"),{color:o=u,thickness:l=1,lineCap:s="round",lineType:a=P.Line,lineDash:d,hoverEdgeIndex:n}=i;e.save(),(()=>{e.strokeStyle=o,e.lineWidth=l,e.lineCap=s,Array.isArray(d)?e.setLineDash(d):e.setLineDash([])})(),a===P.Curve?(n!==void 0&&n>-1&&t.push(t[0]),t=b.createSmoothCurvePointsFromPointList([...t],p),n!==void 0&&n>-1&&(t=t.slice((p+1)*n,(p+1)*(n+1)))):n!==void 0&&n>-1&&(t=[...t,t[0]],t=t.slice(n,n+2));const c=[];e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let h=0;h<t.length-1;h++)t[h].specialEdge&&c.push({i1:h,i2:h+1}),e.lineTo(t[h+1].x,t[h+1].y);e.stroke(),e.save(),e.lineWidth=l*.8,e.lineCap="butt",e.strokeStyle="white",e.setLineDash([3,3]),c.forEach(h=>{const g=t[h.i1],C=t[h.i2];e.beginPath(),e.moveTo(g.x,g.y),e.lineTo(C.x,C.y),e.stroke()}),e.restore();const w=4,y=2;return t.forEach(h=>{h.specialPoint&&(this.drawSpecialPoint(r,h,w+y,o),this.drawSpecialPoint(r,h,w,"white"))}),e.restore(),t}static drawCircle(r,t,i,e={}){const o=r.getContext("2d"),{startAngleDeg:l=0,endAngleDeg:s=360,thickness:a=1,color:d=u,fill:n=u}=e,f=T.deg2rad(l),c=T.deg2rad(s);o.save(),o.beginPath(),o.strokeStyle=d,o.fillStyle=n,o.lineWidth=a,o.arc(t.x,t.y,i,f,c,!1),o.stroke(),n&&o.fill(),o.closePath(),o.restore()}static drawCircleWithFill(r,t,i=3,e={}){const o=r.getContext("2d"),{color:l=u}=e;o.save();const s=T.deg2rad(0),a=T.deg2rad(360);o.fillStyle=l,o.beginPath(),o.arc(t.x,t.y,i,s,a,!1),o.fill(),o.restore()}static drawSpecialPoint(r,t,i=6,e){const o=r.getContext("2d"),{x:l,y:s}=t;o.save(),o.beginPath(),o.fillStyle=e;const a=i*1.5,d=a*Math.sqrt(3)/2,n=a/2;o.moveTo(l,s-a),o.lineTo(l-d,s+n),o.lineTo(l+d,s+n),o.closePath(),o.fill(),o.restore()}static drawPolygon(r,t,i={}){const{isClose:e=!1,lineType:o=P.Line}=i;return e===!0&&(t=[...t,t[0]]),o===P.Curve&&(t=b.createSmoothCurvePointsFromPointList([...t])),this.drawLineWithPointList(r,t,A(m({},i),{lineType:P.Line})),t}static drawPolygonWithFill(r,t,i={}){if(t.length<2)return;const e=r.getContext("2d"),{color:o=u,lineType:l=P.Line}=i;e.save(),e.fillStyle=o,e.beginPath(),l===P.Curve&&(t=b.createSmoothCurvePointsFromPointList([...t,t[0]]));const[s,...a]=t;return e.moveTo(s.x,s.y),a.forEach(d=>{e.lineTo(d.x,d.y)}),e.fill(),e.restore(),t}static drawPolygonWithFillAndLine(r,t,i={}){const{strokeColor:e,fillColor:o,thickness:l,lineCap:s,isClose:a,lineType:d}=i,n=this.drawPolygon(r,t,{color:e,thickness:l,lineCap:s,isClose:a,lineType:d});return this.drawPolygonWithFill(r,t,{color:o,lineType:d}),n}static drawPolygonWithKeyPoint(r,t,i={}){const{pointColor:e="white",strokeColor:o}=i,l=this.drawPolygon(r,t,i);return l.forEach(s=>{this.drawCircleWithFill(r,s,4,{color:o}),this.drawCircleWithFill(r,s,3,{color:e})}),l}static drawSelectedPolygonWithFillAndLine(r,t,i={}){const{pointColor:e="white",strokeColor:o}=i,l=this.drawPolygonWithFillAndLine(r,t,i);return l.forEach(s=>{this.drawCircleWithFill(r,s,4,{color:o}),this.drawCircleWithFill(r,s,3,{color:e})}),l}static drawText(r,t,i,e={}){if(!i)return;const o=r.getContext("2d"),{color:l=u,font:s=O,shadowColor:a="",shadowBlur:d=0,shadowOffsetX:n=0,shadowOffsetY:f=0,textMaxWidth:c=164,offsetX:w=0,offsetY:y=0,textAlign:h="start",lineHeight:g}=e;o.save(),o.textAlign=h,o.fillStyle=l!=null?l:"white",o.font=s,o.shadowColor=a,o.shadowOffsetX=n,o.shadowOffsetY=f,o.shadowBlur=d,this.wrapText(r,`${i}`,t.x+w,t.y+y,c,g),o.restore()}static wrapText(r,t,i,e,o,l){if(typeof t!="string"||typeof i!="number"||typeof e!="number")return;const s=r.getContext("2d");typeof o=="undefined"&&(o=r&&r.width||300),typeof l=="undefined"&&(l=r&&parseInt(window.getComputedStyle(r).lineHeight,10)||parseInt(window.getComputedStyle(document.body).lineHeight,10));const a=t.split(`
|
|
3
|
+
`);for(let d=0;d<a.length;d++){const n=a[d].split("");let f="";for(let c=0;c<n.length;c++){const w=f+n[c],h=s.measureText(w).width;o||(o=300),h>o&&c>0?(s.fillText(f,i,e),f=n[c],e+=l):f=w}s.fillText(f,i,e),e+=l}}static drawArrow(r,t,i,e={}){const{color:o=u,thickness:l=1,lineCap:s="round",theta:a=30,headLen:d=10}=e,n=Math.atan2(t.y-i.y,t.x-i.x)*180/Math.PI,f=(n+a)*Math.PI/180,c=(n-a)*Math.PI/180,w=d*Math.cos(f),y=d*Math.sin(f),h=d*Math.cos(c),g=d*Math.sin(c);r.save(),r.strokeStyle=o,r.lineWidth=l,r.lineCap=s,r.beginPath(),r.moveTo(i.x+w,i.y+y),r.lineTo(i.x,i.y),r.lineTo(i.x+h,i.y+g),r.stroke(),r.restore()}static drawArrowByCanvas(r,t,i,e={}){const o=r.getContext("2d");this.drawArrow(o,t,i,e)}static drawCuboid(r,t,i={}){const{backPoints:e,direction:o,frontPoints:l}=t,{strokeColor:s,thickness:a,fillColor:d}=i,n={color:s,thickness:a};if(e){const c=S.transformPlain2PointList(e);x.drawPolygon(r,c,A(m({},n),{isClose:!0}));const w=D(t);w==null||w.forEach(y=>{x.drawLine(r,y.p1,y.p2,m({},n))})}const f=S.transformPlain2PointList(l);if(o&&e&&l){const c=W({direction:o,frontPoints:l,backPoints:e});c&&x.drawPolygonWithFill(r,c,{color:d})}x.drawPolygon(r,f,A(m({},n),{isClose:!0}))}static drawCuboidWithText(r,t,i,e){const{strokeColor:o}=i,l=o,{config:s,hiddenText:a,selectedID:d,headerText:n,bottomText:f}=e,{backPoints:c,frontPoints:w,textAttribute:y}=t,h=w.br.x-w.bl.x;x.drawCuboid(r,t,i);let g="";(s==null?void 0:s.isShowOrder)&&t.order&&(t==null?void 0:t.order)>0&&(g=`${t.order}`),t.attribute&&(g=`${g} ${M.getAttributeShowText(t.attribute,s==null?void 0:s.attributeList)}`),!a&&c&&g&&x.drawText(r,{x:c.tl.x,y:c.tl.y-5},n!=null?n:g,{color:o,textMaxWidth:300});const C=F({cuboid:t,currentPos:{x:0,y:0},zoom:1,topOffset:16,leftOffset:0});if(!a&&y&&t.id!==d){const E=Math.max(20,h*.8);x.drawText(r,{x:C.left,y:C.top},f!=null?f:y,{color:l,textMaxWidth:E})}}};let _=x;_.drawImg=(r,t,i={})=>{const e=r.getContext("2d"),{zoom:o=j,currentPos:l=B,rotate:s=X,imgAttribute:a}=i;switch(e.save(),s){case 0:e.translate(l.x,l.y);break;case 90:e.translate(l.x+t.height*o,l.y),e.rotate(90*Math.PI/180);break;case 180:e.translate(l.x+t.width*o,l.y+t.height*o),e.rotate(Math.PI);break;case 270:e.translate(l.x,l.y+t.width*o),e.rotate(270*Math.PI/180);break;default:e.translate(l.x,l.y);break}if(a){const{contrast:d,saturation:n,brightness:f}=a;e.filter=`saturate(${n+100}%) contrast(${d+100}%) brightness(${f+100}%)`}e.drawImage(t,0,0,t.width*o,t.height*o),e.restore()};export{_ as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@labelbee/lb-annotation",
|
|
3
|
-
"version": "1.14.0-alpha.
|
|
3
|
+
"version": "1.14.0-alpha.2",
|
|
4
4
|
"description": "Annotation tool collection",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"annotation",
|
|
@@ -92,11 +92,11 @@
|
|
|
92
92
|
"typescript": "^4.2.3"
|
|
93
93
|
},
|
|
94
94
|
"dependencies": {
|
|
95
|
-
"@labelbee/lb-utils": "^1.7.0-alpha.
|
|
95
|
+
"@labelbee/lb-utils": "^1.7.0-alpha.2",
|
|
96
96
|
"@turf/turf": "5.1.6",
|
|
97
97
|
"color-rgba": "^2.3.0",
|
|
98
98
|
"lodash": "^4.17.20",
|
|
99
99
|
"three": ">=0.141.0"
|
|
100
100
|
},
|
|
101
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "a7db5e1d7448a47848f6a338d1ecd5646ade27ff"
|
|
102
102
|
}
|
|
File without changes
|
package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { createBase64WorkerFactory as createBase64WorkerFactory$1 } from './_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js';
|
|
2
|
-
import { createBase64WorkerFactory as createBase64WorkerFactory$2 } from './_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js';
|
|
3
|
-
import { isNodeJS } from './_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js';
|
|
4
|
-
|
|
5
|
-
function createBase64WorkerFactory(base64, sourcemapArg, enableUnicodeArg) {
|
|
6
|
-
if (isNodeJS()) {
|
|
7
|
-
return createBase64WorkerFactory$1(base64, sourcemapArg, enableUnicodeArg);
|
|
8
|
-
}
|
|
9
|
-
return createBase64WorkerFactory$2(base64, sourcemapArg, enableUnicodeArg);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export { createBase64WorkerFactory };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
var WorkerClass = null;
|
|
2
|
-
|
|
3
|
-
try {
|
|
4
|
-
var WorkerThreads =
|
|
5
|
-
typeof module !== 'undefined' && typeof module.require === 'function' && module.require('worker_threads') ||
|
|
6
|
-
typeof __non_webpack_require__ === 'function' && __non_webpack_require__('worker_threads') ||
|
|
7
|
-
typeof require === 'function' && require('worker_threads');
|
|
8
|
-
WorkerClass = WorkerThreads.Worker;
|
|
9
|
-
} catch(e) {} // eslint-disable-line
|
|
10
|
-
|
|
11
|
-
export { WorkerClass };
|
package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { WorkerClass } from './_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js';
|
|
2
|
-
|
|
3
|
-
function decodeBase64(base64, enableUnicode) {
|
|
4
|
-
return Buffer.from(base64, 'base64').toString(enableUnicode ? 'utf16' : 'utf8');
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
function createBase64WorkerFactory(base64, sourcemapArg, enableUnicodeArg) {
|
|
8
|
-
var sourcemap = sourcemapArg === undefined ? null : sourcemapArg;
|
|
9
|
-
var enableUnicode = enableUnicodeArg === undefined ? false : enableUnicodeArg;
|
|
10
|
-
var source = decodeBase64(base64, enableUnicode);
|
|
11
|
-
var start = source.indexOf('\n', 10) + 1;
|
|
12
|
-
var body = source.substring(start) + (sourcemap ? '\/\/# sourceMappingURL=' + sourcemap : '');
|
|
13
|
-
return function WorkerFactory(options) {
|
|
14
|
-
return new WorkerClass(body, Object.assign({}, options, { eval: true }));
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export { createBase64WorkerFactory };
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
|
|
3
|
-
class PointCloudSegmentOperation {
|
|
4
|
-
constructor(props) {
|
|
5
|
-
this.pointer = new THREE.Vector2();
|
|
6
|
-
this.onMouseMove = (e) => {
|
|
7
|
-
const coord = this.getCoordinate(e);
|
|
8
|
-
this.pointer.x = coord.x / this.dom.clientWidth * 2 - 1;
|
|
9
|
-
this.pointer.y = -(coord.y / this.dom.clientHeight) * 2 + 1;
|
|
10
|
-
this.emitRender();
|
|
11
|
-
};
|
|
12
|
-
this.dom = props.dom;
|
|
13
|
-
this.raycaster = new THREE.Raycaster();
|
|
14
|
-
this.dom.addEventListener("pointermove", this.onMouseMove);
|
|
15
|
-
const geometry = new THREE.BufferGeometry();
|
|
16
|
-
const pointsMaterial = new THREE.PointsMaterial({size: 10, color: "red"});
|
|
17
|
-
geometry.setAttribute("position", new THREE.BufferAttribute(new Float32Array([0, 0, 0]), 3));
|
|
18
|
-
this._highlight_Point = new THREE.Points(geometry, pointsMaterial);
|
|
19
|
-
this.emitRender = props.render;
|
|
20
|
-
const geometry2 = new THREE.BufferGeometry();
|
|
21
|
-
const pointsMaterial2 = new THREE.PointsMaterial({size: 5, color: "white"});
|
|
22
|
-
geometry2.setAttribute("position", new THREE.BufferAttribute(new Float32Array([0, 0, 0]), 3));
|
|
23
|
-
this._temp = new THREE.Points(geometry2, pointsMaterial2);
|
|
24
|
-
}
|
|
25
|
-
addMorePoint(scene) {
|
|
26
|
-
scene.add(this._highlight_Point);
|
|
27
|
-
scene.add(this._temp);
|
|
28
|
-
}
|
|
29
|
-
getCoordinate(e) {
|
|
30
|
-
const bounding = this.dom.getBoundingClientRect();
|
|
31
|
-
return {
|
|
32
|
-
x: e.clientX - bounding.left,
|
|
33
|
-
y: e.clientY - bounding.top
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
render({camera, scene}) {
|
|
37
|
-
this.raycaster.setFromCamera(this.pointer, camera);
|
|
38
|
-
const intersects = this.raycaster.intersectObjects(scene.children, false);
|
|
39
|
-
console.log("intersects", intersects[0]);
|
|
40
|
-
const default_Point = new THREE.Vector3(0, 0, 0);
|
|
41
|
-
if (intersects.length > 0) {
|
|
42
|
-
const intersect = intersects[0];
|
|
43
|
-
this._highlight_Point.position.copy(intersect.point);
|
|
44
|
-
} else {
|
|
45
|
-
this._highlight_Point.position.copy(default_Point);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export { PointCloudSegmentOperation };
|