Pan.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  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. console.log(this.currentState.selectWallSet)
  267. this.currentState.selectWallSet ?
  268. strategy.__selectWallSet(args) :
  269. strategy.__selectNotWallSet(args)
  270. }
  271. },
  272. // 悬停在直梯上
  273. __selectStair: function (args) {
  274. var repeat = this.currentState.isRetain(this.previousState);
  275. if (!repeat) {
  276. this.select.clearSelect();
  277. this.currentState.currentendlinePointIndex = this.currentState.selectStairSet.endindex;
  278. this.currentState.currentStairId = this.currentState.selectStairSet.id;
  279. this.currentState.currentstartlinePointIndex = this.currentState.selectStairSet.index;
  280. }
  281. if (this.currentState.selectStairSet.type == 0) { //当前选择的是楼梯的拐角
  282. //状态变化,选择拐角
  283. repeat || this.select.selectStairCorner(
  284. this.currentState.selectStairSet.id,
  285. this.currentState.selectStairSet.index
  286. );
  287. } else if (this.currentState.selectStairSet.type == 1) { //当前选择的是楼梯面
  288. repeat || (this.select.f_selectStairLine = true)
  289. if (this.select.f_selectStairLine && this.currentState.currentLineId == null) {
  290. this.select.selectStairWallLine(
  291. this.currentState.currentStairId,
  292. this.currentState.currentstartlinePointIndex,
  293. this.currentState.currentendlinePointIndex
  294. );
  295. }
  296. }
  297. },
  298. // 悬停在螺旋梯形上
  299. __selectStairSpiral: function (args) {
  300. var stairid = this.currentState.selectStairSet.id;
  301. var repeat = this.previousState.type == this.currentState.selectStairSet.type &&
  302. this.previousState.currentStairId == stairid;
  303. if (!repeat) {
  304. if (this.currentState.selectStairSet.type == 0) {
  305. this.select.endselectSpiralPlane();
  306. this.select.selectSpiralCorner(
  307. this.currentState.selectStairSet.id,
  308. this.currentState.selectStairSet.index
  309. );
  310. } else {
  311. this.select.endselectSpiralCorner();
  312. this.select.selectSpiralPlane(this.currentState.selectStairSet.id);
  313. }
  314. }
  315. },
  316. // 什么都没选择,在空白区域移动
  317. __selectNotWallSet: function (args) {
  318. if (this.layer.build.tryAddSymbol != null && this.layer.build.tryAddSymbol.attributes.draw) {
  319. var moving = this.layer.move.moveVirtualSymbol2(this.layer.build.tryAddSymbol, args.point);
  320. if (!moving) {
  321. return;
  322. }
  323. } else {
  324. this.select.clearSelect();
  325. }
  326. },
  327. // 移动到墙面上
  328. __selectWallSet: function (args) {
  329. console.log('???')
  330. var repeat = !!this.currentState.isRetain(this.previousState);
  331. var r = this.layer.parameter.wallThickness &&
  332. this.layer.parameter.wallThickness / 2;
  333. if (!repeat) {
  334. this.select.clearSelect();
  335. this.currentState.currentendlinePointIndex = this.currentState.selectWallSet.endindex;
  336. this.currentState.currentWallId = this.currentState.selectWallSet.id;
  337. this.currentState.currentstartlinePointIndex = this.currentState.selectWallSet.index;
  338. }
  339. if (this.currentState.addSymbol != null) {
  340. return (
  341. this.layer.build.tryAddSymbol != null &&
  342. this.layer.build.tryAddSymbol.geometry.symbolType != "Stair"
  343. ) && this.layer.move.moveVirtualSymbol1(this.layer.build.tryAddSymbol, args.point) //添加假的元素:门、窗等
  344. }
  345. // 选择的是墙角 角度
  346. if (this.currentState.selectWallSet.type == 0) {
  347. !repeat && this.select.selectWallCorner(
  348. this.currentState.selectWallSet.id,
  349. this.currentState.selectWallSet.index
  350. );
  351. } else if (this.currentState.selectWallSet.type == 1) { //选择墙面
  352. !repeat && (this.select.f_selectWallLine = true);
  353. strategy.__stateChangeWall(args, this.currentState.currentWallId)
  354. }
  355. if (this.select.f_selectWallLine && this.currentState.currentLineId == null) {
  356. this.select.selectStairWallLine(
  357. this.currentState.currentWallId,
  358. this.currentState.currentstartlinePointIndex,
  359. this.currentState.currentendlinePointIndex
  360. );
  361. } else if (!this.select.f_selectWallLine) {
  362. this.select.endSelectWallLine();
  363. }
  364. },
  365. //状态变化,选择墙面
  366. __stateChangeWall: function(args, id) {
  367. //从当前选择的symbol到不选择这个symbol
  368. if (this.currentState.currentSymbolId != null) {
  369. var symbol2d = this.layer.vectors[id].symbol2Ds[this.currentState.currentSymbolId];
  370. var index = Math.min(
  371. symbol2d.attributes.wallstartindex,
  372. symbol2d.attributes.wallendindex
  373. );
  374. var r = this.layer.vectors[id].geometry.wallInfo[index].thick / 2;
  375. if (!this.calculateElement.lineContain(
  376. symbol2d.geometry.point1,
  377. symbol2d.geometry.point2,
  378. args.point, r)
  379. ) {
  380. this.select.endSelectSymbol(
  381. this.select.selectSymbolIds.vectorid,
  382. this.select.selectSymbolIds.selects,
  383. this.select.selectSymbolIds.vectorMeasureid
  384. );
  385. this.select.f_selectSymbol = false;
  386. this.select.f_selectWallLine = true;
  387. }
  388. } else { //当前没有选择symbol
  389. var symbol2d = this.calculateElement.symbolsContain(args.point);
  390. if (symbol2d != null) {
  391. this.select.f_selectWallLine = false;
  392. this.select.drawMeasure(symbol2d);
  393. this.select.selectSymbol(symbol2d);
  394. //选择好symbol的时候,不选择墙面
  395. this.select.f_selectWallLine = false;
  396. }
  397. }
  398. }
  399. }
  400. return function (e) {
  401. for (var key in strategy) {
  402. strategy[key] = strategy[key].bind(this)
  403. }
  404. if (this.layer.control.draggingDialog) {
  405. return
  406. }
  407. var offsetX = (e.offsetX || e.layerX)
  408. var offsetY = (e.offsetY || e.layerY)
  409. var args = {
  410. dx: offsetX - this.lastX, //计算改变的像素值
  411. dy: offsetY - this.lastY,
  412. point: this.layer.getPositionFromPx({ x: offsetX, y: offsetY }), //当前位置
  413. wallid: this.currentState.currentWallId
  414. }
  415. if (args.dx == 0 && args.dy == 0) {
  416. return CanvasSketch.stopEventBubble(e);
  417. }
  418. // 保存最后一次位置
  419. this.lastPoint = this.layer.getPositionFromPx(
  420. { x: this.lastX, y: this.lastY }
  421. );
  422. // 更新位置
  423. this.lastX = offsetX;
  424. this.lastY = offsetY;
  425. for (var i = 0, keys = Object.keys(strategy); i < keys.length; i++) {
  426. if (this[keys[i]]) {
  427. console.log(this[keys[i]])
  428. strategy[keys[i]](args);
  429. break;
  430. }
  431. }
  432. (i === keys.length) && strategy.__default(args)
  433. if (this.layer.control.refreshCanvas ||
  434. this.layer.control.refreshBackgroundCanvas ||
  435. this.layer.control.refreshSelectCanvas) {
  436. this.layer.renderer.autoRedraw();
  437. }
  438. CanvasSketch.stopEventBubble(e);
  439. };
  440. }();
  441. Pan.prototype.endPan = function (e) {
  442. if (this.layer.control.draggingDialog) {
  443. return;
  444. }
  445. this.layer.div.style.cursor = "default";
  446. //调整墙的测量线
  447. var flag = false;
  448. if (this.f_draggingWallCorner) {
  449. this.layer.build.adjustEndPoint(this.currentState.currentWallId);
  450. flag = true;
  451. }
  452. else if (this.f_draggingWallLine) {
  453. if (this.dragging.count < 3) {
  454. //弹出编辑框
  455. clearTimeout(this.editwall);
  456. this.editwall = setTimeout("this.layer.menu.showWallDialog()", 800);
  457. this.layer.menu.initEdit2D(this.dragging.wallid, this.dragging.index);
  458. }
  459. else {
  460. this.layer.build.adjustEndPoint(this.currentState.currentWallId);
  461. flag = true;
  462. }
  463. this.dragging.count = 0;
  464. this.f_draggingWallLine = false;
  465. }
  466. else if (this.ajustEndPointForWall != null) {
  467. var ids = this.ajustEndPointForWall.split(";")
  468. this.layer.build.adjustEndPoint2(ids[1], ids[0]);
  469. this.ajustEndPointForWall = null;
  470. flag = true;
  471. }
  472. if (flag) {
  473. this.layer.control.refreshCanvas = true;
  474. this.layer.renderer.autoRedraw();
  475. //调整墙的测量线
  476. }
  477. this.reset();
  478. CanvasSketch.stopEventBubble(e);
  479. };
  480. Pan.prototype.doubleclick = function (e) {
  481. //clearTimeout(this.timeId);
  482. var id = this.currentState.currentWallId;
  483. clearTimeout(this.editwall);
  484. document.getElementById('configuratorWindow2').style.display = "none";
  485. if (this.currentState.currentSymbolId != null) {
  486. return;
  487. }
  488. //建墙
  489. //if(this.currentState.currentLineId==null)
  490. if (this.currentState.startbuild == "wall" || this.currentState.startbuild == "partition") {
  491. this.build.finishWall();
  492. this.layer.control.refreshCanvas = true;
  493. }
  494. else if (this.currentState.startbuild == "WinderStair") {
  495. this.build.buildwallState = null;
  496. this.f_buildingWinderStair = false;
  497. var point = this.layer.getPositionFromPx({ x: (e.offsetX || e.layerX), y: (e.offsetY || e.layerY) });
  498. this.build.BuildingWinderStair(point);
  499. }
  500. //墙面上双击
  501. else if (!this.currentState.startbuild && this.currentState.selectWallSet != null && this.currentState.selectWallSet.type == 1) {
  502. var point = this.layer.getPositionFromPx({ x: (e.offsetX || e.layerX), y: (e.offsetY || e.layerY) });
  503. var line = this.calculateLine.createLine(this.layer.vectors[id].geometry.points[this.currentState.currentstartlinePointIndex], this.layer.vectors[id].geometry.points[this.currentState.currentendlinePointIndex]);
  504. point = this.calculateLine.getJoinLinePoint(point, line);
  505. point = new Point(point.x, point.y);
  506. point.floor = this.layer.vectors[id].geometry.points[this.currentState.currentstartlinePointIndex].floor;
  507. var points = this.layer.vectors[id].geometry.points;
  508. points.splice(this.currentState.currentstartlinePointIndex + 1, 0, point);
  509. var wallInfo = {};
  510. wallInfo.height = this.layer.vectors[id].geometry.wallInfo[this.currentState.currentstartlinePointIndex].height;
  511. wallInfo.thick = this.layer.vectors[id].geometry.wallInfo[this.currentState.currentstartlinePointIndex].thick;
  512. wallInfo.measuredistance = this.layer.vectors[id].geometry.wallInfo[this.currentState.currentstartlinePointIndex].measuredistance;
  513. this.layer.vectors[id].geometry.wallInfo.splice(this.currentState.currentstartlinePointIndex + 1, 0, wallInfo);
  514. this.calculateElement.updateSymbolsWallCornerIndexAdd(id, this.currentState.currentstartlinePointIndex + 1, point);
  515. this.layer.vectors[id].geometry.points = points;
  516. this.layer.drawVector(this.layer.vectors[id]);
  517. var index = this.currentState.currentstartlinePointIndex + 1;
  518. //this.layer.vectors[id].geometry.wallInfo[index].height = this.layer.vectors[id].geometry.wallInfo[this.currentState.currentstartlinePointIndex].height;
  519. //this.layer.vectors[id].geometry.wallInfo[index].thick = this.layer.vectors[id].geometry.wallInfo[this.currentState.currentstartlinePointIndex].height;
  520. //this.layer.vectors[id].geometry.wallInfo[index].measuredistance = this.layer.vectors[id].geometry.wallInfo[this.currentState.currentstartlinePointIndex].height;
  521. this.select.clearSelect();
  522. this.currentState.currentWallId = id;
  523. this.select.selectWallCorner(id, index);
  524. }
  525. this.layer.renderer.autoRedraw();
  526. CanvasSketch.stopEventBubble(e);
  527. };
  528. Pan.prototype.Events = [["mousedown", Pan.prototype.startPan],
  529. ["mousemove", Pan.prototype.pan],
  530. ["mouseup", Pan.prototype.endPan],
  531. ["dblclick", Pan.prototype.doubleclick]];
  532. Pan.prototype.active = function () {
  533. this.div.addEventListener("mousedown", Pan.prototype.startPan.bind(this), true);
  534. this.div.addEventListener("mousemove", Pan.prototype.pan.bind(this), true);
  535. this.div.addEventListener("mouseup", Pan.prototype.endPan.bind(this), true);
  536. this.div.addEventListener("dblclick", Pan.prototype.doubleclick.bind(this), true);
  537. };
  538. Pan.prototype.reset = function () {
  539. this.f_draggingBackGround = false;
  540. this.f_draggingWallLine = false;
  541. this.f_draggingWallCorner = false;
  542. this.f_draggingStairLine = false;
  543. this.f_draggingStairCorner = false;
  544. this.f_draggingSpiralPlane = false;
  545. this.f_draggingSpiralCorner = false;
  546. this.f_draggingSymbol = false;
  547. this.f_draggingEndpoint = false;
  548. //this.f_buildingWall=false;
  549. this.f_buildingSymbol = false;
  550. };
  551. //新建一个空白页
  552. Pan.prototype.addNew = function () {
  553. document.getElementById("toolbarMenu").addEventListener("click", function (e) {
  554. if (e.target.parentElement.parentElement.id == "toolbarNew") {
  555. if (confirm("您确定要重新打开网页?")) {
  556. //如果是true ,那么就把页面刷新
  557. //location.reload();
  558. this.layer.menu.show2D();
  559. for (var vectorId in this.layer.vectors) {
  560. this.layer.deleteVector(vectorId);
  561. this.layer.data2d.wallIds = [];
  562. }
  563. this.layer.clear();
  564. this.select.clearSelect();
  565. if (my3DEngine != null && typeof (my3DEngine) != "undefined") {
  566. my3DEngine.clearAllSymbols();
  567. my3DEngine = null;
  568. }
  569. one3d = true;
  570. this.currentState.currentWallId = null;
  571. addWall();
  572. }
  573. }
  574. else if (e.target.parentElement.parentElement.id == "toolbarSave") {
  575. alert("save");
  576. }
  577. else if (e.target.parentElement.parentElement.id == "toolbarOption") {
  578. var aw = document.getElementById("aboutWindow");
  579. aw.style.display = "block";
  580. //alert("option");
  581. }
  582. else if (e.target.parentElement.parentElement.id == "userOption") {
  583. alert("user");
  584. }
  585. }.bind(this));
  586. function addWall() {
  587. var vectors = [];
  588. var points = [];
  589. var point1 = new Point(wallleftX, wallleftY);
  590. points.push(point1);
  591. var point2 = new Point(wallrightX, wallleftY);
  592. points.push(point2);
  593. var point3 = new Point(wallrightX, wallrightY);
  594. points.push(point3);
  595. var point4 = new Point(wallleftX, wallrightY);
  596. points.push(point4);
  597. var wall = new Wall(points, document.getElementById("imgWall"));
  598. var vector = new Vector(wall, wallStyle);
  599. wallId = vector.id;
  600. vectors.push(vector);
  601. this.layer.addVectors(vectors);
  602. this.layer.data2d.wallIds.push(wallId);
  603. }
  604. };