Pan.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. //CLASS:控制平移。
  2. function Pan(layer) {
  3. this.layer = layer;
  4. this.calculateLine = this.layer.calculateLine;
  5. this.calculateElement = this.layer.calculateElement;
  6. this.div = this.layer.div;
  7. this.currentState = this.layer.currentState;
  8. this.previousState = this.layer.previousState;
  9. this.calculateElement = this.layer.calculateElement;
  10. this.active();
  11. //区分双击和单击
  12. this._doubleclick = false;
  13. //拖拽背景
  14. this.f_draggingBackGround = false;
  15. //拖拽墙
  16. this.f_draggingWallLine = false;
  17. //拖拽楼梯面
  18. this.f_draggingStairLine = false;
  19. //拖拽墙角
  20. this.f_draggingWallCorner = false;
  21. //拖拽楼梯角
  22. this.f_draggingStairCorner = false;
  23. //拖拽门或窗等元素
  24. this.f_draggingSymbol = false;
  25. //拖拽symbol的端点
  26. this.f_draggingEndpoint = false;
  27. //拖拽旋转梯角
  28. this.f_draggingSpiralCorner = false;
  29. //拖拽旋转梯
  30. this.f_draggingSpiralPlane = false;
  31. //修建墙
  32. this.f_buildingWall = false;
  33. //修建隔断
  34. this.f_buildingPartition = false;
  35. //修建直梯
  36. this.f_buildingWinderStair = false;
  37. //修建螺旋梯
  38. this.f_buildingSpiral = false;
  39. //添加symbol,比如:门或者窗户等
  40. this.f_buildingSymbol = false;
  41. //用来判断拖拽函数调用了几次,如果少于2次,则弹出编辑框
  42. this.dragging = { count: 0, type: null };
  43. this.build = this.layer.build;
  44. this.select = this.layer.select;
  45. this.data2d = this.layer.data2d;
  46. this.move = this.layer.move;
  47. this.lastPoint = {};
  48. this.diffX = 0;
  49. this.diffY = 0;
  50. this.addNew();
  51. //控制显示编辑wall
  52. this.editwall = null;
  53. this.ajustEndPointForWall = null;
  54. };
  55. Pan.prototype.startPan = (function() {
  56. var strategy = {
  57. //建立墙或隔断
  58. wall: function (args) {
  59. this.layer.div.style.cursor = "crosshair";
  60. if ((this.build.buildwallState == 1 || this.build.buildwallState == 2) &&
  61. this.currentState.selectWallSet != null
  62. ) {
  63. this.build.buildwallState = null;
  64. var point = this.build.adjustPoint(args.point);
  65. this.build.temp_buildwallId != null && (
  66. this.layer.vectors[this.build.temp_buildwallId].geometry.points[1] = args.point
  67. );
  68. this.build.BuildingWall(point);
  69. this.layer.vectors[this.build.buildwallId].geometry.endLines = this.build.getRelaEndLines();
  70. this.ajustEndPointForWall = this.currentState.selectWallSet.id + ";" + this.build.buildwallId;
  71. this.build.finishWall();
  72. } else { //开始画墙
  73. this.build.buildwallState = 2;
  74. this.build.BuildingWall(point);
  75. }
  76. this.layer.control.refreshCanvas = true;
  77. },
  78. WinderStair: function (args) {
  79. this.layer.div.style.cursor = "crosshair";
  80. this.f_buildingWinderStair = true;
  81. if (this.build.buildwallState == 1) {
  82. this.build.buildwallState = 2;
  83. }
  84. this.build.BuildingWinderStair(args.point);
  85. },
  86. Spiral: function (args) {
  87. this.layer.div.style.cursor = "crosshair";
  88. this.build.BuildingSpiral(args.point);
  89. this.currentState.startbuild = null;
  90. },
  91. __default: function (args) {
  92. if (this.layer.build.tryAddSymbol == null) {
  93. this.f_draggingBackGround = false;
  94. this.f_draggingSpiralPlane = false;
  95. this.f_draggingWallCorner = false;
  96. this.f_draggingWallLine = false;
  97. this.f_draggingSpiralCorner = false;
  98. this.f_draggingStairLine = false;
  99. this.f_draggingStairCorner = false;
  100. if (this.currentState.selectWallSet != null) {
  101. this.f_draggingWallCorner = this.currentState.selectWallSet.type == 0; // 当前选择墙角
  102. this.f_draggingWallLine = this.currentState.selectWallSet.type == 1; // 当前选择墙面
  103. } else if (this.currentState.selectStairSet == null) {
  104. this.f_draggingBackGround = true;
  105. } else if (this.currentState.selectStairSet.geoType == "Spiral") {
  106. this.f_draggingSpiralCorner = this.currentState.selectStairSet.type == 0;
  107. this.f_draggingSpiralPlane = this.currentState.selectStairSet.type == 1
  108. } else {
  109. this.f_draggingStairCorner = this.currentState.selectStairSet.type == 0; // 当前选择楼梯角
  110. this.f_draggingStairLine = this.currentState.selectStairSet.type == 0; // 当前选择楼梯面
  111. }
  112. // this.f_draggingBackGround = true;
  113. }
  114. //当前选择墙面
  115. if (this.currentState.selectWallSet != null && this.currentState.selectWallSet.type == 1) {
  116. this.f_draggingBackGround = false;
  117. this.f_draggingWallLine = true;
  118. this.f_draggingWallCorner = false;
  119. this.select.f_selectWallLine = true;
  120. if (this.layer.build.tryAddSymbol != null) {
  121. this.select.convertTrue(this.layer.build.tryAddSymbol);
  122. this.layer.build.tryAddSymbol = null;
  123. this.f_draggingWallLine = false;
  124. } else if (this.select.f_selectSymbol) {
  125. this.f_draggingWallLine = false;
  126. this.f_draggingSymbol = true;
  127. this.select.f_selectWallLine = false;
  128. var symbol2d = this.layer.vectors[this.currentState.currentSymbolId];
  129. //编辑门或窗等元素的大小
  130. if (BABYLON.Vector2.Distance(symbol2d.geometry.point1, args.point) < sysmbolCircleR) {
  131. this.select.selectSymbolIds.selectEndPointIndex = 1;
  132. this.select.selectSymbolPoint(symbol2d, args.point);
  133. this.f_draggingEndpoint = true;
  134. } else if (BABYLON.Vector2.Distance(symbol2d.geometry.point2, args.point) < sysmbolCircleR) {
  135. this.select.selectSymbolIds.selectEndPointIndex = 2;
  136. this.select.selectSymbolPoint(symbol2d, args.point);
  137. this.f_draggingEndpoint = true;
  138. }
  139. } else {
  140. this.dragging.type = "wall";
  141. this.dragging.wallid = this.currentState.selectWallSet.id;
  142. this.dragging.index = this.currentState.selectWallSet.index;
  143. }
  144. }
  145. }
  146. }
  147. return function (e) {
  148. for (var key in strategy) {
  149. strategy[key] = strategy[key].bind(this)
  150. }
  151. strategy.partition = strategy.wall
  152. if (this.layer.control.draggingDialog) {
  153. return;
  154. }
  155. document.getElementById('configuratorWindow2').style.display = "none";
  156. this.currentState.addSymbol = null;
  157. //在一开始保存点击的位置。
  158. this.lastX = (e.offsetX || e.layerX);
  159. this.lastY = (e.offsetY || e.layerY);
  160. var point = this.layer.getPositionFromPx({ x: this.lastX, y: this.lastY });
  161. if (this.currentState.startbuild) {
  162. strategy[this.currentState.startbuild]({point: point})
  163. } else {
  164. strategy.__default({ point: point })
  165. }
  166. //设置鼠标样式。
  167. this.layer.div.style.cursor = "move";
  168. this.layer.renderer.autoRedraw();
  169. CanvasSketch.stopEventBubble(e);
  170. };
  171. })();
  172. // 在canvas上移动各个菜单对应发生的事件
  173. Pan.prototype.pan = function () {
  174. var strategy = {
  175. // 拖拽视图
  176. f_draggingBackGround: function (args) {
  177. this.layer.center.x -= args.dx * this.layer.res;
  178. this.layer.center.y += args.dy * this.layer.res;
  179. this.layer.moveTo(this.layer.zoom, this.layer.center);
  180. },
  181. // 拖拽直梯顶点
  182. f_draggingStairCorner: function (args) {
  183. this.move.moveStaircorner(
  184. this.currentState.currentStairId,
  185. this.currentState.currentstartlinePointIndex,
  186. args.point
  187. );
  188. },
  189. // 拖拽直梯中心线
  190. f_draggingStairLine: function (args) {
  191. this.move.moveStairLine(
  192. this.currentState.currentStairId,
  193. args.dx,
  194. args.dy,
  195. this.currentState.currentstartlinePointIndex,
  196. this.currentState.currentendlinePointIndex
  197. );
  198. },
  199. // 拖拽旋转体
  200. f_draggingSpiralCorner: function (args) {
  201. this.move.moveSpiralcorner(
  202. this.currentState.currentStairId,
  203. args.point,
  204. this.currentState.currentstartlinePointIndex
  205. );
  206. },
  207. // 拖拽螺旋体平面位置
  208. f_draggingSpiralPlane: function (args) {
  209. this.move.moveSpiralPlane(
  210. this.currentState.currentStairId,
  211. args.dx,
  212. args.dy
  213. );
  214. },
  215. // 拖拽墙面的角度
  216. f_draggingWallCorner: function (args) {
  217. this.move.moveWallcorner(
  218. args.wallid,
  219. this.currentState.currentstartlinePointIndex,
  220. args.point
  221. );
  222. },
  223. // 拖拽墙面中心线
  224. f_draggingWallLine: function (args) {
  225. this.move.moveWallLine(
  226. args.wallid,
  227. args.dx,
  228. args.dy,
  229. this.currentState.currentstartlinePointIndex,
  230. this.currentState.currentendlinePointIndex
  231. );
  232. this.dragging.count++
  233. },
  234. // 拖拽设置门窗顶点 设置位置
  235. f_draggingSymbol: function (args) {
  236. this.move.moveExistSymbol(
  237. this.lastPoint,
  238. args.point,
  239. this.currentState.currentSymbolId
  240. );
  241. },
  242. // 拖拽设置门窗顶点 设置长度
  243. f_draggingEndpoint: function (args) {
  244. this.move.moveSymbolEndpoint(args.point);
  245. },
  246. // 其余设置都经过
  247. __default: function (args) {
  248. if (this.f_buildingWall || this.f_buildingPartition) { //修墙
  249. this.build.buildwallState = 1;
  250. this.layer.build.BuildingWall(args.point);
  251. } else if (this.f_buildingWinderStair) { //修楼梯
  252. this.build.buildwallState = 1;
  253. this.layer.build.BuildingWinderStair(args.point);
  254. }
  255. this.previousState.save(this.currentState);
  256. this.currentState.selectStairSet = this.calculateElement.stairsContain(args.point); //判断是否在楼梯上
  257. if (this.currentState.selectStairSet != null &&
  258. this.currentState.addSymbol == null) {
  259. var stairid = this.currentState.selectStairSet.id;
  260. this.layer.vectors[stairid].geometry.geoType == "Spiral" ?
  261. strategy.__selectStairSpiral(args) :
  262. strategy.__selectStair(args)
  263. } else if (this.layer.data2d.wallIds.length > 0) {
  264. //当前点是否在墙上
  265. this.currentState.selectWallSet = this.calculateElement.wallsContain(args.point);
  266. this.currentState.selectWallSet ?
  267. strategy.__selectWallSet(args) :
  268. strategy.__selectNotWallSet(args)
  269. }
  270. },
  271. // 悬停在直梯上
  272. __selectStair: function (args) {
  273. var repeat = this.currentState.isRetain(this.previousState);
  274. if (!repeat) {
  275. this.select.clearSelect();
  276. this.currentState.currentendlinePointIndex = this.currentState.selectStairSet.endindex;
  277. this.currentState.currentStairId = this.currentState.selectStairSet.id;
  278. this.currentState.currentstartlinePointIndex = this.currentState.selectStairSet.index;
  279. }
  280. if (this.currentState.selectStairSet.type == 0) { //当前选择的是楼梯的拐角
  281. //状态变化,选择拐角
  282. repeat || this.select.selectStairCorner(
  283. this.currentState.selectStairSet.id,
  284. this.currentState.selectStairSet.index
  285. );
  286. } else if (this.currentState.selectStairSet.type == 1) { //当前选择的是楼梯面
  287. repeat || (this.select.f_selectStairLine = true)
  288. if (this.select.f_selectStairLine && this.currentState.currentLineId == null) {
  289. this.select.selectStairWallLine(
  290. this.currentState.currentStairId,
  291. this.currentState.currentstartlinePointIndex,
  292. this.currentState.currentendlinePointIndex
  293. );
  294. }
  295. }
  296. },
  297. // 悬停在螺旋梯形上
  298. __selectStairSpiral: function (args) {
  299. var stairid = this.currentState.selectStairSet.id;
  300. var repeat = this.previousState.type == this.currentState.selectStairSet.type &&
  301. this.previousState.currentStairId == stairid;
  302. if (!repeat) {
  303. if (this.currentState.selectStairSet.type == 0) {
  304. this.select.endselectSpiralPlane();
  305. this.select.selectSpiralCorner(
  306. this.currentState.selectStairSet.id,
  307. this.currentState.selectStairSet.index
  308. );
  309. } else {
  310. this.select.endselectSpiralCorner();
  311. this.select.selectSpiralPlane(this.currentState.selectStairSet.id);
  312. }
  313. }
  314. },
  315. // 什么都没选择,在空白区域移动
  316. __selectNotWallSet: function (args) {
  317. if (this.layer.build.tryAddSymbol != null && this.layer.build.tryAddSymbol.attributes.draw) {
  318. var moving = this.layer.move.moveVirtualSymbol2(this.layer.build.tryAddSymbol, args.point);
  319. if (!moving) {
  320. return;
  321. }
  322. } else {
  323. this.select.clearSelect();
  324. }
  325. },
  326. // 移动到墙面上
  327. __selectWallSet: function (args) {
  328. console.log('???')
  329. var repeat = !!this.currentState.isRetain(this.previousState);
  330. var r = this.layer.parameter.wallThickness &&
  331. this.layer.parameter.wallThickness / 2;
  332. if (!repeat) {
  333. this.select.clearSelect();
  334. this.currentState.currentendlinePointIndex = this.currentState.selectWallSet.endindex;
  335. this.currentState.currentWallId = this.currentState.selectWallSet.id;
  336. this.currentState.currentstartlinePointIndex = this.currentState.selectWallSet.index;
  337. }
  338. if (this.currentState.addSymbol != null) {
  339. return (
  340. this.layer.build.tryAddSymbol != null &&
  341. this.layer.build.tryAddSymbol.geometry.symbolType != "Stair"
  342. ) && this.layer.move.moveVirtualSymbol1(this.layer.build.tryAddSymbol, args.point) //添加假的元素:门、窗等
  343. }
  344. // 选择的是墙角 角度
  345. if (this.currentState.selectWallSet.type == 0) {
  346. !repeat && this.select.selectWallCorner(
  347. this.currentState.selectWallSet.id,
  348. this.currentState.selectWallSet.index
  349. );
  350. } else if (this.currentState.selectWallSet.type == 1) { //选择墙面
  351. !repeat && (this.select.f_selectWallLine = true);
  352. strategy.__stateChangeWall(args, this.currentState.currentWallId)
  353. }
  354. if (this.select.f_selectWallLine && this.currentState.currentLineId == null) {
  355. this.select.selectStairWallLine(
  356. this.currentState.currentWallId,
  357. this.currentState.currentstartlinePointIndex,
  358. this.currentState.currentendlinePointIndex
  359. );
  360. } else if (!this.select.f_selectWallLine) {
  361. this.select.endSelectWallLine();
  362. }
  363. },
  364. //状态变化,选择墙面
  365. __stateChangeWall: function(args, id) {
  366. //从当前选择的symbol到不选择这个symbol
  367. if (this.currentState.currentSymbolId != null) {
  368. var symbol2d = this.layer.vectors[id].symbol2Ds[this.currentState.currentSymbolId];
  369. var index = Math.min(
  370. symbol2d.attributes.wallstartindex,
  371. symbol2d.attributes.wallendindex
  372. );
  373. var r = this.layer.vectors[id].geometry.wallInfo[index].thick / 2;
  374. if (!this.calculateElement.lineContain(
  375. symbol2d.geometry.point1,
  376. symbol2d.geometry.point2,
  377. args.point, r)
  378. ) {
  379. this.select.endSelectSymbol(
  380. this.select.selectSymbolIds.vectorid,
  381. this.select.selectSymbolIds.selects,
  382. this.select.selectSymbolIds.vectorMeasureid
  383. );
  384. this.select.f_selectSymbol = false;
  385. this.select.f_selectWallLine = true;
  386. }
  387. } else { //当前没有选择symbol
  388. var symbol2d = this.calculateElement.symbolsContain(args.point);
  389. if (symbol2d != null) {
  390. this.select.f_selectWallLine = false;
  391. this.select.drawMeasure(symbol2d);
  392. this.select.selectSymbol(symbol2d);
  393. //选择好symbol的时候,不选择墙面
  394. this.select.f_selectWallLine = false;
  395. }
  396. }
  397. }
  398. }
  399. return function (e) {
  400. for (var key in strategy) {
  401. strategy[key] = strategy[key].bind(this)
  402. }
  403. if (this.layer.control.draggingDialog) {
  404. return
  405. }
  406. var offsetX = (e.offsetX || e.layerX)
  407. var offsetY = (e.offsetY || e.layerY)
  408. var args = {
  409. dx: offsetX - this.lastX, //计算改变的像素值
  410. dy: offsetY - this.lastY,
  411. point: this.layer.getPositionFromPx({ x: offsetX, y: offsetY }), //当前位置
  412. wallid: this.currentState.currentWallId
  413. }
  414. if (args.dx == 0 && args.dy == 0) {
  415. return CanvasSketch.stopEventBubble(e);
  416. }
  417. // 保存最后一次位置
  418. this.lastPoint = this.layer.getPositionFromPx(
  419. { x: this.lastX, y: this.lastY }
  420. );
  421. // 更新位置
  422. this.lastX = offsetX;
  423. this.lastY = offsetY;
  424. for (var i = 0, keys = Object.keys(strategy); i < keys.length; i++) {
  425. if (this[keys[i]]) {
  426. console.log(this[keys[i]])
  427. strategy[keys[i]](args);
  428. break;
  429. }
  430. }
  431. (i === keys.length) && strategy.__default(args)
  432. if (this.layer.control.refreshCanvas ||
  433. this.layer.control.refreshBackgroundCanvas ||
  434. this.layer.control.refreshSelectCanvas) {
  435. this.layer.renderer.autoRedraw();
  436. }
  437. CanvasSketch.stopEventBubble(e);
  438. };
  439. }();
  440. Pan.prototype.endPan = function (e) {
  441. if (this.layer.control.draggingDialog) {
  442. return;
  443. }
  444. this.layer.div.style.cursor = "default";
  445. //调整墙的测量线
  446. var flag = false;
  447. if (this.f_draggingWallCorner) {
  448. this.layer.build.adjustEndPoint(this.currentState.currentWallId);
  449. flag = true;
  450. }
  451. else if (this.f_draggingWallLine) {
  452. if (this.dragging.count < 3) {
  453. //弹出编辑框
  454. clearTimeout(this.editwall);
  455. this.editwall = setTimeout("this.layer.menu.showWallDialog()", 800);
  456. this.layer.menu.initEdit2D(this.dragging.wallid, this.dragging.index);
  457. }
  458. else {
  459. this.layer.build.adjustEndPoint(this.currentState.currentWallId);
  460. flag = true;
  461. }
  462. this.dragging.count = 0;
  463. this.f_draggingWallLine = false;
  464. }
  465. else if (this.ajustEndPointForWall != null) {
  466. var ids = this.ajustEndPointForWall.split(";")
  467. this.layer.build.adjustEndPoint2(ids[1], ids[0]);
  468. this.ajustEndPointForWall = null;
  469. flag = true;
  470. }
  471. if (flag) {
  472. this.layer.control.refreshCanvas = true;
  473. this.layer.renderer.autoRedraw();
  474. //调整墙的测量线
  475. }
  476. this.reset();
  477. CanvasSketch.stopEventBubble(e);
  478. };
  479. Pan.prototype.doubleclick = function (e) {
  480. //clearTimeout(this.timeId);
  481. var id = this.currentState.currentWallId;
  482. clearTimeout(this.editwall);
  483. document.getElementById('configuratorWindow2').style.display = "none";
  484. if (this.currentState.currentSymbolId != null) {
  485. return;
  486. }
  487. //建墙
  488. //if(this.currentState.currentLineId==null)
  489. if (this.currentState.startbuild == "wall" || this.currentState.startbuild == "partition") {
  490. this.build.finishWall();
  491. this.layer.control.refreshCanvas = true;
  492. }
  493. else if (this.currentState.startbuild == "WinderStair") {
  494. this.build.buildwallState = null;
  495. this.f_buildingWinderStair = false;
  496. var point = this.layer.getPositionFromPx({ x: (e.offsetX || e.layerX), y: (e.offsetY || e.layerY) });
  497. this.build.BuildingWinderStair(point);
  498. }
  499. //墙面上双击
  500. else if (!this.currentState.startbuild && this.currentState.selectWallSet != null && this.currentState.selectWallSet.type == 1) {
  501. var point = this.layer.getPositionFromPx({ x: (e.offsetX || e.layerX), y: (e.offsetY || e.layerY) });
  502. var line = this.calculateLine.createLine(this.layer.vectors[id].geometry.points[this.currentState.currentstartlinePointIndex], this.layer.vectors[id].geometry.points[this.currentState.currentendlinePointIndex]);
  503. point = this.calculateLine.getJoinLinePoint(point, line);
  504. point = new Point(point.x, point.y);
  505. point.floor = this.layer.vectors[id].geometry.points[this.currentState.currentstartlinePointIndex].floor;
  506. var points = this.layer.vectors[id].geometry.points;
  507. points.splice(this.currentState.currentstartlinePointIndex + 1, 0, point);
  508. var wallInfo = {};
  509. wallInfo.height = this.layer.vectors[id].geometry.wallInfo[this.currentState.currentstartlinePointIndex].height;
  510. wallInfo.thick = this.layer.vectors[id].geometry.wallInfo[this.currentState.currentstartlinePointIndex].thick;
  511. wallInfo.measuredistance = this.layer.vectors[id].geometry.wallInfo[this.currentState.currentstartlinePointIndex].measuredistance;
  512. this.layer.vectors[id].geometry.wallInfo.splice(this.currentState.currentstartlinePointIndex + 1, 0, wallInfo);
  513. this.calculateElement.updateSymbolsWallCornerIndexAdd(id, this.currentState.currentstartlinePointIndex + 1, point);
  514. this.layer.vectors[id].geometry.points = points;
  515. this.layer.drawVector(this.layer.vectors[id]);
  516. var index = this.currentState.currentstartlinePointIndex + 1;
  517. //this.layer.vectors[id].geometry.wallInfo[index].height = this.layer.vectors[id].geometry.wallInfo[this.currentState.currentstartlinePointIndex].height;
  518. //this.layer.vectors[id].geometry.wallInfo[index].thick = this.layer.vectors[id].geometry.wallInfo[this.currentState.currentstartlinePointIndex].height;
  519. //this.layer.vectors[id].geometry.wallInfo[index].measuredistance = this.layer.vectors[id].geometry.wallInfo[this.currentState.currentstartlinePointIndex].height;
  520. this.select.clearSelect();
  521. this.currentState.currentWallId = id;
  522. this.select.selectWallCorner(id, index);
  523. }
  524. this.layer.renderer.autoRedraw();
  525. CanvasSketch.stopEventBubble(e);
  526. };
  527. Pan.prototype.Events = [["mousedown", Pan.prototype.startPan],
  528. ["mousemove", Pan.prototype.pan],
  529. ["mouseup", Pan.prototype.endPan],
  530. ["dblclick", Pan.prototype.doubleclick]];
  531. Pan.prototype.active = function () {
  532. this.div.addEventListener("mousedown", Pan.prototype.startPan.bind(this), true);
  533. this.div.addEventListener("mousemove", Pan.prototype.pan.bind(this), true);
  534. this.div.addEventListener("mouseup", Pan.prototype.endPan.bind(this), true);
  535. this.div.addEventListener("dblclick", Pan.prototype.doubleclick.bind(this), true);
  536. };
  537. Pan.prototype.reset = function () {
  538. this.f_draggingBackGround = false;
  539. this.f_draggingWallLine = false;
  540. this.f_draggingWallCorner = false;
  541. this.f_draggingStairLine = false;
  542. this.f_draggingStairCorner = false;
  543. this.f_draggingSpiralPlane = false;
  544. this.f_draggingSpiralCorner = false;
  545. this.f_draggingSymbol = false;
  546. this.f_draggingEndpoint = false;
  547. //this.f_buildingWall=false;
  548. this.f_buildingSymbol = false;
  549. };
  550. //新建一个空白页
  551. Pan.prototype.addNew = function () {
  552. document.getElementById("toolbarMenu").addEventListener("click", function (e) {
  553. if (e.target.parentElement.parentElement.id == "toolbarNew") {
  554. if (confirm("您确定要重新打开网页?")) {
  555. //如果是true ,那么就把页面刷新
  556. //location.reload();
  557. this.layer.menu.show2D();
  558. for (var vectorId in this.layer.vectors) {
  559. this.layer.deleteVector(vectorId);
  560. this.layer.data2d.wallIds = [];
  561. }
  562. this.layer.clear();
  563. this.select.clearSelect();
  564. if (my3DEngine != null && typeof (my3DEngine) != "undefined") {
  565. my3DEngine.clearAllSymbols();
  566. my3DEngine = null;
  567. }
  568. one3d = true;
  569. this.currentState.currentWallId = null;
  570. addWall();
  571. }
  572. }
  573. else if (e.target.parentElement.parentElement.id == "toolbarSave") {
  574. alert("save");
  575. }
  576. else if (e.target.parentElement.parentElement.id == "toolbarOption") {
  577. var aw = document.getElementById("aboutWindow");
  578. aw.style.display = "block";
  579. //alert("option");
  580. }
  581. else if (e.target.parentElement.parentElement.id == "userOption") {
  582. alert("user");
  583. }
  584. }.bind(this));
  585. function addWall() {
  586. var vectors = [];
  587. var points = [];
  588. var point1 = new Point(wallleftX, wallleftY);
  589. points.push(point1);
  590. var point2 = new Point(wallrightX, wallleftY);
  591. points.push(point2);
  592. var point3 = new Point(wallrightX, wallrightY);
  593. points.push(point3);
  594. var point4 = new Point(wallleftX, wallrightY);
  595. points.push(point4);
  596. var wall = new Wall(points, document.getElementById("imgWall"));
  597. var vector = new Vector(wall, wallStyle);
  598. wallId = vector.id;
  599. vectors.push(vector);
  600. this.layer.addVectors(vectors);
  601. this.layer.data2d.wallIds.push(wallId);
  602. }
  603. };