123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- //CLASS:矢量图形类
- function Vector(geometry, style, attributes) {
- this.id = CanvasSketch.getId("vector");
- this.geometry = geometry;
- this.symbol2Ds={};
- this.symbol2dsCount=0;
- this.style = style;
-
- /*
- 墙有这种属性,主要是墙上面的symbol
- children
- 主要是针对symbol,其所在墙的id
- wallId=null;
- 与墙重合的宽度
- width;
- //所在墙的端点的位置,如果是墙角,则wallendindex没有值
- wallstartindex;
- wallendindex;
-
- //门或窗的端点坐标
- point1;
- point2;
-
- //朝向
- //如果为1,表示当前点对应的直线中的b要大于symbol对应的b
- //如果为-1,表示小于
- //如果当前symbol对应的线是平行于x轴,则1表示对应的y大于symbol对应的y,-1表示小于
- //如果当前symbol对应的线是平行于y轴,则1表示对应的x大于symbol对应的x,-1表示小于
- toward=1;
-
- vectorMeasureid=null;
- select=false;
- calculatePoints=false;
- exist=false;
- selectSymbolIds=[];
- */
- if(attributes) {
- this.attributes = attributes;
- }
- else
- {
- this.attributes={};
- }
- };
- Vector.prototype.setwallInfo = function (wallid,startindex,endindex) {
- this.attributes.wallId=wallid;
- this.attributes.wallstartindex=startindex;
- this.attributes.wallendindex=endindex;
- };
- Vector.prototype.update = function (layer,wallid,startindex,endindex,point){
-
- //向symbol设置墙的信息
- this.setwallInfo(wallid,startindex,endindex);
- //更新其他点
- var thick=layer.getThickness(wallid,startindex);
- this.geometry.wallType=layer.vectors[this.attributes.wallId].geometry.wallType;
- if(point!=null)
- {
- this.attributes.toward = layer.calculateLine.getToward(this.geometry.point1,this.geometry.point2,point);
- }
-
- this.geometry.points=layer.calculateElement.getSymbolPoints(this.geometry.point1,this.geometry.point2,this.geometry.geoType,this.attributes.toward,thick);
-
- if(!this.attributes.draw)
- {
- layer.drawSingleVector(this);
- layer.vectors[this.id] = this;
- this.attributes.draw=true;
- }
- };
- Vector.prototype.getSymbolLen = function () {
- /*
- if(this.geometry.geoType=="Symbol2D_OpeningWindow")
- {
- return layer.parameter.windowLength[0];
- }
- else if(this.geometry.geoType=="Symbol2D_OpeningDoor")
- {
- return layer.parameter.doorLength[0];
- }
- else if(this.geometry.geoType=="Symbol2D_SimpleDoor")
- {
- return layer.parameter.doorLength[1];
- }
- else if(this.geometry.geoType=="Symbol2D_SingleCasement")
- {
- return layer.parameter.windowLength[1];
- }
- else if(this.geometry.geoType=="Symbol2D_SlidingDoor")
- {
- return layer.parameter.doorLength[2];
- }
- else if(this.geometry.geoType=="Symbol2D_SlidingWindow")
- {
- return layer.parameter.windowLength[2];
- }
- */
- if(this.geometry.points!=null&&this.geometry.points.length>0)
- {
- //return BABYLON.Vector2.Distance(this.points[0],this.points[1]);
- return BABYLON.Vector2.Distance(this.geometry.point1,this.geometry.point2);
- }
- else if(this.geometry.geoType=="OpenDoor")
- {
- return 80;
- }
- else if(this.geometry.geoType=="OpenWindow")
- {
- return 60;
- }
- else if(this.geometry.geoType=="SimpleDoor")
- {
- return 80;
- }
- else if(this.geometry.geoType=="SingleCasement")
- {
- return 60;
- }
- else if(this.geometry.geoType=="BiFoldDoor")
- {
- return 120;
- }
- else if(this.geometry.geoType=="DoubleCasement")
- {
- return 100;
- }
- else if(this.geometry.geoType=="SlidingDoor")
- {
- return 120;
- }
- else if(this.geometry.geoType=="SlidingWindow")
- {
- return 100;
- }
- };
|