123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062 |
- 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];
- var fixPoint = null;
- for (var key in this.layer.vectors[wallid].symbol2Ds) {
- 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;
- }
- }
- }
- };
|