| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063 |
- function Move(layer) {
- this.layer = layer;
- this.moveType = null;
- this.currentState = this.layer.currentState;
- this.calculateLine = this.layer.calculateLine;
- this.calculateElement = this.layer.calculateElement;
- //拖拽门或者窗户 等元素
- this.draggingSymbol2d = null;
- //拖拽门或者窗户的顶点
- this.draggingSymbol2dPoint = null;
- //移动墙角的时候保存移动点的信息
- //this.moveCornerPoint=null;
- };
- //移动楼梯角
- Move.prototype.moveStaircorner = function (stairid, index, newdragPoint) {
- if (stairid == null) {
- return;
- }
- this.layer.vectors[stairid].geometry.points[index].x = newdragPoint.x;
- this.layer.vectors[stairid].geometry.points[index].y = newdragPoint.y;
- var pt = this.layer.vectors[stairid].geometry.points[this.currentState.currentstartlinePointIndex];
- this.layer.vectors[this.currentState.currentCircleId].geometry.x = pt.x;
- this.layer.vectors[this.currentState.currentCircleId].geometry.y = pt.y;
- this.layer.vectors[this.currentState.currentCircleId].geometry.contextIndex = this.layer.select.contextIndex;
- var allpoints = this.calculateElement.getAllPointsFromStair(this.layer.vectors[stairid].geometry.points);
- this.layer.vectors[stairid].geometry.linkedpoints = allpoints.vertical;
- this.layer.vectors[stairid].geometry.borderpoints.border1 = allpoints.border1;
- this.layer.vectors[stairid].geometry.borderpoints.border2 = allpoints.border2;
- this.layer.vectors[stairid].geometry.arrowpoints.arrows1 = allpoints.arrows1;
- this.layer.vectors[stairid].geometry.arrowpoints.arrows2 = allpoints.arrows2;
- this.layer.control.refreshCanvas = true;
- this.layer.control.refreshSelectCanvas = true;
- };
- Move.prototype.moveSpiralcorner = function (stairId, point, index) {
- var center = this.layer.vectors[stairId].geometry.point;
- var r = this.layer.parameter.spiralR1;
- var line = this.calculateLine.createLine(point, center);
- var newpoint = {};
- var angle = null;
- if (line.hasOwnProperty('x')) {
- newpoint.x = center.x;
- if (point.y > center.y) {
- newpoint.y = center.y + r;
- angle = 1.5 * Math.PI;
- }
- else {
- newpoint.y = center.y - r;
- angle = Math.PI / 2;
- }
- }
- else if (line.hasOwnProperty('y')) {
- newpoint.y = center.y;
- if (point.x > center.x) {
- newpoint.x = center.x + r;
- angle = 0;
- }
- else {
- newpoint.x = center.x - r;
- angle = Math.PI;
- }
- }
- else {
- var verticalLine1 = {};
- var verticalLine2 = {};
- verticalLine1.a = -1 / line.a;
- verticalLine2.a = -1 / line.a;
- var b = center.y - verticalLine1.a * center.x;
- verticalLine1.b = b + this.calculateLine.driftY3(verticalLine1.a, this.layer.parameter.spiralR1);
- verticalLine2.b = b - this.calculateLine.driftY3(verticalLine1.a, this.layer.parameter.spiralR1);
- var join1 = this.calculateLine.getIntersectionPoint(verticalLine1, line);
- var join2 = this.calculateLine.getIntersectionPoint(verticalLine2, line);
- if (this.calculateLine.containPoint(center, join1, point) || this.calculateLine.containPoint(center, point, join1)) {
- newpoint = join1;
- }
- else {
- newpoint = join2;
- }
- var dx = newpoint.x - center.x;
- var dy = newpoint.y - center.y;
- if (dx > 0 && dy > 0 || dx < 0 && dy > 0) {
- if (line.a > 0) {
- angle = 2 * Math.PI - Math.atan(line.a);
- }
- else {
- angle = Math.PI + Math.abs(Math.atan(line.a));
- }
- }
- else {
- if (line.a > 0) {
- angle = Math.PI - Math.atan(line.a);
- }
- else {
- angle = Math.abs(Math.atan(line.a));
- }
- }
- }
- if (index == 1) {
- this.layer.vectors[stairId].geometry.sAngle = angle;
- this.layer.vectors[stairId].geometry.point1 = newpoint;
- }
- else {
- this.layer.vectors[stairId].geometry.eAngle = angle;
- this.layer.vectors[stairId].geometry.point2 = newpoint;
- }
- this.layer.vectors[this.currentState.currentPointId].geometry.x = newpoint.x;
- this.layer.vectors[this.currentState.currentCircleId].geometry.x = newpoint.x;
- this.layer.vectors[this.currentState.currentPointId].geometry.y = newpoint.y;
- this.layer.vectors[this.currentState.currentCircleId].geometry.y = newpoint.y;
- this.layer.control.refreshCanvas = true; this.layer.control.refreshSelectCanvas = true;
- };
- Move.prototype.moveSpiralPlane = function (stairId, dx, dy) {
- var point = {};
- point.x = this.layer.vectors[stairId].geometry.point.x + dx;
- point.y = this.layer.vectors[stairId].geometry.point.y - dy;
- var points = this.calculateElement.GetSpiralpoints(point);
- this.layer.vectors[stairId].geometry.point = point;
- this.layer.vectors[stairId].geometry.points = points;
- this.layer.vectors[stairId].geometry.point1.x += dx;
- this.layer.vectors[stairId].geometry.point1.y -= dy;
- this.layer.vectors[stairId].geometry.point2.x += dx;
- this.layer.vectors[stairId].geometry.point2.y -= dy;
- this.layer.control.refreshCanvas = true;
- };
- //
- Move.prototype.endmoveWall = function (newdragPoint) {
- };
- //移动墙角
- //index表示选择的墙角所在的位置
- Move.prototype.moveWallcorner = function (wallid, index, newdragPoint) {
- if (wallid == null) {
- return;
- }
- var interval = this.layer.parameter.wallThickness;
- var len = this.layer.vectors[wallid].geometry.points.length;
- delete this.layer.vectors[wallid].geometry.firstLines;
- delete this.layer.vectors[wallid].geometry.endLines;
- //移动的点与相邻的点是否重合
- var flag = false;
- for (var i = 0; i < len; ++i) {
- if (i != index) {
- if (BABYLON.Vector2.Distance(newdragPoint, this.layer.vectors[wallid].geometry.points[i]) < interval) {
- flag = true;
- //修改data2d的nodes
- var index1 = this.calculateElement.getPreIndex(this.layer.vectors[wallid].geometry.points, index);
- var index2 = this.calculateElement.getNextIndex(this.layer.vectors[wallid].geometry.points, index);
- if (index1 == i) {
- this.layer.data2d.deleteNode({ wallId: wallid, startIndex: index, endIndex: -1 }, index1);
- this.layer.data2d.moveNodeForWall({ wallId: wallid, startIndex: index, endIndex: -1 });
- }
- else if (index2 == i) {
- this.layer.data2d.deleteNode({ wallId: wallid, startIndex: index, endIndex: -1 }, index2);
- this.layer.data2d.moveNodeForWall({ wallId: wallid, startIndex: index, endIndex: -1 });
- }
- this.calculateElement.updateSymbolsWallCornerIndexDelete(wallid, i, index)
- if (index > i && (index - i) != len - 1) {
- this.layer.vectors[wallid].geometry.wallInfo[i].thick = this.layer.vectors[wallid].geometry.wallInfo[index].thick;
- this.layer.vectors[wallid].geometry.wallInfo[i].height = this.layer.vectors[wallid].geometry.wallInfo[index].height;
- }
- this.layer.vectors[wallid].geometry.points.splice(index, 1);
- this.layer.vectors[wallid].geometry.wallInfo.splice(index, 1);
- if (Math.abs(index - i) == len - 1) {
- this.layer.vectors[wallid].geometry.state = 0;
- }
- if (this.layer.vectors[wallid].geometry.points.length == 1) {
- this.layer.data2d.deleteWallid(this.currentState.currentWallId);
- this.layer.deleteVector(wallid);
- this.layer.select.clearSelect();
- this.currentState.selectWallSet = null;
- this.currentState.currentWallId = null;
- this.layer.control.refreshCanvas = true;
- this.layer.pan.f_draggingWallCorner = false;
- return;
- }
- else if (this.layer.vectors[wallid].geometry.points.length < 3) {
- this.layer.vectors[wallid].geometry.state = 1;
- }
- if (index > i) {
- index = i;
- }
- else if (index == 0 && (i == len - 1)) {
- //删除了一个点
- index = len - 2;
- }
- this.currentState.currentstartlinePointIndex = index;
- break;
- }
- }
- }
- if (!flag) {
- }
- this.layer.vectors[wallid].geometry.points[index].x = newdragPoint.x;
- this.layer.vectors[wallid].geometry.points[index].y = newdragPoint.y;
- //this.layer.data2d.moveNodeForWall({wallId:wallid,startIndex:index,endIndex:-1});
- //处理墙上的门、窗等元素
- if (this.layer.vectors[wallid].symbol2dsCount > 0) {
- this.moveSymbolsWithWallCorner(wallid, index);
- }
- //处理选中的图形
- this.changeCorner();
- this.layer.control.refreshCanvas = true;
- this.layer.control.refreshSelectCanvas = true;
- };
- //改变扇形、圆、点
- Move.prototype.changeCorner = function () {
- //改变样式:扇形、圆圈等
- var pt = this.layer.vectors[this.currentState.currentWallId].geometry.points[this.currentState.currentstartlinePointIndex];
- this.layer.vectors[this.currentState.currentPointId].geometry.x = pt.x;
- this.layer.vectors[this.currentState.currentPointId].geometry.y = pt.y;
- this.layer.vectors[this.currentState.currentPointId].geometry.contextIndex = this.layer.select.contextIndex;
- this.layer.vectors[this.currentState.currentCircleId].geometry.x = pt.x;
- this.layer.vectors[this.currentState.currentCircleId].geometry.y = pt.y;
- this.layer.vectors[this.currentState.currentCircleId].geometry.contextIndex = this.layer.select.contextIndex;
- var sector = this.layer.select.editSector(this.currentState.currentstartlinePointIndex);
- if (sector != null) {
- if (this.currentState.currentSecotrId != null) {
- this.layer.vectors[this.currentState.currentSecotrId].geometry.x = sector.x;
- this.layer.vectors[this.currentState.currentSecotrId].geometry.y = sector.y;
- this.layer.vectors[this.currentState.currentSecotrId].geometry.startAngle = sector.start;
- this.layer.vectors[this.currentState.currentSecotrId].geometry.endAngle = sector.end;
- this.layer.vectors[this.currentState.currentSecotrId].geometry.contextIndex = this.layer.select.contextIndex;
- }
- else {
- //添加扇形
- var addsector = new Sector(sector.x, sector.y, Sector_r, sector.start, sector.end);
- var vector = new Vector(addsector, sectorStyle);
- this.currentState.currentSecotrId = vector.id;
- vector.geometry.contextIndex = this.layer.select.contextIndex;
- this.layer.drawSingleVector(vector);
- }
- }
- else {
- this.layer.deleteVector(this.currentState.currentSecotrId);
- this.currentState.currentSecotrId = null;
- }
- this.layer.control.refreshSelectCanvas = true;
- };
- Move.prototype.moveStairLine = function (id, dx, dy, startIndex, endIndex) {
- this.layer.vectors[id].geometry.points[startIndex].x += dx * this.layer.res;
- this.layer.vectors[id].geometry.points[startIndex].y -= dy * this.layer.res;
- this.layer.vectors[id].geometry.points[endIndex].x += dx * this.layer.res;
- this.layer.vectors[id].geometry.points[endIndex].y -= dy * this.layer.res;
- //移动选中的点和线
- if (this.currentState.currentLineId != null) {
- this.layer.vectors[this.currentState.currentLineId].geometry.points[0].x += dx * this.layer.res;
- this.layer.vectors[this.currentState.currentLineId].geometry.points[1].x += dx * this.layer.res;
- this.layer.vectors[this.currentState.currentLineId].geometry.points[0].y -= dy * this.layer.res;
- this.layer.vectors[this.currentState.currentLineId].geometry.points[1].y -= dy * this.layer.res;
- }
- if (this.currentState.currentLinePoint1Id != null) {
- this.layer.vectors[this.currentState.currentLinePoint1Id].geometry.x += dx * this.layer.res;
- this.layer.vectors[this.currentState.currentLinePoint1Id].geometry.y -= dy * this.layer.res;
- }
- if (this.currentState.currentLinePoint2Id != null) {
- this.layer.vectors[this.currentState.currentLinePoint2Id].geometry.x += dx * this.layer.res;
- this.layer.vectors[this.currentState.currentLinePoint2Id].geometry.y -= dy * this.layer.res;
- }
- var allpoints = this.calculateElement.getAllPointsFromStair(this.layer.vectors[id].geometry.points);
- this.layer.vectors[id].geometry.linkedpoints = allpoints.vertical;
- this.layer.vectors[id].geometry.borderpoints.border1 = allpoints.border1;
- this.layer.vectors[id].geometry.borderpoints.border2 = allpoints.border2;
- this.layer.vectors[id].geometry.arrowpoints.arrows1 = allpoints.arrows1;
- this.layer.vectors[id].geometry.arrowpoints.arrows2 = allpoints.arrows2;
- this.layer.control.refreshSelectCanvas = true;
- this.layer.control.refreshCanvas = true;
- this.layer.renderer.autoRedraw();
- };
- /*
- //移动楼梯面
- Move.prototype.moveStairLine=function(id,dx,dy,startIndex,endIndex)
- {
- if(id==null||startIndex==null||endIndex==null)
- {
- return;
- }
-
- var r=this.layer.parameter.stairWidth;
- var len=this.layer.vectors[id].geometry.points.length;
- if(len==2)
- {
- for(var i=0;i<this.layer.vectors[id].geometry.points.length;++i)
- {
- var x=this.layer.vectors[id].geometry.points[i].x+dx * this.layer.res;
- var y=this.layer.vectors[id].geometry.points[i].y-dy * this.layer.res;
- this.layer.vectors[id].geometry.points[i]={x:x,y:y};
- }
-
- //移动选中的点和线
- if(this.currentState.currentLineId!=null)
- {
- this.layer.vectors[this.currentState.currentLineId].geometry.points[0].x+=dx * this.layer.res;
- this.layer.vectors[this.currentState.currentLineId].geometry.points[1].x+=dx * this.layer.res;
-
- this.layer.vectors[this.currentState.currentLineId].geometry.points[0].y-=dy * this.layer.res;
- this.layer.vectors[this.currentState.currentLineId].geometry.points[1].y-=dy * this.layer.res;
- }
-
- if(this.currentState.currentLinePoint1Id!=null)
- {
- this.layer.vectors[this.currentState.currentLinePoint1Id].geometry.x+=dx * this.layer.res;
- this.layer.vectors[this.currentState.currentLinePoint1Id].geometry.y-=dy * this.layer.res;
- }
- if(this.currentState.currentLinePoint2Id!=null)
- {
- this.layer.vectors[this.currentState.currentLinePoint2Id].geometry.x+=dx * this.layer.res;
- this.layer.vectors[this.currentState.currentLinePoint2Id].geometry.y-=dy * this.layer.res;
- }
- }
- else
- {
- var newdragline=[];
- var currentPoint1={};
- currentPoint1.x=this.layer.vectors[id].geometry.points[startIndex].x;
- currentPoint1.y=this.layer.vectors[id].geometry.points[startIndex].y;
- var currentPoint2={};
- currentPoint2.x=this.layer.vectors[id].geometry.points[endIndex].x;
- currentPoint2.y=this.layer.vectors[id].geometry.points[endIndex].y;
-
- //不考虑周围的墙,鼠标移动后,选中的墙本应该在的位置
- newdragline.push({x:currentPoint1.x+ dx * this.layer.res,y:currentPoint1.y- dy * this.layer.res});
- newdragline.push({x:currentPoint2.x+ dx * this.layer.res,y:currentPoint2.y- dy * this.layer.res});
-
- var origin=this.layer.calculateElement.getOrginLine(len,id,startIndex,endIndex);
-
- //得到挨着startIndex但不是newdragline的墙的线段
- var orginLine1=origin.line1;
- //线段的另一个端点
- var orginPoint1=this.layer.vectors[id].geometry.points[origin.point1];
- //得到挨着endIndex但不是newdragline的墙的线段
- var orginLine2=origin.line2;
- //线段的另一个端点
- var orginPoint2=this.layer.vectors[id].geometry.points[origin.point2];
-
- var newline=this.calculateLine.createLine(newdragline[0],newdragline[1]);
-
- var point1=this.layer.vectors[id].geometry.points[orginLine1[0]];
- var point2=this.layer.vectors[id].geometry.points[orginLine1[1]];
- //拖拽的墙与挨着的墙的交点
- var line1=this.calculateLine.createLine(point1,point2);
- var newWallPoint1=this.calculateLine.getIntersectionPoint(line1,newline);
-
- var point3=this.layer.vectors[id].geometry.points[orginLine2[0]];
- var point4=this.layer.vectors[id].geometry.points[orginLine2[1]];
-
- //拖拽的墙与另一堵挨着的墙的交点
- var line2=this.calculateLine.createLine(point3,point4);
- var newWallPoint2=this.calculateLine.getIntersectionPoint(line2,newline);
-
- this.layer.vectors[id].geometry.points[startIndex].x=newWallPoint1.x;
- this.layer.vectors[id].geometry.points[startIndex].y=newWallPoint1.y;
- this.layer.vectors[id].geometry.points[endIndex].x=newWallPoint2.x;
- this.layer.vectors[id].geometry.points[endIndex].y=newWallPoint2.y;
- this.currentState.currentstartlinePointIndex=startIndex;
- this.currentState.currentendlinePointIndex=endIndex;
-
- this.layer.vectors[this.currentState.currentLinePoint1Id].geometry.x=newWallPoint1.x;
- this.layer.vectors[this.currentState.currentLinePoint1Id].geometry.y=newWallPoint1.y;
-
- this.layer.vectors[this.currentState.currentLinePoint2Id].geometry.x=newWallPoint2.x;
- this.layer.vectors[this.currentState.currentLinePoint2Id].geometry.y=newWallPoint2.y;
-
- this.layer.vectors[this.currentState.currentLineId].geometry.points[0].x=this.layer.vectors[this.currentState.currentLinePoint1Id].geometry.x;
- this.layer.vectors[this.currentState.currentLineId].geometry.points[0].y=this.layer.vectors[this.currentState.currentLinePoint1Id].geometry.y;
- this.layer.vectors[this.currentState.currentLineId].geometry.points[1].x=this.layer.vectors[this.currentState.currentLinePoint2Id].geometry.x;
- this.layer.vectors[this.currentState.currentLineId].geometry.points[1].y=this.layer.vectors[this.currentState.currentLinePoint2Id].geometry.y;
- }
-
- var allpoints=this.calculateElement.getAllPointsFromStair(this.layer.vectors[id].geometry.points);
- this.layer.vectors[id].geometry.linkedpoints=allpoints.vertical;
- this.layer.vectors[id].geometry.borderpoints.border1=allpoints.border1;
- this.layer.vectors[id].geometry.borderpoints.border2=allpoints.border2;
-
- this.layer.control.refreshSelectCanvas=true;
- this.layer.control.refreshCanvas=true;
- this.layer.renderer.autoRedraw();
- };
- */
- //移动整面墙
- //startIndex,endIndex表示墙的两个端点
- //id表示当前移动墙的id
- //dx,dy表示偏移量
- Move.prototype.moveWallLine = function (id, dx, dy, startIndex, endIndex) {
- if (id == null || startIndex == null || endIndex == null) {
- return;
- }
- var r;
- if (this.layer.vectors[id].geometry.wallType == 1) {
- r = wallThickness / 2
- }
- else {
- r = partitionThickness / 2
- }
- var len = this.layer.vectors[id].geometry.points.length;
- var newdragline = [];
- var currentPoint1 = {};
- currentPoint1.x = this.layer.vectors[id].geometry.points[startIndex].x;
- currentPoint1.y = this.layer.vectors[id].geometry.points[startIndex].y;
- var currentPoint2 = {};
- currentPoint2.x = this.layer.vectors[id].geometry.points[endIndex].x;
- currentPoint2.y = this.layer.vectors[id].geometry.points[endIndex].y;
- //不考虑周围的墙,鼠标移动后,选中的墙本应该在的位置
- newdragline.push({ x: currentPoint1.x + dx * this.layer.res, y: currentPoint1.y - dy * this.layer.res });
- newdragline.push({ x: currentPoint2.x + dx * this.layer.res, y: currentPoint2.y - dy * this.layer.res });
- //如果墙不是闭合的,就拖拽vector就行
- if (this.layer.vectors[id].geometry.state == 1) {
- for (var i = 0; i < this.layer.vectors[id].geometry.points.length; ++i) {
- var x = this.layer.vectors[id].geometry.points[i].x + dx * this.layer.res;
- var y = this.layer.vectors[id].geometry.points[i].y - dy * this.layer.res;
- this.layer.vectors[id].geometry.points[i] = { x: x, y: y };
- }
- //移动选中的点和线
- if (this.currentState.currentLineId != null) {
- this.layer.vectors[this.currentState.currentLineId].geometry.points[0].x += dx * this.layer.res;
- this.layer.vectors[this.currentState.currentLineId].geometry.points[1].x += dx * this.layer.res;
- this.layer.vectors[this.currentState.currentLineId].geometry.points[0].y -= dy * this.layer.res;
- this.layer.vectors[this.currentState.currentLineId].geometry.points[1].y -= dy * this.layer.res;
- }
- if (this.currentState.currentLinePoint1Id != null) {
- this.layer.vectors[this.currentState.currentLinePoint1Id].geometry.x += dx * this.layer.res;
- this.layer.vectors[this.currentState.currentLinePoint1Id].geometry.y -= dy * this.layer.res;
- }
- if (this.currentState.currentLinePoint2Id != null) {
- this.layer.vectors[this.currentState.currentLinePoint2Id].geometry.x += dx * this.layer.res;
- this.layer.vectors[this.currentState.currentLinePoint2Id].geometry.y -= dy * this.layer.res;
- }
- //移动墙上所有的symbols
- for (var key in this.layer.vectors[id].symbol2Ds) {
- if (this.layer.vectors[id].symbol2Ds[key].geometry.geoType != "OpenDoor" && this.layer.vectors[id].symbol2Ds[key].geometry.geoType != "OpenWindow") {
- for (var i = 0; i < this.layer.vectors[id].symbol2Ds[key].geometry.points.length; ++i) {
- this.layer.vectors[id].symbol2Ds[key].geometry.points[i].x += dx * this.layer.res;
- this.layer.vectors[id].symbol2Ds[key].geometry.points[i].y -= dy * this.layer.res;
- }
- }
- this.layer.vectors[id].symbol2Ds[key].geometry.point1.x += dx * this.layer.res;
- this.layer.vectors[id].symbol2Ds[key].geometry.point1.y -= dy * this.layer.res;
- this.layer.vectors[id].symbol2Ds[key].geometry.point2.x += dx * this.layer.res;
- this.layer.vectors[id].symbol2Ds[key].geometry.point2.y -= dy * this.layer.res;
- }
- this.layer.control.refreshSelectCanvas = true;
- this.layer.control.refreshCanvas = true;
- this.layer.renderer.autoRedraw();
- return;
- }
- //判断墙中的点有没有合并
- var symbolFlag = false;
- var flag = false;
- var orginLine = [];
- var origin = this.layer.calculateElement.getOrginLine(len, id, startIndex, endIndex);
- //得到挨着startIndex但不是newdragline的墙的线段
- var orginLine1 = origin.line1;
- //线段的另一个端点
- var orginPoint1 = this.layer.vectors[id].geometry.points[origin.point1];
- //得到挨着endIndex但不是newdragline的墙的线段
- var orginLine2 = origin.line2;
- //线段的另一个端点
- var orginPoint2 = this.layer.vectors[id].geometry.points[origin.point2];
- var newline = this.calculateLine.createLine(newdragline[0], newdragline[1]);
- var point1 = this.layer.vectors[id].geometry.points[orginLine1[0]];
- var point2 = this.layer.vectors[id].geometry.points[orginLine1[1]];
- //拖拽的墙与挨着的墙的交点
- var line1 = this.calculateLine.createLine(point1, point2);
- var newWallPoint1 = this.calculateLine.getIntersectionPoint(line1, newline);
- var point3 = this.layer.vectors[id].geometry.points[orginLine2[0]];
- var point4 = this.layer.vectors[id].geometry.points[orginLine2[1]];
- //拖拽的墙与另一堵挨着的墙的交点
- var line2 = this.calculateLine.createLine(point3, point4);
- var newWallPoint2 = this.calculateLine.getIntersectionPoint(line2, newline);
- this.layer.vectors[id].geometry.points[startIndex].x = newWallPoint1.x;
- this.layer.vectors[id].geometry.points[startIndex].y = newWallPoint1.y;
- this.layer.vectors[id].geometry.points[endIndex].x = newWallPoint2.x;
- this.layer.vectors[id].geometry.points[endIndex].y = newWallPoint2.y;
- this.currentState.currentstartlinePointIndex = startIndex;
- this.currentState.currentendlinePointIndex = endIndex;
- this.layer.control.refreshCanvas = true;
- if (BABYLON.Vector2.Distance(orginPoint1, newWallPoint1) < 2 * r) {
- this.layer.vectors[this.currentState.currentLinePoint1Id].geometry.x = orginPoint1.x;
- this.layer.vectors[this.currentState.currentLinePoint1Id].geometry.y = orginPoint1.y;
- newWallPoint1.x = orginPoint1.x;
- newWallPoint1.y = orginPoint1.y;
- var indexs = this.calculateElement.updateSelectWallLineIndex(id, startIndex, endIndex, origin.point1);
- if (this.calculateElement.isNeighbor(len, origin.point1, startIndex)) {
- if (startIndex > origin.point1 && (startIndex - origin.point1) != len - 1) {
- this.layer.vectors[id].geometry.wallInfo[origin.point1].thick = this.layer.vectors[id].geometry.wallInfo[startIndex].thick;
- this.layer.vectors[id].geometry.wallInfo[origin.point1].height = this.layer.vectors[id].geometry.wallInfo[startIndex].height;
- }
- this.layer.vectors[id].geometry.points.splice(startIndex, 1);
- this.layer.vectors[id].geometry.wallInfo.splice(startIndex, 1);
- origin.point1 = Math.min(origin.point1, startIndex);
- }
- else {
- if (endIndex > origin.point1 && (endIndex - origin.point1) != len - 1) {
- this.layer.vectors[id].geometry.wallInfo[origin.point1].thick = this.layer.vectors[id].geometry.wallInfo[endIndex].thick;
- this.layer.vectors[id].geometry.wallInfo[origin.point1].height = this.layer.vectors[id].geometry.wallInfo[endIndex].height;
- }
- this.layer.vectors[id].geometry.points.splice(endIndex, 1);
- this.layer.vectors[id].geometry.wallInfo.splice(endIndex, 1);
- origin.point1 = Math.min(origin.point1, endIndex);
- }
- startIndex = indexs.wallindex1;
- endIndex = indexs.wallindex2;
- this.currentState.currentstartlinePointIndex = startIndex;
- this.currentState.currentendlinePointIndex = endIndex;
- if (this.layer.vectors[id].geometry.points.length < 3) {
- this.layer.vectors[id].geometry.state = 1;
- }
- symbolFlag = true;
- }
- else if (this.currentState.currentLinePoint1Id != null) {
- this.layer.vectors[this.currentState.currentLinePoint1Id].geometry.x = newWallPoint1.x;
- this.layer.vectors[this.currentState.currentLinePoint1Id].geometry.y = newWallPoint1.y;
- }
- if (BABYLON.Vector2.Distance(orginPoint2, newWallPoint2) < 2 * r) {
- this.layer.vectors[this.currentState.currentLinePoint2Id].geometry.x = orginPoint2.x;
- this.layer.vectors[this.currentState.currentLinePoint2Id].geometry.y = orginPoint2.y;
- newWallPoint2.x = orginPoint2.x;
- newWallPoint2.y = orginPoint2.y;
- var indexs = this.calculateElement.updateSelectWallLineIndex(id, startIndex, endIndex, origin.point2);
- if (this.calculateElement.isNeighbor(len, origin.point2, startIndex)) {
- if (startIndex > origin.point2 && (startIndex - origin.point2) != len - 1) {
- this.layer.vectors[id].geometry.wallInfo[origin.point2].thick = this.layer.vectors[id].geometry.wallInfo[startIndex].thick;
- this.layer.vectors[id].geometry.wallInfo[origin.point2].height = this.layer.vectors[id].geometry.wallInfo[startIndex].height;
- }
- this.layer.vectors[id].geometry.points.splice(startIndex, 1);
- this.layer.vectors[id].geometry.wallInfo.splice(startIndex, 1);
- origin.point2 = Math.min(origin.point1, startIndex);
- }
- else {
- if (endIndex > origin.point2 && (endIndex - origin.point2) != len - 1) {
- this.layer.vectors[id].geometry.wallInfo[origin.point2].thick = this.layer.vectors[id].geometry.wallInfo[endIndex].thick;
- this.layer.vectors[id].geometry.wallInfo[origin.point2].height = this.layer.vectors[id].geometry.wallInfo[endIndex].height;
- }
- this.layer.vectors[id].geometry.points.splice(endIndex, 1);
- this.layer.vectors[id].geometry.wallInfo.splice(endIndex, 1);
- origin.point2 = Math.min(origin.point1, endIndex);
- }
- startIndex = indexs.wallindex1;
- endIndex = indexs.wallindex2;
- this.currentState.currentstartlinePointIndex = startIndex;
- this.currentState.currentendlinePointIndex = endIndex;
- if (this.layer.vectors[id].geometry.points.length < 3) {
- this.layer.vectors[id].geometry.state = 1;
- }
- symbolFlag = true;
- }
- else if (this.currentState.currentLinePoint2Id != null) {
- this.layer.vectors[this.currentState.currentLinePoint2Id].geometry.x = newWallPoint2.x;
- this.layer.vectors[this.currentState.currentLinePoint2Id].geometry.y = newWallPoint2.y;
- }
- if (this.layer.vectors[id].geometry.points.length == 1) {
- this.layer.data2d.deleteWallid(this.currentState.currentWallId);
- this.layer.deleteVector(id);
- this.layer.select.clearSelect();
- this.currentState.selectWallSet = null;
- this.currentState.currentWallId = null;
- this.layer.control.refreshCanvas = true;
- this.layer.pan.f_draggingWallLine = false;
- return;
- }
- if (this.layer.vectors[id].geometry.points.length == 1 || BABYLON.Vector2.Distance(newWallPoint1, newWallPoint2) < 2 * r) {
- this.layer.select.clearSelect();
- this.layer.select.endSelectWallLine();
- this.layer.pan.f_draggingWallLine = false;
- this.layer.pan.f_draggingWallCorner = true;
- var index = startIndex;
- if (this.layer.vectors[id].geometry.points.length != 1) {
- if (index == this.layer.vectors[id].geometry.points.length - 1) {
- index = 0;
- }
- this.calculateElement.updateSymbolsWallCornerIndexDelete(id, startIndex, endIndex);
- this.layer.vectors[id].geometry.points.splice(startIndex, 1);
- this.layer.vectors[id].geometry.wallInfo.splice(startIndex, 1);
- this.layer.select.selectWallCorner(id, index);
- }
- else {
- index = 0;
- this.layer.deleteVector(id);
- this.currentState.currentWallId = null;
- }
- }
- if (this.currentState.currentLineId != null) {
- if (BABYLON.Vector2.Distance(newWallPoint1, newWallPoint2) < 2 * r) {
- this.layer.select.clearSelect();
- this.layer.select.selectWallCorner(id, startIndex);
- }
- else {
- this.layer.vectors[this.currentState.currentLineId].geometry.points[0].x = this.layer.vectors[this.currentState.currentLinePoint1Id].geometry.x;
- this.layer.vectors[this.currentState.currentLineId].geometry.points[0].y = this.layer.vectors[this.currentState.currentLinePoint1Id].geometry.y;
- this.layer.vectors[this.currentState.currentLineId].geometry.points[1].x = this.layer.vectors[this.currentState.currentLinePoint2Id].geometry.x;
- this.layer.vectors[this.currentState.currentLineId].geometry.points[1].y = this.layer.vectors[this.currentState.currentLinePoint2Id].geometry.y;
- }
- }
- this.layer.control.refreshSelectCanvas = true;
- //计算改变的像素值
- dx = ((newWallPoint1.x - currentPoint1.x) + (newWallPoint2.x - currentPoint2.x)) / 2;
- dy = ((newWallPoint1.y - currentPoint1.y) + (newWallPoint2.y - currentPoint2.y)) / 2;
- this.moveSymbolsWithWallLine(id, this.currentState.currentstartlinePointIndex, this.currentState.currentendlinePointIndex, dx, dy, symbolFlag);
- this.layer.control.refreshCanvas = true;
- this.layer.renderer.autoRedraw();
- };
- //拖拽虚拟的Symbol,point在墙内
- Move.prototype.moveVirtualSymbol1 = function (symbol, point) {
- var len = symbol.getSymbolLen();
- symbol.geometry.r = len;
- var wallid = this.currentState.currentWallId;
- //获取symbol端点
- var endpoint = this.calculateElement.getSymbolEndPoint(point, wallid, this.currentState.currentstartlinePointIndex, this.currentState.currentendlinePointIndex, len);
- //选择canvas
- symbol.geometry.contextIndex = this.layer.parameter.selectcontext;
- symbol.geometry.thick = this.layer.vectors[wallid].geometry.wallInfo[this.currentState.currentstartlinePointIndex].thick;
- //更新端点
- if (endpoint != null) {
- symbol.geometry.point1 = endpoint.newpoint1;
- symbol.geometry.point2 = endpoint.newpoint2;
- }
- if (symbol.geometry.point1 != null & symbol.geometry.point2 != null) {
- symbol.update(this.layer, this.currentState.currentWallId, this.currentState.currentstartlinePointIndex, this.currentState.currentendlinePointIndex, point);
- if (typeof (this.layer.select.selectSymbolIds.selects) == "undefined") {
- this.layer.select.selectSymbol(symbol);
- }
- //更新选中的线和两个圆圈的坐标
- else {
- this.layer.vectors[this.layer.select.selectSymbolIds.selects[1]].geometry.x = symbol.geometry.point1.x;
- this.layer.vectors[this.layer.select.selectSymbolIds.selects[1]].geometry.y = symbol.geometry.point1.y;
- this.layer.vectors[this.layer.select.selectSymbolIds.selects[2]].geometry.x = symbol.geometry.point2.x;
- this.layer.vectors[this.layer.select.selectSymbolIds.selects[2]].geometry.y = symbol.geometry.point2.y;
- this.layer.vectors[this.layer.select.selectSymbolIds.selects[0]].geometry.points[0] = symbol.geometry.point1;
- this.layer.vectors[this.layer.select.selectSymbolIds.selects[0]].geometry.points[1] = symbol.geometry.point2;
- }
- this.layer.control.refreshSelectCanvas = true;
- }
- };
- //拖拽虚拟的Symbol,point在墙外
- Move.prototype.moveVirtualSymbol2 = function (symbol, point) {
- var len = symbol.getSymbolLen();
- symbol.geometry.thick = this.layer.vectors[symbol.attributes.wallId].geometry.wallInfo[symbol.attributes.wallstartindex].thick;
- var endpoint = this.calculateElement.getSymbolEndPoint2(point, symbol.attributes.wallId, symbol.attributes.wallstartindex, symbol.attributes.wallendindex, len);
- if (endpoint == null) {
- return false;
- }
- else {
- var thick = this.layer.getThickness(symbol.attributes.wallId, symbol.attributes.wallstartindex);
- //更新端点
- symbol.geometry.point1 = endpoint.newpoint1;
- symbol.geometry.point2 = endpoint.newpoint2;
- var newPoint = { x: (endpoint.newpoint1.x + endpoint.newpoint2.x) / 2, y: (endpoint.newpoint1.y + endpoint.newpoint2.y) / 2 };
- symbol.geometry.wallType = this.layer.vectors[symbol.attributes.wallId].geometry.wallType;
- symbol.attributes.toward = this.calculateLine.getToward(symbol.geometry.point1, symbol.geometry.point2, point);
- symbol.geometry.points = this.calculateElement.getSymbolPoints(endpoint.newpoint1, endpoint.newpoint2, symbol.geometry.geoType, symbol.attributes.toward, thick);
- this.layer.control.refreshCanvas = true;
- }
- if (typeof (this.layer.select.selectSymbolIds.selects) == "undefined") {
- this.layer.select.selectSymbol(symbol);
- }
- //更新选中的线和两个圆圈的坐标
- else {
- this.layer.vectors[this.layer.select.selectSymbolIds.selects[1]].geometry.x = symbol.geometry.point1.x;
- this.layer.vectors[this.layer.select.selectSymbolIds.selects[1]].geometry.y = symbol.geometry.point1.y;
- this.layer.vectors[this.layer.select.selectSymbolIds.selects[2]].geometry.x = symbol.geometry.point2.x;
- this.layer.vectors[this.layer.select.selectSymbolIds.selects[2]].geometry.y = symbol.geometry.point2.y;
- this.layer.vectors[this.layer.select.selectSymbolIds.selects[0]].geometry.points[0] = symbol.geometry.point1;
- this.layer.vectors[this.layer.select.selectSymbolIds.selects[0]].geometry.points[1] = symbol.geometry.point2;
- }
- this.layer.control.refreshSelectCanvas = true;
- return true;
- };
- //拖拽已经存在的Symbol
- Move.prototype.moveExistSymbol = function (lastpoint, point, id) {
- var symbol = this.layer.vectors[id];
- var wallid = symbol.attributes.wallId;
- var startIndex = this.currentState.currentstartlinePointIndex;
- var endIndex = this.currentState.currentendlinePointIndex;
- symbol.geometry.thick = this.layer.vectors[wallid].geometry.wallInfo[this.currentState.currentstartlinePointIndex].thick;
- var point1, point2;
- var joinpoint = null;
- point1 = this.layer.vectors[wallid].geometry.points[startIndex];
- if (endIndex != null && typeof (endIndex) != undefined) {
- point2 = this.layer.vectors[wallid].geometry.points[endIndex];
- }
- else {
- endIndex = this.calculateElement.getNextIndex(this.layer.vectors[wallid].geometry.points, startIndex, this.layer.vectors[wallid].geometry.state);
- point2 = this.layer.vectors[wallid].geometry.points[endIndex];
- }
- this.currentState.selectWallSet = this.calculateElement.wallsContain(point);
- if (this.currentState.selectWallSet != null) {
- //当前点在墙角
- if (this.currentState.selectWallSet.type == 0) {
- if (wallid != this.currentState.currentWallId) {
- this.currentState.currentstartlinePointIndex = this.currentState.selectWallSet.index;
- this.currentState.currentendlinePointIndex = this.calculateElement.getNextIndex(this.layer.vectors[wallid].geometry.points, this.currentState.selectWallSet.index, this.layer.vectors[wallid].geometry.state);
- this.currentState.currentWallId = this.currentState.selectWallSet.id;
- wallid = this.currentState.currentWallId;
- startIndex = this.currentState.currentstartlinePointIndex;
- endIndex = this.currentState.currentendlinePointIndex;
- point1 = this.layer.vectors[wallid].geometry.points[startIndex];
- if (endIndex) {
- point2 = this.layer.vectors[wallid].geometry.points[endIndex];
- }
- else {
- endIndex = this.calculateElement.getNextIndex(this.layer.vectors[wallid].geometry.points, startIndex, this.layer.vectors[wallid].geometry.state);
- }
- }
- //同一组墙,但是墙角不属于当前墙面
- else if (this.currentState.selectWallSet.index != endIndex && this.currentState.selectWallSet.index != startIndex) {
- this.currentState.currentstartlinePointIndex = this.currentState.selectWallSet.index;
- this.currentState.currentendlinePointIndex = endIndex;
- }
- }
- //当前点在墙面
- else if (this.currentState.selectWallSet.type == 1) {
- this.currentState.currentendlinePointIndex = this.currentState.selectWallSet.endindex;
- this.currentState.currentWallId = this.currentState.selectWallSet.id;
- this.currentState.currentstartlinePointIndex = this.currentState.selectWallSet.index;
- wallid = this.currentState.currentWallId;
- startIndex = this.currentState.currentstartlinePointIndex;
- endIndex = this.currentState.currentendlinePointIndex;
- point1 = this.layer.vectors[wallid].geometry.points[this.currentState.selectWallSet.index];
- point2 = this.layer.vectors[wallid].geometry.points[this.currentState.selectWallSet.endindex];
- }
- else {
- alert("Move:618");
- }
- symbol.attributes.toward = this.calculateLine.getToward(symbol.geometry.point1, symbol.geometry.point2, point);
- }
- else {
- var line = this.calculateLine.createLine(point1, point2);
- joinpoint = { x: point.x, y: point.y };
- point = this.calculateLine.getJoinLinePoint(point, line);
- if (!this.calculateElement.lineContain(point1, point2, point, 1)) {
- return;
- }
- symbol.attributes.toward = this.calculateLine.getToward(symbol.geometry.point1, symbol.geometry.point2, joinpoint);
- }
- var symbolLength = symbol.getSymbolLen();
- if (BABYLON.Vector2.Distance(point1, point) < symbolLength / 2 || BABYLON.Vector2.Distance(point2, point) < symbolLength / 2) {
- return;
- }
- var sp1 = { x: symbol.geometry.point1.x, y: symbol.geometry.point1.y };
- var sp2 = { x: symbol.geometry.point2.x, y: symbol.geometry.point2.y };
- this.calculateElement.updateSymbolEndPoint(symbol, point, wallid, startIndex, endIndex);
- var dx1 = symbol.geometry.point1.x - sp1.x;
- var dy1 = symbol.geometry.point1.y - sp1.y;
- var dx2 = symbol.geometry.point2.x - sp2.x;
- var dy2 = symbol.geometry.point2.y - sp2.y;
- this.layer.vectors[symbol.attributes.vectorMeasureid].geometry.points[0].x += dx1;
- this.layer.vectors[symbol.attributes.vectorMeasureid].geometry.points[0].y += dy1;
- this.layer.vectors[symbol.attributes.vectorMeasureid].geometry.points[1].x += dx2;
- this.layer.vectors[symbol.attributes.vectorMeasureid].geometry.points[1].y += dy2;
- var thick = this.layer.getThickness(symbol.attributes.wallId, symbol.attributes.wallstartindex);
- symbol.geometry.wallType = this.layer.vectors[symbol.attributes.wallId].geometry.wallType;
- symbol.geometry.points = this.calculateElement.getSymbolPoints(symbol.geometry.point1, symbol.geometry.point2, symbol.geometry.geoType, symbol.attributes.toward, thick);
- this.layer.select.f_selectWallLine = false;
- this.layer.control.refreshCanvas = true;
- this.layer.control.refreshSelectCanvas = true;
- };
- //移动Symbol上的端点
- Move.prototype.moveSymbolEndpoint = function (point, selectindex) {
- var wallid = this.draggingSymbol2dPoint.wallid;
- var index1 = this.draggingSymbol2dPoint.wallStartindex;
- var index2 = this.draggingSymbol2dPoint.wallEndindex;
- var selectPoint = this.draggingSymbol2dPoint.selectPoint;
- var noselectPoint = this.draggingSymbol2dPoint.noselectPoint;
- var mid = { x: (selectPoint.x + noselectPoint.x) / 2, y: (selectPoint.y + noselectPoint.y) / 2 };
- var line = this.calculateLine.createLine(this.layer.vectors[wallid].geometry.points[index1], this.layer.vectors[wallid].geometry.points[index2]);
- var join = this.calculateLine.getJoinLinePoint(point, line);
- var point1 = this.layer.vectors[wallid].geometry.points[index1];
- var point2 = this.layer.vectors[wallid].geometry.points[index2];
- var dx, dy;
- var symbol = this.layer.vectors[this.currentState.currentSymbolId];
- if (!this.calculateLine.containPoint(point1, point2, symbol.geometry.point1) || !this.calculateLine.containPoint(point1, point2, symbol.geometry.point2)) {
- return;
- }
- else if (this.calculateLine.containPoint(mid, join, selectPoint) || this.calculateLine.containPoint(mid, selectPoint, join)) {
- if (BABYLON.Vector2.Distance(point1, symbol.geometry.point1) < symbolMinLen || BABYLON.Vector2.Distance(point2, symbol.geometry.point1) < symbolMinLen || BABYLON.Vector2.Distance(point1, symbol.geometry.point2) < symbolMinLen || BABYLON.Vector2.Distance(point2, symbol.geometry.point2) < symbolMinLen) {
- return;
- }
- if (BABYLON.Vector2.Distance(this.layer.vectors[wallid].geometry.points[index1], join) < symbolMinLen) {
- //删除symbol
- this.layer.select.endSelectSymbol(this.layer.select.selectSymbolIds.vectorid, this.layer.select.selectSymbolIds.selects, this.layer.select.selectSymbolIds.vectorMeasureid);
- this.layer.deleteSymbol(this.currentState.currentSymbolId, wallid);
- this.layer.control.refreshCanvas = true;
- return;
- }
- else if (BABYLON.Vector2.Distance(selectPoint, join) < symbolMinLen) {
- return;
- }
- else {
- dx = join.x - selectPoint.x;
- dy = join.y - selectPoint.y;
- noselectPoint.x -= dx;
- noselectPoint.y -= dy;
- selectPoint.x += dx;
- selectPoint.y += dy;
- if (this.layer.select.selectSymbolIds.selectEndPointIndex == 1) {
- symbol.geometry.point1 = join;
- symbol.geometry.point2 = noselectPoint;
- this.layer.vectors[this.currentState.currentSymbolCircleId1].geometry.x = join.x;
- this.layer.vectors[this.currentState.currentSymbolCircleId1].geometry.y = join.y;
- this.layer.vectors[this.currentState.currentSymbolCircleId2].geometry.x = noselectPoint.x;
- this.layer.vectors[this.currentState.currentSymbolCircleId2].geometry.y = noselectPoint.y;
- this.layer.vectors[this.layer.select.selectSymbolIds.selects[0]].geometry.points[0] = join;
- this.layer.vectors[this.layer.select.selectSymbolIds.selects[0]].geometry.points[1] = noselectPoint;
- }
- else {
- symbol.geometry.point2 = join;
- symbol.geometry.point1 = noselectPoint;
- this.layer.vectors[this.currentState.currentSymbolCircleId2].geometry.x = join.x;
- this.layer.vectors[this.currentState.currentSymbolCircleId2].geometry.y = join.y;
- this.layer.vectors[this.currentState.currentSymbolCircleId1].geometry.x = noselectPoint.x;
- this.layer.vectors[this.currentState.currentSymbolCircleId1].geometry.y = noselectPoint.y;
- this.layer.vectors[this.layer.select.selectSymbolIds.selects[0]].geometry.points[1] = join;
- this.layer.vectors[this.layer.select.selectSymbolIds.selects[0]].geometry.points[0] = noselectPoint;
- }
- var thick = this.layer.getThickness(symbol.attributes.wallId, symbol.attributes.wallstartindex);
- symbol.geometry.points = this.calculateElement.getSymbolPoints(symbol.geometry.point1, symbol.geometry.point2, symbol.geometry.geoType, symbol.attributes.toward, thick);
- //symbol.geometry.points=this.calculateElement.getSymbolPoints(symbol.geometry.point1,symbol.geometry.point2,symbol.geometry.geoType,point,thick);
- this.layer.control.refreshCanvas = true;
- this.layer.control.refreshSelectCanvas = true;
- }
- }
- };
- //随墙移动
- Move.prototype.moveSymbolsWithWallCorner = function (wallid, index) {
- var symbol2ds = [];
- var movPoint = this.layer.vectors[wallid].geometry.points[index];
- console.log(this.layer.vectors[wallid].symbol2Ds)
- for (var key in this.layer.vectors[wallid].symbol2Ds) {
- var fixPoint = null;
- var symbol2d = this.layer.vectors[wallid].symbol2Ds[key];
- if (symbol2d.attributes.wallstartindex == index) {
- symbol2ds.push(symbol2d);
- fixPoint = this.layer.vectors[wallid].geometry.points[symbol2d.attributes.wallendindex];
- }
- else if (symbol2d.attributes.wallendindex == index) {
- symbol2ds.push(symbol2d);
- fixPoint = this.layer.vectors[wallid].geometry.points[symbol2d.attributes.wallstartindex];
- }
- else {
- // break;
- }
- if (fixPoint != null) {
- var point = this.calculateLine.getNewSymbolPoint(symbol2d, movPoint, fixPoint);
- symbol2d.geometry.point1 = point.point1;
- symbol2d.geometry.point2 = point.point2;
- symbol2d.select = false;
- var thick = this.layer.getThickness(this.currentState.currentWallId, this.currentState.currentstartlinePointIndex);
- symbol2d.geometry.points = this.calculateElement.getSymbolPoints(symbol2d.geometry.point1, symbol2d.geometry.point2, symbol2d.geometry.geoType, symbol2d.attributes.toward, thick);
- }
- }
- this.layer.control.refreshCanvas = true;
- };
- //随墙移动
- Move.prototype.moveSymbolsWithWallLine = function (id, startIndex, endIndex, dx, dy, flag) {
- if (typeof (this.layer.vectors[id]) != "undefined" && this.layer.vectors[id].symbol2dsCount > 0) {
- for (var key in this.layer.vectors[id].symbol2Ds) {
- var newWallPoint1 = this.layer.vectors[id].geometry.points[startIndex];
- var newWallPoint2 = this.layer.vectors[id].geometry.points[endIndex];
- var symbol2d = this.layer.vectors[id].symbol2Ds[key];
- if ((symbol2d.attributes.wallstartindex == startIndex && symbol2d.attributes.wallendindex == endIndex) || (symbol2d.attributes.wallstartindex == endIndex && symbol2d.attributes.wallendindex == startIndex)) {
- if (!this.calculateLine.segmentContainPoint(newWallPoint1, newWallPoint2, symbol2d.geometry.point1) || !this.calculateLine.segmentContainPoint(newWallPoint1, newWallPoint2, symbol2d.geometry.point2)) {
- this.layer.deleteSymbol(symbol2d.id, symbol2d.attributes.wallId);
- }
- else {
- var thick = this.layer.getThickness(this.currentState.currentWallId, this.currentState.currentstartlinePointIndex);
- if (!flag) {
- symbol2d.geometry.point1.x = symbol2d.geometry.point1.x + dx;
- symbol2d.geometry.point1.y = symbol2d.geometry.point1.y + dy;
- symbol2d.geometry.point2.x = symbol2d.geometry.point2.x + dx;
- symbol2d.geometry.point2.y = symbol2d.geometry.point2.y + dy;
- symbol2d.select = false;
- }
- else {
- var point = this.calculateLine.getNewSymbolPoint(symbol2d, newWallPoint1, newWallPoint2);
- symbol2d.geometry.point1 = point.point1;
- symbol2d.geometry.point2 = point.point2;
- symbol2d.select = false;
- }
- symbol2d.geometry.points = this.calculateElement.getSymbolPoints(symbol2d.geometry.point1, symbol2d.geometry.point2, symbol2d.geometry.geoType, symbol2d.attributes.toward, thick);
- }
- }
- else if (symbol2d.attributes.wallstartindex == startIndex || symbol2d.attributes.wallendindex == startIndex) {
- if (this.calculateLine.segmentContainPoint(symbol2d.geometry.point1, symbol2d.geometry.point2, newWallPoint1)) {
- this.layer.deleteSymbol(symbol2d.id, symbol2d.attributes.wallId);
- }
- }
- else if (symbol2d.attributes.wallstartindex == endIndex || symbol2d.attributes.wallendindex == endIndex) {
- if (this.calculateLine.segmentContainPoint(symbol2d.geometry.point1, symbol2d.geometry.point2, newWallPoint2)) {
- this.layer.deleteSymbol(symbol2d.id, symbol2d.attributes.wallId);
- }
- }
- }
- }
- };
- //修改门或窗等元素的index
- //id表示墙id
- //修改该墙上所有的门、窗等物体
- Move.prototype.updateSymbolIndex = function (id, startIndex) {
- if (this.layer.vectors[id].symbol2dsCount > 0) {
- for (var key in this.layer.vectors[id].symbol2Ds) {
- var symbol2d = this.layer.vectors[id].symbol2Ds[key];
- if (symbol2d.attributes.wallstartindex > startIndex) {
- --symbol2d.attributes.wallstartindex;
- --this.layer.vectors[symbol2d.vectorid].startindex;
- }
- else if (symbol2d.attributes.wallstartindex == startIndex) {
- if (symbol2d.attributes.wallstartindex != 0) {
- --symbol2d.attributes.wallstartindex;
- --this.layer.vectors[symbol2d.vectorid].startindex;
- }
- else {
- symbol2d.attributes.wallstartindex = this.layer.vectors[id].geometry.points.length - 2;
- this.layer.vectors[symbol2d.vectorid].startindex = this.layer.vectors[id].geometry.points.length - 2;
- }
- }
- }
- }
- };
- //修改该墙上所有的门、窗等物体
- Move.prototype.updateSymbolIndex2 = function (id, endIndex) {
- if (this.layer.vectors[id].symbol2dsCount > 0) {
- for (var key in this.layer.vectors[id].symbol2Ds) {
- var symbol2d = this.layer.vectors[id].symbol2Ds[key];
- if (symbol2d.attributes.wallstartindex > endIndex) {
- --symbol2d.attributes.wallstartindex;
- --this.layer.vectors[symbol2d.vectorid].startindex;
- }
- }
- }
- };
|