import{addRegisterMxDbEntity}from"../../tools/registerMxDbEntity";import MxDbEntity from"../MxDbEntity";import MxThreeJS from"../MxThreeJS";import drawMxDbLeadComment from"./draw";class MxDbLeadComment extends MxDbEntity{constructor(){super(...arguments),this.point1=new THREE.Vector3,this.point2=new THREE.Vector3,this.text="",this.textHeight=20,this.textWidth=0,this.fixedSize=!1}getTypeName(){return"MxDbLeadComment"}create(){return new MxDbLeadComment}worldDraw(t){if(t.drawLine(this.point1,this.point2),this.text.length>0){const e=new THREE.Vector3;let i=this.textHeight,n=this.textWidth,o=t.getMxObject();this.fixedSize&&(i=o.screenCoordLong2Doc(i),n=o.screenCoordLong2Doc(n));let h=MxThreeJS.clacTextSpriteSize(this.text,i,n);e.x=this.point2.x+.5*h.textwidth,e.y=this.point2.y+.5*h.allTextHeight,t.drawText(this.text,i,0,e,n);const s=new THREE.Vector3;s.x=this.point2.x+h.textwidth,s.y=this.point2.y,t.drawLine(s,this.point2)}}getGripPoints(){let t=[];return t.push(this.point1),t.push(this.point2),t}moveGripPointsAt(t,e){return 0==t?this.point1.add(e):1==t&&this.point2.add(e),!0}dwgIn(t){return this.onDwgIn(t),this.point1.copy(t.point1),this.point2.copy(t.point2),this.text=t.text.substr(0),this.textHeight=t.textHeight,t.textWidth&&(this.textWidth=t.textWidth),this.fixedSize=t.fixedSize,!0}dwgOut(t){return this.onDwgOut(t),t.point1=this.point1,t.point2=this.point2,t.textHeight=this.textHeight,t.text=this.text,t.textWidth=this.textWidth,t.fixedSize=this.fixedSize,t}onViewChange(){return!!this.fixedSize&&(this.setNeedUpdateDisplay(!1),!0)}}MxDbLeadComment.cmd="Mx_Comment",MxDbLeadComment.draw=drawMxDbLeadComment,addRegisterMxDbEntity(MxDbLeadComment);export default MxDbLeadComment;