MainPanel.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. class MainPanel {
  2. constructor(app) {
  3. this.app = app;
  4. this.panels_znyg = [];
  5. this.panels_znjk = [];
  6. this.panels_znef = [];
  7. this.toolBar = null;
  8. this.toolImgs = {};
  9. this.isExpandBuilding = false;
  10. this.createToolsPanel();
  11. this.building = this.app.buildings[0];
  12. }
  13. // 创建工具面板
  14. createToolsPanel() {
  15. var that = this;
  16. // this.toolBar = THING.widget.ToolBar({ width: '12%', media: true,captionPos:'hover',opacity:0.5});
  17. this.toolBar = THING.widget.Banner({ column: 'left', width: '20px', media: true, captionPos: 'hover', opacity: 0.8 });
  18. this.toolBar.data = { znsx: false, enterBuilding: false, expandBuilding: false, deviceShow: false, electricalFire: false };
  19. this.toolBar.setPosition({ right: 0, top: 60 });
  20. this.toolImgs.img3 = this.toolBar.addImageBoolean(this.toolBar.data, 'enterBuilding').name('进入建筑').imgUrl(baseURL + '建筑.png');
  21. this.toolImgs.img4 = this.toolBar.addImageBoolean(this.toolBar.data, 'expandBuilding').name('楼层展开').imgUrl(baseURL + '多楼层.png');
  22. this.toolImgs.img6 = this.toolBar.addImageBoolean(this.toolBar.data, 'deviceShow').name('建筑透视').imgUrl(baseURL + '透视.png');
  23. this.toolImgs.img3.on('change', function (boolValue) { that.onChangeImageButton('enterBuilding', boolValue); });
  24. this.toolImgs.img4.on('change', function (boolValue) { that.onChangeImageButton('expandBuilding', boolValue); });
  25. this.toolImgs.img6.on('change', function (boolValue) { that.onChangeImageButton('deviceShow', boolValue); });
  26. }
  27. // 处理工具条按钮
  28. onChangeImageButton(key, boolValue) {
  29. var that = this;
  30. if (key == "enterBuilding") { // 进入建筑/室外
  31. this.goinBuild(boolValue);
  32. } else if (key == "deviceShow") {//展示全部设备隐藏楼层\
  33. var devicList = [];
  34. var build = app.buildings[0]
  35. var opacity = build.style.opacity;// 0 为全透明 ,1 为不透明
  36. build.style.opacity = (opacity > 0.8) ? 0.1 : 1.0;
  37. var deviceArray = app.query('["userData/物体类型"="烟感"]');
  38. devicList.push(deviceArray)
  39. if (boolValue) {
  40. flash(devicList);
  41. this.goinBuild(boolValue);
  42. // updateData();
  43. }
  44. else {
  45. reset(devicList);
  46. }
  47. }
  48. else if (key == "expandBuilding") { // 楼层横向展开
  49. this.app.level.change(app.buildings[0]); // 进入建筑
  50. if (boolValue) {
  51. this.building.expandFloors({
  52. 'time': 1000,
  53. 'length': 4,
  54. 'horzMode': false,
  55. 'hideRoof': true,
  56. 'complete': function () {
  57. that.isExpandBuilding = true;
  58. }
  59. })
  60. } else {
  61. this.building.unexpandFloors({
  62. 'time': 500,
  63. 'complete': function () { that.isExpandBuilding = false; }
  64. })
  65. }
  66. }
  67. }
  68. // 展开的楼层收回去
  69. resetExpand() {
  70. var that = this;
  71. if (this.isExpandBuilding) {
  72. this.toolBar.data.expandBuilding = false;
  73. this.building.unexpandFloors({
  74. 'time': 500,
  75. 'complete': function () { that.isExpandBuilding = false; }
  76. })
  77. }
  78. }
  79. goinBuild(boolValue) {
  80. delMydiv();
  81. this.resetExpand();
  82. var name = boolValue ? '返回室外' : '进入建筑';
  83. this.toolImgs.img3.name(name);
  84. if (boolValue) {
  85. removeMark();
  86. this.app.level.change(app.buildings[0]);
  87. var domDiv = document.getElementById('bottomBackground');
  88. if (domDiv) {
  89. domDiv.remove();
  90. }
  91. }
  92. else {
  93. this.app.level.change(app.root.campuses[0]);
  94. }
  95. }
  96. }