var EditCAD=function(){"use strict";var t=function(){this.version="v4.0",this.floors=[]};t.prototype.initFloor=function(t){this.floors[t]={},this.floors[t].points={},this.floors[t].walls={},this.floors[t].symbols={},this.floors[t].components={},this.floors[t].tags={},this.floors[t].furnitures={},this.floors[t].boundingBox={},this.floors[t].rooms=[],this.floors[t].panos=[]};var o=new t;window.floorplanData=o;var i={minPixDistance:10,minPixLen:3,minScreenDis:2,minAdsorbRec:3,furnitureWidth:32,minRealDis:.1,minAdsorb:.1,minAngle:15,maxAngle:165,defaultZoom:100,minSymbolLen:.2,maxSymbolLen:10,ratio:3,miniMap_Width:1200,miniMap_Height:1200},r=function(){};r.prototype.getFixed=function(t,e){return e||(e=5),parseFloat(t.toFixed(e))},r.prototype.getDistance=function(t,e){var o=t.x,i=t.y,n=e.x,r=e.y,s=Math.sqrt(Math.pow(o-n,2)+Math.pow(i-r,2));return this.getFixed(s)},r.prototype.createLine1=function(t,e){if(t.x==e.x&&t.y==e.y)return null;if(0==this.getFixed(Math.abs(t.x-e.x)))return{x:t.x};if(0==this.getFixed(Math.abs(t.y-e.y)))return{y:t.y};var o=(t.y-e.y)/(t.x-e.x),i=(t.x*e.y-e.x*t.y)/(t.x-e.x);return 0==this.getFixed(o)?{y:this.getFixed(i)}:{a:this.getFixed(o),b:this.getFixed(i)}},r.prototype.createLine2=function(t,e){if(e==Math.PI/2||e==1.5*Math.PI)return{x:t.x};var o=Math.tan(e),i=t.y-o*t.x;return 0!=o?{a:o,b:i}:{y:t.y}},r.prototype.createLine3=function(t,e){var o={};return void 0===t.a?void 0!==t.x?o.x=e.x:void 0!==t.y&&(o.y=e.y):(o.a=t.a,o.b=e.y-e.x*t.a),o},r.prototype.create2AngleLine=function(t,e,o){return{line1:this.createLine2(t,e-o/2),line2:this.createLine2(t,e+o/2)}},r.prototype.distanceForPoints=function(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))},r.prototype.getParallelLineForDistance=function(t,e){var o={},i={};if(t.hasOwnProperty("a")){o.a=t.a,o.b=t.b,i.a=t.a,i.b=t.b;var n=Math.atan(t.a),r=Math.abs(e/Math.cos(n)),s=t.b;o.b=s+r,i.b=s-r}else if(t.hasOwnProperty("x")){var l=t.x;o.x=l+e,i.x=l-e}else if(t.hasOwnProperty("y")){var a=t.y;o.y=a+e,i.y=a-e}return{line1:o,line2:i}},r.prototype.getEndpoint=function(t,e,o){var i=this.create2AngleLine(t,e,o),n=this.createLine2(t,e);n=this.getLineForPoint(n,t);var r=this.getParallelLineForDistance(n,15),s=this.getIntersectionPoint(i.line1,r.line1),l=this.getIntersectionPoint(i.line1,r.line2),a=this.getIntersectionPoint(i.line2,r.line1),h=this.getIntersectionPoint(i.line2,r.line2),c=this.Angle(t,s,{x:t.x+1,y:t.y}),u=this.Angle(t,l,{x:t.x+1,y:t.y}),d=this.Angle(t,a,{x:t.x+1,y:t.y}),y=this.Angle(t,h,{x:t.x+1,y:t.y});return e>Math.PI&&(e=2*Math.PI-e),Math.abs((c+d)/2-e)0},r.prototype.reverse=function(t){for(var e=[],o=t.length-1;o>-1;--o)e.push(t[o]);return e},r.prototype.getIntersectionPoint=function(t,e){if(this.isParallel(t,e))return null;if(void 0===t.a&&void 0!==e.a){if(t.x)return{x:t.x,y:e.a*t.x+e.b};if(t.y)return{x:(t.y-e.b)/e.a,y:t.y}}else if(void 0===e.a&&void 0!==t.a){if(e.x)return{x:e.x,y:t.a*e.x+t.b};if(e.y)return{x:(e.y-t.b)/t.a,y:e.y}}else if(void 0===e.a&&void 0===t.a)return t.hasOwnProperty("x")&&e.hasOwnProperty("y")?{x:t.x,y:e.y}:t.hasOwnProperty("y")&&e.hasOwnProperty("x")?{x:e.x,y:t.y}:null;return t.a==e.a?null:{x:(e.b-t.b)/(t.a-e.a),y:(t.a*e.b-e.a*t.b)/(t.a-e.a)}},r.prototype.getIntersectionPoint2=function(t,e,o,i){var n=(e.y-t.y)*(i.x-o.x)-(t.x-e.x)*(o.y-i.y);return 0==n?null:{x:((e.x-t.x)*(i.x-o.x)*(o.y-t.y)+(e.y-t.y)*(i.x-o.x)*t.x-(i.y-o.y)*(e.x-t.x)*o.x)/n,y:-((e.y-t.y)*(i.y-o.y)*(o.x-t.x)+(e.x-t.x)*(i.y-o.y)*t.y-(i.x-o.x)*(e.y-t.y)*o.y)/n}},r.prototype.getIntersectionPoint3=function(t,e,o,i){var n=this.getIntersectionPoint2(t,e,o,i);if(n){var r=n.x,s=n.y;return(r-t.x)*(r-e.x)<=.001&&(s-t.y)*(s-e.y)<=.001&&(r-o.x)*(r-i.x)<=.001&&(s-o.y)*(s-i.y)<=.001?{x:r,y:s}:null}return null},r.prototype.getIntersectionPoint4=function(t,e,o){var i=this.createLine1(t,e),n=this.getIntersectionPoint(i,o);return null==n?null:this.PointInSegment(n,t,e)?n:null},r.prototype.isParallel=function(t,e){return void 0===t.a&&void 0===e.a?!(!t.hasOwnProperty("x")||!e.hasOwnProperty("x"))||!(!t.hasOwnProperty("y")||!e.hasOwnProperty("y")):void 0!==t.a&&void 0!==e.a&&this.getFixed(t.a)==this.getFixed(e.a)},r.prototype.Angle=function(t,e,o){var i,n,r=0,s=e.x-t.x,l=e.y-t.y,a=o.x-t.x,h=o.y-t.y;return r=s*a+l*h,n=(s*s+l*l)*(a*a+h*h),(r/=Math.sqrt(n))>=1?0:r<=-1?Math.PI:180*(i=Math.acos(r))/Math.PI<180?i:2*Math.PI-i},r.prototype.getLineForPoint=function(t,e){var o={};return 0==t.a||void 0===t.a?t.hasOwnProperty("x")?o.y=e.y:t.hasOwnProperty("y")&&(o.x=e.x):(o.a=-1/t.a,o.b=e.y-e.x*o.a),o},r.prototype.getJoinLinePoint=function(t,e){var o=this.getVerticalLine(e,t);return this.getIntersectionPoint(e,o)},r.prototype.getDisForPoinLine=function(t,e){var o=this.getJoinLinePoint(t,e);return this.getDistance(t,o)},r.prototype.getVerticalLine=function(t,e){if(void 0===t.a)return t.hasOwnProperty("x")?{y:e.y}:t.hasOwnProperty("y")?{x:e.x}:null;if(0==t.a)return{x:e.x};var o={};return o.a=-1/t.a,this.createLine3(o,e)},r.prototype.isContainForSegment=function(t,e,o,n){n||(n=i.minAdsorb);var r=this.getDistance(e,t)+this.getDistance(o,t),s=this.getDistance(e,o);return Math.abs(r-s)i!=d>i&&o<(u-h)*(i-c)/(d-c)+h&&(n=!n)}return n},r.prototype.getDisForPoinSegment=function(t,e,o,i){var n=this.createLine1(e,o),r=this.getJoinLinePoint(t,n),s=this.getDistance(e,o),l=this.getDistance(r,e),a=this.getDistance(r,o);return this.getDistance(r,e)>s||this.getDistance(r,o)>s?l=0&&r*c+s*u<=0&&Math.abs(i*s-n*r)<=.001},r.prototype.clonePoint=function(t,e){t.x=e.x,t.y=e.y},r.prototype.equalPoint=function(t,e){return t.x==e.x&&t.y==e.y},r.prototype.crossTwoLines=function(t,e,o,n,r){void 0===r&&(r=i.minAdsorb);var s=this.getIntersectionPoint2(t,e,o,n);if(null!=s){if(this.getDistance(t,s)>r&&this.getDistance(e,s)>r&&this.getDistance(o,s)>r&&this.getDistance(n,s)>r)return this.getDistance(t,s)s.x&&(e=s.x),i>s.y&&(i=s.y),os.x)&&(e=s.x),(null==i||i>s.y)&&(i=s.y),(null==o||o0?null:s};var s=new r,l="Point",a="WallCorner",h="Wall",c="SingleDoor",u="DoubleDoor",d="SlideDoor",y="SingleWindow",x="BayWindow",p="FrenchWindow",g="Pass",f="Beam",m="Flue",v="Corridor",S="Line",P="Tag",I="TV",b="CombinationSofa",k="SingleSofa",T="TeaTable",F="Carpet",C="Plant",w="DiningTable",W="DoubleBed",D="SingleBed",L="Wardrobe",z="Dresser",M="BedsideCupboard",R="Pillow",O="GasStove",A="Cupboard",E="Bathtub",B="Closestool",Y="Washstand",N="Desk",X="BalconyChair",j="Elevator",_="all",U="start",J="end",V="select",H="LEFT",Z="RIGHT",G=function(){this.len=null};G.prototype.setId=function(t){null==t||void 0===t?(t=re.getCurrentId(),re.updateCurrentId(),this.vectorId=this.geoType+t):this.vectorId=t},G.prototype.setSymbolPosition=function(t,e){"start"==e?s.clonePoint(this.startPoint,t):"end"==e&&s.clonePoint(this.endPoint,t)},G.prototype.setSymbolParent=function(t){this.parent=t},G.prototype.setPointParent=function(t,e){null==this.parent&&(this.parent={}),this.parent[t]=e},G.prototype.setOpenSide=function(t){var e=[];e.push(this.startPoint),e.push(this.endPoint),e.push(t);var o=null;o=s.isClockwise(e)?H:Z,this.openSide=o},G.prototype.rotatePoint=function(t,e,o){o*=-1;var i=e.x,n=e.y,r=t.x,s=t.y;return{x:i+(r-i)*Math.cos(o*Math.PI/180)-(s-n)*Math.sin(o*Math.PI/180),y:n+(r-i)*Math.sin(o*Math.PI/180)+(s-n)*Math.cos(o*Math.PI/180)}};var $=function(t){function e(e,o,i,n){t.call(this),this.startPoint=e,this.endPoint=o,this.floor=n,this.openSide=null,this.parent=null,this.enter=null,this.points2d=[],this.position3d={},this.name="单开门",this.geoType=c,this.setId(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setPoints2d=function(){var t=s.createLine1(this.startPoint,this.endPoint),e=s.getDistance(this.startPoint,this.endPoint),o=s.getParallelLineForDistance(t,e),i=s.getVerticalLine(t,this.startPoint),n=s.getVerticalLine(t,this.endPoint),r=s.getIntersectionPoint(o.line1,i),l=s.getIntersectionPoint(o.line2,i),a=s.getIntersectionPoint(o.line1,n),h=s.getIntersectionPoint(o.line2,n);if(this.points2d=[],this.points2d.push(this.startPoint),this.points2d.push(this.endPoint),this.points2d.push(a),this.points2d.push(r),this.openSide==H){if(s.isClockwise(this.points2d))return;this.points2d=[],this.points2d.push(this.startPoint),this.points2d.push(this.endPoint),this.points2d.push(h),this.points2d.push(l)}else if(this.openSide==Z){if(!s.isClockwise(this.points2d))return;this.points2d=[],this.points2d.push(this.startPoint),this.points2d.push(this.endPoint),this.points2d.push(h),this.points2d.push(l)}},e.prototype.isContain=function(t){var e=s.getDistance(t,this.startPoint),o=s.getDistance(t,this.endPoint);if(en)return null;var r=s.Angle(this.points2d[0],t,this.points2d[1]),l=s.Angle(this.points2d[0],t,this.points2d[3]);return rthis.endPoint.x){var i=o.line1;o.line1=o.line2,o.line2=i}var n=s.getVerticalLine(t,this.startPoint),r=s.getVerticalLine(t,this.endPoint),l=o.line1,a=o.line2,h=s.getIntersectionPoint(o.line1,n),c=s.getIntersectionPoint(o.line2,r);this.points2d=[],this.points2d.push(this.startPoint),this.points2d.push(this.endPoint),this.points2d.push(h),s.isClockwise(this.points2d)?null==this.openSide||"LEFT"==this.openSide||(l=o.line2,a=o.line1,h=s.getIntersectionPoint(l,n),c=s.getIntersectionPoint(a,r)):null!=this.openSide&&"LEFT"!=this.openSide||(l=o.line2,a=o.line1,h=s.getIntersectionPoint(l,n),c=s.getIntersectionPoint(a,r));var u={x:(this.startPoint.x+this.endPoint.x)/2,y:(this.startPoint.y+this.endPoint.y)/2};this.points2d=[],this.points2d.push(this.startPoint);var d=4/ie.res,y=s.getVerticalLine(t,u),x=s.getParallelLineForDistance(y,d),p=s.getIntersectionPoint(l,x.line1),g=s.getIntersectionPoint(l,x.line2),f=s.getIntersectionPoint(a,x.line1),m=s.getIntersectionPoint(a,x.line2),v=s.getIntersectionPoint(t,x.line1),S=s.getIntersectionPoint(t,x.line2);s.getDistance(this.startPoint,v)s.getDisForPoinLine(this.startPoint,c.line2)?(t=c.line2,e=u.line2,o=c.line1,i=u.line1):(t=c.line1,e=u.line1,o=c.line2,i=u.line2);var d=s.getParallelLineForDistance(n,2/ie.res),y=s.getParallelLineForDistance(n,this.thickness-2/ie.res),x=s.getParallelLineForDistance(n,this.thickness),p=d.line1,g=d.line2,f=y.line2,m=x.line2,v=d.line2,S=d.line1,P=y.line1,I=x.line1,b=s.getIntersectionPoint(t,p),k=s.getIntersectionPoint(o,p),T=s.getIntersectionPoint(o,f),F=s.getIntersectionPoint(t,f),C=s.getIntersectionPoint(e,g),w=s.getIntersectionPoint(i,g),W=s.getIntersectionPoint(i,m),D=s.getIntersectionPoint(e,m),L=s.getIntersectionPoint(t,v),z=s.getIntersectionPoint(o,v),M=s.getIntersectionPoint(o,P),R=s.getIntersectionPoint(t,P),O=s.getIntersectionPoint(e,S),A=s.getIntersectionPoint(i,S),E=s.getIntersectionPoint(i,I),B=s.getIntersectionPoint(e,I);this.points2d=[],this.points2d.push(b),this.points2d.push(k),this.points2d.push(T),this.points2d.push(F),"LEFT"==this.openSide?s.isClockwise(this.points2d)?(this.points2d.push(C),this.points2d.push(w),this.points2d.push(W),this.points2d.push(D)):(this.points2d=[],this.points2d.push(L),this.points2d.push(z),this.points2d.push(M),this.points2d.push(R),this.points2d.push(O),this.points2d.push(A),this.points2d.push(E),this.points2d.push(B)):"RIGHT"==this.openSide&&(s.isClockwise(this.points2d)?(this.points2d=[],this.points2d.push(L),this.points2d.push(z),this.points2d.push(M),this.points2d.push(R),this.points2d.push(O),this.points2d.push(A),this.points2d.push(E),this.points2d.push(B)):(this.points2d.push(C),this.points2d.push(w),this.points2d.push(W),this.points2d.push(D)))},e.prototype.isContain=function(t){var e=s.getDistance(t,this.startPoint),o=s.getDistance(t,this.endPoint);if(e2){for(var u in s)if(u!=e){var d=this.AngleForWall2(e,u);null==h&&1==d.clockwise?((i=d).wallId=u,h=d.angle,(r=d).wallId=u,c=d.angle):h>d.angle&&1==d.clockwise?((i=d).wallId=u,h=d.angle):cd.angle&&0==d.clockwise?((o=d).wallId=u,l=d.angle):a1)this.moveTo(o,i);else{re.deleteWall(e);var r=re.getPoint(o);s.clonePoint(r,n)}return i},rt.prototype.changeSymbolsWallToWall=function(t,e,o){for(var i=re.getWall(t,o),n=re.getWall(e,o),r=0;ri.maxAngle/180*Math.PI)return this.mergeWall(Object.keys(e.parent)[0],Object.keys(e.parent)[1]);return null},rt.prototype.getLinkPointId=function(t,e){var o=re.getWall(t),i=re.getWall(e);return o.start==i.start||o.start==i.end?o.start:o.end==i.start||o.end==i.end?o.end:o.start==i.start?null:void 0},rt.prototype.moveTo=function(t,e){var o=this.getWallId(t,e),n=re.getPoint(t),r=re.getPoint(e);n.x,r.x,n.y,r.y;var l=n.parent,a=r.parent;for(var h in l)if(h!=o){var c=re.getWall(h).getOtherPointId(t),u=re.getPoint(c);for(var d in a)if(d!=o){var y=re.getWall(d).getOtherPointId(e),x=re.getPoint(y),p=s.Angle(r,u,x);if(Math.abs(p)2)for(var o in e.parent)re.deleteWall(o);else if(2==Object.keys(e.parent).length){this.AngleForWall(Object.keys(e.parent)[0],Object.keys(e.parent)[1])>i.maxAngle/180*Math.PI?this.mergeWall(Object.keys(e.parent)[0],Object.keys(e.parent)[1]):(re.deleteWall(Object.keys(e.parent)[0]),re.deleteWall(Object.keys(e.parent)[0]))}};var st=new rt,lt=function(t){function e(e,o){t.call(this),this.center=e,this.angle=0,this.points2d=[],this.sideWidth=.65,this.sideThickness=.65,this.name="柱子",this.geoType=f,this.setId(o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isContain=function(t){return s.isPointInPoly(t,this.points2d)},e.prototype.setPoints2d=function(){this.points2d=[];var t=this.center.x-this.sideWidth/2,e=this.center.y-this.sideThickness/2,o=this.center.x+this.sideWidth/2,i=this.center.y+this.sideThickness/2,n=this.rotatePoint({x:t,y:i},this.center,this.angle),r=this.rotatePoint({x:o,y:i},this.center,this.angle),s=this.rotatePoint({x:o,y:e},this.center,this.angle),l=this.rotatePoint({x:t,y:e},this.center,this.angle);this.points2d.push(n),this.points2d.push(r),this.points2d.push(s),this.points2d.push(l)},e}(G),at=function(t){function e(e,o){t.call(this),this.center=e,this.angle=0,this.points2d=[],this.sideWidth=.65,this.sideThickness=.65,this.name="烟道",this.geoType=m,this.setId(o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isContain=function(t){var e=[];return e.push(this.points2d[0]),e.push(this.points2d[1]),e.push(this.points2d[2]),e.push(this.points2d[3]),s.isPointInPoly(t,e)},e.prototype.setPoints2d=function(){this.points2d=[];var t=this.center.x-this.sideWidth/2,e=this.center.y-this.sideThickness/2,o=this.center.x+this.sideWidth/2,i=this.center.y+this.sideThickness/2,n=this.rotatePoint({x:t,y:i},this.center,this.angle),r=this.rotatePoint({x:o,y:i},this.center,this.angle),s=this.rotatePoint({x:o,y:e},this.center,this.angle),l=this.rotatePoint({x:t,y:e},this.center,this.angle);this.points2d.push(n),this.points2d.push(r),this.points2d.push(s),this.points2d.push(l),t=this.center.x-(this.sideWidth-.1)/2,e=this.center.y-(this.sideThickness-.1)/2,o=this.center.x+(this.sideWidth-.1)/2,i=this.center.y+(this.sideThickness-.1)/2;var a=this.rotatePoint({x:t,y:i},this.center,this.angle),h=this.rotatePoint({x:o,y:i},this.center,this.angle),c=this.rotatePoint({x:o,y:e},this.center,this.angle),u=this.rotatePoint({x:t,y:e},this.center,this.angle),d={x:(this.center.x+h.x)/2,y:(this.center.y+h.y)/2};this.points2d.push(a),this.points2d.push(h),this.points2d.push(c),this.points2d.push(u),this.points2d.push(d)},e}(G),ht=function(t){function e(e,o){t.call(this),this.center=e,this.angle=0,this.points2d=[],this.sideWidth=.65,this.sideThickness=.65,this.name="楼道",this.geoType=v,this.setId(o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isContain=function(t){var e=[];return e.push(this.points2d[0]),e.push(this.points2d[1]),e.push(this.points2d[2]),e.push(this.points2d[3]),s.isPointInPoly(t,e)},e.prototype.setPoints2d=function(){this.points2d=[];var t=this.center.x-this.sideWidth/2,e=this.center.y-this.sideThickness/2,o=this.center.x+this.sideWidth/2,i=this.center.y+this.sideThickness/2,n=this.rotatePoint({x:t,y:i},this.center,this.angle),r=this.rotatePoint({x:o,y:i},this.center,this.angle),s=this.rotatePoint({x:o,y:e},this.center,this.angle),l=this.rotatePoint({x:t,y:e},this.center,this.angle);this.points2d.push(n),this.points2d.push(r),this.points2d.push(s),this.points2d.push(l);var a=this.center.x-2/ie.res,h=this.center.x+2/ie.res,c=3/ie.res,u=this.rotatePoint({x:a,y:i},this.center,this.angle),d=this.rotatePoint({x:a,y:e},this.center,this.angle);this.points2d.push(u),this.points2d.push(d);var y=this.rotatePoint({x:h,y:i},this.center,this.angle),x=this.rotatePoint({x:h,y:e},this.center,this.angle);this.points2d.push(y),this.points2d.push(x);for(var p=Math.floor(this.sideThickness*ie.res/3),g=0;g0?(s.clonePoint(i.startPoint,c.position1),s.clonePoint(i.endPoint,c.position2)):(s.clonePoint(i.endPoint,c.position1),s.clonePoint(i.startPoint,c.position2)),i.parent!=o&&ee.changeSymbolForBelong(e,o),i.setOpenSide(t),i.setPoints2d(),ee.setPosition3d(i))},qt.prototype.moveSymbolPoint=function(t,e,o){var n=ee.moveSymbolSinglePoint(t,e,o);if(null==n)return null;var r=re.getSymbol(e),l={x:(r.startPoint.x+r.endPoint.x)/2,y:(r.startPoint.y+r.endPoint.y)/2},a=s.getDistance(l,n.position);if(ai.maxSymbolLen)return null;var h=re.getWall(r.parent),c=re.getPoint(h.start),u=re.getPoint(h.end);if(o==U){var d=ee.getNewForContainSymbols(r.endPoint,n.position,r.parent,e);if(null==d||d.collision)return null;st.isContain(h,n.position)?ee.setPosition(r,n.position,"start"):s.getDistance(r.startPoint,c)-1&&t.children.splice(o,1),re.getSymbol(e).parent=null}},te.prototype.deleteSymbol=function(t){var e=re.getSymbol(t);if(e.parent){var o=re.getWall(e.parent);this.deleteSymbolForWall(o,t)}re.deleteSymbol(t)},te.prototype.changeSymbolForBelong=function(t,e){var o=re.getSymbol(t),i=o.parent,n=re.getWall(i);this.deleteSymbolForWall(n,t),o.setSymbolParent(e);var r=re.getWall(e);st.addChildren(r,t)},te.prototype.reBelongForSplitWall=function(t,e,o){for(var i=re.getWall(t),n=0;nd){if(S[k].vectorId==S[k+1].vectorId&&S[k].type!=h)return{position1:x,position2:p,collision:!0,state:!1};if(S[k].vectorId==S[k+1].vectorId&&S[k].type==h)return{position1:x,position2:p,collision:!0,state:!0};if(!s.isContainForSegment(x,S[k],S[k+1])||!s.isContainForSegment(p,S[k],S[k+1]))return{position1:x,position2:p,collision:!0,state:!1}}else{if(s.getDistance(S[k],S[k+1])d&&(e=d)}var y=s.getParallelLineForDistance(a,e/2),x=s.getIntersectionPoint(y.line1,r),p=s.getIntersectionPoint(y.line2,r),g={};s.getDistance(i,x)Math.min(v,S)&&(vs.getDistance(c.endPoint,y)?(y=null,p=null):u=Math.min(v,S));var P=s.getDistance(c.endPoint,m.startPoint),I=s.getDistance(c.endPoint,m.endPoint);d>Math.min(P,I)&&(Ps.getDistance(c.startPoint,x)?(x=null,g=null):d=Math.min(P,I))}return o&&(null==y&&(s.getDistance(l,c.startPoint)>s.getDistance(l,c.endPoint)?(y=a,p=a):(y=l,p=l)),null==x&&(s.getDistance(l,c.startPoint)>s.getDistance(l,c.endPoint)?(x=l,g=l):(x=a,g=a))),{startPosition:y,startPosition2:p,endPosition:x,endPosition2:g}},te.prototype.moveSymbolSinglePoint=function(t,e,o){var i=re.getSymbol(e),n=s.createLine1(i.startPoint,i.endPoint),r=s.getVerticalLine(n,t);t=s.getIntersectionPoint(r,n);var l={x:(i.startPoint.x+i.endPoint.x)/2,y:(i.startPoint.y+i.endPoint.y)/2},a=re.getWall(i.parent),h=re.getPoint(a.start),c=re.getPoint(a.end);if("start"==o){if(!s.PointInSegment(l,t,i.endPoint))return null;s.getDistance(i.startPoint,h)s.getDistance(h,l)&&s.clonePoint(t,h):s.getDistance(t,l)>s.getDistance(c,l)&&s.clonePoint(t,c)}else if("end"==o){if(!s.PointInSegment(l,t,i.startPoint))return null;s.getDistance(i.endPoint,c)s.getDistance(c,l)&&s.clonePoint(t,c):s.getDistance(t,l)>s.getDistance(h,l)&&s.clonePoint(t,h)}return{dir:o,position:t}},te.prototype.setSymbolInfo=function(t){var e=re.getSymbol(t.vectorId);return e.openSide=t.openSide,e.startPoint=t.start,e.endPoint=t.end,e.points2d=JSON.parse(JSON.stringify(t.points2d)),e.enter=t.enter,e.parent=t.parent,e},te.prototype.setEnterImg=function(t){this.enterImg=t},te.prototype.getEnterImg=function(){return this.enterImg},te.prototype.createSymbolFromPanorama=function(t,e,o){var i=[],n={x:t.ray.origin.x,y:-1*t.ray.origin.z},r=re.getWalls();for(var l in r){var a=re.getWall(l),h=re.getPoint(a.start),c=re.getPoint(a.end),u=s.raySegmentIntersection(n,t.ray.direction,h,c);null!=u&&i.push({wallId:l,join:u})}if(i.length>0){function t(t,e){return s.getDistance(n,t.join)-s.getDistance(n,e.join)}i=i.sort(t.bind(this));var d=this.addSymbol(i[0].join,e,i[0].wallId);return null!=d?(Qt.moveFullSymbol(i[0].join,d,i[0].wallId),re.getSymbol(d),d):(console.error("漫游模式下添加门/窗:门/窗区域太小,加不上"),null)}return console.error("漫游模式下添加门/窗:没有与任何墙相交"),null};var ee=new te,oe=function(){this.defaultCenter=null,this.center=null,this.zoom=100,this.res=80,this.ratio=1,this.cadImg_Width=1920,this.cadImg_Height=937,this.initRes=null,this.initWidth=null,this.initHeight=null};oe.prototype.init=function(t){var e=re.getBoundingBox();this.setCenter(e),this.updateForCanvas(t)},oe.prototype.setInitInfo=function(t,e,o){null==this.initRes&&(this.initRes=t),null==this.initWidth&&(this.initWidth=e),null==this.initHeight&&(this.initHeight=o)},oe.prototype.updateResForReSize=function(t,e,o){Math.abs(o)<.01||Math.abs(o-2*Math.PI)<.01?this.res=this.initRes*t/this.initWidth:this.res=this.initRes*e/this.initHeight,i.minRealDis=i.minPixDistance/this.res*i.defaultZoom/this.zoom,i.minAdsorb=i.minPixLen/this.res*i.defaultZoom/this.zoom},oe.prototype.setCenter=function(t){this.defaultCenter?this.center={x:this.defaultCenter.x,y:this.defaultCenter.y}:(this.cadBoundingbox=JSON.parse(JSON.stringify(t)),null!=this.cadBoundingbox&&(this.center={x:(this.cadBoundingbox.maxX+this.cadBoundingbox.minX)/2,y:(this.cadBoundingbox.maxY+this.cadBoundingbox.minY)/2}))},oe.prototype._setDefaultCenter=function(t){this.defaultCenter={x:t.x,y:t.y}},oe.prototype.setDefaultCenter=function(t){this.defaultCenter={x:t.x,y:-t.z}},oe.prototype._setRes=function(t){this.res=t,i.minRealDis=i.minPixDistance/this.res*i.defaultZoom/this.zoom,i.minAdsorb=i.minPixLen/this.res*i.defaultZoom/this.zoom},oe.prototype.setRes=function(t,e){this.res=this.width/Math.abs(e-t),i.minRealDis=i.minPixDistance/this.res*i.defaultZoom/this.zoom,i.minAdsorb=i.minPixLen/this.res*i.defaultZoom/this.zoom},oe.prototype.getScreenXY=function(t){if(null==this.width||null==this.height)return null;var e=t.x,o=t.y,i=this.width/2+(e-this.center.x)*this.res*this.zoom/100,n=this.height/2-(o-this.center.y)*this.res*this.zoom/100;return i=.5+(i*=this.ratio)<<0,n=.5+(n*=this.ratio)<<0,{x:Math.floor(i),y:Math.floor(n)}},oe.prototype.getXYFromScreen=function(t){var e={};return e.x=(t.x-this.width/2)/this.res*100/this.zoom+this.center.x,e.y=(this.height/2-t.y)/this.res*100/this.zoom+this.center.y,e},oe.prototype.getPointForRevRotate=function(t,e){if(Math.abs(e)<.01||Math.abs(e-2*Math.PI)<.01)return t;var o=(t.x-this.center.x)*Math.cos(e)-(t.y-this.center.y)*Math.sin(e)+this.center.x,i=(t.y-this.center.y)*Math.cos(e)+(t.x-this.center.x)*Math.sin(e)+this.center.y;return t.x=o,t.y=i,t},oe.prototype.getVectorForRotate=function(t,e){if(e=-e,Math.abs(e)<.01||Math.abs(e-2*Math.PI)<.01)return t;var o=(t.x-this.center.x)*Math.cos(e)-(t.y-this.center.y)*Math.sin(e)+this.center.x,i=(t.y-this.center.y)*Math.cos(e)+(t.x-this.center.x)*Math.sin(e)+this.center.y;return t.x=o,t.y=i,t},oe.prototype.updateCenterForRotate=function(t){if(!(Math.abs(t)<.01||Math.abs(t-2*Math.PI)<.01)){var e=this.center.x*Math.cos(t)-this.center.y*Math.sin(t),o=this.center.y*Math.cos(t)+this.center.x*Math.sin(t);return this.center.x=e,this.center.y=o,this.center}},oe.prototype.updateForCanvas=function(t){t&&(this.width=t.clientWidth,this.height=t.clientHeight,t.width=t.clientWidth,t.height=t.clientHeight)},oe.prototype.updateZoom=function(t){this.zoom=t,i.minRealDis=i.minPixDistance/this.res*i.defaultZoom/this.zoom,i.minAdsorb=i.minPixLen/this.res*i.defaultZoom/this.zoom},oe.prototype.moveTo=function(t,e){var o=this.getXYFromScreen(e);this.zoom=t;var i=(100*e.x/this.zoom-this.width/2)/this.res,n=(this.height/2-100*e.y/this.zoom)/this.res;this.center.x=o.x-i,this.center.y=o.y-n},oe.prototype.getXYFromScreenForDefaultZoom=function(t){var e={};return e.x=(t.x-this.width/2)/this.res+this.center.x,e.y=(this.height/2-t.y)/this.res+this.center.y,e},oe.prototype.getScreenInfoForCAD=function(){var t=this.getXYFromScreen({x:this.width,y:this.height}),e=this.getXYFromScreen({x:0,y:0}),o={x:this.center.x,y:this.center.y};return{width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y),center:{x:o.x,y:o.y},defaultCenter:this.defaultCenter}},oe.prototype.getPixelRatio=function(t){var e=t.backingStorePixelRatio||t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1;return(window.devicePixelRatio||1)/e},oe.prototype.reSet=function(){this.center={x:this.defaultCenter.x,y:this.defaultCenter.y},this.zoom=100},oe.prototype.updateForRotate=function(t){void 0===t&&(t=Math.PI/2);for(var e=0;eo.floors[s].boundingBox.minX)&&(e=o.floors[s].boundingBox.minX),(null==i||io.floors[s].boundingBox.minY)&&(n=o.floors[s].boundingBox.minY),(null==r||rs.minX)&&(t=s.minX),(null==e||e>s.minY)&&(e=s.minY),(null==i||il.x)&&(o=l.x),(null==i||il.y)&&(n=l.y),(null==r||rh)&&(i=h),(void 0===r||rc)&&(n=c),(void 0===s||s=h&&e[u].x<=c)continue;(h=Math.min(h,e[u].x))!=(c=Math.max(c,e[u].x))&&this.measureLines.top.push({x:e[u].x,y:this.region.top})}e=this.measureLines.top.sort(w.bind(this)),this.measureLines.top=[],this.measureLines.top.push(e[0]);for(var d=0;d=h&&o[p].x<=c)continue;(h=Math.min(h,o[p].x))!=(c=Math.max(c,o[p].x))&&this.measureLines.bottom.push({x:o[p].x,y:this.region.bottom})}o=this.measureLines.bottom.sort(w.bind(this)),this.measureLines.bottom=[],this.measureLines.bottom.push(o[0]);for(var g=0;g=h&&i[v].y<=c)continue;(h=Math.min(h,i[v].y))!=(c=Math.max(c,i[v].y))&&this.measureLines.left.push({x:this.region.left,y:i[v].y})}i=this.measureLines.left.sort(C.bind(this)),this.measureLines.left=[],this.measureLines.left.push(i[0]);for(var S=0;S=h&&n[b].y<=c)continue;(h=Math.min(h,n[b].y))!=(c=Math.max(c,n[b].y))&&this.measureLines.right.push({x:this.region.right,y:n[b].y})}n=this.measureLines.right.sort(C.bind(this)),this.measureLines.right=[],this.measureLines.right.push(n[0]);for(var k=0;k=i})).reduce((function(t,e){return e.fromBase(o)=1?e:t}));return l?[l.fromBase(o),l]:void 0},ye.prototype.getMostRelevantMeasurement2=function(t,e,o,i){void 0===i&&(i=0);var n=[],r=ue.getUnitsOfMeasurementByDomainAndSystem(t,e);for(var s in r)n.push(r[s]);var l=n.filter((function(t){return t.factor>=i})).reduce((function(t,e){return e.toBase(o)=1?e:t}));return l?[l.toBase(o),l]:void 0},ye.prototype.convertBack=function(t,e,o,i,n){if(void 0===o&&(o=2),!t)return"";t=t.trim().replace(",","");var r=ue.getDefaultUnitByDomainAndSystem(e,"metric"),s=this.getMostRelevantMeasurement2(e,i,t,n);return this.getFormattedMeasurementString(s[0],r,o)};var xe=new ye,pe=function(){};pe.prototype.createTag=function(t,e,o){var i=new se(t,e);return i.setPoints2d(),re.addTag(i,o),i},pe.prototype.setTagInfo=function(t){var e=re.getTag(t.vectorId);e.vectorId=t.vectorId,e.center=JSON.parse(JSON.stringify(t.center)),e.points2d=JSON.parse(JSON.stringify(t.points2d)),e.title=t.title,e.des=t.des,e.unit=t.unit,e.adding=t.adding},pe.prototype.deleteTag=function(t,e){re.deleteTag(t,e)},pe.prototype.clearDefaultTags=function(){for(var t=0;tp)&&(n={distance:p,pointId:d.start},s.getDistance(f,t)s.getDistance(t,y)&&(l.x=y.x,l.linkedPointIdX=d.start)}else l.x=y.x,l.linkedPointIdX=d.start;if(Math.abs(t.y-y.y)s.getDistance(t,y)&&(l.y=y.y,l.linkedPointIdY=d.start)}else l.y=y.y,l.linkedPointIdY=d.start}if(-1==h.indexOf(d.end)){if(h.push(d.end),p=s.getDistance(t,x),(null==n||n.distance>p)&&(n={distance:p,pointId:d.end},s.getDistance(f,t)s.getDistance(t,x)&&(l.x=x.x,l.linkedPointIdX=d.end)}else l.x=x.x,l.linkedPointIdX=d.end;if(Math.abs(t.y-x.y)s.getDistance(t,x)&&(l.y=x.y,l.linkedPointIdY=d.end)}else l.y=x.y,l.linkedPointIdY=d.end}p=s.getDistance(t,f);var I=st.isContain(d,f);I&&(null==r||r.distance>p)&&(r={distance:p,wallId:u}),I&&s.getDistance(t,f)0};var Ae=new Oe;window.historyService=Ae;var Ee=function(t){this.layer=t,this.app=this.layer.app,this.houseData=null};Ee.prototype.initVectors=function(t){for(var e=t.floors,i=-1,n=0,r=0,s=0;sf.x)&&(u=f.x),(null==d||d>f.y)&&(d=f.y),(null==y||yr.x||o.x===r.x&&o.y>r.y)&&(o={x:r.x,y:r.y},i=n)}return i},to.prototype.createPolygon=function(t,e,o){if(0!==Object.keys(o).length&&0!==Object.keys(e).length){this.matrix={};var i=[];this.preHandle(o,e);var n=Object.keys(e).length;if(0!==Object.keys(o).length&&0!==Object.keys(e).length){null!==t&&o[t]||(t=this.getStartPoint(o)),i.push(t);var r=this.getNextForMinAngleX(t,o,e);if(null!==r){i.push(r);var s=this.getMaxPolygon(i,o,e);this.checkPolygonSegmentIds(s,o,e);var l=this.splitPolygon(s);if(l){var a=this.getPolygonData(l,o,e),h=Object.keys(a.points),c=Object.keys(a.segments);if(a.segments=this.getChildSegments(a.points,a.segments,e),this.createPolygon(l[0],a.segments,a.points),this.updateMartix2(h,c,o,e),this.preHandle(o,e),0===Object.keys(o).length||0===Object.keys(e).length)return;this.createPolygon(t,e,o)}else if(0!==Object.keys(o).length&&0!==Object.keys(e).length){this.maxPolygons.push(s),this.updateMartix(s,o,e),o[t]||(t=this.getStartPoint(o),r=this.getNextForMinAngleX(t,o,e));var u=[];u.push(t),u.push(r);var d=this.getMinPolygon(u,o,e);if(this.checkPolygonSegmentIds(d,o,e),l=this.splitPolygon(d)){var y=this.getPolygonData(l,o,e),x=Object.keys(y.points),p=Object.keys(y.segments);if(this.createPolygon(l[0],y.segments,y.points),this.updateMartix2(x,p,o,e),this.preHandle(o,e),0===Object.keys(o).length||0===Object.keys(e).length)return;this.createPolygon(t,e,o)}else if(0!==s.length&&0!==d.length){if(this.addPolygon(d,o,e)){var g=d.slice(0);if(g.push(d[0]),this.updateMartix(g,o,e),this.preHandle(o,e),0===Object.keys(o).length||0===Object.keys(e).length)return}if(n===Object.keys(e).length){this.addPolygon(s,o,e);var f=s.slice(0);if(f.push(s[0]),this.updateMartix(f,o,e),this.updateMartix(f,o,e),this.preHandle(o,e),0===Object.keys(o).length||0===Object.keys(e).length)return}var m=this.getStartPoint(o,t);this.createPolygon(m,e,o)}else console.error("createPolygon——————————————————————————————————————————————————————————————出错!")}}}}},to.prototype.splitPolygon=function(t){for(var e=[],o=0;o-1||c.indexOf(d)>-1)){var y=e[d];if(s.isPointInPoly(y,r)){c.push(d);var x=y.parent;for(var p in x)if(o[p]&&!n[p]&&-1===u.indexOf(p)){var g=null;o[p].start===d?g=o[p].end:o[p].end===d&&(g=o[p].start);var f=e[g];t.indexOf(g)>-1||c.indexOf(g)>-1?u.push(p):s.isPointInPoly(f,r)&&(u.push(p),c.push(g))}}}for(var m=0;mc)&&(r=c,l=n[a])}}return l},to.prototype.getNextForMaxMinAngle=function(t,e,o,i){var n=o[t],r=o[e];n&&r||console.error("getNextForMaxMinAngle******************************************");for(var l=r.x-n.x,a=r.y-n.y,h={x:r.x+l,y:r.y+a},c=this.getAllLinkedPoint(e,o,i),u=null,d=null,y=null,x=null,p=0;pf)&&(y=f,x=c[p])}}return{max:d,min:x}},to.prototype.updateMartix=function(t,e,o){for(var i=0;i1)continue;delete t[i]}}return o},to.prototype.getPoint=function(t,e){return e[t]},to.prototype.isClockwise=function(t,e){for(var o=[],i=0;i-1))for(var l=t[s],a=e[l.start],h=e[l.end],c=0;c-1||this.containPoint(y,a))&&(u=!0),(y.pointIds.indexOf(l.end)>-1||this.containPoint(y,h))&&(d=!0),u&&d&&y.childrenSegmentIds.push(s)}},to.prototype.isContain=function(t,e){for(var o=[],i=[],n=0;n-1&&(e=e.concat(n.pointIds),o=o.concat(n.segmentIds))}for(var r={},s={},l=0;l-1){e.splice(l,1),--l;break}this.getChildMaxPolygons(t,e)}else if(1===e.length){var c=this.getPolygon(e[0]);t.caves.push(c.pointIds)}},to.prototype.getPolygon=function(t){for(var e=0;e-1||n.indexOf(a.end)>-1)){var h=re.getPoint(a.start),c=re.getPoint(a.end),u=!1;if(o.indexOf(a.start)<0){o.push(a.start);var d=s.getJoinLinePoint(h,r);s.PointInSegment(d,this.startInfo.position,this.endInfo.position,i.minAdsorb)&&s.getDistance(h,d)>e/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,t)},nth:function(t){return 1===(t%=10)?t+"st":2===t?t+"nd":3===t?t+"rd":t+"th"},extendObject:function(t,e){return Object.keys(e).forEach((function(o){t[o]=e[o]})),t},deepExtend:function t(e){var o=arguments;e=e||{};for(var i=1;i=e&&(t.apply(n,o),lastCallTime=r)}:function(){for(var o=[],n=arguments.length;n--;)o[n]=arguments[n];i&&clearTimeout(i);var r=this;i=setTimeout((function(){t.apply(r,o)}),e)}},getMixedSet:function(t,e){return t.filter((function(t){return e.includes(t)}))},getUnionSet:function(t,e){return t.concat(e.filter((function(e){return!t.includes(e)})))},getDifferenceSet:function(t,e){var o=t.filter((function(t){return!e.includes(t)})),i=e.filter((function(e){return!t.includes(e)}));return o.concat(i)},getDifferenceSetMuti:function(t){var e=[];return t.forEach((function(t){t.forEach((function(t){var o=e.indexOf(t);o>-1?e.splice(o,1):e.push(t)}))})),e},getMAXCUBETEXTURESIZE:function(){try{var t=document.createElement("canvas"),e=t.getContext("webgl");return e||(e=t.getContext("experimental-webgl")),e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE)}catch(t){return 0}}},xo=((ho=new THREE.TextureLoader).setCrossOrigin("Anonymous"),ho.crossOrigin=!0,function(t,e,o,i){var n=ho.load(t,e,o,i);return n.magFilter=n.minFilter=THREE.LinearFilter,n.needsUpadte=!0,n});yo.dataURLtoBlob=function(t){for(var e=t.split(","),o=e[0].match(/:(.*?);/)[1],i=atob(e[1]),n=i.length,r=new Uint8Array(n);n--;)r[n]=i.charCodeAt(n);return new Blob([r],{type:o})},yo.dataURLtoFile=function(t,e){for(var o=t.split(","),i=o[0].match(/:(.*?);/)[1],n=atob(o[1]),r=n.length,s=new Uint8Array(r);r--;)s[r]=n.charCodeAt(r);return new File([s],e,{type:i})},yo.saveFile=function(t,e,o){var i=document.createElementNS("http://www.w3.org/1999/xhtml","a");i.href=t,i.download=e;var n=document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),i.dispatchEvent(n),o&&o()},yo.PrefixPng="data:image/png;base64,",yo.getBlobSrc=function(t,e){var o=yo.dataURLtoBlob((e?yo.PrefixPng:"")+t);return window.URL.createObjectURL(o)},yo.replaceAll=function(t,e,o){var i=new RegExp(e,"g");return t.replace(i,o)},yo.randomWord=function(t,e,o){var i="",n=e,r=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];t&&(n=Math.round(Math.random()*(o-e))+e);for(var s=0;s-1&&(n="cancel",t.unvisibleReasons.splice(r,1)),"add"==n&&(t.visibleReasons.some((function(t){return t.reason==e}))||t.visibleReasons.push({reason:e,level:i}))):((r=t.visibleReasons.findIndex((function(t){return t.reason==e})))>-1&&(n="cancel",t.visibleReasons.splice(r,1)),"cancel"!=n&&(t.unvisibleReasons.some((function(t){return t.reason==e}))||t.unvisibleReasons.push({reason:e,level:i})));!function(){t.unvisibleReasons=t.unvisibleReasons.sort((function(t,e){return e.level-t.level})),t.visibleReasons=t.visibleReasons.sort((function(t,e){return e.level-t.level}));var o=(t.visibleReasons[0]?t.visibleReasons[0].level:-1)>=(t.unvisibleReasons[0]?t.unvisibleReasons[0].level:-1);t.visible!=o&&(t.visible=o,t.dispatchEvent({type:"isVisible",visible:o,reason:e}))}()},yo.getObjVisiByReason=function(t,e){return!!t.visible||(!t.unvisibleReasons||!t.unvisibleReasons.some((function(t){return t.reason==e})))},yo.setCameraLayers=function(t,e,o){void 0===o&&(o=[]),t.layers.disableAll(),e.concat(o).forEach((function(e){var o=Potree.config.renderLayers[e];null!=o?t.layers.enable(o):console.error("setCameraLayer没找到layer!")}))},yo.setObjectLayers=function(t,e){var o=Potree.config.renderLayers[e];null!=o?t.traverse((function(t){t.layers.set(o)})):console.error("setCameraLayer没找到layer!")},yo.intervalTool={list:[],isWaiting:function(t,e,o){var i=this,n=this.list.find((function(e){return e.name==t}));if(n)n.requestUpdate=!0;else{var r=e();n={name:t},this.list.push(n),setTimeout((function(){var s=i.list.indexOf(n);i.list.splice(s,1),(n.requestUpdate||r)&&i.isWaiting(t,e,o)}),o)}}},yo.batchHandling={lists:[],getSlice:function(t,e,o){var i=o.stopWhenAllUsed,n=o.minCount;void 0===n&&(n=5);var r=o.maxCount;void 0===r&&(r=100);var s=o.durBound1,l=o.durBound2,a=o.maxUseCount;if(0==e.length||!(a=null==a?yo.getBestCount({name:t,minCount:n,maxCount:r,durBound1:s,durBound2:l,ifLog:!1}):a))return{list:[]};this.lists[t]||(this.lists[t]={list:[]});var h=this.lists[t].list.filter((function(t){return e.some((function(e){return t.item==e}))}));this.lists[t].list=h,e.forEach((function(t){h.some((function(e){return e.item==t}))||h.push({item:t,count:0})}));var c=h.filter((function(t){return 0==t.count})),u=[];if(c.slice(0,a).forEach((function(t){u.push(t.item),t.count++})),c.length>a);else{if(!i){var d=Math.min(e.length,a)-u.length;h.slice(0,d).forEach((function(t){u.push(t.item),t.count++}))}h.forEach((function(t){return t.count--}))}return{list:u}},addSliceListen:function(t){var e=t.getList,o=t.callback,i=t.minCount,n=t.maxCount;t.durBound1,t.durBound2,t.maxHistory;var r,s,l=t.player;l.on("update",(function(t){if(!l.flying){var a,h=e(),c=!l.lastFrameChanged,u=l.lastFrameChanged||!s;u?(a=h,r=null):(r||(r=yo.getDifferenceSet(h,s)),a=r);var d=yo.batchHandling.getSlice("ifVideoInsight",a,{stopWhenAllUsed:c,minCount:i,maxCount:n,durBound1:3,durBound2:13,maxHistory:3}).list;d.forEach(o),u||(r=yo.getDifferenceSet(r,d)),s=d}}))}},yo.getBestCount=(po={},function(t){var e=t.name,o=t.minCount;void 0===o&&(o=1);var i=t.maxCount;void 0===i&&(i=6);var n=t.durBound1;void 0===n&&(n=1);var r=t.durBound2;void 0===r&&(r=4);var s,l=t.ifLog,a=t.maxHistory,h=performance.getEntriesByName("loop-start");if(h.length){var c=performance.now()-h[h.length-1].startTime;s=Math.round(math.linearClamp(c,n,r,i,o)),a&&(po[e]||(po[e]=[]),0==s&&po[e].length>a-1&&!po[e].some((function(t){return t>0}))&&(s=1),po[e].push(s),po[e].length>a&&po[e].splice(0,1)),l&&console.log(e,s," ,dur:",c.toFixed(3))}else s=i;return s}),yo.getPos2d=function(t,e,o,i){o=o||e.camera,i=i||e.domElement;var n,r,s=t.clone().project(o);n=(s.x+1)/2*i.clientWidth,r=(1-(s.y+1)/2)*i.clientHeight;var l=n<=i.clientWidth&&n>=0&&r<=i.clientHeight&&r>=0;return{pos:new THREE.Vector2(n,r),vector:s,trueSide:s.z<1,inSight:l}},yo.realVisible=function(t){for(var e,o=!0,i=t;i;){if(!1===i.visible){o=!1;break}e=i,i=i.parent}return!o||e instanceof THREE.Scene||(o=!1),o};var go=function(t){this.layer=t,this.showTexture=!0},fo={selectUI:{configurable:!0},currentUI:{configurable:!0},currentFloor:{configurable:!0},currentUnit:{configurable:!0}};fo.selectUI.get=function(){return this.layer.$xui.selectName},fo.selectUI.set=function(t){this.layer.$xui.selectName=t,this.layer.updateEventNameForSelectUI()},fo.currentUI.get=function(){return this.layer.$xui.currentName},fo.currentUI.set=function(t){null===t?this.layer.$xui.hideProps():this.layer.$xui.showProps(t)},fo.currentFloor.get=function(){return this.layer.$xui.currentFloor},fo.currentFloor.set=function(t){this.layer.display&&("image"==this.layer.app.store.getValue("flooruser").type?re.setCurrentFloor(t):(re.setCurrentFloor(t),this.layer.initPanos(re.currentFloor),ae.update(!1),Ae.clearHistoryRecord(),this.layer.$xui.toolbar.recall=!1,this.layer.$xui.toolbar.recover=!1,this.layer.history.init(),setTimeout(function(){this.layer.renderer.autoRedraw()}.bind(this),50)))},fo.currentUnit.get=function(){return this.layer.$xui.currentUnit},fo.currentUnit.set=function(t){this.layer.uiControl.currentUI=null,ae.unit=t,ge.convertUnit(t),this.layer.history.save(),this.layer.renderer.autoRedraw()},go.prototype.setAttributes=function(t,e,o){console.log(e);var i=Kt.getFocusItem();switch(e){case"remove":if(t==h||"OutWall"==t)re.deleteWall(i.vectorId);else if(ee.isSymbol(t))ee.deleteSymbol(i.vectorId);else if(ut.isComponent(t))re.deleteComponent(i.vectorId);else if(t==P){re.deleteTag(i.vectorId);var n=Kt.getDraggingItem();n&&n.vectorId!=i.vectorId&&re.deleteTag(n.vectorId)}else t==a?st.deleteWallCorner(i.vectorId):Gt.isFurniture(t)&&re.deleteFurniture(i.vectorId);Kt.clearItems(),Kt.clearEventName(),this.layer.renderer.autoRedraw();break;case"rotate":if(ee.isSymbol(t)){var r=re.getSymbol(i.vectorId);if(t==c){if(r.openSide==H)if(s.isClockwise(r.points2d))r.openSide=Z;else{var l=r.endPoint;r.endPoint=r.startPoint,r.startPoint=l,r.openSide=Z}else if(r.openSide==Z)if(s.isClockwise(r.points2d))r.openSide=H;else{var y=r.endPoint;r.endPoint=r.startPoint,r.startPoint=y,r.openSide=H}}else if(t==d||t==u||t==x)r.openSide==H?r.openSide=Z:r.openSide==Z&&(r.openSide=H);else{var p=r.endPoint;r.endPoint=r.startPoint,r.startPoint=p}r.setPoints2d(),this.layer.renderer.autoRedraw()}break;case"angle":if(ut.isComponent(t)){var g=re.getComponent(i.vectorId);g.angle=o,g.setPoints2d(),this.layer.renderer.autoRedraw()}else if(Gt.isFurniture(t)){re.getFurniture(i.vectorId).angle=o,this.layer.renderer.autoRedraw()}break;case"width":if(ee.isSymbol(t)){if(ee.updateSymbolForLen(i.vectorId,o).block){var f=re.getSymbol(i.vectorId);console.log("长度阻止:"+s.getDistance(f.startPoint,f.endPoint)),this.layer.$xui.currentAttributes={limit:s.getDistance(f.startPoint,f.endPoint),type:i.type,name:"width",width:s.getDistance(f.startPoint,f.endPoint),thickness:f.thickness}}}else if(ut.isComponent(t)){var m=re.getComponent(i.vectorId);m.sideWidth=o,m.setPoints2d()}this.layer.renderer.autoRedraw();break;case"scale":if(Gt.isFurniture(t))re.getFurniture(i.vectorId).zoom=o,this.layer.renderer.autoRedraw();break;case"thickness":if(ut.isComponent(t)){var v=re.getComponent(i.vectorId);v.sideThickness=o,v.setPoints2d(),this.layer.renderer.autoRedraw()}else if(t==x){var S=re.getSymbol(i.vectorId);S.thickness=o,S.setPoints2d(),this.layer.renderer.autoRedraw()}break;case"split":if(t==h||"OutWall"==t){var I=re.getWall(i.vectorId),b=re.getPoint(I.start),k=re.getPoint(I.end),T={x:(b.x+k.x)/2,y:(b.y+k.y)/2},F=st.createPoint(T.x,T.y),C=st.splitWall(i.vectorId,F.vectorId,"start");I=re.getWall(i.vectorId),b=re.getPoint(I.start),k=re.getPoint(I.end);var w={x:(b.x+k.x)/2,y:(b.y+k.y)/2},W={vectorId:C,type:t};(T.xw.y)&&Kt.setFocusItem(W),this.layer.renderer.autoRedraw()}break;case"tag":if(t==P){var D=re.getTag(i.vectorId);null!=o&&""!=o.trim()?D.setTitle(o):D.setTitle(KanKan.Config.i18n("cad.input")),this.layer.renderer.autoRedraw()}break;case"area":if(t==P){var L=re.getTag(i.vectorId);L.setDes(o),L.setUnit(ae.unit),this.layer.renderer.autoRedraw()}break;case"default":if("compass"==t)return void re.setCompass(0);if(ee.isSymbol(t)){var z=ee.getDefaultSymbolLen(t),M=ee.updateSymbolForLen(i.vectorId,z);re.getSymbol(i.vectorId).enter=null,M.block||(this.layer.$xui.currentAttributes={type:i.type,name:"width",width:s.getFixed(s.getDistance(M.start,M.end),2)})}else if(ut.isComponent(t)){var R=re.getComponent(i.vectorId);R.sideWidth=ut.sideWidth,R.sideThickness=ut.sideThickness,R.angle=0,R.setPoints2d(),this.layer.$xui.currentAttributes={name:i.type,width:s.getFixed(R.sideWidth,2),thickness:s.getFixed(R.sideThickness,2),angle:0}}this.layer.renderer.autoRedraw();break;case"enter":if(t==c||t==u||t==d){var O=re.getSymbol(i.vectorId);O.enter=o?"default":null,this.layer.renderer.autoRedraw()}break;case"enterRotate":if(t==c||t==u||t==d){var A=re.getSymbol(i.vectorId);null==A.enter?A.enter="default":"default"==A.enter?A.enter="reverse":"reverse"==A.enter&&(A.enter="default")}this.layer.renderer.autoRedraw();break;case"important":if(t==h)re.getWall(i.vectorId).setImportant(o),this.layer.renderer.autoRedraw();break;case"wallType":if(t==h){var E=re.getWall(i.vectorId);"OutWall"==o?E.setOut(!0):E.setOut(!1),this.layer.renderer.autoRedraw()}break;case"compass":re.setCompass(parseFloat(o))}},go.prototype.saveAttributes=function(t,e){"compass"==e||"compass"==t&&"default"==e||this.layer.history.save()},go.prototype.showAttributes=function(t){if("compass"!=t){var e=Kt.getFocusItem();if(null==e&&(e=Kt.getDraggingItem()),ee.isSymbol(e.type)){var o=re.getSymbol(e.vectorId),i=s.getDistance(o.startPoint,o.endPoint);i=s.getFixed(i,2),e.type==c||e.type==u||e.type==d?this.layer.$xui.currentAttributes={name:e.type,width:i,enter:o.enter?o.enter:null}:e.type==x?this.layer.$xui.currentAttributes={name:e.type,width:i,thickness:s.getFixed(o.thickness,2)}:this.layer.$xui.currentAttributes={name:e.type,width:i}}else if(ut.isComponent(e.type)){var n=re.getComponent(e.vectorId),r=n.sideWidth,l=n.sideThickness;this.layer.$xui.currentAttributes={name:e.type,width:s.getFixed(r,2),thickness:s.getFixed(l,2),angle:n.angle}}else if(e.type==P){var a=re.getTag(e.vectorId);this.layer.$xui.currentAttributes={name:e.type,tag:a.title,area:a.des}}else if(e.type==h){var y=re.getWall(e.vectorId);this.layer.$xui.currentAttributes={name:y.out?"OutWall":e.type,important:y.important||y.out,wallType:y.out?"OutWall":e.type}}else if(Gt.isFurniture(e.type)){var p=re.getFurniture(e.vectorId),g=p.zoom;this.layer.$xui.currentAttributes={name:e.type,scale:g,angle:p.angle}}}else this.layer.$xui.currentAttributes={name:"compass",compass:re.getCompass()}},go.prototype.clearUI=function(){this.selectUI=null},go.prototype.getSymbolTypeForUI=function(){return this.selectUI==pt?c:this.selectUI==gt?u:this.selectUI==ft?d:this.selectUI==mt?y:this.selectUI==vt?x:this.selectUI==St?p:this.selectUI==Pt?g:void 0},go.prototype.getComponentTypeForUI=function(){return this.selectUI==It?f:this.selectUI==bt?m:this.selectUI==kt?v:void 0},go.prototype.getFurnitureTypeForUI=function(){return this.selectUI==Ft?I:this.selectUI==Ct?b:this.selectUI==wt?k:this.selectUI==Wt?T:this.selectUI==Dt?F:this.selectUI==Lt?C:this.selectUI==zt?w:this.selectUI==Mt?W:this.selectUI==Rt?D:this.selectUI==Ot?L:this.selectUI==At?z:this.selectUI==Et?M:this.selectUI==Bt?R:this.selectUI==Yt?O:this.selectUI==Nt?A:this.selectUI==Xt?E:this.selectUI==jt?B:this.selectUI==_t?Y:this.selectUI==Ut?N:this.selectUI==Jt?X:this.selectUI==Vt?j:void 0},go.prototype.screenShot=function(t){var e=this;return new Promise((function(o){e.menu_flex(),Kt.clearItems(),ro.start();var n=e.layer.canvas;ie.setRadio(i.ratio),n.width=window.innerWidth*ie.ratio,n.height=window.innerHeight*ie.ratio,ie.width=window.innerWidth,ie.height=window.innerHeight;var r=e.layer.app.core.get("CameraControls").activeControl.camera;ie.res=Math.min(window.innerWidth/Math.abs(r.right-r.left),window.innerHeight/Math.abs(r.top-r.bottom)),setTimeout(function(){var e=this;if(1==re.getFloorNum())ae.update(!0),this.layer.renderer.autoRedrawForDownLoadImg(t),this.downloadCadImg(n,"floorPlan.jpg");else{var i=re.getCurrentFloor();co.save(ie.res,ie.center,ie.defaultCenter,i),this.layer.app.store.getValue("flooruser").floors.forEach((function(o,i){e.currentFloor=o.subgroup,co.setTransform(o.subgroup),ae.update(!0),e.layer.renderer.autoRedrawForDownLoadImg(t),yo.canvasToImg(n,3,!0,"image/jpeg",o.name+".jpg")})),this.currentFloor=i,co.recover()}ie.updateForCanvas(n),ie.setRes(r.left,r.right),ie.ratio=1,ae.updateRegion(!0),ae.update(!1),this.layer.renderer.autoRedraw(),o()}.bind(e),100)}))},go.prototype.downloadPanosImg=function(){var t=this;return new Promise((function(e){var o=__sdk.core.get("Player"),i=uo("panoImgcolor",!0)?"#"+uo("panoImgcolor",!0):"#fff",n=o.domElement.clientWidth,r=o.domElement.clientHeight,s=t.layer.app.store.getValue("metadata").floorPlanAngle;s=parseFloat(s);var l=o.model.size.clone().applyEuler(new THREE.Euler(0,s,0));l.x=Math.abs(l.x),l.z=Math.abs(l.z),r=Math.round(l.z/l.x*n),o.domElement.clientHeight,o.cameraControls.controls.floorplan.screenshot=!0,o.flyToMode("floorplan",(function(){o.domElement.style.height=r+"px",o.domElement.style.transformOrigin="top",o.$app.core.get("SceneRenderer").updateScreenSize();o.floorplanMode(null,null,null,1.2),o.updateFromControls();var t=Math.max(n,r);n=Math.round(1024/t*n),r=Math.round(1024/t*r);for(var s,a=1/0,h=o.model.currentFloor.panos.filter((function(t){return t.isAligned()})),c=0,u=h.length;c.001&&(a=y,s=[h[c].id,h[d].id])}s&&console.log("最小距离:"+a+", panos: "+s[0]+", "+s[1]);var x=35*Math.max(l.x,l.z)/a*1.2;x>Math.max(n,r)&&(x=Math.min(8192,Math.round(x)),console.log(x),n>r?(r=Math.round(r/n*x),n=x):(n=Math.round(n/r*x),r=x)),o.$app.Camera.screenshot([{width:n,height:r}],!1).done((function(t){var s=document.createElement("canvas");s.width=n,s.height=r;var l=s.getContext("2d"),a=new Image;a.src=t[0].data,a.onload=function(){l.drawImage(a,0,0),l.font="14px sans-serif",l.fillStyle=i,l.shadowColor="rgba(0, 0, 0, 1)",l.shadowOffsetX=1,l.shadowOffsetY=1,l.shadowBlur=2,l.strokeStyle=i,l.lineWidth="2",l.textAlign="center",l.textBaseline="middle",t.o.camera.projectionMatrix.elements[5]=-t.o.camera.projectionMatrix.elements[5],h.forEach((function(e){var i=yo.getPos2d(e.position,o,t.o.camera),s=(i.vector.x+1)/2*n,a=(1-(i.vector.y+1)/2)*r;l.fillText(e.id+"",s,a-10),l.beginPath(),l.arc(s,a,1,0,2*Math.PI),l.stroke()})),yo.canvasToImg(s,.9,!0,"image/jpeg","点位图.jpg"),e()},o.domElement.style.height="",o.domElement.style.transform="",o.domElement.style.transformOrigin="",o.$app.core.get("SceneRenderer").updateScreenSize(),o.floorplanMode(),o.cameraControls.controls.floorplan.screenshot=!1}))}))}))},go.prototype.downloadCadImg=function(t,e){var o=t.toDataURL("jpg",3);o=o.replace(this._fixType("jpg"),"image/octet-stream"),this.saveFile(o,e)},go.prototype.saveFile=function(t,e){var o=document.createElementNS("http://www.w3.org/1999/xhtml","a");o.href=t,o.download=e;var i=document.createEvent("MouseEvents");i.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),o.dispatchEvent(i)},go.prototype._fixType=function(t){return"image/"+(t=t.toLowerCase().replace(/jpg/i,"jpeg")).match(/png|jpeg|bmp|gif/)[0]},go.prototype.execute=function(t,e){var o=this;switch(Kt.clearFocusItem(),Kt.clearSelectItem(),this.layer.uiControl.currentUI=null,t){case"recall":this.menu_revoke();break;case"recover":this.menu_recovery();break;case"default":this.menu_default();break;case"download":this.layer.div.style.visibility="hidden",this.menu_screenShot(e).then((function(){o.layer.div.style.visibility="visible"}));break;case"texture":this.showTexture=e,this.layer.app.dom.querySelector('.player[name="main"]').style.visibility=this.showTexture?"visible":"hidden";break;case"clear":this.menu_clear();break;case"panos":this.menu_panos(e);break;case"rotate":this.menu_rotate();break;case"flex":this.menu_flex()}},go.prototype.menu_revoke=function(){this.layer.stopAddVector(),this.layer.revokeHistory()},go.prototype.menu_recovery=function(){this.layer.recoveryHistory()},go.prototype.menu_default=function(){var t=this;Ae.clearHistoryRecord();var e=re.angle;re.setAngle(0),this.layer.app.store.getValue("metadata").floorPlanUser=0,this.layer.app.store.getValue("metadata").floorPlanAngle=0,this.menu_flex(!0);var o=ie.getScreenInfoForCAD();if(0!=e){o.floorPlanAngle=0,this.layer.app.store.getValue("metadata").floorPlanAngle=0,this.layer.app.core.get("CameraControls").emit("syncCadAnd3DForRotate",o);var i=this.layer.app.core.get("CameraControls").activeControl.camera;ie.setRes(i.left,i.right)}var n=re.getCurrentFloor();this.layer.load.loadFloorJson(!0).then((function(){t.layer.app.core.get("Player").model.floorplanCadImg.updateAllCadPlanes(),t.layer.app.core.get("Player").model.floorplanCadImg.changeModelOpacity(1),re.setCurrentFloor(n),t.layer.render(),t.layer.app.MinMap.reload(),t.layer.app.core.get("Player").labelManager.reset()}))},go.prototype.menu_screenShot=function(t){return this.layer.stopAddVector(),this.screenShot(t)},go.prototype.menu_clear=function(t){re.clear(t),Kt.clearEventName(),lo.clear(),Re.hideAll(),this.layer.history.save(),this.layer.renderer.autoRedraw()},go.prototype.menu_panos=function(t){this.layer.renderer.displayPanos=t,this.layer.renderer.autoRedraw()},go.prototype.menu_rotate=function(){ie.reSet();var t=re.getAngle();t=parseFloat(t)+Math.PI/2,Math.abs(t-2*Math.PI)<.1&&(t=0),t%=360,re.setAngle(t);var e=ie.getScreenInfoForCAD();e.floorPlanAngle=t,this.layer.app.store.getValue("metadata").floorPlanAngle=t,this.layer.app.core.get("CameraControls").emit("syncCadAnd3DForRotate",e);var o=this.layer.app.core.get("CameraControls").activeControl.camera;ie.setRes(o.left,o.right),ie.updateForRotate(),this.layer.initPanos(re.getCurrentFloor()),ae.update(!1),this.layer.history.save(),this.layer.renderer.autoRedraw()},go.prototype.menu_flex=function(t){if(ie.center){ie.reSet(),this.layer.renderer.autoRedraw();var e=ie.getScreenInfoForCAD();if(e.floorPlanAngle=re.getAngle(),this.layer.app.core.get("CameraControls").emit("syncCadAnd3D",e),t){var o=this.layer.app.core.get("CameraControls").activeControl.camera;ie.setRes(o.left,o.right)}}},Object.defineProperties(go.prototype,fo);var mo={strokeStyle:"#FFFFFF",lineWidth:4,lineWidth_out:8,important:{strokeStyle:"#FFFFFF",lineWidth:8},error:{strokeStyle:"rgba(255,0,0,0.5)",fillStyle:"rgba(255,0,0,0.8)"}},vo={strokeStyle:"green",fillStyle:"rgb(0, 200, 175)",radius:4},So={strokeStyle:"rgba(255,255,255,1)",fillStyle:"rgba(255,255,255,0)",lineWidth:1,Pass:{}},Po={strokeStyle:"rgba(255,255,255,1)",fillStyle:"rgba(255,255,255,0)",lineWidth:1},Io={strokeStyle:"rgb(255,255,255,1)",fillStyle:"rgb(255,255,255,1)",strokeStyle_adding:"rgba(243, 255, 0, 0.8)",fillStyle_adding:"rgba(243, 255, 0, 0.8)",lineWidth:1},bo={strokeStyle:"rgb(255,255,255,1)",fillStyle:"rgba(0,0,0,0)",lineWidth:1},ko={Wall:{strokeStyle:"rgba(243, 255, 0, 1)"},Wall_out:{strokeStyle:"rgba(243, 255, 0, 1)"},Symbol:{strokeStyle:"rgba(243, 255, 0, 0.8)",fillStyle:"rgba(243, 255, 0, 0.5)",lineWidth:2},Component:{strokeStyle:"rgba(243, 255, 0, 0.8)",fillStyle:"rgba(243, 255, 0, 0.5)"},Tag:{strokeStyle:"#00C8AF",fillStyle:"#00C8AF"},Furniture:{strokeStyle:"rgba(243, 255, 0, 0.8)",fillStyle:"rgba(243, 255, 0, 0.5)"},Point:{radius:4,lineWidth:2,fillStyle:"rgba(245, 255, 0, 1)",strokeStyle:"rgba(245, 255, 255, 1)"}},To={Wall:{strokeStyle:"rgba(243, 255, 0, 1)"},Wall_out:{strokeStyle:"rgba(162, 164, 124, 1)"},Symbol:{strokeStyle:"rgba(243, 255, 0, 0.8)",fillStyle:"rgba(243, 255, 0, 0.5)"},Component:{strokeStyle:"rgba(243, 255, 0, 0.8)",fillStyle:"rgba(243, 255, 0, 0.5)"},Tag:{strokeStyle:"#00C8AF",fillStyle:"#00C8AF"},Furniture:{strokeStyle:"rgba(243, 255, 0, 0.8)",fillStyle:"rgba(243, 255, 0, 0.5)"},Point:{radius:4,lineWidth:2,fillStyle:"rgba(245, 255, 0, 1)",strokeStyle:"rgba(245, 255, 255, 1)"}},Fo={StartAddWall:{radius:4,fillStyle:"yellow",strokeStyle:"green"},NewWall:{lineWidth:4,lineWidth_out:6,strokeStyle:"rgba(255,255,255,0.3)",strokeStyle_out:"rgba(102,102,102,0.3)",errorStrokeStyle:"rgb(250,63,72,0.3)"},StartSymbolPoints:{radius:4,fillStyle:"yellow",strokeStyle:"green"},EndSymbolPoints:{radius:4,fillStyle:"yellow",strokeStyle:"green"},CheckLinesX:{lineWidth:2,strokeStyle:"#CED806"},CheckLinesY:{lineWidth:2,strokeStyle:"#CED806"},VCheckLinesX:{lineWidth:2,strokeStyle:"#CED806"},VCheckLinesY:{lineWidth:2,strokeStyle:"#CED806"},SignLine1:{lineWidth:2,strokeStyle:"blue"},SignLine2:{lineWidth:2,strokeStyle:"green"}},Co={font:"14px Microsoft YaHei",fillStyle:"#FFFFFF",strokeStyle:"#FFFFFF",textAlign:"center",textBaseline:"middle",miterLimit:10,direction:"ltr"},wo={radius:10,lineWidth:2,strokeStyle:"rgba(255,255,255,0.4)",fillStyle:"rgba(255,255,255,0.1)"},Wo={txt:"rgba(255,255,255,1)",strokeStyle:"rgba(255,255,255,1)",lineWidth:1},Do={style1:{Wall:{strokeStyle:"#666666",lineWidth:4,lineWidth_out:6,important:{strokeStyle:"#666666",lineWidth:6}},Symbol:{strokeStyle:"#666666",lineWidth:1},Component:{strokeStyle:"#666666",fillStyle:"#666666",lineWidth:1},Tag:{strokeStyle:"#000000",fillStyle:"#000000",lineWidth:1},Font:{font:"14px Microsoft YaHei",fillStyle:"#000000",strokeStyle:"#000000",textAlign:"center",textBaseline:"middle",miterLimit:10,direction:"ltr"},Measure:{strokeStyle:"#CCCCCC",lineWidth:1},Furniture:{strokeStyle:"#666666",fillStyle:"#666666"}},style2:{Wall:{strokeStyle:"#FFFFFF",lineWidth:4,lineWidth_out:6,important:{strokeStyle:"#FFFFFF",lineWidth:6}},Symbol:{strokeStyle:"#FFFFFF",lineWidth:1},Component:{strokeStyle:"#FFFFFF",fillStyle:"#FFFFFF",lineWidth:1},Tag:{strokeStyle:"#FFFFFF",fillStyle:"#FFFFFF",lineWidth:1},Font:{font:"14px Microsoft YaHei",fillStyle:"#FFFFFF",strokeStyle:"#FFFFFF",textAlign:"center",textBaseline:"middle",miterLimit:10,direction:"ltr"},Measure:{strokeStyle:"#FFFFFF",lineWidth:1},Furniture:{strokeStyle:"#FFFFFF",fillStyle:"#FFFFFF"}},style3:{Wall:{strokeStyle:"#666666",lineWidth:4,lineWidth_out:6,important:{strokeStyle:"#666666",lineWidth:6}},Symbol:{strokeStyle:"#666666",lineWidth:1},Component:{strokeStyle:"#666666",fillStyle:"#666666",lineWidth:1},Tag:{strokeStyle:"#000000",fillStyle:"#000000",strokeStyle_adding:"rgba(243, 255, 0, 0.8)",fillStyle_adding:"rgba(243, 255, 0, 0.8)",lineWidth:1},Font:{font:"14px Microsoft YaHei",fillStyle:"#000000",strokeStyle:"#000000",textAlign:"center",textBaseline:"middle",miterLimit:10,direction:"ltr"},Measure:{strokeStyle:"#CCCCCC",lineWidth:2},Furniture:{strokeStyle:"#666666",fillStyle:"#666666"}},style4:{Wall:{strokeStyle:"#FFFFFF",lineWidth:4,lineWidth_out:6,important:{strokeStyle:"#FFFFFF",lineWidth:6}},Symbol:{strokeStyle:"#FFFFFF",lineWidth:1},Component:{strokeStyle:"#FFFFFF",fillStyle:"#FFFFFF",lineWidth:1},Tag:{strokeStyle:"#FFFFFF",fillStyle:"#FFFFFF",lineWidth:1},Font:{font:"14px Microsoft YaHei",fillStyle:"#FFFFFF",strokeStyle:"#FFFFFF",textAlign:"center",textBaseline:"middle",miterLimit:10,direction:"ltr"},Measure:{strokeStyle:"#FFFFFF",lineWidth:1},Furniture:{strokeStyle:"#FFFFFF",fillStyle:"#FFFFFF"}}},Lo=function(){this.whiteImg=null,this.blackImg=null};Lo.prototype.setWhiteImg=function(t){this.whiteImg=t},Lo.prototype.setBlackImg=function(t){this.blackImg=t},Lo.prototype.getWhiteImg=function(){return this.whiteImg},Lo.prototype.getBlackImg=function(){return this.blackImg};var zo=new Lo,Mo=function(){this.context=null};Mo.prototype.initContext=function(t){this.context=t?t.getContext("2d"):null},Mo.prototype.clear=function(){this.context.clearRect(0,0,this.context.canvas.width,this.context.canvas.height)},Mo.prototype.drawBackGround=function(t){this.context.save(),this.context.fillStyle=t,this.context.fillRect(0,0,this.context.canvas.width,this.context.canvas.height),this.context.restore()},Mo.prototype.drawWall=function(t,e){var o=re.getPoint(t.start),i=re.getPoint(t.end),n=[];n.push(o);for(var r=0;rthis.context.measureText(P).width?(this.context.beginPath(),this.context.moveTo(a.x,a.y),this.context.lineTo(v.x,v.y),this.context.stroke(),this.context.beginPath(),this.context.moveTo(S.x,S.y),this.context.lineTo(h.x,h.y),this.context.stroke(),this.context.save(),ie.ratio==i.ratio?this.context.font="36px Microsoft YaHei":this.context.font="12px Microsoft YaHei","style-1"==o||"style-3"==o?(this.context.fillStyle="#000000",this.context.strokeStyle="#000000"):(this.context.fillStyle="#FFFFFF",this.context.strokeStyle="#FFFFFF"),this.context.textAlign="center",this.context.textBaseline="middle",this.context.miterLimit=10,this.context.direction="ltr",c?(this.context.translate(f.x,f.y),this.context.rotate(c),this.context.fillText(P,0,0)):this.context.fillText(P,f.x,f.y),this.context.restore()):(this.context.beginPath(),this.context.moveTo(a.x,a.y),this.context.lineTo(h.x,h.y),this.context.stroke())}else{var I=s.getDistance(t[l],t[l+1]);I="ft"==ae.unit?" "+xe.convert(I,"distance",void 0,"imperial",.01,!0)+" ":s.getFixed(I,2)+"m",s.getDistance(a,h)>this.context.measureText(I).width?(this.context.beginPath(),this.context.moveTo(a.x,a.y),this.context.lineTo(S.x,S.y),this.context.stroke(),this.context.beginPath(),this.context.moveTo(v.x,v.y),this.context.lineTo(h.x,h.y),this.context.stroke(),this.context.save(),ie.ratio==i.ratio?this.context.font="36px Microsoft YaHei":this.context.font="12px Microsoft YaHei","style-1"==o||"style-3"==o?(this.context.fillStyle="#000000",this.context.strokeStyle="#000000"):(this.context.fillStyle="#FFFFFF",this.context.strokeStyle="#FFFFFF"),this.context.textAlign="center",this.context.textBaseline="middle",this.context.miterLimit=10,this.context.direction="ltr",c?(this.context.translate(f.x,f.y),this.context.rotate(c),this.context.fillText(I,0,0)):this.context.fillText(I,f.x,f.y),this.context.restore()):(this.context.beginPath(),this.context.moveTo(a.x,a.y),this.context.lineTo(h.x,h.y),this.context.stroke())}}}this.context.restore()},Mo.prototype.drawMeasureTxt=function(t,e){var o=ie.getScreenXY(t),i=ie.getScreenXY(e),n=s.createLine1(o,i);if(null!=n){var r={x:(o.x+i.x)/2,y:(o.y+i.y)/2},l=s.getParallelLineForDistance(n,10),a=null,h=s.getJoinLinePoint(r,l.line1),c=s.getJoinLinePoint(r,l.line2);r.yg.x?s.clonePoint(r,g):p.y0&&(r=l[0].side?this.updateCenterForComponentFurniture2(l[0].vectorId,l[0].type,l[0].side,r):this.updateCenterForComponentFurniture(l[0].vectorId,l[0].type,l[0].sideIndex,l[0].selfSideIndex,r,n,l[0].distance),ut.isComponent(o)?n=ut.getBoundingVertexs(e,r):Gt.isFurniture(o)&&(n=i.getBoundingVertexs(r)),l.length>1&&(r=l[1].side?this.updateCenterForComponentFurniture2(l[1].vectorId,l[1].type,l[1].side,r):this.updateCenterForComponentFurniture(l[1].vectorId,l[1].type,l[1].sideIndex,l[1].selfSideIndex,r,n,l[1].distance))),l.length<2){var a=this.getNearWalls(n);a.length>0&&(r=this.updateCenterForWall(a[0].vectorId,a[0].selfSideIndex,r,n,a[0].distance),ut.isComponent(o)?n=ut.getBoundingVertexs(e,r):Gt.isFurniture(o)&&(n=i.getBoundingVertexs(r)),0==l.length&&a.length>1&&(r=this.updateCenterForWall(a[1].vectorId,a[1].selfSideIndex,r,n,a[1].distance)))}return r.x=s.getFixed(r.x),r.y=s.getFixed(r.y),s.clonePoint(i.center,r),ut.isComponent(o)&&i.setPoints2d(),null},Oo.prototype.isInScreen=function(t){return t.x>this.screenPoints[0].x&&t.xthis.screenPoints[3].y},Oo.prototype.getNearWalls=function(t){var e=[],o=s.createLine1(t[0],t[1]),n=s.createLine1(t[1],t[2]),r=s.createLine1(t[2],t[3]),l=s.createLine1(t[3],t[0]),a=re.getWalls(),c=null,u=null,d=null,y=null,x=null,p=null;for(var g in a){var f=a[g],m=null;m=f.out?mo.lineWidth_out/ie.res/2*i.defaultZoom/ie.zoom:mo.lineWidth/ie.res/2*i.defaultZoom/ie.zoom;var v=re.getPoint(f.start),S=re.getPoint(f.end),P=s.createLine1(v,S),I=null,b=null,k=null,T=null;if(this.isParallel(o,P)&&this.isCloseForTwoSegments(t[0],t[1],v,S)?(I=s.getDisForPoinLine(t[0],P),I-=m,b=[0,1],this.isAdsorb(I)||(I=null,b=null)):this.isParallel(n,P)&&this.isCloseForTwoSegments(t[1],t[2],v,S)&&(k=s.getDisForPoinLine(t[1],P),k-=m,T=[1,2],this.isAdsorb(k)||(k=null,T=null)),this.isParallel(r,P)&&this.isCloseForTwoSegments(t[2],t[3],v,S)){var F=s.getDisForPoinLine(t[2],P);F-=m,this.isAdsorb(F)&&(null==I||FI)&&(c=I,u=b,d=g):null!=k&&(null==y||y>k)&&(y=k,x=T,p=g))}return null!=c&&e.push({vectorId:d,type:h,distance:c,selfSideIndex:u}),null!=y&&e.push({vectorId:p,type:h,distance:y,selfSideIndex:x}),e},Oo.prototype.getNearComponentsFurnitures=function(t,e){var o=s.createLine1(e[0],e[1]),i=s.createLine1(e[1],e[2]),n=[],r=re.getComponents(),l=re.getFurnitures(),a=(e[0].x+e[1].x+e[2].x+e[3].x)/4,h=(e[0].y+e[1].y+e[2].y+e[3].y)/4,c=null,u=null,d=null,y=null,x=null,p=null,g=null,f=null,m=null,v=null,S=null,P=null,I=null,b=null,k=null,T=null;for(var F in r)if(F!=t){var C=r[F];if(this.isInScreen(C.center)){var w=s.createLine1(C.points2d[0],C.points2d[1]),W=s.createLine1(C.points2d[1],C.points2d[2]),D=s.createLine1(C.points2d[2],C.points2d[3]),L=s.createLine1(C.points2d[3],C.points2d[0]),z=null,M=null,R=null,O=null;if(this.isParallel(o,w)&&this.isCloseForTwoSegments(e[0],e[1],C.points2d[0],C.points2d[1])){z=s.getDisForPoinLine(e[0],w),M=s.getDisForPoinLine(e[0],D),R=s.getDisForPoinLine(e[3],w),O=s.getDisForPoinLine(e[3],D);var A=Math.min(z,M,R,O);this.isAdsorb(A)&&(null==y||y>A)&&(A==z?(c=F,x=C.geoType,u=[0,1],d=[0,1],y=A):A==M?(c=F,x=C.geoType,u=[2,3],d=[0,1],y=A):A==R?(c=F,x=C.geoType,u=[0,1],d=[2,3],y=A):A==O&&(c=F,x=C.geoType,u=[2,3],d=[2,3],y=A))}if(this.isParallel(i,W)&&this.isCloseForTwoSegments(e[1],e[2],C.points2d[1],C.points2d[2])){z=s.getDisForPoinLine(e[1],W),M=s.getDisForPoinLine(e[1],L),R=s.getDisForPoinLine(e[0],W),O=s.getDisForPoinLine(e[0],L);var E=Math.min(z,M,R,O);this.isAdsorb(E)&&(null==m||m>E)&&(E==z?(p=F,v=C.geoType,g=[1,2],f=[1,2],m=E):E==M?(p=F,v=C.geoType,g=[0,3],f=[1,2],m=E):E==R?(p=F,v=C.geoType,g=[1,2],f=[0,3],m=E):E==O&&(p=F,v=C.geoType,g=[0,3],f=[0,3],m=E))}this.isAdsorb(Math.abs(C.center.x-a))&&(null==P||P>Math.abs(C.center.x-a))&&(S=F,I=C.geoType,P=Math.abs(C.center.x-a)),this.isAdsorb(Math.abs(C.center.y-h))&&(null==k||k>Math.abs(C.center.y-h))&&(b=F,T=C.geoType,k=Math.abs(C.center.y-h))}}for(var B in l)if(B!=t){var Y=l[B];if(this.isInScreen(Y.center)){Y.points2d=Y.getBoundingVertexs(Y.center);var N=s.createLine1(Y.points2d[0],Y.points2d[1]),X=s.createLine1(Y.points2d[1],Y.points2d[2]),j=s.createLine1(Y.points2d[2],Y.points2d[3]),_=s.createLine1(Y.points2d[3],Y.points2d[0]),U=null,J=null,V=null,H=null;if(this.isParallel(o,N)&&this.isCloseForTwoSegments(e[0],e[1],Y.points2d[0],Y.points2d[1])){U=s.getDisForPoinLine(e[0],N),J=s.getDisForPoinLine(e[0],j),V=s.getDisForPoinLine(e[3],N),H=s.getDisForPoinLine(e[3],j);var Z=Math.min(U,J,V,H);this.isAdsorb(Z)&&(null==y||y>Z)&&(Z==U?(c=B,x=Y.geoType,u=[0,1],d=[0,1],y=Z):Z==J?(c=B,x=Y.geoType,u=[2,3],d=[0,1],y=Z):Z==V?(c=B,x=Y.geoType,u=[0,1],d=[2,3],y=Z):Z==H&&(c=B,x=Y.geoType,u=[2,3],d=[2,3],y=Z))}if(this.isParallel(i,X)&&this.isCloseForTwoSegments(e[1],e[2],Y.points2d[1],Y.points2d[2])){U=s.getDisForPoinLine(e[1],X),J=s.getDisForPoinLine(e[1],_),V=s.getDisForPoinLine(e[0],X),H=s.getDisForPoinLine(e[0],_);var G=Math.min(U,J,V,H);this.isAdsorb(G)&&(null==m||m>G)&&(G==U?(p=B,v=Y.geoType,g=[1,2],f=[1,2],m=G):G==J?(p=B,v=Y.geoType,g=[0,3],f=[1,2],m=G):G==V?(p=B,v=Y.geoType,g=[1,2],f=[0,3],m=G):G==H&&(p=B,v=Y.geoType,g=[0,3],f=[0,3],m=G))}this.isAdsorb(Math.abs(Y.center.x-a))&&(null==P||P>Math.abs(Y.center.x-a))&&(S=B,I=Y.geoType,P=Math.abs(Y.center.x-a)),this.isAdsorb(Math.abs(Y.center.y-h))&&(null==k||k>Math.abs(Y.center.y-h))&&(b=B,T=Y.geoType,k=Math.abs(Y.center.y-h))}}return null!=y&&(o.hasOwnProperty("x")&&null!=P?(y>=P&&(n.push({vectorId:S,type:I,distance:P,side:"x"}),y=null),P=null):o.hasOwnProperty("y")&&null!=k&&(y>=k&&(n.push({vectorId:b,type:T,distance:k,side:"y"}),y=null),k=null),null!=y&&n.push({vectorId:c,type:x,distance:y,sideIndex:u,selfSideIndex:d})),null!=m&&(i.hasOwnProperty("x")&&null!=P?(m>=P&&(n.push({vectorId:S,type:I,distance:P,side:"x"}),m=null),P=null):i.hasOwnProperty("y")&&null!=k&&(m>=k&&(n.push({vectorId:b,type:T,distance:k,side:"y"}),m=null),k=null),null!=m&&n.push({vectorId:p,type:v,distance:m,sideIndex:g,selfSideIndex:f})),0==n.length?(null!=P&&n.push({vectorId:S,type:I,distance:P,side:"x"}),null!=k&&n.push({vectorId:b,type:T,distance:k,side:"y"})):1==n.length&&(null!=P?n.push({vectorId:S,type:I,distance:P,side:"x"}):null!=k&&n.push({vectorId:b,type:T,distance:k,side:"y"})),n},Oo.prototype.isAdsorb=function(t){return t0){var h=Object.keys(this.adsorbPointWalls)[0],c=re.getWall(this.adsorbPointWalls[h]).getOtherPointId(t),u=re.getPoint(c),d=re.getPoint(h),y=s.createLine1(u,d);e=s.getJoinLinePoint(e,y),n.setPosition(e)}return!1}var x=null;if(null==o){var p=st.getNeighPoints(t);if(1==p.length?x=Re.checkAngle(e,p[0].vectorId,t):2==p.length&&((x=Re.checkAngle(e,p[0].vectorId,t))||(x=Re.checkAngle(e,p[1].vectorId,t))),x){if(!(a=this.canMoveForPoint(t,x,r,l)))return!1;s.clonePoint(e,x)}n.setPosition(e)}else if(o.hasOwnProperty("linkedPointId")&&null!=o.linkedPointId){if(null!=st.getWallId(t,o.linkedPointId))return!1;n.setPosition(o),this.needUpdateRoom=!0}else if(o.hasOwnProperty("linkedWallId")){var g=re.getWall(o.linkedWallId),f=re.getPoint(g.start),m=re.getPoint(g.end);if(s.getDistance(f,e)1&&1==Object.keys(c.parent).length||1==Object.keys(h.parent).length&&1==Object.keys(c.parent).length?st.moveTo(a,l):1==Object.keys(h.parent).length&&Object.keys(c.parent).length>1&&st.moveTo(l,a),this.moveFlag=!1,n=3,this.needUpdateRoom=!0,n):(this.moveFlag=!1,n=3,this.needUpdateRoom=!0,n);if(l=r.start,a=r.end,!this.isOKForCrossForMoveWall(x,p,t,l,a,g.adsorbPointId,f.adsorbPointId))return n=2,this.moveFlag=!1,this.setStartMoving(!1),n;if(m||null!=v&&vi.maxAngle/180*Math.PI&&(o=s.getVerticalLine(c,a),u.startWallId=null,u.newStartWallId=!0)}else{var x,p;r=st.wallIdForMinAngle(l.start,t);var g=re.getWall(r.min0.wallId),f=re.getPoint(g.start),m=re.getPoint(g.end),v=re.getWall(r.min1.wallId),S=re.getPoint(v.start),P=re.getPoint(v.end),I=s.getIntersectionPoint4(f,m,e),b=s.getIntersectionPoint4(S,P,e);if(null==I&&null==b){var k=st.AngleForWall(t,r.min0.wallId),T=st.AngleForWall(t,r.min1.wallId);k>Math.PI&&(k=Math.PI-k),T>Math.PI&&(T=Math.PI-T),p=ki.maxAngle/180*Math.PI||!s.isPointOnSegment(C,w,W))&&(o=s.getVerticalLine(c,a),u.startWallId=null,u.newStartWallId=!0)}if(1==Object.keys(h.parent).length)n=s.getVerticalLine(c,h),u.endWallId=null;else if(2==Object.keys(h.parent).length){var D;Object.keys(h.parent)[0]==t?D=re.getWall(Object.keys(h.parent)[1]):Object.keys(h.parent)[1]==t&&(D=re.getWall(Object.keys(h.parent)[0]));var L=st.AngleForWall(D.vectorId,t);n=st.getLine(D),u.endWallId=D.vectorId,L>i.maxAngle/180*Math.PI&&(n=s.getVerticalLine(c,h),u.endWallId=null,u.newEndWallId=!0)}else{var z,M;r=st.wallIdForMinAngle(l.end,t);var R=re.getWall(r.min0.wallId),O=re.getPoint(R.start),A=re.getPoint(R.end),E=re.getWall(r.min1.wallId),B=re.getPoint(E.start),Y=re.getPoint(E.end),N=s.getIntersectionPoint4(O,A,e),X=s.getIntersectionPoint4(B,Y,e);if(null==N&&null==X){var j=st.AngleForWall(t,r.min0.wallId),_=st.AngleForWall(t,r.min1.wallId);j>Math.PI&&(j=Math.PI-j),_>Math.PI&&(_=Math.PI-_),M=j<_?r.min0.wallId:r.min1.wallId,u.newEndWallId=!0}else null!=N&&null!=X?M=r.min0.anglei.maxAngle/180*Math.PI||!s.isPointOnSegment(J,V,H))&&(n=s.getVerticalLine(c,h),u.endWallId=null,u.newEndWallId=!0)}return u.startLimitLine=o,u.endLimitLine=n,u},Yo.prototype.canMoveForPoint=function(t,e,o,i){var n=re.getPoint(t),r=this.isOKForMinAngleWall(t,e);return r&&(r=this.isOKForCross(t,e,n.parent,o,i)),r},Yo.prototype.isOKForMinAngleWall=function(t,e){var o=re.getPoint(t).parent,n=this.getMinAngle(t,e);if(Math.abs(n)Math.PI){var I=2*Math.PI+S-P;Iu)&&(h={angle:a=u,pointId:r})}return h},Yo.prototype.isOKForCross=function(t,e,o,i,n){var r=re.getWalls();for(var s in r)if(!o.hasOwnProperty(s)&&n!=s)for(var l in o)if(!st.isWallLink(s,l)){var a=re.getWall(l),h=a.getOtherPointId(t),c=re.getPoint(h);if(!this.isOKForCrossTwoWall(e,c,s,i,n,a.vectorId))return this.adsorbPointWalls={},!1}return!(Object.keys(this.adsorbPointWalls).length>0)&&null==this.splitWallId},Yo.prototype.isOKForCrossTwoWall=function(t,e,o,n,r,l){var a=re.getWall(o),h=re.getPoint(a.start),c=re.getPoint(a.end);if(s.getIntersectionPoint3(t,e,h,c)&&a.start!=n&&a.end!=n)return this.splitWallId=o,!0;if(s.equalPoint(t,e))return!0;var u=s.createLine1(t,e),d=s.getJoinLinePoint(h,u),y=s.getJoinLinePoint(c,u);if(s.getDistance(d,h)i.maxAngle/180*Math.PI)s.setPosition(o.virtualPosition);else{var c=st.getDirction(e,t);st.subtraWallFromIntersect(e,t);var u=l.getPointId(c);re.getPoint(u).setPosition(o.virtualPosition),st.splitWall(n,u,c),this.needUpdateRoom=!0}}},Yo.prototype.createWallForMoveWall=function(t,e,o){var i=re.getWall(e),n=st.getDirction(t,e);st.subtraWallFromIntersect(t,e);var r=i.getPointId(n);re.getPoint(r).setPosition(o),st.createWall(t,r)},Yo.prototype.deleteWallForLinked=function(t){var e=re.getWall(t);st.subtraWallFromIntersect(e.start,t),st.subtraWallFromIntersect(e.end,t),re.deleteWall(t)};var No=new Yo,Xo=function(t){this.layer=t,this.displayPanos=!1};Xo.prototype.drawGeometry=function(t,e,o){if(null!=Ro.context){switch(t.geoType){case h:return void Ro.drawWall(t,e);case l:return void Ro.drawPoint(t);case c:return void Ro.drawSingleDoor(t,e,o);case u:return void Ro.drawDoubleDoor(t,e,o);case d:return void Ro.drawSlideDoor(t,e,o);case y:return void Ro.drawSingleWindow(t,e);case p:return void Ro.drawFrenchWindow(t,e);case x:return void Ro.drawBayWindow(t,e);case g:return void Ro.drawPass(t,e);case f:return void Ro.drawBeam(t,e);case m:return void Ro.drawFlue(t,e);case v:return void Ro.drawCorridor(t,e);case P:return void Ro.drawTag(t,e,o)}Gt.isFurniture(t.geoType)&&Ro.drawFurniture(t,e)}},Xo.prototype.drawElement=function(t){if(null!=Ro.context)switch(t.geoType){case l:Ro.drawCircle(t);break;case S:Ro.drawLine(t)}},Xo.prototype.drawPanos=function(t){for(var e=0;e0?(this.layer.$xui.toolbar.clear=!0,this.layer.$xui.toolbar.download=!0):(this.layer.$xui.toolbar.clear=!1,this.layer.$xui.toolbar.download=!1)},ui.prototype.save=function(){if(ci.operate()){ae.update(!1),Ae.addHistoryRecord(ci.elements),ci.saveCurrentInfo(),this.setState(),Ae.getHistoryState().pre&&(this.layer.$xui.toolbar.recall=!0),this.layer.$xui.toolbar.recover=!1;var t=re.getPoints();return Object.keys(t).length>0?(this.layer.$xui.toolbar.clear=!0,this.layer.$xui.toolbar.download=!0):(this.layer.$xui.toolbar.clear=!1,this.layer.$xui.toolbar.download=!1),this.layer.emit("change"),ci.elements}},ui.prototype.setState=function(){var t={pre:0,next:0},e=Ae.getCurrentRecordIndex(),o=Ae.getHistoryRecords();e>-1&&(t.pre=1),e0?(this.layer.$xui.toolbar.clear=!0,this.layer.$xui.toolbar.download=!0):(this.layer.$xui.toolbar.clear=!1,this.layer.$xui.toolbar.download=!1)}else console.error("goPreState超出范围!")},ui.prototype.goPreForPoints=function(t){for(var e=0;e0?(this.layer.$xui.toolbar.clear=!0,this.layer.$xui.toolbar.download=!0):(this.layer.$xui.toolbar.clear=!1,this.layer.$xui.toolbar.download=!1)}else Ae.undoHistoryRecord(),console.error("goNextState超出范围!")};var di={export:{Wall:{strokeStyle:"#70707a",fillStyle:"#70707a",lineWidth:7,lineWidth_out:10},Symbol:{strokeStyle:"rgba(37,40,40,0.5)",fillStyle:"rgba(0,0,0,0.1)",lineWidth:1},Component:{strokeStyle:"rgba(37,40,40,0.5)",fillStyle:"rgba(0,0,0,0.1)",lineWidth:1},Font:[{font:"bold 14px Microsoft YaHei",fillStyle:"rgb(65,65,65)",screen:{x:520,y:856},text:"© "},{font:"bold 14px Microsoft YaHei",fillStyle:"#70707a",screen:{x:538,y:855},text:"版权归58同城、赶集网、安居客、四维时代、正顺所有"},{font:"bold 14px Microsoft YaHei",fillStyle:"rgb(65,65,65)",screen:{x:30,y:840},text:["单位:毫米(mm)","提示:户型图中所有室内装饰、设计、摆设、间隔、尺寸、设备仅供参考。","具体房源标准以室内查勘和测量为准。"]}],compass:{screen:{x:66,y:88}},BackGround:{fillStyle:"#FFFFFF"}},cover:{Wall:{strokeStyle:"#70707a",fillStyle:"#70707a"},Symbol:{strokeStyle:"rgba(37,40,40,0.5)",fillStyle:"rgba(0,0,0,0.1)",lineWidth:1},Component:{strokeStyle:"rgba(37,40,40,0.5)",fillStyle:"rgba(0,0,0,0.1)",lineWidth:1}},default:{Wall:{strokeStyle:"#70707a",fillStyle:"#70707a"},Symbol:{strokeStyle:"rgba(37,40,40,0.5)",fillStyle:"rgba(0,0,0,0.1)",lineWidth:1},Component:{strokeStyle:"rgba(37,40,40,0.5)",fillStyle:"rgba(0,0,0,0.1)",lineWidth:1}},Font:{font:"12px Microsoft YaHei",fillStyle:"rgba(0,0,0,1)",textAlign:"center",textBaseline:"middle",miterLimit:10,direction:"ltr"},Measure:{strokeStyle:"#70707a"}},yi=function(){this.context=null};yi.prototype.initContext=function(t){this.context=t},yi.prototype.clear=function(){this.context.clearRect(0,0,this.context.canvas.width,this.context.canvas.height)},yi.prototype.drawWall=function(t,e){var o=re.getPoint(t.start),i=re.getPoint(t.end),n=[];n.push(o);for(var r=0;r-1?xi.drawRoomBackGround(t.pointIds,this.imgCache.room1):this.roomInfo2.indexOf(t.name)>-1?xi.drawRoomBackGround(t.pointIds,this.imgCache.room2):(this.roomInfo3.indexOf(t.name),xi.drawRoomBackGround(t.pointIds,this.imgCache.room3)),"export"==this.type&&t.name&&(xi.drawText(t.center,t.name,!1,0),null!=t.area&&""!=t.area.trim()&&xi.drawText({x:t.center.x,y:t.center.y-16/ie.res},t.area+"m²",!1,0))};var gi=new pi,fi=function(t,e){this.app=t.app,this.layer=t,gi.layer=t,this.ajkJson={},this.cameraJson={},this.floorPlanJson={},this.getCameraJson(e),this.loadImg()};fi.prototype.loadImg=function(){this.app.store.getAppImage("images/ajk/cad_compass_ajk.png").then((function(t){gi.imgCache.compass=t})),this.app.store.getAppImage("images/ajk/room1_ajk.png").then((function(t){gi.imgCache.room1=t})),this.app.store.getAppImage("images/ajk/room2_ajk.png").then((function(t){gi.imgCache.room2=t})),this.app.store.getAppImage("images/ajk/room3_ajk.png").then((function(t){gi.imgCache.room3=t})),gi.roomInfo1=["书房","厨房","卫生间","多功能室","阳台","储物间","步入式衣柜","外景","露台(无顶)","影视间","入房花园"],gi.roomInfo2=["主卧","儿童房","次卧","客卧","老人房","卧室"],gi.roomInfo3=["整套","客厅","走廊","餐厅","起居室","客餐厅","玄关","门厅"]},fi.prototype.start=function(){var t=this;return new Promise((function(e,o){ro.start(),t.getFloorPlanJson().then((function(i){t.floor=i,re.updateBoundingBox(),gi.init();var n=re.getTags();if(0!=Object.keys(n).length)if(r=t.getAJKRooms(n)){var r=t.getEntrance();r?(t.getSceneName(),t.getPictureRotate(),t.getImgInfo(),t.layer.renderer.clear(),gi.start(),e({ajkJson:t.ajkJson,cameraJson:t.cameraJson,floorPlanJson:{floors:[t.floor.floors[0]]},files:{bgmgdCZp_anjuke:gi.anjuke,bgmgdCZp_anjuke_cover:gi.anjuke_cover,bgmgdCZp_anjuke_export:gi.anjuke_export}})):o({type:"toast",msg:"平面图至少包含要给入户门,且入户门应为单开门"})}else o({type:"toast",msg:"标注应包含房间名称、面积"});else o({type:"toast",msg:"平面图应至少包含一个标注"})}))}))},fi.prototype.getAJKRooms=function(t){gi.rooms=[];var e=re.getRooms();this.ajkJson.rooms=this.createAjkRoomForTag(t);for(var o=[],i=0;i-1))if(e[r].containPoint(this.ajkJson.rooms[i].labelPos)){o.push(r),console.log("匹配:"+this.ajkJson.rooms[i].name+"&"+e[r].tagName),gi.rooms.push({center:JSON.parse(JSON.stringify(this.ajkJson.rooms[i].labelPos)),pointIds:JSON.parse(JSON.stringify(e[r].wallPointIDs)),name:this.ajkJson.rooms[i].name,area:this.ajkJson.rooms[i].area});break}}n==gi.rooms.length&&(this.ajkJson.rooms.splice(i,1),--i)}return this.setRoomsGroup(),!0},fi.prototype.getCameraJson=function(t){this.cameraJson={},this.cameraJson.sweepLocations=[];for(var e=0;eMath.PI/2&&(l.add(c.clone().multiplyScalar(r.distanceTo(s))),c.multiplyScalar(-1)),l.add(c.clone().multiplyScalar(-.5));var u={Position:new THREE.Vector3(l.x,-l.z,l.y),Direction:new THREE.Vector3(c.x,-c.z,c.y)};return this.ajkJson.Entrance=u,!0}return!1},fi.prototype.getSceneName=function(){var t=this.app.store.getValue("metadata");this.ajkJson.scene_name=t.title},fi.prototype.getPictureRotate=function(){var t=re.getAngle(),e=new THREE.Euler(0,t,0),o=new THREE.Vector3(0,0,-1);o.applyEuler(e),o=new THREE.Vector3(o.x,-o.z,o.y),this.ajkJson.picture_rotate=o},fi.prototype.getFootPoint=function(t,e,o,i){var n=t.clone().sub(e),r=e.clone().sub(o),s=r.length(),l=n.dot(r)/s,a=e.clone().add(r.multiplyScalar(l/s));return i&&a.clone().sub(e).dot(a.clone().sub(o))>0&&(a=a.distanceTo(e)1&&(Kt.clearEventName(),lo.clear(),this.uiControl.clearUI(),Re.hideAll())}break;case Xe:if(null!=r&&r.type==h){var u=re.getWall(r.vectorId);u.import||u.out?this.uiControl.currentUI="OutWall":this.uiControl.currentUI=r.type,this.history.save()}else this.history.save();No.setStartMoving(!1);break;case _e:if(null==n)return void this.setEventName("mouseUp");r={vectorId:n.vectorId,type:n.type,cursor:{x:this.lastX,y:this.lastY}},Kt.setFocusItem(r),this.uiControl.showAttributes(),this.uiControl.currentUI=r.type,this.history.save();break;case Ue:l=re.getSymbol(n.vectorId),null!=r&&ee.isSymbol(r.type)?(this.uiControl.currentUI=r.type,this.history.save()):l&&(l.len=null,this.history.save());break;case Je:null!=r&&ee.isSymbol(r.type)?(this.uiControl.currentUI=r.type,this.history.save()):this.history.save();break;case Ve:Re.hideSignLine1(),Re.hideSignLine2(),Ao.clear(),r={vectorId:n.vectorId,type:n.type,cursor:{x:this.lastX,y:this.lastY}},Kt.setFocusItem(r),this.uiControl.showAttributes(),this.uiControl.currentUI=r.type,this.history.save();break;case He:Re.hideSignLine1(),Re.hideSignLine2(),Ao.clear(),null!=r&&ut.isComponent(r.type)?(this.uiControl.currentUI=r.type,this.history.save()):this.history.save(),Re.hideAll();break;case Ge:null!=r&&r.type==P?(this.uiControl.currentUI=r.type,this.history.save()):this.history.save();break;case Ze:re.getTag(n.vectorId).setAdding(!1),r={vectorId:n.vectorId,type:n.type,cursor:{x:this.lastX,y:this.lastY}},Kt.setFocusItem(r),this.history.save(),this.uiControl.currentUI=r.type;break;case $e:Re.hideSignLine1(),Re.hideSignLine2(),Ao.clear(),r={vectorId:n.vectorId,type:n.type,cursor:{x:this.lastX,y:this.lastY}},Kt.setFocusItem(r),this.uiControl.showAttributes(),this.uiControl.currentUI=r.type,this.history.save();break;case Ke:Re.hideSignLine1(),Re.hideSignLine2(),Ao.clear(),null!=r&&Gt.isFurniture(r.type)?(this.uiControl.currentUI=r.type,this.history.save()):this.history.save()}this.setEventName("mouseUp"),Kt.clearDraggingItem(),this.renderer.autoRedraw()}},e.prototype.onWheel=function(t){if(null!=ie.defaultCenter){t.preventDefault();var e=t.type;if("DOMMouseScroll"==e||"mousewheel"==e){var o=t.wheelDelta?t.wheelDelta/120*20:-(t.detail||0)/3*20,i=ie.zoom+o;if(i<14)return;ie.updateZoom(i);var n=ie.getScreenInfoForCAD();n.floorPlanAngle=re.getAngle(),this.app.core.get("CameraControls").emit("syncCadAnd3D",n),this.renderer.autoRedraw()}}},e.prototype.onKeydown=function(t){if(this.display)if(t.ctrlKey&&"KeyZ"==t.code){if(this.stopAddVector(),!this.$xui.toolbar.recall)return void this.renderer.autoRedraw();if("image"==this.app.store.getValue("flooruser").type)return void this.renderer.autoRedraw();this.revokeHistory(),console.log("ctrl+z")}else if(t.ctrlKey&&"KeyY"==t.code){if(!this.$xui.toolbar.recover)return;this.recoveryHistory(),console.log("ctrl+y")}else if("Delete"==t.code)this.deleteItem(),this.uiControl.currentUI=null,this.history.save(),this.renderer.autoRedraw(),console.log("Delete");else if("Escape"==t.code)this.stopAddVector(),this.renderer.autoRedraw(),console.log("Esc");else{var e=Kt.getFocusItem(),o=Kt.getDraggingItem();e&&!o&&t.ctrlKey&&"KeyC"==t.code&&(Pi.copy(e,this.mousePosition),this.renderer.autoRedraw(),this.history.save())}},e.prototype.updateEventNameForSelectUI=function(){if(Re.hideAll(),Kt.getEventName()==Ze){var t=Kt.getDraggingItem();t&&t.type==P&&re.deleteTag(t.vectorId)}Kt.clearItems(),this.uiControl.selectUI==yt||this.uiControl.selectUI==xt?Kt.setEventName(Ye):this.uiControl.selectUI==pt||this.uiControl.selectUI==gt||this.uiControl.selectUI==ft||this.uiControl.selectUI==mt||this.uiControl.selectUI==vt||this.uiControl.selectUI==St||this.uiControl.selectUI==Pt?Kt.setEventName(_e):this.uiControl.selectUI==It||this.uiControl.selectUI==bt||this.uiControl.selectUI==kt?Kt.setEventName(Ve):this.uiControl.selectUI==Tt?Kt.setEventName(Ze):this.uiControl.selectUI!=Ft&&this.uiControl.selectUI!=Ct&&this.uiControl.selectUI!=wt&&this.uiControl.selectUI!=Wt&&this.uiControl.selectUI!=Dt&&this.uiControl.selectUI!=Lt&&this.uiControl.selectUI!=zt&&this.uiControl.selectUI!=Mt&&this.uiControl.selectUI!=Rt&&this.uiControl.selectUI!=Ot&&this.uiControl.selectUI!=At&&this.uiControl.selectUI!=Et&&this.uiControl.selectUI!=Bt&&this.uiControl.selectUI!=Yt&&this.uiControl.selectUI!=Nt&&this.uiControl.selectUI!=Xt&&this.uiControl.selectUI!=jt&&this.uiControl.selectUI!=_t&&this.uiControl.selectUI!=Ut&&this.uiControl.selectUI!=Jt&&this.uiControl.selectUI!=Vt||Kt.setEventName($e)},e.prototype.setEventName=function(t){var e=Kt.getEventName();if("mouseDown"==t)if(null==e){var o=Kt.getSelectItem();if(null==o)Kt.setEventName(Be);else if(o.type==h)Kt.setEventName(Xe);else if(o.type==a)Kt.setEventName(je);else if(ee.isSymbol(o.type))if(o.selectIndex==_||o.selectIndex==V){Kt.setEventName(Ue);var i=re.getSymbol(o.vectorId);i.len=s.getDistance(i.startPoint,i.endPoint)}else o.selectIndex!=U&&o.selectIndex!=J||Kt.setEventName(Je);else ut.isComponent(o.type)?Kt.setEventName(He):o.type==P?Kt.setEventName(Ge):Gt.isFurniture(o.type)&&Kt.setEventName(Ke)}else e==Ye&&Kt.setEventName(Ne);else"mouseUp"==t&&(e==Ze||e!=Ye&&e!=Ne&&Kt.clearEventName())},e.prototype.exit=function(){Kt.clearItems(),Kt.clearEventName(),this.uiControl.clearUI()},e.prototype.stopAddVector=function(){var t=Kt.getEventName();if(t!=Ne){Kt.clearEventName();var e=Kt.getDraggingItem();t==_e?e&&e.vectorId&&(ee.deleteSymbol(e.vectorId),Kt.clearDraggingItem()):t==Ve?e&&e.vectorId&&re.deleteComponent(e.vectorId):t==Ze?e&&e.vectorId&&(ge.deleteTag(e.vectorId),this.uiControl.currentUI=null):t==$e&&e&&e.vectorId&&re.deleteFurniture(e.vectorId)}else Kt.setEventName(Ye);this.uiControl.clearUI(),Re.hideAll()},e.prototype.setNewWallPoint=function(t,e){return"select"!=ze.symbolInfo.state&&(("start"==t||"end"==t)&&(ze.modifyPoint?lo.setPointInfo(t,ze.modifyPoint):lo.setPointInfo(t,ie.getXYFromScreen(e)),!0))},e.prototype.reload=function(){var t=this;Ae.clearHistoryRecord(),this.$xui.toolbar.recall=!1,this.$xui.toolbar.recover=!1,re.clear(),ie.clear(),Kt.clearItems(),Kt.clearEventName(),this.stopAddVector();var e=re.getCurrentFloor();return this.load.loadFloorJson(!0).then((function(){var o=t.app.store.getValue("flooruser");t.app.store.getValue("metadata").floorPlanAngle=o.angle||0,t.app.core.get("Player").model.floorplanCadImg.updateAllCadPlanes(),"image"==o.type?(t.initCoordinate(),t.player.model.floorplanCadImg.displayCadPlane(!0),t.player.model.floorplanCadImg.showCadPlane()):(t.app.core.get("Player").model.floorplanCadImg.hideCadPlane(),t.reRender()),re.setCurrentFloor(e),t.renderer.autoRedraw()}))},e.prototype.update=function(){var t=this;this.app.store.getValue("metadata").floorPlanUser=1,this.app.MinMap.reload().then((function(){"image"==t.app.store.getValue("flooruser").type?re.clear():(t.app.core.get("Player").model.floorplanCadImg.updateAllCadPlanes(),t.renderer.autoRedraw())})),this.div.style.visibility="visible"},e.prototype.exportImages=function(){this.div.style.visibility="hidden",this.stopAddVector();var t=re.getFloorData();return 0==Object.keys(t.points).length&&0==Object.keys(t.components).length&&0==Object.keys(t.tags).length&&0==Object.keys(t.furnitures).length?(this.div.style.visibility="visible",null):this.load.uploadCad()},e.prototype.exportJSON=function(t,e){if(e){var i=JSON.parse(JSON.stringify(o.floors));e.forEach((function(t,e){t.boundingBox=i[e].boundingBox}))}ro.start(),this.app.store.getValue("flooruser").cadInfo=t;var n=JSON.parse(JSON.stringify(e||o.floors));n.sort((function(t,e){return t.id-e.id}));var r={cadInfo:t,version:o.version,floors:n,unit:ae.unit,angle:re.getAngle(),currentId:re.getCurrentId(),compass:re.getCompass()};return r.type=e?"image":"cad",r},e.prototype.exportHouseData=function(){return this.analyService.houseData},e.prototype.importJSON=function(){},n.isChanged.get=function(){return Ae.hasRecords()},n.isCurrentFloorEmpty.get=function(){return!1},e.prototype.revokeHistory=function(){this.history.goPreState(),this.renderer.autoRedraw(),Ae.getHistoryState().pre?this.$xui.toolbar.recall=!0:this.$xui.toolbar.recall=!1,this.$xui.toolbar.recover=!0},e.prototype.recoveryHistory=function(){this.history.goNextState(),this.renderer.autoRedraw(),Ae.getHistoryState().next?this.$xui.toolbar.recover=!0:this.$xui.toolbar.recover=!1,this.$xui.toolbar.recall=!0},e.prototype.deleteItem=function(){var t=Kt.getFocusItem();t&&(t.type==h?re.deleteWall(t.vectorId):ee.isSymbol(t.type)?ee.deleteSymbol(t.vectorId):ut.isComponent(t.type)?re.deleteComponent(t.vectorId):t.type==P?re.deleteTag(t.vectorId):Gt.isFurniture(t.type)?re.deleteComponent(t.vectorId):t.type==a&&st.deleteWallCorner(t.vectorId),this.history.save(),this.renderer.autoRedraw())},e.prototype.uploadCadImg=function(t,e,o,i){this.app.store.getValue("flooruser").type="image",this.player.model.floorplanCadImg.displayCadPlane(!0),this.uiControl.execute("clear",!0),this.uiControl.execute("panos",!1),this.uiControl.execute("texture",!0),this.$xui.toolbars.forEach((function(t){var e=t.list.find((function(t){return"viewSetting"==t.type}));e&&e.data.forEach((function(t){"panos"==t.type?t.checked=!1:"texture"==t.type&&(t.checked=!0)}))})),this.load.uploadCadImg(t,e,o,i)},e.prototype.deleteCadImg=function(t){this.player.model.floorplanCadImg.deleteCustomFloorTexture(t)},e.prototype.setCadImgVisible=function(t,e){this.player.model.floorplanCadImg.setCustomFloorVisible(t,e)},e.prototype.getBoundingBox2DPosition=function(t){return re.getBoundingBox2DPosition(this.player.model.floors.index[t].boundingBox)},e.prototype.recoverForCadImg=function(t,e){this.load.recoverForCadImg(t,e)},e.prototype.createSymbolFromPanorama=function(t,e,o){Kt.clearEventName();var i=ee.createSymbolFromPanorama(t,e,o);return this.history.save(),i},e.prototype.syncFloorplanAngel=function(t){var e=ie.getScreenInfoForCAD();e.floorPlanAngle=null!=t?t:re.getAngle(),this.app.core.get("CameraControls").emit("syncCadAnd3DForRotate",e)},e.prototype.disable=function(){this.app.dom.querySelector("[xui_edit_cad]").style.pointerEvents="none"},e.prototype.enable=function(){this.app.dom.querySelector("[xui_edit_cad]").style.pointerEvents="all"},n.floors.get=function(){return o.floors},Object.defineProperties(e.prototype,n),e}(KanKan.MITT.Emiter);return function(t){var e=KanKan.Deferred(),o=function(){var o=new Ii(t);o.$html="
",o.$name="EditCAD",o.$load=function(){t.CadManager.install(o)},e.resolve(o)};return t.Scene.loaded?o():t.Scene.on("loaded",o),e}}();