1 line
2.6 KiB
JavaScript
1 line
2.6 KiB
JavaScript
import MxDbLeadComment from"../MxDbLeadComment";import MxDbCloudLine from"../MxDbCloudLine";import MxDbEntity from"../MxDbEntity";import MxType from"../MxType";import{addRegisterMxDbEntity}from"../../tools/registerMxDbEntity";import drawMxDbRectBoxLeadComment from"./draw";class MxDbRectBoxLeadComment extends MxDbEntity{constructor(){super(...arguments),this.point1=new THREE.Vector3,this.point2=new THREE.Vector3,this.point3=new THREE.Vector3,this.text="",this.textHeight=20,this.radius=16,this.textWidth=0,this.fixedSize=!1}getTypeName(){return"MxDbRectBoxLeadComment"}create(){return new MxDbRectBoxLeadComment}getCloudLine(){let t=new MxDbCloudLine;t.setRadius(this.radius);let e=this.point1.clone(),i=this.point2.clone();if(e.x>i.x){let t=e.x;e.x=i.x,i.x=t}if(e.y>i.y){let t=e.y;e.y=i.y,i.y=t}let o=new THREE.Vector3(e.x,i.y,e.z);o=t.addLine(e,o),i=new THREE.Vector3(i.x,o.y,i.z),i=t.addLine(o,i);let n=new THREE.Vector3(i.x,e.y,e.z);n=t.addLine(i,n);let d=e=t.addLine(n,e),s=e.distanceTo(this.point3);return s>o.distanceTo(this.point3)&&(d=o,s=o.distanceTo(this.point3)),s>i.distanceTo(this.point3)&&(d=i,s=i.distanceTo(this.point3)),s>n.distanceTo(this.point3)&&(d=n,s=n.distanceTo(this.point3)),{cloudLine:t,pt1:e,pt2:o,pt3:i,pt4:n,leadPt:d}}worldDraw(t){let e=this.getCloudLine();if(e.cloudLine.worldDraw(t),this.text.length>0){let i=e.leadPt,o=new MxDbLeadComment;o.point1=i,o.point2=this.point3,o.text=this.text,o.textHeight=this.textHeight,o.textWidth=this.textWidth,o.fixedSize=this.fixedSize,o.worldDraw(t)}}getGripPoints(){let t=[];return t.push(this.point1),t.push(this.point2),t.push(this.point3),t}moveGripPointsAt(t,e){return 0==t?this.point1.add(e):1==t?this.point2.add(e):2==t&&this.point3.add(e),!0}dwgIn(t){return this.onDwgIn(t),this.point1.copy(t.point1),this.point2.copy(t.point2),this.point3.copy(t.point3),this.text=t.text.substr(0),this.textHeight=t.textHeight,this.radius=t.radius,t.textWidth&&(this.textWidth=t.textWidth),this.fixedSize=t.fixedSize,!0}dwgOut(t){if(this.onDwgOut(t),t.point1=this.point1,t.point2=this.point2,t.point3=this.point3,t.textHeight=this.textHeight,t.text=this.text,t.radius=this.radius,t.textWidth=this.textWidth,t.fixedSize=this.fixedSize,t.type===MxType.MxCloneType.kSaveDwgClone){let e=this.getCloudLine(),i=e.cloudLine.reCalculateDrawGeometryPoint();t.cachePoint=i||[],t.leadPt=e.leadPt}return t}onViewChange(){return!!this.fixedSize&&(this.setNeedUpdateDisplay(!1),!0)}}MxDbRectBoxLeadComment.cmd="Mx_CheckDraw",MxDbRectBoxLeadComment.draw=drawMxDbRectBoxLeadComment,addRegisterMxDbEntity(MxDbRectBoxLeadComment);export default MxDbRectBoxLeadComment; |