Vector.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. //CLASS:矢量图形类
  2. function Vector(geometry, style, attributes) {
  3. this.id = CanvasSketch.getId("vector");
  4. this.geometry = geometry;
  5. this.symbol2Ds={};
  6. this.symbol2dsCount=0;
  7. this.style = style;
  8. /*
  9. 墙有这种属性,主要是墙上面的symbol
  10. children
  11. 主要是针对symbol,其所在墙的id
  12. wallId=null;
  13. 与墙重合的宽度
  14. width;
  15. //所在墙的端点的位置,如果是墙角,则wallendindex没有值
  16. wallstartindex;
  17. wallendindex;
  18. //门或窗的端点坐标
  19. point1;
  20. point2;
  21. //朝向
  22. //如果为1,表示当前点对应的直线中的b要大于symbol对应的b
  23. //如果为-1,表示小于
  24. //如果当前symbol对应的线是平行于x轴,则1表示对应的y大于symbol对应的y,-1表示小于
  25. //如果当前symbol对应的线是平行于y轴,则1表示对应的x大于symbol对应的x,-1表示小于
  26. toward=1;
  27. vectorMeasureid=null;
  28. select=false;
  29. calculatePoints=false;
  30. exist=false;
  31. selectSymbolIds=[];
  32. */
  33. if(attributes) {
  34. this.attributes = attributes;
  35. }
  36. else
  37. {
  38. this.attributes={};
  39. }
  40. };
  41. Vector.prototype.setwallInfo = function (wallid,startindex,endindex) {
  42. this.attributes.wallId=wallid;
  43. this.attributes.wallstartindex=startindex;
  44. this.attributes.wallendindex=endindex;
  45. };
  46. Vector.prototype.update = function (layer,wallid,startindex,endindex,point){
  47. //向symbol设置墙的信息
  48. this.setwallInfo(wallid,startindex,endindex);
  49. //更新其他点
  50. var thick=layer.getThickness(wallid,startindex);
  51. this.geometry.wallType=layer.vectors[this.attributes.wallId].geometry.wallType;
  52. if(point!=null)
  53. {
  54. this.attributes.toward = layer.calculateLine.getToward(this.geometry.point1,this.geometry.point2,point);
  55. }
  56. this.geometry.points=layer.calculateElement.getSymbolPoints(this.geometry.point1,this.geometry.point2,this.geometry.geoType,this.attributes.toward,thick);
  57. if(!this.attributes.draw)
  58. {
  59. layer.drawSingleVector(this);
  60. layer.vectors[this.id] = this;
  61. this.attributes.draw=true;
  62. }
  63. };
  64. Vector.prototype.getSymbolLen = function () {
  65. /*
  66. if(this.geometry.geoType=="Symbol2D_OpeningWindow")
  67. {
  68. return layer.parameter.windowLength[0];
  69. }
  70. else if(this.geometry.geoType=="Symbol2D_OpeningDoor")
  71. {
  72. return layer.parameter.doorLength[0];
  73. }
  74. else if(this.geometry.geoType=="Symbol2D_SimpleDoor")
  75. {
  76. return layer.parameter.doorLength[1];
  77. }
  78. else if(this.geometry.geoType=="Symbol2D_SingleCasement")
  79. {
  80. return layer.parameter.windowLength[1];
  81. }
  82. else if(this.geometry.geoType=="Symbol2D_SlidingDoor")
  83. {
  84. return layer.parameter.doorLength[2];
  85. }
  86. else if(this.geometry.geoType=="Symbol2D_SlidingWindow")
  87. {
  88. return layer.parameter.windowLength[2];
  89. }
  90. */
  91. if(this.geometry.points!=null&&this.geometry.points.length>0)
  92. {
  93. //return BABYLON.Vector2.Distance(this.points[0],this.points[1]);
  94. return BABYLON.Vector2.Distance(this.geometry.point1,this.geometry.point2);
  95. }
  96. else if(this.geometry.geoType=="OpenDoor")
  97. {
  98. return 80;
  99. }
  100. else if(this.geometry.geoType=="OpenWindow")
  101. {
  102. return 60;
  103. }
  104. else if(this.geometry.geoType=="SimpleDoor")
  105. {
  106. return 80;
  107. }
  108. else if(this.geometry.geoType=="SingleCasement")
  109. {
  110. return 60;
  111. }
  112. else if(this.geometry.geoType=="BiFoldDoor")
  113. {
  114. return 120;
  115. }
  116. else if(this.geometry.geoType=="DoubleCasement")
  117. {
  118. return 100;
  119. }
  120. else if(this.geometry.geoType=="SlidingDoor")
  121. {
  122. return 120;
  123. }
  124. else if(this.geometry.geoType=="SlidingWindow")
  125. {
  126. return 100;
  127. }
  128. };