@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
|
-
"use strict";var tool=require("../../constant/tool.js"),RectUtils=require("../../utils/tool/RectUtils.js"),PolygonUtils=require("../../utils/tool/PolygonUtils.js"),MarkerUtils=require("../../utils/tool/MarkerUtils.js"),MathUtils=require("../../utils/MathUtils.js"),annotation=require("../../constant/annotation.js"),keyCode=require("../../constant/keyCode.js"),index=require("../../locales/index.js"),constants=require("../../locales/constants.js"),AttributeUtils=require("../../utils/tool/AttributeUtils.js"),AxisUtils=require("../../utils/tool/AxisUtils.js"),CommonToolUtils=require("../../utils/tool/CommonToolUtils.js"),DrawUtils=require("../../utils/tool/DrawUtils.js"),StyleUtils=require("../../utils/tool/StyleUtils.js"),uuid=require("../../utils/uuid.js"),basicToolOperation=require("./basicToolOperation.js"),textAttributeClass=require("./textAttributeClass.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__pow=Math.pow,__defNormalProp=(c,t,e)=>t in c?__defProp(c,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[t]=e,__spreadValues=(c,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(c,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(c,e,t[e]);return c},__spreadProps=(c,t)=>__defProps(c,__getOwnPropDescs(t));const TEXTAREA_WIDTH=200;class PointOperation extends basicToolOperation.BasicToolOperation{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(r=>r.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(AttributeUtils.default.textChange(e,this.selectedID,this.pointList)),this.emit("selectedChange"),this.render())},this.isMinDistance=e=>{const i=AxisUtils.default.changePointByZoom(e,this.zoom);return this.pointList.some(s=>{const r=AxisUtils.default.changePointByZoom(s,this.zoom);return MathUtils.default.getLineLength(r,i)<.2})},this.config=CommonToolUtils.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=CommonToolUtils.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=CommonToolUtils.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 AttributeUtils.default.getTextIconSvg(t,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}clearActiveStatus(){this.hoverID=void 0,this.dragStatus=annotation.EDragStatus.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=>__spreadProps(__spreadValues({},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=annotation.EDragStatus.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===annotation.EDragStatus.Start||this.dragStatus===annotation.EDragStatus.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===annotation.EDragStatus.Move&&(this.history.pushHistory(this.pointList),this.dragInfo=void 0),this.dragStatus=annotation.EDragStatus.Wait,this.render()}onDragMove(t){var e,i;if(!this.imgInfo)return;this.dragStatus=annotation.EDragStatus.Move;const s=this.getCoordinateUnderZoom(t);if(this.isMultiMoveMode&&this.dragInfo){const n={x:s.x-this.dragInfo.dragStartCoord.x,y:s.y-this.dragInfo.dragStartCoord.y};this.onDragMoveAll(n);return}const r=AxisUtils.default.changeDrawOutsideTarget(s,{x:0,y:0},this.imgInfo,this.drawOutsideTarget,this.basicResult,this.zoom),h=this.drawOutsideTarget?AxisUtils.default.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos):AxisUtils.default.changePointByZoom(r,1/this.zoom);this.drawOutsideTarget===!1&&this.dependToolName===tool.EToolName.Polygon&&((i=(e=this.basicResult)==null?void 0:e.pointList)==null?void 0:i.length)>0&&!PolygonUtils.isInPolygon(h,this.basicResult.pointList)||(this.pointList.forEach(n=>{n.id===this.selectedID&&(n.x=h.x,n.y=h.y)}),this.render())}onKeyDown(t){if(!CommonToolUtils.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case keyCode.Delete:this.deletePoint();break;case keyCode.Tab:{this.onTabKeyDown(t);break}case keyCode.Z:this.setIsHidden(!this.isHidden),this.render();break;default:{if(this.config.attributeConfigurable){const i=AttributeUtils.default.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}}createPoint(t){var e,i,s,r;if(!this.imgInfo)return;const{upperLimit:h}=this.config;if(h&&this.currentPageResult.length>=h){this.emit("messageInfo",`${index.getMessagesByLocale(constants.EMessage.LowerLimitPoint,this.lang)}`);return}const n=CommonToolUtils.getSourceID(this.basicResult),d=this.getCoordinateUnderZoom(t);let l=AxisUtils.default.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);if(this.config.edgeAdsorption&&this.referenceData&&[tool.EToolName.Polygon,tool.EToolName.Line].includes((e=this.referenceData)==null?void 0:e.toolName)){const g=((i=this.referenceData)==null?void 0:i.toolName)===tool.EToolName.Polygon,{dropFoot:f,hasClosed:v}=PolygonUtils.getClosestPoint(l,this.referenceData.result,(r=(s=this.referenceData.config)==null?void 0:s.lineType)!=null?r:tool.ELineTypes.Line,tool.edgeAdsorptionScope/this.zoom,{isClose:g});f&&(l=f),v&&this.emit("messageSuccess",`${index.getMessagesByLocale(constants.EMessage.SuccessfulEdgeAdsorption,this.lang)}`)}if(this.drawOutsideTarget===!1){if(this.dependToolName&&this.basicCanvas){let a=!1;switch(this.dependToolName){case tool.EToolName.Rect:{a=!RectUtils.isInRect(l,this.basicResult);break}case tool.EToolName.Polygon:{a=!PolygonUtils.isInPolygon(l,this.basicResult.pointList);break}}if(a)return}if(d.x<0||d.y<0||d.x>this.imgInfo.width||d.y>this.imgInfo.height)return}if(this.isMinDistance(l))return;let o=__spreadProps(__spreadValues({},l),{attribute:this.defaultAttribute,valid:!t.ctrlKey,id:uuid(8,62),sourceID:n,textAttribute:"",order:CommonToolUtils.getMaxOrder(this.pointList.filter(a=>CommonToolUtils.isSameSourceID(a.sourceID,n)))+1});if(this.config.textConfigurable){let a="";a=AttributeUtils.default.getTextAttribute(this.pointList.filter(g=>CommonToolUtils.isSameSourceID(g.sourceID,n)),this.config.textCheckType),o=__spreadProps(__spreadValues({},o),{textAttribute:a})}if(this.hasMarkerConfig){const a=CommonToolUtils.getNextMarker(this.currentPageResult,this.config.markerList,this.markerIndex);if(a)o=__spreadProps(__spreadValues({},o),{label:a.label}),this.markerIndex=a.index,this.emit("markIndexChange");else{this.emit("messageInfo",index.getMessagesByLocale(constants.EMessage.MarkerFinish,this.lang));return}}this.hoverID=o.id;const u=[...this.pointList,o];this.setPointList(u),this.history.pushHistory(u),this.setSelectedID(o.id)}isInPoint(t,e,i=this.zoom){return(this.style.width+2)/i>=Math.sqrt(__pow(t.x-e.x,2)+__pow(t.y-e.y,2))}getHoverId(){var t;const e=AxisUtils.default.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=CommonToolUtils.getCurrentMarkerIndex(t.label,this.config.markerList);e>=0&&(this.setMarkerIndex(e),this.emit("markIndexChange"))}}onTabKeyDown(t){if(t.preventDefault(),this.dragStatus===annotation.EDragStatus.Move||this.dragStatus===annotation.EDragStatus.Start)return;let e=annotation.ESortDirection.ascend;t.shiftKey&&(e=annotation.ESortDirection.descend);const[i,s]=CommonToolUtils.getRenderResultList(this.pointList,CommonToolUtils.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);let r=[...i];s&&(r=[...r,s]);const h=CommonToolUtils.getNextSelectedRectID(r,e,this.selectedID);h&&this.setSelectedID(h.id)}get currentPageResult(){const[t]=CommonToolUtils.getRenderResultList(this.pointList,CommonToolUtils.getSourceID(this.basicResult),[]);return t}getCurrentPageResult(t){const[e]=CommonToolUtils.getRenderResultList(t,CommonToolUtils.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===annotation.EDragStatus.Move||this.dragStatus===annotation.EDragStatus.Start)return;const s=(i=(e=this.history)[t])==null?void 0:i.call(e);(s==null?void 0:s.some(r=>r.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(r=>r.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=annotation.EDragStatus.Wait,{width:TEXTAREA_WIDTH*this.zoom*.6,textAttribute:(e==null?void 0:e.textAttribute)||"",color:s}}updateSelectedTextAttribute(t){if(this._textAttributInstance&&t&&this.selectedID){let e=t;AttributeUtils.default.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",AttributeUtils.default.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setPointList(AttributeUtils.default.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(g=>g.id===this.selectedID);if(!this.ctx||this.config.textConfigurable!==!0||!i)return;const{x:s,y:r,attribute:h,valid:n}=i,d=TEXTAREA_WIDTH*this.zoom*.6,l=AxisUtils.default.getOffsetCoordinate({x:s,y:r},this.currentPos,this.zoom),o=this.getColor(h),u=n?o==null?void 0:o.valid.stroke:o==null?void 0:o.invalid.stroke,a=4;this._textAttributInstance||(this._textAttributInstance=new textAttributeClass({width:d,container:this.container,icon:this.getTextIconSvg(h),color:u,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:l.x,top:l.y+a,color:u,width:d})}renderPoint(t,e=!1){var i,s,r;const{textAttribute:h="",attribute:n}=t,d=e||t.id===this.selectedID,l=this.getColor(n),o=AxisUtils.default.changePointByZoom(t,this.zoom,this.currentPos),{width:u=2,hiddenText:a=!1}=this.style,g=StyleUtils.getStrokeAndFill(l,t.valid,{isSelected:d||t.id===this.hoverID});DrawUtils.drawCircle(this.canvas,o,u,{startAngleDeg:0,endAngleDeg:360,thickness:1,color:g.stroke,fill:g.fill});let f="";(((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&&(f=`${t.order}`),t.label&&this.hasMarkerConfig&&(f=`${CommonToolUtils.getCurrentMarkerIndex(t.label,this.config.markerList)+1}_${MarkerUtils.getMarkerShowText(t.label,this.config.markerList)}`),t.attribute&&(f=`${f} ${AttributeUtils.default.getAttributeShowText(t.attribute,(r=this.config)==null?void 0:r.attributeList)}`),a||DrawUtils.drawText(this.canvas,{x:o.x+u/2,y:o.y-u-4},f,{textAlign:"center",color:g.stroke}),d?this.renderTextAttribute():a||DrawUtils.drawText(this.canvas,{x:o.x+u,y:o.y+u+24},h,__spreadValues({color:g.stroke},annotation.DEFAULT_TEXT_OFFSET))}renderMultiSelectedPoint(){!this.isMultiMoveMode||this.pointList.forEach(t=>{this.renderPoint(t,!0)})}renderPointList(){switch(this.operationMode){case tool.EOperationMode.MultiMove:this.renderMultiSelectedPoint();break;default:{const[t,e]=CommonToolUtils.getRenderResultList(this.pointList,CommonToolUtils.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]=CommonToolUtils.getRenderResultList(this.pointList,CommonToolUtils.getSourceID(this.basicResult),this.attributeLockList,this.selectedID),s=e;if(i&&s.push(i),s.length<2)return;const r=MarkerUtils.getAuxiliaryLineByMarkerList(this.config.markerList,"value");MarkerUtils.getAuxiliaryLineCoord(r,s).forEach(n=>{const{start:d,end:l}=n,o=AxisUtils.default.changePointListByZoom([d,l],this.zoom,this.currentPos);DrawUtils.drawLine(this.canvas,o[0],o[1],{color:"#C5C5C5"})})}renderTop(){var t,e,i;const s=this.getLineColor(this.defaultAttribute);if(this.renderCursorLine(s),this.config.edgeAdsorption&&this.referenceData){let r=AxisUtils.default.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);const h=((t=this.referenceData)==null?void 0:t.toolName)===tool.EToolName.Polygon,{dropFoot:n}=PolygonUtils.getClosestPoint(r,this.referenceData.result,(i=(e=this.referenceData.config)==null?void 0:e.lineType)!=null?i:tool.ELineTypes.Line,tool.edgeAdsorptionScope/this.zoom,{isClose:h});n&&r!==n&&r!==n&&(r=n,DrawUtils.drawCircle(this.canvas,AxisUtils.default.changePointByZoom(r,this.zoom,this.currentPos),5,{color:"white",fill:"white"}),DrawUtils.drawCircle(this.canvas,AxisUtils.default.changePointByZoom(r,this.zoom,this.currentPos),3,{fill:s,color:s}))}}render(){!this.ctx||(super.render(),this.renderAuxiliaryLine(),this.renderPointList(),this.renderTop())}}module.exports=PointOperation;
|
|
1
|
+
"use strict";var tool=require("../../constant/tool.js"),RectUtils=require("../../utils/tool/RectUtils.js"),PolygonUtils=require("../../utils/tool/PolygonUtils.js"),MarkerUtils=require("../../utils/tool/MarkerUtils.js"),MathUtils=require("../../utils/MathUtils.js"),_=require("lodash"),annotation=require("../../constant/annotation.js"),keyCode=require("../../constant/keyCode.js"),index=require("../../locales/index.js"),constants=require("../../locales/constants.js"),AttributeUtils=require("../../utils/tool/AttributeUtils.js"),AxisUtils=require("../../utils/tool/AxisUtils.js"),CommonToolUtils=require("../../utils/tool/CommonToolUtils.js"),DrawUtils=require("../../utils/tool/DrawUtils.js"),StyleUtils=require("../../utils/tool/StyleUtils.js"),uuid=require("../../utils/uuid.js"),basicToolOperation=require("./basicToolOperation.js"),textAttributeClass=require("./textAttributeClass.js");function _interopDefaultLegacy(l){return l&&typeof l=="object"&&"default"in l?l:{default:l}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__pow=Math.pow,__defNormalProp=(l,t,e)=>t in l?__defProp(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e,__spreadValues=(l,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(l,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(l,e,t[e]);return l},__spreadProps=(l,t)=>__defProps(l,__getOwnPropDescs(t));const TEXTAREA_WIDTH=200;class PointOperation extends basicToolOperation.BasicToolOperation{constructor(t){super(t);this.setMarkerIndex=s=>{this.markerIndex=s},this.setMarkerIndexAndSelect=s=>{if(!this.config.markerList)return;this.markerIndex=s;const r=this.config.markerList[s].value,n=this.currentPageResult.find(o=>o.label===r);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(AttributeUtils.default.textChange(s,this.selectedID,this.pointList)),this.emit("selectedChange"),this.render())},this.isMinDistance=s=>{const r=AxisUtils.default.changePointByZoom(s,this.zoom);return this.pointList.some(n=>{const o=AxisUtils.default.changePointByZoom(n,this.zoom);return MathUtils.default.getLineLength(o,r)<.2})};var e,i;this.config=CommonToolUtils.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=CommonToolUtils.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=CommonToolUtils.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 AttributeUtils.default.getTextIconSvg(t,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}clearActiveStatus(){this.hoverID=void 0,this.dragStatus=annotation.EDragStatus.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=>__spreadProps(__spreadValues({},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=annotation.EDragStatus.Start,this.dragInfo={dragStartCoord:this.getCoordinateUnderZoom(t),originPointList:___default.default.cloneDeep(this.pointList)};return}return this.render(),!0}}onMouseMove(t){super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo||(this.hoverID=this.getHoverId(),(this.dragStatus===annotation.EDragStatus.Start||this.dragStatus===annotation.EDragStatus.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===annotation.EDragStatus.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=annotation.EDragStatus.Wait,this.render()}onDragMove(t){var e,i;if(!this.imgInfo)return;this.dragStatus=annotation.EDragStatus.Move;const s=this.getCoordinateUnderZoom(t);if(this.isMultiMoveMode&&this.dragInfo){const o={x:s.x-this.dragInfo.dragStartCoord.x,y:s.y-this.dragInfo.dragStartCoord.y};this.onDragMoveAll(o);return}const r=AxisUtils.default.changeDrawOutsideTarget(s,{x:0,y:0},this.imgInfo,this.drawOutsideTarget,this.basicResult,this.zoom),n=this.drawOutsideTarget?AxisUtils.default.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos):AxisUtils.default.changePointByZoom(r,1/this.zoom);this.drawOutsideTarget===!1&&this.dependToolName===tool.EToolName.Polygon&&((i=(e=this.basicResult)==null?void 0:e.pointList)==null?void 0:i.length)>0&&!PolygonUtils.isInPolygon(n,this.basicResult.pointList)||(this.pointList.forEach(o=>{o.id===this.selectedID&&(o.x=n.x,o.y=n.y)}),this.render())}onKeyDown(t){if(!CommonToolUtils.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case keyCode.Delete:this.deletePoint();break;case keyCode.Tab:{this.onTabKeyDown(t);break}case keyCode.Z:this.setIsHidden(!this.isHidden),this.render();break;default:{if(this.config.attributeConfigurable){const i=AttributeUtils.default.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}}createPoint(t){var e,i,s,r;if(!this.imgInfo||this.forbidAddNew)return;const{upperLimit:n}=this.config;if(n&&this.currentPageResult.length>=n){this.emit("messageInfo",`${index.getMessagesByLocale(constants.EMessage.LowerLimitPoint,this.lang)}`);return}const o=CommonToolUtils.getSourceID(this.basicResult),u=this.getCoordinateUnderZoom(t);let d=AxisUtils.default.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);if(this.config.edgeAdsorption&&this.referenceData&&[tool.EToolName.Polygon,tool.EToolName.Line].includes((e=this.referenceData)==null?void 0:e.toolName)){const f=((i=this.referenceData)==null?void 0:i.toolName)===tool.EToolName.Polygon,{dropFoot:g,hasClosed:v}=PolygonUtils.getClosestPoint(d,this.referenceData.result,(r=(s=this.referenceData.config)==null?void 0:s.lineType)!=null?r:tool.ELineTypes.Line,tool.edgeAdsorptionScope/this.zoom,{isClose:f});g&&(d=g),v&&this.emit("messageSuccess",`${index.getMessagesByLocale(constants.EMessage.SuccessfulEdgeAdsorption,this.lang)}`)}if(this.drawOutsideTarget===!1){if(this.dependToolName&&this.basicCanvas){let h=!1;switch(this.dependToolName){case tool.EToolName.Rect:{h=!RectUtils.isInRect(d,this.basicResult);break}case tool.EToolName.Polygon:{h=!PolygonUtils.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 a=__spreadProps(__spreadValues({},d),{attribute:this.defaultAttribute,valid:!t.ctrlKey,id:uuid(8,62),sourceID:o,textAttribute:"",order:CommonToolUtils.getMaxOrder(this.pointList.filter(h=>CommonToolUtils.isSameSourceID(h.sourceID,o)))+1});if(this.config.textConfigurable){let h="";h=AttributeUtils.default.getTextAttribute(this.pointList.filter(f=>CommonToolUtils.isSameSourceID(f.sourceID,o)),this.config.textCheckType),a=__spreadProps(__spreadValues({},a),{textAttribute:h})}if(this.hasMarkerConfig){const h=CommonToolUtils.getNextMarker(this.currentPageResult,this.config.markerList,this.markerIndex);if(h)a=__spreadProps(__spreadValues({},a),{label:h.label}),this.markerIndex=h.index,this.emit("markIndexChange");else{this.emit("messageInfo",index.getMessagesByLocale(constants.EMessage.MarkerFinish,this.lang));return}}this.hoverID=a.id;const c=[...this.pointList,a];this.setPointList(c),this.emit("pointCreated",a,this.zoom),this.history.pushHistory(c),this.setSelectedID(a.id)}isInPoint(t,e,i=this.zoom){return(this.style.width+2)/i>=Math.sqrt(__pow(t.x-e.x,2)+__pow(t.y-e.y,2))}getHoverId(){var t;const e=AxisUtils.default.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=CommonToolUtils.getCurrentMarkerIndex(t.label,this.config.markerList);e>=0&&(this.setMarkerIndex(e),this.emit("markIndexChange"))}}onTabKeyDown(t){if(t.preventDefault(),this.dragStatus===annotation.EDragStatus.Move||this.dragStatus===annotation.EDragStatus.Start)return;let e=annotation.ESortDirection.ascend;t.shiftKey&&(e=annotation.ESortDirection.descend);const[i,s]=CommonToolUtils.getRenderResultList(this.pointList,CommonToolUtils.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);let r=[...i];s&&(r=[...r,s]);const n=CommonToolUtils.getNextSelectedRectID(r,e,this.selectedID);n&&this.setSelectedID(n.id)}get currentPageResult(){const[t]=CommonToolUtils.getRenderResultList(this.pointList,CommonToolUtils.getSourceID(this.basicResult),[]);return t}getCurrentPageResult(t){const[e]=CommonToolUtils.getRenderResultList(t,CommonToolUtils.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===annotation.EDragStatus.Move||this.dragStatus===annotation.EDragStatus.Start)return;const s=(i=(e=this.history)[t])==null?void 0:i.call(e);(s==null?void 0:s.some(r=>r.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(r=>r.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=annotation.EDragStatus.Wait,{width:TEXTAREA_WIDTH*this.zoom*.6,textAttribute:(e==null?void 0:e.textAttribute)||"",color:s}}updateSelectedTextAttribute(t){if(this._textAttributInstance&&t&&this.selectedID){let e=t;AttributeUtils.default.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",AttributeUtils.default.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setPointList(AttributeUtils.default.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(f=>f.id===this.selectedID);if(!this.ctx||this.config.textConfigurable!==!0||!i)return;const{x:s,y:r,attribute:n,valid:o}=i,u=TEXTAREA_WIDTH*this.zoom*.6,d=AxisUtils.default.getOffsetCoordinate({x:s,y:r},this.currentPos,this.zoom),a=this.getColor(n),c=o?a==null?void 0:a.valid.stroke:a==null?void 0:a.invalid.stroke,h=4;this._textAttributInstance||(this._textAttributInstance=new textAttributeClass({width:u,container:this.container,icon:this.getTextIconSvg(n),color:c,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:c,width:u})}renderPoint(t,e=!1){var i,s,r;const{textAttribute:n="",attribute:o}=t,u=e||t.id===this.selectedID,d=this.getColor(o),a=AxisUtils.default.changePointByZoom(t,this.zoom,this.currentPos),{width:c=2,hiddenText:h=!1}=this.style,f=StyleUtils.getStrokeAndFill(d,t.valid,{isSelected:u||t.id===this.hoverID});DrawUtils.drawCircle(this.canvas,a,c,{startAngleDeg:0,endAngleDeg:360,thickness:1,color:f.stroke,fill:f.fill});let g="";(((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&&(g=`${t.order}`),t.label&&this.hasMarkerConfig&&(g=`${CommonToolUtils.getCurrentMarkerIndex(t.label,this.config.markerList)+1}_${MarkerUtils.getMarkerShowText(t.label,this.config.markerList)}`),t.attribute&&!this.config.hideAttribute&&(g=`${g} ${AttributeUtils.default.getAttributeShowText(t.attribute,(r=this.config)==null?void 0:r.attributeList)}`),h||DrawUtils.drawText(this.canvas,{x:a.x+c/2,y:a.y-c-4},g,{textAlign:"center",color:f.stroke}),u?this.renderTextAttribute():h||DrawUtils.drawText(this.canvas,{x:a.x+c,y:a.y+c+24},n,__spreadValues({color:f.stroke},annotation.DEFAULT_TEXT_OFFSET))}renderMultiSelectedPoint(){!this.isMultiMoveMode||this.pointList.forEach(t=>{this.renderPoint(t,!0)})}renderPointList(){switch(this.operationMode){case tool.EOperationMode.MultiMove:this.renderMultiSelectedPoint();break;default:{const[t,e]=CommonToolUtils.getRenderResultList(this.pointList,CommonToolUtils.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]=CommonToolUtils.getRenderResultList(this.pointList,CommonToolUtils.getSourceID(this.basicResult),this.attributeLockList,this.selectedID),s=e;if(i&&s.push(i),s.length<2)return;const r=MarkerUtils.getAuxiliaryLineByMarkerList(this.config.markerList,"value");MarkerUtils.getAuxiliaryLineCoord(r,s).forEach(o=>{const{start:u,end:d}=o,a=AxisUtils.default.changePointListByZoom([u,d],this.zoom,this.currentPos);DrawUtils.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 r=AxisUtils.default.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);const n=((t=this.referenceData)==null?void 0:t.toolName)===tool.EToolName.Polygon,{dropFoot:o}=PolygonUtils.getClosestPoint(r,this.referenceData.result,(i=(e=this.referenceData.config)==null?void 0:e.lineType)!=null?i:tool.ELineTypes.Line,tool.edgeAdsorptionScope/this.zoom,{isClose:n});o&&r!==o&&r!==o&&(r=o,DrawUtils.drawCircle(this.canvas,AxisUtils.default.changePointByZoom(r,this.zoom,this.currentPos),5,{color:"white",fill:"white"}),DrawUtils.drawCircle(this.canvas,AxisUtils.default.changePointByZoom(r,this.zoom,this.currentPos),3,{fill:s,color:s}))}}render(){!this.ctx||(super.render(),this.renderAuxiliaryLine(),this.renderPointList(),this.renderTop())}}module.exports=PointOperation;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var rectOperation=require("./core/toolOperation/rectOperation.js"),tagOperation=require("./core/toolOperation/tagOperation.js"),pointOperation=require("./core/toolOperation/pointOperation.js"),LineToolOperation=require("./core/toolOperation/LineToolOperation.js"),TextToolOperation=require("./core/toolOperation/TextToolOperation.js"),polygonOperation=require("./core/toolOperation/polygonOperation.js"),measureOperation=require("./core/toolOperation/measureOperation.js"),basicToolOperation=require("./core/toolOperation/basicToolOperation.js"),ViewOperation=require("./core/toolOperation/ViewOperation.js"),ScribbleTool=require("./core/toolOperation/ScribbleTool.js"),pointCloud2dOperation=require("./core/toolOperation/pointCloud2dOperation.js"),annotation=require("./constant/annotation.js"),annotationTask=require("./constant/annotationTask.js"),keyCode=require("./constant/keyCode.js"),style=require("./constant/style.js"),tool=require("./constant/tool.js"),TagUtils=require("./utils/tool/TagUtils.js"),uuid=require("./utils/uuid.js"),EnhanceCommonToolUtils=require("./utils/tool/EnhanceCommonToolUtils.js"),MarkerUtils=require("./utils/tool/MarkerUtils.js"),RectUtils=require("./utils/tool/RectUtils.js"),AxisUtils=require("./utils/tool/AxisUtils.js"),DrawUtils=require("./utils/tool/DrawUtils.js"),ImgUtils=require("./utils/ImgUtils.js"),MathUtils=require("./utils/MathUtils.js"),AttributeUtils=require("./utils/tool/AttributeUtils.js"),ActionsHistory=require("./utils/ActionsHistory.js"),DblClickEventListener=require("./utils/tool/DblClickEventListener.js"),index=require("./core/index.js"),UnitUtils=require("./utils/tool/UnitUtils.js"),CanvasScheduler=require("./newCore/CanvasScheduler.js"),index$1=require("./core/pointCloud/index.js"),matrix=require("./core/pointCloud/matrix.js"),annotation$1=require("./core/pointCloud/annotation.js");function _interopNamespaceDefaultOnly(e){return Object.freeze({__proto__:null,default:e})}var keyCode__namespace=_interopNamespaceDefaultOnly(keyCode);const CommonToolUtils=EnhanceCommonToolUtils.default,toolUtils=EnhanceCommonToolUtils.default;exports.RectOperation=rectOperation.RectOperation,exports.TagOperation=tagOperation,exports.PointOperation=pointOperation,exports.LineToolOperation=LineToolOperation.default,exports.TextToolOperation=TextToolOperation,exports.PolygonOperation=polygonOperation,exports.MeasureOperation=measureOperation,exports.BasicToolOperation=basicToolOperation.BasicToolOperation,exports.ViewOperation=ViewOperation,exports.ScribbleTool=ScribbleTool,exports.PointCloud2dOperation=pointCloud2dOperation,exports.cAnnotation=annotation,exports.cAnnotationTask=annotationTask,exports.cKeyCode=keyCode__namespace,exports.cStyle=style,exports.CLIENT_TOOL_HEAD_TYPE=tool.CLIENT_TOOL_HEAD_TYPE,exports.CLIENT_TOOL_NAME=tool.CLIENT_TOOL_NAME,exports.DEFAULT_FONT=tool.DEFAULT_FONT,exports.DEFAULT_TEXT_MAX_WIDTH=tool.DEFAULT_TEXT_MAX_WIDTH,Object.defineProperty(exports,"EAnnotationMode",{enumerable:!0,get:function(){return tool.EAnnotationMode}}),Object.defineProperty(exports,"EAuditStatus",{enumerable:!0,get:function(){return tool.EAuditStatus}}),Object.defineProperty(exports,"ECheckModel",{enumerable:!0,get:function(){return tool.ECheckModel}}),Object.defineProperty(exports,"EDependPattern",{enumerable:!0,get:function(){return tool.EDependPattern}}),Object.defineProperty(exports,"EDragTarget",{enumerable:!0,get:function(){return tool.EDragTarget}}),Object.defineProperty(exports,"EDrawPointPattern",{enumerable:!0,get:function(){return tool.EDrawPointPattern}}),Object.defineProperty(exports,"EFilterToolOperation",{enumerable:!0,get:function(){return tool.EFilterToolOperation}}),Object.defineProperty(exports,"ELineColor",{enumerable:!0,get:function(){return tool.ELineColor}}),Object.defineProperty(exports,"ELineTypes",{enumerable:!0,get:function(){return tool.ELineTypes}}),Object.defineProperty(exports,"EOperationMode",{enumerable:!0,get:function(){return tool.EOperationMode}}),Object.defineProperty(exports,"EPageOperator",{enumerable:!0,get:function(){return tool.EPageOperator}}),Object.defineProperty(exports,"EPointCloudName",{enumerable:!0,get:function(){return tool.EPointCloudName}}),Object.defineProperty(exports,"EPolygonPattern",{enumerable:!0,get:function(){return tool.EPolygonPattern}}),Object.defineProperty(exports,"ERectPattern",{enumerable:!0,get:function(){return tool.ERectPattern}}),Object.defineProperty(exports,"EScribblePattern",{enumerable:!0,get:function(){return tool.EScribblePattern}}),Object.defineProperty(exports,"ESelectedType",{enumerable:!0,get:function(){return tool.ESelectedType}}),Object.defineProperty(exports,"ETextType",{enumerable:!0,get:function(){return tool.ETextType}}),Object.defineProperty(exports,"EThumbnailOption",{enumerable:!0,get:function(){return tool.EThumbnailOption}}),Object.defineProperty(exports,"EToolName",{enumerable:!0,get:function(){return tool.EToolName}}),Object.defineProperty(exports,"EToolType",{enumerable:!0,get:function(){return tool.EToolType}}),Object.defineProperty(exports,"EVideoToolName",{enumerable:!0,get:function(){return tool.EVideoToolName}}),exports.OPERATION_LIST=tool.OPERATION_LIST,exports.SEGMENT_NUMBER=tool.SEGMENT_NUMBER,exports.TEXT_ATTRIBUTE_LINE_HEIGHT=tool.TEXT_ATTRIBUTE_LINE_HEIGHT,exports.TEXT_ATTRIBUTE_MAX_LENGTH=tool.TEXT_ATTRIBUTE_MAX_LENGTH,exports.TEXT_TYPE=tool.TEXT_TYPE,exports.TOOL_NAME=tool.TOOL_NAME,exports.TOOL_NAME_EN=tool.TOOL_NAME_EN,exports.cTool=tool,exports.edgeAdsorptionScope=tool.edgeAdsorptionScope,exports.editStepWidth=tool.editStepWidth,exports.TagUtils=TagUtils,exports.uuid=uuid,exports.MarkerUtils=MarkerUtils,exports.RectUtils=RectUtils,exports.AxisUtils=AxisUtils.default,exports.DrawUtils=DrawUtils,exports.ImgUtils=ImgUtils,exports.MathUtils=MathUtils.default,exports.AttributeUtils=AttributeUtils.default,exports.ActionsHistory=ActionsHistory,exports.DblClickEventListener=DblClickEventListener,exports.AnnotationEngine=index,exports.UnitUtils=UnitUtils,exports.CanvasScheduler=CanvasScheduler.CanvasScheduler,exports.PointCloud=index$1.PointCloud,exports.createThreeMatrix4=matrix.createThreeMatrix4,exports.getCuboidFromPointCloudBox=matrix.getCuboidFromPointCloudBox,exports.lidar2image=matrix.lidar2image,exports.pointCloudLidar2image=matrix.pointCloudLidar2image,exports.rotatePoint=matrix.rotatePoint,exports.transferKitti2Matrix=matrix.transferKitti2Matrix,exports.PointCloudAnnotation=annotation$1.PointCloudAnnotation,exports.CommonToolUtils=CommonToolUtils,exports.toolUtils=toolUtils;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var rectOperation=require("./core/toolOperation/rectOperation.js"),tagOperation=require("./core/toolOperation/tagOperation.js"),pointOperation=require("./core/toolOperation/pointOperation.js"),LineToolOperation=require("./core/toolOperation/LineToolOperation.js"),TextToolOperation=require("./core/toolOperation/TextToolOperation.js"),polygonOperation=require("./core/toolOperation/polygonOperation.js"),measureOperation=require("./core/toolOperation/measureOperation.js"),basicToolOperation=require("./core/toolOperation/basicToolOperation.js"),ViewOperation=require("./core/toolOperation/ViewOperation.js"),ScribbleTool=require("./core/toolOperation/ScribbleTool.js"),pointCloud2dOperation=require("./core/toolOperation/pointCloud2dOperation.js"),annotation=require("./constant/annotation.js"),annotationTask=require("./constant/annotationTask.js"),keyCode=require("./constant/keyCode.js"),style=require("./constant/style.js"),tool=require("./constant/tool.js"),TagUtils=require("./utils/tool/TagUtils.js"),uuid=require("./utils/uuid.js"),EnhanceCommonToolUtils=require("./utils/tool/EnhanceCommonToolUtils.js"),MarkerUtils=require("./utils/tool/MarkerUtils.js"),RectUtils=require("./utils/tool/RectUtils.js"),AxisUtils=require("./utils/tool/AxisUtils.js"),DrawUtils=require("./utils/tool/DrawUtils.js"),ImgUtils=require("./utils/ImgUtils.js"),MathUtils=require("./utils/MathUtils.js"),AttributeUtils=require("./utils/tool/AttributeUtils.js"),ActionsHistory=require("./utils/ActionsHistory.js"),DblClickEventListener=require("./utils/tool/DblClickEventListener.js"),index=require("./core/index.js"),UnitUtils=require("./utils/tool/UnitUtils.js"),StyleUtils=require("./utils/tool/StyleUtils.js"),CanvasScheduler=require("./newCore/CanvasScheduler.js"),index$1=require("./core/pointCloud/index.js"),matrix=require("./core/pointCloud/matrix.js"),annotation$1=require("./core/pointCloud/annotation.js");function _interopNamespaceDefaultOnly(e){return Object.freeze({__proto__:null,default:e})}var keyCode__namespace=_interopNamespaceDefaultOnly(keyCode);const CommonToolUtils=EnhanceCommonToolUtils.default,toolUtils=EnhanceCommonToolUtils.default;exports.RectOperation=rectOperation.RectOperation,exports.TagOperation=tagOperation,exports.PointOperation=pointOperation,exports.LineToolOperation=LineToolOperation.default,exports.TextToolOperation=TextToolOperation,exports.PolygonOperation=polygonOperation,exports.MeasureOperation=measureOperation,exports.BasicToolOperation=basicToolOperation.BasicToolOperation,exports.ViewOperation=ViewOperation,exports.ScribbleTool=ScribbleTool,exports.PointCloud2dOperation=pointCloud2dOperation,exports.cAnnotation=annotation,exports.cAnnotationTask=annotationTask,exports.cKeyCode=keyCode__namespace,exports.cStyle=style,exports.CLIENT_TOOL_HEAD_TYPE=tool.CLIENT_TOOL_HEAD_TYPE,exports.CLIENT_TOOL_NAME=tool.CLIENT_TOOL_NAME,exports.DEFAULT_FONT=tool.DEFAULT_FONT,exports.DEFAULT_TEXT_MAX_WIDTH=tool.DEFAULT_TEXT_MAX_WIDTH,Object.defineProperty(exports,"EAnnotationMode",{enumerable:!0,get:function(){return tool.EAnnotationMode}}),Object.defineProperty(exports,"EAuditStatus",{enumerable:!0,get:function(){return tool.EAuditStatus}}),Object.defineProperty(exports,"ECheckModel",{enumerable:!0,get:function(){return tool.ECheckModel}}),Object.defineProperty(exports,"EDependPattern",{enumerable:!0,get:function(){return tool.EDependPattern}}),Object.defineProperty(exports,"EDragTarget",{enumerable:!0,get:function(){return tool.EDragTarget}}),Object.defineProperty(exports,"EDrawPointPattern",{enumerable:!0,get:function(){return tool.EDrawPointPattern}}),Object.defineProperty(exports,"EFilterToolOperation",{enumerable:!0,get:function(){return tool.EFilterToolOperation}}),Object.defineProperty(exports,"ELineColor",{enumerable:!0,get:function(){return tool.ELineColor}}),Object.defineProperty(exports,"ELineTypes",{enumerable:!0,get:function(){return tool.ELineTypes}}),Object.defineProperty(exports,"EOperationMode",{enumerable:!0,get:function(){return tool.EOperationMode}}),Object.defineProperty(exports,"EPageOperator",{enumerable:!0,get:function(){return tool.EPageOperator}}),Object.defineProperty(exports,"EPointCloudName",{enumerable:!0,get:function(){return tool.EPointCloudName}}),Object.defineProperty(exports,"EPolygonPattern",{enumerable:!0,get:function(){return tool.EPolygonPattern}}),Object.defineProperty(exports,"ERectPattern",{enumerable:!0,get:function(){return tool.ERectPattern}}),Object.defineProperty(exports,"EScribblePattern",{enumerable:!0,get:function(){return tool.EScribblePattern}}),Object.defineProperty(exports,"ESelectedType",{enumerable:!0,get:function(){return tool.ESelectedType}}),Object.defineProperty(exports,"ETextType",{enumerable:!0,get:function(){return tool.ETextType}}),Object.defineProperty(exports,"EThumbnailOption",{enumerable:!0,get:function(){return tool.EThumbnailOption}}),Object.defineProperty(exports,"EToolName",{enumerable:!0,get:function(){return tool.EToolName}}),Object.defineProperty(exports,"EToolType",{enumerable:!0,get:function(){return tool.EToolType}}),Object.defineProperty(exports,"EVideoToolName",{enumerable:!0,get:function(){return tool.EVideoToolName}}),exports.OPERATION_LIST=tool.OPERATION_LIST,exports.SEGMENT_NUMBER=tool.SEGMENT_NUMBER,exports.TEXT_ATTRIBUTE_LINE_HEIGHT=tool.TEXT_ATTRIBUTE_LINE_HEIGHT,exports.TEXT_ATTRIBUTE_MAX_LENGTH=tool.TEXT_ATTRIBUTE_MAX_LENGTH,exports.TEXT_TYPE=tool.TEXT_TYPE,exports.TOOL_NAME=tool.TOOL_NAME,exports.TOOL_NAME_EN=tool.TOOL_NAME_EN,exports.cTool=tool,exports.edgeAdsorptionScope=tool.edgeAdsorptionScope,exports.editStepWidth=tool.editStepWidth,exports.TagUtils=TagUtils,exports.uuid=uuid,exports.MarkerUtils=MarkerUtils,exports.RectUtils=RectUtils,exports.AxisUtils=AxisUtils.default,exports.DrawUtils=DrawUtils,exports.ImgUtils=ImgUtils,exports.MathUtils=MathUtils.default,exports.AttributeUtils=AttributeUtils.default,exports.ActionsHistory=ActionsHistory,exports.DblClickEventListener=DblClickEventListener,exports.AnnotationEngine=index,exports.UnitUtils=UnitUtils,exports.StyleUtils=StyleUtils,exports.CanvasScheduler=CanvasScheduler.CanvasScheduler,exports.PointCloud=index$1.PointCloud,exports.createThreeMatrix4=matrix.createThreeMatrix4,exports.getCuboidFromPointCloudBox=matrix.getCuboidFromPointCloudBox,exports.lidar2image=matrix.lidar2image,exports.pointCloudLidar2image=matrix.pointCloudLidar2image,exports.rotatePoint=matrix.rotatePoint,exports.transferKitti2Matrix=matrix.transferKitti2Matrix,exports.PointCloudAnnotation=annotation$1.PointCloudAnnotation,exports.CommonToolUtils=CommonToolUtils,exports.toolUtils=toolUtils;
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
* @createDate 2022-07-18
|
|
4
4
|
* @author Ron <ron.f.luo@gmail.com>
|
|
5
5
|
*/
|
|
6
|
-
import { IPointCloudBox, IPointCloudConfig } from '@labelbee/lb-utils';
|
|
6
|
+
import { IPointCloudBox, IPointCloudSphere, IPointCloudConfig, ILine } from '@labelbee/lb-utils';
|
|
7
7
|
import { EToolName, THybridToolName } from '@/constant/tool';
|
|
8
8
|
import { CanvasScheduler } from '@/newCore';
|
|
9
9
|
import { IPolygonData } from '@/types/tool/polygon';
|
|
10
10
|
import { PointCloud } from '.';
|
|
11
11
|
import PointCloud2dOperation, { IPointCloud2dOperationProps } from '../toolOperation/pointCloud2dOperation';
|
|
12
|
+
import { IPointOperationProps } from '../toolOperation/pointOperation';
|
|
12
13
|
import { ToolScheduler } from '../scheduler';
|
|
13
14
|
interface IPointCloudAnnotationOperation {
|
|
14
15
|
updateData: (pcdPath: string, result: string) => void;
|
|
@@ -17,7 +18,7 @@ interface IPointCloudAnnotationProps {
|
|
|
17
18
|
container: HTMLElement;
|
|
18
19
|
size: ISize;
|
|
19
20
|
pcdPath?: string;
|
|
20
|
-
|
|
21
|
+
extraProps?: IPointCloud2dOperationProps | IPointOperationProps;
|
|
21
22
|
config: IPointCloudConfig;
|
|
22
23
|
checkMode?: boolean;
|
|
23
24
|
toolName: THybridToolName;
|
|
@@ -29,7 +30,7 @@ export declare class PointCloudAnnotation implements IPointCloudAnnotationOperat
|
|
|
29
30
|
toolScheduler: ToolScheduler;
|
|
30
31
|
toolInstance: any;
|
|
31
32
|
config: IPointCloudConfig;
|
|
32
|
-
constructor({ size, container, pcdPath,
|
|
33
|
+
constructor({ size, container, pcdPath, extraProps, config, checkMode, toolName }: IPointCloudAnnotationProps);
|
|
33
34
|
updateConfig(config: IPointCloudConfig): void;
|
|
34
35
|
/**
|
|
35
36
|
* Get default boundary by size.
|
|
@@ -50,7 +51,11 @@ export declare class PointCloudAnnotation implements IPointCloudAnnotationOperat
|
|
|
50
51
|
*/
|
|
51
52
|
initSize(size: ISize): void;
|
|
52
53
|
addPolygonListOnTopView(result: string): void;
|
|
54
|
+
updateLineList: (lineList: ILine[]) => void;
|
|
55
|
+
addLineListOnTopView(result: string): void;
|
|
56
|
+
addPointListOnTopView(result: string): void;
|
|
53
57
|
updatePolygonList: (pointCloudDataList: IPointCloudBox[], extraList?: IPolygonData[]) => void;
|
|
58
|
+
updatePointList: (sphereList: IPointCloudSphere[]) => void;
|
|
54
59
|
/**
|
|
55
60
|
* Init or Update PointCloud Data
|
|
56
61
|
* @param pcdPath
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @author Ron <ron.f.luo@gmail.com>
|
|
5
5
|
*/
|
|
6
6
|
import * as THREE from 'three';
|
|
7
|
-
import { TMatrix4Tuple, EPerspectiveView, IVolume, IPointCloudBox, I3DSpaceCoord, IPointCloudConfig } from '@labelbee/lb-utils';
|
|
7
|
+
import { TMatrix4Tuple, EPerspectiveView, IVolume, IPointCloudBox, IPointCloudSphere, I3DSpaceCoord, IPointCloudConfig } from '@labelbee/lb-utils';
|
|
8
8
|
import { OrthographicCamera, PerspectiveCamera, Shader } from 'three';
|
|
9
9
|
import { IPolygonPoint } from '@/types/tool/polygon';
|
|
10
10
|
import { PCDLoader } from './PCDLoader';
|
|
@@ -87,6 +87,13 @@ export declare class PointCloud {
|
|
|
87
87
|
getAllAttributeColor(boxes: IPointCloudBox[]): {
|
|
88
88
|
[k: string]: any;
|
|
89
89
|
};
|
|
90
|
+
/**
|
|
91
|
+
* add new sphere just like adding new box
|
|
92
|
+
* @param sphereParams
|
|
93
|
+
*/
|
|
94
|
+
addSphereToSense: (sphereParams: IPointCloudSphere, color?: string) => void;
|
|
95
|
+
generateSphere: (sphereParams: IPointCloudSphere) => void;
|
|
96
|
+
generateSpheres: (spheres: IPointCloudSphere[]) => void;
|
|
90
97
|
AddBoxToSense: (boxParams: IPointCloudBox, color?: number) => void;
|
|
91
98
|
generateBoxes(boxes: IPointCloudBox[]): void;
|
|
92
99
|
/**
|
|
@@ -111,9 +118,13 @@ export declare class PointCloud {
|
|
|
111
118
|
* @param customCameraVector Provide a custom way.
|
|
112
119
|
*/
|
|
113
120
|
updateCameraByBox(boxParams: IPointCloudBox, perspectiveView: EPerspectiveView, customCameraVector?: I3DSpaceCoord): THREE.Vector3;
|
|
121
|
+
updateCameraBySphere(sphereParams: IPointCloudSphere, perspectiveView: EPerspectiveView): THREE.Vector3;
|
|
114
122
|
updateOrthoCamera(boxParams: IPointCloudBox, perspectiveView: EPerspectiveView): {
|
|
115
123
|
cameraPositionVector: THREE.Vector3;
|
|
116
124
|
};
|
|
125
|
+
updateOrthoCameraBySphere(sphereParams: IPointCloudSphere, perspectiveView: EPerspectiveView): {
|
|
126
|
+
cameraPositionVector: THREE.Vector3;
|
|
127
|
+
};
|
|
117
128
|
/**
|
|
118
129
|
* Initialize the camera to the initial position
|
|
119
130
|
*/
|
|
@@ -188,8 +199,8 @@ export declare class PointCloud {
|
|
|
188
199
|
* 2. Filter out points 10cm above the road surface.
|
|
189
200
|
* 3. Filter out the first 0.5% of noise points in other directions
|
|
190
201
|
*/
|
|
191
|
-
filterNoise(
|
|
192
|
-
getFittedCoordinates(polygon: IPolygonPoint[], innerPointList: ICoordinate[]): import("@labelbee/lb-utils
|
|
202
|
+
filterNoise(innerPointList: I3DSpaceCoord[]): I3DSpaceCoord[];
|
|
203
|
+
getFittedCoordinates(polygon: IPolygonPoint[], innerPointList: ICoordinate[]): import("@labelbee/lb-utils").ICoordinate[];
|
|
193
204
|
getSensesPointZAxisInPolygon(polygon: IPolygonPoint[], zScope?: [number, number], intelligentFit?: boolean): {
|
|
194
205
|
maxZ: number;
|
|
195
206
|
minZ: number;
|
|
@@ -252,6 +263,14 @@ export declare class PointCloud {
|
|
|
252
263
|
polygon2d: THREE.Vector3[];
|
|
253
264
|
zoom: number;
|
|
254
265
|
};
|
|
266
|
+
getSphereSidePoint2DCoordinate(sphereParams: IPointCloudSphere): {
|
|
267
|
+
point2d: THREE.Vector3;
|
|
268
|
+
zoom: number;
|
|
269
|
+
};
|
|
270
|
+
getSphereBackPoint2DCoordinate(sphereParams: IPointCloudSphere): {
|
|
271
|
+
point2d: THREE.Vector3;
|
|
272
|
+
zoom: number;
|
|
273
|
+
};
|
|
255
274
|
boxParams2ViewPolygon(boxParams: IPointCloudBox, perspectiveView: EPerspectiveView): {
|
|
256
275
|
x: number;
|
|
257
276
|
y: number;
|
|
@@ -275,6 +294,17 @@ export declare class PointCloud {
|
|
|
275
294
|
polygon2d: THREE.Vector3[];
|
|
276
295
|
zoom: number;
|
|
277
296
|
};
|
|
297
|
+
getSpherePoint2DCoordinate(sphereParams: IPointCloudSphere): {
|
|
298
|
+
point2d: THREE.Vector3;
|
|
299
|
+
zoom: number;
|
|
300
|
+
};
|
|
301
|
+
getSphereTopPoint2DCoordinate(sphereParams: IPointCloudSphere): {
|
|
302
|
+
point2d: {
|
|
303
|
+
x: number;
|
|
304
|
+
y: number;
|
|
305
|
+
};
|
|
306
|
+
zoom: number;
|
|
307
|
+
};
|
|
278
308
|
getBoxTopPolygon2DCoordinate(boxParams: IPointCloudBox): {
|
|
279
309
|
polygon2d: {
|
|
280
310
|
x: number;
|
|
@@ -325,7 +355,7 @@ export declare class PointCloud {
|
|
|
325
355
|
[k: string]: string;
|
|
326
356
|
} | undefined;
|
|
327
357
|
count?: number | undefined;
|
|
328
|
-
newPointList?: import("@labelbee/lb-utils
|
|
358
|
+
newPointList?: import("@labelbee/lb-utils").ICoordinate[] | undefined;
|
|
329
359
|
};
|
|
330
360
|
} | undefined;
|
|
331
361
|
/**
|
|
@@ -44,7 +44,7 @@ export declare function getCuboidFromPointCloudBox(boxParams: IPointCloudBox): {
|
|
|
44
44
|
[k: string]: string;
|
|
45
45
|
} | undefined;
|
|
46
46
|
count?: number | undefined;
|
|
47
|
-
newPointList?: import("@labelbee/lb-utils
|
|
47
|
+
newPointList?: import("@labelbee/lb-utils").ICoordinate[] | undefined;
|
|
48
48
|
width: number;
|
|
49
49
|
height: number;
|
|
50
50
|
depth: number;
|
|
@@ -67,10 +67,21 @@ export declare class ToolScheduler implements IToolSchedulerOperation {
|
|
|
67
67
|
*/
|
|
68
68
|
getFirstToolOperation(): RectOperation | PolygonOperation | SegmentByRect;
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
70
|
+
* Switch to canvas by given toolName
|
|
71
71
|
* TODO: change operationList to operationMap
|
|
72
72
|
*/
|
|
73
73
|
switchToCanvas(toolName: EToolName): RectOperation | PolygonOperation | undefined;
|
|
74
|
+
/**
|
|
75
|
+
*
|
|
76
|
+
* @param toolName
|
|
77
|
+
* @param result
|
|
78
|
+
* Update result by give toolName
|
|
79
|
+
* All the operation instances are maintained in toolOperationList,
|
|
80
|
+
* there is no more specific instance like pointCloud2dOperation you can reach,
|
|
81
|
+
* so if you need to update result in specific operation instance, you can try this.
|
|
82
|
+
*/
|
|
83
|
+
updateDataByToolName(toolName: EToolName, result: any): void;
|
|
84
|
+
clearStatusAndResult(): void;
|
|
74
85
|
destroyAllLayer(): void;
|
|
75
86
|
init(): void;
|
|
76
87
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* @date 2022-06-02
|
|
5
5
|
*/
|
|
6
6
|
import { BasicToolOperation, IBasicToolOperationProps } from './basicToolOperation';
|
|
7
|
+
import TextAttributeClass from './textAttributeClass';
|
|
7
8
|
declare enum EStatus {
|
|
8
9
|
Create = 0,
|
|
9
10
|
/** 正在激活 */
|
|
@@ -32,6 +33,7 @@ declare class LineToolOperation extends BasicToolOperation {
|
|
|
32
33
|
* @param e 鼠标事件
|
|
33
34
|
*/
|
|
34
35
|
drawActivatedLine: (coord?: ICoordinate, e?: MouseEvent, hideTempAxis?: boolean) => void;
|
|
36
|
+
_textAttributInstance?: TextAttributeClass;
|
|
35
37
|
/** 线条是否被选中 */
|
|
36
38
|
get isLineSelected(): "" | ILinePoint[] | undefined;
|
|
37
39
|
/** 选中点线条的点 */
|
|
@@ -42,6 +44,8 @@ declare class LineToolOperation extends BasicToolOperation {
|
|
|
42
44
|
*/
|
|
43
45
|
drawHoverPoint: (coord: ICoordinate) => void;
|
|
44
46
|
selectedID?: string;
|
|
47
|
+
updatedLine: ILine;
|
|
48
|
+
toolName: string;
|
|
45
49
|
private lineList;
|
|
46
50
|
private activeLine?;
|
|
47
51
|
private status;
|
|
@@ -62,6 +66,7 @@ declare class LineToolOperation extends BasicToolOperation {
|
|
|
62
66
|
private textEditingID?;
|
|
63
67
|
private isLineValid;
|
|
64
68
|
private lineDragging;
|
|
69
|
+
private selectedIDs;
|
|
65
70
|
constructor(props: ILineOperationProps);
|
|
66
71
|
/** 创建状态 */
|
|
67
72
|
get isCreate(): boolean;
|
|
@@ -146,6 +151,12 @@ declare class LineToolOperation extends BasicToolOperation {
|
|
|
146
151
|
* 对存在绘制对象,绘制热区
|
|
147
152
|
*/
|
|
148
153
|
renderActiveArea(): void;
|
|
154
|
+
/**
|
|
155
|
+
* Update selectedIDs and rerender
|
|
156
|
+
* @param selectedIDs
|
|
157
|
+
*/
|
|
158
|
+
setSelectedIDs(selectedIDs: string[]): void;
|
|
159
|
+
setSelectedID(newID?: string): void;
|
|
149
160
|
/**
|
|
150
161
|
* 添加点
|
|
151
162
|
* @param coord 坐标
|
|
@@ -2,6 +2,7 @@ import { ECuboidDirection } from '@/constant/annotation';
|
|
|
2
2
|
import type { ICuboid, ICuboidConfig, IDrawingCuboid } from '@/types/tool/cuboid';
|
|
3
3
|
import { BasicToolOperation } from './basicToolOperation';
|
|
4
4
|
import type { IBasicToolOperationProps } from './basicToolOperation';
|
|
5
|
+
import { ITextAttributeFuc } from './textAttributeClass';
|
|
5
6
|
type ICuboidOperationProps = IBasicToolOperationProps;
|
|
6
7
|
/**
|
|
7
8
|
* Just use for the drawing.
|
|
@@ -11,7 +12,7 @@ declare enum EDrawingStatus {
|
|
|
11
12
|
FirstPoint = 2,
|
|
12
13
|
Cuboid = 3
|
|
13
14
|
}
|
|
14
|
-
declare class CuboidOperation extends BasicToolOperation {
|
|
15
|
+
declare class CuboidOperation extends BasicToolOperation implements ITextAttributeFuc {
|
|
15
16
|
private toggleButtonInstance?;
|
|
16
17
|
drawingCuboid?: IDrawingCuboid;
|
|
17
18
|
/**
|
|
@@ -26,6 +27,7 @@ declare class CuboidOperation extends BasicToolOperation {
|
|
|
26
27
|
private dragInfo?;
|
|
27
28
|
private highlightInfo?;
|
|
28
29
|
private _textAttributeInstance?;
|
|
30
|
+
get selectedText(): string;
|
|
29
31
|
constructor(props: ICuboidOperationProps);
|
|
30
32
|
destroy(): void;
|
|
31
33
|
/**
|
|
@@ -60,10 +62,11 @@ declare class CuboidOperation extends BasicToolOperation {
|
|
|
60
62
|
hoverCuboid?: undefined;
|
|
61
63
|
};
|
|
62
64
|
updateSelectedCuboid(newCuboid: ICuboid): void;
|
|
63
|
-
|
|
65
|
+
getStylesToRender(attribute: string, valid: boolean): {
|
|
64
66
|
strokeColor: any;
|
|
65
67
|
toolColor: any;
|
|
66
68
|
fillColor: any;
|
|
69
|
+
lineWidth: any;
|
|
67
70
|
};
|
|
68
71
|
/**
|
|
69
72
|
* Get Selected Data.
|
|
@@ -122,8 +125,24 @@ declare class CuboidOperation extends BasicToolOperation {
|
|
|
122
125
|
*/
|
|
123
126
|
closeNewDrawingFrontPlane(): void;
|
|
124
127
|
closeAndCreateNewCuboid(): void;
|
|
128
|
+
deleteSelectedID(): void;
|
|
125
129
|
clearDrawingStatus(): void;
|
|
130
|
+
clearActiveStatus(): void;
|
|
126
131
|
rightMouseUp(e: MouseEvent): void;
|
|
132
|
+
/**
|
|
133
|
+
* Render the highlight components
|
|
134
|
+
*
|
|
135
|
+
* Situation:
|
|
136
|
+
* 1. hover
|
|
137
|
+
* 2. selected.
|
|
138
|
+
*
|
|
139
|
+
* Components:
|
|
140
|
+
* 1. 6 Points
|
|
141
|
+
* 2. 5 Lines.
|
|
142
|
+
*
|
|
143
|
+
* @param cuboid
|
|
144
|
+
*/
|
|
145
|
+
renderHighlightCuboidCom(cuboid: ICuboid | IDrawingCuboid): void;
|
|
127
146
|
/**
|
|
128
147
|
* TODO - Need to optimize.
|
|
129
148
|
* @param cuboid
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { BasicToolOperation, IBasicToolOperationProps } from './basicToolOperation';
|
|
2
2
|
export interface IPointOperationProps extends IBasicToolOperationProps {
|
|
3
3
|
style: any;
|
|
4
|
+
forbidAddNew?: boolean;
|
|
5
|
+
forbidDelete?: boolean;
|
|
4
6
|
}
|
|
5
7
|
declare class PointOperation extends BasicToolOperation {
|
|
6
8
|
config: IPointToolConfig;
|
|
@@ -12,6 +14,8 @@ declare class PointOperation extends BasicToolOperation {
|
|
|
12
14
|
dragStartCoord: ICoordinate;
|
|
13
15
|
originPointList: IPointUnit[];
|
|
14
16
|
};
|
|
17
|
+
forbidAddNew?: boolean;
|
|
18
|
+
forbidDelete?: boolean;
|
|
15
19
|
private _textAttributInstance?;
|
|
16
20
|
constructor(props: IPointOperationProps);
|
|
17
21
|
get dataList(): IPointUnit[];
|
|
@@ -43,7 +47,7 @@ declare class PointOperation extends BasicToolOperation {
|
|
|
43
47
|
clearResult(): void;
|
|
44
48
|
setDefaultAttribute(defaultAttribute?: string): void;
|
|
45
49
|
/**
|
|
46
|
-
* 外层
|
|
50
|
+
* 外层 sidebar 调用
|
|
47
51
|
* @param v
|
|
48
52
|
* @returns
|
|
49
53
|
*/
|
|
@@ -75,6 +79,7 @@ declare class PointOperation extends BasicToolOperation {
|
|
|
75
79
|
createPoint(e: MouseEvent): void;
|
|
76
80
|
isInPoint(pos: ICoordinate, point: ICoordinate, zoom?: number): boolean;
|
|
77
81
|
getHoverId(): string | undefined;
|
|
82
|
+
get selectedPoint(): IPointUnit | undefined;
|
|
78
83
|
rightMouseUp(): void;
|
|
79
84
|
onTabKeyDown(e: KeyboardEvent): void;
|
|
80
85
|
/**
|
|
@@ -53,4 +53,13 @@ export default class TextAttributeClass {
|
|
|
53
53
|
*/
|
|
54
54
|
changeSelected(): void;
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* TextAttribute injection requires content changes.
|
|
58
|
+
*
|
|
59
|
+
* Custom Changes.
|
|
60
|
+
* 1. Need to init textAttribute when creating data.
|
|
61
|
+
*/
|
|
62
|
+
export interface ITextAttributeFuc extends IBaseInfo {
|
|
63
|
+
selectedText: string;
|
|
64
|
+
}
|
|
56
65
|
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -28,9 +28,10 @@ import ActionsHistory from './utils/ActionsHistory';
|
|
|
28
28
|
import DblClickEventListener from './utils/tool/DblClickEventListener';
|
|
29
29
|
import AnnotationEngine from './core';
|
|
30
30
|
import UnitUtils from './utils/tool/UnitUtils';
|
|
31
|
+
import StyleUtils from './utils/tool/StyleUtils';
|
|
31
32
|
declare const CommonToolUtils: typeof EnhanceCommonToolUtils;
|
|
32
33
|
declare const toolUtils: typeof EnhanceCommonToolUtils;
|
|
33
|
-
export { RectOperation, TagOperation, PointOperation, LineToolOperation, PolygonOperation, TextToolOperation, BasicToolOperation, MeasureOperation, ViewOperation, PointCloud2dOperation, cAnnotation, cAnnotationTask, cKeyCode, cStyle, cTool, toolUtils, DblClickEventListener, CommonToolUtils, uuid, MarkerUtils, RectUtils, AxisUtils, TagUtils, DrawUtils, ImgUtils, MathUtils, AttributeUtils, AnnotationEngine, ScribbleTool, UnitUtils, ActionsHistory, };
|
|
34
|
+
export { RectOperation, TagOperation, PointOperation, LineToolOperation, PolygonOperation, TextToolOperation, BasicToolOperation, MeasureOperation, ViewOperation, PointCloud2dOperation, cAnnotation, cAnnotationTask, cKeyCode, cStyle, cTool, toolUtils, DblClickEventListener, CommonToolUtils, uuid, MarkerUtils, RectUtils, AxisUtils, TagUtils, DrawUtils, ImgUtils, MathUtils, AttributeUtils, AnnotationEngine, ScribbleTool, UnitUtils, StyleUtils, ActionsHistory, };
|
|
34
35
|
export * from './newCore';
|
|
35
36
|
export * from './constant/tool';
|
|
36
37
|
export * from './core/pointCloud';
|
|
@@ -102,6 +102,7 @@ export declare function getCuboidShowingSideLine({ frontPoints, backPoints, }: {
|
|
|
102
102
|
};
|
|
103
103
|
};
|
|
104
104
|
/**
|
|
105
|
+
* Get the intersections from frontPoints & backPoints.
|
|
105
106
|
*
|
|
106
107
|
* @param param0
|
|
107
108
|
* @returns
|
|
@@ -184,7 +185,6 @@ export declare function getHighlightPoints(cuboid: ICuboid): {
|
|
|
184
185
|
/**
|
|
185
186
|
* Get the range of Cuboid in 2D.
|
|
186
187
|
*
|
|
187
|
-
*
|
|
188
188
|
* @param param0
|
|
189
189
|
* @returns
|
|
190
190
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ICuboid, IDrawingCuboid } from '@/types/tool/cuboid';
|
|
1
|
+
import type { ICuboid, ICuboidConfig, IDrawingCuboid } from '@/types/tool/cuboid';
|
|
2
2
|
import { ELineTypes } from '../../constant/tool';
|
|
3
3
|
import { IPolygonPoint } from '../../types/tool/polygon';
|
|
4
4
|
export interface IDrawTextConfig {
|
|
@@ -175,4 +175,22 @@ export default class DrawUtils {
|
|
|
175
175
|
fillColor: string;
|
|
176
176
|
thickness: number;
|
|
177
177
|
}>): void;
|
|
178
|
+
/**
|
|
179
|
+
* Draw Cuboid and Text in header & bottom.
|
|
180
|
+
* @param canvas
|
|
181
|
+
* @param cuboid
|
|
182
|
+
* @param options
|
|
183
|
+
* @param dataConfig
|
|
184
|
+
*/
|
|
185
|
+
static drawCuboidWithText(canvas: HTMLCanvasElement, cuboid: ICuboid | IDrawingCuboid, options: {
|
|
186
|
+
strokeColor: string;
|
|
187
|
+
fillColor?: string;
|
|
188
|
+
thickness?: number;
|
|
189
|
+
}, dataConfig: {
|
|
190
|
+
config: ICuboidConfig;
|
|
191
|
+
hiddenText?: boolean;
|
|
192
|
+
selectedID?: string;
|
|
193
|
+
headerText?: string;
|
|
194
|
+
bottomText?: string;
|
|
195
|
+
}): void;
|
|
178
196
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tool=require("../../constant/tool.js"),MathUtils=require("../MathUtils.js"),PolygonUtils=require("./PolygonUtils.js"),LineToolUtils=require("./LineToolUtils.js"),CuboidUtils=require("./CuboidUtils.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(h,t,e)=>t in h?__defProp(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,__spreadValues=(h,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(h,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(h,e,t[e]);return h},__spreadProps=(h,t)=>__defProps(h,__getOwnPropDescs(t));class AxisUtils{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 __spreadProps(__spreadValues({},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 __spreadProps(__spreadValues({},t),{x:t.x*e+i.x,y:t.y*e+i.y})}static changePointListByZoom(t,e,i={x:0,y:0}){return 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=AxisUtils.changePointByZoom(o,e,i);return __spreadProps(__spreadValues({},s),{[n]:r})},{})}static changeCuboidByZoom(t,e,i={x:0,y:0}){return __spreadProps(__spreadValues({},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=CuboidUtils.getHighlightPoints(e),{scope:n=5}=i;for(let r=0;r<s.length;r++){const g=s[r];if(this.getIsInScope(t,g.point,n))return!0}const o=CuboidUtils.getHighlightLines(e);for(let r=0;r<o.length;r++){const g=o[r],{length:y}=MathUtils.default.getFootOfPerpendicular(t,g.p1,g.p2,!0);if(y<n)return!0}return!!PolygonUtils.isInPolygon(t,CuboidUtils.getCuboidHoverRange(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=CuboidUtils.getHighlightPoints(e),{scope:n=5,zoom:o=1}=i;for(let a=0;a<s.length;a++){const l=s[a];if(this.getIsInScope(t,l.point,n))return[{type:"point",points:[this.changePointByZoom(s[a].point,o)],originCuboid:e,positions:l.positions}]}let r=n;const g=CuboidUtils.getHighlightLines(e);let y;for(let a=0;a<g.length;a++){const l=g[a],{length:p}=MathUtils.default.getFootOfPerpendicular(t,l.p1,l.p2,!0);p<r&&(r=p,y=[{type:"line",points:this.changePointListByZoom([l.p1,l.p2],o),originCuboid:e,positions:l.positions}])}if(y)return y}static getIsInScope(t,e,i){return Math.abs(t.x-e.x)<i&&Math.abs(t.y-e.y)<i}}class CoordinateUtils{constructor(t){this.currentPos=t.currentPos,this.zoom=t.zoom,this.basicImgInfo=t.basicImgInfo,this.dependToolName=""}get isDependPolygon(){return this.dependToolName===tool.EToolName.Polygon}get isDependRect(){return this.dependToolName===tool.EToolName.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:MathUtils.default.withinRange(t.x,[i,i+n]),y:MathUtils.default.withinRange(t.y,[s,s+o])}}getPolygonPointList(t,e){return t===tool.ELineTypes.Curve?PolygonUtils.createSmoothCurvePointsFromPointList(e):e}getIntersection(t,e,i){const s=this.getRenderCoord(e),n=this.getRenderCoord(t),o={pointA:s,pointB:n};return LineToolUtils.default.calcOptimalIntersection(i,o,s,LineToolUtils.POINT_RADIUS,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(PolygonUtils.isInPolygon(t,r))return t;const y=r.concat(r[0]).map(l=>this.getRenderCoord(l)),a=this.getIntersection(t,e,y);return a?this.getAbsCoord(a==null?void 0:a.point):t}coordInsideImage(t){return this.coordInsideRect(t,__spreadProps(__spreadValues({},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 MathUtils.default.isInRange(t.x,o)&&MathUtils.default.isInRange(t.y,r)}return MathUtils.default.isInRange(t.x,[0,this.basicImgInfo.width])&&MathUtils.default.isInRange(t.y,[0,this.basicImgInfo.height])}isInBasicPolygon(t){var e,i;return PolygonUtils.isInPolygon(t,((e=this.basicResult)==null?void 0:e.pointList)||[],(i=this.dependToolConfig)==null?void 0:i.lineType)}}exports.CoordinateUtils=CoordinateUtils,exports.default=AxisUtils;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tool=require("../../constant/tool.js"),MathUtils=require("../MathUtils.js"),PolygonUtils=require("./PolygonUtils.js"),LineToolUtils=require("./LineToolUtils.js"),CuboidUtils=require("./CuboidUtils.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(h,t,e)=>t in h?__defProp(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,__spreadValues=(h,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(h,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(h,e,t[e]);return h},__spreadProps=(h,t)=>__defProps(h,__getOwnPropDescs(t));class AxisUtils{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 __spreadProps(__spreadValues({},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 __spreadProps(__spreadValues({},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=AxisUtils.changePointByZoom(o,e,i);return __spreadProps(__spreadValues({},s),{[n]:r})},{})}static changeCuboidByZoom(t,e,i={x:0,y:0}){return __spreadProps(__spreadValues({},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=CuboidUtils.getHighlightPoints(e),{scope:n=5}=i;for(let r=0;r<s.length;r++){const g=s[r];if(this.getIsInScope(t,g.point,n))return!0}const o=CuboidUtils.getHighlightLines(e);for(let r=0;r<o.length;r++){const g=o[r],{length:y}=MathUtils.default.getFootOfPerpendicular(t,g.p1,g.p2,!0);if(y<n)return!0}return!!PolygonUtils.isInPolygon(t,CuboidUtils.getCuboidHoverRange(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=CuboidUtils.getHighlightPoints(e),{scope:n=5,zoom:o=1}=i;for(let a=0;a<s.length;a++){const l=s[a];if(this.getIsInScope(t,l.point,n))return[{type:"point",points:[this.changePointByZoom(s[a].point,o)],originCuboid:e,positions:l.positions}]}let r=n;const g=CuboidUtils.getHighlightLines(e);let y;for(let a=0;a<g.length;a++){const l=g[a],{length:p}=MathUtils.default.getFootOfPerpendicular(t,l.p1,l.p2,!0);p<r&&(r=p,y=[{type:"line",points:this.changePointListByZoom([l.p1,l.p2],o),originCuboid:e,positions:l.positions}])}if(y)return y}static getIsInScope(t,e,i){return Math.abs(t.x-e.x)<i&&Math.abs(t.y-e.y)<i}}class CoordinateUtils{constructor(t){this.currentPos=t.currentPos,this.zoom=t.zoom,this.basicImgInfo=t.basicImgInfo,this.dependToolName=""}get isDependPolygon(){return this.dependToolName===tool.EToolName.Polygon}get isDependRect(){return this.dependToolName===tool.EToolName.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:MathUtils.default.withinRange(t.x,[i,i+n]),y:MathUtils.default.withinRange(t.y,[s,s+o])}}getPolygonPointList(t,e){return t===tool.ELineTypes.Curve?PolygonUtils.createSmoothCurvePointsFromPointList(e):e}getIntersection(t,e,i){const s=this.getRenderCoord(e),n=this.getRenderCoord(t),o={pointA:s,pointB:n};return LineToolUtils.default.calcOptimalIntersection(i,o,s,LineToolUtils.POINT_RADIUS,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(PolygonUtils.isInPolygon(t,r))return t;const y=r.concat(r[0]).map(l=>this.getRenderCoord(l)),a=this.getIntersection(t,e,y);return a?this.getAbsCoord(a==null?void 0:a.point):t}coordInsideImage(t){return this.coordInsideRect(t,__spreadProps(__spreadValues({},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 MathUtils.default.isInRange(t.x,o)&&MathUtils.default.isInRange(t.y,r)}return MathUtils.default.isInRange(t.x,[0,this.basicImgInfo.width])&&MathUtils.default.isInRange(t.y,[0,this.basicImgInfo.height])}isInBasicPolygon(t){var e,i;return PolygonUtils.isInPolygon(t,((e=this.basicResult)==null?void 0:e.pointList)||[],(i=this.dependToolConfig)==null?void 0:i.lineType)}}exports.CoordinateUtils=CoordinateUtils,exports.default=AxisUtils;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _=require("lodash"),annotation=require("../../constant/annotation.js"),AxisUtils=require("./AxisUtils.js"),VectorUtils=require("../VectorUtils.js"),LineToolUtils=require("./LineToolUtils.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(i,t,n)=>t in i?__defProp(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,__spreadValues=(i,t)=>{for(var n in t||(t={}))__hasOwnProp.call(t,n)&&__defNormalProp(i,n,t[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(t))__propIsEnum.call(t,n)&&__defNormalProp(i,n,t[n]);return i},__spreadProps=(i,t)=>__defProps(i,__getOwnPropDescs(t));function getPlanePointsBasicInfo({tr:i,tl:t,br:n}){return{width:Math.abs(i.x-t.x),height:Math.abs(n.y-i.y),centerPoints:{x:(t.x+n.x)/2,y:(t.y+n.y)/2}}}function getCuboidBasicInfo({frontPoints:i,backPoints:t}){const{width:n,height:o,centerPoints:s}=getPlanePointsBasicInfo(i),{width:e,height:r,centerPoints:l}=getPlanePointsBasicInfo(t);return{frontCenter:s,backCenter:l,frontWidth:n,frontHeight:o,backWidth:e,backHeight:r,isLeftSide:l.x<s.x}}function getPlainPointsByDiagonalPoints(i,t){return{tl:{x:Math.min(i.x,t.x),y:Math.min(i.y,t.y)},tr:{x:Math.max(i.x,t.x),y:Math.min(i.y,t.y)},bl:{x:Math.min(i.x,t.x),y:Math.max(i.y,t.y)},br:{x:Math.max(i.x,t.x),y:Math.max(i.y,t.y)}}}function getMaxExternalQuadrilateral(i){const t=Object.values(i).reduce((e,r)=>r.x<e?r.x:e,Number.MAX_SAFE_INTEGER),n=Object.values(i).reduce((e,r)=>r.x>e?r.x:e,0),o=Object.values(i).reduce((e,r)=>r.y<e?r.y:e,Number.MAX_SAFE_INTEGER),s=Object.values(i).reduce((e,r)=>r.y>e?r.y:e,0);return{tl:{x:t,y:o},tr:{x:n,y:o},bl:{x:t,y:s},br:{x:n,y:s}}}function judgeCuboidLineIsRowOrColumn(i){const[t,n]=i;if(annotation.CUBOID_ROW[t.position]===n.position)return annotation.ECuboidLineDirection.Row;if(annotation.CUBOID_COLUMN[t.position]===n.position)return annotation.ECuboidLineDirection.Column}function getPointsByBottomRightPoint({coord:i,points:t}){const{width:n,height:o}=getPlanePointsBasicInfo(t);return{br:i,tr:{x:i.x,y:i.y-o},tl:{x:i.x-n,y:i.y-o},bl:{x:i.x-n,y:i.y}}}function getPointsByBottomLeftPoint({coord:i,points:t}){const{width:n,height:o}=getPlanePointsBasicInfo(t);return{bl:i,tr:{x:i.x+n,y:i.y-o},tl:{x:i.x,y:i.y-o},br:{x:i.x+n,y:i.y}}}function getCuboidShowingSideLine({frontPoints:i,backPoints:t}){const{isLeftSide:n}=getCuboidBasicInfo({frontPoints:i,backPoints:t});return n?{top:{p1:i.tl,p2:t.tl},bottom:{p1:i.bl,p2:t.bl}}:{top:{p1:i.tr,p2:t.tr},bottom:{p1:i.br,p2:t.br}}}function getPointsByIntersection({frontPoints:i,backPoints:t}){const{isLeftSide:n}=getCuboidBasicInfo({frontPoints:i,backPoints:t});let o=__spreadValues({},t);const s=getCuboidShowingSideLine({frontPoints:i,backPoints:t}),e=LineToolUtils.default.lineIntersection({pointA:s.bottom.p1,pointB:s.bottom.p2},{pointA:s.top.p1,pointB:s.top.p2});if(n){const r=LineToolUtils.default.lineIntersection({pointA:t.bl,pointB:t.br},{pointA:i.br,pointB:e});r&&(o=__spreadProps(__spreadValues({},t),{br:r,tr:{x:r.x,y:t.tl.y}}))}else{const r=LineToolUtils.default.lineIntersection({pointA:t.bl,pointB:t.br},{pointA:i.bl,pointB:e});r&&(o=__spreadProps(__spreadValues({},t),{bl:r,tl:{x:r.x,y:t.tr.y}}))}return{backPoints:o}}function getBackPointsByFrontPoints({frontPoints:i,backPoints:t}){const{isLeftSide:n,frontHeight:o,backHeight:s}=getCuboidBasicInfo({frontPoints:i,backPoints:t});let e=__spreadValues({},t);return n?e=getPointsByBottomLeftPoint({coord:t.bl,points:i}):e=getPointsByBottomRightPoint({coord:t.br,points:i}),o>s&&(e=getPointsByIntersection({frontPoints:i,backPoints:t}).backPoints),{frontPoints:i,backPoints:e}}function getFrontPointsByBackPoints({frontPoints:i,backPoints:t}){const{isLeftSide:n,frontHeight:o,backHeight:s,frontWidth:e,backWidth:r}=getCuboidBasicInfo({frontPoints:i,backPoints:t});let l=__spreadValues({},i),u=t;return n||r>e?l=getPointsByBottomLeftPoint({coord:i.bl,points:t}):l=getPointsByBottomRightPoint({coord:i.br,points:t}),o>s&&(l.tl.y=i.tl.y,l.tr.y=i.tr.y,u=getPointsByIntersection({backPoints:t,frontPoints:i}).backPoints),e>=r&&Object.keys(l).forEach(a=>{l[a].x=i[a].x}),{frontPoints:l,backPoints:u}}function getCuboidAllSideLine({frontPoints:i,backPoints:t}){return[{p1:i.bl,p2:t.bl},{p1:i.tl,p2:t.tl},{p1:i.tr,p2:t.tr},{p1:i.br,p2:t.br}]}function getHighlightLines(i){const{frontPoints:t,backPoints:n}=i,{isLeftSide:o}=getCuboidBasicInfo(i),s=[{p1:t.tl,p2:t.tr,positions:[{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.TL},{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.TR}]},{p1:t.tr,p2:t.br,plain:annotation.ECuboidPlain.Front,positions:[{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.TR},{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.BR}]},{p1:t.br,p2:t.bl,plain:annotation.ECuboidPlain.Front,positions:[{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.BR},{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.BL}]},{p1:t.bl,p2:t.tl,plain:annotation.ECuboidPlain.Front,positions:[{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.BL},{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.TL}]}];return o?[...s,{p1:n.tl,p2:n.bl,positions:[{plain:annotation.ECuboidPlain.Back,position:annotation.ECuboidPosition.TL},{plain:annotation.ECuboidPlain.Back,position:annotation.ECuboidPosition.BL}]}]:[...s,{p1:n.tr,p2:n.br,positions:[{plain:annotation.ECuboidPlain.Back,position:annotation.ECuboidPosition.TR},{plain:annotation.ECuboidPlain.Back,position:annotation.ECuboidPosition.BR}]}]}function getHighlightPoints(i){const{backPoints:t}=i,{isLeftSide:n}=getCuboidBasicInfo(i),o=Object.entries(i.frontPoints).map(([s,e])=>({positions:[{plain:annotation.ECuboidPlain.Front,position:s}],point:e}));return n?[{point:t.tl,positions:[{position:annotation.ECuboidPosition.TL,plain:annotation.ECuboidPlain.Back}]},{point:t.bl,positions:[{position:annotation.ECuboidPosition.BL,plain:annotation.ECuboidPlain.Back}]},...o]:[{point:t.tr,positions:[{position:annotation.ECuboidPosition.TR,plain:annotation.ECuboidPlain.Back}]},{point:t.br,positions:[{position:annotation.ECuboidPosition.BR,plain:annotation.ECuboidPlain.Back}]},...o]}function getCuboidHoverRange(i){const{frontPoints:t,backPoints:n}=i,{backCenter:o,frontCenter:s,frontHeight:e,frontWidth:r,backHeight:l,backWidth:u,isLeftSide:a}=getCuboidBasicInfo(i),c=Math.abs(r-u),p=Math.abs(e-l),x=Math.abs(s.x-o.x),f=Math.abs(s.y-o.y),d=x>c,b=f>p;return d||b?b&&!d?[t.tl,n.tl,n.tr,t.tr,t.br,t.bl]:d&&!b?a?[t.tl,t.tr,t.br,t.bl,n.bl,n.tl]:[t.tl,t.tr,n.tr,n.br,t.br,t.bl]:d&&b?a?[n.tl,n.tr,t.tr,t.br,t.bl,n.bl]:[t.tl,n.tl,n.tr,n.br,t.br,t.bl]:[]:[t.tl,t.tr,t.br,t.bl]}function getNewPointsAfterOffset({offset:i,frontPoints:t,backPoints:n,positions:o}){let s=_.cloneDeep(t),e=_.cloneDeep(n);if((o==null?void 0:o.length)===2){const r=o.every(b=>b.plain===annotation.ECuboidPlain.Front),l=!r,u=judgeCuboidLineIsRowOrColumn([o[0],o[1]]),a=u===annotation.ECuboidLineDirection.Row,c=u===annotation.ECuboidLineDirection.Column;let p=i;a&&(p={x:0,y:i.y}),c&&(p={y:0,x:i.x}),r&&(o==null||o.forEach(({position:b})=>{const g=s,P=g[b];g[b]={x:P.x+p.x,y:P.y+p.y}}),s=getMaxExternalQuadrilateral(s),e=getMaxExternalQuadrilateral(e)),l&&Object.keys(e).forEach(b=>{e[b]={x:e[b].x+p.x,y:e[b].y+p.y}});const x=r?getBackPointsByFrontPoints:getFrontPointsByBackPoints,{frontPoints:f,backPoints:d}=x({frontPoints:s,backPoints:e});s=f,e=d}return{frontPoints:s,backPoints:e}}function getCuboidDragMove({offset:i,cuboid:t,dragTarget:n,positions:o}){const{frontPoints:s,backPoints:e}=t;switch(n){case annotation.EDragTarget.Cuboid:{const r=Object.entries(s).reduce((u,[a,c])=>__spreadProps(__spreadValues({},u),{[a]:{x:c.x+i.x,y:c.y+i.y}}),{}),l=Object.entries(e).reduce((u,[a,c])=>__spreadProps(__spreadValues({},u),{[a]:{x:c.x+i.x,y:c.y+i.y}}),{});return __spreadProps(__spreadValues({},t),{frontPoints:r,backPoints:l})}case annotation.EDragTarget.Line:{const{frontPoints:r,backPoints:l}=getNewPointsAfterOffset({offset:i,frontPoints:s,backPoints:e,positions:o});return __spreadProps(__spreadValues({},t),{frontPoints:r,backPoints:l})}case annotation.EDragTarget.Point:{if(!(o==null?void 0:o[0]))return;const r=o[0],l=r.plain===annotation.ECuboidPlain.Front,u=l?s:e;let a=u[r.position];const c=u[annotation.DIAGONAL_POINT[r.position]];if(!a||!c)return;a=VectorUtils.add(a,i);const p=getPlainPointsByDiagonalPoints(a,c),x=l?getBackPointsByFrontPoints:getFrontPointsByBackPoints;let f={frontPoints:s,backPoints:p};l&&(f={frontPoints:p,backPoints:e});const{frontPoints:d,backPoints:b}=x(f);return __spreadProps(__spreadValues({},t),{frontPoints:d,backPoints:b})}default:{console.error("No DragTarget");break}}}function getPointListsByDirection({direction:i,frontPoints:t,backPoints:n}){if(i&&t&&n){let o=t;switch(i){case annotation.ECuboidDirection.Back:o=n;break;case annotation.ECuboidDirection.Left:o={bl:n.bl,br:t.bl,tl:n.tl,tr:t.tl};break;case annotation.ECuboidDirection.Right:o={bl:n.br,br:t.br,tl:n.tr,tr:t.tr};break;case annotation.ECuboidDirection.Top:o={bl:n.tl,br:t.tl,tl:n.tr,tr:t.tr};break;default:o=t;break}return AxisUtils.default.transformPlain2PointList(o)}}function getToggleDirectionButtonOffset({cuboid:i,currentPos:t,zoom:n}){const{frontPoints:o}=i,s={width:40,height:74},e={x:(o.bl.x+o.tl.x)/2,y:(o.bl.y+o.tl.y)/2},r=s.width+10,l=s.height/2,u={x:e.x,y:e.y},a=AxisUtils.default.getOffsetCoordinate(u,t,n);return{left:a.x-r,top:a.y-l}}function getCuboidTextAttributeOffset({cuboid:i,currentPos:t,zoom:n,leftOffset:o=16,topOffset:s=2}){const{frontPoints:e}=i,r={x:e.bl.x,y:e.bl.y},l=AxisUtils.default.getOffsetCoordinate(r,t,n);return{left:l.x+o,top:l.y+s}}function isCuboidWithInLimits({cuboid:i,config:t}){const{minHeight:n,minWidth:o}=t,{width:s,height:e}=getPlanePointsBasicInfo(i.frontPoints);return s>=o&&e>=n}exports.getBackPointsByFrontPoints=getBackPointsByFrontPoints,exports.getCuboidAllSideLine=getCuboidAllSideLine,exports.getCuboidBasicInfo=getCuboidBasicInfo,exports.getCuboidDragMove=getCuboidDragMove,exports.getCuboidHoverRange=getCuboidHoverRange,exports.getCuboidShowingSideLine=getCuboidShowingSideLine,exports.getCuboidTextAttributeOffset=getCuboidTextAttributeOffset,exports.getFrontPointsByBackPoints=getFrontPointsByBackPoints,exports.getHighlightLines=getHighlightLines,exports.getHighlightPoints=getHighlightPoints,exports.getMaxExternalQuadrilateral=getMaxExternalQuadrilateral,exports.getNewPointsAfterOffset=getNewPointsAfterOffset,exports.getPlainPointsByDiagonalPoints=getPlainPointsByDiagonalPoints,exports.getPlanePointsBasicInfo=getPlanePointsBasicInfo,exports.getPointListsByDirection=getPointListsByDirection,exports.getPointsByBottomLeftPoint=getPointsByBottomLeftPoint,exports.getPointsByBottomRightPoint=getPointsByBottomRightPoint,exports.getPointsByIntersection=getPointsByIntersection,exports.getToggleDirectionButtonOffset=getToggleDirectionButtonOffset,exports.isCuboidWithInLimits=isCuboidWithInLimits,exports.judgeCuboidLineIsRowOrColumn=judgeCuboidLineIsRowOrColumn;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _=require("lodash"),annotation=require("../../constant/annotation.js"),AxisUtils=require("./AxisUtils.js"),VectorUtils=require("../VectorUtils.js"),LineToolUtils=require("./LineToolUtils.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(i,t,n)=>t in i?__defProp(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,__spreadValues=(i,t)=>{for(var n in t||(t={}))__hasOwnProp.call(t,n)&&__defNormalProp(i,n,t[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(t))__propIsEnum.call(t,n)&&__defNormalProp(i,n,t[n]);return i},__spreadProps=(i,t)=>__defProps(i,__getOwnPropDescs(t));function getPlanePointsBasicInfo({tr:i,tl:t,br:n}){return{width:Math.abs(i.x-t.x),height:Math.abs(n.y-i.y),centerPoints:{x:(t.x+n.x)/2,y:(t.y+n.y)/2}}}function getCuboidBasicInfo({frontPoints:i,backPoints:t}){const{width:n,height:o,centerPoints:r}=getPlanePointsBasicInfo(i),{width:e,height:s,centerPoints:l}=getPlanePointsBasicInfo(t);return{frontCenter:r,backCenter:l,frontWidth:n,frontHeight:o,backWidth:e,backHeight:s,isLeftSide:l.x<r.x}}function getPlainPointsByDiagonalPoints(i,t){return{tl:{x:Math.min(i.x,t.x),y:Math.min(i.y,t.y)},tr:{x:Math.max(i.x,t.x),y:Math.min(i.y,t.y)},bl:{x:Math.min(i.x,t.x),y:Math.max(i.y,t.y)},br:{x:Math.max(i.x,t.x),y:Math.max(i.y,t.y)}}}function getMaxExternalQuadrilateral(i){const t=Object.values(i).reduce((e,s)=>s.x<e?s.x:e,Number.MAX_SAFE_INTEGER),n=Object.values(i).reduce((e,s)=>s.x>e?s.x:e,0),o=Object.values(i).reduce((e,s)=>s.y<e?s.y:e,Number.MAX_SAFE_INTEGER),r=Object.values(i).reduce((e,s)=>s.y>e?s.y:e,0);return{tl:{x:t,y:o},tr:{x:n,y:o},bl:{x:t,y:r},br:{x:n,y:r}}}function judgeCuboidLineIsRowOrColumn(i){const[t,n]=i;if(annotation.CUBOID_ROW[t.position]===n.position)return annotation.ECuboidLineDirection.Row;if(annotation.CUBOID_COLUMN[t.position]===n.position)return annotation.ECuboidLineDirection.Column}function getPointsByBottomRightPoint({coord:i,points:t}){const{width:n,height:o}=getPlanePointsBasicInfo(t);return{br:i,tr:{x:i.x,y:i.y-o},tl:{x:i.x-n,y:i.y-o},bl:{x:i.x-n,y:i.y}}}function getPointsByBottomLeftPoint({coord:i,points:t}){const{width:n,height:o}=getPlanePointsBasicInfo(t);return{bl:i,tr:{x:i.x+n,y:i.y-o},tl:{x:i.x,y:i.y-o},br:{x:i.x+n,y:i.y}}}function getCuboidShowingSideLine({frontPoints:i,backPoints:t}){const{isLeftSide:n}=getCuboidBasicInfo({frontPoints:i,backPoints:t});return n?{top:{p1:i.tl,p2:t.tl},bottom:{p1:i.bl,p2:t.bl}}:{top:{p1:i.tr,p2:t.tr},bottom:{p1:i.br,p2:t.br}}}function getPointsByIntersection({frontPoints:i,backPoints:t}){const{isLeftSide:n}=getCuboidBasicInfo({frontPoints:i,backPoints:t});let o=__spreadValues({},t);const r=getCuboidShowingSideLine({frontPoints:i,backPoints:t}),e=LineToolUtils.default.lineIntersection({pointA:r.bottom.p1,pointB:r.bottom.p2},{pointA:r.top.p1,pointB:r.top.p2});if(n){const s=LineToolUtils.default.lineIntersection({pointA:t.bl,pointB:t.br},{pointA:i.br,pointB:e});s&&(o=__spreadProps(__spreadValues({},t),{br:s,tr:{x:s.x,y:t.tl.y}}))}else{const s=LineToolUtils.default.lineIntersection({pointA:t.bl,pointB:t.br},{pointA:i.bl,pointB:e});s&&(o=__spreadProps(__spreadValues({},t),{bl:s,tl:{x:s.x,y:t.tr.y}}))}return{backPoints:o}}function getBackPointsByFrontPoints({frontPoints:i,backPoints:t}){const{isLeftSide:n,frontHeight:o,backHeight:r}=getCuboidBasicInfo({frontPoints:i,backPoints:t});let e=__spreadValues({},t);return n?e=getPointsByBottomLeftPoint({coord:t.bl,points:i}):e=getPointsByBottomRightPoint({coord:t.br,points:i}),o>r&&(e=getPointsByIntersection({frontPoints:i,backPoints:t}).backPoints),{frontPoints:i,backPoints:e}}function getFrontPointsByBackPoints({frontPoints:i,backPoints:t}){const{isLeftSide:n,frontHeight:o,backHeight:r,frontWidth:e,backWidth:s}=getCuboidBasicInfo({frontPoints:i,backPoints:t});let l=__spreadValues({},i),a=t;return n||s>e?l=getPointsByBottomLeftPoint({coord:i.bl,points:t}):l=getPointsByBottomRightPoint({coord:i.br,points:t}),o>r&&(l.tl.y=i.tl.y,l.tr.y=i.tr.y,a=getPointsByIntersection({backPoints:t,frontPoints:i}).backPoints),e>=s&&Object.keys(l).forEach(u=>{l[u].x=i[u].x}),{frontPoints:l,backPoints:a}}function getCuboidAllSideLine({frontPoints:i,backPoints:t}){return[{p1:i.bl,p2:t.bl},{p1:i.tl,p2:t.tl},{p1:i.tr,p2:t.tr},{p1:i.br,p2:t.br}]}function getHighlightLines(i){const{frontPoints:t,backPoints:n}=i,{isLeftSide:o}=getCuboidBasicInfo(i),r=[{p1:t.tl,p2:t.tr,positions:[{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.TL},{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.TR}]},{p1:t.tr,p2:t.br,plain:annotation.ECuboidPlain.Front,positions:[{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.TR},{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.BR}]},{p1:t.br,p2:t.bl,plain:annotation.ECuboidPlain.Front,positions:[{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.BR},{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.BL}]},{p1:t.bl,p2:t.tl,plain:annotation.ECuboidPlain.Front,positions:[{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.BL},{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.TL}]}];return o?[...r,{p1:n.tl,p2:n.bl,positions:[{plain:annotation.ECuboidPlain.Back,position:annotation.ECuboidPosition.TL},{plain:annotation.ECuboidPlain.Back,position:annotation.ECuboidPosition.BL}]}]:[...r,{p1:n.tr,p2:n.br,positions:[{plain:annotation.ECuboidPlain.Back,position:annotation.ECuboidPosition.TR},{plain:annotation.ECuboidPlain.Back,position:annotation.ECuboidPosition.BR}]}]}function getHighlightPoints(i){const{backPoints:t}=i,{isLeftSide:n}=getCuboidBasicInfo(i),o=Object.entries(i.frontPoints).map(([r,e])=>({positions:[{plain:annotation.ECuboidPlain.Front,position:r}],point:e}));return n?[{point:t.tl,positions:[{position:annotation.ECuboidPosition.TL,plain:annotation.ECuboidPlain.Back}]},{point:t.bl,positions:[{position:annotation.ECuboidPosition.BL,plain:annotation.ECuboidPlain.Back}]},...o]:[{point:t.tr,positions:[{position:annotation.ECuboidPosition.TR,plain:annotation.ECuboidPlain.Back}]},{point:t.br,positions:[{position:annotation.ECuboidPosition.BR,plain:annotation.ECuboidPlain.Back}]},...o]}function getCuboidHoverRange(i){const{frontPoints:t,backPoints:n}=i,{backCenter:o,frontCenter:r,frontHeight:e,frontWidth:s,backHeight:l,backWidth:a,isLeftSide:u}=getCuboidBasicInfo(i),p=Math.abs(s-a),c=Math.abs(e-l),d=Math.abs(r.x-o.x),x=Math.abs(r.y-o.y),f=d>p,b=x>c;return f||b?b&&!f?[t.tl,n.tl,n.tr,t.tr,t.br,t.bl]:f&&!b?u?[t.tl,t.tr,t.br,t.bl,n.bl,n.tl]:[t.tl,t.tr,n.tr,n.br,t.br,t.bl]:f&&b?u?[n.tl,n.tr,t.tr,t.br,t.bl,n.bl]:[t.tl,n.tl,n.tr,n.br,t.br,t.bl]:[]:[t.tl,t.tr,t.br,t.bl]}function getNewPointsAfterOffset({offset:i,frontPoints:t,backPoints:n,positions:o}){let r=_.cloneDeep(t),e=_.cloneDeep(n);if((o==null?void 0:o.length)===2){const s=o.every(b=>b.plain===annotation.ECuboidPlain.Front),l=!s,a=judgeCuboidLineIsRowOrColumn([o[0],o[1]]),u=a===annotation.ECuboidLineDirection.Row,p=a===annotation.ECuboidLineDirection.Column;let c=i;u&&(c={x:0,y:i.y}),p&&(c={y:0,x:i.x}),s&&(o==null||o.forEach(({position:b})=>{const g=r,y=g[b];g[b]={x:y.x+c.x,y:y.y+c.y}}),r=getMaxExternalQuadrilateral(r),e=getMaxExternalQuadrilateral(e)),l&&Object.keys(e).forEach(b=>{e[b]={x:e[b].x+c.x,y:e[b].y+c.y}});const d=s?getBackPointsByFrontPoints:getFrontPointsByBackPoints,{frontPoints:x,backPoints:f}=d({frontPoints:r,backPoints:e});r=x,e=f}return{frontPoints:r,backPoints:e}}function moveCuboidByCuboid({offset:i,cuboid:t}){const{frontPoints:n,backPoints:o}=t,r=Object.entries(n).reduce((s,[l,a])=>__spreadProps(__spreadValues({},s),{[l]:{x:a.x+i.x,y:a.y+i.y}}),{}),e=Object.entries(o).reduce((s,[l,a])=>__spreadProps(__spreadValues({},s),{[l]:{x:a.x+i.x,y:a.y+i.y}}),{});return{frontPoints:r,backPoints:e}}function moveCuboidByLine({offset:i,cuboid:t,positions:n}){const{frontPoints:o,backPoints:r}=t;return getNewPointsAfterOffset({offset:i,frontPoints:o,backPoints:r,positions:n})}function moveCuboidByPoints({offset:i,cuboid:t,positions:n}){if(!(n==null?void 0:n[0]))return;const{frontPoints:o,backPoints:r}=t,e=n[0],s=e.plain===annotation.ECuboidPlain.Front,l=s?o:r;let a=l[e.position];const u=l[annotation.DIAGONAL_POINT[e.position]];if(!a||!u)return;a=VectorUtils.add(a,i);const p=getPlainPointsByDiagonalPoints(a,u),c=s?getBackPointsByFrontPoints:getFrontPointsByBackPoints;let d={frontPoints:o,backPoints:p};return s&&(d={frontPoints:p,backPoints:r}),c(d)}function getCuboidDragMove({offset:i,cuboid:t,dragTarget:n,positions:o}){switch(n){case annotation.EDragTarget.Cuboid:{const r=moveCuboidByCuboid({offset:i,cuboid:t});return __spreadValues(__spreadValues({},t),r)}case annotation.EDragTarget.Line:{const r=moveCuboidByLine({offset:i,cuboid:t,positions:o});return __spreadValues(__spreadValues({},t),r)}case annotation.EDragTarget.Point:{const r=moveCuboidByPoints({cuboid:t,offset:i,positions:o});if(r)return __spreadValues(__spreadValues({},t),r);break}default:{console.error("No DragTarget");break}}}function getPointListsByDirection({direction:i,frontPoints:t,backPoints:n}){if(i&&t&&n){let o=t;switch(i){case annotation.ECuboidDirection.Back:o=n;break;case annotation.ECuboidDirection.Left:o={bl:n.bl,br:t.bl,tl:n.tl,tr:t.tl};break;case annotation.ECuboidDirection.Right:o={bl:n.br,br:t.br,tl:n.tr,tr:t.tr};break;case annotation.ECuboidDirection.Top:o={bl:n.tl,br:t.tl,tl:n.tr,tr:t.tr};break;default:o=t;break}return AxisUtils.default.transformPlain2PointList(o)}}function getToggleDirectionButtonOffset({cuboid:i,currentPos:t,zoom:n}){const{frontPoints:o}=i,r={width:40,height:74},e={x:(o.bl.x+o.tl.x)/2,y:(o.bl.y+o.tl.y)/2},s=r.width+10,l=r.height/2,a={x:e.x,y:e.y},u=AxisUtils.default.getOffsetCoordinate(a,t,n);return{left:u.x-s,top:u.y-l}}function getCuboidTextAttributeOffset({cuboid:i,currentPos:t,zoom:n,leftOffset:o=16,topOffset:r=2}){const{frontPoints:e}=i,s={x:e.bl.x,y:e.bl.y},l=AxisUtils.default.getOffsetCoordinate(s,t,n);return{left:l.x+o,top:l.y+r}}function isCuboidWithInLimits({cuboid:i,config:t}){const{minHeight:n,minWidth:o}=t,{width:r,height:e}=getPlanePointsBasicInfo(i.frontPoints);return r>=o&&e>=n}exports.getBackPointsByFrontPoints=getBackPointsByFrontPoints,exports.getCuboidAllSideLine=getCuboidAllSideLine,exports.getCuboidBasicInfo=getCuboidBasicInfo,exports.getCuboidDragMove=getCuboidDragMove,exports.getCuboidHoverRange=getCuboidHoverRange,exports.getCuboidShowingSideLine=getCuboidShowingSideLine,exports.getCuboidTextAttributeOffset=getCuboidTextAttributeOffset,exports.getFrontPointsByBackPoints=getFrontPointsByBackPoints,exports.getHighlightLines=getHighlightLines,exports.getHighlightPoints=getHighlightPoints,exports.getMaxExternalQuadrilateral=getMaxExternalQuadrilateral,exports.getNewPointsAfterOffset=getNewPointsAfterOffset,exports.getPlainPointsByDiagonalPoints=getPlainPointsByDiagonalPoints,exports.getPlanePointsBasicInfo=getPlanePointsBasicInfo,exports.getPointListsByDirection=getPointListsByDirection,exports.getPointsByBottomLeftPoint=getPointsByBottomLeftPoint,exports.getPointsByBottomRightPoint=getPointsByBottomRightPoint,exports.getPointsByIntersection=getPointsByIntersection,exports.getToggleDirectionButtonOffset=getToggleDirectionButtonOffset,exports.isCuboidWithInLimits=isCuboidWithInLimits,exports.judgeCuboidLineIsRowOrColumn=judgeCuboidLineIsRowOrColumn;
|